Changeset 247391 in webkit


Ignore:
Timestamp:
Jul 12, 2019 10:27:53 AM (5 years ago)
Author:
youenn@apple.com
Message:

Stopping a cloned MediaStream video track should not stop any other video track
https://bugs.webkit.org/show_bug.cgi?id=199635

Reviewed by Eric Carlson.

Source/WebCore:

In case a track is requesting its source to end, the
RealtimeVideoSource should request its own source to end and not stop it directly.

Also, if a track is removing itself as an observer to a RealtimeVideoSource, we should
stop the underlying source only if this one does not have any other observer.
Covered by updated test.

  • platform/mediastream/RealtimeMediaSource.cpp:

(WebCore::RealtimeMediaSource::removeObserver):

  • platform/mediastream/RealtimeMediaSource.h:
  • platform/mediastream/RealtimeVideoSource.cpp:

(WebCore::RealtimeVideoSource::requestToEnd):
(WebCore::RealtimeVideoSource::stopBeingObserved):

  • platform/mediastream/RealtimeVideoSource.h:

LayoutTests:

  • fast/mediastream/mediastreamtrack-video-clone-expected.txt:
  • fast/mediastream/mediastreamtrack-video-clone.html:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247388 r247391  
     12019-07-12  Youenn Fablet  <youenn@apple.com>
     2
     3        Stopping a cloned MediaStream video track should not stop any other video track
     4        https://bugs.webkit.org/show_bug.cgi?id=199635
     5
     6        Reviewed by Eric Carlson.
     7
     8        * fast/mediastream/mediastreamtrack-video-clone-expected.txt:
     9        * fast/mediastream/mediastreamtrack-video-clone.html:
     10
    1112019-07-12  Timothy Hatcher  <timothy@apple.com>
    212
  • trunk/LayoutTests/fast/mediastream/mediastreamtrack-video-clone-expected.txt

    r246644 r247391  
    44PASS Setup for height test
    55PASS Setup for width+height test
     6PASS Stopping a track should not stop its clone
     7PASS Stopping a cloned track should not stop the original track
     8PASS Collecting a cloned track should not stop the original track
    69PASS Check cloned track settings after applying width constraints
    710PASS Check cloned track settings after applying width constraint to original track
  • trunk/LayoutTests/fast/mediastream/mediastreamtrack-video-clone.html

    r246644 r247391  
    44    <meta charset="utf-8">
    55    <title>Clone a video track.</title>
     6    <script src="../../resources/gc.js"></script>
    67    <script src="../../resources/testharness.js"></script>
    78    <script src="../../resources/testharnessreport.js"></script>
     
    106107    }, "Setup for width+height test");
    107108
     109    promise_test(async (t) => {
     110        const stream = await navigator.mediaDevices.getUserMedia({ video: { width: 100, height: 100 } });
     111        const streamClone = stream.clone();
     112
     113        video1.srcObject = streamClone;
     114        stream.getVideoTracks()[0].stop();
     115
     116        await video1.play();
     117        assert_equals(video1.videoWidth, 100);
     118    }, "Stopping a track should not stop its clone");
     119
     120    promise_test(async (t) => {
     121        const stream = await navigator.mediaDevices.getUserMedia({ video: { width: 100, height: 100 } });
     122        const streamClone = stream.clone();
     123
     124        video1.srcObject = stream;
     125        streamClone.getVideoTracks()[0].stop();
     126
     127        await video1.play();
     128        assert_equals(video1.videoWidth, 100);
     129    }, "Stopping a cloned track should not stop the original track");
     130
     131    promise_test(async (t) => {
     132        const stream = await navigator.mediaDevices.getUserMedia({ video: { width: 100, height: 100 } });
     133        stream.clone().getVideoTracks()[0].stop();
     134        gc();
     135
     136        video1.srcObject = stream;
     137
     138        await video1.play();
     139        assert_equals(video1.videoWidth, 100);
     140    }, "Collecting a cloned track should not stop the original track");
    108141    </script>
    109142</body>
  • trunk/Source/WebCore/ChangeLog

    r247388 r247391  
     12019-07-12  Youenn Fablet  <youenn@apple.com>
     2
     3        Stopping a cloned MediaStream video track should not stop any other video track
     4        https://bugs.webkit.org/show_bug.cgi?id=199635
     5
     6        Reviewed by Eric Carlson.
     7
     8        In case a track is requesting its source to end, the
     9        RealtimeVideoSource should request its own source to end and not stop it directly.
     10
     11        Also, if a track is removing itself as an observer to a RealtimeVideoSource, we should
     12        stop the underlying source only if this one does not have any other observer.
     13        Covered by updated test.
     14
     15        * platform/mediastream/RealtimeMediaSource.cpp:
     16        (WebCore::RealtimeMediaSource::removeObserver):
     17        * platform/mediastream/RealtimeMediaSource.h:
     18        * platform/mediastream/RealtimeVideoSource.cpp:
     19        (WebCore::RealtimeVideoSource::requestToEnd):
     20        (WebCore::RealtimeVideoSource::stopBeingObserved):
     21        * platform/mediastream/RealtimeVideoSource.h:
     22
    1232019-07-12  Timothy Hatcher  <timothy@apple.com>
    224
  • trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp

    r247211 r247391  
    7070{
    7171    auto locker = holdLock(m_observersLock);
    72 
    7372    m_observers.remove(&observer);
    7473    if (m_observers.isEmpty())
    75         stop();
     74        stopBeingObserved();
    7675}
    7776
  • trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h

    r247211 r247391  
    110110    void start();
    111111    void stop();
    112     void requestToEnd(Observer& callingObserver);
     112    virtual void requestToEnd(Observer& callingObserver);
    113113
    114114    bool muted() const { return m_muted; }
     
    233233    virtual void stopProducingData() { }
    234234    virtual void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) { }
     235
     236    virtual void stopBeingObserved() { stop(); }
    235237
    236238    virtual void hasEnded() { }
  • trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp

    r247165 r247391  
    119119}
    120120
     121void RealtimeVideoSource::requestToEnd(RealtimeMediaSource::Observer&)
     122{
     123    m_source->requestToEnd(*this);
     124}
     125
     126void RealtimeVideoSource::stopBeingObserved()
     127{
     128    m_source->requestToEnd(*this);
     129}
     130
    121131void RealtimeVideoSource::sourceStopped()
    122132{
  • trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h

    r246644 r247391  
    4747    void setSizeAndFrameRate(Optional<int> width, Optional<int> height, Optional<double> frameRate) final;
    4848    Ref<RealtimeMediaSource> clone() final;
     49    void requestToEnd(RealtimeMediaSource::Observer& callingObserver) final;
     50    void stopBeingObserved() final;
    4951
    5052    const RealtimeMediaSourceCapabilities& capabilities() final { return m_source->capabilities(); }
Note: See TracChangeset for help on using the changeset viewer.