FFmpeg  4.0
Functions
id3v2enc.c File Reference
#include <stdint.h>
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio.h"
#include "avio_internal.h"
#include "id3v2.h"

Go to the source code of this file.

Functions

static void id3v2_put_size (AVIOContext *pb, int size)
 
static int string_is_ascii (const uint8_t *str)
 
static void id3v2_encode_string (AVIOContext *pb, const uint8_t *str, enum ID3v2Encoding enc)
 
static int id3v2_put_ttag (ID3v2EncContext *id3, AVIOContext *avioc, const char *str1, const char *str2, uint32_t tag, enum ID3v2Encoding enc)
 Write a text frame with one (normal frames) or two (TXXX frames) strings according to encoding (only UTF-8 or UTF-16+BOM supported). More...
 
static int id3v2_put_priv (ID3v2EncContext *id3, AVIOContext *avioc, const char *key, const char *data)
 Write a priv frame with owner and data. More...
 
static int id3v2_check_write_tag (ID3v2EncContext *id3, AVIOContext *pb, AVDictionaryEntry *t, const char table[][4], enum ID3v2Encoding enc)
 
static void id3v2_3_metadata_split_date (AVDictionary **pm)
 
void ff_id3v2_start (ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version, const char *magic)
 Initialize an ID3v2 tag. More...
 
static int write_metadata (AVIOContext *pb, AVDictionary **metadata, ID3v2EncContext *id3, int enc)
 
static int write_chapter (AVFormatContext *s, ID3v2EncContext *id3, int id, int enc)
 
int ff_id3v2_write_metadata (AVFormatContext *s, ID3v2EncContext *id3)
 Convert and write all global metadata from s into an ID3v2 tag. More...
 
int ff_id3v2_write_apic (AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
 Write an attached picture from pkt into an ID3v2 tag. More...
 
void ff_id3v2_finish (ID3v2EncContext *id3, AVIOContext *pb, int padding_bytes)
 Finalize an opened ID3v2 tag. More...
 
int ff_id3v2_write_simple (struct AVFormatContext *s, int id3v2_version, const char *magic)
 Write an ID3v2 tag containing all global metadata from s. More...
 

Function Documentation

◆ id3v2_put_size()

static void id3v2_put_size ( AVIOContext pb,
int  size 
)
static

Definition at line 32 of file id3v2enc.c.

Referenced by ff_id3v2_finish(), ff_id3v2_write_apic(), id3v2_put_priv(), and id3v2_put_ttag().

◆ string_is_ascii()

static int string_is_ascii ( const uint8_t str)
static

Definition at line 40 of file id3v2enc.c.

Referenced by ff_id3v2_write_apic(), and id3v2_put_ttag().

◆ id3v2_encode_string()

static void id3v2_encode_string ( AVIOContext pb,
const uint8_t str,
enum ID3v2Encoding  enc 
)
static

Definition at line 46 of file id3v2enc.c.

Referenced by ff_id3v2_write_apic(), and id3v2_put_ttag().

◆ id3v2_put_ttag()

static int id3v2_put_ttag ( ID3v2EncContext id3,
AVIOContext avioc,
const char *  str1,
const char *  str2,
uint32_t  tag,
enum ID3v2Encoding  enc 
)
static

Write a text frame with one (normal frames) or two (TXXX frames) strings according to encoding (only UTF-8 or UTF-16+BOM supported).

Returns
number of bytes written or a negative error code.

Definition at line 65 of file id3v2enc.c.

Referenced by id3v2_check_write_tag(), and write_metadata().

◆ id3v2_put_priv()

static int id3v2_put_priv ( ID3v2EncContext id3,
AVIOContext avioc,
const char *  key,
const char *  data 
)
static

Write a priv frame with owner and data.

'key' is the owner prepended with ID3v2_PRIV_METADATA_PREFIX. 'data' is provided as a string. Any (where 'X' is a valid hex digit) will be unescaped to the byte value.

Definition at line 104 of file id3v2enc.c.

Referenced by write_metadata().

◆ id3v2_check_write_tag()

static int id3v2_check_write_tag ( ID3v2EncContext id3,
AVIOContext pb,
AVDictionaryEntry t,
const char  table[][4],
enum ID3v2Encoding  enc 
)
static

Definition at line 152 of file id3v2enc.c.

Referenced by write_metadata().

◆ id3v2_3_metadata_split_date()

static void id3v2_3_metadata_split_date ( AVDictionary **  pm)
static

Definition at line 167 of file id3v2enc.c.

Referenced by write_metadata().

◆ ff_id3v2_start()

void ff_id3v2_start ( ID3v2EncContext id3,
AVIOContext pb,
int  id3v2_version,
const char *  magic 
)

Initialize an ID3v2 tag.

Definition at line 205 of file id3v2enc.c.

Referenced by ff_id3v2_write_simple(), mp3_write_header(), and put_id3v2_tags().

◆ write_metadata()

static int write_metadata ( AVIOContext pb,
AVDictionary **  metadata,
ID3v2EncContext id3,
int  enc 
)
static

Definition at line 219 of file id3v2enc.c.

Referenced by ff_id3v2_write_metadata(), and write_chapter().

◆ write_chapter()

static int write_chapter ( AVFormatContext s,
ID3v2EncContext id3,
int  id,
int  enc 
)
static

Definition at line 258 of file id3v2enc.c.

Referenced by ff_id3v2_write_metadata().

◆ ff_id3v2_write_metadata()

int ff_id3v2_write_metadata ( AVFormatContext s,
ID3v2EncContext id3 
)

Convert and write all global metadata from s into an ID3v2 tag.

Definition at line 299 of file id3v2enc.c.

Referenced by ff_id3v2_write_simple(), mp3_write_header(), and put_id3v2_tags().

◆ ff_id3v2_write_apic()

int ff_id3v2_write_apic ( AVFormatContext s,
ID3v2EncContext id3,
AVPacket pkt 
)

Write an attached picture from pkt into an ID3v2 tag.

Definition at line 317 of file id3v2enc.c.

Referenced by mp3_write_packet(), and put_id3v2_tags().

◆ ff_id3v2_finish()

void ff_id3v2_finish ( ID3v2EncContext id3,
AVIOContext pb,
int  padding_bytes 
)

Finalize an opened ID3v2 tag.

Definition at line 386 of file id3v2enc.c.

Referenced by ff_id3v2_write_simple(), mp3_queue_flush(), mp3_write_header(), and put_id3v2_tags().

◆ ff_id3v2_write_simple()

int ff_id3v2_write_simple ( struct AVFormatContext s,
int  id3v2_version,
const char *  magic 
)

Write an ID3v2 tag containing all global metadata from s.

Parameters
id3v2_versionSubversion of ID3v2; supported values are 3 and 4
magicmagic bytes to identify the header If in doubt, use ID3v2_DEFAULT_MAGIC.

Definition at line 410 of file id3v2enc.c.

Referenced by adts_write_header(), and oma_write_header().