[MediaStream] Cleanup platform interface
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Sep 2013 17:43:07 +0000 (17:43 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Sep 2013 17:43:07 +0000 (17:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121935

Reviewed by Jer Noble.

No new tests, tests will be updated in the next patch.

* CMakeLists.txt: Remove MediaStreamComponent.cpp.
* GNUmakefile.list.am: Remove MediaStreamComponent.h|cpp and MediaStreamSourcesQueryClient.h.
    Add MediaStreamConstraintsValidationClient.h and MediaStreamCreationClient.h.

* Modules/mediastream/MediaStream.cpp:
(WebCore::processTrack): Duplicate MediaStreamSource when necessary to work around bug 121954.
(WebCore::createFromSourceVectors): MediaStreamCenter::instance -> MediaStream::sharedStreamCenter.
(WebCore::MediaStream::MediaStream): *Components -> *Streams.
(WebCore::MediaStream::setEnded): New.
(WebCore::MediaStream::stop):  MediaStreamCenter::instance -> MediaStream::sharedStreamCenter.
(WebCore::MediaStream::addTrack): Append the track parameter rather than duplicating it, as per spec.
(WebCore::MediaStream::removeTrack): *Components -> *Streams.
(WebCore::MediaStream::trackDidEnd): Renamed from trackEnded.
(WebCore::MediaStream::streamDidEnd): Renamed from streamEnded.
(WebCore::MediaStream::addRemoteSource): Renamed from addRemoteTrack. *Components -> *Streams.
(WebCore::MediaStream::removeRemoteSource): Renamed from removeRemoteTrack. *Components -> *Streams.
* Modules/mediastream/MediaStream.h:

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::create): *Component -> *Stream.
(WebCore::MediaStreamTrack::MediaStreamTrack): Don't assume source is valid.
(WebCore::MediaStreamTrack::~MediaStreamTrack): Ditto.
(WebCore::MediaStreamTrack::kind): Ditto. AtomicString -> const AtomicString&.
(WebCore::MediaStreamTrack::setSource): Moved from .h file.
(WebCore::MediaStreamTrack::id): Don't assume source is valid. Create ID when the source doesn't have one.
(WebCore::MediaStreamTrack::label): Don't assume source is valid.
(WebCore::MediaStreamTrack::enabled):
(WebCore::MediaStreamTrack::setEnabled): *Component -> *Stream. MediaStreamCenter::instance -> MediaStreamCenter::shared.
(WebCore::MediaStreamTrack::readyState): "muted" is not a readyState, but "new" is.
(WebCore::MediaStreamTrack::getSources): MediaStreamCenter::instance -> MediaStreamCenter::shared.
(WebCore::MediaStreamTrack::ended): *Component -> *Stream.
(WebCore::MediaStreamTrack::sourceChangedState): Dispatch "started" and "unmuted" events.
(WebCore::MediaStreamTrack::trackDidEnd): Renamed from didEndTrack. m_component -> m_source.
* Modules/mediastream/MediaStreamTrack.h:

* Modules/mediastream/RTCDTMFSender.cpp:
(WebCore::RTCDTMFSender::create): track->component() -> track->source();

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::didRemoveRemoteStream): Ditto.

* Modules/mediastream/RTCStatsRequestImpl.cpp:
(WebCore::RTCStatsRequestImpl::RTCStatsRequestImpl): Ditto.
(WebCore::RTCStatsRequestImpl::component): Removed, it was unused.
* Modules/mediastream/RTCStatsRequestImpl.h:

* Modules/mediastream/UserMediaClient.h:
* Modules/mediastream/UserMediaController.h:
(WebCore::UserMediaController::requestPermission): Renamed from requestUserMedia, get rid of source
    vector parameters.
(WebCore::UserMediaController::cancelRequest): Renamed from cancelUserMediaRequest.

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::parseOptions): MediaConstraintsImpl -> MediaConstraints.
(WebCore::UserMediaRequest::create): Ditto.
(WebCore::UserMediaRequest::UserMediaRequest): Ditto.
(WebCore::UserMediaRequest::securityOrigin): New.
(WebCore::UserMediaRequest::start): Request constraint validation.
(WebCore::UserMediaRequest::constraintsValidated): New. Callback from media engine when constraints
    can be supported.
(WebCore::UserMediaRequest::requestPermission): New. Ask user media client for permission to access media.
(WebCore::UserMediaRequest::userMediaAccessGranted): New. Access has been granted.
(WebCore::UserMediaRequest::createMediaStream): New. Allowed to access media, ask media engine
    to create stream sources.
(WebCore::UserMediaRequest::userMediaAccessDenied): New. User media client has denied access request.
(WebCore::UserMediaRequest::constraintsInvalid): New. Media engine can not support constraints.
(WebCore::UserMediaRequest::didCreateStream): New. Media engine has created stream sources.
(WebCore::UserMediaRequest::callSuccessHandler): New. Create stream from sources and call success handler.
(WebCore::UserMediaRequest::failedToCreateStreamWithConstraintsError): Renamed from constraintFailure.
(WebCore::UserMediaRequest::failedToCreateStreamWithPermissionError): Renamed from permissionFailure.
(WebCore::UserMediaRequest::callErrorHandler):
(WebCore::UserMediaRequest::contextDestroyed): cancelUserMediaRequest -> cancelRequest.
* Modules/mediastream/UserMediaRequest.h:

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::createMediaStreamSource): localAudio->component()->source() -> localAudio->source().

* Modules/webaudio/MediaStreamAudioDestinationNode.cpp:
(WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode): MediaStreamSource::TypeAudio ->
    MediaStreamSource::Audio, MediaStreamSource::ReadyStateLive -> MediaStreamSource::Live.
    MediaStreamCenter::instance -> MediaStreamCenter::shared.

* WebCore.exp.in: Export new symbols.

* WebCore.xcodeproj/project.pbxproj: Add new files and remove deleted files.

* dom/EventNames.h: Define "started" event.

* platform/mediastream/MediaStreamCenter.cpp:
(WebCore::mediaStreamCenterOverride): Make it possible to override the shared stream center. Will
    be used for testing in a later patch.
(WebCore::MediaStreamCenter::shared): Renamed from instance. Return current stream center.
(WebCore::MediaStreamCenter::setSharedStreamCenter): Override current stream center.
(WebCore::MediaStreamCenter::endLocalMediaStream): Never call the descriptor client, always call
    the descriptor and let it deal with the client.
* platform/mediastream/MediaStreamCenter.h:

* platform/mediastream/MediaStreamComponent.cpp: Removed.
* platform/mediastream/MediaStreamComponent.h: Removed.

* platform/mediastream/MediaStreamConstraintsValidationClient.h: Added.
* platform/mediastream/MediaStreamCreationClient.h: Added.

* platform/mediastream/MediaStreamDescriptor.cpp:
(WebCore::MediaStreamDescriptor::addSource): *Component -> *Source.
(WebCore::MediaStreamDescriptor::removeSource): Ditto.
(WebCore::MediaStreamDescriptor::addRemoteSource): Ditto.
(WebCore::MediaStreamDescriptor::removeRemoteSource): Ditto.
(WebCore::MediaStreamDescriptor::MediaStreamDescriptor): Ditto.
(WebCore::MediaStreamDescriptor::setEnded): Ditto. Set source readyStates to Ended.
* platform/mediastream/MediaStreamDescriptor.h:

* platform/mediastream/MediaStreamSource.cpp:
(WebCore::MediaStreamSource::MediaStreamSource): Initialize new member variables.
(WebCore::MediaStreamSource::setReadyState): Early return when the state hasn't changed.
(WebCore::MediaStreamSource::setStream): New.
(WebCore::MediaStreamSource::setMuted): New.
* platform/mediastream/MediaStreamSource.h:

* platform/mediastream/MediaStreamSourcesQueryClient.h: Removed.

* platform/mediastream/RTCPeerConnectionHandler.h:
* platform/mediastream/RTCStatsRequest.h:

* platform/mediastream/blackberry/MediaStreamCenterBlackBerry.cpp: Update for new MediaStreamCenter API.
* platform/mediastream/blackberry/MediaStreamCenterBlackBerry.h:

* platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp: Ditto.
* platform/mediastream/gstreamer/MediaStreamCenterGStreamer.h:

* platform/mediastream/mac/MediaStreamCenterMac.cpp: Ditto.
* platform/mediastream/mac/MediaStreamCenterMac.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156473 268f45cc-cd09-0410-ab3c-d52691b4dbfc

39 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStream.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/RTCDTMFSender.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCStatsRequestImpl.cpp
Source/WebCore/Modules/mediastream/RTCStatsRequestImpl.h
Source/WebCore/Modules/mediastream/UserMediaClient.h
Source/WebCore/Modules/mediastream/UserMediaController.h
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.h
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/EventNames.h
Source/WebCore/platform/mediastream/MediaStreamCenter.cpp
Source/WebCore/platform/mediastream/MediaStreamCenter.h
Source/WebCore/platform/mediastream/MediaStreamComponent.cpp [deleted file]
Source/WebCore/platform/mediastream/MediaStreamComponent.h [deleted file]
Source/WebCore/platform/mediastream/MediaStreamConstraintsValidationClient.h [new file with mode: 0644]
Source/WebCore/platform/mediastream/MediaStreamCreationClient.h [new file with mode: 0644]
Source/WebCore/platform/mediastream/MediaStreamDescriptor.cpp
Source/WebCore/platform/mediastream/MediaStreamDescriptor.h
Source/WebCore/platform/mediastream/MediaStreamSource.cpp
Source/WebCore/platform/mediastream/MediaStreamSource.h
Source/WebCore/platform/mediastream/MediaStreamSourcesQueryClient.h [deleted file]
Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h
Source/WebCore/platform/mediastream/RTCStatsRequest.h
Source/WebCore/platform/mediastream/blackberry/MediaStreamCenterBlackBerry.cpp
Source/WebCore/platform/mediastream/blackberry/MediaStreamCenterBlackBerry.h
Source/WebCore/platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp
Source/WebCore/platform/mediastream/gstreamer/MediaStreamCenterGStreamer.h
Source/WebCore/platform/mediastream/mac/MediaStreamCenterMac.cpp
Source/WebCore/platform/mediastream/mac/MediaStreamCenterMac.h

index 66794d3..e819b21 100644 (file)
@@ -2025,7 +2025,6 @@ set(WebCore_SOURCES
     platform/leveldb/LevelDBWriteBatch.cpp
 
     platform/mediastream/MediaStreamCenter.cpp
-    platform/mediastream/MediaStreamComponent.cpp
     platform/mediastream/MediaStreamDescriptor.cpp
     platform/mediastream/MediaStreamSource.cpp
     platform/mediastream/RTCIceCandidateDescriptor.cpp
index 78350e9..d9eea35 100644 (file)
-2013-09-26  Tim Horton  <timothy_horton@apple.com>
+2013-09-26  Eric Carlson  <eric.carlson@apple.com>
 
-        Tiled drawing should not imply threaded scrolling
-        https://bugs.webkit.org/show_bug.cgi?id=121874
-        <rdar://problem/15071494>
+        [MediaStream] Cleanup platform interface
+        https://bugs.webkit.org/show_bug.cgi?id=121935
 
-        Reviewed by Sam Weinig.
+        Reviewed by Jer Noble.
 
-        No new tests; a near-future patch is going to put the majority of layout
-        tests into the tiled-drawing-without-threaded-scrolling mode.
+        No new tests, tests will be updated in the next patch.
 
-        * page/ChromeClient.h:
-        (WebCore::ChromeClient::shouldUseTiledBackingForFrame):
-        Add a ChromeClient callback to determine whether a given frame wants a TiledBacking for its contents.
+        * CMakeLists.txt: Remove MediaStreamComponent.cpp.
+        * GNUmakefile.list.am: Remove MediaStreamComponent.h|cpp and MediaStreamSourcesQueryClient.h. 
+            Add MediaStreamConstraintsValidationClient.h and MediaStreamCreationClient.h.
 
-        * page/FrameView.h:
-        * WebCore.exp.in:
-        Make isMainFrameView public and export it for use in WebKit2.
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::processTrack): Duplicate MediaStreamSource when necessary to work around bug 121954.
+        (WebCore::createFromSourceVectors): MediaStreamCenter::instance -> MediaStream::sharedStreamCenter.
+        (WebCore::MediaStream::MediaStream): *Components -> *Streams.
+        (WebCore::MediaStream::setEnded): New.
+        (WebCore::MediaStream::stop):  MediaStreamCenter::instance -> MediaStream::sharedStreamCenter.
+        (WebCore::MediaStream::addTrack): Append the track parameter rather than duplicating it, as per spec.
+        (WebCore::MediaStream::removeTrack): *Components -> *Streams.
+        (WebCore::MediaStream::trackDidEnd): Renamed from trackEnded.
+        (WebCore::MediaStream::streamDidEnd): Renamed from streamEnded.
+        (WebCore::MediaStream::addRemoteSource): Renamed from addRemoteTrack. *Components -> *Streams.
+        (WebCore::MediaStream::removeRemoteSource): Renamed from removeRemoteTrack. *Components -> *Streams.
+        * Modules/mediastream/MediaStream.h:
 
