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
In a recent refactor that made some internals of DASH parsing async for the first time, we broke the creation of SegmentReferences by having createUris close around values that changed later. This fixes the bug and adds a regression test.
This was broken in "Replace find/get callbacks with SegmentIndex"
because automated tests for SegmentBase did not cover multiple
Representations with different index/init ranges. Once the parsing
became async in the previous change, the index information was being
pulled from the last Representation parsed, rather than any specific
one.
This fixes the issue by making a shallow copy of the parsing context,
as was already done for SegmentTemplate.
SegmentList is synchronous, so it was not affected.
Issue #1339
Change-Id: I09c606c464b49c99d35d1031734b64872cfa6599
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
In the DASH parser, if there was no suggestedPresentationDelay and
ignoreMinBufferTime was set to true, the parser would set the
presentationDelay to NaN. This was because Math.max() will return NaN
if undefined is passed into it.
This changes minBufferTime to default to 0, if ignoreMinBufferTime is
true.
Fixes#2015
Change-Id: I8fc61706a04d14fd729e2185ce993a8bc87e48e5
This is a helper to aid in iterating over items. This returns a list
of objects that contain:
- "item": The current value.
- "prev": The previous value in the list.
- "next": The next value in the list.
- "i": The zero-based index in the list.
Issue #1518
Change-Id: Id18ab977e3ae45dfbfd2b4137a1bffb6e53c6bce
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
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
This enables the eslint rule that requires all functions to consistently
either return a value or not return a value.
Change-Id: I98b579f3689c3b6c74968116824231bb792bd9dd
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
A follow-up commit will convert "function" functions to arrow functions.
This caused some errors with the compiler, which this change fixes
beforehand.
Change-Id: Iff85b1e1f56b63a38b09f8db9947ed5daf02ddf4
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
This prepares some changes for the conversion from "let" to "const".
This ensures the follow-up is just an automated change with minimal
intervention.
Change-Id: I19b24dc67f20038dffd36b8903547f6ee4f00c25
It is type-safe to alias a class, but not one of its static methods.
Aliasing the method without the class makes it a "free call" to invoke
the aliased method.
A "free call" is when you call a method without the context of its
instance of class. There were several cases of this with static
methods.
This will be enforced by a future release of the compiler, which I
believe will lead into compiler support for "this" in static ES6
methods. In ES6, you can use "this" in static methods to refer to the
class and call other static methods. Closure compiler doesn't support
static "this" yet, but we will start using it as soon as it is
supported.
Change-Id: I4249db8b6dda9231ebba60ee0d4ad734a692c2fe
In four different places in our code base, we did the same
work to create a segment request. The bulk of the work was
based on setting-up the range header.
This CL creates a common utility that will create the request
for us while keeping networking engine as ignorant to segments
as it was before.
Issue #1788
Change-Id: Ie3dc2a99a34b3925fecbfdaae7b1e178a0b7a3b6
This CL limits the use of |setTimeout| by wrapping it in our own timer
class. The timer class makes it easier to track and cancel time-based
events.
To ensure that|setTimeout| is not used outside of our timer classes, the
conformance rules have been updated to only allow |setTimeout| to be
used by our timer classes.
Since |setTimeout| is very similar to |setInterval|, the conformance
rules for |setInternal| rules were updates to reflect more of the logic
behind why we don't want to use |setTimeout| and |setInterval| directly.
Change-Id: Iff5da32a61b515dd2016837fa74a34c04b6c5fd2
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
The configured clock sync URI was only being used for true live
streams, but there are cases where it is needed for in-progress
recordings, as well. This came up while working with a partner on
issues with CEA caption support.
Related to b/70902665
Change-Id: Ie7199dec3177a7ed014d9d0d9aaeb9f1bb1dbeac
When the dash content has CEA closed captions signal but no detail
information about channel number and language, we show the default
caption information.
Issue #1404
Change-Id: Ie6ca77739a043d24832efc5a28d4ba708dc4b17f
Adding support for CEA closed captions embedded in video streams for
Dash.
1. Dash parser reads and parses closed captions' channel and language
information.
2. Player creates text streams for the closed captions.
3. Media Source Engine calls mux.js Caption Parser API to get the closed
captions embedded in the video streams.
4. Text Engine stores the closed captions, and text displayer shows the
captions.
TODO:
1. Add test cases, will send out another CL.
2. Change closed captions support for hls to the similar way we handle
dash closed captions, will send out another CL.
3. Handle dash content that's missing language indication from the manifest.
Issue: #1404
Change-Id: Ibae8f69623c13561415ec860107d7f5bc86e19e9
- Only traverse children once.
- Avoid traversing into SegmentTimeline, which is usually large and
won't contain xlinks.
Issue #1640
Change-Id: I8a7a05d580740f9a9953b0a8aec89a06cc7e33f2
Add the config field manifest.dash.ignoreMinBufferTime, which will default to false. If true, the DASH parser will ignore minBufferTime in the manifest, such that streaming.rebufferingGoal is the only factor in play.
Closes#1547
This replaces almost every instance of indexOf on both String and
Array. There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.
Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
Changed the ClosedCaptions field in Stream from an object to an
array of ClosedCaption objects, so that it can be iterated through
and accessed easier.
Issue: #1404.
Change-Id: I67980cf4d5b5746785ba29f95718970fe89056f4
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
In some environments, goog.asserts.assert can cause an exception to be
thrown. Therefore, we must avoid spurious assertion failures.
In this case, the assertion about $Time$ could fire even if $Time$ was
not being used in the URI template.
Change-Id: Idba351989cd439f5202373d1ecb71804b372705e
The DASH parser will now expose Representation IDs via new fields in
the Stream and Track objects. The "id" field will continue to be a
unique, auto-generated numerical ID, and will be supplemented by a
nullable string containing whatever was originally in the manifest.
The HLS parser will now expose the NAME attribute in the originalId
field as well.
Bug: 112087288
Change-Id: I6b8107d27780fb97ab18de767f7abdc6c7110fe7
Closure was giving the warning "incomplete alias created for namespace
shaka.util.ManifestParserUtils". This change removes the alias which
resolves the warning.
Change-Id: Ie0ad79b217ba0b4f82eb6b45325075d1f1f4faa0
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
This reverts the implementation to an earlier draft state. During
review of the first version, I recommended moving the implementation
to Player so that it would be independent of the manifest parsers.
That was bad advice on my part, because this overlooked updates made
by the parsers when live manifests are updated later.
Closes#1177Closes#1307
Change-Id: I4611e00824dead83c6467da04a2a11afa892ace7