Commit Graph

2168 Commits

Author SHA1 Message Date
Joey Parrish 13202cecae Fix storage cell constructor args
When we changed the constructors for the V2 cells with the
introduction of V5 format, these call sites didn't get updated.  This
doesn't seem to be a user-facing bug, and did not affect any releases.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: I77228d17631ef44a6b85a81b88054790461617bc
2020-04-28 20:57:59 +00:00
Joey Parrish 8867db6773 Fix implicit string-to-number conversions
This was caught by a compiler upgrade.

Issue #2528

Change-Id: Ica262703aa30dce2e59c139c88f3c1e74d5d9e2f
2020-04-27 17:33:06 -07:00
michellezhuo fb0d819f1c Verify period flattening with multiple representations of the same
resolution

Closes #2517

Change-Id: I7102153f2df83b8ad66411e709fdaf5a5a043b53
2020-04-27 18:41:04 +00:00
Joey Parrish 0911a6b3d0 Fix bad reference to frameRate on Variant
This is only defined on Stream, not Variant.  This bug has was
introduced in PR #2332 and the v2.5.8 release and affects v2.5.8 -
v2.5.10.  The corresponding feature (frameRate restrictions) has
actually never worked.

This was caught by a compiler upgrade which is still in progress.

Change-Id: I0409d9be8d3f6eb0794775ca29f28b98208bab4f
2020-04-27 18:05:02 +00:00
Joey Parrish 423e6c98e8 Add backward compatibility shim for exported util
This method (shaka.util.Uint8ArrayUtils.equal) was removed between
v2.5.0 and v2.6, but could be in use by applications.  This change
adds the utility method back, with a deprecation warning.

