RESOLVED FIXED 70895
Add WebCore platform interface needed by updated MediaStream API design
https://bugs.webkit.org/show_bug.cgi?id=70895
Summary Add WebCore platform interface needed by updated MediaStream API design
Adam Bergkvist
Reported 2011-10-26 02:42:39 PDT
Add the remaining platform files needed by MediaStream and LocalMediaStream to WebCore/platform/mediastream.
Attachments
Proposed patch (10.92 KB, patch)
2011-11-17 09:55 PST, Adam Bergkvist
abarth: review-
Updated patch (15.02 KB, patch)
2011-11-21 08:01 PST, Adam Bergkvist
no flags
Adam Bergkvist
Comment 1 2011-11-17 09:55:08 PST
Created attachment 115608 [details] Proposed patch
Adam Barth
Comment 2 2011-11-17 10:20:08 PST
Comment on attachment 115608 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=115608&action=review > Source/WebCore/platform/mediastream/MediaStreamCenter.cpp:57 > +void MediaStreamCenter::endLocalMediaStream(MediaStreamDescriptor* streamDescriptor) > +{ > + MediaStream* stream = streamDescriptor->owner(); > + if (stream) > + stream->streamEnded(); > + else > + streamDescriptor->setEnded(); > +} This function doesn't appear to have any callers. Why wouldn't the callers just do this work directly? What's the value in having a static MediaStreamCenter to help? > Source/WebCore/platform/mediastream/MediaStreamCenter.h:44 > +class MediaStreamCenter { Can you help me understand what role the MediaStreamCenter plays?
Adam Bergkvist
Comment 3 2011-11-18 03:01:24 PST
(In reply to comment #2) > (From update of attachment 115608 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=115608&action=review > > > Source/WebCore/platform/mediastream/MediaStreamCenter.cpp:57 > > +void MediaStreamCenter::endLocalMediaStream(MediaStreamDescriptor* streamDescriptor) > > +{ > > + MediaStream* stream = streamDescriptor->owner(); > > + if (stream) > > + stream->streamEnded(); > > + else > > + streamDescriptor->setEnded(); > > +} > > This function doesn't appear to have any callers. Why wouldn't the callers just do this work directly? What's the value in having a static MediaStreamCenter to help? It works as a utility function, but its main purpose is layering so that the platform doesn't have to be aware of DOM objects (MediaStream). > > Source/WebCore/platform/mediastream/MediaStreamCenter.h:44 > > +class MediaStreamCenter { > > Can you help me understand what role the MediaStreamCenter plays? DOM objects: | Browser chrome: | +--------------+ +-------------------+ | +-------------------+ +----------------+ | MediaStream: | | LocalMediaStream: | | | Mute Video Button | | getUserMedia | | stream1 | | stream2 | | +-------------------+ | Selector UI | +--------------+ +-------------------+ | | (user consent) | | +----------------+ | | Requests from DOM objects and the WebKit API V +-------------------+ ==============================| MediaStreamCenter |==================================== +-------------------+ ^ | Requests from platform layer to higher layers Platform: +=================+ | Active streams: | +=================+ | stream1 | +-----------------+ | stream2 | +-----------------+ MediaStreamCenter responsibilities: * Expose media stream source probing functionality to higher layers * Notify the platform that: - A MediaStreamTrack has been enabled/disabled (from JavaScript) - A LocalMediaStream has been stopped (from JavaScript) - A local MediaStreamSource has been muted (via mute button in browser chrome) * Notify a MediaStream that the corresponding stream in the platfom has ended (e.g. USB camera was unplugged) Our platform specific implementation of MediaStreamCenter is responsible for all the plumbing of the media pipelines (e.g. from local media stream sources to player sinks and network transport sinks).
Adam Barth
Comment 4 2011-11-18 19:27:41 PST
Does MediaStreamCenter keep any state? If not, perhaps it should be a collection of free functions.
Adam Barth
Comment 5 2011-11-18 19:30:31 PST
Comment on attachment 115608 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=115608&action=review > Source/WebCore/platform/mediastream/MediaStreamCenter.cpp:38 > +#include "MediaStream.h" Another issue is that MediaStream.h is outside the Platform directory and Platform isn't allowed to include headers from the rest of WebCore. > Source/WebCore/platform/mediastream/MediaStreamCenter.cpp:48 > +MediaStreamCenter& MediaStreamCenter::instance() > +{ > + ASSERT(isMainThread()); > + DEFINE_STATIC_LOCAL(MediaStreamCenter, center, ()); > + return center; > +} The reason I ask these questions is that "static" is almost certainly the wrong scope for any state in WebKit.
Adam Barth
Comment 6 2011-11-18 19:30:46 PST
Comment on attachment 115608 [details] Proposed patch Marking r- for now.
Adam Bergkvist
Comment 7 2011-11-21 08:01:51 PST
Created attachment 116089 [details] Updated patch (In reply to comment #4) > Does MediaStreamCenter keep any state? If not, perhaps it should be a collection of free functions. Yes, e.g., each media capture device is only represented by a single MediaStreamSource instance so the MediaStreamCenter must keep track of the MediaStreamSource instances it has created. (In reply to comment #5) > (From update of attachment 115608 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=115608&action=review > > > Source/WebCore/platform/mediastream/MediaStreamCenter.cpp:38 > > +#include "MediaStream.h" > > Another issue is that MediaStream.h is outside the Platform directory and Platform isn't allowed to include headers from the rest of WebCore. Fixed (introduced MediaStreamDescriptorOwner on the platform level). Fixed similar issue with UserMediaRequest. > > Source/WebCore/platform/mediastream/MediaStreamCenter.cpp:48 > > +MediaStreamCenter& MediaStreamCenter::instance() > > +{ > > + ASSERT(isMainThread()); > > + DEFINE_STATIC_LOCAL(MediaStreamCenter, center, ()); > > + return center; > > +} > > The reason I ask these questions is that "static" is almost certainly the wrong scope for any state in WebKit. One reason it's static is to allow MediaStreamSource instances (which correspond to specific media capture devices) to out-live everything else. A MediaStreamSource can be used by several unrelated pages and muting a source takes effect in all pages.
Adam Barth
Comment 8 2011-11-21 11:04:27 PST
I see, so there really is global static state in this API. That's unfortunate, but it sounds unavoidable. Thanks for answering my questions.
Adam Bergkvist
Comment 9 2011-11-22 04:07:48 PST
Comment on attachment 116089 [details] Updated patch Thank you for the review.
WebKit Review Bot
Comment 10 2011-11-22 06:26:47 PST
Comment on attachment 116089 [details] Updated patch Clearing flags on attachment: 116089 Committed r100997: <http://trac.webkit.org/changeset/100997>
WebKit Review Bot
Comment 11 2011-11-22 06:26:56 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.