Commit Graph

255 Commits

Author SHA1 Message Date
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
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 938da032b5 Allow non-decimal formats in SegmentTemplate.
Fixes: 75988239
Change-Id: I023a1bd003662c6d651eb870b4aba025dc687327
2018-03-21 22:41:26 +00:00
Theodore Abshire 5ae80cc67d Typo fixes and rewording in comments, part 4
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: I5904ec91b96417a9ac5e19cb4f7b07a084f26ac8
2018-03-21 17:25:03 +00:00
Theodore Abshire dc17969822 Typo fixes and rewording in comments, part 1
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: I048b430e4c0bea2ccb9aec572d5e9ec6b606a87a
2018-03-14 17:59:26 +00:00
TheJohnBowers b0f7ba488e Warn if parsing the date from the UTC timing element fails (#1318)
Closes #1317
2018-02-26 15:05:35 -08: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 cfbbe485e9 Use seek range in Playhead.
Rather than using the availability window, Playhead should use the
seek range to restrict the playhead's position.

Closes #1224

Change-Id: I8612bfafb53bbb214e32aae2d71af52d748a3aee
2018-02-20 23:42:12 +00: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
Jacob Trimble c52884afed Fix 'var' scoping problems.
A follow-up fix changes all 'var' definitions to 'let'.  This fixes
issues caused by it.  One major change is adding brackets to case
statements.  Each case statement is considered in the same scope, so
defining variables in them actually are the same variable.  By adding
brackes to the cases, each case gets its own scope.

Change-Id: I99b1298223786f4df415594a2e64eb31d72b2053
2018-02-13 21:32:57 +00:00
Jacob Trimble 554cffc95c Fix SegmentTemplate w/ duration.
We incorrectly added the presentationTimeOffset to the segment times as
a fix for #1164.  The correct fix is to use the include the PTO in the
time structure passed to the text parsers.  This is a partial revert
of 207505.

Issue #1164
Closes #1232

Change-Id: I1f2805e0dbdc44be71e2160b3d37a73732c97a4f
2018-02-01 00:12:45 +00:00
Joey Parrish f428ec83fc Use OperationManager in HLS and DASH parsers
This adds OperationManager to HLS and DASH parsers to allow them to
abort and clean up network operations when stopped.  We now re-enable
the player integration tests that were written to prove the previous
polling-based cancelation model.

Issue #829

Change-Id: Id09df6e3f2f40eef614d9e597d35f43a50e1673e
2018-01-29 19:23:47 +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 a63352c8f3 [ES6] Enable stricter checks in eslint
This digests and organizes many of the automatic settings in eslint,
and changes several of them to be more strict.  This also fixes the
following errors:
  - array-callback-return
  - no-catch-shadow
  - no-multi-spaces
  - no-new
  - no-throw-literal
  - no-useless-call
  - no-useless-concat
  - no-useless-return

Several checks have been organized into a group of checks we should
use, but need more time to implement and fix.  Some other checks have
been delegated to the Closure compiler, which can more precisely
whitelist exceptions.

Issue #1157

Change-Id: I8fe4966959e08050f8159e6a1fee161e7d71177e
2018-01-17 21:56:41 +00:00
Joey Parrish 4067c20a7c [ES6] Replace gjslint with compiler linter & eslint
The eslint configuration is derived from analyzing the style of our
sources as they are now, plus a few tweaks.

In particular, we have disabled checks for undefined variables and use
of console, both of which the compiler handle with greater precision.
The compiler already knows what is defined in the environment through
our externs, and has specific exceptions for the use of console (demo,
tests).

We have also disabled a few checks that we should use, but will
require many changes to the code: no-unused-vars, no-redeclare,
and comma-dangle.

This commit also fixes several types of eslint errors that were easy:
  - no-useless-escape (unneccessary escape characters in Regexp)
  - no-constant-condition (using true/false/0/1/etc in if/while)
  - no-fallthrough (caught an actual bug in one EME polyfill)
  - no-irregular-whitespace (we had a UTF-8 nbsp in externs)
  - no-cond-assign (using an assignment inside a conditional)

To satisfy stricter provide/require checks in the Closure Compiler
Linter, we will no longer use provide/require at all in tests.  We
will still use provide in test utilities (test/test/util/) since it
sets up the namespace for us.  But we will not use require there
because there is no deps management for test code.

Issue #1157

Change-Id: Icc44f51feeb568ea7d3980e693e92e560d897afd
2018-01-16 17:25:05 +00:00
Joey Parrish 74316c37d9 Add missing require statements
These were not caught by the compiler due to aliases used to access
them, but they were caught by some new linter tools I am trying to
integrate into the build.

Change-Id: I343d155d43285e8244376b95c95b08b5d4f2fa39
2018-01-03 22:29:45 +00: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
Joey Parrish 20750504fe Fix presentationTimeOffset in SegmentTemplate
We were not previously applying presentationTimeOffset in
SegmentTemplate w/ the duration attribute.  This fixes the DASH parser
to correctly apply the offset in this case.

This also fixes an issue in which segment times could stretch past the
end of the period or even past the end of the presentation, causing
StreamingEngine to fail period transitions afterward.

Closes #1164
Closes #1163 (PR to address 1164)

Change-Id: Ib16fc2b65117557a4ad9a05adc4a07f8bc90fd3c
2017-12-13 18:46:28 +00:00
Jacob Trimble f0c85093b4 Only use mediaPresentationDuration to detect IPR.
We shouldn't use the sum of Period durations to detect the duration of
live streams.  It is possible for Periods to be added or the duration
to change, so the sum of Period durations is only valid for VOD.

Closes #1148

Change-Id: I53846807d18b97b0127eb75bb83be526eb7095ee
2017-11-22 12:55:47 -08:00
Joey Parrish e2aef50912 Disallow unknown "this"
This change enables an additional conformance check in the compiler
which prevents us from committing code where the compiler fails to
infer what "this" means.

None of these changes constituted actual bugs, just inference failures
in the compiler.

Issue #1130

Change-Id: If9b18203768e197258042a9b4339530f371ed831
2017-11-15 11:35:56 -08:00
Joey Parrish b54ca32835 Do not assume same timescale in manifest and media
According to the DASH spec, the timescale in the manifest need not match the
timescale in the media.  Therefore, we should be applying scaled
presentationTimeOffsets in segment index parsers, since the two scales might
differ.

Issue #1098

Change-Id: Ic191d1bba399b30a656ab5060d7bb226e659b79a
2017-11-09 21:37:17 +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 5166699e10 Fix PTO for SegmentBase
In DASH SegmentBase, we were not dividing presentationTimeOffset by
the timescale.  In all other instances of presentationTimeOffset in
DASH, we were handling it correctly.

This bug was present in all v2 releases until now.

The solution is not only to divide by timescale, but to rename all
internal uses of presentationTimeOffset to either unscaled or scaled,
to differentiate between those in timescale units and those in
seconds.  I believe inconsistent naming and units were a contributing
factor to the creation of the bug.

Closes #1099

Change-Id: Id561f8eb1f5bc011c606e1925c12f0d8183fd51a
2017-11-01 11:25:51 -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
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 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
Joey Parrish 015b4f456f Revert timeline correction code.
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
2017-07-31 10:42:33 -07:00
Joey Parrish 572c3bdd7c Parse DASH audio channels
Closes #424

Change-Id: I33f707784abb04c3feda3a3f3e3fbefa3dac2b01
2017-07-25 20:15:02 +00:00
Joey Parrish 4334b6ea90 Add mediaSegmentReferences to shakaExtern.Stream.
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
2017-07-25 20:13:42 +00:00
Joey Parrish 3062b72390 Tolerate bandwidth of 0 or missing bandwidth
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 #938
Closes #940

Change-Id: I0c9b8eba923971f00946282cd8c138f68827961f
2017-07-25 08:24:16 +00: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
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
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 98f3f3e218 Support MIME and codecs on different DASH elements
This fixes the detection of content type for text AdaptationSets which
contain mimeType only, but contain a Representation with codecs only.

Closes #875

Change-Id: Ibae7ae8357653c1960daefa4c3e122187de51bb3
2017-06-15 11:03:46 -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
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
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
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
Theodore Abshire bdae795ae9 Fixed bug with nested relative xlink links.
Before, if a relative xlink contained another relative xlink,
the nested xlink link would resolve its URI based on the filename
of the parent link, rather than its final URI.

Change-Id: Ic42ad8bfbd8487b4d1da66d86117823800c447be
2017-05-09 21:47:32 +00:00
Theodore Abshire b641a24acf Removed uses of .children from processXLinks.
Element.children does not work on IE or Edge, so all uses of it
were refactored to use .childNodes instead.

In addition, Element.children was added to the ban list, to prevent
further problems like this in the future.

Closes #792

Change-Id: I33009f77dbb1f4afa9847e31b57fda324baba472
2017-05-09 19:15:50 +00:00
Theodore Abshire 723e6ad1bc Added basic xlink support.
This adds a utility to mpd_utils.js that filters a manifest and
automatically downloads and substitutes in the contents of any xlink
link.

This only supports xlink:actuate="onLoad"; "onRequest" would require
significant changes to our manifest processing pipeline.
It also adds a new field to INVALID_XML errors to indicate which
xml was invalid, to make the error more informative when called on
xml loaded by xlink links.

Also added a demo asset.
This is just a simple modification of heliocentrism to break it into
multiple files.

Closes #587

Change-Id: If87b1e78e65261dcc4e043b0c2e6cf69c1b12e08
2017-05-08 14:00:56 -07: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
Theodore Abshire 5985dced7c Added another XML parsing validity check.
Different browsers implementations of DOMParser handle invalid XML in
different ways. In some cases, instead of the DOMParser erroring it
just inserts a <parsererror> element into the resulting xml tree.
This change detects if there was a typo deeper in the manifest, such
that the outer MPD tags are intact.

Change-Id: I9b11b0762d073b8e54129cddd5f3477039f2cb39
2017-04-17 20:41:43 +00: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 72c61ed785 Handle gaps between Periods.
Now the DASH parser will remove gaps that appear between Periods.
It removes the gaps by adjusting the duration of the previous Period
to fill the gap.  Because it affects the duration, the last segment of
the Period will also be adjusted. This only affects the segment index;
if this adjustment results in gaps in the media, they will not be
jumped (yet).

Issue #555

Change-Id: Idd2cd7ad960855be01565615c8917f7191b29503
2017-04-05 18:45:58 +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