Source/WebCore: Add webkitSourceAddId() & webkitSourceRemoveId() to HTMLMediaElement
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 17:09:40 +0000 (17:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 17:09:40 +0000 (17:09 +0000)
and propagate calls to the MediaPlayerPrivate interface.
These are needed to bring the Media Source implementation
up to date with the new 0.4 version of the Media Source spec.
http://html5-mediasource-api.googlecode.com/svn/tags/0.4/draft-spec/mediasource-draft-spec.html
https://bugs.webkit.org/show_bug.cgi?id=83616

Patch by Aaron Colwell <acolwell@chromium.org> on 2012-04-17
Reviewed by Eric Carlson, Darin Fisher.

Test: http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html

* html/HTMLMediaElement.cpp:
(WebCore):
(WebCore::HTMLMediaElement::isValidSourceId):
(WebCore::HTMLMediaElement::webkitSourceAddId):
(WebCore::HTMLMediaElement::webkitSourceRemoveId):
(WebCore::HTMLMediaElement::setSourceState):
* html/HTMLMediaElement.h:
(HTMLMediaElement):
* html/HTMLMediaElement.idl:
* platform/graphics/MediaPlayer.cpp:
(WebCore::NullMediaPlayerPrivate::sourceAddId):
(WebCore::NullMediaPlayerPrivate::sourceRemoveId):
(WebCore):
(WebCore::MediaPlayer::sourceAddId):
(WebCore::MediaPlayer::sourceRemoveId):
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::sourceAddId):
(WebCore::MediaPlayerPrivateInterface::sourceRemoveId):

Source/WebKit/chromium: Add sourceAddId() & sourceRemoveId() stubs for Chromium.
These are needed to bring the Media Source implementation
up to date with the new 0.4 version of the Media Source spec.
http://html5-mediasource-api.googlecode.com/svn/tags/0.4/draft-spec/mediasource-draft-spec.html
https://bugs.webkit.org/show_bug.cgi?id=83616

Patch by Aaron Colwell <acolwell@chromium.org> on 2012-04-17
Reviewed by Eric Carlson, Darin Fisher.

* public/WebMediaPlayer.h:
(WebKit::WebMediaPlayer::sourceAddId):
(WebKit::WebMediaPlayer::sourceRemoveId):
* src/AssertMatchingEnums.cpp:
* src/WebMediaPlayerClientImpl.cpp:
(WebKit::WebMediaPlayerClientImpl::sourceAddId):
(WebKit):
(WebKit::WebMediaPlayerClientImpl::sourceRemoveId):
* src/WebMediaPlayerClientImpl.h:
(WebMediaPlayerClientImpl):

LayoutTests: Add LayoutTests for new webkitSourceAddId() & webkitSourceRemoveId() methods.
https://bugs.webkit.org/show_bug.cgi?id=83616

Patch by Aaron Colwell <acolwell@chromium.org> on 2012-04-17
Reviewed by Eric Carlson, Darin Fisher.

* http/tests/media/media-source/webm/video-media-source-add-and-remove-ids-expected.txt: Added.
* http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html: Added.
* platform/chromium/test_expectations.txt:

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/media/media-source/webm/video-media-source-add-and-remove-ids-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMediaElement.idl
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebMediaPlayer.h
Source/WebKit/chromium/src/AssertMatchingEnums.cpp
Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h

index d2ecb8d..45e5056 100644 (file)
@@ -1,3 +1,14 @@
+2012-04-17  Aaron Colwell  <acolwell@chromium.org>
+
+        Add LayoutTests for new webkitSourceAddId() & webkitSourceRemoveId() methods.
+        https://bugs.webkit.org/show_bug.cgi?id=83616
+
+        Reviewed by Eric Carlson, Darin Fisher.
+
+        * http/tests/media/media-source/webm/video-media-source-add-and-remove-ids-expected.txt: Added.
+        * http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html: Added.
+        * platform/chromium/test_expectations.txt:
+
 2012-04-17  Alexander Pavlov  <apavlov@chromium.org>
 
         Web Inspector: [CRASH] InspectorDOMAgent::didInsertDOMNode() on page reload with open Inspector
