Title: [100997] trunk/Source/WebCore
Revision
100997
Author
commit-qu...@webkit.org
Date
2011-11-22 06:26:31 -0800 (Tue, 22 Nov 2011)

Log Message

Add WebCore platform interface needed by updated MediaStream API design
https://bugs.webkit.org/show_bug.cgi?id=70895

Patch by Adam Bergkvist <adam.bergkv...@ericsson.com> on 2011-11-22
Reviewed by Adam Barth.

This is one in a series of patches that update the MediaStream feature
to use WebCore platform interfaces.

Tests will be provided by http://webkit.org/b/56587

* GNUmakefile.list.am:
* WebCore.gypi:
* mediastream/LocalMediaStream.cpp:
(WebCore::LocalMediaStream::stopTimerFired):
* mediastream/MediaStream.h:
* mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::setEnabled):
* mediastream/PeerConnection.cpp:
(WebCore::PeerConnection::didRemoveRemoteStream):
* mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::start):
* mediastream/UserMediaRequest.h:
* platform/mediastream/MediaStreamCenter.cpp: Added.
(WebCore::MediaStreamCenter::instance):
(WebCore::MediaStreamCenter::endLocalMediaStream):
(WebCore::MediaStreamCenter::MediaStreamCenter):
(WebCore::MediaStreamCenter::~MediaStreamCenter):
(WebCore::MediaStreamCenter::queryMediaStreamSources):
(WebCore::MediaStreamCenter::didSetMediaStreamTrackEnabled):
(WebCore::MediaStreamCenter::didStopLocalMediaStream):
* platform/mediastream/MediaStreamCenter.h: Added.
(WebCore::MediaStreamSourcesQueryClient::~MediaStreamSourcesQueryClient):
* platform/mediastream/MediaStreamDescriptor.h:
(WebCore::MediaStreamDescriptorOwner::~MediaStreamDescriptorOwner):
(WebCore::MediaStreamDescriptor::owner):
(WebCore::MediaStreamDescriptor::setOwner):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (100996 => 100997)


--- trunk/Source/WebCore/ChangeLog	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/ChangeLog	2011-11-22 14:26:31 UTC (rev 100997)
@@ -1,3 +1,42 @@
+2011-11-22  Adam Bergkvist  <adam.bergkv...@ericsson.com>
+
+        Add WebCore platform interface needed by updated MediaStream API design
+        https://bugs.webkit.org/show_bug.cgi?id=70895
+
+        Reviewed by Adam Barth.
+
+        This is one in a series of patches that update the MediaStream feature
+        to use WebCore platform interfaces.
+
+        Tests will be provided by http://webkit.org/b/56587
+
+        * GNUmakefile.list.am:
+        * WebCore.gypi:
+        * mediastream/LocalMediaStream.cpp:
+        (WebCore::LocalMediaStream::stopTimerFired):
+        * mediastream/MediaStream.h:
+        * mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::setEnabled):
+        * mediastream/PeerConnection.cpp:
+        (WebCore::PeerConnection::didRemoveRemoteStream):
+        * mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::start):
+        * mediastream/UserMediaRequest.h:
+        * platform/mediastream/MediaStreamCenter.cpp: Added.
+        (WebCore::MediaStreamCenter::instance):
+        (WebCore::MediaStreamCenter::endLocalMediaStream):
+        (WebCore::MediaStreamCenter::MediaStreamCenter):
+        (WebCore::MediaStreamCenter::~MediaStreamCenter):
+        (WebCore::MediaStreamCenter::queryMediaStreamSources):
+        (WebCore::MediaStreamCenter::didSetMediaStreamTrackEnabled):
+        (WebCore::MediaStreamCenter::didStopLocalMediaStream):
+        * platform/mediastream/MediaStreamCenter.h: Added.
+        (WebCore::MediaStreamSourcesQueryClient::~MediaStreamSourcesQueryClient):
+        * platform/mediastream/MediaStreamDescriptor.h:
+        (WebCore::MediaStreamDescriptorOwner::~MediaStreamDescriptorOwner):
+        (WebCore::MediaStreamDescriptor::owner):
+        (WebCore::MediaStreamDescriptor::setOwner):
+
 2011-11-22  Pavel Feldman  <pfeld...@google.com>
 
         Web Inspector: remove Inspector::bringToFront from the protocol.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (100996 => 100997)


--- trunk/Source/WebCore/GNUmakefile.list.am	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2011-11-22 14:26:31 UTC (rev 100997)
@@ -2774,6 +2774,8 @@
 	Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h \
 	Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp \
 	Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h \
+	Source/WebCore/platform/mediastream/MediaStreamCenter.cpp \
+	Source/WebCore/platform/mediastream/MediaStreamCenter.h \
 	Source/WebCore/platform/mediastream/MediaStreamComponent.h \
 	Source/WebCore/platform/mediastream/MediaStreamDescriptor.h \
 	Source/WebCore/platform/mediastream/MediaStreamSource.h \

