DCL 4.0
Loading...
Searching...
No Matches
ID3v2Frame Class Reference

#include <ID3v2.h>

Inheritance diagram for ID3v2Frame:
Object

Public Member Functions

 ID3v2Frame (const ID3v2 &_tag)
uint32_t word (const char *_bytes, size_t _n)
size_t read (const char *_begin, const char *_end)
virtual String toString () const
const ID3v2tag () const
const String id () const
uint32_t size () const
short flags () const
char encoding () const
char type () const
const String & url () const
const String & description () const
const String & text () const
const ByteString & binary () const
Public Member Functions inherited from Object
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Protected Attributes

const ID3v2__tag
String __id
uint32_t __size
short __flags
char __encoding
char __type
String __url
String __description
String __text
ByteString __binary

Additional Inherited Members

Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Detailed Description

Definition at line 116 of file ID3v2.h.

Constructor & Destructor Documentation

◆ ID3v2Frame()

ID3v2Frame::ID3v2Frame ( const ID3v2 & _tag)

Member Function Documentation

◆ binary()

const ByteString & ID3v2Frame::binary ( ) const
inline

Definition at line 174 of file ID3v2.h.

174 {
175 return __binary;
176 }
ByteString __binary
Definition ID3v2.h:199

◆ description()

const String & ID3v2Frame::description ( ) const
inline

Definition at line 166 of file ID3v2.h.

166 {
167 return __description;
168 }
String __description
Definition ID3v2.h:197

◆ encoding()

char ID3v2Frame::encoding ( ) const
inline

Definition at line 154 of file ID3v2.h.

154 {
155 return __encoding;
156 }
char __encoding
Definition ID3v2.h:191

◆ flags()

short ID3v2Frame::flags ( ) const
inline

Definition at line 150 of file ID3v2.h.

150 {
151 return __flags;
152 }
short __flags
Definition ID3v2.h:188

◆ id()

const String ID3v2Frame::id ( ) const
inline

Definition at line 142 of file ID3v2.h.

142 {
143 return __id;
144 }
String __id
Definition ID3v2.h:183

◆ read()

size_t ID3v2Frame::read ( const char * _begin,
const char * _end )

Definition at line 383 of file ID3v2.cpp.

