aditya sista
aditya sista

Reputation: 141

kurento android client library: how to get video stream from sdp offer?

In kurento android, after joining the room for group video call, whenever someone connects and starts streaming, the function

onRemoteStreamAdded(MediaStream mediaStream, NBMPeerConnection nbmPeerConnection)

is called, and I can simply attach the mediastream with a videorenderer and it works. But when I join the room with existing peers publishing their videos, no media streams show up, but sdp offers are generated. How do I get video stream from all the users in the room using sdp offers?

Upvotes: 3

Views: 804

Answers (2)

Vivek Patel
Vivek Patel

Reputation: 419

@aditya i have worked on M2M streaming . I have done like this :-

  @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);
        }
    } 
}

Upvotes: 0

Vivek Patel
Vivek Patel

Reputation: 419

hi first you need to close the connection when someone leaves the group using

nbmWebRTCPeer.closeConnection("username");

you can manages on this method :

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

}

Upvotes: -1

Related Questions