Commit Graph

280 Commits

Author SHA1 Message Date
Aaron Vaage 14e6b3a230 Create Upgrade Pattern
Create the pattern for how to handle database upgrades. As of this
change the only upgrade supported is from version 0 (no database).

Issue #1047

Change-Id: I9f889a9e39a190e926cf06f0720a5371bc3c59af
2017-12-14 14:53:48 -08:00
Joey Parrish 2e5b856f79 Do not require EXT-X-MEDIA-SEQUENCE in HLS live
Closes #1189

Change-Id: Iae6f4f4524bb9895f8b211491793cf7626661a5d
2017-12-13 18:49:03 +00:00
theodab 5f612bd1d3 Added an integration test for cast receiver
This adds a single integration test for cast receiver, as well as a
framework for adding more in the future.
This particular test pauses at each stage in Player.load where the
player could theoretically be polled to compose an update message, and
waits for an update message to be polled. This should help catch any
further null exceptions in the cast receiver that prevent update
messages from being sent out.

Issue #1162

Change-Id: If24486dd821275ab674960e559bd6d10776955a7
2017-12-06 13:45:17 -08:00
Aaron Vaage 464a34ba4b Add events to Cancellable Chain
Added onComplete and onCancel events to CancellableChain so that someone
creating it can invoke their own code when it is cancelled or completed.

This is needed for the work on IDestroyable.

Change-Id: I5c274356e952ecbd43dd5e8809a6d4cb4e5e85c5
2017-11-27 23:44:10 +00:00
Joey Parrish 88857c59aa Fix HLS playback where moof box is larger than 1k
When we started fetching partial HLS segments to find the start time,
we were no longer able to start playback for content with a moof box
larger than the partial segment.  This is because we parsed the boxes
hierarchically, which required the entire payload.

Now, we can selectively instruct the parser to tolerate a partial box
if the part we have includes the child box we are looking for.

This fixes playback of several pieces of HLS content in our demo app.

Change-Id: I956c8b8905dc9f1707f2b24b8248b984b1c036c6
2017-11-13 10:48:27 -08:00
Joey Parrish a93455a917 Make partial segment requests in HLS parser
This speeds up HLS stream startup significantly for servers that
permit this kind of request, and falls back to full segments for
servers that do not.

Closes #1106

Change-Id: I96bc7f0df0fb84b75f3a3fe43476ba0ba5fc2264
2017-11-07 19:44:35 +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 6129416370 Create ArrayUtils.count to avoid creating arrays
Rather than creating an array just to get its length, this change adds
a new array utility called count that will just count the values that
pass the given predicate.

Change-Id: Id2944f7bce7653c3dcf03ac3cbb3905ae5acb3d6
2017-11-01 23:41:58 +00: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 a35c2d621d Get timestamps from HLS TS segments
This adds a TS packet parser to find PTS values from the segments
themselves.

Issue #740

Change-Id: I267a9dbe5e4fc050ae63b5738c143a91cfa4f12b
2017-11-01 16:59:11 +00:00
Joey Parrish a18dc01874 Remove broken HLS time offset code
We misinterpretted the EXT-X-START tag before.  Now, we ignore this
tag and parse segment times from the segments themselves.  This is
more robust for both VOD and live HLS content.

We avoid segment parsing when updating normal, well-behaved live
streams.  For poorly-behaved live streams, we will fall back to
segment parsing and recover.

This also addresses the issue of VOD content which does not start at
zero.  Instead of using configuration to make this playable, we will
now offset VOD content back to 0 automatically.

Issue #740
Closes #1011

Change-Id: Ib3a59f87e3a050244cd39854409d8e3542c50b0a
2017-10-30 18:51:29 +00:00
Sandra Lokshina 113d9744a7 Add support for HLS playlists with type LIVE
Issue #740

Change-Id: Ia3dcdd29d8b85f5f1b266455d70a6cafbdc94757
2017-10-24 23:58:37 +00:00
Tim Plummer c2c3ff341d Replace setInterval with shaka.util.Timer
Use of setInterval has unpredictable behavior when the device goes
to sleep or is in a background tab. Adds a function to the shaka
Timer class which reproduces setInterval functionality using
setTimeout.

Change-Id: I0b2db8a5a9197527717bc4566c7beb109270f8ea
2017-10-20 11:56:35 -07:00
Jacob Trimble d125a54656 Use Uint8Arrays in text parsers.
This converts from using ArrayBuffer in the text parsers to using
Uint8Array.  This avoids doing extra buffer copies when using
ArrayBuffer.slice().

Closes #1022

Change-Id: I34a789ec4eb76c95169ba81f27a8433ef25f27f0
2017-10-03 10:36:48 -07:00
Jacob Trimble 1224464535 Use goog.DEBUG over COMPILED.
This allows including the extra assertions and logging in the debug
compiled library.

Change-Id: Ie8575a31b428e1985077939169bfae9254e395d5
2017-09-27 11:24:32 -07:00
Tim Plummer 775d755259 Remove deprecated @expose annotations.
Added externs for error.js and removed the @expose declarations from the
actual error.js file. Updated the jscompiler flags and docs.

Change-Id: I2aa95ef1c82fc7bd349c637cca3141d5a003b646
2017-09-26 13:51:36 -07:00
Jacob Trimble 3d259125c5 Use a custom cloneObject implementation.
Tizen 2016 throws when trying to use JSON to clone cyclic objects.  To
avoid this and to remove a hack to clone objects, this replaces it with
an explicit clone implementation.

Closes #935

