Simple key:value store. More...

Data Structures

struct  AVDictionaryEntry

Macros

#define AV_DICT_MATCH_CASE   1
#define AV_DICT_IGNORE_SUFFIX   2
#define AV_DICT_DONT_STRDUP_KEY   4
 Take ownership of a key that's been allocated with av_malloc() and children.
#define AV_DICT_DONT_STRDUP_VAL   8
 Take ownership of a value that's been allocated with av_malloc() and chilren.
#define AV_DICT_DONT_OVERWRITE   16
 Don't overwrite existing entries.
#define AV_DICT_APPEND   32
 If the entry already exists, append to it.

Typedefs

typedef struct AVDictionary AVDictionary

Functions

AVDictionaryEntryav_dict_get (AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
 Get a dictionary entry with matching key.
int av_dict_set (AVDictionary **pm, const char *key, const char *value, int flags)
 Set the given entry in *pm, overwriting an existing entry.
void av_dict_copy (AVDictionary **dst, AVDictionary *src, int flags)
 Copy entries from one AVDictionary struct into another.
void av_dict_free (AVDictionary **m)
 Free all the memory allocated for an AVDictionary struct and all keys and values.

Detailed Description

Simple key:value store.

Dictionaries are used for storing key:value pairs. To create an AVDictionary, simply pass an address of a NULL pointer to av_dict_set(). NULL can be used as an empty dictionary wherever a pointer to an AVDictionary is required. Use av_dict_get() to retrieve an entry or iterate over all entries and finally av_dict_free() to free the dictionary and all its contents.

AVDictionary *d = NULL; // "create" an empty dictionary
av_dict_set(&d, "foo", "bar", 0); // add an entry
char *k = av_strdup("key"); // if your strings are already allocated,
char *v = av_strdup("value"); // you can avoid copying them like this
while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
<....> // iterate over all entries in d
}

Macro Definition Documentation

#define AV_DICT_APPEND   32

If the entry already exists, append to it.

Note that no delimiter is added, the strings are simply concatenated.

Definition at line 68 of file dict.h.

Referenced by av_dict_set().

#define AV_DICT_DONT_OVERWRITE   16

Don't overwrite existing entries.

Definition at line 67 of file dict.h.

Referenced by av_dict_set(), copy_metadata(), new_output_stream(), opt_output_file(), read_ttag(), transcode(), and transcode_init().

#define AV_DICT_DONT_STRDUP_KEY   4

Take ownership of a key that's been allocated with av_malloc() and children.

Definition at line 63 of file dict.h.

Referenced by av_dict_set(), ff_vorbis_comment(), read_tag(), and read_ttag().

#define AV_DICT_DONT_STRDUP_VAL   8
#define AV_DICT_MATCH_CASE   1

Definition at line 61 of file dict.h.

Referenced by av_dict_get(), and get_date_tag().

Typedef Documentation

typedef struct AVDictionary AVDictionary

Definition at line 76 of file dict.h.

Function Documentation

void av_dict_copy ( AVDictionary **  dst,
AVDictionary src,
int  flags 
)

Copy entries from one AVDictionary struct into another.

Parameters
dstpointer to a pointer to a AVDictionary struct. If *dst is NULL, this function will allocate a struct for you and put it in *dst
srcpointer to source AVDictionary struct
flagsflags to use when setting entries in *dst
Note
metadata is read using the AV_DICT_IGNORE_SUFFIX flag

Definition at line 114 of file dict.c.

Referenced by avcodec_open2(), avformat_open_input(), avformat_write_header(), copy_chapters(), copy_metadata(), ff_wms_parse_sdp_a_line(), opt_output_file(), and transcode().

AVDictionaryEntry* av_dict_get ( AVDictionary m,
const char *  key,
const AVDictionaryEntry prev,
int  flags 
)
int av_dict_set ( AVDictionary **  pm,
const char *  key,
const char *  value,
int  flags 
)

Set the given entry in *pm, overwriting an existing entry.

Parameters
pmpointer to a pointer to a dictionary struct. If *pm is NULL a dictionary struct is allocated and put in *pm.
keyentry key to add to *pm (will be av_strduped depending on flags)
valueentry value to add to *pm (will be av_strduped depending on flags). Passing a NULL value will cause an existing tag to be deleted.
Returns
>= 0 on success otherwise an error code <0

Definition at line 50 of file dict.c.

Referenced by add_metadata(), amf_parse_object(), ape_tag_read_field(), applehttp_read_header(), asf_read_header(), av_dict_copy(), av_opt_set_dict(), avformat_find_stream_info(), avformat_write_header(), avi_metadata_creation_time(), avi_read_nikon(), avi_read_tag(), avpriv_new_chapter(), build_file_streams(), decode_info_header(), ff_metadata_conv(), ff_parse_mpeg2_descriptor(), ff_read_riff_info(), ff_rtp_chain_mux_open(), ff_sauce_read(), ff_vorbis_comment(), filter_codec_opts(), get_attachment(), get_meta(), get_metadata(), get_string(), get_tag(), http_prepare_data(), init_input_stream(), main(), matroska_convert_tag(), matroska_read_header(), merge_date(), mov_metadata_creation_time(), mov_metadata_gnre(), mov_metadata_int8_bypass_padding(), mov_metadata_int8_no_padding(), mov_metadata_track_or_disc_number(), mov_read_ftyp(), mov_read_mdhd(), mov_read_udta_string(), new_audio_stream(), new_output_stream(), new_subtitle_stream(), new_video_stream(), nsv_parse_NSVf_header(), ogm_chapter(), opt_default(), opt_input_file(), opt_metadata(), opt_output_file(), parse_chunks(), parse_tag(), prepare_sdp_description(), r3d_read_red1(), read_gab2_sub(), read_info_chunk(), read_tag(), read_ttag(), rm_read_metadata(), rpl_read_header(), sdt_cb(), smjpeg_read_header(), sox_read_header(), stream_component_open(), transcode_init(), try_decode_frame(), vqf_read_header(), and wc3_read_header().