Commit Graph

28 Commits

Author SHA1 Message Date
Timothy Drews 22c57e99e4 Rework SegmentIndex functionality.
This patch reworks SegmentIndexes so that any SegmentReference they
contain is guaranteed to be available. This makes SegmentIndexes work
consistently between static content and live content (specifically
content specified using SegmentTemplate with @duration).

* Rework StreamInfo to use a ISegmentIndexSource and a ISegmentInitSource,
  which construct a SegmentIndex and an intiailization segment
  respectively.
* Make ManifestInfo destructible and various async operations in
  StreamVideoSource safer.
* Introduce LiveSegmentIndex, which manages SegmentReference eviction.
* Introduce DynamicLiveSegmentIndex, which manages SegmentReference
  eviction and generation.
* Implement improved segment availability logic for segment eviction.
* Move SegmentIndex construction from MpdProcessor to several
  ISegmentIndexSource implementations.
* Use a SegmentIndex to represent subtitles to simplify Stream creation
  in StreamVideoSource.
* Move manifest update code from StreamVideoSource to ManifestUpdater.
* Move PeriodInfo.duration determination in MpdProcessor to StreamVideoSource.
* Since "forced" manifest updates are no longer required for content
  specified using SegmentTemplate with @duration, simplify manifest update
  code in DashVideoSource.
* Make Stream continue to update even if it runs out of
  SegmentReferences, this simplifies previous resync logic and makes
  DynamicLiveSegmentIndex work seamlessly.
* Refactor SegmentIndex and initialization fetch code in ContentDatabase.
* Download all SegmentIndexes in the background after the initial streams
  have started.

Follow up work is required to remove seek range logic from
DashVideoSource.

Change-Id: I4a908195aba632a911a6e55213fc41d41428162b
2015-06-09 11:46:40 -07:00
Joey Parrish 7dc3c1b0a9 Choose live playback by type='dynamic'.
Also avoid fetching manifest updates when minimumUpdatePeriod is
missing.  In the absence of minimumUpdatePeriod, just reprocess
the MPD we already downloaded.

Closes #69, #70.

Change-Id: I138bf136e5b0d691d9d625bbad02fb07ae21d32f
2015-04-28 11:59:55 -07:00
Timothy Drews 5e6bd2507a Make MediaSource duration larger for live streams
Setting the MediaSource duration to a larger value ensures that
the stream can play-out longer.

Change-Id: I04d330692f0f1291d85a605be53636842f3b42fa
2015-04-15 15:55:51 -07:00
Joey Parrish 10f80d2577 Refactor minBufferTime and bufferingGoal.
Strip extraneous minBufferTime copies.
Default minBufferTime in MpdProcessor if missing.
Pass minBufferTime as a parameter to Stream.start().
Keep a buffering goal separate from minBufferTime, which will only
be used for stream startup (as intended by the DASH spec).

This allows us to startup quickly and still buffer ahead.

Relates to #51.

Change-Id: I94b6b2566419344fa761ff75b0884719f255cd66
2015-04-14 14:35:02 -07:00
Joey Parrish 51563c118f Use start time as reference ID.
Since SegmentTimeline streams may not have segment numbers, we should
not use segment numbers as reference IDs.  These IDs must be unique
for the buffering and streaming systems to function properly.

This also adds assertions to check that reference IDs are unique.

Issue #21.

Change-Id: Ia94a48c68149283f87d27c6595a4f5a6cca07a27
2015-04-09 10:10:38 -07:00
Timothy Drews ea1f0120ef Align each SegmentIndex to its media timeline.
A SegmentIndex only provides an approximation of its media timeline. The
differences between the two can be particularly problematic if the
SegmentIndex is "behind" its media timeline, as such an offset may cause
the stream to get stuck during startup.

* Correct each SegmentIndex using timestamps in the actual segments.
* Make hasStarted() return true only after the Stream fully initializes.
* Adjust the seek range after computing a timestamp correction.
* Set timestampOffset for all types of SegmentTemplate based manifests.
* Remove PTO rounding, which is not required with timestamp correction.
* Only attempt to resync Streams after all streams have started.

Change-Id: Id03c38826d07513d8f451029ffc9d891854c19df
2015-04-09 16:21:20 +00:00
Timothy Drews a19ec9337f Fix earliest/best segment for SegmentTimeline.
* Only fallback to 0 for the earliest timestamp if there are
  no segments.
* Don't allow the best timestamp to be less than the earliest
  timestamp.

