Commit Graph

70 Commits

Author SHA1 Message Date
Joey Parrish 7e6a0f38ff fix: Correct license headers in misc. files
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs.  This does not
affect the compiled output, and is only done for consistency.

Issue #2638

Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
2020-06-09 16:13:56 -07:00
Joey Parrish 4eefaa44cb Correct type info in tests
In many places in the tests, we used "Object" or "*" or just no type
at all for various fakes.  These were all flagged by the new Closure
Compiler version we are adopting.

In some other places, we mixed up similar types or had the wrong
nullability on a type.

In still others, types were missing fields.

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I324e0b28f7e30a4102aa26ec2c9901fa9732211b
2020-04-30 16:00:17 +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
Jacob Trimble 011749e95f Standardize argument comments.
This changes the eslint rule to enforce a strict pattern for the
argument comments.  The comment must appear before the argument and
must be /* foo= */.  This still ignores line comments.

Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
2020-01-06 19:40:52 +00:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Joey Parrish f4536acb7e Fix missing tracks, race on time during startup
During startup, there was a race between the video element's ready
state and seeking to the requested start position.  If the video
became ready before the seek to the start position, there could
briefly be 0 tracks.  Reproducing this required a first period start
> 0 and a start position > 0, such that a lookup of the "current"
period during this brief window would return null.

The problem was more likely to be seen on Chromecast, where the time
between load() and the completion of a seek was much larger than on
desktops.

The bug was caused by Playhead, which both seeks to the start position
and manages the concept of "current time", returning the start
position during startup and the video element's position thereafter.

This fixes the race, making sure that startup is not considered
complete by Playhead until the initial seek is over.  This adds an
appropriate regression test and simulated content that can reproduce
the conditions in the original bug report.

Fixes b/138941217
Fixes #2045

Change-Id: Ie8a57283468d88697619349a29e37a804586e5ef
2019-08-14 18:01:56 +00:00
Jacob Trimble 5c35108cb8 Avoid integer for loops.
Issue #1518

Change-Id: I3ba3cb6a439264e823022b2a64e7cdbd265494c7
2019-07-09 17:11:49 +00:00
Jacob Trimble 98aa050de9 Fix addEventListener on some platforms.
Some platforms (e.g. IE11 and Tizen) don't support passing an object as
the third argument to addEventListener.  When we do, it interprets it
as a "true" for the capture value and causes the listener to be called
at the wrong time.  This now detects whether the browser supports this
and calls the boolean version if not.

Fixes #1979

Change-Id: I05b3f5e536a9bcb5c275cac7f243a9ccc88f8149
2019-06-07 16:46:57 +00:00
Michelle Zhuo f67df3d7ad Use eventManager.listen() instead of addEventListener in UI
Issue #1924

Change-Id: I9870d4002fd5f0f99b5de164de41b107af1b3d9b
2019-06-05 16:25:26 -07:00
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Jacob Trimble b87a066832 Add some additional style rules.
- Disallow mixing different types of some operators (e.g. && ||).
- Disallow useless constructors.
- Require a newline between class members.
- Require spacing around arrow functions.
- Require using the compound assignment when possible (e.g. +=).
- Check for possible errors in assignments involving "await".

Change-Id: Ib48167aea61a62b33f0b76bb869abe18398ee5b7
2019-05-08 20:43:07 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Aaron Vaage 40212ec43e Move Trick Play Out of Video Wrapper
This change moves the trick play logic out of the video wrapper so that
it will be more available to the src= code. By doing this, I hope that
we can make it clearer how we are working with the playback rate and
ensure a tighter integration with it.

Issue #816
Issue #997

Change-Id: Id462cda2c5eb82c3713237341424b91891bd38ea
2019-04-11 15:50:11 +00:00
Aaron Vaage 10f85361df Create Playhead Interface
We need to have a playhead for media source and src=, however the
current playhead implementation is tied very tightly to manifests.
Rather than working to refactor playhead, this change defines an
interface and makes the old playhead the Media Source implementation of
the interface.

In a later change the src= version will be introduced to allow playhead
functionality when we don't have a manifest.

Issue #816
Issue #997

Change-Id: Ie74e50839c79c3cd3acf14000849e3d5fa71a42f
2019-03-20 13:10:04 -07:00
Aaron Vaage 7148354aab Refactor Playhead (and below) to use IReleasable
This change takes playhead and its internal members and moves them
over to use the IReleasable interfaces instead of the IDestroyable
interface.

Change-Id: Iddb525725591a29a61ca6b5e2ad519ab708164eb
2019-01-24 01:11:48 +00:00
Jacob Trimble c3ce160217 Consolidate default configs in tests.
Instead of duplicating the default configuration values in each test,
this now uses the default configuration methods.

