1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Copyright (c) 2011 Reinhard Tartler 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 5cabdff1aSopenharmony_ci * of this software and associated documentation files (the "Software"), to deal 6cabdff1aSopenharmony_ci * in the Software without restriction, including without limitation the rights 7cabdff1aSopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8cabdff1aSopenharmony_ci * copies of the Software, and to permit persons to whom the Software is 9cabdff1aSopenharmony_ci * furnished to do so, subject to the following conditions: 10cabdff1aSopenharmony_ci * 11cabdff1aSopenharmony_ci * The above copyright notice and this permission notice shall be included in 12cabdff1aSopenharmony_ci * all copies or substantial portions of the Software. 13cabdff1aSopenharmony_ci * 14cabdff1aSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15cabdff1aSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16cabdff1aSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17cabdff1aSopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18cabdff1aSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19cabdff1aSopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20cabdff1aSopenharmony_ci * THE SOFTWARE. 21cabdff1aSopenharmony_ci */ 22cabdff1aSopenharmony_ci 23cabdff1aSopenharmony_ci/** 24cabdff1aSopenharmony_ci * @file 25cabdff1aSopenharmony_ci * Shows how the metadata API can be used in application programs. 26cabdff1aSopenharmony_ci * @example metadata.c 27cabdff1aSopenharmony_ci */ 28cabdff1aSopenharmony_ci 29cabdff1aSopenharmony_ci#include <stdio.h> 30cabdff1aSopenharmony_ci 31cabdff1aSopenharmony_ci#include <libavformat/avformat.h> 32cabdff1aSopenharmony_ci#include <libavutil/dict.h> 33cabdff1aSopenharmony_ci 34cabdff1aSopenharmony_ciint main (int argc, char **argv) 35cabdff1aSopenharmony_ci{ 36cabdff1aSopenharmony_ci AVFormatContext *fmt_ctx = NULL; 37cabdff1aSopenharmony_ci const AVDictionaryEntry *tag = NULL; 38cabdff1aSopenharmony_ci int ret; 39cabdff1aSopenharmony_ci 40cabdff1aSopenharmony_ci if (argc != 2) { 41cabdff1aSopenharmony_ci printf("usage: %s <input_file>\n" 42cabdff1aSopenharmony_ci "example program to demonstrate the use of the libavformat metadata API.\n" 43cabdff1aSopenharmony_ci "\n", argv[0]); 44cabdff1aSopenharmony_ci return 1; 45cabdff1aSopenharmony_ci } 46cabdff1aSopenharmony_ci 47cabdff1aSopenharmony_ci if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL))) 48cabdff1aSopenharmony_ci return ret; 49cabdff1aSopenharmony_ci 50cabdff1aSopenharmony_ci if ((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) { 51cabdff1aSopenharmony_ci av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n"); 52cabdff1aSopenharmony_ci return ret; 53cabdff1aSopenharmony_ci } 54cabdff1aSopenharmony_ci 55cabdff1aSopenharmony_ci while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) 56cabdff1aSopenharmony_ci printf("%s=%s\n", tag->key, tag->value); 57cabdff1aSopenharmony_ci 58cabdff1aSopenharmony_ci avformat_close_input(&fmt_ctx); 59cabdff1aSopenharmony_ci return 0; 60cabdff1aSopenharmony_ci} 61