[RED5]Red5 Client 连接 Red5Server java代码
[RED5]Red5 Client 连接 Red5Server java代码
[RED5]Red5 Client 连接 Red5Server java代码
- import java.util.ArrayList;
- import java.util.Map;
- import org.red5.io.utils.ObjectMap;
- import org.red5.server.api.event.IEvent;
- import org.red5.server.api.event.IEventDispatcher;
- import org.red5.server.api.service.IPendingServiceCall;
- import org.red5.server.api.service.IPendingServiceCallback;
- import org.red5.server.net.rtmp.INetStreamEventHandler;
- import org.red5.server.net.rtmp.RTMPClient;
- import org.red5.server.net.rtmp.RTMPConnection;
- import org.red5.server.net.rtmp.codec.RTMP;
- import org.red5.server.net.rtmp.event.Notify;
- public class RtmpClientNew extends RTMPClient implements
- INetStreamEventHandler, IPendingServiceCallback, IEventDispatcher {
- String host = "111.92.237.33";
- String app = "chainGunSyncService";
- int port = 1935;
- public RtmpClientNew() {
- super();
- Map<String, Object> map = makeDefaultConnectionParams(host,
- 1935, "chainGunSyncService");
- connect(host, 1935, map, this, new String[] { "admin", "",
- "111.92.237.33" });
- }
- @Override
- public void dispatchEvent(IEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void resultReceived(IPendingServiceCall call) {
- // TODO Auto-generated method stub
- Object result = call.getResult();
- if (result instanceof ObjectMap) {
- if ("connect".equals(call.getServiceMethodName())) {
- createStream(this);
- }
- } else {
- if ("createStream".equals(call.getServiceMethodName())) {
- if (result instanceof Integer) {
- Integer streamIdInt = (Integer) result;
- // int streamId = streamIdInt.intValue();
- // publish(streamId, "testgio2", "live", this);
- invoke("getRoomsInfo", this);
- } else {
- disconnect();
- }
- } else if ("getRoomsInfo".equals(call.getServiceMethodName())) {
- ArrayList<String> list = (ArrayList<String>) result;
- for (int i = 0; i < list.size(); i++) {
- System.out.println(list.get(i));
- }
- }
- }
- }
- @Override
- public void onStreamEvent(Notify arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void connectionOpened(RTMPConnection conn, RTMP state) {
- // TODO Auto-generated method stub
- // System.out.println("connectionOpened");
- super.connectionOpened(conn, state);
- }
- public static void main(String[] args) {
- new RtmpClientNew();
- }
- }
热门文章推荐
- [Red5]Red5之Flash流媒体服务器的安装与使用教程完整版(组图)
- [RED5]搭建RED5直播用流媒体服务(搭直播环境)
- [RED5]Red5的直播与点播的压力测试(并发数的测试)
- [RED5]red5流媒体服务器(开源免费)的安装方法
- [RED5]用red5做视频直播(red5流媒体直播)
- [RED5]Red5在线录制音视频源代码示例
- [RED5]Red5 Client 连接 Red5Server java代码
- [RED5]red5流媒体播放平台搭建环境方法
请稍候...