Commit Graph

89 Commits

Author SHA1 Message Date
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
Joey Parrish ba4f1d5468 Fix type info for StreamingEngine test fakes
The StreamingEngine tests use various fakes that did not have strong
type info before.  The new Closure Compiler won't allow this, and for
good reason.  Cleaning up the type info exposed a few ways that we had
left out important things or failed to remove methods that are no
longer on the types we're faking.

We also had some fakes for StreamingEngine tests that were redundant
with strongly-typed fakes that already existed in shaka.test.  This
deduplicates them.  The fakes for StreamingEngine are now just
instances of the other fakes with specific behavior attached.

Issue #2528

Change-Id: I0da67bea462e855fcfcb1b391fe83027ffa70702
2020-04-30 19:32:30 -07:00
Joey Parrish 5d07b5fbb7 Fix flake in high playback rate test
Something weird happens on some platforms (variously Chromecast, IE,
legacy Edge, and Safari) where the playhead can go past duration.  To
cope with this, don't fail on timeout.  If the video never got flagged
as "ended", check for the playhead to be near or past the end.

Also, wait for playback to begin before increasing the playback rate.
This improves test reliability on slow platforms like Chromecast.

Change-Id: If7d70de95b75e602853ec77ad1c285c118875db4
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
Jacob Trimble c8043f3916 Allow configuring when to fetch prev segment.
We fetch the previous segment in Live streams to combat differences
between the manfiest times and the segment times.  Now this can be
configured so apps with correct manifests can avoid the extra segment
request.

Also, we'll update the buffering state when a segment appends so we
leave the buffering state sooner.

Issue #2291

Change-Id: Id12c8132dc11739e4c8d42cb1f08e6ae7da1a966
2020-02-15 01:52:05 +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
Joey Parrish a48f8792a9 Move test-only method to test utils
This method should probably never have been in the library, since it
creates a fixed-sized, muted element.