-        * rendering/RenderLayerBacking.cpp:
-        (WebCore::RenderLayerBacking::RenderLayerBacking):
-        Make use of shouldUseTiledBackingForFrame instead of predicating the
-        main frame using a tile cache on whether we have a scrolling coordinator.
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::create): *Component -> *Stream.
+        (WebCore::MediaStreamTrack::MediaStreamTrack): Don't assume source is valid.
+        (WebCore::MediaStreamTrack::~MediaStreamTrack): Ditto.
+        (WebCore::MediaStreamTrack::kind): Ditto. AtomicString -> const AtomicString&.
+        (WebCore::MediaStreamTrack::setSource): Moved from .h file.
+        (WebCore::MediaStreamTrack::id): Don't assume source is valid. Create ID when the source doesn't have one.
+        (WebCore::MediaStreamTrack::label): Don't assume source is valid.
+        (WebCore::MediaStreamTrack::enabled): 
+        (WebCore::MediaStreamTrack::setEnabled): *Component -> *Stream. MediaStreamCenter::instance -> MediaStreamCenter::shared.
+        (WebCore::MediaStreamTrack::readyState): "muted" is not a readyState, but "new" is.
+        (WebCore::MediaStreamTrack::getSources): MediaStreamCenter::instance -> MediaStreamCenter::shared.
+        (WebCore::MediaStreamTrack::ended): *Component -> *Stream.
+        (WebCore::MediaStreamTrack::sourceChangedState): Dispatch "started" and "unmuted" events.
+        (WebCore::MediaStreamTrack::trackDidEnd): Renamed from didEndTrack. m_component -> m_source.
+        * Modules/mediastream/MediaStreamTrack.h:
 
-        * rendering/RenderLayerCompositor.cpp:
-        (WebCore::RenderLayerCompositor::mainFrameBackingIsTiled): Added.
+        * Modules/mediastream/RTCDTMFSender.cpp:
+        (WebCore::RTCDTMFSender::create): track->component() -> track->source();
 
-        (WebCore::RenderLayerCompositor::shouldCompositeOverflowControls):
-        (WebCore::RenderLayerCompositor::requiresOverhangAreasLayer):
-        (WebCore::RenderLayerCompositor::requiresContentShadowLayer):
-        All of these checks for existence of a scrollingCoordinator should actually
-        key off whether we're using tiled drawing at the root; they have nothing
-        to do with threaded scrolling.
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::didRemoveRemoteStream): Ditto.
 
-        * rendering/RenderLayerCompositor.h:
+        * Modules/mediastream/RTCStatsRequestImpl.cpp:
+        (WebCore::RTCStatsRequestImpl::RTCStatsRequestImpl): Ditto.
+        (WebCore::RTCStatsRequestImpl::component): Removed, it was unused.
+        * Modules/mediastream/RTCStatsRequestImpl.h:
+
+        * Modules/mediastream/UserMediaClient.h:
+        * Modules/mediastream/UserMediaController.h:
+        (WebCore::UserMediaController::requestPermission): Renamed from requestUserMedia, get rid of source
+            vector parameters.
+        (WebCore::UserMediaController::cancelRequest): Renamed from cancelUserMediaRequest.
 
-2013-09-26  Brady Eidson  <beidson@apple.com>
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::parseOptions): MediaConstraintsImpl -> MediaConstraints.
+        (WebCore::UserMediaRequest::create): Ditto.
+        (WebCore::UserMediaRequest::UserMediaRequest): Ditto.
+        (WebCore::UserMediaRequest::securityOrigin): New.
+        (WebCore::UserMediaRequest::start): Request constraint validation.
+        (WebCore::UserMediaRequest::constraintsValidated): New. Callback from media engine when constraints
+            can be supported.
+        (WebCore::UserMediaRequest::requestPermission): New. Ask user media client for permission to access media.
+        (WebCore::UserMediaRequest::userMediaAccessGranted): New. Access has been granted.
+        (WebCore::UserMediaRequest::createMediaStream): New. Allowed to access media, ask media engine
+            to create stream sources.
+        (WebCore::UserMediaRequest::userMediaAccessDenied): New. User media client has denied access request.
+        (WebCore::UserMediaRequest::constraintsInvalid): New. Media engine can not support constraints.
+        (WebCore::UserMediaRequest::didCreateStream): New. Media engine has created stream sources.
+        (WebCore::UserMediaRequest::callSuccessHandler): New. Create stream from sources and call success handler.
+        (WebCore::UserMediaRequest::failedToCreateStreamWithConstraintsError): Renamed from constraintFailure.
+        (WebCore::UserMediaRequest::failedToCreateStreamWithPermissionError): Renamed from permissionFailure.
+        (WebCore::UserMediaRequest::callErrorHandler): 
+        (WebCore::UserMediaRequest::contextDestroyed): cancelUserMediaRequest -> cancelRequest.
+        * Modules/mediastream/UserMediaRequest.h:
 
-        Mark IDBDatabase "FINAL" now that http://webkit.org/b/121747 is fixed.
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::createMediaStreamSource): localAudio->component()->source() -> localAudio->source().
+
+        * Modules/webaudio/MediaStreamAudioDestinationNode.cpp:
+        (WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode): MediaStreamSource::TypeAudio ->
+            MediaStreamSource::Audio, MediaStreamSource::ReadyStateLive -> MediaStreamSource::Live.
+            MediaStreamCenter::instance -> MediaStreamCenter::shared.
 
-        Rubberstamped by Andreas Kling
+        * WebCore.exp.in: Export new symbols.
 
-        * Modules/indexeddb/IDBDatabase.h: Mark this class FINAL.
+        * WebCore.xcodeproj/project.pbxproj: Add new files and remove deleted files.
+
+        * dom/EventNames.h: Define "started" event.
+
+        * platform/mediastream/MediaStreamCenter.cpp:
+        (WebCore::mediaStreamCenterOverride): Make it possible to override the shared stream center. Will
+            be used for testing in a later patch.
+        (WebCore::MediaStreamCenter::shared): Renamed from instance. Return current stream center.
+        (WebCore::MediaStreamCenter::setSharedStreamCenter): Override current stream center.
+        (WebCore::MediaStreamCenter::endLocalMediaStream): Never call the descriptor client, always call
+            the descriptor and let it deal with the client.
+        * platform/mediastream/MediaStreamCenter.h:
+
+        * platform/mediastream/MediaStreamComponent.cpp: Removed.
+        * platform/mediastream/MediaStreamComponent.h: Removed.
+
+        * platform/mediastream/MediaStreamConstraintsValidationClient.h: Added.
+        * platform/mediastream/MediaStreamCreationClient.h: Added.
+
+        * platform/mediastream/MediaStreamDescriptor.cpp:
+        (WebCore::MediaStreamDescriptor::addSource): *Component -> *Source.
+        (WebCore::MediaStreamDescriptor::removeSource): Ditto.
+        (WebCore::MediaStreamDescriptor::addRemoteSource): Ditto.
+        (WebCore::MediaStreamDescriptor::removeRemoteSource): Ditto.
+        (WebCore::MediaStreamDescriptor::MediaStreamDescriptor): Ditto.
+        (WebCore::MediaStreamDescriptor::setEnded): Ditto. Set source readyStates to Ended.
+        * platform/mediastream/MediaStreamDescriptor.h:
+
+        * platform/mediastream/MediaStreamSource.cpp:
+        (WebCore::MediaStreamSource::MediaStreamSource): Initialize new member variables.
+        (WebCore::MediaStreamSource::setReadyState): Early return when the state hasn't changed.
+        (WebCore::MediaStreamSource::setStream): New.
+        (WebCore::MediaStreamSource::setMuted): New.
+        * platform/mediastream/MediaStreamSource.h:
+
+        * platform/mediastream/MediaStreamSourcesQueryClient.h: Removed.
+
+        * platform/mediastream/RTCPeerConnectionHandler.h:
+        * platform/mediastream/RTCStatsRequest.h:
+
+        * platform/mediastream/blackberry/MediaStreamCenterBlackBerry.cpp: Update for new MediaStreamCenter API.
+        * platform/mediastream/blackberry/MediaStreamCenterBlackBerry.h:
+
+        * platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp: Ditto.
+        * platform/mediastream/gstreamer/MediaStreamCenterGStreamer.h:
+
+        * platform/mediastream/mac/MediaStreamCenterMac.cpp: Ditto.
+        * platform/mediastream/mac/MediaStreamCenterMac.h:
 
 2013-09-26  Gurpreet Kaur  <k.gurpreet@samsung.com>
 
index d9a4810..8f38627 100644 (file)
@@ -5454,13 +5454,12 @@ webcore_platform_sources += \
        Source/WebCore/platform/mediastream/MediaConstraints.h \
        Source/WebCore/platform/mediastream/MediaStreamCenter.cpp \
        Source/WebCore/platform/mediastream/MediaStreamCenter.h \
-       Source/WebCore/platform/mediastream/MediaStreamComponent.cpp \
-       Source/WebCore/platform/mediastream/MediaStreamComponent.h \
+       Source/WebCore/platform/mediastream/MediaStreamConstraintsValidationClient.h \
+       Source/WebCore/platform/mediastream/MediaStreamCreationClient.h \
        Source/WebCore/platform/mediastream/MediaStreamDescriptor.cpp \
        Source/WebCore/platform/mediastream/MediaStreamDescriptor.h \
        Source/WebCore/platform/mediastream/MediaStreamSource.cpp \
        Source/WebCore/platform/mediastream/MediaStreamSource.h \
-       Source/WebCore/platform/mediastream/MediaStreamSourcesQueryClient.h \
        Source/WebCore/platform/mediastream/MediaStreamTrackSourcesRequestClient.h \
        Source/WebCore/platform/mediastream/RTCConfiguration.h \
        Source/WebCore/platform/mediastream/RTCDTMFSenderHandler.h \
index 1ab24f4..5fdb4dd 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011, 2012 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,6 +35,7 @@
 #include "MediaStreamRegistry.h"
 #include "MediaStreamSource.h"
 #include "MediaStreamTrackEvent.h"
+#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -51,15 +53,22 @@ static void processTrack(MediaStreamTrack* track, MediaStreamSourceVector& sourc
     if (track->ended())
         return;
 
-    MediaStreamSource* source = track->component()->source();
-    if (!containsSource(sourceVector, source))
-        sourceVector.append(source);
+    MediaStreamSource* source = track->source();
+    if (!containsSource(sourceVector, source)) {
+        if (source->stream()) {
+            // FIXME: this should not be necessary because tracks and streams must be able to share sources, but our code
+            // currenlty assumes each source is attached to just one track.
+            // https://bugs.webkit.org/show_bug.cgi?id=121954
+            sourceVector.append(MediaStreamSource::create(source->id(), source->type(), source->name(), source->readyState(), source->requiresAudioConsumer()).get());
+        } else
+            sourceVector.append(source);
+    }
 }
 
 static PassRefPtr<MediaStream> createFromSourceVectors(ScriptExecutionContext* context, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
 {
     RefPtr<MediaStreamDescriptor> descriptor = MediaStreamDescriptor::create(audioSources, videoSources);
-    MediaStreamCenter::instance().didCreateMediaStream(descriptor.get());
+    MediaStreamCenter::shared().didCreateMediaStream(descriptor.get());
 
     return MediaStream::create(context, descriptor.release());
 }
@@ -112,15 +121,15 @@ MediaStream::MediaStream(ScriptExecutionContext* context, PassRefPtr<MediaStream
 {
     m_descriptor->setClient(this);
 
-    size_t numberOfAudioTracks = m_descriptor->numberOfAudioComponents();
+    size_t numberOfAudioTracks = m_descriptor->numberOfAudioStreams();
     m_audioTracks.reserveCapacity(numberOfAudioTracks);
     for (size_t i = 0; i < numberOfAudioTracks; i++)
-        m_audioTracks.append(MediaStreamTrack::create(context, m_descriptor->audioComponent(i)));
+        m_audioTracks.append(MediaStreamTrack::create(context, m_descriptor->audioStreams(i)));
 
-    size_t numberOfVideoTracks = m_descriptor->numberOfVideoComponents();
+    size_t numberOfVideoTracks = m_descriptor->numberOfVideoStreams();
     m_videoTracks.reserveCapacity(numberOfVideoTracks);
     for (size_t i = 0; i < numberOfVideoTracks; i++)
-        m_videoTracks.append(MediaStreamTrack::create(context, m_descriptor->videoComponent(i)));
+        m_videoTracks.append(MediaStreamTrack::create(context, m_descriptor->videoStreams(i)));
 }
 
 MediaStream::~MediaStream()
@@ -133,13 +142,20 @@ bool MediaStream::ended() const
     return m_stopped || m_descriptor->ended();
 }
 
+void MediaStream::setEnded()
+{
+    if (ended())
+        return;
+    m_descriptor->setEnded();
+}
+
 void MediaStream::stop()
 {
     if (ended())
         return;
 
-    MediaStreamCenter::instance().didStopLocalMediaStream(descriptor());
-    streamEnded();
+    MediaStreamCenter::shared().didStopLocalMediaStream(descriptor());
+    setEnded();
 }
 
 void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
@@ -155,24 +171,19 @@ void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode&
     }
 
     RefPtr<MediaStreamTrack> track = prpTrack;
-
     if (getTrackById(track->id()))
         return;
 
-    RefPtr<MediaStreamComponent> component = MediaStreamComponent::create(m_descriptor.get(), track->component()->source());
-    RefPtr<MediaStreamTrack> newTrack = MediaStreamTrack::create(scriptExecutionContext(), component.get());
-
-    switch (component->source()->type()) {
-    case MediaStreamSource::TypeAudio:
-        m_audioTracks.append(newTrack);
+    switch (track->source()->type()) {
+    case MediaStreamSource::Audio:
+        m_audioTracks.append(track);
         break;
-    case MediaStreamSource::TypeVideo:
-        m_videoTracks.append(newTrack);
+    case MediaStreamSource::Video:
+        m_videoTracks.append(track);
         break;
     }
 
-    m_descriptor->addComponent(component.release());
-    MediaStreamCenter::instance().didAddMediaStreamTrack(m_descriptor.get(), newTrack->component());
+    MediaStreamCenter::shared().didAddMediaStreamTrack(track->source());
 }
 
 void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
@@ -190,13 +201,13 @@ void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCo
     RefPtr<MediaStreamTrack> track = prpTrack;
 
     size_t pos = notFound;
