MediaStream API: Update MediaStreamTrack to match the specification
authortommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jul 2012 16:52:56 +0000 (16:52 +0000)
committertommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jul 2012 16:52:56 +0000 (16:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90180

Reviewed by Adam Barth.

Source/Platform:

* chromium/public/WebMediaStreamDescriptor.h:
(WebMediaStreamDescriptor):
* chromium/public/WebMediaStreamSource.h:
(WebMediaStreamSource):

Source/WebCore:

MediaStreamTracks are now required to show the status of the underlying source,
and trigger events when that status changes.

Test: fast/mediastream/MediaStreamTrack.html

* GNUmakefile.list.am:
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::MediaStream):
(WebCore::MediaStream::addTrack):
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::create):
(WebCore::MediaStreamTrack::MediaStreamTrack):
(WebCore::MediaStreamTrack::~MediaStreamTrack):
(WebCore::MediaStreamTrack::setEnabled):
(WebCore::MediaStreamTrack::readyState):
(WebCore):
(WebCore::MediaStreamTrack::sourceChangedState):
(WebCore::MediaStreamTrack::stop):
(WebCore::MediaStreamTrack::interfaceName):
(WebCore::MediaStreamTrack::scriptExecutionContext):
(WebCore::MediaStreamTrack::eventTargetData):
(WebCore::MediaStreamTrack::ensureEventTargetData):
* Modules/mediastream/MediaStreamTrack.h:
* Modules/mediastream/MediaStreamTrack.idl:
* WebCore.gypi:
* dom/EventNames.h:
(WebCore):
* dom/EventTargetFactory.in:
* platform/chromium/support/WebMediaStreamDescriptor.cpp:
* platform/chromium/support/WebMediaStreamSource.cpp:
(WebKit::WebMediaStreamSource::setReadyState):
(WebKit):
(WebKit::WebMediaStreamSource::readyState):
* platform/mediastream/MediaStreamSource.cpp: Copied from Source/WebCore/platform/mediastream/MediaStreamSource.h.
(WebCore):
(WebCore::MediaStreamSource::create):
(WebCore::MediaStreamSource::MediaStreamSource):
(WebCore::MediaStreamSource::setReadyState):
(WebCore::MediaStreamSource::addObserver):
(WebCore::MediaStreamSource::removeObserver):
* platform/mediastream/MediaStreamSource.h:
(Observer):
(WebCore::MediaStreamSource::Observer::~Observer):
(MediaStreamSource):
(WebCore::MediaStreamSource::readyState):
* platform/mediastream/chromium/MediaStreamCenterChromium.cpp:
(WebCore::MediaStreamCenterChromium::queryMediaStreamSources):
(WebCore::MediaStreamCenterChromium::didCreateMediaStream):

Tools:

Adding a Mock WebMediaStreamCenter to enable better LayoutTests.

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/MockWebKitPlatformSupport.cpp:
(MockWebKitPlatformSupport::createMediaStreamCenter):
* DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp: Added.
(WebKit):
(WebKit::MockWebMediaStreamCenter::MockWebMediaStreamCenter):
(WebKit::MockWebMediaStreamCenter::queryMediaStreamSources):
(WebKit::MockWebMediaStreamCenter::didEnableMediaStreamTrack):
(WebKit::MockWebMediaStreamCenter::didDisableMediaStreamTrack):
(WebKit::MockWebMediaStreamCenter::didStopLocalMediaStream):
(WebKit::MockWebMediaStreamCenter::didCreateMediaStream):
(WebKit::MockWebMediaStreamCenter::constructSDP):
* DumpRenderTree/chromium/MockWebMediaStreamCenter.h: Copied from Tools/DumpRenderTree/chromium/MockWebKitPlatformSupport.cpp.
(WebKit):
(MockWebMediaStreamCenter):
(WebKit::MockWebMediaStreamCenter::MockWebMediaStreamCenter):

LayoutTests:

* fast/mediastream/MediaStreamTrack-expected.txt: Added.
* fast/mediastream/MediaStreamTrack.html: Added.

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

27 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaStreamTrack-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/MediaStreamTrack.html [new file with mode: 0644]
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebMediaStreamDescriptor.h
Source/Platform/chromium/public/WebMediaStreamSource.h
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.idl
Source/WebCore/WebCore.gypi
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventTargetFactory.in
Source/WebCore/platform/chromium/support/WebMediaStreamDescriptor.cpp
Source/WebCore/platform/chromium/support/WebMediaStreamSource.cpp
Source/WebCore/platform/mediastream/MediaStreamSource.cpp [new file with mode: 0644]
Source/WebCore/platform/mediastream/MediaStreamSource.h
Source/WebCore/platform/mediastream/chromium/MediaStreamCenterChromium.cpp
Source/WebKit/chromium/src/AssertMatchingEnums.cpp
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.gypi
Tools/DumpRenderTree/chromium/MockWebKitPlatformSupport.cpp
Tools/DumpRenderTree/chromium/MockWebKitPlatformSupport.h
Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp [new file with mode: 0644]
Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.h [new file with mode: 0644]

index ef88bb4..e18b92a 100644 (file)
@@ -1,3 +1,13 @@
+2012-07-25  Tommy Widenflycht  <tommyw@google.com>
+
+        MediaStream API: Update MediaStreamTrack to match the specification
+        https://bugs.webkit.org/show_bug.cgi?id=90180
+
+        Reviewed by Adam Barth.
+
+        * fast/mediastream/MediaStreamTrack-expected.txt: Added.
+        * fast/mediastream/MediaStreamTrack.html: Added.
+
 2012-07-25  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
 
         NodesFromRect and area-based hit-testing can not handle CSS transforms.
diff --git a/LayoutTests/fast/mediastream/MediaStreamTrack-expected.txt b/LayoutTests/fast/mediastream/MediaStreamTrack-expected.txt
new file mode 100644 (file)
index 0000000..afd6460
--- /dev/null
@@ -0,0 +1,13 @@
+Tests MediaStreamTrack callbacks.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS getUserMedia succeeded.
+PASS Track onmute callback succeeded.
+PASS Track onunmute callback succeeded.
+PASS Track onended callback succeeded.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/MediaStreamTrack.html b/LayoutTests/fast/mediastream/MediaStreamTrack.html
new file mode 100644 (file)
index 0000000..7f5b6eb
--- /dev/null
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("Tests MediaStreamTrack callbacks.");
+
+// Note that the below behaviour doesn't reflect how it works outside of LayoutTests.
+// The underlying mock is modified to trigger the events when certain functions are called.
+// This modified behaviour allows us to test the MediaStreamTrack class properly.
+
+var stream;
+var track;
+
+function error() {
+    testFailed('Stream generation failed.');
+    finishJSTest();
+}
+
+function getUserMedia(constraints, callback) {
+    try {
+        navigator.webkitGetUserMedia(constraints, callback, error);
+    } catch (e) {
+        testFailed('webkitGetUserMedia threw exception :' + e);
+        finishJSTest();
+    }
+}
+
+function onTrackEnded() {
+    testPassed('Track onended callback succeeded.');
+
+    finishJSTest();
+}
+
+function onTrackUnmute() {
+    testPassed('Track onunmute callback succeeded.');
+
+    stream.stop();
+}
+
+function onTrackMute() {
+    testPassed('Track onmute callback succeeded.');
+
+    track.enabled = true;
+}
+
+function gotStream(s) {
+    testPassed('getUserMedia succeeded.');
+
+    stream = s;
+    track = stream.videoTracks[0];
+
+    track.onunmute = onTrackUnmute;
+    track.onmute = onTrackMute;
+    track.onended = onTrackEnded;
+
+    track.enabled = false;
+}
+
+getUserMedia({audio:true, video:true}, gotStream);
+
+window.jsTestIsAsync = true;
+window.successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 47c8fa6..fd8cc08 100644 (file)
@@ -1,3 +1,15 @@
+2012-07-25  Tommy Widenflycht  <tommyw@google.com>
+
+        MediaStream API: Update MediaStreamTrack to match the specification
+        https://bugs.webkit.org/show_bug.cgi?id=90180
+
+        Reviewed by Adam Barth.
+
+        * chromium/public/WebMediaStreamDescriptor.h:
+        (WebMediaStreamDescriptor):
+        * chromium/public/WebMediaStreamSource.h:
+        (WebMediaStreamSource):
+
 2012-07-24  Dave Tu  <dtu@chromium.org>
 
         [chromium] Add time spent painting to GPU benchmarking renderingStats() API.
index c25f42e..d1b3853 100644 (file)
@@ -68,9 +68,6 @@ public:
 
     WEBKIT_EXPORT WebString label() const;
 
-    // DEPRECATED
-    WEBKIT_EXPORT void sources(WebVector<WebMediaStreamSource>&) const;
-
     WEBKIT_EXPORT void audioSources(WebVector<WebMediaStreamComponent>&) const;
     WEBKIT_EXPORT void videoSources(WebVector<WebMediaStreamComponent>&) const;
 
index 142d598..01aa8cf 100644 (file)
@@ -50,6 +50,12 @@ public:
         TypeVideo
     };
 
+    enum ReadyState {
+        ReadyStateLive = 0,
+        ReadyStateMuted = 1,
+        ReadyStateEnded = 2
+    };
+
     WebMediaStreamSource() { }
     WebMediaStreamSource(const WebMediaStreamSource& other) { assign(other); }
     ~WebMediaStreamSource() { reset(); }
@@ -70,6 +76,9 @@ public:
     WEBKIT_EXPORT Type type() const;
     WEBKIT_EXPORT WebString name() const;
 
+    WEBKIT_EXPORT void setReadyState(ReadyState);
+    WEBKIT_EXPORT ReadyState readyState() const;
+
 #if WEBKIT_IMPLEMENTATION
     WebMediaStreamSource(const WTF::PassRefPtr<WebCore::MediaStreamSource>&);
     WebMediaStreamSource& operator=(WebCore::MediaStreamSource*);
