Re: Releasing media stream created by gUM

I am trying to create a simple wrapper that can be used to embed webrtc
phone-like functionality into pages provided by a third party. There is
nothing to prevent multiple copies of this wrapper (or other gUM using
code) from being included on a single page.

If both 'apps' presented on a single page, call getUserMedia and each get a
stream with a track that is derived from the same source. When one of the
apps has finished with its stream how can it ensure that it is stopped
without affecting the other app's stream.

I don't think that I can rely on garbage collection as the page using my
wrapper may still have a reference to the stream. (I suppose it may also
have cloned the stream but that would be a deliberate attempt to break
things, so I not particularly worried about that).


On 22 October 2013 11:58, Stefan Håkansson LK <
stefan.lk.hakansson@ericsson.com> wrote:

> On 10/18/13 11:53 AM, Kevin Dempsey wrote:
> > In earlier versions of the gUM spec, the stream created by a
> > getUserMedia() call had a stop() method that ended all the tracks,
> > reduced the reference count on the track sources and if that reference
> > count reached zero, the source was stopped (and recommended that any
> > 'on-air' indicator was removed).
> >
> > In recent versions of the spec the stream doesn't have a stop() method,
> > but MediaStreamTrack does. However, this stop() method stops the source
> > regardless of whether any other track is using that source. I know that
> > the 'best practices' section recommends that sources should not be
> > shared but the MediaStreamTrack stop() function's "kill switch"
> > behaviour forces that upon implementors.
> >
> > So under the current spec, the release the stream created by
> > getUserMedia() you have to call stop on all tracks it has (one audio and
> > one video maximum). This will also kill the sources and therefore end
> > any track also using those sources.
>
> Kevin, could you elaborate on what functionality you are missing? And
> note that stop() on a track will only stop the source for this context -
> if there is another app using the same source it will continue to work.
>
> * Is it a way to revoke access to input devices (for this app)? I guess
> not since you can do that by stop() on the corresponding track(s).
>
> * Is it a way to allow your app be a bit careless in its book keeping
> (stop() on a track would indeed stop the source from feeding data into
> other tracks in the same app)?
>
> * Is it a way to tell the UA that a MediaStream is not needed any more
> (so it can be garbage collected)?
>
>
>

Received on Tuesday, 22 October 2013 11:33:55 UTC