Changeset 167750 in webkit


Ignore:
Timestamp:
Apr 23, 2014 11:37:51 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[MediaStream] Implement MediaStream active attribute
https://bugs.webkit.org/show_bug.cgi?id=131973

Patch by Praveen R Jadhav <praveen.j@samsung.com> on 2014-04-23
Reviewed by Eric Carlson.

Source/WebCore:
MediaStream .active attribute are introduced which will replace
.ended attribute. This patch implements the newly introduced attributes.

MediaStream-add-remove-tracks.html is updated to handle this scenario.

  • Modules/mediastream/MediaStream.cpp:

(WebCore::MediaStream::active): Added.
(WebCore::MediaStream::setActive): Added.
(WebCore::MediaStream::addTrack): Propagates 'onactive' event when required.
(WebCore::MediaStream::removeTrack): Propagates 'oninactive' event when required.
(WebCore::MediaStream::trackDidEnd): Propagates 'oninactive' event when required.
(WebCore::MediaStream::streamDidEnd):
(WebCore::MediaStream::setStreamIsActive): Added.

  • Modules/mediastream/MediaStream.h:
  • Modules/mediastream/MediaStream.idl:
  • dom/EventNames.h:
  • platform/mediastream/MediaStreamPrivate.cpp:

(WebCore::MediaStreamPrivate::MediaStreamPrivate): Initialize .active attribute
(WebCore::MediaStreamPrivate::setEnded):
(WebCore::MediaStreamPrivate::setActive): Added.

  • platform/mediastream/MediaStreamPrivate.h:

(WebCore::MediaStreamPrivate::active): Added.

