Using WebRTC & getUserMedia from inside Web Worker

2,253 views
Skip to first unread message

Jonas Schneider

unread,
Dec 13, 2014, 6:01:02 AM12/13/14
to discuss...@googlegroups.com
Hi,

Are there any plans to support using getUserMedia and the WebRTC APIs from inside Service/Shared Workers? Right now, the WorkerNavigator doesn't have getUserMedia.

Is this only a missing implementation or are there other spec/policy concerns that need to be addressed first? 

- Jonas

Justin Uberti

unread,
Dec 17, 2014, 7:07:28 PM12/17/14
to discuss...@googlegroups.com
Last time we looked into this, most/all DOM objects were not available to Web Workers. I don't know if anything has changed in the general web platform in this regard.

Iñaki Baz Castillo

unread,
Dec 17, 2014, 7:14:58 PM12/17/14
to discuss...@googlegroups.com
2014-12-18 1:07 GMT+01:00 Justin Uberti <jub...@google.com>:
> Last time we looked into this, most/all DOM objects were not available to
> Web Workers. I don't know if anything has changed in the general web
> platform in this regard.

Why do we need access to the DOM within the WebRTC API at all?

Obviously the way in which a WebWorker interacts with the "page" is by
sending messages. There is no reason at all for WebWorkers not to
include the WebRTC and gUM API.

For example, WebSocket is also supposed to work within a Worker (I
admit I do not know about implementations status), but of course I
would not try to write the innerHTML of a DOM element when the
WebSocket onmessage event fires.

--
Iñaki Baz Castillo
<i...@aliax.net>

bryand...@gmail.com

unread,
Dec 17, 2014, 9:20:04 PM12/17/14
to discuss...@googlegroups.com
Without DOM access you could not assign a stream to a <video> element.  And you also could not pass a media stream via postMessage.


--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

PhistucK

unread,
Dec 18, 2014, 1:58:53 AM12/18/14
to WebRTC-discuss
There are a few things you can do without any relation to the DOM - using data channels, or forwarding streams (currently only audio streams are supported, I think), for example. It makes sense to enable those in Workers, however, the working group must specify that (it sometimes simply means to add WorkerNavigator implements MediaDevices or something similar to the WebIDL).


PhistucK

Iñaki Baz Castillo

unread,
Dec 18, 2014, 3:04:55 AM12/18/14
to discuss...@googlegroups.com
2014-12-18 7:57 GMT+01:00 PhistucK <phis...@gmail.com>:
> There are a few things you can do without any relation to the DOM - using
> data channels,

You can handle your DataChannel on the worker and communicate with the
app via messages, and send text/binary messages from one to each
other.


> or forwarding streams (currently only audio streams are
> supported, I think), for example. It makes sense to enable those in Workers,
> however, the working group must specify that (it sometimes simply means to
> add WorkerNavigator implements MediaDevices or something similar to the
> WebIDL).

That's a good point. At the end a MediaStream is referenced as a
blob:// URL (not sure if this is a W3C standard or a vendor specific
choice). I understand this is not yet ready, but IMHO it should be
possible to pass such a URL via messages from the worker to the app.
For example, in a previous spec (now I think it is changing) the
MediaStream is attached to the video.src by means of
URL.CreateObjectURL(stream), which returns a string with the blob URL
as text value.

Raj Kumaradass

unread,
Aug 3, 2015, 5:28:10 AM8/3/15
to discuss-webrtc
I was looking for feasibility of webworkers support with data/audio stream together and stumbled upon this old thread. My requirement is to do establish peer connection with data and audio involved and i intend to use webworkers for doing all the peer connection and data transfer/receive stuff without using gUM(i.e, using web audio API). Does web workers work with data and audio stream together as audio requires attaching the stream to audio tag?

thanks,
raj

Randell Jesup

unread,
Aug 4, 2015, 12:19:01 AM8/4/15
to discuss...@googlegroups.com
On 8/3/2015 5:28 AM, Raj Kumaradass wrote:
> I was looking for feasibility of webworkers support with data/audio
> stream together and stumbled upon this old thread. My requirement is
> to do establish peer connection with data and audio involved and i
> intend to use webworkers for doing all the peer connection and data
> transfer/receive stuff without using gUM(i.e, using web audio API).
> Does web workers work with data and audio stream together as audio
> requires attaching the stream to audio tag?

PeerConnections, DataChannels and MediaStreams are not generally usable
in Workers yet. There are lots of issues to deal with (and spec work to
do) to make this possible.

CreateObjectURL() is not the preferred method - use
media_element.srcObject = stream instead; otherwise the MediaStream can
never be GC'd until you leave the page. And just because you can make a
blob URL doesn't mean you can push DataChannel and other code into workers.

--
Randell Jesup -- rjesup a t mozilla d o t com
Please please please don't email randel...@jesup.org! Way too much spam

Reply all
Reply to author
Forward
0 new messages