|
1 | | -/*! codem-isoboxer v0.3.8 https://github.com/madebyhiro/codem-isoboxer/blob/master/LICENSE.txt */ |
| 1 | +/*! codem-isoboxer v0.3.10 https://github.com/madebyhiro/codem-isoboxer/blob/master/LICENSE.txt */ |
2 | 2 | var ISOBoxer = {}; |
3 | 3 |
|
4 | 4 | ISOBoxer.parseBuffer = function(arrayBuffer) { |
@@ -253,7 +253,7 @@ ISOBox.create = function(type) { |
253 | 253 | return newBox; |
254 | 254 | }; |
255 | 255 |
|
256 | | -ISOBox.prototype._boxContainers = ['dinf', 'edts', 'mdia', 'meco', 'mfra', 'minf', 'moof', 'moov', 'mvex', 'stbl', 'strk', 'traf', 'trak', 'tref', 'udta', 'vttc', 'sinf', 'schi', 'encv', 'enca']; |
| 256 | +ISOBox.prototype._boxContainers = ['dinf', 'edts', 'mdia', 'meco', 'mfra', 'minf', 'moof', 'moov', 'mvex', 'stbl', 'strk', 'traf', 'trak', 'tref', 'udta', 'vttc', 'sinf', 'schi', 'encv', 'enca','meta','grpl','prsl']; |
257 | 257 |
|
258 | 258 | ISOBox.prototype._boxProcessors = {}; |
259 | 259 |
|
@@ -366,6 +366,8 @@ ISOBox.prototype._readField = function(type, size) { |
366 | 366 | return this._readData(size); |
367 | 367 | case 'utf8': |
368 | 368 | return this._readUTF8String(); |
| 369 | + case 'utf8string': |
| 370 | + return this._readUTF8TerminatedString(); |
369 | 371 | default: |
370 | 372 | return -1; |
371 | 373 | } |
@@ -476,6 +478,25 @@ ISOBox.prototype._readUTF8String = function() { |
476 | 478 | return data ? ISOBoxer.Utils.dataViewToString(data) : data; |
477 | 479 | }; |
478 | 480 |
|
| 481 | +ISOBox.prototype._readUTF8TerminatedString = function() { |
| 482 | + var length = this._raw.byteLength - (this._cursor.offset - this._offset); |
| 483 | + var data = null; |
| 484 | + if (length > 0) { |
| 485 | + data = new DataView(this._raw.buffer, this._cursor.offset, length); |
| 486 | + |
| 487 | + var l; |
| 488 | + for (l=0; l<length; l++) |
| 489 | + if (data.getUint8(l) === 0) |
| 490 | + break; |
| 491 | + |
| 492 | + // remap the Dataview with the actual length |
| 493 | + data = new DataView(this._raw.buffer, this._cursor.offset, l); |
| 494 | + this._cursor.offset += Math.min(l+1, length); |
| 495 | + } |
| 496 | + |
| 497 | + return data ? ISOBoxer.Utils.dataViewToString(data) : data; |
| 498 | +}; |
| 499 | + |
479 | 500 | ISOBox.prototype._parseBox = function() { |
480 | 501 | this._parsing = true; |
481 | 502 | this._cursor.offset = this._offset; |
@@ -769,6 +790,12 @@ ISOBox.prototype._writeField = function(type, size, value) { |
769 | 790 | } |
770 | 791 | }; |
771 | 792 |
|
| 793 | +// ISO/IEC 14496-12:202x - 12.2.8 Audio rendering indication box |
| 794 | +ISOBox.prototype._boxProcessors['ardi'] = function() { |
| 795 | + this._procFullBox(); |
| 796 | + this._procField('audio_rendering_indication', 'uint', 8); |
| 797 | +}; |
| 798 | + |
772 | 799 | // ISO/IEC 14496-15:2014 - avc1/2/3/4, hev1, hvc1, encv |
773 | 800 | ISOBox.prototype._boxProcessors['avc1'] = |
774 | 801 | ISOBox.prototype._boxProcessors['avc2'] = |
@@ -814,6 +841,12 @@ ISOBox.prototype._boxProcessors['dref'] = function() { |
814 | 841 | this._procSubBoxes('entries', this.entry_count); |
815 | 842 | }; |
816 | 843 |
|
| 844 | +// ISO/IEC 14496-12:202x - 8.4.6 Extended language tag |
| 845 | +ISOBox.prototype._boxProcessors['elng'] = function() { |
| 846 | + this._procFullBox(); |
| 847 | + this._procField('extended_language', 'utf8string'); |
| 848 | +}; |
| 849 | + |
817 | 850 | // ISO/IEC 14496-12:2012 - 8.6.6 Edit List Box |
818 | 851 | ISOBox.prototype._boxProcessors['elst'] = function() { |
819 | 852 | this._procFullBox(); |
@@ -876,6 +909,30 @@ ISOBox.prototype._boxProcessors['hdlr'] = function() { |
876 | 909 | this._procField('name', 'string', -1); |
877 | 910 | }; |
878 | 911 |
|
| 912 | +// ISO/IEC 14496-12:2012 - 9.1.4.1 Identified media data box |
| 913 | +ISOBox.prototype._boxProcessors['imda'] = function() { |
| 914 | + this._procField('imda_identifier', 'uint', 32); |
| 915 | + // until the end of the box |
| 916 | + this._procField('data', 'data', -1); |
| 917 | +}; |
| 918 | + |
| 919 | +// ISO/IEC 14496-12:202x - 8.10.4 Track kind box |
| 920 | +ISOBox.prototype._boxProcessors['kind'] = function() { |
| 921 | + this._procFullBox(); |
| 922 | + |
| 923 | + this._procField('schemeURI', 'utf8string'); |
| 924 | + this._procField('value', 'utf8string'); |
| 925 | +}; |
| 926 | + |
| 927 | +// ISO/IEC 14496-12:202x - 8.10.5 Label box |
| 928 | +ISOBox.prototype._boxProcessors['labl'] = function() { |
| 929 | + this._procFullBox(); |
| 930 | + this.is_group_label = (this.flags & 0x1) != 0; |
| 931 | + this._procField('label_id', 'uint', 16); |
| 932 | + this._procField('language', 'utf8string'); |
| 933 | + this._procField('label', 'utf8string'); |
| 934 | +}; |
| 935 | + |
879 | 936 | // ISO/IEC 14496-12:2012 - 8.1.1 Media Data Box |
880 | 937 | ISOBox.prototype._boxProcessors['mdat'] = function() { |
881 | 938 | this._procField('data', 'data', -1); |
@@ -909,6 +966,13 @@ ISOBox.prototype._boxProcessors['mehd'] = function() { |
909 | 966 | this._procField('fragment_duration', 'uint', (this.version == 1) ? 64 : 32); |
910 | 967 | }; |
911 | 968 |
|
| 969 | +// ISO/IEC 14496-12:202x - 8.11.1 Meta box |
| 970 | +ISOBox.prototype._boxProcessors['meta'] = function() { |
| 971 | + this._procFullBox(); |
| 972 | + |
| 973 | + /* rest of the boxes will be read by _parseContainerBox */ |
| 974 | +}; |
| 975 | + |
912 | 976 | // ISO/IEC 14496-12:2012 - 8.8.5 Movie Fragment Header Box |
913 | 977 | ISOBox.prototype._boxProcessors['mfhd'] = function() { |
914 | 978 | this._procFullBox(); |
@@ -968,6 +1032,21 @@ ISOBox.prototype._boxProcessors['prft'] = function() { |
968 | 1032 | this._procField('media_time', 'uint', (this.version == 1) ? 64 : 32); |
969 | 1033 | }; |
970 | 1034 |
|
| 1035 | +// ISO/IEC 14496-12:202x - 8.18.4.1 Preselection group box |
| 1036 | +ISOBox.prototype._boxProcessors['prsl'] = function() { |
| 1037 | + this._procFullBox(); |
| 1038 | + this._procField('group_id', 'uint', 32); |
| 1039 | + this._procField('num_entities_in_group', 'uint', 32); |
| 1040 | + this._procEntries('entities', this.num_entities_in_group, function(entry) { |
| 1041 | + this._procEntryField(entry, 'entity_id', 'uint', 32); |
| 1042 | + }); |
| 1043 | + if (this.flags & 0x1000) this._procField('preselection_tag', 'utf8string'); |
| 1044 | + if (this.flags & 0x2000) this._procField('selection_priority', 'uint', 8); |
| 1045 | + if (this.flags & 0x4000) this._procField('interleaving_tag', 'utf8string'); |
| 1046 | + |
| 1047 | + /* rest of the boxes will be read by _parseContainerBox */ |
| 1048 | +}; |
| 1049 | + |
971 | 1050 | //ISO/IEC 23001-7:2011 - 8.1 Protection System Specific Header Box |
972 | 1051 | ISOBox.prototype._boxProcessors['pssh'] = function() { |
973 | 1052 | this._procFullBox(); |
@@ -1056,6 +1135,11 @@ ISOBox.prototype._boxProcessors['stsd'] = function() { |
1056 | 1135 | this._procSubBoxes('entries', this.entry_count); |
1057 | 1136 | }; |
1058 | 1137 |
|
| 1138 | +// ISO/IEC 14496-30:2014 - WebVTT Cue Settings Box. |
| 1139 | +ISOBox.prototype._boxProcessors['sttg'] = function() { |
| 1140 | + this._procField('settings', 'utf8'); |
| 1141 | +}; |
| 1142 | + |
1059 | 1143 | // ISO/IEC 14496-12:2012 - 8.6.1.2 Decoding Time To Sample Box |
1060 | 1144 | ISOBox.prototype._boxProcessors['stts'] = function() { |
1061 | 1145 | this._procFullBox(); |
|
0 commit comments