Commit Graph

2275 Commits

Author SHA1 Message Date
Álvaro Velad Galván dcf471d85c Calculate approximate segment size based on bandwidth (#2288) 2020-02-17 13:05:38 -08:00
Jacob Trimble c8043f3916 Allow configuring when to fetch prev segment.
We fetch the previous segment in Live streams to combat differences
between the manfiest times and the segment times.  Now this can be
configured so apps with correct manifests can avoid the extra segment
request.

Also, we'll update the buffering state when a segment appends so we
leave the buffering state sooner.

Issue #2291

Change-Id: Id12c8132dc11739e4c8d42cb1f08e6ae7da1a966
2020-02-15 01:52:05 +00:00
Joey Parrish b1e13fa658 Fix async tracks callback
PR #2387 introduced a bug. It awaited the track selection callback,
but that was done in a loop, the results of which were not awaited.
This would cause storage to continue before the complete list of
tracks was available.

Closes #2383

Change-Id: I18a429cf0f40b829020c520c622ffdae8b12622e
2020-02-14 15:13:03 -08:00
Joey Parrish 39eb6cfcbf Always log config errors
This makes the config-rejection logs always-on in compiled mode, to
help application developers notice problems during upgrade.

Found while fixing #2383

Change-Id: I131a1bf8197da394a743e9a121348178d38e5948
2020-02-14 15:13:03 -08:00
Joey Parrish e82b13b311 Fix acceptance of async functions in configuration
The config merging code was rejecting async functions, because the
.constructor field of a function is the "Function" constructor, but
the .constructor field of an async function is the "AsyncFunction"
constructor (not exposed as a global).  This led to the async function
being rejected because it was misdetected as a different type of
"object" than the default value.

The fix is to exclude functions from this constructor-based
type-checking.

Note that the compiler will turn async default values into synchronous
functions in the compiled build, so an async default will appear as a
synchronous function in the compiled build and an async function in
the uncompiled demo.

A synchronous function from the app will always be okay, even if the
library expects async, because "await" will still work.  But if the
library expects a synchronous function, the app should not supply an
async function, because that will return a Promise instead of the
expected type.

This adds a test to show that it is okay to pass a synchronous
function to an async config field, which is important for backward
compatibility as we make trackSelectionCallback async (#2383).
However, because the compiler causes us to lose the native async-ness
of our default values, we can't reject async for sync fields or write
a test for that scenario.

Found while fixing #2383

Change-Id: I62891441ce75bfc887ea13c24212a2ee78f90af4
2020-02-14 15:13:03 -08:00
Joey Parrish dbc9ea9772 Add externs for V1 database format
This will make it easier to ensure conversions are done correctly,
which will be increasingly important as we change the database format
as part of #1339 (period flattening).

Change-Id: I1114b1a9a0d341589f7f1026ec23ad93af38a6b0
2020-02-14 19:59:19 +00:00
Joey Parrish 0406bc0da9 Fix duplicate stream storage in offline content
Since v2.5.0, we have been storing duplicate streams for multi-period
offline content.  For example, instead of storing one stream per
period, a 3-period manifest would have 3 streams per period.  The
segment data would also be duplicated, leading to 3x the storage used
for a 3-period manifest.

This fixes the error for future content and ensures that the correct
number of variants are still shown when this broken content is loaded.

This change also tweaks the frameRate field in the existing database
dumps, which for some reason contained the wrong value for the
existing v1-v3 dumps.  This must have been a bug we fixed already.  To
make the expected results consistent across dumps, the frameRate value
in the old dumps has been updated.

Closes #2389

Change-Id: Ibf7db7543f25ad23cecd12efad1eb039630e381c
2020-02-14 19:59:12 +00:00
Sandra Lokshina 696fdba359 Lowercase mime type when looking up start time for HLS.
Change-Id: I5fa1c2ebc85d364ddcd99c63fc111529fc125527
2020-02-13 22:22:11 +00:00
Jacob Trimble 59b47651ca Add some documentation/links for Error.
This adds some links to where users can find error codes for some of
the browser errors that can happen.

Change-Id: I8ce94307159afb2df9e06813b07593920dcbac1e
2020-02-13 21:59:23 +00:00
Theodore Abshire 8e69a011fa Fix bug with changing cast app id to empty string
If that method was called with an app id that was an empty
string, it would destroy the cast receiver, and then not make a
new one.
This lead to the ChromeCast callbacks all pointing to a destroyed
cast sender, which would then spew out errors whenever session
availability changed.
Normally, changing the app id to empty string doesn't make sense,
but it can happen if someone configures the UI thoughtlessly.
This changes the API callbacks provided to be static, and only
forward the calls to live senders.

Change-Id: I88593532791b3448be3ebdf7ef4df4d38c1bc6e4
2020-02-13 20:40:55 +00:00
Joey Parrish d16865b304 Add tests for v2 and v3 offline content
Before this, we only had tests in place for loading and converting the
v1 format for offline storage.  We had database dumps already for v2
and v3, but no tests exercising them.  This adds some basic tests and
fixes a bug in the loading of expiration times for v2 and v3,
equivalent to what we already had for v1.

Note that here, v1, v2, and v3 do not refer to major versions of Shaka
Player.  Instead, they refer to IndexedDB storage formats used in v2.x
versions of Shaka Player.

Change-Id: If32d1f1131b935eb191101463c4152317e711c5c
2020-02-13 20:30:28 +00:00
Jacob Trimble 78c13fe5cb Add additional logs for buffering and state change.
Issue #2291

Change-Id: Iffb80f9ae1844d2fe5a441bd810faa328f66e357
2020-02-12 23:00:21 +00:00
Álvaro Velad Galván 059e2a9a08 Make trackSelectionCallback async (#2387)
Resolves #2383
2020-02-12 13:11:17 -08:00
michellezhuo cfe1f89171 Add playback speed selection to UI
Closes #2362
Closes #1676

Change-Id: I10184dccab301be7382940e35e36d66dc7a5e2ad
2020-02-12 20:24:03 +00:00
Álvaro Velad Galván bf3c0f721e Fix IMA CS detection (#2386) 2020-02-11 10:50:51 -08:00
Jacob Trimble f7be614c42 Add option to log license exchange.
It is common when debugging protected content to want to see the
license request/response data.  This adds a configuration to easily log
the license request/response data so we can see this without modifying
the code or adding breakpoints.

Change-Id: Ib5db3eaa1447ae8714da935ee459fc7f9ba1e937
2020-02-07 22:22:11 +00:00
Sandra Lokshina c9fe0a28b3 Set player type and version for IMA CS ads.
Change-Id: I3ccfec8e3daba6f44e84f2287f539d8810d157b0
2020-02-07 11:24:23 -08:00
Sandra Lokshina 9c40107cca Clean up a comment about disambiguating IMA SDKs.
Change-Id: If55bb0f6734cc9a788ccf0cec5be231725de9f30
2020-02-06 19:09:09 +00:00
Tijn Porcelijn 5025f2c789 Lower case codec string for IMSC1 Text profile (#2378) (#2381) 2020-02-06 10:54:20 -08:00
Álvaro Velad Galván 32e81c0e79 IMA: disambig between CS and DAI (#2375)
IMA has two separate SDKs for CS and SS ad insertion.
This PR makes sure people don't try to init CS ads when they only have SS SDK
included.
2020-02-06 10:40:35 -08:00
Álvaro Velad Galván d551a15fe5 Disable video when the media element is AUDIO (#2371) 2020-02-06 10:34:13 -08:00
Joey Parrish 9f448710bc Fix DASH SegmentTemplate multi-period regression
The recent DASH refactor broke the details of multi-period segment
references for SegmentTemplate+duration.

This change introduces a corrected universal model for generating
segment references for fixed-duration SegmentTemplate content.  It has
been tested with a variety of streams from third-parties, most notably
the DASH-IF's live simulator.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)
Closes #2111
Bug: 28087927

Change-Id: Ife4e9ae2bb726e24e97dfe153882dabba4c03f2d
2020-02-05 13:37:29 -08:00
LanaIV 3dab79e49c Fix error 4012 RESTRICTIONS_CANNOT_BE_MET for Video Futur platform (#2368)
For Video Futur platform, like for Tizen, key IDs should not be
transformed to big-endian UUIDs, it causes `4012
RESTRICTIONS_CANNOT_BE_MET` error.

Issue #2189
2020-02-05 08:18:13 -08:00
Joey Parrish b979d27fc7 Update changelog for v2.5.9
Change-Id: I18f239240e4179d8fabb73572be74ae219e61ad6
2020-02-04 19:42:17 +00:00
Joey Parrish 917e788271 Fix exception thrown for Chrome & Firefox on iOS
Because we have some polyfills and blacklists that are specific to
Safari and iOS, we need to detect specific versions of Safari and iOS.
The existing detection of Safari/iOS versions was in multiple places,
and did not account for non-Safari browsers on iOS.  This refactor
allows us to correctly detect iOS Chrome, and fixes a fatal exception
thrown in the MediaSource polyfill for all non-Safari browsers on iOS.

Change-Id: Ic88dc1a4c82087054cd4791dbf295b7ea2aeab09
2020-02-04 18:57:51 +00:00
Joey Parrish 65ad9adf2b Fix iPad 13+ detection
Closes #2360

Change-Id: I789ea3fed108a9d05544502b11bfcbf8adb5dc31
2020-02-04 18:48:52 +00:00
Álvaro Velad Galván 323b0f18ad Expose some events of IMA SDK to the app (#2372) 2020-02-03 10:14:06 -08:00
Álvaro Velad Galván 02db99f567 Take into account the playbackRate in bandwidth calculations (#2329)
Resolves #812
2020-01-31 10:03:00 -08:00
Theodore Abshire 6a6a47c5ca Added stats for time taken in load stages.
Change-Id: I3b9c8397999468e606b241f160174a2063b23ae0
2020-01-29 18:57:45 +00:00
Sandra Lokshina a38f61b1b6 Integrate ad experience into the demo page.
Different ads have been added to three assets.
Demo search CSS has been adjusted a bit for better
experience.
Feature name has been changed from "AD" to "ADS" to
reflect the fact that a single asset can have more
than one ad.

Issue #2222:

Change-Id: I12a63b813fb4bac79362f1689b485a824f5a9682
2020-01-29 18:21:16 +00:00
Joey Parrish 37a5e4abd2 Fix PiP polyfill for iOS
This solution involves polyfilling the disablePictureInPicture
attribute on the video element. If the polyfill is installed, it will
show document.pictureInPictureEnabled==true, but
video.disablePictureInPicture will be a getter that does a runtime
check on that specific element using webkitSupportsPresentationMode.

disablePictureInPicture (JS property & HTML attribute) is part of the
PiP spec, so this should be sufficient to disable PiP correctly on iOS
in your application, whether or not you are using our UI.

Closes #2199

Change-Id: Iac9fc7e6cf6d4b0f7576f55af7507348ab2dc02c
2020-01-27 21:04:47 -08:00
Joey Parrish 03d2992f09 Ban iOS < 12
Also:
 - Hide the close button next to a "browser not supported" error
 - Update the support matrix in the README

Closes #1920

Change-Id: Ic3db57a53d800eda3c280b45436eda4f1dae6baa
2020-01-27 20:59:14 -08:00
Sandra Lokshina e9eb292c65 Move native/shaka controls toggle logic to CSS.
Closes #2345

Change-Id: I54bb91899f2f9aa000c43aedbb04ccec22666751
2020-01-27 21:18:13 +00:00
Joey Parrish bce3cfeac2 Fix race condition on HLS parser shutdown
Closes #2138

Change-Id: I30f70874149acacdad57fd387de948ced325cfc9
2020-01-24 23:23:46 +00:00
Joey Parrish 6f3ffe154d Fix StringUtils on Xbox One
Using the spread operator in StringUtils causes issues on Xbox One.
It has something to do with the compiler's polyfill for it.  But
there's no reason we have to use the spread operator instead of
Function.apply in this instance.

Closes #2186

Change-Id: If8b3ff436f852ccae1f1a8c3ee5b7d8c142e15cf
2020-01-24 22:26:26 +00:00
Joey Parrish 139aa4c4db Fix misdetection of HLS audio-only+group as video.
Closes #1875

Change-Id: I09c5f6cda31762992d9d76cadea8037f1245f5c3
2020-01-24 22:24:31 +00:00
michellezhuo 84b8ab4dfe selectAudioLanguage() selects only audio's role
Before, we checked either the audio role or the video role matches the selected role,
but we should check only the audio role when selecting audio language.

Closes #2346

Change-Id: I040f41129dc902cce79c66ba36cb10917fcc8453
2020-01-24 10:07:38 -08:00
Joey Parrish 639137b4e6 Drop dead code and extra export in TextEngine
The appendCues method in TextEngine was completely unused.  Another
method was exported that should not have been.

Change-Id: Icee35d8ccbc5a903cb13409211a8c5770f1c6a87
2020-01-23 12:32:21 -08:00
Sandra Lokshina 36aaa4d253 Stop client-side ads on asset unload.
Before this change, even if an asset was unloaded,
currently playing ads would continue until the end
of the playthrough. If a new asset was loaded,
the presentation wouldn't start until the end
of the ads.
Now stopping the ads is part of the unload proccess.

Issue #2222

Change-Id: I996cde95a826877971812339cad6c328e15fc97e
2020-01-21 11:55:54 -08:00
Joey Parrish 1ee32849e4 Fix skipping of raw format streams in HLS
Raw, containerless streams can't be played yet (#2337), but our logic
for skipping or rejecting them was broken.  This broken logic affected
the whole v2.5.x series of releases up to and including v2.5.8.

This fixes the logic and improves it in several ways:
 - Skip streams that can't be played, instead of rejecting the whole
   master playlist
 - Handle raw AC3 and EC3, in addition to MP3 and AAC
 - Handle and skip WebM+HLS in the same way
 - Add the playlist and segment URLs to
   HLS_COULD_NOT_PARSE_SEGMENT_START_TIME errors

This allows us to re-enable the Apple HLS+TS asset as video-only.

Change-Id: Ia00857d87b085aa7e2b810b0b949993cebabe4ba
2020-01-17 12:28:08 -08:00
Joey Parrish 34376194d9 Update changelog and bump version to v2.5.8
Change-Id: If7e72bf1fa625fe3d4231877e6fcf743fda76130
2020-01-15 23:17:15 +00:00
Joey Parrish 4ffcbc6188 Fix pixelAspectRatio types for backward compatibility
For backward compatibility, the new pixelAspectRatio field in Stream
should be string|undefined rather than being nullable.  This ensures
that manifest parser plugins that do not output that field will still
compile against the externs.

PR #2294

Change-Id: I1aae03994a213c8ce52dc64e8a34bf179045f4fb
2020-01-15 19:04:14 +00:00
Joey Parrish 9427c788c6 Drop pixelAspectRatio from MIME type
This is not a supported query parameter on the Chromecast.

Change-Id: Ia370d046669b61a223c0f36518d7b3df0ebfa6ea
2020-01-15 09:54:20 -08:00
Joey Parrish 1372da934d Drop dead HLS code
This turned up as uncovered in a code coverage report, but it's
actually completely dead code.

Change-Id: I2ec6e83189d68aa3a43b136a20a0bb3e15eb41eb
2020-01-14 00:51:26 +00:00
Joey Parrish d2ccc62ab8 Recognize and reject raw AAC in HLS
This makes the HLS parser recognize raw AAC, but refuse to play it.
It will not play correctly until we have full support for
containerless formats at the MediaSource level.

Closes #1083 (raw AAC, can't do anything more for this right now)
Issue #2337 (full support for containerless formats in general)

Change-Id: I50c7f06a1aa08d515f4d9f74603954a6d015dc29
2020-01-13 22:01:59 +00:00
Joey Parrish 17473d5370 Fix DASH SegmentTemplate IPR regression
In an in-progress DASH stream (in which the content is static, but not
fully available yet), we will need to produce additional segment
references as time progresses.  This was broken recently during
refactors for period flattening, when SegmentTemplate with a fixed
duration was changed to use a SegmentIndex instead of generating
references on-demand.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: I0239335fa7c569063f06f4416982fc5ca7d5873d
2020-01-11 21:29:59 +00:00
Álvaro Velad Galván e0045e5731 Add corruptedFrames to stats (#2328) 2020-01-10 15:46:20 -08:00
Álvaro Velad Galván 6e8ab0132f Add framerate restriction to the config (#2332)
Closes #2068
2020-01-08 11:33:58 -08:00
Leon Chen c6f0a86d73 add manifest.dash.ignoreEmptyAdaptationSet config option (#2330)
Closes #2023
2020-01-08 11:33:22 -08:00
Theodore Abshire 78756198dd Add enum for player event names.
By having an explicit enum, we can make sure there are no typos in
FakeEvent creation calls. This change also allows the cast proxy and
receiver to proxy events based entirely on the enum; that way, they
do not need to maintain their own independent list of events, that
can potentially fall out of sync (see #2318).

Change-Id: I08fa6653f35d86e87efda7fc822c8988688cfcff
2020-01-07 21:35:23 +00:00