Commit Graph

326 Commits

Author SHA1 Message Date
Casey Occhialini fe38e45f4d fix: Adds missing CMCD params to some http requests (#5072)
Fixes #5067
Fixes #5094

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2023-03-15 02:13:16 -07:00
Álvaro Velad Galván ea290ab958 fix: Increase IndexedDB timeout (#4984)
Related to https://github.com/shaka-project/shaka-player/issues/4625
2023-02-09 10:25:30 +01:00
Álvaro Velad Galván 2b50b88030 feat(HLS): Add HLS support for non-sequence mode (#4623) 2023-01-30 21:22:30 +01:00
Joey Parrish a7f0be726d fix: Fix HLS lazy-loading with DRM (#4646)
Now that DRM info is only parsed after playback has begun, the manifest
parser needs to communicate back to the other components that new DRM
info is available after lazy-loading a playlist.

Closes #4622
2022-11-04 08:31:52 -07:00
theodab d4d37407c8 fix(offline): Add storage muxer init timeout (#4566)
In some cases, indexedDB.open() can end up calling neither callback.
When this does happen, according to my initial testing, it happens
consistently when reloading the page, so it's not a one-off fluke but
presumably some sort of implementation or browser install problem. If
that does happen, the init promise of the storage muxer hangs forever,
potentially blocking other operations from happening. This adds a
timeout to the invocation of indexedDB.open(), after which the operation
fails with a new error.
2022-10-13 15:35:55 -07:00
Joey Parrish a16b1ac8a4 fix: Fix HLS dynamic to static transition (#4483)
fix: Fix HLS dynamic to static transition

 - Keep maxSegmentEndTime_ updated in PresentationTimeline by calling
   notifySegments on each HLS playlist update, so that the seek range
   doesn't revert to the original playlist size when it becomes
   static.
 - Wait to change the presentation type to VOD until after _all_
   active playlists have an ENDLIST tag, to avoid missing the final
   segments in one type or the other.
 - Stop updating the playlists after transition to VOD.
 - Update the MSE duration at exactly the same time as we transition
   to VOD, to avoid a loophole where the UI knows it's VOD, but
   doesn't have any way to get the correct duration.  Previously, this
   state would persist until the final segments were appended.

Closes #4431
2022-09-13 13:44:44 -07:00
Joey Parrish 87e91874ee test: Disable offline for Xbox One (#4232)
Xbox One tests have been failing often for some time now, so it went
unnoticed that offline was not working.  It seems that IndexedDB is
not working properly on Xbox, and the platform throws `UnknownError`.

This restricts offline so that it is not triggered on Xbox One, and
this also fixes the filtering of our offline tests to respect the
offline storage muxer's support method.
2022-05-17 11:18:59 -07:00
Albert Daurell b57279d39c feat: Temporarily disable the active variant from NETWORK HTTP_ERROR (#4189)
When a `NETWORK HTTP_ERROR` is thrown, we'll temporarily disable the variant for `shaka.extern.Restrictions.maxDisabledTime` seconds (default will be 30 seconds).

Closes #4121
Closes #1542
2022-05-05 09:02:32 -07:00
Joey Parrish c07447f00e fix(offline): Clean up orphaned segments on abort (#4177)
If a storage operation is aborted (via API, not via closing the page),
this will now be cleaned up from the database.  More work is needed to
find and remove orphaned segments in the database.

Related to #4166 and follow-up to PR #4176.
2022-04-29 20:11:31 -07:00
Joey Parrish c1c9613512 fix(offline): Speed up offline storage by ~87% (#4176)
By waiting for all segment data to be written to the database before updating the manifest, we can speed up offline storage in the foreground by ~87%.

Closes #4166
2022-04-29 16:34:23 -07:00
Álvaro Velad Galván 73f6de3e01 feat(offline): improve the speed of offline downloads (#4168)
Add the possibility to configure the number of downloads in parallel per stream. If you put a higher value the download time can decrease.

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

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-04-28 11:30:52 -07:00
Joey Parrish ac5acc80cb feat!: Remove deprecated features, update upgrade guides (#4089)
Below are the changelog entries for each deprecated feature removed by this commit.

-----

feat(config)!: `manifest.dash.defaultPresentationDelay` has been replaced by `manifest.defaultPresentationDelay` (deprecated in v3.0.0)

feat(config)!: Configuration of factories should be plain factory functions, not constructors; these will not be invoked with `new` (deprecated in v3.1.0)

feat(player)!: `shaka.Player.prototype.addTextTrack()` has been replaced by `addTextTrackAsync()`, which returns a `Promise` (deprecated in v3.1.0)

feat(ui)!: `shaka.ui.TrackLabelFormat` has been renamed to `shaka.ui.Overlay.TrackLabelFormat` (deprecated in v3.1.0)

feat(ui)!: `shaka.ui.FailReasonCode` has been renamed to `shaka.ui.Overlay.FailReasonCode` (deprecated in v3.1.0)

feat(offline)!: `shaka.offline.Storage.prototype.store()` returns `AbortableOperation` instead of `Promise` (deprecated in v3.0.0)

feat(offline)!: `shaka.offline.Storage.prototype.getStoreInProgress()` has been removed; concurrent operations are supported, so callers don't need to check this (deprecated in v3.0.0)

feat!: `shaka.util.Uint8ArrayUtils.equal` has been replaced by `shaka.util.BufferUtils.equal`, which can handle multiple types of buffers (deprecated in v3.0.0)

feat(manifest)!: `shaka.media.SegmentIndex.prototype.destroy()` has been replaced by `release()`, which is synchronous (deprecated in v3.0.0)

feat(manifest)!: `shaka.media.SegmentIterator.prototype.seek()`, which mutates the iterator, has been replaced by `shaka.media.SegmentIndex.getIteratorForTime()` (deprecated in v3.1.0)

feat(manifest)!: `shaka.media.SegmentIndex.prototype.merge()` has become private; use `mergeAndEvict()` instead (deprecated in v3.2.0)

feat(plugin)!: `AbrManager` plugins must implement the `playbackRateChanged()` method (deprecated in v3.0.0)

feat(plugin)!: `shaka.extern.Cue.prototype.spacer` has been replaced by the more clearly-named `lineBreak` (deprecated in v3.1.0)

feat(plugin)!: `IUIElement` plugins must have a `release()` method (not `destroy()`) (deprecated in v3.0.0)
2022-04-11 17:11:40 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
Álvaro Velad Galván 36ca820877 fix: Fix download of some HLS assets (#3934)
Fix download of https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8

The filterManifestByMediaCapabilities method is async, but the code doesn't wait for it to finish before continuing the download process. This PR fix it.

This also fixes a hidden compiler issue caused by the use of an alias for StreamUtils.
2022-02-10 08:36:50 -08:00
Michelle Zhuo 36d0b5484f feat(HLS): Containerless format support
This adds code to allow Shaka Player to play media in sequence
mode, an alternate playback mode that makes the browser ignore
media timestamps, when playing HLS media.
This is important for containerless media formats, as they do not
contain such timestamps.
Changing HLS to not require timestamps also means that we no
longer need to fetch media segments in order to get the start
time, which should lower bandwidth usage and startup delay.
In initial tests, on a simulated 3G network, load latency went down
from an average 3.16s to 2.61s on the HLS version of "Big Buck Bunny:
the Dark Truths of a Video Dev Cartoon"; an improvement of about 17%.

Issue #2337

Change-Id: I507898d74ae30ddfb1bddf8dce643780949fbd9b
2022-02-08 09:34:03 -08:00
Casey Occhialini 221637a66c feat: Add Common Media Client Data (CMCD) logging support (#3662)
Add support for including Common Media Client Data (CMCD) in outgoing requests.

Fixes #3619

NOTE: The following fields have not been implemented: rtp, nrr, nor, dl

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2021-10-20 12:22:41 -07:00
Theodore Abshire aded252e40 feat(offline): Make segment storage stateless.
This refactors the storage mechanism so that the method that
attaches a segment to the manifest is be a stateless async method,
and no longer needs to be in the same session as the method that
stored the manifest.
This is the end of phase one of the work towards allowing Shaka
Player to use background fetch to store assets offline.
This change will allow a service worker to store the segments as
they are downloaded, without having to keep the Shaka Player
instance alive.

Issue #879

Change-Id: I6a3545c57bacaf7229fe8c32669e88c6cc4e4138
2021-09-07 17:05:46 +00:00
Theodore Abshire db8ad31bfb feat(offline): Load init segments first for keys
It is unlikely that we will be able to load DRM sessions inside
the service worker for BG fetch. However, sometimes we have to get
the DRM keys from the init segments.
This changes Storage.downloadSegments_ to download the init segments
first if it looks like they will contain needed init data to create
license requests.
This also fixes a typo that was preventing us from getting init data
from segments, and adds a test that would catch that issue.

Issue #879

Change-Id: Ide859ed0eb2d9208150787f14d915135df681d96
2021-08-12 21:03:04 -07:00
Theodore Abshire 5215f5319f feat(offline): Changed store order of operations.
This changes the order that things happen when the offline storage
mechanism stores a manifest, so that the manifest is made and the
segments are downloaded in separate steps.
This is in preparation for adding background fetch support.

Issue #879

Change-Id: I4451db839b654f6134f06a58c240a9ca98d31a4e
2021-08-10 23:23:13 -07:00
Joey Parrish 32702483eb cleanup: Abort all operations when destroying download manager
This was previously enforced only by the caller, but it makes more
sense to also enforce it at destroy(), which should always have the
last say in cancelation and cleanup.

Change-Id: I8c7a9f967383ed49104f673ba0ab239d28d69766
2021-07-20 03:19:19 +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
Michelle Zhuo 9709086e98 refactor(MediaCap): Remove MediaCapabilities config
Remove "useMediaCapabilities" configuration in the code base.

Issue #1391

Change-Id: I5fc74e31666840828e9dc04a5733db3eaed0d21a
2021-05-21 20:39:06 +00:00
Michelle Zhuo 9a706ef90e feat(CodecPreference): Add preferred codecs config
Adding the "preferredVideoCodecs" and "preferredAudioCodecs"
configuration, so that the application can set their own preferences
when choosing a codec.

Issue: #2179
Change-Id: Ib56aec10613dda9b7dce8e465c5f1d81540c34fd
2021-05-21 18:59:04 +00:00
Michelle Zhuo 79d5fd8ca0 feat(MediaCap): Add preferredDecodingAttributes config
We'll allow users to configure the decoding attributes they prefer when
choosing codecs through the configuration. The attributes include
'smooth', 'powerEfficient' and 'bandwidth'.

For example, if the user configures the field as ['smooth',
'powerEfficient'], we'll filter the variants and keep the smooth ones
first, and if we have more than one available variants, we'll filter and
keep the power efficient variants.
After that, we choose the codecs with lowest bandwidth if we have
multiple codecs available.

Issue #1391

Change-Id: Ief3f6d8ff98fabff5ec99bb0365cdc6a36d2ab2d
2021-05-11 23:50:29 +00:00
Álvaro Velad Galván 69c310cefd fix: Fix STORAGE_LIMIT_REACHED error masked by DOWNLOAD_SIZE_CALLBACK_ERROR (#3396) 2021-05-10 13:39:56 -07:00
Michelle Zhuo 0f0c9409c3 feat(MediaCap): Skip filtering by DrmEngine with MediaCap enabled
When we use decodingInfo() with the drmInfo of the variants to get media
keys, the decodingInfo result can tell us whether the variant's DRM is
supported by the platform. Thus, filterManifestByDrm_() is no longer
needed with MediaCapabilities enabled.

Issue #1391
Closes #3334

Change-Id: I34fbb3e11877f02cae1d435e9dbf274ce0e691dc
2021-04-20 07:48:49 -07:00
Michelle Zhuo 2f65b97b79 feat(MediaCap): Use MediaCapabilities for offline storage
Issue #1391

Change-Id: Ifdf4477d3798ddacf77036f7d85d9cb29438becc
2021-04-07 19:50:51 +00:00
Michelle Zhuo b63a64e4ba feat(MediaCap): Use mediaKeySystemAccess from decodingInfo in DrmEngine
In DrmEngine, previously we created MediaKeySystemConfiguration for the
variants, and called navigator.requestMediaKeySystemAccess() to get the
mediaKeySystemAccess, and set up MediaKeys.

Now we can use the mediaKeySystemAccess from the decodingInfo results of
the variants directly to set up MediaKeys.

Issue #1391

Change-Id: Id93a5e2fed7f6827317ae11644967185fc0cffbd
2021-04-07 19:32:47 +00:00
Vincent Valot b4595d5a59 feat(drm): make dash keySystems configurable (#3276)
Make the DASH keySystems configurable, so that any developer could chose to opt-in for recommendation based on DASH DRM UUID.

Example:
player.configure({
  dash: {
    keySystemsByURI: {
      'urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95': 'com.microsoft.playready.recommendation',
    }
  }
});
2021-04-02 17:33:39 -07:00
Michelle Zhuo aca343bf2c feat(MediaCap): get mediaKeySystemAccess via decodingInfo
In StreamUtils, add a MediaCapabilitiesKeySystemConfiguration
for each key system for the encrypted variant passed to the
decodingInfo API, to get the mediaKeySystemAccess as a part of
the decodingInfo results.

We create a list of mediaDecodingConfigurations for each variant,
and call decodingInfo() with each mediaDecodingConfiguration to
get the mediaKeySystemAccess.

Eventually, we'll use the mediaKeySystemAccess from the
decodingInfo results to replace the call of
navigator.requestMediaKeySystemAccess() in DrmEngine. That will be
in the next CL.

Also, adding MediaCapabilties polyfill with mediaKeysSystemAccess.

Issue #1391

Change-Id: Ied4a27dd8a1ade43209bcf07f21f0c9b31c2693c
2021-03-30 20:26:46 +00:00
Álvaro Velad Galván 06982defa0 feat(thumbnails): Allow download thumbnails (for offline usage) (#3280) 2021-03-30 09:04:30 -07:00
Michelle Zhuo 57ee23812e feat(MediaCap): Use MediaCapabilities for supporting info
In StreamUtils, use MediaCapabilities.decodingInfo() instead of
MediaSource.isTypeSupported() to check if the stream is supported.

MediaCapabilities.decodingInfo() takes an
MediaDecodingConfiguration object as input, and returns a Promise
with a MediaCapabilitiesInfo object. The returned object tells us
whether decoding the media is supported, smooth, and
powerefficient.

Steps:
1. Create a MediaDecodingConfiguration object for each variant as
   the input.
2. Query the decodingInfo API with the config.
3. Get the 'supported' info from the decodingInfo result, to know
   whether the variant is supported.

Issue #1391

Change-Id: I8fc2d3ec6a9868f38269d550d35f45c298faae98
2021-03-12 21:41:53 +00:00
Álvaro Velad Galván b9b3cc8098 feat(dash): Add support for thumbnail tracks (#3145) 2021-03-02 13:36:09 -08:00
Álvaro Velad Galván f067ae10ac Parse spatial audio from manifest (#3148) 2021-02-24 09:28:33 -08:00
Joey Parrish 04003a3891 fix: Fix offline storage after a failure
When we started deduplicating storage by caching download results for
identical init segments, we mistakenly also cached download failures
or aborted operations.

This moves the cache to the stack so that Storage does not cache
content across store() calls.

Closes #2781

Change-Id: Ia02ca72c3da3132ae6c55a3832bafc67613df810
2021-02-18 00:34:42 +00:00
Joey Parrish 7544670ee5 chore: Upgrade eslint
The new eslint found many style errors which have now been corrected.

It also complains a lot about atomic update issues that do not seem to
exist, so that rule has been disabled.

This upgrade will allow us to adopt eslint's "id-denylist" instead of
the older "id-blacklist" rule, the name of which violates new Google
guidelines about respectful language.

Bug: 178203011

Change-Id: Ia65581b96e4dd1331f720fa396183dca020b9caf
2021-02-01 23:36:12 +00:00
Álvaro Velad Galván 54b8f6eaee feat: Add downloadSizeCallback before storing offline (#3049)
When downloading content for storage, it's useful to know how much storage space
will be needed before storing. This is extremely important for mobile devices
that have limited space. See google/shaka-player-embedded#167.

Use the info in the manifest and make HEAD requests to determine the
size of the content we're downloading.

Add a downloadSizeCallback that will be called with the size once we know it.
The callback determine if the content can be downloaded due to its estimated
size.

Closes #3049 .
2021-02-01 11:45:19 -08:00
Álvaro Velad Galván 71372869de feat: Extract HDR metadata from HLS manifests (#3116)
In our isTypeSupported polyfill for Cast, we use the HEVC profile ("hevc1.2") as
an indication of the HDR transfer function, which is not always accurate.
The polyfill should stop assuming that 10-bit color HEVC means HDR, and remove
the extra eotf="smpte2084" parameter. Instead, the manifest parser should
extract HDR profile information from the DASH manifest and pass that info along
through the Stream object.

Issue #3116 .
2021-01-31 23:36:57 -08:00
Joey Parrish 562a2d567b chore: Strictly require jsdoc
This enables the eslint rule requiring jsdocs on all class
declarations, function declarations, and methods.

Unfortunately, there are two problems with this:

1. We don't use class _declarations_, we use class _expressions_,
which are not covered by this rule.  So it does not enforce jsdoc at
the class level.
2. We tend to document a class at the class-level, rather than at the
constructor.  But a constructor counts as a method for eslint, so it
requires docs on the constructor.  There is no way to configure it to
make an exception for trivial constructors.

So for all trivial (no-argument) constructors, we add empty jsdocs:
  /** */
  constructor() {

This was quicker and easier than setting up some alternative plugin in
eslint to make an exception for us.

The good news is that this rule caught several undocumented parameters
and places where the jsdoc comment was malformed.  So fixing those
also improves the compiler's ability to enforce types.

Change-Id: Icbc46ed690c94e53d354648a883119524f8fca45
2021-01-09 02:00:31 +00:00
Álvaro Velad Galván 28f35c251c feat(lowLatency): Add autoLowLatencyMode config (#2861)
With "lowLatencyMode" enabled, "rebufferingGoal" is set to 0.001, and inaccurateManifestTolerance is set to 0 by default. However, in some cases longer rebufferingGoal helps to avoid new rebuffering.
Besides  "lowLatencyMode", this code change adds the  "autoLowLatencyMode" config. When "lowLatencyMode" config is disabled and "autoLowLatencyMode" config is enabled, and the manifest provides low latency features, we automatically activate the lowLatencyMode.
If "lowLatencyMode" is enabled, "autoLowLatencyMode" has no effect.

Issue #1525
2020-11-12 11:07:19 -08:00
Álvaro Velad Galván 01998f3b99 Parse forced subtitles from manifest (#2938)
Issue #2122
Issue #2916
2020-10-27 14:00:48 -07:00
michellezhuo c17f427194 build: Add require and requireType
Add missing require and requireType for compiler upgrade.

Change-Id: Ie21418d93eb70c2213815638d6fd2d784cf6ef2e
2020-09-24 22:20:14 +00:00
Joey Parrish 256f89dff7 fix(cast): Fix Shaka+Cast apps using IndexedDB
The IndexedDB polyfill was preventing Cast apps from using IndexedDB
outside of Shaka Player.  Instead of breaking IDB, we should just
directly disallow offline storage on the Cast platform.

Fixes #2850

b/168565999

Change-Id: Ie504531c412723cc0f93530b2e34000873bfaf32
2020-09-17 18:40:47 +00:00
Theodore Abshire 509e7b046a fix(manifest): Fix embedded captions vanishing.
Previously, on manifest updates, embedded captions would vanish in
single-period live DASH streams.  The problem was based on the
specific point in the load order that we added dummy text streams
to indicate the presence of embedded captions.
This modifies the PlayerInterface for manifest parsers to add a
new method passed in, makeTextStreamsForClosedCaptions, which
must be called by manifest parsers for new video streams.
This also completes an unfinished feature, where new video streams
which add new closed captions would not get corresponding
text streams.

Closes #2811

Change-Id: Iee7499ec950b363cf6839765cc2bd2d01743467d
2020-08-26 15:05:40 -07:00
Michelle Zhuo a22df6d18c feat(lowLatency): Move lowLatencyMode config to streaming configuration
1. Move the config field from ManifestConfiguration to StreamingConfiguration, since StreamingEngine will need it.
2. In manifest parsers, we get the value of lowLatencyMode config from the StreamingConfiguration.

Issue #1525

Change-Id: Iaa961b4e6799ecc1fcf3147b2fb992e86d4b043d
2020-08-20 03:33:46 +00:00
Jacob Trimble dc8b007d56 cleanup: Add missing requires.
This is a port of the internal changes: cr/321495405, cr/321592702,
and cr/321594488.

Change-Id: If6a4c4266ed10a70b01442974dbd19329bb5122e
2020-07-16 10:59:49 -07:00
Joey Parrish 53b6e40c6d fix(offline): Fix progress callbacks in release mode
This works around an apparent compiler bug that caused the invocation
of our progress callbacks to be removed from the compiled output.  To
test for this, the existing progress tests now use the compiled
library.

Closes #2652

Change-Id: I5698cfe0a833696e9cd5c8f8851698e1e66ef901
2020-06-16 00:09:39 +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
Theodore Abshire 8d657140f1 Made ManifestParser.PlayerInterface.filter async.
This is a change in preparation for the adoption of the
MediaCapabilities API.

Related to #1391

Change-Id: If0988aedafe15aa3be794fb977fd8e04e91ca10e
2020-06-04 17:42:27 -07:00
Joey Parrish 5d2dc2daaf Update deprecation timelines (v3.1 => v4.0)
Since we are getting strict about semantic versioning, we can't remove
features in v3.1.  Any backward compatibility we offer will be
maintained until v4.0.

The exception is explicit IE 11 support, which will still be removed
in v3.1.

To help us follow the rules for removal, the Deprecate utility no
longer accepts a minor version argument.

Change-Id: I4dd94a6084e4ed72eeec410eb9aa0ad974d8dac8
2020-06-01 15:57:31 -07:00