Commit Graph

250 Commits

Author SHA1 Message Date
Ivan 921206dc1d feat: transmux in a worker (#9914)
This PR introduces a Web Worker for transmuxing resolving
https://github.com/shaka-project/shaka-player/issues/1735

- The worker bundle is compiled separately
- The build output is embedded as a string constant and then wrapped in
a Blob to create an inline Worker URL (HLS.js does this very similarly)
- `TransmuxerProxy` is created wrapping a real transmuxer, but no worker
is started yet - on the first `transmux()` call, it checks if the device
supports worker transmuxing
- For each transmux() call: the buffer is copied, then zero-copy
transferred to the worker. A PublicPromise is stored under a reqId with
a timeout timer, and the main thread awaits it.
- The worker transmuxes and posts back transmuxed (or error). The shared
message listener routes the response to the right proxy instance by id,
which resolves the promise and cancels the timer.
- When the last proxy instance is destroyed, the worker is terminated
and the blob URL is revoked.
  loaded inside the worker.
- Some low-end devices have been excluded since their Worker support is
questionable

There most likely is a better way to do this - please let me know
2026-05-27 21:51:03 +02:00
Matthias Van Parijs 09b6c94ad8 fix: Bail out on initial text preference when a user selected one manually. (#10010)
```js
player.addTextTrackAsync("...", "en", "subtitles");
const textTracks = player.getTextTracks();
// Text tracks has a length of 1, but immediately selecting it would fail.
player.selectTextTrack(textTracks[0]);
```

Text track preference runs after we manually selected a text track, in
`src=` we'd wait for `loadeddata` before figuring out which initial text
track should be selected. The fix is to bail out when we already have a
text track active when trying to select an initial text track.
2026-04-20 23:32:00 +02:00
dong-heun 0f322b08bb fix: include unencrypted decodingConfigs in preferredKeySystems loop (#9975)
HLS SUPPLEMENTAL-CODECS (e.g. Dolby Vision dvh1) creates duplicate
variant tags with different codecs but the same media playlist URI. Due
to lazy-loading, only one variant gets its drmInfos populated via
createSegmentIndex(). The other variant remains with empty drmInfos and
is treated as unencrypted by getDecodingConfigs_().

In the preferredKeySystems loop, the filter rejected these unencrypted
configs (undefined !== preferredKeySystem), leaving the variant with no
decodingInfo and causing it to be dropped.

Fix: allow unencrypted configs (!keySystem) to pass through, matching
the pattern already used in the second (fallback) loop.

Propagating drmInfos in HLS parser would be more correct but is complex
because stream duplication happens at the tag level with separate cache
keys (URI + codecs) in createStreamInfoFromVariantTags_.
2026-04-15 12:39:19 +02:00
Wojciech Tyczyński 6509d9b7ac chore: Remove rarely used Functional methods (#9928) 2026-04-02 18:43:37 +02:00
Matthias Van Parijs 73ee27bf17 feat!: Remove autoShowText and simplify initial text track selection (#9435)
This is the first step in a series of efforts to simplify how we handle
text tracks internally.

The purpose of `autoShowText` has always felt a bit unclear. It was
originally added because Shaka wasn't flexible enough when choosing an
initial text track. I don't think we should try to handle every possible
scenario for initial text track selection. Instead, we should respect
`config.preferredTextLanguage` and let the application decide if it
needs more granular control. Apps can already do this easily with
`getTextTracks()` and `selectTextTrack(track)`.

Ultimately, I'd like to move toward a simpler API where either a text
track is selected or none is. If nothing is selected, we shouldn't
stream any text at all.

See https://github.com/shaka-project/shaka-player/issues/9301 for extra
context.
2025-12-12 09:41:15 +01:00
Álvaro Velad Galván 8d7a15b2be fix: Fix exception reading audio-only content (#9465)
Fixes https://github.com/shaka-project/shaka-player/issues/9458
2025-12-03 11:13:12 -08:00
Álvaro Velad Galván 35f187ee0c fix: text track active property when using src= (#9462)
This is necessary because NativeTextDisplayer and UITextDisplayer work
differently.

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2025-12-03 11:22:56 +01:00
Álvaro Velad Galván 2c1ab30d71 fix: Avoid audio streams filtering and use AdaptationSetCriteria instead (#9457)
This is part to remove dontChooseCodecs config in the future.
2025-12-03 10:31:38 +01:00
Joey Parrish 4d99357bbe chore: Clean up and comment stream filtering (#9453)
In chooseCodecsAndFilterManifest, there was a real lack of comments. So
first and foremost, this adds comments.

Second, group IDs for audio & video streams were made by concatenating
various properties, but without delimiters, so there may have been a
possibility for collisions. This adds delimiters in the group ID
construction.

Third, streams are already sorted by bandwidth before we start grouping
them, so the grouping code for audio & video doesn't need to check
`stream.bandwidth < previousStream.bandwidth`. This should always be
true.

Fourth, the video stream sorting conditions were too nested and hard to
read. This flattens those out in a way that makes them easier to
understand.

Finally, because we're always only allowing one codec per group,
skipping a stream due to `!supportsSmoothSwitch` makes no sense. We're
only ever adding streams to our filter list when their codecs match
what's already in the group. So the check on `supportsSmoothSwitch` is
removed.
2025-12-02 09:11:28 +01:00
absidue 888f6d3e13 fix: text track active property with SRC_EQUALS load mode (#9418)
This fixes the `active` property on text tracks returned by
`Player#getTextTracks()` still being `true` after calling
`Player#selectTextTrack(null)` when the load mode is `SRC_EQUALS`, this
was also causing the text track selector to still show the text track as
selected after clicking `Off`.

The text track selector UI issue is only a problem on the main branch
(v5.0) as #9048 hasn't been released in any of the release branches yet.
2025-11-21 23:14:06 +01:00
Romualdas Paskevicius 3143505f1d fix(UI): Support non-square pixels in getResolutionLabel_ (#9300)
The changes in this PR add support for non-square pixels, e.g. SAR value
of 2:1 (or any other) to the Resolution Selection Menu.

Currently, some contents can be falsely detected as portrait video by
getResolutionLabel_, e.g. a 960x1080p content with a SAR value of 2:1
would be detected as portrait and have its width and height swapped by
getResolutionLabel_. However it is a landscape content: the horizontal
pixels would be stretched to display a horizontal video.
2025-10-29 12:04:02 +01:00
Wojciech Tyczyński 8e67e0bafc chore: Simplify codec switch check (#9274)
Move all logic related to smooth switch check to device API.
2025-10-23 16:45:02 +02:00
Álvaro Velad Galván cdf5f6db73 fix: Add usage of AccessibilityPurpose.VISUALLY_IMPAIRED when using src= (#9255)
Fixes https://github.com/shaka-project/shaka-player/issues/9253
2025-10-22 13:04:36 +02:00
Álvaro Velad Galván 9aed4df063 feat: Add native chapters support (#9208) 2025-10-14 16:08:50 +02: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
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
Álvaro Velad Galván cd8285f9fd fix: Fix audio/video bandwidth calculation when only one of them is provided (#9091) 2025-09-15 12:40:19 +02:00
Álvaro Velad Galván f905bdad1d fix: Fix videoBandwidth when using LCEVC dual track (#9013) 2025-08-22 10:19:17 +02:00
Álvaro Velad Galván cb52a88509 fix: Don't filter video streams with different roles (#8991)
Related to https://github.com/shaka-project/shaka-player/issues/8943
2025-08-19 16:30:04 +02:00
Álvaro Velad Galván 5654aea946 feat: Expose video label in Track and VideoTrack (#8947) 2025-07-31 16:15:47 +02:00
Álvaro Velad Galván 4967e5278a feat: Expose video roles in Track and VideoTrack (#8944)
Related to https://github.com/shaka-project/shaka-player/issues/8943
2025-07-31 14:00:29 +02:00
Matthias 5245bc3589 fix: Bail out on other decodingInfos when we found a preferred and supported one. (#8829)
Pick a multi DRM asset, set `preferredKeySystems` to prefer PlayReady
over Widevine and run on a device that does not support PlayReady (eg;
Chrome).

A `REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE` is thrown.

This is due to the logic in `getDecodingInfosForVariants` where we bail
out on probing other decodingInfos when we found a prefered one, but we
didn't check whether it was supported or not. As a result, Widevine was
never checked and PlayReady was left marked as unsupported.
2025-07-02 12:18:28 +02:00
Wojciech Tyczyński fd7ee12c9d chore: Simplify DrmEngine queryMediaKeys() (#8828)
`queryMediaKeys()` was able to work both with variants and key system
configs. The latter option was needed only for `initForRemoval()`
method. By removing it we are able to make the logic more easy to
follow.
Additionally, compiled build is now 2 KB smaller.
2025-07-02 11:21:26 +02:00
Álvaro Velad Galván f056c8c0b0 fix: MCap improvements in order to support more MCap implementations (#8821) 2025-07-01 11:27:04 +02:00
Álvaro Velad Galván 53db6554f3 perf: Simplify getAudioTracks internally when using src= (#8703) 2025-06-06 09:34:14 +02:00
Wojciech Tyczyński 970d7756ea feat: Add Device API (#8210)
The goal is to simplify and abstract feature logic detection. Currently
lots of places depend on various calls to `shaka.util.Platform` and
mainteinance of this is hard & not easy to read.

By introducing device API ideally rest of the player logic would look
into device features instead of directly checking platform. Additionally
we can more easily cache needed values, so we won't have to parse user
agent several times anymore.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-06-02 13:46:40 +02:00
Álvaro Velad Galván 2d8ad94690 feat: Simplify getStats to support MSE-AirPlay (#8309) 2025-03-21 11:53:31 +01:00
Álvaro Velad Galván 77a3f567bd feat: Add more info on src= tracks when the browser support it (#8302)
This add info about videoTrack when there is not audioTrack

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2025-03-20 12:09:10 +01:00
Álvaro Velad Galván 9021bd8272 feat: Add more info on src= tracks when the browser support it (#8299)
More info
https://github.com/WebKit/explainers/tree/main/TrackConfiguration
2025-03-19 20:21:59 +01:00
Álvaro Velad Galván d2f3657c96 feat: Simplicate Image/Thumbnails API (#8266) 2025-03-13 16:25:45 +01:00
Álvaro Velad Galván c0455d781f feat: Simplicate Text and Chapters APIs (#8264) 2025-03-13 12:20:49 +01:00
Álvaro Velad Galván 2d0995f58b fix: Fix codec selection (#8197)
Fixes ccbbb01e55 that broken codec
selection on
https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd
2025-03-03 14:55:51 +01:00
Álvaro Velad Galván 4e05551986 feat: Allow preload text tracks and expose the preloaded variant and text tracks (#8187) 2025-02-28 15:14:25 +01:00
Álvaro Velad Galván 6ffc30210e fix: Remove timeout for decodingInfo in some platforms and increase the timeout (#8172) 2025-02-26 15:37:27 +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
vlazh ccbbb01e55 fix: Check bandwidth when filtering streams (#8125)
Fixes #8124.
2025-02-20 17:29:03 +01:00
Álvaro Velad Galván 75709351c8 fix: Remove isSafari and always use isApple (#8104)
This replacement is safe to do and also reduces the number of internal
operations to obtain the result.
2025-02-19 10:07:35 +01:00
Álvaro Velad Galván f778713e13 feat: Create a new simple API for Audio (#8005)
Close https://github.com/shaka-project/shaka-player/issues/3544

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2025-02-05 12:16:25 +01:00
Álvaro Velad Galván 8e17bad40f fix: Add more info in getVariantTracks for muxed streams (#8002) 2025-02-03 14:11:14 +01:00
stefangehrer 4eb2ceab05 fix: Fix AC-3 playback on Tizen 3.0 devices (#7969)
Fixes https://github.com/shaka-project/shaka-player/issues/7955
2025-01-29 09:42:20 +01:00
Wojciech Tyczyński 16e66876c6 chore: Stop using "Object" in DV codecs mapping (#7946)
Related to #1672
2025-01-24 16:53:28 +01:00
Álvaro Velad Galván 148c4011e6 chore: Stop using "Object" in cache annotations (#7938)
Related to https://github.com/shaka-project/shaka-player/issues/1672
2025-01-24 11:36:56 +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 bd996328a5 fix: Remove useless calls to isTypeSupported (#7817)
It also enables a test that has been disabled due to this bug.
2025-01-02 08:55:24 +01:00
Gary Katsevman 88472b3076 feat: add support for multiple robustness levels in drm (#7753)
This changes the `drm.advanced.videoRobustness` and `audioRobustness`
config options from a string to an array of strings. Internally, in the
drm engine, this gets expanded into an array of `DrmInfos` which have
those values as strings.

Best way to review this change is with whitespace turned off in the diff
options.

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2024-12-23 10:20:24 +01:00
Álvaro Velad Galván 179ccc61b8 chore: Move DrmEngine and DrmUtils to drm namespace (#7788) 2024-12-20 13:10:29 +01:00
Wojciech Tyczyński 51765e9693 build: Change spellchecking tool and fix spelling mistakes (#7765)
Fixes #7693
2024-12-20 12:27:05 +01:00
Álvaro Velad Galván 60429e93f9 fix: Prefer Dolby Vision p5 over Dolby Vision p8 (#7745) 2024-12-11 14:10:50 +01:00
Álvaro Velad Galván 79a481e4ab fix: Fix usage of keySystemsMapping (#7736)
Related to https://github.com/shaka-project/shaka-player/issues/7613
2024-12-10 16:11:01 +01:00
Álvaro Velad Galván 656d16c7e0 perf: Reduce calls to isTypeSupported (#7729)
There should not be any call to isTypeSupported if we have already used
Mcap with the same codecs/mimeType
2024-12-09 13:29:38 +01:00