Commit Graph

63 Commits

Author SHA1 Message Date
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
Tomohiro Matsuzawa (Tomo) 83e36006bb Fix the bug that UTCTiming is ignored even when autoCorrectDrift is off (#2412)
Closes #2411
2020-02-26 14:48:12 -08:00
Joey Parrish 9f448710bc Fix DASH SegmentTemplate multi-period regression
The recent DASH refactor broke the details of multi-period segment
references for SegmentTemplate+duration.

This change introduces a corrected universal model for generating
segment references for fixed-duration SegmentTemplate content.  It has
been tested with a variety of streams from third-parties, most notably
the DASH-IF's live simulator.

Issue #1339 (flatten periods)
Issue #892 (refactor StreamingEngine)
Closes #2111
Bug: 28087927

Change-Id: Ife4e9ae2bb726e24e97dfe153882dabba4c03f2d
2020-02-05 13:37:29 -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 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 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
Sandra Lokshina 8f57efbe9f Export getMaxSegmentDuration() on presentationTimeline.
Closes #2124.

Change-Id: I6260c2156575ff5adf5c251713d0e1a522334251
2019-08-29 18:35:01 +00:00
Jacob Trimble 3da809019b Enable additional ES6 linter rules.
Change-Id: I6861541b27153ba034364a5972a9b086de581cef
2019-06-11 18:35:09 +00:00
Michelle Zhuo a6beb0efdc Update media files to ES6
Issue #1157

Change-Id: I81ff0cee6e479bba728c1e65af70133ba6f28091
2019-05-20 23:11:16 +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 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
Jacob Trimble 2d99929400 Add option to disable drift fixing.
The drift fixing allows us to play content that has drift by starting
to play at the last segment in the manifest.  But some live content
specifies content in the future, so we can't just start playing at the
last segment in the manifest.

Fixes #1729

Change-Id: I3095a2d28b34ed93346933f561d77335361f1fae
2019-02-15 22:50:16 +00:00
Joey Parrish c8cfa63e20 Fix a small typo
Change-Id: I18ab77180497ac171599f53949e83ecb5e5c60c7
2019-02-05 17:59:05 +00:00
Sandra Lokshina 34408b9c26 Notify min segment start time when creating stream.
Fixes #1601

Change-Id: I132f05a23129fca944e955cbf8a347e735724b37
2018-11-07 15:11:33 -08:00
Jacob Trimble bc7f31efbd Fix seekable range with non-zero start.
Closes #1602

Change-Id: Ibe39f71c47f39235ac3815cb0f5bb49482f4fd53
2018-10-22 15:57:20 +00:00
Joey Parrish ca3119dfba Correct segment timestamps in PresentationTimeline
Before, segment timestamps were used in PresentationTimeline without
regard for the period start.  This means they were not truly relative
to the presentation, but to the period.

The "isFirstPeriod" argument was also broken.  It was meant to be true
for segments from the first period *ever*, but was passed true for the
first period *in the latest manifest update*.  So data calculated from
that was bogus for live streams.

Now, notifySegments() is supplied with a period start time, so that
segment references can be combined with the period start to give
presentation timestamps.  This fixes a major issue with the original
fix for #999.

Closes #999

Change-Id: Id0fe450f3ce4f90a2387d7103c75eb88f0c69c72
2018-08-20 19:10:02 +00:00
Joey Parrish 7a1c662b8a Tolerate drift in DASH live streams
This calculates the DASH live edge from explicit segment descriptions
when we have them.  The net effect is that availabilityStartTime will
only be used with SegmentTemplate+duration, in which we have no
explicit segment times.

With this, a DASH live stream experiencing encoder drift can still be
played so long as we know the segment times.  This makes playback of
DASH live streams work more like HLS live streams.

Please note that DASH live streams using SegmentTemplate+duration may
still suffer from encoder drift.

This change also:
  - Avoids DASH clock sync when availabilityStartTime is not used,
    which should reduce startup latency
  - Removes the simulation of a presentation start time for HLS live
  - Renames some variables and improves comments for clarity
  - Fixes some brittle tests that made bad assumptions or instrumented
    the wrong methods
  - Adds new tests that show the new behavior in PresentationTimeline

Closes #999

Change-Id: I21d7f3ccc81c9d9e218857a9b41882a7609ca36a
2018-08-07 18:34:16 +00:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Jacob Trimble a10b8a629c Rename segmentAvailabilityStart_ variable.
This is only used for the user-defined seek range for VOD, so the name
is not entirely correct.  This renames the field to make its usage more
clear.

Change-Id: I65a07a07fbfcb79086ed7679004f7e714b2db6f0
2018-03-27 17:36:21 +00:00
Jacob Trimble 2200d9b292 Fix safe seek window calculations.
This fixes how we determine the seek window for live content.  This
also allows for a slight margin for small seek windows in reposition_
so we don't repeatedly seek with that.

Closes #1331

Change-Id: I70e5e7c134677350d89d42cb0b5abfa784061b9e
2018-03-27 16:52:13 +00:00
Theodore Abshire fca48ea304 Typo fixes and rewording in comments, part 3
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: Ibce58f022b79de5efd5c0f3d5ab40a6042055b3f
2018-03-15 10:12:34 -07: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 b2bde18a3d Convert 'var' to 'let'/'const' (5 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: If4792c1bd3d5a82c24a4b2f0f84790d4eed22e67
2018-02-20 11:26:46 -08:00
Jacob Trimble 383867cde5 Remove getSegmentAvailabilityDuration.
This was only being used in tests which verified its own behavior.  This
removes the useless method to make tests that use mock
PresentationTimeline cleaner.  Code should use the availability window
methods indead of explicitly using the availability duration.

Change-Id: I0a9be8f319977ea8eb3ab50c65e458f49d9a3a75
2018-02-09 11:04:02 -08:00
theodab abf9f5ed08 Min bound bufferBehind with max segment size
When playing manifests with segments longer than bufferBehind, while
gap jumping is enabled, there can be issues where the streaming engine
evicts the frames of the segment currently playing, thus creating a
gap that is then jumped.
This change makes the streaming engine use bufferBehind or
maxSegmentSize, whichever is larger, when choosing when to evict
segments.
It also adds a getter for maxSegmentSize on presentationTimeline.

Closes #1123

Change-Id: I83459c5eb3ebb1d6dff031e2bc244ac9fc3b5763
2018-01-30 22:04:14 +00: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
Sandra Lokshina 051531b80f Add support for HLS playlists with type EVENT.
HLS Live comes in two flavors: LIVE and EVENT.
EVENTs append segments to the end of the playlist, but do not
ever remove segments. LIVE can both append segments to the end
and remove segments from the beginning of the playlist.
This CL lays the ground for supporting both types and introduces
support for EVENTs.

Issue #740.

Change-Id: I2042660daf9d1e7209cb1b40f50ab8b24571faa4
2017-08-22 19:02:04 +00: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 478fb1a473 Detect and attempt to correct timeline sync issues
This uses the new mediaSegmentReferences field, if available, to
detect and attempt to correct common timeline sync issues.  If the
most recent segment is outside the availability window, we make a
guess and move the window to align with the segments.

Closes #933

Change-Id: I1b9c444f82f9c526caf7a6942a758493d0adf9be
2017-07-26 07:22:11 +00:00
Sandra Lokshina 765e016e0b Add an API to limit playable/seekable range for VOD.
Closes #246.

Change-Id: If555ab5b78c60defe0932eb4c160ab4e296c9d9b
2017-05-31 21:28:52 +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
Jacob Trimble cbbc61ec4c Add a diagram for the PresentationTimeline
Change-Id: I6ca8dcd88e56daaf99820816ca9f3c9f02a2076f
2017-02-27 17:06:30 -08:00
Jacob Trimble 39e9b29c10 Allow seeking to 0 in live streams
This is a slightly-temporary fix that fixes #692.  This will
be replaced by a refactoring of Playhead.  That is also why there are
no new tests for this behavior.

We calculate a "safe window" where we could seek to if we are
unbuffered.  This ensures that we don't move backward while we are
buffering and "fall" out of the availability window.  Before, we would
take the availability start and add the rebuffering goal.  This led
to a problem where we couldn't seek to 0 since we would truncate the
availability start to 0 before adding.  This meant that even if
timeShiftBufferDepth was far enough away so that 0 was "safe", we would
still not allow seeking to it.

This makes it so we add the rebuffering goal before we truncate to 0
so time 0 can be considered "safe".

This also changes how seeks before the availability window are handled.
Before, it would always seek back to the "safe" point, even if there
was enough buffered.  Now, so long as the start of the window is
buffered, we will seek to the start of the window if you seek before it.

Closes #692

Change-Id: If8fc23b4d7dd945e0e1c01dd215e998037cd4ebb
2017-02-24 09:22:04 -08:00
Jacob Trimble db236cb6fb Don't use SPD to determine availability start.
Before we would use the suggestedPresentationDelay attribute when we
determined the availability start, which is incorrect.  This can be
seen by loading the DashIF live simulator streams and seeking to the
beginning of the seek range.

The DASH spec doesn't explicitly state this either way.  It seems to
suggest that suggestedPresentationDelay is only used to synchronize
playback and isn't used to calculate segment times or availability.
The spec also says that clients can ignore the attribute and use their
own, which suggests that it shouldn't affect availability.

Change-Id: I44d23a556c1aa40c42e2893718f8da1d3a373e8d
2017-02-16 18:52:14 +00:00
Sandra Lokshina 91da191a02 Add API to get live stream position as Date.
Closes #356

Change-Id: I5bea5906c4528313da96fd6577005b385b445a65
2016-10-06 17:25:28 +00:00
Joey Parrish 54dfe329b8 Fix missing semicolons and missing dependencies
These issues were identified by an upcoming release of the compiler
and must be fixed before we can upgrade.

Change-Id: I8cf3af90b930f2adfa9760299fe69f1892614bf2
2016-09-30 16:54:53 +00:00
Joey Parrish b5334d6e8a Account for presentation delay in IPR seek range
Closes #477

Change-Id: Ic171e89ab00c9af6b35ae205555e108946270c76
2016-08-29 17:06:31 -07:00
Joey Parrish 3cad924cf1 In-progress recording (IPR) support, phase 2
Behavior for IPR streams:
 * offline storage disallowed
 * segment references will not be stretched to the period
 * seek range starts at 0
 * seek range end is calculated like the live edge
 * seek bar is from 0 to duration, not the seek range

Closes #477

Change-Id: Ia36874bb7208c2473c79cb817395ce03925b8c95
2016-08-29 19:57:15 +00:00
Joey Parrish c7e73e0115 In-progress recording (IPR) support, phase 1
This change creates a new model which divides DASH streams into VOD,
IPR, and live.  It is possible to create manifests which do not fit
into any of the three categories according to our model, so we now
assert that our input fits cleanly into one of the three.

Inline manifests used in our tests had to be updated to conform to
the new model.  All external test assets have been verified to fit
into these categories.

This is phase 1 of IPR support.  There should be no behavior change
in this CL.

In phase 2, we will make various other parts of the library aware of
IPR so that IPR-specific behaviors can be achieved.

Issue #477

Change-Id: I395d3a0c8c9825a3cd2efde263b8493ce0920ed9
2016-08-29 11:09:45 -07:00
Joey Parrish da03f4391a Revert in-progress recording (IPR) support
These patches and IPR support in general will be revisited when we
have a better model for how this should work.

Closes #463

Change-Id: I2c5fe372986a9af232b052c67f8e5c3ba6585cee
2016-07-28 16:49:08 -07:00
Jacob Trimble 28aac020a6 Add test networking scheme.
This allows integration tests to test Player and offline with "real"
manifests and segments that are generated using ManifestGenerator and
StreamGenerator.  The networking scheme can also be used with an
unmodified Player.

b/29883614

Change-Id: I77aa5385ecaaac43ba713687befa2f064654375a
2016-07-12 21:52:36 +00:00
Seth Madison 30ef66eea2 change getSeekRangeEnd to allow scrubbing to end of in-progress VOD 2016-07-11 16:03:19 -07:00
Timothy Drews bf20f4ad2a Clamp getSeekRangeEnd() if necessary.
Change-Id: Ie6f3e43fbe84fe0c6fe21d9ef44dc92695a04dfd
2016-07-08 16:56:00 +00:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07:00
Jacob Trimble 7aab332e9b Correctly use suggestedPresentationDelay in seek range.
Before, we did not use suggestedPresentationDelay in the seek range.
This meant that seeking to the live edge would usually lead to a
buffering state because the seek range is the same as the availability
window.  Now the seek range is handled differently from the
availability window.

b/28938315

Change-Id: Iacfffe30778f7c63734fe24eeb95634611da86be
2016-06-22 22:06:51 +00:00
Timothy Drews 294bcca4e9 Treat absent timeShiftBufferDepth as infinity.
This patch also enables presentations to start in live mode
and end in VOD mode.

Issue #351

Change-Id: Idc0ad0c69887d61d080f844ef388222d1228a535
2016-05-02 14:22:38 -07:00
Timothy Drews 1108700f10 Use segment info to adjust the pres. timeline.
* Permit non-zero presentation start times for VOD: some
  presentations have segments which start too far from 0 to
  allow the video element to begin playback; now the player will
  start VOD presentations from the start of the first segment.
  However, segments of the 2nd, 3rd, 4th, etc., Period of a
  multi-Period presentation must still start close to 0 (the
  player will not jump any gaps in the presentation).
* Prohibit seeking to regions at the beginning of the segment
  availability window if segment information is missing from
  that region: sometimes live manifests do not contain all the
  segments in the segment availability window; now the player
  will prohibit seeking to these regions.
* Update definition of live in DashParser to match Player and
  Playhead.
* Simplify PresentationTimeline's constructor by just using setter
  functions.

Issue #341
Closes #348
Issue #357

Change-Id: I96c22774448476bea89ff4014f03b87bdb51ba07
2016-04-26 21:09:57 +00:00