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>
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.
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.
Fixes#6605
Resets cache (including last used presentation timestamp) of CEA Decoder
on every init segment append.
Adds few debug logs to easify investigations in the future.
Ensure whitespace rendered in CEA-608 test streams instead of `⠀` (braille pattern blank).
Updated UT too, but avoiding this char at ends of the string hence vulnerable to trim() 🤦Fixes#6328
Fixes#5891
In production, we are seeing the occasional SEI packet [`0x5b`], which
is causing the parser to error. Using Mux.JS, this packet is ignored
because it's not long enough to be a valid captions packet, so for
feature parity it would make sense for the built in Shaka parser to also
ignore.
Tizen 3 does not support Array.flat(). This fixes a runtime exception on
Tizen 3 by replacing flat() with concat() and the spread operator. This
also bans the use of flat().
flat() was originally introduced in PR #5422
Fixes#5178
Changes included:
- converted CEA parsers to externs
- added API to register/unregister CEA parsers
- TextEngine now checks is CEA decoder registered
- excluded CEA plugin from core build
- added lcevc plugin to core build
Bundle size results (all in KB, compared to
bf4b4a54cc):
| core | complete - ui | complete - ui - cea
-- | -- | -- | --
before | 246 | 473 | 473
after | 231 | 474 | 459
This updates the compiler and closure library to the latest releases.
This required a few small tweaks:
- Drop custom extern for WebCrypto (now built into the compiler)
- Remove require() in cea parser, only used in `throws` annotations
- Hack around a typing issue in a fake version of TextTrack in tests
When unboxing TKHD, the reader read int64 as trackId instead of int32. Thus unable to find matching timescale when doing TFHD unboxing. Therefore when parsing MDAT, the default timescale will be used which is 90000. All CC timestamps will then be incorrect.
This also fixes "Shaka Error MEDIA.VIDEO_ERROR (3,,PIPELINE_ERROR_DECODE: Failed to parse H.264 stream)" error when playing DASH MP4 H.264 streams with CEA-608 CC embedded. It's likely that the VDA bundled in Chromium-based browsers have already included EPB detection & prevention. If we let the player to remove the byte, VDA will complain about stream conformance.
Closes#3502