Commit Graph

2275 Commits

Author SHA1 Message Date
Sandra Lokshina 43b9567b5b Propagate UI locale changes to ad manager.
Change-Id: I4de1a8a5d16c9b2d8efb71eb94df70ae73fc0c3f
2020-05-26 15:29:10 +00:00
Joey Parrish 6b11f1ecdc Don't preload data on iOS
Instead of calling video.load() and waiting for loadeddata for src=,
wait for loadedmetadata.  This should be a safe event to use in most
cases, and calling video.load() causes native HLS to start preloading
an uncontrollable amount of content.

The exception is if the app sets preload='none' on the video element.
If this happens, we will detect it, log a warning, and avoid the
loadedmetadata event which may never fire.  This is not a scenario we
will officially support, but at least we can prevent a hang in
player.load().

Closes #2483

Change-Id: Id64c8f23cb8fa82bb5c301abafb51f2d9d8730f7
2020-05-21 20:01:32 +00:00
Joey Parrish afcbfb968f Fix annotations in MediaReadyState util
For some reason, the new compiler in the master branch let this by,
but the old compiler in the v2.5.x branch complained when I
cherry-picked the utility.

Change-Id: I1e688f72594b74ed7d2a7c2801eb179b8ec13e8c
2020-05-21 20:01:18 +00:00
Joey Parrish 453ab69a11 Add missing goog.require calls in polyfills
Change-Id: Ieb3724fb8e6b29a1b85e73cb249c1bd5a166f732
2020-05-21 11:46:10 -07:00
Joey Parrish 8a20eb71c1 Work around IE 11 bug in text region positioning
While developing screenshot-based layout tests, it was discovered that
IE 11 did not position VTT/TTML regions in the same way as other
browsers.  This turned out to be caused by a bug in IE's flexbox
implementation in which flex items that are center-positioned can
overflow the flex parent.

This uses the work-around recommended here:
https://github.com/philipwalton/flexbugs/tree/6e720da8#flexbug-2

Closes #2584

Change-Id: I22b9790b8f5798ba757a111d2c502dd5a3415441
2020-05-21 16:19:49 +00:00
Joey Parrish 754f16ab80 Fix subtitles in the center of the video
The margin: auto style centers the element both horizontally and
vertically.  We don't want vertical centering, and we already get
horizontal centering when appropriate through other styles.  So
removing margin: auto is the best fix.

Closes #2524