384{
385 size_t __6_OR_10__ = __tag.version() == 2 ? 6 : 10;
386 // 프레임 헤더를 읽는다.
387 // 최소 __6_OR_10__ bytes보다 커야 한다.
388 __DCL_ASSERT(_begin + __6_OR_10__ < _end);
389 char FIRST = *_begin;
390 if (__tag.version() == 2) {
391 __id = AsciiDecoder::decode(_begin, 3); // Frame ID 3 bytes
392 __size = word(_begin + 3, 3); // size 3 bytes
393 }
394 else {
395 // 2.3, 2.4
396 __id = AsciiDecoder::decode(_begin, 4); // Frame ID 4 bytes
397 __size = word(_begin + 4, 4); // size 4 bytes
398 __flags = *(_begin + 8); // flags 2 bytes
399 __flags = __flags << 8 | *(_begin + 9);
400 }
401
402#define __IF_ENCODING__ \
403 if (_begin < _end) { \
404 __encoding = *_begin++; \
405 }
406#define __IF_LANGUAGE__ \
407 if (_begin + 3 < _end && __valid_language_code(_begin)) { \
408 __url = AsciiDecoder::decode(_begin, 3).trim(); \
409 _begin += 3; \
410 }
411#define __IF_DESCRIPTION__ \
412 if (_begin < _end) { \
413 size_t n = __decode_length__(__encoding, _begin, _end - _begin); \
414 __description = decode(__encoding, _begin, n).trim(); \
415 _begin += __skip_length__(__encoding, n); \
416 }
417#define __IF_TEXT__ \
418 if (_begin < _end) { \
419 size_t n = __decode_length__(__encoding, _begin, _end - _begin); \
420 __text = decode(__encoding, _begin, n).trim(); \
421 _begin += __skip_length__(__encoding, n); \
422 }
423#define __IF_URL__ \
424 if (_begin < _end) { \
425 size_t n = ByteString::length(_begin, _end - _begin); \
426 __url = decode(0, _begin, n).trim(); \
427 _begin += n + 1; \
428 }
429#define __IF_TYPE__ \
430 if (_begin < _end) { \
431 __type = *_begin++; \
432 }
433#define __IF_BINARY__ \
434 if (_begin < _end) { \
435 __binary.assign(_begin, _end - _begin); \
436 }
437
438 _begin += __6_OR_10__;
439 _end = _begin + __size;
440 switch (FIRST) {
441 default: {
442 // "ENCR" "CRM" Owner identifier, Moehod symbol, Encryption data (b)
443 // "EQU2" "EQU" Interpolation method, Identification
444 // "ETCO" "ETC" Time stamp format
445 // "LINK" "LNK" Frame identifier, URL, ID
446 // "MCDI" "MCI" CD TOC
447 // "MLLT" "MLL" MPEG frames between reference, ...
448 // "OWNE" Text encoding, Price paid, ... Seller
449 // "RBUF" "BUF" Buffer size, Embedded info flag, Offset to next tag
450 // "RVA2" "RVA" Identification
451 // "RVRB" "REV" Reverb left (ms), ...
452 // "SEEK" Minium offset to next tag
453 // "SIGN" Group symbol, Signature (b)
454 // "SYLT" "SLT" Text encoding, Language, Time stamp format, ...
455 // "SYTC" "STC" Time stamp format, Temp data (b)
457 __DCL_TRACE3_N(L"[%ls][%zd][%ls]\n",
458 __id.data(), __size, String::toHexString(__binary, 40).data());
459 __DCL_TRACE1_N(L"[%ls]\n", String::tryString(__binary, 40).data());
460 break;
461 }
462 case 'A': {
463 if (__id == L"AENC") { // Audio encryption
464 __IF_URL__ // Owner identifier
465 __IF_BINARY__ // Preview start, Preview length, Encryption info
466 }
467 else if (__id == L"APIC") {
468 uint32_t dataLength = 0;
469 if (__flags & 0x01) {
470 dataLength = word(_begin, 4);
471 _begin += 4;
472 }
473 __DCL_TRACE4_N(L"[%ls][%d][%d][%ls]\n", __id.data(), __size,
474 dataLength, String::tryString(_begin, __size, 40).data());
476 __IF_URL__ // MIME type or URL
477 __IF_TYPE__ // Picture type
479 if (_begin < _end) {// Picture data
480 __binary.assign(_begin,
481 dataLength > 0 ? dataLength : _end - _begin);
482 }
483 }
484 else {
485 // ASPI
487 }
488 break;
489 }
490 case 'C': {
491 if (__id == L"COMM" || __id == L"COM") {
496 }
497 else if (__id == L"CRA") { // Audio encryption
498 __IF_URL__ // Owner identifier
499 __IF_BINARY__ // Preview start, Preview length, Encryption info
500 }
501 else {
502 // COMR
503 __IF_BINARY__ // Text encoding, Price string, ... Seller logo
504 }
505 break;
506 }
507 case 'G': {
508 if (__id == L"GEOB" || __id == L"GEO") {
510 __IF_URL__ // MIME type or URL
511 __IF_TEXT__ // Filename
513 __IF_BINARY__ // Encapsulated object
514 }
515 else {
516 // GRID
517 __IF_BINARY__ // Owner identifier, Group symbol, Group dependent data
518 }
519 break;
520 }
521 case 'P': {
522 if (__id == L"PIC") {
524 if (_begin < _end) {
525 __url = AsciiDecoder::decode(_begin, 3);
526 _begin += 3;
527 }
528 __IF_TYPE__ // Picture type
530 __IF_BINARY__ // Picture data
531 }
532 else if (__id == L"PRIV") {
533 __IF_URL__ // Owner identifier
534 __IF_BINARY__ // The private data (b)
535 }
536 else {
537 // "PCNT" "CNT" Counter
538 // "POPM" "POP" Email to user, Rating, Counter
539 // "POSS" Time stamp format, Position
541 }
542 break;
543 }
544 case 'I': {
545 if (__id.compare(L"IPL", 3) != 0) { // Involved people list
547 break;
548 }
549 // IPLS(3), IPL(2), TIPL(4)
550 }
551 case 'T': {
553 if (__id.compare(L"TXX", 3) == 0) {
555 }
557 break;
558 }
559 case 'U': {
560 // UFID USER USLT
561 if (__id.compare(L"UFI", 3) == 0) {
563 if (_begin < _end) {
564 // up to 64 bytes binary data
565 size_t n = _end - _begin;
566 __binary.assign(_begin, __MIN(64, n));
567 if (n <= 64) {
568 __text = String::tryString(__binary);
569 }
570 }
571 break;
572 }
575
576 if (__id == L"USLT" || __id == L"ULT") {
578 }
580 break;
581 }
582 case 'W': {
583 if (__id.compare(L"WXX", 3)) {
586 }
588 break;
589 }
590 }
591
592 // 프레임 데이터 크기 + 프레임 헤더 6 또는 10 bytes
593 return __size + __6_OR_10__;
594}
#define __DCL_TRACE1_N(fmt, arg)
#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
#define __IF_TYPE__
#define __IF_TEXT__
#define __IF_URL__
#define __IF_ENCODING__
#define __IF_DESCRIPTION__
#define __IF_LANGUAGE__
#define __IF_BINARY__
#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
Definition IFXField.cpp:41
#define __DCL_ASSERT(expr)
Definition Object.h:371
void CharsetConvertException *size_t n
Definition SQLField.cpp:253
static String decode(const char *_mbs, size_t _mbslen=(size_t) -1)
String __url
Definition ID3v2.h:196
uint32_t word(const char *_bytes, size_t _n)
Definition ID3v2.h:128
const ID3v2 & __tag
Definition ID3v2.h:180
String __text
Definition ID3v2.h:198
uint32_t __size
Definition ID3v2.h:186
size_t __MIN(size_t x, size_t y)
Definition size_t.h:27

