Commit Graph

718 Commits

Author SHA1 Message Date
Aaron Vaage 4a4050d223 Change Download Manager To Take Requests
Changed download manager to take |shakaExtern.Request| as input
instead of |shaka.media.SegmentReference| and |shaka.media.InitSegmentReference|
as it really does not need to know about those types.

Issue #1248

Change-Id: I797c437f4339cf670b5eddad14952b0526b72ea5
2018-04-09 18:13:28 +00:00
Joey Parrish 66abf9cb27 Remove all protocol-relative URIs
According to @beaufortfrancois, we should no longer be using protocol-
relative URIs.  He quotes this passage from Paul Irish:

> Now that SSL is encouraged for everyone and doesn’t have performance
> concerns, this technique is now an anti-pattern. If the asset you
> need is available on SSL, then always use the https:// asset.

> Allowing the snippet to request over HTTP opens the door for attacks
> like the recent Github Man-on-the-side attack. It’s always safe to
> request HTTPS assets even if your site is on HTTP, however the
> reverse is not true.

Source: https://www.paulirish.com/2010/the-protocol-relative-url/

This change was begun with the following command:
  git grep -l "'//" | xargs sed -i "s@'//@'https://@g"

Some changes made by that command were false-positives, which I then
reverted manually.  Others required additional cleanup to meet style
rules.

I've also just discovered that the "max-len" rule in eslint's Google
style config exempts URIs, so there's no need to disable the max-len
rule on URIs in the assets list.  These have been removed in the asset
list where unnecessary.

Finally, testing these updated URIs led to the discovery that two of
our third-party demo assets are no longer available.  One URI needed
to be updated.  The other had no obvious replacement, so it was
removed.

Closes #1390

Change-Id: I2fe23faec04f1904c1741236b364d5089900092a
2018-04-09 18:06:18 +00:00
Michelle Zhuo a09ae24b85 Add audio channels count configuration
Added a preferred audio channel count to configuration, default set
to 2.
Choose the codec with the largest number of audio channels less than
or equal to the configured number of output channels. If this is not
possible, choose the smallest number of channels.

Closes #1013.
Issue #1071.

Change-Id: I6c6a956e33637cf34bd4bd79af563dc10a595e94
2018-04-06 20:51:28 +00:00
Aaron Vaage d86713cf0d Group Streams Before Downloading
To make it easier to understand, we collect all the streams within a
period using a map. This ensures that we will have a set of streams.

We then download each stream in the map. Since the map is indexed by
stream id, we can easily connect the variants and streams.

Issue #1248

Change-Id: I65ae01733b5d9dbf8b6d73c37f802320fffa03d1
2018-04-06 20:15:52 +00:00
Jacob Trimble f13acd6ac5 Fix ABR selecting key-system restricted streams.
ABR should not select key-system restricted tracks since we can't play
them.  Rather than updating AbrManager to do it, the Player should
just filter out the restricted tracks so a custom AbrManager doesn't
need to worry about it.

Change-Id: I5fa5cdcd9a035136fdccf9bee1a54752a0cacf1f
2018-04-04 14:50:57 -07:00
Aaron Vaage 3e56d4ea1e Update Storage Unit Tests
Made some changes in how the unit tests were structured so
that it will be easier to identify problems with changes to
storage.

Issue #1248

Change-Id: I8331f18e9c9e360cf8057737ddfd71c7152a744b
2018-04-04 17:50:36 +00:00
Theodore Abshire 4327153007 Loosen tolerance on CEA-708 captions test
On some platforms, the sample used in that test leads to a
buffer start time of 1.4; on other platforms, it leads
to a buffer start time of 1.4667333333333332.
Perhaps this is a result of the implementation-specific rounding
differences in different mediaSource implementations, or perhaps there
us a very small gap in the content that some platforms handle slightly
differently.

Either way, this change loosens the tolerance on the check. That buffer
start time check wasn't the important part of the test, anyway.

Fixes: 77471871
Change-Id: I866fafe671566cc7116e7c99222f75225cffd476
2018-04-02 14:11:31 -07:00
Theodore Abshire f32767578a Handle segment tags before playlist tags in HLS
Normally, we expect that only media playlists contain segment tags
(EXT-X-KEY, EXTINF, etc).  We determine if a playlist is a media
playlist by the presence of an appropriate playlist tag (EXT-X-MAP,
EXT-X-PLAYLIST-TYPE, etc).
However, we were checking tags one-by-one, on a single while loop.
This meant that we would reject manifests where a segment tag appears
before a playlist tag, as we did not yet know that the playlist was a
media playlist.

