Changeset 117662 in webkit


Ignore:
Timestamp:
May 18, 2012 6:08:46 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: Update Media Source implementation to reflect changes in 0.5 spec.
https://bugs.webkit.org/show_bug.cgi?id=83607

Patch by Aaron Colwell <acolwell@chromium.org> on 2012-05-18
Reviewed by Darin Fisher.

Tests: http/tests/media/media-source/video-media-source-event-attributes.html

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

  • html/HTMLAttributeNames.in: Add onwebkitsourcexxx event attribute names.
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute): Add code to register event listeners for the onwebkitsourcexxx attributes.
(WebCore::HTMLMediaElement::pauseInternal):
(WebCore):
(WebCore::HTMLMediaElement::webkitSourceAddId): Changed code to pass the parsed type & codecs to m_player instead of the whole MIME-type string. This was done to allow some simple parsing & validation code to be shared in WebKit instead of reimplemented in every port.
(WebCore::HTMLMediaElement::webkitSourceBuffered): New method in the v0.5 spec. It validates the parameters & that it is being called in the correct state. If so it forwards the call to m_player.
(WebCore::HTMLMediaElement::webkitSourceAppend): Adds id parameter to match v0.5 signature. Minor logic changes that avoid calling m_player for 0 byte arrays and fixes exceptions reported for a null array and a parse error so they match the spec text.
(WebCore::HTMLMediaElement::webkitSourceAbort): New method in the v0.5 spec. It validates the parameter & that it is being called in athe correct state. If so it forwards the call to m_player.

  • html/HTMLMediaElement.h:

(HTMLMediaElement): Added new methods, signature updates, and onwebitsourcexxx event listener attributes.

  • html/HTMLMediaElement.idl: Added new methods, signature updates, and onwebitsourcexxx event listener attributes.
  • platform/ContentType.cpp:

(WebCore::ContentType::codecs): A new method that parses the codecs parameter into a vector of codec strings.
(WebCore):

  • platform/ContentType.h:

(ContentType):

  • platform/graphics/MediaPlayer.cpp:

(WebCore::NullMediaPlayerPrivate::sourceAddId): Update the signature to take the parsed type and codecs vector.
(WebCore::NullMediaPlayerPrivate::sourceBuffered): Add default implementation for this new method.
(WebCore::NullMediaPlayerPrivate::sourceRemoveId): Remove id parameter name to match other methods.
(WebCore::NullMediaPlayerPrivate::sourceAppend): Updated signature to include id parameter.
(WebCore::NullMediaPlayerPrivate::sourceAbort): Add default implementation for this new method.
(WebCore::NullMediaPlayerPrivate::sourceEndOfStream): Remove parameter name to match other methods.
(WebCore::MediaPlayer::sourceAddId): Update the signature to take the parsed type and codecs vector.
(WebCore):
(WebCore::MediaPlayer::sourceBuffered): Add implementation for new method that forwards the call to the MediaPlayerPrivate interface.
(WebCore::MediaPlayer::sourceAppend): Update method to forward the new id parameter in the signature.
(WebCore::MediaPlayer::sourceAbort): Add implementation for new method that forwards the call to the MediaPlayerPrivate interface.

  • platform/graphics/MediaPlayer.h: Update interface to include new methods and updated signatures.
  • platform/graphics/MediaPlayerPrivate.h:

(WebCore::MediaPlayerPrivateInterface::sourceAddId): Update the signature to take the parsed type and codecs vector.
(WebCore::MediaPlayerPrivateInterface::sourceBuffered): Add default implementation for new method.
(WebCore::MediaPlayerPrivateInterface::sourceAppend): Update method to forward the new id parameter in the signature.
(WebCore::MediaPlayerPrivateInterface::sourceAbort): Add default implementation for new method.

Source/WebKit/chromium: Update Media Source implementation to reflect changes in 0.5 spec.
https://bugs.webkit.org/show_bug.cgi?id=83607

Patch by Aaron Colwell <acolwell@chromium.org> on 2012-05-18
Reviewed by Darin Fisher.

  • public/WebMediaPlayer.h:

(WebKit::WebMediaPlayer::sourceAddId): Update the signature to take the parsed type and codecs vector.
(WebKit::WebMediaPlayer::sourceBuffered): Add default implementation for new method.
(WebKit::WebMediaPlayer::sourceAppend): Update signature to include id parameter.
(WebKit::WebMediaPlayer::sourceAbort): Add default implementation for new method.

  • src/WebMediaPlayerClientImpl.cpp:

(WebKit::WebMediaPlayerClientImpl::sourceAddId): Update the signature to take the parsed type and codecs vector.
(WebKit::WebMediaPlayerClientImpl::sourceBuffered): Added implementation for new method. Converts WebKit::WebTimeRanges to WebCore::TimeRanges.
(WebKit):
(WebKit::WebMediaPlayerClientImpl::sourceAppend): Update signature to include id parameter.
(WebKit::WebMediaPlayerClientImpl::sourceAbort): Implementation for new method.

  • src/WebMediaPlayerClientImpl.h:

