Commit Graph

2285 Commits

Author SHA1 Message Date
Joey Parrish 6c85c8cbfc fix: Fix rendering of TTML nested cues and spacers
TTML nested cues are meant to be displayed horizontally as inline
elements.  This fixes the rendering of these nested cues in both
SimpleTextDisplayer and UITextDisplayer.

In UITextDisplayer, the styles have been adjusted to lay out the
nested cues horizontally rather than vertically.

In SimpleTextDisplayer, the nested cues were being displayed as if
they were top-level cues.  This change concatenates the nested cues
into a single cue displayed in the browser.

This also improves comments on the poorly-named "spacer" property,
which represents a line break in TTML.

This fixes the rendering of "spacer" in SimpleTextDisplayer by
inserting an actual newline character into the collapsed nested cues.

Finally, this fixes and clarifies names used internally in
UITextDisplayer.  For example, there is a difference between a nested
cue and leaf cue.  A nested cue and a top-level cue without nested
cues are both "leaf" cues, but a top-level cue is never a "nested"
cue, since it is at the top level.  The conflation of these names
before this fix made it difficult to understand and fix the code in
the first place.

Closes #2760

Change-Id: I89633761d12704e253371d17e2e786c5b2ed67a7
2020-07-30 11:29:55 -07:00
Joey Parrish 9456fd1da8 chore: Bump master branch version to avoid confusion
To keep people from thinking that the master branch contains v3.0,
bump the master branch version number in player.js to v3.1.0-pre

Change-Id: I15d1e24b6b431318f2e492901bcba8b5e468fb07
2020-07-27 11:28:46 -07:00
Joey Parrish 04f3009346 fix(Tizen): Fix stalling playback on Tizen 3
Playback stalls on Tizen can be corrected by pausing and playing
again.  For Tizen and similar platforms, this is superior to the old
way of seeking to unstall playback, because seeking is expensive on
those platforms.

To facilitate pausing and playing again instead of seeking, a
stallSkip value of 0 will trigger the pause/play workaround instead of
the seeking workaround.  Further, we will make this the default on
Tizen, WebOS, and Chromecast.

An internal detail which is changing is that GapJumpingController will
now call StallDetector first and inhibit gap jumping when the stall
detector has something to do, rather than the other way around.  This
allows the StallDetector to be in charge of deciding what is buffered,
rather than having to pass GapJumpingController's interpretation of
buffered ranges first.

Fixes #2620

Change-Id: I5ad7aad42aa185b2837c830970e54218b4e55a21
2020-07-23 22:09:36 +00:00
Theodore Abshire 6a89f27ace fix: Re-add a session close workaround.
There is a new bug that is preventing the DRM engine from
shutting down, for Widevine assets. Or, at least, new to us.
It happens if session.generateRequest is called, but
session.update is never called (e.g. if the network request fails).
In this case, session.close will never resolve.
This re-adds the old workaround we used to use, where we
would timeout after a while, if the session fails to close.

This also adds a regression test.

Issue #2741

Change-Id: Ieb6a64b762473edb9a3209580a84aee870e21fb5
2020-07-23 01:00:37 +00:00
Joey Parrish 4ba162797b fix(Tizen): Fix src= playback on Tizen 3
src= playback on Tizen 3 was stalled at time 0, causing automated test
failures.  These went unnoticed while our Tizen device in the lab was
offline.

The only workaround I was able to find was to call load(), which we
recently stopped doing for src= playback.  This adds it back, but only
for Tizen.

Found while investigating #2620.

Change-Id: I4e071a6f1ccb18b9891dfc646a22dbb8c1711eb4
2020-07-22 21:36:07 +00:00
Joey Parrish ef7767ff21 fix(Tizen): Fix initial bandwidth estimate on Tizen
Tizen 3 has the NetworkInformation API, but not the downlink
attribute.  This led to NaN as a bandwidth estimate.  Now we screen
for the presence of this attribute as well as the API overall.

Futhermore, we now disable this API in unit tests to better control
the fake estimates used during the tests.

Found while investigating #2620.  Introduced in PR #2663, and has not
affected any release versions.

Change-Id: Iaa1486545825ceee536ecbe5ea617f92de4fbc2d
2020-07-22 21:23:16 +00:00
michellezhuo a534dca883 feat(LL-HLS): Add configuration comments for low latency mode
1. In low latency mode, the playback start time from live edge is about
3 times partial segment duration, 3s for example. The rebufferingGoal of
2s would result in infinite buffering.

2. In low latency mode, do not allow drift for seeking. Only seek with
the presentation time.

Change-Id: Iee92727bf17dab8b52fae070522a5a2ec1621ffc
2020-07-22 17:00:15 +00:00
michellezhuo 3a14bcf72f fix[LL-HLS]: Set init segments for every segment
If the last segment in the media playlist contains only partial
segments, its init segment was not set, causing playback failing to
start, with 'Append: stream parsing failed' error.

Issue #1525