This changes the manifest text parser so that it checks for playlist
type first.

Issue #1382

Change-Id: I1b9f674a58c60ab291d6d004462b0c0cae49631d
2018-03-30 16:30:16 -07: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 25971503fa Don't update DASH faster than a device can manage
For slow embedded devices, such as the v1 Chromecast, updating the
DASH manifest takes far too long.  The result is that we can sometimes
repeatedly fall out of the seek range when playing near the left edge
of a live stream.

Until we can dig into and optimize the DASH parser, we will detect
and adapt to slow parsing by updating the manifest less often.

This is done based on how long updating actually takes, and does not
hard-code either the platforms that need this workaround, nor the
frequency of updates they can handle.

Bug: 75276747

Change-Id: I6565192b4ce6935ee8416ea4843fee851f4bd990
2018-03-28 22:48:07 +00: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
Theodore Abshire f22a00aba7 Quarantine CastUtils.TimeRanges.deserialize
This test has been flakey on OSX for quite a while, but it was very
occasional, and the likely cause of the flake is unrelated to the test
itself, so it was never really dealt with.
Recently, though, the test has been failing repeatedly on the BuildBot.
This change quarantines the test so that the BuildBot will stop failing.

Issue #1215

Change-Id: I1a721976c277cfb9324b0b3f9cf8eae49b17d1ca
2018-03-28 17:27:34 +00:00
Joey Parrish 726e013215 Do not buffer audio far ahead of video
No one media type will be streamed far ahead of any other.  The limit
will be the max duration of one segment.

Bug: 75276747  (mitigates)
Closes #964

Change-Id: I0f118e73912b46c987e58d4a5c123acf8412be0b
2018-03-27 22:10:48 +00:00
Aaron Vaage 33547d071c Stubbing-in Mechanism & Cell Fields in Offline Uri
Adding "mechanism" and "cell" fields to offline uri. But since
they are not used anywhere, this change sets them to dummy values
so that all the constructors could be updated.

Moved the manifest reconstruction code into a instance class as
the mechanism and cell for the asset is needed in order to create
all the segment uris.

Change-Id: I2b5738805b17c4aa33d39b3166fddf1528aed489
2018-03-27 21:19:47 +00:00
Theodore Abshire 8ea237c214 Fixes how the MDAT is read for VTT in mp4 content.
Previously, we would read each individual VTTC and VTTE box in the
MDAT and associate them with durations in the TRUN. This worked for a
lot of content, but if sampleSize is defined in the TRUN, a duration
might refer to multiple VTTC boxes.

This changes the VTT in mp4 reader to parse the MDAT based on the TRUN,
to account for such situations.

For the moment, this only accounts for a single MDAT, and assumes that
the MDAT contains nothing but vttc or vtte boxes, listed in order.

Issue #1266

Change-Id: I56e310d085abdda16e968761ed3b4fd0cc5e24d0
2018-03-27 17:10:48 +00:00
Jacob Trimble 2200d9b292 Fix safe seek window calculations.
This fixes how we determine the seek window for live content.  This
also allows for a slight margin for small seek windows in reposition_
so we don't repeatedly seek with that.

Closes #1331

Change-Id: I70e5e7c134677350d89d42cb0b5abfa784061b9e
2018-03-27 16:52:13 +00:00
Aaron Vaage e6302f5d73 Make Update Expiration Simpler
The only time we ever need to update a manifest value is when
we update the expiration time. To make it easier to support
updating expiration time across different version, only allow
that one value to be updated.

Change-Id: I621ec744019802edc65b059baa7f5cf0c476b0b1
2018-03-26 20:13:15 +00:00
Aaron Vaage 6ae49efc96 Move Offline Uri Functions in Class
The offline uri is going to soon contain more information (routing
information used by the storage muxer) so this change makes offline
uri a class so that all components can be accessed.

Change-Id: I5137f278e0dab059191d450876cab42745e4ed0b
2018-03-26 19:17:35 +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
Aaron Vaage a6c34b64b6 Create Storage Cell Tests for Memory Storage Cell
Made a copy of the storage cell tests for indexeddb but made them
work for the memory storage cell so show that we can expect the
same behavior from them.

This is to give us an extra level of confidence when we use the
memory storage cells in place of the indexeddb storage cells in
our tests.

