kurento RtpEndpoint獲取rtp流

該修改方案是在kurento-tutorial-java項目中kurento-hello-world測試demo的基礎上進行修改的。

  private void handleProcessSdpOffer(final WebSocketSession session,
      JsonObject jsonMessage)
  {
    // ---- Session handling

    final String sessionId = session.getId();

    log.info("[Handler::handleStart] User count: {}", users.size());
    log.info("[Handler::handleStart] New user, id: {}", sessionId);

    final UserSession user = new UserSession();
    users.put(sessionId, user);


    // ---- Media pipeline

    log.info("[Handler::handleStart] Create Media Pipeline");

    final MediaPipeline pipeline = kurento.createMediaPipeline();
    user.setMediaPipeline(pipeline);

    final WebRtcEndpoint webRtcEp =
        new WebRtcEndpoint.Builder(pipeline).build();
    user.setWebRtcEndpoint(webRtcEp);
    webRtcEp.connect(webRtcEp);

    // ---- Endpoint configuration
	String sdpOffer = jsonMessage.get("sdpOffer").getAsString();
	initWebRtcEndpoint(session, webRtcEp, sdpOffer);
	
	log.info("[Handler::handleStart] New WebRtcEndpoint: {}",
	                     webRtcEp.getName());
     
    // change by dws
    RtpEndpoint rtpEndpoint = new RtpEndpoint.Builder(pipeline).build();
    webRtcEp.connect(rtpEndpoint);
    RtpEndpoint rtpEndpoint1 = new RtpEndpoint.Builder(pipeline).build();
    rtpEndpoint1.connect(webRtcEp);
 
    String genOffer = rtpEndpoint1.generateOffer();
    String sdpRtpOfferString = "v=0\n";
	sdpRtpOfferString += "o=- 0 0 IN IP4 " + "11.0.4.136" + "\n";
	sdpRtpOfferString += "s=KMS\n";
	sdpRtpOfferString += "c=IN IP4 " + "11.0.4.136" + "\n";
	sdpRtpOfferString += "t=0 0\n";
	sdpRtpOfferString += "m=audio " + "16666" + " RTP/AVP 97\n";
	sdpRtpOfferString += "a=recvonly\n";
	sdpRtpOfferString += "a=rtpmap:97 PCMU/8000\n";
	sdpRtpOfferString += "a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1508\n";
	sdpRtpOfferString += "m=video " + "18888" + " RTP/AVP 96\n";
	sdpRtpOfferString += "a=rtpmap:96 H264/90000\n";
	sdpRtpOfferString += "a=fmtp:96 packetization-mode=1\n";
	genOffer = sdpRtpOfferString;
	
    log.debug("[Handler::handleStart] RTP offer info", genOffer);
    String answer = rtpEndpoint.processOffer(genOffer);
    rtpEndpoint1.processAnswer(answer);
    log.error("\ngenOffer:\n" + genOffer+"\n\nanswer:\n"+answer);

    // webRtcEp.connect(webRtcEp);

    startWebRtcEndpoint(webRtcEp);

  }
發佈了56 篇原創文章 · 獲贊 22 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章