LayoutTests:
MediaStream .onended attribute will be replaced with .active attribute.
Patch updates the test case to verify the .active attribute.

  • fast/mediastream/MediaStream-add-remove-tracks-expected.txt:
  • fast/mediastream/MediaStream-add-remove-tracks.html:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r167732 r167750  
     12014-04-23  Praveen R Jadhav  <praveen.j@samsung.com>
     2
     3        [MediaStream] Implement MediaStream active attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=131973
     5
     6        Reviewed by Eric Carlson.
     7
     8        MediaStream .onended attribute will be replaced with .active attribute.
     9        Patch updates the test case to verify the .active attribute.
     10
     11        * fast/mediastream/MediaStream-add-remove-tracks-expected.txt:
     12        * fast/mediastream/MediaStream-add-remove-tracks.html:
     13
    1142014-04-23  Alexey Proskuryakov  <ap@apple.com>
    215
  • trunk/LayoutTests/fast/mediastream/MediaStream-add-remove-tracks-expected.txt

    r158220 r167750  
    44
    55
     6PASS stream1.active is true
    67PASS stream1.getAudioTracks().length is 1
    78PASS stream1.getVideoTracks().length is 1
     9PASS stream2.active is true
    810PASS stream2.getAudioTracks().length is 1
    911PASS stream2.getVideoTracks().length is 1
     
    5153PASS stream2.addTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
    5254PASS stream2.removeTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
     55Stream2 is inactive.
    5356PASS successfullyParsed is true
    5457
  • trunk/LayoutTests/fast/mediastream/MediaStream-add-remove-tracks.html

    r158987 r167750  
    5151            }
    5252
     53            function shouldFireActive() {
     54                debug("Stream2 is active.");
     55                finishJSTest();
     56            }
     57
     58            function shouldFireInActive() {
     59                debug("Stream2 is inactive.");
     60                finishJSTest();
     61            }
     62
    5363            function gotStream2(s) {
    5464                stream2 = s;
    5565
     66                shouldBe('stream1.active', 'true');
    5667                shouldBe('stream1.getAudioTracks().length', '1');
    5768                shouldBe('stream1.getVideoTracks().length', '1');
    5869
     70                shouldBe('stream2.active', 'true');
    5971                shouldBe('stream2.getAudioTracks().length', '1');
    6072                shouldBe('stream2.getVideoTracks().length', '1');
     
    6274                stream1.onaddtrack = shouldNotFire;
    6375                stream1.onremovetrack = shouldNotFire;
     76
     77                stream2.onactive = shouldFireActive;
     78                stream2.oninactive = shouldFireInActive;
    6479
    6580                audioTrack = stream1.getAudioTracks()[0];
     
    120135                shouldThrow('stream2.addTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
    121136                shouldThrow('stream2.removeTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
    122 
    123                 setTimeout(finishJSTest, 0);
    124137            }
    125138
  • trunk/Source/WebCore/ChangeLog

    r167746 r167750  
     12014-04-23  Praveen R Jadhav  <praveen.j@samsung.com>
     2
     3        [MediaStream] Implement MediaStream active attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=131973
     5
     6        Reviewed by Eric Carlson.
     7
     8        MediaStream .active attribute are introduced which will replace
     9        .ended attribute. This patch implements the newly introduced attributes.
     10
     11        MediaStream-add-remove-tracks.html is updated to handle this scenario.
     12
     13        * Modules/mediastream/MediaStream.cpp:
     14        (WebCore::MediaStream::active): Added.
     15        (WebCore::MediaStream::setActive): Added.
     16        (WebCore::MediaStream::addTrack): Propagates 'onactive' event when required.
     17        (WebCore::MediaStream::removeTrack): Propagates 'oninactive' event when required.
     18        (WebCore::MediaStream::trackDidEnd): Propagates 'oninactive' event when required.
     19        (WebCore::MediaStream::streamDidEnd):
     20        (WebCore::MediaStream::setStreamIsActive): Added.
     21        * Modules/mediastream/MediaStream.h:
     22        * Modules/mediastream/MediaStream.idl:
     23        * dom/EventNames.h:
     24        * platform/mediastream/MediaStreamPrivate.cpp:
     25        (WebCore::MediaStreamPrivate::MediaStreamPrivate): Initialize .active attribute
     26        (WebCore::MediaStreamPrivate::setEnded):
     27        (WebCore::MediaStreamPrivate::setActive): Added.
     28        * platform/mediastream/MediaStreamPrivate.h:
     29        (WebCore::MediaStreamPrivate::active): Added.
     30
    1312014-04-23  Darin Adler  <darin@apple.com>
    232
  • trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp

    r160181 r167750  
    127127}
    128128
     129bool MediaStream::active() const
     130{
     131    return m_private->active();
     132}
     133
     134void MediaStream::setActive(bool isActive)
     135{
     136    if (active() == isActive)
     137        return;
     138    m_private->setActive(isActive);
     139}
     140
    129141PassRefPtr<MediaStream> MediaStream::clone()
    130142{
     
    173185    track->addObserver(this);
    174186    m_private->addTrack(&track->privateTrack());
     187    setActive(true);
    175188    return true;
    176189}
     
    215228
    216229    track->removeObserver(this);
    217     if (!m_audioTracks.size() && !m_videoTracks.size())
    218         setEnded();
     230    if (!m_audioTracks.size() && !m_videoTracks.size()) {
     231        setEnded(); // FIXME : to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
     232        setActive(false);
     233    }
    219234
    220235    return true;
     
    265280    }
    266281
    267     setEnded();
     282    setEnded(); // FIXME : to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
     283
     284    if (!m_audioTracks.size() && !m_videoTracks.size())
     285        setActive(false);
    268286}
    269287
     
    274292
    275293    scheduleDispatchEvent(Event::create(eventNames().endedEvent, false, false));
     294}
     295
     296void MediaStream::setStreamIsActive(bool streamActive)
     297{
     298    if (streamActive)
     299        scheduleDispatchEvent(Event::create(eventNames().activeEvent, false, false));
     300    else
     301        scheduleDispatchEvent(Event::create(eventNames().inactiveEvent, false, false));
    276302}
    277303
  • trunk/Source/WebCore/Modules/mediastream/MediaStream.h

    r165834 r167750  
    7676    DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack);
    7777
     78    bool active() const;
     79    void setActive(bool);
     80
     81    DEFINE_ATTRIBUTE_EVENT_LISTENER(active);
     82    DEFINE_ATTRIBUTE_EVENT_LISTENER(inactive);
     83
    7884    MediaStreamPrivate* privateStream() const { return m_private.get(); }
    7985
     
    105111    virtual void trackDidEnd() override final;
    106112    virtual void streamDidEnd() override final;
     113    virtual void setStreamIsActive(bool) override final;
    107114    virtual void addRemoteSource(MediaStreamSource*) override final;
    108115    virtual void removeRemoteSource(MediaStreamSource*) override final;
  • trunk/Source/WebCore/Modules/mediastream/MediaStream.idl

    r159061 r167750  
    4949    attribute EventListener onremovetrack;
    5050
     51    readonly attribute boolean active;
     52
     53    attribute EventListener onactive;
     54    attribute EventListener oninactive;
     55
    5156    // EventTarget interface
    5257    void addEventListener(DOMString type,
  • trunk/Source/WebCore/dom/EventNames.h

    r163092 r167750  
    164164    macro(waiting) \
    165165    \
     166    macro(active) \
     167    macro(inactive) \
    166168    macro(addtrack) \
    167169    macro(cuechange) \
  • trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp

    r158849 r167750  
    130130    , m_id(id)
    131131    , m_ended(false)
     132    , m_isActive(false)
    132133{
    133134    ASSERT(m_id.length());
     
    141142    unsigned tracksSize = m_audioPrivateTracks.size() + m_videoPrivateTracks.size();
    142143    // If sources were provided and no track was added to the MediaStreamPrivate's tracks, this means
    143     // that the tracks were all ended
     144    // that the tracks were all ended.
     145    // Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
    144146    if (providedSourcesSize > 0 && !tracksSize)
    145147        m_ended = true;
     148
     149    if (providedSourcesSize > 0 && tracksSize > 0)
     150        m_isActive = true;
    146151}
    147152
     
    150155    , m_id(id)
    151156    , m_ended(false)
     157    , m_isActive(false)
    152158{
    153159    ASSERT(m_id.length());
     
    162168    // If tracks were provided and no one was added to the MediaStreamPrivate's tracks, this means
    163169    // that the tracks were all ended
     170    // Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
    164171    if (providedTracksSize > 0 && !tracksSize)
    165172        m_ended = true;
     173
     174    if (providedTracksSize > 0 && tracksSize > 0)
     175        m_isActive = true;
    166176}
    167177
     
    172182
    173183    m_ended = true;
     184}
     185
     186void MediaStreamPrivate::setActive(bool active)
     187{
     188    if (m_isActive != active) {
     189        m_isActive = active;
     190
     191        if (m_client)
     192            m_client->setStreamIsActive(active);
     193    }
    174194}
    175195
  • trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h

    r158849 r167750  
    5151
    5252    virtual void streamDidEnd() = 0;
     53    virtual void setStreamIsActive(bool) = 0;
    5354    virtual void addRemoteSource(MediaStreamSource*) = 0;
    5455    virtual void removeRemoteSource(MediaStreamSource*) = 0;
     
    8788    void removeRemoteSource(MediaStreamSource*);
    8889
     90    // Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
    8991    bool ended() const { return m_ended; }
    9092    void setEnded();
     93
     94    bool active() const { return m_isActive; }
     95    void setActive(bool);
    9196
    9297    void addTrack(PassRefPtr<MediaStreamTrackPrivate>);
     
    107112    Vector<RefPtr<MediaStreamTrackPrivate>> m_audioPrivateTracks;
    108113    Vector<RefPtr<MediaStreamTrackPrivate>> m_videoPrivateTracks;
    109     bool m_ended;
     114    bool m_ended; // Deprecated. to be removed in bug https://bugs.webkit.org/show_bug.cgi?id=132104
     115    bool m_isActive;
    110116};
    111117
Note: See TracChangeset for help on using the changeset viewer.