[OWR] Unskip fast/mediastream/MediaStream-video-element-track-stop.html
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 11:03:35 +0000 (11:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 11:03:35 +0000 (11:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165316

Patch by Alejandro G. Castro <alex@igalia.com> on 2017-01-09
Reviewed by Philippe Normand.

Source/WebCore:

Fixed the ended support of the video element in the OWR player and
fixed the videoTracks support. Now the OW player properly adds and
removes the audio and video tracks. Added the getSettings support
to the mediastream interface. Solved also the size handling in
some of the enable/muted situations.

Unskipping fast/mediastream/MediaStream-video-element-track-stop.html.

* platform/GStreamer.cmake: Added the new
RealtimeMediaSourceOwr.cpp with the new code handling the
settings.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.cpp:
(WebCore::MediaPlayerPrivateGStreamerOwr::~MediaPlayerPrivateGStreamerOwr):
Release the new video and audio maps that creates a relationship
of the mediastream tracks with the mediatracks of the video element.
(WebCore::MediaPlayerPrivateGStreamerOwr::play): Set ended to
false when we start playing.
(WebCore::MediaPlayerPrivateGStreamerOwr::load): Create the media
tracks to the player so that the videoTracks API returns it, and
add an entry in the map to be able to restore it using the
mediastream track.
(WebCore::MediaPlayerPrivateGStreamerOwr::disableMediaTracks):
Move some part of the stop function to this one in order to use it
in pause method and avoid changing the video selection in that
case.
(WebCore::MediaPlayerPrivateGStreamerOwr::stop): Now we call the
function disableMediaTracks and we also change teh selected
videoTrack.
(WebCore::MediaPlayerPrivateGStreamerOwr::trackEnded): For
videoTrack reset the size and the selected element. In case there
is no media playing we Make sure we set the ended variable to true
and call the timeChange to modify the state of the player.
(WebCore::MediaPlayerPrivateGStreamerOwr::trackEnabledChanged):
Handle properly the situation when the user changed the enabled
value, we disable the media.
(WebCore::MediaPlayerPrivateGStreamerOwr::setSize): Modify the
size of the source.
(WebCore::MediaPlayerPrivateGStreamerOwr::naturalSize): Overrided
to make sure we return a size even when the sample is not ready
for gst.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.h:
Added the ended attribute and the maps.
* platform/mediastream/openwebrtc/MediaEndpointOwr.cpp:
(WebCore::MediaEndpointOwr::createMutedRemoteSource): Use the new
realtime video and audio sources classes, this new classes
implement the settings of each type of media element.
* platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
(WebCore::RealtimeMediaSourceCenterOwr::mediaSourcesAvailable):
Use the new audio and video source classes instead of the general
one in order to handle the settings properly.
* platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp: Added
(WebCore::RealtimeMediaSourceOwr::settings): Initialize using the
subclass and return the new currentSettings attribute.
(WebCore::RealtimeMediaSourceOwr::supportedConstraints): Call the
subclass initialization of the supportedSettings.
* platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h:
(WebCore::RealtimeMediaSourceOwr::initializeSettings): Added to
initialize the settings before returning the value. Implemented in
the subclass.
(WebCore::RealtimeMediaSourceOwr::initializeSupportedConstraints):
Added to initialize the supported settings of the
media. Implemented in the subclass.
(WebCore::RealtimeMediaSourceOwr::settings): Moved to the cpp
file, implemented using the initialize functions of the subclass
* platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h: Added
this new class to handle the settings of the video elements. The
class initializes the settings and the supportedSettings.
* platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h: Added
this new class to handle the settings of the audio elements. The
class initializes the settings and the supportedSettings.

LayoutTests:

* platform/gtk/TestExpectations: Unskipped the test and moved the
stop one, now it does not timeout because we correctly handle the
ended value but still fails, we need more features in the mock
classes for owr.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/GStreamer.cmake
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.h
Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.cpp
Source/WebCore/platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h [new file with mode: 0644]
Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp
Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp [new file with mode: 0644]
Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h
Source/WebCore/platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h [new file with mode: 0644]

index 7ccd142..e92b99a 100644 (file)
@@ -1,3 +1,15 @@
+2017-01-09  Alejandro G. Castro  <alex@igalia.com>
+
+        [OWR] Unskip fast/mediastream/MediaStream-video-element-track-stop.html
+        https://bugs.webkit.org/show_bug.cgi?id=165316
+
+        Reviewed by Philippe Normand.
+
+        * platform/gtk/TestExpectations: Unskipped the test and moved the
+        stop one, now it does not timeout because we correctly handle the
+        ended value but still fails, we need more features in the mock
+        classes for owr.
+
 2017-01-08  Filip Pizlo  <fpizlo@apple.com>
 
         Unreviewed, since this test is slow it should run in fewer configurations. This resolves the
index 9c6742d..a049fb2 100644 (file)
@@ -310,7 +310,6 @@ webkit.org/b/79203 fast/events/constructors/media-stream-event-constructor.html
 webkit.org/b/79203 webaudio/mediastreamaudiodestinationnode.html [ Skip ]
 webkit.org/b/79203 webaudio/mediastreamaudiosourcenode.html [ Skip ]
 webkit.org/b/79203 fast/mediastream/MediaStream-video-element.html [ Skip ]
-webkit.org/b/79203 fast/mediastream/MediaStream-video-element-track-stop.html [ Skip ]
 webkit.org/b/151344 fast/mediastream/MediaStream-add-ended-tracks.html [ Skip ]
 webkit.org/b/151344 fast/mediastream/MediaStream-add-remove-tracks.html [ Skip ]
 webkit.org/b/79203 fast/mediastream/mock-media-source.html [ Skip ]
@@ -319,6 +318,7 @@ webkit.org/b/160996 fast/mediastream/MediaStream-video-element-video-tracks-disa
 webkit.org/b/160996 fast/mediastream/apply-constraints-advanced.html [ Skip ]
 webkit.org/b/160996 fast/mediastream/apply-constraints-audio.html [ Skip ]
 webkit.org/b/160996 fast/mediastream/apply-constraints-video.html [ Skip ]
+webkit.org/b/161956 fast/mediastream/MediaStream-video-element-displays-buffer.html [ Skip ]
 
 # Proximity Events is not supported.
 webkit.org/b/99060 proximity [ Failure ]
@@ -817,8 +817,6 @@ webkit.org/b/117756 media/track/media-element-enqueue-event-crash.html [ Timeout
 
 webkit.org/b/153937 http/tests/misc/detach-during-notifyDone.html [ Crash Pass ]
 
-webkit.org/b/161956 fast/mediastream/MediaStream-video-element-displays-buffer.html [ Timeout ]
-
 webkit.org/b/131546 media/track/track-in-band.html [ Crash Timeout Failure ]
 
 webkit.org/b/163782 media/video-played-ranges-1.html [ Crash Pass ]
index a3ff5e1..34c76cd 100644 (file)
@@ -1,3 +1,82 @@
+2017-01-09  Alejandro G. Castro  <alex@igalia.com>
+
+        [OWR] Unskip fast/mediastream/MediaStream-video-element-track-stop.html
+        https://bugs.webkit.org/show_bug.cgi?id=165316
+
+        Reviewed by Philippe Normand.
+
+        Fixed the ended support of the video element in the OWR player and
+        fixed the videoTracks support. Now the OW player properly adds and
+        removes the audio and video tracks. Added the getSettings support
+        to the mediastream interface. Solved also the size handling in
+        some of the enable/muted situations.
+
+        Unskipping fast/mediastream/MediaStream-video-element-track-stop.html.
+
+        * platform/GStreamer.cmake: Added the new
+        RealtimeMediaSourceOwr.cpp with the new code handling the
+        settings.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerOwr::~MediaPlayerPrivateGStreamerOwr):
+        Release the new video and audio maps that creates a relationship
+        of the mediastream tracks with the mediatracks of the video element.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::play): Set ended to
+        false when we start playing.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::load): Create the media
+        tracks to the player so that the videoTracks API returns it, and
+        add an entry in the map to be able to restore it using the
+        mediastream track.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::disableMediaTracks):
+        Move some part of the stop function to this one in order to use it
+        in pause method and avoid changing the video selection in that
+        case.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::stop): Now we call the
+        function disableMediaTracks and we also change teh selected
+        videoTrack.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::trackEnded): For
+        videoTrack reset the size and the selected element. In case there
+        is no media playing we Make sure we set the ended variable to true
+        and call the timeChange to modify the state of the player.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::trackEnabledChanged):
+        Handle properly the situation when the user changed the enabled
+        value, we disable the media.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::setSize): Modify the
+        size of the source.
+        (WebCore::MediaPlayerPrivateGStreamerOwr::naturalSize): Overrided
+        to make sure we return a size even when the sample is not ready
+        for gst.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.h:
+        Added the ended attribute and the maps.
+        * platform/mediastream/openwebrtc/MediaEndpointOwr.cpp:
+        (WebCore::MediaEndpointOwr::createMutedRemoteSource): Use the new
+        realtime video and audio sources classes, this new classes
+        implement the settings of each type of media element.
+        * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
+        (WebCore::RealtimeMediaSourceCenterOwr::mediaSourcesAvailable):
+        Use the new audio and video source classes instead of the general
+        one in order to handle the settings properly.
+        * platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp: Added
+        (WebCore::RealtimeMediaSourceOwr::settings): Initialize using the
+        subclass and return the new currentSettings attribute.
+        (WebCore::RealtimeMediaSourceOwr::supportedConstraints): Call the
+        subclass initialization of the supportedSettings.
+        * platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h:
+        (WebCore::RealtimeMediaSourceOwr::initializeSettings): Added to
+        initialize the settings before returning the value. Implemented in
+        the subclass.
+        (WebCore::RealtimeMediaSourceOwr::initializeSupportedConstraints):
+        Added to initialize the supported settings of the
+        media. Implemented in the subclass.
+        (WebCore::RealtimeMediaSourceOwr::settings): Moved to the cpp
+        file, implemented using the initialize functions of the subclass
+        * platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h: Added
+        this new class to handle the settings of the video elements. The
+        class initializes the settings and the supportedSettings.
+        * platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h: Added
+        this new class to handle the settings of the audio elements. The
+        class initializes the settings and the supportedSettings.
+
+
 2017-01-08  Konstantin Tokarev  <annulen@yandex.ru>
 
         Introduce CPU(X86_SSE2) instead of various SSE2 checks
