Search code examples
node.jsrecordwebrtckurento

Kurento recording caller and callee stream in node.js


I am using kurento to record the stream to the server-disk. I followed the change of the kurento tutorial here where the tutorial hello-world in node.js was changed to record the stream to the disk. Now what I want to do is change the tutorial4 one-to-one call to record the caller and the callee stream to 2 files.

As I understanded kurento the recorder is linked to the pipeline. The pipeline is the representation of the connection between 2 peers. How can I record the stream of a single peer in the pipeline, respectively both streams the one of the caller and the one of the callee?

I tried a lot but could not find a sollution.


Solution

  • Perhaps you should be reading the basic Kurento documentation introducing what's a media element and what's a pipeline to have a more clear image on how Kurento's API work.

    For you specific question, a RecorerEndpoint is just media element capable of recording to a file the stream offered as its input. This means that you can connect a RecorderEndpoint to any other source element. For example, if you have a B2B call among two peers, every peer will have associated a WebRtcEndpoint so that the resulting pipeline will be something like this:

    Peer A <--------->webRtcEndpointA<==>webRtcEndpointB<---------->Peer B
    

    For recording the streams coming from both Peer A and Peer B, you just need to create two RecorderEndpoints and connect them appropriately so that the final pipeline is something like:

                                 ------>recorderEndpointA
                                 |
     Peer A <--------->webRtcEndpointA<==>webRtcEndpointB<---------->Peer B
                                            |
                                            --->recorderEndpointB
    

    The source code for this should include (I ommit the boilerplate code that you already have in the tutorials you cite):

    pipeline.create('RecorderEndpoint', {uri: "file:///tmp/fileA.webm"}, function(error, recorderEndpointA ...
    ...
    webRtcEndpointA.connect(recorderEndpointA);
    recorderEndpointA.record();
    
    pipeline.create('RecorderEndpoint', {uri: "file:///tmp/fileB.webm"}, function(error, recoderEndpointB ...
    ...
    webRtcEndpointB.connect(recorderEndpointB);
    recorderEndpointB.record();