Change-Id: I53b474305465bef34d43ce40ec5e7dedceb20a25
2020-01-06 18:57:28 +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 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
Jacob Trimble f9a031b086 Fix high playback rate test.
This tests wasn't working properly before since the 'onBuffering'
callback wasn't given to StreamingEngine.  This test was broken on
Edge, but at some point got fixed (or Edge fixed it's behavior).

Fixes #1743

Change-Id: I0af48207f5e8ad1c2e5007967a093f243e1837c9
2019-08-19 17:44:22 +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
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
Jacob Trimble 61d71df219 Convert media tests to ES6.
Issue #1157

Change-Id: I007f5dd43f297ca108cbb2caa7a9118527722350
2019-05-30 19:54:16 +00:00
Joey Parrish 208c7c55f0 Abort network requests if it won't cause buffering
Rather than only aborting a request if the new request is smaller
(effective when adapting down), abort if the new request will be done
"on time" (effective when adapting up) without causing buffering.

Change-Id: I7572b8bfc566a4f264a5080e4c1bc983f1363ce0
2019-05-15 17:27:37 +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 0dd64074b9 Only allow one statement per line.
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.

Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
2019-05-13 22:11:50 +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 061350a66d Use mdhd box over mvhd box in StreamGenerator
In our tests, we overwrite timestamps in segments to simulate streams.
In some cases, the init segment contains two different timescales:
one in the mdhd box and one in the mvhd box.  In fact, the mdhd box is
what the browser uses to interpret the tfdt box timestamps.  So the
mdhd box is what we should be reading, not the mvhd box.

This change fixes gaps in the test content generated from the multidrm
clips in our integration tests.  These were not detected before
because the tests in question never played beyond the first segment.
An unintentional change in buffering thresholds (fixed in an earlier
change) allowed us to see these gaps for the first time in our tests.

The buffering threshold change caused a buffering state in the offline
integration tests some small percentage of the time, which caused the
test to never reach its target timestamp.

This fixes the gaps by using the correct timescale to calculate the
timestamps for the tfdt box.  We knew this was an issue in theory as
far back as December 2017, but this was the first time our tests
actually failed because of it.  In most of our content, the two
timescale values match.  In the multidrm content from Axinom, they do
not.

Closes #1206

Change-Id: I863db30a16417a84f8e5df42f4d533b47fa4e7dc
2019-04-22 20:26:53 +00:00
Joey Parrish eff0d47c08 Factor out Tizen workaround
There is a workaround for a Tizen bug which appears in many of our
test suites.  To avoid having to add this to yet more, this change
factors out the workaround such that it applies to all tests.

Change-Id: Ie34c81bfcac94310bf3cd021fd4f2d55905b647a
2019-04-18 09:27:51 -07:00
Sandra Lokshina 493d459c47 Add a DOM util.
Change-Id: Ia0941868f20dbb42fa0fe02a639015ac244a65ed
2019-04-05 12:01:59 -07:00
Aaron Vaage 1776ea6e55 Rename StreamingEngine.init to StreamingEngine.start
The init method on streaming engine is responsible for initializing
streaming engine but it also starts the streaming process. In the
greater scheme of things, this is what starts playback.

To help communicate the full effect of what this one method does, this
changes its name to be "start" which helps show that it is starting a
process, not just initializing.

Change-Id: Ieceecce85917d97277782f41fd376fc6f97eaac9
2019-03-29 00:25:56 +00:00
Aaron Vaage 10f85361df Create Playhead Interface
We need to have a playhead for media source and src=, however the
current playhead implementation is tied very tightly to manifests.
Rather than working to refactor playhead, this change defines an
interface and makes the old playhead the Media Source implementation of
the interface.

In a later change the src= version will be introduced to allow playhead
functionality when we don't have a manifest.

Issue #816
Issue #997

Change-Id: Ie74e50839c79c3cd3acf14000849e3d5fa71a42f
2019-03-20 13:10:04 -07:00
Aaron Vaage 0f0a3515b6 Refactor media source engine to take text displayer in constructor
Before, media source engine could be created with no text displayer.
However, player would always create media source engine with a
text displayer.

Just like with closed captions, this appeared to be a good time
to change it to be passed in the constructor and have media source
engine own it.

This now means that media source engine is responsible for destroying
it - lessening player's responsibilities.

Change-Id: I71cd1c28a3c22d3c765a3892fe74ae3f9abd1914
2019-01-24 01:12:37 +00:00
Aaron Vaage 7148354aab Refactor Playhead (and below) to use IReleasable
This change takes playhead and its internal members and moves them
over to use the IReleasable interfaces instead of the IDestroyable
interface.

Change-Id: Iddb525725591a29a61ca6b5e2ad519ab708164eb
2019-01-24 01:11:48 +00:00
Aaron Vaage 43afe3a7c8 Refactor Event Manager To "Release" and not "Destroy"
We often use the IDestroyable interface to provide us with a standardized
way to break internal references and tear-down objects, however many
objects don't need this to be async. Once using IDestroyable, everyone
must assume that you must be async.

This change introduces IReleasable, a sibling to IDestryable, which
provides the |release| method. IReleasable is the synchronous version of
IDestroyable.

This change converts EventManager from IDestroyable to IReleasable as
the first of many conversions.

Change-Id: Ic3e90e594abc1c7326eccbe2521eb71676b74a09
2019-01-24 01:11:38 +00:00
Aaron Vaage edd7394ee0 Refactor StreamingEngine to not use Playhead directly
In streaming engine, we would use playhead to get the current
presentation time. Playhead was provided via the player
interface (defined by streaming engine).

Since streaming engine only needed to know what the presentation
time is, this changes the player interface to require a function
to get the presentation time rather than the playhead.

The general theme of this move is to help define the interface
in terms of needs and not the means in which they are fulfilled.

Change-Id: I442d54f08b650f22b9273a191d5a3a57af37b5bf
2019-01-22 22:00:07 +00:00
Aaron Vaage 7029a93378 Update Some StreamingEngine Tests to ES6
In prep of doing some work with streaming engine, I needed to update
the test to use ES6 so that it will be easier to make the changes
needed in the tests to try out the ideas.

Issue #1157

Change-Id: I5b468a70a3514df07063c2aa3c56f1b265ce4cc6
2019-01-05 00:10:22 +00: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
Tomáš Tichý e3739c9495 Add safeSeekOffset to StreamingConfiguration (#1726)
Closes #1723
2018-12-14 11:01:50 -08:00
Aaron Vaage f09d5d7a6c Pass ClosedCaptionParser into MediaSourceEngine
Instead of requiring media source engine to create its own closed
caption parser and then allow tests to override it, have it be
passed into the constructor.

This allows us to easily use the fake one in all our tests and
removes the need for a test only method on media source engine.

Change-Id: Ia1d4f0bb988dca30699b30ccaf4522126f357f90
2018-12-07 00:10:13 +00:00
Jacob Trimble 0abacfbc22 Avoid 'ended' event in StreamingEngine tests.
It seems that there is a bug in Safari where it will sometimes not fire
the 'ended' event even though it does end correctly.  So this changes
to use the 'timeupdate' event instead.

Fixes: 88699186
Fixes: 113334148
Fixes: 115994183
Change-Id: I6544f0a04feed1d2478a8f65070946811b9736d0
2018-09-18 21:55:45 +00:00
Aaron Vaage b0a52a68b8 Do not pass Manifest To Playhead
Changed the playhead constructor to not require a manifest.

Issue #816

Change-Id: If1f626cbfefa67edad39bf050a59bcc7e0696c3a
2018-07-10 16:24:07 -07: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
Theodore Abshire cd7dcf5286 Added async/await to some of Media tests.
Issue #1337
Change-Id: I0cb350ad87d0b5448d9f87f7823dbf307131108b
2018-06-07 15:03:05 -07:00
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Theodore Abshire c5de6cb115 Add option to force TS transmuxing
Our support for CEA 708 closed captions only works if the container
video file is transmuxed. Because of that, we were not successfully
reading such captions on platforms with native TS support.
This change adds a configuration option to force TS to be transmuxed
even when unnecessary, to account for that situation.
It also adds an integration test to ensure that CEA 708 captions can
be extracted on every platform.

Closes #276

Change-Id: Id8b2a67f2327d1b69c9cdfc443e9592c99baf0db
2018-03-30 11:04:03 -07:00
Joey Parrish 0c217391c9 Add alwaysStreamText config
This will allow text streaming to work correctly with browser native
controls.

Closes #1332

Change-Id: If11ba67957babad8dea23759aab9004d891aaf6b
2018-03-15 03:49:44 -07:00
Sandra Lokshina 6aae04ae29 Add setTextDisplayer() method to MediaSourceEngine.
Invoke the new method after a textDisplayer's been created.

Closes #1314.

Change-Id: I19891c845905a5a3509e74a93ebfe9a9c1ea7816
2018-02-22 23:47:40 +00:00
Jacob Trimble 064089152b Remove spacing around object definitions.
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.

Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
2018-02-21 13:35:00 -08: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 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
Joey Parrish b7bcafccc2 Move MediaSource setup to MediaSourceEngine
This isolates MediaSource code without changing the early
initialization of MediaSource, which was designed for low-latency
startup.

Prerequisite for #1087, #880, #997, #816

Change-Id: I61acedd95d73610d3e67436d9c7767d643fe2d29
2018-02-20 18:50:54 +00: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
Joey Parrish a63352c8f3 [ES6] Enable stricter checks in eslint
This digests and organizes many of the automatic settings in eslint,
and changes several of them to be more strict.  This also fixes the
following errors:
  - array-callback-return
  - no-catch-shadow
  - no-multi-spaces
  - no-new
  - no-throw-literal
  - no-useless-call
  - no-useless-concat
  - no-useless-return

Several checks have been organized into a group of checks we should
use, but need more time to implement and fix.  Some other checks have
been delegated to the Closure compiler, which can more precisely
whitelist exceptions.

Issue #1157

Change-Id: I8fe4966959e08050f8159e6a1fee161e7d71177e
2018-01-17 21:56:41 +00:00
Joey Parrish 719ba3a2ef Do not allow seeking/startup at duration
Seeking to or starting playback at the duration does not work well
across browsers.  Any seek or startup time at or past the duration of
VOD or IPR content will be bumped back by a configurable amount
(default 1s).

Closes #1014
Bug: 69874888

Change-Id: I6d21ecd8e211f0f823a093b8eb8b95d329b4385f
2017-12-05 18:08:51 +00:00
Joey Parrish e37aaed8f3 Work around Tizen hang in integration tests
Some integration tests have started failing on Tizen.  Without a brief
delay between tests, Tizen's pipeline gets stuck on subsequent tests.
There is media buffered, playbackRate is 1, paused is false, but the
playhead will not move.

Fixes: 64015865

Change-Id: If4497924d981e6ce1081690e02a16dc37b3dd439
2017-09-08 17:53:30 +00:00
Joey Parrish 2af0de2adb Move streaming retry logic into callback
Closes #960

Change-Id: Ieeacbf2e25f53a5af25a1de1935085e43457a092
2017-08-10 20:27:53 +00:00
Joey Parrish 79d0204d27 Flush pipeline only once
When we detect stalls in the media pipeline and attempt to flush them,
we should only flush once.  This avoids a situation in which a slow
hardware pipeline could trigger multiple flushes (when slowness can't
be differentiated from a stall).

Change-Id: Idd2ff8f6dd6ee64e903768b8846d8906e4db6787
2017-08-07 22:11:35 +00:00