Commit Graph

100 Commits

Author SHA1 Message Date
Álvaro Velad Galván 8f36ae50ec Add support for EXT-X-SESSION-DATA (#2642)
Resolves: #1460
2020-06-17 11:48:17 -07:00
Joey Parrish 7e6a0f38ff fix: Correct license headers in misc. files
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs.  This does not
affect the compiled output, and is only done for consistency.

Issue #2638

Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
2020-06-09 16:13:56 -07:00
Theodore Abshire 8d657140f1 Made ManifestParser.PlayerInterface.filter async.
This is a change in preparation for the adoption of the
MediaCapabilities API.

Related to #1391

Change-Id: If0988aedafe15aa3be794fb977fd8e04e91ca10e
2020-06-04 17:42:27 -07:00
Sergei Gridasov 2fdbd5b676 Add new option manifest.hls.useFullSegmentsForStartTime (#2575)
If true, forces HlsParser to use a full segment request for determining
start time, in case the server does not support partial requests.

Closes #2556
2020-05-19 08:24:04 -07:00
Joey Parrish 7bce3f452b Add support for null TS packets in HLS
The timestamp parser in our HLS parser should not fail on null TS
packets.  These are indicates by a packet ID of 8191 (0x1fff), and
according to the spec, should be skipped by any receiver.

We will not skip such packets and continue through the segment to find
a PES packet with a timestamp.

In addition to the comments in #2546, I found this document helpful:
https://www.mikrocontroller.net/attachment/27265/mpeg2ts.pdf

Closes #2546

Change-Id: Id9dc16160bbde03969199150ca50122f12de77f4
2020-05-15 20:35:34 +00:00
Álvaro Velad Galván 71b129977c Parse HLS CHARACTERISTICS attribute (#2534)
Resolves #1598
2020-04-30 14:57:20 -07:00
Joey Parrish 4eefaa44cb Correct type info in tests
In many places in the tests, we used "Object" or "*" or just no type
at all for various fakes.  These were all flagged by the new Closure
Compiler version we are adopting.

In some other places, we mixed up similar types or had the wrong
nullability on a type.

In still others, types were missing fields.

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I324e0b28f7e30a4102aa26ec2c9901fa9732211b
2020-04-30 16:00:17 +00:00
Joey Parrish 7ee124c2c1 Fix SegmentIndex usage and nullability in tests
The usage of SegmentIndex in tests was correct, but the latest Closure
Compiler is more strict about nullability.  We need to add assertions
and refactor to avoid nullable numbers where a non-nullable number is
required.  We also need to add assertions for the nullability of
Stream.segmentIndex after createSegmentIndex() is called.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: I5615ffa27b878f86739d507f993c2b66ae8eb61a
2020-04-30 16:00:08 +00:00
Álvaro Velad Galván e246855c63 Add variable substitution support to HLS parser (#2509)
Resolves #1561
2020-04-24 12:37:11 -07:00
Joey Parrish e8ac57f36c Move drmInfos array to Stream
Period-flattening will concatenate Stream objects, so this information
should be available per-Stream instead of at the Variant level.

Issue #1339

Change-Id: I96195fea48cab1e4a349b2ab0b16064a443e928a
2020-04-09 19:22:16 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
Joey Parrish 1ab3f9c6db Remove position from SegmentReference
As part of Period-flattening, I'm trying to remove our dependence on
the "position" field of SegmentReference.  With that eliminated, we
can more easily concatenate Arrays of SegmentReferences without
modifying them.

 - Make SegmentIndex iterable
 - Add specialized seek() and current() methods to SegmentIterator
 - Remove position from SegmentReference
 - Make positions in SegmentIndex API stable without field in
   reference
 - Remove brittle hard-coded positions in tests (except SegmentIndex
   tests, where they would be hard to avoid in testing methods
   separately)
 - Use SegmentIterator in StreamingEngine to track the next segment
   between switches

Issue #892 (refactor StreamingEngine)
Issue #1339 (period flattening)

Change-Id: I666cc21249c34ee6cbc138a59109d9f1159fa127
2020-03-23 10:09:35 -07:00
Joey Parrish 6202b9372e Revert "Move next-segment tracking to SegmentIndex"
This reverts commit 235e4e11ad.

The effort to remove SegmentReference's position field will be handled
in a different way.

Issue #892 (refactor StreamingEngine)
Issue #1339 (period flattening)

Change-Id: I62b115137abc89f498b30467e574b0401dcad05d
2020-03-23 10:09:35 -07:00
Joey Parrish 235e4e11ad Move next-segment tracking to SegmentIndex
As part of Period-flattening, I'm trying to reduce our dependence on
the "position" field of SegmentReference.  If it can be eliminated, we
can more easily concatenate Arrays of SegmentReferences without
modifying them.

SegmentIndex can now track the last reference you asked for and
iterate through the list of references.  This means we don't need the
"position" field of SegmentReference, which means we don't need to
know positions in advance or globally.  StreamingEngine will no longer
use position to request segments.

The old methods find(time):position and get(position):SegmentReference
have been replaced with seek(time), current(), and next(), all of
which return a SegmentReference and maintain an internal pointer to
the "current" reference.  Care has been taken to maintain that pointer
during the evict() and fit() operations.  Recent changes to merge()
made sure that the pointer does not need to change during that
operation.

All test updates are related to the SegmentIndex API change, not
changing expectations or behavior.

Issue #892 (refactor StreamingEngine)
Issue #1339 (period flattening)

Change-Id: I1682dcc2dd625c6e390711538e46d31e6eb6cea8
2020-03-11 18:14:14 +00:00
michellezhuo 2223710ac9 Support multiple EXT-X-MAP tags
One playlist may contain multiple EXT-X-MAP tags, and each EXT-X-MAP tag
represents the initalization information for the segments after it,
until the next EXT-X-MAP tag or the end of the playlist.

Issue #1335
Closes #2397

Change-Id: Ibb0b4f5da6a48f0303d205cb6bd3abad278527fd
2020-03-04 18:03:00 +00:00
Tijn Porcelijn 5025f2c789 Lower case codec string for IMSC1 Text profile (#2378) (#2381) 2020-02-06 10:54:20 -08:00
Joey Parrish 139aa4c4db Fix misdetection of HLS audio-only+group as video.
Closes #1875

Change-Id: I09c5f6cda31762992d9d76cadea8037f1245f5c3
2020-01-24 22:24:31 +00:00
Joey Parrish 1ee32849e4 Fix skipping of raw format streams in HLS
Raw, containerless streams can't be played yet (#2337), but our logic
for skipping or rejecting them was broken.  This broken logic affected
the whole v2.5.x series of releases up to and including v2.5.8.

This fixes the logic and improves it in several ways:
 - Skip streams that can't be played, instead of rejecting the whole
   master playlist
 - Handle raw AC3 and EC3, in addition to MP3 and AAC
 - Handle and skip WebM+HLS in the same way
 - Add the playlist and segment URLs to
   HLS_COULD_NOT_PARSE_SEGMENT_START_TIME errors

This allows us to re-enable the Apple HLS+TS asset as video-only.

Change-Id: Ia00857d87b085aa7e2b810b0b949993cebabe4ba
2020-01-17 12:28:08 -08:00
Jacob Trimble 011749e95f Standardize argument comments.
This changes the eslint rule to enforce a strict pattern for the
argument comments.  The comment must appear before the argument and
must be /* foo= */.  This still ignores line comments.

Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
2020-01-06 19:40:52 +00:00
Joey Parrish c13830e535 Augment SegmentReference with offset and window
SegmentReference used to have presentationTimeOffset, which,
subtracted from the period start time, was then _added_ to the
timestamps in the segment by MediaSource.

Now, SegmentReference has a timestampOffset field, which is exactly
what MediaSource's timestampOffset field is set to on the SourceBuffer
before this segment is appended.  For DASH, this is periodStart minus
presentationTimeOffset.

This also adds append window start & end times to the
SegmentReference.  Now segments can be appended to SourceBuffers
without reference to the period.

Note that start & end times of the SegmentReference in each segment
index are still relative to the period.  This will change in a
follow-up.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: I9d54eb2b529ec643c9475b8e9d218c3e2e826a26
2019-12-19 11:35:14 -08:00
Joey Parrish 4923622e88 Make SegmentReference comparison more general
There were fields in SegmentReference which were not being examined
when instances are compared by jasmine.  Now, the comparison is more
general and will continue to work when we change the structure.

This relates to the issues below because the next changes for those
issues will change the fields in SegmentReference.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)

Change-Id: Ib7cd3d3cadeb0e58efd70964c082219b1c097fad
2019-12-19 19:01:07 +00:00
Álvaro Velad Galván 8cbe54575a Allow disabling the text parsing, decoding, etc in DASH/HLS with a config (#2278) 2019-12-04 13:50:56 -08:00
Álvaro Velad Galván 05c03fcf64 Allow disable the video parsing/decoding/.. in DASH/HLS with a config (#2259)
* Add disableVideo configuration

* Add missing locale
2019-12-03 11:11:06 -08:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Álvaro Velad Galván 585c725d09 Allow disable the audio parsing/decoding/.. in DASH/HLS with a config (#2196)
Resolves #2195
2019-10-22 15:00:36 +02:00
michellezhuo ae6e67e136 [Hls] Add unit test for hls getStartTime_() optimization
Change-Id: I85177bc6f7af9479bcbb524030eea7ae81deb7ec
2019-10-02 10:49:40 -07:00
michellezhuo 9d66e3bb09 [Hls] Avoid duplicate calls to get segment start time for VOD
For VOD, the first segment of every Media Playlist in every Variant
Stream must start at the same media timestamp. Thus, we can get the
start time once and store the value, and all the streams can use the
value directly. For live, we assume for the same.
This change reduces calling getStartTime_() from 15 times to once for
Angel One, and also fixes the text segment timestamp issue.
Also removed associated methods that no longer needed.

Closes #1558
Closes #1563

Change-Id: I0e95ab93ea2b13758128f11019b262bc53dbcd38
2019-09-30 15:43:57 -07:00
Jacob Trimble c0e7a9b62a Use callbacks for ManifestGenerator.
This allows us to avoid suppressing the indentation rules and ensures
we have correct indentation.  It also makes it harder to make mistakes
since the variables are only accessible within the callback and you
can't accidentally contaminate another object with an incorrect call.

Closes #1692

Change-Id: Ic38b5cd57a2587dfc8c115ba782656c15565b655
2019-09-04 22:51:12 +00:00
Jacob Trimble bf5547b78c Refactor ArrayBuffer usage in tests.
Change-Id: I27e898a7d3c2d706e265abfc4b9bde88b67f3256
2019-08-21 20:44:36 +00:00
Jacob Trimble d7fc19ab31 Allow filtering out failed HLS text tracks.
This adds a separate configuration value for this because (a) the HLS
parser can't access the streaming configuration and (b) this behavior
is different in that the streams are removed instead of just not playing
them.

Closes #2065

Change-Id: Ic9b1e0d40b161cd4ba0eb6d7c922882112034626
2019-08-12 18:16:28 +00:00
michellezhuo 1d417ff5ed HLS Refactor: Flatten createPeriod_() logic
Our previous approach:
For every variant tag, find the associated media tags(with the same
group id), create stream info for each media tag, and then create stream
info for variant tag based on that, and create variants.
This approach has duplicate calls for the media tags with the same group
id to create stream infos.

New approach:
1. Get codecs from variant tags
2. Create stream info from each media tag (with the codecs from variant
tags)
3. Create stream info for each variant tag, and then create variants.
This creates stream info for each media tag once, and avoids duplicate
calls to guess the codecs.

Issue #1558
Closes #2066

Change-Id: Icdf3133b1b15d1baf60624ff449e0a61fdb78d8a
2019-08-07 19:28:32 +00:00
Joey Parrish 7fe97b841b Move fields to SegmentReference
To prepare for flattening out the manifest structure to remove
periods, this change moves initSegmentReference and
presentationTimeOffset fields into the SegmentReference object.  This
way, the segments on either side of a period transition or HLS
discontinuity can have different offsets or init segments, eventually
allowing us to create a single array of SegmentReferences for
multi-period content.

Issue #1339

Change-Id: Ic7eff0483789644881247ecf8044c5fb6a48f0e6
2019-08-01 11:04:36 -07:00
michellezhuo fd326951c5 Small refactor of Hls Parser
1. Make createPeriod_() and createVariantsForTag_() clearer to read.
2. Simplify and remove duplicate code.

Change-Id: Idda7cb40f33905afd9512d427d7e78cb6c96ede9
2019-07-18 22:11:28 +00:00
Joey Parrish 08cec995c9 Replace find/get callbacks with SegmentIndex
This replaces find/get callbacks in Stream with a SegmentIndex.  With
the exception of DASH's SegmentTemplate+duration, all manifests were
already backed by SegmentIndex.  Now, all manifests are backed by
SegmentIndex.  This will simplify Period-flattening, in which all
tracks will be represented by a list of segments, some of which come
from different Periods.

The SegmentIndex in Stream will not be created until
createSegmentIndex is called.  Prior to this change, the find/get
callbacks could be invoked without createSegmentIndex() in some cases
(excluding DASH's SegmentBase), which some lazy tests took advantage
of.  Now that find/get are methods on SegmentIndex, createSegmentIndex
must be called in all cases.  The tests have been updated accordingly.

Making SegmentIndex generation async in all cases exposed some issues
with the parser context being modified in-place between one
Representation and the next.  So the parser now makes a shallow copy
of the context before it is bound into an async callback.

To facilitate updating the SegmentIndex for SegmentTemplate+duration
content, SegmentIndex now has a method to update its list on a timer.
Once per segment duration, the index will be updated to add and remove
SegmentReferences.

The initial expansion of SegmentTemplate+duration will be limited to a
relatively small number of segments, to avoid excessive CPU or memory
consumption.  This defaults to 1000 segments, but is configurable.

Issue #1339

Change-Id: I99c007b1096c3b396d04a729750cd7b743cb899d
2019-07-08 22:22:13 +00:00
michellezhuo 77d8c04415 Small refactor for HLS Parser
1. Moving getRequiredAttributeValue_() from Hls Parser to Hls Classes.
2. Removing redundant filters in getMediaTags_().

Change-Id: Ic8eca43f51386636e307ae4255d88d78e729be8f
2019-07-04 00:11:14 +00:00
Jacob Trimble 83de1ad634 Use toBe instead of toEqual for primitives.
This ensures that we get the expected types and that type coercion
doesn't convert between types.  This also ensures we are consistent
in how we check for equality of primitives in tests.

Change-Id: I9f3aacdf25ab1afe5e8d6e4b895b5299ee687d54
2019-06-26 18:57:18 +00:00
Jacob Trimble e2ba179201 Favor using toHaveBeenCalledTimes.
This gives better error messages than using toBe() or toEqual() with
the number of calls.

Change-Id: Ice353f1ebcc715da69416da2d983e919597f82d1
2019-06-26 18:52:36 +00:00
Jacob Trimble 3cdadc3db9 Convert HLS tests to ES6.
Issue #1157

Change-Id: I7997921809076fa5e36653f51af32ee11b50ab88
2019-06-03 15:29:26 +00:00
Jacob Trimble f130dffcef Enable eslint indentation rule.
This is a fully automated change.  The linter will fail because the
extra indentation caused line-length errors.  These won't be fixed
automatically.  They are fixed in a follow-up to make this one fully
automated.

Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
2019-05-13 22:31:09 +00:00
Jacob Trimble 984bb6f340 Fix ManifestGenerator indentation.
We use custom indentation for the ManifestGenerator to make the repeated
calls easier to read.  This disables the coming linter rule for these
blocks of code.  This also goes through and unifies the formatting.  The
indentation should be 4 spaces from the left side.

Change-Id: I687e69cea39bded1e9e06bffdcc888970b383fa2
2019-05-13 22:11:37 +00:00
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Joey Parrish e246a6cb77 Fix major HLS variant creation bug
The wrong loop index was used, which caused us to create bogus and
non-unique keys for a map, which in turn caused us to skip certain
variants that should have been created.

Fixes #1908

Change-Id: I6475acad16cd76acb81cd562ef033724c7c4ebaf
2019-05-02 22:28:23 +00:00
Jacob Trimble fbb558ae36 Ignore duplicate CODECS in HLS.
In HLS, the CODECS attribute may contain duplicate of the same codec
with different profiles.

Closes #1817

Change-Id: I0d59c1ade6c8387a2e6b3ca00c0287e15c943ea3
2019-04-29 16:51:52 +00:00
Michelle Zhuo cb9decbb5f Reject AES-128 HLS content with meaningful error
Currently we check encrypt key tags after we parse the segment, so
playing an AES-128 encrypted content results in error message
'MANIFEST.HLS_COULD_NOT_PARSE_SEGMENT_START_TIME'. We should check the
encrypt key before, and give a more clear error message.
Filtering out the contents encrypted with AES-128, and if there's no
valid content left, we'll show 'CONTENT_UNSUPPORTED_BY_BROWSER'.

Closes #1838

Change-Id: I893f57a939e45f2787144dfe311b779aed26ac34
2019-04-22 18:48:18 +00:00
Aaron Vaage 40db29841c Define HLS Parser Interruption Test
If we try to stop the HLS parser while it is parsing a manifest (either
via |start| or |update|) it can misinterpret the aborted partial segment
request as the server not supporting the range request.

This change creates a test that show that we can't interrupt the HLS
parser while it is parsing the manifest (even through we expect to).

The test added in this CL is expected to fail, showing the problem, and
will be fixed in a following CL, showing the fix works.

Issue #1788

Change-Id: I91c459eb5fe0d84af8fe5987a459a054d3aa1107
2019-03-12 21:18:52 +00:00
Rob Colantuoni adde0bd38d fixes 1086 and 1730 - if an X-EXT-MEDIA asset does not contain URI, ignore when building stream list (#1732)
Allow URI attribute on Media tags to be optional for every media type, but Subtitles (#1732)
2019-01-18 10:57:36 -08:00
Jacob Trimble c3ce160217 Consolidate default configs in tests.
Instead of duplicating the default configuration values in each test,
this now uses the default configuration methods.

Change-Id: Ifd2ab349db7903a2acb0d06fed4bd0ccd5050b35
2018-12-27 18:00:55 +00:00
Michelle Zhuo 1afceadc9c Refactor Closed Captions Support for HLS
Refactor the closed captions support for HLS, using the same approach as
the closed captions support for Dash.
If closed captions are signaled in the manifest, player will create a
text stream for to represent the closed captions, and text engine will
store and append them. We don't need to set 'useEmbeddedText' value for
closed captions any longer.

Issue #1404

Change-Id: I9a5bf4df7e29d6e6982f29fd5e2df07bc78071d7
2018-11-27 20:59:52 +00:00
Joey Parrish 69d3193675 Clarify and clean up usage of URIs in HLS
This fixes issues with the interpretation of URIs in HLS and makes
their usage and meaning consistent and clear.

 - Name URI variables as either absolute, final (post-redirect), or
   verbatim (exactly as they appear in the playlist)
 - Identify media playlists by their verbatim URI when testing for
   equality or duplication
 - When a master playlist is redirected, interpret media playlists as
   relative to the redirected location
 - When a media playlist is redirected, request updates from the
   redirected location
 - When updating a media playlist, resolve media segment URIs as
   relative to the latest redirected media playlist URI
 - Resolve absolute segment URIs when parsing the playlist text,
   rather than waiting until we intepret and build the manifest
 - Remove some incidental bind() calls, which exposed compiler errors
 - Avoid refactoring long parameter lists
 - Avoid refactoring for async/await
 - Clean up redirection tests, which were brittle and did not verify
   what they seemed to
 - Use relative segment URIs for all segments in tests
 - Use media playlist URIs within master playlists in tests
 - Add a regression test specifically for #1664

Closes #1664

Change-Id: I45f946790c7d669637c231ae93920a09c18c4222
2018-11-19 12:37:50 -08:00