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
This mitigates "wrong error type" failures when accessing
the buffered property after a previous MSE error was
encountered.
Change-Id: I5ae9f6f689e17a04fc6d855a8bb179d40a2ddea0
Some browsers/platforms emit 'updateend' events at unexpected
times. Instead of failing right away when encountering these
events, just ignore them.
Change-Id: I71d1e5aba2591b1890d49dd746e4d20a5be71cf4
This adds a tolerance for certain buffered range checks. The browser
will jump small gaps, so we should not let small gaps interfere with
our buffering algorithm.
This also clamps lookup times to zero to avoid errors thrown on
positive drift.
Fixes#320
Change-Id: I2de9ef4850a96cac29bbcacaeb75285a358c230f
Safari 8's MediaSource implementation is incomplete (missing
appendWindowEnd), so we can't fully support it.
Since it is too complex to detect the missing feature directly,
we blacklist Safari 8.
Closes#169, #294
Change-Id: I7ef963922ba9e621b3187fcaae092dc56a3565af
Using goog.asserts will work with the compiler. So rather than
simply casting a nullable value when passing to a method, we can use
an assert which will correct the type and print a log if it somehow
is null.
This is not the same goog.asserts found in closure library, this
simply calls console.assert, but it is not required to do anything
for the compiler help.
Change-Id: I2548e39e772f0aa7ec41437cf9f5a2be383e0fbd
Before there were two style to indent comments after an annotation,
using 2 and 4 spaces. Now this only uses 2 spaces.
Change-Id: Id06415d7193cc154a2768fb3932aff7a06b7ed32
Instead of rejecting Promises with either exceptions or empty error
events, build full Error objects in MediaSourceEngine.
Change-Id: Ib4317f0ffe66c0292b3560f89f7a07e74e474dd3
This adds a fudge to appendWindowEnd so that the final frame in a
period won't be dropped and a gap will not appear between periods.
Change-Id: I9ded5237c949a3bae7e2c4081b32fa33938d9583
This changes the text APIs to correctly handle buffered ranges of
segmented text.
b/25517444
Related to issue #150
Change-Id: I3a11b87e8d93376a5012566deb3bf0d015f52391
* Tidy up unit tests, and add more eviction tests and drift tests.
* Add integration tests.
* Handle end-of-stream and end-of-Period scenarios when segments
are not perfectly aligned to Period boundaries.
* Use segment receipts to determine which segment to buffer next.
* Handle drift with eviction and other drift corner cases.
* Handle additional errors and improve overall robustness.
Change-Id: Ib57a255cda7a6e8c5857eb82accc14697983b893
Non-nullability on some types forces us to use casts everywhere, at
which point the compiler is just trusting us. So they might as well
be nullable and save us some typing.
Also, change HTMLVideoElement to the more general HTMLMediaElement.
Change-Id: Iaf111835bfbf230b99ad8cd7a7a06a6caffd16bc
This makes sure that remove() is called in a way that is compatible
with IE11. For more information, see #251.
Change-Id: Iabe752713ba74c7bf516b4e7b93bc83cfccdd481
We will be transitioning toward a new way of documenting record
typedefs. Each record will be annotated with 'property' for each
field in the record. This results in better output from jsdoc.
This covers all internal record types. External records will be
handled in a separate CL.
Change-Id: I2ab93015bfc9db01b4b6d474b608709c99fd70cd
This also cleans up compiler errors for:
- Things required but not used
- Things used but not required
- Write-only local variables
We are suppressing the 'unnecessaryCasts' error in specific places
where it is, in fact, necessary to convert between unrelated types
for polyfills and work-alikes.
Change-Id: I155c746116f95383ea0a9caf9239fadccd8601af
Support testing is hierarchical. Player.support returns an object
mapping out the support present in various parts of the system.
This creates a shell for Player and DrmEngine, and introduces support
tests for MediaSourceEngine, ManifestParser, and DrmEngine.
This also adjusts the way support checks are done for text types, to
allow for expansion into MP4-embedded text types and other segmented
subtitle types.
Text changes related to #150 and #146
Change-Id: I707f01ba52cba6262ee89bee2c1f28d24aca4655
This error type will be used for all internal errors, and will rely
on numeric error codes which can be easily checked by the application.
This also changes PSSH parsing to throw on errors instead of retaining
partial data.
Issue #201
b/25306826
Change-Id: I19d23d99d4ee72cb31fe5f233bac57a3a9cfc283