Changeset 209860 in webkit


Ignore:
Timestamp:
Dec 15, 2016 5:15:33 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[OWR] Unskip fast/mediastream/MediaStream-video-element-track-stop.html
https://bugs.webkit.org/show_bug.cgi?id=165316

Patch by Alejandro G. Castro <alex@igalia.com> on 2016-12-15
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.

Location:
trunk
Files:
9 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r209849 r209860  
     12016-12-15  Alejandro G. Castro  <alex@igalia.com>
     2
     3        [OWR] Unskip fast/mediastream/MediaStream-video-element-track-stop.html
     4        https://bugs.webkit.org/show_bug.cgi?id=165316
     5
     6        Reviewed by Philippe Normand.
     7
     8        * platform/gtk/TestExpectations: Unskipped the test and moved the
     9        stop one, now it does not timeout because we correctly handle the
     10        ended value but still fails, we need more features in the mock
     11        classes for owr.
     12
    1132016-12-14  Yusuke Suzuki  <utatane.tea@gmail.com>
    214
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r209849 r209860  
    315315webkit.org/b/79203 webaudio/mediastreamaudiosourcenode.html [ Skip ]
    316316webkit.org/b/79203 fast/mediastream/MediaStream-video-element.html [ Skip ]
    317 webkit.org/b/79203 fast/mediastream/MediaStream-video-element-track-stop.html [ Skip ]
    318317webkit.org/b/151344 fast/mediastream/MediaStream-add-ended-tracks.html [ Skip ]
    319318webkit.org/b/151344 fast/mediastream/MediaStream-add-remove-tracks.html [ Skip ]
     
    324323webkit.org/b/160996 fast/mediastream/apply-constraints-audio.html [ Skip ]
    325324webkit.org/b/160996 fast/mediastream/apply-constraints-video.html [ Skip ]
     325webkit.org/b/161956 fast/mediastream/MediaStream-video-element-displays-buffer.html [ Skip ]
    326326
    327327# Proximity Events is not supported.
     
    822822webkit.org/b/153937 http/tests/misc/detach-during-notifyDone.html [ Crash Pass ]
    823823
    824 webkit.org/b/161956 fast/mediastream/MediaStream-video-element-displays-buffer.html [ Timeout ]
    825 
    826824webkit.org/b/131546 media/track/track-in-band.html [ Crash Timeout Failure ]
    827825
  • trunk/Source/WebCore/ChangeLog

    r209857 r209860  
     12016-12-15  Alejandro G. Castro  <alex@igalia.com>
     2
     3        [OWR] Unskip fast/mediastream/MediaStream-video-element-track-stop.html
     4        https://bugs.webkit.org/show_bug.cgi?id=165316
     5
     6        Reviewed by Philippe Normand.
     7
     8        Fixed the ended support of the video element in the OWR player and
     9        fixed the videoTracks support. Now the OW player properly adds and
     10        removes the audio and video tracks. Added the getSettings support
     11        to the mediastream interface. Solved also the size handling in
     12        some of the enable/muted situations.
     13
     14        Unskipping fast/mediastream/MediaStream-video-element-track-stop.html.
     15
     16        * platform/GStreamer.cmake: Added the new
     17        RealtimeMediaSourceOwr.cpp with the new code handling the
     18        settings.
     19        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.cpp:
     20        (WebCore::MediaPlayerPrivateGStreamerOwr::~MediaPlayerPrivateGStreamerOwr):
     21        Release the new video and audio maps that creates a relationship
     22        of the mediastream tracks with the mediatracks of the video element.
     23        (WebCore::MediaPlayerPrivateGStreamerOwr::play): Set ended to
     24        false when we start playing.
     25        (WebCore::MediaPlayerPrivateGStreamerOwr::load): Create the media
     26        tracks to the player so that the videoTracks API returns it, and
     27        add an entry in the map to be able to restore it using the
     28        mediastream track.
     29        (WebCore::MediaPlayerPrivateGStreamerOwr::disableMediaTracks):
     30        Move some part of the stop function to this one in order to use it
     31        in pause method and avoid changing the video selection in that
     32        case.
     33        (WebCore::MediaPlayerPrivateGStreamerOwr::stop): Now we call the
     34        function disableMediaTracks and we also change teh selected
     35        videoTrack.
     36        (WebCore::MediaPlayerPrivateGStreamerOwr::trackEnded): For
     37        videoTrack reset the size and the selected element. In case there
     38        is no media playing we Make sure we set the ended variable to true
     39        and call the timeChange to modify the state of the player.
     40        (WebCore::MediaPlayerPrivateGStreamerOwr::trackEnabledChanged):
     41        Handle properly the situation when the user changed the enabled
     42        value, we disable the media.
     43        (WebCore::MediaPlayerPrivateGStreamerOwr::setSize): Modify the
     44        size of the source.
     45        (WebCore::MediaPlayerPrivateGStreamerOwr::naturalSize): Overrided
     46        to make sure we return a size even when the sample is not ready
     47        for gst.
     48        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.h:
     49        Added the ended attribute and the maps.
     50        * platform/mediastream/openwebrtc/MediaEndpointOwr.cpp:
     51        (WebCore::MediaEndpointOwr::createMutedRemoteSource): Use the new
     52        realtime video and audio sources classes, this new classes
     53        implement the settings of each type of media element.
     54        * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
     55        (WebCore::RealtimeMediaSourceCenterOwr::mediaSourcesAvailable):
     56        Use the new audio and video source classes instead of the general
     57        one in order to handle the settings properly.
     58        * platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp: Added
     59        (WebCore::RealtimeMediaSourceOwr::settings): Initialize using the
     60        subclass and return the new currentSettings attribute.
     61        (WebCore::RealtimeMediaSourceOwr::supportedConstraints): Call the
     62        subclass initialization of the supportedSettings.
     63        * platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h:
     64        (WebCore::RealtimeMediaSourceOwr::initializeSettings): Added to
     65        initialize the settings before returning the value. Implemented in
     66        the subclass.
     67        (WebCore::RealtimeMediaSourceOwr::initializeSupportedConstraints):
     68        Added to initialize the supported settings of the
     69        media. Implemented in the subclass.
     70        (WebCore::RealtimeMediaSourceOwr::settings): Moved to the cpp
     71        file, implemented using the initialize functions of the subclass
     72        * platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h: Added
     73        this new class to handle the settings of the video elements. The
     74        class initializes the settings and the supportedSettings.
     75        * platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h: Added
     76        this new class to handle the settings of the audio elements. The
     77        class initializes the settings and the supportedSettings.
     78
     79
    1802016-12-15  Alex Christensen  <achristensen@webkit.org>
    281
  • trunk/Source/WebCore/platform/GStreamer.cmake

    r207891 r209860  
    1717        platform/mediastream/openwebrtc/MediaEndpointOwr.cpp
    1818        platform/mediastream/openwebrtc/OpenWebRTCUtilities.cpp
     19        platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp
    1920        platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp
    2021    )
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.cpp

    r209125 r209860  
    5757        m_videoTrack->removeObserver(*this);
    5858
     59    m_audioTrackMap.clear();
     60    m_videoTrackMap.clear();
     61
    5962    stop();
    6063}
     
    7073    }
    7174
     75    m_ended = false;
    7276    m_paused = false;
    7377
     
    8589    GST_DEBUG("Pause");
    8690    m_paused = true;
    87     stop();
     91    disableMediaTracks();
    8892}
    8993
     
    202206                if (!preSelectedDevice || (preSelectedDevice == track->label())) {
    203207                    m_audioTrack = track;
     208                    auto audioTrack = AudioTrackPrivateMediaStream::create(*m_audioTrack.get());
     209                    m_player->addAudioTrack(*audioTrack);
     210                    m_audioTrackMap.add(track->id(), audioTrack);
    204211                    observeTrack = true;
    205212                }
     
    211218                if (!preSelectedDevice || (preSelectedDevice == track->label())) {
    212219                    m_videoTrack = track;
     220                    auto videoTrack = VideoTrackPrivateMediaStream::create(*m_videoTrack.get());
     221                    m_player->addVideoTrack(*videoTrack);
     222                    videoTrack->setSelected(true);
     223                    m_videoTrackMap.add(track->id(), videoTrack);
    213224                    observeTrack = true;
    214225                }
     
    246257}
    247258
    248 void MediaPlayerPrivateGStreamerOwr::stop()
     259void MediaPlayerPrivateGStreamerOwr::disableMediaTracks()
    249260{
    250261    if (m_audioTrack) {
    251262        GST_DEBUG("Stop: disconnecting audio");
    252         g_object_set(m_audioRenderer.get(), "disabled", TRUE, nullptr);
     263        g_object_set(m_audioRenderer.get(), "disabled", true, nullptr);
    253264        owr_media_renderer_set_source(OWR_MEDIA_RENDERER(m_audioRenderer.get()), nullptr);
    254265    }
     266
    255267    if (m_videoTrack) {
    256268        GST_DEBUG("Stop: disconnecting video");
    257         g_object_set(m_videoRenderer.get(), "disabled", TRUE, nullptr);
     269        g_object_set(m_videoRenderer.get(), "disabled", true, nullptr);
    258270        owr_media_renderer_set_source(OWR_MEDIA_RENDERER(m_videoRenderer.get()), nullptr);
     271    }
     272}
     273
     274void MediaPlayerPrivateGStreamerOwr::stop()
     275{
     276    disableMediaTracks();
     277    if (m_videoTrack) {
     278        auto videoTrack = m_videoTrackMap.get(m_videoTrack->id());
     279        if (videoTrack)
     280            videoTrack->setSelected(false);
    259281    }
    260282}
     
    328350
    329351    if (&track == m_audioTrack)
    330         g_object_set(m_audioRenderer.get(), "disabled", TRUE, nullptr);
    331     else if (&track == m_videoTrack)
    332         g_object_set(m_videoRenderer.get(), "disabled", TRUE, nullptr);
     352        g_object_set(m_audioRenderer.get(), "disabled", true, nullptr);
     353    else if (&track == m_videoTrack) {
     354        g_object_set(m_videoRenderer.get(), "disabled", true, nullptr);
     355        auto& realTimeMediaSource = static_cast<RealtimeMediaSourceOwr&>(m_videoTrack->source());
     356        realTimeMediaSource.setWidth(0);
     357        realTimeMediaSource.setHeight(0);
     358        auto videoTrack = m_videoTrackMap.get(m_videoTrack->id());
     359        if (videoTrack)
     360            videoTrack->setSelected(false);
     361    }
     362
     363    bool audioDisabled;
     364    bool videoDisabled;
     365    g_object_get(m_audioRenderer.get(), "disabled", &audioDisabled, nullptr);
     366    g_object_get(m_videoRenderer.get(), "disabled", &videoDisabled, nullptr);
     367    if (audioDisabled && videoDisabled) {
     368        m_ended = true;
     369        m_player->timeChanged();
     370    }
    333371}
    334372
     
    380418{
    381419    GST_DEBUG("%s track now %s", track.type() == RealtimeMediaSource::Audio ? "audio":"video", track.enabled() ? "enabled":"disabled");
    382     maybeHandleChangeMutedState(track);
     420
     421    switch (track.type()) {
     422    case RealtimeMediaSource::Audio:
     423        g_object_set(m_audioRenderer.get(), "disabled", !track.enabled(), nullptr);
     424        break;
     425    case RealtimeMediaSource::Video:
     426        g_object_set(m_videoRenderer.get(), "disabled", !track.enabled(), nullptr);
     427        break;
     428    case RealtimeMediaSource::None:
     429        GST_WARNING("Trying to change enabled state of a track with None type");
     430    }
    383431}
    384432
     
    427475    if (m_videoRenderer)
    428476        g_object_set(m_videoRenderer.get(), "width", size.width(), "height", size.height(), nullptr);
     477
     478    auto& realTimeMediaSource = static_cast<RealtimeMediaSourceOwr&>(m_videoTrack->source());
     479    realTimeMediaSource.setWidth(size.width());
     480    realTimeMediaSource.setHeight(size.height());
     481}
     482
     483FloatSize MediaPlayerPrivateGStreamerOwr::naturalSize() const
     484{
     485    auto size = MediaPlayerPrivateGStreamerBase::naturalSize();
     486
     487    // In case we are not playing the video we return the size we set to the media source.
     488    if (size.isZero()) {
     489        auto& realTimeMediaSource = static_cast<RealtimeMediaSourceOwr&>(m_videoTrack->source());
     490        return realTimeMediaSource.size();
     491    }
     492
     493    return size;
    429494}
    430495
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerOwr.h

    r208943 r209860  
    2323#if ENABLE(VIDEO) && ENABLE(MEDIA_STREAM) && USE(GSTREAMER) && USE(OPENWEBRTC)
    2424
     25#include "AudioTrackPrivateMediaStream.h"
    2526#include "MediaPlayerPrivateGStreamerBase.h"
    2627#include "MediaStreamTrackPrivate.h"
     28#include "VideoTrackPrivateMediaStream.h"
    2729
    2830typedef struct _OwrGstVideoRenderer OwrGstVideoRenderer;
     
    4244
    4345    void setSize(const IntSize&) final;
     46
     47    FloatSize naturalSize() const final;
    4448
    4549private:
     
    8892    bool canLoadPoster() const final { return false; }
    8993    void setPoster(const String&) final { }
     94    bool ended() const final { return m_ended; }
    9095
    9196    // MediaStreamTrackPrivate::Observer implementation.
     
    102107    void stop();
    103108    void maybeHandleChangeMutedState(MediaStreamTrackPrivate&);
     109    void disableMediaTracks();
    104110
    105111    bool m_paused { true };
     112    bool m_ended { false };
    106113    RefPtr<MediaStreamTrackPrivate> m_videoTrack;
    107114    RefPtr<MediaStreamTrackPrivate> m_audioTrack;
     
    110117    GRefPtr<OwrGstVideoRenderer> m_videoRenderer;
    111118    GRefPtr<OwrGstAudioRenderer> m_audioRenderer;
     119
     120    HashMap<String, RefPtr<AudioTrackPrivateMediaStream>> m_audioTrackMap;
     121    HashMap<String, RefPtr<VideoTrackPrivateMediaStream>> m_videoTrackMap;
    112122};
    113123
  • trunk/Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.cpp

    r208944 r209860  
    4040#include "PeerConnectionStates.h"
    4141#include "RTCDataChannelHandler.h"
    42 #include "RealtimeMediaSourceOwr.h"
     42#include "RealtimeAudioSourceOwr.h"
     43#include "RealtimeVideoSourceOwr.h"
    4344#include <owr/owr.h>
    4445#include <owr/owr_audio_payload.h>
     
    351352    String name;
    352353    String id("not used");
     354    RefPtr<RealtimeMediaSourceOwr> source;
    353355
    354356    switch (type) {
    355     case RealtimeMediaSource::Audio: name = "remote audio"; break;
    356     case RealtimeMediaSource::Video: name = "remote video"; break;
     357    case RealtimeMediaSource::Audio:
     358        name = "remote audio";
     359        source = adoptRef(new RealtimeAudioSourceOwr(nullptr, id, type, name));
     360        break;
     361    case RealtimeMediaSource::Video:
     362        name = "remote video";
     363        source = adoptRef(new RealtimeVideoSourceOwr(nullptr, id, type, name));
     364        break;
    357365    case RealtimeMediaSource::None:
    358366        ASSERT_NOT_REACHED();
    359367    }
    360368
    361     RefPtr<RealtimeMediaSourceOwr> source = adoptRef(new RealtimeMediaSourceOwr(nullptr, id, type, name));
    362369    m_mutedRemoteSources.set(mid, source);
    363370
  • trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h

    r209859 r209860  
    11/*
    2  * Copyright (C) 2015 Igalia S.L
     2 * Copyright (C) 2015,2016 Igalia S.L
    33 * Copyright (C) 2015 Metrological
    44 *
     
    3333 */
    3434
    35 #ifndef RealtimeMediaSourceOwr_h
    36 #define RealtimeMediaSourceOwr_h
     35#pragma once
    3736
    3837#if ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
    3938
    40 #include "GRefPtrGStreamer.h"
    41 #include "RealtimeMediaSource.h"
    42 #include <owr/owr_media_source.h>
    43 #include <wtf/HashMap.h>
    44 #include <wtf/RefPtr.h>
    45 #include <wtf/text/WTFString.h>
     39#include "RealtimeMediaSourceOwr.h"
    4640
    4741namespace WebCore {
    4842
    49 class RealtimeMediaSourceCapabilities;
    50 
    51 class RealtimeMediaSourceOwr : public RealtimeMediaSource {
     43class RealtimeAudioSourceOwr : public RealtimeMediaSourceOwr {
    5244public:
    53 RealtimeMediaSourceOwr(OwrMediaSource* mediaSource, const String& id, RealtimeMediaSource::Type type, const String& name)
    54     : RealtimeMediaSource(id, type, name)
    55     , m_mediaSource(mediaSource)
    56     {
    57         if (!mediaSource)
    58             m_muted = true;
    59     }
    60 
    61 RealtimeMediaSourceOwr(const String& id, RealtimeMediaSource::Type type, const String& name)
    62     : RealtimeMediaSource(id, type, name)
    63     , m_mediaSource(nullptr)
     45RealtimeAudioSourceOwr(OwrMediaSource* mediaSource, const String& id, RealtimeMediaSource::Type type, const String& name)
     46    : RealtimeMediaSourceOwr(mediaSource, id, type, name)
    6447    {
    6548    }
    6649
    67     virtual ~RealtimeMediaSourceOwr() { }
    68 
    69     void swapOutShallowSource(OwrMediaSource& realSource)
     50RealtimeAudioSourceOwr(const String& id, RealtimeMediaSource::Type type, const String& name)
     51    : RealtimeMediaSourceOwr(id, type, name)
    7052    {
    71         m_mediaSource = &realSource;
    72         setMuted(false);
    7353    }
    7454
    75     virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() const { return m_capabilities; }
    76     virtual const RealtimeMediaSourceSettings& settings() const { return m_currentSettings; }
     55    virtual ~RealtimeAudioSourceOwr() { }
    7756
    78     OwrMediaSource* mediaSource() const { return m_mediaSource; }
     57    bool applySize(const IntSize&) final { return false; }
    7958
    80 private:
    81     RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
    82     RealtimeMediaSourceSettings m_currentSettings;
    83     OwrMediaSource* m_mediaSource;
     59protected:
     60    void initializeSettings() final {
     61        if (m_currentSettings.deviceId().isEmpty())
     62            m_currentSettings.setSupportedConstraits(supportedConstraints());
     63
     64        m_currentSettings.setDeviceId(id());
     65    }
    8466};
    85 
    86 typedef HashMap<String, RefPtr<RealtimeMediaSourceOwr>> RealtimeMediaSourceOwrMap;
    8767
    8868} // namespace WebCore
    8969
    9070#endif // ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
    91 
    92 #endif // RealtimeMediaSourceOwr_h
  • trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp

    r208687 r209860  
    4141#include "NotImplemented.h"
    4242#include "OpenWebRTCUtilities.h"
     43#include "RealtimeAudioSourceOwr.h"
    4344#include "RealtimeMediaSourceCapabilities.h"
     45#include "RealtimeVideoSourceOwr.h"
    4446#include "UUID.h"
    4547#include <owr/owr.h>
     
    150152        }
    151153
    152         auto mediaSource = adoptRef(*new RealtimeMediaSourceOwr(source, id, mediaSourceType, sourceName));
     154        RefPtr<RealtimeMediaSourceOwr> mediaSource;
     155        if (mediaSourceType == RealtimeMediaSource::Audio)
     156            mediaSource = adoptRef(new RealtimeAudioSourceOwr(source, id, mediaSourceType, sourceName));
     157        else
     158            mediaSource = adoptRef(new RealtimeVideoSourceOwr(source, id, mediaSourceType, sourceName));
    153159
    154160        RealtimeMediaSourceOwrMap::iterator sourceIterator = m_sourceMap.find(id);
     
    157163
    158164        if (mediaType & OWR_MEDIA_TYPE_AUDIO)
    159             audioSources.append(WTFMove(mediaSource));
     165            audioSources.append(mediaSource.releaseNonNull());
    160166        else if (mediaType & OWR_MEDIA_TYPE_VIDEO)
    161             videoSources.append(WTFMove(mediaSource));
     167            videoSources.append(mediaSource.releaseNonNull());
     168
    162169    }
    163170
  • trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.cpp

    r209859 r209860  
    11/*
    2  * Copyright (C) 2015 Igalia S.L
    3  * Copyright (C) 2015 Metrological
     2 * Copyright (C) 2016 Igalia S.L
    43 *
    54 * All rights reserved.
     
    3332 */
    3433
    35 #ifndef RealtimeMediaSourceOwr_h
    36 #define RealtimeMediaSourceOwr_h
     34#include "config.h"
    3735
    3836#if ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
    39 
    40 #include "GRefPtrGStreamer.h"
    41 #include "RealtimeMediaSource.h"
    42 #include <owr/owr_media_source.h>
    43 #include <wtf/HashMap.h>
    44 #include <wtf/RefPtr.h>
    45 #include <wtf/text/WTFString.h>
     37#include "RealtimeMediaSourceOwr.h"
    4638
    4739namespace WebCore {
    4840
    49 class RealtimeMediaSourceCapabilities;
     41const RealtimeMediaSourceSettings& RealtimeMediaSourceOwr::settings() const
     42{
     43    const_cast<RealtimeMediaSourceOwr&>(*this).initializeSettings();
     44    return m_currentSettings;
     45}
    5046
    51 class RealtimeMediaSourceOwr : public RealtimeMediaSource {
    52 public:
    53 RealtimeMediaSourceOwr(OwrMediaSource* mediaSource, const String& id, RealtimeMediaSource::Type type, const String& name)
    54     : RealtimeMediaSource(id, type, name)
    55     , m_mediaSource(mediaSource)
    56     {
    57         if (!mediaSource)
    58             m_muted = true;
    59     }
     47RealtimeMediaSourceSupportedConstraints& RealtimeMediaSourceOwr::supportedConstraints()
     48{
     49    if (m_supportedConstraints.supportsDeviceId())
     50        return m_supportedConstraints;
    6051
    61 RealtimeMediaSourceOwr(const String& id, RealtimeMediaSource::Type type, const String& name)
    62     : RealtimeMediaSource(id, type, name)
    63     , m_mediaSource(nullptr)
    64     {
    65     }
     52    m_supportedConstraints.setSupportsDeviceId(true);
     53    initializeSupportedConstraints(m_supportedConstraints);
    6654
    67     virtual ~RealtimeMediaSourceOwr() { }
    68 
    69     void swapOutShallowSource(OwrMediaSource& realSource)
    70     {
    71         m_mediaSource = &realSource;
    72         setMuted(false);
    73     }
    74 
    75     virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() const { return m_capabilities; }
    76     virtual const RealtimeMediaSourceSettings& settings() const { return m_currentSettings; }
    77 
    78     OwrMediaSource* mediaSource() const { return m_mediaSource; }
    79 
    80 private:
    81     RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
    82     RealtimeMediaSourceSettings m_currentSettings;
    83     OwrMediaSource* m_mediaSource;
    84 };
    85 
    86 typedef HashMap<String, RefPtr<RealtimeMediaSourceOwr>> RealtimeMediaSourceOwrMap;
     55    return m_supportedConstraints;
     56}
    8757
    8858} // namespace WebCore
    8959
    9060#endif // ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
    91 
    92 #endif // RealtimeMediaSourceOwr_h
  • trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h

    r208542 r209860  
    7474
    7575    virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() const { return m_capabilities; }
    76     virtual const RealtimeMediaSourceSettings& settings() const { return m_currentSettings; }
     76    virtual const RealtimeMediaSourceSettings& settings() const;
    7777
    7878    OwrMediaSource* mediaSource() const { return m_mediaSource; }
    7979
     80protected:
     81    virtual void initializeSettings() { };
     82    virtual void initializeSupportedConstraints(RealtimeMediaSourceSupportedConstraints&) { };
     83    RealtimeMediaSourceSupportedConstraints& supportedConstraints();
     84
     85    RealtimeMediaSourceSettings m_currentSettings;
     86
    8087private:
     88
     89    RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
    8190    RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
    82     RealtimeMediaSourceSettings m_currentSettings;
     91
    8392    OwrMediaSource* m_mediaSource;
    8493};
  • trunk/Source/WebCore/platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h

    r209859 r209860  
    11/*
    2  * Copyright (C) 2015 Igalia S.L
     2 * Copyright (C) 2015,2016 Igalia S.L
    33 * Copyright (C) 2015 Metrological
    44 *
     
    3333 */
    3434
    35 #ifndef RealtimeMediaSourceOwr_h
    36 #define RealtimeMediaSourceOwr_h
     35#pragma once
    3736
    3837#if ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
    3938
    40 #include "GRefPtrGStreamer.h"
    41 #include "RealtimeMediaSource.h"
    42 #include <owr/owr_media_source.h>
    43 #include <wtf/HashMap.h>
    44 #include <wtf/RefPtr.h>
    45 #include <wtf/text/WTFString.h>
     39#include "RealtimeMediaSourceOwr.h"
    4640
    4741namespace WebCore {
    4842
    49 class RealtimeMediaSourceCapabilities;
    50 
    51 class RealtimeMediaSourceOwr : public RealtimeMediaSource {
     43class RealtimeVideoSourceOwr : public RealtimeMediaSourceOwr {
    5244public:
    53 RealtimeMediaSourceOwr(OwrMediaSource* mediaSource, const String& id, RealtimeMediaSource::Type type, const String& name)
    54     : RealtimeMediaSource(id, type, name)
    55     , m_mediaSource(mediaSource)
    56     {
    57         if (!mediaSource)
    58             m_muted = true;
    59     }
    60 
    61 RealtimeMediaSourceOwr(const String& id, RealtimeMediaSource::Type type, const String& name)
    62     : RealtimeMediaSource(id, type, name)
    63     , m_mediaSource(nullptr)
     45RealtimeVideoSourceOwr(OwrMediaSource* mediaSource, const String& id, RealtimeMediaSource::Type type, const String& name)
     46    : RealtimeMediaSourceOwr(mediaSource, id, type, name)
    6447    {
    6548    }
    6649
    67     virtual ~RealtimeMediaSourceOwr() { }
    68 
    69     void swapOutShallowSource(OwrMediaSource& realSource)
     50RealtimeVideoSourceOwr(const String& id, RealtimeMediaSource::Type type, const String& name)
     51    : RealtimeMediaSourceOwr(id, type, name)
    7052    {
    71         m_mediaSource = &realSource;
    72         setMuted(false);
    7353    }
    7454
    75     virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() const { return m_capabilities; }
    76     virtual const RealtimeMediaSourceSettings& settings() const { return m_currentSettings; }
     55    virtual ~RealtimeVideoSourceOwr() { }
    7756
    78     OwrMediaSource* mediaSource() const { return m_mediaSource; }
     57    bool applySize(const IntSize&) final { return true; }
    7958
    80 private:
    81     RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
    82     RealtimeMediaSourceSettings m_currentSettings;
    83     OwrMediaSource* m_mediaSource;
     59protected:
     60    void initializeSettings() final {
     61        if (m_currentSettings.deviceId().isEmpty())
     62            m_currentSettings.setSupportedConstraits(supportedConstraints());
     63
     64        m_currentSettings.setDeviceId(id());
     65
     66        m_currentSettings.setFrameRate(frameRate());
     67        m_currentSettings.setWidth(size().width());
     68        m_currentSettings.setHeight(size().height());
     69    }
     70
     71    void initializeSupportedConstraints(RealtimeMediaSourceSupportedConstraints& supportedConstraints) final {
     72        supportedConstraints.setSupportsFacingMode(RealtimeMediaSourceSettings::Unknown);
     73        supportedConstraints.setSupportsWidth(true);
     74        supportedConstraints.setSupportsHeight(true);
     75        supportedConstraints.setSupportsAspectRatio(true);
     76        supportedConstraints.setSupportsFrameRate(true);
     77    }
    8478};
    85 
    86 typedef HashMap<String, RefPtr<RealtimeMediaSourceOwr>> RealtimeMediaSourceOwrMap;
    8779
    8880} // namespace WebCore
    8981
    9082#endif // ENABLE(MEDIA_STREAM) && USE(OPENWEBRTC)
    91 
    92 #endif // RealtimeMediaSourceOwr_h
Note: See TracChangeset for help on using the changeset viewer.