index 2365678..ff764be 100644 (file)
@@ -16,6 +16,7 @@ if (ENABLE_MEDIA_STREAM)
 
         platform/mediastream/openwebrtc/MediaEndpointOwr.cpp
         platform/mediastream/openwebrtc/OpenWebRTCUtilities.cpp
+        platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp
         platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp
     )
 endif ()
index 3f00e8d..ee568cb 100644 (file)
@@ -56,6 +56,9 @@ MediaPlayerPrivateGStreamerOwr::~MediaPlayerPrivateGStreamerOwr()
     if (hasVideo())
         m_videoTrack->removeObserver(*this);
 
+    m_audioTrackMap.clear();
+    m_videoTrackMap.clear();
+
     stop();
 }
 
@@ -69,6 +72,7 @@ void MediaPlayerPrivateGStreamerOwr::play()
         return;
     }
 
+    m_ended = false;
     m_paused = false;
 
     GST_DEBUG("Connecting to live stream, descriptor: %p", m_streamPrivate.get());
@@ -84,7 +88,7 @@ void MediaPlayerPrivateGStreamerOwr::pause()
 {
     GST_DEBUG("Pause");
     m_paused = true;
-    stop();
+    disableMediaTracks();
 }
 
 bool MediaPlayerPrivateGStreamerOwr::hasVideo() const
