kurento android客户端库:如何从sdp提供视频流?

时间:2017-09-28 12:45:31

标签: android webrtc kurento

在kurento android中,加入房间进行群组视频通话后,每当有人连接并开始流式传输时,该功能

onRemoteStreamAdded(MediaStream mediaStream, NBMPeerConnection nbmPeerConnection)

被调用,我可以简单地将媒体流附加到视频中心,它可以工作。 但是,当我与现有同行一起发布他们的视频时,没有媒体流出现,但生成了sdp优惠。如何使用sdp优惠从房间中的所有用户获取视频流?

2 个答案:

答案 0 :(得分:0)

@aditya我参与了M2M流媒体工作。 我这样做了: -

  @Override
public void onRoomResponse(RoomResponse response) {
    int requestId = response.getId();
    boolean check = false;
    for (Map.Entry<Integer, String> entry : videoRequestUserMapping.entrySet()) {

        if (entry.getKey() == requestId) {
            check = true;
        }
    }
    if (check || (requestId == publishVideoRequestId)) {

        SessionDescription sd = new SessionDescription(SessionDescription.Type.ANSWER,
                response.getValue("sdpAnswer").get(0));

        if (callState == CallState.PUBLISHING) {

            callState = CallState.PUBLISHED;
            nbmWebRTCPeer.processAnswer(sd, "local");
            mHandler.postDelayed(offerWhenReady, 2000);

        } else if (callState == CallState.WAITING_REMOTE_USER) {
            callState = CallState.RECEIVING_REMOTE_USER;
            String connectionId = videoRequestUserMapping.get(requestId);
            Log.e("ConnectionId", ":" + connectionId);
            nbmWebRTCPeer.processAnswer(sd, connectionId);
        } else {

            callState = CallState.RECEIVING_REMOTE_USER;
            String connectionId = videoRequestUserMapping.get(requestId);

            nbmWebRTCPeer.processAnswer(sd, connectionId);
        }
    } 
}

答案 1 :(得分:-1)

首先,当有人使用

离开小组时,您需要关闭连接
nbmWebRTCPeer.closeConnection("username");

您可以管理此方法:

 public void onIceStatusChanged(PeerConnection.IceConnectionState     iceConnectionState, NBMPeerConnection nbmPeerConnection) {
 if (iceConnectionState.name().equalsIgnoreCase("CLOSED"))  
   {
   nbmWebRTCPeer.closeConnection(nbmPeerConnection.getConnectionId());
   }

}