Using player endpoint to stream via dispatcher (in a loop)

389 views
Skip to first unread message

Mayank

unread,
Oct 25, 2016, 6:36:41 PM10/25/16
to kurento
Hi guys,

I am using player endpoint to stream a webm file (in a loop) to multiple viewers via one to many dispatcher. Had a few questions about my approach.

1. I am using end of stream event to restart the player, but this does not work all the time. Is there a better way/option?
2. Is there a need for a cyclic relationship between the playerEndpoint and the hubPort? Do they both need to connect to each other?
3. Is the sequence of object creation in the code below optimal ?


function create() {
  getKurentoClient
(function(error, kurentoClient) {
   
if (error) {
     
return console.error(error);
   
}


    kurentoClient
.create('MediaPipeline', function(error, pipeline) {
     
if (error) {
       
return console.error(error);
     
}


      pipeline
.create('DispatcherOneToMany', function(error, dispatcher) {
       
if (error) {
          pipeline
.release();
         
return console.error(error);
       
}


       
var opts = {uri: 'file:///tmp/big_buck_bunny.webm'};
        pipeline
.create('PlayerEndpoint', opts, function(error, playerEndpoint) {
         
if (error) {
           
return console.error(error);
         
}


          dispatcher
.createHubPort(function(error, hubPort) {
           
if (error) {
             
return console.error(error);
           
}


            dispatcher
.setSource(hubPort, function(error) {
             
if (error) {
               
return console.error(error);
             
}


              hubPort
.connect(playerEndpoint, function(error) {
               
if (error) {
                 
return console.error(error);
               
}


                playerEndpoint
.connect(hubPort, function(error) {
                 
if (error) {
                   
return console.error(error);
                 
}
                  startPlayer
(playerEndpoint, hubPort, dispatcher);
               
});
             
});
           
});
         
});
       
});
     
});
   
});
 
});
}


function startPlayer(playerEndpoint, hubPort, dispatcher) {
  playerEndpoint
.play().then(function() {
    playerEndpoint
.on('EndOfStream', function(event) {
      playerEndpoint
.stop().then(function() {
        playerEndpoint
.play().then(function() {
          dispatcher
.setSource(hubPort).then(handleSuccess, handleError);
       
}, handleError);
     
}, handleError);
   
});
 
}, handleError);
}


function handleError(err) {
 
if (err) {
    console
.error(err);
 
}
}


function handleSuccess(data) {
 
if (data) {
    console
.log("Success: " + JSON.stringify(data));
 
}
 
else {
    console
.log("Success");
 
}
}



In my setup the turn server, kurento media server, and the app server all run on the same machine.
Thanks.
Mayank.

Ivan Gracia

unread,
Oct 26, 2016, 2:22:01 PM10/26/16
to Kurento Public
You shouldn't do this

              hubPort.connect(playerEndpoint, function(error) {
                
if (error) {
                  
return console.error(error);
                
}

the player is really a one-way object, so it's not going to receive anything from the dispatcher. Also, you don't need to repeat this

dispatcher.setSource(hubPort).then(handleSuccess, handleError);

Ivan Gracia



--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+unsubscribe@googlegroups.com.
To post to this group, send email to kur...@googlegroups.com.
Visit this group at https://groups.google.com/group/kurento.
To view this discussion on the web visit https://groups.google.com/d/msgid/kurento/ec219cba-ea50-4188-b791-dd3173097cf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mayank

unread,
Oct 26, 2016, 5:28:40 PM10/26/16
to kurento
Thanks Ivan.
I upgraded to kurento 6.6.1 and after some experimentation I am following the source.connect(sink) methodology. So for player/presenter its endpoint.connect(hubport) whereas for viewers its hubport.connect(endpoint). This works reliably.

However looping by calling playerEndpoint.play() on receiving an end of stream event does not work reliably. After a few loops the video stops (frozen video accompanied by "media not flowing" logs from the media server). And eventually the audio also stops. Is restarting this way not supported? Is there something else that need to be set?


Ivan Gracia



To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.

Ivan Gracia

unread,
Oct 27, 2016, 4:11:34 AM10/27/16
to Kurento Public
Can you try without the dispatcher? That element is not being actively maintained, and besides it will also add a small overhead.

If the error persists, then the problem is elsewhere.

Ivan Gracia



To unsubscribe from this group and stop receiving emails from it, send an email to kurento+unsubscribe@googlegroups.com.

To post to this group, send email to kur...@googlegroups.com.
Visit this group at https://groups.google.com/group/kurento.

Mayank

unread,
Oct 27, 2016, 7:47:38 AM10/27/16
to kur...@googlegroups.com
I used the dispatcher as it allowed me to switch presenters without having all the viewers to renegotiate. My first implementation followed the one2many tutorial, but when I switched presenters, just calling presenter.connnect(viewer) didn't re-establish the  media sessions. A complete new negotiation was needed. 

Hence the dispatcher is now a vital part of my design. Are there any plans to start maintaining the one2many dispatcher? Is there an alternate dispatcher that's being maintained?

Thanks. 
Mayank
You received this message because you are subscribed to a topic in the Google Groups "kurento" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kurento/uS6r0cDALJE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kurento+u...@googlegroups.com.

To post to this group, send email to kur...@googlegroups.com.
Visit this group at https://groups.google.com/group/kurento.

Ivan Gracia

unread,
Oct 27, 2016, 10:13:43 AM10/27/16
to Kurento Public
They don't need to renegotiate. You just need to repeat all the connects in the media server.

Ivan Gracia



To unsubscribe from this group and all its topics, send an email to kurento+unsubscribe@googlegroups.com.

To post to this group, send email to kur...@googlegroups.com.
Visit this group at https://groups.google.com/group/kurento.

--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+unsubscribe@googlegroups.com.
To post to this group, send email to kur...@googlegroups.com.
Visit this group at https://groups.google.com/group/kurento.

Mayank

unread,
Oct 27, 2016, 12:02:20 PM10/27/16
to kur...@googlegroups.com
I have tried that before without success. Is there a particular sequence to follow for reconnection?

Ivan Gracia

unread,
Oct 27, 2016, 1:32:06 PM10/27/16
to Kurento Public
You don't need to do any reconnection. Just invoke start on the player again and it will restart.

Ivan Gracia



Ian Williams

unread,
Aug 2, 2017, 6:55:32 AM8/2/17
to kurento
Hi Mayank,

I'm facing the same issue trying to get videos to loop.  Did you ever come up with a solution?

Thanks.

Ian.
Reply all
Reply to author
Forward
0 new messages