Skip to content

Commit

Permalink
Remove periods from manifest structure
Browse files Browse the repository at this point in the history
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 shaka-project#1339 (flatten periods)
Issue shaka-project#1698 (rapid period transitions issue)
Issue shaka-project#856 (audio change causes bitrate change)
Closes shaka-project#892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
  • Loading branch information
joeyparrish committed Apr 9, 2020
1 parent f8f6479 commit 99de217
Show file tree
Hide file tree
Showing 73 changed files with 4,958 additions and 7,766 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ module.exports = {
},
{
'selector': 'CatchClause',
'message': 'Use expect.toFail or expectAsync.toBeRejected',
'message': 'Use expect.toThrow or expectAsync.toBeRejected',
},
{
'selector': 'CallExpression[callee.name=expect] >' +
Expand Down
2 changes: 0 additions & 2 deletions build/types/core
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
+../../lib/deprecate/enforcer.js
+../../lib/deprecate/version.js

+../../lib/media/active_stream_map.js
+../../lib/media/adaptation_set.js
+../../lib/media/adaptation_set_criteria.js
+../../lib/media/buffering_observer.js
Expand All @@ -22,7 +21,6 @@
+../../lib/media/manifest_parser.js
+../../lib/media/media_source_engine.js
+../../lib/media/mp4_segment_index_parser.js
+../../lib/media/period_observer.js
+../../lib/media/play_rate_controller.js
+../../lib/media/playhead.js
+../../lib/media/playhead_observer.js
Expand Down
1 change: 1 addition & 0 deletions build/types/offline
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
+../../lib/offline/indexeddb/storage_mechanism.js
+../../lib/offline/indexeddb/v1_storage_cell.js
+../../lib/offline/indexeddb/v2_storage_cell.js
+../../lib/offline/indexeddb/v5_storage_cell.js
+../../lib/offline/manifest_converter.js
+../../lib/offline/offline_manifest_parser.js
+../../lib/offline/offline_scheme.js
Expand Down
64 changes: 19 additions & 45 deletions externs/shaka/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
/**
* @typedef {{
* presentationTimeline: !shaka.media.PresentationTimeline,
* periods: !Array.<!shaka.extern.Period>,
* variants: !Array.<shaka.extern.Variant>,
* textStreams: !Array.<shaka.extern.Stream>,
* offlineSessionIds: !Array.<string>,
* minBufferTime: number
* }}
Expand All @@ -36,8 +37,6 @@
* </p>
*
* <p>
* The presentation timeline is divided into one or more Periods, and each of
* these Periods contains its own collection of Variants and text streams.
* A variant is a combination of an audio and a video streams that can be played
* together.
* </p>
Expand All @@ -54,9 +53,12 @@
* @property {!shaka.media.PresentationTimeline} presentationTimeline
* <i>Required.</i> <br>
* The presentation timeline.
* @property {!Array.<!shaka.extern.Period>} periods
* @property {!Array.<shaka.extern.Variant>} variants
* <i>Required.</i> <br>
* The presentation's Variants. There must be at least one Variant.
* @property {!Array.<shaka.extern.Stream>} textStreams
* <i>Required.</i> <br>
* The presentation's Periods. There must be at least one Period.
* The presentation's text streams.
* @property {!Array.<string>} offlineSessionIds
* <i>Defaults to [].</i> <br>
* An array of EME sessions to load for offline playback.
Expand All @@ -71,35 +73,6 @@
shaka.extern.Manifest;


/**
* @typedef {{
* startTime: number,
* variants: !Array.<shaka.extern.Variant>,
* textStreams: !Array.<shaka.extern.Stream>
* }}
*
* @description
* A Period object contains the Streams for part of the presentation.
*
* @property {number} startTime
* <i>Required.</i> <br>
* The Period's start time, in seconds, relative to the start of the
* presentation. The first Period must begin at the start of the
* presentation. The Period ends immediately before the next Period's start
* time or exactly at the end of the presentation timeline. Periods which
* begin after the end of the presentation timeline are ignored.
* @property {!Array.<shaka.extern.Variant>} variants
* <i>Required.</i> <br>
* The Period's Variants. There must be at least one Variant.
* @property {!Array.<shaka.extern.Stream>} textStreams
* <i>Required.</i> <br>
* The Period's text streams.
*
* @exportDoc
*/
shaka.extern.Period;


/**
* @typedef {{
* initData: !Uint8Array,
Expand Down Expand Up @@ -209,9 +182,9 @@ shaka.extern.DrmInfo;
* See {@link http://www.iso.org/iso/home/standards/language_codes.htm}
* @property {boolean} primary
* <i>Defaults to false.</i> <br>
* True indicates that the player should use this Variant over others in the
* same Period. The player may still use another Variant to meet application
* preferences.
* True indicates that the player should use this Variant over others if user
* preferences cannot be met. The player may still use another Variant to
* meet user preferences.
* @property {?shaka.extern.Stream} audio
* The audio stream of the variant.
* @property {?shaka.extern.Stream} video
Expand Down Expand Up @@ -261,7 +234,7 @@ shaka.extern.CreateSegmentIndexFunction;
* height: (number|undefined),
* kind: (string|undefined),
* encrypted: boolean,
* keyId: ?string,
* keyIds: !Array.<string>,
* language: string,
* label: ?string,
* type: string,
Expand Down Expand Up @@ -321,10 +294,11 @@ shaka.extern.CreateSegmentIndexFunction;
* @property {boolean} encrypted
* <i>Defaults to false.</i><br>
* True if the stream is encrypted.
* @property {?string} keyId
* <i>Defaults to null (i.e., unencrypted or key ID unknown).</i> <br>
* The stream's key ID as a lowercase hex string. This key ID identifies the
* encryption key that the browser (key system) can use to decrypt the stream.
* @property {!Array.<string>} keyIds
* <i>Defaults to empty (i.e., unencrypted or key ID unknown).</i> <br>
* The stream's key IDs as lowercase hex strings. These key IDs identify the
* encryption keys that the browser (key system) can use to decrypt the
* stream.
* @property {string} language
* The Stream's language, specified as a language code. <br>
* Audio stream's language must be identical to the language of the containing
Expand All @@ -336,9 +310,9 @@ shaka.extern.CreateSegmentIndexFunction;
* Content type (e.g. 'video', 'audio' or 'text')
* @property {boolean} primary
* <i>Defaults to false.</i> <br>
* True indicates that the player should prefer this Stream over others
* in the same Period. The player may still use another Stream to meet
* application preferences.
* True indicates that the player should use this Stream over others if user
* preferences cannot be met. The player may still use another Variant to
* meet user preferences.
* @property {?shaka.extern.Stream} trickModeVideo
* <i>Video streams only.</i> <br>
* An alternate video stream to use for trick mode playback.
Expand Down
10 changes: 4 additions & 6 deletions externs/shaka/manifest_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ shaka.extern.ManifestParser = class {
/**
* @typedef {{
* networkingEngine: !shaka.net.NetworkingEngine,
* filterNewPeriod: function(shaka.extern.Period),
* filterAllPeriods: function(!Array.<!shaka.extern.Period>),
* filter: function(shaka.extern.Manifest),
* onTimelineRegionAdded: function(shaka.extern.TimelineRegionInfo),
* onEvent: function(!Event),
* onError: function(!shaka.util.Error)
Expand All @@ -114,10 +113,9 @@ shaka.extern.ManifestParser = class {
*
* @property {!shaka.net.NetworkingEngine} networkingEngine
* The networking engine to use for network requests.
* @property {function(shaka.extern.Period)} filterNewPeriod
* Should be called on a new Period so that it can be filtered.
* @property {function(!Array.<!shaka.extern.Period>)} filterAllPeriods
* Should be called on all Periods so that they can be filtered.
* @property {function(shaka.extern.Manifest)} filter
* Should be called when new variants or text streams are added to the
* Manifest.
* @property {function(shaka.extern.TimelineRegionInfo)} onTimelineRegionAdded
* Should be called when a new timeline region is added.
* @property {function(!Event)} onEvent
Expand Down
72 changes: 40 additions & 32 deletions externs/shaka/offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ shaka.extern.OfflineSupport;
* The time that the encrypted license expires, in milliseconds. If the media
* is clear or the license never expires, this will equal Infinity.
* @property {!Array.<shaka.extern.Track>} tracks
* The tracks that are stored. This only lists those found in the first
* Period.
* The tracks that are stored.
* @property {Object} appMetadata
* The metadata passed to store().
* @exportDoc
Expand All @@ -64,7 +63,7 @@ shaka.extern.StoredContent;
* duration: number,
* size: number,
* expiration: number,
* periods: !Array.<shaka.extern.PeriodDB>,
* streams: !Array.<shaka.extern.StreamDB>,
* sessionIds: !Array.<string>,
* drmInfo: ?shaka.extern.DrmInfo,
* appMetadata: Object
Expand All @@ -80,8 +79,8 @@ shaka.extern.StoredContent;
* The license expiration, in milliseconds; or Infinity if not applicable.
* Note that upon JSON serialization, Infinity becomes null, and must be
* converted back upon loading from storage.
* @property {!Array.<shaka.extern.PeriodDB>} periods
* The Periods that are stored.
* @property {!Array.<shaka.extern.StreamDB>} streams
* The Streams that are stored.
* @property {!Array.<string>} sessionIds
* The DRM offline session IDs for the media.
* @property {?shaka.extern.DrmInfo} drmInfo
Expand All @@ -92,26 +91,11 @@ shaka.extern.StoredContent;
shaka.extern.ManifestDB;


/**
* @typedef {{
* startTime: number,
* streams: !Array.<shaka.extern.StreamDB>
* }}
*
* @property {number} startTime
* The start time of the period, in seconds.
* @property {!Array.<shaka.extern.StreamDB>} streams
* The streams that define the Period.
*/
shaka.extern.PeriodDB;


/**
* @typedef {{
* id: number,
* originalId: ?string,
* primary: boolean,
* presentationTimeOffset: number,
* contentType: string,
* mimeType: string,
* codecs: string,
Expand All @@ -122,11 +106,14 @@ shaka.extern.PeriodDB;
* label: ?string,
* width: ?number,
* height: ?number,
* initSegmentKey: ?number,
* encrypted: boolean,
* keyId: ?string,
* keyIds: !Array.<string>,
* segments: !Array.<shaka.extern.SegmentDB>,
* variantIds: !Array.<number>
* variantIds: !Array.<number>,
* roles: !Array.<string>,
* channelsCount: ?number,
* audioSamplingRate: ?number,
* closedCaptions: Map.<string, string>
* }}
*
* @property {number} id
Expand All @@ -136,9 +123,6 @@ shaka.extern.PeriodDB;
* DASH, this is the "id" attribute of the Representation element.
* @property {boolean} primary
* Whether the stream set was primary.
* @property {number} presentationTimeOffset
* The presentation time offset of the stream, in seconds. Note that this is
* the inverse of the timestampOffset as defined in the manifest types.
* @property {string} contentType
* The type of the stream, 'audio', 'text', or 'video'.
* @property {string} mimeType
Expand All @@ -159,31 +143,55 @@ shaka.extern.PeriodDB;
* The width of the stream; null for audio/text.
* @property {?number} height
* The height of the stream; null for audio/text.
* @property {?number} initSegmentKey
* The storage key where the init segment is found; null if no init segment.
* @property {boolean} encrypted
* Whether this stream is encrypted.
* @property {?string} keyId
* The key ID this stream is encrypted with.
* @property {!Array.<string>} keyIds
* The key IDs this stream is encrypted with.
* @property {!Array.<shaka.extern.SegmentDB>} segments
* An array of segments that make up the stream.
* @property {!Array.<number>} variantIds
* An array of ids of variants the stream is a part of.
* @property {!Array.<string>} roles
* The roles of the stream as they appear on the manifest,
* e.g. 'main', 'caption', or 'commentary'.
* @property {?number} channelsCount
* The channel count information for the audio stream.
* @property {?number} audioSamplingRate
* Specifies the maximum sampling rate of the content.
* @property {Map.<string, string>} closedCaptions
* A map containing the description of closed captions, with the caption
* channel number (CC1 | CC2 | CC3 | CC4) as the key and the language code
* as the value. If the channel number is not provided by the description,
* we'll set an 0-based index as the key.
* Example: {'CC1': 'eng'; 'CC3': 'swe'}, or {'1', 'eng'; '2': 'swe'}, etc.
*/
shaka.extern.StreamDB;


/**
* @typedef {{
* initSegmentKey: ?number,
* startTime: number,
* endTime: number,
* appendWindowStart: number,
* appendWindowEnd: number,
* timestampOffset: number,
* dataKey: number
* }}
*
* @property {?number} initSegmentKey
* The storage key where the init segment is found; null if no init segment.
* @property {number} startTime
* The start time of the segment, in seconds from the start of the Period.
* The start time of the segment in the presentation timeline.
* @property {number} endTime
* The end time of the segment, in seconds from the start of the Period.
* The end time of the segment in the presentation timeline.
* @property {number} appendWindowStart
* A start timestamp before which media samples will be truncated.
* @property {number} appendWindowEnd
* An end timestamp beyond which media samples will be truncated.
* @property {number} timestampOffset
* An offset which MediaSource will add to the segment's media timestamps
* during ingestion, to align to the presentation timeline.
* @property {number} dataKey
* The key to the data in storage.
*/
Expand Down
Loading

0 comments on commit 99de217

Please sign in to comment.