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() {
majorBrand: 'avc1',
minorVersion: 2,
compatibleBrands: [3, 4]
}], 'parsed an ftyp');
}], 'parsed an styp');
});
test('can parse a vmhd', function() {
......@@ -767,6 +767,21 @@ test('can parse a sidx', function(){
}]);
});
test('can parse a tfdt', function() {
var data = box('tfdt',
0x00, // version
0x00, 0x00, 0x00, // flags
0x01, 0x02, 0x03, 0x04); // baseMediaDecodeTime
deepEqual(videojs.inspectMp4(new Uint8Array(data)),
[{
type: 'tfdt',
version: 0,
size: 16,
flags: new Uint8Array([0, 0, 0]),
baseMediaDecodeTime: 0x01020304
}]);
});
test('can parse a series of boxes', function() {
var ftyp = [
0x00, 0x00, 0x00, 0x18 // size 4 * 6 = 24
......
......@@ -376,6 +376,13 @@ var
styp: function(data) {
return parse.ftyp(data);
},
tfdt: function(data) {
return {
version: data[0],
flags: new Uint8Array(data.subarray(1, 4)),
baseMediaDecodeTime: data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7]
};
},
tfhd: function(data) {
var
view = new DataView(data.buffer, data.byteOffset, data.byteLength),
......