2ce0fbcb by Gary Katsevman Committed by David LaPalomento

move transmuxing into drainBuffer

1 parent 05131ca4
...@@ -412,23 +412,15 @@ videojs.Hls.prototype.loadSegment = function(segmentUri, offset) { ...@@ -412,23 +412,15 @@ videojs.Hls.prototype.loadSegment = function(segmentUri, offset) {
412 tech.bandwidth = (this.response.byteLength / tech.segmentXhrTime) * 8 * 1000; 412 tech.bandwidth = (this.response.byteLength / tech.segmentXhrTime) * 8 * 1000;
413 tech.bytesReceived += this.response.byteLength; 413 tech.bytesReceived += this.response.byteLength;
414 414
415 // transmux the segment data from MP2T to FLV
416 tech.segmentParser_.parseSegmentBinaryData(new Uint8Array(this.response));
417 tech.segmentParser_.flushTags();
418
419 // package up all the work to append the segment 415 // package up all the work to append the segment
420 // if the segment is the start of a timestamp discontinuity, 416 // if the segment is the start of a timestamp discontinuity,
421 // we have to wait until the sourcebuffer is empty before 417 // we have to wait until the sourcebuffer is empty before
422 // aborting the source buffer processing 418 // aborting the source buffer processing
423 tags = [];
424 while (tech.segmentParser_.tagsAvailable()) {
425 tags.push(tech.segmentParser_.getNextTag());
426 }
427 tech.segmentBuffer_.push({ 419 tech.segmentBuffer_.push({
428 mediaIndex: tech.mediaIndex, 420 mediaIndex: tech.mediaIndex,
429 playlist: tech.playlists.media(), 421 playlist: tech.playlists.media(),
430 offset: offset, 422 offset: offset,
431 tags: tags 423 bytes: this.response
432 }); 424 });
433 tech.drainBuffer(); 425 tech.drainBuffer();
434 426
...@@ -447,6 +439,7 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -447,6 +439,7 @@ videojs.Hls.prototype.drainBuffer = function(event) {
447 playlist, 439 playlist,
448 offset, 440 offset,
449 tags, 441 tags,
442 bytes,
450 segment, 443 segment,
451 444
452 ptsTime, 445 ptsTime,
...@@ -460,7 +453,7 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -460,7 +453,7 @@ videojs.Hls.prototype.drainBuffer = function(event) {
460 mediaIndex = segmentBuffer[0].mediaIndex; 453 mediaIndex = segmentBuffer[0].mediaIndex;
461 playlist = segmentBuffer[0].playlist; 454 playlist = segmentBuffer[0].playlist;
462 offset = segmentBuffer[0].offset; 455 offset = segmentBuffer[0].offset;
463 tags = segmentBuffer[0].tags; 456 bytes = segmentBuffer[0].bytes;
464 segment = playlist.segments[mediaIndex]; 457 segment = playlist.segments[mediaIndex];
465 458
466 if (segment.key) { 459 if (segment.key) {
...@@ -489,6 +482,15 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -489,6 +482,15 @@ videojs.Hls.prototype.drainBuffer = function(event) {
489 this.el().vjs_setProperty('currentTime', segmentOffset * 0.001); 482 this.el().vjs_setProperty('currentTime', segmentOffset * 0.001);
490 } 483 }
491 484
485 // transmux the segment data from MP2T to FLV
486 this.segmentParser_.parseSegmentBinaryData(new Uint8Array(bytes));
487 this.segmentParser_.flushTags();
488
489 tags = [];
490 while (this.segmentParser_.tagsAvailable()) {
491 tags.push(this.segmentParser_.getNextTag());
492 }
493
492 // if we're refilling the buffer after a seek, scan through the muxed 494 // if we're refilling the buffer after a seek, scan through the muxed
493 // FLV tags until we find the one that is closest to the desired 495 // FLV tags until we find the one that is closest to the desired
494 // playback time 496 // playback time
......