diff --git a/LayoutTests/http/tests/media/media-source/webm/video-media-source-add-and-remove-ids-expected.txt b/LayoutTests/http/tests/media/media-source/webm/video-media-source-add-and-remove-ids-expected.txt
new file mode 100644 (file)
index 0000000..1e1b810
--- /dev/null
@@ -0,0 +1,42 @@
+Tests webkitSourceAddId() & webkitSourceRemoveId() methods
+
+
+running testAddIdFailureCases
+Got expected exception Error: INVALID_STATE_ERR: DOM Exception 11
+EVENT(loadstart)
+EVENT(webkitsourceopen)
+Test empty ID case
+Got expected exception Error: INVALID_ACCESS_ERR: DOM Exception 15
+Test adding the same ID again.
+Got expected exception Error: INVALID_STATE_ERR: DOM Exception 11
+Test empty type.
+Got expected exception Error: INVALID_ACCESS_ERR: DOM Exception 15
+Test an unsupported type.
+Got expected exception Error: NOT_SUPPORTED_ERR: DOM Exception 9
+Test reaching sourceID limit.
+Got expected exception Error: INVALID_STATE_ERR: DOM Exception 11
+
+running testRemoveIdFailureCases
+EVENT(loadstart)
+EVENT(webkitsourceopen)
+Test empty ID case
+Got expected exception Error: INVALID_ACCESS_ERR: DOM Exception 15
+Test removing an ID that was never added.
+Got expected exception Error: SYNTAX_ERR: DOM Exception 12
+Got expected exception Error: SYNTAX_ERR: DOM Exception 12
+Test adding the same ID again.
+Test that an ID can be removed while in the ended state.
+
+running testAppendFailureCases
+EVENT(loadstart)
+EVENT(webkitsourceopen)
+Test append with empty ID.
+Got expected exception Error: INVALID_ACCESS_ERR: DOM Exception 15
+Test append with an invalid ID
+Got expected exception Error: SYNTAX_ERR: DOM Exception 12
+Test append with a null buffer.
+Got expected exception Error: INVALID_ACCESS_ERR: DOM Exception 15
+Test a successful append.
+Got expected exception Error: SYNTAX_ERR: DOM Exception 12
+END OF TEST
+
diff --git a/LayoutTests/http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html b/LayoutTests/http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html
new file mode 100644 (file)
index 0000000..624e5ba
--- /dev/null
@@ -0,0 +1,215 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src="../../../media-resources/video-test.js"></script>
+        <script src="webm-media-source.js"></script>
+        <script>
+            var defaultSourceMimetype = "video/webm; codecs=\"vp8, vorbis\"";
+
+            function runOnSourceOpen(videoTag, onOpenFunction)
+            {
+                var eventHandlerFunction = function (event)
+                {
+                    event.target.removeEventListener('webkitsourceopen', eventHandlerFunction);
+                    onOpenFunction(event.target);
+                };
+                videoTag.addEventListener('webkitsourceopen', eventHandlerFunction);
+                setSrcToMediaSourceURL(videoTag);
+            }
+
+            // The index of the next cluster to send to appendData().
+            var nextClusterIndex = 0;
+
+            function expectExceptionOnAddId(videoTag, id, type, error)
+            {
+                try {
+                    videoTag.webkitSourceAddId(id, type);
+                    failTest("Expected an exception");
+                } catch (e) {
+                    if (!(e.code == error)) {
+                        failTest("Unexpected exception " + e);
+                        throw e;
+                    }
+                    consoleWrite("Got expected exception " + e);
+                }
+            }
+
+            function expectExceptionOnRemoveId(videoTag, id, error)
+            {
+                try {
+                    videoTag.webkitSourceRemoveId(id);
+                    failTest("Expected an exception");
+                } catch (e) {
+                    if (!(e.code == error)) {
+                        failTest("Unexpected exception " + e);
+                        throw e;
+                    }
+                    consoleWrite("Got expected exception " + e);
+                }
+            }
+
+            function expectExceptionOnAppend(videoTag, id, buf, error)
+            {
+                try {
+                    videoTag.webkitSourceAppend(id, buf);
+                    failTest("Expected an exception");
+                } catch (e) {
+                    if (!(e.code == error)) {
+                        failTest("Unexpected exception " + e);
+                        throw e;
+                    }
+                    consoleWrite("Got expected exception " + e);
+                }
+            }
+
+            function testAddIdFailureCases(videoTag)
+            {
+                // Test adding while closed.
+                expectExceptionOnAddId(videoTag, "123", defaultSourceMimetype, DOMException.INVALID_STATE_ERR);
+
+                runOnSourceOpen(videoTag, function (vt)
+                {
+                    consoleWrite("Test empty ID case");
+                    expectExceptionOnAddId(vt, "", defaultSourceMimetype, DOMException.INVALID_ACCESS_ERR);
+
+                    vt.webkitSourceAddId("123", defaultSourceMimetype);
+
+                    consoleWrite("Test adding the same ID again.");
+                    expectExceptionOnAddId(vt, "123", defaultSourceMimetype, DOMException.INVALID_STATE_ERR);
+                    vt.webkitSourceRemoveId("123");
+
+                    consoleWrite("Test empty type.");
+                    expectExceptionOnAddId(vt, "234", "", DOMException.INVALID_ACCESS_ERR);
+
+                    consoleWrite("Test an unsupported type.");
+                    expectExceptionOnAddId(vt, "234", "audio/wav", DOMException.NOT_SUPPORTED_ERR);
+
+                    consoleWrite("Test reaching sourceID limit.");
+                    var reachedIdLimit = false;
+
+                    // The 20 here is an arbitrary upper limit to make sure the test terminates. This test
+                    // assumes that implementations won't support more than 20 sourceID's simultaneously.
+                    for (var i = 0; i < 20; ++i) {
+                        var sourceID = "sourceID-" + i;
+                        try {
+                            vt.webkitSourceAddId(sourceID, defaultSourceMimetype);
+                        } catch(e) {
+                            if (e.code != DOMException.QUOTA_EXCEEDED_ERR) {
+                                failTest("Unexpected exception " + e);
+                                throw e;
+                            }
+                            reachedIdLimit = true;
+                            break;
+                        }
+                    }
+
+                    if (!reachedIdLimit) {
+                        failTest("Failed to reach SourceID limit.");
+                        return;
+                    }
+
+                    // Test that SourceIDs can't be added while in the ended state.
+                    vt.webkitSourceEndOfStream(vt.EOS_NO_ERROR);
+                    expectExceptionOnAddId(vt, "123", defaultSourceMimetype, DOMException.INVALID_STATE_ERR);
+
+                    runNextTestCase(vt);
+                });
+            }
+
+            function testRemoveIdFailureCases(videoTag)
+            {
+                runOnSourceOpen(videoTag, function (vt)
+                {
+                    consoleWrite("Test empty ID case");
+                    expectExceptionOnRemoveId(vt, "", DOMException.INVALID_ACCESS_ERR);
+
+                    consoleWrite("Test removing an ID that was never added.");
+                    expectExceptionOnRemoveId(vt, "345", DOMException.SYNTAX_ERR);
+
+                    vt.webkitSourceAddId("123", defaultSourceMimetype);
+                    vt.webkitSourceRemoveId("123");
+                    expectExceptionOnRemoveId(vt, "123", DOMException.SYNTAX_ERR);
+
+                    consoleWrite("Test adding the same ID again.");
+                    vt.webkitSourceAddId("123", defaultSourceMimetype);
+
+                    consoleWrite("Test that an ID can be removed while in the ended state.");
+                    vt.webkitSourceEndOfStream(vt.EOS_NO_ERROR);
+                    vt.webkitSourceRemoveId("123");
+
+                    runNextTestCase(vt);
+                });
+            }
+
+            function testAppendFailureCases(videoTag)
+            {
+                runOnSourceOpen(videoTag, function (vt)
+                {
+                    vt.webkitSourceAddId("123", defaultSourceMimetype);
+
+                    consoleWrite("Test append with empty ID.");
+                    expectExceptionOnAppend(vt, "", getHeaders(), DOMException.INVALID_ACCESS_ERR);
+
+                    consoleWrite("Test append with an invalid ID");
+                    expectExceptionOnAppend(vt, "234", getHeaders(), DOMException.SYNTAX_ERR);
+
+                    consoleWrite("Test append with a null buffer.");
+                    expectExceptionOnAppend(vt, "123", null, DOMException.INVALID_ACCESS_ERR);
+
+                    consoleWrite("Test a successful append.");
+                    vt.webkitSourceAppend("123", getHeaders());
+
+                    vt.webkitSourceRemoveId("123");
+                    expectExceptionOnAppend(vt, "123", getCluster(0), DOMException.SYNTAX_ERR);
+
+                    runNextTestCase(vt);
+                });
+
+            }
+
+            var testCases = [
+                testAddIdFailureCases,
+                testRemoveIdFailureCases,
+                testAppendFailureCases,
+            ];
+
+            var testCaseIndex = 0;
+
+            function runNextTestCase(videoTag)
+            {
+                if (testCaseIndex >= testCases.length) {
+                    endTest();
+                    return;
+                }
+
+                var testCaseFunction = testCases[testCaseIndex];
+                testCaseIndex++;
+
+                consoleWrite("");
+                consoleWrite("running " + testCaseFunction.name);
+                testCaseFunction(videoTag);
+            }
+
+            function onLoad()
+            {
+                findMediaElement();
+
+                waitForEvent('loadstart');
+                waitForEvent('webkitsourceopen');
+
+                loadWebMData(function(success)
+                {
+                    if (!success) {
+                        failTest("Failed to load WebM data");
+                        return;
+                    }
+                    runNextTestCase(video);
+                });
+            }
+        </script>
+    </head>
+    <body onload="onLoad()">
+        <video> </video>
+        <p>Tests webkitSourceAddId() &amp; webkitSourceRemoveId() methods</p>
+    </body>
+</html>
index 806dea1..b99d308 100644 (file)
@@ -3749,6 +3749,9 @@ BUGCR122448 : media/video-seek-past-end-paused.html = PASS TEXT
 
 BUGCR122462 WIN LINUX : http/tests/inspector/inspect-element.html = TEXT
 
