Stopping media stream without disposing the WebRTC endpoint

2,428 views
Skip to first unread message

Alexandre Verri

unread,
Oct 13, 2014, 2:07:55 PM10/13/14
to kur...@googlegroups.com
Hello, I would like to know if it's possible to stop media stream without disposing the WebRTC endpoints associated. 

Considering for example, the Tutorial 3, suppose that the master wishes to pause his video and continue later.

LuLop

unread,
Oct 13, 2014, 3:58:44 PM10/13/14
to kur...@googlegroups.com
You can use the MediaStream API at the client side for this. You need to mute the video stream, and it will pause. This feature is not provided by our WebRtcPeer API, but it should be quite simple to implement.

Best.

L.

El 13/10/2014, a las 20:07, Alexandre Verri <alexand...@gmail.com> escribió:

Hello, I would like to know if it's possible to stop media stream without disposing the WebRTC endpoints associated. 

Considering for example, the Tutorial 3, suppose that the master wishes to pause his video and continue later.

--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexandre Verri

unread,
Oct 13, 2014, 4:52:03 PM10/13/14
to kur...@googlegroups.com
Thank you Luis. I'll change the MediaStream API and add a mute() method. I would like to change the tutorial 3 in order to introduce the concept of "muting" the master. I think that it's better to mute than to dispose all WebRtcPeers and create then again.

I've changed the tutorial 3 in order to permit the viewer to join a session by ID. In this case, I can create the media pipeline when the viewer join a session, even when there is no master yet. When the master join the session by ID, I connect the master webrtcendpoint to viewers webrtsendpoints. It's working fine.

Question: how does Media Server garbage collector works? Suppose that the media pipeline is created in MS, and there is no media stream after a long time.

Ivan Gracia

unread,
Oct 13, 2014, 5:32:09 PM10/13/14
to Kurento Public
Hi Alexandre,

As long as you keep a websocket session open, KMS will not garbage collect the pipeline. If the WS connection is closed, and no other WS session is open using this pipeline, the server will dispose the pipeline and the underlying objects after 4min. The fact that there is no media stream flowing does not trigger the collection of the object.

You are more than welcome to fork the WebRtcPeer API, and add a "mute" method if you feel like it. It's a very useful contribution, and most likely other users will have the need for it :-)

Cheers,

Ivan Gracia


Alexandre Verri

unread,
Oct 13, 2014, 5:45:50 PM10/13/14
to kur...@googlegroups.com
Luis, it's very simple indeed. I've added two methods to the WebRtcPeer in kurento-utils.js as follows:

WebRtcPeer.prototype.pause = function() {
     console
.debug('Pausing stream...');
     
if (this.stream) {
         
this.stream.getAudioTracks().forEach(function(track) {
             track
.enabled = false
         
})
         
this.stream.getVideoTracks().forEach(function(track) {
             track
.enabled = false
         
})
     
}
 
}


WebRtcPeer.prototype.play = function() {
        console
.debug('Playing stream...');
   
if (this.stream) {
       
this.stream.getAudioTracks().forEach(function(track) {
            track
.enabled = true
       
})
       
this.stream.getVideoTracks().forEach(function(track) {
            track
.enabled = true
       
})
   
}
 
}

Alexandre Verri

unread,
Oct 13, 2014, 5:52:46 PM10/13/14
to kur...@googlegroups.com
Ivan, 

you mentioned "As long as you keep a websocket session open, KMS will not garbage collect the pipeline." 

You are talking about the websocket between Java client and KMS or websocket between browser and Java client?

Sure, I can fork the WebRtcPeer API, I've just changed it in my local code and it's working fine.

Alexandre Verri

unread,
Oct 13, 2014, 10:21:40 PM10/13/14
to kur...@googlegroups.com
I've noticed that disabling the MediaStream causes the video to be black, on both master and viewers, which is not good in terms of user experience.
 
I am looking for a way to pause the broadcast, but the local video (the master video) continues to play (it's ok to have viewers with black video). 

mac...@gmail.com

unread,
Nov 8, 2015, 5:50:41 AM11/8/15
to kurento
While this worked great on KMS5 it would seem that the API in KMS6 changed to much :( 

Any idea on how to do this with the newest kurento-utils.js?

THX! 

Ivan Gracia

unread,
Nov 9, 2015, 10:38:49 AM11/9/15
to Kurento Public
You can get the RTCPeerConnection object from the WebRTCPeer object, and do with it as you please :-) It's just a wrapper.

Ivan Gracia


Dnyaneshwar

unread,
Dec 10, 2015, 6:47:24 AM12/10/15
to kurento
Hello All,

When I pause the video stream it causes the video to be black, on both me and another participant, which is not good in terms of user experience.
I am looking for a way to pause the broadcast.
When the user pauses his/her image, a snapshot image should be shown instead of the Black box.
Could Please help me ?

Ivan Gracia

unread,
Dec 15, 2015, 3:48:45 AM12/15/15
to Kurento Public
I think there was a way to do that in the client. In the server, you'll need to create a filter for that.

Ivan Gracia


Dnyaneshwar

unread,
Dec 21, 2015, 1:27:35 AM12/21/15
to kurento
Thanks for the suggestion..But can you tell me how to do that?
It is very important for us.
I have seen some examples on filter in kurento tutorials.
So should we take help from these tutorials? Or else is there any suggestion for this Filter?

Ivan Gracia

unread,
Dec 22, 2015, 10:52:57 AM12/22/15
to Kurento Public
Yes, you can use those tutorials for info on how to create modules for Kurento. The juicy part is what you put inside those modules, the openCV or GStreamer code that implements all the logic and magic.

Though this is not in our roadmap, there always exist the possibility to get tailored developments. If you are interested in this kind of services, please send an email to in...@kurento.org

Ivan Gracia


Dnyaneshwar

unread,
Dec 29, 2015, 6:39:47 AM12/29/15
to kurento
Thank you Ivan.
First of all sorry for late reply..
I will try to implement those things in our application.
In case if I need any help then I will let you know.
Reply all
Reply to author
Forward
0 new messages