@@ -201,6 +205,9 @@ void MediaPlayerPrivateGStreamerOwr::load(MediaStreamPrivate& streamPrivate)
                 String preSelectedDevice = getenv("WEBKIT_AUDIO_DEVICE");
                 if (!preSelectedDevice || (preSelectedDevice == track->label())) {
                     m_audioTrack = track;
+                    auto audioTrack = AudioTrackPrivateMediaStream::create(*m_audioTrack.get());
+                    m_player->addAudioTrack(*audioTrack);
+                    m_audioTrackMap.add(track->id(), audioTrack);
                     observeTrack = true;
                 }
             }
@@ -210,6 +217,10 @@ void MediaPlayerPrivateGStreamerOwr::load(MediaStreamPrivate& streamPrivate)
                 String preSelectedDevice = getenv("WEBKIT_VIDEO_DEVICE");
                 if (!preSelectedDevice || (preSelectedDevice == track->label())) {
                     m_videoTrack = track;
+                    auto videoTrack = VideoTrackPrivateMediaStream::create(*m_videoTrack.get());
+                    m_player->addVideoTrack(*videoTrack);
+                    videoTrack->setSelected(true);
+                    m_videoTrackMap.add(track->id(), videoTrack);
                     observeTrack = true;
                 }
             }
@@ -245,20 +256,31 @@ bool MediaPlayerPrivateGStreamerOwr::didLoadingProgress() const
     return true;
 }
 
