Commit Graph

87 Commits

Author SHA1 Message Date
Álvaro Velad Galván e59b8b40a7 feat(HLS): Add chapter images (#9738)
Spec:
https://developer.apple.com/documentation/http-live-streaming/providing-javascript-object-notation-json-chapters
2026-02-20 15:04:12 +01:00
Álvaro Velad Galván 88c65c6bbf chore: Reduce the internal complexity of the chapters (#9737)
Instead of saving chapter titles as a URL, they are now saved as a
metadata section that can be expanded in the future.
2026-02-20 11:38:33 +01:00
Álvaro Velad Galván 81344a84d4 fix: Allow calculate the segment size from partials segments (#9094) 2025-09-15 13:22:32 +02:00
Álvaro Velad Galván 8dbd074435 fix: Bad init segment size calculation when using byte ranges (#9092)
When calculating the size of a segment when using startByte and endByte,
both are inclusive. So the sum should add 1.
2025-09-15 12:50:33 +02:00
Álvaro Velad Galván 26c4b0dd66 fix: Bad segment size calculation when using byte ranges (#9090)
When calculating the size of a segment when using startByte and endByte,
both are inclusive. So the sum should add 1.
2025-09-15 12:13:10 +02:00
Álvaro Velad Galván 06d92a5e56 fix(HLS): Allow get better segment size estimations (#9043)
Related to https://github.com/shaka-project/shaka-player/pull/9041
2025-09-03 17:09:05 +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 aed6471dd4 perf(HLS): Reduce load time when loading in the player a media playlist (#8333)
This allows temporary caching of init segment and data segment used to
obtain the data (eg: codec) needed for playback.
2025-03-25 18:00:47 +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 5debddcf4d chore: Add encrypted flag to init segments (#8182) 2025-02-27 14:10:32 +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
Álvaro Velad Galván 9e2b15ead4 fix(HLS): Fix subtitle timing (#7625)
Simplifies subtitle management for sequence mode and segments mode 
Runs subtitle tests in segments mode as well (Tizen 3.0)

Fixes: https://github.com/shaka-project/shaka-player/issues/7447
2024-11-19 18:36:49 +01:00
Álvaro Velad Galván 013b3c7f22 feat(Offline): Allow store external thumbnails (#7322)
Related to https://github.com/shaka-project/shaka-player/issues/2016
2024-09-17 09:44:53 +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 0895e2e771 feat(HLS): Add support for MediaQualityInfo events (#6927) 2024-06-28 09:14:24 +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
Álvaro Velad Galván 2bb6dbc56d feat: Add segmentData info to SegmentReference (#6370)
This is useful when creating custom manifests, which are actually a
single segment. For example, a custom AAC manifest or any other audio
format.
2024-03-26 22:44:50 +01:00
Wojciech Tyczyński 58d946e35a perf: Optimize init segment reference comparison for common case (#6014) 2024-02-20 10:03:10 -08: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
theodab 24e32559bf feat(DASH): Handle mixed-codec variants. (#5950)
With the addition of the changeType API for MediaSource, it is theoretically possible for a variant to change between multiple codecs for a given buffer, over the course of playback.
This adds support for the DASH player to stitch together periods which have such multi-codec variants, but only as a last resort. For example, if one period only has audio in aac, and another period only has opus audio, the player will now stitch those periods together as one, but if there is a throughline that does not involve changing codecs it will go for that instead.

Closes #5961
2023-12-01 00:37:32 -08:00
Álvaro Velad Galván 82ab8937e6 fix: Fix init segment comparison (#5920) 2023-11-22 23:02:34 +01:00
Álvaro Velad Galván 766b0a139e feat: Add partial info to shaka.media.SegmentReference (#5822) 2023-10-30 07:35:51 +01:00
Álvaro Velad Galván 2a3557915f perf(HLS): Improve detection of all partial segments (#5761)
This reduces calls to getUris that use regular expressions which are
slow on low-end devices.
2023-10-11 10:40:55 +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 7874667645 chore: Rename hlsAes128Key to aes128Key (#5653)
This change is required in preparation for
https://github.com/shaka-project/shaka-player/issues/5622
2023-09-13 20:52:01 +02:00
Álvaro Velad Galván 9e6655a04a feat(HLS): Optimization of LL-HLS with byterange (#5319)
This solution is based on
https://www.akamai.com/blog/performance/-using-ll-hls-with-byte-range-addressing-to-achieve-interoperabi
2023-06-21 11:20:56 +02:00
Álvaro Velad Galván 022f6b96fb fix: Get the correct timescale when there are two trak boxes (#5327)
Stream used for test it:
https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8
2023-06-20 22:41:52 +02:00
Álvaro Velad Galván ed5915e437 fix(HLS): Fix load of LL-HLS when the partial segment is not independent (#5277) 2023-06-12 12:03:57 +02:00
Álvaro Velad Galván ec8804d0be feat(HLS): Add support to _HLS_part query param in LL streams (#5265) 2023-06-07 18:53:04 +02:00
Álvaro Velad Galván f80bf208b1 feat(MSS): Add support for Microsoft Smooth Streaming (VOD only) (#5002)
Closes https://github.com/shaka-project/shaka-player/issues/703

---------

Co-authored-by: Joey Parrish <joeyparrish@google.com>
2023-03-24 07:47:33 +01:00
Ashwin Bhat 71affe7e85 fix(HLS): support discontinuities in segments mode (#5102) 2023-03-21 09:03:23 +01:00
Joey Parrish 50c9df49a7 fix: Sync each segment against EXT-X-PROGRAM-DATE-TIME (#4870)
Closes #4589
2023-01-12 14:22:40 -08:00
Joey Parrish 35033bb2db fix(HLS): Fix AV sync over ad boundaries (#4824)
If server-side ad segments aren't aligned, AV could get out of sync by
accumulating errors in the timestampOffset of the SourceBuffers.

This improves the issue by tracking discontinuity boundaries and
resetting timestampOffset to theoretical segment start times when a
boundary is crossed.

Issue #4589
2022-12-13 10:14:17 -08:00
Álvaro Velad Galván 86cb3e714c feat: Add external thumbnails with sprites support (#4584)
Continuation of https://github.com/shaka-project/shaka-player/pull/4497
2022-10-18 07:31:15 +02:00
Dave Nicholas 89777dd704 feat: Parse and surface "prft" boxes as events (#4389)
Closes #4382
2022-09-14 13:39:58 +02:00
theodab 6194021a3d feat(hls): Support AES-128 in HLS (#4386)
Expands on the original PR (#3880) by adding support for MP4 and key rotation.

Close #850

Co-authored-by: wjywbs <wjywbs@users.noreply.github.com>
2022-08-12 10:50:32 -07:00
Joey Parrish 314a987ecf fix(hls): Fix AV sync issues, fallback to sequence numbers if PROGRAM-DATE-TIME ignored (#4289)
We now have an explicit fallback to sync on sequence numbers if
PROGRAM-DATE-TIME is explicitly ignored.  This is more robust than
relying on whatever happens to be first in the various media
playlists.

This also refactors how PROGRAM-DATE-TIME is used.  The date will now
be used to adjust segment reference start times, rather than
overriding the time used in StreamingEngine.  (This was hard to
discover when reading the HLS parser.)  Now all HLS sync logic is in
the HLS parser.

Closes #4287
2022-06-13 13:35:57 -07:00
Álvaro Velad Galván 42eecc84f9 feat(hls): parse EXT-X-GAP (#4134)
Parse EXT-X-GAP HLS tag and add a status enum to shaka.media.SegmentReference.

shaka.media.SegmentReference.Status.AVAILABLE --> Normal behaviour
shaka.media.SegmentReference.Status. UNAVAILABLE --> Related to https://github.com/shaka-project/shaka-player/issues/2541
shaka.media.SegmentReference.Status. MISSING --> EXT-X-GAP in HLS

Note: only the parsing is added, but the functionality is not yet implemented.

Issue https://github.com/shaka-project/shaka-player/issues/1308
2022-04-18 10:22:30 -07:00
theodab 89409cee3e feat(hls): Read EXT-X-PROGRAM-DATE-TIME (#4034)
This makes the HLS parser read the EXT-X-PROGRAM-DATE-TIME value
on manifests, and use it to make sure that segments are inserted at
the correct place in the timeline, when in sequence mode.

Issue #2337
2022-03-24 15:58:53 -07:00
Theodore Abshire 264c842496 fix(image): Fix HLS image track issues
This makes the HLS parser honor more attributes for image tracks.
It also makes some changes to player.getImageTracks, so that the
returned track shows the size of a single thumbnail rather than the
entire sheet.

Closes #3840

Change-Id: I2ae096f455864201e08a85e29f0f02a3e06eb07f
2022-01-11 03:41:12 +00:00
Aidan Ridley bd7b384c66 feat: Add media quality change events (#3700)
Closes ##3431
2021-11-12 15:07:18 -08:00
Joey Parrish d4a1255235 fix: Fix thumbnail duration, expose start time and duration
Thumbnail segments may be structured for a certain grid size and
duration, but the segment references may have their duration truncated
due to the end of a period or the end of the presentation.  This was
causing us to calculate the wrong duration for those individual
thumbnails, and therefore return the wrong
thumbnail.

We also did not have any way to indicate to an application how long a
thumbnail should be shown.

This fixes the duration calculation by retaining the original,
untruncated duration in SegmentReference.  This also exposes startTime
and duration information on the Thumbnail object, so that applications
know when/where and how long to show a given thumbnail.

Closes #3517

Change-Id: I84aa7705a19691fc6ae68eee9944fecbd7067fe0
2021-07-14 15:37:43 +00:00
Álvaro Velad Galván 2a4083bab8 feat: Add support to HLS Image Media Playlists (#3365)
Close: #2429
2021-06-02 10:53:32 -07:00
Theodore Abshire 8e1eeda965 fix: Exported SegmentReference.getUris.
Previously, SegmentReference.getUris was listed as public field,
but not actually exported. For an object that does not have externs,
there is no way to ensure that a member variable is not renamed.
So, instead, this CL makes an exported public getUris method, that
wraps the getUrisInner member variable. This allows for the method
to be exported, without having to make an extern for the class.

Closes #3096

Change-Id: I847439c444021bcf6af2b210f7138a51ba164d71
2021-03-11 19:49:03 +00:00
Álvaro Velad Galván 3484ac8c7c fix(media): Fix initSegment requests on manifest updates (#2942)
Fixes #2856
2020-11-10 10:38:35 -08:00
michellezhuo 109973c7e2 feat(LL-HLS):Enable preload hinted segments
LL-HLS hints a resource that is needed to playback in the upcoming
update. It's available for request, and may not be available for
download yet.

A preload hinted resource is either a partial segment, or an init
segment. If it's an init segment, treat it the same way as the Map tag
in ManifestTextParser.
A preload hinted segment contains no duration information, so its
start time and end time are the same. It will be replaced by a partial
segment in the next update.
We should fetch and append the preload hinted segment the same way as a
partial segment.

Issue #1525

Change-Id: I1e30f216ecdc843c3cd01681629a8886383d0b22
2020-07-08 22:11:06 +00:00
michellezhuo 965ef453b6 feat(LL-HLS):Enable Partial Segments streaming
Changed SegmentIndex and SegmentIterator to iterate through regular and
Partial SegmentReferences.

SegmentIndex:
merge(): Find all the old segments after the first new segment's start
time, and replace the old ones with new segments.

SegmentIterator:
Use the currentPosition and currentPartialPosition pointers to iterate
through the two-layer arrays.
current(): Get the current SegmentReference, and get its current Partial
SegmentReference if it has a Partial Segment list. Move to the next
regular segment if we reached the end of the current segment's partial
list.
next():
If the regular segment has a partial list, go to the next Partial
Segment. If reached the end of the current partial list, move to the
next regular segment.
If the regular segment doesn't have a partial list, move to the next
regular segment.

Issue #1525

Change-Id: Icb7f49e50314f15ea40bf3a74d008191ed1a9a6c
2020-07-06 00:34:55 +00:00
michellezhuo 244ebacac3 feat(LL-HLS): create SegmentReferences for Partial Segments
If a segment has partial segment tags, create a SegmentReference for
each partial tag, and add the list of partial SegmentReferences to the
parent SegmentReference as an attribute.
If the parent segment contains the segment tag(EXTINF tag), use the
duration information from EXTINF tag to create the SegmentReference.
Otherwise, calculate the parent segment's duration based on the partial
segments' durations.

Issue #1525

Change-Id: I946cc007aad2ff911b69bf1c6a46df145452bfaa
2020-06-17 17:09:23 +00:00
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00
Joey Parrish 342d35f4f9 Fix issues with nullability of numbers
Various issues with the nullability of number types led to various
fixes, including:
 - defaulting a nullable number to 0 to avoid propagating a null value
   through calculations
 - adding an assertion or runtime check that something is not null
 - moving an existing null check to before the calculation
 - returning early on null during an iteration
 - changing a nullable number to non-nullable
 - defaulting to NaN instead of null

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I86d516c74a42ee3624c33d7513d2d4c76d3ea589
2020-04-30 16:00:00 +00:00