Search code examples
node.jswebrtckurentoendpoints

Reuse/reconnect receiver endpoint to new sender endpoint


I'm using node-js API to use kurento. So, I connect sender's webrtcendpoint to receiver endpoint using code -

senderWebRtcEndPoint.connect(receiverWebRtcEndPoint, function(error) {
                if (error) {
                    return console.log("Error in connecting endpoints :: "+error);
                }
                io.log.info("EndPointConnected");
            });

Using this code media start streaming to receiver. But, if sender get disconnect -

  1. How to disconnect receiver endpoint to sender's endpoint?
  2. How to destroy sender endpoint?
  3. How to release that sender endpoint from mediapipeline?
  4. When new sender endpoint is created how to reuse the receiver's endpoint to connect newly created sender's endpoint?

It would be more helpful if I could get an example(using JS-API) highlighting these -

  • disconnect endpoints from each other
  • destroying endpoints
  • destroying a pipeline
  • reconnect old endpoint to new endpoint
  • any event of endpoint notifying endpoint get connected and disconnected to other endpoint

Solution

  • How to disconnect receiver endpoint to sender's endpoint?

    If you are going to release the sender endpoint, there's no need to do this. In any case, there is a disconnect method

    receiverWebRtcEndPoint.disconnect(senderWebRtcEndPoint)
    

    How to destroy sender endpoint? How to release that sender endpoint from mediapipeline?

    These are basically the same

    senderWebRtcEndPoint.release()
    

    Don't forget to invoke dispose on the WebRtcPeer object from the client, if you are using the Kurento Utils library. If you are using the RTCPeerConnection directly, do also close that.

    When new sender endpoint is created how to reuse the receiver's endpoint to connect newly created sender's endpoint?

    senderWebRtcEndPoint.connect(ReceivererWebRtcEndPoint)