Commit Graph

29 Commits

Author SHA1 Message Date
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 575f2ad109 Add an indicator for critical errors.
This adds a severity field to Error objects.  This can be used to
detect whether an error is recoverable.  All the same errors are still
reported so the field can be ignored.

There are two possible values:
* RECOVERABLE means that the Player will try to recover from the error
* CRITICAL means the Player will be unable to continue and must call
  load() again

Closes #564

Change-Id: Ie2c5468340c13e7a288b99690ab65b7ecc0a6b29
2017-04-04 23:57:59 +00:00
Joey Parrish aee79d460f Do not construct infinite segment references
This fixes an infinite loop when storing SegmentTemplate-based VOD
content.  In shaka.offline.Storage.prototype.createStream_, we loop
over all segment references to feed the download manager.  Those
references should stop at the period duration.

Closes #739

Change-Id: Ia16e89968b3bd8fc554b71ac857f8d9ae890cde1
2017-03-29 17:01:55 +00:00
Sandra Lokshina cb11dac389 Fit segment references to the period length in HLS parser.
b/36070874
b/35849456

Change-Id: Ibd64b02dd98d2ff6db175412e5f44dc5e872d767
2017-03-14 10:32:41 -07:00
Jacob Trimble d51079516e Fit segments to Period for live content.
We usually fit segment references to the Period for VOD content.  This
ensures that a gap in the manifest at the end of the Period doesn't
cause problems.  We don't do this for live because we may get more
segments.  However, for multi-Period live, we should still fit the
references for all Periods except the last one.

This also removes the error about duplicate Representation IDs for
VOD content since the problem only occurs for live.

Issue #694
b/35849085