index 6b95919..27e0dae 100644 (file)
@@ -1,3 +1,59 @@
+2012-07-25  Tommy Widenflycht  <tommyw@google.com>
+
+        MediaStream API: Update MediaStreamTrack to match the specification
+        https://bugs.webkit.org/show_bug.cgi?id=90180
+
+        Reviewed by Adam Barth.
+
+        MediaStreamTracks are now required to show the status of the underlying source,
+        and trigger events when that status changes.
+
+        Test: fast/mediastream/MediaStreamTrack.html
+
+        * GNUmakefile.list.am:
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::MediaStream):
+        (WebCore::MediaStream::addTrack):
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::create):
+        (WebCore::MediaStreamTrack::MediaStreamTrack):
+        (WebCore::MediaStreamTrack::~MediaStreamTrack):
+        (WebCore::MediaStreamTrack::setEnabled):
+        (WebCore::MediaStreamTrack::readyState):
+        (WebCore):
+        (WebCore::MediaStreamTrack::sourceChangedState):
+        (WebCore::MediaStreamTrack::stop):
+        (WebCore::MediaStreamTrack::interfaceName):
+        (WebCore::MediaStreamTrack::scriptExecutionContext):
+        (WebCore::MediaStreamTrack::eventTargetData):
+        (WebCore::MediaStreamTrack::ensureEventTargetData):
+        * Modules/mediastream/MediaStreamTrack.h:
+        * Modules/mediastream/MediaStreamTrack.idl:
+        * WebCore.gypi:
+        * dom/EventNames.h:
+        (WebCore):
+        * dom/EventTargetFactory.in:
+        * platform/chromium/support/WebMediaStreamDescriptor.cpp:
+        * platform/chromium/support/WebMediaStreamSource.cpp:
+        (WebKit::WebMediaStreamSource::setReadyState):
+        (WebKit):
+        (WebKit::WebMediaStreamSource::readyState):
+        * platform/mediastream/MediaStreamSource.cpp: Copied from Source/WebCore/platform/mediastream/MediaStreamSource.h.
+        (WebCore):
+        (WebCore::MediaStreamSource::create):
+        (WebCore::MediaStreamSource::MediaStreamSource):
+        (WebCore::MediaStreamSource::setReadyState):
+        (WebCore::MediaStreamSource::addObserver):
+        (WebCore::MediaStreamSource::removeObserver):
+        * platform/mediastream/MediaStreamSource.h:
+        (Observer):
+        (WebCore::MediaStreamSource::Observer::~Observer):
+        (MediaStreamSource):
+        (WebCore::MediaStreamSource::readyState):
+        * platform/mediastream/chromium/MediaStreamCenterChromium.cpp:
+        (WebCore::MediaStreamCenterChromium::queryMediaStreamSources):
+        (WebCore::MediaStreamCenterChromium::didCreateMediaStream):
+
 2012-07-25  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
 
         Incorrect rounding in ceiledLayoutUnit and roundedLayoutUnit.
index f1f4c76..db5f864 100644 (file)
@@ -3546,6 +3546,7 @@ webcore_sources += \
        Source/WebCore/platform/mediastream/MediaStreamCenter.h \
        Source/WebCore/platform/mediastream/MediaStreamComponent.h \
        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/PeerConnection00Handler.cpp \
index e4efc49..ce8e265 100644 (file)
@@ -94,14 +94,14 @@ MediaStream::MediaStream(ScriptExecutionContext* context, PassRefPtr<MediaStream
     size_t numberOfAudioTracks = m_descriptor->numberOfAudioComponents();
     audioTrackVector.reserveCapacity(numberOfAudioTracks);
     for (size_t i = 0; i < numberOfAudioTracks; i++)
-        audioTrackVector.append(MediaStreamTrack::create(m_descriptor, m_descriptor->audioComponent(i)));
+        audioTrackVector.append(MediaStreamTrack::create(context, m_descriptor, m_descriptor->audioComponent(i)));
     m_audioTracks = MediaStreamTrackList::create(this, audioTrackVector);
 
     MediaStreamTrackVector videoTrackVector;
     size_t numberOfVideoTracks = m_descriptor->numberOfVideoComponents();
     videoTrackVector.reserveCapacity(numberOfVideoTracks);
     for (size_t i = 0; i < numberOfVideoTracks; i++)
-        videoTrackVector.append(MediaStreamTrack::create(m_descriptor, m_descriptor->videoComponent(i)));
+        videoTrackVector.append(MediaStreamTrack::create(context, m_descriptor, m_descriptor->videoComponent(i)));
     m_videoTracks = MediaStreamTrackList::create(this, videoTrackVector);
 }
 
