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
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
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
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
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
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
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
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
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
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
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
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
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
These formats are at various stages of specification or
implementation, but all are coming eventually.
Closes#944
Change-Id: Id904d488b688cbb61e3dac502882069e9e15c2b3
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
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
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
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
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
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
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
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
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
* 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
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
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
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
* 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
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
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
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
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#388Closes#389
Change-Id: I313a41d9f123871272f1395aeb99c980df1f4bae
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