71a0366f by David LaPalomento

Add tfdt parsing

Parse out a track fragment decode time box. According to the Media Source byte stream format spec, at least one tfdt is required per media segment.
1 parent 11243fc1
...@@ -594,7 +594,7 @@ test('can parse an styp', function() { ...@@ -594,7 +594,7 @@ test('can parse an styp', function() {
594 majorBrand: 'avc1', 594 majorBrand: 'avc1',
595 minorVersion: 2, 595 minorVersion: 2,
596 compatibleBrands: [3, 4] 596 compatibleBrands: [3, 4]
597 }], 'parsed an ftyp'); 597 }], 'parsed an styp');
598 }); 598 });
599 599
600 test('can parse a vmhd', function() { 600 test('can parse a vmhd', function() {
...@@ -767,6 +767,21 @@ test('can parse a sidx', function(){ ...@@ -767,6 +767,21 @@ test('can parse a sidx', function(){
767 }]); 767 }]);
768 }); 768 });
769 769
770 test('can parse a tfdt', function() {
771 var data = box('tfdt',
772 0x00, // version
773 0x00, 0x00, 0x00, // flags
774 0x01, 0x02, 0x03, 0x04); // baseMediaDecodeTime
775 deepEqual(videojs.inspectMp4(new Uint8Array(data)),
776 [{
777 type: 'tfdt',
778 version: 0,
779 size: 16,
780 flags: new Uint8Array([0, 0, 0]),
781 baseMediaDecodeTime: 0x01020304
782 }]);
783 });
784
770 test('can parse a series of boxes', function() { 785 test('can parse a series of boxes', function() {
771 var ftyp = [ 786 var ftyp = [
772 0x00, 0x00, 0x00, 0x18 // size 4 * 6 = 24 787 0x00, 0x00, 0x00, 0x18 // size 4 * 6 = 24
......
...@@ -376,6 +376,13 @@ var ...@@ -376,6 +376,13 @@ var
376 styp: function(data) { 376 styp: function(data) {
377 return parse.ftyp(data); 377 return parse.ftyp(data);
378 }, 378 },
379 tfdt: function(data) {
380 return {
381 version: data[0],
382 flags: new Uint8Array(data.subarray(1, 4)),
383 baseMediaDecodeTime: data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7]
384 };
385 },
379 tfhd: function(data) { 386 tfhd: function(data) {
380 var 387 var
381 view = new DataView(data.buffer, data.byteOffset, data.byteLength), 388 view = new DataView(data.buffer, data.byteOffset, data.byteLength),
......