Commit Graph

612 Commits

Author SHA1 Message Date
Ivan 3a5d588dbd perf(DASH): drop array operations on unique IDs when parsing periods (#9870)
Two targeted performance improvements in aimed at reducing overhead on
older devices

1. Avoid intermediate array for representation ID uniqueness check

Previously, all representation IDs were pushed into a temporary ids[]
array, then a Set - this PR eliminates the array allocation entirely.

2. Re-parse only affected AdaptationSets for dependency streams

Previously, when any stream had a dependency stream, every AdaptationSet
was re-parsed from XML. Now, only the specific AdaptationSet nodes that
contain streams with dependencies are re-parsed. This avoids redundant
XML traversal and parsing for the common case where most adaptation sets
have no dependency streams.
2026-03-23 10:09:42 +01:00
Ivan c9f8057f9a perf(DASH): loop over adaptation sets using the partition method (#9862) 2026-03-20 15:45:57 +01:00
Álvaro Velad Galván 72a8e942b5 fix(LCEVC): Fix live support when using DASH dual track (#9841) 2026-03-19 11:54:29 +01:00
Álvaro Velad Galván b9abb399bb fix(LCEVC): Fix multi-period VOD support (#9837)
A new integration test has been added.
The use of `stream` within `stream` in `periods.js` has been refactored
to simplify management and avoid duplicates.

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2026-03-19 10:07:14 +01:00
Gábor Balogh 1c83a69481 perf(DASH): Add period caching to speed up manifest parsing (#9353)
Adds period caching to speed up manifest parsing. The aim of this
feature is to improve parsing of length multi-period DASH manifests on
low power devices.
2026-03-11 10:03:10 +01:00
Álvaro Velad Galván c92c3bddba feat(DASH): Add json format support (#9788)
This initial support is complete but not efficient, as it involves
conversion to XML and normal processing. It should only be used for
testing purposes. Improved support will be added in the future.

Tested with https://github.com/Dash-Industry-Forum/dash-json-schema

Note: This is only added to the experimental build.
2026-03-09 09:52:06 +01:00
Álvaro Velad Galván 90f59213bb fix: Honors streaming.retryParameters for segments (#9796)
Fixes https://github.com/shaka-project/shaka-player/issues/9787
2026-03-06 20:23:25 +01:00
Álvaro Velad Galván e3781c493b feat(DASH): Enable automatic XLink processing with fast detection and performance improvements (#9764)
This PR modernizes and optimizes XLink handling in the DASH parser by
removing the legacy flag-based behavior and replacing it with a
standards‑aligned, fast, and deterministic workflow. The changes improve
performance on large MPDs, simplify configuration, and ensure correct
XLink expansion according to DASH/XLink rules.

XLink processing is now automatically enabled only when needed. If the
MPD contains no XLinks, the parser skips processXlinks entirely.
2026-02-26 14:05:32 +01:00
Álvaro Velad Galván 4082ed75ee feat(DASH): Add support for SegmentTimeline@Pattern (#9669)
Close https://github.com/shaka-project/shaka-player/issues/9659
2026-02-06 07:31:49 +01:00
Andy(김규회) 05b09728c7 perf: Use Map.getOrInsert/getOrInsertComputed native methods (#9546)
Added polyfills for `Map.getOrInsert()` and
`Map.getOrInsertComputed()` from the TC39 upsert proposal and refactor
the codebase to use them.
These methods replace the common "check if key exists, then set default"
pattern with a single atomic operation. This improves code readability
and eliminates redundant map lookups throughout the player.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2026-01-13 10:57:25 +01:00
Chad Michael 42df30a84e fix(DASH): Handle external SegmentBase BaseURL and SIDX offset fallback (#9477)
This pull request improves support for external SIDX (Segment Index)
files in DASH manifests, particularly when the `RepresentationIndex`
uses a different `BaseURL` or `sourceURL` than the media itself. It also
enhances base64 decoding robustness and adds a new unit test to verify
correct behavior.

**DASH SIDX and Segment Reference Handling:**

* Enhanced `Mp4SegmentIndexParser.parse` to accept an `indexIsExternal`
parameter, enabling correct parsing of SIDX files that are external to
the media and may have different base URIs. The parser now adjusts the
offset logic for external indices.
[[1]](diffhunk://#diff-6435d27cfd56024b0920175aa9a6992242d18900d27f7edfaa77d89673a8dd0aR29-R37)
[[2]](diffhunk://#diff-6435d27cfd56024b0920175aa9a6992242d18900d27f7edfaa77d89673a8dd0aR54-L63)
* Addresses #6091: Updated `SegmentBase.generateSegmentIndexFromUris` to
detect when the index URI is external by comparing the base URIs, and to
pass this information to the parser. This ensures that segment
references are resolved against the correct URIs.

**Robustness Improvements:**

* Improved base64 decoding in `Uint8ArrayUtils.fromBase64` by
normalizing padding, handling cases where the input string omits
trailing `=` characters.

**Testing Enhancements:**

* Added a unit test to verify that `RepresentationIndex` with a
different `BaseURL` or `sourceURL` is correctly honored, ensuring that
segment index requests use the proper URI and range.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-12-12 10:25:08 +01:00
Matthias Van Parijs 0bc7a96b33 fix(DASH): Shift segment timeline with cached presentationTimeOffset (#9481)
Fixes https://github.com/shaka-project/shaka-player/issues/9480.

A change in PTO when updating periods & segment timelines should be
avoided by whatever produces the manifest. This is merely a mitigation.
When detected, it'll log an error to warn the user about the timeline
shift.
2025-12-09 12:30:40 +01:00
Gábor Balogh 219c733015 fix(DASH): Memory leak on DASH streams (#9369)
Fixes https://github.com/shaka-project/shaka-player/issues/9368
2025-11-21 09:55:00 +01:00
Álvaro Velad Galván 5d59f68a84 chore: Extract PlayReady licenseServerUri from PSSH in shaka.media.SegmentUtils.BasicInfo (#9404)
Related to https://github.com/shaka-project/shaka-player/pull/9402
2025-11-19 12:14:45 +01:00
Álvaro Velad Galván c920ecd4fa chore: Move createSegmentRequest to shaka.net.NetworkingUtils (#9363) 2025-11-05 21:05:49 +01:00
Álvaro Velad Galván 7ccb20a641 feat(HLS): Add support for com.apple.hls.chapters (#9195)
Spec:
https://developer.apple.com/documentation/http-live-streaming/providing-javascript-object-notation-json-chapters

Add disableChapters config
Update the UI to show chapters if there is only one language Add support
to download chapters

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2025-10-14 15:20:51 +02:00
Álvaro Velad Galván 0ecc68c8ad feat(DASH): Add programinformation event (#9202) 2025-10-14 13:16:23 +02:00
Álvaro Velad Galván 945c57ab77 feat!: Remove all deprecated things (#9162) 2025-10-07 10:52:13 +02:00
Gary Katsevman 729cea8fc4 feat: Change dvvC box to free box for Dolby Vision workarounds (#9101)
This is based on
https://professionalsupport.dolby.com/s/article/Guidelines-to-developers-building-DASH-HLS-player-apps-for-LG-WebOS-Chromecast-and-other-Chromium-based-app-development-platforms?language=en_US
2025-09-17 10:21:12 +02:00
Wojciech Tyczyński a054b7e6ad perf(DASH): Do not store duplicated pssh data buffers (#9006)
Use PSSH string to cache init data in order to avoid creating duplicated
init data buffers. On streams with many periods due to ad insertion it
can make a difference - i.e. on stream with 50 periods this change
reduces used memory by init data buffers from 40 KB to 1 KB.

In DASH, PSSH can often be a duplicated data between protected periods
and/or adaptation sets.
2025-08-21 11:06:40 +02:00
Álvaro Velad Galván ca01e1c228 chore: Fix some extends definitions (#8941) 2025-07-30 17:05:38 +02:00
Álvaro Velad Galván e8ccbeeedd fix(DASH): Update SegmentSequenceProperties according to latest spec (#8909)
Update according to
https://github.com/MPEGGroup/DASHSchema/pull/150/files
2025-07-26 21:45:23 +02:00
Wojciech Tyczyński ca63ed07a2 chore(DASH): Add comments to latest DashParser changes (#8888)
Follow up to #8884 based on comment
https://github.com/shaka-project/shaka-player/pull/8884#discussion_r2213944738
2025-07-18 12:21:51 +02:00
Wojciech Tyczyński 27163ff82c fix(DASH): Prevent memory leak in uncompiled mode (#8884)
Keeping `this` references in DASH uri callbacks leads to keeping
DashParser instances in memory after unloading.
Luckily this is only the issue in uncompiled mode, Closure Compiler
handles it somehow. It is though better to fix it in case we change
tooling some day.
2025-07-17 13:46:14 +02:00
Álvaro Velad Galván 1f115d3846 fix(DASH): Fix segmentSequenceCadence default value (#8877)
According to the latest draft of DASH 6th edition, the default value is
1, not 0.
2025-07-16 10:23:23 +02:00
Álvaro Velad Galván bf26c3fb4b feat(DASH): Remove multiTypeVariantsAllowed config and add support for it on all browsers (#8858) 2025-07-15 09:26:04 +02:00
Matthias ff34d1cd29 fix(DASH): Update timeline on PTO change (#8869)
Fixes https://github.com/shaka-project/shaka-player/issues/8351.

When we detect a change in `unscaledPresentationTimeOffset`, we'll
update the timeline along with both the scaled and unscaled
presentationTimeOffset.

For reference, updating `templateInfo_` introduced a memory leak a while
back (https://github.com/shaka-project/shaka-player/issues/6610), I ran
this change for 2 hours straight and memory was kept in check.
2025-07-14 16:31:56 +02:00
Laura Harker 4ef5e33697 refactor: fix upcoming Closure Compiler type errors on Symbol.iterator (#8851)
Closure Compiler will soon start typechecking well-known symbol
properties, such as Symbol.iterator - see
https://github.com/google/closure-compiler/issues/1737.

This will cause some type errors in existing code that implements
`Iterable` (for context, I ran into these errors in google's internal
repo) that is missing a Symbol.iterator override or `@override`
annotation
2025-07-10 15:48:01 -07:00
Matthias 731c4f1fcb fix: Live to VOD discards the wrong segments when crossBoundaryStrategy is not KEEP (#8863)
Due to not setting the `boundaryEnd` for the last period, we ensure we
do not discard the wrong segments in a live to VOD situation (where a
boundaryEnd becomes available mid stream).

The same applies in live, when a period ends and a new period starts.
The previous one will now have a boundaryEnd, the new one does not.

 Co-authored-by: @avelad
2025-07-10 12:49:03 +02:00
Emil Santurio 7526f2b2e9 fix(DASH): Change start number for SubNumber templating, based on DASH 6th edition (#8860)
Close #8859
2025-07-10 12:05:54 +02:00
Wojciech Tyczyński f512b3af30 fix(DASH): Always fit segments to period boundaries on VOD (#8825)
Fixes #8774
2025-07-01 14:07:38 +02:00
Álvaro Velad Galván 5b5e2220e4 feat(DASH): Add support for certificate acquisition URL (#8824)
Close https://github.com/shaka-project/shaka-player/issues/8823
2025-07-01 13:24:40 +02:00
Joey Parrish 7c1e31d4e6 chore: Add trailing commas to all record types (#8820)
Now that jsdoc supports this, it will make future diffs cleaner. See
#8819 and #1236.
2025-06-30 13:36:04 -07:00
Álvaro Velad Galván 93117d2ace feat: Add enableAudioGroups config (#8792)
Close https://github.com/shaka-project/shaka-player/issues/8684
2025-06-25 12:46:38 +02:00
Gregory McGarry 88627c3714 fix(DASH): Use the correct Representation ID for Uri substitution of media segments (#8760)
For DASH segment templates, MpdUtils.fillUriTemplate() is used for
substitution of tokens in the fetch URL, like $RepresentationID$. When
supplemental codecs are used, the incorrect RepresentationID will be
substituted for media segments. The initialisation segment is correctly
substituted.

The symptom is that fetches for media segments will fail with 404
response codes.
2025-06-20 11:27:07 +02:00
Álvaro Velad Galván cb22ab6933 fix(DASH): Fix L3D streams (with k parameter) without $SubNumber$ (#8770) 2025-06-19 09:31:10 +02:00
Wojciech Tyczyński 6b976dbcb9 fix(DASH): Fix infinite buffering on end of content (#8677)
Fixes #8672
2025-06-03 11:36:31 +02:00
v-nova-romas 4ef126b2d0 fix(LCEVC): Ensure unique originalVideoId for LCEVC dual-track (#8562)
In LCEVC dual-track implementation, both tracks share the same
originalVideoId, which causes one to be dropped when `getVideoTracks()`
returns them as a Map. This PR assigns a unique originalVideoId to each
track to ensure both appear correctly in the resolution menu
2025-05-07 18:03:49 +02:00
Gary Katsevman 6e029d1753 fix(CEA): cache and restore cea decoders based on the period continuity for dash content that uses SegmentTemplate (#8378)
We had an issue where in SSAI content, 708 data was being split by ad
periods. Currently, when this happens, we reset the 708 decoder, which
means that captions are lost. Instead, we want to cache this decoder for
a later time. This change keeps track of continuous periods and caches
the 708 decoder when a period change happens to a discontinuous period.
This is so that it could be later restored if we go back to a continuous
period.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2025-04-23 10:00:02 +02:00
Wojciech Tyczyński a7abb2967a fix(DASH): Fix live playback with Period duration (#8493)
Fixes #8481
2025-04-22 14:53:00 +02:00
Álvaro Velad Galván 396bdf69df perf(DASH): Release period combiner after parsing a VOD (#8443) 2025-04-11 12:24:25 +02:00
Wojciech Tyczyński ce08da5609 feat(DASH): Parse ProducerReferenceTime nodes (#8439)
This PR introduces support for `ProducerReferenceTime` tags in DASH.
When finding any, it emits event, similar to inband PRFTs added in
#4389.
Additionally, calculated start date from `ProducerReferenceTime` is used
as program start date, as it's more accurate value than
`MPD#availabilityStartTime` used before.
2025-04-10 16:49:47 +02:00
Matthias ab01bb724a feat(DASH): Add support for "Spoken Subtitles" in tva:metadata:cs:AudioPurpose (#8364) 2025-03-31 15:46:52 +02:00
Wojciech Tyczyński 51ff82f204 build: Migrate to stylistic eslint plugin (#8298)
Fixes #8278
Migrates deprecated rules from `eslint-config-google` and our rules as
well to stylistic.
Additionally removes broken `eslint-disable` python check and replaces
with eslint `reportUnusedDisableDirectives` option.
2025-03-19 16:18:30 +01:00
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 9ba31325ea chore: Move isMediaKeysPolyfilled to DrmUtils (#8216) 2025-03-05 16:03:48 +01:00
Álvaro Velad Galván be12a7f132 build: Move EBML parser to dash to improve the build size (#8189) 2025-02-28 15:14:39 +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 8f0b0e3282 feat(LCEVC): Detect as supported dual track content with LCEVC (#8134)
This PR does not yet add enhancement layer decoding support.
2025-02-21 13:28:56 +01:00