Commit Graph

117 Commits

Author SHA1 Message Date
Joey Parrish f86e7208ee style: Re-enable the prefer-spread eslint rule
The prefer-spread rule to prevent use of apply() was disabled, but we
had another custom rule that also prevented the use of apply().  This
re-enables the standard rule.

Issue #2639

Change-Id: Ic3778d7267deb6cd5ed49282ea43bb84ad076060
2020-06-15 23:53:39 +00:00
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
Álvaro Velad Galván bafe18fadd Add maxSegmentDuration to stats (#2613)
Resolves #2610
2020-06-03 11:51:59 -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 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 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 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
Joey Parrish 817c2157a8 Fix test flake in very large MPD test
While fixing cherry-picks for v2.5.x, I found that the test for
parsing very large MPDs would fail on that branch because it referred
to segments that do not exist locally.  This changes the MPD to refer
to local segments which can be loaded, which is important on v2.5.x
where the load() call can fail if the first segment fails.

This tweak makes the test work universally on both branches.

Change-Id: I97284aa964034bf5768abdb97f06b2a1e371d865
2020-03-18 15:41:49 -07:00
Theodore Abshire daa316643a Fix compiled release version of supportsChunkSize.
In the code for supportsChunkSize, we test to see if a given chunk
size is supported by array to string conversion by trying to perform an
operation on a Uint8Array of that size without throwing an error.
However, the result of that operation was only ever referenced inside an
assert. Because asserts are compiled out in release builds, the
result of that operation was not being used... and thus, the entire
call was being compiled out.
This changes the return value of the function to use the result of the
operation, thus preventing it from being compiled out.
This also adds a unit test that will detect this problem in the future.

Closes #2433

Change-Id: If3048531afc460beb16de0dda7f7fcbd5499fdaf
2020-03-11 18:17:31 +00:00
Joey Parrish 06a44fae8e Fix adaptation event tests in uncompiled mode
These tests failed an assertion because they did not respect the rules
for AbrManager.  In compiled mode, this went unnoticed because asserts
are removed in the compiled bundle.  But when running tests in
uncompiled mode, these would always fail the assertion and therefore
fail the test.

Change-Id: I44700d118f3f45ebcc955d9306deaca4815b902e
2020-03-03 14:42:48 -08:00
Jacob Trimble 3f63021a2f Avoid using "new" with factories.
Instead of having the "factories" use "new" to construct them, now they
will be plain functions.

Closes #1521

Change-Id: Ia6151ad679a78a5c6db128d43094c82add0af348
2020-02-19 09:57:51 -08:00
Jacob Trimble 9e975a2f6d Don't fire 'adaptation' event when not switching.
Closes #2392

Change-Id: Ib3af4fa465bc8502dfe751856eda1a27e038b304
2020-02-18 15:38:40 -08:00
Joey Parrish e07a965df2 Fix argument count on compiled default callback
This fixes the argument count on the compiled versions of our default
callbacks.  This makes sure we don't issue incorrect warnings about
the application's configured callbacks.

This was discovered in the compiled build of our own demo by observing
the warning logs about the wrong number of arguments in some of our
callbacks.

Change-Id: I401d54bdc706aee9a70fbf5db83fc5e7de5cb183
2020-02-18 18:00:52 +00:00
Theodore Abshire 6a6a47c5ca Added stats for time taken in load stages.
Change-Id: I3b9c8397999468e606b241f160174a2063b23ae0
2020-01-29 18:57:45 +00:00
Álvaro Velad Galván e0045e5731 Add corruptedFrames to stats (#2328) 2020-01-10 15:46:20 -08:00
Joey Parrish efca237739 Prefer the compiled Shaka Player in integration tests
We should always use the compiled build in full-stack integration
tests to ensure that we catch compilation-related errors in the tested
code paths.

There was one instance where we should have done this, and it has been
corrected.  There were two instances where we MUST use the uncompiled
build to regression test assertion issues, and those now have more
obvious comments.

Change-Id: I7cb2f67cbdfbd5a76af69036237adaa576e9806e
2020-01-08 19:50:16 +00:00
Joey Parrish 48836912a9 Reimplement "Avoid Platform.supportsMediaType when loading."
This reverts commit 6667ea5edf and
reimplements it using a fallback to an arbitrary media element when
there isn't one yet.

This also adds a regression test that would have caught the issue
sooner.

Closes #2326

Change-Id: I44573ae551db51f788d7c97b9680dfd45adee0a0
2020-01-07 12:30:09 -08:00
Álvaro Velad Galván cdbf8c5fbc Add licenseTime to stats (#2297)
This gives the cumulative time spent fetching licenses.
2020-01-06 11:11:28 -08:00
Joey Parrish a48f8792a9 Move test-only method to test utils
This method should probably never have been in the library, since it
creates a fixed-sized, muted element.

Change-Id: I53b474305465bef34d43ce40ec5e7dedceb20a25
2020-01-06 18:57:28 +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
Jacob Trimble 597decae3d Fix issues in new Player buffering tests.
Fixes: 143690520
Change-Id: I492d3a0b9d95b0a2117a32ded14d794f8866311f
2019-11-01 16:09:06 +00:00
Jacob Trimble 17432912a8 Add integration tests for Player buffering.
Change-Id: I3efc5f1c23090fca566bc2a63f707a6b4ae655b7
2019-10-30 22:30:51 +00:00
Jacob Trimble cbcfba031d Avoid having two top-level describe() blocks.
This moves some of the tests around to have each file use only one
top-level describe() block.  This removes some Player integration tests
that are already tested elsewhere.

There are two cases where there are two top-level describe() blocks
left: the segment reference and http plugin tests.

Change-Id: Iab7365919cfba739d4710184f079b6d2638192b6
2019-09-12 15:50:43 +00:00
Jacob Trimble dedd96530e Don't generate compiled assets in some tests.
These tests don't use the compiled assets, and this line doesn't even
build the assets for the compiled library, it uses the uncompiled
library.

Change-Id: Iff5c74c7ef258a18c29a3011266ce459f9e5cf75
2019-09-10 21:53:21 +00:00
Jacob Trimble 4fdf8f7a1c Allow running tests without Babel.
This greatly speeds up startup time when running tests on a modern
browser.  This change also fixes a bug in one of the tests that only
worked with Babel running.

Change-Id: I1493ef30388c5043dcdf8350bec7817ab5d28d55
2019-08-20 20:10:02 +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
Sandra Lokshina b838dd8c8f Add a test for an issue with external text visibility.
I promised Theodore to add a test for this.
A Lannister always pays his (technical)  debts.

Issue #1938

Change-Id: I9741b8c65a4a26b1c07ed1feb9082751dab49505
2019-07-16 19:58:06 +00:00
Jacob Trimble d771aaef0f Remove some eslint-disable lines.
Issue #1692

Change-Id: I9db8e43e2159d28e1fd7ebf30933d32a8741e6b7
2019-07-15 14:54:11 -07:00
Joey Parrish 3e44fac804 Use function for factories in tests
These factories require actual functions, not arrow functions.  This
was only working so far because of Babel translating the code to ES5.

Closes #1953

Change-Id: If05d11f4a66f920077343c3e1759964f41e4433c
2019-07-09 21:23:54 +00:00
Jacob Trimble 83de1ad634 Use toBe instead of toEqual for primitives.
This ensures that we get the expected types and that type coercion
doesn't convert between types.  This also ensures we are consistent
in how we check for equality of primitives in tests.

Change-Id: I9f3aacdf25ab1afe5e8d6e4b895b5299ee687d54
2019-06-26 18:57:18 +00:00
Jacob Trimble 52522c7dca Fix cases where errors weren't propagated.
This propagates errors in several places and fixes waiting for some
async calls.

Change-Id: Idf4519b473538c1fa00bfe63e634194610ba29f2
2019-06-19 20:35:30 +00:00
Jacob Trimble e31f4ec3c8 Fix playback rate errors on IE11.
Apparently calling play() causes the playbackRate to be set back to 1,
so we need to call play() before setting the rate.

Fixes: 135520981
Change-Id: Ibea1cbd7c0ee4605b10b0fee87a8b5c069e04fa3
2019-06-18 22:53:59 +00:00
Jacob Trimble 3da809019b Enable additional ES6 linter rules.
Change-Id: I6861541b27153ba034364a5972a9b086de581cef
2019-06-11 18:35:09 +00:00
Jacob Trimble 799e96c05c Convert test utils to ES6.
This also removes the unused SimpleIDB type and removes the duplicate
code in Utils that appears in Waiter.

Issue #1157

Change-Id: Ib3cfc16212b9d169b360825a25a084c5ebd7b80f
2019-06-03 18:41:17 +00:00
Jacob Trimble e59187adf5 Convert player tests to ES6.
Issue #1157

Change-Id: Ib405576ff77e324e5586b93cdbfddcde69d264ab
2019-05-22 16:14:19 +00:00
Jacob Trimble f130dffcef Enable eslint indentation rule.
This is a fully automated change.  The linter will fail because the
extra indentation caused line-length errors.  These won't be fixed
automatically.  They are fixed in a follow-up to make this one fully
automated.

Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
2019-05-13 22:31:09 +00:00
Jacob Trimble 0dd64074b9 Only allow one statement per line.
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.

Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
2019-05-13 22:11:50 +00: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 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
Jacob Trimble 9ae237cc3c Fix captions being displayed initially.
When the audio and text languages differ, we should display the captions
by default.  This also happens if the app calls setTextTrackVisibility
before calling load.  What happened is the text media state was being
created, but an update wasn't being scheduled.  This meant the text
segments never got appended.  This changes when the update gets
schedules.  This also removes an unnecessary call to set the initial
state during startup.

Issue #1696
Closes #1879

Change-Id: If3a1b9e2889fc0e487da0e7276ca837636bf2e54
2019-05-03 15:58:08 +00:00
Joey Parrish 831dfa6168 Consider src= fully loaded only after first frame
This fixes the definition of load() to wait for a frame before
resolving the load() Promise for src= playbacks.  Now methods like
isAudioOnly can be trusted as soon as load() resolves.

This also allows load() to fail for src= playbacks if an error event
fires from the media element.

Issue #816
Issue #997

Change-Id: I0f6120d1334bbebcb78efdbbca65c7981f3ef265
2019-04-30 12:03:01 -07:00
Joey Parrish ea9a7d2b32 Relax restrictions on load state
Allow indirect access to members (such as DRM engine, manifest, etc)
from Player methods as soon as they become available, instead of
waiting until the very end of the load process.

This fixes application access to several methods during the
"manifestparsed" event.  The point of the "manifestparsed" event was
to allow early access to manifest and other metadata before streaming
begins.

This also lays the foundations for improvements in native HLS support
in those same methods, including the ability to get track information.

Issue #382
Issue #997
Fixes b/131604508

Change-Id: Ifee7b06fc2ccdcf5bcdf1c44f2f851d1d7e67fa1
2019-04-29 17:46:12 +00:00
Joey Parrish eff0d47c08 Factor out Tizen workaround
There is a workaround for a Tizen bug which appears in many of our
test suites.  To avoid having to add this to yet more, this change
factors out the workaround such that it applies to all tests.

Change-Id: Ie34c81bfcac94310bf3cd021fd4f2d55905b647a
2019-04-18 09:27:51 -07:00
Joey Parrish 3b0ceafdca Deflake offline and player integration tests
This makes some of our integration tests more robust by using
integration test utilities for observing playback status.

b/128923302

Change-Id: Iae5efe55308660bfe1cde9a7f735ee54dbc0b526
2019-04-17 15:26:26 -07:00
Joey Parrish 133f161b93 Support all types of single-file playback
Instead of triggering src= based on 'video/mp4' MIME types, ask the
browser what it can support using video.canPlayType().

Querying canPlayType() also allows us to detect src= support for
native HLS in Safari.

The original version of this change also added a complete fallback
system to detect MIME types based on common file extensions and
fetch MIME types via HEAD request when necessary, but the load graph
system does not yet allow us to make async decisions about destination
node.  So this async MIME detection is commented out for now.

Closes #816 (src= single file playback)
Issue #997 (native HLS in Safari)

Change-Id: If1930ca4fd5710481a925d63fb312d9a5b15fec8
2019-04-16 22:59:18 +00:00
Sandra Lokshina 493d459c47 Add a DOM util.
Change-Id: Ia0941868f20dbb42fa0fe02a639015ac244a65ed
2019-04-05 12:01:59 -07:00
Aaron Vaage 040ecf6978 Create src= node
This CL creates the "loaded with src=" node and its initial
implementation. Adding this node required some changed to the routing
logic as a new destination was created.

We will use src= when given mp4 content or media source is unavailable.
We detect mp4 content via the mimeType in |load| and/or the file
extension. When media source is not available on a platform, we fall
back to using src=. To do this, we check if media source is available
whenever |load| is called, and will route to the src= branch if media
source is not found.

To avoid pre-initializing media source (when it is not available) we
modify the |initializeMediaSource| flag in |attach| and |unload| when
media source is not available.

Doing this showed that we had inconsistent behaviour between |attach|
and |unload|. |attach| would default to initializing media source
whereas |unload| would not. This has been fixed.

Issue #816
Issue #997

Change-Id: I00599832b49c9079e273e65a4b827fee736479cc
2019-04-01 22:56:39 +00:00
Álvaro Velad Galván 732f86b18a Track time in "pause" state in stats (#1855)
Before, we reported the total seconds spent in the "playing" and "buffering" states, but we did not track the total time spent in the "paused" state.

Now that we can derive the "total time spent in" via `StateHistory`, we can easily fetch the total amount of time spent in the "paused" state (which is tracked in our state history).

This adds a new field to `shaka.extern.Stats` for `pauseTime`, defined as "The total time spent in a paused state in seconds'.
2019-03-29 08:47:11 -07:00
Aaron Vaage d9acac7f58 Return to Attach After Error
If the player sees an error and we are attached to a media element, we
should return to the attach state because we assume that the media
element is still usable after an error.

If we keep throwing away the media element, it means that after each
error, an app would need to re-attach to the media element. This will
break backwards-compatibility.

This CL restores backwards-compatibility by resetting the walker to be
at the attached-state if it has a media element.

Issue #816
Issue #997
Close #1843

Change-Id: Idaa70d9fcc01cd9af06ff8967812a4051f8c6e53
2019-03-21 15:58:39 +00:00