MediaStream API: Update MediaStreamTrack::readyState to match specification
authortommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2013 09:34:29 +0000 (09:34 +0000)
committertommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2013 09:34:29 +0000 (09:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106781

Reviewed by Kentaro Hara.

Source/WebCore:

MediaStreamTrack::readyState now returns a string like the rest of the RTC classes.

Existing tests expanded to cover patch.

* Modules/mediastream/MediaStream.cpp:
(WebCore::processTrack):
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::readyState):
(WebCore::MediaStreamTrack::ended):
(WebCore):
* Modules/mediastream/MediaStreamTrack.h:
(MediaStreamTrack):
* Modules/mediastream/MediaStreamTrack.idl:

LayoutTests:

* fast/mediastream/MediaStreamTrack-expected.txt:
* fast/mediastream/MediaStreamTrack.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaStreamTrack-expected.txt
LayoutTests/fast/mediastream/MediaStreamTrack.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.idl

index a854bc6..7477ed3 100644 (file)
@@ -1,3 +1,13 @@
+2013-01-16  Tommy Widenflycht  <tommyw@google.com>
+
+        MediaStream API: Update MediaStreamTrack::readyState to match specification
+        https://bugs.webkit.org/show_bug.cgi?id=106781
+
+        Reviewed by Kentaro Hara.
+
+        * fast/mediastream/MediaStreamTrack-expected.txt:
+        * fast/mediastream/MediaStreamTrack.html:
+
 2013-01-16  Andrey Adaikin  <aandrey@chromium.org>
 
         Web Inspector: array grouping does not work for big and negative number keys
index afd6460..7a26b2c 100644 (file)
@@ -4,9 +4,13 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS getUserMedia succeeded.
+PASS track.readyState is "live"
 PASS Track onmute callback succeeded.
+PASS track.readyState is "muted"
 PASS Track onunmute callback succeeded.
+PASS track.readyState is "live"
 PASS Track onended callback succeeded.
+PASS track.readyState is "ended"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index d2f76af..704899b 100644 (file)
@@ -34,18 +34,24 @@ function getUserMedia(constraints, callback) {
 function onTrackEnded() {
     testPassed('Track onended callback succeeded.');
 
+    shouldBeEqualToString('track.readyState', 'ended');
+
     finishJSTest();
 }
 
 function onTrackUnmute() {
     testPassed('Track onunmute callback succeeded.');
 
+    shouldBeEqualToString('track.readyState', 'live');
+
     stream.stop();
 }
 
 function onTrackMute() {
     testPassed('Track onmute callback succeeded.');
 
+    shouldBeEqualToString('track.readyState', 'muted');
+
     track.enabled = true;
 }
 
@@ -55,6 +61,8 @@ function gotStream(s) {
     stream = s;
     track = stream.getVideoTracks()[0];
 
+    shouldBeEqualToString('track.readyState', 'live');
+
     track.onunmute = onTrackUnmute;
     track.onmute = onTrackMute;
     track.onended = onTrackEnded;
index 9590e3a..1e8c581 100644 (file)
@@ -1,3 +1,24 @@
+2013-01-16  Tommy Widenflycht  <tommyw@google.com>
+
+        MediaStream API: Update MediaStreamTrack::readyState to match specification
+        https://bugs.webkit.org/show_bug.cgi?id=106781
+
+        Reviewed by Kentaro Hara.
+
+        MediaStreamTrack::readyState now returns a string like the rest of the RTC classes.
+
+        Existing tests expanded to cover patch.
+
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::processTrack):
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::readyState):
+        (WebCore::MediaStreamTrack::ended):
+        (WebCore):
+        * Modules/mediastream/MediaStreamTrack.h:
+        (MediaStreamTrack):
+        * Modules/mediastream/MediaStreamTrack.idl:
+
 2013-01-16  Andrey Adaikin  <aandrey@chromium.org>
 
         Web Inspector: array grouping does not work for big and negative number keys
index ca67669..dcf0e82 100644 (file)
@@ -48,7 +48,7 @@ static bool containsSource(MediaStreamSourceVector& sourceVector, MediaStreamSou
 
 static void processTrack(MediaStreamTrack* track, MediaStreamSourceVector& sourceVector)
 {
-    if (track->readyState() == MediaStreamTrack::ENDED)
+    if (track->ended())
         return;
 
     MediaStreamSource* source = track->component()->source();
index 87e18f7..6268383 100644 (file)
@@ -99,22 +99,27 @@ void MediaStreamTrack::setEnabled(bool enabled)
     MediaStreamCenter::instance().didSetMediaStreamTrackEnabled(m_streamDescriptor.get(), m_component.get());
 }
 
-MediaStreamTrack::ReadyState MediaStreamTrack::readyState() const
+String MediaStreamTrack::readyState() const
 {
     if (m_stopped)
-        return ENDED;
+        return ASCIILiteral("ended");
 
     switch (m_component->source()->readyState()) {
     case MediaStreamSource::ReadyStateLive:
-        return LIVE;
+        return ASCIILiteral("live");
     case MediaStreamSource::ReadyStateMuted:
-        return MUTED;
+        return ASCIILiteral("muted");
     case MediaStreamSource::ReadyStateEnded:
-        return ENDED;
+        return ASCIILiteral("ended");
     }
 
     ASSERT_NOT_REACHED();
-    return ENDED;
+    return String();
+}
+
+bool MediaStreamTrack::ended() const
+{
+    return m_stopped || (m_component->source()->readyState() == MediaStreamSource::ReadyStateEnded);
 }
 
 void MediaStreamTrack::sourceChangedState()
index 1c4a19b..c1b8f40 100644 (file)
@@ -43,12 +43,6 @@ class MediaStreamComponent;
 
 class MediaStreamTrack : public RefCounted<MediaStreamTrack>, public ActiveDOMObject, public EventTarget, public MediaStreamSource::Observer {
 public:
-    enum ReadyState {
-        LIVE = 0,
-        MUTED = 1,
-        ENDED = 2
-    };
-
     static PassRefPtr<MediaStreamTrack> create(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>, MediaStreamComponent*);
     virtual ~MediaStreamTrack();
 
@@ -59,7 +53,7 @@ public:
     bool enabled() const;
     void setEnabled(bool);
 
-    ReadyState readyState() const;
+    String readyState() const;
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(mute);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(unmute);
@@ -67,6 +61,7 @@ public:
 
     MediaStreamDescriptor* streamDescriptor();
     MediaStreamComponent* component();
+    bool ended() const;
 
     // EventTarget
     virtual const AtomicString& interfaceName() const OVERRIDE;
index 93c939a..20af404 100644 (file)
     readonly attribute DOMString label;
              attribute boolean enabled;
 
-    const unsigned short LIVE = 0;
-    const unsigned short MUTED = 1;
-    const unsigned short ENDED = 2;
-    readonly attribute unsigned short readyState;
+    readonly attribute DOMString readyState;
 
     attribute EventListener onmute;
     attribute EventListener onunmute;