-void MediaPlayerPrivateGStreamerOwr::stop()
+void MediaPlayerPrivateGStreamerOwr::disableMediaTracks()
 {
     if (m_audioTrack) {
         GST_DEBUG("Stop: disconnecting audio");
-        g_object_set(m_audioRenderer.get(), "disabled", TRUE, nullptr);
+        g_object_set(m_audioRenderer.get(), "disabled", true, nullptr);
         owr_media_renderer_set_source(OWR_MEDIA_RENDERER(m_audioRenderer.get()), nullptr);
     }
+
     if (m_videoTrack) {
         GST_DEBUG("Stop: disconnecting video");
-        g_object_set(m_videoRenderer.get(), "disabled", TRUE, nullptr);
+        g_object_set(m_videoRenderer.get(), "disabled", true, nullptr);
         owr_media_renderer_set_source(OWR_MEDIA_RENDERER(m_videoRenderer.get()), nullptr);
     }
 }
 
+void MediaPlayerPrivateGStreamerOwr::stop()
+{
+    disableMediaTracks();
+    if (m_videoTrack) {
+        auto videoTrack = m_videoTrackMap.get(m_videoTrack->id());
+        if (videoTrack)
+            videoTrack->setSelected(false);
+    }
+}
+
 void MediaPlayerPrivateGStreamerOwr::registerMediaEngine(MediaEngineRegistrar registrar)
 {
     if (initializeGStreamerAndGStreamerDebugging()) {
@@ -327,9 +349,25 @@ void MediaPlayerPrivateGStreamerOwr::trackEnded(MediaStreamTrackPrivate& track)
     }
 
     if (&track == m_audioTrack)
-        g_object_set(m_audioRenderer.get(), "disabled", TRUE, nullptr);
-    else if (&track == m_videoTrack)
-        g_object_set(m_videoRenderer.get(), "disabled", TRUE, nullptr);
+        g_object_set(m_audioRenderer.get(), "disabled", true, nullptr);
+    else if (&track == m_videoTrack) {
+        g_object_set(m_videoRenderer.get(), "disabled", true, nullptr);
+        auto& realTimeMediaSource = static_cast<RealtimeMediaSourceOwr&>(m_videoTrack->source());
+        realTimeMediaSource.setWidth(0);
+        realTimeMediaSource.setHeight(0);
+        auto videoTrack = m_videoTrackMap.get(m_videoTrack->id());
+        if (videoTrack)
+            videoTrack->setSelected(false);
+    }
+
+    bool audioDisabled;
+    bool videoDisabled;
+    g_object_get(m_audioRenderer.get(), "disabled", &audioDisabled, nullptr);
+    g_object_get(m_videoRenderer.get(), "disabled", &videoDisabled, nullptr);
+    if (audioDisabled && videoDisabled) {
+        m_ended = true;
+        m_player->timeChanged();
+    }
 }
 
 void MediaPlayerPrivateGStreamerOwr::trackMutedChanged(MediaStreamTrackPrivate& track)
