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.
在服务器上,我正在使用简单的Broadcaster, 我想把它传送到手机和机器人手机上。
我的代码:
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);
}
}
我总是接收NetStream.Play. Stream NotFound on Status 函数上的网络Status。
谢谢