Change-Id: Ifd780759ae389e766c1889a83545cfda8969e76b
2020-04-27 17:39:24 +00:00
Álvaro Velad Galván 1e3e9f479d Support for cuechange events in HLS playback (#2476) 2020-04-27 10:04:57 -07:00
Joey Parrish 3d29160309 Remove extraneous exports
These exports are not needed by the application.  Some of them may
have been added to work around the extern generator's lack of support
for partially-exported classes.

Change-Id: Iaf142397f31bd927bf942499a79da595f77361d5
2020-04-27 16:58:14 +00:00
Álvaro Velad Galván 6d91f90558 Parse metadata in mux transmuxer (#2501) 2020-04-27 09:44:23 -07:00
Dong-heun ebae1158cf Fix error 4012 RESTRICTIONS_CANNOT_BE_MET for webOS TV platform (#2513)
For webOS TV 2020 platform, like for Tizen, key IDs should not be
transformed to big-endian UUIDs, it causes `4012
RESTRICTIONS_CANNOT_BE_MET` error.

Closes #2512
2020-04-24 14:16:54 -07:00
Theodore Abshire 087c1ba247 Allow offline downloads to be aborted.
You can either abort downloads one at a time, using the
AbortableOperation interface, or you can implicitly abort them all at
once by destroying the storage instance.

Closes #2417
Closes #1362
Issue #1301

Change-Id: I0ba102e5bf60a063f0e2f6ecd3f135445226996f
2020-04-24 20:43:54 +00:00
Álvaro Velad Galván ee1683fe2e Setup preferredAudioLanguage and preferredTextLanguage in src mode (#2506)
Resolves #2269
2020-04-24 13:25:28 -07:00
Álvaro Velad Galván f9f48417ab Filter metadata textracks in player APIs for src mode (#2519)
Resolves #2518
2020-04-24 12:56:52 -07:00
Álvaro Velad Galván e246855c63 Add variable substitution support to HLS parser (#2509)
Resolves #1561
2020-04-24 12:37:11 -07:00
Joey Parrish db42d7e436 Revert "Fix bogus text track in UI with src= mode"
This partially reverts commit ad3d4604, because that fix seems to have
caused #2523.

This also adds a regression test for #2523.

Reopens #2516
Closes #2523

Change-Id: If3ed5942fff029f522e24048edcb4a04e7cc30e9
2020-04-23 21:33:28 +00:00
Álvaro Velad Galván 9104c1d68e Fix metadata tracks for live server side ad streams (#2500) 2020-04-23 14:09:54 -07:00
Joey Parrish 8796415d87 Quote exported enum keys
All other enum keys are quoted, and these should be, too.

Change-Id: If1776d9611b1102d65bab6584b19aced82b4ba81
2020-04-22 11:54:30 -07:00
Sandra Lokshina e8d027d7a5 Ads: move setting ad container to IMA StreamManager constructor.
The setClickElement() method we've been using for this is
getting deprecated, and IMA recommends setting this through
the constuctor instead.

Change-Id: I7dd5c5e2644e2b270996be7fe2b1390e41009505
2020-04-22 17:32:25 +00:00
Joey Parrish ad3d4604af Fix bogus text track in UI with src= mode
When the non-UI TextDisplayer is constructed, it creates an extra
TextTrack that can never be removed.  This leads to a bogus text track
showing up in the UI when content is played in src= mode.

This changes the TextDisplayer to disable the extra TextTrack (since
there is no API to remove it) and changes the Player to ignore
disabled TextTracks when generating a track list for src= playbacks.

Closes #2516

Change-Id: I2e651f737445049da5fa46a798a2bc0751de2822
2020-04-21 13:26:14 -07:00
michellezhuo 030147c7f4 Avoid displaying duplicate vtt cues
Closes #2497

Change-Id: Ibc4de196f500d8685244217f9a056d8b12c05f8a
2020-04-20 22:58:45 +00:00
Joey Parrish f0caf4067c Fix serialization of Error objects over Cast
When the Cast receiver throws an Error or rejects a Promise with a
non-Shaka Error, we need to represent it to the sender in a reasonable
way.  Otherwise, it can be very difficult to debug.

Related to the investigation of #2487

Change-Id: Ia58dd1e1e56ee93bea9afc9d368084d53c381db3
2020-04-17 21:41:01 +00:00
Joey Parrish 7ea5fbe60d Fix PlayRateController leak
We were leaking one PlayRateController instance per playback, with
each one running an infinite repeating timer that fired every 250 ms.

In a single run of our tests, this bug fix gets triggered 116 times.
That means we had, by the end of a test run, 116 timers with callbacks
every 250 ms.  Each would have to complete in 2.1 ms to avoid bogging
down the browser's JavaScript thread.

This bug could have had a significant performance impact in the field,
depending on usage patterns, and was part of v2.5.0 - v2.5.10.

I found this by running the Karma/Jasmine tests in a foreground
browser tab at http://localhost:9876/debug.html .  After the tests
completed, I hit the "pause" button in the JS debugger, and found that
this periodic timer was still running.

After the fix, pausing after the test run is complete does nothing.
There is no JavaScript executing beyond the end of the tests.

Change-Id: I87b402e733b1ccaa5e696d52d31cfe00ef12cfe0
2020-04-17 02:03:32 +00:00
michellezhuo 1f30becf13 Display nested cues in SimpleTextDisplayer
Closes #2263

Change-Id: I18af70e4ff69a1d27ef462678c0c49bacb74553c
2020-04-16 18:59:44 +00:00
Sandra Lokshina 09895652b3 Set shaka's player name and version in DAI IMA for tracking.
Issue #2469.

Change-Id: I1a71349b2f61c2a03a496cd4e7d1109474ffe4d5
2020-04-14 20:17:58 +00:00
Joey Parrish 2f6ed0eb77 Recover from timed-out Cast connection
When a mobile device goes idle, the Cast connection can be terminated
without explicitly closing it.  When this happens, the Cast session is
unusable and throws exceptions.

This changes CastSender to correctly detect and recover from such a
problem by disconnecting explicitly and dispatching an Error to the
application.

This also fixes the disconnection process so that playback can be
correctly resumed on the local device.

Closes #2446

Change-Id: I59f51a1e911199eee22693e7db4ab39855de0298
2020-04-13 18:30:43 +00:00
kumarashu123 6a04bde61f Fix TTML position parsing (#2493)
The TTML parser would accept 100%, but not 100.0%.

This makes the parser more flexible, so even 100.00000% is valid.

Fixes #2477
2020-04-13 09:43:12 -07:00
Theodore Abshire 9af3b9e247 Fix src= load promise callback on iOS Safari.
For whatever reason, on iOS Safari, the 'loadeddata' and
'loadedmetadata' events don't fire until the video actually starts
to play. That is to say, until the play button is pressed or the load
method is called (or the video is set to autoplay).
This changes the src= playback to call video.load.

Closes #2483

Change-Id: I49eb119a01d88073532496b5af062bbbcfcfa9fa
2020-04-12 00:31:44 +00:00
Álvaro Velad Galván 2807971e4e Add creationTime to offline assets (#2406) 2020-04-10 09:58:45 -07:00
Theodore Abshire a2a988d876 Allow for multiple concurrent storage operations.
In the process, this removes the in-progress flag, which should fix
issues where the storage instance can't be re-used after an error.

Closes #1432
Closes #2432

Change-Id: I51018e170fb9ab262b5c70125a03d979c8ccfb08
2020-04-10 04:33:11 +00:00
Joey Parrish d562761a3f Fix exception when enabling CEA text
This exception was thrown when we attempted to set up a
SegmentIterator on CEA tracks.  Because they do not have their own
segments, this is not possible.  The fix is to exclude CEA tracks from
this step.

Discovered while debugging #2395, but seems to be unrelated.

This bug does not affect any release versions.

Change-Id: I534b19139d88cc7ad2d6167611c04f400308a71b
2020-04-10 03:52:57 +00:00
Joey Parrish ba5d062be6 Fix missing segments in offline storage
In Change-Id If885e828b4761528e40abdbc601a11cf13849a1e, I fixed a
memory leak, but broke offline storage.

The fix for the memory leak was to release SegmentIndexes and
SegmentReferences when the DASH parser stops, but offline storage was
stopping the parser before making use of the parsed manifest.

This changes offline storage to keep the parser alive until after the
storage operation is complete.

This bug did not affect any release versions.

Change-Id: I88b86d250b4407cc0740d35eaf4a7ef3d5a67798
2020-04-09 17:40:44 -07:00
michellezhuo 734d129fcd Add Support for HLS Discontinuity
Closes #2397
Closes #1335

Change-Id: I6f540c42c72bf0ae36239b682d4016cca3981c0f
2020-04-09 14:59:42 -07:00
Joey Parrish e24fec4b08 Flatten periods
This creates a new utility used by DashParser and old offline DB
formats to combine Streams across Periods.  This allows multi-Period
DASH content to be played without period-specific structures in the
manifest format, StreamingEngine, or Player.  This also makes the
Tracks stable across Periods.

Closes #1339 (flatten periods)
Closes #1698 (rapid period transitions issue)
Closes #856 (audio change causes bitrate change)

Change-Id: Icb04c8e47e36eacf7ac024a5063130d85a115e54
2020-04-09 19:22:16 +00:00
Joey Parrish c84676c7ee Make offline manifest conversion async
This will be used in period-flattening, where we will need to create
segment indexes before combining Streams.  Although the operation
would be synchronous for DB types, the general interface will need to
be async.

Issue #1339

Change-Id: Ibedb267118462cbaf3ca599ab6a67c8f355965f6
2020-04-09 19:22:16 +00:00
Joey Parrish 6e3dfa40ba Deduplicate key IDs with Set
When period-flattening combines Streams, key ID arrays would get very
long with duplicates.

This changes keyIds in the manifest and offline structures from Array
to Set.

Issue #1339

Change-Id: I003d23e567efafa771ecd2ad597900181604ad18
2020-04-09 19:22:16 +00:00
Joey Parrish c4a5513ca5 Rename offline StreamDB.contentType to type
This brings the field name in line with the Stream objects from the
manifest types, allowing for more general processing of Stream and
StreamDB for period-flattening.

Issue #1339

Change-Id: Ic5d0e5d69a6560d475a19f5d3ecb0b1b40b8d271
2020-04-09 19:22:16 +00:00
Joey Parrish e8ac57f36c Move drmInfos array to Stream
Period-flattening will concatenate Stream objects, so this information
should be available per-Stream instead of at the Variant level.

Issue #1339

Change-Id: I96195fea48cab1e4a349b2ab0b16064a443e928a
2020-04-09 19:22:16 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
michellezhuo 3b52166f56 Remove support for custom DASH ContentProtection schemas
Remove manifest.dash.customScheme callback function since it's no longer used.

Closes #2356

Change-Id: I6d08fcf97cff1bf2985e7c660d74efcd767eaed9
2020-04-09 09:11:20 -07:00
Joey Parrish fe36234951 Fix buffer check in StallDetector
mediaElement.buffered can never be null.  If nothing is buffered,
buffered.length will be 0.

The bug has been in this file since it was created in January 2019.
This affects all v2.5.x releases up to v2.5.10.

Hopefully this will address some seeking issues on Chromecast, though
that has not yet been confirmed.

Closes #1809

Change-Id: Iccc49d299cdac9fccdafdfc2d35e5b2376cff644
2020-04-08 21:31:10 +00:00
Joey Parrish 94f07dd410 Fix ratechange events w/ src= playback
The Player ratechange event is a filtered version of the video
ratechange event.  This is necessary because we manipulate
playbackRate as part of our buffering state management.

The UI uses this Player ratechange event to drive the playback rate UI
menu, but the event was not firing for src= playbacks (native HLS or
plain MP4s).

This fixes the ratechange event for src= playbacks, and also fixes a
small mistake in the MediaSource setup that could have resulted in the
ratechange event being triggered before playRateController_ was
created.

Closes #2488

Change-Id: If85e489d681cfbb1ae6141b490d82264e1d932bd
2020-04-07 23:36:07 +00:00
Jacob Trimble 7ae6fc7d93 Fix FairPlay encrypted event handling.
The 'webkitkeyneeded' and 'encrypted' events send similar data, but
they were incompatible with each other and our transform handling.
This makes our polyfill produce the same format as the browser for
cases where the browser may only fire the old event.  This also makes
our utilities work with the new format.

The 'webkitkeyneeded' event was a length-prefixed UTF-16 string while
the 'encrypted' event was just a UTF-8 string.

This also makes a breaking change in the transform callback to pass the
init data type.  This shouldn't break anyone that only uses the first
argument; the second argument was mainly added so we could have the
default transform work without knowing anything.

This change could also break people who use custom transform functions.
The init data format is changing, which could break people who read
it directly.  If they follow the tutorial and use our utilities, it
shouldn't break.  This also updates the tutorial to match the new format
and be more clear about the format.

Fixes #2214

Change-Id: I006382028e828e31e20e085114fd7fd85c0e1eaa
2020-04-07 16:59:27 +00:00
Joey Parrish 1573f9cea1 Fix race and exception in StreamingEngine
Playing content in our demo with my WiFi acting CRAZY, I found an
exception in StreamingEngine.  The bad connection seems to have
exacerbated and exposed a race condition that can be triggered when
the active stream is switched during an async appendBuffer() call.

The fix is to be careful not to assume that the mediaState object is
the same as it was after the async call.  If mediaState.stream has
changed, we should not manipulate mediaState.segmentIterator, which
may refer to a different Stream or may be null.

This bug does not affect any release versions.

Change-Id: I3d00009e78978cae95b47bb9f862fca4294b7b20
2020-04-07 16:38:33 +00:00
Joey Parrish 51779cf3be Fix memory leak in live streams
Live stream tests call stop() on their manifest parsers, but nobody
was calling release() on the SegmentIndex objects.  This meant they
could continue to generate SegmentReference objects indefinitely.

In production, the Player releases all SegmentIndex objects.  But if
some Variants had been removed due to filtering, they would never be
stopped.

By having DashParser release all SegmentIndexes it generated, we can
ensure that there are no timers running after the parser is stopped.

This bug was introduced in the master branch and has not appeared in
any release.

Change-Id: If885e828b4761528e40abdbc601a11cf13849a1e
2020-04-04 03:46:15 +00:00
Theodore Abshire ae568e0649 Fix offline picking high-bandwidth codecs.
When playing an asset, the player will first choose a codec, based
on the lowest average bandwidth.
However, the storage mechanism did not have any such filtering;
instead, all it did (if using the default track filtering plugin) was
pick the middle-bandwidth audio track. This lead to it sometimes making
different codec decisions than the player would have.
This CL breaks the codec filtering logic out into a helper function, and
calls it both for playback and storage.

It also adds headers comments to some functions in the demo page.

Closes #2390

Change-Id: I09f1a24753121afd0e7500577c0f64ccffe5a4d1
2020-04-02 22:46:10 +00:00
Joey Parrish bf5e0e254b Fix SegmentIterator after evict
After evicting segments from a SegmentIndex, SegmentIterator should no
longer start at 0.  So instead of starting at 0, start at the earliest
position, which is returned by find(0).

Change-Id: I512ffb10a7f09f52930c5afbd783db063e9ebd66
2020-04-02 21:46:13 +00:00
Joey Parrish 6d120bda49 Fix language normalization with native HLS
To make language selection work correctly with native HLS on Safari,
we should normalize both the input language and the language we get
from the browser's track list.  Though our HLS implementation
normalizes languages as we read them from the playlist, Apple's
implementation does not.

Fixes #2480

Change-Id: I213b5992fe7921627d691cc958951e31bdff59f8
2020-04-01 21:33:07 -07:00
Joey Parrish 0416df3d76 Minor style cleanup in TTML parser
I find this much more readable.

Change-Id: I80ab374e5cef8cb50a4fc15c6fdae006fd78823c
2020-04-01 18:29:12 +00:00
Álvaro Velad Galván 907c75f832 Add loadTimeSeconds to ads stats
Issue #2475
2020-04-01 10:55:18 -07:00
Álvaro Velad Galván ad33625a11 Add non-standard DASH PlayReady UUID (#2474)
Resolves #2440
2020-04-01 09:54:42 -07:00
Joey Parrish f151f55da9 Fix nested TTML cues with non-ASCII characters
A regex in the TTML parser was looking for "word" characters (\w),
which is short-hand for non-whitespace ASCII characters, and excludes
Unicode characters and symbols from non-English languages.

There is a better option in Regex in some browsers, which is /\p{L}/u.
This is not supported universally yet, and defining an equivalent
regex constant using character codes is over 4kB of extra code.

It seems that the original author of that code meant "word" (\w) in
the sense of "non-whitespace" (\S), so we can just use \S instead.

This change also adds a regression test that doesn't depend on the
specifics of the regular expression used.

Closes #2478

Change-Id: I794258a797ba5d26a7bd8fc0a5244adc70c8a1ef
2020-04-01 16:08:48 +00:00