Modified: trunk/Source/WebCore/WebCore.gypi (100996 => 100997)


--- trunk/Source/WebCore/WebCore.gypi	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/WebCore.gypi	2011-11-22 14:26:31 UTC (rev 100997)
@@ -814,6 +814,8 @@
             'platform/mac/WebCoreSystemInterface.h',
             'platform/mac/WebCoreView.h',
             'platform/mac/WebFontCache.h',
+            'platform/mediastream/MediaStreamCenter.cpp',
+            'platform/mediastream/MediaStreamCenter.h',
             'platform/mediastream/MediaStreamComponent.h',
             'platform/mediastream/MediaStreamDescriptor.h',
             'platform/mediastream/MediaStreamSource.h',

Modified: trunk/Source/WebCore/mediastream/LocalMediaStream.cpp (100996 => 100997)


--- trunk/Source/WebCore/mediastream/LocalMediaStream.cpp	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/mediastream/LocalMediaStream.cpp	2011-11-22 14:26:31 UTC (rev 100997)
@@ -28,6 +28,7 @@
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "MediaStreamCenter.h"
 #include "UUID.h"
 
 namespace WebCore {
@@ -56,7 +57,7 @@
     if (readyState() == ENDED)
         return;
 
-    // FIXME: tell the platform that the stream was stopped
+    MediaStreamCenter::instance().didStopLocalMediaStream(descriptor());
 
     streamEnded();
 }

Modified: trunk/Source/WebCore/mediastream/MediaStream.h (100996 => 100997)


--- trunk/Source/WebCore/mediastream/MediaStream.h	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/mediastream/MediaStream.h	2011-11-22 14:26:31 UTC (rev 100997)
@@ -38,7 +38,7 @@
 
 class ScriptExecutionContext;
 