@@ -151,7 +151,7 @@ EventTargetData* MediaStream::ensureEventTargetData()
 
 void MediaStream::addTrack(MediaStreamComponent* component)
 {
-    RefPtr<MediaStreamTrack> track = MediaStreamTrack::create(m_descriptor, component);
+    RefPtr<MediaStreamTrack> track = MediaStreamTrack::create(scriptExecutionContext(), m_descriptor, component);
     ExceptionCode ec = 0;
     switch (component->source()->type()) {
     case MediaStreamSource::TypeAudio:
index f227749..fa071fe 100644 (file)
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "Event.h"
 #include "MediaStreamCenter.h"
 #include "MediaStreamComponent.h"
 
 namespace WebCore {
 
-PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(PassRefPtr<MediaStreamDescriptor> streamDescriptor, MediaStreamComponent* component)
+PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor, MediaStreamComponent* component)
 {
-    return adoptRef(new MediaStreamTrack(streamDescriptor, component));
+    RefPtr<MediaStreamTrack> track = adoptRef(new MediaStreamTrack(context, streamDescriptor, component));
+    track->suspendIfNeeded();
+    return track.release();
 }
 
-MediaStreamTrack::MediaStreamTrack(PassRefPtr<MediaStreamDescriptor> streamDescriptor, MediaStreamComponent* component)
-    : m_streamDescriptor(streamDescriptor)
+MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor, MediaStreamComponent* component)
+    : ActiveDOMObject(context, this)
+    , m_stopped(false)
+    , m_streamDescriptor(streamDescriptor)
     , m_component(component)
 {
+    m_component->source()->addObserver(this);
 }
 
 MediaStreamTrack::~MediaStreamTrack()
 {
+    m_component->source()->removeObserver(this);
 }
 
 String MediaStreamTrack::kind() const
@@ -76,7 +83,7 @@ bool MediaStreamTrack::enabled() const
 
 void MediaStreamTrack::setEnabled(bool enabled)
 {
-    if (enabled == m_component->enabled())
+    if (m_stopped || enabled == m_component->enabled())
         return;
 
     m_component->setEnabled(enabled);
@@ -87,11 +94,72 @@ void MediaStreamTrack::setEnabled(bool enabled)
     MediaStreamCenter::instance().didSetMediaStreamTrackEnabled(m_streamDescriptor.get(), m_component.get());
 }
 
+MediaStreamTrack::ReadyState MediaStreamTrack::readyState() const
+{
+    if (m_stopped)
+        return ENDED;
+
+    switch (m_component->source()->readyState()) {
+    case MediaStreamSource::ReadyStateLive:
+        return LIVE;
+    case MediaStreamSource::ReadyStateMuted:
+        return MUTED;
+    case MediaStreamSource::ReadyStateEnded:
+        return ENDED;
+    }
+
+    ASSERT_NOT_REACHED();
+    return ENDED;
+}
+
+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:
+        dispatchEvent(Event::create(eventNames().endedEvent, false, false));
+        break;
+    }
+}
+
 MediaStreamComponent* MediaStreamTrack::component()
 {
     return m_component.get();
 }
 
