我正在尝试从http://www.aftek.com/afteklab/aftek-RTMP-library.shtml实现库 以从 red5 服务器流式传输实时视频。
在服务器上,我使用的是 simpleBroadcaster,我想将它流式传输到 android 手机。
我的代码:
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);
}
}
我总是在 onStatus 函数中接收 NetStream.Play.StreamNotFound 。
谢谢