diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-14 00:41:08 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-14 00:41:21 +0200 |
commit | b8e4c11d93326cd86278d012c28e54dca0a06cef (patch) | |
tree | 96ed0fc1c7d5db348b532dd993710430290585a1 /libavformat/utils.c | |
parent | c8571c61ec4c352e7eac7147b7c1644d2406189e (diff) | |
parent | 481a3667495425db9fdffb653292b6460fb68208 (diff) | |
download | ffmpeg-b8e4c11d93326cd86278d012c28e54dca0a06cef.tar.gz |
Merge commit '481a3667495425db9fdffb653292b6460fb68208'
* commit '481a3667495425db9fdffb653292b6460fb68208':
cmdutils: allow matching by metadata in stream specifiers
Conflicts:
Changelog
cmdutils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 13d4c6b1ee..5bb56428f0 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4216,6 +4216,29 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, stream_id = strtol(spec, &endptr, 0); if (!*endptr) return stream_id == st->id; + } else if (*spec == 'm' && *(spec + 1) == ':') { + AVDictionaryEntry *tag; + char *key, *val; + int ret; + + spec += 2; + val = strchr(spec, ':'); + + key = val ? av_strndup(spec, val - spec) : av_strdup(spec); + if (!key) + return AVERROR(ENOMEM); + + tag = av_dict_get(st->metadata, key, NULL, 0); + if (tag) { + if (!val || !strcmp(tag->value, val + 1)) + ret = 1; + else + ret = 0; + } else + ret = 0; + + av_freep(&key); + return ret; } else if (!*spec) /* empty specifier, matches everything */ return 1; |