+// Temporarily disabled until Chromium sourceAddId() & sourceRemoveId() code has been checked in.
+BUGWK83616 SKIP : http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html = FAIL
+
 BUGWK83503 LINUX DEBUG : plugins/inner-html-display-none.html = CRASH
 
 
index ccbc276..daea945 100644 (file)
@@ -1,3 +1,36 @@
+2012-04-17  Aaron Colwell  <acolwell@chromium.org>
+
+        Add webkitSourceAddId() & webkitSourceRemoveId() to HTMLMediaElement
+        and propagate calls to the MediaPlayerPrivate interface.
+        These are needed to bring the Media Source implementation 
+        up to date with the new 0.4 version of the Media Source spec.
+        http://html5-mediasource-api.googlecode.com/svn/tags/0.4/draft-spec/mediasource-draft-spec.html
+        https://bugs.webkit.org/show_bug.cgi?id=83616
+
+        Reviewed by Eric Carlson, Darin Fisher.
+
+        Test: http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore):
+        (WebCore::HTMLMediaElement::isValidSourceId):
+        (WebCore::HTMLMediaElement::webkitSourceAddId):
+        (WebCore::HTMLMediaElement::webkitSourceRemoveId):
+        (WebCore::HTMLMediaElement::setSourceState):
+        * html/HTMLMediaElement.h:
+        (HTMLMediaElement):
+        * html/HTMLMediaElement.idl:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::NullMediaPlayerPrivate::sourceAddId):
+        (WebCore::NullMediaPlayerPrivate::sourceRemoveId):
+        (WebCore):
+        (WebCore::MediaPlayer::sourceAddId):
+        (WebCore::MediaPlayer::sourceRemoveId):
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::sourceAddId):
+        (WebCore::MediaPlayerPrivateInterface::sourceRemoveId):
+
 2012-04-17  Alexander Pavlov  <apavlov@chromium.org>
 
         Web Inspector: [CRASH] InspectorDOMAgent::didInsertDOMNode() on page reload with open Inspector
