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
This commit is contained in:
Timothy Drews
2015-01-23 14:09:20 -08:00
committed by Joey Parrish
parent c8036b8cad
commit 36fec68e75
20 changed files with 417 additions and 415 deletions
+1 -1
View File
@@ -285,7 +285,7 @@ app.loadDashStream = function() {
var mediaUrl = document.getElementById('manifestUrlInput').value;
app.load_(
new shaka.player.DashVideoSource(
new shaka.player.StreamVideoSource(
mediaUrl,
app.interpretContentProtection_));
};
+19 -19
View File
@@ -20,14 +20,14 @@ goog.provide('shaka.dash.MpdProcessor');
goog.require('goog.Uri');
goog.require('shaka.asserts');
goog.require('shaka.dash.PeriodInfo');
goog.require('shaka.dash.SegmentIndex');
goog.require('shaka.dash.SegmentMetadataInfo');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.dash.StreamInfo');
goog.require('shaka.dash.StreamSetInfo');
goog.require('shaka.dash.mpd');
goog.require('shaka.log');
goog.require('shaka.media.PeriodInfo');
goog.require('shaka.media.SegmentIndex');
goog.require('shaka.media.SegmentMetadataInfo');
goog.require('shaka.media.SegmentReference');
goog.require('shaka.media.StreamInfo');
goog.require('shaka.media.StreamSetInfo');
@@ -36,17 +36,17 @@ goog.require('shaka.log');
* from SegmentTemplate elements, calculates start/duration attributes, removes
* invalid Representations, and ultimately generates an array of PeriodInfos.
*
* @param {shaka.player.DashVideoSource.ContentProtectionCallback}
* @param {shaka.player.StreamVideoSource.ContentProtectionCallback}
* interpretContentProtection
*
* @constructor
* @struct
*/
shaka.dash.MpdProcessor = function(interpretContentProtection) {
/** @private {shaka.player.DashVideoSource.ContentProtectionCallback} */
/** @private {shaka.player.StreamVideoSource.ContentProtectionCallback} */
this.interpretContentProtection_ = interpretContentProtection;
/** @type {!Array.<!shaka.dash.PeriodInfo>} */
/** @type {!Array.<!shaka.media.PeriodInfo>} */
this.periodInfos = [];
};
@@ -821,7 +821,7 @@ shaka.dash.MpdProcessor.prototype.createPeriodInfos_ = function(mpd) {
for (var i = 0; i < mpd.periods.length; ++i) {
var period = mpd.periods[i];
var periodInfo = new shaka.dash.PeriodInfo();
var periodInfo = new shaka.media.PeriodInfo();
shaka.asserts.assert(period.start != null);
periodInfo.start = period.start || 0;
@@ -832,7 +832,7 @@ shaka.dash.MpdProcessor.prototype.createPeriodInfos_ = function(mpd) {
for (var j = 0; j < period.adaptationSets.length; ++j) {
var adaptationSet = period.adaptationSets[j];
var streamSetInfo = new shaka.dash.StreamSetInfo();
var streamSetInfo = new shaka.media.StreamSetInfo();
streamSetInfo.contentType = adaptationSet.contentType || '';
for (var k = 0; k < adaptationSet.representations.length; ++k) {
@@ -872,12 +872,12 @@ shaka.dash.MpdProcessor.prototype.createPeriodInfos_ = function(mpd) {
* Creates a StreamInfo from the given Representation.
*
* @param {!shaka.dash.mpd.Representation} representation
* @return {shaka.dash.StreamInfo} The new StreamInfo on success; otherwise,
* @return {shaka.media.StreamInfo} The new StreamInfo on success; otherwise,
* return null.
* @private
*/
shaka.dash.MpdProcessor.prototype.createStreamInfo_ = function(representation) {
var streamInfo = new shaka.dash.StreamInfo();
var streamInfo = new shaka.media.StreamInfo();
streamInfo.id = representation.id;
streamInfo.lang = representation.lang || '';
@@ -967,7 +967,7 @@ shaka.dash.MpdProcessor.prototype.updateCommonDrmSchemes_ = function(
*
* @param {shaka.dash.mpd.RepresentationIndex|
* shaka.dash.mpd.Initialization} urlTypeObject
* @return {shaka.dash.SegmentMetadataInfo}
* @return {shaka.media.SegmentMetadataInfo}
* @private
*/
shaka.dash.MpdProcessor.prototype.createSegmentMetadataInfo_ = function(
@@ -976,7 +976,7 @@ shaka.dash.MpdProcessor.prototype.createSegmentMetadataInfo_ = function(
return null;
}
var segmentMetadataInfo = new shaka.dash.SegmentMetadataInfo();
var segmentMetadataInfo = new shaka.media.SegmentMetadataInfo();
segmentMetadataInfo.url = urlTypeObject.url;
@@ -993,7 +993,7 @@ shaka.dash.MpdProcessor.prototype.createSegmentMetadataInfo_ = function(
* Creates a SegmentIndex from a SegmentList.
*
* @param {!shaka.dash.mpd.SegmentList} segmentList
* @return {shaka.dash.SegmentIndex} A SegmentIndex on success; otherwise,
* @return {shaka.media.SegmentIndex} A SegmentIndex on success; otherwise,
* return null.
* @private
*/
@@ -1003,7 +1003,7 @@ shaka.dash.MpdProcessor.prototype.createSegmentIndex_ = function(segmentList) {
var firstSegmentNumber = segmentList.firstSegmentNumber;
var segmentDuration = segmentList.segmentDuration;
/** @type {!Array.<!shaka.dash.SegmentReference>} */
/** @type {!Array.<!shaka.media.SegmentReference>} */
var references = [];
for (var i = 0; i < segmentList.segmentUrls.length; ++i) {
@@ -1063,7 +1063,7 @@ shaka.dash.MpdProcessor.prototype.createSegmentIndex_ = function(segmentList) {
shaka.asserts.assert(segmentUrl.mediaUrl);
references.push(
new shaka.dash.SegmentReference(
new shaka.media.SegmentReference(
i,
startTime,
endTime,
@@ -1072,7 +1072,7 @@ shaka.dash.MpdProcessor.prototype.createSegmentIndex_ = function(segmentList) {
/** @type {!goog.Uri} */ (segmentUrl.mediaUrl)));
}
return new shaka.dash.SegmentIndex(references);
return new shaka.media.SegmentIndex(references);
};
@@ -16,7 +16,7 @@
* @fileoverview Implements a manager for adaptive bitrate streaming.
*/
goog.provide('shaka.dash.AbrManager');
goog.provide('shaka.media.AbrManager');
goog.require('shaka.log');
goog.require('shaka.player.AudioTrack');
@@ -41,7 +41,7 @@ goog.require('shaka.util.IBandwidthEstimator');
* @struct
* @constructor
*/
shaka.dash.AbrManager = function(estimator, videoSource) {
shaka.media.AbrManager = function(estimator, videoSource) {
/** @private {!shaka.util.IBandwidthEstimator} */
this.estimator_ = estimator;
@@ -56,7 +56,7 @@ shaka.dash.AbrManager = function(estimator, videoSource) {
* @private {number}
*/
this.nextAdaptationTime_ = (Date.now() / 1000) +
shaka.dash.AbrManager.FIRST_SWITCH_INTERVAL_;
shaka.media.AbrManager.FIRST_SWITCH_INTERVAL_;
/** @private {boolean} */
this.enabled_ = true;
@@ -74,7 +74,7 @@ shaka.dash.AbrManager = function(estimator, videoSource) {
* @private
* @const {number}
*/
shaka.dash.AbrManager.FIRST_SWITCH_INTERVAL_ = 4.0;
shaka.media.AbrManager.FIRST_SWITCH_INTERVAL_ = 4.0;
/**
@@ -84,7 +84,7 @@ shaka.dash.AbrManager.FIRST_SWITCH_INTERVAL_ = 4.0;
* @private
* @const {number}
*/
shaka.dash.AbrManager.MIN_SWITCH_INTERVAL_ = 8.0;
shaka.media.AbrManager.MIN_SWITCH_INTERVAL_ = 8.0;
/**
@@ -94,7 +94,7 @@ shaka.dash.AbrManager.MIN_SWITCH_INTERVAL_ = 8.0;
* @private
* @const {number}
*/
shaka.dash.AbrManager.MIN_EVAL_INTERVAL_ = 3.0;
shaka.media.AbrManager.MIN_EVAL_INTERVAL_ = 3.0;
/**
@@ -104,7 +104,7 @@ shaka.dash.AbrManager.MIN_EVAL_INTERVAL_ = 3.0;
* @private
* @const {number}
*/
shaka.dash.AbrManager.BANDWIDTH_UPGRADE_TARGET_ = 0.85;
shaka.media.AbrManager.BANDWIDTH_UPGRADE_TARGET_ = 0.85;
/**
@@ -114,7 +114,7 @@ shaka.dash.AbrManager.BANDWIDTH_UPGRADE_TARGET_ = 0.85;
* @private
* @const {number}
*/
shaka.dash.AbrManager.BANDWIDTH_DOWNGRADE_TARGET_ = 0.95;
shaka.media.AbrManager.BANDWIDTH_DOWNGRADE_TARGET_ = 0.95;
/**
@@ -122,7 +122,7 @@ shaka.dash.AbrManager.BANDWIDTH_DOWNGRADE_TARGET_ = 0.95;
*
* @suppress {checkTypes} to set otherwise non-nullable types to null.
*/
shaka.dash.AbrManager.prototype.destroy = function() {
shaka.media.AbrManager.prototype.destroy = function() {
this.eventManager_.destroy();
this.eventManager_ = null;
@@ -136,7 +136,7 @@ shaka.dash.AbrManager.prototype.destroy = function() {
*
* @param {boolean} enabled
*/
shaka.dash.AbrManager.prototype.enable = function(enabled) {
shaka.media.AbrManager.prototype.enable = function(enabled) {
this.enabled_ = enabled;
};
@@ -147,7 +147,7 @@ shaka.dash.AbrManager.prototype.enable = function(enabled) {
* @return {?number} The chosen video track ID or null if there are no video
* tracks to choose.
*/
shaka.dash.AbrManager.prototype.getInitialVideoTrackId = function() {
shaka.media.AbrManager.prototype.getInitialVideoTrackId = function() {
var chosen = this.chooseVideoTrack_();
return chosen ? chosen.id : null;
};
@@ -162,7 +162,7 @@ shaka.dash.AbrManager.prototype.getInitialVideoTrackId = function() {
* @template T
* @private
*/
shaka.dash.AbrManager.findActiveTrack_ = function(trackList) {
shaka.media.AbrManager.findActiveTrack_ = function(trackList) {
for (var i = 0; i < trackList.length; ++i) {
if (trackList[i].active) {
return trackList[i];
@@ -179,13 +179,13 @@ shaka.dash.AbrManager.findActiveTrack_ = function(trackList) {
* @param {!Event} event
* @private
*/
shaka.dash.AbrManager.prototype.onBandwidth_ = function(event) {
shaka.media.AbrManager.prototype.onBandwidth_ = function(event) {
if (!this.enabled_) {
return;
}
// Alias.
var AbrManager = shaka.dash.AbrManager;
var AbrManager = shaka.media.AbrManager;
var now = Date.now() / 1000.0;
if (now < this.nextAdaptationTime_) {
@@ -216,9 +216,9 @@ shaka.dash.AbrManager.prototype.onBandwidth_ = function(event) {
* are no video tracks to choose.
* @private
*/
shaka.dash.AbrManager.prototype.chooseVideoTrack_ = function() {
shaka.media.AbrManager.prototype.chooseVideoTrack_ = function() {
// Alias.
var AbrManager = shaka.dash.AbrManager;
var AbrManager = shaka.media.AbrManager;
var videoTracks = this.videoSource_.getVideoTracks();
if (videoTracks.length == 0) {
@@ -16,9 +16,9 @@
* @fileoverview An interface for a generic segment index parser.
*/
goog.provide('shaka.dash.ISegmentIndexParser');
goog.provide('shaka.media.ISegmentIndexParser');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.media.SegmentReference');
@@ -27,7 +27,7 @@ goog.require('shaka.dash.SegmentReference');
*
* @interface
*/
shaka.dash.ISegmentIndexParser = function() {};
shaka.media.ISegmentIndexParser = function() {};
/**
@@ -38,9 +38,9 @@ shaka.dash.ISegmentIndexParser = function() {};
* @param {!DataView} indexData The segment index bytes.
* @param {number} indexOffset The byte offset of the segmentIndex in the
* container.
* @return {Array.<!shaka.dash.SegmentReference>} The segment references, or
* @return {Array.<!shaka.media.SegmentReference>} The segment references, or
* null if an error occurred
*/
shaka.dash.ISegmentIndexParser.prototype.parse =
shaka.media.ISegmentIndexParser.prototype.parse =
function(initSegmentData, indexData, indexOffset) {};
@@ -13,62 +13,62 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @fileoverview DASH stream interface.
* @fileoverview A generic media stream interface.
*/
goog.provide('shaka.dash.IDashStream');
goog.provide('shaka.media.IStream');
goog.require('shaka.dash.mpd');
/**
* An IDashStream is an active representation.
* An IStream is a generic media stream interface.
*
* @interface
* @extends {EventTarget}
*/
shaka.dash.IDashStream = function() {};
shaka.media.IStream = function() {};
/**
* Destroys the DashStream.
* Destroys the Stream.
*/
shaka.dash.IDashStream.prototype.destroy = function() {};
shaka.media.IStream.prototype.destroy = function() {};
/** @return {shaka.dash.StreamInfo} */
shaka.dash.IDashStream.prototype.getStreamInfo = function() {};
/** @return {shaka.media.StreamInfo} */
shaka.media.IStream.prototype.getStreamInfo = function() {};
/** @return {boolean} */
shaka.dash.IDashStream.prototype.hasEnded = function() {};
shaka.media.IStream.prototype.hasEnded = function() {};
/**
* Start processing the stream. This should only be called once.
* An 'ended' event will be fired on EOF.
*
* @param {!shaka.dash.StreamInfo} streamInfo
* @param {!shaka.media.StreamInfo} streamInfo
*/
shaka.dash.IDashStream.prototype.start = function(streamInfo) {};
shaka.media.IStream.prototype.start = function(streamInfo) {};
/**
* Switch the stream to use the given |representation|. The stream must
* already be started.
*
* @param {!shaka.dash.StreamInfo} streamInfo
* @param {!shaka.media.StreamInfo} streamInfo
* @param {boolean} immediate If true, switch as soon as possible. Otherwise,
* switch when convenient.
*/
shaka.dash.IDashStream.prototype.switch = function(streamInfo, immediate) {};
shaka.media.IStream.prototype.switch = function(streamInfo, immediate) {};
/**
* Resync the stream with the video's currentTime. Called on seeking.
*/
shaka.dash.IDashStream.prototype.resync = function() {};
shaka.media.IStream.prototype.resync = function() {};
/**
@@ -76,11 +76,11 @@ shaka.dash.IDashStream.prototype.resync = function() {};
*
* @param {boolean} enabled
*/
shaka.dash.IDashStream.prototype.setEnabled = function(enabled) {};
shaka.media.IStream.prototype.setEnabled = function(enabled) {};
/**
* @return {boolean} true if the stream is enabled.
*/
shaka.dash.IDashStream.prototype.getEnabled = function() {};
shaka.media.IStream.prototype.getEnabled = function() {};
@@ -16,11 +16,11 @@
* @fileoverview Parses a segment index from an ISO BMFF SIDX structure.
*/
goog.provide('shaka.dash.IsobmffSegmentIndexParser');
goog.provide('shaka.media.IsobmffSegmentIndexParser');
goog.require('shaka.dash.ISegmentIndexParser');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexParser');
goog.require('shaka.media.SegmentReference');
goog.require('shaka.util.DataViewReader');
@@ -32,16 +32,16 @@ goog.require('shaka.util.DataViewReader');
* SegmentReferences are assumed to be reteivable from |mediaUrl|.
*
* @constructor
* @implements {shaka.dash.ISegmentIndexParser}
* @implements {shaka.media.ISegmentIndexParser}
*/
shaka.dash.IsobmffSegmentIndexParser = function(mediaUrl) {
shaka.media.IsobmffSegmentIndexParser = function(mediaUrl) {
/** @private {!goog.Uri} */
this.mediaUrl_ = mediaUrl;
};
/** @override */
shaka.dash.IsobmffSegmentIndexParser.prototype.parse =
shaka.media.IsobmffSegmentIndexParser.prototype.parse =
function(initSegmentData, indexData, indexOffset) {
var references = null;
@@ -62,26 +62,26 @@ shaka.dash.IsobmffSegmentIndexParser.prototype.parse =
* 32-bit unsigned integer.
* @const {number}
*/
shaka.dash.IsobmffSegmentIndexParser.SIDX_INDICATOR = 0x73696478;
shaka.media.IsobmffSegmentIndexParser.SIDX_INDICATOR = 0x73696478;
/**
* Parses the segment index from an ISO BMFF SIDX structure.
* @param {!DataView} dataView The ISO BMFF SIDX data.
* @param {number} sidxOffset The byte offset of the SIDX in the container.
* @return {Array.<!shaka.dash.SegmentReference>} The segment references, or
* @return {Array.<!shaka.media.SegmentReference>} The segment references, or
* null if an error occurred.
* @throws {RangeError}
* @private
* @see ISO/IEC 14496-12:2012 section 4.2 and 8.16.3
*/
shaka.dash.IsobmffSegmentIndexParser.prototype.parseInternal_ = function(
shaka.media.IsobmffSegmentIndexParser.prototype.parseInternal_ = function(
dataView, sidxOffset) {
var reader = new shaka.util.DataViewReader(
dataView,
shaka.util.DataViewReader.Endianness.BIG_ENDIAN);
/** @type {!Array.<!shaka.dash.SegmentReference>} */
/** @type {!Array.<!shaka.media.SegmentReference>} */
var references = [];
// A SIDX structure is contained within a FullBox structure, which itself is
@@ -91,7 +91,7 @@ shaka.dash.IsobmffSegmentIndexParser.prototype.parseInternal_ = function(
var boxSize = reader.readUint32();
var boxType = reader.readUint32();
if (boxType != shaka.dash.IsobmffSegmentIndexParser.SIDX_INDICATOR) {
if (boxType != shaka.media.IsobmffSegmentIndexParser.SIDX_INDICATOR) {
shaka.log.error('Invalid box type, expected "sidx".');
return null;
}
@@ -160,7 +160,7 @@ shaka.dash.IsobmffSegmentIndexParser.prototype.parseInternal_ = function(
}
references.push(
new shaka.dash.SegmentReference(
new shaka.media.SegmentReference(
i,
unscaledStartTime / timescale,
(unscaledStartTime + subsegmentDuration) / timescale,
@@ -16,23 +16,23 @@
* @fileoverview Implements a segment index.
*/
goog.provide('shaka.dash.SegmentIndex');
goog.provide('shaka.media.SegmentIndex');
goog.require('shaka.asserts');
goog.require('shaka.dash.SegmentRange');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.media.SegmentRange');
goog.require('shaka.media.SegmentReference');
/**
* Creates a SegmentIndex.
*
* @param {!Array.<!shaka.dash.SegmentReference>} references Sorted by time in
* @param {!Array.<!shaka.media.SegmentReference>} references Sorted by time in
* ascending order.
* @constructor
*/
shaka.dash.SegmentIndex = function(references) {
/** @private {!Array.<!shaka.dash.SegmentReference>} */
shaka.media.SegmentIndex = function(references) {
/** @private {!Array.<!shaka.media.SegmentReference>} */
this.references_ = references;
};
@@ -42,7 +42,7 @@ shaka.dash.SegmentIndex = function(references) {
*
* @return {number}
*/
shaka.dash.SegmentIndex.prototype.getNumReferences = function() {
shaka.media.SegmentIndex.prototype.getNumReferences = function() {
return this.references_.length;
};
@@ -51,10 +51,10 @@ shaka.dash.SegmentIndex.prototype.getNumReferences = function() {
* Gets the SegmentReference at the given index.
*
* @param {number} index
* @return {shaka.dash.SegmentReference} The SegmentReference or null if |index|
* is out of range.
* @return {shaka.media.SegmentReference} The SegmentReference or null if
* |index| is out of range.
*/
shaka.dash.SegmentIndex.prototype.getReference = function(index) {
shaka.media.SegmentIndex.prototype.getReference = function(index) {
if (index < 0 || index >= this.references_.length) {
return null;
}
@@ -69,17 +69,17 @@ shaka.dash.SegmentIndex.prototype.getReference = function(index) {
*
* @param {number} startTime The starting time in seconds.
* @param {number} duration The interval's duration in seconds.
* @return {shaka.dash.SegmentRange} The SegmentRange or null if there are no
* @return {shaka.media.SegmentRange} The SegmentRange or null if there are no
* segments.
*/
shaka.dash.SegmentIndex.prototype.getRangeForInterval =
shaka.media.SegmentIndex.prototype.getRangeForInterval =
function(startTime, duration) {
var beginIndex = this.findReferenceIndex(startTime);
if (beginIndex < 0) {
return null;
}
/** @type {!Array.<!shaka.dash.SegmentReference>} */
/** @type {!Array.<!shaka.media.SegmentReference>} */
var references = [];
for (var i = beginIndex; i < this.references_.length; i++) {
@@ -91,7 +91,7 @@ shaka.dash.SegmentIndex.prototype.getRangeForInterval =
}
}
return new shaka.dash.SegmentRange(references);
return new shaka.media.SegmentRange(references);
};
@@ -104,7 +104,7 @@ shaka.dash.SegmentIndex.prototype.getRangeForInterval =
* index of the last SegmentReference is returned if |time| is greater than
* the last segment's time. -1 is returned if there are no segments.
*/
shaka.dash.SegmentIndex.prototype.findReferenceIndex = function(time) {
shaka.media.SegmentIndex.prototype.findReferenceIndex = function(time) {
for (var i = 0; i < this.references_.length; i++) {
if (this.references_[i].startTime > time) {
return i ? i - 1 : 0;
@@ -17,10 +17,10 @@
* more contiguous segments.
*/
goog.provide('shaka.dash.SegmentRange');
goog.provide('shaka.media.SegmentRange');
goog.require('shaka.asserts');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.media.SegmentReference');
@@ -28,16 +28,16 @@ goog.require('shaka.dash.SegmentReference');
* Creates a SegmentRange, which represents a set of one or more contiguous
* segments.
*
* @param {!Array.<!shaka.dash.SegmentReference>} references A set of
* @param {!Array.<!shaka.media.SegmentReference>} references A set of
* references to contiguous segments. There must be at least one reference.
*
* @constructor
* @struct
*/
shaka.dash.SegmentRange = function(references) {
shaka.media.SegmentRange = function(references) {
shaka.asserts.assert(references.length > 0);
/** @type {!Array.<!shaka.dash.SegmentReference>} */
/** @type {!Array.<!shaka.media.SegmentReference>} */
this.references = references;
};
@@ -16,7 +16,7 @@
* @fileoverview Implements a segment reference structure.
*/
goog.provide('shaka.dash.SegmentReference');
goog.provide('shaka.media.SegmentReference');
goog.require('goog.Uri');
@@ -38,7 +38,7 @@ goog.require('goog.Uri');
* @constructor
* @struct
*/
shaka.dash.SegmentReference = function(
shaka.media.SegmentReference = function(
index, startTime, endTime, startByte, endByte, url) {
/**
* The segment's number, starting at 0, within the stream.
@@ -17,10 +17,10 @@
* based on Promises.
*/
goog.provide('shaka.dash.SourceBufferManager');
goog.provide('shaka.media.SourceBufferManager');
goog.require('shaka.asserts');
goog.require('shaka.dash.SegmentRange');
goog.require('shaka.media.SegmentRange');
goog.require('shaka.util.EventManager');
goog.require('shaka.util.IBandwidthEstimator');
goog.require('shaka.util.PublicPromise');
@@ -46,7 +46,7 @@ goog.require('shaka.util.RangeRequest');
* @struct
* @constructor
*/
shaka.dash.SourceBufferManager = function(
shaka.media.SourceBufferManager = function(
mediaSource, sourceBuffer, estimator) {
/** @private {!MediaSource} */
this.mediaSource_ = mediaSource;
@@ -66,8 +66,8 @@ shaka.dash.SourceBufferManager = function(
*/
this.buffered_ = [];
/** @private {shaka.dash.SourceBufferManager.State_} */
this.state_ = shaka.dash.SourceBufferManager.State_.IDLE;
/** @private {shaka.media.SourceBufferManager.State_} */
this.state_ = shaka.media.SourceBufferManager.State_.IDLE;
/** @private {Promise} */
this.promise_ = null;
@@ -77,7 +77,7 @@ shaka.dash.SourceBufferManager = function(
/**
* The current SegmentReferences being fetched or appended.
* @private {!Array.<!shaka.dash.SegmentReference>}
* @private {!Array.<!shaka.media.SegmentReference>}
*/
this.references_ = [];
@@ -105,7 +105,7 @@ shaka.dash.SourceBufferManager = function(
* @enum
* @private
*/
shaka.dash.SourceBufferManager.State_ = {
shaka.media.SourceBufferManager.State_ = {
IDLE: 0,
REQUESTING: 1,
APPENDING: 2,
@@ -118,7 +118,7 @@ shaka.dash.SourceBufferManager.State_ = {
* Destroys the SourceBufferManager.
* @suppress {checkTypes} to set otherwise non-nullable types to null.
*/
shaka.dash.SourceBufferManager.prototype.destroy = function() {
shaka.media.SourceBufferManager.prototype.destroy = function() {
this.abort();
this.state_ = null;
@@ -144,7 +144,7 @@ shaka.dash.SourceBufferManager.prototype.destroy = function() {
* @param {number} index The segment's index.
* @return {boolean} True if the segment is buffered.
*/
shaka.dash.SourceBufferManager.prototype.isBuffered = function(index) {
shaka.media.SourceBufferManager.prototype.isBuffered = function(index) {
return this.buffered_[index] == true;
};
@@ -154,25 +154,25 @@ shaka.dash.SourceBufferManager.prototype.isBuffered = function(index) {
* retrieved segment data to the underlying SourceBuffer. This cannot be called
* if another operation is in progress.
*
* @param {!shaka.dash.SegmentRange} segmentRange
* @param {!shaka.media.SegmentRange} segmentRange
* @param {!ArrayBuffer=} opt_initSegment Optional initialization segment that
* will be appended to the underlying SourceBuffer before the retrieved
* segment data.
*
* @return {!Promise}
*/
shaka.dash.SourceBufferManager.prototype.fetch = function(
shaka.media.SourceBufferManager.prototype.fetch = function(
segmentRange, opt_initSegment) {
shaka.log.v1('fetch');
// Alias.
var SBM = shaka.dash.SourceBufferManager;
var SBM = shaka.media.SourceBufferManager;
// Check state.
shaka.asserts.assert(this.state_ == SBM.State_.IDLE);
if (this.state_ != SBM.State_.IDLE) {
var error = new Error('Cannot fetch: previous operation not complete.');
error.type = 'dash';
error.type = 'stream';
return Promise.reject(error);
}
@@ -238,7 +238,7 @@ shaka.dash.SourceBufferManager.prototype.fetch = function(
* @return {!Promise}
* @private
*/
shaka.dash.SourceBufferManager.prototype.fetchFromSingleUrl_ = function() {
shaka.media.SourceBufferManager.prototype.fetchFromSingleUrl_ = function() {
shaka.log.v1('fetchFromSingleUrl_');
shaka.asserts.assert(this.references_.length > 0);
shaka.asserts.assert(this.request_ == null);
@@ -263,15 +263,15 @@ shaka.dash.SourceBufferManager.prototype.fetchFromSingleUrl_ = function() {
* @return {!Promise}
* @private
*/
shaka.dash.SourceBufferManager.prototype.fetchFromMultipleUrls_ = function() {
shaka.media.SourceBufferManager.prototype.fetchFromMultipleUrls_ = function() {
shaka.log.v1('fetchFromMultipleUrls_');
shaka.asserts.assert(this.references_.length > 0);
shaka.asserts.assert(this.request_ == null);
/**
* Requests the segment specified by |reference|.
* @param {!shaka.dash.SegmentReference} reference
* @this {shaka.dash.SourceBufferManager}
* @param {!shaka.media.SegmentReference} reference
* @this {shaka.media.SourceBufferManager}
* @return {!Promise.<!ArrayBuffer>}
*/
var requestSegment = function(reference) {
@@ -308,7 +308,7 @@ shaka.dash.SourceBufferManager.prototype.fetchFromMultipleUrls_ = function() {
* @return {!Promise}
* @private
*/
shaka.dash.SourceBufferManager.prototype.appendSegment_ = function(data) {
shaka.media.SourceBufferManager.prototype.appendSegment_ = function(data) {
this.segments_.push(data);
return Promise.resolve();
};
@@ -322,17 +322,17 @@ shaka.dash.SourceBufferManager.prototype.appendSegment_ = function(data) {
*
* @return {!Promise}
*/
shaka.dash.SourceBufferManager.prototype.clear = function() {
shaka.media.SourceBufferManager.prototype.clear = function() {
shaka.log.v1('clear');
// Alias.
var SBM = shaka.dash.SourceBufferManager;
var SBM = shaka.media.SourceBufferManager;
// Check state.
shaka.asserts.assert(this.state_ == SBM.State_.IDLE);
if (this.state_ != SBM.State_.IDLE) {
var error = new Error('Cannot clear: previous operation not complete.');
error.type = 'dash';
error.type = 'stream';
return Promise.reject(error);
}
@@ -370,7 +370,7 @@ shaka.dash.SourceBufferManager.prototype.clear = function() {
* Resets the virtual source buffer without removing any media from the
* underlying SourceBuffer. This can be called at any time.
*/
shaka.dash.SourceBufferManager.prototype.reset = function() {
shaka.media.SourceBufferManager.prototype.reset = function() {
this.buffered_ = [];
};
@@ -382,11 +382,11 @@ shaka.dash.SourceBufferManager.prototype.reset = function() {
*
* @return {!Promise}
*/
shaka.dash.SourceBufferManager.prototype.abort = function() {
shaka.media.SourceBufferManager.prototype.abort = function() {
shaka.log.v1('abort');
// Alias.
var SBM = shaka.dash.SourceBufferManager;
var SBM = shaka.media.SourceBufferManager;
shaka.asserts.assert(this.abortPromise_ == null);
shaka.asserts.assert(this.state_ != SBM.State_.ABORTING);
@@ -445,12 +445,12 @@ shaka.dash.SourceBufferManager.prototype.abort = function() {
*
* @private
*/
shaka.dash.SourceBufferManager.prototype.onSourceBufferUpdateEnd_ =
shaka.media.SourceBufferManager.prototype.onSourceBufferUpdateEnd_ =
function(event) {
shaka.log.v1('onSourceBufferUpdateEnd_');
// Alias.
var SBM = shaka.dash.SourceBufferManager;
var SBM = shaka.media.SourceBufferManager;
shaka.asserts.assert(this.sourceBuffer_.updating == false);
shaka.asserts.assert(this.state_ == SBM.State_.APPENDING ||
@@ -509,7 +509,7 @@ shaka.dash.SourceBufferManager.prototype.onSourceBufferUpdateEnd_ =
*
* @private
*/
shaka.dash.SourceBufferManager.prototype.resolveAbortPromise_ = function() {
shaka.media.SourceBufferManager.prototype.resolveAbortPromise_ = function() {
shaka.log.v1('resolveAbortPromise_');
shaka.asserts.assert(this.abortPromise_);
@@ -530,14 +530,14 @@ shaka.dash.SourceBufferManager.prototype.resolveAbortPromise_ = function() {
*
* @private
*/
shaka.dash.SourceBufferManager.prototype.rejectPromise_ = function(error) {
shaka.media.SourceBufferManager.prototype.rejectPromise_ = function(error) {
shaka.log.v1('rejectPromise_');
shaka.asserts.assert(this.promise_);
shaka.asserts.assert(this.abortPromise_ == null);
this.promise_.reject(error);
this.state_ = shaka.dash.SourceBufferManager.State_.IDLE;
this.state_ = shaka.media.SourceBufferManager.State_.IDLE;
this.promise_ = null;
this.references_ = [];
this.request_ = null;
+90 -90
View File
@@ -13,20 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @fileoverview Implements a DASH stream.
* @fileoverview Implements a media stream.
*/
goog.provide('shaka.dash.DashStream');
goog.provide('shaka.media.Stream');
goog.require('shaka.asserts');
goog.require('shaka.dash.IDashStream');
goog.require('shaka.dash.ISegmentIndexParser');
goog.require('shaka.dash.IsobmffSegmentIndexParser');
goog.require('shaka.dash.SegmentIndex');
goog.require('shaka.dash.SourceBufferManager');
goog.require('shaka.dash.StreamInfo');
goog.require('shaka.dash.WebmSegmentIndexParser');
goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexParser');
goog.require('shaka.media.IStream');
goog.require('shaka.media.IsobmffSegmentIndexParser');
goog.require('shaka.media.SegmentIndex');
goog.require('shaka.media.SourceBufferManager');
goog.require('shaka.media.StreamInfo');
goog.require('shaka.media.WebmSegmentIndexParser');
goog.require('shaka.timer');
goog.require('shaka.util.FakeEvent');
goog.require('shaka.util.FakeEventTarget');
@@ -36,7 +36,7 @@ goog.require('shaka.util.TypedBind');
/**
* @event shaka.dash.DashStream.AdaptationEvent
* @event shaka.media.Stream.AdaptationEvent
* @description Fired when video or audio tracks change.
* Bubbles up through the Player.
* @property {string} type 'adaptation'
@@ -49,7 +49,7 @@ goog.require('shaka.util.TypedBind');
* @export
*/
/**
* @event shaka.dash.DashStream.EndedEvent
* @event shaka.media.Stream.EndedEvent
* @description Fired when the stream ends.
* @property {string} type 'ended'
* @property {boolean} bubbles false
@@ -58,25 +58,25 @@ goog.require('shaka.util.TypedBind');
/**
* Creates a DashStream.
* Creates a Stream.
* @param {!shaka.util.FakeEventTarget} parent The parent for event bubbling.
* @param {!HTMLVideoElement} video The video element.
* @param {!MediaSource} mediaSource The SourceBuffer's MediaSource parent.
* @param {!SourceBuffer} sourceBuffer The SourceBuffer. It's assumed that
* |sourceBuffer| has the same mime type as |streamInfo_|.
* @param {shaka.util.IBandwidthEstimator} estimator A bandwidth estimator to
* attach to all DASH data requests.
* attach to all data requests.
*
* @fires shaka.dash.DashStream.AdaptationEvent
* @fires shaka.dash.DashStream.EndedEvent
* @fires shaka.media.Stream.AdaptationEvent
* @fires shaka.media.Stream.EndedEvent
* @fires shaka.player.Player.ErrorEvent
*
* @struct
* @constructor
* @implements {shaka.dash.IDashStream}
* @implements {shaka.media.IStream}
* @extends {shaka.util.FakeEventTarget}
*/
shaka.dash.DashStream =
shaka.media.Stream =
function(parent, video, mediaSource, sourceBuffer, estimator) {
shaka.util.FakeEventTarget.call(this, parent);
@@ -86,17 +86,17 @@ shaka.dash.DashStream =
/** @private {!SourceBuffer} */
this.sourceBuffer_ = sourceBuffer;
/** @private {!shaka.dash.SourceBufferManager} */
/** @private {!shaka.media.SourceBufferManager} */
this.sbm_ =
new shaka.dash.SourceBufferManager(mediaSource, sourceBuffer, estimator);
new shaka.media.SourceBufferManager(mediaSource, sourceBuffer, estimator);
/** @private {shaka.util.IBandwidthEstimator} */
this.estimator_ = estimator;
/** @private {shaka.dash.StreamInfo} */
/** @private {shaka.media.StreamInfo} */
this.streamInfo_ = null;
/** @private {shaka.dash.SegmentIndex} */
/** @private {shaka.media.SegmentIndex} */
this.segmentIndex_ = null;
/** @private {?function()} */
@@ -105,20 +105,20 @@ shaka.dash.DashStream =
/** @private {?number} */
this.updateTimerId_ = null;
/** @private {shaka.dash.DashStream.State_} */
this.state_ = shaka.dash.DashStream.State_.IDLE;
/** @private {shaka.media.Stream.State_} */
this.state_ = shaka.media.Stream.State_.IDLE;
/** @private {string} */
this.type_ = '';
};
goog.inherits(shaka.dash.DashStream, shaka.util.FakeEventTarget);
goog.inherits(shaka.media.Stream, shaka.util.FakeEventTarget);
/**
* @enum
* @private
*/
shaka.dash.DashStream.State_ = {
shaka.media.Stream.State_ = {
// The stream has not started yet.
IDLE: 0,
@@ -149,7 +149,7 @@ shaka.dash.DashStream.State_ = {
* @private {number}
* @const
*/
shaka.dash.DashStream.BUFFER_SIZE_SECONDS_ = 15.0;
shaka.media.Stream.BUFFER_SIZE_SECONDS_ = 15.0;
/**
@@ -159,7 +159,7 @@ shaka.dash.DashStream.BUFFER_SIZE_SECONDS_ = 15.0;
* @private {number}
* @const
*/
shaka.dash.DashStream.SWITCH_BUFFER_SIZE_SECONDS_ = 5.0;
shaka.media.Stream.SWITCH_BUFFER_SIZE_SECONDS_ = 5.0;
/**
@@ -169,14 +169,14 @@ shaka.dash.DashStream.SWITCH_BUFFER_SIZE_SECONDS_ = 5.0;
* @private
* @const {number}
*/
shaka.dash.DashStream.SINGLE_FRAME_SECONDS_ = 0.05;
shaka.media.Stream.SINGLE_FRAME_SECONDS_ = 0.05;
/**
* @override
* @suppress {checkTypes} to set otherwise non-nullable types to null.
*/
shaka.dash.DashStream.prototype.destroy = function() {
shaka.media.Stream.prototype.destroy = function() {
this.state_ = null;
this.cancelUpdateTimer_();
@@ -197,24 +197,24 @@ shaka.dash.DashStream.prototype.destroy = function() {
/** @override */
shaka.dash.DashStream.prototype.getStreamInfo = function() {
shaka.media.Stream.prototype.getStreamInfo = function() {
return this.streamInfo_;
};
/** @override */
shaka.dash.DashStream.prototype.hasEnded = function() {
return this.state_ == shaka.dash.DashStream.State_.ENDED;
shaka.media.Stream.prototype.hasEnded = function() {
return this.state_ == shaka.media.Stream.State_.ENDED;
};
/** @override */
shaka.dash.DashStream.prototype.start = function(streamInfo) {
shaka.media.Stream.prototype.start = function(streamInfo) {
shaka.asserts.assert((streamInfo.segmentIndex) ||
(streamInfo.segmentIndexInfo && streamInfo.mediaUrl));
shaka.asserts.assert(this.state_ == shaka.dash.DashStream.State_.IDLE);
if (this.state_ != shaka.dash.DashStream.State_.IDLE) {
shaka.asserts.assert(this.state_ == shaka.media.Stream.State_.IDLE);
if (this.state_ != shaka.media.Stream.State_.IDLE) {
shaka.log.error('Cannot start stream: stream has already been started.');
return;
}
@@ -224,7 +224,7 @@ shaka.dash.DashStream.prototype.start = function(streamInfo) {
this.streamInfo_ = streamInfo;
this.type_ = streamInfo.mimeType.split('/')[0];
this.segmentIndex_ = null;
this.state_ = shaka.dash.DashStream.State_.INITIALIZING;
this.state_ = shaka.media.Stream.State_.INITIALIZING;
// Request all segment metadata in parallel.
var async = this.requestAllSegmentMetadata_(streamInfo);
@@ -242,7 +242,7 @@ shaka.dash.DashStream.prototype.start = function(streamInfo) {
streamInfo, segmentIndexData, initSegmentData);
if (!this.segmentIndex_) {
var error = new Error('Failed to create SegmentIndex.');
error.type = 'dash';
error.type = 'stream';
return Promise.reject(error);
}
} else {
@@ -278,7 +278,7 @@ shaka.dash.DashStream.prototype.start = function(streamInfo) {
/** @param {!Error} error */
function(error) {
if (error.type != 'aborted') {
this.state_ = shaka.dash.DashStream.State_.IDLE;
this.state_ = shaka.media.Stream.State_.IDLE;
var event = shaka.util.FakeEvent.createErrorEvent(error);
this.dispatchEvent(event);
}
@@ -288,7 +288,7 @@ shaka.dash.DashStream.prototype.start = function(streamInfo) {
/** @override */
shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
shaka.media.Stream.prototype.switch = function(streamInfo, immediate) {
shaka.asserts.assert((streamInfo.segmentIndex) ||
(streamInfo.segmentIndexInfo && streamInfo.mediaUrl));
@@ -296,20 +296,20 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
shaka.timer.begin('switch logic');
// Alias.
var DashStream = shaka.dash.DashStream;
var Stream = shaka.media.Stream;
// We cannot switch streams if the stream has not been started.
shaka.asserts.assert(this.state_ != DashStream.State_.IDLE);
if (this.state_ == DashStream.State_.IDLE) {
shaka.asserts.assert(this.state_ != Stream.State_.IDLE);
if (this.state_ == Stream.State_.IDLE) {
shaka.log.error('Cannot switch stream: stream has not been started.');
return;
}
// We cannot switch streams if we are initializing or already switching
// streams.
if (this.state_ == DashStream.State_.INITIALIZING ||
this.state_ == DashStream.State_.SWITCHING ||
this.state_ == DashStream.State_.SPLICING) {
if (this.state_ == Stream.State_.INITIALIZING ||
this.state_ == Stream.State_.SWITCHING ||
this.state_ == Stream.State_.SPLICING) {
shaka.log.info('Waiting to switch streams...');
this.nextSwitch_ = this.switch.bind(this, streamInfo, immediate);
return;
@@ -338,7 +338,7 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
check();
}
this.state_ = DashStream.State_.SWITCHING;
this.state_ = Stream.State_.SWITCHING;
// Request all segment metadata in parallel.
var async = this.requestAllSegmentMetadata_(streamInfo);
@@ -368,7 +368,7 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
streamInfo, segmentIndexData, initSegmentData);
if (!this.segmentIndex_) {
var error = new Error('Failed to create SegmentIndex.');
error.type = 'dash';
error.type = 'stream';
return Promise.reject(error);
}
} else {
@@ -377,7 +377,7 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
this.streamInfo_ = streamInfo;
this.type_ = streamInfo.mimeType.split('/')[0];
this.state_ = DashStream.State_.SPLICING;
this.state_ = Stream.State_.SPLICING;
this.sbm_.reset();
@@ -392,7 +392,7 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
function() {
var currentTime = this.getCurrentTime_();
var bufferTime = Math.max(streamInfo.minBufferTime,
DashStream.BUFFER_SIZE_SECONDS_);
Stream.BUFFER_SIZE_SECONDS_);
// Fetch new segments to meet the buffering requirement and replace
// what's currently in buffer.
var segmentRange = this.segmentIndex_.getRangeForInterval(
@@ -409,7 +409,7 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
function() {
if (immediate) {
// Force the video to start presenting the new segment(s).
this.video_.currentTime -= DashStream.SINGLE_FRAME_SECONDS_;
this.video_.currentTime -= Stream.SINGLE_FRAME_SECONDS_;
if (!previouslyPaused) {
this.video_.play();
}
@@ -425,7 +425,7 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
this.dispatchEvent(event);
// Try to recover.
this.state_ = DashStream.State_.UPDATING;
this.state_ = Stream.State_.UPDATING;
this.onUpdate_();
}
})
@@ -434,12 +434,12 @@ shaka.dash.DashStream.prototype.switch = function(streamInfo, immediate) {
/**
* Fires a shaka.dash.DashStream.AdaptationEvent for the given StreamInfo.
* Fires a shaka.media.Stream.AdaptationEvent for the given StreamInfo.
*
* @param {shaka.dash.StreamInfo} streamInfo
* @param {shaka.media.StreamInfo} streamInfo
* @private
*/
shaka.dash.DashStream.prototype.fireAdaptationEvent_ = function(streamInfo) {
shaka.media.Stream.prototype.fireAdaptationEvent_ = function(streamInfo) {
var contentType = streamInfo.mimeType.split('/')[0];
var size = (contentType != 'video') ? null : {
'width': streamInfo.width,
@@ -460,17 +460,17 @@ shaka.dash.DashStream.prototype.fireAdaptationEvent_ = function(streamInfo) {
* Calls |nextSwitch_| if it's non-null; otherwise, calls onUpdate_().
* @private
*/
shaka.dash.DashStream.prototype.switchStreamOrUpdate_ = function() {
shaka.media.Stream.prototype.switchStreamOrUpdate_ = function() {
// Alias.
var DashStream = shaka.dash.DashStream;
var Stream = shaka.media.Stream;
shaka.asserts.assert(this.state_ == DashStream.State_.INITIALIZING ||
this.state_ == DashStream.State_.SPLICING);
shaka.asserts.assert(this.state_ == Stream.State_.INITIALIZING ||
this.state_ == Stream.State_.SPLICING);
// Note that |state_| must be set to UPDATING before switchStream_()
// is called.
this.state_ = DashStream.State_.UPDATING;
this.state_ = Stream.State_.UPDATING;
if (this.nextSwitch_) {
shaka.log.info('Processing deferred switch...');
@@ -484,19 +484,19 @@ shaka.dash.DashStream.prototype.switchStreamOrUpdate_ = function() {
/** @override */
shaka.dash.DashStream.prototype.resync = function() {
shaka.media.Stream.prototype.resync = function() {
// Alias.
var DashStream = shaka.dash.DashStream;
var Stream = shaka.media.Stream;
shaka.asserts.assert(this.state_ != DashStream.State_.IDLE);
if (this.state_ == DashStream.State_.IDLE) {
shaka.asserts.assert(this.state_ != Stream.State_.IDLE);
if (this.state_ == Stream.State_.IDLE) {
shaka.log.error('Cannot resync stream: stream has not been initialized.');
return;
}
if (this.state_ == DashStream.State_.INITIALIZING ||
this.state_ == DashStream.State_.SWITCHING ||
this.state_ == DashStream.State_.SPLICING) {
if (this.state_ == Stream.State_.INITIALIZING ||
this.state_ == Stream.State_.SWITCHING ||
this.state_ == Stream.State_.SPLICING) {
// Since the stream is initializing or switching it will be resynchronized
// after the first call to onUpdate_().
return;
@@ -507,7 +507,7 @@ shaka.dash.DashStream.prototype.resync = function() {
this.cancelUpdateTimer_();
this.sbm_.abort().then(shaka.util.TypedBind(this,
function() {
this.state_ = DashStream.State_.UPDATING;
this.state_ = Stream.State_.UPDATING;
this.onUpdate_();
})
);
@@ -515,26 +515,26 @@ shaka.dash.DashStream.prototype.resync = function() {
/** @override */
shaka.dash.DashStream.prototype.setEnabled = function(enabled) {
shaka.media.Stream.prototype.setEnabled = function(enabled) {
// NOP, not supported for audio and video streams.
};
/** @override */
shaka.dash.DashStream.prototype.getEnabled = function() {
shaka.media.Stream.prototype.getEnabled = function() {
return true;
};
/**
* Requests all segment metadata for the given StreamInfo.
* @param {!shaka.dash.StreamInfo} streamInfo
* @param {!shaka.media.StreamInfo} streamInfo
* @return {!Array.<!Promise.<!ArrayBuffer>|!Promise.<null>>} The first result
* contains the segment index data or null. The second result contains the
* initialization segment data or null.
* @private
*/
shaka.dash.DashStream.prototype.requestAllSegmentMetadata_ = function(
shaka.media.Stream.prototype.requestAllSegmentMetadata_ = function(
streamInfo) {
return [
this.requestSegmentMetadata_(streamInfo.segmentIndexInfo),
@@ -546,11 +546,11 @@ shaka.dash.DashStream.prototype.requestAllSegmentMetadata_ = function(
/**
* Requests segment metadata, e.g., a segment index or an initialization
* segment.
* @param {shaka.dash.SegmentMetadataInfo} info
* @param {shaka.media.SegmentMetadataInfo} info
* @return {!Promise.<!ArrayBuffer>|!Promise.<null>}
* @private
*/
shaka.dash.DashStream.prototype.requestSegmentMetadata_ = function(info) {
shaka.media.Stream.prototype.requestSegmentMetadata_ = function(info) {
if (!info || !info.url) {
shaka.log.debug('No metadata to fetch.');
return Promise.resolve(null);
@@ -565,22 +565,22 @@ shaka.dash.DashStream.prototype.requestSegmentMetadata_ = function(info) {
/**
* Creates a SegmentIndex.
* @param {shaka.dash.StreamInfo} streamInfo
* @param {shaka.media.StreamInfo} streamInfo
* @param {!ArrayBuffer} segmentIndexData The segment index data.
* @param {ArrayBuffer} initSegmentData The initialization segment data.
* @return {shaka.dash.SegmentIndex}
* @return {shaka.media.SegmentIndex}
* @private
*/
shaka.dash.DashStream.prototype.createSegmentIndex_ = function(
shaka.media.Stream.prototype.createSegmentIndex_ = function(
streamInfo, segmentIndexData, initSegmentData) {
shaka.asserts.assert(streamInfo.segmentIndexInfo);
shaka.asserts.assert(streamInfo.mediaUrl);
/** @type {shaka.dash.ISegmentIndexParser} */
/** @type {shaka.media.ISegmentIndexParser} */
var indexParser = null;
if (streamInfo.mimeType.indexOf('mp4') >= 0) {
indexParser = new shaka.dash.IsobmffSegmentIndexParser(
indexParser = new shaka.media.IsobmffSegmentIndexParser(
/** @type {!goog.Uri} */ (streamInfo.mediaUrl));
} else if (streamInfo.mimeType.indexOf('webm') >= 0) {
if (!initSegmentData) {
@@ -588,7 +588,7 @@ shaka.dash.DashStream.prototype.createSegmentIndex_ = function(
'required for WebM.');
return null;
}
indexParser = new shaka.dash.WebmSegmentIndexParser(
indexParser = new shaka.media.WebmSegmentIndexParser(
/** @type {!goog.Uri} */ (streamInfo.mediaUrl));
} else {
shaka.log.error('Cannot create segment index: unsupported mime type.');
@@ -609,7 +609,7 @@ shaka.dash.DashStream.prototype.createSegmentIndex_ = function(
return null;
}
return new shaka.dash.SegmentIndex(references);
return new shaka.media.SegmentIndex(references);
};
@@ -617,14 +617,14 @@ shaka.dash.DashStream.prototype.createSegmentIndex_ = function(
* Update callback.
* @private
*/
shaka.dash.DashStream.prototype.onUpdate_ = function() {
shaka.media.Stream.prototype.onUpdate_ = function() {
// Alias.
var DashStream = shaka.dash.DashStream;
var Stream = shaka.media.Stream;
shaka.asserts.assert(this.streamInfo_);
shaka.asserts.assert(this.segmentIndex_);
shaka.asserts.assert(this.state_ == DashStream.State_.SWITCHING ||
this.state_ == DashStream.State_.UPDATING);
shaka.asserts.assert(this.state_ == Stream.State_.SWITCHING ||
this.state_ == Stream.State_.UPDATING);
// Avoid stacking timeouts.
this.cancelUpdateTimer_();
@@ -638,7 +638,7 @@ shaka.dash.DashStream.prototype.onUpdate_ = function() {
if (!reference) {
// EOF.
shaka.log.info('EOF for ' + this.streamInfo_.mimeType + ' stream.');
this.state_ = DashStream.State_.ENDED;
this.state_ = Stream.State_.ENDED;
// Dispatch a non-bubbling event. Let the VideoSource handle it.
var event = shaka.util.FakeEvent.create({ type: 'ended' });
@@ -648,7 +648,7 @@ shaka.dash.DashStream.prototype.onUpdate_ = function() {
}
var bufferingGoal = Math.max(this.streamInfo_.minBufferTime,
DashStream.BUFFER_SIZE_SECONDS_);
Stream.BUFFER_SIZE_SECONDS_);
var bufferedAhead = reference.startTime - currentTime;
if (bufferedAhead >= bufferingGoal) {
// We don't need to make a request right now, so check again in a second.
@@ -665,7 +665,7 @@ shaka.dash.DashStream.prototype.onUpdate_ = function() {
// This operation may be interrupted by switchStream_().
shaka.log.v1('Fetching segment', this.type_, reference);
var fetch = this.sbm_.fetch(new shaka.dash.SegmentRange([reference]));
var fetch = this.sbm_.fetch(new shaka.media.SegmentRange([reference]));
fetch.then(shaka.util.TypedBind(this,
function() {
shaka.log.v1('Added segment', referenceIndex);
@@ -693,7 +693,7 @@ shaka.dash.DashStream.prototype.onUpdate_ = function() {
*
* @private
*/
shaka.dash.DashStream.prototype.findNextNeededIndex_ = function(time) {
shaka.media.Stream.prototype.findNextNeededIndex_ = function(time) {
shaka.asserts.assert(this.segmentIndex_);
var index = this.segmentIndex_.findReferenceIndex(time);
@@ -712,7 +712,7 @@ shaka.dash.DashStream.prototype.findNextNeededIndex_ = function(time) {
* Cancels the update timer if it is running.
* @private
*/
shaka.dash.DashStream.prototype.cancelUpdateTimer_ = function() {
shaka.media.Stream.prototype.cancelUpdateTimer_ = function() {
if (this.updateTimerId_) {
window.clearTimeout(this.updateTimerId_);
this.updateTimerId_ = null;
@@ -725,7 +725,7 @@ shaka.dash.DashStream.prototype.cancelUpdateTimer_ = function() {
* @return {number}
* @private
*/
shaka.dash.DashStream.prototype.getCurrentTime_ = function() {
shaka.media.Stream.prototype.getCurrentTime_ = function() {
return this.video_.currentTime - this.sourceBuffer_.timestampOffset;
};
@@ -17,10 +17,10 @@
* description of a stream.
*/
goog.provide('shaka.dash.PeriodInfo');
goog.provide('shaka.dash.SegmentMetadataInfo');
goog.provide('shaka.dash.StreamInfo');
goog.provide('shaka.dash.StreamSetInfo');
goog.provide('shaka.media.PeriodInfo');
goog.provide('shaka.media.SegmentMetadataInfo');
goog.provide('shaka.media.StreamInfo');
goog.provide('shaka.media.StreamSetInfo');
@@ -30,9 +30,9 @@ goog.provide('shaka.dash.StreamSetInfo');
* @constructor
* @struct
*/
shaka.dash.StreamInfo = function() {
shaka.media.StreamInfo = function() {
/** @type {number} */
this.uniqueId = shaka.dash.StreamInfo.nextUniqueId_++;
this.uniqueId = shaka.media.StreamInfo.nextUniqueId_++;
/** @type {?string} */
this.id = null;
@@ -66,13 +66,13 @@ shaka.dash.StreamInfo = function() {
/** @type {goog.Uri} */
this.mediaUrl = null;
/** @type {shaka.dash.SegmentMetadataInfo} */
/** @type {shaka.media.SegmentMetadataInfo} */
this.segmentIndexInfo = null;
/** @type {shaka.dash.SegmentMetadataInfo} */
/** @type {shaka.media.SegmentMetadataInfo} */
this.segmentInitializationInfo = null;
/** @type {shaka.dash.SegmentIndex} */
/** @type {shaka.media.SegmentIndex} */
this.segmentIndex = null;
};
@@ -81,7 +81,7 @@ shaka.dash.StreamInfo = function() {
* The next unique ID to assign to a StreamInfo.
* @private {number}
*/
shaka.dash.StreamInfo.nextUniqueId_ = 0;
shaka.media.StreamInfo.nextUniqueId_ = 0;
/**
@@ -90,7 +90,7 @@ shaka.dash.StreamInfo.nextUniqueId_ = 0;
*
* @return {string}
*/
shaka.dash.StreamInfo.prototype.getFullMimeType = function() {
shaka.media.StreamInfo.prototype.getFullMimeType = function() {
var fullMimeType = this.mimeType || '';
if (this.codecs) {
fullMimeType += '; codecs="' + this.codecs + '"';
@@ -106,7 +106,7 @@ shaka.dash.StreamInfo.prototype.getFullMimeType = function() {
* @constructor
* @struct
*/
shaka.dash.SegmentMetadataInfo = function() {
shaka.media.SegmentMetadataInfo = function() {
/** @type {goog.Uri} */
this.url = null;
@@ -125,11 +125,11 @@ shaka.dash.SegmentMetadataInfo = function() {
* @constructor
* @struct
*/
shaka.dash.StreamSetInfo = function() {
shaka.media.StreamSetInfo = function() {
/** @type {string} */
this.contentType = '';
/** @type {!Array.<!shaka.dash.StreamInfo>} */
/** @type {!Array.<!shaka.media.StreamInfo>} */
this.streamInfos = [];
/** @type {!Array.<!shaka.player.DrmSchemeInfo>} */
@@ -144,14 +144,14 @@ shaka.dash.StreamSetInfo = function() {
* @constructor
* @struct
*/
shaka.dash.PeriodInfo = function() {
shaka.media.PeriodInfo = function() {
/** @type {number} */
this.start = 0;
/** @type {number} */
this.duration = 0;
/** @type {!Array.<!shaka.dash.StreamSetInfo>} */
/** @type {!Array.<!shaka.media.StreamSetInfo>} */
this.streamSetInfos = [];
};
@@ -16,17 +16,17 @@
* @fileoverview Implements StreamInfoProcessor.
*/
goog.provide('shaka.dash.StreamInfoProcessor');
goog.provide('shaka.media.StreamInfoProcessor');
goog.require('goog.Uri');
goog.require('shaka.asserts');
goog.require('shaka.dash.PeriodInfo');
goog.require('shaka.dash.SegmentIndex');
goog.require('shaka.dash.SegmentMetadataInfo');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.dash.StreamInfo');
goog.require('shaka.dash.StreamSetInfo');
goog.require('shaka.log');
goog.require('shaka.media.PeriodInfo');
goog.require('shaka.media.SegmentIndex');
goog.require('shaka.media.SegmentMetadataInfo');
goog.require('shaka.media.SegmentReference');
goog.require('shaka.media.StreamInfo');
goog.require('shaka.media.StreamSetInfo');
goog.require('shaka.player.DrmSchemeInfo');
goog.require('shaka.player.Player');
goog.require('shaka.util.ArrayUtils');
@@ -42,10 +42,10 @@ goog.require('shaka.util.MultiMap');
* @constructor
* @struct
*/
shaka.dash.StreamInfoProcessor = function() {
shaka.media.StreamInfoProcessor = function() {
/**
* @private
* {!Array.<shaka.dash.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme>}
* {!Array.<shaka.media.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme>}
*/
this.streamSetInfoMapAndDrmSchemeByPeriod_ = [];
@@ -56,25 +56,25 @@ shaka.dash.StreamInfoProcessor = function() {
/**
* Maps a content type to an array of StreamSetInfos.
* @typedef {!shaka.util.MultiMap.<!shaka.dash.StreamSetInfo>}
* @typedef {!shaka.util.MultiMap.<!shaka.media.StreamSetInfo>}
*/
shaka.dash.StreamInfoProcessor.StreamSetInfoMap;
shaka.media.StreamInfoProcessor.StreamSetInfoMap;
/**
* @typedef
* {{streamSetInfoMap: !shaka.dash.StreamInfoProcessor.StreamSetInfoMap,
* {{streamSetInfoMap: !shaka.media.StreamInfoProcessor.StreamSetInfoMap,
* drmScheme: shaka.player.DrmSchemeInfo}}
*/
shaka.dash.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme;
shaka.media.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme;
/**
* Processes the given PeriodInfos.
*
* @param {!Array.<shaka.dash.PeriodInfo>} periodInfos
* @param {!Array.<shaka.media.PeriodInfo>} periodInfos
*/
shaka.dash.StreamInfoProcessor.prototype.process = function(periodInfos) {
shaka.media.StreamInfoProcessor.prototype.process = function(periodInfos) {
this.calculateStreamDuration_(periodInfos);
this.filterPeriodInfos_(periodInfos);
this.sortStreamSetInfos_(periodInfos);
@@ -87,7 +87,7 @@ shaka.dash.StreamInfoProcessor.prototype.process = function(periodInfos) {
*
* @return {number}
*/
shaka.dash.StreamInfoProcessor.prototype.getNumPeriods = function() {
shaka.media.StreamInfoProcessor.prototype.getNumPeriods = function() {
return this.streamSetInfoMapAndDrmSchemeByPeriod_.length;
};
@@ -97,7 +97,7 @@ shaka.dash.StreamInfoProcessor.prototype.getNumPeriods = function() {
*
* @return {number}
*/
shaka.dash.StreamInfoProcessor.prototype.getStreamDuration = function() {
shaka.media.StreamInfoProcessor.prototype.getStreamDuration = function() {
return this.streamDuration_;
};
@@ -108,9 +108,9 @@ shaka.dash.StreamInfoProcessor.prototype.getStreamDuration = function() {
* @param {number} periodIdx
* @param {string=} opt_type Optional content type. If left undefined then all
* StreamInfos are returned for the given period.
* @return {!Array.<!shaka.dash.StreamSetInfo>}
* @return {!Array.<!shaka.media.StreamSetInfo>}
*/
shaka.dash.StreamInfoProcessor.prototype.getStreamSetInfos = function(
shaka.media.StreamInfoProcessor.prototype.getStreamSetInfos = function(
periodIdx, opt_type) {
shaka.asserts.assert(
periodIdx >= 0 &&
@@ -133,7 +133,7 @@ shaka.dash.StreamInfoProcessor.prototype.getStreamSetInfos = function(
* @param {number} periodIdx
* @return {shaka.player.DrmSchemeInfo}
*/
shaka.dash.StreamInfoProcessor.prototype.getDrmScheme = function(periodIdx) {
shaka.media.StreamInfoProcessor.prototype.getDrmScheme = function(periodIdx) {
shaka.asserts.assert(
periodIdx >= 0 &&
periodIdx < this.streamSetInfoMapAndDrmSchemeByPeriod_.length);
@@ -152,9 +152,9 @@ shaka.dash.StreamInfoProcessor.prototype.getDrmScheme = function(periodIdx) {
*
* @param {number} periodIdx
* @param {string} preferredLang The preferred language.
* @return {!Array.<!shaka.dash.StreamSetInfo>}
* @return {!Array.<!shaka.media.StreamSetInfo>}
*/
shaka.dash.StreamInfoProcessor.prototype.selectStreamSetInfos = function(
shaka.media.StreamInfoProcessor.prototype.selectStreamSetInfos = function(
periodIdx, preferredLang) {
shaka.asserts.assert(
periodIdx >= 0 &&
@@ -165,7 +165,7 @@ shaka.dash.StreamInfoProcessor.prototype.selectStreamSetInfos = function(
return [];
}
/** @type {!Array.<!shaka.dash.StreamSetInfo>} */
/** @type {!Array.<!shaka.media.StreamSetInfo>} */
var streamSetInfos = [];
// Add a video StreamSetInfo.
@@ -206,12 +206,12 @@ shaka.dash.StreamInfoProcessor.prototype.selectStreamSetInfos = function(
/**
* Returns an array of StreamSetInfos that match the preferred language.
*
* @param {Array.<!shaka.dash.StreamSetInfo>} streamSetInfos
* @param {Array.<!shaka.media.StreamSetInfo>} streamSetInfos
* @param {string} preferredLang The preferred language.
* @return {!Array.<!shaka.dash.StreamSetInfo>}
* @return {!Array.<!shaka.media.StreamSetInfo>}
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.getStreamSetInfosByLanguage_ =
shaka.media.StreamInfoProcessor.prototype.getStreamSetInfosByLanguage_ =
function(streamSetInfos, preferredLang) {
// Alias.
var LanguageUtils = shaka.util.LanguageUtils;
@@ -244,7 +244,7 @@ shaka.dash.StreamInfoProcessor.prototype.getStreamSetInfosByLanguage_ =
*
* @param {!shaka.player.DrmSchemeInfo.Restrictions} restrictions
*/
shaka.dash.StreamInfoProcessor.prototype.enforceRestrictions = function(
shaka.media.StreamInfoProcessor.prototype.enforceRestrictions = function(
restrictions) {
var numPeriods = this.getNumPeriods();
for (var i = 0; i < numPeriods; ++i) {
@@ -287,11 +287,11 @@ shaka.dash.StreamInfoProcessor.prototype.enforceRestrictions = function(
/**
* Calculates the stream's full duration.
* @param {!Array.<!shaka.dash.PeriodInfo>} periodInfos
* @param {!Array.<!shaka.media.PeriodInfo>} periodInfos
*
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.calculateStreamDuration_ = function(
shaka.media.StreamInfoProcessor.prototype.calculateStreamDuration_ = function(
periodInfos) {
this.streamDuration_ = 0;
@@ -305,10 +305,10 @@ shaka.dash.StreamInfoProcessor.prototype.calculateStreamDuration_ = function(
/**
* Removes unsupported StreamInfos from |periodInfos|.
*
* @param {!Array.<!shaka.dash.PeriodInfo>} periodInfos
* @param {!Array.<!shaka.media.PeriodInfo>} periodInfos
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.filterPeriodInfos_ = function(
shaka.media.StreamInfoProcessor.prototype.filterPeriodInfos_ = function(
periodInfos) {
for (var i = 0; i < periodInfos.length; ++i) {
var periodInfo = periodInfos[i];
@@ -330,10 +330,10 @@ shaka.dash.StreamInfoProcessor.prototype.filterPeriodInfos_ = function(
* Removes any StreamInfo from the given StreamSetInfo that has
* an unsupported content type and DrmSchemeInfo combination.
*
* @param {!shaka.dash.StreamSetInfo} streamSetInfo
* @param {!shaka.media.StreamSetInfo} streamSetInfo
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.filterStreamSetInfo_ =
shaka.media.StreamInfoProcessor.prototype.filterStreamSetInfo_ =
function(streamSetInfo) {
// Alias.
var Player = shaka.player.Player;
@@ -371,17 +371,17 @@ shaka.dash.StreamInfoProcessor.prototype.filterStreamSetInfo_ =
/**
* Sorts each StreamSetInfo by bandwidth.
*
* @param {!Array.<!shaka.dash.PeriodInfo>} periodInfos
* @param {!Array.<!shaka.media.PeriodInfo>} periodInfos
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.sortStreamSetInfos_ = function(
shaka.media.StreamInfoProcessor.prototype.sortStreamSetInfos_ = function(
periodInfos) {
for (var i = 0; i < periodInfos.length; ++i) {
var periodInfo = periodInfos[i];
for (var j = 0; j < periodInfo.streamSetInfos.length; ++j) {
var streamSetInfo = periodInfo.streamSetInfos[j];
streamSetInfo.streamInfos.sort(
shaka.dash.StreamInfoProcessor.compareByBandwidth_);
shaka.media.StreamInfoProcessor.compareByBandwidth_);
}
}
};
@@ -390,12 +390,12 @@ shaka.dash.StreamInfoProcessor.prototype.sortStreamSetInfos_ = function(
/**
* Compares two StreamInfos by bandwidth.
*
* @param {!shaka.dash.StreamInfo} streamInfo1
* @param {!shaka.dash.StreamInfo} streamInfo2
* @param {!shaka.media.StreamInfo} streamInfo1
* @param {!shaka.media.StreamInfo} streamInfo2
* @return {number}
* @private
*/
shaka.dash.StreamInfoProcessor.compareByBandwidth_ = function(
shaka.media.StreamInfoProcessor.compareByBandwidth_ = function(
streamInfo1, streamInfo2) {
var b1 = streamInfo1.bandwidth || Number.MAX_VALUE;
var b2 = streamInfo2.bandwidth || Number.MAX_VALUE;
@@ -413,10 +413,10 @@ shaka.dash.StreamInfoProcessor.compareByBandwidth_ = function(
/**
* Chooses viable StreamSetInfos for each period.
*
* @param {!Array.<!shaka.dash.PeriodInfo>} periodInfos
* @param {!Array.<!shaka.media.PeriodInfo>} periodInfos
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.chooseStreamSetInfos_ =
shaka.media.StreamInfoProcessor.prototype.chooseStreamSetInfos_ =
function(periodInfos) {
this.streamSetInfoMapAndDrmSchemeByPeriod_ = [];
@@ -433,16 +433,16 @@ shaka.dash.StreamInfoProcessor.prototype.chooseStreamSetInfos_ =
/**
* Chooses viable StreamInfos for the given period.
*
* @param {!shaka.dash.PeriodInfo} periodInfo
* @return {?shaka.dash.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme}
* @param {!shaka.media.PeriodInfo} periodInfo
* @return {?shaka.media.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme}
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.chooseStreamSetInfosForPeriod_ =
shaka.media.StreamInfoProcessor.prototype.chooseStreamSetInfosForPeriod_ =
function(periodInfo) {
/** @type {!shaka.dash.StreamInfoProcessor.StreamSetInfoMap} */
/** @type {!shaka.media.StreamInfoProcessor.StreamSetInfoMap} */
var byType = new shaka.util.MultiMap();
/** @type {!shaka.dash.StreamInfoProcessor.StreamSetInfoMap} */
/** @type {!shaka.media.StreamInfoProcessor.StreamSetInfoMap} */
var byKeySystem = new shaka.util.MultiMap();
// Build multi-maps by both type and key system.
@@ -509,12 +509,12 @@ shaka.dash.StreamInfoProcessor.prototype.chooseStreamSetInfosForPeriod_ =
* the output. This allows an unencrypted source to mix in with all other key
* systems.
*
* @param {!Array.<!shaka.dash.StreamSetInfo>} streamSetInfos
* @param {!Array.<!shaka.media.StreamSetInfo>} streamSetInfos
* @param {!Array.<string>} allKeySystems
* @return {!Array.<string>}
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.buildKeySystemList_ =
shaka.media.StreamInfoProcessor.prototype.buildKeySystemList_ =
function(streamSetInfos, allKeySystems) {
/** @type {!Object.<string, null>} */
var keySystemSet = {};
@@ -542,16 +542,16 @@ shaka.dash.StreamInfoProcessor.prototype.buildKeySystemList_ =
* Gets the StreamSetInfos that support the given key system, and gets
* those StreamSetInfos' common DrmSchemeInfo.
*
* @param {!Array.<!shaka.dash.StreamSetInfo>} streamSetInfos
* @param {!Array.<!shaka.media.StreamSetInfo>} streamSetInfos
* @param {string} keySystem
* @return {shaka.dash.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme}
* @return {shaka.media.StreamInfoProcessor.StreamSetInfoMapAndDrmScheme}
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.getStreamSetInfosByKeySystem_ =
shaka.media.StreamInfoProcessor.prototype.getStreamSetInfosByKeySystem_ =
function(streamSetInfos, keySystem) {
/**
* The StreamSetInfos that support |keySystem|.
* @type {!shaka.util.MultiMap.<!shaka.dash.StreamSetInfo>}
* @type {!shaka.util.MultiMap.<!shaka.media.StreamSetInfo>}
*/
var allowableStreamSetInfoMap = new shaka.util.MultiMap();
@@ -599,13 +599,13 @@ shaka.dash.StreamInfoProcessor.prototype.getStreamSetInfosByKeySystem_ =
* within a StreamSetInfo that each StreamInfo has the same MIME type
* as the first StreamInfo within that StreamSetInfo.
*
* @param {!shaka.dash.StreamInfoProcessor.StreamSetInfoMap} byType
* @return {!shaka.dash.StreamInfoProcessor.StreamSetInfoMap}
* @param {!shaka.media.StreamInfoProcessor.StreamSetInfoMap} byType
* @return {!shaka.media.StreamInfoProcessor.StreamSetInfoMap}
* @private
*/
shaka.dash.StreamInfoProcessor.prototype.getStreamSetInfosByMimeType_ =
shaka.media.StreamInfoProcessor.prototype.getStreamSetInfosByMimeType_ =
function(byType) {
/** @type {!shaka.util.MultiMap.<!shaka.dash.StreamSetInfo>} */
/** @type {!shaka.util.MultiMap.<!shaka.media.StreamSetInfo>} */
var allowableStreamSetInfoMap = new shaka.util.MultiMap();
// Add one video StreamSetInfos.
@@ -13,49 +13,49 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @fileoverview Implements a DASH stream for text tracks.
* @fileoverview Implements a media stream for text tracks.
*/
goog.provide('shaka.dash.DashTextStream');
goog.provide('shaka.media.TextStream');
goog.require('shaka.dash.IDashStream');
goog.require('shaka.dash.StreamInfo');
goog.require('shaka.log');
goog.require('shaka.media.IStream');
goog.require('shaka.media.StreamInfo');
goog.require('shaka.util.FakeEventTarget');
/**
* Creates a DashTextStream. A DashTextStream is a DashStream work-alike for
* Creates a TextStream. A TextStream is a Stream work-alike for
* text tracks.
*
* @param {!shaka.util.FakeEventTarget} parent The parent for event bubbling.
* @param {!HTMLVideoElement} video The video element.
* @struct
* @constructor
* @implements {shaka.dash.IDashStream}
* @implements {shaka.media.IStream}
* @extends {shaka.util.FakeEventTarget}
*/
shaka.dash.DashTextStream = function(parent, video) {
shaka.media.TextStream = function(parent, video) {
shaka.util.FakeEventTarget.call(this, parent);
/** @private {!HTMLVideoElement} */
this.video_ = video;
/** @private {shaka.dash.StreamInfo} */
/** @private {shaka.media.StreamInfo} */
this.streamInfo_ = null;
/** @private {HTMLTrackElement} */
this.track_ = null;
};
goog.inherits(shaka.dash.DashTextStream, shaka.util.FakeEventTarget);
goog.inherits(shaka.media.TextStream, shaka.util.FakeEventTarget);
/**
* @override
* @suppress {checkTypes} to set otherwise non-nullable types to null.
*/
shaka.dash.DashTextStream.prototype.destroy = function() {
shaka.media.TextStream.prototype.destroy = function() {
if (this.track_) {
this.video_.removeChild(this.track_);
}
@@ -68,19 +68,19 @@ shaka.dash.DashTextStream.prototype.destroy = function() {
/** @override */
shaka.dash.DashTextStream.prototype.getStreamInfo = function() {
shaka.media.TextStream.prototype.getStreamInfo = function() {
return this.streamInfo_;
};
/** @override */
shaka.dash.DashTextStream.prototype.hasEnded = function() {
shaka.media.TextStream.prototype.hasEnded = function() {
return true;
};
/** @override */
shaka.dash.DashTextStream.prototype.start = function(streamInfo) {
shaka.media.TextStream.prototype.start = function(streamInfo) {
this.streamInfo_ = streamInfo;
shaka.log.info('Starting stream for', streamInfo);
@@ -112,25 +112,25 @@ shaka.dash.DashTextStream.prototype.start = function(streamInfo) {
/** @override */
shaka.dash.DashTextStream.prototype.switch = function(streamInfo, immediate) {
shaka.media.TextStream.prototype.switch = function(streamInfo, immediate) {
this.start(streamInfo);
};
/** @override */
shaka.dash.DashTextStream.prototype.resync = function() {
shaka.media.TextStream.prototype.resync = function() {
// NOP
};
/** @override */
shaka.dash.DashTextStream.prototype.setEnabled = function(enabled) {
shaka.media.TextStream.prototype.setEnabled = function(enabled) {
this.track_.track.mode = enabled ? 'showing' : 'disabled';
};
/** @override */
shaka.dash.DashTextStream.prototype.getEnabled = function() {
shaka.media.TextStream.prototype.getEnabled = function() {
if (!this.track_) return false;
return this.track_.track.mode == 'showing';
};
@@ -16,12 +16,12 @@
* @fileoverview Implements a WebM segment index parser.
*/
goog.provide('shaka.dash.WebmSegmentIndexParser');
goog.provide('shaka.media.WebmSegmentIndexParser');
goog.require('shaka.asserts');
goog.require('shaka.dash.ISegmentIndexParser');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexParser');
goog.require('shaka.media.SegmentReference');
goog.require('shaka.util.EbmlElement');
goog.require('shaka.util.EbmlParser');
@@ -34,16 +34,16 @@ goog.require('shaka.util.EbmlParser');
* SegmentReferences are assumed to be retrievable from |mediaUrl|.
*
* @constructor
* @implements {shaka.dash.ISegmentIndexParser}
* @implements {shaka.media.ISegmentIndexParser}
*/
shaka.dash.WebmSegmentIndexParser = function(mediaUrl) {
shaka.media.WebmSegmentIndexParser = function(mediaUrl) {
/** @private {!goog.Uri} */
this.mediaUrl_ = mediaUrl;
};
/** @override */
shaka.dash.WebmSegmentIndexParser.prototype.parse =
shaka.media.WebmSegmentIndexParser.prototype.parse =
function(initSegmentData, indexData, indexOffset) {
var references = null;
@@ -62,53 +62,53 @@ shaka.dash.WebmSegmentIndexParser.prototype.parse =
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.EBML_ID = 0x1a45dfa3;
shaka.media.WebmSegmentIndexParser.EBML_ID = 0x1a45dfa3;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.SEGMENT_ID = 0x18538067;
shaka.media.WebmSegmentIndexParser.SEGMENT_ID = 0x18538067;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.INFO_ID = 0x1549a966;
shaka.media.WebmSegmentIndexParser.INFO_ID = 0x1549a966;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.TIMECODE_SCALE_ID = 0x2ad7b1;
shaka.media.WebmSegmentIndexParser.TIMECODE_SCALE_ID = 0x2ad7b1;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.CUES_ID = 0x1c53bb6b;
shaka.media.WebmSegmentIndexParser.CUES_ID = 0x1c53bb6b;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.CUE_POINT_ID = 0xbb;
shaka.media.WebmSegmentIndexParser.CUE_POINT_ID = 0xbb;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.CUE_TIME_ID = 0xb3;
shaka.media.WebmSegmentIndexParser.CUE_TIME_ID = 0xb3;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID = 0xb7;
shaka.media.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID = 0xb7;
/** @const {number} */
shaka.dash.WebmSegmentIndexParser.CUE_CLUSTER_POSITION = 0xf1;
shaka.media.WebmSegmentIndexParser.CUE_CLUSTER_POSITION = 0xf1;
/**
* Parses a segment index from a WebM container.
* @param {!DataView} webmData The WebM container data.
* @param {!DataView} cuesData The WebM container's "Cueing Data" section.
* @return {Array.<!shaka.dash.SegmentReference>} The segment references, or
* @return {Array.<!shaka.media.SegmentReference>} The segment references, or
* null if an error occurred
* @throws {RangeError}
* @see http://www.matroska.org/technical/specs/index.html
* @see http://www.webmproject.org/docs/container/
* @private
*/
shaka.dash.WebmSegmentIndexParser.prototype.parseInternal_ = function(
shaka.media.WebmSegmentIndexParser.prototype.parseInternal_ = function(
webmData, cuesData) {
var tuple = this.parseWebmContainer_(webmData);
if (!tuple) {
@@ -117,7 +117,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseInternal_ = function(
var parser = new shaka.util.EbmlParser(cuesData);
var cuesElement = parser.parseElement();
if (cuesElement.id != shaka.dash.WebmSegmentIndexParser.CUES_ID) {
if (cuesElement.id != shaka.media.WebmSegmentIndexParser.CUES_ID) {
shaka.log.error('CuesElement does not exist.');
return null;
}
@@ -133,20 +133,20 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseInternal_ = function(
* offset in bytes, and the segment's timecode scale in seconds.
* @private
*/
shaka.dash.WebmSegmentIndexParser.prototype.parseWebmContainer_ = function(
shaka.media.WebmSegmentIndexParser.prototype.parseWebmContainer_ = function(
webmData) {
var parser = new shaka.util.EbmlParser(webmData);
// Check that the WebM container data starts with the EBML header, but
// skip its contents.
var ebmlElement = parser.parseElement();
if (ebmlElement.id != shaka.dash.WebmSegmentIndexParser.EBML_ID) {
if (ebmlElement.id != shaka.media.WebmSegmentIndexParser.EBML_ID) {
shaka.log.error('EBML element does not exist.');
return null;
}
var segmentElement = parser.parseElement();
if (segmentElement.id != shaka.dash.WebmSegmentIndexParser.SEGMENT_ID) {
if (segmentElement.id != shaka.media.WebmSegmentIndexParser.SEGMENT_ID) {
shaka.log.error('Segment element does not exist.');
return null;
}
@@ -171,7 +171,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseWebmContainer_ = function(
* error occurred.
* @private
*/
shaka.dash.WebmSegmentIndexParser.prototype.parseSegment_ = function(
shaka.media.WebmSegmentIndexParser.prototype.parseSegment_ = function(
segmentElement) {
var parser = segmentElement.createParser();
@@ -179,7 +179,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseSegment_ = function(
var infoElement = null;
while (parser.hasMoreData()) {
var elem = parser.parseElement();
if (elem.id != shaka.dash.WebmSegmentIndexParser.INFO_ID) {
if (elem.id != shaka.media.WebmSegmentIndexParser.INFO_ID) {
continue;
}
@@ -203,7 +203,8 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseSegment_ = function(
* @return {number} The segment's timecode scale in seconds.
* @private
*/
shaka.dash.WebmSegmentIndexParser.prototype.parseInfo_ = function(infoElement) {
shaka.media.WebmSegmentIndexParser.prototype.parseInfo_ = function(
infoElement) {
var parser = infoElement.createParser();
// The timecode scale factor in units of [nanoseconds / T], where [T] are the
@@ -213,7 +214,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseInfo_ = function(infoElement) {
while (parser.hasMoreData()) {
var elem = parser.parseElement();
if (elem.id != shaka.dash.WebmSegmentIndexParser.TIMECODE_SCALE_ID) {
if (elem.id != shaka.media.WebmSegmentIndexParser.TIMECODE_SCALE_ID) {
continue;
}
@@ -234,14 +235,14 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseInfo_ = function(infoElement) {
* @param {!shaka.util.EbmlElement} cuesElement
* @param {number} segmentOffset
* @param {number} timecodeScale
* @return {Array.<!shaka.dash.SegmentReference>} The segment references.
* @return {Array.<!shaka.media.SegmentReference>} The segment references.
* @private
*/
shaka.dash.WebmSegmentIndexParser.prototype.parseCues_ = function(
shaka.media.WebmSegmentIndexParser.prototype.parseCues_ = function(
cuesElement, segmentOffset, timecodeScale) {
var parser = cuesElement.createParser();
/** @type {Array.<shaka.dash.SegmentReference>} */
/** @type {Array.<shaka.media.SegmentReference>} */
var references = [];
var lastTime = -1;
@@ -250,7 +251,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseCues_ = function(
while (parser.hasMoreData()) {
var elem = parser.parseElement();
if (elem.id != shaka.dash.WebmSegmentIndexParser.CUE_POINT_ID) {
if (elem.id != shaka.media.WebmSegmentIndexParser.CUE_POINT_ID) {
continue;
}
@@ -266,7 +267,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseCues_ = function(
shaka.asserts.assert(lastOffset >= 0);
references.push(
new shaka.dash.SegmentReference(
new shaka.media.SegmentReference(
index,
lastTime,
currentTime,
@@ -285,7 +286,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseCues_ = function(
shaka.asserts.assert(lastOffset >= 0);
references.push(
new shaka.dash.SegmentReference(
new shaka.media.SegmentReference(
index,
lastTime,
null,
@@ -307,13 +308,13 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseCues_ = function(
* element.
* @private
*/
shaka.dash.WebmSegmentIndexParser.prototype.parseCuePoint_ = function(
shaka.media.WebmSegmentIndexParser.prototype.parseCuePoint_ = function(
cuePointElement) {
var parser = cuePointElement.createParser();
// Parse CueTime element.
var cueTimeElement = parser.parseElement();
if (cueTimeElement.id != shaka.dash.WebmSegmentIndexParser.CUE_TIME_ID) {
if (cueTimeElement.id != shaka.media.WebmSegmentIndexParser.CUE_TIME_ID) {
shaka.log.warning('CueTime element does not exist.');
return null;
}
@@ -322,7 +323,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseCuePoint_ = function(
// Parse CueTrackPositions element.
var cueTrackPositionsElement = parser.parseElement();
if (cueTrackPositionsElement.id !=
shaka.dash.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID) {
shaka.media.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID) {
shaka.log.warning('CueTrackPositions element does not exist.');
return null;
}
@@ -332,7 +333,7 @@ shaka.dash.WebmSegmentIndexParser.prototype.parseCuePoint_ = function(
while (cueTrackParser.hasMoreData()) {
var elem = cueTrackParser.parseElement();
if (elem.id != shaka.dash.WebmSegmentIndexParser.CUE_CLUSTER_POSITION) {
if (elem.id != shaka.media.WebmSegmentIndexParser.CUE_CLUSTER_POSITION) {
continue;
}
+3 -3
View File
@@ -19,7 +19,7 @@
goog.provide('shaka.player.Stats');
goog.require('shaka.asserts');
goog.require('shaka.dash.mpd');
goog.require('shaka.media.StreamInfo');
@@ -160,7 +160,7 @@ shaka.player.Stats.prototype.logBufferingTime = function(t) {
/**
* Logs a stream change.
*
* @param {!shaka.dash.StreamInfo} streamInfo
* @param {!shaka.media.StreamInfo} streamInfo
*/
shaka.player.Stats.prototype.logStreamChange = function(streamInfo) {
this.streamStats = new shaka.player.Stats.StreamStats(streamInfo);
@@ -194,7 +194,7 @@ shaka.player.Stats.prototype.logPlaybackLatency = function(latency) {
/**
* A collection of stream stats.
*
* @param {!shaka.dash.StreamInfo} streamInfo
* @param {!shaka.media.StreamInfo} streamInfo
*
* @constructor
* @struct
@@ -13,23 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @fileoverview Implements a DASH video source.
* @fileoverview Implements a stream oriented video source.
*/
goog.provide('shaka.player.DashVideoSource');
goog.provide('shaka.player.StreamVideoSource');
goog.require('shaka.asserts');
goog.require('shaka.dash.AbrManager');
goog.require('shaka.dash.DashStream');
goog.require('shaka.dash.DashTextStream');
goog.require('shaka.dash.IDashStream');
goog.require('shaka.dash.MpdProcessor');
goog.require('shaka.dash.MpdRequest');
goog.require('shaka.dash.StreamInfo');
goog.require('shaka.dash.StreamInfoProcessor');
goog.require('shaka.dash.StreamSetInfo');
goog.require('shaka.dash.mpd');
goog.require('shaka.log');
goog.require('shaka.media.AbrManager');
goog.require('shaka.media.IStream');
goog.require('shaka.media.Stream');
goog.require('shaka.media.StreamInfo');
goog.require('shaka.media.StreamInfoProcessor');
goog.require('shaka.media.StreamSetInfo');
goog.require('shaka.media.TextStream');
goog.require('shaka.player.AudioTrack');
goog.require('shaka.player.DrmSchemeInfo');
goog.require('shaka.player.IVideoSource');
@@ -46,13 +46,13 @@ goog.require('shaka.util.TypedBind');
/**
* Creates a DashVideoSource.
* Creates a StreamVideoSource.
* @param {string} mpdUrl The MPD URL.
* @param {shaka.player.DashVideoSource.ContentProtectionCallback}
* @param {shaka.player.StreamVideoSource.ContentProtectionCallback}
* interpretContentProtection A callback to interpret the ContentProtection
* elements in the DASH MPD.
*
* @listens shaka.dash.DashStream.EndedEvent
* @listens shaka.media.Stream.EndedEvent
* @listens shaka.util.IBandwidthEstimator.BandwidthEvent
*
* @struct
@@ -61,7 +61,7 @@ goog.require('shaka.util.TypedBind');
* @extends {shaka.util.FakeEventTarget}
* @export
*/
shaka.player.DashVideoSource = function(mpdUrl, interpretContentProtection) {
shaka.player.StreamVideoSource = function(mpdUrl, interpretContentProtection) {
shaka.util.FakeEventTarget.call(this, null);
/** @private {string} */
@@ -70,11 +70,11 @@ shaka.player.DashVideoSource = function(mpdUrl, interpretContentProtection) {
/** @private {number} */
this.resumeThreshold_ = 0;
/** @private {shaka.player.DashVideoSource.ContentProtectionCallback} */
/** @private {shaka.player.StreamVideoSource.ContentProtectionCallback} */
this.interpretContentProtection_ = interpretContentProtection;
/** @private {!shaka.dash.StreamInfoProcessor} */
this.processor_ = new shaka.dash.StreamInfoProcessor();
/** @private {!shaka.media.StreamInfoProcessor} */
this.processor_ = new shaka.media.StreamInfoProcessor();
/** @private {!MediaSource} */
this.mediaSource_ = new MediaSource();
@@ -83,8 +83,8 @@ shaka.player.DashVideoSource = function(mpdUrl, interpretContentProtection) {
this.video_ = null;
/**
* The active DASH streams.
* @private {!Object.<string, !shaka.dash.IDashStream>}
* The active streams.
* @private {!Object.<string, !shaka.media.IStream>}
*/
this.streamsByType_ = {};
@@ -106,10 +106,10 @@ shaka.player.DashVideoSource = function(mpdUrl, interpretContentProtection) {
/** @private {shaka.player.Stats} */
this.stats_ = null;
/** @private {!shaka.dash.AbrManager} */
this.abrManager_ = new shaka.dash.AbrManager(this.estimator_, this);
/** @private {!shaka.media.AbrManager} */
this.abrManager_ = new shaka.media.AbrManager(this.estimator_, this);
};
goog.inherits(shaka.player.DashVideoSource, shaka.util.FakeEventTarget);
goog.inherits(shaka.player.StreamVideoSource, shaka.util.FakeEventTarget);
/**
@@ -125,14 +125,14 @@ goog.inherits(shaka.player.DashVideoSource, shaka.util.FakeEventTarget);
* shaka.player.DrmSchemeInfo}
* @expose
*/
shaka.player.DashVideoSource.ContentProtectionCallback;
shaka.player.StreamVideoSource.ContentProtectionCallback;
/**
* Destroys the DashVideoSource.
* Destroys the StreamVideoSource.
* @suppress {checkTypes} to set otherwise non-nullable types to null.
*/
shaka.player.DashVideoSource.prototype.destroy = function() {
shaka.player.StreamVideoSource.prototype.destroy = function() {
this.eventManager_.destroy();
this.eventManager_ = null;
@@ -153,7 +153,7 @@ shaka.player.DashVideoSource.prototype.destroy = function() {
/** @override */
shaka.player.DashVideoSource.prototype.attach = function(player, video) {
shaka.player.StreamVideoSource.prototype.attach = function(player, video) {
this.parent = player;
this.video_ = video;
this.stats_ = player.getStats();
@@ -192,7 +192,7 @@ shaka.player.DashVideoSource.prototype.attach = function(player, video) {
/** @override */
shaka.player.DashVideoSource.prototype.getDrmSchemeInfo = function() {
shaka.player.StreamVideoSource.prototype.getDrmSchemeInfo = function() {
if (this.processor_.getNumPeriods() == 0) {
return null;
}
@@ -206,7 +206,7 @@ shaka.player.DashVideoSource.prototype.getDrmSchemeInfo = function() {
/** @override */
shaka.player.DashVideoSource.prototype.load = function(preferredLanguage) {
shaka.player.StreamVideoSource.prototype.load = function(preferredLanguage) {
this.lang_ = preferredLanguage;
var mpdRequest = new shaka.dash.MpdRequest(this.mpdUrl_);
@@ -245,7 +245,7 @@ shaka.player.DashVideoSource.prototype.load = function(preferredLanguage) {
/** @override */
shaka.player.DashVideoSource.prototype.getVideoTracks = function() {
shaka.player.StreamVideoSource.prototype.getVideoTracks = function() {
if (this.processor_.getNumPeriods() == 0) {
return [];
}
@@ -285,7 +285,7 @@ shaka.player.DashVideoSource.prototype.getVideoTracks = function() {
/** @override */
shaka.player.DashVideoSource.prototype.getAudioTracks = function() {
shaka.player.StreamVideoSource.prototype.getAudioTracks = function() {
if (this.processor_.getNumPeriods() == 0) {
return [];
}
@@ -322,7 +322,7 @@ shaka.player.DashVideoSource.prototype.getAudioTracks = function() {
/** @override */
shaka.player.DashVideoSource.prototype.getTextTracks = function() {
shaka.player.StreamVideoSource.prototype.getTextTracks = function() {
if (this.processor_.getNumPeriods() == 0) {
return [];
}
@@ -360,34 +360,34 @@ shaka.player.DashVideoSource.prototype.getTextTracks = function() {
/** @override */
shaka.player.DashVideoSource.prototype.getResumeThreshold = function() {
shaka.player.StreamVideoSource.prototype.getResumeThreshold = function() {
return this.resumeThreshold_;
};
/** @override */
shaka.player.DashVideoSource.prototype.selectVideoTrack =
shaka.player.StreamVideoSource.prototype.selectVideoTrack =
function(id, immediate) {
return this.selectTrack_('video', id, immediate);
};
/** @override */
shaka.player.DashVideoSource.prototype.selectAudioTrack =
shaka.player.StreamVideoSource.prototype.selectAudioTrack =
function(id, immediate) {
return this.selectTrack_('audio', id, immediate);
};
/** @override */
shaka.player.DashVideoSource.prototype.selectTextTrack =
shaka.player.StreamVideoSource.prototype.selectTextTrack =
function(id, immediate) {
return this.selectTrack_('text', id, immediate);
};
/** @override */
shaka.player.DashVideoSource.prototype.enableTextTrack = function(enabled) {
shaka.player.StreamVideoSource.prototype.enableTextTrack = function(enabled) {
var textStream = this.streamsByType_['text'];
if (textStream) {
textStream.setEnabled(enabled);
@@ -396,13 +396,13 @@ shaka.player.DashVideoSource.prototype.enableTextTrack = function(enabled) {
/** @override */
shaka.player.DashVideoSource.prototype.enableAdaptation = function(enabled) {
shaka.player.StreamVideoSource.prototype.enableAdaptation = function(enabled) {
this.abrManager_.enable(enabled);
};
/** @override */
shaka.player.DashVideoSource.prototype.setRestrictions =
shaka.player.StreamVideoSource.prototype.setRestrictions =
function(restrictions) {
this.processor_.enforceRestrictions(restrictions);
};
@@ -419,7 +419,7 @@ shaka.player.DashVideoSource.prototype.setRestrictions =
* @return {boolean} True if the specified track was found.
* @private
*/
shaka.player.DashVideoSource.prototype.selectTrack_ =
shaka.player.StreamVideoSource.prototype.selectTrack_ =
function(type, id, immediate) {
if (this.processor_.getNumPeriods() == 0) {
return false;
@@ -453,7 +453,7 @@ shaka.player.DashVideoSource.prototype.selectTrack_ =
* @param {!Event} event The MediaSource event.
* @private
*/
shaka.player.DashVideoSource.prototype.onMediaSourceOpen_ =
shaka.player.StreamVideoSource.prototype.onMediaSourceOpen_ =
function(event) {
shaka.asserts.assert(this.processor_.getNumPeriods() > 0);
shaka.asserts.assert(this.mediaSource_.sourceBuffers.length == 0);
@@ -463,13 +463,13 @@ shaka.player.DashVideoSource.prototype.onMediaSourceOpen_ =
// TODO(story 1890046): Support multiple periods.
this.mediaSource_.duration = this.processor_.getStreamDuration();
/** @type {!Array.<!shaka.dash.StreamSetInfo>} */
/** @type {!Array.<!shaka.media.StreamSetInfo>} */
var streamSetInfos = this.processor_.selectStreamSetInfos(0, this.lang_);
/** @type {!Object.<string, !shaka.dash.StreamInfo>} */
/** @type {!Object.<string, !shaka.media.StreamInfo>} */
var selectedStreamInfosByType = {};
// Create DASH streams.
// Create streams.
for (var i = 0; i < streamSetInfos.length; ++i) {
var streamSetInfo = streamSetInfos[i];
@@ -514,7 +514,7 @@ shaka.player.DashVideoSource.prototype.onMediaSourceOpen_ =
selectedStreamInfosByType[streamSetInfo.contentType] = streamInfo;
}
// Start DASH streams.
// Start streams.
for (var contentType in this.streamsByType_) {
var stream = this.streamsByType_[contentType];
this.eventManager_.listen(stream, 'ended', this.onStreamEnded_.bind(this));
@@ -550,13 +550,14 @@ shaka.player.DashVideoSource.prototype.onMediaSourceOpen_ =
/**
* Creates a DashStream object.
* Creates a Stream object.
*
* @param {string} fullMimeType
* @return {shaka.dash.DashStream} or null on failure.
* @return {shaka.media.Stream} or null on failure.
* @private
*/
shaka.player.DashVideoSource.prototype.createStream_ = function(fullMimeType) {
shaka.player.StreamVideoSource.prototype.createStream_ = function(
fullMimeType) {
// Create source buffer.
var buf;
try {
@@ -565,14 +566,14 @@ shaka.player.DashVideoSource.prototype.createStream_ = function(fullMimeType) {
} catch (exception) {
this.destroyStreams_();
var error = new Error('Failed to create stream for ' + fullMimeType + '.');
error.type = 'dash';
error.type = 'stream';
error.exception = exception;
this.attachPromise_.reject(error);
return null;
}
// Create stream.
return new shaka.dash.DashStream(
return new shaka.media.Stream(
this,
/** @type {!HTMLVideoElement} */ (this.video_),
this.mediaSource_,
@@ -582,14 +583,14 @@ shaka.player.DashVideoSource.prototype.createStream_ = function(fullMimeType) {
/**
* Creates a DashTextStream object.
* Creates a TextStream object.
*
* @return {!shaka.dash.DashTextStream}
* @return {!shaka.media.TextStream}
* @private
*/
shaka.player.DashVideoSource.prototype.createTextStream_ = function() {
shaka.player.StreamVideoSource.prototype.createTextStream_ = function() {
var video = /** @type {!HTMLVideoElement} */ (this.video_);
return new shaka.dash.DashTextStream(this, video);
return new shaka.media.TextStream(this, video);
};
@@ -598,7 +599,7 @@ shaka.player.DashVideoSource.prototype.createTextStream_ = function() {
*
* @private
*/
shaka.player.DashVideoSource.prototype.destroyStreams_ = function() {
shaka.player.StreamVideoSource.prototype.destroyStreams_ = function() {
for (var type in this.streamsByType_) {
this.streamsByType_[type].destroy();
}
@@ -607,12 +608,12 @@ shaka.player.DashVideoSource.prototype.destroyStreams_ = function() {
/**
* DashStream EOF callback.
* Stream EOF callback.
*
* @param {!Event} event
* @private
*/
shaka.player.DashVideoSource.prototype.onStreamEnded_ = function(event) {
shaka.player.StreamVideoSource.prototype.onStreamEnded_ = function(event) {
shaka.log.v1('onStreamEnded_', event);
// Check the state, otherwise this throws an exception.
@@ -636,7 +637,7 @@ shaka.player.DashVideoSource.prototype.onStreamEnded_ = function(event) {
* @param {!Event} event
* @private
*/
shaka.player.DashVideoSource.prototype.onSeeking_ = function(event) {
shaka.player.StreamVideoSource.prototype.onSeeking_ = function(event) {
// Resync each stream to the new timestamp.
for (var type in this.streamsByType_) {
this.streamsByType_[type].resync();
@@ -650,7 +651,7 @@ shaka.player.DashVideoSource.prototype.onSeeking_ = function(event) {
* @param {!Event} event
* @private
*/
shaka.player.DashVideoSource.prototype.onBandwidth_ = function(event) {
shaka.player.StreamVideoSource.prototype.onBandwidth_ = function(event) {
this.stats_.logBandwidth(this.estimator_.getBandwidth());
};
+1 -1
View File
@@ -16,7 +16,7 @@
* @fileoverview Requires all exported classes from the library.
*/
goog.require('shaka.player.DashVideoSource');
goog.require('shaka.player.StreamVideoSource');
goog.require('shaka.player.DrmSchemeInfo');
goog.require('shaka.player.HttpVideoSource');
goog.require('shaka.player.Player');
+6 -6
View File
@@ -16,8 +16,8 @@
* @fileoverview Player integration tests.
*/
goog.require('shaka.player.DashVideoSource');
goog.require('shaka.player.Player');
goog.require('shaka.player.StreamVideoSource');
goog.require('shaka.polyfill.MediaKeys');
goog.require('shaka.polyfill.VideoPlaybackQuality');
@@ -310,14 +310,14 @@ describe('Player', function() {
player.play();
return delay(3.0);
}).then(function() {
var DashStream = shaka.dash.DashStream;
var Stream = shaka.media.Stream;
var videoStream = source.streamsByType_['video'];
expect(videoStream.state_).toBe(DashStream.State_.UPDATING);
expect(videoStream.state_).toBe(Stream.State_.UPDATING);
var track = getVideoTrackByHeight(480);
var ok = player.selectVideoTrack(track.id);
expect(ok).toBe(true);
expect(videoStream.state_).toBe(DashStream.State_.SWITCHING);
expect(videoStream.state_).toBe(Stream.State_.SWITCHING);
player.seek(30.0);
return delay(7.0);
@@ -649,12 +649,12 @@ describe('Player', function() {
* @param {string} manifest
* @param {shaka.player.DrmSchemeInfo.LicensePostProcessor=}
* opt_licensePostProcessor
* @return {!shaka.player.DashVideoSource}
* @return {!shaka.player.StreamVideoSource}
*/
function newSource(manifest, opt_licensePostProcessor) {
var callback =
interpretContentProtection.bind(null, opt_licensePostProcessor);
return new shaka.player.DashVideoSource(manifest, callback);
return new shaka.player.StreamVideoSource(manifest, callback);
}
/**
+14 -14
View File
@@ -16,10 +16,10 @@
* @fileoverview segment_index.js unit tests.
*/
goog.require('shaka.dash.IsobmffSegmentIndexParser');
goog.require('shaka.dash.SegmentIndex');
goog.require('shaka.dash.SegmentReference');
goog.require('shaka.dash.WebmSegmentIndexParser');
goog.require('shaka.media.IsobmffSegmentIndexParser');
goog.require('shaka.media.SegmentIndex');
goog.require('shaka.media.SegmentReference');
goog.require('shaka.media.WebmSegmentIndexParser');
goog.require('shaka.util.PublicPromise');
// TODO: Move IsobmffSegmentIndexParser and WebmSegmentIndexParser tests into
@@ -91,7 +91,7 @@ describe('SegmentIndex', function() {
// The SIDX data was obtained from an MP4 file where the SIDX offset was
// 708. We use this value here since the expected offsets for parsing this
// SIDX are known.
var parser = new shaka.dash.IsobmffSegmentIndexParser();
var parser = new shaka.media.IsobmffSegmentIndexParser();
var references = parser.parse(null, new DataView(sidxData), 708);
expect(references).not.toBeNull();
@@ -123,7 +123,7 @@ describe('SegmentIndex', function() {
// The SIDX data was obtained from an MP4 file where the SIDX offset was
// 1322. We use this value here since the expected offsets for parsing this
// SIDX are known.
var parser = new shaka.dash.IsobmffSegmentIndexParser();
var parser = new shaka.media.IsobmffSegmentIndexParser();
var references =
parser.parse(null, new DataView(sidxDataWithNonZeroStart), 1322);
expect(references).not.toBeNull();
@@ -147,7 +147,7 @@ describe('SegmentIndex', function() {
});
it('parses a WebM segment index', function() {
var parser = new shaka.dash.WebmSegmentIndexParser();
var parser = new shaka.media.WebmSegmentIndexParser();
var references =
parser.parse(new DataView(webmData), new DataView(cuesData), 0);
expect(references).not.toBeNull();
@@ -172,12 +172,12 @@ describe('SegmentIndex', function() {
var index;
beforeEach(function() {
var parser = new shaka.dash.WebmSegmentIndexParser();
var parser = new shaka.media.WebmSegmentIndexParser();
var references =
parser.parse(new DataView(webmData), new DataView(cuesData), 0);
expect(references).not.toBeNull();
index = new shaka.dash.SegmentIndex(references);
index = new shaka.media.SegmentIndex(references);
});
it('handles a regular interval', function() {
@@ -239,12 +239,12 @@ describe('SegmentIndex', function() {
var url = new goog.Uri('http://example.com');
var references = [
new shaka.dash.SegmentReference(0, 0, 1, 0, 5, url),
new shaka.dash.SegmentReference(1, 1, 2, 6, 9, url),
new shaka.dash.SegmentReference(2, 2, null, 10, null, url)
new shaka.media.SegmentReference(0, 0, 1, 0, 5, url),
new shaka.media.SegmentReference(1, 1, 2, 6, 9, url),
new shaka.media.SegmentReference(2, 2, null, 10, null, url)
];
var index2 = new shaka.dash.SegmentIndex(references);
var index2 = new shaka.media.SegmentIndex(references);
var range = index2.getRangeForInterval(0, 2);
var expectedStartTimes = [0, 1, 2];
@@ -263,7 +263,7 @@ describe('SegmentIndex', function() {
});
it('handles no segments', function() {
index = new shaka.dash.SegmentIndex([]);
index = new shaka.media.SegmentIndex([]);
var range = index.getRangeForInterval(31, 40);
expect(range).toBeNull();
});