(WebMediaPlayerClientImpl): Added declarations for new methods and updated signatures for existing ones.

LayoutTests: Updated Media Source LayoutTests to use v0.5 spec signatures and added
new tests to verify the behavior of the new methods.
https://bugs.webkit.org/show_bug.cgi?id=83607

Patch by Aaron Colwell <acolwell@chromium.org> on 2012-05-18
Reviewed by Darin Fisher.

  • http/tests/media/media-source/video-media-source-event-attributes-expected.txt: Added.
  • http/tests/media/media-source/video-media-source-event-attributes.html: Added. Tests onwebkitsourcexxx event attributes.
  • http/tests/media/media-source/webm/video-media-source-abort-expected.txt: Added.
  • http/tests/media/media-source/webm/video-media-source-abort.html: Added. Tests basic webkitSourceAbort() functionality.
  • 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. Tests webkitSourceAddId() & webkitSourceRemoveId().
  • http/tests/media/media-source/webm/video-media-source-errors.html: Style fixes and add addSourceId() since we need to add an ID before appending data now.
  • http/tests/media/media-source/webm/video-media-source-play.html: Style fixes and add addSourceId().
  • http/tests/media/media-source/webm/video-media-source-seek.html: Style fixes and add addSourceId().
  • http/tests/media/media-source/webm/video-media-source-state-changes.html: Style fixes and add addSourceId().
  • http/tests/media/media-source/webm/webm-media-source.js:

(getData.request.onload): Style fix.
(getData): Style fix.
(loadWebMData): Style fix.
(addSourceId): New helper method that adds SOURCE_ID to the video tag so data can be appended with this ID.
(appendHeaders): Add SOURCE_ID parameter since the webkitSourceAppend() signature changed.
(appendCluster): Add SOURCE_ID parameter since the webkitSourceAppend() signature changed.
(appendUntilEndOfStream): Add SOURCE_ID parameter since the webkitSourceAppend() signature changed.