Issue: #1248
Change-Id: I96eaf57a9d808b4c7e07f97ac2713318a889fc24
2018-03-22 15:46:41 +00:00
Aaron Vaage 798ca28131 Creating Storage Cell Tests
Issue: #1248
Change-Id: I2522ce02e8a9bdb8c6bea9f77adf91393b0265b6
2018-03-22 15:46:36 +00:00
Jacob Trimble 938da032b5 Allow non-decimal formats in SegmentTemplate.
Fixes: 75988239
Change-Id: I023a1bd003662c6d651eb870b4aba025dc687327
2018-03-21 22:41:26 +00: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
Theodore Abshire e58e8b656b Refactor Player.load using async/await
This breaks Player.load into a number of async sub-methods, which are
called using await.
This should improve readability, and make load somewhat less
intimidating.
This also removes cancelable chain, which after the refactor is no
longer used anywhere in the codebase.

Closes #1336

Change-Id: I85ad22b9c8c6b7f72b27471ddd762763e6591a71
2018-03-13 11:20:52 -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 c37b5e9513 Allow multiple EMSG boxes per segment.
Closes #1340

Change-Id: I6e539ee54ca77f2069fd74c28f8e0d3ed870860f
2018-03-07 19:00:36 +00:00
Joey Parrish b27ea82e7f Allow Player to attach/detach from video
This adds attach/detach methods to replace the media element in the
Player constructor.  Now applications can take back control of the
media element or provide a reference later in the Player's life cycle.

This also allows applications to decide whether or not to set up
MediaSource in advance, through an optional argument on attach and
unload.  The default will be to set up MediaSource in advance, which
maintains current behavior.  This advanced setup of MediaSource can
improve load latency later.

This change also introduces async/await for the first time in the
project, which required changes to eslint config, Closure build
arguments, Babel & Babel-polyfill setup, and the esprima parser used
by our extern generator.

The use of async/await will improve readability in many places, and
these infrastructure changes to enable async/await should also unblock
issues #1336 and #1337.

Closes #1087

Change-Id: I0d6b4e0e2af27a6520a3d070fa92b7139b2cb8b0
2018-03-06 22:19:53 +00:00
Joey Parrish 5e7bbf77d8 Fix MP4+VTT in HLS
Our HLS parser made init segment references for everything but text
streams.  This condition was unnecessary, and the
createInitSegmentReference_ method already returns null if there is
no init segment specified in the playlist.

Closes #1270

Change-Id: Ia9e92a561dc0f9ee3caccfac30f3fb936d9dac87
2018-03-01 15:00:09 -08:00
Joey Parrish 02e648ccf3 Fix track selection during "streaming" event
This turned out to be three issues layered on top of one another:

First, we would fire the "streaming" event too early, before our final
stage of filtering. This meant that for multicodec content, you might
be selecting a track which will be subsequently filtered out. If the
track was no longer available after filtering, we would effectively
ignore your selection. This bug would only be triggered by multicodec
content (VP9 & H.264, for example).

This change fixes the ordering so that filtering comes before the
"streaming" event is fired.  A unit regression test was added.

Second, there was a code path in which we could ignore your track
selection. This was very easy to trigger with the "streaming" event,
and in an uncompiled build, would result in a failed assertion.

This change corrects assumptions about when we can ignore deferred
switches in the Player.  We had not previously accounted for the case
where we were still setting up the first period, which is easy to
trigger with the "streaming" event.  An integration regression test
was added.

Third, once the second bug was fixed, we could fail some assertions in
StreamingEngine and still effectively ignore your track selection.
This is because we did not reset a flag in the Player that tracks the
StreamingEngine setup state and informs when we defer switches.

This change resets the flag when we tear down streaming.  An
integration regression test was added.

Closes #1119

Change-Id: I16be372cfaf4d592ca895e41ad04333bc0b2eeee
2018-03-01 21:35:08 +00:00
Joey Parrish 8262d7a8e2 Work around MSE rounding errors in Edge
Edge bug: https://goo.gl/3ZTzse

Issue #1281

Change-Id: I03fcef7d52afc3a15b7cd7c4b873bff774087f82
2018-03-01 18:59:51 +00:00
Joey Parrish 1f1c05fbc1 Upgrade promise-mock
The new release has a new parameter in runAll() which simplifies
flush().

At this point, we could technically do away with our flush() method
and call runAll(false) directly, but I find flush() more clearly
indicates to the reader what we are doing.

Change-Id: I90f105ff38d032e3c9caf5484d78824dc64fe43d
2018-03-01 18:41:52 +00:00
Joey Parrish b85759840c Fix IE ended states
This fixes both IE ended states in the demo controls and in streaming.

If StreamingEngine increases the duration of PresentationTimeline to
match MediaSource's duration, this can cause buffering at the end of
a replay by inhibiting a call to endOfStream().

Closes #979

Change-Id: I6770edb69597198dee3ae1b96df31756bbf4b391
2018-02-28 23:43:56 +00:00
Joey Parrish f48f7fd9c4 Clean up uncaught Promise rejections
- Translate uncaught Promise rejections into test failures
   (Chrome only until the event is more widely implemented)

 - Clean up uncaught Promise rejection caused by exceptions thrown
   after destroy() in:
   - CastProxy
   - CastReceiver
   - NetworkingEngine
   - StreamingEngine

 - Clean up uncaught Promise rejection caused by test cases in:
   - CancelableChain unit tests
   - DrmEngine unit tests
   - StreamingEngine unit and integration tests
   - Player unit and integration tests

 - Speed up rejection in NetworkingEngine when we should not retry

 - Add --delay-tests to test.py, to aid in debugging uncaught
   Promise rejections and other types of async test pollution

Closes #1323

Change-Id: I5a8f5702a22430929babeb071bf6650c52c5ad17
2018-02-28 22:56:12 +00:00
Chris Fillmore 40e7524ed9 Catch BAD_HTTP_STATUS error thrown by makeResponse in xhr.onload (#1303)
Catch BAD_HTTP_STATUS error thrown by makeResponse in xhr.onload

Also wrap mock XHR event handlers in try-catch blocks in
http_plugin_unit to avoid regression.

Resolves #1302
2018-02-27 13:14:44 -08:00
Michelle Zhuo 0ad646dcc2 Enable TS Assets in demo asset list
The Transport Stream assets (Art of Motion(HLS,TS) and Sintel(HLS,TS,4k))
were disabled in the demo app, because the assets were only filtered by
native platform support.

Closes #1214.

Change-Id: I03b60df291813b4669889fc8f8500627d206b28a
2018-02-23 11:54:21 -08:00
Sandra Lokshina 6aae04ae29 Add setTextDisplayer() method to MediaSourceEngine.
Invoke the new method after a textDisplayer's been created.

Closes #1314.

Change-Id: I19891c845905a5a3509e74a93ebfe9a9c1ea7816
2018-02-22 23:47:40 +00:00
Sandra Lokshina e8134ca4de Update currentTextLanguage and currentAudioLanguage on track change.
We've been asked to implement this to allow for a custom app
behavior where app exposes all the tracks independent of language
and role.
In that scenario changing audio language will affect current text
track and the other way around. This CL makes sure it doesn't.

Closes #1299.

Change-Id: I39a9748c033ea748173ca00bfa7168dff642a03e
2018-02-22 17:26:04 +00:00
Jacob Trimble 064089152b Remove spacing around object definitions.
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.

Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
2018-02-21 13:35:00 -08: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 d47ab5c98c Disallow use of 'var'.
This also fixes some usages of 'var' that didn't get caught by the
previous CLs.

Change-Id: I4ce53d62d24e53e121d7eced70590836c1d26523
2018-02-20 22:43:30 +00:00
Jacob Trimble 2a130473dc Convert 'var' to 'let'/'const' (9 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: I270c70f6cda733ca6121d0761b4c1c162104d379
2018-02-20 11:30:04 -08:00
Jacob Trimble b512db87dd Convert 'var' to 'let'/'const' (8 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: I6a329d28e13a81c9f7136737518c6bb8fa18402e
2018-02-20 11:29:30 -08:00
Jacob Trimble 0154dbc4d4 Convert 'var' to 'let'/'const' (6 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: I475eba0a477d13cd9201c88ad44899d521ad8991
2018-02-20 11:28:02 -08: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 0200f498cf Convert 'var' to 'let'/'const' (4 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: Ib395106b14156a1f4000b516131684e319db78de
2018-02-20 11:09:07 -08:00
Joey Parrish b7bcafccc2 Move MediaSource setup to MediaSourceEngine
This isolates MediaSource code without changing the early
initialization of MediaSource, which was designed for low-latency
startup.

Prerequisite for #1087, #880, #997, #816

Change-Id: I61acedd95d73610d3e67436d9c7767d643fe2d29
2018-02-20 18:50:54 +00:00