Commit Graph

341 Commits

Author SHA1 Message Date
Álvaro Velad Galván bd167c3744 feat: Add listenMulti and listenOnceMulti to shaka.util.EventManager (#9652)
Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2026-02-03 21:49:35 +01:00
Álvaro Velad Galván 5ee77799f5 chore: Remove unused code (#9584) 2026-01-21 14:08:36 +01:00
Woody Hill 66b0c74a01 fix: parseHDLR for Apple QuickTime hdlr box compatibility (#9577)
Apple QuickTime places a manufacturer field ('appl') immediately after
the handler type ('soun'), causing readTerminatedString() to incorrectly
read 'sounappl' instead of 'soun'. This breaks Opus fMP4 audio playback
for content packaged with Apple tools.

Replace null-terminated string parsing with fixed-length byte reading to
extract exactly 4 bytes for the handler type.

Closes #9576

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2026-01-20 12:59:31 +01:00
Álvaro Velad Galván ef361ed039 feat: Add MoQT draft-14 + WARP/MSF draft-1 experimental support (#9409)
Spec: https://datatracker.ietf.org/doc/draft-ietf-moq-transport/14/
Spec: https://datatracker.ietf.org/doc/draft-ietf-moq-warp/01/

Note: this is experimental and not included in the default builds

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2026-01-14 09:27:10 +01:00
Álvaro Velad Galván 5b473c8d54 test: Fix override TextDecoder on tests (#9549) 2026-01-08 11:44:12 +01: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 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
Álvaro Velad Galván 9ff4134dee chore: Update shaka.media.SegmentUtils.BasicInfo to include drmInfos info (#9402)
Co-authored-by: Theodore Abshire <TheodoreAbshire@Gmail.com>
2025-11-18 11:44:03 +01:00
Álvaro Velad Galván 85797133e7 test: Add tests for native tracks (audio, video and text) APIs (#9383) 2025-11-12 20:45:33 +01:00
Constanza Dibueno ac2d390807 feat(CMCDv2): Response Received (#9362) 2025-11-06 10:10:20 +01:00
Romualdas Paskevicius f7c7d2a178 fix(UI): Add LCEVC label in resolution menu (#9186)
This PR adds `isLCEVC` check to the `basicResolutionComparison` and
appends `'LCEVC'` to the label text in `getResolutionLabel_` if the
track is LCEVC. This makes it easier to tell LCEVC profiles apart and
fixes an issue we were seeing when many different Dual-Track profiles
are contained in the manifest, it might be hard to differentiate them
(e.g. base and LCEVC profile with the same 1080p resolution).
2025-10-09 16:37:59 +02:00
Álvaro Velad Galván 945c57ab77 feat!: Remove all deprecated things (#9162) 2025-10-07 10:52:13 +02:00
Constanza Dibueno c79b66b2e3 fix(CMCDv2): Prevent processing when target is disabled in response mode (#9065)
Fixes #9056 

This PR fixes:
- The fact that CMCD functions were executed when the feature was
disabled in https://github.com/shaka-project/shaka-player/issues/9056

The issue was identified on response mode workflow, where data
processing was being executed even if target was disabled. Request and
Event mode were already skipping processing if disabled.
In order to fix the issue, data processing is now skipped if response
mode targets are disabled or not configured.
2025-09-09 09:27:08 +02:00
Casey Occhialini 89d12a86e8 fix: prevent infinite loop when constructing CMCD relative urls (#9055)
Fixes #9050
2025-09-08 14:19:31 +02:00
Joey Parrish 849bff1db3 fix: Audit all usage of readBytes for memory leaks (#9027)
Make cloning buffers (or not) explicit in readBytes.

When we use a range of bytes temporarily for further parsing, we pass
clone=false and get a view on the existing memory buffer. When we want
to store the range of bytes, we pass clone=true and avoid holding a
reference to an entire segment in memory.

The call for the EMSG parser in MediaSourceEngine had an explicit clone,
but now uses the new clone parameter. This is not a functional change,
though.

The only readBytes call that changed in this audit was in the UI seek
bar.

The rest all appear to be values for temporary usage, and so are not
being cloned.

The new `clone` parameter will require future callers of `readBytes()`
to think about their purpose and make a choice.
2025-08-27 10:49:48 +02:00
Álvaro Velad Galván 72294bc20f test: Fix CMCD test on Tizen (#9019) 2025-08-25 15:29:42 +02:00
Álvaro Velad Galván c8d2452f3f fix(CMCD): Fix player expand/collapse events (#9016)
Listen fullscreenchange event on document instead of video
Fix compatibility with Apple Vision Pro
2025-08-25 12:59:27 +02:00
Juan Manuel Gonzalez c33e19e2f7 feat(CMCD): Add event mode support (#8980)
This pull request introduces comprehensive support for the CMCDv2
"event" mode in Shaka Player. This new functionality allows the player
to send real-time Common Media Client Data (CMCD) based on various
player and media events

- CMCDv2 Event Mode Implementation: Partial support for CMCDv2's "event"
mode has been implemented, enabling real-time event data reporting from
the player.
- Configurable Event Reporting: Configuration options have been
introduced to specify which CMCD keys and player events (e.g., play
state, mute/unmute, fullscreen, background mode) are included in the
reports.
- Periodic Time Interval Events: A timeInterval configuration option has
been added for periodic CMCD event reports, with a default of 10 seconds
and the ability to disable by setting it to 0.
- Unit Testing: Extensive unit tests have been added to validate the new
CMCDv2 event mode functionality across various scenarios, including
event filtering, header usage, and handling of multiple targets.

Shaka Player config for testing event mode:
```js
const cmcdConfig = {
    enabled: false,
    version: 2,
    contentId: 'id',
    useHeaders: false,
    targets: [{
        mode: 'response',
        enabled: false,
        useHeaders: false,
        url: 'http://localhost:3003/response-mode',
    },{
        mode: 'event',
        useHeaders: false,
        url: 'http://localhost:3003/event-mode',
        includeKeys: [],
        enabled: true,
    }]
}

player.configure('cmcd', cmcdConfig);
```

---------

Co-authored-by: Constanza Dibueno <121617928+cotid-qualabs@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-08-25 09:37:09 +02:00
Juan Manuel Gonzalez eab22af5d3 feat(CMCD): Add bg key support (#8973) 2025-08-19 17:03:29 +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
Juan Manuel Gonzalez 712850cb41 feat(CMCD): Add sn key support (#8975) 2025-08-19 15:42:01 +02:00
Juan Manuel Gonzalez 51a9c9cb84 feat(CMCD): Add cmsds key support (#8977) 2025-08-19 14:48:42 +02:00
Juan Manuel Gonzalez 842f2d4285 feat(CMCD): Add cmsdd key support (#8976) 2025-08-18 21:19:02 +02:00
Juan Manuel Gonzalez 863714d906 feat(CMCD): Add ttfb and ttlb keys support (#8974) 2025-08-18 19:48:13 +02:00
Juan Manuel Gonzalez 9e1ea12867 feat(CMCD): Add rc key support (#8972) 2025-08-18 16:43:15 +02:00
Juan Manuel Gonzalez c6df3cf9cf feat(CMCD): Add url key support (#8970) 2025-08-18 16:02:24 +02:00
Juan Manuel Gonzalez ab3a452cea feat(CMCD): Add ts key support (#8971) 2025-08-18 10:24:53 +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
Wojciech Tyczyński f69a7fa36c fix(DASH): Consider codec profile when matching multi-period renditions (#8842)
Fixes #8839

Changes how do we consider best AV match. Exact codec equality is now
better than codec compatibility.
2025-07-07 13:05:17 +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
Juan Manuel Gonzalez 2420cc90ab feat(CMCD): Add response mode for CMCDv2 (#8782)
# CMCD V2 - Response Mode
## PR Description
This PR focuses on the implementation of Response Mode functionalities
for version 2 of the Common Media Client Data (CMCD v2) specification
within the Shaka Player project.

Key changes made in this pull request include:
- **Response Mode**: CMCD v2 introduces "Request Mode" "Response Mode"
and "Event Mode". Request Mode aligns with the default delivery mode in
CMCD v1. Response Mode, which this PR implements, allows clients to send
data to one or more alternative destinations after receiving either a
full response or an error to a media object request. These reports use
one of the defined data transmission modes (Query Mode or Headers Mode)
- **CmcdTarget**: A new configuration type, `shaka.extern.CmcdTarget`,
was introduced. This configuration allows specifying the transmission
strategy (mode=response) since targets can also be configured for
**event mode** (mode=event), whether it's enabled (enabled), if it uses
HTTP headers mode (`useHeaders=true`) or query parameters mode, the
destination URL (url), and specific keys to include (`includeKeys`). For
Response Mode, the mode value includes 'response'.
- **Independent Handling of Transmission Modes**: Request mode and
Response mode can be enabled and disabled independently using the
previously mentioned CmcdTarget config for response mode and the base
config for request mode.
- **Validation and Filtering of Keys**: Allowed keys for Response Mode
were added, and validation for these keys was implemented. The
capability to include (`includeKeys`) and filter specific keys for both
Request Mode and each Response Mode target was also enabled. Also, CMCD
dictionary definitions were moved to a new dedicated section to improve
structure
- **Unit Tests**: Extensive unit tests were included and unified to
validate CMCD v2 functionality in both Request Mode and Response Mode.

Config example with request mode and targets with response mode:
```js
const cmcdConfig = {
	enabled: true,
	version: 2,
	contentId: 'content-id',
	useHeaders: false,
	targets: [{
        	mode: 'response',
        	useHeaders: false,
        	enabled: true,
        	url: 'http://localhost:3003/response-mode'
        }]
}
```

## Keys not implemented in this PR
The following keys are defined in the CMCD v2 specification but are not
calculated or attached to requests/responses in the `cmcd_manager.js`
code:
- **Common & Request Mode Keys:**
	- **`ab` (Aggregate encoded bitrate)**
	- **`tbl` (Target Buffer length)**
	- **`cdn` (CDN Id)**
	- **`bg` (Backgrounded)**
	- **`sta` (State)**
	- **`ts` (Timestamp)**
	- **`tpb` (Top playable bitrate)**
	- **`lb` (Lowest encoded bitrate)**
	- **`tab` (Top aggregated encoded bitrate)**
	- **`lab` (Lowest aggregated encoded bitrate)**
	- **`pt` (Playhead time)**
	- **`ec` (Player Error Code)**
- **Response Mode Keys:**
	- **`rc` (Response code)**
	- **`ttfb` (Time to first byte)**
	- **`ttfbb` (Time to first body byte)**
	- **`ttlb` (Time to last byte)** 
	- **`url` (Request URL)**
	- **`cmsdd` (CMSD Dynamic Header)**
	- **`cmsds` (CMSD Static Header)**

Related to https://github.com/shaka-project/shaka-player/issues/8660

---------

Co-authored-by: Constanza Dibueno <121617928+cotid-qualabs@users.noreply.github.com>
Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-06-25 10:19:25 +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 73843fb7fc chore(CMCD): Preparation for CMCDv2 response mode (#8657) 2025-05-28 16:08:18 +02:00
Wojciech Tyczyński 89584bf737 fix: Fix NTP conversion on Tizen 3 (#8444) 2025-04-11 12:24:36 +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
Srikanth Peddibhotla 933a4f2f7a fix: Support more Dolby codec notations (#8387)
Player errors out for Dolby contents in adaptive streaming because
correct mimetype is not identified.
This change adds ac3, ac-3, eac3, ec-3, and ac-4 mimetype support.

---------

Co-authored-by: Srikanth Peddibhotla <peddisri@amazon.com>
2025-04-03 06:38:45 +02:00
theodab b809646614 fix: Count line break characters as ASCII (#8376)
Previously, shaka.util.StringUtils.fromBytesAutoDetect assumed any
character between ' ' and '~' was ASCII.
This worked for many cases, but it meant that the method would be unable
to determine the encoding of a buffer if there was a newline character
near the start.
This could be a problem for parsing, for example, JSON.

Closes #8336
2025-04-01 13:39:18 -07:00
Darrin DuFord 34eaeb62f6 test: Added platform unit tests for Chromecast devices (#8311)
Added platform-detection unit tests for three flavors of Chromecast:
- Android-based
- Fuchsia-based
- Older Chromecasts (including Vizio builtins)

Closes https://github.com/shaka-project/shaka-player/issues/8308

---------

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2025-03-21 15:13:21 +01:00
Álvaro Velad Galván 36db472d93 feat(net): Add networking config (#8306) 2025-03-21 10:20:38 +01: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
Wojciech Tyczyński e0a57bb27d fix: Make shaka.util.Lazy work with null (#8267)
Due to usage of `==` instead of `===` Lazy utility does not work
correctly with null generators, despite of what is stated in
documentation.
2025-03-13 17:10:37 +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 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 be12a7f132 build: Move EBML parser to dash to improve the build size (#8189) 2025-02-28 15:14:39 +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 0400d1e365 fix(tXml): Allow case insensitive in parseDuration (#8064)
This is not in the spec, but it is used to make some malformed content
work. Dash.js already does this by default.
2025-02-12 11:19:31 +01:00
Wojciech Tyczyński 9a618d479b fix(DASH): Fix playback of ClearKey when only part of keys are defined (#8055)
Fixes #8052
Key ids were not used when looking for stream duplicates, so it was
possible to filter out streams without accompanying configuration. Now
we will use key ids as well for duplicates detection.
2025-02-11 12:18:15 +01:00
Álvaro Velad Galván 16ca489843 feat: Add Vizio as community support (#8049) 2025-02-10 14:57:33 +01:00
Wojciech Tyczyński 87bdbafdb7 test: Fix new platform tests on Android (#8043) 2025-02-10 09:40:12 +01:00
Wojciech Tyczyński d03eb6ed02 chore: Simplify Apple detection (#8035)
Our Apple device detection misdetects any Webkit-based STB as Apple, due
to looking only at vendor property. To mitigate it, we were excluding
another user agents, but maintenance of this is problematic.
This PR tries to change direction - an Apple device right now is a
device with Apple vendor AND with characteristics of MacOS or iOS.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-02-07 13:28:27 +01:00