Change-Id: Icff74e49b3917b50141d1205232ebb0856fbcf16
2020-05-21 16:19:44 +00:00
Oren Me 7e1bb94ef6 Fix PlayReady key ID endianness for TiVo (#2582)
For Tivo Box with Opera browser and Opera Devices SDK inbuilt (Virgin Media STB in UK)
2020-05-20 21:04:00 -07:00
Álvaro Velad Galván 8648a3e0fc Add option to customize the polling of expiration time (#2579)
A large value effectively disables use of the expiration time

Closes #2252
2020-05-20 14:58:35 -07:00
michellezhuo ed0d718ea1 Rename fetchPartialSegment to fetchStartofSegment
In HlsParser, fetchPartialSegment_() is meant to fetch the starting part
of the segment to get the segment's start time, so we don't have to
download the full segment if possible.
PART_SEGMENT_SIZE is the default size of the starting part of the
segment we fetch.

Low Latency HLS introduces 'Partial Segment' as a smaller part of
a regular segment, such as CMAF chunks, and a regular segment might be
divided into many partial segments.

Renaming the original function and field to improve code readability and
avoid any future confusion.

Issue #1525

Change-Id: I593497f6e99e9ffe6128d6976eb7886bbd79679c
2020-05-20 04:18:42 +00:00
Sandra Lokshina 26d2e98959 Add a util for handling media readyState related logic.
Fixes #2555.

Change-Id: I735064952bc425bfb18d6c5681921ae1691eb348
2020-05-19 22:43:13 +00:00
Joey Parrish 48749210b0 Fix shaka.log in debug builds
This fixes the missing shaka.log in debug builds by exporting it
explicitly with the Closure Library API if goog.DEBUG is set.

Closes #2565

Change-Id: I4edd3220997f890058b693cec3bdf295ab5c171c
2020-05-19 18:41:29 +00:00
Sergei Gridasov 2fdbd5b676 Add new option manifest.hls.useFullSegmentsForStartTime (#2575)
If true, forces HlsParser to use a full segment request for determining
start time, in case the server does not support partial requests.

Closes #2556
2020-05-19 08:24:04 -07:00
Joey Parrish 7bce3f452b Add support for null TS packets in HLS
The timestamp parser in our HLS parser should not fail on null TS
packets.  These are indicates by a packet ID of 8191 (0x1fff), and
according to the spec, should be skipped by any receiver.

We will not skip such packets and continue through the segment to find
a PES packet with a timestamp.

In addition to the comments in #2546, I found this document helpful:
https://www.mikrocontroller.net/attachment/27265/mpeg2ts.pdf

Closes #2546

Change-Id: Id9dc16160bbde03969199150ca50122f12de77f4
2020-05-15 20:35:34 +00:00
Álvaro Velad Galván a7d46ee3d1 Add locale setting to AdManager (#2563) 2020-05-15 12:57:32 -07:00
Joey Parrish b9f07f6883 Fix overlapping nested cues in UI text display
The position: 'absolute' style should only be set when other
positioning attributes (left, right, top, bottom) are being set.
Otherwise, the natural layout flow is disturbed, without anything to
replace it.

Closes #2524

Change-Id: I4062c68253218a0f4ace6560a8847381d80c48d5
2020-05-13 21:41:38 +00:00
michellezhuo 8ad0f48939 export shaka.polyfill
@exportInterface is used by the extern generator, but ignored by the
compiler. @export should be used for shaka.polyfill.

Closes #2549 .

Change-Id: I400db152ec8ca222a45a598ab58ddfbe44552443
2020-05-12 17:27:33 -07:00
Joey Parrish ca81d553de Fix text track change after enabling text display
Setting text track visibility to true may, in some cases, require us
to choose a text track.  But we should not do this if one has already
been chosen.

Closes #2553

Change-Id: I53bf1b624b59baae774ffaeb0f0e9eb5467984fc
2020-05-12 19:06:31 +00:00
Joey Parrish 82dc707579 Default cue size to 0, meaning "auto".
When no specific size has been set on a Cue object, the default will
now be 0, which means "auto" size to the text displayer.  If a cue has
no specific width, the background will fit to the text.  If a cue has
an explicit width of 100%, the background will fill the entire
horizontal space of the text container.

This fixes the 100%-width background introduced in Change-Id
I4500b8f637f3f43f48d019d14ef527e75d960fec in #2524.

Fixes #2524

Change-Id: I98caeb89d3da640a8175560810c8ccf2de27a2bb
2020-05-12 17:46:52 +00:00
Álvaro Velad Galván 6f9b36f755 Allow OPUS on Tizen 5 or higher. (#2564) 2020-05-11 15:07:04 -07:00
Joey Parrish 29ed83c180 Add missing export on compatibility method
The destroy method on SegmentIndex is needed for backward
compatiblity, so it should definitely be exported in v2.6, as it was
for v2.5.

Change-Id: Id29faea5ae1719f1ea9201808aa9ce674574afc7
2020-05-08 23:40:57 +00:00
Sandra Lokshina 285cc73b1d Fix period flattening matching by role.
Matches for all streams. Пусть никто не уйдет обиженным!

Closes #2542.

Change-Id: I5cfa25c426c40125ab6532ad62ef08dbe2dc9f81
2020-05-07 19:40:27 +00:00
michellezhuo 252c41dbc3 Fix playback rate display in UI
1. When the video hasn't started playing and is buffering, display
playback rate as 1x.
2. When the video is buffering and the playback rate gets updated,
display the newly selected playback rate.

Closes #2526.

Change-Id: I2e8764cfabdcc675a94e26bd9cd18cbc056a35f9
2020-05-06 16:52:26 -07:00
michellezhuo e74dfde811 Revert "Fix playback rate display in UI"
This reverts commit 604a33d7b9.
Instead of adding another another getter method, we can change the
current behavior of the existing getPlaybackRate() function.

Reopens #2526.

Change-Id: Ic8e60220191ef89fbb2fb242aa7b8263e0409c4b
2020-05-06 15:19:00 -07:00
michellezhuo 604a33d7b9 Fix playback rate display in UI
1. When the video hasn't started playing and is buffering, display
playback rate as 1x.
2. When the video is buffering and the playback rate gets updated,
display the newly selected playback rate.

Closes #2526.

Change-Id: Idf074e402ef8fdd2905dee84dcd5f084f217342e
2020-05-06 19:17:56 +00:00
Joey Parrish 80f53221fd Correct minimum supported Safari version in README
Also add a note to the MSE polyfill about restrictions being applied
in Player as well.  We used to restrict Safari versions only in the
polyfill, and I had forgotten about the other version check.

Closes #2548

Change-Id: I4d2f319939c3a079e7f0ec7134876d91fc425bf4
2020-05-05 14:47:08 -07:00
Sandra Lokshina 9f43011e0b Prefer original source stream when matching for period flattening.
When we construct final streams in period flattening, we start them
off original streams and then combine streams from each period that
best matches the characteristics of the original stream.
The original stream also participates in the matching process, but
it was possible for it not to get selected as the best match if
there were other streams with similar characteristics.
This change adds logic to always prefer the original stream if
it's encountered.

Also, this change adds a bandwidth comparison for audio
streams to ensure the closest streams get matched bandwidth-wise.

Issue #2537.

Change-Id: I5d99a452a12ea1c4bb70fa8aba4bec479ff9d27b
2020-05-05 21:19:20 +00:00
Joey Parrish 77f483b374 Update changelog for v2.5.11
Change-Id: I8f3bc86157c52b7ea505336f5f5aebb2deb2d482
2020-05-05 17:11:22 +00:00
Joey Parrish 5f62f4e779 Clean up use of "self" in arrow function
There is no need to use "self" to capture "this" with arrow functions.

Change-Id: I8d4c2251292d7e27952770b2d45f34fbdfceceb6
2020-05-05 09:13:43 -07:00
michellezhuo 562168a1f6 Set UITextDisplayer as TextDisplayFactory in default config
In player, SimpleTextDisplayer was set as the default TextDisplayer. In
our UI, it changes the configuration to use the UITextDisplayer, and
UITextDisplayer gets constructed with the player. Later in our demo, it
resets the config, so an extra SimpleTextDisplayer gets constructed.
This introduces an extra TextTrack created by SimpleTextDisplayer.

This change sets the UITextDisplayer as the default TextDisplayer in
player's default config.

Closes #2516

Change-Id: I3f653be9fad8b2edbc2fb9de84e8abb327dcfc51
2020-05-04 20:40:18 -07:00
Joey Parrish 74d3dc08fc Add backward compatibility for SegmentIndex release
We changed SegmentIndex from IDestroyable to IReleasable since v2.5.x,
so this adds compatibility for the v2.6 release to avoid breaking
existing apps.

Change-Id: I3a12eec98c9af58fe08f0aec7e499266b70e9b48
2020-05-02 14:56:00 +00:00
Joey Parrish aeaa285916 Fix export annotation on abstract IReleasable
It does not make sense to truly export an abstract interface.  This
should always have used the exportInterface annotation.

Change-Id: If170b41b89728dd549669cee0c606de492b79ad9
2020-05-02 14:55:55 +00:00
Álvaro Velad Galván 46c8ed49bc Add roles in text and audio tracks (src mode) using the kind parameter (#2543) 2020-05-01 10:42:48 -07:00
michellezhuo dc32bd88ba Remove extra text track generated by SimpleTextDisplayer in src= mode
When SimpleTextDisplayer is constructed, a TextTrack is created,
and that cannot be removed. This introduces an extra TextTrack when the
content is played in src= mode.

This is the straight-forward solution to filter the extra TextTrack out
by the label in src= mode.

Issue #2516

Change-Id: I8c417f837e4ad2f90ec779b533c8484de9e22b11
2020-05-01 16:48:04 +00:00
Joey Parrish 1076b78465 Unfork Closure base and update the compiler
The Closure Library's base.js, the Closure Compiler, and the Closure
deps-writer are all now loaded via NPM instead of commiting them
directly to the repo.  This also updates both the library and compiler
to the latest version: 20200406.

We still have a fork of the Closure Library's URI parser.  The latest
upstream version of that has too many dependencies on the rest of the
library to import directly from NPM.

Some internals of the build system have been refactored, and the
"complete" set of files in the build system now includes third_party.

Our forked URI parser does not pass lint checks yet, so the linter
does not run over third_party yet.

A couple of overly-severe sets of compiler checks have been disabled,
since even the latest Closure Library's base.js doesn't pass them.

The script-loader in load.js had to be updated for compatibility with
the new Closure Library.  If you don't return "true" now, Closure's
base.js will stop loading subsequent source files.

Some local externs that we had written are now available from the
compiler, so our local copies have been deleted.

A few type-related changes have been made as well, removing casts that
were necessary with the old compiler, but not necessary with the new
one.

Finally, this corrects some type issues in the tests using the new
"typeof" annotation from the compiler.  This allows us to type a
variable as a class defined elsewhere.  For example, after loading the
compiled library, we can reference compiledShaka.Player, which has the
type "typeof shaka.Player".  The compiler can then type-check all uses
of it in the tests.

Closes #2528 (bad polyfill code generated by the old compiler)

Change-Id: I62ec61e82d4edf342b2c576c2d4f89f11562ee65
2020-04-30 19:32:30 -07:00
Álvaro Velad Galván 71b129977c Parse HLS CHARACTERISTICS attribute (#2534)
Resolves #1598
2020-04-30 14:57:20 -07:00
Álvaro Velad Galván 395700fecb Setup preferredVariantRole and preferredTextRole in src mode (#2535)
Resolves #2531
2020-04-30 14:56:17 -07:00
Joey Parrish 11f3347a48 Fix static method aliases
We used to alias static utility methods by assigning the method itself
to a local variable.  This is not allowed by the new Closure Compiler
release that we are adopting, and for good reason.

The old compiler did not understand the use of "this" in static
methods, but the new one does.  And it turns out that when we start
using "this" in static methods (see #2532), aliasing the method itself
can break everything.

When you refer to "this" in a static method, it refers to the class.
This is really useful in utility classes that have private static
methods they use to perform common tasks.  However, just as it ruins
the value of "this" to alias an instance method, the same is true of
an ES6 class's static method.

The fix is to always alias the class instead of the method.  The new
compiler will simply not let us get away with the old way any more, so
regressions after this are unlikely.

Issue #2528 (compiler upgrade)
Issue #2532 (static "this")

Change-Id: Id800d466e639c7cbcf4aa6fbb05114c772a2229f
2020-04-30 19:28:53 +00:00
Álvaro Velad Galván 6e7b9c363f Add liveLatency to stats (only MSE) (#2508)
Resolves #1872
2020-04-30 12:25:29 -07:00
Joey Parrish 7917348fbe Correct out-of-date comment in lib/offline/
Change-Id: Id3087eeb897a7d4184d5a2b03f469247e1a3f9d1
2020-04-30 17:30:44 +00:00
Joey Parrish a65ef9983b Remove partial exports, broken in new compiler
The old compiler would let us export a static method on a class
without exporting the whole class and its constructor.  The new
compiler silently ignores `@export` for any methods of a non-exported
class.

This means that for the latest Closure Compiler, we must export any
class with exported static methods.  In some cases, these are
non-utility classes with constructors we'd rather not export, but the
constructor is implicitly exported by exporting the class itself.

This was initially caught by the integration tests.  The error wasn't
especially helpful, so I added a try/catch to loadShaka that makes the
error more apparent:
  TypeError: Cannot read property 'registerParserByMime' of undefined

To make sure we do not make this mistake again, I've added a check to
the extern generator, which was already able to detect these types of
classes.  I don't know a compiler-based way to do it, since the
compiler silently ignores the export annotations in these cases.

Issue #2528

Change-Id: I797c75a8098b0bb3cf837588569f878253dec2cf
2020-04-30 17:30:36 +00:00
Joey Parrish 286ff17361 Fix getPlayheadTimeAsDate while loading/buffering
Before we buffer a segment, video.currentTime will be 0, even for live
streams.  So this should not be used in getPlayheadTimeAsDate().
Instead, we should use the Playhead time or the time that will be used
later once content is loaded.

Bug: 149549467

Change-Id: I585fd2364003021839bc16724f41510637489326
2020-04-30 16:22:34 +00:00
Joey Parrish 342d35f4f9 Fix issues with nullability of numbers
Various issues with the nullability of number types led to various
fixes, including:
 - defaulting a nullable number to 0 to avoid propagating a null value
   through calculations
 - adding an assertion or runtime check that something is not null
 - moving an existing null check to before the calculation
 - returning early on null during an iteration
 - changing a nullable number to non-nullable
 - defaulting to NaN instead of null

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I86d516c74a42ee3624c33d7513d2d4c76d3ea589
2020-04-30 16:00:00 +00:00
Joey Parrish 3ac75b04ab Fix IndexedDB types
The built-in externs for IndexedDB in Closure Compiler are missing
some type info.  This overrides them to add what's missing.

This also tweaks type information in a few places in lib/offline/ to
match.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: I97096656f53b426067219e2d4e3aa16f32b87188
2020-04-30 15:59:50 +00:00
Joey Parrish f15f371d20 Fix issues with nullability of strings
Various issues with the nullability of string types led to various
fixes, including:
  - adding an assertion or runtime check that something is not null
  - moving an existing null check to before a calculation
  - converting a test expectation into an assertion that the compiler
    understands (which will still fail the test if the assertion
    fails)

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I11da091c9e7974c8bea84b3b584cbd29d1e320e2
2020-04-29 22:40:49 +00:00
Joey Parrish 50bf467055 Assert that number|string union is number
The new Closure Compiler complains that a number|string union from a
map in MpdUtils is used in a calculation.  In practice, we know that
this specific value is always a number, so we add an assertion to
satisfy the newer compiler's type checks.

Issue #2528

Change-Id: Id12de47d2dd4a12f9cc35879bee8da5ee25cdd70
2020-04-29 22:40:26 +00:00
Joey Parrish 0395b37fd7 Fix missing export
In "Remove extraneous exports" (Change-Id
Iaf142397f31bd927bf942499a79da595f77361d5), I removed an export that
was actually required in the newer compiler.  This replaces the
missing export.

Issue #2528

Change-Id: I3e9ec7085d813365dab917b4712571585d2286c8
2020-04-29 20:45:55 +00:00
Joey Parrish 4dc2c65578 Add type assertions for Errors
In many places, we check error codes on shaka.util.Error.  But the
compiler doesn't know that what is caught in "catch" is that type, so
we add type assertions.

In some cases, we know that other types may also be thrown, so there
are also some runtime checks.  Some of these had to be refactored to
allow the compiler to correctly infer types.

Change-Id: I053bd7e96213c689aae3889315052dd402124690
2020-04-29 10:11:21 -07:00
Joey Parrish 07335d79f6 Fix missing or bad type info
In many places, the implicit type info was insufficient.  For example,
document.createElement returns Element, but the actual return is
always a subclass of Element.  In many cases, we need the compiler to
know that a specific subclass is in use, so that it can correctly
check our use of subclass-specific properties.  Another common pattern
is confusion between Node and Element (which is a subclass of Node).

Almost all of the changes in the demo and UI are Element-related.

In some places, we referred to HTMLMediaElement, used in the Player
API, instead of the more specific HTMLVideoElement in use in our demo.
Since the demo uses video-specific properties, we must use the more
specific type.

Another case is the use of document.createEvent, which returns Event
according to the compiler, but in reality always returns a subclass,
like CustomEvent.

In one case in NetworkingEngine, correcting the type of an
AbortableOperation led to the discovery that we had been incorrectly
accessing a private method of that type.

In goog.Uri, there were several instances of "*" for a type, which the
newer compiler won't accept.  These have all been corrected.

Finally, in some places, we had the wrong nullability on a type.

These were all caught by a compiler upgrade.

Issue #2528

Change-Id: I7f2d070e3da32fe9ff5f444315649f3cbdb5a4a5
2020-04-28 16:51:20 -07:00
Joey Parrish 34cde38108 Fix type info and initData types in EME polyfills
The latest Closure Compiler initially complained about "initData" not
being a known property of "Event".  Correcting the type to
MediaEncryptedEvent exposed a potential bug, which is that we were
assigning Uint8Array in some cases instead of the correct ArrayBuffer.
This fixes both the type of the event and converts the Uint8Arrays to
ArrayBuffers.

This also works around a complaint about "code" on "Error".  We use
"Error" objects as look-alikes for DOMException because there is no
exposed constructor for DOMExceptions.  To satisfy the compiler, we
use square brackets now to set the "code" field on these DOMException
look-alikes.

Finally, this removes the "method" field on certain Errors in the
WebKit EME polyfill.  These must have been leftover from some
debugging, and are not used at all.

Issue #2528

Change-Id: I32c4617b14a30c412d5bc532ec17a46fdc1fea1a
2020-04-28 22:30:19 +00:00
Joey Parrish 15e48e91f3 Fix over-indentation of classes
These classes were over-idented, making formatting more challenging.
I wanted to fix this before making compiler-upgrade-related changes in
these files.

Issue #2528

Change-Id: Ic44448760161a3e724d8c92f41f07c1a0babfa72
2020-04-28 22:30:19 +00:00