Location:
trunk
Files:
6 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117658 r117662  
     12012-05-18  Aaron Colwell  <acolwell@chromium.org>
     2
     3        Updated Media Source LayoutTests to use v0.5 spec signatures and added
     4        new tests to verify the behavior of the new methods.
     5        https://bugs.webkit.org/show_bug.cgi?id=83607
     6
     7        Reviewed by Darin Fisher.
     8
     9        * http/tests/media/media-source/video-media-source-event-attributes-expected.txt: Added.
     10        * http/tests/media/media-source/video-media-source-event-attributes.html: Added. Tests onwebkitsourcexxx event attributes.
     11        * http/tests/media/media-source/webm/video-media-source-abort-expected.txt: Added.
     12        * http/tests/media/media-source/webm/video-media-source-abort.html: Added. Tests basic webkitSourceAbort() functionality.
     13        * http/tests/media/media-source/webm/video-media-source-add-and-remove-ids-expected.txt: Added.
     14        * http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html: Added. Tests webkitSourceAddId() & webkitSourceRemoveId().
     15        * http/tests/media/media-source/webm/video-media-source-errors.html: Style fixes and add addSourceId() since we need to add an ID before appending data now.
     16        * http/tests/media/media-source/webm/video-media-source-play.html: Style fixes and add addSourceId().
     17        * http/tests/media/media-source/webm/video-media-source-seek.html: Style fixes and add addSourceId().
     18        * http/tests/media/media-source/webm/video-media-source-state-changes.html: Style fixes and add addSourceId().
     19        * http/tests/media/media-source/webm/webm-media-source.js:
     20        (getData.request.onload): Style fix.
     21        (getData): Style fix.
     22        (loadWebMData): Style fix.
     23        (addSourceId): New helper method that adds SOURCE_ID to the video tag so data can be appended with this ID.
     24        (appendHeaders): Add SOURCE_ID parameter since the webkitSourceAppend() signature changed.
     25        (appendCluster): Add SOURCE_ID parameter since the webkitSourceAppend() signature changed.
     26        (appendUntilEndOfStream): Add SOURCE_ID parameter since the webkitSourceAppend() signature changed.
     27
    1282012-05-18  Eric Seidel  <eric@webkit.org>
    229
  • trunk/LayoutTests/http/tests/media/media-source/webm/video-media-source-errors.html

    r115380 r117662  
    146146                testCaseIndex++;
    147147
    148                 var eventHandlerFunction = function (event) {
     148                var eventHandlerFunction = function (event)
     149                {
    149150                    consoleWrite("");
    150151                    consoleWrite("running " + functionName);
    151152                    event.target.removeEventListener('webkitsourceopen', eventHandlerFunction);
     153                    addSourceId(event.target);
    152154                    onOpenFunction(event);
    153155                };
  • trunk/LayoutTests/http/tests/media/media-source/webm/video-media-source-play.html

    r113495 r117662  
    88            {
    99                var videoTag = event.target;
     10                addSourceId(videoTag);
    1011                appendHeaders(videoTag);
    1112                appendUntilEndOfStream(videoTag, 0);
     
    2526                video.addEventListener('webkitsourceopen', onSourceOpen);
    2627
    27                 loadWebMData(function(success) {
     28                loadWebMData(function(success)
     29                {
    2830                    if (!success) {
    2931                        failTest("Failed to load WebM data");
  • trunk/LayoutTests/http/tests/media/media-source/webm/video-media-source-seek.html

    r113495 r117662  
    1616                    firstOpen = false;
    1717
     18                    addSourceId(videoTag);
    1819                    appendHeaders(videoTag);
    1920                    appendUntilEndOfStream(videoTag, 0);
     
    6970                video.addEventListener('seeked', onSeeked);
    7071
    71                 loadWebMData(function(success) {
     72                loadWebMData(function(success)
     73                {
    7274                    if (!success) {
    7375                        failTest("Failed to load WebM data");
  • trunk/LayoutTests/http/tests/media/media-source/webm/video-media-source-state-changes.html

    r113495 r117662  
    77            var seekTime = getClusterTimeForIndex(4);
    88
    9             function appendUntilEnd(videoTag, startIndex) 
     9            function appendUntilEnd(videoTag, startIndex)
    1010            {
    1111                for (var index = startIndex; index < getClusterCount(); index++) {
    12                     videoTag.webkitSourceAppend(getCluster(index));
     12                    appendCluster(videoTag, index);
    1313                }
    1414
     
    1616            }
    1717
    18             function appendClustersForSeek(videoTag, clusterSeekTime) 
     18            function appendClustersForSeek(videoTag, clusterSeekTime)
    1919            {
    2020                var clusterIndex = getClusterIndexForTimestamp(clusterSeekTime);
     
    2222
    2323                for (; (clusterIndex < endIndex) && (clusterIndex < getClusterCount()); clusterIndex++) {
    24                     videoTag.webkitSourceAppend(getCluster(clusterIndex));
     24                    appendCluster(videoTag, clusterIndex);
    2525                }
    2626
     
    3131            }
    3232
    33             function onSourceEvent(event) 
     33            function onSourceEvent(event)
    3434            {
    3535                consoleWrite('EVENT(' + event.type + ') : ' + getSourceStateName(event.target.webkitSourceState));
    3636            }
    3737
    38             function onFirstSourceOpen(event) 
     38            function onFirstSourceOpen(event)
    3939            {
    4040                // This is the first time the source is opened. We just want to append
     
    4444                var videoTag = event.target;
    4545                videoTag.removeEventListener('webkitsourceopen', onFirstSourceOpen);
     46                addSourceId(videoTag);
    4647
    4748                expectSourceState(videoTag, HTMLMediaElement.SOURCE_OPEN);
     
    5556            }
    5657
    57             function onFirstSourceEnded(event) 
     58            function onFirstSourceEnded(event)
    5859            {
    5960                var videoTag = event.target;
     
    6667            }
    6768
    68             function triggerFirstSeek(event) {
     69            function triggerFirstSeek(event)
     70            {
    6971                var videoTag = event.target;
    7072                videoTag.removeEventListener('playing', triggerFirstSeek);
     
    7779            }
    7880
    79             function onFirstSeeking(event) 
     81            function onFirstSeeking(event)
    8082            {
    8183                var videoTag = event.target;
     
    8890            }
    8991
    90             function onFirstSeeked(event) 
     92            function onFirstSeeked(event)
    9193            {
    9294                var videoTag = event.target;
     
    101103            }
    102104
    103             function onSecondSeeking(event) 
     105            function onSecondSeeking(event)
    104106            {
    105107                var videoTag = event.target;
     
    112114            }
    113115
    114             function onSecondSeeked(event) 
     116            function onSecondSeeked(event)
    115117            {
    116118                var videoTag = event.target;
     
    124126            }
    125127
    126             function onFirstSourceClose(event) 
     128            function onFirstSourceClose(event)
    127129            {
    128130                var videoTag = event.target;
     
    134136            }
    135137
    136             function onSecondSourceOpen(event) 
     138            function onSecondSourceOpen(event)
    137139            {
    138140                var videoTag = event.target;
    139141                videoTag.removeEventListener('webkitsourceopen', onSecondSourceOpen);
     142                addSourceId(videoTag);
    140143
    141144                expectSourceState(videoTag, HTMLMediaElement.SOURCE_OPEN);
     
    149152            }
    150153
    151             function onSecondSourceEnded(event) 
     154            function onSecondSourceEnded(event)
    152155            {
    153156                var videoTag = event.target;
     
    160163            }
    161164
    162             function triggerSecondSourceClose(event) {
     165            function triggerSecondSourceClose(event)
     166            {
    163167                var videoTag = event.target;
    164168                videoTag.removeEventListener('playing', triggerSecondSourceClose);
     
    169173            }
    170174
    171             function onSecondSourceClose(event) 
     175            function onSecondSourceClose(event)
    172176            {
    173177                var videoTag = event.target;
     
    178182            }
    179183
    180             function onThirdSourceOpen(event) 
     184            function onThirdSourceOpen(event)
    181185            {
    182186                var videoTag = event.target;
    183187                videoTag.removeEventListener('webkitsourceopen', onThirdSourceOpen);
     188                addSourceId(videoTag);
    184189
    185190                expectSourceState(videoTag, HTMLMediaElement.SOURCE_OPEN);
     
    188193            }
    189194
    190             function onLoad() 
     195            function onLoad()
    191196            {
    192197                findMediaElement();
     
    207212
    208213                logSourceState(video);
    209                 loadWebMData(function(success) {
     214                loadWebMData(function(success)
     215                {
    210216                    if (!success) {
    211217                        failTest("Failed to load WebM data");
  • trunk/LayoutTests/http/tests/media/media-source/webm/webm-media-source.js

    r113495 r117662  
    1212var headerData = null;
    1313var clusterData = [];
     14var SOURCE_ID = "sourceID1";
    1415
    1516function getData(url, callback)
     
    1819    request.open("GET", url, true);
    1920    request.responseType = 'arraybuffer';
    20     request.onload = function() {
     21    request.onload = function()
     22    {
    2123        if (request.status != 200) {
    2224            failTest("Unexpected status code " + request.status + " for " + url);
     
    3032}
    3133
    32 function createClusterGetFunction(clusterIndex, callback) {
    33     return function(data) {
     34function createClusterGetFunction(clusterIndex, callback)
     35{
     36    return function(data)
     37    {
    3438        if (!data) {
    3539            callback(false);
     
    5054}
    5155
    52 function loadWebMData(callback) {
    53     getData("/media/resources/media-source/webm/test.webm.headers", function(data) {
     56function loadWebMData(callback)
     57{
     58    getData("/media/resources/media-source/webm/test.webm.headers", function(data)
     59    {
    5460        if (!data) {
    5561            callback(false);
     
    109115}
    110116
     117function addSourceId(videoTag)
     118{
     119    try {
     120        videoTag.webkitSourceAddId(SOURCE_ID, 'video/webm; codecs="vp8, vorbis"');
     121    } catch (e) {
     122        failTest("Unexpected webkitSourceAddId() exception " + e);
     123    }
     124}
     125
    111126function appendHeaders(videoTag)
    112127{
     
    116131    }
    117132
    118     videoTag.webkitSourceAppend(getHeaders());
     133    videoTag.webkitSourceAppend(SOURCE_ID, getHeaders());
    119134}
    120135
     
    133148    try {
    134149        var cluster = getCluster(clusterIndex);
    135         videoTag.webkitSourceAppend(cluster);
     150        videoTag.webkitSourceAppend(SOURCE_ID, cluster);
    136151    } catch (err) {
    137152        consoleWrite(err);
     
    147162
    148163    for (var clusterIndex = startIndex; clusterIndex < getClusterCount(); clusterIndex++) {
    149         videoTag.webkitSourceAppend(getCluster(clusterIndex));
     164        videoTag.webkitSourceAppend(SOURCE_ID, getCluster(clusterIndex));
    150165    }
    151166    videoTag.webkitSourceEndOfStream(videoTag.EOS_NO_ERROR);
  • trunk/Source/WebCore/ChangeLog

    r117659 r117662  
     12012-05-18  Aaron Colwell  <acolwell@chromium.org>
     2
     3        Update Media Source implementation to reflect changes in 0.5 spec.
     4        https://bugs.webkit.org/show_bug.cgi?id=83607
     5
     6        Reviewed by Darin Fisher.
     7
     8        Tests: http/tests/media/media-source/video-media-source-event-attributes.html
     9               http/tests/media/media-source/webm/video-media-source-abort.html
     10               http/tests/media/media-source/webm/video-media-source-add-and-remove-ids.html
     11
     12        * html/HTMLAttributeNames.in: Add onwebkitsourcexxx event attribute names.
     13        * html/HTMLMediaElement.cpp:
     14        (WebCore::HTMLMediaElement::parseAttribute): Add code to register event listeners for the onwebkitsourcexxx attributes.
     15        (WebCore::HTMLMediaElement::pauseInternal):
     16        (WebCore):
     17        (WebCore::HTMLMediaElement::webkitSourceAddId): Changed code to pass the parsed type & codecs to m_player instead of the whole MIME-type string. This was done to allow some simple parsing & validation code to be shared in WebKit instead of reimplemented in every port.
     18        (WebCore::HTMLMediaElement::webkitSourceBuffered): New method in the v0.5 spec. It validates the parameters & that it is being called in the correct state. If so it forwards the call to m_player.
     19        (WebCore::HTMLMediaElement::webkitSourceAppend): Adds id parameter to match v0.5 signature. Minor logic changes that avoid calling m_player for 0 byte arrays and fixes exceptions reported for a null array and a parse error so they match the spec text.
     20        (WebCore::HTMLMediaElement::webkitSourceAbort): New method in the v0.5 spec. It validates the parameter & that it is being called in athe correct state. If so it forwards the call to m_player.
     21        * html/HTMLMediaElement.h:
     22        (HTMLMediaElement): Added new methods, signature updates, and onwebitsourcexxx event listener attributes.
     23        * html/HTMLMediaElement.idl: Added new methods, signature updates, and onwebitsourcexxx event listener attributes.
     24        * platform/ContentType.cpp:
     25        (WebCore::ContentType::codecs): A new method that parses the codecs parameter into a vector of codec strings.
     26        (WebCore):
     27        * platform/ContentType.h:
     28        (ContentType):
     29        * platform/graphics/MediaPlayer.cpp:
     30        (WebCore::NullMediaPlayerPrivate::sourceAddId): Update the signature to take the parsed type and codecs vector.
     31        (WebCore::NullMediaPlayerPrivate::sourceBuffered): Add default implementation for this new method.
     32        (WebCore::NullMediaPlayerPrivate::sourceRemoveId): Remove id parameter name to match other methods.
     33        (WebCore::NullMediaPlayerPrivate::sourceAppend): Updated signature to include id parameter.
     34        (WebCore::NullMediaPlayerPrivate::sourceAbort): Add default implementation for this new method.
     35        (WebCore::NullMediaPlayerPrivate::sourceEndOfStream): Remove parameter name to match other methods.
     36        (WebCore::MediaPlayer::sourceAddId): Update the signature to take the parsed type and codecs vector.
     37        (WebCore):
     38        (WebCore::MediaPlayer::sourceBuffered): Add implementation for new method that forwards the call to the MediaPlayerPrivate interface.
     39        (WebCore::MediaPlayer::sourceAppend): Update method to forward the new id parameter in the signature.
     40        (WebCore::MediaPlayer::sourceAbort): Add implementation for new method that forwards the call to the MediaPlayerPrivate interface.
     41        * platform/graphics/MediaPlayer.h: Update interface to include new methods and updated signatures.
     42        * platform/graphics/MediaPlayerPrivate.h:
     43        (WebCore::MediaPlayerPrivateInterface::sourceAddId): Update the signature to take the parsed type and codecs vector.
     44        (WebCore::MediaPlayerPrivateInterface::sourceBuffered): Add default implementation for new method.
     45        (WebCore::MediaPlayerPrivateInterface::sourceAppend): Update method to forward the new id parameter in the signature.
     46        (WebCore::MediaPlayerPrivateInterface::sourceAbort): Add default implementation for new method.
     47
    1482012-05-18  Levi Weintraub  <leviw@chromium.org>
    249
  • trunk/Source/WebCore/html/HTMLAttributeNames.in

    r116592 r117662  
    254254onwebkitkeymessage
    255255onwebkitneedkey
     256onwebkitsourceclose
     257onwebkitsourceended
     258onwebkitsourceopen
    256259onwebkittransitionend
    257260open
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r117242 r117662  
    425425    else if (attribute.name() == onwebkitendfullscreenAttr)
    426426        setAttributeEventListener(eventNames().webkitendfullscreenEvent, createAttributeEventListener(this, attribute));
     427#if ENABLE(MEDIA_SOURCE)
     428    else if (attribute.name() == onwebkitsourcecloseAttr)
     429        setAttributeEventListener(eventNames().webkitsourcecloseEvent, createAttributeEventListener(this, attribute));
     430    else if (attribute.name() == onwebkitsourceendedAttr)
     431        setAttributeEventListener(eventNames().webkitsourceendedEvent, createAttributeEventListener(this, attribute));
     432    else if (attribute.name() == onwebkitsourceopenAttr)
     433        setAttributeEventListener(eventNames().webkitsourceopenEvent, createAttributeEventListener(this, attribute));
     434#endif
    427435    else
    428436        HTMLElement::parseAttribute(attribute);
     
    22922300
    22932301    m_autoplaying = false;
    2294    
     2302
    22952303    if (!m_paused) {
    22962304        m_paused = true;
     
    23032311
    23042312#if ENABLE(MEDIA_SOURCE)
     2313
    23052314void HTMLMediaElement::webkitSourceAddId(const String& id, const String& type, ExceptionCode& ec)
    23062315{
     
    23252334    }
    23262335
    2327     switch (m_player->sourceAddId(id, type)) {
     2336    ContentType contentType(type);
     2337    Vector<String> codecs = contentType.codecs();
     2338
     2339    if (!codecs.size()) {
     2340        ec = NOT_SUPPORTED_ERR;
     2341        return;
     2342    }
     2343
     2344    switch (m_player->sourceAddId(id, contentType.type(), codecs)) {
    23282345    case MediaPlayer::Ok:
    23292346        m_sourceIDs.add(id);
     
    23562373}
    23572374
    2358 void HTMLMediaElement::webkitSourceAppend(PassRefPtr<Uint8Array> data, ExceptionCode& ec)
    2359 {
     2375PassRefPtr<TimeRanges> HTMLMediaElement::webkitSourceBuffered(const String& id, ExceptionCode& ec)
     2376{
     2377    if (!isValidSourceId(id, ec))
     2378        return 0;
     2379
     2380    if (!m_player || m_currentSrc != m_mediaSourceURL || m_sourceState == SOURCE_CLOSED) {
     2381        ec = INVALID_STATE_ERR;
     2382        return 0;
     2383    }
     2384
     2385    return m_player->sourceBuffered(id);
     2386}
     2387
     2388void HTMLMediaElement::webkitSourceAppend(const String& id, PassRefPtr<Uint8Array> data, ExceptionCode& ec)
     2389{
     2390    if (!isValidSourceId(id, ec))
     2391        return;
     2392
    23602393    if (!m_player || m_currentSrc != m_mediaSourceURL || m_sourceState != SOURCE_OPEN) {
    23612394        ec = INVALID_STATE_ERR;
     
    23632396    }
    23642397
    2365     if (!data.get() || !m_player->sourceAppend(data->data(), data->length())) {
     2398    if (!data.get()) {
     2399        ec = INVALID_ACCESS_ERR;
     2400        return;
     2401    }
     2402
     2403    if (!data->length())
     2404        return;
     2405
     2406    if (!m_player->sourceAppend(id, data->data(), data->length())) {
    23662407        ec = SYNTAX_ERR;
    23672408        return;
    23682409    }
     2410}
     2411
     2412void HTMLMediaElement::webkitSourceAbort(const String& id, ExceptionCode& ec)
     2413{
     2414    if (!isValidSourceId(id, ec))
     2415        return;
     2416
     2417    if (!m_player || m_currentSrc != m_mediaSourceURL || m_sourceState != SOURCE_OPEN) {
     2418        ec = INVALID_STATE_ERR;
     2419        return;
     2420    }
     2421
     2422    if (!m_player->sourceAbort(id))
     2423        ASSERT_NOT_REACHED();
    23692424}
    23702425
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r117195 r117662  
    175175    void webkitSourceAddId(const String&, const String&, ExceptionCode&);
    176176    void webkitSourceRemoveId(const String&, ExceptionCode&);
    177     void webkitSourceAppend(PassRefPtr<Uint8Array> data, ExceptionCode&);
     177    PassRefPtr<TimeRanges> webkitSourceBuffered(const String&, ExceptionCode&);
     178    void webkitSourceAppend(const String&, PassRefPtr<Uint8Array> data, ExceptionCode&);
     179    void webkitSourceAbort(const String&, ExceptionCode&);
    178180    enum EndOfStreamStatus { EOS_NO_ERROR, EOS_NETWORK_ERR, EOS_DECODE_ERR };
    179181    void webkitSourceEndOfStream(unsigned short, ExceptionCode&);
     
    181183    SourceState webkitSourceState() const;
    182184    void setSourceState(SourceState);
     185
     186    DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitsourceopen);
     187    DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitsourceended);
     188    DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitsourceclose);
    183189#endif
    184190
  • trunk/Source/WebCore/html/HTMLMediaElement.idl

    r115745 r117662  
    100100    readonly attribute [V8EnabledAtRuntime=mediaSource, URL] DOMString webkitMediaSourceURL;
    101101
    102     // Appends media to to the source.
    103     [V8EnabledAtRuntime=mediaSource] void webkitSourceAppend(in Uint8Array data) raises (DOMException);
     102    // Manages IDs for appending media to the source.
     103    [V8EnabledAtRuntime=mediaSource] void webkitSourceAddId(in DOMString id, in DOMString type) raises (DOMException);
     104    [V8EnabledAtRuntime=mediaSource] void webkitSourceRemoveId(in DOMString id) raises (DOMException);
     105
     106    // Returns the time ranges buffered for a specific source ID.
     107    [V8EnabledAtRuntime=mediaSource] TimeRanges webkitSourceBuffered(in DOMString id) raises (DOMException);
     108   
     109    // Appends segment data.
     110    [V8EnabledAtRuntime=mediaSource] void webkitSourceAppend(in DOMString id, in Uint8Array data) raises (DOMException);
     111
     112    // Aborts the current segment.
     113    [V8EnabledAtRuntime=mediaSource] void webkitSourceAbort(in DOMString id) raises (DOMException);
    104114
    105115    // Signals the end of stream.
     
    114124    [V8EnabledAtRuntime=mediaSource] const unsigned short SOURCE_ENDED = 2;
    115125    readonly attribute [V8EnabledAtRuntime=mediaSource] unsigned short webkitSourceState;
     126
     127    attribute [V8EnabledAtRuntime=mediaSource] EventListener onwebkitsourceopen;
     128    attribute [V8EnabledAtRuntime=mediaSource] EventListener onwebkitsourceended;
     129    attribute [V8EnabledAtRuntime=mediaSource] EventListener onwebkitsourceclose;
    116130#endif
    117131
  • trunk/Source/WebCore/platform/ContentType.cpp

    r95901 r117662  
    7777}
    7878
     79Vector<String> ContentType::codecs() const
     80{
     81    String codecsParameter = parameter("codecs");
     82
     83    if (codecsParameter.isEmpty())
     84        return Vector<String>();
     85
     86    Vector<String> codecs;
     87    codecsParameter.split(",", codecs);
     88    for (size_t i = 0; i < codecs.size(); ++i)
     89        codecs[i] = codecs[i].simplifyWhiteSpace();
     90
     91    return codecs;
     92}
     93
    7994} // namespace WebCore
  • trunk/Source/WebCore/platform/ContentType.h

    r95901 r117662  
    3838        String parameter (const String& parameterName) const;
    3939        String type() const;
     40        Vector<String> codecs() const;
    4041        const String& raw() const { return m_type; }
    4142    private:
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r117147 r117662  
    150150
    151151#if ENABLE(MEDIA_SOURCE)
    152     virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type) { return MediaPlayer::NotSupported; }
    153     virtual bool sourceRemoveId(const String& id) { return false; }
    154     virtual bool sourceAppend(const unsigned char*, unsigned) { return false; }
    155     virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus status) { }
     152    virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
     153    virtual PassRefPtr<TimeRanges> sourceBuffered(const String&) { return TimeRanges::create(); }
     154    virtual bool sourceRemoveId(const String&) { return false; }
     155    virtual bool sourceAppend(const String&, const unsigned char*, unsigned) { return false; }
     156    virtual bool sourceAbort(const String&) { return false; }
     157    virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { }
    156158#endif
    157159
     
    462464#if ENABLE(MEDIA_SOURCE)
    463465
    464 MediaPlayer::AddIdStatus MediaPlayer::sourceAddId(const String& id, const String& type)
    465 {
    466     return m_private->sourceAddId(id, type);
     466MediaPlayer::AddIdStatus MediaPlayer::sourceAddId(const String& id, const String& type, const Vector<String>& codecs)
     467{
     468    return m_private->sourceAddId(id, type, codecs);
     469}
     470
     471PassRefPtr<TimeRanges> MediaPlayer::sourceBuffered(const String& id)
     472{
     473    return m_private->sourceBuffered(id);
    467474}
    468475
     
    472479}
    473480
    474 bool MediaPlayer::sourceAppend(const unsigned char* data, unsigned length)
    475 {
    476     return m_private->sourceAppend(data, length);
     481bool MediaPlayer::sourceAppend(const String& id, const unsigned char* data, unsigned length)
     482{
     483    return m_private->sourceAppend(id, data, length);
     484}
     485
     486bool MediaPlayer::sourceAbort(const String& id)
     487{
     488    return m_private->sourceAbort(id);
    477489}
    478490
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r117147 r117662  
    239239#if ENABLE(MEDIA_SOURCE)
    240240    enum AddIdStatus { Ok, NotSupported, ReachedIdLimit };
    241     AddIdStatus sourceAddId(const String& id, const String& type);
     241    AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs);
    242242    bool sourceRemoveId(const String& id);
    243     bool sourceAppend(const unsigned char* data, unsigned length);
     243    PassRefPtr<TimeRanges> sourceBuffered(const String& id);
     244    bool sourceAppend(const String& id, const unsigned char* data, unsigned length);
     245    bool sourceAbort(const String& id);
    244246    enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
    245247    void sourceEndOfStream(EndOfStreamStatus);
  • trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r116782 r117662  
    166166
    167167#if ENABLE(MEDIA_SOURCE)
    168     virtual MediaPlayer::AddIdStatus sourceAddId(const String&, const String&) { return MediaPlayer::NotSupported; }
    169     virtual bool sourceRemoveId(const String&) { return false; }
    170     virtual bool sourceAppend(const unsigned char*, unsigned) { return false; }
     168    virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
     169    virtual PassRefPtr<TimeRanges> sourceBuffered(const String& id) { return TimeRanges::create(); }
     170    virtual bool sourceRemoveId(const String& id) { return false; }
     171    virtual bool sourceAppend(const String& id, const unsigned char* data, unsigned length) { return false; }
     172    virtual bool sourceAbort(const String& id) { return false; }
    171173    virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { };
    172174#endif
  • trunk/Source/WebKit/chromium/ChangeLog

    r117645 r117662  
     12012-05-18  Aaron Colwell  <acolwell@chromium.org>
     2
     3        Update Media Source implementation to reflect changes in 0.5 spec.
     4        https://bugs.webkit.org/show_bug.cgi?id=83607
     5
     6        Reviewed by Darin Fisher.
     7
     8        * public/WebMediaPlayer.h:
     9        (WebKit::WebMediaPlayer::sourceAddId): Update the signature to take the parsed type and codecs vector.
     10        (WebKit::WebMediaPlayer::sourceBuffered): Add default implementation for new method.
     11        (WebKit::WebMediaPlayer::sourceAppend): Update signature to include id parameter.
     12        (WebKit::WebMediaPlayer::sourceAbort): Add default implementation for new method.
     13        * src/WebMediaPlayerClientImpl.cpp:
     14        (WebKit::WebMediaPlayerClientImpl::sourceAddId): Update the signature to take the parsed type and codecs vector.
     15        (WebKit::WebMediaPlayerClientImpl::sourceBuffered): Added implementation for new method. Converts WebKit::WebTimeRanges to WebCore::TimeRanges.
     16        (WebKit):
     17        (WebKit::WebMediaPlayerClientImpl::sourceAppend): Update signature to include id parameter.
     18        (WebKit::WebMediaPlayerClientImpl::sourceAbort): Implementation for new method.
     19        * src/WebMediaPlayerClientImpl.h:
     20        (WebMediaPlayerClientImpl): Added declarations for new methods and updated signatures for existing ones.
     21
    1222012-05-18  Shawn Singh  <shawnsingh@chromium.org>
    223
  • trunk/Source/WebKit/chromium/public/WebMediaPlayer.h

    r116782 r117662  
    174174    virtual WebAudioSourceProvider* audioSourceProvider() { return 0; }
    175175
    176     virtual AddIdStatus sourceAddId(const WebString& id, const WebString& type) { return AddIdStatusNotSupported; }
     176    virtual AddIdStatus sourceAddId(const WebString& id, const WebString& type,
     177                                    const WebVector<WebString>& codecs) { return AddIdStatusNotSupported; }
    177178    virtual bool sourceRemoveId(const WebString& id) { return false; }
    178     virtual bool sourceAppend(const unsigned char* data, unsigned length) { return false; }
     179    virtual WebTimeRanges sourceBuffered(const WebString& id) { return WebTimeRanges(); };
     180    virtual bool sourceAppend(const WebString& id, const unsigned char* data, unsigned length) { return false; }
     181    virtual bool sourceAbort(const WebString& id) { return false; }
    179182    virtual void sourceEndOfStream(EndOfStreamStatus)  { }
    180183
  • trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp

    r116782 r117662  
    360360
    361361#if ENABLE(MEDIA_SOURCE)
    362 WebCore::MediaPlayer::AddIdStatus WebMediaPlayerClientImpl::sourceAddId(const String& id, const String& type)
     362WebCore::MediaPlayer::AddIdStatus WebMediaPlayerClientImpl::sourceAddId(const String& id, const String& type, const Vector<String>& codecs)
    363363{
    364364    if (!m_webMediaPlayer)
    365365        return WebCore::MediaPlayer::NotSupported;
    366366
    367     return static_cast<WebCore::MediaPlayer::AddIdStatus>(m_webMediaPlayer->sourceAddId(id, type));
     367    return static_cast<WebCore::MediaPlayer::AddIdStatus>(m_webMediaPlayer->sourceAddId(id, type, codecs));
    368368}
    369369
     
    376376}
    377377
    378 bool WebMediaPlayerClientImpl::sourceAppend(const unsigned char* data, unsigned length)
    379 {
    380     if (m_webMediaPlayer)
    381         return m_webMediaPlayer->sourceAppend(data, length);
     378PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::sourceBuffered(const String& id)
     379{
     380    if (!m_webMediaPlayer)
     381        return TimeRanges::create();
     382
     383    WebTimeRanges webRanges = m_webMediaPlayer->sourceBuffered(id);
     384    RefPtr<TimeRanges> ranges = TimeRanges::create();
     385    for (size_t i = 0; i < webRanges.size(); ++i)
     386        ranges->add(webRanges[i].start, webRanges[i].end);
     387    return ranges.release();
     388}
     389
     390bool WebMediaPlayerClientImpl::sourceAppend(const String& id, const unsigned char* data, unsigned length)
     391{
     392    if (m_webMediaPlayer)
     393        return m_webMediaPlayer->sourceAppend(id, data, length);
    382394    return false;
     395}
     396
     397bool WebMediaPlayerClientImpl::sourceAbort(const String& id)
     398{
     399    if (!m_webMediaPlayer)
     400        return false;
     401
     402    return m_webMediaPlayer->sourceAbort(id);
    383403}
    384404
  • trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h

    r116782 r117662  
    155155
    156156#if ENABLE(MEDIA_SOURCE)
    157     virtual WebCore::MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type);
     157    virtual WebCore::MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs);
    158158    virtual bool sourceRemoveId(const String&);
    159     virtual bool sourceAppend(const unsigned char* data, unsigned length);
     159    virtual WTF::PassRefPtr<WebCore::TimeRanges> sourceBuffered(const String&);
     160    virtual bool sourceAppend(const String&, const unsigned char* data, unsigned length);
     161    virtual bool sourceAbort(const String&);
    160162    virtual void sourceEndOfStream(WebCore::MediaPlayer::EndOfStreamStatus);
    161163#endif
Note: See TracChangeset for help on using the changeset viewer.