Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "seamless" cross-codec (and possibly cross-container/track) switching #155

Closed
wolenetz opened this issue Aug 23, 2016 · 32 comments
Closed

Comments

@wolenetz
Copy link
Member

Currently, the minimum interop requirement for A/V tracks is at most one of each.
These tracks must conform to the mime-type used to construct their SourceBuffer(s).
Consequently, web apps that would like to have "seamless" cross-codec (e.g., webm vp9->h264 avc->webm vp8) transitions within the same media timeline must polyfill and depend on event delivery/timers to approximate a best-effort transition across these using multiple MediaSource objects swapped in as media element src.

This issue is opened to understand:

  1. more details of what web authors need around this use case, and
  2. how the MSE spec might need to be adjusted to enable this use case.
@wolenetz wolenetz added this to the VNext milestone Aug 23, 2016
@paulbrucecotton
Copy link

paulbrucecotton commented Aug 23, 2016

Isn't this directly related to the requested Ad Insertion use case and the related Implementation Use Cases?

@wolenetz
Copy link
Member Author

It is. Thank you for linking those here.

@wolenetz
Copy link
Member Author

wolenetz commented May 5, 2017

Codec switching is a commonly requested feature for MSE.
Recent discussion (and potentially improved ability to eventually support this) has been occurring in Chromium (https://crbug.com/695595).

Since the current title of this spec issue implies a solution route (and scope that includes cross-container switching, not just cross-codec switching), I'm renaming it to allow discussion of what the desired scope is first.

Also some details copied from the Chromium discussion, bold mine:

From this comment:

Doing [cross codec switching, possibly with cross container switching] would require a spec change in addition to implementation change.
In addition to codec switching, would container switching also need to be required? (e.g. splice mp4:h264+aac ad into the middle of a webm:vp9+opus stream?)

In the spec, the initialization segment received algorithm disallows codec changes. Such an initialization segment identifies the codec parameters for upcoming media segment appends to that SourceBuffer.
The spec allows for multiple initialization segments to be appended over time to a SourceBuffer (e.g. to accomplish stream adaptation), but disallows for the initialization segments to differ their codec. Paste from pertinent spec text:

Verify the following properties. If any of the checks fail then run the append error algorithm and abort these steps.
The number of audio, video, and text tracks match what was in the first initialization segment.
The codecs for each track, match what was specified in the first initialization segment.
If more than one track for a single type are present (e.g., 2 audio tracks), then the Track IDs match the ones in the first initialization segment.

Rough idea of what might need to be done:

  1. Determine if container switching is also desired, and if so, how to signal such a switch normatively to the SourceBuffer (SourceBuffer.abort() might not be enough by itself; "sniffing" which container bytestream type is appended following a parser reset might not be a complexity that user agents want to be required to do. Alternatively, a mechanism - perhaps a parameter to the abort() call itself, or a distinct method - could be added and required of apps to directly signal which container bytestream will be appended next.

  2. Modify the spec (and incubate in WICG with interested browsers and other web authors) to
    2.a. Include a mechanism by which the API can be queried proactively to determine support for codec (and maybe container) switching. Not all implementations must allow such switching, right?
    2.a.1. Perhaps a new method on MediaSource, akin to isTypeSupported()? Or maybe modify isTypeSupported() (and possibly the non-MSE canPlayType()) enough to provide definitive response to the app about?
    2.a.2. Or perhaps something in the MediaCapabilities spec?
    2.b. Update the spec for MediaSource.isTypeSupported()
    2.c. Update the spec for the initialization segment received algorithm.

  3. Modify Chrome's implementation to experiment through incubation and eventually ship it on by default.

From this comment:

If "seamless" container switching is required, then either a mechanism for proactively requesting track switching is needed, or proactively requiring the application to identify which tracks across the different containers map to the same logical stream. The former is probably simpler to do with the way media track in HTMLMediaElement is currently described.

But if container switching isn't required, just codec switching within the same container track, then both spec and implementation change scope is reduced to accomplish just "seamless" codec switching.

Comments welcome, especially about whether or not cross-container switching is desired, or just same-container cross-codec switching within the same track.

@wolenetz wolenetz changed the title Support "seamless" cross-codec track switching Support "seamless" cross-codec (and possibly cross-container/track) switching May 5, 2017
@paulbrucecotton
Copy link

In addition to codec switching, would container switching also need to be required? (e.g. splice mp4:h264+aac ad into the middle of a webm:vp9+opus stream?)

Wouldn't container switching require changes in HTML5?

/paulc

@wolenetz
Copy link
Member Author

wolenetz commented May 5, 2017

In addition to codec switching, would container switching also need to be required? (e.g. splice mp4:h264+aac ad into the middle of a webm:vp9+opus stream?)

Wouldn't container switching require changes in HTML5?

@paulbrucecotton This isn't totally clear to me, though I suspect it would involve at minimum further extension of HTML5 A/V/Text tracks that MSE already extends. What part of HTML5 were you specifically thinking might need changing to accommodate MSE SourceBuffer container switching (which is "MSE bytestream" switching).

@paulbrucecotton
Copy link

What part of HTML5 were you specifically thinking might need changing to accommodate MSE SourceBuffer container switching (which is "MSE bytestream" switching).

@wolenetz - I could be wrong but I thought HTML5 only supported a single MIME type for content attached to a particular HTMLMediaElement. Every time someone asked for the ability to change MIME types ie for ad insertion someone would point to this this restriction and the discussion would end.

/paulc

@wolenetz
Copy link
Member Author

wolenetz commented May 5, 2017

@paulbrucecotton I don't recall that particular restriction. Rather, MSE v1 requires implementations to support at least 1 audio and 1 video codec in a MediaSource (in 1 or 2 SourceBuffers), but leaves it as a quality of implementation issue for a user agent to possibly support more than this. Historically, many implementations have only done the minimum here, though this is slowly changing.

canPlayType() may need to be extended, though.

-edit added the canPlayType() portion.

@adrianba
Copy link
Contributor

adrianba commented May 5, 2017

This is an issue worth discussion but there are several issues in this space that we explored in the past. For example, what happens when the tracks don't match in the inserted segment. See Bug 22137 - changes in number of audio tracks during advert insertion. canPlayType and anywhere else decisions are made using the codec params would be impacted by allowing format switching.

One approach to solving this was proposed to provide a way to schedule audio/video track selection changes in HTMLMediaElements. Since this was a generic capability for media elements independent of MSE, it was filed on the HTML5 spec but no concrete proposal was made.

@wolenetz
Copy link
Member Author

wolenetz commented May 5, 2017

@adrianba - excellent recall! Using timed text track metadata cues to tell the UA to perform the transitions makes sense to me on the surface. @silviapfeiffer, are there standardized metadata cue possibilities already for this, or would this require new kinds of cues?

If folks agree that metadata cues afford the best route forward, we should follow https://www.w3.org/Bugs/Public/show_bug.cgi?id=22785#c19 and begin working on incubating a proposal (for HTML5 media in general, not just MSE).

@wolenetz
Copy link
Member Author

wolenetz commented Mar 16, 2018

@jdsmith3000 @mwatson2 @mounirlamouri @jyavenard, I have a proposal for potentially incubating a solution for this issue, hopefully for WICG incubation towards inclusion in MSE vNext. Please take a look:

https://github.com/wolenetz/media-source/blob/codec-switching/codec-switching-explainer.md

@jyavenard
Copy link
Member

At a quick glance, I don't understand the need for the changes as stated. A change of spec isn't compulsory.

Currently, the only thing forbidden by the specs is a change of codec type within the same source buffer.
If that limitation still need to be applied (which would be disappointing) the existing spec already allows for adding multiple source buffer of different types. The user agent would "just" (I say just because that's damn hard to implement) have to select which source buffer contains the data we need at a present time.
If the data is only found in a source buffer, that source buffer is selected, otherwise any use buffer would do (maybe could use the one with the best quality)

The impossibility to change code in a source buffer is an artificial limitation, one that would be easy to remove. If we kept the scope to only allow codec change (not container type change), one could simply append a new init segment of the new data type and continue as before.
The new data type would coexist with the existing data.

Such modifications would be trivial (at least for gecko), would allow seamless codec change, and would integrate well with many content providers (they typically don't want to change container)

Why the need for "changeType" when the information is already contained in the init segment to be appended ?

@wolenetz
Copy link
Member Author

The two main parts that the proposed changeType() method affords are cross-codec and cross-bytestream "seamless" adaptation.

While some content providers may not want to change container (bytestream), there is a long-documented use case for this. Further, this allows adaptation cross-bytestream even within "primary content", not just the ad-insertion case.

While I'm increasingly in favor of dropping Chrome's strictness of codec parameters in both addSourceBuffer() and the proposed changeType(), simply dropping that strictness is insufficient at least for affording the seamless cross-bytestream use case.

Also, the proposed changeType(), even for cross-bytestream-switching, requires minimal additional spec'ing; definitely less than might be required for cross-SourceBuffer switching (the latter is certainly not the route I'm proposing).

@wolenetz
Copy link
Member Author

@jyavenard #155 (comment), also:

Why the need for "changeType" when the information is already contained in the init segment to be appended ?

In the cross-bytestream case, changeType() provides a clear point where the application can indicate the bytestream format is changing. This allows the implementation to perform any necessary parser reset and reconfiguration to extract data out of the (potentially new) bytestream format.

@joeyparrish
Copy link
Member

I generally like the proposal in your explainer, but I have a couple of questions.

  1. Would an application be able to detect that changeType() is present in the implementation?

Because of the way Shaka Player is currently architected, this is something we would require to adopt changeType() quickly.

For example, if we could see it before setting up MediaSource by checking SourceBuffer.prototype.changeType, then we could know early and modify the way we filter out streams before playback begins. This would be much preferable to finding out at MediaSource setup time or at switching time that changeType() isn't implemented.

I recall some previous versions of Safari didn't expose SourceBuffer on window at all, though I don't think this is still true, and I don't know if that is explicitly spec'd or not.

  1. If MediaSource.isTypeSupported() returns true for both types a and b, and changeType() is present, is it then implied that we can change from a to b and vice-versa? Or can an implementation support two types independently without permitting switching between them?

If switching between two supported types is not guaranteed to be supported by a given implementation of changeType(), this will complicate things for us. We currently have a one-way pipeline leading into MediaSource. We could react to the rejection of a certain type at switch time, go back up the pipeline, drop that type, and switch to another type and try to recover, but we have nothing resembling this today. changeType() would be more convenient to adopt if we didn't have to grapple with that.

@jyavenard
Copy link
Member

@wolenetz
My suggestions for simply relying on the init comment, was purely related to support of codec change within the same container. All required for support of this, spec wise is the removal in 3.5.7.5 (https://w3c.github.io/media-source/index.html#sourcebuffer-init-segment-received) of the line "The codecs for each track, match what was specified in the first initialization segment."

For cross-codec, cross container. I see no advantage in having changeType() when all of this can be achieved with multiple source buffers with no change in the current spec whatsoever. Though, having better description on the expected behaviour in switching source buffers (like do we prefer the most recent data if buffered range is available in both etc...)
It would keep the spirit of the original spec, as I believe it was intended.

A source buffer contains one type of binary blob (mp4, webm, mpeg), it doesn't introduce the difficulty that @joeyparrish mentioned above (what would isTypeSupported return and the like) by piggy backing something on an existing well defined container.

Adding a new method to just get around some user agent implementation isn't enough I believe to justify those changes.

@jyavenard
Copy link
Member

Following private discussion with @wolenetz, we agree that having a SourceBuffer::changeType(DOMString type) be the easiest way forward.
changeType would have the same prototype as addSourceBuffer

changeType would take the same argument format as MediaSource::addSourceBuffer()

In addition, 3.5.7 Initialization Segment Received (https://w3c.github.io/media-source/index.html#sourcebuffer-init-segment-received) in step 3 (If the first initialization segment received flag is true, then run the following steps: )
the line "The codecs for each track, match what was specified in the first initialization segment." is to be removed, allowing seamless codec change within a container type.

@jyavenard
Copy link
Member

A test page was setup there: https://jyavenard.github.io/htmltests/tests/mse_mp4/changeType/changeType.html
Using firefox nightly, set media.mediasource.experimental.enabled and media.mediasource.webm.enabled preferences to true.

This plays a h264/aac 400x300 followed by h264/aac 640x480 followed by vp9/vorbis 400x300

@wolenetz
Copy link
Member Author

wolenetz commented May 22, 2018

I've updated my media-source fork to now be off wicg (which is off w3c), instead of directly off w3c, since GH doesn't allow for one account having multiple forks sharing an ancestor repository.

For feature work on this issue, let's continue using just this w3c github issue for now. If that becomes too complex, we can add a tag "codec-switching" to track multiple issues related to this feature later.

Feature work will be at github.com/wicg/media-source repository's "codec-switching" branch. This allows multiple other features to also be incubated.

I've populated that branch just now with my codec-switching-explainer.md.

The updated URL for the codec-switching explainer is now: https://github.com/wicg/media-source/blob/codec-switching/codec-switching-explainer.md

@wolenetz
Copy link
Member Author

@jyavenard - Please review the pull request containing the new codec-switching logic: WICG#2 (comment)

If you need wicg repo permissions to be able to comment on that PR, please let me know.

Thanks!

@wolenetz
Copy link
Member Author

(As of next dev/canary build following the changes which landed today), Chrome M69 has SourceBuffer.changeType() available when chrome://flags/#enable-experimental-web-platform-features is enabled.

I have also landed changeType() web-platform-tests: web-platform-tests/wpt#11618
These check the basic interface, implementation steps, and (if there are enough of the test media types detected supported) append various test media, including changeType() and overlap-appends, and then plays the buffered media from start to finish.

Note that some implementations may, for some test media, introduce buffered range gaps across appended media, just like existing same-codec, same-bytestream media before this feature (typically, when the unbuffered gap exceeds implementation-specific tolerances). Such gaps continue to motivate solving #160 for MSE vNext, too.

hubot pushed a commit to WebKit/WebKit-http that referenced this issue Aug 16, 2018
https://bugs.webkit.org/show_bug.cgi?id=188626
LayoutTests/imported/w3c:

Reviewed by Eric Carlson.

* resources/import-expectations.json:
* web-platform-tests/media-source/mediasource-changetype-expected.txt: Added.
* web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added.
* web-platform-tests/media-source/mediasource-changetype-play.html: Added.
* web-platform-tests/media-source/mediasource-changetype-util.js: Added.
(findSupportedChangeTypeTestTypes):
(appendBuffer):
(trimBuffered):
(trimDuration):
(runChangeTypeTest):
(mediaSourceChangeTypeTest):
* web-platform-tests/media-source/mediasource-changetype.html: Added.
* web-platform-tests/media-source/mp3/sound_5.mp3: Added.
* web-platform-tests/media-source/mp3/w3c-import.log: Added.
* web-platform-tests/media-source/w3c-import.log:
* web-platform-tests/media-source/webm/test-vp9.webm: Added.
* web-platform-tests/media-source/webm/w3c-import.log:

Source/WebCore:

Reviewed by Eric Carlson.

Tests: imported/w3c/web-platform-tests/media-source/mediasource-changetype-play.html
       imported/w3c/web-platform-tests/media-source/mediasource-changetype.html

The WICG is incubating a new proposal to allow clients to switch between streams
with different codecs within the same SourceBuffer. The proposal is being tracked
by <w3c/media-source#155> and the proposed spec change
is available at <https://rawgit.com/wicg/media-source/codec-switching/index.html>.

Drive-by fix: One of the wpt tests uses a .mp3 file to test SourceBuffer switching.
The AVStreamDataParser does not necessarily emit every frame appended, and after a
new init segment is appended, it's possible that frames from the previous media
segment will be emitted. This causes an error condition to occur, due to an added
check in the spec for a new flag. When the SourceBuffer asks its private implementation
to reset the parser state, since there's no API on AVStreamDataParser to actually
reset the parser state, just set a flag to drop all emitted buffers until the next
initialization segment is parsed.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::contentTypeShouldGenerateTimestamps):
(WebCore::MediaSource::setDurationInternal):
(WebCore::MediaSource::addSourceBuffer):
* Modules/mediasource/MediaSource.h:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::changeType):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
(WebCore::SourceBuffer::validateInitializationSegment):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
* Modules/mediasource/SourceBuffer.h:
* Modules/mediasource/SourceBuffer.idl:
* page/Settings.yaml:
* platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::canSwitchToType):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):
(WebCore::SourceBufferPrivateAVFObjC::processCodedFrame):
(WebCore::SourceBufferPrivateAVFObjC::resetParserState):
(WebCore::SourceBufferPrivateAVFObjC::canSwitchToType):

Source/WebKit:

Reviewed by Eric Carlson.

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetSourceBufferChangeTypeEnabled):
(WKPreferencesGetSourceBufferChangeTypeEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:

Source/WebKitLegacy/mac:

<rdar://problem/43356021>

Reviewed by Eric Carlson.

Add a new WebPreference property mapping to the WebCore SourceBufferChangeTypeEnabled setting.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences sourceBufferChangeTypeEnabled]):
(-[WebPreferences setSourceBufferChangeTypeEnabled:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

<rdar://problem/43356021>

Reviewed by Eric Carlson.

* DumpRenderTree/mac/DumpRenderTree.mm:
(enableExperimentalFeatures):
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

Reviewed by Eric Carlson.

* platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@234940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@wolenetz
Copy link
Member Author

I've updated the codec switching explainer today to describe the API in the incubation specification that evolved from the original proposal. The explainer now also includes links to implementation status and experimental web platform test results, describes the routes chosen in the incubation spec to resolve the original proposal's open questions, and it also mentions the "implicit codec switching" scenario and the related new non-normative guidance also included in the incubation spec.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 25, 2019
…allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
aarongable pushed a commit to chromium/chromium that referenced this issue Jun 25, 2019
…allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672316}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 26, 2019
…allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672316}
Hexcles pushed a commit to web-platform-tests/wpt that referenced this issue Jul 16, 2019
…allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672316}
Hexcles pushed a commit to web-platform-tests/wpt that referenced this issue Jul 16, 2019
…allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672316}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jul 24, 2019
… relaxed type strictness and allowance for implicit changeType, a=testonly

