Commit Graph

52 Commits

Author SHA1 Message Date
Joey Parrish 6bdbebfa47 Minor cleanup of null checks on non-nullables
Change-Id: I924c267be2b8fc689391ed888f08707e0bd574e0
2018-04-09 18:05:04 +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
Theodore Abshire 7c5186332b Typo fixes and rewording in comments, part 7
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: I225f5c7e54adf4cca8512cddae082ba50ed82e4e
2018-03-21 19:45:15 +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 f70436540c Convert 'var' to 'let'/'const' (3 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: I10f5c38a8b06b5797c6eec7492829084114514c9
2018-02-14 00:47:03 +00:00
Joey Parrish 529e97fbf2 [ES6] Configure eslint with Google style checks
Some style rules are temporarily overridden until we can get in
compliance.

Issue #1157

Change-Id: Ie27be6ec6632b7786a1f9ebc32911ba9dcd42599
2018-01-18 00:01:05 +00:00
theodab d6773da99b Prefer no role text streams when no preferred role
Beforehand, if there were some text streams with a given language
which had a role, and some which did not, the no-role text streams
would never be chosen.
Now, they are chosen if there is no preferred role.

Closes #1212

Change-Id: I28b426304b1a828f500012425b8d89c94ccc3178
2018-01-04 22:26:57 +00:00
Aaron Vaage 6c89a36fa7 Changed filterStreamsByLanuageAndRole to take streams
Before, filterStreamsByLanguageAndRole would take a period, this changes
it to take an array of stream to better match the function name.

Change-Id: I4621f98ff17d8d1c3c95162217eef9b8cf7aaebc
2018-01-02 17:28:11 +00:00
Aaron Vaage d98df7e244 Changed filterVariantsByLanguageAndRole to take variants
Before, filterVariantsByLanguageAndRole would take a period, this changes
it to take an array of variants to better reflect the function name.

Change-Id: Ic090baf4a281798ec855e369b0b4acdf519fee14
2018-01-02 17:28:11 +00:00
Aaron Vaage d49c07bcd4 Isolate conversion of variants/streams to tracks
Create functions in StreamUtils to convert from variants/text to tracks.

Change-Id: Ie142c129fb512b2d3dab5c0607e31485e9322e11
2017-11-03 18:47:08 +00:00
Aaron Vaage f4d655deb1 Changed filterNewPeriods to take audio and video separately
To prevent us from packing and unpacking audio and video from an object
this changes filterNewPeriod to just take audio and video rather than
a map.

Change-Id: I152f2b1762d4ff9ce21cb5b501579bca315e4e4a
2017-11-01 17:18:22 -07:00
Aaron Vaage 9f2e3fbcf3 Changed Stream Utils To Use Filter
Originally some of the logic in Stream Utils was iterating over elements
manually and doing its own splicing and index manipulations. This changes
it to use array.filter so that the logic is simpler.

Change-Id: I2a8d1db9336a574e0992e0de430afd006dea4846
2017-11-01 15:25:26 -07:00
Aaron Vaage fb6907575d Changed how isStreamCompatible is formatted
Changed how isStreamCompatible is formatted to make it easier to read.

Change-Id: Ic40754095ad25a8c91942fd13565f3d3ccc36377
2017-11-01 22:21:08 +00:00
Aaron Vaage 81cad159c3 Renamed functions to be questions
There were two functions is stream utils that were used to check
for compatibility. However they were named as statements, and this changes
them to be named as questions.

Change-Id: I0ca7e4a6597910a8f65192c50b9def895e2ac437
2017-11-01 22:20:58 +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 72c07b35e2 Never adapt across roles or languages
This adds additional logic and tests to filtering in StreamUtils.

Closes #918
Closes #947
Closes #949

Change-Id: I4cce0e0dd5d247e1eaadf7401116cdafb72c7259
2017-08-04 21:11:58 +00:00
Michelle Zhuo d67764b5ff New Error Code for Content unsupported by Browser
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.m3u8

Closes #868.

Change-Id: Ied135b687190919abbeb1561c2bff36a7203136e
2017-08-04 11:07:07 -07:00
Joey Parrish 7e0f46931e Overhaul variant-based and stream-based interfaces
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
2017-08-03 21:34:47 +00:00
Sandra Lokshina b3586c193a Add stream bandwidth info to variant tracks.
Closes #834.

Change-Id: I3af66a227ad09f1686a7ca3f545c2bf9683d3c24
2017-07-07 10:20:54 -07:00
Jacob Trimble 310e48f8cc Fix rounding issues with multi-Period content.
Closes #882
Closes #909
Closes #911

Change-Id: Id31567137860b6bd683169b5b68ca83d6f14473d
2017-07-05 16:57:42 -07:00
Michelle Zhuo f09999aa80 Add channel count information for HLS audio tracks
Adding the count of channels, as a new field for tracks and streams.
Used for HLS audio tracks.

Resolves #826.

Change-Id: I1448b4a8cfaf6dd798670bb2f0f3981d6c7e40c3
2017-06-22 11:34:36 -07:00
Michelle Zhuo 00b440f376 Support audio track selection by role and language
Exposing the roles of tracks, which come from the manifest, in the
select audio language method. This is a follow up on commit
b27861050c11451db57d87270ec1385c1906627a.

Closes #767.

Change-Id: Iebb873f1db8834c7275a8a9fc01c3b855c0288aa
2017-06-15 22:41:21 +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
Matias Russitto ace0e8cf49 add video and audio stream IDs for getStats().switchHistory (#846)
Closes #785, #823
2017-06-05 10:29:55 -07:00
iKinnrot bed012dc3c Add label attribute to text track (#831) 2017-05-31 13:54:57 -07:00
Michelle Zhuo afb0ded49c Expose Roles of Audio Tracks
This change is to expose an audio track's role in order to differentiate
among a main / caption / commentary track that shares the same
language.

Issue #767.

Change-Id: I05d38cba2170d0005611cf160b7ae45996fe77dd
2017-05-26 13:51:43 -07:00
iKinnrot 151930284a Add support for DASH label and HLS NAME attributes (#811)
* add support for non-standard DASH label attribute
* add support for HLS NAME attribute

Closes #825
2017-05-25 10:43:07 -07:00
Michelle Zhuo b65cf1de81 Separate audio codec and video codec in Track
The audio and video codecs were combined in Track, so it's hard to
detect whether the track variant has video or audio track.
Changing the combined codec to two separate fields.

Closes #758.

Change-Id: I9fbd0b85830cac306dc09db2d71cf96f77146cbe
2017-05-05 17:32:20 +00:00
Jacob Trimble d4d4347dd5 Add configurations for gap jumping.
This adds the new configuration options that will be used in gap
jumping.  This also changes Playhead to accept the config over the
rebuffing goal directly.

Issue #555

Change-Id: I467690ad1f417e69634087e04e0b44c98e1c9b81
2017-04-03 18:29:10 +00:00
Joey Parrish 58d9156be2 Update default track selection for offline
By default, we will now store all text tracks, regardless preferences.
This not only helps with our demo, but makes sense for applications
that have not bothered to configure the track callback for offline
storage.

This also fixes bugs in the default track selection algorithm,
changes the default audio track selection to fall back on primary
variants in cases where the audio language preference cannot be met,
and adds tests for the default selection algorithm to verify correct
behavior.

Change-Id: Iead0499039e9ec596514aa7577265a7472914621
2017-03-10 00:51:28 +00:00
Jacob Trimble 5f8bc48ddd Choose an arbitrary language when none given
Before, we would select every variant when there was no preference
or primary tracks.  This meant that AbrManager could adapt between
different languages.  Instead, we should select an arbitrary language
initially so we only adapt within one language.

b/36094412

Change-Id: I4670a8bf02683fb78cfe572992c6268ed32e649d
2017-03-10 00:12:26 +00:00
Sandra Lokshina 0b12937520 Replace content type strings with constansts.
Change-Id: I4fda583915766b40ee7a5c7451d037077d9f2582
2017-03-08 21:41:59 +00:00
Jacob Trimble 6b6bfb71a3 Track active tracks in Player.
Before, the Player would query StreamingEngine for the "active" streams.
The Player would use this to set the |track.active| field.  However,
this causes problems with multi-Period content.  Once StreamingEngine
has buffered through a Period transition, it will report the active
streams from the new Period.  This will mean that in
|player.getVariantTracks|, none of the tracks will be active.

Now, Player will track the IDs of the active tracks for every Period
so it can correctly report which tracks are active.

Closes #680

Change-Id: Ib5ffc88b32e165f088e6472930eeb1b29b5adfe9
2017-02-09 21:00:11 +00:00
Jacob Trimble bac8fb135c Use Playhead to determine when changing Periods.
Before, we would fire a 'trackschanged' event when StreamingEngine
asked us to select streams for a new Period.  However, this is not
when the tracks change, they change when the playhead moves into a
different Period.

This adds code to Playhead to track where the current Period is and
raise an event when it changes.  This also reduces any extra events so
a 'trackschanged' event is only fired when the tracks actually change.

Issue #680

Change-Id: I85aedaed737f9324d5871201d952066886ea290c
2017-02-06 19:38:22 +00:00
Joey Parrish 4d5e668583 Expand player stats and track metadata
Visible changes:
 - Add loadLatency stat
 - Add mimeType to tracks
 - Track state changes (buffering, playing, paused, ended)

Internal changes:
 - Track switchHistory, playTime, bufferingTime in private Stats struct
 - Remove dead timer code

Change-Id: I4566373251b9876b0d4f762a9d77aa50aea8ed00
2017-01-20 22:54:05 +00:00
Sandra Lokshina 23a23b9b36 Make language selection explicit. Split text and variant selection.
Add UI options to select current audio and text language.
Split selectTrack() into selectText() and selectVariant().
Stop automatically disabling ABR manager when a variant is selected.
Add a warning if selectVariant() is called while abr is enabled.

Issue #412.
Issue #626.

Change-Id: I15f1c3c4fdc6d6b641f708fbef19dbcf10cbcfc6
2017-01-18 00:05:52 +00:00
Jacob Trimble b28f84ccc3 Add separate restrictions to AbrManager.
This adds a second Restrictions object to the Player configuration to
restrict ABR decisions.  The original restrictions will remove any
non-matching streams from the manifest, like before.  This new
configuration will only apply to AbrManager choices.  Any restricted
track can still be explicitly selected using Player.selectTrack.

Closes #565

Change-Id: I52379b096e81f97df22b6683669c5787694d87e7
2017-01-09 20:25:14 +00:00
Joey Parrish e093ab2f3b Fix text filtering and cleanup MIME computation
During recent refactoring, we introduced a bug in which we would
filter out any text stream with a non-empty codecs parameter.

Replaces PR #639

Change-Id: I9a45ef7e1bc250fd989e3972c0670f3e48336511
2017-01-04 14:28:42 -08:00
Sandra Lokshina e95d7b9de4 Refactor shaka internals to use variants instead of stream sets.
Issue #279

Change-Id: Idf4241b4e2490876bdc6275685361a5c9bf132b0
2016-12-28 17:49:24 +00:00
Joey Parrish 7dc98a7d6b Fix DASH content type parsing
The DASH parser was not always correctly deducing the content type.

For unspecified content types, the type can be deduced from the MIME
type.  For example, video/mp4 is video, and audio/webm is audio.

For text, things are a little more complicated.  Text types do not
always start with text/.  In particular, embedded text, such as VTT
in MP4, have a MIME type that starts with application/mp4.

To deal with that, if we see an unknown type, we ask TextEngine if it
supports it.  If so, we deduce that the content type should be text.

This check against TextEngine was only happening for MIME types
specified on the Representation, but not on AdaptationSet.  This
replaces a weaker deduction in the general frame parser with the same
TextEngine check we were using elsewhere.

Furthermore, Player mishandled the content types it passed to
AbrManager.  AbrManager will only choose audio, video, and text
streams.  It ignores all other types.  Player, meanwhile, threw a
confusing error if AbrManager failed to choose some of the types
passed to it.  Therefore, Player should only pass audio, video, and
text types to AbrManager.

This fixes both issues and adds new unit tests for both.

Closes #631

Change-Id: Ib1311d37d00c3989367fd066f66e1eba85652e40
2016-12-14 22:10:14 +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
Jonas Birmé a060050564 Provide framerate and codecs information on video tracks (#533)
Closes #516
2016-09-28 14:13:54 -07:00
Joey Parrish 1fa69b2375 Filter text streams for compatibility
Type compatibility checks are important for multicodec or
multicontainer content, and there's no good reason to exclude text
from those checks.  The new Axinom v7 test vectors have multicodec
text (both mp4+VTT and mp4+TTML).

Change-Id: I999aaf5b37cda8a9243538b4dd21c503df33dcb9
2016-08-29 23:27:30 +00:00
Sandra Lokshina b9c362808d Define order of AdaptationSet preference.
When a piece of content has several StreamSets with the same
language and role, pick an audio set with lower average bandwidth,
pick a video set with the highest top resolution. Pick the first one
when the above is not applicable.

Closes #476

Change-Id: Id2cb9095994e8aa6b205024504a5d665f8656437
2016-08-15 18:56:32 +00:00
Joey Parrish b7af879583 Remove hasOutputRestrictions
If a key status is 'output-restricted', treat the key as unusable.
In many cases it is, and we have no way of differentiating when it is
or is not.  So our treatment of this status should be conservative,
and we should treat the key as unusable.  This will prevent
HDCP-related failures that may be caused by adapting to a stream whose
output restrictions may not be met.  The hasOutputRestrictions flag on
streams and tracks is now gone.

The caveat to this change is that if content is encoded with the same
key for SD and HD, and HD streams have HDCP restrictions that cannot
be met, we will now consider both the SD and HD streams to be
unplayable, even though we could still play the SD streams.  Because
we can't separate the status of the two streams, we don't know for
sure if the SD streams can be played.

We will no longer support such content due to the complexity of doing
so, and due to the risk of playback failures on adaptation to
restricted streams.  Streams with different security requirements
should always be encrypted with different keys.  Content which does
not follow this best practice will no longer be playable in Shaka
without modifying the player.

Change-Id: Ia29db8efa0b6f83c0376199dea5210c9b468bc40
2016-07-13 10:40:24 -07:00
Joey Parrish 3624d8e079 Limit Chromecast playback to 1080p
Original Chromecast devices can output a max of 1080p, and may have
issues digesting higher resolution content.  Since higher resolution
content would be downscaled for display anyway, limit Chromecast to
1080p to avoid both decoder issues and wasted bandwidth.

Some Cast devices may support UHD content, but the max res for
Chromecast is currently hard-coded until we have a way to detect a
device's capabilities at runtime.

Issue #261

Change-Id: I3dd093b07f9a964116f81422f3c298dfbf7e2e52
2016-07-07 19:28:48 +00:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07:00
Joey Parrish 0acc6deb5b Filter based on both mime type and codec
Some streams have the same mime type, but incompatible codecs.  For
example, mp4a.40.2 and ec-3.  Once a stream has been selected, filter
out incompatible codecs.

Closes #391

Change-Id: Id3f5521cb3f995d88d93255c0bc5cfda8e239fcd
2016-06-01 11:32:51 -07:00
Jacob Trimble d7824550d2 Drm support testing can be used to detect offline support.
Change-Id: I4a9ce4302583e84e2ff9613f790a63bdc5b57e3c
2016-05-17 20:06:19 +00:00
Timothy Drews be09f52f03 Fix "parser" property & improve load/unload.
* Set this.parser_ to the correct property in load()
  (stops old manifests from being fetched).
* Stop load() from unloading first when the Player is a new instance.
* Handle multiple repeated calls to load().
* Fully cleanup after partial loads.
* Add additional destruction checks.

Issue #369

Change-Id: I43d5ed90c8119b1040b87a0dc187f52738e1c683
2016-05-15 06:17:50 +00:00