3e86d199 by David LaPalomento

Parse sdtp boxes

Add an inspector function for sdtp boxes.
1 parent a35f70c6
......@@ -766,6 +766,33 @@ test('can parse a trun with per-sample flags', function() {
});
test('can parse an sdtp', function() {
var data = box('sdtp',
0x00, // version
0x00, 0x00, 0x00, // flags
// reserved + sample_depends_on +
// sample_is_dependend_on + sample_has_redundancy
0x15,
// reserved + sample_depends_on +
// sample_is_dependend_on + sample_has_redundancy
0x27);
deepEqual(videojs.inspectMp4(new Uint8Array(data)), [{
type: 'sdtp',
version: 0,
flags: new Uint8Array([0, 0, 0]),
size: 14,
samples: [{
sampleDependsOn: 1,
sampleIsDependedOn: 1,
sampleHasRedundancy: 1
}, {
sampleDependsOn: 2,
sampleIsDependedOn: 1,
sampleHasRedundancy: 3
}]
}]);
});
test('can parse a sidx', function(){
var data = box('sidx',
0x00, // version
......
......@@ -277,6 +277,23 @@ var
initialDelay: view.getUint32(8)
};
},
sdtp: function(data) {
var
result = {
version: data[0],
flags: new Uint8Array(data.subarray(1, 4)),
samples: []
}, i;
for (i = 4; i < data.byteLength; i++) {
result.samples.push({
sampleDependsOn: (data[i] & 0x30) >> 4,
sampleIsDependedOn: (data[i] & 0x0c) >> 2,
sampleHasRedundancy: data[i] & 0x03
});
}
return result;
},
sidx: function(data) {
var view = new DataView(data.buffer, data.byteOffset, data.byteLength),
result = {
......