Automatic update from web-platform-tests
MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672316}

--
Fix async tests in media-source

mediasource-util.js redefines test.done() to add a final assertion
before actually calling done(). However, the assertion was not wrapped
in test.step(), which would lead to uncaught errors.

--

wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845
wpt-pr: 17416
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Jul 25, 2019
… relaxed type strictness and allowance for implicit changeType, a=testonly

Automatic update from web-platform-tests
MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672316}

--
Fix async tests in media-source

mediasource-util.js redefines test.done() to add a final assertion
before actually calling done(). However, the assertion was not wrapped
in test.step(), which would lead to uncaught errors.

--

wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845
wpt-pr: 17416
natechapin pushed a commit to natechapin/wpt that referenced this issue Aug 23, 2019
…allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672316}
@guest271314
Copy link

Is changeType() intended to support change from "video/webm;codecs=vp8" to "video/webm;codecs=vp8,opus"?

@wolenetz
Copy link
Member Author

changeType is intended to support changing the codec or bytestream for an existing track, with some flexibility for track ID varying if there is only one track of that media type (e.g. audio or video). However, if previously, only one track type (e.g. audio-only or video-only) were buffered into a SourceBuffer, using changeType to switch that track type (audio->video or vice-versa) or to add another track of any type is not intended to be supported.

gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 4, 2019
… relaxed type strictness and allowance for implicit changeType, a=testonly

Automatic update from web-platform-tests
MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersdchromium.org>
Commit-Queue: Matthew Wolenetz <wolenetzchromium.org>
Cr-Commit-Position: refs/heads/master{#672316}

--
Fix async tests in media-source

mediasource-util.js redefines test.done() to add a final assertion
before actually calling done(). However, the assertion was not wrapped
in test.step(), which would lead to uncaught errors.

--

wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845
wpt-pr: 17416

UltraBlame original commit: 87512e5f2ef881420cf09f14c96520b4281cccb0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 4, 2019
… relaxed type strictness and allowance for implicit changeType, a=testonly

Automatic update from web-platform-tests
MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersdchromium.org>
Commit-Queue: Matthew Wolenetz <wolenetzchromium.org>
Cr-Commit-Position: refs/heads/master{#672316}

--
Fix async tests in media-source

mediasource-util.js redefines test.done() to add a final assertion
before actually calling done(). However, the assertion was not wrapped
in test.step(), which would lead to uncaught errors.

--

wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845
wpt-pr: 17416

UltraBlame original commit: 87512e5f2ef881420cf09f14c96520b4281cccb0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 4, 2019
… relaxed type strictness and allowance for implicit changeType, a=testonly

Automatic update from web-platform-tests
MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType

In preparation for Chrome's relaxation of addSourceBuffer and
changeType codec specificity within the mime type parameter, this
change adds new new tests. It also updates the Blink test expectations
for these new tests to be failures. Later changes will add Chrome's
implementation of the relaxed strictness, and will also remove the
failure expectations.

external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter:
  Tests successful addSourceBuffer, changeType, and codec switching
  without using any codecs parameter in types passed to addSourceBuffer
  and changeType for pairs of test media that are of same media class
  (audio or video) and are single track. This test is very similar to
  mediasource-changetype-play.html, just with less specific parameters
  to addSourceBuffer and changeType. This file is kept separate from
  mediasource-changetype-play.html to help identify implementations
  (like Chrome at the time of this change) that require more specific
  parameters to those methods.

external/wpt/media-source/mediasource-changetype-play-implicit.html:
  Tests successful codec switching without using changeType for test
  media of the same bytestream format, separately for audio-only and
  video-only pairs of media. Also includes a set of the same tests where
  the initial addSourceBuffer uses only the (relaxed) mime type/subtype
  without any codecs parameters, for any pairs that included codecs
  parameters in their full types.
  Note: In Chrome, only 1 pair of actually different media files is
  supported across the test media: webm vp8 and vp9. We can add more
  test media later if greater coverage is desired.

external/wpt/media-source/mediasource-changetype-play-negative.html:
  Tests of various explicit, implicit, strict and relaxed scenarios
  which should fail.

Main MSE spec issue for this:
  w3c/media-source#161
Related codec-switching MSE spec issue:
  w3c/media-source#155
These new tests exercise related scenarios to the new non-normative
  guidance in the codec-switching incubation spec branch in WICG
  (https://github.com/WICG/media-source/tree/codec-switching),
  clarifying that implementations can be relaxed in addSourceBuffer
  and changeType codec-specificity, but not isTypeSupported; apps
  should still provide as much type specifics as they can to achieve
  earlier confidence in support or lack thereof, and to avoid issues
  with implementations (like Chrome at the time of this change) that
  require more specific parameters to those methods.

BUG=535738

Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349
Reviewed-by: Dan Sanders <sandersdchromium.org>
Commit-Queue: Matthew Wolenetz <wolenetzchromium.org>
Cr-Commit-Position: refs/heads/master{#672316}

--
Fix async tests in media-source

mediasource-util.js redefines test.done() to add a final assertion
before actually calling done(). However, the assertion was not wrapped
in test.step(), which would lead to uncaught errors.

--

wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845
wpt-pr: 17416

UltraBlame original commit: 87512e5f2ef881420cf09f14c96520b4281cccb0
@gregwhitworth
Copy link

I've noticed that this has begun landing in more and more browsers and I don't see it in the Editor's draft, what is the plan for getting this into the official media-source spec?

@wolenetz
Copy link
Member Author

wolenetz commented Nov 8, 2019

#155 (comment) / @gregwhitworth that is a very timely question. I'm working on upstreaming the various incubations, including this one, from wicg to the main w3c repo. Expect progress on this very soon.

@wolenetz wolenetz removed this from the VNext milestone Jun 9, 2020
@mwatson2 mwatson2 added this to the V2 milestone Sep 21, 2020
@JohnRiv
Copy link
Member

JohnRiv commented Sep 22, 2020

We discussed this within CTA WAVE and are pleased to see it is planned for v2.

If it is possible to address @jpiesing's most recent comment, that would be beneficial.

@guest271314
Copy link

In cases where the browser is delegating media rendering to the OS+hardware, if the definitions of seamless and supported are a quality of implementation issue (without even any examples) then how can someone porting a browser to a particular OS+hardware know when to throw the NotSupportedError and when not?

For example, if the best a particular browser+OS+hardware platform could do for a transition between two particular codecs would involve pausing the media timeline for perhaps 0.5s (e.g. while a hardware decoder is re-initialised), with black video and audio silence, should this count as supported?

Yes. That should count as supported. Then changes can be made to improve support. Chromium MediaRecorder implementation from https://download-chromium.appspot.com/ does not support H264, AVC1, and does not play MP4 at HTMLMediaElement. Different browser source code builds support different codecs.

The implementation MUST disclose which codecs they intend to support is clear language to developers. isTypeSupported() facilitates a means to determine which codecs are supported before proceeding with any media playback code.

Relevant to delays between frames when switching media, the ideal is "seamless". Where evidence, for example, in a bug report at an implementation describes delay between frames, that is in fact a bug. RTCRtpSender.replaceTrack() is describes similar seamless replacing of tracks. One important aspect of switching video tracks is handling variable input width and height tracks in sequence. Using a MediaStream as source the HTMLMediaElement could resize several times before reaching encoded pixel dimensions. MediaSource at Firefox was capable of handling variable frame video input before changeType() was supported. Chromium had several bugs that crashed the browser when variable pixel dimension tracks were attempted to be rendered at HTMLMediaElement due to particular encoder used.

Implementations MUST disclose the codecs used and the specific implememtation thereof to the user, in code, if possible, so that the user knows which encoder or decoder the implementation is using, coould save dozens of bugs just to get to the source of a specific codec limitation.

@patrickkunka
Copy link

Would somebody be willing to assist me regarding the recommended approach for polyfilling this on legacy platforms that do not support changeType? Specifically with regard to a simple codec change (not container), for example - when transitioning to an ad period in a multi-period DASH stream.

I've seen reference to "resetting" the source buffer, or simply filtering out representations with a codec not matching the first played one, but I'm unsure how either of these would work in a practical sense.

Assuming we can have only one audio or video source buffer attached at a time, and the player will be appending data into the source buffer several seconds ahead of the play head, how could the source buffer be replaced or reset at the point of "new codec append" without interrupting playback?

Any advice much appreciated.

@wolenetz
Copy link
Member Author

wolenetz commented Dec 11, 2020

@#155 (comment) : The practical problem you'll probably hit due to an implementation's lack of changeType support is approaching "seamless" UX across the transition. Some approaches might be:

  1. Ensure all your content uses the same bytestream format and codec. Transmux in JS or on server-side might be necessary to keep the content in the same format. However, if you have distinct codecs in your content such that there is no one codec common to all the content needed in your presentation, then your other options might be:
  2. Consider preparing-in-advance of the transition point another media element with an attached mediasource and begin buffering into it. At the transition point, then swap media elements. Note that removing/adding a media element from a document may cause it to invoke the load algorithm (and thereby lose any prebuffered media in a previously attached MediaSource). I'm uncertain of mechanisms for showing/hiding an element in a document, but I suspect you'll need to hide it from visibility when prebuffering to it before the transition/swap point. Note that accomplishing that swap will likely not be seamless: the precise timing of the swap is lower-bounded by the scheduling/dispatch precision of the JS runtime in which your app is running, and the actual swap may have implementation constraints (maybe an implementation only supports one media element at a time, in the worst case, such that prebuffering is infeasible).
  3. Alternatively, attach a new MediaSource to the media element and begin buffering to it at the transition time. This will introduce some UX-visible latency at the transition point, because buffering hasn't begun until that time. If I understand correctly, this might be what "resetting" the SourceBuffer refers to. Alternatively to creating a new MediaSource, you could try to removeSourceBuffer() each of the old SourceBuffers at the transition time, then add new ones and buffer into them. However, support for adding new SourceBuffers after having reached 'loadedmetadata' is not required of implementations, so you might have to start from scratch with attaching a new MediaSource first. Attaching a new MediaSource is likely to be the most common denominator for supporting a sequence of presentations for which codecs differ, when changeType is not available.
  4. Probably unavailable on the implementation since it doesn't have MSE changeType() support, but consider checking if WebCodecs decoding and rendering support are available in the implementation, and if so, you might consider implementing your own player based on WebCodecs.

edited to reference the comment to which this is a response.

@patrickkunka
Copy link

@#155 (comment) thank you that's very helpful.

ryanhaddad pushed a commit to WebKit/WebKit that referenced this issue Dec 22, 2020
https://bugs.webkit.org/show_bug.cgi?id=188626
LayoutTests/imported/w3c:

Reviewed by Eric Carlson.

* resources/import-expectations.json:
* web-platform-tests/media-source/mediasource-changetype-expected.txt: Added.
* web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added.
* web-platform-tests/media-source/mediasource-changetype-play.html: Added.
* web-platform-tests/media-source/mediasource-changetype-util.js: Added.
(findSupportedChangeTypeTestTypes):
(appendBuffer):
(trimBuffered):
(trimDuration):
(runChangeTypeTest):
(mediaSourceChangeTypeTest):
* web-platform-tests/media-source/mediasource-changetype.html: Added.
* web-platform-tests/media-source/mp3/sound_5.mp3: Added.
* web-platform-tests/media-source/mp3/w3c-import.log: Added.
* web-platform-tests/media-source/w3c-import.log:
* web-platform-tests/media-source/webm/test-vp9.webm: Added.
* web-platform-tests/media-source/webm/w3c-import.log:

Source/WebCore:

Reviewed by Eric Carlson.

Tests: imported/w3c/web-platform-tests/media-source/mediasource-changetype-play.html
       imported/w3c/web-platform-tests/media-source/mediasource-changetype.html

The WICG is incubating a new proposal to allow clients to switch between streams
with different codecs within the same SourceBuffer. The proposal is being tracked
by <w3c/media-source#155> and the proposed spec change
is available at <https://rawgit.com/wicg/media-source/codec-switching/index.html>.

Drive-by fix: One of the wpt tests uses a .mp3 file to test SourceBuffer switching.
The AVStreamDataParser does not necessarily emit every frame appended, and after a
new init segment is appended, it's possible that frames from the previous media
segment will be emitted. This causes an error condition to occur, due to an added
check in the spec for a new flag. When the SourceBuffer asks its private implementation
to reset the parser state, since there's no API on AVStreamDataParser to actually
reset the parser state, just set a flag to drop all emitted buffers until the next
initialization segment is parsed.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::contentTypeShouldGenerateTimestamps):
(WebCore::MediaSource::setDurationInternal):
(WebCore::MediaSource::addSourceBuffer):
* Modules/mediasource/MediaSource.h:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::changeType):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
(WebCore::SourceBuffer::validateInitializationSegment):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
* Modules/mediasource/SourceBuffer.h:
* Modules/mediasource/SourceBuffer.idl:
* page/Settings.yaml:
* platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::canSwitchToType):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):
(WebCore::SourceBufferPrivateAVFObjC::processCodedFrame):
(WebCore::SourceBufferPrivateAVFObjC::resetParserState):
(WebCore::SourceBufferPrivateAVFObjC::canSwitchToType):

Source/WebKit:

Reviewed by Eric Carlson.

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetSourceBufferChangeTypeEnabled):
(WKPreferencesGetSourceBufferChangeTypeEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:

Source/WebKitLegacy/mac:

<rdar://problem/43356021>

Reviewed by Eric Carlson.

Add a new WebPreference property mapping to the WebCore SourceBufferChangeTypeEnabled setting.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences sourceBufferChangeTypeEnabled]):
(-[WebPreferences setSourceBufferChangeTypeEnabled:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

<rdar://problem/43356021>

Reviewed by Eric Carlson.

* DumpRenderTree/mac/DumpRenderTree.mm:
(enableExperimentalFeatures):
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

Reviewed by Eric Carlson.

* platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added.

Canonical link: https://commits.webkit.org/203720@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@wolenetz
Copy link
Member Author

#274 merged the WICG-incubated specification for this feature into MSEv2 main spec (editor's draft).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests