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() { ...@@ -766,6 +766,33 @@ test('can parse a trun with per-sample flags', function() {
766 766
767 }); 767 });
768 768
769 test('can parse an sdtp', function() {
770 var data = box('sdtp',
771 0x00, // version
772 0x00, 0x00, 0x00, // flags
773 // reserved + sample_depends_on +
774 // sample_is_dependend_on + sample_has_redundancy
775 0x15,
776 // reserved + sample_depends_on +
777 // sample_is_dependend_on + sample_has_redundancy
778 0x27);
779 deepEqual(videojs.inspectMp4(new Uint8Array(data)), [{
780 type: 'sdtp',
781 version: 0,
782 flags: new Uint8Array([0, 0, 0]),
783 size: 14,
784 samples: [{
785 sampleDependsOn: 1,
786 sampleIsDependedOn: 1,
787 sampleHasRedundancy: 1
788 }, {
789 sampleDependsOn: 2,
790 sampleIsDependedOn: 1,
791 sampleHasRedundancy: 3
792 }]
793 }]);
794 });
795
769 test('can parse a sidx', function(){ 796 test('can parse a sidx', function(){
770 var data = box('sidx', 797 var data = box('sidx',
771 0x00, // version 798 0x00, // version
......
...@@ -277,6 +277,23 @@ var ...@@ -277,6 +277,23 @@ var
277 initialDelay: view.getUint32(8) 277 initialDelay: view.getUint32(8)
278 }; 278 };
279 }, 279 },
280 sdtp: function(data) {
281 var
282 result = {
283 version: data[0],
284 flags: new Uint8Array(data.subarray(1, 4)),
285 samples: []
286 }, i;
287
288 for (i = 4; i < data.byteLength; i++) {
289 result.samples.push({
290 sampleDependsOn: (data[i] & 0x30) >> 4,
291 sampleIsDependedOn: (data[i] & 0x0c) >> 2,
292 sampleHasRedundancy: data[i] & 0x03
293 });
294 }
295 return result;
296 },
280 sidx: function(data) { 297 sidx: function(data) {
281 var view = new DataView(data.buffer, data.byteOffset, data.byteLength), 298 var view = new DataView(data.buffer, data.byteOffset, data.byteLength),
282 result = { 299 result = {
...@@ -301,7 +318,7 @@ var ...@@ -301,7 +318,7 @@ var
301 sapDeltaTime: view.getUint32(i + 8) & 0x0FFFFFFF 318 sapDeltaTime: view.getUint32(i + 8) & 0x0FFFFFFF
302 }); 319 });
303 } 320 }
304 321
305 return result; 322 return result;
306 }, 323 },
307 stbl: function(data) { 324 stbl: function(data) {
......