Change-Id: I0dab967fe55c9d792f102f4d49dda7f9437d8897
2020-07-22 16:58:51 +00:00
Jacob Trimble dc8b007d56 cleanup: Add missing requires.
This is a port of the internal changes: cr/321495405, cr/321592702,
and cr/321594488.

Change-Id: If6a4c4266ed10a70b01442974dbd19329bb5122e
2020-07-16 10:59:49 -07:00
michellezhuo d9df1b341a fix: Log buffered info as a string
On WebOS, objects are logged as 'Object' rather than the properties.
Convert buffered info to a string, so that the properties get printed
in the logs.

Change-Id: Ia6daab48122ed696e69ff7d15c551fdcb10bdb7e
2020-07-14 16:28:39 +00:00
Á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 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
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
ismena 2386d4ea99 feat(Ads): Proxy all CS IMA events through the ad manager.
Change-Id: Id66c5ab5287ed99d7847ac6279e1b49284aef2b6
2020-06-23 20:19:03 +00:00
Sandra Lokshina 00942069d7 Fire a shaka.Player.Metadata event on detecting ID3 metadata.
Issue #2592.

Change-Id: Ia2a98668a5971071adfa0ee4d987337ea9c10c59
2020-06-22 18:18:36 +00:00
Theodore Abshire 34337ca28d feat(UI): Added polyfill for screen.orientation.
There are some platforms (e.g. iPad) which can be rotated,
but do not support the screen.orientation API. This is relevant
because iPad now supports requestFullscreen, which it did not
before.

Found while investigating #2653

Change-Id: Iacc93433aa1fb50a25d968203dc9fd4f7f16b4ae
2020-06-17 12:31:24 -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
ismena a2554364ee feat(Ads): Expose more client side IMA info to apps.
In particular:
- New ad events were added
- It's now possible to get original IMA ad and ad manager
objects through Shaka

Change-Id: I2ffdc08befc11011673ebba5fb2fdb5e485977f5
2020-06-17 15:39:11 +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 06fd3ce322 fix: Fix strict compiler errors
In our Google-internal build systems, with the strictest compiler
settings, we were seeing errors related to these two issues:

1. A missing require
2. Incomplete type info

This fixes the errors in that environment.

Change-Id: I9c4c482ed6ef8f669e113263a70958b53138c4ee
2020-06-11 10:17:48 -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
Jacob Trimble 705fae7908 refactor: Clean AbortableOperation and add tests
Change-Id: I2e0aee32c20bd009cb56ab58070b960f6b19b4b2
2020-06-09 22:20:45 +00:00
michellezhuo 6d373eb631 Add config for low latency mode
Issue #1525

Change-Id: I561ac50b4681036b7675efdceae70937c4b9244d
2020-06-09 17:29:54 +00:00
Álvaro Velad Galván a201be414a fix: export shaka.util.FairPlayUtils and shaka.util.BufferUtils (#2628)
@exportInterface is used by the extern generator, but ignored by the
compiler. @export should be used for shaka.util.FairPlayUtils and
shaka.util.BufferUtils.

Closes #2626 and #2627
2020-06-09 07:32:59 -07:00
Joey Parrish 02379d354e fix: Abort pending requests in StreamingEngine.destroy
Closes #2619

Change-Id: I10cc2e9567720c9d021038a4da3c26b6857ec709
2020-06-08 21:28:28 +00: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
Alvaro Velad c4e6d1c7b2 Background color only should apply to nested cues in UITextDisplayer 2020-06-08 09:32:45 -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
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
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
Álvaro Velad Galván 1568d28686 Wrong pixelAspectRatio population in DASH (#2614)
The current implementation of pixelAspectRatio in DASH is wrong. `@par` in DASH is "picture  aspect ratio" so the correct is populate this field with `@sar`.
2020-06-03 14:46:41 -07: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
Joey Parrish 732b6895f1 Report support for all commands in cast receiver
There is not a separate message for skip forward or skip backward, and
we already support seek.  So there's no obvious reason to claim we
can't support skip forward and skip backward.

Related to #2606

Change-Id: If9a931afa2d6a0d323b561ed9f6500f79fb0d1bd
2020-06-02 19:57:34 -07:00
Joey Parrish b3996ad98b Slight improvement to media info messaging in Cast
The docs for the Cast messages say that duration is optional, so it
seems better to omit it for live content, rather than send back an
absurdly-large number.

Note that this does not seem to affect seeking in live streams.
Seeking in live streams seems to be disallowed by the Google Home app
either way.

Related to #2606

Change-Id: Id7d3911b410489b56643afaaee12102b5d6929a1
2020-06-02 19:57:34 -07:00
Joey Parrish 8c3775ce5e Fix Google Home app scrubber for casted VOD
When we get a GET_STATUS request, we are supposed to send back media
info.  That field is only optional for other requests.

This fixes the scrubber in the Google Home app for VOD content.

Issue #2606

Change-Id: Iceec95f18cf15325b7ee2350a0f30f31edc90560
2020-06-03 00:42:25 +00:00