+void MediaStreamTrack::stop()
+{
+    m_stopped = true;
+}
+
+const AtomicString& MediaStreamTrack::interfaceName() const
+{
+    return eventNames().interfaceForMediaStreamTrack;
+}
+
+ScriptExecutionContext* MediaStreamTrack::scriptExecutionContext() const
+{
+    return ActiveDOMObject::scriptExecutionContext();
+}
+
+EventTargetData* MediaStreamTrack::eventTargetData()
+{
+    return &m_eventTargetData;
+}
+
+EventTargetData* MediaStreamTrack::ensureEventTargetData()
+{
+    return &m_eventTargetData;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index c45be18..724a120 100644 (file)
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "ActiveDOMObject.h"
+#include "EventTarget.h"
 #include "MediaStreamDescriptor.h"
+#include "MediaStreamSource.h"
 #include "PlatformString.h"
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -38,9 +41,15 @@ namespace WebCore {
 
 class MediaStreamComponent;
 
-class MediaStreamTrack : public RefCounted<MediaStreamTrack> {
+class MediaStreamTrack : public RefCounted<MediaStreamTrack>, public ActiveDOMObject, public EventTarget, public MediaStreamSource::Observer {
 public:
-    static PassRefPtr<MediaStreamTrack> create(PassRefPtr<MediaStreamDescriptor>, MediaStreamComponent*);
+    enum ReadyState {
+        LIVE = 0,
+        MUTED = 1,
+        ENDED = 2
+    };
+
+    static PassRefPtr<MediaStreamTrack> create(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>, MediaStreamComponent*);
     virtual ~MediaStreamTrack();
 
     String kind() const;
@@ -49,11 +58,38 @@ public:
     bool enabled() const;
     void setEnabled(bool);
 
+    ReadyState readyState() const;
+
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(mute);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(unmute);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(ended);
+
     MediaStreamComponent* component();
 
+    // EventTarget
+    virtual const AtomicString& interfaceName() const OVERRIDE;
+    virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
+
+    // ActiveDOMObject
+    virtual void stop() OVERRIDE;
+
+    using RefCounted<MediaStreamTrack>::ref;
+    using RefCounted<MediaStreamTrack>::deref;
+
 private:
-    MediaStreamTrack(PassRefPtr<MediaStreamDescriptor>, MediaStreamComponent*);
+    MediaStreamTrack(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>, MediaStreamComponent*);
+
+    // EventTarget
+    virtual EventTargetData* eventTargetData() OVERRIDE;
+    virtual EventTargetData* ensureEventTargetData() OVERRIDE;
+    virtual void refEventTarget() OVERRIDE { ref(); }
+    virtual void derefEventTarget() OVERRIDE { deref(); }
+    EventTargetData m_eventTargetData;
+
+    // MediaStreamSourceObserver
+    virtual void sourceChangedState() OVERRIDE;
 
+    bool m_stopped;
     RefPtr<MediaStreamDescriptor> m_streamDescriptor;
     RefPtr<MediaStreamComponent> m_component;
 };
index 7987597..e103ce2 100644 (file)
@@ -26,10 +26,31 @@ module core {
 
     interface [
         Conditional=MEDIA_STREAM,
+        EventTarget,
+        ActiveDOMObject
     ] MediaStreamTrack {
         readonly attribute DOMString kind;
         readonly attribute DOMString label;
                  attribute boolean enabled;
+
+        const unsigned short LIVE = 0;
+        const unsigned short MUTED = 1;
+        const unsigned short ENDED = 2;
+        readonly attribute unsigned short readyState;
+
+        attribute EventListener onmute;
+        attribute EventListener onunmute;
+        attribute EventListener onended;
+
+        // EventTarget interface
+        void addEventListener(in DOMString type,
+                              in EventListener listener,
+                              in [Optional] boolean useCapture);
+        void removeEventListener(in DOMString type,
+                                 in EventListener listener,
+                                 in [Optional] boolean useCapture);
+        boolean dispatchEvent(in Event event)
+            raises(EventException);
     };
 
 }
index 397bfc1..5f2c202 100644 (file)
             'platform/mediastream/MediaStreamCenter.h',
             'platform/mediastream/MediaStreamComponent.h',
             'platform/mediastream/MediaStreamDescriptor.h',
+            'platform/mediastream/MediaStreamSource.cpp',
             'platform/mediastream/MediaStreamSource.h',
             'platform/mediastream/PeerConnection00Handler.h',
             'platform/mediastream/PeerConnection00HandlerClient.h',
index 983df29..b0efbe7 100644 (file)
@@ -219,6 +219,8 @@ namespace WebCore {
     macro(removestream) \
     macro(statechange) \
     macro(removetrack) \
+    macro(mute) \
+    macro(unmute) \
     \
     macro(show) \
     \
index 7f25d30..9c2bd9b 100644 (file)
@@ -17,6 +17,7 @@ JavaScriptAudioNode conditional=WEB_AUDIO
 LocalMediaStream conditional=MEDIA_STREAM
 MediaController conditional=VIDEO
 MediaStream conditional=MEDIA_STREAM
+MediaStreamTrack conditional=MEDIA_STREAM
 MediaStreamTrackList conditional=MEDIA_STREAM
 MessagePort
 NetworkInfoConnection conditional=NETWORK_INFO
index 8e7a3a7..36cce74 100644 (file)
@@ -91,20 +91,6 @@ void WebMediaStreamDescriptor::setExtraData(ExtraData* extraData)
     m_private->setExtraData(adoptRef(new ExtraDataContainer(extraData)));
 }
 
-// FIXME: Cleanup when the chromium code has switched to the split sources implementation.
-void WebMediaStreamDescriptor::sources(WebVector<WebMediaStreamSource>& webSources) const
-{
-    size_t numberOfAudioSources = m_private->numberOfAudioComponents();
-    size_t numberOfVideoSources = m_private->numberOfVideoComponents();
-    WebVector<WebMediaStreamSource> result(numberOfAudioSources + numberOfVideoSources);
-    size_t i = 0;
-    for (size_t j = 0; j < numberOfAudioSources; ++i, ++j)
-        result[i] = m_private->audioComponent(j)->source();
-    for (size_t j = 0; j < numberOfVideoSources; ++i, ++j)
-        result[i] = m_private->videoComponent(j)->source();
-    webSources.swap(result);
-}
-
 void WebMediaStreamDescriptor::audioSources(WebVector<WebMediaStreamComponent>& webSources) const
 {
     size_t numberOfSources = m_private->numberOfAudioComponents();
index 3f877f5..70ef708 100644 (file)
@@ -96,6 +96,18 @@ WebString WebMediaStreamSource::name() const
     return m_private.get()->name();
 }
 
+void WebMediaStreamSource::setReadyState(ReadyState state)
+{
+    ASSERT(!m_private.isNull());
+    m_private->setReadyState(static_cast<MediaStreamSource::ReadyState>(state));
+}
+
+WebMediaStreamSource::ReadyState WebMediaStreamSource::readyState() const
+{
+    ASSERT(!m_private.isNull());
+    return static_cast<ReadyState>(m_private->readyState());
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(MEDIA_STREAM)
diff --git a/Source/WebCore/platform/mediastream/MediaStreamSource.cpp b/Source/WebCore/platform/mediastream/MediaStreamSource.cpp
new file mode 100644 (file)
index 0000000..1720487
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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 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 "MediaStreamSource.h"
+
+namespace WebCore {
+
+PassRefPtr<MediaStreamSource> MediaStreamSource::create(const String& id, Type type, const String& name, ReadyState readyState)
+{
+    return adoptRef(new MediaStreamSource(id, type, name, readyState));
+}
+
+MediaStreamSource::MediaStreamSource(const String& id, Type type, const String& name, ReadyState readyState)
+    : m_id(id)
+    , m_type(type)
+    , m_name(name)
+    , m_readyState(readyState)
+{
+}
+
+void MediaStreamSource::setReadyState(ReadyState readyState)
+{
+    ASSERT(m_readyState != ReadyStateEnded);
+    if (m_readyState != readyState) {
+        m_readyState = readyState;
+        for (Vector<Observer*>::iterator i = m_observers.begin(); i != m_observers.end(); ++i)
+            (*i)->sourceChangedState();
+    }
+}
+
+void MediaStreamSource::addObserver(MediaStreamSource::Observer* observer)
+{
+    m_observers.append(observer);
+}
+
+void MediaStreamSource::removeObserver(MediaStreamSource::Observer* observer)
+{
+    size_t pos = m_observers.find(observer);
+    if (pos != notFound)
+        m_observers.remove(pos);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
index 7634e40..c45b571 100644 (file)
@@ -41,36 +41,43 @@ namespace WebCore {
 
 class MediaStreamSource : public RefCounted<MediaStreamSource> {
 public:
+    class Observer {
+    public:
+        virtual ~Observer() { }
+        virtual void sourceChangedState() = 0;
+    };
+
     enum Type {
         TypeAudio,
         TypeVideo
     };
 
-    static PassRefPtr<MediaStreamSource> create(const String& id, Type type, const String& name)
-    {
-        return adoptRef(new MediaStreamSource(id, type, name));
-    }
+    enum ReadyState {
+        ReadyStateLive = 0,
+        ReadyStateMuted = 1,
+        ReadyStateEnded = 2
+    };
+
+    static PassRefPtr<MediaStreamSource> create(const String& id, Type, const String& name, ReadyState = ReadyStateLive);
 
     const String& id() const { return m_id; }
     Type type() const { return m_type; }
     const String& name() const { return m_name; }
 
-    bool muted() const { return m_muted; }
-    void setMuted(bool muted) { m_muted = muted; }
+    void setReadyState(ReadyState);
+    ReadyState readyState() const { return m_readyState; }
+
+    void addObserver(Observer*);
+    void removeObserver(Observer*);
 
 private:
-    MediaStreamSource(const String& id, Type type, const String& name)
-        : m_id(id)
-        , m_type(type)
-        , m_name(name)
-        , m_muted(false)
-    {
-    }
+    MediaStreamSource(const String& id, Type, const String& name, ReadyState);
 
     String m_id;
     Type m_type;
     String m_name;
-    bool m_muted;
+    ReadyState m_readyState;
+    Vector<Observer*> m_observers;
 };
 
 typedef Vector<RefPtr<MediaStreamSource> > MediaStreamSourceVector;
index 3c82f5f..9258074 100644 (file)
@@ -68,9 +68,12 @@ MediaStreamCenterChromium::~MediaStreamCenterChromium()
 
 void MediaStreamCenterChromium::queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient> client)
 {
-    // FIXME: Remove this "short-circuit" and forward to m_private when Chrome and DumpRenderTree has implemented WebMediaStreamCenter.
-    MediaStreamSourceVector audioSources, videoSources;
-    client->didCompleteQuery(audioSources, videoSources);
+    if (m_private)
+        m_private->queryMediaStreamSources(client);
+    else {
+        MediaStreamSourceVector audioSources, videoSources;
+        client->didCompleteQuery(audioSources, videoSources);
+    }
 }
 
 void MediaStreamCenterChromium::didSetMediaStreamTrackEnabled(MediaStreamDescriptor* stream,  MediaStreamComponent* component)
@@ -100,9 +103,6 @@ void MediaStreamCenterChromium::didStopLocalMediaStream(MediaStreamDescriptor* s
 void MediaStreamCenterChromium::didCreateMediaStream(MediaStreamDescriptor* stream)
 {
     if (m_private) {
-        // FIXME: Remove when Chromium have switched to the new API.
-        m_private->didConstructMediaStream(stream);
-
         WebKit::WebMediaStreamDescriptor webStream(stream);
         m_private->didCreateMediaStream(webStream);
     }
index 789d1b6..5f25035 100644 (file)
@@ -537,6 +537,9 @@ COMPILE_ASSERT_MATCHING_ENUM(WebPageVisibilityStatePreview, PageVisibilityStateP
 #if ENABLE(MEDIA_STREAM)
 COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::TypeAudio, MediaStreamSource::TypeAudio);
 COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::TypeVideo, MediaStreamSource::TypeVideo);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::ReadyStateLive, MediaStreamSource::ReadyStateLive);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::ReadyStateMuted, MediaStreamSource::ReadyStateMuted);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaStreamSource::ReadyStateEnded, MediaStreamSource::ReadyStateEnded);
 
 COMPILE_ASSERT_MATCHING_ENUM(WebICEOptions::CandidateTypeAll, IceOptions::ALL);
 COMPILE_ASSERT_MATCHING_ENUM(WebICEOptions::CandidateTypeNoRelay, IceOptions::NO_RELAY);
index 780a745..9b4469d 100644 (file)
@@ -1,3 +1,29 @@
+2012-07-25  Tommy Widenflycht  <tommyw@google.com>
+
+        MediaStream API: Update MediaStreamTrack to match the specification
+        https://bugs.webkit.org/show_bug.cgi?id=90180
+
+        Reviewed by Adam Barth.
+
+        Adding a Mock WebMediaStreamCenter to enable better LayoutTests.
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/chromium/MockWebKitPlatformSupport.cpp:
+        (MockWebKitPlatformSupport::createMediaStreamCenter):
+        * DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp: Added.
+        (WebKit):
+        (WebKit::MockWebMediaStreamCenter::MockWebMediaStreamCenter):
+        (WebKit::MockWebMediaStreamCenter::queryMediaStreamSources):
+        (WebKit::MockWebMediaStreamCenter::didEnableMediaStreamTrack):
+        (WebKit::MockWebMediaStreamCenter::didDisableMediaStreamTrack):
+        (WebKit::MockWebMediaStreamCenter::didStopLocalMediaStream):
+        (WebKit::MockWebMediaStreamCenter::didCreateMediaStream):
+        (WebKit::MockWebMediaStreamCenter::constructSDP):
+        * DumpRenderTree/chromium/MockWebMediaStreamCenter.h: Copied from Tools/DumpRenderTree/chromium/MockWebKitPlatformSupport.cpp.
+        (WebKit):
+        (MockWebMediaStreamCenter):
+        (WebKit::MockWebMediaStreamCenter::MockWebMediaStreamCenter):
+
 2012-07-25  Krist√≥f Koszty√≥  <kkristof@inf.u-szeged.hu>
 
         [NRWT] Rename baseline_search_path() to default_baseline_search_path()
index e11f40e..7dd5a1e 100644 (file)
@@ -16,6 +16,8 @@
             'chromium/MockSpellCheck.h',
             'chromium/MockWebKitPlatformSupport.cpp',
             'chromium/MockWebKitPlatformSupport.h',
+            'chromium/MockWebMediaStreamCenter.cpp',
+            'chromium/MockWebMediaStreamCenter.h',
             'chromium/MockWebPrerenderingSupport.cpp',
             'chromium/MockWebPrerenderingSupport.h',
             'chromium/MockWebSpeechInputController.cpp',
index 23b5aa7..0a8b295 100644 (file)
 #include "config.h"
 #include "MockWebKitPlatformSupport.h"
 
+#include "MockWebMediaStreamCenter.h"
 #include <wtf/Assertions.h>
+#include <wtf/PassOwnPtr.h>
 
 using namespace WebKit;
 
 PassOwnPtr<MockWebKitPlatformSupport> MockWebKitPlatformSupport::create()
 {
-    return WTF::adoptPtr(new MockWebKitPlatformSupport());
+    return adoptPtr(new MockWebKitPlatformSupport());
 }
 
 MockWebKitPlatformSupport::MockWebKitPlatformSupport()
@@ -53,7 +55,12 @@ void MockWebKitPlatformSupport::cryptographicallyRandomValues(unsigned char*, si
     CRASH();
 }
 
-WebMediaStreamCenter* MockWebKitPlatformSupport::createMediaStreamCenter(WebMediaStreamCenterClient*)
+#if ENABLE(MEDIA_STREAM)
+WebMediaStreamCenter* MockWebKitPlatformSupport::createMediaStreamCenter(WebMediaStreamCenterClient* client)
 {
-    return 0;
+    if (!m_mockMediaStreamCenter)
+        m_mockMediaStreamCenter = adoptPtr(new MockWebMediaStreamCenter(client));
+
+    return m_mockMediaStreamCenter.get();
 }
+#endif // ENABLE(MEDIA_STREAM)
index 5e8977d..1c9d30b 100644 (file)
@@ -32,6 +32,7 @@
 #define MockWebKitPlatformSupport_h
 
 #include <public/Platform.h>
+#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 
 class MockWebKitPlatformSupport : public WebKit::Platform {
@@ -41,10 +42,16 @@ public:
 
     virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) OVERRIDE;
 
+#if ENABLE(MEDIA_STREAM)
     virtual WebKit::WebMediaStreamCenter* createMediaStreamCenter(WebKit::WebMediaStreamCenterClient*) OVERRIDE;
+#endif // ENABLE(MEDIA_STREAM)
 
 private:
     MockWebKitPlatformSupport();
+
+#if ENABLE(MEDIA_STREAM)
+    OwnPtr<WebKit::WebMediaStreamCenter> m_mockMediaStreamCenter;
+#endif // ENABLE(MEDIA_STREAM)
 };
 
 #endif // MockWebKitPlatformSupport_h
diff --git a/Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp b/Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp
new file mode 100644 (file)
index 0000000..30b56f1
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 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:
+ *
+ *     * 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 "MockWebMediaStreamCenter.h"
+
+#include "platform/WebICECandidateDescriptor.h"
+#include "platform/WebMediaStreamCenterClient.h"
+#include "platform/WebMediaStreamComponent.h"
+#include "platform/WebMediaStreamDescriptor.h"
+#include "platform/WebMediaStreamSource.h"
+#include "platform/WebMediaStreamSourcesRequest.h"
+#include "platform/WebSessionDescriptionDescriptor.h"
+#include "platform/WebVector.h"
+
+using namespace WebKit;
+
+MockWebMediaStreamCenter::MockWebMediaStreamCenter(WebMediaStreamCenterClient* client)
+{
+}
+
+void MockWebMediaStreamCenter::queryMediaStreamSources(const WebMediaStreamSourcesRequest& request)
+{
+    WebVector<WebMediaStreamSource> audioSources, videoSources;
+    request.didCompleteQuery(audioSources, videoSources);
+}
+
+void MockWebMediaStreamCenter::didEnableMediaStreamTrack(const WebMediaStreamDescriptor&, const WebMediaStreamComponent& component)
+{
+    component.source().setReadyState(WebMediaStreamSource::ReadyStateLive);
+}
+
+void MockWebMediaStreamCenter::didDisableMediaStreamTrack(const WebMediaStreamDescriptor&, const WebMediaStreamComponent& component)
+{
+    component.source().setReadyState(WebMediaStreamSource::ReadyStateMuted);
+}
+
+void MockWebMediaStreamCenter::didStopLocalMediaStream(const WebMediaStreamDescriptor& stream)
+{
+    WebVector<WebMediaStreamComponent> audioComponents;
+    stream.audioSources(audioComponents);
+    for (size_t i = 0; i < audioComponents.size(); ++i)
+        audioComponents[i].source().setReadyState(WebMediaStreamSource::ReadyStateEnded);
+
+    WebVector<WebMediaStreamComponent> videoComponents;
+    stream.videoSources(videoComponents);
+    for (size_t i = 0; i < videoComponents.size(); ++i)
+        videoComponents[i].source().setReadyState(WebMediaStreamSource::ReadyStateEnded);
+}
+
+void MockWebMediaStreamCenter::didCreateMediaStream(WebMediaStreamDescriptor&)
+{
+}
+
+WebString MockWebMediaStreamCenter::constructSDP(const WebICECandidateDescriptor& iceCandidate)
+{
+    string16 result = iceCandidate.label();
+    result += WebString(":");
+    result += iceCandidate.candidateLine();
+    result += WebString(";");
+    return result;
+}
+
+WebString MockWebMediaStreamCenter::constructSDP(const WebSessionDescriptionDescriptor& sessionDescription)
+{
+    string16 result = sessionDescription.initialSDP();
+    result += WebString(";");
+    for (size_t i = 0; i < sessionDescription.numberOfAddedCandidates(); ++i) {
+        result += constructSDP(sessionDescription.candidate(i));
+        result += WebString(";");
+    }
+    return result;
+}
+
+#endif // ENABLE(MEDIA_STREAM)
diff --git a/Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.h b/Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.h
new file mode 100644 (file)
index 0000000..75baf24
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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:
+ *
+ *     * 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.
+ */
+
+#ifndef MockWebMediaStreamCenter_h
+#define MockWebMediaStreamCenter_h
+
+#if ENABLE(MEDIA_STREAM)
+#include "platform/WebMediaStreamCenter.h"
+
+namespace WebKit {
+class WebMediaStreamCenterClient;
+};
+
+class MockWebMediaStreamCenter : public WebKit::WebMediaStreamCenter {
+public:
+    explicit MockWebMediaStreamCenter(WebKit::WebMediaStreamCenterClient*);
+
+    virtual void queryMediaStreamSources(const WebKit::WebMediaStreamSourcesRequest&) OVERRIDE;
+    virtual void didEnableMediaStreamTrack(const WebKit::WebMediaStreamDescriptor&, const WebKit::WebMediaStreamComponent&) OVERRIDE;
+    virtual void didDisableMediaStreamTrack(const WebKit::WebMediaStreamDescriptor&, const WebKit::WebMediaStreamComponent&) OVERRIDE;
+    virtual void didStopLocalMediaStream(const WebKit::WebMediaStreamDescriptor&) OVERRIDE;
+    virtual void didCreateMediaStream(WebKit::WebMediaStreamDescriptor&) OVERRIDE;
+    virtual WebKit::WebString constructSDP(const WebKit::WebICECandidateDescriptor&) OVERRIDE;
+    virtual WebKit::WebString constructSDP(const WebKit::WebSessionDescriptionDescriptor&) OVERRIDE;
+
+private:
+    MockWebMediaStreamCenter() { }
+};
+
+#endif // ENABLE(MEDIA_STREAM)
+#endif // MockWebMediaStreamCenter_h
+