Commit Graph

211 Commits

Author SHA1 Message Date
michellezhuo 109973c7e2 feat(LL-HLS):Enable preload hinted segments
LL-HLS hints a resource that is needed to playback in the upcoming
update. It's available for request, and may not be available for
download yet.

A preload hinted resource is either a partial segment, or an init
segment. If it's an init segment, treat it the same way as the Map tag
in ManifestTextParser.
A preload hinted segment contains no duration information, so its
start time and end time are the same. It will be replaced by a partial
segment in the next update.
We should fetch and append the preload hinted segment the same way as a
partial segment.

Issue #1525

Change-Id: I1e30f216ecdc843c3cd01681629a8886383d0b22
2020-07-08 22:11:06 +00:00
michellezhuo ec3bf7aaa5 fix(HLS): Fix discontinuity timestamp offset
Closes #2687

Change-Id: I60e41341d1149eb8200bec71fa1bafb5be8e57c7
2020-07-07 14:12:47 -07:00
michellezhuo 965ef453b6 feat(LL-HLS):Enable Partial Segments streaming
Changed SegmentIndex and SegmentIterator to iterate through regular and
Partial SegmentReferences.

SegmentIndex:
merge(): Find all the old segments after the first new segment's start
time, and replace the old ones with new segments.

SegmentIterator:
Use the currentPosition and currentPartialPosition pointers to iterate
through the two-layer arrays.
current(): Get the current SegmentReference, and get its current Partial
SegmentReference if it has a Partial Segment list. Move to the next
regular segment if we reached the end of the current segment's partial
list.
next():
If the regular segment has a partial list, go to the next Partial
Segment. If reached the end of the current partial list, move to the
next regular segment.
If the regular segment doesn't have a partial list, move to the next
regular segment.

Issue #1525

Change-Id: Icb7f49e50314f15ea40bf3a74d008191ed1a9a6c
2020-07-06 00:34:55 +00:00
michellezhuo 1685b2cd83 feat(LL-HLS):Enable playlist delta update
Player can request delta updates to reduce the transfer cost.
Client: sends a request for playlist update with '_HLS_skip=YES'
parameter.
Server: replaces the older segments in the media playlist with
'EXT-X-SKIP' tag.

Issue #1525

Change-Id: I3643641d0cb97444ba1c00f06d9e113acba7b824
2020-07-06 00:33:06 +00:00
michellezhuo fb43b1f0fd feat(LL-HLS):Add support for Server Control Tag
For LL-HLS, use the value of 'PART-HOLD-BACK' in the Server Control tag
as the default presentation delay.
'PART-HOLD-BACK' is the server suggested min distance from the live
edge, and must be >= 3 * partial segment target duration.
It's always available when the playlist contains partial segments.

Issue #1525

Change-Id: I176188dbd39be0d038eee938d3e8358e54b8a3a8
2020-06-30 02:55:54 +00:00
Álvaro Velad Galván 8f36ae50ec Add support for EXT-X-SESSION-DATA (#2642)
Resolves: #1460
2020-06-17 11:48:17 -07:00
michellezhuo 213e00c586 feat(LL-HLS):Use partial duration as update period and delay from live
In low latency streaming mode, EXT-X-PART-INF tag provides the target
duration of Partial Segments. It's required if the playlist contains
Partial Segments.
1. Get a playlist update every Partial Segment target duration.
2. Set the distance from live edge as 3 * Partial Segment target
duration, if not configured.

Issue: #1525
Change-Id: I8770f2be30f510ec143672411da0624801d48f4e
2020-06-17 17:09:32 +00:00
michellezhuo 244ebacac3 feat(LL-HLS): create SegmentReferences for Partial Segments
If a segment has partial segment tags, create a SegmentReference for
each partial tag, and add the list of partial SegmentReferences to the
parent SegmentReference as an attribute.
If the parent segment contains the segment tag(EXTINF tag), use the
duration information from EXTINF tag to create the SegmentReference.
Otherwise, calculate the parent segment's duration based on the partial
segments' durations.

Issue #1525

Change-Id: I946cc007aad2ff911b69bf1c6a46df145452bfaa
2020-06-17 17:09:23 +00:00
michellezhuo 76c4c674dc feat:(LL-HLS) Parse Partial Segment tags
Low Latency HLS uses 'EXT-X-PART' tag for Partial Segments.
ManifestTextParser will parse the Partial Segment tags, and add them to
the regular segment after them.
If a list of Partial Segment tags is being published and doesn't have a
regular segment Uri following it yet, create a segment object to wrap
the Partial Segment tags list.

Issue #1525

Change-Id: Ie04ed70ae15c88416d677d67b721f76bc2f5b486
2020-06-16 04:06:52 +00:00
Muhammad Haris e8f24ece6f Created MP4 Box parsers to parse data for common box types (#2649)
Issue #2648
2020-06-15 17:35:38 -07:00
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00
michellezhuo e63813c363 fix(HlsParser): Fix HLS live stream playback failure
Since createSegments_() is asynchronous, and we are updating all the streams
in parallel, the global playlistStartTime_ value may get changed when we update
other playlists, rather than the current playlist. This caused the references'
start and end times discontinuous in a stream.

Closes #2605

Change-Id: Ib2dd1161f4075486f79b0122b98e558ea7d05aaa
2020-06-08 19:20:31 +00: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
michellezhuo ec2674a4d8 Refactor createSegments_() to improve readability
1. We get the start time for either the first segment in the playlist,
or a segment after discontinuity. The logic for getting the start time
in both places is almost the same.
Moving the dupliate code to getStartTime_() function.
2. We create a temporary SegmentReference to get the start time.
Moving creating the SegmentReference into getStartTime_() function.
3. Moving the logic of getting timestampOffset for a discontinuity
segment into a seperate function.

createSegments_() is now 20+ lines shorter.

Change-Id: If484aab56aa169d4a0f9166813d696724230b919
2020-06-03 23:12:24 +00:00
michellezhuo 9584804b6c Fix HLS live stream freezing
When we get a playlist update, we replace the list of SegmentReferences
in the SegmentIndex. However, the position pointer in the
SegmentIterator of the SegmentIndex is not updated, and still points to
the index of the old SegmentReference list. Thus, the current
SegmentReference may be null.
We should merge the new SegmentReference list with the old list, and
mark the offset of the list.

Closes #2605

Change-Id: Ia6740e1173ac48467e7b141257cc9c6148e30a0c
2020-06-02 15:57:37 -07:00
michellezhuo ed0d718ea1 Rename fetchPartialSegment to fetchStartofSegment
In HlsParser, fetchPartialSegment_() is meant to fetch the starting part
of the segment to get the segment's start time, so we don't have to
download the full segment if possible.
PART_SEGMENT_SIZE is the default size of the starting part of the
segment we fetch.

Low Latency HLS introduces 'Partial Segment' as a smaller part of
a regular segment, such as CMAF chunks, and a regular segment might be
divided into many partial segments.

Renaming the original function and field to improve code readability and
avoid any future confusion.

Issue #1525

Change-Id: I593497f6e99e9ffe6128d6976eb7886bbd79679c
2020-05-20 04:18:42 +00: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 07335d79f6 Fix missing or bad type info
In many places, the implicit type info was insufficient.  For example,
document.createElement returns Element, but the actual return is
always a subclass of Element.  In many cases, we need the compiler to
know that a specific subclass is in use, so that it can correctly
check our use of subclass-specific properties.  Another common pattern
is confusion between Node and Element (which is a subclass of Node).

Almost all of the changes in the demo and UI are Element-related.

In some places, we referred to HTMLMediaElement, used in the Player
API, instead of the more specific HTMLVideoElement in use in our demo.
Since the demo uses video-specific properties, we must use the more
specific type.

Another case is the use of document.createEvent, which returns Event
according to the compiler, but in reality always returns a subclass,
like CustomEvent.

In one case in NetworkingEngine, correcting the type of an
AbortableOperation led to the discovery that we had been incorrectly
accessing a private method of that type.

In goog.Uri, there were several instances of "*" for a type, which the
newer compiler won't accept.  These have all been corrected.

Finally, in some places, we had the wrong nullability on a type.

These were all caught by a compiler upgrade.

Issue #2528

Change-Id: I7f2d070e3da32fe9ff5f444315649f3cbdb5a4a5
2020-04-28 16:51:20 -07:00
Álvaro Velad Galván e246855c63 Add variable substitution support to HLS parser (#2509)
Resolves #1561
2020-04-24 12:37:11 -07:00
michellezhuo 734d129fcd Add Support for HLS Discontinuity
Closes #2397
Closes #1335

Change-Id: I6f540c42c72bf0ae36239b682d4016cca3981c0f
2020-04-09 14:59:42 -07:00
Joey Parrish 6e3dfa40ba Deduplicate key IDs with Set
When period-flattening combines Streams, key ID arrays would get very
long with duplicates.

This changes keyIds in the manifest and offline structures from Array
to Set.

Issue #1339

Change-Id: I003d23e567efafa771ecd2ad597900181604ad18
2020-04-09 19:22:16 +00: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
Álvaro Velad Galván 4938034d81 Recognize new CMAF file extensions cmfv, cmfa, cmft in HLS (#2473)
Resolves #2470
2020-03-30 09:35:44 -07: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
michellezhuo c82ff51d1f Add a presentationDelay config for HLS live
Closes #2373

Change-Id: I627bbd226ed9cab9bc476e2c2a3257d2e2dbc0e9
2020-03-11 18:41:15 +00:00
Joey Parrish b0238c3c00 Stop using segment position in HLS parser
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.

The HLS parser uses positions to find previously-resolved segment
times when refreshing a live playlist.  What we're really doing is
using HLS media sequence numbers, since we use those to assign the
segment positions in the first place.

This change makes the use of media sequence numbers more explicit, and
adds a per-Stream map from media sequence number to segment start
time.

The only other users of segment positions are StreamingEngine and
various tests.

Issue #1339 (period-flattening)

Change-Id: If970ed2c8722ed5779a51349ca2e64208d78130d
2020-03-05 22:47:09 +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
michellezhuo 687319caec Add timestampOffset as a parameter to createSegmentReference
TimestampOffset will be used as a paramater to create the segment
references with discontinuity tags.

Issue #1335

Change-Id: If7dfb63766c2397256561e6668e98f9136f885b5
2020-02-26 00:39:31 +00:00
Jacob Trimble c49f24b31b Remove remaining deprecated features for v2.6.
Change-Id: I2199e3c960fe6319eb9ab342291dfd9a62d9090e
2020-02-24 15:57:05 -08:00
michellezhuo eb03777de7 Remove unused parameter
Change-Id: Id661050866beaea65e873212dd7fbe6144f9d28b
2020-02-24 18:02:43 +00:00
michellezhuo 689b83f211 Small clean up in hls parser
Change-Id: I4a6d0c4c5b317d45dc3b52325d6c30d2f8bc5e30
2020-02-19 14:31:46 -08:00
Jacob Trimble 3f63021a2f Avoid using "new" with factories.
Instead of having the "factories" use "new" to construct them, now they
will be plain functions.

Closes #1521

Change-Id: Ia6151ad679a78a5c6db128d43094c82add0af348
2020-02-19 09:57:51 -08:00
Sandra Lokshina 696fdba359 Lowercase mime type when looking up start time for HLS.
Change-Id: I5fa1c2ebc85d364ddcd99c63fc111529fc125527
2020-02-13 22:22:11 +00:00
Joey Parrish bce3cfeac2 Fix race condition on HLS parser shutdown
Closes #2138

Change-Id: I30f70874149acacdad57fd387de948ced325cfc9
2020-01-24 23:23:46 +00: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
Joey Parrish 4ffcbc6188 Fix pixelAspectRatio types for backward compatibility
For backward compatibility, the new pixelAspectRatio field in Stream
should be string|undefined rather than being nullable.  This ensures
that manifest parser plugins that do not output that field will still
compile against the externs.

PR #2294

Change-Id: I1aae03994a213c8ce52dc64e8a34bf179045f4fb
2020-01-15 19:04:14 +00:00
Joey Parrish 1372da934d Drop dead HLS code
This turned up as uncovered in a code coverage report, but it's
actually completely dead code.

Change-Id: I2ec6e83189d68aa3a43b136a20a0bb3e15eb41eb
2020-01-14 00:51:26 +00:00
Joey Parrish d2ccc62ab8 Recognize and reject raw AAC in HLS
This makes the HLS parser recognize raw AAC, but refuse to play it.
It will not play correctly until we have full support for
containerless formats at the MediaSource level.

Closes #1083 (raw AAC, can't do anything more for this right now)
Issue #2337 (full support for containerless formats in general)

Change-Id: I50c7f06a1aa08d515f4d9f74603954a6d015dc29
2020-01-13 22:01:59 +00: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
Álvaro Velad Galván bdca05ff4b Add pixelAspectRatio property from DASH (#2294) 2020-01-06 10:56:28 -08:00
Joey Parrish 41a8664dba Make segment references independent of periods
This is a step along the way to flattening periods, and also
simplifies a few small things in StreamingEngine and tests.

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

Change-Id: Ie17cd5e15ed6ec9290a918c3a69c05c74581e0fc
2020-01-02 19:03:18 +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
Álvaro Velad Galván 02fa8c6876 Add audioSamplingRate property (#2290) 2019-12-10 18:00:16 -08: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