Change-Id: Ifd2ab349db7903a2acb0d06fed4bd0ccd5050b35
2018-12-27 18:00:55 +00:00
Tomáš Tichý e3739c9495 Add safeSeekOffset to StreamingConfiguration (#1726)
Closes #1723
2018-12-14 11:01:50 -08:00
Jacob Trimble 86a4f30380 Fix gap jumping test failures on IE/Edge/Tizen.
The workaround for Tizen stalls broke the gap-jumping tests on
IE/Edge/Tizen because those platforms will trigger gap jumping when
they are within 0.5 seconds of the gap.  So this adjusts the timer
so it doesn't put the playhead 0.5 seconds from the gap.

Change-Id: I78b0fe199bad209bd5e18263112f6f2971bed119
2018-09-28 10:40:32 -07:00
Jacob Trimble d95b37732b Fix stalls on Tizen TV.
Sometimes the Tizen TV will stall inside a buffered range.  We have
stall-detection logic, but for Tizen's case, it doesn't change the
readyState of the video, so our logic doesn't trigger.  This changes
the logic to work for other kinds of stall too.

This also changes the tests since they waited too long.  Since the
tests would wait for a second, the stall-detection logic would trigger
and move the playhead.  So now the tests move time more frequently to
more accurately represent the moving playhead time.

Fixes: 110093558
Change-Id: If4dd36dd3da309d5a9bc67d539bf2f9cb27df862
2018-09-27 20:21:51 +00:00
Aaron Vaage b0a52a68b8 Do not pass Manifest To Playhead
Changed the playhead constructor to not require a manifest.

Issue #816

Change-Id: If1f626cbfefa67edad39bf050a59bcc7e0696c3a
2018-07-10 16:24:07 -07:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Jacob Trimble 759eef9685 Change goo.gl links to bit.ly.
https://goo.gl is being turned-down, so we can't use it for new URLS.
So we have consistent short links, this converts them to be
https://bit.ly.

Change-Id: I07a86cba807b67157664893341f648023918d0de
2018-06-22 20:20:00 +00:00
theodab 46114b9f90 Stop Playhead.onSeeking_ from infinitely recursing
Playhead.onSeeking_ assumes that seeking is nearly instant;
thus, it has 0.001s tolerance. That works fine on most platforms, but
on some slow platforms (e.g. v1 Chromecasts), this can actually be a
problem. Specifically, it can cause them to get stuck in a loop of
repeatedly seeking, when playing HLS livestreams.
This changes Playhead.onSeeking_ so that it will only attempt to undo
a seek once every second. This way, if running on a slow platform, it
won't get stuck trying to seek to start time.

Closes #1411

Change-Id: Ia4fa6da8bcd90eb04b80d80c3f793bba2a7f382d
2018-06-22 18:32:47 +00:00
Theodore Abshire cd7dcf5286 Added async/await to some of Media tests.
Issue #1337
Change-Id: I0cb350ad87d0b5448d9f87f7823dbf307131108b
2018-06-07 15:03:05 -07:00
theodab a039c66cac Increase MIN_SEEK_RANGE to 3s
On Chromecast, some streams were unable to keep up with the narrow
seek window, and got stuck perpetually seeking forward.
This change increases the seek window to 3 seconds long, which some
initial testing has shown to be the shortest value to play without
uncomfortable choppiness.
Unfortunately, v1 Chromecasts still have issues, even with this.
It seems like they have a separate issue.

Issue #1411

Change-Id: I597315cd418861b18e63a859197a8c2585cb4fd0
2018-04-19 11:28:00 -07:00
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Theodore Abshire c5de6cb115 Add option to force TS transmuxing
Our support for CEA 708 closed captions only works if the container
video file is transmuxed. Because of that, we were not successfully
reading such captions on platforms with native TS support.
This change adds a configuration option to force TS to be transmuxed
even when unnecessary, to account for that situation.
It also adds an integration test to ensure that CEA 708 captions can
be extracted on every platform.

Closes #276

Change-Id: Id8b2a67f2327d1b69c9cdfc443e9592c99baf0db
2018-03-30 11:04:03 -07:00
Joey Parrish 8bab1964e5 Do not defer seek range corrections during seeking
This fixes a weird edge case where StreamingEngine could get stuck
waiting for Playhead.

If StreamingEngine is playing close to the left edge of a live stream,
a manifest update can evict segments it needs.  This causes
StreamingEngine to wait for segment references.  This condition won't,
change, though, until Playhead seeks back into the seek range.

Playhead wouldn't seek back into the seek range until video.seeking
became false, which couldn't happen until StreamingEngine appended
some content that intersected with video.currentTime.

There seems to be no good reason for Playhead to care about the
video.seeking.

This resolves a startup failure while trying to play live streams at
the left edge of the seek range on slow embedded devices such as the
v1 Chromecast.

Bug: 75276747

Change-Id: Iaa084e8220ace174909d3ad91abe0c1eac00cea9
2018-03-28 22:45:52 +00:00
Michelle Zhuo 10e1227051 Fixing Seek after load
Fixing the seek after load not working issue where our customer wants to
start the video from a certain time when playback.
Deleted earlySeekTimer.

Closes #1298.

Change-Id: Ifa293c20c1baf76193948e3b5a7778a2f262222e
2018-03-23 13:34:50 -07:00
Joey Parrish 3e8a83584d Update the compiler to v20180204
This unblocks conversion of tests to async.  We ran into issues in
compiler version v20171203 which have already been fixed upstream.

We are not, however, updating the linter.  The matching linter version
reports errors about our tests not using goog.require, which we do on
purpose.  We will wait to update the linter until we have resolved
that.

This change also fixes issues discovered by the upgraded compiler:
  1. Missing property definition in playhead_unit
  2. Wrong type name in storage_unit
  3. Wrong type name in FakeManifestParser

Change-Id: I4ba3f43e6a6471e182a69c85cfc619de3380c559
2018-03-21 13:57:46 -07:00
Joey Parrish 0c217391c9 Add alwaysStreamText config
This will allow text streaming to work correctly with browser native
controls.

Closes #1332

Change-Id: If11ba67957babad8dea23759aab9004d891aaf6b
2018-03-15 03:49:44 -07:00
Michelle Zhuo 7568d774df Start playing live stream with certain offset from live edge
To allow playing live stream from certain offset from live edge, we
allow setting the value of opt_startTime parameter for player's load()
function.

Closes #1178.

Change-Id: I23a2375ba8ee5946791ee79714ed017c4e677c9a
2018-03-09 21:42:59 +00:00
Jacob Trimble 7edb11ba39 Don't repeatedly seek for zero-width seek range.
When there is a zero-width seek range, don't repeatedly try to
reposition the playhead to keep within that range.  This simply adds a
small buffer around zero-width seek ranges.

Closes #1331

Change-Id: I87b787f1454750eaa2caafa7c23cb9e37d3328e6
2018-03-07 19:02:05 +00:00
Jacob Trimble 624acc66b8 Add curly braces to all blocks.
Google style guide requires adding curly braces to all block statements
even if it is only has one line.  This fixes it by using eslint's
--fix flag followed by running clang-format to reformat the change.

Change-Id: Idc086c2aa8c02df5ef8b2140a11bfb9128eeb4bd
2018-02-21 11:23:34 -08:00
Jacob Trimble 909c7a8fde Don't jump extremely small gaps.
The browser should handle extremely small gaps for us.  So having the
browser handle these gaps, this avoids an infinite loop if there are
rounding errors.

Closes #1309

Change-Id: I365f44185f570571f6b093bdcaad92fef49b5b16
2018-02-21 18:42:35 +00:00
Jacob Trimble cfbbe485e9 Use seek range in Playhead.
Rather than using the availability window, Playhead should use the
seek range to restrict the playhead's position.

Closes #1224

Change-Id: I8612bfafb53bbb214e32aae2d71af52d748a3aee
2018-02-20 23:42:12 +00:00
Jacob Trimble b2bde18a3d Convert 'var' to 'let'/'const' (5 of 9).
This is part of a change to convert all usages of 'var' with either
'let' or 'const'.  This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.

Change-Id: If4792c1bd3d5a82c24a4b2f0f84790d4eed22e67
2018-02-20 11:26:46 -08:00
Jacob Trimble 917a01df5b Split Playhead responsibilities.
This splits some of the independent code from Playhead into several
new helper classes.  This allows Playhead to be simpler and easier to
understand.

This keeps the new behaviors and classes as private pieces of Playhead
to keep Playhead conceptually in-charge of handing the Playhead.  It
still has the same responsibilities, but the code is split into other
files.

Issue #1224

Change-Id: Ia828f902ba9490d128f4ca9cb1e34119ec93f188
2018-02-20 18:10:22 +00:00
Jacob Trimble 383867cde5 Remove getSegmentAvailabilityDuration.
This was only being used in tests which verified its own behavior.  This
removes the useless method to make tests that use mock
PresentationTimeline cleaner.  Code should use the availability window
methods indead of explicitly using the availability duration.

Change-Id: I0a9be8f319977ea8eb3ab50c65e458f49d9a3a75
2018-02-09 11:04:02 -08:00
theodab 8ad48fafed Don't gap jump until seeking event fires
This changes onPollGapJump_ to not gap jump if the video is seeking
but a seeking event has not yet occurred.
This also adds a unit test that tests for the bug in issue #1061.

Closes #1061

Change-Id: I8662f5878006ed8626ca8df55f0506edb2dd970e
2018-01-05 22:22:28 +00:00
Joey Parrish 719ba3a2ef Do not allow seeking/startup at duration
Seeking to or starting playback at the duration does not work well
across browsers.  Any seek or startup time at or past the duration of
VOD or IPR content will be bumped back by a configurable amount
(default 1s).

Closes #1014
Bug: 69874888

Change-Id: I6d21ecd8e211f0f823a093b8eb8b95d329b4385f
2017-12-05 18:08:51 +00:00
Joey Parrish 07860ba4c7 Fix race condition between metadata and timeupdate
On Edge & IE, the timing of "loadedmetadata" and "timeupdate" events
is different, and exposed a race condition in the fix for #1105.
This solves the race by canceling any pending "early seek" handling
once "loadedmetadata" fires.

A fix for the fix of issue #1105

Change-Id: I5587a72e12c6b28beb0b3ea36f2665a0f1e39f08
2017-11-28 22:10:40 +00:00
Michelle Zhuo e6f675a448 Stop buffering live stream when paused
We shall not buffer live stream, when the video is paused and the
playhead falls out of the seek range.

Closes #1121.

Change-Id: I66bbe1e62017f6ae8d121f072f324763f73da0f4
2017-11-28 10:44:35 -08:00
Joey Parrish d1070b4026 Allow Playhead to recover from drift
There are two ways Playhead should be able to recover from a drifting
stream:

1. Wait until the initial position is available
2. Seek to another position

Neither of these was working.  For one, we couldn't detect seeks
before content was loaded.  For another, we were constantly updating
the initial streaming position, so a drifted stream would never catch
up to our expectations.

This fixes both issues so that a drifting stream can at least recover.

Relates to issue #999 (drift tolerance)

Closes #1105

Change-Id: I8d2eedcff25b92b42ecd2e1f361d45ecbddd26ba
2017-11-27 22:43:24 +00:00
Jacob Trimble 59b48f0c8e Revert "Prevent gap jumping while seeking."
This also changes the tests so they mirror the |video.seeking|
property to reveal the problem that change created.  That change
broke seeking into gaps and gaps before the start.

Issue #1149
Issue #1150
Reopens #1061

Change-Id: I18fb65b1529acdacd0becd77078780625e0a955b
2017-11-22 23:01:36 +00:00
Jacob Trimble 5cb720436c Allow setting opt_startTime to 0.
Closes #1069

Change-Id: I345626ec5418cc3d15935a8a0bc6f1d4449832e7
2017-10-16 23:19:15 +00:00
Joey Parrish 2af0de2adb Move streaming retry logic into callback
Closes #960

Change-Id: Ieeacbf2e25f53a5af25a1de1935085e43457a092
2017-08-10 20:27:53 +00:00
Joey Parrish 4b6e1fda65 Fix native control seeking on Edge
When the user seeks using Edge's native controls, Edge sets
playbackRate to 0 first.  This confused Playhead and resulted in a
playbackRate stuck at 0 after the seek.

To fix it, we filter out rate changes to 0 in the code that remembers
the previous setting during a buffering event.

Closes #951

Change-Id: Ia7a9a2a6d65dcf2d74ea6fb4d92594070a1ebe6a
2017-08-10 18:12:21 +00:00
Theodore Abshire 98c4c14093 Fixes livestreams with no seek range.
When the availability window of a live stream is very narrow, in
at least some cases, the playhead can end up starting before the
availability window. In that case, the stream will fail to load unless
gap jumping is set up to jump long gaps.
This makes the playhead jump ahead if it falls behind the availability
window, to avoid that situation (and others that might have the same
effect.)

Closes #916

Change-Id: I87f8c70ba6053d3524a1546e57d55cb6528cc683
2017-08-07 12:11:49 -07:00
Jacob Trimble 78fc6d9b36 Disallow unknown properties (2/5).
This is part of adding a new conformance rule to add additional type
safety.  This will disallow using properties of unknown types or using
unknown properties.

The first parts will be fixing errors caused by the new rule.  These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.

Change-Id: I48335fc6659d3c33a6d55b00d087b59410c79cf7
2017-06-27 19:47:42 +00:00