Fix MP4 text parser integration

* removes an assertion which is no longer valid
 * corrects the registration of the VTT in MP4 parser
 * fixes some type issues in TextEngine

Change-Id: I0b7f41f01e5d7be2932c86a56f3cdfd6a53d04cb
This commit is contained in:
Joey Parrish
2016-07-19 14:43:37 -07:00
parent 7b6a140512
commit ab64c76ee9
3 changed files with 12 additions and 6 deletions
-2
View File
@@ -352,8 +352,6 @@ shaka.media.MediaSourceEngine.prototype.getBuffered_ = function(contentType) {
shaka.media.MediaSourceEngine.prototype.appendBuffer =
function(contentType, data, startTime, endTime) {
if (contentType == 'text') {
goog.asserts.assert(startTime != null && endTime != null,
'text streams do not have init segments!');
return this.textEngine_.appendBuffer(data, startTime, endTime);
}
return this.enqueueOperation_(
+1 -1
View File
@@ -193,4 +193,4 @@ shaka.media.Mp4VttParser.BOX_TYPE_STTG = 0x73747467;
shaka.media.TextEngine.registerParser(
'application/mp4; codecs="wvtt"', shaka.media.Mp4TtmlParser);
'application/mp4; codecs="wvtt"', shaka.media.Mp4VttParser);
+11 -3
View File
@@ -59,7 +59,7 @@ shaka.media.TextEngine = function(track, mimeType) {
/**
* Parses a text buffer into an array of cues.
*
* @typedef {function(ArrayBuffer, number, number):!Array.<!TextTrackCue>}
* @typedef {function(ArrayBuffer, ?number, ?number):!Array.<!TextTrackCue>}
* @exportDoc
*/
shaka.media.TextEngine.TextParser;
@@ -112,8 +112,8 @@ shaka.media.TextEngine.prototype.destroy = function() {
/**
* @param {ArrayBuffer} buffer
* @param {number} startTime
* @param {number} endTime
* @param {?number} startTime
* @param {?number} endTime
* @return {!Promise}
*/
shaka.media.TextEngine.prototype.appendBuffer =
@@ -125,6 +125,14 @@ shaka.media.TextEngine.prototype.appendBuffer =
// Parse the buffer and add the new cues.
var cues = this.parser_(buffer, startTime, endTime);
if (!cues.length) {
// Init segments have no cues and no times.
return;
}
// If cues were parsed, startTime and endTime should be non-null.
goog.asserts.assert(startTime != null && endTime != null,
'start and end times should be non-null!');
for (var i = 0; i < cues.length; ++i) {
cues[i].startTime += offset;
cues[i].endTime += offset;