libavformat/id3v2.c File Reference

ID3v2 header parser. More...

#include "id3v2.h"
#include "id3v1.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avio_internal.h"

Go to the source code of this file.

Data Structures

struct  ID3v2EMFunc

Functions

int ff_id3v2_match (const uint8_t *buf, const char *magic)
 Detect ID3v2 Header.
int ff_id3v2_tag_len (const uint8_t *buf)
 Get the length of an ID3v2 tag.
static unsigned int get_size (AVIOContext *s, int len)
static void free_geobtag (void *obj)
 Free GEOB type extra metadata.
static int decode_str (AVFormatContext *s, AVIOContext *pb, int encoding, uint8_t **dst, int *maxread)
 Decode characters to UTF-8 according to encoding type.
static void read_ttag (AVFormatContext *s, AVIOContext *pb, int taglen, const char *key)
 Parse a text tag.
static void read_geobtag (AVFormatContext *s, AVIOContext *pb, int taglen, char *tag, ID3v2ExtraMeta **extra_meta)
 Parse GEOB tag into a ID3v2ExtraMetaGEOB struct.
static int is_number (const char *str)
static AVDictionaryEntryget_date_tag (AVDictionary *m, const char *tag)
static void merge_date (AVDictionary **m)
static const ID3v2EMFuncget_extra_meta_func (const char *tag, int isv34)
 Get the corresponding ID3v2EMFunc struct for a tag.
static void ff_id3v2_parse (AVFormatContext *s, int len, uint8_t version, uint8_t flags, ID3v2ExtraMeta **extra_meta)
void ff_id3v2_read_all (AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta)
 Read an ID3v2 tag, including supported extra metadata (currently only GEOB).
void ff_id3v2_read (AVFormatContext *s, const char *magic)
 Read an ID3v2 tag (text tags only).
void ff_id3v2_free_extra_meta (ID3v2ExtraMeta **extra_meta)
 Free memory allocated parsing special (non-text) metadata.

Variables

const AVMetadataConv ff_id3v2_34_metadata_conv []
const AVMetadataConv ff_id3v2_4_metadata_conv []
static const AVMetadataConv id3v2_2_metadata_conv []
const char ff_id3v2_tags [][4]
 A list of text information frames allowed in both ID3 v2.3 and v2.4 http://www.id3.org/id3v2.4.0-frames http://www.id3.org/id3v2.4.0-changes.
const char ff_id3v2_4_tags [][4]
 ID3v2.4-only text information frames.
const char ff_id3v2_3_tags [][4]
 ID3v2.3-only text information frames.
static const ID3v2EMFunc id3v2_extra_meta_funcs []


Detailed Description

ID3v2 header parser.

Specifications available at: http://id3.org/Developer_Information

Definition in file id3v2.c.


Function Documentation

static int decode_str ( AVFormatContext s,
AVIOContext pb,
int  encoding,
uint8_t **  dst,
int *  maxread 
) [static]

Decode characters to UTF-8 according to encoding type.

The decoded buffer is always null terminated. Stop reading when either *maxread bytes are read from pb or U+0000 character is found.

Parameters:
dst Pointer where the address of the buffer with the decoded bytes is stored. Buffer must be freed by caller.
maxread Pointer to maximum number of characters to read from the AVIOContext. After execution the value is decremented by the number of bytes actually read.
Returns:
0 if no error occured, dst is uninitialized on error

Definition at line 154 of file id3v2.c.

Referenced by read_geobtag(), and read_ttag().

void ff_id3v2_free_extra_meta ( ID3v2ExtraMeta **  extra_meta  ) 

Free memory allocated parsing special (non-text) metadata.

Parameters:
extra_meta Pointer to a pointer to the head of a ID3v2ExtraMeta list, *extra_meta is set to NULL.

Definition at line 606 of file id3v2.c.

Referenced by oma_read_header().

int ff_id3v2_match ( const uint8_t *  buf,
const char *  magic 
)

Detect ID3v2 Header.

Parameters:
buf must be ID3v2_HEADER_SIZE byte long
magic magic bytes to identify the header. If in doubt, use ID3v2_DEFAULT_MAGIC.

Definition at line 96 of file id3v2.c.

Referenced by av_probe_input_format3(), ff_id3v2_read_all(), and oma_read_probe().

static void ff_id3v2_parse ( AVFormatContext s,
int  len,
uint8_t  version,
uint8_t  flags,
ID3v2ExtraMeta **  extra_meta 
) [static]

Definition at line 422 of file id3v2.c.

Referenced by ff_id3v2_read_all().

void ff_id3v2_read ( AVFormatContext s,
const char *  magic 
)

Read an ID3v2 tag (text tags only).

Definition at line 601 of file id3v2.c.

Referenced by avformat_open_input().

void ff_id3v2_read_all ( AVFormatContext s,
const char *  magic,
ID3v2ExtraMeta **  extra_meta 
)

Read an ID3v2 tag, including supported extra metadata (currently only GEOB).

Parameters:
extra_meta If not NULL, extra metadata is parsed into a list of ID3v2ExtraMeta structs and *extra_meta points to the head of the list

Definition at line 570 of file id3v2.c.

Referenced by ff_id3v2_read(), and oma_read_header().