Issue #21

Change-Id: Ie4df6e36d60adc0ee0dfc54dcbefef7ae0de2705
2015-04-08 22:48:12 +00:00
Timothy Drews ea6d57c232 Reorganize mpd_processor.js
* Make function order in mpd_processor.js match function
  dependencies.
* Make a two line parameter list into a one line parameter list.

Actual code and comments are not changed.

Change-Id: I586b2552601a3c36c5cd1711f4589447213462a4
2015-04-07 18:31:41 +00:00
Timothy Drews b8b3ad862b Cleanup SegmentIndex, make merge() more robust.
* Rename SegmentIndex functions to shorter names.
* Add first() and last() functions for convenience.
* Throw exceptions for out of range errors.
* Handle more corner-cases in merge().
* Add more unit tests.

Change-Id: If875cd766e7091504c028413694326fcdf2aae5b
2015-04-06 22:07:17 +00:00
Timothy Drews 5b659acf9a Recover from unavailable live streams.
* After updating a manifest restart any streams that failed
  to initially start.
* Seek to the stream start time only after the streams have been
  initialized, seeking before can cause lock-ups with MSE.
* Rename 'bestStartTime' to 'currentSegmentStartTime'.

Issue #21

Change-Id: Ibad91fe2d5171196e93f20961008cdd25ecc437e
2015-03-30 19:19:53 +00:00
Timothy Drews a8e567c9db Start live streams near the "live-edge".
* Construct the initial SegmentIndex for a live stream such that it
  includes at least @timeShiftBufferDepth seconds of content before
  the "live-edge".
* Use segment numbers relative to @startNumber instead of relative
  to the start of the Period in SegmentReference to handle MPDs
  with partial segment information.
* Start live streams near the "live-edge", a.k.a., "best start time",
  and start static streams at the latest start time.

Issue #21

Change-Id: I3c553a1b7120a59c68f19cdc85f412f31972c1b8
2015-03-25 15:43:33 -07:00
Timothy Drews bc8c2bcf49 Refactor MpdProcessor.
* Expand SegmentTemplates directly to StreamInfos instead of using
  intermediate SegmentBases and SegmentLists.
* Remove "fake" attributes from SegmentBase and SegmentUrl.
* Simplify Period duration derivation.
* Add additional unit tests.

Change-Id: I203e269bd9dfb1fb1cc4ca48be29043c1ee4007b
2015-03-24 18:25:22 +00:00
Timothy Drews ac95cdfe14 Correct treatment of StreamInfo.timestampOffset.
* Set SourceBuffer.timestampOffset to StreamInfo.timestampOffset
  directly.
* Compute StreamInfo.timestampOffset in MpdProcessor.

Change-Id: Iea5621bc29df3de29d378e58720d6f71452274cd
2015-03-19 14:55:34 -07:00
Joey Parrish d481fdc7ec Best-effort clock synchronization.
The clock will be synced, when possible, to the server hosting the
MPD.  The synced clock will only be used in places where accurate
time matters, such as in loggable player stats and in live streaming.

Relates to #21

Change-Id: Id9da1cf23a781f2ce07a46e0936695d512a65133
2015-03-19 18:05:20 +00:00
Timothy Drews 44af1e4518 Implement initial support for live streams.
* Implement an update() method on StreamVideoSource that merges
  a new manifest into its existing one.
* Re-fetch and re-process MPDs from DashVideoSource to generate new
  SegmentReferences.
* Compute last available segment numbers and times in MpdProcessor
  when generating SegmentLists.
* Re-work Period computation in MpdProcessor.
* Handle stream EOF differently for live content.

Additional work is required to handle all "styles" of manifests.

Issue #21

Change-Id: I38be9513dc73e4683d1079b4dedb489e8206043d
2015-03-18 09:11:52 -07:00
Joey Parrish 56650d6820 Make DashVideoSource inherit from StreamVideoSource.
Change-Id: I1cb18e779721695333dd510ecb62119b9420d7ae
2015-03-11 15:10:36 -07:00
Timothy Drews 27ed78203a Merge Segment{Base, List, Template} across levels.
* Instead of overriding SegmentBase, SegmentList, etc. between
  levels (e.g., from Period to AdaptationSet) merge them, but
  prefer elements and attributes from inner levels.
* Refactor MPD parsing unit tests into separate files.
* Rewrite SegmentBase unit tests, add SegmentList, and
  SegmentTemplate unit tests.