@@ -379,7 +417,17 @@ void MediaPlayerPrivateGStreamerOwr::trackSettingsChanged(MediaStreamTrackPrivat
 void MediaPlayerPrivateGStreamerOwr::trackEnabledChanged(MediaStreamTrackPrivate& track)
 {
     GST_DEBUG("%s track now %s", track.type() == RealtimeMediaSource::Audio ? "audio":"video", track.enabled() ? "enabled":"disabled");
-    maybeHandleChangeMutedState(track);
+
+    switch (track.type()) {
+    case RealtimeMediaSource::Audio:
+        g_object_set(m_audioRenderer.get(), "disabled", !track.enabled(), nullptr);
+        break;
+    case RealtimeMediaSource::Video:
+        g_object_set(m_videoRenderer.get(), "disabled", !track.enabled(), nullptr);
+        break;
+    case RealtimeMediaSource::None:
+        GST_WARNING("Trying to change enabled state of a track with None type");
+    }
 }
 
 GstElement* MediaPlayerPrivateGStreamerOwr::createVideoSink()
@@ -426,6 +474,26 @@ void MediaPlayerPrivateGStreamerOwr::setSize(const IntSize& size)
     MediaPlayerPrivateGStreamerBase::setSize(size);
     if (m_videoRenderer)
         g_object_set(m_videoRenderer.get(), "width", size.width(), "height", size.height(), nullptr);
+
+    if (!m_videoTrack)
+        return;
+
+    auto& realTimeMediaSource = static_cast<RealtimeMediaSourceOwr&>(m_videoTrack->source());
+    realTimeMediaSource.setWidth(size.width());
+    realTimeMediaSource.setHeight(size.height());
+}
+
+FloatSize MediaPlayerPrivateGStreamerOwr::naturalSize() const
+{
+    auto size = MediaPlayerPrivateGStreamerBase::naturalSize();
+
+    // In case we are not playing the video we return the size we set to the media source.
+    if (m_videoTrack && size.isZero()) {
+        auto& realTimeMediaSource = static_cast<RealtimeMediaSourceOwr&>(m_videoTrack->source());
+        return realTimeMediaSource.size();
+    }
+
+    return size;
 }
 
 } // namespace WebCore
index e622d42..334630e 100644 (file)
 
 #if ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER) && USE(OPENWEBRTC)
 
+#include "AudioTrackPrivateMediaStream.h"
 #include "MediaPlayerPrivateGStreamerBase.h"
 #include "MediaStreamTrackPrivate.h"
+#include "VideoTrackPrivateMediaStream.h"
 
 typedef struct _OwrGstVideoRenderer OwrGstVideoRenderer;
 typedef struct _OwrGstAudioRenderer OwrGstAudioRenderer;
@@ -42,6 +44,8 @@ public:
 
     void setSize(const IntSize&) final;
 
+    FloatSize naturalSize() const final;
+
 private:
     GstElement* createVideoSink() final;
     GstElement* audioSink() const final { return m_audioSink.get(); }
@@ -87,6 +91,7 @@ private:
 
     bool canLoadPoster() const final { return false; }
     void setPoster(const String&) final { }
+    bool ended() const final { return m_ended; }
 
     // MediaStreamTrackPrivate::Observer implementation.
     void trackEnded(MediaStreamTrackPrivate&) final;
@@ -101,14 +106,19 @@ private:
     void loadingFailed(MediaPlayer::NetworkState error);
     void stop();
     void maybeHandleChangeMutedState(MediaStreamTrackPrivate&);
+    void disableMediaTracks();
 
     bool m_paused { true };
+    bool m_ended { false };
     RefPtr<MediaStreamTrackPrivate> m_videoTrack;
     RefPtr<MediaStreamTrackPrivate> m_audioTrack;
     GRefPtr<GstElement> m_audioSink;
     RefPtr<MediaStreamPrivate> m_streamPrivate;
     GRefPtr<OwrGstVideoRenderer> m_videoRenderer;
     GRefPtr<OwrGstAudioRenderer> m_audioRenderer;
+
+    HashMap<String, RefPtr<AudioTrackPrivateMediaStream>> m_audioTrackMap;
+    HashMap<String, RefPtr<VideoTrackPrivateMediaStream>> m_videoTrackMap;
 };
 
 } // namespace WebCore
index a7a21f4..44839d1 100644 (file)
@@ -39,7 +39,8 @@
 #include "OpenWebRTCUtilities.h"
 #include "PeerConnectionStates.h"
 #include "RTCDataChannelHandler.h"
-#include "RealtimeMediaSourceOwr.h"
+#include "RealtimeAudioSourceOwr.h"
+#include "RealtimeVideoSourceOwr.h"
 #include <owr/owr.h>
 #include <owr/owr_audio_payload.h>
 #include <owr/owr_crypto_utils.h>
