Commit Graph

838 Commits

Author SHA1 Message Date
Jacob Trimble c09deeeb5d Fix invalid assertion in StreamingEngine.
Change-Id: I2f32009e83efa101dff5ebb479da0c48eed79b51
2017-02-07 23:43:49 +00:00
Jacob Trimble dc55676650 Don't clear individual buffers in StreamingEngine.
Before, we would treat each buffer separately when deciding to clear
when seeking.  However, this can cause problems because the media
states can end up needing different Periods.

For example: we are in Period 2 and seek backwards into Period 1 where
we have buffered text but not video.  The text media state will need
Period 2 since it is buffered; but the video media state will need
Period 1.  For both states, the "current" Period is 2, so the video
state will try to handle a Period transition.  This will cause an
indefinite hang since text state will never need Period 1.

Issue #655

Change-Id: I9d03c0378481b412a79eef205cd647ec9895a8d7
2017-02-07 18:47:38 +00:00
Joey Parrish 6cfd337680 Remove unnecessary triple-equals usage
Change-Id: Ibfd76f8b36926e41e9bf2fd26b5bea16d3bd8f2a
2017-02-06 22:20:09 +00:00
Joey Parrish d1abc8b4c3 Remove outdated Firefox DRM workaround
Change-Id: I3a0228242e4b926ba6c466cd0a503a957272548e
2017-02-06 22:20:05 +00:00
Jacob Trimble 75acdde2e1 Add warning about not supporting the indexRange attribute.
Change-Id: Id97a1b7a57bc4ae0c74130ea09d1ff937222bd5d
2017-02-06 20:50:37 +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
Jacob Trimble a1b2e53e95 Fix bug when merging DrmInfo structures.
The member |initData| may be null or an Array.  When calling
Array.concat with a non-array (e.g. null) it will add a new element.
This results in an array containing null rather than the intended
empty array.

Issue #682

Change-Id: I76b7625a04327f0e236b523d7dc83e08385a7804
2017-02-03 22:58:06 +00:00
Jacob Trimble 79ea0f0854 Update documentation for Tracks.
Closes #679

Change-Id: I7a7fa6534f328a79fdce2b7b8cd6cd60fec210fc
2017-02-03 22:50:49 +00:00
Jacob Trimble eb1491da06 Fix bug with multi-codec content.
This is a slight revert/modification of d4f2566d.

We should be calling setVariants inside load().  This is because we
need to tell AbrManager about the last filtering (for MIME type).
However, we should be using the current Period, not the first Period
like it was originally.

Change-Id: I83e1a3fa71e0b19815697d02658913d9e6edeb04
2017-02-03 12:29:46 -08:00
Joey Parrish ad963069fe Fix exceptions in exported methods
All of these exported methods on Player should be callable on
non-destroyed Player instances, even before media has been loaded or
after media fails to load.  This makes sure we do not encounter
exceptions in these exported methods.

A follow-up on #677 and #678

Change-Id: Ia366c201da722f3e1d00935cc9de64d8a50883c8
2017-02-02 12:14:10 -08:00
Sanborn Hilland 4eb88dc8b2 Add guard to stop getAudioLanguages and getTextLanguages from failing (#678)
If no content has been loaded and therefore there is no streamingEngine
then these two functions will fail. Add a guard to check and return an
empty array if there is no streamingEngine.

Close #677
2017-02-02 10:49:25 -08:00
Joey Parrish 8ba088a38f Generate externs automatically
We were not able to get our externs generated by the Closure compiler.
There were many issues with the Closure-generated externs, including
the order of the externs and the replacement of record types and enums
with their underlying types.

We made a few attempts to patch the compiler, but could not get our
patches accepted upstream.

This change introduces a new script to generate our externs from
scratch.  It uses a JavaScript parser called 'esprima'.

Some interfaces need to be exported to the generated externs, but are
not actually attached to the namespace by the compiler.  For this, we
introduce a new annotation.  These are the currently-supported export
annotations:

 - @export: truly exported (attached to namespace) by the compiler
 - @expose: truly exposed (not renamed) by the compiler
 - @exportDoc: considered part of the exports in the docs
 - @exportInterface: considered part of the exports in generated externs

These annotations are now documented in docs/design/export.md

Change-Id: I33bf7384889c14c9edb0fa5f11caa7c4f4d79af6
2017-02-01 11:42:16 -08:00
Jacob Trimble b445e46f75 Add error for duplicate Representation IDs.
See https://goo.gl/BAM3mi

Change-Id: Iea49b78ecd299e992b60f3776ec5360c15d2cb62
2017-01-30 21:06:24 +00:00
Jacob Trimble b88a98a425 Don't use segments to determine buffered ahead.
Before, we would use the last appended segment to determine how much
we have buffered in StreamingEngine.  However, this causes a slight
difference between StreamingEngine and Playhead, which uses the
MediaSource buffered ranges.

If the video has a non-zero drift, StreamingEngine will think it has
buffered enough and will stop buffering, but Playhead will see the
buffered ranges slightly less than the goal and wait forever.

Issue #600

Change-Id: Ib68df5f8a84c15bcc8530f9db9c6b9a06e6a72ba
2017-01-30 21:04:44 +00:00
Theodore Abshire 354880c32e Fixed the keyIds field in drmInfo.
Now it is set in a more suitable stage of content parsing, thus
fixing a bug where the field would contain multiple copies of
every keyInfo.

Change-Id: I12875efa04c4e3ccbb459945091533006bd398fd
2017-01-30 20:25:14 +00:00
Jacob Trimble 3f4eb4a111 Add additional docs for AbrManager.
Issue #629

Change-Id: I9548c24078e07537ae4c1e6f28461c992f5f794e
2017-01-27 23:19:13 +00:00
Jacob Trimble d4f2566de7 Fix several bugs with multi-Period content.
First, Player should not call AbrManager.setVariants as part of load().
Before, it would set them for the first Period; however, this doesn't
work with a start time in another Period.  StreamingEngine will call
chooseStreams_ for the starting Period before startup finishes.

Second, we should handle Period transitions before we handle buffering
goal.  Before, we would wait until the playhead moves closer to the
Period transition even if we have buffered the entire Period.  This
can cause problems when seeking, especially with text content that
buffers quickly.  If we seek and we have buffered text but not video,
the pipeline will stall since text is waiting for the playhead to move
while video is waiting for the Period transition.

Lastly, it is possible for multiple Period transitions to occur closely
together.  If we seek into a Period that is not setup yet, and then
seek back to a Period that is setup, then the second transition will
complete and the first will override it once it finishes setting up
the Period.  We should stop any old transitions if another starts.

Issue #655

Change-Id: Iab8961c606a65487704c9f0efaa255db0e3dc942
2017-01-27 14:08:59 -08:00
Jacob Trimble 68e870dc9a Add support for EventStream elements in DASH.
This also makes the Playhead ignore duplicate regions.  This simplifies
manifest updates in DashParser by having it add every Event tag it
sees.  The DASH spec doesn't specify how we should detect duplicate
entries or how events are fired.  So to avoid firing all the same
'timelineregionadded' events on every manifest update and getting
multiple enter/exit events, we will simply remove duplicates.

Closes #462

Change-Id: If5d2c42bd6958567b2ec05ba1e9af252c95cf354
2017-01-26 21:56:07 +00:00
Jacob Trimble 6596a3d9a0 Don't use |session.closed| in DrmEngine.destroy.
If a session has been created but the license request hasn't been sent,
the session is not "callable".  This will cause the |session.close()|
to be rejected and the |session.closed| Promise to never resolve.  So
in DrmEngine.destroy, we should be using the Promise returned from
|session.close()| instead of |session.closed|.  The |session.close()|
Promise will only resolve once the |session.closed| Promise is resolved
so they are effectively the same.

Closes #664

Change-Id: Ia619740d1eb3fa8ca1bdf121574d1efb1ddbea26
2017-01-26 21:05:34 +00:00
Joey Parrish 406ca0aec3 Fix doubling of offset for segment-relative cues
When using segment-relative timestamps in VTT, the presentation
offset has already been factored into the segment time.  Therefore,
it should not be added again in the VTT parser.

Closes #595
Closes #599

Change-Id: I9d062af7a17859f6f3374ecf20369b361f3eac7b
2017-01-26 16:07:54 +00:00
Jacob Trimble 40a92b615e Don't use fudge factor for buffered ranges when seeking.
Chrome doesn't seem to support gap jumping immediately after a seek.
So when we detect how much is buffered after a seek, we should use the
exact ranges.  Otherwise we will be left with a small gap that Chrome
doesn't want to jump.

Issue #655

Change-Id: I2d853e0c2b95285013463f38cece56ea9ea56133
2017-01-23 12:17:59 -08:00
Joey Parrish c56ae07242 Use ConfigUtils.cloneObject to clone history stats
This cleans up the code to use the new utility for this and avoids the
need for a cast.

Change-Id: I2635d0c98f0f7d3caf3e302edd84bca9c8a35c57
2017-01-20 14:56:37 -08: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
Joey Parrish c391be5012 Add listenOnce to EventManager
Often we listen for an event once, then stop.  This adds a convenience
method to EventManager for this increasingly common pattern.

Change-Id: I1507a904a8dac10b8d89965b3a0f192ed8f9ae2c
2017-01-20 22:54:05 +00:00
Jacob Trimble 87c7d5d665 Add framework for events on the media timeline.
This add the groundwork for event regions that occur while playing.
When the playhead enters (or plays through) a specified region it will
fire enter/exit events for it.  They are not fired when seeking over.

Issue #462

Change-Id: I9e280796bd012ad74d0319aa2056c6f6aa28890d
2017-01-20 22:19:33 +00:00
Sandra Lokshina 0553f61528 Refactor HLS manifest text parsing into it's own class.
HLS parsing will be split into parsing the text of the manifest into
shaka internal objects and parsing those into a shakaExtern.Manifest.
This will make logic more clear and allow to test ManifestTextParser
independently of HlsParser.

Issue #279.

Change-Id: I44349966d3617e2d208185e3ad125ecea89732b4
2017-01-20 19:13:21 +00:00
Sandra Lokshina 87073c9afa Create ManifestParserUtil common to dash and hls parsers.
Both DASH and HLS parsers will be using resolveUris() and possibly
other methods in the future.
Create a ManifestParserUtil for the shared methods.

Issue #279.

Change-Id: Iaa5e32ec543a390341a54752563a9f27251f0832
2017-01-19 23:34:25 +00:00
Jacob Trimble 2ca962a33c Refactor ManifestParser.start to accept an object.
Rather than accepting multiple callback methods as separate arguments,
now start() will accept an object.  This will allow us to add new
callbacks without breaking backwards compatibility or adding
additional arguments.

Change-Id: I839cbb12e71c2e7270aa218802c79440c458e964
2017-01-19 22:54:09 +00:00
Jacob Trimble 7ca8b9a1fb Increase Playhead fudge factor for IE/Edge.
IE/Edge have problems with reporting the buffered ranges when we get
to the end of the media.  We use a fudge factor to determine if we have
buffered all the content.  It was too small which meant that we would
not detect end of stream correctly.  This increases the fudge factor
so we detect it correctly.

Closes #658

Change-Id: Ie9ecf8fd49eb716ffd8ccd9bcdff53b88356bbfe
2017-01-18 10:54:53 -08: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
Jozef Chutka ca299b2822 VTTCue polyfill (#643)
This adds a VTTCue polyfill for IE/Edge (3-arg TextTrackCue) and
Toshiba dTV (6-arg TextTrackCue).

Closes #635
2017-01-17 10:42:54 -08:00
Joey Parrish efa1108a19 Add additional docs for offline storage
This adds additional text explaining how to use the Storage API.

Change-Id: Icff55d6fe19e91f983ffb3e4a786f2beefe9ae8f
2017-01-13 00:56:49 +00:00
Jacob Trimble 66963dc232 Add tests for OfflineUtils.reconstructPeriod.
Change-Id: I936a0667de97b2210e9d32cde89c43561c81b4c8
2017-01-12 20:03:26 +00:00
Joey Parrish 5fb8b60422 Add support for Chromecast Ultra at 4k
Using a special API available on the Chromecast, determine if we can
do 4k.  If so, raise the hardware limit from 1080p to 4k.

Change-Id: I6e403cce5d9c43a22f1b76cf4d79661ac096dd82
2017-01-11 18:49:01 +00:00
Jacob Trimble ded62a8205 Add more tests and remove dead code.
This brings 9 classes over 80% branch coverage.

Change-Id: Id9edf22022c3f99d21fa6cad6df6994ee751079d
2017-01-11 01:20:19 +00:00
Torbjörn Einarsson a640f53d31 Fix parsing of white-space-only div in TTML (#650)
A div element with no timing and only whitespace should be considered empty.

Closes #646
2017-01-10 09:50:48 -08:00
Theodore Abshire 292fd9a0db Fixed a bug with resolve in the promise polyfill.
Now, when you pass a rejected or pending promise into Promise.resolve(),
it won't count as resolved.

Change-Id: Ib2ee6e12625753436bfeb0b418dd824df4bb422a
2017-01-09 21:10:32 +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
Sandra Lokshina 8afadb4773 Add HLS objects and basic routines to parse manifests into them.
Issue #279.

Change-Id: I5b6f90b682d77849ce075a2a76a4202c56e5d882
2017-01-09 10:50:55 -08:00
Joey Parrish f561163de4 Stop playback on an unplayable period
When we call this.onError_() directly, the load() pipeline will
continue even in a case where it should not.  By throwing the error
instead, we force load() to stop before issuing additional, confusing
errors.

b/34127751

Change-Id: I9c5e1412711b08407c976aeec2fcd01abcf73456
2017-01-09 17:41:34 +00:00
Theodore Abshire 8b2212c65d Enabled asynchronous response filters.
Also updated externs.

Issue #610

Change-Id: I4c9539442d6fb77781296ea1acf123b3653e3b40
2017-01-09 17:34:22 +00:00
Joey Parrish 2cfaf366e9 Add missing events and methods to cast proxy
The emsg, loading, and unloading events were present in v2.0.0.
The drmInfo, isInProgress, and keySystem method were also present in
v2.0.0.  The getPlayheadTimeAsDate method was introduced in v2.0.1.

None of these were proxied to the cast device until now.  All v2.0.x
events and methods are now being proxied.

Change-Id: I6fba60f4ca451053c1449cafcddd9c1006292ad9
2017-01-07 00:14:41 +00:00
Theodore Abshire 07c564b4a2 The http plugin now fails on 202 status codes.
Closes #645

Change-Id: Ie20d1de1e8eff30d7656886e2b85d0e39079774a
2017-01-06 21:37:59 +00:00
Theodore Abshire 07ce75273e Allowed network plugins to see the request type.
Closes #602
Change-Id: Ib86389956c4908d94184abe8775d497b09a5f90e
2017-01-06 21:23:09 +00:00
Theodore Abshire 9153f68ab3 Fixed a bug with removing pending requests.
In some cases, the networking engine could have attempted to
remove a pending request that did not exist, thus removing other
requests.

Change-Id: I08fb9c11c3dd153af7a148fcb591fe5c0c3634a1
2017-01-06 18:59:59 +00:00
Theodore Abshire abca628239 Added support for asynchronous request filters.
Closes #610
Change-Id: I10d407d6c858f6541e869b834877a2ebbc516694
2017-01-05 15:49:49 -08:00
Joey Parrish fc7d04c0cc Skip parents with unrecognized EssentialProperty
Any EssentialProperty element we don't recognize is necessarily
attached to something we don't know how to handle correctly.  We are
now following the recommendations in the specs which say that the
parent element should be skipped in these cases.

Change-Id: Iabd8a796c6c27e4187b3f0d7efe60ea35c933c7e
2017-01-05 21:17:13 +00:00
Joey Parrish c6451690e6 DASH trick mode support
Parses DASH trick mode tracks and puts the extra trick mode Stream
into the manifest.  StreamingEngine can now use this info to optimize
streaming during trick play mode.

Includes:
 - a new demo asset with a trick mode track
 - updates to tests (we now require at least one audio or video stream
   and we require bandwidth attributes on them)
 - updates to the parser's trickmode test
 - a new StreamingEngine test

Closes #538

Change-Id: Id38264ca64bc7905a5c33a269269741cfd12dd4d
2017-01-05 04:45:10 +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
Joey Parrish 2a69c78e96 Be more permissive of text failures
Now, the ignoreTextStreamFailures config applies to parsing errors as
well as network errors.

We also no longer count text streams against the startup phase.  Early
text failures will not prevent StreamingEngine from switching, without
regard for the presence of the ignoreTextStreamFailures config.

Issue #635

Change-Id: I6818ef021beabfbc8742a7b013fa0424b77cff47
2017-01-04 22:08:29 +00:00