Commit Graph

121 Commits

Author SHA1 Message Date
Matthias 369916489e feat: Add config to allow reset MSE on cross boundary (#8156)
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](https://github.com/Dash-Industry-Forum/dash.js/blob/a656ec709e7f92f76b392bf196ee9883da7928ce/src/streaming/controllers/StreamController.js#L672),
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.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2025-03-07 10:45:31 +01:00
Álvaro Velad Galván 5debddcf4d chore: Add encrypted flag to init segments (#8182) 2025-02-27 14:10:32 +01:00
David Pfister b26dd1f777 fix: Fit template check template info (#8162)
`TimelineSegmentIndex` `fitTimeline` doesn't check if `templateInfo` is
null. This means it errors in this case when it tries to access the
`timeline` property. It now exits early if it's null
2025-02-26 08:05:29 +01:00
Álvaro Velad Galván 66ca230238 fix(DASH): Fix DASH_DUPLICATE_REPRESENTATION_ID error when using supplemental codec (#7961)
Fixes https://github.com/shaka-project/shaka-player/issues/7948
2025-01-28 10:44:17 +01:00
Wojciech Tyczyński 97832b7c45 chore: Stop using "Object" in DASH (#7947)
Related to #1672
2025-01-24 16:38:03 +01:00
Álvaro Velad Galván a89ee1a560 fix(DASH): Notify time range with the fitted timeline (#7911) 2025-01-21 10:12:18 +01:00
Álvaro Velad Galván c7a93d7c6c fix(DASH): Ignore early segments in a period (#7910)
Now we always are fitting the timeline
2025-01-20 12:42:19 +01:00
Wojciech Tyczyński 6e55a3b21b build: Forbid using dot in generic types (#7904)
Fixes #2643

Happy reviewing!
2025-01-20 09:39:51 +01:00
Wojciech Tyczyński 82f7eafdc5 build: Add new JSDoc rules to ESLint (#7897)
Adds a replacement for removed JSDoc checks from ESLint v9.
Additionally fixes lots of issues found in the JSDoc, such as:
- missing `@param`/`@return` annotations
- bad formatting
- params order
- param name in the same line as type definition (tried to disable it,
but it was causing other issues and we didn't have lots of places with
such formatting)

Minor fixes in code found by Closure Compiler after fixing JSDoc are
also included.
2025-01-17 09:28:19 +01:00
Joey Parrish abd6d8b34c fix(dash): Fix $Time$ usage with SegmentTemplate (#7849)
`$Time$` in SegmentTemplate should not be adjusted for
presentationTimeOffset or Period start. It should always match the
segment's own media timestamp as it appears in the manifest.
2025-01-08 11:23:40 -08:00
Wojciech Tyczyński 51765e9693 build: Change spellchecking tool and fix spelling mistakes (#7765)
Fixes #7693
2024-12-20 12:27:05 +01:00
has992 3f9dec2342 fix(DASH): Exclude text segments when calculating max segment size (#7564)
This PR excludes the use of text segments when calculating the max
segment size.
This is due to Shaka using the max value between the buffer behind and
max segment size.
The max segment size of text segments can be a lot larger than video
segments.
This can cause the buffer behind to be extremely large and is a
particular problem for low
powered devices, which have memory constraints.

---------

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2024-11-12 09:43:28 +01:00
Álvaro Velad Galván 0ff61a52b7 fix: Fix support of getAllThumbnails when using shaka.dash.TimelineSegmentIndex (#7508) 2024-10-25 08:38:29 -07:00
Iragne 051a8c5edd fix(DASH): Live DASH allows segment overlap in the updated manifest for first new segments (#7405)
fix(DASH): Live DASH allows segment overlap in the updated manifest for
first new segments to avoid creating GAP with ms inaccurate manifest vs
Segment duration and start time

Fixes https://github.com/shaka-project/shaka-player/issues/7397
2024-10-15 12:49:17 +02:00
Álvaro Velad Galván e7229fbc18 fix(DASH): Allow mixing SegmentTemplate-SegmentTimeline with SegmentTemplate-numbering (#7286)
Fixes https://github.com/shaka-project/shaka-player/issues/7192
2024-09-12 09:45:29 +02:00
Álvaro Velad Galván a1d3927640 fix(DASH): Fix allPartialSegments signal when using L3D (#7179) 2024-08-20 11:54:01 +02:00
theodab b4e04b6616 feat: Store bandwidth info inside references. (#6825)
Issue #6725

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2024-07-23 14:32:09 +02:00
Álvaro Velad Galván a5adb39713 feat(DASH): Support Annex I: Flexible Insertion of URL Parameters (#7086)
Resolves https://github.com/shaka-project/shaka-player/issues/6472
2024-07-23 08:49:22 +02:00
Álvaro Velad Galván d1435c7459 fix(DASH): Improve memory usage with live streams (#7039)
Related to https://github.com/shaka-project/shaka-player/issues/6610
2024-07-15 14:46:39 +02:00
Álvaro Velad Galván 3cb40bf516 feat(DASH): Add support for urn:mpeg:dash:ssr:2023 with SegmentTemplate $Number$ (#6745) 2024-07-09 09:27:51 +02:00
Álvaro Velad Galván c574be4377 fix(DASH): Fix update of SegmentTemplate with $number$ for LL (#6687) 2024-05-29 09:27:23 +02:00
Dave Nicholas d38aabf04d feat(DASH): Add MPD Patch support (#5247)
Closes https://github.com/shaka-project/shaka-player/issues/2228

---------

Co-authored-by: Wojciech Tyczyński <wojciech.tyczynski@sky.uk>
2024-05-29 08:11:28 +02:00
Álvaro Velad Galván 6c47f8be65 fix(DASH): Fix get partial current position for LL when using SegmentTemplate@duration (#6516) 2024-05-01 00:09:17 +02:00
Cristian Atehortúa 2dd85e4e23 fix(DASH): decrease memory preasure on manifest with SegmentReference by updating old initSegmentReference (#6499)
Helps on #6070
2024-04-29 11:54:14 -07:00
theodab 1da5da9790 fix(DASH): Fix support for multi-mimeType variants (#6348)
A previous PR, #5950, added support for variants that contain multiple
different codecs.
It was supposed to also add support for variants with multiple
mimeTypes, but that part didn't work correctly. This reworks a lot of
#5950 and #6047, to change how they handle such complicated variants.

This has the side-effect of allowing the stream utils to differentiate
between content that has multiple codecs because of type changes, and
content that has multiple codecs because of being muxed video+audio.

Fixes #6010

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2024-04-10 02:48:57 -07:00
Álvaro Velad Galván 07a32419d3 feat(DASH): Add signalling the last segment number in Period (#6416)
Closes https://github.com/shaka-project/shaka-player/issues/2430

Test stream:
http://dash.akamaized.net/dash264/TestCasesIOP41/LastSegmentNumber/1/manifest_last_segment_num.mpd
2024-04-09 09:35:53 +02:00
Dave Nicholas 67cd2dd29d fix(tXml): html unescape node attributes with urls (#6267)
To provide feature parity with the `DOMParser.getAttribute` API which
would unescape html entities for free this PR unescapes url strings
which come from node attributes.

In a similar vain to
https://github.com/shaka-project/shaka-player/pull/6198 which unescapes
child strings.
2024-02-23 08:55:07 -08:00
Wojciech Tyczyński 4a0d1ca06f fix(DASH): Fix precision issue on some platforms (#6258)
When recalculations of period end are made, it is possible that we will not be able to find last segment from period on low precision platforms. To mitigate it, try to use cached value of `periodEnd_` whenever possible.

Issue observed on Xbox One & Xbox Series.
2024-02-20 10:23:06 -08:00
Dave Nicholas 7116a34ec2 feat!: Remove DOM Parser (#6063)
## Background: 
The native DOM Parser can perform poorly on some older devices, this
approach is faster on newer devices but is considerably better on older
devices.
This PR replaces the usage of the DOM Parser for DASH, MSS, VTT and
TTML.

The draw back of this approach that it does not include any validation
at the cost of better performance.
2024-01-22 08:39:06 +01:00
Álvaro Velad Galván 31c06ca189 feat: Rename aes128Key to aesKey to allow aes256 in the future (#5990)
See:
https://mailarchive.ietf.org/arch/msg/hls-interest/RZBgatOvI4W0M0J5cShuXWzdigg/
2023-12-05 11:57:14 +01:00
Álvaro Velad Galván 30de1771cf fix(DASH): SegmentTemplate@media not updated after change in manifest (#5899)
Fixes https://github.com/shaka-project/shaka-player/issues/5898
2023-11-16 19:21:27 +01:00
Dave Nicholas d8aa24f41d fix(DASH): Segments being fetched out of the range of the timeline (#5889)
Fixes: https://github.com/shaka-project/shaka-player/issues/3952
2023-11-16 09:48:12 +01:00
Álvaro Velad Galván 5f891d98d6 fix(DASH): Fix bad url when specify MPD BaseURL and AdaptationSet BaseURL (#5883)
Fixes https://github.com/shaka-project/shaka-player/issues/5882
2023-11-14 16:00:20 +01:00
Álvaro Velad Galván 508e5cfbba feat(DASH): Add initial support for "urn:mpeg:dash:ssr:2023" (#5762) 2023-11-03 14:57:15 +01:00
Albin Larsson 8d2b6574de fix(dash): fix race condition in segment template (#5842)
Fixes https://github.com/shaka-project/shaka-player/issues/5760
2023-11-02 09:23:01 +01:00
Álvaro Velad Galván 5e9245a384 chore(DASH): Update DASH URL management to allow Content Steering in the future (#5739) 2023-10-09 09:40:42 +02:00
Álvaro Velad Galván 45009d2c0c fix(DASH): Fix bigint implementation (#5707) 2023-10-02 23:17:52 +02:00
Álvaro Velad Galván 96ae7f2fe6 feat(DASH): Add support for AES-128 (#5656)
Closes https://github.com/shaka-project/shaka-player/issues/5622
2023-09-16 07:34:42 +02:00
Álvaro Velad Galván 4a1c96e630 feat(DASH): Allow the playback of DASH with $time$ and large timescale value (#5621)
Closes https://github.com/shaka-project/shaka-player/issues/4337

Only supported on browsers with support to BigInt
2023-09-12 20:57:33 +02:00
Álvaro Velad Galván 29d9a10705 fix(DASH): Fix race condition error while switching audio tracks (#5619)
Fixes https://github.com/shaka-project/shaka-player/issues/5614
2023-09-08 22:34:53 +02:00
Joey Parrish d4dca2a571 chore: Fix core build without dash (#5289)
- Move TimeRange from shaka.dash.MpdUtils to
shaka.media.PresentationTimeline
- Move AccessibilityPurpose from shaka.dash.DashParser to
shaka.media.ManifestParser

With these changes, core Shaka Player can be built without the dash
module.
2023-06-13 12:23:55 +02:00
Wojciech Tyczyński 2d9f56627a fix(DASH): Fix bufferBehind with image tracks regression (#5210)
A recent change to allow for on-demand segment references (#5061) ended up causing a
regression with an older issue (#4717), where the presence of an image track overrides
`bufferBehind` behavior.
This fixes the segment template handler to properly account for image tracks, once again.
2023-05-04 14:47:44 -07:00
Nick Crast f1c5a1c191 feat(dash): Improve DASH SegmentTemplate performance with on-demand segment references (#5061)
This is a performance optimization intended to reduce the Video Start
Time for DASH streams, both VOD and Live, by reducing the amount of
processing done during manifest parse time. This is especially effective
for long multi-period assets, assets with many variants, or on low end
devices in general. I've provided some measurements showing the
performance improvements at the conclusion of this PR.

Currently, during manifest parse time for a Segment Template, Shaka will
loop through the entire timeline and create segment references for each
timeline entry. For a long asset, or an asset with many tracks, this is
a significant amount of processing.

I've created a new entity called the Timeline Segment Index that extends
the SegmentIndex interface. The purpose of the Timeline Segment Index is
to ingest a timeline during construction, and then use that information
to build Segment References only on demand. This removes the need to
parse the entire timeline and create all of the Segment References
during parse time.

The effects of this change aren't quite as apparent on desktop web
browsers, given their speed and power. This improvement really shines on
lower end TVs on assets with a long timeline.

DASH parsing speed-ups in some cases can be as much as 40%.

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2023-04-28 17:20:33 -07:00
theodab fbce38af1c feat(net): Added advanced type to filters (#5006)
This adds an optional parameter to request and response filters, of a
new enum called AdvancedRequestType.
This enum describes request types that are subtypes of the basic types.
For example, INIT_SEGMENT is a type of SEGMENT.
This gives users more information about the type of the request, while
maintaining backwards compatibility.

Closes #4966
2023-02-23 11:56:23 -08:00
Álvaro Velad Galván 056588b2e1 fix(DASH): Fix dynamic manifests from edgeware (#4914)
Fixes https://github.com/shaka-project/shaka-player/issues/4913

---------

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
Co-authored-by: Joey Parrish <joeyparrish@google.com>
2023-01-30 18:22:05 +01:00
Casey Occhialini cd1b7c0942 fix: Fix bufferBehind setting broken by image segments (#4718)
Resolves #4717
2022-11-17 09:17:34 -08:00
Álvaro Velad Galván 298b60481d fix(dash): Fix performance regression (#4064)
See: https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1077826210
2022-03-25 13:56:38 -07:00
Aidan Ridley bd7b384c66 feat: Add media quality change events (#3700)
Closes ##3431
2021-11-12 15:07:18 -08:00
Theodore Abshire b8b72a900d fix(dash): Notify segments on all updates.
Before, when using SegmentTemplate or SegmentList, we would tell
the presentation timeline about new segments only when we saw a
new period or representation. This meant that, in live streams,
if new content was being added to the SegmentTemplate or SegmentList,
the presentation timeline was not being kept abreast of the changes.
Thus, if that stream were to then transition to VOD, the presentation
timeline would suddenly start to report that the current time was
beyond the end of the seek range, which caused playback to stop.

Closes #3675

Change-Id: I77ef00c5a86de9ebcb86f18f792084ed70f94e8d
2021-10-28 00:44:18 -07:00
Michelle Zhuo fce5935800 refactor(dash): Use map of streams for Dash Parser
This is a step prior to the closeSegmentIndex implementation.
In the DashParser, use a map of context id to stream instead of
context id to segment index when parsing SegmentList.

For Dash live content, every time we parse a manifest update, we
create a new Stream object, leaving the old stream with its old
segment index.
If we close the segment index and create it later again, we need
update the stream's segment index.

Change-Id: I7a3af3666ddb4e26362c40eeb82c3d050fafe3ee
2021-09-10 13:43:19 -07:00