-    switch (track->component()->source()->type()) {
-    case MediaStreamSource::TypeAudio:
+    switch (track->source()->type()) {
+    case MediaStreamSource::Audio:
         pos = m_audioTracks.find(track);
         if (pos != notFound)
             m_audioTracks.remove(pos);
         break;
-    case MediaStreamSource::TypeVideo:
+    case MediaStreamSource::Video:
         pos = m_videoTracks.find(track);
         if (pos != notFound)
             m_videoTracks.remove(pos);
@@ -206,12 +217,12 @@ void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCo
     if (pos == notFound)
         return;
 
-    m_descriptor->removeComponent(track->component());
+    m_descriptor->removeSource(track->source());
 
     if (!m_audioTracks.size() && !m_videoTracks.size())
-        m_descriptor->setEnded();
+        setEnded();
 
-    MediaStreamCenter::instance().didRemoveMediaStreamTrack(m_descriptor.get(), track->component());
+    MediaStreamCenter::shared().didRemoveMediaStreamTrack(track->source());
 }
 
 MediaStreamTrack* MediaStream::getTrackById(String id)
@@ -229,7 +240,7 @@ MediaStreamTrack* MediaStream::getTrackById(String id)
     return 0;
 }
 
-void MediaStream::trackEnded()
+void MediaStream::trackDidEnd()
 {
     for (size_t i = 0; i < m_audioTracks.size(); ++i)
         if (!m_audioTracks[i]->ended())
@@ -239,15 +250,14 @@ void MediaStream::trackEnded()
         if (!m_videoTracks[i]->ended())
             return;
     
-    streamEnded();
+    setEnded();
 }
 
-void MediaStream::streamEnded()
+void MediaStream::streamDidEnd()
 {
     if (ended())
         return;
 
-    m_descriptor->setEnded();
     scheduleDispatchEvent(Event::create(eventNames().endedEvent, false, false));
 }
 
@@ -257,46 +267,46 @@ void MediaStream::contextDestroyed()
     m_stopped = true;
 }
 
-void MediaStream::addRemoteTrack(MediaStreamComponent* component)
+void MediaStream::addRemoteSource(MediaStreamSource* source)
 {
-    ASSERT(component && !component->stream());
+    ASSERT(source);
     if (ended())
         return;
 
-    component->setStream(descriptor());
+    source->setStream(descriptor());
 
-    RefPtr<MediaStreamTrack> track = MediaStreamTrack::create(scriptExecutionContext(), component);
-    switch (component->source()->type()) {
-    case MediaStreamSource::TypeAudio:
+    RefPtr<MediaStreamTrack> track = MediaStreamTrack::create(scriptExecutionContext(), source);
+    switch (source->type()) {
+    case MediaStreamSource::Audio:
         m_audioTracks.append(track);
         break;
-    case MediaStreamSource::TypeVideo:
+    case MediaStreamSource::Video:
         m_videoTracks.append(track);
         break;
     }
-    m_descriptor->addComponent(component);
+    m_descriptor->addSource(source);
 
     scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().addtrackEvent, false, false, track));
 }
 
-void MediaStream::removeRemoteTrack(MediaStreamComponent* component)
+void MediaStream::removeRemoteSource(MediaStreamSource* source)
 {
     if (ended())
         return;
 
     MediaStreamTrackVector* tracks = 0;
-    switch (component->source()->type()) {
-    case MediaStreamSource::TypeAudio:
+    switch (source->type()) {
+    case MediaStreamSource::Audio:
         tracks = &m_audioTracks;
         break;
-    case MediaStreamSource::TypeVideo:
+    case MediaStreamSource::Video:
         tracks = &m_videoTracks;
         break;
     }
 
     size_t index = notFound;
     for (size_t i = 0; i < tracks->size(); ++i) {
-        if ((*tracks)[i]->component() == component) {
+        if ((*tracks)[i]->source() == source) {
             index = i;
             break;
         }
@@ -304,7 +314,7 @@ void MediaStream::removeRemoteTrack(MediaStreamComponent* component)
     if (index == notFound)
         return;
 
-    m_descriptor->removeComponent(component);
+    m_descriptor->removeSource(source);
 
     RefPtr<MediaStreamTrack> track = (*tracks)[index];
     tracks->remove(index);
index 9f7c341..7a282fc 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,6 +42,8 @@
 
 namespace WebCore {
 
+class MediaStreamCenter;
+
 // FIXME: This class should be marked FINAL once <http://webkit.org/b/121747> is fixed.
 class MediaStream : public RefCounted<MediaStream>, public URLRegistrable, public ScriptWrappable, public MediaStreamDescriptorClient, public EventTargetWithInlineData, public ContextDestructionObserver {
 public:
@@ -60,16 +63,13 @@ public:
     MediaStreamTrackVector getVideoTracks() const { return m_videoTracks; }
 
     bool ended() const;
+    void setEnded();
     void stop();
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(ended);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack);
 
-    // MediaStreamDescriptorClient
-    virtual void trackEnded() OVERRIDE;
-    virtual void streamEnded() OVERRIDE;
-
     MediaStreamDescriptor* descriptor() const { return m_descriptor.get(); }
 
     // EventTarget
@@ -89,25 +89,29 @@ protected:
     virtual void contextDestroyed();
 
 private:
+    // MediaStreamDescriptorClient
+    virtual void trackDidEnd() OVERRIDE;
+    virtual void streamDidEnd() OVERRIDE;
+    
     // EventTarget
     virtual void refEventTarget() OVERRIDE FINAL { ref(); }
     virtual void derefEventTarget() OVERRIDE FINAL { deref(); }
 
     // MediaStreamDescriptorClient
-    virtual void addRemoteTrack(MediaStreamComponent*) OVERRIDE;
-    virtual void removeRemoteTrack(MediaStreamComponent*) OVERRIDE;
+    virtual void addRemoteSource(MediaStreamSource*) OVERRIDE;
+    virtual void removeRemoteSource(MediaStreamSource*) OVERRIDE;
 
     void scheduleDispatchEvent(PassRefPtr<Event>);
     void scheduledEventTimerFired(Timer<MediaStream>*);
 
     bool m_stopped;
 
+    RefPtr<MediaStreamDescriptor> m_descriptor;
     MediaStreamTrackVector m_audioTracks;
     MediaStreamTrackVector m_videoTracks;
-    RefPtr<MediaStreamDescriptor> m_descriptor;
 
     Timer<MediaStream> m_scheduledEventTimer;
-    Vector<RefPtr<Event> > m_scheduledEvents;
+    Vector<RefPtr<Event>> m_scheduledEvents;
 };
 
 typedef Vector<RefPtr<MediaStream> > MediaStreamVector;
index 4030d05..34846ff 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "Dictionary.h"
 #include "Event.h"
 #include "ExceptionCode.h"
+#include "MediaStream.h"
 #include "MediaStreamCenter.h"
-#include "MediaStreamComponent.h"
+#include "MediaStreamDescriptor.h"
 #include "MediaStreamTrackSourcesCallback.h"
 #include "MediaStreamTrackSourcesRequest.h"
+#include "UUID.h"
 #include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
-PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext* context, MediaStreamComponent* component)
+PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext* context, const Dictionary& videoConstraints)
 {
-    RefPtr<MediaStreamTrack> track = adoptRef(new MediaStreamTrack(context, component));
-    track->suspendIfNeeded();
+    RefPtr<MediaStreamTrack> track = adoptRef(new MediaStreamTrack(context, 0, &videoConstraints));
     return track.release();
 }
 
-MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext* context, MediaStreamComponent* component)
+PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext* context, MediaStreamSource* source)
+{
+    RefPtr<MediaStreamTrack> track = adoptRef(new MediaStreamTrack(context, source, 0));
+    return track.release();
+}
+
+MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext* context, MediaStreamSource* source, const Dictionary*)
     : ActiveDOMObject(context)
-    , m_component(component)
+    , m_source(source)
+    , m_readyState(MediaStreamSource::New)
     , m_stopped(false)
+    , m_enabled(true)
+    , m_muted(false)
 {
-    m_component->source()->addObserver(this);
+    suspendIfNeeded();
+    if (m_source) {
+        m_source->addObserver(this);
+        m_muted = m_source->muted();
+    }
 }
 
 MediaStreamTrack::~MediaStreamTrack()
 {
-    m_component->source()->removeObserver(this);
+    if (m_source)
+        m_source->removeObserver(this);
 }
 
-AtomicString MediaStreamTrack::kind() const
+const AtomicString& MediaStreamTrack::kind() const
 {
+    if (!m_source)
+        return emptyAtom;
+
     static NeverDestroyed<AtomicString> audioKind("audio", AtomicString::ConstructFromLiteral);
     static NeverDestroyed<AtomicString> videoKind("video", AtomicString::ConstructFromLiteral);
 
-    switch (m_component->source()->type()) {
-    case MediaStreamSource::TypeAudio:
+    switch (m_source->type()) {
+    case MediaStreamSource::Audio:
         return audioKind;
-    case MediaStreamSource::TypeVideo:
+    case MediaStreamSource::Video:
         return videoKind;
     }
 
@@ -74,49 +94,81 @@ AtomicString MediaStreamTrack::kind() const
     return emptyAtom;
 }
 
-String MediaStreamTrack::id() const
+void MediaStreamTrack::setSource(MediaStreamSource* source)
 {
-    return m_component->id();
+    ASSERT(source == m_source || !m_source);
+    m_source = source;
 }
 
-String MediaStreamTrack::label() const
+const String& MediaStreamTrack::id() const
 {
-    return m_component->source()->name();
+    if (!m_id.isEmpty())
+        return m_id;
+
+    if (!m_source)
+        return emptyString();
+
+    const String& id = m_source->id();
+    if (!id.isEmpty())
+        return id;
+
+    // The spec says:
+    //   Unless a MediaStreamTrack object is created as a part a of special purpose algorithm that
+    //   specifies how the track id must be initialized, the user agent must generate a globally
+    //   unique identifier string and initialize the object's id attribute to that string.
+    // so generate a UUID if the source doesn't have an ID.
+    m_id = createCanonicalUUIDString();
+    return m_id;
+}
+
+const String& MediaStreamTrack::label() const
+{
+    if (m_source)
+        return m_source->name();
+    return emptyString();
 }
 
 bool MediaStreamTrack::enabled() const
 {
-    return m_component->enabled();
+    return m_enabled;
 }
 
 void MediaStreamTrack::setEnabled(bool enabled)
 {
-    if (m_stopped || enabled == m_component->enabled())
+    if (m_stopped)
+        return;
+    
+    m_enabled = enabled;
+
+    if (!m_source || enabled == m_source->enabled())
         return;
 
-    m_component->setEnabled(enabled);
+    m_source->setEnabled(enabled);
 
-    if (m_component->stream()->ended())
+    if (m_source->stream()->ended())
         return;
 
-    MediaStreamCenter::instance().didSetMediaStreamTrackEnabled(m_component->stream(), m_component.get());
+    MediaStreamCenter::shared().didSetMediaStreamTrackEnabled(m_source.get());
 }
 
-AtomicString MediaStreamTrack::readyState() const
+const AtomicString& MediaStreamTrack::readyState() const
 {
     static NeverDestroyed<AtomicString> ended("ended", AtomicString::ConstructFromLiteral);
     static NeverDestroyed<AtomicString> live("live", AtomicString::ConstructFromLiteral);
-    static NeverDestroyed<AtomicString> muted("muted", AtomicString::ConstructFromLiteral);
+    static NeverDestroyed<AtomicString> newState("new", AtomicString::ConstructFromLiteral);
+
+    if (!m_source)
+        return newState;
 
     if (m_stopped)
         return ended;
 
-    switch (m_component->source()->readyState()) {
-    case MediaStreamSource::ReadyStateLive:
+    switch (m_source->readyState()) {
+    case MediaStreamSource::Live:
         return live;
-    case MediaStreamSource::ReadyStateMuted:
-        return muted;
-    case MediaStreamSource::ReadyStateEnded:
+    case MediaStreamSource::New:
+        return newState;
+    case MediaStreamSource::Ended:
         return ended;
     }
 
@@ -127,13 +179,13 @@ AtomicString MediaStreamTrack::readyState() const
 void MediaStreamTrack::getSources(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrackSourcesCallback> callback, ExceptionCode& ec)
 {
     RefPtr<MediaStreamTrackSourcesRequest> request = MediaStreamTrackSourcesRequest::create(context, callback);
-    if (!MediaStreamCenter::instance().getMediaStreamTrackSources(request.release()))
+    if (!MediaStreamCenter::shared().getMediaStreamTrackSources(request.release()))
         ec = NOT_SUPPORTED_ERR;
 }
 
 bool MediaStreamTrack::ended() const
 {
-    return m_stopped || (m_component->source()->readyState() == MediaStreamSource::ReadyStateEnded);
+    return m_stopped || (m_source && m_source->readyState() == MediaStreamSource::Ended);
 }
 
 void MediaStreamTrack::sourceChangedState()
@@ -141,32 +193,32 @@ void MediaStreamTrack::sourceChangedState()
     if (m_stopped)
         return;
 
-    switch (m_component->source()->readyState()) {
-    case MediaStreamSource::ReadyStateLive:
-        dispatchEvent(Event::create(eventNames().unmuteEvent, false, false));
-        break;
-    case MediaStreamSource::ReadyStateMuted:
-        dispatchEvent(Event::create(eventNames().muteEvent, false, false));
-        break;
-    case MediaStreamSource::ReadyStateEnded:
+    MediaStreamSource::ReadyState oldReadyState = m_readyState;
+    m_readyState = m_source->readyState();
+
+    if (m_readyState >= MediaStreamSource::Live && oldReadyState == MediaStreamSource::New)
+        dispatchEvent(Event::create(eventNames().startedEvent, false, false));
+    if (m_readyState == MediaStreamSource::Ended && oldReadyState != MediaStreamSource::Ended)
         dispatchEvent(Event::create(eventNames().endedEvent, false, false));
-        didEndTrack();
-        break;
-    }
+
+    if (m_muted == m_source->muted())
+        return;
+
+    m_muted = m_source->muted();
+    if (m_muted)
+        dispatchEvent(Event::create(eventNames().muteEvent, false, false));
+    else
+        dispatchEvent(Event::create(eventNames().unmuteEvent, false, false));
 }
 
-void MediaStreamTrack::didEndTrack()
+void MediaStreamTrack::trackDidEnd()
 {
-    MediaStreamDescriptorClient* client = m_component->stream()->client();
+    // FIXME: this is wrong, the track shouldn't have to call the descriptor's client!
+    MediaStreamDescriptorClient* client = m_source ? m_source->stream()->client() : 0;
     if (!client)
         return;
     
-    client->trackEnded();
-}
-
-MediaStreamComponent* MediaStreamTrack::component()
-{
-    return m_component.get();
+    client->trackDidEnd();
 }
 
 void MediaStreamTrack::stop()
index 9667f90..a2d8aa7 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2011 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,7 +31,6 @@
 
 #include "ActiveDOMObject.h"
 #include "EventTarget.h"
-#include "MediaStreamDescriptor.h"
 #include "MediaStreamSource.h"
 #include "ScriptWrappable.h"
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 
-class MediaStreamComponent;
+class Dictionary;
+class MediaConstraints;
 class MediaStreamTrackSourcesCallback;
 
 // FIXME: This class should be marked FINAL once <http://webkit.org/b/121747> is fixed.
 class MediaStreamTrack : public RefCounted<MediaStreamTrack>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInlineData, public MediaStreamSource::Observer {
 public:
-    static PassRefPtr<MediaStreamTrack> create(ScriptExecutionContext*, MediaStreamComponent*);
+
+    static PassRefPtr<MediaStreamTrack> create(ScriptExecutionContext*, const Dictionary&);
+    static PassRefPtr<MediaStreamTrack> create(ScriptExecutionContext*, MediaStreamSource*);
+
     virtual ~MediaStreamTrack();
 
-    AtomicString kind() const;
-    String id() const;
-    String label() const;
+    const AtomicString& kind() const;
+    const String& id() const;
+    const String& label() const;
 
     bool enabled() const;
     void setEnabled(bool);
-
-    void didEndTrack();
     
-    AtomicString readyState() const;
+    const AtomicString& readyState() const;
 
     static void getSources(ScriptExecutionContext*, PassRefPtr<MediaStreamTrackSourcesCallback>, ExceptionCode&);
 
+    MediaStreamSource* source() const { return m_source.get(); }
+    void setSource(MediaStreamSource*);
+
     DEFINE_ATTRIBUTE_EVENT_LISTENER(mute);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(unmute);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(ended);
 
-    MediaStreamComponent* component();
     bool ended() const;
 
     // EventTarget
@@ -80,7 +84,9 @@ public:
     using RefCounted<MediaStreamTrack>::deref;
 
 private:
-    MediaStreamTrack(ScriptExecutionContext*, MediaStreamComponent*);
+    MediaStreamTrack(ScriptExecutionContext*, MediaStreamSource*, const Dictionary*);
+
+    void trackDidEnd();
 
     // EventTarget
     virtual void refEventTarget() OVERRIDE FINAL { ref(); }
@@ -89,8 +95,14 @@ private:
     // MediaStreamSourceObserver
     virtual void sourceChangedState() OVERRIDE;
 
-    RefPtr<MediaStreamComponent> m_component;
+    RefPtr<MediaStreamSource> m_source;
+    RefPtr<MediaConstraints> m_constraints;
+    MediaStreamSource::ReadyState m_readyState;
+    mutable String m_id;
+
     bool m_stopped;
+    bool m_enabled;
+    bool m_muted;
 };
 
 typedef Vector<RefPtr<MediaStreamTrack> > MediaStreamTrackVector;
index 45e4e90..d61a165 100644 (file)
@@ -47,7 +47,7 @@ static const long defaultInterToneGapMs = 50;
 PassRefPtr<RTCDTMFSender> RTCDTMFSender::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* peerConnectionHandler, PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
 {
     RefPtr<MediaStreamTrack> track = prpTrack;
-    OwnPtr<RTCDTMFSenderHandler> handler = peerConnectionHandler->createDTMFSender(track->component());
+    OwnPtr<RTCDTMFSenderHandler> handler = peerConnectionHandler->createDTMFSender(track->source());
     if (!handler) {
         ec = NOT_SUPPORTED_ERR;
         return 0;
index 85d4aa4..ced0233 100644 (file)
@@ -559,8 +559,9 @@ void RTCPeerConnection::didRemoveRemoteStream(MediaStreamDescriptor* streamDescr
     ASSERT(scriptExecutionContext()->isContextThread());
     ASSERT(streamDescriptor->client());
 
+    // FIXME: this class shouldn't know that the descriptor client is a MediaStream!
     RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->client());
-    stream->streamEnded();
+    stream->setEnded();
 
     if (m_signalingState == SignalingStateClosed)
         return;
index 343e30b..5c4b25a 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "RTCStatsRequestImpl.h"
 
+#include "MediaStreamDescriptor.h"
+#include "MediaStreamTrack.h"
 #include "RTCStatsCallback.h"
 #include "RTCStatsRequest.h"
 #include "RTCStatsResponse.h"
@@ -44,8 +46,7 @@ PassRefPtr<RTCStatsRequestImpl> RTCStatsRequestImpl::create(ScriptExecutionConte
 RTCStatsRequestImpl::RTCStatsRequestImpl(ScriptExecutionContext* context, PassRefPtr<RTCStatsCallback> callback, PassRefPtr<MediaStreamTrack> selector)
     : ActiveDOMObject(context)
     , m_successCallback(callback)
-    , m_stream(selector ? selector->component()->stream() : 0)
-    , m_component(selector ? selector->component() : 0)
+    , m_stream(selector ? selector->source()->stream() : 0)
 {
 }
 
@@ -68,11 +69,6 @@ MediaStreamDescriptor* RTCStatsRequestImpl::stream()
     return m_stream.get();
 }
 
-MediaStreamComponent* RTCStatsRequestImpl::component()
-{
-    return m_component.get();
-}
-
 void RTCStatsRequestImpl::requestSucceeded(PassRefPtr<RTCStatsResponseBase> response)
 {
     if (!m_successCallback)
index 876063c..3fab8c2 100644 (file)
@@ -46,7 +46,6 @@ public:
     virtual PassRefPtr<RTCStatsResponseBase> createResponse() OVERRIDE;
     virtual bool hasSelector() OVERRIDE;
     virtual MediaStreamDescriptor* stream() OVERRIDE;
-    virtual MediaStreamComponent* component() OVERRIDE;
 
     virtual void requestSucceeded(PassRefPtr<RTCStatsResponseBase>) OVERRIDE;
 
@@ -60,7 +59,6 @@ private:
 
     RefPtr<RTCStatsCallback> m_successCallback;
     RefPtr<MediaStreamDescriptor> m_stream;
-    RefPtr<MediaStreamComponent> m_component;
 };
 
 } // namespace WebCore
index 744711e..b847c78 100644 (file)
 
 #if ENABLE(MEDIA_STREAM)
 
-#include "UserMediaRequest.h"
-#include <wtf/text/WTFString.h>
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
 class Page;
+class UserMediaRequest;
 
 class UserMediaClient {
 public:
     virtual void pageDestroyed() = 0;
 
-    virtual void requestUserMedia(PassRefPtr<UserMediaRequest>, const MediaStreamSourceVector& audioSources,  const MediaStreamSourceVector& videoSources) = 0;
-    virtual void cancelUserMediaRequest(UserMediaRequest*) = 0;
+    virtual void requestPermission(PassRefPtr<UserMediaRequest>) = 0;
+    virtual void cancelRequest(UserMediaRequest*) = 0;
 
 protected:
     virtual ~UserMediaClient() { }
index 67fc49f..4d15c98 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "Page.h"
 #include "UserMediaClient.h"
+#include "UserMediaRequest.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -38,8 +39,8 @@ public:
     ~UserMediaController();
 
     UserMediaClient* client() const { return m_client; }
-    void requestUserMedia(PassRefPtr<UserMediaRequest>, const MediaStreamSourceVector& audioSources,  const MediaStreamSourceVector& videoSources);
-    void cancelUserMediaRequest(UserMediaRequest*);
+    void requestPermission(PassRefPtr<UserMediaRequest>);
+    void cancelRequest(UserMediaRequest*);
 
     static PassOwnPtr<UserMediaController> create(UserMediaClient*);
     static const char* supplementName();
@@ -52,14 +53,14 @@ private:
     UserMediaClient* m_client;
 };
 
-inline void UserMediaController::requestUserMedia(PassRefPtr<UserMediaRequest> request, const MediaStreamSourceVector& audioSources,  const MediaStreamSourceVector& videoSources)
+inline void UserMediaController::requestPermission(PassRefPtr<UserMediaRequest> request)
 {
-    m_client->requestUserMedia(request, audioSources, videoSources);
+    m_client->requestPermission(request);
 }
 
-inline void UserMediaController::cancelUserMediaRequest(UserMediaRequest* request)
+inline void UserMediaController::cancelRequest(UserMediaRequest* request)
 {
-    m_client->cancelUserMediaRequest(request);
+    m_client->cancelRequest(request);
 }
 
 } // namespace WebCore
index a981b49..d880af3 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Ericsson AB. All rights reserved.
  * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "MediaStream.h"
 #include "MediaStreamCenter.h"
 #include "MediaStreamDescriptor.h"
-#include "SpaceSplitString.h"
+#include "SecurityOrigin.h"
 #include "UserMediaController.h"
 #include <wtf/Functional.h>
 #include <wtf/MainThread.h>
 
 namespace WebCore {
 
-static PassRefPtr<MediaConstraintsImpl> parseOptions(const Dictionary& options, const String& mediaType, ExceptionCode& ec)
+static PassRefPtr<MediaConstraints> parseOptions(const Dictionary& options, const String& mediaType, ExceptionCode& ec)
 {
-    RefPtr<MediaConstraintsImpl> constraints;
+    RefPtr<MediaConstraints> constraints;
 
     Dictionary constraintsDictionary;
     bool ok = options.get(mediaType, constraintsDictionary);
@@ -71,11 +72,11 @@ PassRefPtr<UserMediaRequest> UserMediaRequest::create(ScriptExecutionContext* co
 {
     ASSERT(successCallback);
 
-    RefPtr<MediaConstraintsImpl> audioConstraints = parseOptions(options, AtomicString("audio", AtomicString::ConstructFromLiteral), ec);
+    RefPtr<MediaConstraints> audioConstraints = parseOptions(options, AtomicString("audio", AtomicString::ConstructFromLiteral), ec);
     if (ec)
         return 0;
 
-    RefPtr<MediaConstraintsImpl> videoConstraints = parseOptions(options, AtomicString("video", AtomicString::ConstructFromLiteral), ec);
+    RefPtr<MediaConstraints> videoConstraints = parseOptions(options, AtomicString("video", AtomicString::ConstructFromLiteral), ec);
     if (ec)
         return 0;
 
@@ -85,7 +86,7 @@ PassRefPtr<UserMediaRequest> UserMediaRequest::create(ScriptExecutionContext* co
     return adoptRef(new UserMediaRequest(context, controller, audioConstraints.release(), videoConstraints.release(), successCallback, errorCallback));
 }
 
-UserMediaRequest::UserMediaRequest(ScriptExecutionContext* context, UserMediaController* controller, PassRefPtr<MediaConstraintsImpl> audioConstraints, PassRefPtr<MediaConstraintsImpl> videoConstraints, PassRefPtr<NavigatorUserMediaSuccessCallback> successCallback, PassRefPtr<NavigatorUserMediaErrorCallback> errorCallback)
+UserMediaRequest::UserMediaRequest(ScriptExecutionContext* context, UserMediaController* controller, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints, PassRefPtr<NavigatorUserMediaSuccessCallback> successCallback, PassRefPtr<NavigatorUserMediaErrorCallback> errorCallback)
     : ContextDestructionObserver(context)
     , m_audioConstraints(audioConstraints)
     , m_videoConstraints(videoConstraints)
@@ -99,87 +100,112 @@ UserMediaRequest::~UserMediaRequest()
 {
 }
 
-PassRefPtr<MediaConstraints> UserMediaRequest::audioConstraints() const
+SecurityOrigin* UserMediaRequest::securityOrigin() const
 {
-    return m_audioConstraints;
+    if (m_scriptExecutionContext)
+        return m_scriptExecutionContext->securityOrigin();
+    
+    return 0;
+}
+    
+void UserMediaRequest::start()
+{
+    // 1 - make sure the system is capable of supporting the audio and video constraints. We don't want to ask for
+    // user permission if the constraints can not be suported.
+    MediaStreamCenter::shared().validateRequestConstraints(this, m_audioConstraints, m_videoConstraints);
 }
 
-PassRefPtr<MediaConstraints> UserMediaRequest::videoConstraints() const
+    
+void UserMediaRequest::constraintsValidated()
 {
-    return m_videoConstraints;
+    if (m_controller)
+        callOnMainThread(bind(&UserMediaRequest::requestPermission, this));
 }
 
-Document* UserMediaRequest::ownerDocument()
+void UserMediaRequest::requestPermission()
 {
-    if (m_scriptExecutionContext)
-        return toDocument(m_scriptExecutionContext);
+    // 2 - The constraints are valid, ask the user for access to media.
+    if (m_controller)
+        m_controller->requestPermission(this);
+}
 
-    return 0;
+void UserMediaRequest::userMediaAccessGranted()
+{
+    callOnMainThread(bind(&UserMediaRequest::createMediaStream, this));
 }
 
-void UserMediaRequest::start()
+void UserMediaRequest::createMediaStream()
 {
-    MediaStreamCenter::instance().queryMediaStreamSources(this);
+    // 3 - the user granted access, ask platform to create the media stream descriptors.
+    MediaStreamCenter::shared().createMediaStream(this, m_audioConstraints, m_videoConstraints);
 }
 
-void UserMediaRequest::didCompleteQuery(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
+void UserMediaRequest::userMediaAccessDenied()
 {
-    if (m_controller)
-        m_controller->requestUserMedia(this, audioSources, videoSources);
+    failedToCreateStreamWithPermissionError();
 }
 
-void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescriptor)
+void UserMediaRequest::constraintsInvalid(const String& constraintName)
 {
-    if (!m_scriptExecutionContext)
+    failedToCreateStreamWithConstraintsError(constraintName);
+}
+
+void UserMediaRequest::didCreateStream(PassRefPtr<MediaStreamDescriptor> streamDescriptor)
+{
+    if (!m_scriptExecutionContext || !m_successCallback)
         return;
 
+    callOnMainThread(bind(&UserMediaRequest::callSuccessHandler, this, streamDescriptor));
+}
+
+void UserMediaRequest::callSuccessHandler(PassRefPtr<MediaStreamDescriptor> streamDescriptor)
+{
+    // 4 - Create the MediaStream and pass it to the success callback.
+    ASSERT(m_successCallback);
+
     RefPtr<MediaStream> stream = MediaStream::create(m_scriptExecutionContext, streamDescriptor);
 
     MediaStreamTrackVector tracks = stream->getAudioTracks();
     for (MediaStreamTrackVector::iterator iter = tracks.begin(); iter != tracks.end(); ++iter)
-        (*iter)->component()->source()->setConstraints(m_audioConstraints);
+        (*iter)->source()->setConstraints(m_audioConstraints);
 
     tracks = stream->getVideoTracks();
     for (MediaStreamTrackVector::iterator iter = tracks.begin(); iter != tracks.end(); ++iter)
-        (*iter)->component()->source()->setConstraints(m_videoConstraints);
+        (*iter)->source()->setConstraints(m_videoConstraints);
 
+    MediaStreamCenter::shared().didCreateMediaStream(streamDescriptor.get());
     m_successCallback->handleEvent(stream.get());
 }
 
-void UserMediaRequest::permissionFailure()
+void UserMediaRequest::failedToCreateStreamWithConstraintsError(const String& constraintName)
 {
+    ASSERT(!constraintName.isEmpty());
     if (!m_scriptExecutionContext)
         return;
 
     if (!m_errorCallback)
         return;
-    
-    RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::permissionDeniedErrorName(), emptyString());
+
+    RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::constraintNotSatisfiedErrorName(), constraintName);
     callOnMainThread(bind(&UserMediaRequest::callErrorHandler, this, error.release()));
 }
 
-void UserMediaRequest::constraintFailure(const String& constraintName)
+void UserMediaRequest::failedToCreateStreamWithPermissionError()
 {
-    ASSERT(!constraintName.isEmpty());
     if (!m_scriptExecutionContext)
         return;
-    
+
     if (!m_errorCallback)
         return;
 
-    RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::constraintNotSatisfiedErrorName(), constraintName);
+    RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(NavigatorUserMediaError::permissionDeniedErrorName(), emptyString());
     callOnMainThread(bind(&UserMediaRequest::callErrorHandler, this, error.release()));
 }
 
-void UserMediaRequest::callSuccessHandler(PassRefPtr<MediaStream> stream)
+void UserMediaRequest::callErrorHandler(PassRefPtr<NavigatorUserMediaError> prpError)
 {
-    ASSERT(m_successCallback);
-    
-    m_successCallback->handleEvent(stream.get());
-}
+    RefPtr<NavigatorUserMediaError> error = prpError;
 
-void UserMediaRequest::callErrorHandler(PassRefPtr<NavigatorUserMediaError> error)
-{
     ASSERT(error);
     
     m_errorCallback->handleEvent(error.get());
@@ -190,7 +216,7 @@ void UserMediaRequest::contextDestroyed()
     Ref<UserMediaRequest> protect(*this);
 
     if (m_controller) {
-        m_controller->cancelUserMediaRequest(this);
+        m_controller->cancelRequest(this);
         m_controller = 0;
     }
 
index 0dd03d3..3cfeef7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #if ENABLE(MEDIA_STREAM)
 
 #include "ActiveDOMObject.h"
-#include "ExceptionBase.h"
+#include "MediaStreamCreationClient.h"
 #include "MediaStreamSource.h"
-#include "MediaStreamSourcesQueryClient.h"
 #include "NavigatorUserMediaErrorCallback.h"
 #include "NavigatorUserMediaSuccessCallback.h"
 #include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -47,38 +48,43 @@ namespace WebCore {
 class Dictionary;
 class Document;
 class MediaConstraints;
-class MediaConstraintsImpl;
 class MediaStreamDescriptor;
 class UserMediaController;
+class SecurityOrigin;
 
-class UserMediaRequest : public MediaStreamSourcesQueryClient, public ContextDestructionObserver {
+typedef int ExceptionCode;
+
+class UserMediaRequest : public MediaStreamCreationClient, public ContextDestructionObserver {
 public:
     static PassRefPtr<UserMediaRequest> create(ScriptExecutionContext*, UserMediaController*, const Dictionary& options, PassRefPtr<NavigatorUserMediaSuccessCallback>, PassRefPtr<NavigatorUserMediaErrorCallback>, ExceptionCode&);
     ~UserMediaRequest();
 
-    Document* ownerDocument();
+    SecurityOrigin* securityOrigin() const;
 
     void start();
-    void succeed(PassRefPtr<MediaStreamDescriptor>);
-    void permissionFailure();
-    void constraintFailure(const String& constraintName);
-
-    // MediaStreamSourcesQueryClient
-    virtual PassRefPtr<MediaConstraints> audioConstraints() const OVERRIDE;
-    virtual PassRefPtr<MediaConstraints> videoConstraints() const OVERRIDE;
-    virtual void didCompleteQuery(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources) OVERRIDE;
-
-    // ContextDestructionObserver
-    virtual void contextDestroyed();
+    void userMediaAccessGranted();
+    void userMediaAccessDenied();
 
 private:
-    UserMediaRequest(ScriptExecutionContext*, UserMediaController*, PassRefPtr<MediaConstraintsImpl> audioConstraints, PassRefPtr<MediaConstraintsImpl> videoConstraints, PassRefPtr<NavigatorUserMediaSuccessCallback>, PassRefPtr<NavigatorUserMediaErrorCallback>);
+    UserMediaRequest(ScriptExecutionContext*, UserMediaController*, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints, PassRefPtr<NavigatorUserMediaSuccessCallback>, PassRefPtr<NavigatorUserMediaErrorCallback>);
+
+    // MediaStreamCreationClient
+    virtual void constraintsValidated() OVERRIDE FINAL;
+    virtual void constraintsInvalid(const String& constraintName) OVERRIDE FINAL;
+    virtual void didCreateStream(PassRefPtr<MediaStreamDescriptor>) OVERRIDE FINAL;
+    virtual void failedToCreateStreamWithConstraintsError(const String& constraintName) OVERRIDE FINAL;
+    virtual void failedToCreateStreamWithPermissionError() OVERRIDE FINAL;
 
-    void callSuccessHandler(PassRefPtr<MediaStream>);
+    // ContextDestructionObserver
+    virtual void contextDestroyed() OVERRIDE FINAL;
+    
+    void callSuccessHandler(PassRefPtr<MediaStreamDescriptor>);
     void callErrorHandler(PassRefPtr<NavigatorUserMediaError>);
+    void requestPermission();
+    void createMediaStream();
 
-    RefPtr<MediaConstraintsImpl> m_audioConstraints;
-    RefPtr<MediaConstraintsImpl> m_videoConstraints;
+    RefPtr<MediaConstraints> m_audioConstraints;
+    RefPtr<MediaConstraints> m_videoConstraints;
 
     UserMediaController* m_controller;
 
index a2e3e22..aab309b 100644 (file)
@@ -421,7 +421,7 @@ PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med
     // FIXME: get a provider for non-local MediaStreams (like from a remote peer).
     for (size_t i = 0; i < audioTracks.size(); ++i) {
         RefPtr<MediaStreamTrack> localAudio = audioTracks[i];
-        MediaStreamSource* source = localAudio->component()->source();
+        MediaStreamSource* source = localAudio->source();
         if (!source->deviceId().isEmpty()) {
             destination()->enableInput(source->deviceId());
             provider = destination()->localAudioInputProvider();
index d57beb8..80485fd 100644 (file)
@@ -49,12 +49,12 @@ MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext* c
 {
     setNodeType(NodeTypeMediaStreamAudioDestination);
 
-    m_source = MediaStreamSource::create(ASCIILiteral("WebAudio-") + createCanonicalUUIDString(), MediaStreamSource::TypeAudio, "MediaStreamAudioDestinationNode", MediaStreamSource::ReadyStateLive, true);
+    m_source = MediaStreamSource::create(ASCIILiteral("WebAudio-") + createCanonicalUUIDString(), MediaStreamSource::Audio, "MediaStreamAudioDestinationNode", MediaStreamSource::Live, true);
     MediaStreamSourceVector audioSources;
     audioSources.append(m_source);
     MediaStreamSourceVector videoSources;
     m_stream = MediaStream::create(context->scriptExecutionContext(), MediaStreamDescriptor::create(audioSources, videoSources));
-    MediaStreamCenter::instance().didCreateMediaStream(m_stream->descriptor());
+    MediaStreamCenter::shared().didCreateMediaStream(m_stream->descriptor());
 
     m_source->setAudioFormat(numberOfChannels, context->sampleRate());
 
index 41e04b8..5aa9e18 100644 (file)
@@ -2799,3 +2799,10 @@ _wkIsPublicSuffix
 __ZN7WebCore15ResourceRequest13partitionNameERKN3WTF6StringE
 _wkCachePartitionKey
 #endif
+
+#if ENABLE(MEDIA_STREAM)
+__ZN7WebCore16UserMediaRequest22userMediaAccessGrantedEv
+__ZN7WebCore16UserMediaRequest21userMediaAccessDeniedEv
+__ZN7WebCore18provideUserMediaToEPNS_4PageEPNS_15UserMediaClientE
+__ZNK7WebCore16UserMediaRequest14securityOriginEv
+#endif
index 2c7944e..5340b51 100644 (file)
@@ -95,7 +95,8 @@
                070756DF14239B4E00414161 /* JSTextTrackCueList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 070756D914239B4C00414161 /* JSTextTrackCueList.cpp */; };
                070756E014239B4E00414161 /* JSTextTrackCueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 070756DA14239B4E00414161 /* JSTextTrackCueList.h */; };
                0709FC4E1025DEE30059CDBA /* AccessibilitySlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */; };
-               0711589017DF6F6200EDFE2B /* MediaStreamComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0711588E17DF633700EDFE2B /* MediaStreamComponent.cpp */; };
+               070F549817F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 070F549717F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h */; };
+               070F549E17F2402700169E04 /* AudioDestinationConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 070F549D17F2402700169E04 /* AudioDestinationConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0711589117DF6F6600EDFE2B /* MediaStreamDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0711588F17DF633700EDFE2B /* MediaStreamDescriptor.cpp */; };
                071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */; };
                071A9EC3168FBC55002629F9 /* TextTrackCueGeneric.h in Headers */ = {isa = PBXBuildFile; fileRef = 071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E093217D1684600420AA1 /* MediaStreamCenterMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0729B14F17CFCCA0004F1D60 /* MediaStreamCenterMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E093317D16B0600420AA1 /* MediaStreamCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B9A17CF0AD400848E51 /* MediaStreamCenter.cpp */; };
                078E093417D16B0B00420AA1 /* MediaStreamCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B9B17CF0AD400848E51 /* MediaStreamCenter.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               078E093517D16B2100420AA1 /* MediaStreamComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B9C17CF0AD400848E51 /* MediaStreamComponent.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E093617D16B2100420AA1 /* MediaStreamSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B9E17CF0AD400848E51 /* MediaStreamSource.cpp */; };
                078E093717D16B2C00420AA1 /* MediaStreamDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B9D17CF0AD400848E51 /* MediaStreamDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E093817D16B2C00420AA1 /* MediaStreamSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B9F17CF0AD400848E51 /* MediaStreamSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               078E093917D16B2C00420AA1 /* MediaStreamSourcesQueryClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221BA017CF0AD400848E51 /* MediaStreamSourcesQueryClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               078E093917D16B2C00420AA1 /* MediaStreamCreationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221BA017CF0AD400848E51 /* MediaStreamCreationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E093A17D16E1C00420AA1 /* MediaConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B9917CF0AD400848E51 /* MediaConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E093B17D16E1C00420AA1 /* RTCConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221BA117CF0AD400848E51 /* RTCConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E093C17D16E1C00420AA1 /* RTCDataChannelHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221BA217CF0AD400848E51 /* RTCDataChannelHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
                070756DA14239B4E00414161 /* JSTextTrackCueList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCueList.h; sourceTree = "<group>"; };
                0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySlider.h; sourceTree = "<group>"; };
                070DD8F50F01868000727DEB /* mediaControls.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mediaControls.css; sourceTree = "<group>"; };
-               0711588E17DF633700EDFE2B /* MediaStreamComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamComponent.cpp; sourceTree = "<group>"; };
+               070F549717F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamConstraintsValidationClient.h; sourceTree = "<group>"; };
+               070F549D17F2402700169E04 /* AudioDestinationConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioDestinationConsumer.h; sourceTree = "<group>"; };
                0711588F17DF633700EDFE2B /* MediaStreamDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamDescriptor.cpp; sourceTree = "<group>"; };
                071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackCueGeneric.cpp; sourceTree = "<group>"; };
                071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackCueGeneric.h; sourceTree = "<group>"; };
                07221B9917CF0AD400848E51 /* MediaConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaConstraints.h; sourceTree = "<group>"; };
                07221B9A17CF0AD400848E51 /* MediaStreamCenter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamCenter.cpp; sourceTree = "<group>"; };
                07221B9B17CF0AD400848E51 /* MediaStreamCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamCenter.h; sourceTree = "<group>"; };
-               07221B9C17CF0AD400848E51 /* MediaStreamComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamComponent.h; sourceTree = "<group>"; };
                07221B9D17CF0AD400848E51 /* MediaStreamDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamDescriptor.h; sourceTree = "<group>"; };
                07221B9E17CF0AD400848E51 /* MediaStreamSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamSource.cpp; sourceTree = "<group>"; };
                07221B9F17CF0AD400848E51 /* MediaStreamSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamSource.h; sourceTree = "<group>"; };
-               07221BA017CF0AD400848E51 /* MediaStreamSourcesQueryClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamSourcesQueryClient.h; sourceTree = "<group>"; };
+               07221BA017CF0AD400848E51 /* MediaStreamCreationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamCreationClient.h; sourceTree = "<group>"; };
                07221BA117CF0AD400848E51 /* RTCConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCConfiguration.h; sourceTree = "<group>"; };
                07221BA217CF0AD400848E51 /* RTCDataChannelHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCDataChannelHandler.h; sourceTree = "<group>"; };
                07221BA317CF0AD400848E51 /* RTCDataChannelHandlerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCDataChannelHandlerClient.h; sourceTree = "<group>"; };
                                07221B9917CF0AD400848E51 /* MediaConstraints.h */,
                                07221B9A17CF0AD400848E51 /* MediaStreamCenter.cpp */,
                                07221B9B17CF0AD400848E51 /* MediaStreamCenter.h */,
-                               0711588E17DF633700EDFE2B /* MediaStreamComponent.cpp */,
-                               07221B9C17CF0AD400848E51 /* MediaStreamComponent.h */,
+                               070F549717F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h */,
+                               07221BA017CF0AD400848E51 /* MediaStreamCreationClient.h */,
                                0711588F17DF633700EDFE2B /* MediaStreamDescriptor.cpp */,
                                07221B9D17CF0AD400848E51 /* MediaStreamDescriptor.h */,
                                07221B9E17CF0AD400848E51 /* MediaStreamSource.cpp */,
                                07221B9F17CF0AD400848E51 /* MediaStreamSource.h */,
-                               07221BA017CF0AD400848E51 /* MediaStreamSourcesQueryClient.h */,
                                076306E217E22A43005A7C4E /* MediaStreamTrackSourcesRequestClient.h */,
                                07221BA117CF0AD400848E51 /* RTCConfiguration.h */,
                                07221BA217CF0AD400848E51 /* RTCDataChannelHandler.h */,
                                FD31604712B026F700C1A359 /* AudioChannel.cpp */,
                                FD31604812B026F700C1A359 /* AudioChannel.h */,
                                FD31604912B026F700C1A359 /* AudioDestination.h */,
+                               070F549D17F2402700169E04 /* AudioDestinationConsumer.h */,
                                FD31604A12B026F700C1A359 /* AudioDSPKernel.h */,
                                FD31604B12B026F700C1A359 /* AudioDSPKernelProcessor.cpp */,
                                FD31604C12B026F700C1A359 /* AudioDSPKernelProcessor.h */,
                                FD31607E12B026F700C1A359 /* AudioChannel.h in Headers */,
                                FD31600512B0267600C1A359 /* AudioContext.h in Headers */,
                                FD31607F12B026F700C1A359 /* AudioDestination.h in Headers */,
+                               070F549E17F2402700169E04 /* AudioDestinationConsumer.h in Headers */,
                                FD3160BD12B0272A00C1A359 /* AudioDestinationMac.h in Headers */,
                                FD31600812B0267600C1A359 /* AudioDestinationNode.h in Headers */,
                                FD31608012B026F700C1A359 /* AudioDSPKernel.h in Headers */,
                                BC5A12E00DC0414800C9AFAD /* CSSReflectValue.h in Headers */,
                                A80E6D0D0A1989CA007FB8C5 /* CSSRule.h in Headers */,
                                A80E6CF20A1989CA007FB8C5 /* CSSRuleList.h in Headers */,
+                               070F549817F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h in Headers */,
                                371F51A10D262FA000ECE0D5 /* CSSSegmentedFontFace.h in Headers */,
                                A80E73520A199C77007FB8C5 /* CSSSelector.h in Headers */,
                                E4C1789B0EE6903800824D69 /* CSSSelectorList.h in Headers */,
                                858C38A50AA8F20400B187A4 /* DOMCounter.h in Headers */,
                                85E711910AC5D5350053270F /* DOMCounterInternal.h in Headers */,
                                BC1A37B0097C715F0019F3D8 /* DOMCSS.h in Headers */,
-                               078E093917D16B2C00420AA1 /* MediaStreamSourcesQueryClient.h in Headers */,
+                               078E093917D16B2C00420AA1 /* MediaStreamCreationClient.h in Headers */,
                                85032DD70AA8C9BE007D3B7D /* DOMCSSCharsetRule.h in Headers */,
                                85909CDC0ACC7A7E00DF01F1 /* DOMCSSCharsetRuleInternal.h in Headers */,
                                85032DD90AA8C9BE007D3B7D /* DOMCSSFontFaceRule.h in Headers */,
                                B2227A210D00BF220071B782 /* SVGFontFaceUriElement.h in Headers */,
                                B2227A240D00BF220071B782 /* SVGForeignObjectElement.h in Headers */,
                                B2227A270D00BF220071B782 /* SVGGElement.h in Headers */,
-                               078E093517D16B2100420AA1 /* MediaStreamComponent.h in Headers */,
                                087E0AF713606D0B00FA4BA8 /* SVGGlyph.h in Headers */,
                                B2A1F2AE0CEF0ABF00442F6A /* SVGGlyphElement.h in Headers */,
                                3744570F0DB05FA500AE0992 /* SVGGlyphMap.h in Headers */,
                                D3AA10F3123A98AA0092152B /* MediaQueryMatcher.cpp in Sources */,
                                CD61FE671794AADB004101EB /* MediaSourceRegistry.cpp in Sources */,
                                FD671A77159BB07000197559 /* MediaStreamAudioSourceNode.cpp in Sources */,
-                               0711589017DF6F6200EDFE2B /* MediaStreamComponent.cpp in Sources */,
                                0711589117DF6F6600EDFE2B /* MediaStreamDescriptor.cpp in Sources */,
                                BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */,
                                657EDA081385CB97004E0645 /* MemoryPressureHandler.cpp in Sources */,
index aa56402..d2c34b3 100644 (file)
@@ -240,6 +240,7 @@ namespace WebCore {
     macro(removetrack) \
     macro(mute) \
     macro(unmute) \
+    macro(started) \
     macro(iceconnectionstatechange) \
     macro(icecandidate) \
     macro(negotiationneeded) \
index 2121ce2..f24f3db 100644 (file)
 
 namespace WebCore {
 
+static MediaStreamCenter*& mediaStreamCenterOverride()
+{
+    static MediaStreamCenter* override;
+    return override;
+}
+
+MediaStreamCenter& MediaStreamCenter::shared()
+{
+    MediaStreamCenter* override = mediaStreamCenterOverride();
+    if (override)
+        return *override;
+    
+    return MediaStreamCenter::platformCenter();
+}
+
+void MediaStreamCenter::setSharedStreamCenter(MediaStreamCenter* center)
+{
+    mediaStreamCenterOverride() = center;
+}
+
 MediaStreamCenter::MediaStreamCenter()
 {
 }
@@ -49,11 +69,7 @@ MediaStreamCenter::~MediaStreamCenter()
 
 void MediaStreamCenter::endLocalMediaStream(MediaStreamDescriptor* streamDescriptor)
 {
-    MediaStreamDescriptorClient* client = streamDescriptor->client();
-    if (client)
-        client->streamEnded();
-    else
-        streamDescriptor->setEnded();
+    streamDescriptor->setEnded();
 }
 
 } // namespace WebCore
index a08e635..82c2e3b 100644 (file)
 
 namespace WebCore {
 
-class MediaStreamComponent;
+class MediaConstraints;
+class MediaStreamCreationClient;
+class MediaStreamCreationClient;
 class MediaStreamDescriptor;
-class MediaStreamSourcesQueryClient;
+class MediaStreamSource;
 class MediaStreamTrackSourcesRequestClient;
 
 class MediaStreamCenter {
 public:
     virtual ~MediaStreamCenter();
 
-    static MediaStreamCenter& instance();
+    static MediaStreamCenter& shared();
+    static void setSharedStreamCenter(MediaStreamCenter*);
 
-    virtual void queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient>) = 0;
+    virtual void validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints) = 0;
+
+    virtual void createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints) = 0;
 
-    // Calls from the DOM objects to notify the platform
     virtual bool getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>) = 0;
-    virtual void didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*) = 0;
-    virtual bool didAddMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) = 0;
-    virtual bool didRemoveMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) = 0;
+
+    virtual void didSetMediaStreamTrackEnabled(MediaStreamSource*) = 0;
+
+    virtual bool didAddMediaStreamTrack(MediaStreamSource*) = 0;
+    virtual bool didRemoveMediaStreamTrack(MediaStreamSource*) = 0;
+
     virtual void didStopLocalMediaStream(MediaStreamDescriptor*) = 0;
     virtual void didCreateMediaStream(MediaStreamDescriptor*) = 0;
 
@@ -64,6 +71,7 @@ protected:
     MediaStreamCenter();
 
     void endLocalMediaStream(MediaStreamDescriptor*);
+    static MediaStreamCenter& platformCenter();
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/platform/mediastream/MediaStreamComponent.cpp b/Source/WebCore/platform/mediastream/MediaStreamComponent.cpp
deleted file mode 100644 (file)
index dccbaac..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 Ericsson AB. All rights reserved.
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "MediaStreamComponent.h"
-
-#include "MediaStreamSource.h"
-#include "UUID.h"
-
-namespace WebCore {
-
-PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(PassRefPtr<MediaStreamSource> source)
-{
-    return adoptRef(new MediaStreamComponent(createCanonicalUUIDString(), 0, source));
-}
-
-PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(MediaStreamDescriptor* stream, PassRefPtr<MediaStreamSource> source)
-{
-    return adoptRef(new MediaStreamComponent(createCanonicalUUIDString(), stream, source));
-}
-
-MediaStreamComponent::MediaStreamComponent(const String& id, MediaStreamDescriptor* stream, PassRefPtr<MediaStreamSource> source)
-    : m_stream(stream)
-    , m_source(source)
-    , m_id(id)
-    , m_enabled(true)
-{
-    ASSERT(m_id.length());
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
diff --git a/Source/WebCore/platform/mediastream/MediaStreamComponent.h b/Source/WebCore/platform/mediastream/MediaStreamComponent.h
deleted file mode 100644 (file)
index 3ff6ed6..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 Ericsson AB. All rights reserved.
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer
- *    in the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of Ericsson nor the names of its contributors
- *    may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MediaStreamComponent_h
-#define MediaStreamComponent_h
-
-#if ENABLE(MEDIA_STREAM)
-
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class MediaStreamDescriptor;
-class MediaStreamSource;
-
-class MediaStreamComponent : public RefCounted<MediaStreamComponent> {
-public:
-    static PassRefPtr<MediaStreamComponent> create(PassRefPtr<MediaStreamSource>);
-    static PassRefPtr<MediaStreamComponent> create(MediaStreamDescriptor*, PassRefPtr<MediaStreamSource>);
-
-    MediaStreamDescriptor* stream() const { return m_stream; }
-    void setStream(MediaStreamDescriptor* stream) { ASSERT(!m_stream && stream); m_stream = stream; }
-
-    MediaStreamSource* source() const { return m_source.get(); }
-
-    String id() const { return m_id; }
-    bool enabled() const { return m_enabled; }
-    void setEnabled(bool enabled) { m_enabled = enabled; }
-
-private:
-    MediaStreamComponent(const String& id, MediaStreamDescriptor*, PassRefPtr<MediaStreamSource>);
-
-    MediaStreamDescriptor* m_stream;
-    RefPtr<MediaStreamSource> m_source;
-    String m_id;
-    bool m_enabled;
-};
-
-typedef Vector<RefPtr<MediaStreamComponent> > MediaStreamComponentVector;
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
-
-#endif // MediaStreamComponent_h
diff --git a/Source/WebCore/platform/mediastream/MediaStreamConstraintsValidationClient.h b/Source/WebCore/platform/mediastream/MediaStreamConstraintsValidationClient.h
new file mode 100644 (file)
index 0000000..5787058
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaStreamConstraintsValidationClient_h
+#define MediaStreamConstraintsValidationClient_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "MediaStreamSource.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class MediaConstraints;
+
+class MediaStreamConstraintsValidationClient : public RefCounted<MediaStreamConstraintsValidationClient> {
+public:
+    virtual ~MediaStreamConstraintsValidationClient() { }
+
+    virtual void constraintsAreValid() = 0;
+    virtual void constraintsInvalid(const String& constraintName) = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MediaStreamConstraintsValidationClient_h
diff --git a/Source/WebCore/platform/mediastream/MediaStreamCreationClient.h b/Source/WebCore/platform/mediastream/MediaStreamCreationClient.h
new file mode 100644 (file)
index 0000000..3eb92fc
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaStreamCreationClient_h
+#define MediaStreamCreationClient_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "MediaStreamSource.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class MediaStreamCreationClient : public RefCounted<MediaStreamCreationClient> {
+public:
+    virtual ~MediaStreamCreationClient() { }
+
+    virtual void constraintsValidated() = 0;
+    virtual void constraintsInvalid(const String& constraintName) = 0;
+
+    virtual void didCreateStream(PassRefPtr<MediaStreamDescriptor>) = 0;
+    virtual void failedToCreateStreamWithConstraintsError(const String& constraintName) = 0;
+    virtual void failedToCreateStreamWithPermissionError() = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MediaStreamCreationClient_h
index 46d41ac..3dd9bfd 100644 (file)
@@ -47,56 +47,51 @@ PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStrea
     return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audioSources, videoSources));
 }
 
-PassRefPtr<MediaStreamDescriptor> MediaStreamDescriptor::create(const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents)
+void MediaStreamDescriptor::addSource(PassRefPtr<MediaStreamSource> source)
 {
-    return adoptRef(new MediaStreamDescriptor(createCanonicalUUIDString(), audioComponents, videoComponents));
-}
-
-void MediaStreamDescriptor::addComponent(PassRefPtr<MediaStreamComponent> component)
-{
-    switch (component->source()->type()) {
-    case MediaStreamSource::TypeAudio:
-        if (m_audioComponents.find(component) == notFound)
-            m_audioComponents.append(component);
+    switch (source->type()) {
+    case MediaStreamSource::Audio:
+        if (m_audioStreamSources.find(source) == notFound)
+            m_audioStreamSources.append(source);
         break;
-    case MediaStreamSource::TypeVideo:
-        if (m_videoComponents.find(component) == notFound)
-            m_videoComponents.append(component);
+    case MediaStreamSource::Video:
+        if (m_videoStreamSources.find(source) == notFound)
+            m_videoStreamSources.append(source);
         break;
     }
 }
 
-void MediaStreamDescriptor::removeComponent(PassRefPtr<MediaStreamComponent> component)
+void MediaStreamDescriptor::removeSource(PassRefPtr<MediaStreamSource> source)
 {
     size_t pos = notFound;
-    switch (component->source()->type()) {
-    case MediaStreamSource::TypeAudio:
-        pos = m_audioComponents.find(component);
+    switch (source->type()) {
+    case MediaStreamSource::Audio:
+        pos = m_audioStreamSources.find(source);
         if (pos != notFound)
-            m_audioComponents.remove(pos);
+            m_audioStreamSources.remove(pos);
         break;
-    case MediaStreamSource::TypeVideo:
-        pos = m_videoComponents.find(component);
+    case MediaStreamSource::Video:
+        pos = m_videoStreamSources.find(source);
         if (pos != notFound)
-            m_videoComponents.remove(pos);
+            m_videoStreamSources.remove(pos);
         break;
     }
 }
 
-void MediaStreamDescriptor::addRemoteTrack(MediaStreamComponent* component)
+void MediaStreamDescriptor::addRemoteSource(MediaStreamSource* source)
 {
     if (m_client)
-        m_client->addRemoteTrack(component);
+        m_client->addRemoteSource(source);
     else
-        addComponent(component);
+        addSource(source);
 }
 
-void MediaStreamDescriptor::removeRemoteTrack(MediaStreamComponent* component)
+void MediaStreamDescriptor::removeRemoteSource(MediaStreamSource* source)
 {
     if (m_client)
-        m_client->removeRemoteTrack(component);
+        m_client->removeRemoteSource(source);
     else
-        removeComponent(component);
+        removeSource(source);
 }
 
 MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
@@ -105,27 +100,26 @@ MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStream
     , m_ended(false)
 {
     ASSERT(m_id.length());
-    for (size_t i = 0; i < audioSources.size(); i++)
-        m_audioComponents.append(MediaStreamComponent::create(this, audioSources[i]));
+    for (size_t i = 0; i < audioSources.size(); i++) {
+        audioSources[i]->setStream(this);
+        m_audioStreamSources.append(audioSources[i]);
+    }
 
-    for (size_t i = 0; i < videoSources.size(); i++)
-        m_videoComponents.append(MediaStreamComponent::create(this, videoSources[i]));
+    for (size_t i = 0; i < videoSources.size(); i++) {
+        videoSources[i]->setStream(this);
+        m_videoStreamSources.append(videoSources[i]);
+    }
 }
 
-MediaStreamDescriptor::MediaStreamDescriptor(const String& id, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents)
-    : m_client(0)
-    , m_id(id)
-    , m_ended(false)
+void MediaStreamDescriptor::setEnded()
 {
-    ASSERT(m_id.length());
-    for (MediaStreamComponentVector::const_iterator iter = audioComponents.begin(); iter != audioComponents.end(); ++iter) {
-        (*iter)->setStream(this);
-        m_audioComponents.append((*iter));
-    }
-    for (MediaStreamComponentVector::const_iterator iter = videoComponents.begin(); iter != videoComponents.end(); ++iter) {
-        (*iter)->setStream(this);
-        m_videoComponents.append((*iter));
-    }
+    if (m_client)
+        m_client->streamDidEnd();
+    m_ended = true;
+    for (size_t i = 0; i < m_audioStreamSources.size(); i++)
+        m_audioStreamSources[i]->setReadyState(MediaStreamSource::Ended);
+    for (size_t i = 0; i < m_videoStreamSources.size(); i++)
+        m_videoStreamSources[i]->setReadyState(MediaStreamSource::Ended);
 }
 
 } // namespace WebCore
index 8500f62..b623e59 100644 (file)
@@ -34,9 +34,7 @@
 
 #if ENABLE(MEDIA_STREAM)
 
-#include "MediaStreamComponent.h"
 #include "MediaStreamSource.h"
-#include "UUID.h"
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
@@ -46,56 +44,45 @@ class MediaStreamDescriptorClient {
 public:
     virtual ~MediaStreamDescriptorClient() { }
 
-    virtual void trackEnded() = 0;
-    virtual void streamEnded() = 0;
-    virtual void addRemoteTrack(MediaStreamComponent*) = 0;
-    virtual void removeRemoteTrack(MediaStreamComponent*) = 0;
+    virtual void trackDidEnd() = 0;
+    virtual void streamDidEnd() = 0;
+    virtual void addRemoteSource(MediaStreamSource*) = 0;
+    virtual void removeRemoteSource(MediaStreamSource*) = 0;
 };
 
 class MediaStreamDescriptor : public RefCounted<MediaStreamDescriptor> {
 public:
-    class ExtraData : public RefCounted<ExtraData> {
-    public:
-        virtual ~ExtraData() { }
-    };
 
     static PassRefPtr<MediaStreamDescriptor> create(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources);
-    static PassRefPtr<MediaStreamDescriptor> create(const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents);
 
     MediaStreamDescriptorClient* client() const { return m_client; }
     void setClient(MediaStreamDescriptorClient* client) { m_client = client; }
 
     String id() const { return m_id; }
 
-    unsigned numberOfAudioComponents() const { return m_audioComponents.size(); }
-    MediaStreamComponent* audioComponent(unsigned index) const { return m_audioComponents[index].get(); }
+    unsigned numberOfAudioStreams() const { return m_audioStreamSources.size(); }
+    MediaStreamSource* audioStreams(unsigned index) const { return m_audioStreamSources[index].get(); }
 
-    unsigned numberOfVideoComponents() const { return m_videoComponents.size(); }
-    MediaStreamComponent* videoComponent(unsigned index) const { return m_videoComponents[index].get(); }
+    unsigned numberOfVideoStreams() const { return m_videoStreamSources.size(); }
+    MediaStreamSource* videoStreams(unsigned index) const { return m_videoStreamSources[index].get(); }
 
-    void addComponent(PassRefPtr<MediaStreamComponent>);
-    void removeComponent(PassRefPtr<MediaStreamComponent>);
+    void addSource(PassRefPtr<MediaStreamSource>);
+    void removeSource(PassRefPtr<MediaStreamSource>);
 
-    void addRemoteTrack(MediaStreamComponent*);
-    void removeRemoteTrack(MediaStreamComponent*);
+    void addRemoteSource(MediaStreamSource*);
+    void removeRemoteSource(MediaStreamSource*);
 
     bool ended() const { return m_ended; }
-    void setEnded() { m_ended = true; }
-
-    PassRefPtr<ExtraData> extraData() const { return m_extraData; }
-    void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData; }
+    void setEnded();
 
 private:
     MediaStreamDescriptor(const String& id, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources);
-    MediaStreamDescriptor(const String& id, const MediaStreamComponentVector& audioComponents, const MediaStreamComponentVector& videoComponents);
 
     MediaStreamDescriptorClient* m_client;
     String m_id;
-    Vector<RefPtr<MediaStreamComponent> > m_audioComponents;
-    Vector<RefPtr<MediaStreamComponent> > m_videoComponents;
+    Vector<RefPtr<MediaStreamSource> > m_audioStreamSources;
+    Vector<RefPtr<MediaStreamSource> > m_videoStreamSources;
     bool m_ended;
-
-    RefPtr<ExtraData> m_extraData;
 };
 
 typedef Vector<RefPtr<MediaStreamDescriptor> > MediaStreamDescriptorVector;