-class MediaStream : public RefCounted<MediaStream>, public EventTarget {
+class MediaStream : public RefCounted<MediaStream>, public MediaStreamDescriptorOwner, public EventTarget {
 public:
     // Must match the constants in the .idl file.
     enum ReadyState {

Modified: trunk/Source/WebCore/mediastream/MediaStreamTrack.cpp (100996 => 100997)


--- trunk/Source/WebCore/mediastream/MediaStreamTrack.cpp	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/mediastream/MediaStreamTrack.cpp	2011-11-22 14:26:31 UTC (rev 100997)
@@ -28,6 +28,8 @@
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "MediaStreamCenter.h"
+
 namespace WebCore {
 
 PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(PassRefPtr<MediaStreamDescriptor> streamDescriptor, size_t trackIndex)
@@ -78,7 +80,7 @@
 
     m_streamDescriptor->component(m_trackIndex)->setEnabled(enabled);
 
-    // FIXME: tell the platform that the track was enabled/disabled
+    MediaStreamCenter::instance().didSetMediaStreamTrackEnabled(m_streamDescriptor.get(), m_trackIndex);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/mediastream/PeerConnection.cpp (100996 => 100997)


--- trunk/Source/WebCore/mediastream/PeerConnection.cpp	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/mediastream/PeerConnection.cpp	2011-11-22 14:26:31 UTC (rev 100997)
@@ -224,7 +224,7 @@
     ASSERT(scriptExecutionContext()->isContextThread());
     ASSERT(streamDescriptor->owner());
 
-    RefPtr<MediaStream> stream = streamDescriptor->owner();
+    RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->owner());
     stream->streamEnded();
 
     if (m_readyState == CLOSED)

Modified: trunk/Source/WebCore/mediastream/UserMediaRequest.cpp (100996 => 100997)


--- trunk/Source/WebCore/mediastream/UserMediaRequest.cpp	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/mediastream/UserMediaRequest.cpp	2011-11-22 14:26:31 UTC (rev 100997)
@@ -68,7 +68,7 @@
 
 void UserMediaRequest::start()
 {
-    // FIXME: query the platform for available media stream sources, see http://webkit.org/b/70895
+    MediaStreamCenter::instance().queryMediaStreamSources(this);
 }
 
 void UserMediaRequest::mediaStreamSourcesQueryCompleted(const MediaStreamSourceVector& sources)

Modified: trunk/Source/WebCore/mediastream/UserMediaRequest.h (100996 => 100997)


--- trunk/Source/WebCore/mediastream/UserMediaRequest.h	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/mediastream/UserMediaRequest.h	2011-11-22 14:26:31 UTC (rev 100997)
@@ -34,6 +34,7 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "ActiveDOMObject.h"
+#include "MediaStreamCenter.h"
 #include "MediaStreamSource.h"
 #include "NavigatorUserMediaErrorCallback.h"
 #include "NavigatorUserMediaSuccessCallback.h"
@@ -45,7 +46,7 @@
 
 class UserMediaClient;
 
-class UserMediaRequest : public RefCounted<UserMediaRequest>, public ContextDestructionObserver {
+class UserMediaRequest : public MediaStreamSourcesQueryClient, public ContextDestructionObserver {
 public:
     static PassRefPtr<UserMediaRequest> create(ScriptExecutionContext*, UserMediaClient*, const String& options, PassRefPtr<NavigatorUserMediaSuccessCallback>, PassRefPtr<NavigatorUserMediaErrorCallback>);
     ~UserMediaRequest();

Copied: trunk/Source/WebCore/platform/mediastream/MediaStreamCenter.cpp (from rev 100996, trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h) (0 => 100997)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamCenter.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamCenter.cpp	2011-11-22 14:26:31 UTC (rev 100997)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2011 Ericsson AB. 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "MediaStreamCenter.h"
+
+#include "MainThread.h"
+#include "MediaStreamDescriptor.h"
+
+namespace WebCore {
+
+MediaStreamCenter& MediaStreamCenter::instance()
+{
+    ASSERT(isMainThread());
+    DEFINE_STATIC_LOCAL(MediaStreamCenter, center, ());
+    return center;
+}
+
+void MediaStreamCenter::endLocalMediaStream(MediaStreamDescriptor* streamDescriptor)
+{
+    MediaStreamDescriptorOwner* owner = streamDescriptor->owner();
+    if (owner)
+        owner->streamEnded();
+    else
+        streamDescriptor->setEnded();
+}
+
+// FIXME: remove when real implementations are available
+// Empty implementations for ports that build with MEDIA_STREAM enabled by default.
+MediaStreamCenter::MediaStreamCenter()
+{
+}
+
+MediaStreamCenter::~MediaStreamCenter()
+{
+}
+
+void MediaStreamCenter::queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient> client)
+{
+    MediaStreamSourceVector sources;
+    client->mediaStreamSourcesQueryCompleted(sources);
+}
+
+void MediaStreamCenter::didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, unsigned)
+{
+}
+
+void MediaStreamCenter::didStopLocalMediaStream(MediaStreamDescriptor*)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)

Copied: trunk/Source/WebCore/platform/mediastream/MediaStreamCenter.h (from rev 100996, trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h) (0 => 100997)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamCenter.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamCenter.h	2011-11-22 14:26:31 UTC (rev 100997)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011 Ericsson AB. 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 MediaStreamCenter_h
+#define MediaStreamCenter_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "MediaStreamSource.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+class MediaStreamDescriptor;
+
+class MediaStreamSourcesQueryClient : public RefCounted<MediaStreamSourcesQueryClient> {
+public:
+    virtual ~MediaStreamSourcesQueryClient() { }
+
+    virtual bool audio() const = 0;
+    virtual bool video() const = 0;
+
+    virtual void mediaStreamSourcesQueryCompleted(const MediaStreamSourceVector&) = 0;
+};
+
+class MediaStreamCenter {
+    WTF_MAKE_NONCOPYABLE(MediaStreamCenter);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    ~MediaStreamCenter();
+
+    static MediaStreamCenter& instance();
+
+    void queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient>);
+
+    // FIXME: add a way to mute a MediaStreamSource from the WebKit API layer
+
+    // Calls from the DOM objects to notify the platform
+    void didSetMediaStreamTrackEnabled(MediaStreamDescriptor*, unsigned componentIndex);
+    void didStopLocalMediaStream(MediaStreamDescriptor*);
+
+    // Calls from the platform to update the DOM objects
+    void endLocalMediaStream(MediaStreamDescriptor*);
+
+private:
+    MediaStreamCenter();
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MediaStreamCenter_h

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h (100996 => 100997)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h	2011-11-22 14:14:17 UTC (rev 100996)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamDescriptor.h	2011-11-22 14:26:31 UTC (rev 100997)
@@ -39,8 +39,13 @@
 
 namespace WebCore {
 
-class MediaStream;
+class MediaStreamDescriptorOwner {
+public:
+    virtual ~MediaStreamDescriptorOwner() { }
 
+    virtual void streamEnded() = 0;
+};
+
 class MediaStreamDescriptor : public RefCounted<MediaStreamDescriptor> {
 public:
     static PassRefPtr<MediaStreamDescriptor> create(const String& label, const MediaStreamSourceVector& sources)
@@ -48,8 +53,8 @@
         return adoptRef(new MediaStreamDescriptor(label, sources));
     }
 
-    MediaStream* owner() const { return m_owner; }
-    void setOwner(MediaStream* owner) { m_owner = owner; }
+    MediaStreamDescriptorOwner* owner() const { return m_owner; }
+    void setOwner(MediaStreamDescriptorOwner* owner) { m_owner = owner; }
 
     String label() const { return m_label; }
 
@@ -69,7 +74,7 @@
             m_components.append(MediaStreamComponent::create(sources[i]));
     }
 
-    MediaStream* m_owner;
+    MediaStreamDescriptorOwner* m_owner;
     String m_label;
     Vector<RefPtr<MediaStreamComponent> > m_components;
     bool m_ended;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to