Search code examples
androidvideo-streamingred5rtmp

RTMP android aftek


I am trying to implement the library from http://www.aftek.com/afteklab/aftek-RTMP-library.shtml to stream live video from a red5 server.

On the server i am using the simpleBroadcaster and i want to stream it to the android phone.

my code:

package com.cu.reader;

import java.nio.channels.FileChannel;
import java.util.Map;
import com.al.rtmp.client.RtmpClient;
import com.al.rtmp.client.RtmpStream;
import com.al.rtmp.client.RtmpStreamFactory;
import com.al.rtmp.client.data.MetaData;
import com.al.rtmp.client.data.RTMPData;
import com.al.rtmp.client.data.VideoCodec;
import com.al.rtmp.message.Metadata;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class StreamreaderActivity extends Activity implements RtmpClient {
     RtmpStream stream = null;
     Boolean connected = false;
 String server = "rtmp://216.224.181.197/oflaDemo/";
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    stream = RtmpStreamFactory.getRtmpStream();
    stream.setClient(this);
    stream.connect(server);
}
@Override
public void streamCreated() {
    Log.i("stream","Connected!");       

    connected = true;
    stream.setPlayName("red5StreamDemo");
    stream.play();

}
@Override
public byte[] getWriteData(int length) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public void invoke(String arg0, Object... arg1) {
    // TODO Auto-generated method stub
;   
}
@Override
public void onDataReceived(RTMPData rtmpData) {
    MetaData metaData = rtmpData.getMetaData();
    VideoCodec vc = metaData.getVideoCodec();
}
@Override
public void onError(Exception ex) {
    Log.e("ClientException", " Some exception occurred." + ex.getMessage());
    ex.printStackTrace();
}
@Override
public void onMetaDataReceived(Map map) {
    Log.i("code","METADATA:" + map);        

}
@Override
public void onResult(String method, Object... arg1) {
    Log.i("result","METADATA:" + method);       

}
@Override
public void onStatus(String code) {
    Log.i("code",code);     
}

}

i am always receiving NetStream.Play.StreamNotFound in onStatus function.

Thank you


Solution

  • The stream does not exist, correct. But why? Probably one or two reasons: you have not created a live broadcast stream and 2) because you are using the wrong scope. Unless you configure it differently by hand (which is unlikely), use the 'live' broadcaster scope, which is in /live.

    Thus, publish to rtmp://216.224.181.197/live/red5StreamDemo and to subscribe to the exact same mrl, in this example rtmp://216.224.181.197/live/red5StreamDemo. NOTE: for this to work, you need to create a 'live' stream and feed it to your RED5 server. You can use avconv (aka ffmpeg) to create an rtmp feed.