index 904f554..caea8ca 100644 (file)
@@ -33,6 +33,8 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "MediaStreamSource.h"
+
+#include "AudioDestinationConsumer.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -47,17 +49,21 @@ MediaStreamSource::MediaStreamSource(const String& id, Type type, const String&
     , m_type(type)
     , m_name(name)
     , m_readyState(readyState)
+    , m_stream(0)
     , m_requiresConsumer(requiresConsumer)
+    , m_enabled(true)
+    , m_muted(false)
 {
 }
 
 void MediaStreamSource::setReadyState(ReadyState readyState)
 {
-    if (m_readyState != ReadyStateEnded && m_readyState != readyState) {
-        m_readyState = readyState;
-        for (Vector<Observer*>::iterator i = m_observers.begin(); i != m_observers.end(); ++i)
-            (*i)->sourceChangedState();
-    }
+    if (m_readyState == Ended || m_readyState == readyState)
+        return;
+
+    m_readyState = readyState;
+    for (Vector<Observer*>::iterator i = m_observers.begin(); i != m_observers.end(); ++i)
+        (*i)->sourceChangedState();
 }
 
 void MediaStreamSource::addObserver(MediaStreamSource::Observer* observer)
@@ -72,6 +78,22 @@ void MediaStreamSource::removeObserver(MediaStreamSource::Observer* observer)
         m_observers.remove(pos);
 }
 