◆ size()

uint32_t ID3v2Frame::size ( ) const
inline

Definition at line 146 of file ID3v2.h.

146 {
147 return __size;
148 }

◆ tag()

const ID3v2 & ID3v2Frame::tag ( ) const
inline

Definition at line 138 of file ID3v2.h.

138 {
139 return __tag;
140 }

◆ text()

const String & ID3v2Frame::text ( ) const
inline

Definition at line 170 of file ID3v2.h.

170 {
171 return __text;
172 }

◆ toString()

String ID3v2Frame::toString ( ) const
virtual

Reimplemented from Object.

Definition at line 596 of file ID3v2.cpp.

597{
598 StringBuilder sb(__id);
599 sb.format(L" size[%d] flags[%x] encoding[%d] type[%d]",
601 if (!__url.isEmpty()) {
602 sb.format(L" url[%ls]", __url.data());
603 }
604 if (!__description.isEmpty()) {
605 sb.format(L" description[%ls]", __description.data());
606 }
607 if (!__text.isEmpty()) {
608 sb.format(L" text[%ls]", __text.data());
609 }
610 if (!__binary.isEmpty()) {
611 sb.format(L" binary[%zd][%ls]", __binary.length(),
612 String::tryString(__binary, 40).data());
613 }
614 return sb;
615}
char __type
Definition ID3v2.h:193

◆ type()

char ID3v2Frame::type ( ) const
inline

Definition at line 158 of file ID3v2.h.

158 {
159 return __type;
160 }

◆ url()

const String & ID3v2Frame::url ( ) const
inline

Definition at line 162 of file ID3v2.h.

162 {
163 return __url;
164 }

◆ word()

uint32_t ID3v2Frame::word ( const char * _bytes,
size_t _n )
inline

Definition at line 128 of file ID3v2.h.

128 {
129 return __tag.fsbits() == 7 ?
130 ID3v2::word7(_bytes, _n)
131 : ID3v2::word8(_bytes, _n);
132 }

Member Data Documentation

◆ __binary

ByteString ID3v2Frame::__binary
protected

Definition at line 199 of file ID3v2.h.

◆ __description

String ID3v2Frame::__description
protected

Definition at line 197 of file ID3v2.h.

◆ __encoding

char ID3v2Frame::__encoding
protected

Definition at line 191 of file ID3v2.h.

◆ __flags

short ID3v2Frame::__flags
protected

Definition at line 188 of file ID3v2.h.

◆ __id

String ID3v2Frame::__id
protected

Definition at line 183 of file ID3v2.h.

◆ __size

uint32_t ID3v2Frame::__size
protected

Definition at line 186 of file ID3v2.h.

◆ __tag

const ID3v2& ID3v2Frame::__tag
protected

Definition at line 180 of file ID3v2.h.

◆ __text

String ID3v2Frame::__text
protected

Definition at line 198 of file ID3v2.h.

◆ __type

char ID3v2Frame::__type
protected

Definition at line 193 of file ID3v2.h.

◆ __url

String ID3v2Frame::__url
protected

Definition at line 196 of file ID3v2.h.


The documentation for this class was generated from the following files: