Commit Graph

33 Commits

Author SHA1 Message Date
Joey Parrish 25971503fa Don't update DASH faster than a device can manage
For slow embedded devices, such as the v1 Chromecast, updating the
DASH manifest takes far too long.  The result is that we can sometimes
repeatedly fall out of the seek range when playing near the left edge
of a live stream.

Until we can dig into and optimize the DASH parser, we will detect
and adapt to slow parsing by updating the manifest less often.

This is done based on how long updating actually takes, and does not
hard-code either the platforms that need this workaround, nor the
frequency of updates they can handle.

Bug: 75276747

Change-Id: I6565192b4ce6935ee8416ea4843fee851f4bd990
2018-03-28 22:48:07 +00:00
Jacob Trimble 064089152b Remove spacing around object definitions.
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.

Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
2018-02-21 13:35:00 -08:00
Jacob Trimble 29f39077dc Convert 'var' to 'let'/'const' (2 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: Iebba756b5d0e68c41292ecabda89503682d8d434
2018-02-14 00:38:06 +00:00
Joey Parrish 82357486a6 Replace buggy Promise polyfill
A bug in our Promise polyfill caused issues with the recently-added
AbortableOperation class on IE11.  Since external polyfills for this
are smaller, it is easier to remove ours in favor of a third-party
polyfill.  Applications that wish to support IE11 must now load this
additional polyfill.

We are using the "es6-promise-polyfill" module from npm, but any
compliant polyfill should suffice.

One feature our own polyfill offered was the ability to flush all
Promises, which allowed us to write synchronous unit tests that
simulated async processes.  To get this ability back, we are now
using the "promise-mock" module in our tests.

Getting "promise-mock" to load correctly involved switching from
"requirejs" to "cajon", which builds on requirejs and supports
AMD modules more directly.

Closes #1260

Change-Id: I5de48e88a910736ae5c1897a7a509bc5641acb70
2018-01-30 23:10:04 +00:00
Joey Parrish 2f55d2a3bd Use AbortableOperation in networking
This uses AbortableOperation in all networking, from the scheme
plugins all the way to the request interface.

This also updates all default scheme plugins, docs, and sample code.

Backward compatibility is provided for scheme plugins and the
request API in NetworkingEngine.  This compatibility will be
removed in v2.5.

Two cancelation-related tests have been disabled in
player_integration until the new abort interface has been adopted
in the manifest parsers.

Issue #829

Change-Id: I91c8e6efe97798d111e8ddca5655cddc1f6bcbf3
2018-01-29 19:23:47 +00:00
Benjamin Wallberg cf3e1e3337 Change so that default presentation delay for DASH is configurable (#1235)
It is useful to have the default presentation delay configurable when the stream provider isn't able to add `suggestedPresentationDelay` in the manifest

Fixes #1234
2018-01-22 09:31:22 -08:00
Joey Parrish 073ba6f67e Fix SegmentTemplate w/ duration for live
When calculating segment references, the end time should be capped at
the period's end, except when the period has no end.

Closes #1204

Change-Id: Ia608452706bbc3fd847a645197e8a0cb57d7aaec
2017-12-23 00:32:49 +00:00
Theodore Abshire cbdf76d6aa Skip manifest load retries when destroying player
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
2017-11-06 18:42:33 +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 051531b80f Add support for HLS playlists with type EVENT.
HLS Live comes in two flavors: LIVE and EVENT.
EVENTs append segments to the end of the playlist, but do not
ever remove segments. LIVE can both append segments to the end
and remove segments from the beginning of the playlist.
This CL lays the ground for supporting both types and introduces
support for EVENTs.

Issue #740.

Change-Id: I2042660daf9d1e7209cb1b40f50ab8b24571faa4
2017-08-22 19:02:04 +00:00
Joey Parrish 6bc4b65f83 Fix duplication of DASH periods on update
This fixes a bug in which we did not track DASH period IDs during the
initial manifest parse, which led to duplication of all periods during
the first update.

Closes #963

Change-Id: Ife9be7e5f5e158a565b0095d7cbb81b50c681422
2017-08-14 10:10:08 -07: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
Jacob Trimble adb8da4764 Disallow unknown properties (1/5).
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: Iefde089b2f62ddfdf43944cda5badab438577561
2017-06-27 19:43:00 +00:00
Theodore Abshire 1e119e40cf Adds option to fail gracefully on xlink failure.
At the moment, when there is an xlink problem, the manifest parser
returns a rejected promise. This adds a configuration variable to
instead simply not replace the xml tag.

Closes #788

Change-Id: Iace953233c83a57820130033150e7cd9a9385d6f
2017-05-25 21:10:09 +00:00
Joey Parrish 0371210a14 Clarify DASH minimumUpdatePeriod
A missing minimumUpdatePeriod should mean "do not update" or "only
update via emsg box".  Internally, this is represented by -1.

A minimumUpdatePeriod of zero will be clamped to our internal limit,
which is 3 seconds.

This adds comments and new tests to cover these scenarios.

Change-Id: Ic1e74e0edf3a5f7bf5aed21c7740dbd33eab84ac
2017-04-24 09:35:43 -07:00
Jacob Trimble e5ce395f37 Implement gap jumping.
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
2017-04-17 18:15:23 +00:00
Sandra Lokshina b14867bc65 Add config to ignore key system and init data in DASH manifest.
Closes #750.

Change-Id: I551a671eb153428f7d9a7900bf9b47cb37694f95
2017-04-17 17:22:37 +00:00
Jacob Trimble 575f2ad109 Add an indicator for critical errors.
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
2017-04-04 23:57:59 +00:00
Jacob Trimble 67c874c2ca Fix some test contaminations.
There were two instances of tests not cleaning up correctly.  The
Dash Live tests didn't uninstall the Promise polyfill, which breaks
Promise.resolve for tests that don't expect it.  Also, in the
CastReceiver tests, it defines a property on window.  It needs to be
configurable, otherwise it cannot be set twice.  Somehow the resulting
exception is not being caught by jasmine.

Change-Id: I0691a7bcddf14fd455f034d63e12fc8046044750
2017-03-28 12:16:08 -07:00
Sandra Lokshina c6729d7c14 Add hls config with default time offset.
Apple encoded content has a default time offset of 10 seconds.
Every other packeger we've encountered so far doesn't.
New config will default to 0 and allow the application to specify
the offset for their content according to the packager's standards.

Issue #279

Change-Id: I65b16b05a5974a2f0318cd1f9847c3a56c38b745
2017-03-02 13:32:17 -08:00
Jacob Trimble db236cb6fb Don't use SPD to determine availability start.
Before we would use the suggestedPresentationDelay attribute when we
determined the availability start, which is incorrect.  This can be
seen by loading the DashIF live simulator streams and seeking to the
beginning of the seek range.

The DASH spec doesn't explicitly state this either way.  It seems to
suggest that suggestedPresentationDelay is only used to synchronize
playback and isn't used to calculate segment times or availability.
The spec also says that clients can ignore the attribute and use their
own, which suggests that it shouldn't affect availability.

Change-Id: I44d23a556c1aa40c42e2893718f8da1d3a373e8d
2017-02-16 18:52:14 +00: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 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
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 aa00166277 Remove dots from test suite names
These are confusing the build bot's parser for the junit reports
karma generates.

Change-Id: If38355bcd6b9adfb1e1c995d79eb47a80cab8a48
2016-11-29 11:15:56 -08:00
Joey Parrish 54dfe329b8 Fix missing semicolons and missing dependencies
These issues were identified by an upcoming release of the compiler
and must be fixed before we can upgrade.

Change-Id: I8cf3af90b930f2adfa9760299fe69f1892614bf2
2016-09-30 16:54:53 +00:00
Joey Parrish 5389501197 Improve live edge startup
This fixes the definition of start time to exclude the rebuffering
goal. It also gives us a more conservative default presentation delay.
Content providers should always strive to provide a presentation delay
for their live streams.

Closes #504

Change-Id: I5a373666f4e325cc056ab2336d236b207430bde6
2016-09-03 10:48:03 -07:00
Joey Parrish eafe954d0c Replace Number.POSITIVE_INFINITY with Infinity
This is supported on all browsers, is more compact, and is easier to
read.

Change-Id: I96576dc341e093b7be9ef94fe36595c945b063c1
2016-08-29 18:56:54 +00:00
Joey Parrish c7e73e0115 In-progress recording (IPR) support, phase 1
This change creates a new model which divides DASH streams into VOD,
IPR, and live.  It is possible to create manifests which do not fit
into any of the three categories according to our model, so we now
assert that our input fits cleanly into one of the three.

Inline manifests used in our tests had to be updated to conform to
the new model.  All external test assets have been verified to fit
into these categories.

This is phase 1 of IPR support.  There should be no behavior change
in this CL.

In phase 2, we will make various other parts of the library aware of
IPR so that IPR-specific behaviors can be achieved.

Issue #477

Change-Id: I395d3a0c8c9825a3cd2efde263b8493ce0920ed9
2016-08-29 11:09:45 -07:00
Joey Parrish 1ba2ebb23e Simplify and speed up fakeEventLoop with polyfill
Forcing the use of the Promise polyfill allows us to remove the hacky
parts of fakeEventLoop and gives a huge boost in speed for the tests
that use it, particularly on Edge where the delays were large.  Many
fakeEventLoop tests can now run synchronously.

Time to run tests in our lab before this change:
  - Edge: 21 minutes
  - Safari: 6 minutes
  - Chrome, Firefox, Opera, IE: 6-7 minutes

Time to run tests in our lab after this change:
  - All browsers: 5-6 minutes

This also reduces the incidence of Safari failures in our lab, but
that issue does not reproduce on other machines.  It looks
increasingly likely that our lab machine is faulty and needs to be
replaced.

Change-Id: I7bdcc6830c8fdf298538ce6538b1ca8e1b92cab2
2016-08-18 19:51:48 +00:00
baconz 651b3fb68d Do not prematurely evict segments from multi-period manifests (#483)
presentationTimeline.getSegmentAvailabilityStart() yields a start time
relative to the AST, but all of the reference start/end times are relative
to their PTO. We need to normalize the start time to the period before
we evict any segments.
2016-08-16 12:44:17 -07:00
Joey Parrish d0908fe743 Raise the async test timeout to 120s
All tests now have the same timeout value.  This should simplify the
process of addressing timeouts on Safari.

Change-Id: I3b455bd639758007ec8b2b86ef236c56e919c15a
2016-08-11 10:54:49 -07:00
Leandro Moreira a8c44da4b1 restructures test files 2016-07-01 09:53:30 -03:00