Red5 클 라 이언 트 연결 Red5Server

2851 단어 red5자바
더 읽 기
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 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 list = (ArrayList) 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();
 }
}


좋은 웹페이지 즐겨찾기