index 9eb1c20..ac3700f 100644 (file)
@@ -1698,6 +1698,22 @@ String HTMLMediaElement::mediaPlayerSourceURL() const
 {
     return m_mediaSourceURL.string();
 }
+
+bool HTMLMediaElement::isValidSourceId(const String& id, ExceptionCode& ec) const
+{
+    if (id.isNull() || id.isEmpty()) {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    if (!m_sourceIDs.contains(id)) {
+        ec = SYNTAX_ERR;
+        return false;
+    }
+
+    return true;
+}
+
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA)
@@ -2285,6 +2301,59 @@ void HTMLMediaElement::pauseInternal()
 }
 
 #if ENABLE(MEDIA_SOURCE)
+void HTMLMediaElement::webkitSourceAddId(const String& id, const String& type, ExceptionCode& ec)
+{
+    if (id.isNull() || id.isEmpty()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    if (m_sourceIDs.contains(id)) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
+    if (type.isNull() || type.isEmpty()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    if (!m_player || m_currentSrc != m_mediaSourceURL || m_sourceState != SOURCE_OPEN) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
+    switch (m_player->sourceAddId(id, type)) {
+    case MediaPlayer::Ok:
+        m_sourceIDs.add(id);
+        return;
+    case MediaPlayer::NotSupported:
+        ec = NOT_SUPPORTED_ERR;
+        return;
+    case MediaPlayer::ReachedIdLimit:
+        ec = QUOTA_EXCEEDED_ERR;
+        return;
+    }
+
+    ASSERT_NOT_REACHED();
+}
+
+void HTMLMediaElement::webkitSourceRemoveId(const String& id, ExceptionCode& ec)
+{
+    if (!isValidSourceId(id, ec))
+        return;
+
+    if (!m_player || m_currentSrc != m_mediaSourceURL || m_sourceState == SOURCE_CLOSED) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
+    if (!m_player->sourceRemoveId(id))
+        ASSERT_NOT_REACHED();
+
+    m_sourceIDs.remove(id);
+}
+
 void HTMLMediaElement::webkitSourceAppend(PassRefPtr<Uint8Array> data, ExceptionCode& ec)
 {
     if (!m_player || m_currentSrc != m_mediaSourceURL || m_sourceState != SOURCE_OPEN) {
@@ -2340,6 +2409,7 @@ void HTMLMediaElement::setSourceState(SourceState state)
         return;
 
     if (m_sourceState == SOURCE_CLOSED) {
+        m_sourceIDs.clear();
         scheduleEvent(eventNames().webkitsourcecloseEvent);
         return;
     }
index 1fe066a..6de35db 100644 (file)
@@ -172,6 +172,8 @@ public:
 #if ENABLE(MEDIA_SOURCE)
 //  Media Source.
     const KURL& webkitMediaSourceURL() const { return m_mediaSourceURL; }
+    void webkitSourceAddId(const String&, const String&, ExceptionCode&);
+    void webkitSourceRemoveId(const String&, ExceptionCode&);
     void webkitSourceAppend(PassRefPtr<Uint8Array> data, ExceptionCode&);
     enum EndOfStreamStatus { EOS_NO_ERROR, EOS_NETWORK_ERR, EOS_DECODE_ERR };
     void webkitSourceEndOfStream(unsigned short, ExceptionCode&);
@@ -407,6 +409,7 @@ private:
 #if ENABLE(MEDIA_SOURCE)
     virtual void mediaPlayerSourceOpened();
     virtual String mediaPlayerSourceURL() const;
+    bool isValidSourceId(const String&, ExceptionCode&) const;
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA)
@@ -577,6 +580,7 @@ private:
 #if ENABLE(MEDIA_SOURCE)
     KURL m_mediaSourceURL;
     SourceState m_sourceState;
+    HashSet<String> m_sourceIDs;
 #endif
 
     mutable float m_cachedTime;
index 87854be..5b9c101 100644 (file)
@@ -99,6 +99,10 @@ module html {
     // URL passed to src attribute to enable the media source logic.
     readonly attribute [V8EnabledAtRuntime=mediaSource, URL] DOMString webkitMediaSourceURL;
 
+    // Manages IDs for appending media to the source.
+    [V8EnabledAtRuntime=mediaSource] void webkitSourceAddId(in DOMString id, in DOMString type) raises (DOMException);
+    [V8EnabledAtRuntime=mediaSource] void webkitSourceRemoveId(in DOMString id) raises (DOMException);
+
     // Appends media to to the source.
     [V8EnabledAtRuntime=mediaSource] void webkitSourceAppend(in Uint8Array data) raises (DOMException);
 
index e98ebfd..1e81857 100644 (file)
@@ -149,6 +149,8 @@ public:
     virtual bool hasSingleSecurityOrigin() const { return true; }
 
 #if ENABLE(MEDIA_SOURCE)
+    virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type) { return MediaPlayer::NotSupported; }
+    virtual bool sourceRemoveId(const String& id) { return false; }
     virtual bool sourceAppend(const unsigned char*, unsigned) { return false; }
     virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus status) { }
 #endif
@@ -456,6 +458,17 @@ void MediaPlayer::pause()
 }
 
 #if ENABLE(MEDIA_SOURCE)
+
+MediaPlayer::AddIdStatus MediaPlayer::sourceAddId(const String& id, const String& type)
+{
+    return m_private->sourceAddId(id, type);
+}
+
+bool MediaPlayer::sourceRemoveId(const String& id)
+{
+    return m_private->sourceRemoveId(id);
+}
+
 bool MediaPlayer::sourceAppend(const unsigned char* data, unsigned length)
 {
     return m_private->sourceAppend(data, length);
index d9b6e27..429e5fc 100644 (file)
@@ -229,6 +229,9 @@ public:
     void pause();    
 
 #if ENABLE(MEDIA_SOURCE)
+    enum AddIdStatus { Ok, NotSupported, ReachedIdLimit };
+    AddIdStatus sourceAddId(const String& id, const String& type);
+    bool sourceRemoveId(const String& id);
     bool sourceAppend(const unsigned char* data, unsigned length);
     enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
     void sourceEndOfStream(EndOfStreamStatus);
index 378b259..ff55d1b 100644 (file)
@@ -158,6 +158,8 @@ public:
 #endif
 
 #if ENABLE(MEDIA_SOURCE)
+    virtual MediaPlayer::AddIdStatus sourceAddId(const String&, const String&) { return MediaPlayer::NotSupported; }
+    virtual bool sourceRemoveId(const String&) { return false; }
     virtual bool sourceAppend(const unsigned char*, unsigned) { return false; }
     virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { };
 #endif
index 760cda5..6e84ca5 100644 (file)
@@ -1,3 +1,24 @@
+2012-04-17  Aaron Colwell  <acolwell@chromium.org>
+
+        Add sourceAddId() & sourceRemoveId() stubs for Chromium.
+        These are needed to bring the Media Source implementation 
+        up to date with the new 0.4 version of the Media Source spec.
+        http://html5-mediasource-api.googlecode.com/svn/tags/0.4/draft-spec/mediasource-draft-spec.html
+        https://bugs.webkit.org/show_bug.cgi?id=83616
+
+        Reviewed by Eric Carlson, Darin Fisher.
+
+        * public/WebMediaPlayer.h:
+        (WebKit::WebMediaPlayer::sourceAddId):
+        (WebKit::WebMediaPlayer::sourceRemoveId):
+        * src/AssertMatchingEnums.cpp:
+        * src/WebMediaPlayerClientImpl.cpp:
+        (WebKit::WebMediaPlayerClientImpl::sourceAddId):
+        (WebKit):
+        (WebKit::WebMediaPlayerClientImpl::sourceRemoveId):
+        * src/WebMediaPlayerClientImpl.h:
+        (WebMediaPlayerClientImpl):
+
 2012-04-17  Kent Tamura  <tkent@chromium.org>
 
         [Chromium] Calendar Picker: Popup position is wrong when there are
index c293cee..f39469f 100644 (file)
@@ -34,6 +34,7 @@
 #include "WebTimeRange.h"
 #include "WebVideoFrame.h"
 #include "platform/WebCanvas.h"
+#include "platform/WebString.h"
 
 namespace WebKit {
 
@@ -98,6 +99,12 @@ public:
         Auto = PreloadAuto,
     };
 
+    enum AddIdStatus {
+        AddIdStatusOk,
+        AddIdStatusNotSupported,
+        AddIdStatusReachedIdLimit
+    };
+
     enum EndOfStreamStatus {
         EndOfStreamStatusNoError,
         EndOfStreamStatusNetworkError,
@@ -191,6 +198,8 @@ public:
 
     virtual WebAudioSourceProvider* audioSourceProvider() { return 0; }
 
+    virtual AddIdStatus sourceAddId(const WebString& id, const WebString& type) { return AddIdStatusNotSupported; }
+    virtual bool sourceRemoveId(const WebString& id) { return false; }
     virtual bool sourceAppend(const unsigned char* data, unsigned length) { return false; }
     virtual void sourceEndOfStream(EndOfStreamStatus)  { }
 
index 2dbcda6..4a2186a 100644 (file)
@@ -402,6 +402,12 @@ COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadNone, MediaPlayer::None);
 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadMetaData, MediaPlayer::MetaData);
 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadAuto, MediaPlayer::Auto);
 
