annotate ffmpeg/libavformat/id3v2.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * ID3v2 header parser
yading@11 3 * Copyright (c) 2003 Fabrice Bellard
yading@11 4 *
yading@11 5 * This file is part of FFmpeg.
yading@11 6 *
yading@11 7 * FFmpeg is free software; you can redistribute it and/or
yading@11 8 * modify it under the terms of the GNU Lesser General Public
yading@11 9 * License as published by the Free Software Foundation; either
yading@11 10 * version 2.1 of the License, or (at your option) any later version.
yading@11 11 *
yading@11 12 * FFmpeg is distributed in the hope that it will be useful,
yading@11 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 15 * Lesser General Public License for more details.
yading@11 16 *
yading@11 17 * You should have received a copy of the GNU Lesser General Public
yading@11 18 * License along with FFmpeg; if not, write to the Free Software
yading@11 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 20 */
yading@11 21
yading@11 22 #ifndef AVFORMAT_ID3V2_H
yading@11 23 #define AVFORMAT_ID3V2_H
yading@11 24
yading@11 25 #include <stdint.h>
yading@11 26 #include "avformat.h"
yading@11 27 #include "internal.h"
yading@11 28 #include "metadata.h"
yading@11 29
yading@11 30 #define ID3v2_HEADER_SIZE 10
yading@11 31
yading@11 32 /**
yading@11 33 * Default magic bytes for ID3v2 header: "ID3"
yading@11 34 */
yading@11 35 #define ID3v2_DEFAULT_MAGIC "ID3"
yading@11 36
yading@11 37 #define ID3v2_FLAG_DATALEN 0x0001
yading@11 38 #define ID3v2_FLAG_UNSYNCH 0x0002
yading@11 39 #define ID3v2_FLAG_ENCRYPTION 0x0004
yading@11 40 #define ID3v2_FLAG_COMPRESSION 0x0008
yading@11 41
yading@11 42 enum ID3v2Encoding {
yading@11 43 ID3v2_ENCODING_ISO8859 = 0,
yading@11 44 ID3v2_ENCODING_UTF16BOM = 1,
yading@11 45 ID3v2_ENCODING_UTF16BE = 2,
yading@11 46 ID3v2_ENCODING_UTF8 = 3,
yading@11 47 };
yading@11 48
yading@11 49 typedef struct ID3v2EncContext {
yading@11 50 int version; ///< ID3v2 minor version, either 3 or 4
yading@11 51 int64_t size_pos; ///< offset of the tag total size
yading@11 52 int len; ///< size of the tag written so far
yading@11 53 } ID3v2EncContext;
yading@11 54
yading@11 55 typedef struct ID3v2ExtraMeta {
yading@11 56 const char *tag;
yading@11 57 void *data;
yading@11 58 struct ID3v2ExtraMeta *next;
yading@11 59 } ID3v2ExtraMeta;
yading@11 60
yading@11 61 typedef struct ID3v2ExtraMetaGEOB {
yading@11 62 uint32_t datasize;
yading@11 63 uint8_t *mime_type;
yading@11 64 uint8_t *file_name;
yading@11 65 uint8_t *description;
yading@11 66 uint8_t *data;
yading@11 67 } ID3v2ExtraMetaGEOB;
yading@11 68
yading@11 69 typedef struct ID3v2ExtraMetaAPIC {
yading@11 70 AVBufferRef *buf;
yading@11 71 const char *type;
yading@11 72 uint8_t *description;
yading@11 73 enum AVCodecID id;
yading@11 74 } ID3v2ExtraMetaAPIC;
yading@11 75
yading@11 76 /**
yading@11 77 * Detect ID3v2 Header.
yading@11 78 * @param buf must be ID3v2_HEADER_SIZE byte long
yading@11 79 * @param magic magic bytes to identify the header.
yading@11 80 * If in doubt, use ID3v2_DEFAULT_MAGIC.
yading@11 81 */
yading@11 82 int ff_id3v2_match(const uint8_t *buf, const char *magic);
yading@11 83
yading@11 84 /**
yading@11 85 * Get the length of an ID3v2 tag.
yading@11 86 * @param buf must be ID3v2_HEADER_SIZE bytes long and point to the start of an
yading@11 87 * already detected ID3v2 tag
yading@11 88 */
yading@11 89 int ff_id3v2_tag_len(const uint8_t *buf);
yading@11 90
yading@11 91 /**
yading@11 92 * Read an ID3v2 tag, including supported extra metadata
yading@11 93 * @param extra_meta If not NULL, extra metadata is parsed into a list of
yading@11 94 * ID3v2ExtraMeta structs and *extra_meta points to the head of the list
yading@11 95 */
yading@11 96 void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta);
yading@11 97
yading@11 98 /**
yading@11 99 * Initialize an ID3v2 tag.
yading@11 100 */
yading@11 101 void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version,
yading@11 102 const char *magic);
yading@11 103
yading@11 104 /**
yading@11 105 * Convert and write all global metadata from s into an ID3v2 tag.
yading@11 106 */
yading@11 107 int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3);
yading@11 108
yading@11 109 /**
yading@11 110 * Write an attached picture from pkt into an ID3v2 tag.
yading@11 111 */
yading@11 112 int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt);
yading@11 113
yading@11 114 /**
yading@11 115 * Finalize an opened ID3v2 tag.
yading@11 116 */
yading@11 117 void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb);
yading@11 118
yading@11 119 /**
yading@11 120 * Write an ID3v2 tag containing all global metadata from s.
yading@11 121 * @param id3v2_version Subversion of ID3v2; supported values are 3 and 4
yading@11 122 * @param magic magic bytes to identify the header
yading@11 123 * If in doubt, use ID3v2_DEFAULT_MAGIC.
yading@11 124 */
yading@11 125 int ff_id3v2_write_simple(struct AVFormatContext *s, int id3v2_version, const char *magic);
yading@11 126
yading@11 127 /**
yading@11 128 * Free memory allocated parsing special (non-text) metadata.
yading@11 129 * @param extra_meta Pointer to a pointer to the head of a ID3v2ExtraMeta list, *extra_meta is set to NULL.
yading@11 130 */
yading@11 131 void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta);
yading@11 132
yading@11 133 /**
yading@11 134 * Create a stream for each APIC (attached picture) extracted from the
yading@11 135 * ID3v2 header.
yading@11 136 */
yading@11 137 int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
yading@11 138
yading@11 139 extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
yading@11 140 extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
yading@11 141
yading@11 142 /**
yading@11 143 * A list of text information frames allowed in both ID3 v2.3 and v2.4
yading@11 144 * http://www.id3.org/id3v2.4.0-frames
yading@11 145 * http://www.id3.org/id3v2.4.0-changes
yading@11 146 */
yading@11 147 extern const char ff_id3v2_tags[][4];
yading@11 148
yading@11 149 /**
yading@11 150 * ID3v2.4-only text information frames.
yading@11 151 */
yading@11 152 extern const char ff_id3v2_4_tags[][4];
yading@11 153
yading@11 154 /**
yading@11 155 * ID3v2.3-only text information frames.
yading@11 156 */
yading@11 157 extern const char ff_id3v2_3_tags[][4];
yading@11 158
yading@11 159 extern const CodecMime ff_id3v2_mime_tags[];
yading@11 160
yading@11 161 extern const char *ff_id3v2_picture_types[21];
yading@11 162
yading@11 163 #endif /* AVFORMAT_ID3V2_H */