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

fix: Fix legacy codec support by rewriting codec metadata #4858

Merged
merged 2 commits into from
Jan 5, 2023

Conversation

cuyl
Copy link
Contributor

@cuyl cuyl commented Dec 29, 2022

This fixes legacy codec support by rewriting the codec metadata in the Stream objects. After capability checking, the converted codec information will be used.

@cuyl
Copy link
Contributor Author

cuyl commented Dec 29, 2022

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2022

Incremental code coverage: 83.33%

@cuyl cuyl force-pushed the legacy-avc1-with-audio branch from e91a141 to 81e7274 Compare January 2, 2023 16:38
@avelad avelad added type: bug Something isn't working correctly priority: P1 Big impact or workaround impractical; resolve before feature release component: HLS The issue involves Apple's HLS manifest format labels Jan 3, 2023
@avelad avelad added this to the v4.4 milestone Jan 3, 2023
@avelad avelad requested review from theodab and joeyparrish January 3, 2023 06:43
@joeyparrish
Copy link
Member

I'm going to need more information to review this. Is there an associated issue filed? Why is this more correct than what we did before?

@cuyl
Copy link
Contributor Author

cuyl commented Jan 5, 2023

@joeyparrish It's because other code will use the codecs from streams.codecs to call shaka.media.Capabilities.isTypeSupporte which can cause error.
ref lines: 361, 368

async init(streamsByType, sequenceMode=false) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;
await this.mediaSourceOpen_;
this.sequenceMode_ = sequenceMode;
for (const contentType of streamsByType.keys()) {
const stream = streamsByType.get(contentType);
goog.asserts.assert(
shaka.media.MediaSourceEngine.isStreamSupported(stream),
'Type negotiation should happen before MediaSourceEngine.init!');
let mimeType = shaka.util.MimeUtils.getFullType(
stream.mimeType, stream.codecs);
if (contentType == ContentType.TEXT) {
this.reinitText(mimeType, sequenceMode);
} else {
const forceTransmux = this.config_.forceTransmux;
if ((forceTransmux ||
!shaka.media.Capabilities.isTypeSupported(mimeType)) &&
shaka.media.Transmuxer.isSupported(mimeType, contentType)) {
this.transmuxers_[contentType] =
new shaka.media.Transmuxer(mimeType);
mimeType =
shaka.media.Transmuxer.convertCodecs(contentType, mimeType);
}
const type = mimeType + this.config_.sourceBufferExtraFeatures;
const sourceBuffer = this.mediaSource_.addSourceBuffer(type);

@cuyl
Copy link
Contributor Author

cuyl commented Jan 5, 2023

@cuyl
Copy link
Contributor Author

cuyl commented Jan 5, 2023

So basically, I just store the converted correct formatted codecs for further use.

@joeyparrish
Copy link
Member

Thanks. As a tip for next time, that all would have been useful information to include in code comments or the PR description.

@joeyparrish joeyparrish changed the title fix: Fix support legacy AVC1 codec with audio fix: Fix legacy codec support by rewriting codec metadata Jan 5, 2023
@joeyparrish
Copy link
Member

Based on your explanation, I took the liberty of writing a PR description (now for the commit log, but would have been helpful for reviewers), as well as code comments (which will be helpful for future readers of that code to avoid "cleaning up" and reverting your change).

Even better would have been to add a regression test, in case this logic is some day replaced in rewrite without preserving all the details.

@cuyl
Copy link
Contributor Author

cuyl commented Jan 5, 2023

@joeyparrish Thanks, Sorry for the inconvenience .

@joeyparrish
Copy link
Member

I'll merge this once the test pass is complete. (Or the other maintainers can do it if I'm too slow.)

@joeyparrish
Copy link
Member

@joeyparrish Thanks, Sorry for the inconvenience .

No problem. I hope the explanations are helpful, and that you'll continue to contribute to Shaka Player. We appreciate your contribution!

@joeyparrish joeyparrish merged commit e351395 into shaka-project:main Jan 5, 2023
@cuyl cuyl deleted the legacy-avc1-with-audio branch January 6, 2023 08:50
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This fixes legacy codec support by rewriting the codec metadata in the
Stream objects. After capability checking, the converted codec
information will be used.

Co-authored-by: Joey Parrish <[email protected]>
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This fixes legacy codec support by rewriting the codec metadata in the
Stream objects. After capability checking, the converted codec
information will be used.

Co-authored-by: Joey Parrish <[email protected]>
@joeyparrish
Copy link
Member

We have a failing test case on Tizen since this was merged:

https://github.com/shaka-project/shaka-player/actions/runs/3854362680/jobs/6568932949

joeyparrish added a commit to joeyparrish/shaka-player that referenced this pull request Jan 13, 2023
This test started failing on Tizen after PR shaka-project#4858.
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This test started failing on Tizen after PR #4858, which updates codecs
in manifest metadata any time they are rewritten. Since ac-3 is
rewritten as ec-3 on Tizen, that caused this test case covering ac-3 to
start failing (because the codec says ec-3 by the end of the test).
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This test started failing on Tizen after PR #4858, which updates codecs
in manifest metadata any time they are rewritten. Since ac-3 is
rewritten as ec-3 on Tizen, that caused this test case covering ac-3 to
start failing (because the codec says ec-3 by the end of the test).
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This test started failing on Tizen after PR #4858, which updates codecs
in manifest metadata any time they are rewritten. Since ac-3 is
rewritten as ec-3 on Tizen, that caused this test case covering ac-3 to
start failing (because the codec says ec-3 by the end of the test).
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This fixes legacy codec support by rewriting the codec metadata in the
Stream objects. After capability checking, the converted codec
information will be used.

Co-authored-by: Joey Parrish <[email protected]>
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This test started failing on Tizen after PR #4858, which updates codecs
in manifest metadata any time they are rewritten. Since ac-3 is
rewritten as ec-3 on Tizen, that caused this test case covering ac-3 to
start failing (because the codec says ec-3 by the end of the test).
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This fixes legacy codec support by rewriting the codec metadata in the
Stream objects. After capability checking, the converted codec
information will be used.

Co-authored-by: Joey Parrish <[email protected]>
joeyparrish added a commit that referenced this pull request Jan 13, 2023
This test started failing on Tizen after PR #4858, which updates codecs
in manifest metadata any time they are rewritten. Since ac-3 is
rewritten as ec-3 on Tizen, that caused this test case covering ac-3 to
start failing (because the codec says ec-3 by the end of the test).
Robloche pushed a commit to Robloche/shaka-player that referenced this pull request Feb 8, 2023
…ect#4858)

This fixes legacy codec support by rewriting the codec metadata in the
Stream objects. After capability checking, the converted codec
information will be used.

Co-authored-by: Joey Parrish <[email protected]>
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: HLS The issue involves Apple's HLS manifest format priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants