Commit Graph

127 Commits

Author SHA1 Message Date
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00: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
Theodore Abshire 9b57779f15 Typo fixes and rewording in comments, part 2
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I45fb053b6a92f36313cfbc060eeec36cdccc581b
2018-03-14 17:59:30 +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 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
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
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 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
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
theodab 79a215b096 Clear old text stream when loading new text stream
In our previous fixes for issue #1058, we made it so that we
remove the text engine when not displaying captions.
However, we did not clear MediaSource's buffered text. Thus, when
loading a new text stream after re-enabling the captions, the old
buffered text would still be displayed. Text tracks, in VOD content,
can potentially be a single file for the entire video. Thus, when
changing text languages while closed captions were disabled, the
actual captions did not change.

This modifies streaming engine to clear buffered text, to fix that
problem. It also updates unit tests.

Closes #1293

Change-Id: Iddf2591101286474862b52579d4cf6b464e450fb
2018-02-15 08:55:59 -08:00
Michelle Zhuo 175e0b9594 Support CEA 708 Closed Captions
Issue #276.

Change-Id: If42ab04a451dc8c4c7038213b7f7c925648c3444
2018-02-03 00:03:44 +00:00
Joey Parrish e298fb60fc Update muxjs to use new keepOriginalTimestamps option
Depended on issue videojs/mux.js#168

Issue #1194

Change-Id: Ia2ad5c17ad82a2c53215d34fbfec7be1d119df95
2018-01-18 20:18:09 +00:00
J. Oliva 58caec4341 Remove duplicated mime types (#1181) 2017-12-11 11:57:57 -08:00
Joey Parrish af73139d05 Set appendWindowStart in MediaSource
This avoids having media from one period replaced by media from the
next period.  Instead, media that comes before the period start will
be chopped off by MediaSource.

Closes #1098

Change-Id: Idf6dc2ffafe78214e94bc75aca63920e153f1a2c
2017-11-10 10:23:40 -08:00
Joey Parrish bde4c45274 Fix timestamps in transmuxed output
Timestamps should not change during transmuxing.

Until videojs/mux.js#168 is solved, we work around the Transmuxer's
timestamp manipulation by setting an explicit base time.

Closes #1102

Change-Id: I92658d795797013a6e962b1e4bc4c712edfd50fc
2017-11-07 18:58:13 +00:00
Michelle Zhuo e516a64487 Transmux from Transport Stream to MP4
Supporting Transport Stream by transmuxing it to MP4, with mux.js
library.

Issue #887

Change-Id: I70361bb364721fc5e72cba7d0fabc311ce0ba8b5
2017-10-20 18:14:02 +00:00
Jacob Trimble b4d4294efc Add Player method to get buffered ranges.
Change-Id: I8237dc1d0b42a1d96bbd51cbd1c02ff58dd372f4
2017-10-17 16:24:53 +00:00
Jacob Trimble 1224464535 Use goog.DEBUG over COMPILED.
This allows including the extra assertions and logging in the debug
compiled library.

Change-Id: Ie8575a31b428e1985077939169bfae9254e395d5
2017-09-27 11:24:32 -07:00
Joey Parrish 41e38990fe Revert MediaSource append window fudge factor
This hack is no longer needed to avoid gaps, since we now have a
gap-jumping implementation in the player.

The fudge factor was causing rounding errors in presentation duration
after an end-of-stream event, which could lead to playback hangs in
certain content.

Closes #979

Change-Id: I719813c8da8da08e1ebfb6daf7f6857757e7d228
2017-09-01 19:52:21 +00:00
Joey Parrish 3cd18bb336 Query platform MSE support using "extended" MIME types
Some platforms (such as Chromecast) support extra MIME parameters like
framerate, bitrate, width, height, and channels.  Since other
platforms will ignore these extra parameters, we should always query
using these parameters.

This introduces the framework to construct these "extended" MIME types
from Stream objects.  Extra parameters for other platforms can easily
be added later.

Change-Id: I8936ca93e84068da18f12127fbc8fc1a0646695a
2017-08-17 17:35:00 +00:00
Joey Parrish b7b890b908 Add a polyfill for Chromecast isTypeSupported
There are several issues with isTypeSupported on Chromecast that
require workarounds in JavaScript:
  - Dolby Vision strings must be removed from the codecs parameter,
    even though the content is supported by the platform
  - HDR must be guessed at from the codecs parameter and an additional
    parameter must be added to query HDR support
  - Queries must be made through a non-standard interface

Change-Id: I4c8c70e70cf9c26283913783f5f62f7d6470c2f1
2017-08-17 17:35:00 +00:00
Joey Parrish 4af3cfa2bc Add vp9, opus, and flac mp4 to probeSupport
These formats are at various stages of specification or
implementation, but all are coming eventually.

Closes #944

Change-Id: Id904d488b688cbb61e3dac502882069e9e15c2b3
2017-07-31 23:03:46 +00:00
Sandra Lokshina c70367dc97 Separate text parsing and display logic.
Closes #796.
Closes #923.

Change-Id: Ifc2017b40a0fb570103f0fed7bc130aa24819e9f
2017-07-17 21:39:59 +00:00
Sandra Lokshina c6c6d05810 Move text-related files into their own directory.
This change creates a lib/text directory and moves all files
with text-related logic to it. It also lays the ground for
separating text parsing and display logic. (That change will
introduce even more files with text-related logic which will
crowd lib/media directory).

Issue #796.

Change-Id: I65ac134020a0126ff02a8f2067beb73870232e65
2017-06-06 18:21:09 +00:00
Joey Parrish bf404d4fbc Check for MediaSource.isTypeSupported
On at least one TV platform, isBrowserSupported returned true in spite
of a lack of MediaSource.isTypeSupported.  (See #804)  This adds a
check for that required method.

Change-Id: I4e68b66700508c1b3eafc9a97901f7d573ecbb80
2017-05-16 11:36:38 -07:00
Jacob Trimble e5ce395f37 Implement gap jumping.
The bulk of the logic for gap jumping is handled in Playhead.  It
tracks the current buffered ranges and jumps over any gaps that appear.
It listens for a special browser event ('waiting') for when the video
element runs out of playable frames.

This change also removes the logic for jumping gaps at the beginning
of the timeline.  This is handled by the more general gap jumping
logic and works cross-browser.

Finally, this updates the buffering logic to only count the amount of
content buffered (i.e. ignoring the gaps).  This fixes some bugs where
gaps in the content can result in StreamingEngine buffering forever
since it thinks only a little is buffered.

This includes full implementation of the logic, but this doesn't close
the issue since there aren't any integration tests yet.  Those will
be added next.

Issue #555

Change-Id: Id99eb9fe469e8cf2c7464a3d70c3733791e806e0
2017-04-17 18:15:23 +00:00
Aaron Vaage 9a86d0460f Redefining Text Parsing Plugin System
The text parsers were all stateless. This caused problems with MP4
VTT as the timescale is needed later on for other boxes. This changes
parsers to carry state.

How time is referenced with the text parsers is not clear and has
caused confusion. In v2.0.1, we introduced the useRelativeCueTimestamps
option to control the behavior of our WebVTT parser. We decided in #480
(comment) that we would remove this option in v2.1.0. All WebVTT
timestamps in v2.1.0 will be relative to the segment time. This change
creates a new time context interface that will be used to help limit
the confusion around how time is communicated.

Closes #726

Change-Id: I67409608c35d2d5abb8b8b25529859cb37f8f0a8
2017-04-05 13:41:27 -07:00
Jacob Trimble 575f2ad109 Add an indicator for critical errors.
This adds a severity field to Error objects.  This can be used to
detect whether an error is recoverable.  All the same errors are still
reported so the field can be ignored.

There are two possible values:
* RECOVERABLE means that the Player will try to recover from the error
* CRITICAL means the Player will be unable to continue and must call
  load() again

Closes #564

Change-Id: Ie2c5468340c13e7a288b99690ab65b7ecc0a6b29
2017-04-04 23:57:59 +00:00
Jacob Trimble e7ce5a7f35 Allow small gap at start when buffering.
We allow small gaps ahead of the playhead in StreamingEngine.  But this
is not mirrored in Playhead.  We should exit a buffering state even
when there is a small gap.

Note this is unrelated to the issue where Chrome won't jump gaps after
a seek.  In StreamingEngine, we don't allow this gap when seeking;
however, this change involves normal playback and doesn't involve that
bug.

Change-Id: If091994ee1a93965836e99cdb41873afb18d0fd4
2017-03-22 21:22:24 +00:00
Sandra Lokshina 0b12937520 Replace content type strings with constansts.
Change-Id: I4fda583915766b40ee7a5c7451d037077d9f2582
2017-03-08 21:41:59 +00:00
Jacob Trimble 43380239ba Call abort() before setting timestampOffset.
When appending MPEG2-TS segments, we seem to always enter a
PARSING_MEDIA_SEGMENT state in the SourceBuffer.  While we are in this
state we can't change the timestampOffset.  This means that we can't
change Periods or adapt to a different resolution.

To fix this, we call abort() before setting the timestampOffset to
reset the state.  Because abort() also resets the appendWindowEnd,
this merges the two operations so we set timestampOffset and
appendWindowEnd at the same time (since we do already).

Issue #279

Change-Id: Icd893ded9e3137179f262ba10e55e41d06ec5a77
2017-02-17 11:51:06 -08:00
Joey Parrish 25c500242b Refactor pipeline flushing
Rather than flushing implicitly when clearing the buffer, flush
explicitly in some circumstances.  In particular, do not flush on
unbuffered seeks.  Flushing uses seeking, so flushing on seek
creates a race condition that may cause a nasty loop.

Issue #569

Change-Id: I61489b13100b56a5316a8313a1b2782dc242f858
2016-11-28 18:54:05 +00:00
Joey Parrish 4c9ee5db76 Allow text parsers to change during playback
Text parsers can easily be changed during playback, unlike the
browser's media decoders.  Whenever we change text tracks,
reinitialize the text parser.

This also removes restrictions on text tracks of different types
when we filter manifests.

Closes #571

Change-Id: I3c243dde951cd04554c2fa1be2c8ebf06988791b
2016-11-21 17:50:08 +00:00
Joey Parrish 894c56d3c9 Remove suppression of "unnecessaryCasts"
This no longer seems to be needed.

Change-Id: I8f9ed03f97b235d4652930745d4416f6c8f77445
2016-11-04 19:40:55 +00:00
Joey Parrish a4bc7f36d7 Add additional codecs to the MediaSource probe
Change-Id: Ia41fe1514020a86f989aed8a7ca19c98d6be9283
2016-11-03 23:27:28 +00:00
Sanborn Hilland fff9892373 Add config option for using segment relative timestamps for VTT (#542)
* Add config option for using segment relative timestamps for VTT

Fix for #480

* Make useRelativeCueTimestamps a non-nullable param

* Update tests for the new useRelativeCueTimestamps param

* Move period relative timestamp deprecation warning to vtt parser

* Log warning only if using absolute timestamps in text cue

* Fix vtt text parser test
2016-10-24 11:22:54 -07:00
Joey Parrish 385a501d0d Stop clearing the buffer ahead of the playhead
Clearing ahead of the playhead is causing hiccups in playback on the
following browsers:
 * Chrome (all platforms, inconsistent)
 * Edge

These browsers appear not to be affected:
 * IE 11
 * Firefox
 * Safari

This is a manual change that reverts almost all of:
 * a8ac3142 - Make buffer clearing behavior explicit
 * 4593cf78 - Check position against null, fix bug in a8ac3142
 * 10b3dd0a - Seek after clearing a buffer, workaround Chrome bug
 * 6daa7f3b - Allow AbrManager to clear ahead of the playhead

Clearing the buffer is now an all-or-nothing proposition because that
is the only way to get consistent playback quality across browsers.
This comes at a cost, because we can no longer count on the ability to
remove buffered data on upgrade without a stutter.

Issue #520

Change-Id: Ia6f8b2fcb223f9c50e9829b26d7003ae8f6efb8d
2016-10-20 10:30:59 -07:00
Joey Parrish 96045b5ff2 Flush Chromecast pipeline after clearing buffer
To work around a bug in Chromecast, seek after clearing the buffer.
This forces the device to flush the pipeline and remove any decoded
data from the old representation.

Closes #544

Change-Id: I3c34d344bfd856b429a360fc41ce7288791716bb
2016-10-19 14:00:21 -07:00
Joey Parrish eafe954d0c Replace Number.POSITIVE_INFINITY with Infinity
This is supported on all browsers, is more compact, and is easier to
read.

Change-Id: I96576dc341e093b7be9ef94fe36595c945b063c1
2016-08-29 18:56:54 +00:00
Joey Parrish 8c7c74e950 Polyfill Safari 9 MediaSource bugs
This adds a polyfill for a Safari 9 MediaSource bug where calling
abort() on SourceBuffer causes the decoder to fail.

The reason we call abort() at all is to reset the decoder and smooth
segment transitions on Chrome, Firefox, and Opera.  Safari does not
seem to have this problem in the first place, so it is fine to
completely stub out abort().

Issue #446

Change-Id: Icbaaa3e9ce5372efdee937ddc4cf94a27dce6a47
2016-07-29 18:42:31 +00:00
Joey Parrish ab64c76ee9 Fix MP4 text parser integration
* removes an assertion which is no longer valid
 * corrects the registration of the VTT in MP4 parser
 * fixes some type issues in TextEngine

Change-Id: I0b7f41f01e5d7be2932c86a56f3cdfd6a53d04cb
2016-07-19 23:03:16 +00:00
Sandra Lokshina 259777fe9f Implement parser for segmented TTML in MP4
Closes issue #278

Change-Id: I2f454a2c2f63d8ce6682cd4593c1d843b2967978
2016-07-13 21:49:43 +00:00
Joey Parrish 6daa7f3b83 Allow AbrManager to clear ahead of the playhead
SimpleAbrManager will now leave 5s of video ahead of the playhead and
clear the rest when upgrading to a higher resolution.

Also smooths transitions for overlapping segments by scheduling an
abort() call to reset MediaSource internals after removing content or
changing the append window.

Related to issue #435

Change-Id: Ie036515388e1e7e4b3b8f3ab9922e3d5e7ed2627
2016-07-13 04:01:11 +00:00
Jacob Trimble 2c3dccc45e Fix bug with text engine buffered ranges.
Based on pull request by @baconz.  Before, when appending segments,
TextEngine was given the segment times and then added the timestamp
offset to get the real time.  However, this is incorrect as we want
the time relative to the presentation timeline.  So we should only be
adding the period start time (the timestamp offset also includes PTO).

Closes #411

Change-Id: I92582d1cda034daef5e8ce2d7b79deafa0ddf828
2016-07-08 16:21:23 -07:00
Joey Parrish 422f5aa5cb Correct usage of jasmine's toBeCloseTo matcher
The second argument is meant to be the number of decimal places to
which the value must match, not the maximum difference.  So using
"0.1 decimal places" meant the maximum difference was actually 1.25.
You must pass "1" to get a maximum difference of "0.1".

This also adjusts some of the expectations to fix affected tests.

Change-Id: Ibc1223297011063e3e4f3fff0ba64fde06292128
2016-07-07 17:52:46 +00:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07:00
Jacob Trimble 5102f54120 Make Player.support synchronous and add support plugin system.
Now there is a new synchronous method Player.isBrowserSupported.  This
will detect basic support and return a boolean.  The support() method
has been renamed to probeSupport() and should only be used for
diagnostics.

Also added a plugin system to Player support testing.  Now a plugin
(e.g. offline) can add extra info to the output of probeSupport().

Closes #388
Closes #389

Change-Id: I313a41d9f123871272f1395aeb99c980df1f4bae
2016-06-02 21:57:38 +00:00
Timothy Drews ddbc13d4f8 Handle QuotaExceededError from appendBuffer().
MediaSource may throw QuotaExceededError if it cannot append a
segment. Now, StreamingEngine will catch these errors from
MediaSourceEngine and reduce the buffering goals to avoid
encountering additional errors.

Closes #258

Change-Id: I1d957831424a4a6fb2681ee2c4f9ed7db7bf1711
2016-05-12 18:12:17 +00:00