kurento RtpEndpoint获取rtp流

本文介绍在kurento-tutorial-java项目中,基于kurento-hello-world测试demo进行的修改方案,详细展示了如何处理WebSocket会话,创建和配置WebRtcEndpoint,以及如何使用RtpEndpoint进行音视频流的处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该修改方案是在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);

  }
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值