misc/winutils/include/libavutil/dict.h
author sheepluva
Sat, 29 Apr 2017 23:45:14 +0200
changeset 12383 e3d9abcc427a
parent 7813 7ac83d79b897
permissions -rw-r--r--
cmake: Fix SDL2 header version detection
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7813
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     1
/*
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     2
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     3
 * This file is part of Libav.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     4
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     5
 * Libav is free software; you can redistribute it and/or
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     7
 * License as published by the Free Software Foundation; either
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     8
 * version 2.1 of the License, or (at your option) any later version.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     9
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    10
 * Libav is distributed in the hope that it will be useful,
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    13
 * Lesser General Public License for more details.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    14
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    16
 * License along with Libav; if not, write to the Free Software
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    18
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    19
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    20
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    21
 * @file
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    22
 * Public dictionary API.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    23
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    24
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    25
#ifndef AVUTIL_DICT_H
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    26
#define AVUTIL_DICT_H
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    27
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    28
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    29
 * @addtogroup lavu_dict AVDictionary
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    30
 * @ingroup lavu_data
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    31
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    32
 * @brief Simple key:value store
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    33
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    34
 * @{
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    35
 * Dictionaries are used for storing key:value pairs. To create
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    36
 * an AVDictionary, simply pass an address of a NULL pointer to
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    37
 * av_dict_set(). NULL can be used as an empty dictionary wherever
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    38
 * a pointer to an AVDictionary is required.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    39
 * Use av_dict_get() to retrieve an entry or iterate over all
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    40
 * entries and finally av_dict_free() to free the dictionary
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    41
 * and all its contents.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    42
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    43
 * @code
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    44
 * AVDictionary *d = NULL;                // "create" an empty dictionary
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    45
 * av_dict_set(&d, "foo", "bar", 0);      // add an entry
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    46
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    47
 * char *k = av_strdup("key");            // if your strings are already allocated,
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    48
 * char *v = av_strdup("value");          // you can avoid copying them like this
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    49
 * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    50
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    51
 * AVDictionaryEntry *t = NULL;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    52
 * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    53
 *     <....>                             // iterate over all entries in d
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    54
 * }
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    55
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    56
 * av_dict_free(&d);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    57
 * @endcode
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    58
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    59
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    60
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    61
#define AV_DICT_MATCH_CASE      1
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    62
#define AV_DICT_IGNORE_SUFFIX   2
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    63
#define AV_DICT_DONT_STRDUP_KEY 4   /**< Take ownership of a key that's been
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    64
                                         allocated with av_malloc() and children. */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    65
#define AV_DICT_DONT_STRDUP_VAL 8   /**< Take ownership of a value that's been
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    66
                                         allocated with av_malloc() and chilren. */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    67
#define AV_DICT_DONT_OVERWRITE 16   ///< Don't overwrite existing entries.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    68
#define AV_DICT_APPEND         32   /**< If the entry already exists, append to it.  Note that no
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    69
                                      delimiter is added, the strings are simply concatenated. */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    70
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    71
typedef struct AVDictionaryEntry {
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    72
    char *key;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    73
    char *value;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    74
} AVDictionaryEntry;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    75
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    76
typedef struct AVDictionary AVDictionary;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    77
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    78
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    79
 * Get a dictionary entry with matching key.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    80
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    81
 * @param prev Set to the previous matching element to find the next.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    82
 *             If set to NULL the first matching element is returned.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    83
 * @param flags Allows case as well as suffix-insensitive comparisons.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    84
 * @return Found entry or NULL, changing key or value leads to undefined behavior.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    85
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    86
AVDictionaryEntry *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    87
av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    88
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    89
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    90
 * Get number of entries in dictionary.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    91
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    92
 * @param m dictionary
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    93
 * @return  number of entries in dictionary
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    94
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    95
int av_dict_count(const AVDictionary *m);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    96
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    97
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    98
 * Set the given entry in *pm, overwriting an existing entry.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    99
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   100
 * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   101
 * a dictionary struct is allocated and put in *pm.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   102
 * @param key entry key to add to *pm (will be av_strduped depending on flags)
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   103
 * @param value entry value to add to *pm (will be av_strduped depending on flags).
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   104
 *        Passing a NULL value will cause an existing entry to be deleted.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   105
 * @return >= 0 on success otherwise an error code <0
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   106
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   107
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   108
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   109
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   110
 * Copy entries from one AVDictionary struct into another.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   111
 * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   112
 *            this function will allocate a struct for you and put it in *dst
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   113
 * @param src pointer to source AVDictionary struct
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   114
 * @param flags flags to use when setting entries in *dst
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   115
 * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   116
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   117
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   118
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   119
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   120
 * Free all the memory allocated for an AVDictionary struct
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   121
 * and all keys and values.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   122
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   123
void av_dict_free(AVDictionary **m);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   124
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   125
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   126
 * @}
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   127
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   128
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   129
#endif /* AVUTIL_DICT_H */