id3lib 3.8.3

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

field.cpp
Go to the documentation of this file.
1 // $Id: field.cpp,v 1.47 2002/11/03 00:41:27 t1mpy Exp $
2
3 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags
4 // Copyright 1999, 2000 Scott Thomas Haug
5 // Copyright 2002 Thijmen Klok (thijmen@id3lib.org)
6
7 // This library is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU Library General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or (at your
10 // option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public License
18 // along with this library; if not, write to the Free Software Foundation,
19 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 // The id3lib authors encourage improvements and optimisations to be sent to
22 // the id3lib coordinator. Please see the README file for details on where to
23 // send such submissions. See the AUTHORS file for a list of people who have
24 // contributed to id3lib. See the ChangeLog file for a list of changes to
25 // id3lib. These files are distributed with id3lib at
26 // http://download.sourceforge.net/id3lib/
27
28
29 #include "field_impl.h"
30 #include "id3/utils.h" // has <config.h> "id3/id3lib_streams.h" "id3/globals.h" "id3/id3lib_strings.h"
31 #include "field_def.h"
32 #include "frame_def.h"
33 #include "readers.h"
34 #include <assert.h>
35
36 #include "string.h"
37
38 using namespace dami;
39
40 // This is used for unimplemented frames so that their data is preserved when
41 // parsing and rendering
42 static ID3_FieldDef ID3FD_Unimplemented[] =
43 {
44 {
45 ID3FN_DATA, // FIELD NAME
46 ID3FTY_BINARY, // FIELD TYPE
47 0, // FIXED LEN
48 ID3V2_EARLIEST, // INITIAL SPEC
49 ID3V2_LATEST, // ENDING SPEC
50 ID3FF_NONE, // FLAGS
51 ID3FN_NOFIELD // LINKED FIELD
52 },
53 { ID3FN_NOFIELD }
54 };
55
56 const ID3_FieldDef* ID3_FieldDef::DEFAULT = ID3FD_Unimplemented;
57
58 static ID3_FieldDef ID3FD_URL[] =
59 {
60 {
61 ID3FN_URL, // FIELD NAME
62 ID3FTY_TEXTSTRING, // FIELD TYPE
63 0, // FIXED LEN
64 ID3V2_EARLIEST, // INITIAL SPEC
65 ID3V2_LATEST, // ENDING SPEC
66 ID3FF_NONE, // FLAGS
67 ID3FN_NOFIELD // LINKED FIELD
68 },
69 { ID3FN_NOFIELD }
70 };
71
72 static ID3_FieldDef ID3FD_UserURL[] =
73 {
74 {
75 ID3FN_TEXTENC, // FIELD NAME
76 ID3FTY_INTEGER, // FIELD TYPE
77 1, // FIXED LEN
78 ID3V2_EARLIEST, // INITIAL SPEC
79 ID3V2_LATEST, // ENDING SPEC
80 ID3FF_NONE, // FLAGS
81 ID3FN_NOFIELD // LINKED FIELD
82 },
83 {
84 ID3FN_DESCRIPTION, // FIELD NAME
85 ID3FTY_TEXTSTRING, // FIELD TYPE
86 0, // FIXED LEN
87 ID3V2_EARLIEST, // INITIAL SPEC
88 ID3V2_LATEST, // ENDING SPEC
89 ID3FF_CSTR | ID3FF_ENCODABLE, // FLAGS
90 ID3FN_NOFIELD // LINKED FIELD
91 },
92 {
93 ID3FN_URL, // FIELD NAME
94 ID3FTY_TEXTSTRING, // FIELD TYPE
95 0, // FIXED LEN
96 ID3V2_EARLIEST, // INITIAL SPEC
97 ID3V2_LATEST, // ENDING SPEC
98 ID3FF_NONE, // FLAGS
99 ID3FN_NOFIELD // LINKED FIELD
100 },
101 { ID3FN_NOFIELD }
102 };
103
104 static ID3_FieldDef ID3FD_Text[] =
105 {
106 {
107 ID3FN_TEXTENC, // FIELD NAME
108 ID3FTY_INTEGER, // FIELD TYPE
109 1, // FIXED LEN
110 ID3V2_EARLIEST, // INITIAL SPEC
111 ID3V2_LATEST, // ENDING SPEC
112 ID3FF_NONE, // FLAGS
113 ID3FN_NOFIELD // LINKED FIELD
114 },
115 {
116 ID3FN_TEXT, // FIELD NAME
117 ID3FTY_TEXTSTRING, // FIELD TYPE
118 0, // FIXED LEN
119 ID3V2_EARLIEST, // INITIAL SPEC
120 ID3V2_LATEST, // ENDING SPEC
121 ID3FF_ENCODABLE, // FLAGS
122 ID3FN_NOFIELD // LINKED FIELD
123 },
124 { ID3FN_NOFIELD }
125 };
126
127
128 static ID3_FieldDef ID3FD_UserText[] =
129 {
130 {
131 ID3FN_TEXTENC, // FIELD NAME
132 ID3FTY_INTEGER, // FIELD TYPE
133 1, // FIXED LEN
134 ID3V2_EARLIEST, // INITIAL SPEC
135 ID3V2_LATEST, // ENDING SPEC
136 ID3FF_NONE, // FLAGS
137 ID3FN_NOFIELD // LINKED FIELD
138 },
139 {
140 ID3FN_DESCRIPTION, // FIELD NAME
141 ID3FTY_TEXTSTRING, // FIELD TYPE
142 0, // FIXED LEN
143 ID3V2_EARLIEST, // INITIAL SPEC
144 ID3V2_LATEST, // ENDING SPEC
145 ID3FF_CSTR | ID3FF_ENCODABLE, // FLAGS
146 ID3FN_NOFIELD // LINKED FIELD
147 },
148 {
149 ID3FN_TEXT, // FIELD NAME
150 ID3FTY_TEXTSTRING, // FIELD TYPE
151 0, // FIXED LEN
152 ID3V2_EARLIEST, // INITIAL SPEC
153 ID3V2_LATEST, // ENDING SPEC
154 ID3FF_ENCODABLE, // FLAGS
155 ID3FN_NOFIELD // LINKED FIELD
156 },
157 { ID3FN_NOFIELD }
158 };
159
160
161 static ID3_FieldDef ID3FD_GeneralText[] =
162 {
163 {
164 ID3FN_TEXTENC, // FIELD NAME
165 ID3FTY_INTEGER, // FIELD TYPE
166 1, // FIXED LEN
167 ID3V2_EARLIEST, // INITIAL SPEC
168 ID3V2_LATEST, // ENDING SPEC
169 ID3FF_NONE, // FLAGS
170 ID3FN_NOFIELD // LINKED FIELD
171 },
172 {
173 ID3FN_LANGUAGE, // FIELD NAME
174 ID3FTY_TEXTSTRING, // FIELD TYPE
175 3, // FIXED LEN
176 ID3V2_EARLIEST, // INITIAL SPEC
177 ID3V2_LATEST, // ENDING SPEC
178 ID3FF_NONE, // FLAGS
179 ID3FN_NOFIELD // LINKED FIELD
180 },
181 {
182 ID3FN_DESCRIPTION, // FIELD NAME
183 ID3FTY_TEXTSTRING, // FIELD TYPE
184 0, // FIXED LEN
185 ID3V2_EARLIEST, // INITIAL SPEC
186 ID3V2_LATEST, // ENDING SPEC
187 ID3FF_CSTR | ID3FF_ENCODABLE, // FLAGS
188 ID3FN_NOFIELD // LINKED FIELD
189 },
190 {
191 ID3FN_TEXT, // FIELD NAME
192 ID3FTY_TEXTSTRING, // FIELD TYPE
193 0, // FIXED LEN
194 ID3V2_EARLIEST, // INITIAL SPEC
195 ID3V2_LATEST, // ENDING SPEC
196 ID3FF_ENCODABLE, // FLAGS
197 ID3FN_NOFIELD // LINKED FIELD
198 },
199 { ID3FN_NOFIELD }
200 };
201
202 static ID3_FieldDef ID3FD_TermsOfUse[] =
203 {
204 {
205 ID3FN_TEXTENC, // FIELD NAME
206 ID3FTY_INTEGER, // FIELD TYPE
207 1, // FIXED LEN
208 ID3V2_3_0, // INITIAL SPEC
209 ID3V2_LATEST, // ENDING SPEC
210 ID3FF_NONE, // FLAGS
211 ID3FN_NOFIELD // LINKED FIELD
212 },
213 {
214 ID3FN_LANGUAGE, // FIELD NAME
215 ID3FTY_TEXTSTRING, // FIELD TYPE
216 3, // FIXED LEN
217 ID3V2_3_0, // INITIAL SPEC
218 ID3V2_LATEST, // ENDING SPEC
219 ID3FF_NONE, // FLAGS
220 ID3FN_NOFIELD // LINKED FIELD
221 },
222 {
223 ID3FN_TEXT, // FIELD NAME
224 ID3FTY_TEXTSTRING, // FIELD TYPE
225 0, // FIXED LEN
226 ID3V2_3_0, // INITIAL SPEC
227 ID3V2_LATEST, // ENDING SPEC
228 ID3FF_ENCODABLE, // FLAGS
229 ID3FN_NOFIELD // LINKED FIELD
230 },
231 { ID3FN_NOFIELD }
232 };
233
234 static ID3_FieldDef ID3FD_LinkedInfo[] =
235 {
236 {
237 ID3FN_ID, // FIELD NAME
238 ID3FTY_TEXTSTRING, // FIELD TYPE
239 3, // FIXED LEN
240 ID3V2_EARLIEST, // INITIAL SPEC
241 ID3V2_2_1, // ENDING SPEC
242 ID3FF_NONE, // FLAGS
243 ID3FN_NOFIELD // LINKED FIELD
244 },
245 {
246 ID3FN_ID, // FIELD NAME
247 ID3FTY_TEXTSTRING, // FIELD TYPE
248 4, // FIXED LEN
249 ID3V2_3_0, // INITIAL SPEC
250 ID3V2_LATEST, // ENDING SPEC
251 ID3FF_NONE, // FLAGS
252 ID3FN_NOFIELD // LINKED FIELD
253 },
254 {
255 ID3FN_URL, // FIELD NAME
256 ID3FTY_TEXTSTRING, // FIELD TYPE
257 0, // FIXED LEN
258 ID3V2_EARLIEST, // INITIAL SPEC
259 ID3V2_LATEST, // ENDING SPEC
260 ID3FF_CSTR, // FLAGS
261 ID3FN_NOFIELD // LINKED FIELD
262 },
263 {
264 ID3FN_TEXT, // FIELD NAME
265 ID3FTY_TEXTSTRING, // FIELD TYPE
266 0, // FIXED LEN
267 ID3V2_EARLIEST, // INITIAL SPEC
268 ID3V2_LATEST, // ENDING SPEC
269 ID3FF_NONE, // FLAGS
270 ID3FN_NOFIELD // LINKED FIELD
271 },
272 { ID3FN_NOFIELD }
273 };
274
275 static ID3_FieldDef ID3FD_Picture[] =
276 {
277 {
278 ID3FN_TEXTENC, // FIELD NAME
279 ID3FTY_INTEGER, // FIELD TYPE
280 1, // FIXED LEN
281 ID3V2_EARLIEST, // INITIAL SPEC
282 ID3V2_LATEST, // ENDING SPEC
283 ID3FF_NONE, // FLAGS
284 ID3FN_NOFIELD // LINKED FIELD
285 },
286 {
287 ID3FN_IMAGEFORMAT, // FIELD NAME
288 ID3FTY_TEXTSTRING, // FIELD TYPE
289 3, // FIXED LEN
290 ID3V2_EARLIEST, // INITIAL SPEC
291 ID3V2_2_1, // ENDING SPEC
292 ID3FF_NONE, // FLAGS
293 ID3FN_NOFIELD // LINKED FIELD
294 },
295 {
296 ID3FN_MIMETYPE, // FIELD NAME
297 ID3FTY_TEXTSTRING, // FIELD TYPE
298 0, // FIXED LEN
299 ID3V2_3_0, // INITIAL SPEC
300 ID3V2_LATEST, // ENDING SPEC
301 ID3FF_CSTR, // FLAGS
302 ID3FN_NOFIELD // LINKED FIELD
303 },
304 {
305 ID3FN_PICTURETYPE, // FIELD NAME
306 ID3FTY_INTEGER, // FIELD TYPE
307 1, // FIXED LEN
308 ID3V2_EARLIEST, // INITIAL SPEC
309 ID3V2_LATEST, // ENDING SPEC
310 ID3FF_NONE, // FLAGS
311 ID3FN_NOFIELD // LINKED FIELD
312 },
313 {
314 ID3FN_DESCRIPTION, // FIELD NAME
315 ID3FTY_TEXTSTRING, // FIELD TYPE
316 0, // FIXED LEN
317 ID3V2_EARLIEST, // INITIAL SPEC
318 ID3V2_LATEST, // ENDING SPEC
319 ID3FF_CSTR | ID3FF_ENCODABLE, // FLAGS
320 ID3FN_NOFIELD // LINKED FIELD
321 },
322 {
323 ID3FN_DATA, // FIELD NAME
324 ID3FTY_BINARY, // FIELD TYPE
325 0, // FIXED LEN
326 ID3V2_EARLIEST, // INITIAL SPEC
327 ID3V2_LATEST, // ENDING SPEC
328 ID3FF_NONE, // FLAGS
329 ID3FN_NOFIELD // LINKED FIELD
330 },
331 { ID3FN_NOFIELD }
332 };
333
334 static ID3_FieldDef ID3FD_GEO[] =
335 {
336 {
337 ID3FN_TEXTENC, // FIELD NAME
338 ID3FTY_INTEGER, // FIELD TYPE
339 1, // FIXED LEN
340 ID3V2_EARLIEST, // INITIAL SPEC
341 ID3V2_LATEST, // ENDING SPEC
342 ID3FF_NONE, // FLAGS
343 ID3FN_NOFIELD // LINKED FIELD
344 },
345 {
346 ID3FN_MIMETYPE, // FIELD NAME
347 ID3FTY_TEXTSTRING, // FIELD TYPE
348 0, // FIXED LEN
349 ID3V2_EARLIEST, // INITIAL SPEC
350 ID3V2_LATEST, // ENDING SPEC
351 ID3FF_CSTR, // FLAGS
352 ID3FN_NOFIELD // LINKED FIELD
353 },
354 {
355 ID3FN_FILENAME, // FIELD NAME
356 ID3FTY_TEXTSTRING, // FIELD TYPE
357 0, // FIXED LEN
358 ID3V2_EARLIEST, // INITIAL SPEC
359 ID3V2_LATEST, // ENDING SPEC
360 ID3FF_CSTR | ID3FF_ENCODABLE, // FLAGS
361 ID3FN_NOFIELD // LINKED FIELD
362 },
363 {
364 ID3FN_DESCRIPTION, // FIELD NAME
365 ID3FTY_TEXTSTRING, // FIELD TYPE
366 0, // FIXED LEN
367 ID3V2_EARLIEST, // INITIAL SPEC
368 ID3V2_LATEST, // ENDING SPEC
369 ID3FF_CSTR | ID3FF_ENCODABLE, // FLAGS
370 ID3FN_NOFIELD // LINKED FIELD
371 },
372 {
373 ID3FN_DATA, // FIELD NAME
374 ID3FTY_BINARY, // FIELD TYPE
375 0, // FIXED LEN
376 ID3V2_EARLIEST, // INITIAL SPEC
377 ID3V2_LATEST, // ENDING SPEC
378 ID3FF_NONE, // FLAGS
379 ID3FN_NOFIELD // LINKED FIELD
380 },
381 { ID3FN_NOFIELD }
382 };
383
384 static ID3_FieldDef ID3FD_UFI[] =
385 {
386 {
387 ID3FN_OWNER, // FIELD NAME
388 ID3FTY_TEXTSTRING, // FIELD TYPE
389 0, // FIXED LEN
390 ID3V2_EARLIEST, // INITIAL SPEC
391 ID3V2_LATEST, // ENDING SPEC
392 ID3FF_CSTR, // FLAGS
393 ID3FN_NOFIELD // LINKED FIELD
394 },
395 {
396 ID3FN_DATA, // FIELD NAME
397 ID3FTY_BINARY, // FIELD TYPE
398 0, // FIXED LEN
399 ID3V2_EARLIEST, // INITIAL SPEC
400 ID3V2_LATEST, // ENDING SPEC
401 ID3FF_NONE, // FLAGS
402 ID3FN_NOFIELD // LINKED FIELD
403 },
404 { ID3FN_NOFIELD }
405 };
406
407 static ID3_FieldDef ID3FD_PlayCounter[] =
408 {
409 {
410 ID3FN_COUNTER, // FIELD NAME
411 ID3FTY_INTEGER, // FIELD TYPE
412 4, // FIXED LEN
413 ID3V2_EARLIEST, // INITIAL SPEC
414 ID3V2_LATEST, // ENDING SPEC
415 ID3FF_NONE, // FLAGS
416 ID3FN_NOFIELD // LINKED FIELD
417 },
418 { ID3FN_NOFIELD }
419 };
420
421 static ID3_FieldDef ID3FD_Popularimeter[] =
422 {
423 {
424 ID3FN_EMAIL, // FIELD NAME
425 ID3FTY_TEXTSTRING, // FIELD TYPE
426 0, // FIXED LEN
427 ID3V2_EARLIEST, // INITIAL SPEC
428 ID3V2_LATEST, // ENDING SPEC
429 ID3FF_CSTR, // FLAGS
430 ID3FN_NOFIELD // LINKED FIELD
431 },
432 {
433 ID3FN_RATING, // FIELD NAME
434 ID3FTY_INTEGER, // FIELD TYPE
435 1, // FIXED LEN
436 ID3V2_EARLIEST, // INITIAL SPEC
437 ID3V2_LATEST, // ENDING SPEC
438 ID3FF_NONE, // FLAGS
439 ID3FN_NOFIELD // LINKED FIELD
440 },
441 {
442 ID3FN_COUNTER, // FIELD NAME
443 ID3FTY_INTEGER, // FIELD TYPE
444 4, // FIXED LEN
445 ID3V2_EARLIEST, // INITIAL SPEC
446 ID3V2_LATEST, // ENDING SPEC
447 ID3FF_NONE, // FLAGS
448 ID3FN_NOFIELD // LINKED FIELD
449 },
450 { ID3FN_NOFIELD }
451 };
452
453 static ID3_FieldDef ID3FD_Private[] =
454 {
455 {
456 ID3FN_OWNER, // FIELD NAME
457 ID3FTY_TEXTSTRING, // FIELD TYPE
458 0, // FIXED LEN
459 ID3V2_3_0, // INITIAL SPEC
460 ID3V2_LATEST, // ENDING SPEC
461 ID3FF_CSTR, // FLAGS
462 ID3FN_NOFIELD // LINKED FIELD
463 },
464 {
465 ID3FN_DATA, // FIELD NAME
466 ID3FTY_BINARY, // FIELD TYPE
467 0, // FIXED LEN
468 ID3V2_3_0, // INITIAL SPEC
469 ID3V2_LATEST, // ENDING SPEC
470 ID3FF_NONE, // FLAGS
471 ID3FN_NOFIELD // LINKED FIELD
472 },
473 { ID3FN_NOFIELD }
474 };
475
476
477 static ID3_FieldDef ID3FD_Registration[] =
478 {
479 {
480 ID3FN_OWNER, // FIELD NAME
481 ID3FTY_TEXTSTRING, // FIELD TYPE
482 0, // FIXED LEN
483 ID3V2_3_0, // INITIAL SPEC
484 ID3V2_LATEST, // ENDING SPEC
485 ID3FF_CSTR, // FLAGS
486 ID3FN_NOFIELD // LINKED FIELD
487 },
488 {
489 ID3FN_ID, // FIELD NAME
490 ID3FTY_INTEGER, // FIELD TYPE
491 1, // FIXED LEN
492 ID3V2_3_0, // INITIAL SPEC
493 ID3V2_LATEST, // ENDING SPEC
494 ID3FF_NONE, // FLAGS
495 ID3FN_NOFIELD // LINKED FIELD
496 },
497 {
498 ID3FN_DATA, // FIELD NAME
499 ID3FTY_BINARY, // FIELD TYPE
500 0, // FIXED LEN
501 ID3V2_3_0, // INITIAL SPEC
502 ID3V2_LATEST, // ENDING SPEC
503 ID3FF_NONE, // FLAGS
504 ID3FN_NOFIELD // LINKED FIELD
505 },
506 { ID3FN_NOFIELD }
507 };
508
509 static ID3_FieldDef ID3FD_InvolvedPeople[] =
510 {
511 {
512 ID3FN_TEXTENC, // FIELD NAME
513 ID3FTY_INTEGER, // FIELD TYPE
514 1, // FIXED LEN
515 ID3V2_EARLIEST, // INITIAL SPEC
516 ID3V2_LATEST, // ENDING SPEC
517 ID3FF_NONE, // FLAGS
518 ID3FN_NOFIELD // LINKED FIELD
519 },
520 {
521 ID3FN_TEXT, // FIELD NAME
522 ID3FTY_TEXTSTRING, // FIELD TYPE
523 0, // FIXED LEN
524 ID3V2_EARLIEST, // INITIAL SPEC
525 ID3V2_LATEST, // ENDING SPEC
526 ID3FF_TEXTLIST, // FLAGS
527 ID3FN_NOFIELD // LINKED FIELD
528 },
529 { ID3FN_NOFIELD }
530 };
531
532 static ID3_FieldDef ID3FD_CDM[] =
533 {
534 {
535 ID3FN_DATA, // FIELD NAME
536 ID3FTY_BINARY, // FIELD TYPE
537 0, // FIXED LEN
538 ID3V2_2_1, // INITIAL SPEC
539 ID3V2_2_1, // ENDING SPEC
540 ID3FF_NONE, // FLAGS
541 ID3FN_NOFIELD // LINKED FIELD
542 }
543 };
544
545 static ID3_FieldDef ID3FD_SyncLyrics[] =
546 {
547 {
548 ID3FN_TEXTENC, // FIELD NAME
549 ID3FTY_INTEGER, // FIELD TYPE
550 1, // FIXED LEN
551 ID3V2_EARLIEST, // INITIAL SPEC
552 ID3V2_LATEST, // ENDING SPEC
553 ID3FF_NONE, // FLAGS
554 ID3FN_NOFIELD // LINKED FIELD
555 },
556 {
557 ID3FN_LANGUAGE, // FIELD NAME
558 ID3FTY_TEXTSTRING, // FIELD TYPE
559 3, // FIXED LEN
560 ID3V2_EARLIEST, // INITIAL SPEC
561 ID3V2_LATEST, // ENDING SPEC
562 ID3FF_NONE, // FLAGS
563 ID3FN_NOFIELD // LINKED FIELD
564 },
565 {
566 ID3FN_TIMESTAMPFORMAT, // FIELD NAME
567 ID3FTY_INTEGER, // FIELD TYPE
568 1, // FIXED LEN
569 ID3V2_EARLIEST, // INITIAL SPEC
570 ID3V2_LATEST, // ENDING SPEC
571 ID3FF_NONE, // FLAGS
572 ID3FN_NOFIELD // LINKED FIELD
573 },
574 {
575 ID3FN_CONTENTTYPE, // FIELD NAME
576 ID3FTY_INTEGER, // FIELD TYPE
577 1, // FIXED LEN
578 ID3V2_EARLIEST, // INITIAL SPEC
579 ID3V2_LATEST, // ENDING SPEC
580 ID3FF_NONE, // FLAGS
581 ID3FN_NOFIELD // LINKED FIELD
582 },
583 {
584 ID3FN_DESCRIPTION, // FIELD NAME
585 ID3FTY_TEXTSTRING, // FIELD TYPE
586 0, // FIXED LEN
587 ID3V2_EARLIEST, // INITIAL SPEC
588 ID3V2_LATEST, // ENDING SPEC
589 ID3FF_CSTR | ID3FF_ENCODABLE, // FLAGS
590 ID3FN_NOFIELD // LINKED FIELD
591 },
592 {
593 ID3FN_DATA, // FIELD NAME
594 ID3FTY_BINARY, // FIELD TYPE
595 0, // FIXED LEN
596 ID3V2_EARLIEST, // INITIAL SPEC
597 ID3V2_LATEST, // ENDING SPEC
598 ID3FF_NONE, // FLAGS
599 ID3FN_NOFIELD // LINKED FIELD
600 },
601 { ID3FN_NOFIELD }
602 };
603
604
605 /*
606 * Currently unused
607 */
608 #if defined _UNDEFINED_
609 static ID3_FieldDef ID3FD_Volume[] =
610 {
611 {
612 ID3FN_VOLUMEADJ, // FIELD NAME
613 ID3FTY_INTEGER, // FIELD TYPE
614 1, // FIXED LEN
615 ID3V2_EARLIEST, // INITIAL SPEC
616 ID3V2_LATEST, // ENDING SPEC
617 ID3FF_NONE, // FLAGS
618 ID3FN_NOFIELD // LINKED FIELD
619 },
620 {
621 ID3FN_NUMBITS, // FIELD NAME
622 ID3FTY_INTEGER, // FIELD TYPE
623 1, // FIXED LEN
624 ID3V2_EARLIEST, // INITIAL SPEC
625 ID3V2_LATEST, // ENDING SPEC
626 ID3FF_NONE, // FLAGS
627 ID3FN_NOFIELD // LINKED FIELD
628 },
629 {
630 ID3FN_VOLCHGRIGHT, // FIELD NAME
631 ID3FTY_BITFIELD, // FIELD TYPE
632 0, // FIXED LEN
633 ID3V2_EARLIEST, // INITIAL SPEC
634 ID3V2_LATEST, // ENDING SPEC
635 ID3FF_ADJUSTEDBY, // FLAGS
636 ID3FN_NUMBITS // LINKED FIELD
637 },
638 {
639 ID3FN_VOLCHGLEFT, // FIELD NAME
640 ID3FTY_BITFIELD, // FIELD TYPE
641 0, // FIXED LEN
642 ID3V2_EARLIEST, // INITIAL SPEC
643 ID3V2_LATEST, // ENDING SPEC
644 ID3FF_ADJUSTEDBY, // FLAGS
645 ID3FN_NUMBITS // LINKED FIELD
646 },
647 {
648 ID3FN_PEAKVOLRIGHT, // FIELD NAME
649 ID3FTY_BITFIELD, // FIELD TYPE
650 0, // FIXED LEN
651 ID3V2_EARLIEST, // INITIAL SPEC
652 ID3V2_LATEST, // ENDING SPEC
653 ID3FF_ADJUSTEDBY, // FLAGS
654 ID3FN_NUMBITS // LINKED FIELD
655 },
656 {
657 ID3FN_PEAKVOLLEFT, // FIELD NAME
658 ID3FTY_BITFIELD, // FIELD TYPE
659 0, // FIXED LEN
660 ID3V2_EARLIEST, // INITIAL SPEC
661 ID3V2_LATEST, // ENDING SPEC
662 ID3FF_ADJUSTEDBY, // FLAGS
663 ID3FN_NUMBITS // LINKED FIELD
664 },
665 { ID3FN_NOFIELD }
666 };
667 #endif /* _UNDEFINED_ */
668
669 // **** Currently Implemented Frames
670 // APIC PIC ID3FID_PICTURE Attached picture
671 // COMM COM ID3FID_COMMENT Comments
672 // ENCR ID3FID_CRYPTOREG Encryption method registration
673 // GEOB GEO ID3FID_GENERALOBJECT General encapsulated object
674 // GRID ID3FID_GROUPINGREG Group identification registration
675 // IPLS IPL ID3FID_INVOLVEDPEOPLE Involved people list
676 // LINK LNK ID3FID_LINKEDINFO Linked information
677 // PCNT CNT ID3FID_PLAYCOUNTER Play counter
678 // POPM POP ID3FID_POPULARIMETER Popularimeter
679 // PRIV ID3FID_PRIVATE Private frame
680 // SYLT SLT ID3FID_SYNCEDLYRICS Synchronized lyric/text
681 // TALB TAL ID3FID_ALBUM Album/Movie/Show title
682 // TBPM TBP ID3FID_BPM BPM (beats per minute)
683 // TCOM TCM ID3FID_COMPOSER Composer
684 // TCON TCO ID3FID_CONTENTTYPE Content type
685 // TCOP TCR ID3FID_COPYRIGHT Copyright message
686 // TDAT TDA ID3FID_DATE Date
687 // TDLY TDY ID3FID_PLAYLISTDELAY Playlist delay
688 // TENC TEN ID3FID_ENCODEDBY Encoded by
689 // TEXT TXT ID3FID_LYRICIST Lyricist/Text writer
690 // TFLT TFT ID3FID_FILETYPE File type
691 // TIME TKE ID3FID_TIME Time
692 // TIT1 TIM ID3FID_CONTENTGROUP Content group description
693 // TIT2 TT1 ID3FID_TITLE Title/songname/content description
694 // TIT3 TT2 ID3FID_SUBTITLE Subtitle/Description refinement
695 // TKEY TT3 ID3FID_INITIALKEY Initial key
696 // TLAN TLA ID3FID_LANGUAGE Language(s)
697 // TLEN TLE ID3FID_SONGLEN Length
698 // TMED TMT ID3FID_MEDIATYPE Media type
699 // TOAL TOT ID3FID_ORIGALBUM Original album/movie/show title
700 // TOFN TOF ID3FID_ORIGFILENAME Original filename
701 // TOLY TOL ID3FID_ORIGLYRICIST Original lyricist(s)/text writer(s)
702 // TOPE TOA ID3FID_ORIGARTIST Original artist(s)/performer(s)
703 // TORY TOR ID3FID_ORIGYEAR Original release year
704 // TOWN ID3FID_FILEOWNER File owner/licensee
705 // TPE1 TP1 ID3FID_LEADARTIST Lead performer(s)/Soloist(s)
706 // TPE2 TP2 ID3FID_BAND Band/orchestra/accompaniment
707 // TPE3 TP3 ID3FID_CONDUCTOR Conductor/performer refinement
708 // TPE4 TP4 ID3FID_MIXARTIST Interpreted, remixed, or otherwise modified
709 // TPOS TPA ID3FID_PARTINSET Part of a set
710 // TPUB TPB ID3FID_PUBLISHER Publisher
711 // TRCK TRK ID3FID_TRACKNUM Track number/Position in set
712 // TRDA TRD ID3FID_RECORDINGDATES Recording dates
713 // TRSN TRN ID3FID_NETRADIOSTATION Internet radio station name
714 // TRSO TRO ID3FID_NETRADIOOWNER Internet radio station owner
715 // TSIZ TSI ID3FID_SIZE Size
716 // TSRC TRC ID3FID_ISRC ISRC (international standard recording code)
717 // TSSE TSS ID3FID_ENCODERSETTINGS Software/Hardware and encoding settings
718 // TXXX TXX ID3FID_USERTEXT User defined text information
719 // TYER TYE ID3FID_YEAR Year
720 // UFID UFI ID3FID_UNIQUEFILEID Unique file identifier
721 // USER ID3FID_TERMSOFUSE Terms of use
722 // USLT ULT ID3FID_UNSYNCEDLYRICS Unsynchronized lyric/text transcription
723 // WCOM WCM ID3FID_WWWCOMMERCIALINFO Commercial information
724 // WCOP WCM ID3FID_WWWCOPYRIGHT Copyright/Legal infromation
725 // WOAF WCP ID3FID_WWWAUDIOFILE Official audio file webpage
726 // WOAR WAF ID3FID_WWWARTIST Official artist/performer webpage
727 // WOAS WAR ID3FID_WWWAUDIOSOURCE Official audio source webpage
728 // WORS WAS ID3FID_WWWRADIOPAGE Official internet radio station homepage
729 // WPAY WRA ID3FID_WWWPAYMENT Payment
730 // WPUB WPY ID3FID_WWWPUBLISHER Official publisher webpage
731 // WXXX WXX ID3FID_WWWUSER User defined URL link
732 // CDM ID3FID_METACOMPRESSION Compressed data meta frame
733
734 // **** Currently unimplemented frames
735 // AENC CRA ID3FID_AUDIOCRYPTO Audio encryption
736 // COMR ID3FID_COMMERCIAL Commercial frame
737 // EQUA EQU ID3FID_EQUALIZATION Equalization
738 // ETCO ETC ID3FID_EVENTTIMING Event timing codes
739 // MCDI MCI ID3FID_CDID Music CD identifier
740 // MLLT MLL ID3FID_MPEGLOOKUP MPEG location lookup table
741 // OWNE ID3FID_OWNERSHIP Ownership frame
742 // POSS ID3FID_POSITIONSYNC Position synchronisation frame
743 // RBUF BUF ID3FID_BUFFERSIZE Recommended buffer size
744 // RVAD RVA ID3FID_VOLUMEADJ Relative volume adjustment
745 // RVRB REV ID3FID_REVERB Reverb
746 // SYTC STC ID3FID_SYNCEDTEMPO Synchronized tempo codes
747 // CRM ID3FID_METACRYPTO Encrypted meta frame
748 static ID3_FrameDef ID3_FrameDefs[] =
749 {
750 // short long tag file
751 // frame id id id discrd discrd field defs description
752 {ID3FID_AUDIOCRYPTO, "CRA", "AENC", false, false, ID3FD_Unimplemented, "Audio encryption"},
753 {ID3FID_PICTURE, "PIC", "APIC", false, false, ID3FD_Picture, "Attached picture"},
754 {ID3FID_COMMENT, "COM", "COMM", false, false, ID3FD_GeneralText, "Comments"},
755 {ID3FID_COMMERCIAL, "" , "COMR", false, false, ID3FD_Unimplemented, "Commercial"},
756 {ID3FID_CRYPTOREG, "" , "ENCR", false, false, ID3FD_Registration, "Encryption method registration"},
757 {ID3FID_EQUALIZATION, "EQU", "EQUA", false, true, ID3FD_Unimplemented, "Equalization"},
758 {ID3FID_EVENTTIMING, "ETC", "ETCO", false, true, ID3FD_Unimplemented, "Event timing codes"},
759 {ID3FID_GENERALOBJECT, "GEO", "GEOB", false, false, ID3FD_GEO, "General encapsulated object"},
760 {ID3FID_GROUPINGREG, "" , "GRID", false, false, ID3FD_Registration, "Group identification registration"},
761 {ID3FID_INVOLVEDPEOPLE, "IPL", "IPLS", false, false, ID3FD_InvolvedPeople,"Involved people list"},
762 {ID3FID_LINKEDINFO, "LNK", "LINK", false, false, ID3FD_LinkedInfo, "Linked information"},
763 {ID3FID_CDID, "MCI", "MCDI", false, false, ID3FD_Unimplemented, "Music CD identifier"},
764 {ID3FID_MPEGLOOKUP, "MLL", "MLLT", false, true, ID3FD_Unimplemented, "MPEG location lookup table"},
765 {ID3FID_OWNERSHIP, "" , "OWNE", false, false, ID3FD_Unimplemented, "Ownership frame"},
766 {ID3FID_PRIVATE, "" , "PRIV", false, false, ID3FD_Private, "Private frame"},
767 {ID3FID_PLAYCOUNTER, "CNT", "PCNT", false, false, ID3FD_PlayCounter, "Play counter"},
768 {ID3FID_POPULARIMETER, "POP", "POPM", false, false, ID3FD_Popularimeter, "Popularimeter"},
769 {ID3FID_POSITIONSYNC, "" , "POSS", false, true, ID3FD_Unimplemented, "Position synchronisation frame"},
770 {ID3FID_BUFFERSIZE, "BUF", "RBUF", false, false, ID3FD_Unimplemented, "Recommended buffer size"},
771 {ID3FID_VOLUMEADJ, "RVA", "RVAD", false, true, ID3FD_Unimplemented, "Relative volume adjustment"},
772 {ID3FID_REVERB, "REV", "RVRB", false, false, ID3FD_Unimplemented, "Reverb"},
773 {ID3FID_SYNCEDLYRICS, "SLT", "SYLT", false, false, ID3FD_SyncLyrics, "Synchronized lyric/text"},
774 {ID3FID_SYNCEDTEMPO, "STC", "SYTC", false, true, ID3FD_Unimplemented, "Synchronized tempo codes"},
775 {ID3FID_ALBUM, "TAL", "TALB", false, false, ID3FD_Text, "Album/Movie/Show title"},
776 {ID3FID_BPM, "TBP", "TBPM", false, false, ID3FD_Text, "BPM (beats per minute)"},
777 {ID3FID_COMPOSER, "TCM", "TCOM", false, false, ID3FD_Text, "Composer"},
778 {ID3FID_CONTENTTYPE, "TCO", "TCON", false, false, ID3FD_Text, "Content type"},
779 {ID3FID_COPYRIGHT, "TCR", "TCOP", false, false, ID3FD_Text, "Copyright message"},
780 {ID3FID_DATE, "TDA", "TDAT", false, false, ID3FD_Text, "Date"},
781 {ID3FID_PLAYLISTDELAY, "TDY", "TDLY", false, false, ID3FD_Text, "Playlist delay"},
782 {ID3FID_ENCODEDBY, "TEN", "TENC", false, true, ID3FD_Text, "Encoded by"},
783 {ID3FID_LYRICIST, "TXT", "TEXT", false, false, ID3FD_Text, "Lyricist/Text writer"},
784 {ID3FID_FILETYPE, "TFT", "TFLT", false, false, ID3FD_Text, "File type"},
785 {ID3FID_TIME, "TIM", "TIME", false, false, ID3FD_Text, "Time"},
786 {ID3FID_CONTENTGROUP, "TT1", "TIT1", false, false, ID3FD_Text, "Content group description"},
787 {ID3FID_TITLE, "TT2", "TIT2", false, false, ID3FD_Text, "Title/songname/content description"},
788 {ID3FID_SUBTITLE, "TT3", "TIT3", false, false, ID3FD_Text, "Subtitle/Description refinement"},
789 {ID3FID_INITIALKEY, "TKE", "TKEY", false, false, ID3FD_Text, "Initial key"},
790 {ID3FID_LANGUAGE, "TLA", "TLAN", false, false, ID3FD_Text, "Language(s)"},
791 {ID3FID_SONGLEN, "TLE", "TLEN", false, true, ID3FD_Text, "Length"},
792 {ID3FID_MEDIATYPE, "TMT", "TMED", false, false, ID3FD_Text, "Media type"},
793 {ID3FID_ORIGALBUM, "TOT", "TOAL", false, false, ID3FD_Text, "Original album/movie/show title"},
794 {ID3FID_ORIGFILENAME, "TOF", "TOFN", false, false, ID3FD_Text, "Original filename"},
795 {ID3FID_ORIGLYRICIST, "TOL", "TOLY", false, false, ID3FD_Text, "Original lyricist(s)/text writer(s)"},
796 {ID3FID_ORIGARTIST, "TOA", "TOPE", false, false, ID3FD_Text, "Original artist(s)/performer(s)"},
797 {ID3FID_ORIGYEAR, "TOR", "TORY", false, false, ID3FD_Text, "Original release year"},
798 {ID3FID_FILEOWNER, "" , "TOWN", false, false, ID3FD_Text, "File owner/licensee"},
799 {ID3FID_LEADARTIST, "TP1", "TPE1", false, false, ID3FD_Text, "Lead performer(s)/Soloist(s)"},
800 {ID3FID_BAND, "TP2", "TPE2", false, false, ID3FD_Text, "Band/orchestra/accompaniment"},
801 {ID3FID_CONDUCTOR, "TP3", "TPE3", false, false, ID3FD_Text, "Conductor/performer refinement"},
802 {ID3FID_MIXARTIST, "TP4", "TPE4", false, false, ID3FD_Text, "Interpreted, remixed, or otherwise modified by"},
803 {ID3FID_PARTINSET, "TPA", "TPOS", false, false, ID3FD_Text, "Part of a set"},
804 {ID3FID_PUBLISHER, "TPB", "TPUB", false, false, ID3FD_Text, "Publisher"},
805 {ID3FID_TRACKNUM, "TRK", "TRCK", false, false, ID3FD_Text, "Track number/Position in set"},
806 {ID3FID_RECORDINGDATES, "TRD", "TRDA", false, false, ID3FD_Text, "Recording dates"},
807 {ID3FID_NETRADIOSTATION, "TRN", "TRSN", false, false, ID3FD_Text, "Internet radio station name"},
808 {ID3FID_NETRADIOOWNER, "TRO", "TRSO", false, false, ID3FD_Text, "Internet radio station owner"},
809 {ID3FID_SIZE, "TSI", "TSIZ", false, true, ID3FD_Text, "Size"},
810 {ID3FID_ISRC, "TRC", "TSRC", false, false, ID3FD_Text, "ISRC (international standard recording code)"},
811 {ID3FID_ENCODERSETTINGS, "TSS", "TSSE", false, false, ID3FD_Text, "Software/Hardware and settings used for encoding"},
812 {ID3FID_USERTEXT, "TXX", "TXXX", false, false, ID3FD_UserText, "User defined text information"},
813 {ID3FID_YEAR, "TYE", "TYER", false, false, ID3FD_Text, "Year"},
814 {ID3FID_UNIQUEFILEID, "UFI", "UFID", false, false, ID3FD_UFI, "Unique file identifier"},
815 {ID3FID_TERMSOFUSE, "" , "USER", false, false, ID3FD_TermsOfUse, "Terms of use"},
816 {ID3FID_UNSYNCEDLYRICS, "ULT", "USLT", false, false, ID3FD_GeneralText, "Unsynchronized lyric/text transcription"},
817 {ID3FID_WWWCOMMERCIALINFO, "WCM", "WCOM", false, false, ID3FD_URL, "Commercial information"},
818 {ID3FID_WWWCOPYRIGHT, "WCP", "WCOP", false, false, ID3FD_URL, "Copyright/Legal infromation"},
819 {ID3FID_WWWAUDIOFILE, "WAF", "WOAF", false, false, ID3FD_URL, "Official audio file webpage"},
820 {ID3FID_WWWARTIST, "WAR", "WOAR", false, false, ID3FD_URL, "Official artist/performer webpage"},
821 {ID3FID_WWWAUDIOSOURCE, "WAS", "WOAS", false, false, ID3FD_URL, "Official audio source webpage"},
822 {ID3FID_WWWRADIOPAGE, "WRA", "WORS", false, false, ID3FD_URL, "Official internet radio station homepage"},
823 {ID3FID_WWWPAYMENT, "WPY", "WPAY", false, false, ID3FD_URL, "Payment"},
824 {ID3FID_WWWPUBLISHER, "WPB", "WPUB", false, false, ID3FD_URL, "Official publisher webpage"},
825 {ID3FID_WWWUSER, "WXX", "WXXX", false, false, ID3FD_UserURL, "User defined URL link"},
826 {ID3FID_METACRYPTO, "CRM", "" , false, false, ID3FD_Unimplemented, "Encrypted meta frame"},
827 {ID3FID_METACOMPRESSION, "CDM", "" , false, false, ID3FD_CDM, "Compressed data meta frame"},
828 {ID3FID_NOFRAME}
829 };
830
888 ID3_FieldImpl::ID3_FieldImpl()
889 : _id(ID3FN_NOFIELD),
890 _type(ID3FTY_INTEGER),
891 _spec_begin(ID3V2_EARLIEST),
892 _spec_end(ID3V2_LATEST),
893 _flags(0),
894 _changed(false),
895 _fixed_size(0),
896 _num_items(0),
897 _enc(ID3TE_NONE)
898 {
899 this->Clear();
900 }
901
902 ID3_FieldImpl::ID3_FieldImpl(const ID3_FieldDef& def)
903 : _id(def._id),
904 _type(def._type),
905 _spec_begin(def._spec_begin),
906 _spec_end(def._spec_end),
907 _flags(def._flags),
908 _changed(false),
909 _fixed_size(def._fixed_size),
910 _num_items(0),
911 _enc((_type == ID3FTY_TEXTSTRING) ? ID3TE_ASCII : ID3TE_NONE)
912 {
913 this->Clear();
914 }
915
916 ID3_FieldImpl::~ID3_FieldImpl()
917 {
918 }
919
925 void ID3_FieldImpl::Clear()
926 {
927 switch (_type)
928 {
929 case ID3FTY_INTEGER:
930 {
931 _integer = 0;
932 break;
933 }
934 case ID3FTY_BINARY:
935 {
936 _binary.erase();
937 if (_fixed_size > 0)
938 {
939 _binary.assign(_fixed_size, '\0');
940 }
941 break;
942 }
943 case ID3FTY_TEXTSTRING:
944 {
945 _text.erase();
946 if (_fixed_size > 0)
947 {
948 if (this->GetEncoding() == ID3TE_UNICODE)
949 {
950 _text.assign(_fixed_size * 2, '\0');
951 }
952 else if (this->GetEncoding() == ID3TE_ASCII)
953 {
954 _text.assign(_fixed_size, '\0');
955 }
956 }
957 break;
958 }
959 default:
960 {
961 break;
962 }
963 }
964 _changed = true;
965
966 return ;
967 }
968
969 bool
970 ID3_FieldImpl::HasChanged() const
971 {
972 return _changed;
973 }
974
994 size_t ID3_FieldImpl::BinSize() const
995 {
996 if (_fixed_size > 0)
997 {
998 return _fixed_size;
999 }
1000 size_t size = this->Size();
1001 if (_type == ID3FTY_TEXTSTRING)
1002 {
1003 ID3_TextEnc enc = this->GetEncoding();
1004 if (enc == ID3TE_UNICODE && size > 0)
1005 {
1006 size++;
1007 }
1008 if (_flags & ID3FF_CSTR)
1009 {
1010 size++;
1011 }
1012 if (enc == ID3TE_UNICODE)
1013 {
1014 size *= 2;
1015 }
1016 }
1017 return size;
1018 }
1019
1020 size_t ID3_FieldImpl::Size() const
1021 {
1022 size_t size = 0;
1023 // check to see if we are within the legal limit for this field 0 means
1024 // arbitrary length field
1025 if (_fixed_size > 0)
1026 {
1027 size = _fixed_size;
1028 }
1029 else if (_type == ID3FTY_INTEGER)
1030 {
1031 size = sizeof(uint32);
1032 }
1033 else if (_type == ID3FTY_TEXTSTRING)
1034 {
1035 size = _text.size();
1036 }
1037 else
1038 {
1039 size = _binary.size();
1040 }
1041
1042 return size;
1043 }
1044
1045 bool ID3_FieldImpl::Parse(ID3_Reader& reader)
1046 {
1047 bool success = false;
1048 switch (this->GetType())
1049 {
1050 case ID3FTY_INTEGER:
1051 {
1052 success = this->ParseInteger(reader);
1053 break;
1054 }
1055
1056 case ID3FTY_BINARY:
1057 {
1058 success = this->ParseBinary(reader);
1059 break;
1060 }
1061
1062 case ID3FTY_TEXTSTRING:
1063 {
1064 success = this->ParseText(reader);
1065 break;
1066 }
1067
1068 default:
1069 {
1070 ID3D_WARNING( "ID3_FieldImpl::Parse(): unknown field type" );
1071 break;
1072 }
1073 }
1074 return success;
1075 }
1076
1077 ID3_FrameDef* ID3_FindFrameDef(ID3_FrameID id)
1078 {
1079 ID3_FrameDef *info = NULL;
1080
1081 for (size_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; ++cur)
1082 {
1083 if (ID3_FrameDefs[cur].eID == id)
1084 {
1085 info = &ID3_FrameDefs[cur];
1086 break;
1087 }
1088 }
1089
1090 return info;
1091 }
1092
1093 ID3_FrameID
1094 ID3_FindFrameID(const char *id)
1095 {
1096 ID3_FrameID fid = ID3FID_NOFRAME;
1097 const int slen = strlen(id);
1098
1099 for (size_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; ++cur)
1100 {
1101 if (((strcmp(ID3_FrameDefs[cur].sShortTextID, id) == 0) &&
1102 slen == 3) ||
1103 ((strcmp(ID3_FrameDefs[cur].sLongTextID, id) == 0) &&
1104 slen == 4))
1105 {
1106 fid = ID3_FrameDefs[cur].eID;
1107 break;
1108 }
1109 }
1110
1111 return fid;
1112 }
1113
1114 void ID3_FieldImpl::Render(ID3_Writer& writer) const
1115 {
1116 switch (this->GetType())
1117 {
1118 case ID3FTY_INTEGER:
1119 {
1120 RenderInteger(writer);
1121 break;
1122 }
1123
1124 case ID3FTY_BINARY:
1125 {
1126 RenderBinary(writer);
1127 break;
1128 }
1129
1130 case ID3FTY_TEXTSTRING:
1131 {
1132 RenderText(writer);
1133 break;
1134 }
1135
1136 default:
1137 {
1138 ID3D_WARNING ( "ID3D_FieldImpl::Render(): unknown field type" );
1139 break;
1140 }
1141 }
1142 }
1143
1144 ID3_Field &
1145 ID3_FieldImpl::operator=( const ID3_Field &rhs )
1146 {
1147 const ID3_FieldImpl* fld = (const ID3_FieldImpl*) &rhs;
1148 if (this != &rhs && this->GetType() == fld->GetType())
1149 {
1150 switch (fld->GetType())
1151 {
1152 case ID3FTY_INTEGER:
1153 {
1154 this->SetInteger(fld->GetInteger());
1155 break;
1156 }
1157 case ID3FTY_TEXTSTRING:
1158 {
1159 this->SetEncoding(fld->GetEncoding());
1160 this->SetText(fld->GetText());
1161 break;
1162 }
1163 case ID3FTY_BINARY:
1164 {
1165 this->SetBinary(fld->GetBinary());
1166 break;
1167 }
1168 default:
1169 {
1170 break;
1171 }
1172 }
1173 }
1174 return *this;
1175 }
1176
1177 bool ID3_FieldImpl::SetEncoding(ID3_TextEnc enc)
1178 {
1179 bool changed = this->IsEncodable() && (enc != this->GetEncoding()) &&
1180 (ID3TE_NONE < enc && enc < ID3TE_NUMENCODINGS);
1181 if (changed)
1182 {
1183 _text = convert(_text, _enc, enc);
1184 _enc = enc;
1185 _changed = true;
1186 }
1187 return changed;
1188 }
1189
1244 char *ID3_FrameInfo::ShortName(ID3_FrameID frameID)
1245 {
1246 ID3_FrameDef *pFD = ID3_FindFrameDef(frameID);
1247 if (pFD!=NULL)
1248 return pFD->sShortTextID;
1249 else
1250 return NULL;
1251 }
1252
1253 char *ID3_FrameInfo::LongName(ID3_FrameID frameID)
1254 {
1255 ID3_FrameDef *pFD = ID3_FindFrameDef(frameID);
1256 if (pFD!=NULL)
1257 return pFD->sLongTextID;
1258 else
1259 return NULL;
1260 }
1261
1262 const char *ID3_FrameInfo::Description(ID3_FrameID frameID)
1263 {
1264 ID3_FrameDef *pFD = ID3_FindFrameDef(frameID);
1265 if (pFD!=NULL)
1266 return pFD->sDescription;
1267 else
1268 return NULL;
1269 }
1270
1271 int ID3_FrameInfo::MaxFrameID()
1272 {
1273 return ID3FID_LASTFRAMEID-1;
1274 }
1275
1276 int ID3_FrameInfo::NumFields(ID3_FrameID frameID)
1277 {
1278 int fieldnum=0;
1279 ID3_FrameDef *pFD = ID3_FindFrameDef(frameID);
1280 if (pFD!=NULL)
1281 {
1282 while (pFD->aeFieldDefs[fieldnum]._id != ID3FN_NOFIELD)
1283 {
1284 ++fieldnum;
1285 }
1286 }
1287 return fieldnum;
1288 }
1289
1290 ID3_FieldType ID3_FrameInfo::FieldType(ID3_FrameID frameID, int fieldnum)
1291 {
1292 ID3_FrameDef *pFD = ID3_FindFrameDef(frameID);
1293 if (pFD!=NULL)
1294 return (pFD->aeFieldDefs[fieldnum]._type);
1295 else
1296 return ID3FTY_NONE;
1297 }
1298
1299 size_t ID3_FrameInfo::FieldSize(ID3_FrameID frameID, int fieldnum)
1300 {
1301 ID3_FrameDef *pFD = ID3_FindFrameDef(frameID);
1302 if (pFD!=NULL)
1303 return (pFD->aeFieldDefs[fieldnum]._fixed_size);
1304 else
1305 return 0;
1306 }
1307
1308 flags_t ID3_FrameInfo::FieldFlags(ID3_FrameID frameID, int fieldnum)
1309 {
1310 ID3_FrameDef *pFD = ID3_FindFrameDef(frameID);
1311 if (pFD!=NULL)
1312 return (pFD->aeFieldDefs[fieldnum]._flags);
1313 else
1314 return 0;
1315 }
1316
ID3FID_WWWARTIST
Official artist/performer webpage.
Definition: globals.h:318
ID3FID_AUDIOCRYPTO
Audio encryption.
Definition: globals.h:232
ID3FF_TEXTLIST
Definition: globals.h:347
ID3FN_EMAIL
Email field.
Definition: globals.h:206
ID3_FieldImpl::BinSize
size_t BinSize() const
Definition: field.cpp:994
ID3TE_NUMENCODINGS
Definition: globals.h:144
ID3FID_BUFFERSIZE
Recommended buffer size.
Definition: globals.h:252
ID3FID_WWWCOPYRIGHT
Copyright/Legal infromation.
Definition: globals.h:316
ID3FID_ORIGLYRICIST
Original lyricist(s)/text writer(s)
Definition: globals.h:288
ID3FID_POSITIONSYNC
Position synchronisation frame.
Definition: globals.h:251
ID3_FrameInfo::FieldSize
size_t FieldSize(ID3_FrameID frameid, int fieldnum)
Definition: field.cpp:1299
ID3FID_BPM
BPM (beats per minute)
Definition: globals.h:261
ID3_FindFrameDef
ID3_FrameDef * ID3_FindFrameDef(ID3_FrameID id)
Definition: field.cpp:1077
ID3FID_MIXARTIST
Interpreted, remixed, or otherwise modified by.
Definition: globals.h:295
ID3FID_CONDUCTOR
Conductor/performer refinement.
Definition: globals.h:294
ID3_FrameDef::aeFieldDefs
const ID3_FieldDef * aeFieldDefs
Definition: frame_def.h:43
ID3_FieldImpl::RenderInteger
void RenderInteger(ID3_Writer &) const
Definition: field_integer.cpp:105
ID3_FrameDef
Definition: frame_def.h:36
ID3_FieldImpl::Render
void Render(ID3_Writer &) const
Definition: field.cpp:1114
ID3FID_ORIGFILENAME
Original filename.
Definition: globals.h:287
ID3TE_NONE
Definition: globals.h:139
ID3FN_VOLUMEADJ
Volume adjustment field.
Definition: globals.h:215
ID3FID_COMMENT
Comments.
Definition: globals.h:235
ID3FN_LANGUAGE
Language field.
Definition: globals.h:209
ID3FID_TITLE
Title/songname/content description.
Definition: globals.h:278
ID3FTY_NONE
Definition: globals.h:353
ID3FID_PRIVATE
Private frame.
Definition: globals.h:248
ID3FID_FILETYPE
File type.
Definition: globals.h:275
ID3FID_WWWPUBLISHER
Official publisher webpage.
Definition: globals.h:322
flags_t
uint16 flags_t
Definition: globals.h:118
ID3_FieldDef::_id
ID3_FieldID _id
Definition: field_def.h:35
ID3FID_SUBTITLE
Subtitle/Description refinement.
Definition: globals.h:279
ID3_FieldImpl::ParseText
bool ParseText(ID3_Reader &)
Definition: field_string_ascii.cpp:327
ID3FID_RECORDINGDATES
Recording dates.
Definition: globals.h:300
ID3FID_UNIQUEFILEID
Unique file identifier.
Definition: globals.h:312
ID3FID_ISRC
ISRC (international standard recording code)
Definition: globals.h:307
ID3FID_VOLUMEADJ
Relative volume adjustment.
Definition: globals.h:254
ID3FID_NETRADIOOWNER
Internet radio station owner.
Definition: globals.h:302
ID3FID_CONTENTGROUP
Content group description.
Definition: globals.h:277
ID3_FieldImpl::GetInteger
uint32 GetInteger() const
Definition: field_integer.cpp:77
ID3FID_TIME
Time.
Definition: globals.h:276
ID3FID_PICTURE
Attached picture.
Definition: globals.h:233
ID3FID_OWNERSHIP
Ownership frame.
Definition: globals.h:247
ID3FN_TIMESTAMPFORMAT
SYLT Timestamp Format.
Definition: globals.h:221
ID3FN_PEAKVOLRIGHT
Peak volume on the right channel.
Definition: globals.h:219
ID3_FieldImpl::SetEncoding
bool SetEncoding(ID3_TextEnc enc)
Definition: field.cpp:1177
ID3FF_ENCODABLE
Definition: globals.h:346
ID3FID_ORIGALBUM
Original album/movie/show title.
Definition: globals.h:286
ID3TE_UNICODE
Definition: globals.h:146
ID3FID_PARTINSET
Part of a set.
Definition: globals.h:296
ID3TE_ASCII
Definition: globals.h:145
ID3_FieldImpl::GetText
dami::String GetText() const
Definition: field_string_ascii.cpp:124
ID3_FieldImpl::~ID3_FieldImpl
~ID3_FieldImpl()
Definition: field.cpp:916
ID3FID_SYNCEDTEMPO
Synchronized tempo codes.
Definition: globals.h:259
ID3FID_DATE
Date.
Definition: globals.h:265
ID3FID_CONTENTTYPE
Content type.
Definition: globals.h:263
ID3FN_COUNTER
Counter field.
Definition: globals.h:213
ID3FID_NOFRAME
No known frame.
Definition: globals.h:231
ID3_FieldImpl::Clear
void Clear()
Clears any data and frees any memory associated with the field.
Definition: field.cpp:925
ID3FID_MEDIATYPE
Media type.
Definition: globals.h:284
ID3_FrameID
ID3_FrameID
Enumeration of the different types of frames recognized by id3lib.
Definition: globals.h:229
ID3FID_EQUALIZATION
Equalization.
Definition: globals.h:239
ID3_FieldImpl
Definition: field_impl.h:40
ID3FTY_TEXTSTRING
Definition: globals.h:356
ID3FID_LEADARTIST
Lead performer(s)/Soloist(s)
Definition: globals.h:292
ID3_FieldImpl::GetType
ID3_FieldType GetType() const
Definition: field_impl.h:103
utils.h
dami::convert
String ID3_C_EXPORT convert(String data, ID3_TextEnc, ID3_TextEnc)
Definition: utils.cpp:185
ID3_FrameInfo::MaxFrameID
int MaxFrameID()
Definition: field.cpp:1271
field_def.h
ID3_FieldDef::_type
ID3_FieldType _type
Definition: field_def.h:36
ID3FN_DESCRIPTION
Description field.
Definition: globals.h:204
ID3FID_PUBLISHER
Publisher.
Definition: globals.h:298
ID3_FrameInfo::LongName
char * LongName(ID3_FrameID frameid)
Definition: field.cpp:1253
ID3V2_EARLIEST
Definition: globals.h:168
ID3FN_CONTENTTYPE
SYLT content type.
Definition: globals.h:222
ID3_FieldDef::_flags
flags_t _flags
Definition: field_def.h:40
ID3_FieldType
ID3_FieldType
Enumeration of the types of field types.
Definition: globals.h:351
ID3FN_MIMETYPE
Mimetype field.
Definition: globals.h:212
ID3_FieldDef::_fixed_size
size_t _fixed_size
Definition: field_def.h:37
ID3FF_CSTR
Definition: globals.h:344
ID3FN_ID
Identifier/Symbol field.
Definition: globals.h:214
field_impl.h
ID3FID_TRACKNUM
Track number/Position in set.
Definition: globals.h:299
ID3_FrameInfo::FieldFlags
flags_t FieldFlags(ID3_FrameID frameid, int fieldnum)
Definition: field.cpp:1308
ID3_FieldImpl::ParseBinary
bool ParseBinary(ID3_Reader &)
Definition: field_binary.cpp:195
ID3FID_GROUPINGREG
Group identification registration.
Definition: globals.h:242
ID3_FieldImpl::RenderBinary
void RenderBinary(ID3_Writer &) const
Definition: field_binary.cpp:203
ID3_Reader
Definition: reader.h:33
ID3_FieldImpl::HasChanged
bool HasChanged() const
Definition: field.cpp:970
ID3_FrameDef::sLongTextID
char sLongTextID[4+1]
Definition: frame_def.h:40
ID3_FieldImpl::Parse
bool Parse(ID3_Reader &)
Definition: field.cpp:1045
ID3FID_WWWRADIOPAGE
Official internet radio station homepage.
Definition: globals.h:320
ID3_FieldDef::DEFAULT
static const ID3_FieldDef * DEFAULT
Definition: field_def.h:42
ID3_FieldImpl::GetEncoding
ID3_TextEnc GetEncoding() const
Definition: field_impl.h:105
ID3_TextEnc
ID3_TextEnc
Enumeration of the types of text encodings: ascii or unicode.
Definition: globals.h:137
ID3_FindFrameID
ID3_FrameID ID3_FindFrameID(const char *id)
Definition: field.cpp:1094
ID3FN_URL
A URL.
Definition: globals.h:202
ID3FID_ENCODERSETTINGS
Software/Hardware and settings used for encoding.
Definition: globals.h:308
ID3_FieldImpl::SetBinary
size_t SetBinary(dami::BString)
Copies the supplied unicode string to the field.
Definition: field_binary.cpp:55
ID3FID_EVENTTIMING
Event timing codes.
Definition: globals.h:240
ID3_FrameDef::eID
ID3_FrameID eID
Definition: frame_def.h:38
ID3FID_YEAR
Year.
Definition: globals.h:311
ID3V2_3_0
Definition: globals.h:166
ID3_FieldImpl::SetInteger
void SetInteger(uint32)
Definition: field_integer.cpp:52
ID3_FieldImpl::SetText
size_t SetText(dami::String)
Definition: field_string_ascii.cpp:189
ID3_FrameDef::sShortTextID
char sShortTextID[3+1]
Definition: frame_def.h:39
ID3FID_SYNCEDLYRICS
Synchronized lyric/text.
Definition: globals.h:258
ID3FID_SIZE
Size.
Definition: globals.h:303
ID3FID_WWWAUDIOFILE
Official audio file webpage.
Definition: globals.h:317
ID3FN_VOLCHGLEFT
Volume chage on the left channel.
Definition: globals.h:218
ID3FID_WWWCOMMERCIALINFO
Commercial information.
Definition: globals.h:315
ID3FID_REVERB
Reverb.
Definition: globals.h:255
ID3FID_ORIGYEAR
Original release year.
Definition: globals.h:290
ID3FID_ENCODEDBY
Encoded by.
Definition: globals.h:273
ID3FN_TEXTENC
Text encoding (unicode or ASCII)
Definition: globals.h:200
ID3FN_IMAGEFORMAT
Image format field.
Definition: globals.h:211
ID3FID_WWWUSER
User defined URL link.
Definition: globals.h:323
ID3FID_TERMSOFUSE
Terms of use.
Definition: globals.h:313
ID3FID_WWWAUDIOSOURCE
Official audio source webpage.
Definition: globals.h:319
ID3FID_INITIALKEY
Initial key.
Definition: globals.h:280
ID3FN_PEAKVOLLEFT
Peak volume on the left channel.
Definition: globals.h:220
ID3FID_LASTFRAMEID
Last field placeholder.
Definition: globals.h:326
frame_def.h
ID3_FieldImpl::operator=
ID3_Field & operator=(uint32 val)
A shortcut for the Set method.
Definition: field_impl.h:53
ID3_FrameInfo::FieldType
ID3_FieldType FieldType(ID3_FrameID frameid, int fieldnum)
Definition: field.cpp:1290
ID3FID_ORIGARTIST
Original artist(s)/performer(s)
Definition: globals.h:289
ID3FID_CRYPTOREG
Encryption method registration.
Definition: globals.h:237
ID3_FieldImpl::GetBinary
dami::BString GetBinary() const
Definition: field_binary.cpp:81
ID3FID_GENERALOBJECT
General encapsulated object.
Definition: globals.h:241
ID3_FieldImpl::IsEncodable
bool IsEncodable() const
Definition: field_impl.h:106
ID3_FrameDef::sDescription
const char * sDescription
Definition: frame_def.h:44
ID3FN_OWNER
Owner field.
Definition: globals.h:205
ID3_FrameInfo::NumFields
int NumFields(ID3_FrameID frameid)
Definition: field.cpp:1276
ID3FID_USERTEXT
User defined text information.
Definition: globals.h:310
ID3FN_DATA
Data field.
Definition: globals.h:203
ID3FN_VOLCHGRIGHT
Volume chage on the right channel.
Definition: globals.h:217
ID3FID_BAND
Band/orchestra/accompaniment.
Definition: globals.h:293
ID3FN_NUMBITS
Number of bits field.
Definition: globals.h:216
ID3FID_WWWPAYMENT
Payment.
Definition: globals.h:321
ID3FID_LINKEDINFO
Linked information.
Definition: globals.h:244
ID3FN_NOFIELD
No field.
Definition: globals.h:199
NULL
#define NULL
Definition: globals.h:743
ID3V2_2_1
Definition: globals.h:165
ID3FF_NONE
Definition: globals.h:343
ID3FID_METACOMPRESSION
Compressed meta frame (id3v2.2.1)
Definition: globals.h:325
ID3_FieldDef
Definition: field_def.h:33
ID3FID_NETRADIOSTATION
Internet radio station name.
Definition: globals.h:301
ID3FID_LYRICIST
Lyricist/Text writer.
Definition: globals.h:274
ID3FN_RATING
Rating field.
Definition: globals.h:207
ID3_Field
The representative class of an ID3v2 field.
Definition: field.h:36
ID3FID_INVOLVEDPEOPLE
Involved people list.
Definition: globals.h:243
ID3_Writer
Definition: writer.h:33
ID3_FrameInfo::Description
const char * Description(ID3_FrameID frameid)
Definition: field.cpp:1262
ID3FID_PLAYLISTDELAY
Playlist delay.
Definition: globals.h:267
ID3FID_COPYRIGHT
Copyright message.
Definition: globals.h:264
ID3_FrameInfo::ShortName
char * ShortName(ID3_FrameID frameid)
Definition: field.cpp:1244
ID3FN_PICTURETYPE
Picture type field.
Definition: globals.h:210
ID3FID_MPEGLOOKUP
MPEG location lookup table.
Definition: globals.h:246
ID3_FieldImpl::Size
size_t Size() const
Returns the size of a field.
Definition: field.cpp:1020
ID3FID_POPULARIMETER
Popularimeter.
Definition: globals.h:250
ID3FID_CDID
Music CD identifier.
Definition: globals.h:245
readers.h
ID3FID_COMMERCIAL
Commercial frame.
Definition: globals.h:236
ID3_FieldImpl::RenderText
void RenderText(ID3_Writer &) const
Definition: field_string_ascii.cpp:376
ID3FID_ALBUM
Album/Movie/Show title.
Definition: globals.h:260
ID3FID_SONGLEN
Length.
Definition: globals.h:282
ID3_FieldImpl::ParseInteger
bool ParseInteger(ID3_Reader &)
Definition: field_integer.cpp:87
ID3FID_UNSYNCEDLYRICS
Unsynchronized lyric/text transcription.
Definition: globals.h:314
ID3FN_FILENAME
Filename field.
Definition: globals.h:208
ID3FID_METACRYPTO
Encrypted meta frame (id3v2.2.x)
Definition: globals.h:324
ID3FID_LANGUAGE
Language(s)
Definition: globals.h:281
ID3FID_FILEOWNER
File owner/licensee.
Definition: globals.h:291
ID3FN_TEXT
Text field.
Definition: globals.h:201
ID3FID_PLAYCOUNTER
Play counter.
Definition: globals.h:249
ID3FTY_INTEGER
Definition: globals.h:354
ID3FTY_BINARY
Definition: globals.h:355
ID3FID_COMPOSER
Composer.
Definition: globals.h:262
ID3V2_LATEST
Definition: globals.h:169