+#if ENABLE(MEDIA_SOURCE)
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::AddIdStatusOk, MediaPlayer::Ok);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::AddIdStatusNotSupported, MediaPlayer::NotSupported);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::AddIdStatusReachedIdLimit, MediaPlayer::ReachedIdLimit);
+#endif
+
 #if ENABLE(ENCRYPTED_MEDIA)
 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::EndOfStreamStatusNoError, MediaPlayer::EosNoError);
 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::EndOfStreamStatusNetworkError, MediaPlayer::EosNetworkError);
index 6a92753..58b6396 100644 (file)
@@ -340,6 +340,22 @@ void WebMediaPlayerClientImpl::pause()
 }
 
 #if ENABLE(MEDIA_SOURCE)
+WebCore::MediaPlayer::AddIdStatus WebMediaPlayerClientImpl::sourceAddId(const String& id, const String& type)
+{
+    if (!m_webMediaPlayer)
+        return WebCore::MediaPlayer::NotSupported;
+
+    return static_cast<WebCore::MediaPlayer::AddIdStatus>(m_webMediaPlayer->sourceAddId(id, type));
+}
+
+bool WebMediaPlayerClientImpl::sourceRemoveId(const String& id)
+{
+    if (!m_webMediaPlayer)
+        return false;
+
+    return m_webMediaPlayer->sourceRemoveId(id);
+}
+
 bool WebMediaPlayerClientImpl::sourceAppend(const unsigned char* data, unsigned length)
 {
     if (m_webMediaPlayer)
index 7ae32a5..2e9e083 100644 (file)
@@ -149,6 +149,8 @@ public:
 #endif
 
 #if ENABLE(MEDIA_SOURCE)
+    virtual WebCore::MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type);
+    virtual bool sourceRemoveId(const String&);
     virtual bool sourceAppend(const unsigned char* data, unsigned length);
     virtual void sourceEndOfStream(WebCore::MediaPlayer::EndOfStreamStatus);
 #endif