+void MediaStreamSource::setStream(MediaStreamDescriptor* stream)
+{
+    ASSERT(!m_stream && stream);
+    m_stream = stream;
+}
+
+void MediaStreamSource::setMuted(bool muted)
+{
+    if (m_muted == muted)
+        return;
+
+    m_muted = muted;
+    for (Vector<Observer*>::iterator i = m_observers.begin(); i != m_observers.end(); ++i)
+        (*i)->sourceChangedState();
+}
+
 void MediaStreamSource::addAudioConsumer(PassRefPtr<AudioDestinationConsumer> consumer)
 {
     ASSERT(m_requiresConsumer);
index 0ed26b1..74f59a5 100644 (file)
@@ -42,6 +42,9 @@
 
 namespace WebCore {
 
+class AudioBus;
+class MediaStreamDescriptor;
+
 class MediaStreamSource : public RefCounted<MediaStreamSource> {
 public:
     class Observer {
@@ -50,25 +53,13 @@ public:
         virtual void sourceChangedState() = 0;
     };
 
-    class ExtraData : public RefCounted<ExtraData> {
-    public:
-        virtual ~ExtraData() { }
-    };
-
-    enum Type {
-        TypeAudio,
-        TypeVideo
-    };
-
-    enum ReadyState {
-        ReadyStateLive = 0,
-        ReadyStateMuted = 1,
-        ReadyStateEnded = 2
-    };
+    enum Type { Audio, Video };
+    enum ReadyState { New = 0, Live = 1, Ended = 2 };
 
-    static PassRefPtr<MediaStreamSource> create(const String& id, Type, const String& name, ReadyState = ReadyStateLive, bool requiresConsumer = false);
+    static PassRefPtr<MediaStreamSource> create(const String& id, Type, const String& name, ReadyState = New, bool requiresConsumer = false);
 
     const String& id() const { return m_id; }
+
     Type type() const { return m_type; }
     const String& name() const { return m_name; }
 
@@ -78,22 +69,28 @@ public:
     void addObserver(Observer*);
     void removeObserver(Observer*);
 
-    PassRefPtr<ExtraData> extraData() const { return m_extraData; }
-    void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData; }
-
     void setConstraints(PassRefPtr<MediaConstraints> constraints) { m_constraints = constraints; }
-    MediaConstraints* constraints() { return m_constraints.get(); }
+    MediaConstraints* constraints() const { return m_constraints.get(); }
 
-    const String& deviceId() { return m_deviceId; }
+    const String& deviceId() const { return m_deviceId; }
     void setDeviceId(const String& deviceId) { m_deviceId = deviceId; }
 
+    bool enabled() const { return m_enabled; }
+    void setEnabled(bool enabled) { m_enabled = enabled; }
+
+    bool muted() const { return m_muted; }
+    void setMuted(bool);
+    
     void setAudioFormat(size_t numberOfChannels, float sampleRate);
     void consumeAudio(AudioBus*, size_t numberOfFrames);
 
+    MediaStreamDescriptor* stream() const { return m_stream; }
+    void setStream(MediaStreamDescriptor*);
+
     bool requiresAudioConsumer() const { return m_requiresConsumer; }
     void addAudioConsumer(PassRefPtr<AudioDestinationConsumer>);
     bool removeAudioConsumer(AudioDestinationConsumer*);
-    const Vector<RefPtr<AudioDestinationConsumer> >& audioConsumers() { return m_audioConsumers; }
+    const Vector<RefPtr<AudioDestinationConsumer> >& audioConsumers() const { return m_audioConsumers; }
 
 private:
     MediaStreamSource(const String& id, Type, const String& name, ReadyState, bool requiresConsumer);
@@ -103,12 +100,15 @@ private:
     String m_name;
     ReadyState m_readyState;
     String m_deviceId;
-    bool m_requiresConsumer;
     Vector<Observer*> m_observers;
     Mutex m_audioConsumersLock;
-    Vector<RefPtr<AudioDestinationConsumer> > m_audioConsumers;
-    RefPtr<ExtraData> m_extraData;
+    Vector<RefPtr<AudioDestinationConsumer>> m_audioConsumers;
     RefPtr<MediaConstraints> m_constraints;
+    MediaStreamDescriptor* m_stream;
+
+    bool m_requiresConsumer;
+    bool m_enabled;
+    bool m_muted;
 };
 
 typedef Vector<RefPtr<MediaStreamSource> > MediaStreamSourceVector;
diff --git a/Source/WebCore/platform/mediastream/MediaStreamSourcesQueryClient.h b/Source/WebCore/platform/mediastream/MediaStreamSourcesQueryClient.h
deleted file mode 100644 (file)
index 49ca983..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 Ericsson AB. All rights reserved.
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer
- *    in the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of Ericsson nor the names of its contributors
- *    may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MediaStreamSourcesQueryClient_h
-#define MediaStreamSourcesQueryClient_h
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "MediaStreamSource.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class MediaConstraints;
-
-class MediaStreamSourcesQueryClient : public RefCounted<MediaStreamSourcesQueryClient> {
-public:
-    virtual ~MediaStreamSourcesQueryClient() { }
-
-    virtual PassRefPtr<MediaConstraints> audioConstraints() const = 0;
-    virtual PassRefPtr<MediaConstraints> videoConstraints() const = 0;
-
-    virtual void didCompleteQuery(const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources) = 0;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
-
-#endif // MediaStreamSourcesQueryClient_h
index 86ade41..6362a24 100644 (file)
@@ -40,7 +40,7 @@
 namespace WebCore {
 
 class MediaConstraints;
-class MediaStreamComponent;
+class MediaStreamSource;
 class RTCConfiguration;
 class RTCDTMFSenderHandler;
 class RTCDataChannelHandler;
@@ -86,7 +86,7 @@ public:
     virtual void removeStream(PassRefPtr<MediaStreamDescriptor>) = 0;
     virtual void getStats(PassRefPtr<RTCStatsRequest>) = 0;
     virtual PassOwnPtr<RTCDataChannelHandler> createDataChannel(const String& label, const RTCDataChannelInit&) = 0;
-    virtual PassOwnPtr<RTCDTMFSenderHandler> createDTMFSender(PassRefPtr<MediaStreamComponent>) = 0;
+    virtual PassOwnPtr<RTCDTMFSenderHandler> createDTMFSender(PassRefPtr<MediaStreamSource>) = 0;
     virtual void stop() = 0;
 
 protected:
index 6b90968..f23fc90 100644 (file)
@@ -50,7 +50,6 @@ public:
     virtual PassRefPtr<RTCStatsResponseBase> createResponse() = 0;
     virtual bool hasSelector() = 0;
     virtual MediaStreamDescriptor* stream() = 0;
-    virtual MediaStreamComponent* component() = 0;
     virtual void requestSucceeded(PassRefPtr<RTCStatsResponseBase>) = 0;
 
 protected:
index cb69078..afdbfe3 100644 (file)
@@ -41,7 +41,7 @@
 
 namespace WebCore {
 
-MediaStreamCenter& MediaStreamCenter::instance()
+MediaStreamCenter& MediaStreamCenter::platformCenter()
 {
     ASSERT(isMainThread());
     DEFINE_STATIC_LOCAL(MediaStreamCenterBlackBerry, center, ());
@@ -56,37 +56,47 @@ MediaStreamCenterBlackBerry::~MediaStreamCenterBlackBerry()
 {
 }
 
-void MediaStreamCenterBlackBerry::queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient> client)
+void MediaStreamCenterBlackBerry::validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints>, PassRefPtr<MediaConstraints>)
 {
-    MediaStreamSourceVector audioSources, videoSources;
-    client->didCompleteQuery(audioSources, videoSources);
+    notImplemented();
+}
+    
+void MediaStreamCenterBlackBerry::createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints>, PassRefPtr<MediaConstraints>)
+{
+    notImplemented();
 }
 
-bool MediaStreamCenterMac::getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>)
+bool MediaStreamCenterBlackBerry::getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>)
 {
+    notImplemented();
     return false;
 }
 
-void MediaStreamCenterBlackBerry::didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*)
+void MediaStreamCenterBlackBerry::didSetMediaStreamTrackEnabled(MediaStreamSource*)
 {
+    notImplemented();
 }
 
-bool MediaStreamCenterBlackBerry::didAddMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*)
+bool MediaStreamCenterBlackBerry::didAddMediaStreamTrack(MediaStreamSource*)
 {
+    notImplemented();
     return false;
 }
 
-bool MediaStreamCenterBlackBerry::didRemoveMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*)
+bool MediaStreamCenterBlackBerry::didRemoveMediaStreamTrack(MediaStreamSource*)
 {
+    notImplemented();
     return false;
 }
 
-void MediaStreamCenterBlackBerry::didStopLocalMediaStream(MediaStreamDescriptor*)
+void MediaStreamCenterBlackBerry::didStopLocalMediaStream(MediaStreamDescriptor* stream)
 {
+    endLocalMediaStream(stream);
 }
 
 void MediaStreamCenterBlackBerry::didCreateMediaStream(MediaStreamDescriptor*)
 {
+    notImplemented();
 }
 
 } // namespace WebCore
index 224599e..e34d892 100644 (file)
@@ -41,8 +41,8 @@
 
 namespace WebCore {
 
-class MediaStreamComponent;
 class MediaStreamDescriptor;
+class MediaStreamSource;
 class MediaStreamSourcesQueryClient;
 
 class MediaStreamCenterBlackBerry : public MediaStreamCenter {
@@ -51,11 +51,12 @@ public:
     ~MediaStreamCenterBlackBerry();
 
     // MediaStreamCenter
-    virtual void queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient>) OVERRIDE;
+    virtual void validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints);
+    virtual void createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints);
     virtual bool getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>) OVERRIDE;
-    virtual void didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
-    virtual bool didAddMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
-    virtual bool didRemoveMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
+    virtual void didSetMediaStreamTrackEnabled(MediaStreamSource*) OVERRIDE;
+    virtual bool didAddMediaStreamTrack(MediaStreamSource*) OVERRIDE;
+    virtual bool didRemoveMediaStreamTrack(MediaStreamSource*) OVERRIDE;
     virtual void didStopLocalMediaStream(MediaStreamDescriptor*) OVERRIDE;
     virtual void didCreateMediaStream(MediaStreamDescriptor*) OVERRIDE;
 };
index 4f5d41d..dd6d336 100644 (file)
@@ -41,7 +41,7 @@
 
 namespace WebCore {
 
-MediaStreamCenter& MediaStreamCenter::instance()
+MediaStreamCenter& MediaStreamCenter::platformCenter()
 {
     ASSERT(isMainThread());
     DEFINE_STATIC_LOCAL(MediaStreamCenterGStreamer, center, ());
@@ -56,37 +56,47 @@ MediaStreamCenterGStreamer::~MediaStreamCenterGStreamer()
 {
 }
 
-void MediaStreamCenterGStreamer::queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient> client)
+void MediaStreamCenterGStreamer::validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints>, PassRefPtr<MediaConstraints>)
 {
-    MediaStreamSourceVector audioSources, videoSources;
-    client->didCompleteQuery(audioSources, videoSources);
+    notImplemented();
+}
+    
+void MediaStreamCenterGStreamer::createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints>, PassRefPtr<MediaConstraints>)
+{
+    notImplemented();
 }
 
-bool MediaStreamCenterMac::getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>)
+bool MediaStreamCenterGStreamer::getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>)
 {
+    notImplemented();
     return false;
 }
 
-void MediaStreamCenterGStreamer::didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*)
+void MediaStreamCenterGStreamer::didSetMediaStreamTrackEnabled(MediaStreamSource*)
 {
+    notImplemented();
 }
 
-bool MediaStreamCenterGStreamer::didAddMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*)
+bool MediaStreamCenterGStreamer::didAddMediaStreamTrack(MediaStreamSource*)
 {
+    notImplemented();
     return false;
 }
 
-bool MediaStreamCenterGStreamer::didRemoveMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*)
+bool MediaStreamCenterGStreamer::didRemoveMediaStreamTrack(MediaStreamSource*)
 {
+    notImplemented();
     return false;
 }
 
-void MediaStreamCenterGStreamer::didStopLocalMediaStream(MediaStreamDescriptor*)
+void MediaStreamCenterGStreamer::didStopLocalMediaStream(MediaStreamDescriptor* stream)
 {
+    endLocalMediaStream(stream);
 }
 
 void MediaStreamCenterGStreamer::didCreateMediaStream(MediaStreamDescriptor*)
 {
+    notImplemented();
 }
 
 } // namespace WebCore
index ab54d03..df133af 100644 (file)
@@ -41,8 +41,8 @@
 
 namespace WebCore {
 
-class MediaStreamComponent;
 class MediaStreamDescriptor;
+class MediaStreamSource;
 class MediaStreamSourcesQueryClient;
 
 class MediaStreamCenterGStreamer : public MediaStreamCenter {
@@ -51,11 +51,12 @@ public:
     ~MediaStreamCenterGStreamer();
 
     // MediaStreamCenter
-    virtual void queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient>) OVERRIDE;
+    virtual void validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints);
+    virtual void createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints);
     virtual bool getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>) OVERRIDE;
-    virtual void didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
-    virtual bool didAddMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
-    virtual bool didRemoveMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
+    virtual void didSetMediaStreamTrackEnabled(MediaStreamSource*) OVERRIDE;
+    virtual bool didAddMediaStreamTrack(MediaStreamSource*) OVERRIDE;
+    virtual bool didRemoveMediaStreamTrack(MediaStreamSource*) OVERRIDE;
     virtual void didStopLocalMediaStream(MediaStreamDescriptor*) OVERRIDE;
     virtual void didCreateMediaStream(MediaStreamDescriptor*) OVERRIDE;
 };
index 613cba3..2c1610b 100644 (file)
 
 #include "MediaStreamCenterMac.h"
 
+#include "MediaStreamCreationClient.h"
 #include "MediaStreamDescriptor.h"
-#include "MediaStreamSourcesQueryClient.h"
 #include "MediaStreamTrackSourcesRequestClient.h"
 #include "NotImplemented.h"
 #include <wtf/MainThread.h>
 
 namespace WebCore {
 
-MediaStreamCenter& MediaStreamCenter::instance()
+MediaStreamCenter& MediaStreamCenter::platformCenter()
 {
     ASSERT(isMainThread());
     DEFINE_STATIC_LOCAL(MediaStreamCenterMac, center, ());
@@ -57,7 +57,12 @@ MediaStreamCenterMac::~MediaStreamCenterMac()
 {
 }
 
-void MediaStreamCenterMac::queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient>)
+void MediaStreamCenterMac::validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints>, PassRefPtr<MediaConstraints>)
+{
+    notImplemented();
+}
+    
+void MediaStreamCenterMac::createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints>, PassRefPtr<MediaConstraints>)
 {
     notImplemented();
 }
@@ -68,18 +73,18 @@ bool MediaStreamCenterMac::getMediaStreamTrackSources(PassRefPtr<MediaStreamTrac
     return false;
 }
 
-void MediaStreamCenterMac::didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*)
+void MediaStreamCenterMac::didSetMediaStreamTrackEnabled(MediaStreamSource*)
 {
     notImplemented();
 }
 
-bool MediaStreamCenterMac::didAddMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*)
+bool MediaStreamCenterMac::didAddMediaStreamTrack(MediaStreamSource*)
 {
     notImplemented();
     return false;
 }
 
-bool MediaStreamCenterMac::didRemoveMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*)
+bool MediaStreamCenterMac::didRemoveMediaStreamTrack(MediaStreamSource*)
 {
     notImplemented();
     return false;
index cc8c708..59df80d 100644 (file)
@@ -40,8 +40,8 @@
 
 namespace WebCore {
 
-class MediaStreamComponent;
 class MediaStreamDescriptor;
+class MediaStreamSource;
 class MediaStreamSourcesQueryClient;
 
 class MediaStreamCenterMac FINAL : public MediaStreamCenter {
@@ -50,12 +50,12 @@ public:
     ~MediaStreamCenterMac();
 
     // MediaStreamCenter
-    virtual void queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient>) OVERRIDE;
-    
+    virtual void validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints);
+    virtual void createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints);
     virtual bool getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>) OVERRIDE;
-    virtual void didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
-    virtual bool didAddMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
-    virtual bool didRemoveMediaStreamTrack(MediaStreamDescriptor*, MediaStreamComponent*) OVERRIDE;
+    virtual void didSetMediaStreamTrackEnabled(MediaStreamSource*) OVERRIDE;
+    virtual bool didAddMediaStreamTrack(MediaStreamSource*) OVERRIDE;
+    virtual bool didRemoveMediaStreamTrack(MediaStreamSource*) OVERRIDE;
     virtual void didStopLocalMediaStream(MediaStreamDescriptor*) OVERRIDE;
     virtual void didCreateMediaStream(MediaStreamDescriptor*) OVERRIDE;
 };