Change-Id: I3fdb7657bb9f468e10f63e47e9a52fbf8ebbd40b
2015-03-05 01:20:07 +00:00
Timothy Drews 85cbc0e223 Fix # of segments computation in MpdProcessor.
* Correctly compute the number of segments when generating
  a SegmentList from a SegmentTemplate with a segment duration.
* Update unit tests.

Change-Id: Ic3edfd8c6eb8173ea52a4c606bbcd38c662de55f
2015-02-26 21:23:43 +00:00
Joey Parrish a253872c8a Update to 9 February 2015 EME spec.
This removes reliance on MediaKeys.isTypeSupported and instead uses the
supportedConfigurations parameter of requestMediaKeySystemAccess.

A lot of refactoring went into this effort, particularly around
StreamVideoSource, StreamSetInfo, and StreamInfoProcessor.

Closes #2, b/19354928.

Change-Id: Ibf81da909b8207b5babaec5ef0422dd1293d130d
2015-02-23 16:51:20 -08:00
Timothy Drews 3226db0d9d Handle gaps/overlaps in SegmentTimeline.
* Stretch/compress segments within a SegmentTimeline to align them
  to the beginning of the next segment.

This does not allow playback of content with actual gaps in it, but
allows MPDs with inaccurate SegmentTimelines to be used.

Closes #24, b/19144876

Change-Id: I183935db23fe26e1d6295e099b201a6af487d53b
2015-02-19 17:47:01 +00:00
Timothy Drews b244def2f4 Fix-up startNumber behavior.
* Revert 5c7fca90b6, which intended
  to allow startNumber to be 0, and maintain the previous behavior,
  which requires startNumber to begin at 1 (this appears to be in-line
  with the MPD spec).
* Correctly compute the $Time$ placeholder.
* Rename firstSegmentNumber to startNumber to clarify code.

Closes #10

Change-Id: I9b565edc9e23b9ad7c6bc62829d6b0ab565008a4
2015-02-13 18:45:59 +00:00
Timothy Drews 7e5983feac Change SourceBuffer timestamp offset calculation.
* Adjust SourceBuffer timestamps forward by the Period's
  start time and backwards by the Representation's
  presentationTimeOffset.
* Incorporate the start time of a Representation's first
  segment in the calculation of a Period's duration.
* Seek to the latest start time before starting playback.

Further adjustments will be required to support live playback.

Closes #17, b/19130302

Change-Id: Ia9fe6d8bbe5a69488130de2d8b146ce54dfff50e
2015-02-11 22:16:23 +00:00
Joey Parrish a92d673b1a Add support for the Role tag.
AdaptationSets are sorted by language (audio-only), then by those with
the "main" role.  Main sets are preferred when there are multiple to
choose from.

Closes #20, b/19214703.

Change-Id: I4fdd601c0bd7c7d29801084199123311ab9dbec3
2015-01-30 15:18:43 -08:00
Timothy Drews dddcfb344b Create DashVideoSource class.
Factor out DASH specific code from StreamVideoSource into
DashVideoSource.

b/18903621

Change-Id: I9743bf27bfe167d26236db7629abafb0c432f955
2015-01-27 16:28:20 -08:00
Timothy Drews 36fec68e75 Create 'media' namespace for stream generic code.
* Move internal non-DASH specific code into the 'media' namespace.
* Remove DASH references from generic stream code.

The documentation is not changed as a follow-up patch will factor out
DASH functionality from StreamVideoSource back into a new
DashVideoSource class.

b/18903621

Change-Id: I78d6e4f2824d4983619f17872828d95655fcfe50
2015-01-26 15:08:48 -08:00
Timothy Drews c8036b8cad Decouple DashVideoSource and DashStream from MPD classes.
* Create generic stream description classes to represent
  Representations, AdaptationSets, and Periods.
* Move generic stream selection logic out of MpdProcessor and
  into StreamInfoProcessor.
* Refactor DashVideoSource and DashStream to use the generic
  stream description classes.

A follow-up patch is required to re-organize files and namespaces.

b/18903621
b/18948677

Change-Id: I8bbb87ebf0242b31541199d0d1d3c40767c93a29
2015-01-26 15:08:48 -08:00
Joey Parrish d4df6987e7 Shaka Player release v1.1 2015-01-15 15:12:58 -08:00
Joey Parrish b3d035be9f Shaka Player release v1.0 2014-12-19 14:26:19 -08:00