@@ -350,15 +351,21 @@ Ref<RealtimeMediaSource> MediaEndpointOwr::createMutedRemoteSource(const String&
 {
     String name;
     String id("not used");
+    RefPtr<RealtimeMediaSourceOwr> source;
 
     switch (type) {
-    case RealtimeMediaSource::Audio: name = "remote audio"; break;
-    case RealtimeMediaSource::Video: name = "remote video"; break;
+    case RealtimeMediaSource::Audio:
+        name = "remote audio";
+        source = adoptRef(new RealtimeAudioSourceOwr(nullptr, id, type, name));
+        break;
+    case RealtimeMediaSource::Video:
+        name = "remote video";
+        source = adoptRef(new RealtimeVideoSourceOwr(nullptr, id, type, name));
+        break;
     case RealtimeMediaSource::None:
         ASSERT_NOT_REACHED();
     }
 
-    RefPtr<RealtimeMediaSourceOwr> source = adoptRef(new RealtimeMediaSourceOwr(nullptr, id, type, name));
     m_mutedRemoteSources.set(mid, source);
 
     return *source;
diff --git a/Source/WebCore/platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h b/Source/WebCore/platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h
new file mode 100644 (file)
index 0000000..2349f05
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015,2016 Igalia S.L
+ * Copyright (C) 2015 Metrological
+ *
+ * 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 the copyright holder 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
+ * HOLDER 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.
+ */
+
+#pragma once
+
+#if ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
+
+#include "RealtimeMediaSourceOwr.h"
+
+namespace WebCore {
+
+class RealtimeAudioSourceOwr : public RealtimeMediaSourceOwr {
+public:
+RealtimeAudioSourceOwr(OwrMediaSource* mediaSource, const String& id, RealtimeMediaSource::Type type, const String& name)
+    : RealtimeMediaSourceOwr(mediaSource, id, type, name)
+    {
+    }
+
+RealtimeAudioSourceOwr(const String& id, RealtimeMediaSource::Type type, const String& name)
+    : RealtimeMediaSourceOwr(id, type, name)
+    {
+    }
+
+    virtual ~RealtimeAudioSourceOwr() { }
+
+    bool applySize(const IntSize&) final { return false; }
+
+protected:
+    void initializeSettings() final {
+        if (m_currentSettings.deviceId().isEmpty())
+            m_currentSettings.setSupportedConstraits(supportedConstraints());
+
+        m_currentSettings.setDeviceId(id());
+    }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
index 67c91b8..f3e6f1f 100644 (file)
@@ -40,7 +40,9 @@
 #include "MediaStreamPrivate.h"
 #include "NotImplemented.h"
 #include "OpenWebRTCUtilities.h"
+#include "RealtimeAudioSourceOwr.h"
 #include "RealtimeMediaSourceCapabilities.h"
+#include "RealtimeVideoSourceOwr.h"
 #include "UUID.h"
 #include <owr/owr.h>
 #include <owr/owr_local.h>
@@ -149,16 +151,21 @@ void RealtimeMediaSourceCenterOwr::mediaSourcesAvailable(GList* sources)
             ASSERT_NOT_REACHED();
         }
 
-        auto mediaSource = adoptRef(*new RealtimeMediaSourceOwr(source, id, mediaSourceType, sourceName));
+        RefPtr<RealtimeMediaSourceOwr> mediaSource;
+        if (mediaSourceType == RealtimeMediaSource::Audio)
+            mediaSource = adoptRef(new RealtimeAudioSourceOwr(source, id, mediaSourceType, sourceName));
+        else
+            mediaSource = adoptRef(new RealtimeVideoSourceOwr(source, id, mediaSourceType, sourceName));
 
         RealtimeMediaSourceOwrMap::iterator sourceIterator = m_sourceMap.find(id);
         if (sourceIterator == m_sourceMap.end())
             m_sourceMap.add(id, mediaSource.copyRef());
 
         if (mediaType & OWR_MEDIA_TYPE_AUDIO)
-            audioSources.append(WTFMove(mediaSource));
+            audioSources.append(mediaSource.releaseNonNull());
         else if (mediaType & OWR_MEDIA_TYPE_VIDEO)
-            videoSources.append(WTFMove(mediaSource));
+            videoSources.append(mediaSource.releaseNonNull());
+
     }
 
     if (videoSources.isEmpty() && audioSources.isEmpty())
diff --git a/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp b/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp
new file mode 100644 (file)
index 0000000..ee7499d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 Igalia S.L
+ *
+ * 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 the copyright holder 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
+ * HOLDER 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) && USE(OPENWEBRTC)
+#include "RealtimeMediaSourceOwr.h"
+
+namespace WebCore {
+
+const RealtimeMediaSourceSettings& RealtimeMediaSourceOwr::settings() const
+{
+    const_cast<RealtimeMediaSourceOwr&>(*this).initializeSettings();
+    return m_currentSettings;
+}
+
+RealtimeMediaSourceSupportedConstraints& RealtimeMediaSourceOwr::supportedConstraints()
+{
+    if (m_supportedConstraints.supportsDeviceId())
+        return m_supportedConstraints;
+
+    m_supportedConstraints.setSupportsDeviceId(true);
+    initializeSupportedConstraints(m_supportedConstraints);
+
+    return m_supportedConstraints;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
index 1bf5128..a8f78e2 100644 (file)
@@ -73,13 +73,20 @@ RealtimeMediaSourceOwr(const String& id, RealtimeMediaSource::Type type, const S
     }
 
     RefPtr<RealtimeMediaSourceCapabilities> capabilities() const override { return m_capabilities; }
-    const RealtimeMediaSourceSettings& settings() const override { return m_currentSettings; }
+    const RealtimeMediaSourceSettings& settings() const override;
 
     OwrMediaSource* mediaSource() const { return m_mediaSource; }
 
+protected:
+    virtual void initializeSettings() { };
+    virtual void initializeSupportedConstraints(RealtimeMediaSourceSupportedConstraints&) { };
+    RealtimeMediaSourceSupportedConstraints& supportedConstraints();
+
+    RealtimeMediaSourceSettings m_currentSettings;
+
 private:
+    RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
     RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
-    RealtimeMediaSourceSettings m_currentSettings;
     OwrMediaSource* m_mediaSource;
 };
 
diff --git a/Source/WebCore/platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h b/Source/WebCore/platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h
new file mode 100644 (file)
index 0000000..dc66a3e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2015,2016 Igalia S.L
+ * Copyright (C) 2015 Metrological
+ *
+ * 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 the copyright holder 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
+ * HOLDER 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.
+ */
+
+#pragma once
+
+#if ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
+
+#include "RealtimeMediaSourceOwr.h"
+
+namespace WebCore {
+
+class RealtimeVideoSourceOwr : public RealtimeMediaSourceOwr {
+public:
+RealtimeVideoSourceOwr(OwrMediaSource* mediaSource, const String& id, RealtimeMediaSource::Type type, const String& name)
+    : RealtimeMediaSourceOwr(mediaSource, id, type, name)
+    {
+    }
+
+RealtimeVideoSourceOwr(const String& id, RealtimeMediaSource::Type type, const String& name)
+    : RealtimeMediaSourceOwr(id, type, name)
+    {
+    }
+
+    virtual ~RealtimeVideoSourceOwr() { }
+
+    bool applySize(const IntSize&) final { return true; }
+
+protected:
+    void initializeSettings() final {
+        if (m_currentSettings.deviceId().isEmpty())
+            m_currentSettings.setSupportedConstraits(supportedConstraints());
+
+        m_currentSettings.setDeviceId(id());
+
+        m_currentSettings.setFrameRate(frameRate());
+        m_currentSettings.setWidth(size().width());
+        m_currentSettings.setHeight(size().height());
+    }
+
+    void initializeSupportedConstraints(RealtimeMediaSourceSupportedConstraints& supportedConstraints) final {
+        supportedConstraints.setSupportsFacingMode(RealtimeMediaSourceSettings::Unknown);
+        supportedConstraints.setSupportsWidth(true);
+        supportedConstraints.setSupportsHeight(true);
+        supportedConstraints.setSupportsAspectRatio(true);
+        supportedConstraints.setSupportsFrameRate(true);
+    }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)