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
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
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
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
- 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
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
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.
Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
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
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
The player unit test setup creates a fake StreamingEngine, which
responds to a request for the current period by returning a value
captured in an anonymous function.
Because of this, any test which loads a manifest other than the
"var manifest" at the top will result in inconsistencies between
the current period known to the fake StreamingEngine and the manifest
loaded by the Player instance.
This makes sure all tests in this file are using the same "var
manifest", even if they overwrite it.
This is not the best fix. The Player unit tests should be
restructured so that the fake StreamingEngine is always consistent
with the Player instance it belongs to.
Change-Id: Iad3b61006de3dcf902334f5348cd51fe7b5f8db4
For some platforms and CDMs, such as PlayReady on Chromecast, there
are no key statuses. We still get a key status event, but there is
not even a synthetic key ID. In these cases, do not restrict tracks,
as that would result in a 4012 error (RESTRICTIONS_CANNOT_BE_MET).
Closes#1070
Change-Id: Ib3a853418629433cc9be491a0cf7981dd41a3f59
When the user chooses not to show captions, we unload the text stream,
by canceling the update of text mediaState, and deleting the text
mediaState.
Since setupStreams_() is an async function, I'm adding a boolean
variable to mark the request of unloading text stream, so as to prevent
the race condition caused by quickly hiding and showing captions.
Closes#1058.
Change-Id: I554522b542bde5db037d74aa3a499d1ac0001151
Configure should only switch tracks if the current variant can't be
played under the new configuration.
Closes#1138
Change-Id: I1acb8bdbb0c8b41252e978bd17ef52bec1095844
getVariantTracks and getTextTracks both check values on
player.playhead_, but don't check if the playhead exists beforehand.
This leads to problems when casting an encrypted asset; the cast status
update will check getVariantTracks and getTextTracks before the
playhead exists, and the error will make the status updates stop
coming.
Issue #1128
Change-Id: If38e586b1ea3006c01d3556216f5333d9eaf6e17
If the user chooses not to show captions, we do not download text
streams, so as to save some bandwidth cost.
Closes#1058.
Change-Id: Ifd0d306680de7bd683405ad9b30b3c3c5c51097c
If the parser is failing to load a manifest, perhaps due to being offline,
and the player is destroyed mid-load, it will wait for all of the retries to
run out before canceling. This causes a significant wait time on destroy.
This change adds an optional isCanceled callback to the request method in
NetworkingEngine, allowing requests to be made that can be canceled via a
provided callback. This is then used to quickly skip past all of the
retries, when destroying the parser.
This doesn't stop any backoff in progress, so there still might be a delay of
a second or two (depending on networking settings, of course) if you destroy
during a backoff period. That will be changed in a followup CL.
Issue #1084
Change-Id: I0b99616ed4d5be078161122532ea271e84613170
We want to be able to write logs for deprecated APIs. This ensures
that those logs appear even when we disable logging in compiled builds.
Change-Id: I1f1546049fb17967eedb1bb45a7f76d5b1809cd1
When changing restrictions, we don't need to clear the buffers. This tests
checks that when we change the config to change the ABR restrictions,
we do not clear the buffers.
Change-Id: I04e360c7fdfa008d7ae9a8050974bcd28f1d3388
Closes: #1009
Adding an event right after the player parses the manifest, and before
initiating streaming, so that users can get the manifest information.
Adding manifest getter method in player so that customers can access
manifest information.
Closes#1043Closes#1074
Issue #1036
Change-Id: I0016c312bacdfa86299e5df68b586f90d565cfdc
Instead of destroying the TextDisplayer instance when the Player is
destroyed, it should be destroyed when the Player resets for another
piece of content. This way, old cues are removed before we start
streaming new media.
Fixes#984
Change-Id: I9f417682a6f79eb2190404876b0bcb4b670040ad
Applications should be able to call player.getStats() on any
non-destroyed Player instance. We were throwing an exception in
getStats() if called before load().
Closes#968
Change-Id: Idb32694a0502b52a4127e7179496dfd87192f017
Previously "UNPLAYABLE_PERIOD" exception is thrown when a browser
doesn't support the container or codecs in a piece of content, which is
confusing to developers and customers.
Changing it to "CONTENT_NOT_SUPPORTED_BY_BROWSER" exception.
Test manifest:
https://media-ci.foxford.ru/dist/hls-issue/issue.master.m3u8Closes#868.
Change-Id: Ied135b687190919abbeb1561c2bff36a7203136e
While I set out to fix failing assertions during playback, I found
many more changes necessary to clean up the code and make things more
consistent.
When we changed switch history to include variants instead of streams,
we broke the filtering logic that is applied to the history. This
caused assertions at runtime that were not caught by the tests.
This moves the filtering logic to addToSwitchHistory_ and makes it
aware of variants. It also adds a regression test that would have
caught the assertions.
This fix affected many other tests, though, which necessitated other
API changes and cleanup.
Many interfaces are simplified, as is switching logic in Player. The
data flow is also easier to follow, since there are fewer transitions
between variant and stream. Everything up to StreamingEngine uses
Variants, and StreamingEngine uses Streams internally.
- All stream-based interfaces on AbrManager replaced
- switch callback takes a variant
- chooseStreams replaced with chooseVariant
- setTextStreams has been dropped
- Player maintains compatibility with old interfaces until v2.3
- Most stream-based interfaces on StreamingEngine replaced
- onChooseStreams callback to Player returns variant & text
instead of a stream map
- switch was replaced with switchVariant and switchTextStream,
both of which delegate to switchInternal_, which is largely
unchanged from the original switch method
- still has getActiveStreams, which I hope some day can become
getActiveVariant and getActiveTextStream so Player no longer
has to convert anything
- Most stream-based logic in Player replaced
- deferred switches map broken into variant and text members
- switch history logging broken into simpler variant and text
methods
- simplified manual and automatic track selection logic using
new AbrManager and StreamingEngine APIs
- player no longer filters duplicate selections, StreamingEngine
handles that
- replaced one case of deferred switches with an assertion
Closes#954
Change-Id: Ia49f6ffb9c5fa13ed8790dd03eeeded5122f7683
This simplifies detection of audio-only content and makes the process
a little more obvious.
Closes#942
Change-Id: I89b599fb8c8915c9e1b45d2f9b81a3ac7193e5ef
This reverts commit 478fb1a473
("Detect and attempt to correct timeline sync issues") and commit
4334b6ea90 ("Add mediaSegmentReferences
to shakaExtern.Stream").
Timeline correction only addresses one class of broken live content,
while actually making it more difficult to diagnose other classes of
broken live content.
Issue #933
Change-Id: Ie71b8a45600ed0994626f53268fb90e336c3c62b
This uses the new mediaSegmentReferences field, if available, to
detect and attempt to correct common timeline sync issues. If the
most recent segment is outside the availability window, we make a
guess and move the window to align with the segments.
Closes#933
Change-Id: I1b9c444f82f9c526caf7a6942a758493d0adf9be
This will allow us, in many cases, to detect time sync issues in
content by comparing the media segment references to the presentation
timeline. If the references are outside the timeline, it may indicate
a common form of bad content, and we may be able to attempt to correct
it.
In some cases, the references are not available upfront. We can't
detect time sync issues in DASH with SegmentTemplate+duration, because
the references are not explicitly described by the manifest. We can't
detect time sync issues in DASH with SegmentBase, because the segment
index requires additional fetching and parsing. (SegmentBase is not
used with live content, so this should be a non-issue.)
This only introduces the new data, but does not use it for detection
or correction yet.
Issue #933
Change-Id: If70b1bdbd3b08a7c8b7ae296da209737492dfe17
Although bandwidth is a required attribute in DASH and a bandwidth
value of 0 makes no sense, we can tolerate such content in many cases
and play it regardless. This used to work in v2.0.x, but stopped
working in v2.1.0 through v2.1.5.
Closes#938Closes#940
Change-Id: I0c9b8eba923971f00946282cd8c138f68827961f
The old interface is deprecated and will be removed in v2.3.
It should still work (with a warning) in v2.2.x.
Change-Id: I8f8bf092683f6c91ba17175316b463f537b993d2
In situations where there are variants with video and audio, and variants
with only one of the two, this filters out the less-complete variants.
This removes the possibility of the player switching to an audio-only
variant and breaking MediaSource. It also solves the regression where
audio-only variants have the lowest bandwidth and thus are chosen
preferentially on weak connections.
Closes#824Closes#861
Change-Id: Ic37543d98962ddd83a85224e26e5225d142b844e
This is part of adding a new conformance rule to add additional type
safety. This will disallow using properties of unknown types or using
unknown properties.
The first parts will be fixing errors caused by the new rule. These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.
Change-Id: I48335fc6659d3c33a6d55b00d087b59410c79cf7
The old definition using a union with a Function causes problems. The
compiler tends to treat this as an unknown type, so we loose type
safety. The new types ensure full type safety, at the cost of needing
to "convert" the spy when it is used as a function.
Change-Id: I98ebd9dffd9cb865d0cf5d03db0fb5d6ea001ed3
Adding the count of channels, as a new field for tracks and streams.
Used for HLS audio tracks.
Resolves#826.
Change-Id: I1448b4a8cfaf6dd798670bb2f0f3981d6c7e40c3
Our EME polyfills give a key status with a Key ID of '00' (a single 0
byte). This breaks the Player logic for restricted tracks since it
assumes that those are not playable. When we get this Key ID, we should
treat the key status as a global status, not for that specific Key ID.
Closes#884Closes#890
Change-Id: I392550227274fb321d2c223eb8d483a0a4733186
Before asking AbrManager to choose streams, we should choose codecs.
Choose the most efficient codecs, and do it after we have filtered
out the codecs that the platform cannot use.
Closes#841
Change-Id: Ifbdd22b33254d4584f77db6456ab238f7c04c755
- Make FakeStreamingEngine injectable by removing Period argument
- FakeStreamingEngine can now have its spies manipulated before we
call player.load().
- Do not poke into player's manifest_ and streamingEngine_ members in
chooseStreams(), since load() sets those already.
- Instead of setting activeStreams in the constructor, set them in
init(). This is a more accurate fake, and this is important for
upcoming tests related to early filtering, since filtering takes
into account the active streams.
Leads into a fix for #841
Change-Id: Ia893053490cde819e32907c7a1a2030c29022f62
- Fix isTypeSupported override in MSE unit tests
(Should not be a prototype method)
- Add isTypeSupported override in Player unit tests
- Fix a Player test that used to pass for the wrong reasons
(MSE type filtering instead of EME type filtering)
Change-Id: Ibb72957f3bdff62923f2b235e9b9e9a598353912
- cleans up config merging now that abr.manager has been removed
from the config
- uses thing.constructor == Object instead of
typeof(thing) == 'object', for better detection of anonymous
objects
- adds a default (empty) server certificate for type-checking
- treats empty certs the same as null (no cert provided)
Fixes#784
Change-Id: Ie833a1b3bf484d5f12f3ebf6d513ed51740bdc44