Change-Id: Ia057e3f6853b813dd89fe33c291b558b71534726
2017-09-26 20:30:59 +00:00
Jacob Trimble 6069e76c4e Disallow ArrayBuffer.slice.
ArrayBuffer.slice isn't supported with two arguments on Tizen 2016.
This is a temporary fix that can be cherry-picked to v2.2.  A better
fix will be handled in a follow-up change.

Issue #1022

Change-Id: Iae6a0b2ef0cf17843f42f22f0ea0962a56e8be68
2017-09-25 17:28:19 +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 defc851283 Remove unnecessary functional utilities
The isEqualFunc and isNotEqualFunc methods in shaka.util.Functional
are no longer needed.

This removes the last two calls to isNotEqualFunc.  There were no
calls to isEqualFunc.  Both utility methods can now be dropped.

Change-Id: I9d4de215527982951e84162947ad9b17831eaf44
2017-08-14 11:41:33 -07:00
Joey Parrish 2af0de2adb Move streaming retry logic into callback
Closes #960

Change-Id: Ieeacbf2e25f53a5af25a1de1935085e43457a092
2017-08-10 20:27:53 +00:00
Sandra Lokshina 5f0a830c36 Reject HLS live content until we have support for it.
Change-Id: I57842758cf62ec05df0c552886b8a80d2c15b38e
2017-08-07 22:06:57 +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 b1f337a625 Add style attributes to shaka.text.Cue and TtmlParser.
Closes #927.

Change-Id: Ife2e241f8e91999ac0f4600766b0b0c04738c013
2017-07-19 16:13:56 +00:00
Joey Parrish 84a8d1ca18 Polyfill the HTML5 'input' event
The HTML5 'input' event does not work correctly on all input elements
in IE 11.  There are equivalent events that the UI can use on IE.

Instead of remembering this and checking for IE every time the 'input'
event is needed, let the polyfill translate the event type.

Change-Id: I23258a5c6a0bd37e946214380ad07949f3ee7f88
2017-07-12 12:29:14 -07: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
Joey Parrish 651b32a4ea Add detail to video errors in Chrome
This makes use of a new field added to Chrome 59.

Change-Id: I1b68e803967cfd7cfb64cea26458d0f3ef8a27c1
2017-06-20 16:49:59 -07:00
Jacob Trimble 7a5991a01d Fix date parsing when timezone is missing.
In DASH, when parsing a date, it should default to UTC.  When we pass
the date string to Date.parse(), it will use the local timezone.  So
if we don't see a timezone, we need to manually add the UTC timezone
so Date.parse() will parse the correct timezone.

Closes #901

Change-Id: Ica0433042e9bfd42b0cbf62653bdbd2b97b56297
2017-06-20 12:43:23 -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
Jacob Trimble 8835f7b898 Fix bug when trying to load when there are pending failures.
If you attempt to load an asset and then the first load fails, then
the second load will hang forever.  This was caused by the second load
trying to cancel the first, but the CancelableChain not handling this
case.

Closes #782

Change-Id: I79e201db44cbf47485e7221cc148bbfdde6276f7
2017-06-07 13:29:28 -07: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
Joey Parrish 8fdd2921dc Fix offline storage offline in compiled mode
We were giving Storage a Player proxy from CastProxy instead of a
local Player instance.  This fixes the mistake and adds a new error
code to make it clear when this mistake is made by other apps.

Change-Id: I4f2d49adc45ef5ca3a942a72192a09f001f5100c
2017-06-05 18:03:32 +00:00
Joey Parrish 434f1bf9b0 Choose lowest bandwidth codecs
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
2017-06-05 18:00:23 +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
Joey Parrish e8af210dab Clean up config merging, type check certs
- 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
2017-06-05 03:21:48 +00:00
Joey Parrish bb32073725 Fix PlayReady on IE and Edge
We broke PlayReady on IE and Edge in #815 when we fixed PlayReady for
Tizen.  This should work for both, but will still need to be tested on
Tizen after merging.

Closes #837

Change-Id: Iff41845ae6a4b369e8f21a80623ebb2cb5475fd6
2017-06-05 03:21:33 +00: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
Joey Parrish 494d6081fc Update Closure Compiler to v20170423
Change-Id: I28361a6c2d50087edc34695596731035a083543d
2017-05-16 17:19:27 +00:00
Joey Parrish eb92f14ab5 Add more missing exports
See also commit 7a770783.

This fixes exports and externs that were broken in v2.1.0 and v2.1.1.

Generated externs are now verified and working with an external
Closure project.

Change-Id: I73a6b92474c87fd6119592c6d632ce91045fc073
2017-05-12 14:54:41 -07:00
Joey Parrish 7a770783a8 Fix export of DataViewReader
DataViewReader is referenced in the exported class Mp4Parser, so it
must be exported as well.  This fixes broken exports and externs in
v2.1.0 and v2.1.1.

Change-Id: If94e623d36694dd528495f654bbb8f27d0b113ba
2017-05-12 14:24:50 -07:00
Joey Parrish f992851925 Don't recurse on serverCertificate in config merge
Treating serverCertificate as an Object and recursing causes an
exception the second time you set the serverCertificate config.

As a quick fix that can be cherry-picked for v2.1.x, do not recurse
on serverCertificate.  This has the side-effect of not type-checking
the serverCertificate field on input.

A more detailed fix will be made later, for inclusion in v2.2.

Issue #784

Change-Id: I84c05ee3dd370a4b83e9ce2337d2326ec36532c2
2017-05-08 23:46:38 +00:00