3f8b1ce8 by David LaPalomento

Parse compatible brands

Translate compatible brand byte sequences into their string equivalents for ftyp and styp boxes.
1 parent 55ac868e
...@@ -139,14 +139,14 @@ test('can parse an ftyp', function() { ...@@ -139,14 +139,14 @@ test('can parse an ftyp', function() {
139 deepEqual(videojs.inspectMp4(new Uint8Array(box('ftyp', 139 deepEqual(videojs.inspectMp4(new Uint8Array(box('ftyp',
140 0x61, 0x76, 0x63, 0x31, // major brand 140 0x61, 0x76, 0x63, 0x31, // major brand
141 0x00, 0x00, 0x00, 0x02, // minor version 141 0x00, 0x00, 0x00, 0x02, // minor version
142 0x00, 0x00, 0x00, 0x03, // compatible brands 142 98, 111, 111, 112, // compatible brands
143 0x00, 0x00, 0x00, 0x04 // compatible brands 143 98, 101, 101, 112 // compatible brands
144 ))), [{ 144 ))), [{
145 type: 'ftyp', 145 type: 'ftyp',
146 size: 4 * 6, 146 size: 4 * 6,
147 majorBrand: 'avc1', 147 majorBrand: 'avc1',
148 minorVersion: 2, 148 minorVersion: 2,
149 compatibleBrands: [3, 4] 149 compatibleBrands: ['boop', 'beep']
150 }], 'parsed an ftyp'); 150 }], 'parsed an ftyp');
151 }); 151 });
152 152
...@@ -586,14 +586,13 @@ test('can parse an styp', function() { ...@@ -586,14 +586,13 @@ test('can parse an styp', function() {
586 deepEqual(videojs.inspectMp4(new Uint8Array(box('styp', 586 deepEqual(videojs.inspectMp4(new Uint8Array(box('styp',
587 0x61, 0x76, 0x63, 0x31, // major brand 587 0x61, 0x76, 0x63, 0x31, // major brand
588 0x00, 0x00, 0x00, 0x02, // minor version 588 0x00, 0x00, 0x00, 0x02, // minor version
589 0x00, 0x00, 0x00, 0x03, // compatible brands 589 98, 111, 111, 112 // compatible brands
590 0x00, 0x00, 0x00, 0x04 // compatible brands
591 ))), [{ 590 ))), [{
592 type: 'styp', 591 type: 'styp',
593 size: 4 * 6, 592 size: 4 * 5,
594 majorBrand: 'avc1', 593 majorBrand: 'avc1',
595 minorVersion: 2, 594 minorVersion: 2,
596 compatibleBrands: [3, 4] 595 compatibleBrands: ['boop']
597 }], 'parsed an styp'); 596 }], 'parsed an styp');
598 }); 597 });
599 598
...@@ -788,8 +787,8 @@ test('can parse a series of boxes', function() { ...@@ -788,8 +787,8 @@ test('can parse a series of boxes', function() {
788 ].concat(typeBytes('ftyp')).concat([ 787 ].concat(typeBytes('ftyp')).concat([
789 0x69, 0x73, 0x6f, 0x6d, // major brand 788 0x69, 0x73, 0x6f, 0x6d, // major brand
790 0x00, 0x00, 0x00, 0x02, // minor version 789 0x00, 0x00, 0x00, 0x02, // minor version
791 0x00, 0x00, 0x00, 0x03, // compatible brands 790 98, 101, 101, 112, // compatible brands
792 0x00, 0x00, 0x00, 0x04, // compatible brands 791 98, 111, 111, 112, // compatible brands
793 ]); 792 ]);
794 793
795 deepEqual(videojs.inspectMp4(new Uint8Array(ftyp.concat(ftyp))), 794 deepEqual(videojs.inspectMp4(new Uint8Array(ftyp.concat(ftyp))),
...@@ -798,13 +797,13 @@ test('can parse a series of boxes', function() { ...@@ -798,13 +797,13 @@ test('can parse a series of boxes', function() {
798 size: 4 * 6, 797 size: 4 * 6,
799 majorBrand: 'isom', 798 majorBrand: 'isom',
800 minorVersion: 2, 799 minorVersion: 2,
801 compatibleBrands: [3, 4] 800 compatibleBrands: ['beep', 'boop']
802 },{ 801 },{
803 type: 'ftyp', 802 type: 'ftyp',
804 size: 4 * 6, 803 size: 4 * 6,
805 majorBrand: 'isom', 804 majorBrand: 'isom',
806 minorVersion: 2, 805 minorVersion: 2,
807 compatibleBrands: [3, 4] 806 compatibleBrands: ['beep', 'boop']
808 }], 807 }],
809 'parsed two boxes in series'); 808 'parsed two boxes in series');
810 809
......
...@@ -93,7 +93,7 @@ var ...@@ -93,7 +93,7 @@ var
93 }, 93 },
94 i = 8; 94 i = 8;
95 while (i < data.byteLength) { 95 while (i < data.byteLength) {
96 result.compatibleBrands.push(view.getUint32(i)); 96 result.compatibleBrands.push(parseType(data.subarray(i, i + 4)));
97 i += 4; 97 i += 4;
98 } 98 }
99 return result; 99 return result;
......