OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 importScripts('function_sequence.js'); | 5 importScripts('function_sequence.js'); |
6 importScripts('function_parallel.js'); | 6 importScripts('function_parallel.js'); |
7 | 7 |
8 function Id3Parser(parent) { | 8 function Id3Parser(parent) { |
9 MetadataParser.call(this, parent, 'id3', /\.(mp3)$/i); | 9 MetadataParser.call(this, parent, 'id3', /\.(mp3)$/i); |
10 } | 10 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 end - reader.tell()); | 117 end - reader.tell()); |
118 | 118 |
119 frame.value = this.readString_( | 119 frame.value = this.readString_( |
120 reader, | 120 reader, |
121 frame.encoding, | 121 frame.encoding, |
122 end - reader.tell()); | 122 end - reader.tell()); |
123 }; | 123 }; |
124 | 124 |
125 /** | 125 /** |
126 * @private | 126 * @private |
| 127 * @param {ByteReader} reader Reader to use. |
| 128 * @param {number} majorVersion Major id3 version to use. |
| 129 * @param {Object} frame Frame so store data at. |
| 130 * @param {number} end Frame end position in reader. |
127 */ | 131 */ |
128 Id3Parser.prototype.readPIC_ = function(reader, majorVersion, frame, end) { | 132 Id3Parser.prototype.readPIC_ = function(reader, majorVersion, frame, end) { |
129 frame.encoding = reader.readScalar(1, false, end); | 133 frame.encoding = reader.readScalar(1, false, end); |
130 frame.format = reader.readNullTerminatedString(3, end - reader.tell()); | 134 frame.format = reader.readNullTerminatedString(3, end - reader.tell()); |
131 frame.pictureType = reader.readScalar(1, false, end); | 135 frame.pictureType = reader.readScalar(1, false, end); |
132 frame.description = this.readString_(reader, | 136 frame.description = this.readString_(reader, |
133 frame.encoding, | 137 frame.encoding, |
134 end - reader.tell()); | 138 end - reader.tell()); |
135 | 139 |
136 | 140 |
137 if (frame.format == '-->') { | 141 if (frame.format == '-->') { |
138 frame.imageUrl = reader.readNullTerminatedString(end - reader.tell()); | 142 frame.imageUrl = reader.readNullTerminatedString(end - reader.tell()); |
139 } else { | 143 } else { |
140 frame.imageUrl = reader.readImage(end - reader.tell()); | 144 frame.imageUrl = reader.readImage(end - reader.tell()); |
141 } | 145 } |
142 }; | 146 }; |
143 | 147 |
144 /** | 148 /** |
145 * @private | 149 * @private |
| 150 * @param {ByteReader} reader Reader to use. |
| 151 * @param {number} majorVersion Major id3 version to use. |
| 152 * @param {Object} frame Frame so store data at. |
| 153 * @param {number} end Frame end position in reader. |
146 */ | 154 */ |
147 Id3Parser.prototype.readAPIC_ = function(reader, majorVersion, frame, end) { | 155 Id3Parser.prototype.readAPIC_ = function(reader, majorVersion, frame, end) { |
148 this.vlog('Extracting picture'); | 156 this.vlog('Extracting picture'); |
149 frame.encoding = reader.readScalar(1, false, end); | 157 frame.encoding = reader.readScalar(1, false, end); |
150 frame.mime = reader.readNullTerminatedString(end - reader.tell()); | 158 frame.mime = reader.readNullTerminatedString(end - reader.tell()); |
151 frame.pictureType = reader.readScalar(1, false, end); | 159 frame.pictureType = reader.readScalar(1, false, end); |
152 frame.description = this.readString_( | 160 frame.description = this.readString_( |
153 reader, | 161 reader, |
154 frame.encoding, | 162 frame.encoding, |
155 end - reader.tell()); | 163 end - reader.tell()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 reader.tell() + frame.size); | 228 reader.tell() + frame.size); |
221 } | 229 } |
222 | 230 |
223 reader.popSeek(); | 231 reader.popSeek(); |
224 | 232 |
225 reader.seek(frame.size + frame.headerSize, ByteReader.SEEK_CUR); | 233 reader.seek(frame.size + frame.headerSize, ByteReader.SEEK_CUR); |
226 | 234 |
227 return frame; | 235 return frame; |
228 }; | 236 }; |
229 | 237 |
| 238 /** |
| 239 * @param {File} file //TODO(JSDOC). |
| 240 * @param {Object} metadata //TODO(JSDOC). |
| 241 * @param {function(Object)} callback //TODO(JSDOC). |
| 242 * @param {function(etring)} onError //TODO(JSDOC). |
| 243 */ |
230 Id3Parser.prototype.parse = function(file, metadata, callback, onError) { | 244 Id3Parser.prototype.parse = function(file, metadata, callback, onError) { |
231 var self = this; | 245 var self = this; |
232 | 246 |
233 this.log('Starting id3 parser for ' + file.name); | 247 this.log('Starting id3 parser for ' + file.name); |
234 | 248 |
235 var id3v1Parser = new FunctionSequence( | 249 var id3v1Parser = new FunctionSequence( |
236 'id3v1parser', | 250 'id3v1parser', |
237 [ | 251 [ |
238 /** | 252 /** |
239 * Reads last 128 bytes of file in bytebuffer, | 253 * Reads last 128 bytes of file in bytebuffer, |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 TYER: 'ID3_YEAR', | 694 TYER: 'ID3_YEAR', |
681 WCOP: 'ID3_COPYRIGHT', | 695 WCOP: 'ID3_COPYRIGHT', |
682 WOAF: 'ID3_OFFICIAL_AUDIO_FILE_WEBPAGE', | 696 WOAF: 'ID3_OFFICIAL_AUDIO_FILE_WEBPAGE', |
683 WOAR: 'ID3_OFFICIAL_ARTIST', | 697 WOAR: 'ID3_OFFICIAL_ARTIST', |
684 WOAS: 'ID3_OFFICIAL_AUDIO_SOURCE_WEBPAGE', | 698 WOAS: 'ID3_OFFICIAL_AUDIO_SOURCE_WEBPAGE', |
685 WPUB: 'ID3_PUBLISHERS_OFFICIAL_WEBPAGE' | 699 WPUB: 'ID3_PUBLISHERS_OFFICIAL_WEBPAGE' |
686 } | 700 } |
687 }; | 701 }; |
688 | 702 |
689 MetadataDispatcher.registerParserClass(Id3Parser); | 703 MetadataDispatcher.registerParserClass(Id3Parser); |
OLD | NEW |