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

feat: Add config to allow reset MSE on cross boundary #8156

Merged
merged 58 commits into from
Mar 7, 2025

Conversation

matvp91
Copy link
Contributor

@matvp91 matvp91 commented Feb 25, 2025

There's devices out there that are not compliant with the MSE spec. Such as halting MSE when a secondary init segment is appended (webOS 3), or failing to transition from a plain to encrypted init segment (Tizen 2017). While we initially prefer content workarounds, it's a time consuming and trial & error process. For some devices it might not be worth investing time into finding a proper workaround due to low usage. We're giving people an alternative by resetting MSE when needed (configurable). dash.js offers somewhat similar behavior here, where MSE is reset before applying an encrypted init segment.

This PR introduces crossBoundaryStrategy in StreamingConfiguration. It can be configured as following:

  • KEEP - we're keeping MSE active, this is the default and the current behavior.
  • RESET - we'll always reset MSE when it crosses a boundary.
  • RESET_TO_ENCRYPTED - we reset MSE when it crosses an encrypted boundary, and we keep MSE afterwards. Additionally, we're not going to reset when we're crossing a plain to plain boundary.

Each initSegmentReference now holds an encrypted and boundaryEnd value. When configured with a different value than KEEP, StreamingEngine will be instructed to fetch and append segment references up until the boundary of the currently applied init segment.

We detect whether we're at a boundary in a few ways:

  • Listening to the HTML5 MediaElement's waiting event, this'll indicate that we do not have enough buffer to advance. If we're pretty close to the boundary, we assume we're at the boundary.
  • Due to subtle differences in the segment alignments, waiting wasn't reliable. When close to a boundary, a timer is fired with the assumption that "we'll reach the boundary at soon". I've set the threshold to 1 second, when playhead is further than the threshold, we'll skip checking whether an MSE reset is due.

The implementation relies on the added properties in the init segment reference, and the concept of a "Period" is avoided in StreamingEngine to ensure it's compatible with HLS too.

@avelad avelad marked this pull request as draft February 25, 2025 08:55
@avelad avelad changed the title Reset MSE on period switch fix: Reset MSE on period switch Feb 25, 2025
@avelad avelad changed the title fix: Reset MSE on period switch fix: Reset MSE on period switch or discontinuity Feb 25, 2025
@shaka-bot
Copy link
Collaborator

shaka-bot commented Feb 25, 2025

Incremental code coverage: 96.02%

@matvp91 matvp91 changed the title feat: Reset MSE on period switch or discontinuity feat: Reset MSE on period switch Mar 4, 2025
@avelad avelad changed the title feat: Reset MSE on period switch feat: Add config to allow reset MSE on cross boundary Mar 4, 2025
@avelad avelad requested a review from tykus160 March 4, 2025 13:29
@avelad avelad added type: enhancement New feature or request priority: P3 Useful but not urgent labels Mar 5, 2025
@avelad avelad added this to the v4.14 milestone Mar 5, 2025
@avelad
Copy link
Member

avelad commented Mar 5, 2025

@shaka-bot test

@shaka-bot
Copy link
Collaborator

@avelad: Lab tests started with arguments:

  • pr=8156

Co-authored-by: Wojciech Tyczyński <[email protected]>
@avelad avelad requested a review from tykus160 March 5, 2025 11:26
@avelad
Copy link
Member

avelad commented Mar 7, 2025

@shaka-bot test

@shaka-bot
Copy link
Collaborator

@avelad: Lab tests started with arguments:

  • pr=8156

@avelad
Copy link
Member

avelad commented Mar 7, 2025

@shaka-bot test

@shaka-bot
Copy link
Collaborator

@avelad: Lab tests started with arguments:

  • pr=8156

@avelad avelad merged commit 3699164 into shaka-project:main Mar 7, 2025
59 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: P3 Useful but not urgent type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants