Commit Graph

1330 Commits

Author SHA1 Message Date
Álvaro Velad Galván 943bdb2b35 Use Network Information API to react to network changes (#2663)
Resolves #1067
2020-07-09 09:46:24 -07:00
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 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
Muhammad Haris 480d4a801a Parse CEA-708 Packets from Fragmented MP4 streams. (#2660)
This is an MP4 Parser which extracts CEA-708 packets from Fragmented MP4 streams.

The Closed Caption Parser (shaka.media.ClosedCaptionParser) will own this MP4 Parser, and will initialize it and call it as shown. As data comes in, the parser will parse this data, and the caption packets data then be returned in a callback (on708Data), as shown. Here, a theoretical decoder (future pull request, mentioned as a Todo comment) will decode and extract the parsed captions from these packets.

Issue #2648
2020-07-05 16:29:17 -07: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
Muhammad Haris d53fbaeeeb fix: Fix disappearing captions with certain input patterns (#2674)
When the subtitles are turned off, unloadTextStream() on streaming engine is called, but currentTextStream is never set to null. When the captions are turned back on, a check in player.js sees that the current text stream is not null, so it assumes it exists, and is ready to go. Thus captions are never loaded.

Clearing (setting to null) the current stream on unloadTextStream ensures the text stream is properly initialized the next time it is called, and in a state so that captions can resume being parsed.

After further investigation, it seems that the unit tests are written in a way that assumes that the text stream is nulled when unloadTextStream is called. So this fix is definitely something that we assume already happens.

Closes #2671
2020-06-24 13:12:09 -07:00
Muhammad Haris d383047de1 fix(CEA): Fix missing captions when switching streams (#2672)
During video playback, if the user switches the caption stream (e.g. CC1 to CC3 which changes languages), the first caption in the next fragment is missing.

In fragmented MP4s, the end time of a caption is determined by the start time of the next caption. Thus for the last caption in a fragment, the end time cannot be determined until the next fragment is parsed.

Before this fix: the clearing of the caption stream was being called from a chain of function calls originating from clearBuffer_() on the Media source engine. But clearing a buffer and resetting a caption stream are two independent operations. As a result, the caption parser was being reset (its buffer cleared) during video seeks, and during stream switches. This makes sense for video seeks, because the end time of the last caption in the fragment can't be determined if the entire presentation timestamp changes. However for stream switches, resetting the parser doesn't make sense. Clearing the caption parser during a stream switch would actually get rid of the last caption in that fragment (which wasn't emitted since its end time wasn't determined yet), and we would lose the data, causing the problem.

The fix is to reset (and hence clear) the caption parser during seeks, but not during stream switches.

Issue #2648
2020-06-23 16:40:35 -07:00
Joey Parrish 15d13c1dd7 test: Add missing Android screenshots
The Android device in our lab exploded and had to be replaced, and in
the meantime, new screenshots were added to the repo.  This adds the
missing screenshots so that the layout tests can pass on Android.

Change-Id: If82042d6b5d5c425108337d22fce938f339f2311
2020-06-18 09:47:55 -07: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
Joey Parrish 810f09ff1e fix(DASH): fix failure with identical text streams
The period-flattening algorithm is run even on single-period content
if the manifest is dynamic, because we don't know if another period
will be added later.

As a failsafe, we should create one output per input for single-period
content, and we can ensure that no streams are unused by marking an
input stream as the "best match" for an output if they share the same
ID.  That way, even if all other characteristics for two inputs are
the same, the input-to-output mapping for single-period content will
always be sane.

That ID-based logic was missing for text streams.  This change
corrects that.

Closes #2646

Change-Id: I28c6c63d92bcf710ae0072783911f9e66ed78228
2020-06-17 16:12:00 +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 53b6e40c6d fix(offline): Fix progress callbacks in release mode
This works around an apparent compiler bug that caused the invocation
of our progress callbacks to be removed from the compiled output.  To
test for this, the existing progress tests now use the compiled
library.

Closes #2652

Change-Id: I5698cfe0a833696e9cd5c8f8851698e1e66ef901
2020-06-16 00:09:39 +00:00
Joey Parrish f86e7208ee style: Re-enable the prefer-spread eslint rule
The prefer-spread rule to prevent use of apply() was disabled, but we
had another custom rule that also prevented the use of apply().  This
re-enables the standard rule.

Issue #2639

Change-Id: Ic3778d7267deb6cd5ed49282ea43bb84ad076060
2020-06-15 23:53:39 +00:00
Joey Parrish 486123ce41 fix(DASH): Fix bad segment URLs in SegmentTimeline
When Representations have different BaseURLs, segment URLs generated
for SegmentTimeline were always using the BaseURL of the last
Representation because the wrong parsing context was being used.  This
fixes the issue and adds a regression test.

This only affected v3.0.0.

Closes #2650

Change-Id: I04df950b5d3205e102f9c74f52ece9773ce92282
2020-06-15 22:40:48 +00:00
Joey Parrish b84061a764 build: Upgrade the compiler
This upgrades the compiler to the latest release and fixes some type
errors in the tests found by the new compiler.

Change-Id: I3a555cbdfc94c51fb0683f8397c6adb8ea43f120
2020-06-11 22:03:47 +00: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
Jacob Trimble 705fae7908 refactor: Clean AbortableOperation and add tests
Change-Id: I2e0aee32c20bd009cb56ab58070b960f6b19b4b2
2020-06-09 22:20:45 +00:00
Joey Parrish f692bfe7d6 test: Add regression tests for cue backgrounds
This adds two new layout tests for cue backgrounds, corresponding to
issue #2623 and PR #2624.

Change-Id: I2f07e46c31ac613792471dd8d65fef1676f6b6bf
2020-06-09 00:10:48 +00:00
Joey Parrish 02379d354e fix: Abort pending requests in StreamingEngine.destroy
Closes #2619

Change-Id: I10cc2e9567720c9d021038a4da3c26b6857ec709
2020-06-08 21:28:28 +00:00
Joey Parrish 3bf5ed10b7 Fix flaky test results on Chromecast
One of the src= playback tests was failing on Chromecast with an
estimated rate of about 20% when the src= tests are run alone.  The
timeout for playback to start was found to be too short on that
resource-limited embedded device.  This increases the playback timeout
in the test.

Fixes: 157702575

Change-Id: Ib8d5a0d961bc0e99e77c16b93ca63569f3a2cc31
2020-06-08 18:00:22 +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
Joey Parrish 0df39c62b6 Add content metadata methods to CastReceiver
This change adds the following methods on CastReceiver:
 - setContentMetadata(metadata)
 - clearContentMetadata()
 - setContentTitle(title)
 - setContentImage(imageUrl)
 - setContentArtist(artist)

These should be called from the CastReceiver's app data callback.

The title, image, and artist methods cover all the Cast content
metadata fields that have an effect in the Google Home App as of June
2020, and setContentMetadata can be used to set one of several object
formats with many more fields defined in the Cast SDK docs.

See https://developers.google.com/cast/docs/reference/messages and the
definitions of GenericMediaMetadata, MovieMediaMetadata,
TvShowMediaMetadata, and MusicTrackMediaMetadata for details.

This also uses these methods from our cast receiver demo, so our demo
will now set all possible metadata when casting our content library.

Closes #2606

Change-Id: I6386276449dbddd2501cd6e3e52206f7fb30b8fd
2020-06-04 20:59:08 +00:00
Sandra Lokshina 1fc19510ec Hook up ID3 tag parsing information from mux.js
Issue #2592.

Change-Id: I0b17977b88cf37189d7611254ce14171ba52c54f
2020-06-04 17:12:06 +00:00
Joey Parrish a132592b20 Add regression test for Google Home scrubber fix
The fix for Google Home scrubber in 8c3775ce (Change-Id
Iceec95f18cf15325b7ee2350a0f30f31edc90560) did not come with a
regression test.  This change covers that fix with an automated test.

I have confirmed that the test fails without the fix.

Issue #2606

Change-Id: I13a2bcfb2fcca059db4e909d7c27fb68b0bfb409
2020-06-03 23:03:13 +00:00
Joey Parrish b48d35f16e Minor refactor and cleanup in cast tests
Details of the cleanup:
 - Don't replace the load() spy with a non-spy
 - Fix an out-of-date comment on an explicit delay in a test
 - Hoist expectMediaInfo helper to make it available for all tests
 - Simulate loading content before the "generic controls messages" to allow the
   use of expectMediaInfo
 - Don't do a substring comparison on a JSON blob, which is inherently
   unreliable, and compare the parsed object structure instead

Related to #2606

Change-Id: Ifb46e223ba800c0e10cbdfa6cb847faa8424cd3d
2020-06-03 23:03:13 +00:00
Álvaro Velad Galván bafe18fadd Add maxSegmentDuration to stats (#2613)
Resolves #2610
2020-06-03 11:51:59 -07:00
Alex Jones 64557ff82c Add support for nested TTML captions with an offset (#2602)
Closes #2601
2020-06-03 11:49:15 -07: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
Joey Parrish aba5e2583c Rename v2.6 to v3.0 and v2.7 to v3.1
We have decided to bump the major version number instead of the minor
number, based primarily on the fact that this release breaks
compatibility with our previous manifest structure.

Change-Id: I67e4c8267c6e103cfc7278e09daac186ae5cbbc6
2020-05-29 17:50:22 +00:00
Joey Parrish 21c3d7dc4d Fix language preferences in src= mode
Changes to the load() promise resolution on iOS for #2483 accidentally
broke language preferences in src= mode, and the regression test for
this revealed subtleties in how and when tracks may be selected with
Apple's native HLS.

By waiting for a "change" event on video.textTracks, we can make sure
Apple is ready to accept our own text track selection.

This should now work correctly on all platforms.

Closes #2593

Change-Id: Iec59b89001fbec3779a0f7087ce11efe1be003ef
2020-05-28 10:02:50 -07:00
Joey Parrish bab451e655 Update screenshots
I'm not sure what caused the change, but after some other changes
merged, screenshots on Linux were off slightly and needed an update.
Screenshots in Safari were way off, and a workaround in the screenshot
utility needed to be removed.

Change-Id: Ic28d83dddcd6272b4cbb83aa7a3dcdb5c8fcdad9
2020-05-28 00:06:10 +00:00
Jacob Trimble 654b6cbee3 Fix SegmentTimeline with t attribute missing.
Fixes #2590

Change-Id: I2ac4adb1898b4affea9ee337f1d59fc3dca69ced
2020-05-27 16:48:54 +00:00
Joey Parrish b839340220 Add screenshot-based layout tests for subtitles
This adds our first screenshot-based layout tests and the
infrastructure to use WebDriver for screenshots through Karma.
This new kind of test will be skipped in any non-WebDriver context.

There are many pieces to this system.

First, we update the Karma WebDriver launcher to a newly-released
version that lets us access the client spec object from the launcher.

Second, we build a Karma middleware plugin to respond to HTTP requests
from the tests.  We handle /screenshot/isSupported and return a bool
so tests can be skipped on non-WebDriver launchers.  We also handle
/screenshot/diff to take the screenshot and compare it to a known-good
version.

The screenshot is a full-page screenshot, since element screenshots
don't work consistently across all the browsers in our test lab.  The
screenshot is then cropped to a rectangle specified in the request.
This rectangle is measured to match a specific element, so in
practice, we are screenshotting just one element.

Browsers use sub-pixel rendering, effectively rendering at a scale
larger than the "pixels" seen by JS.  The screenshot comes in at this
scale, so the requested cropping rectangle is scaled to match, then
the cropped screenshot is scaled down to the JS-measured size.

Because of sub-pixel rendering, element offsets can be non-integer
numbers.  Normally, Karma puts the tests in a iframe, above which is a
variable-height banner showing which devices are connected to Karma
and what state they are in.  So this variation and the lack of integer
offsets means we can run into stability issues due to rounding errors.
To make offsets consistent and improve stability of the screenshots,
this banner is now disabled in our Karma config.

The cropping, scaling, and diffing of images is handled Karma-side by
a node module called Jimp.

Before we start the layout tests for UITextDisplayer, we use a node
module in the browser called fontfaceonload to wait for our web fonts
to be fully loaded.  This module is a polyfill that polls on IE and
uses a standard API in modern browsers to wait for our font to load.
This is all wrapped into a new test util called waitForFont.

Screenshots are stored in test/test/assets/screenshots/ and are
organized into folders by platform and browser and named according to
an identifier specified by each test case.  The new screenshot is
written to disk with the suffix "-new", and a diff image is written
with the suffix "-diff".  When a test fails, we can review the changes
in a browser with test/test/assets/screenshots/review.html.  The
known-good screenshots can be updated with the new tool
build/updateScreenshots.py.

Change-Id: Ib477fd3c459de466c6dc91e9a60d3e2579164b12
2020-05-26 22:38:04 +00:00
Joey Parrish af206b79db Fix src= test failures
These issues were mostly introduced in "Don't preload data on iOS",
and were not detectable in Chrome.  They came up during a full test
pass in our test lab on all browsers.

Change-Id: Ife6e157a18df84ea30b840615f6d06a22e340a44
2020-05-21 18:42:01 -07:00
Joey Parrish 6b11f1ecdc Don't preload data on iOS
Instead of calling video.load() and waiting for loadeddata for src=,
wait for loadedmetadata.  This should be a safe event to use in most
cases, and calling video.load() causes native HLS to start preloading
an uncontrollable amount of content.

The exception is if the app sets preload='none' on the video element.
If this happens, we will detect it, log a warning, and avoid the
loadedmetadata event which may never fire.  This is not a scenario we
will officially support, but at least we can prevent a hang in
player.load().

Closes #2483

Change-Id: Id64c8f23cb8fa82bb5c301abafb51f2d9d8730f7
2020-05-21 20:01:32 +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 a7d46ee3d1 Add locale setting to AdManager (#2563) 2020-05-15 12:57:32 -07:00
Joey Parrish d215994123 Fix renaming of ad-related shaka.ui.Element fields
This also changes the Element plugin renaming test to avoid a
hard-coded list of member names so we don't miss one in the future.

Change-Id: Ifeb3b951ea3422da5014f16d9dcb13e8b8c7fc45
2020-05-13 21:33:07 +00:00
Joey Parrish ca81d553de Fix text track change after enabling text display
Setting text track visibility to true may, in some cases, require us
to choose a text track.  But we should not do this if one has already
been chosen.

Closes #2553

Change-Id: I53bf1b624b59baae774ffaeb0f0e9eb5467984fc
2020-05-12 19:06:31 +00:00
Joey Parrish 7ba1c46832 Generate test content with multiple tracks
The test content generator was only designed for single-track content.
In the one remaining case where we generated multi-track content,
there was one-off logic to generate that content instead of generating
it based on descriptive metadata.

Now we can generate test content with multiple tracks from descriptive
metadata.  The tracks will still all contain the same thing, but the
metadata can be varied to create distinct resolutions and languages.

This is an important step toward generating content to build a
regression test for #2553.

Change-Id: Ic752ff1e50273470d2784910251d181fe995128a
2020-05-12 19:06:31 +00:00
Joey Parrish ca538e7da3 Factor out common test clip metadata
This makes the test clips easier to read and add to by factoring out
common metadata (same URIs, offsets, etc.)

Change-Id: I3f6e7ff39f10ad5f3ed28cb9caf5eac010650668
2020-05-12 19:06:31 +00:00
Joey Parrish 9695c68bb7 Fix demo app close button
As an external, abstract interface, the constructor doesn't do
anything.  The members in it were parts of the base class
shaka.ui.Element, which implementations of IUIElement can still
inherit from.

However, I was wrong about this part of the extern being unnecessary.
It turns out to prevent the compiler from renaming those critical
parts of the base class.  Application-provided UI elements (such as
our demo's close button) break without these definitions being part of
the library build.

This reverts commit 89059f81e5 ("Remove
bogus parts of IUIElement interface") and adds a comment to the
interface definition that would have prevented me from making this
mistake in the first place.  It also adds a regression test to the UI
test suite.

Change-Id: I712d985a6287136d68dc0a888662badd7e306b9e
2020-05-12 19:05:13 +00:00
Joey Parrish a1b71197ef Minor style changes in UI tests
This removes double-newlines and adds comments to indicate what the
end of a describe block corresponds to.

Change-Id: I6832b52c3d849896d0c8e93bd8f27a22e665c3f6
2020-05-12 19:05:13 +00:00
Sandra Lokshina 285cc73b1d Fix period flattening matching by role.
Matches for all streams. Пусть никто не уйдет обиженным!

Closes #2542.

Change-Id: I5cfa25c426c40125ab6532ad62ef08dbe2dc9f81
2020-05-07 19:40:27 +00:00
michellezhuo 562168a1f6 Set UITextDisplayer as TextDisplayFactory in default config
In player, SimpleTextDisplayer was set as the default TextDisplayer. In
our UI, it changes the configuration to use the UITextDisplayer, and
UITextDisplayer gets constructed with the player. Later in our demo, it
resets the config, so an extra SimpleTextDisplayer gets constructed.
This introduces an extra TextTrack created by SimpleTextDisplayer.

This change sets the UITextDisplayer as the default TextDisplayer in
player's default config.

Closes #2516

Change-Id: I3f653be9fad8b2edbc2fb9de84e8abb327dcfc51
2020-05-04 20:40:18 -07:00