int ff_id3v2_tag_len ( const uint8_t *  buf  ) 

Get the length of an ID3v2 tag.

Parameters:
buf must be ID3v2_HEADER_SIZE bytes long and point to the start of an already detected ID3v2 tag

Definition at line 109 of file id3v2.c.

Referenced by av_probe_input_format3(), and oma_read_probe().

static void free_geobtag ( void *  obj  )  [static]

Free GEOB type extra metadata.

Definition at line 132 of file id3v2.c.

Referenced by read_geobtag().

static AVDictionaryEntry* get_date_tag ( AVDictionary m,
const char *  tag 
) [static]

Definition at line 351 of file id3v2.c.

Referenced by merge_date().

static const ID3v2EMFunc* get_extra_meta_func ( const char *  tag,
int  isv34 
) [static]

Get the corresponding ID3v2EMFunc struct for a tag.

Parameters:
isv34 Determines if v2.2 or v2.3/4 strings are used
Returns:
A pointer to the ID3v2EMFunc struct if found, NULL otherwise.

Definition at line 408 of file id3v2.c.

Referenced by ff_id3v2_free_extra_meta(), and ff_id3v2_parse().

static unsigned int get_size ( AVIOContext s,
int  len 
) [static]

Definition at line 121 of file id3v2.c.

Referenced by ff_id3v2_parse().

static int is_number ( const char *  str  )  [static]

Definition at line 345 of file id3v2.c.

Referenced by get_date_tag().

static void merge_date ( AVDictionary **  m  )  [static]

Definition at line 360 of file id3v2.c.

Referenced by ff_id3v2_read_all().

static void read_geobtag ( AVFormatContext s,
AVIOContext pb,
int  taglen,
char *  tag,
ID3v2ExtraMeta **  extra_meta 
) [static]

Parse GEOB tag into a ID3v2ExtraMetaGEOB struct.

Definition at line 274 of file id3v2.c.

static void read_ttag ( AVFormatContext s,
AVIOContext pb,
int  taglen,
const char *  key 
) [static]

Parse a text tag.

Definition at line 232 of file id3v2.c.

Referenced by ff_id3v2_parse().


Variable Documentation

Initial value:

 {
    { "TALB", "album"},
    { "TCOM", "composer"},
    { "TCON", "genre"},
    { "TCOP", "copyright"},
    { "TENC", "encoded_by"},
    { "TIT2", "title"},
    { "TLAN", "language"},
    { "TPE1", "artist"},
    { "TPE2", "album_artist"},
    { "TPE3", "performer"},
    { "TPOS", "disc"},
    { "TPUB", "publisher"},
    { "TRCK", "track"},
    { "TSSE", "encoder"},
    { 0 }
}

Definition at line 36 of file id3v2.c.

Referenced by ff_id3v2_write().

const char ff_id3v2_3_tags[][4]

Initial value:

 {
   "TDAT", "TIME", "TORY", "TRDA", "TSIZ", "TYER",
   { 0 },
}
ID3v2.3-only text information frames.

Definition at line 91 of file id3v2.c.

Referenced by ff_id3v2_write().

Initial value:

 {
    { "TDRL", "date"},
    { "TDRC", "date"},
    { "TDEN", "creation_time"},
    { "TSOA", "album-sort"},
    { "TSOP", "artist-sort"},
    { "TSOT", "title-sort"},
    { 0 }
}

Definition at line 54 of file id3v2.c.

Referenced by ff_id3v2_write().

const char ff_id3v2_4_tags[][4]

Initial value:

 {
   "TDEN", "TDOR", "TDRC", "TDRL", "TDTG", "TIPL", "TMCL", "TMOO",
   "TPRO", "TSOA", "TSOP", "TSOT", "TSST",
   { 0 },
}
ID3v2.4-only text information frames.

Definition at line 85 of file id3v2.c.

Referenced by ff_id3v2_write().

const char ff_id3v2_tags[][4]

Initial value:

 {
   "TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDLY", "TENC", "TEXT",
   "TFLT", "TIT1", "TIT2", "TIT3", "TKEY", "TLAN", "TLEN", "TMED",
   "TOAL", "TOFN", "TOLY", "TOPE", "TOWN", "TPE1", "TPE2", "TPE3",
   "TPE4", "TPOS", "TPUB", "TRCK", "TRSN", "TRSO", "TSRC", "TSSE",
   { 0 },
}
A list of text information frames allowed in both ID3 v2.3 and v2.4 http://www.id3.org/id3v2.4.0-frames http://www.id3.org/id3v2.4.0-changes.

Definition at line 77 of file id3v2.c.

Referenced by ff_id3v2_write().

Initial value:

 {
    { "TAL",  "album"},
    { "TCO",  "genre"},
    { "TT2",  "title"},
    { "TEN",  "encoded_by"},
    { "TP1",  "artist"},
    { "TP2",  "album_artist"},
    { "TP3",  "performer"},
    { "TRK",  "track"},
    { 0 }
}

Definition at line 64 of file id3v2.c.

Initial value:

 {
    { "GEO", "GEOB", read_geobtag, free_geobtag },
    { NULL }
}

Definition at line 398 of file id3v2.c.


Generated on Fri Oct 26 02:43:52 2012 for FFmpeg by  doxygen 1.5.8