mirror of https://github.com/mpv-player/mpv
tags: add mp_tags_remove
This removes all tags matching the provided key. This will be used for removing metadata tags during encoding.
This commit is contained in:
parent
e530783cdb
commit
e2f71f509f
|
@ -18,6 +18,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <libavutil/dict.h>
|
#include <libavutil/dict.h>
|
||||||
#include "tags.h"
|
#include "tags.h"
|
||||||
#include "misc/bstr.h"
|
#include "misc/bstr.h"
|
||||||
|
@ -44,6 +45,24 @@ void mp_tags_set_bstr(struct mp_tags *tags, bstr key, bstr value)
|
||||||
tags->num_keys++;
|
tags->num_keys++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mp_tags_remove_str(struct mp_tags *tags, const char *key)
|
||||||
|
{
|
||||||
|
mp_tags_remove_bstr(tags, bstr0(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
void mp_tags_remove_bstr(struct mp_tags *tags, bstr key)
|
||||||
|
{
|
||||||
|
for (int n = 0; n < tags->num_keys; n++) {
|
||||||
|
if (bstrcasecmp0(key, tags->keys[n]) == 0) {
|
||||||
|
talloc_free(tags->keys[n]);
|
||||||
|
talloc_free(tags->values[n]);
|
||||||
|
int num_keys = tags->num_keys; // copy so it's only decremented once
|
||||||
|
MP_TARRAY_REMOVE_AT(tags->keys, num_keys, n);
|
||||||
|
MP_TARRAY_REMOVE_AT(tags->values, tags->num_keys, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *mp_tags_get_str(struct mp_tags *tags, const char *key)
|
char *mp_tags_get_str(struct mp_tags *tags, const char *key)
|
||||||
{
|
{
|
||||||
return mp_tags_get_bstr(tags, bstr0(key));
|
return mp_tags_get_bstr(tags, bstr0(key));
|
||||||
|
|
|
@ -11,6 +11,8 @@ struct mp_tags {
|
||||||
|
|
||||||
void mp_tags_set_str(struct mp_tags *tags, const char *key, const char *value);
|
void mp_tags_set_str(struct mp_tags *tags, const char *key, const char *value);
|
||||||
void mp_tags_set_bstr(struct mp_tags *tags, bstr key, bstr value);
|
void mp_tags_set_bstr(struct mp_tags *tags, bstr key, bstr value);
|
||||||
|
void mp_tags_remove_str(struct mp_tags *tags, const char *key);
|
||||||
|
void mp_tags_remove_bstr(struct mp_tags *tags, bstr key);
|
||||||
char *mp_tags_get_str(struct mp_tags *tags, const char *key);
|
char *mp_tags_get_str(struct mp_tags *tags, const char *key);
|
||||||
char *mp_tags_get_bstr(struct mp_tags *tags, bstr key);
|
char *mp_tags_get_bstr(struct mp_tags *tags, bstr key);
|
||||||
void mp_tags_clear(struct mp_tags *tags);
|
void mp_tags_clear(struct mp_tags *tags);
|
||||||
|
|
Loading…
Reference in New Issue