Change-Id: Ib195dc51982ca58b8d5613b37817216980b8d366
2017-03-09 21:03:23 +00:00
Torbjörn Einarsson 547a88c1b5 Improvement of segment timeline $Time$ accuracy (#706)
Fix incorrect timeReplacement when large timescale

The current code essentially does this

    timeReplacement =
	(startTime / timescale + presentationTimeOffset) * timescale

When timescale is large enough (e.g. 10 MHz in order to support MS
Smooth Streaming as well), "startTime / timescale * timescale" may not
always be exactly "startTime" because of floating point precision,
which could produce incorrect segment URLs.

Keep startTime and presentationTimeOffset unchanged in the timeline
just to avoid the multiply/divide dance.

Closes #690
2017-02-22 13:46:22 -08:00
Sandra Lokshina 87073c9afa Create ManifestParserUtil common to dash and hls parsers.
Both DASH and HLS parsers will be using resolveUris() and possibly
other methods in the future.
Create a ManifestParserUtil for the shared methods.

Issue #279.

Change-Id: Iaa5e32ec543a390341a54752563a9f27251f0832
2017-01-19 23:34:25 +00: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
baconz 651b3fb68d Do not prematurely evict segments from multi-period manifests (#483)
presentationTimeline.getSegmentAvailabilityStart() yields a start time
relative to the AST, but all of the reference start/end times are relative
to their PTO. We need to normalize the start time to the period before
we evict any segments.
2016-08-16 12:44:17 -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
Seth Madison ab86551814 fitSegmentReferences: live check should consider timeShiftBufferDepth
If we rely on duration != null in-progress recordings get their
last segment stretched to the end
2016-07-01 17:06:51 -04:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07:00
Jacob Trimble a3c1ed29d4 Defer filling URI template until request is made.
Instead of filling the URI templates when parsing the manifest,
wait until the request is made to fill it.  This reduces the time
it takes to parse the manifest.

This was tested using a stream with a 24-hour timeShiftBufferDepth.
Using a Chromebook pixel running Chrome 51.  The average manifest
parse time was about 1 second before, now it is about 200ms.

Issue #405

Change-Id: I89f36085441f6c6b7d6281b24b671dc668f23fe5
2016-06-23 21:15:19 +00: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
Timothy Drews d36bb6bcf0 Set maxSegmentDuration for ST w/ duration.
Also add more unit tests for maxSegmentDuration.

Change-Id: I7648f64ab9f90c70d1daf53f30a3d558b7a899f3
2016-04-21 23:04:27 +00:00
Joey Parrish 32e351d060 Add @namespace annotations to static classes
Without @namespace annotations, static classes do not show up in the
generated API docs.  Although I stumbled over one instance while
writing tutorials, the rest were discovered programmatically by:

for x in $(find lib/ -name '*.js'); do
  grep -Eq '@(constructor|interface|namespace)' $x || echo $x
done

Change-Id: I97dd2bb4bf3faad5ac8d952a28837fa1f594deb9
2016-04-01 11:37:41 -07:00
Timothy Drews 3e300d25ae Fix live-edge calculation.
The live-edge calculation in PresentationTimeline needs to take into
account the duration of the current segment since the current segment
is not available until it has ended.

To do this we use MPD@maxSegmentDuration when available, and compute our
own maxSegmentDuration when it's not (as specified by the DASH spec).

Change-Id: Ic5b8478dbbff8eac93cf123a00a8b02db140cf15
2016-03-22 20:50:51 +00:00
Joey Parrish e50832f372 Do not require AdaptationSet ids for update
When updating a DASH manifest, we can key off of Period and
Representation only.  The spec says that Representation IDs are unique
within the Period, and that Period IDs are unique within the
presentation.  Therefore we do not need an AdaptationSet ID to merge
on update.

Relates to #310

Change-Id: I12b9f83c2bfda958a14e9ee31d459c04da8722e6
2016-03-21 16:38:31 -07:00
Costel G d56cbb1385 Add PTO support for SegmentBase 2016-03-20 15:36:28 +02:00
Costel Madalin Grecu c0e0aef46d Fix presentationTimeOffset handling in v2 #297 2016-03-16 12:08:06 +02:00
Jacob Trimble 19973d63f4 Changed copyright headers from 2015 to 2016.
Change-Id: I429ff27e4794c03b7ea392e38415075077f9bfb1
2016-03-15 16:32:13 -07:00
Timothy Drews 1007ffbc5e Fit SegmentReferences into their Period.
This ensures that small gaps from the start of the Period or from the
end of the Period are not interpreted as missing SegmentReferences.

Change-Id: I7492faef8e44067494e3daf3ff73742fa914d1e3
2016-03-15 13:50:19 -07:00
Jacob Trimble 8b99513242 Removed live check from Dash parser.
Our new interpretation of whether a stream is live is if there is
no duration.  This removes the old check for type='dynamic' from
the Dash parser.

Change-Id: I58aa1a785c7e949be7b48ab5b3b409cbf8e828a6
2016-03-14 21:19:32 +00:00
Jacob Trimble 8daf53e329 Renamed shaka.asserts to goog.asserts.
Using goog.asserts will work with the compiler.  So rather than
simply casting a nullable value when passing to a method, we can use
an assert which will correct the type and print a log if it somehow
is null.

This is not the same goog.asserts found in closure library, this
simply calls console.assert, but it is not required to do anything
for the compiler help.

Change-Id: I2548e39e772f0aa7ec41437cf9f5a2be383e0fbd
2016-03-11 15:29:20 -08:00
Joey Parrish 78e996d090 Fix issues found by the newest Closure compiler
Fixes the following issues:
=====

lib/player.js:106: ERROR - Property id never defined on TextTrack

lib/util/xml_utils.js:42: ERROR - inconsistent return type
found   : (Node|null)
required: (Element|null)

lib/dash/content_protection.js:256: ERROR - Parameter must have JSDoc.
      function(element) {

lib/dash/content_protection.js:284: ERROR - Parameter must have JSDoc.
      function(elem) {

lib/media/drm_engine.js:47: ERROR - Private property configuration_ is never read

lib/polyfill/patchedmediakeys_20140218.js:269: ERROR - Private property keySystem_ is never read

lib/polyfill/patchedmediakeys_20140218.js:389: ERROR - Private property type_ is never read

lib/util/language_utils.js:84: ERROR - The value 0.0 is duplicated in this enum.
  MIN: 0, MAX: 2

lib/util/language_utils.js:84: ERROR - The value 2.0 is duplicated in this enum.
  MIN: 0, MAX: 2

demo/assets.js:171: ERROR - Value assigned to local variable headers is never read

lib/dash/content_protection.js:188: ERROR - Value assigned to local variable repUnknown is never read

lib/dash/dash_parser.js:400: ERROR - Value assigned to local variable suggestedDelay is never read

lib/dash/segment_base.js:41: ERROR - Value assigned to local variable SegmentBase is never read

lib/dash/segment_template.js:291: ERROR - Value assigned to local variable periodStart is never read

lib/media/drm_engine.js:172: ERROR - Value assigned to local variable onEncrypted is never read

test/dash_parser_live_unit.js:358: ERROR - Value assigned to local variable manifest is never read

test/drm_engine_unit.js:383: ERROR - Value assigned to local variable cert1 is never read

test/drm_engine_unit.js:384: ERROR - Value assigned to local variable cert2 is never read

test/media_source_engine_unit.js:24: ERROR - Value assigned to local variable dummyData is never read

test/media_source_engine_unit.js:504: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:505: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:506: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:535: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:601: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:602: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:603: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:632: ERROR - Value assigned to local variable p2 is never read

test/mpd_utils_unit.js:20: ERROR - Value assigned to local variable HUGE_NUMBER_STRING is never read

test/streaming_engine_integration.js:55: ERROR - Value assigned to local variable onSeek is never read

test/streaming_engine_unit.js:1263: ERROR - Value assigned to local variable reportedContentType is never read

test/streaming_engine_unit.js:1264: ERROR - Value assigned to local variable reportedPeriodIndex is never read

test/streaming_engine_unit.js:1540: ERROR - Value assigned to local variable size is never read

test/util/dash_parser_util.js:77: ERROR - Value assigned to local variable retry is never read

test/util/dash_parser_util.js💯 ERROR - Value assigned to local variable retry is never read

test/vtt_text_parser_unit.js:272: ERROR - Value assigned to local variable result is never read

Change-Id: I707700250541e04ccbfe81d7298b3f0c5a82dcdc
2016-03-03 16:04:58 -08:00
Joey Parrish 793560d368 Fix typo
Change-Id: I6bf5b8df4f55a4e3f1c44d00db1905a89898abc6
2016-02-23 21:17:00 +00:00
Jacob Trimble 56d9bebc8e Fix DASH manifest parser when compiled.
The use of strings as indexers in the DASH manifest parser would
not work when the library is compiled.  This fixes it as well as
adding type-safety to those parts.

Change-Id: Id07068bc0eefdab4730dadc114e66b661cd4bb3e
2016-02-19 17:03:02 +00:00
Joey Parrish 63cc420d70 Promise.resolve requires context
This fails on Chrome:

var fn = Promise.resolve;
fn();

But this does not:

var fn = Promise.resolve.bind(Promise);
fn();

It seems that the native implementation of function "Promise.resolve"
needs the context of "Promise" as "this" to execute.

Change-Id: I4e06e6a85f966ef0af2f630da50cbfc60f12ed50
2016-02-09 20:22:10 +00:00
Jacob Trimble 54fa88f6f0 Added Dash manifest parser.
b/25851171

Change-Id: I4fbd6410d579899b749b50c8819fa8c17ac80658
2016-01-13 19:29:07 +00:00