From patchwork Fri Nov 4 07:17:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 1285 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1177675vsb; Fri, 4 Nov 2016 00:17:59 -0700 (PDT) X-Received: by 10.28.232.23 with SMTP id f23mr1916582wmh.125.1478243878968; Fri, 04 Nov 2016 00:17:58 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i8si13558398wjt.187.2016.11.04.00.17.58; Fri, 04 Nov 2016 00:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 58647689AD3; Fri, 4 Nov 2016 09:17:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CC08A689A9F for ; Fri, 4 Nov 2016 09:17:44 +0200 (EET) X-QQ-mid: bizesmtp16t1478243844t183ojfj Received: from localhost (unknown [58.96.181.81]) by esmtp4.qq.com (ESMTP) with id ; Fri, 04 Nov 2016 15:17:24 +0800 (CST) X-QQ-SSF: 01100000002000F0F510000A0000000 X-QQ-FEAT: R/yWRekfFcovTnzmb6l2x/4YUHscVpEtshIkrdq2RlZQLRFaX9/xJ5loFlpR2 8YB9DHJa3IcdXLkYl/Ma0axtMvvJd0nnh9RvrSLlYRsMek2SLM4C2lJeJnbiIIYGO1mA71E gKwGLZH3njnry73ybgf8MhsfTT9Uw2qPf5ZMcDKRfyHyLWysR5tL+q3E2Ewqvc8sEnJ/uNa kBiniyGeGT2I8kMAboNAdpZPWpNsEKxRhAt5KrwOM2UStB8ouBM44LkRDazaZXdjdij4SLE zF5g== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Nov 2016 15:17:23 +0800 Message-Id: <20161104071723.13422-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] add show_demuxers and show_muxers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu , Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" add -muxers and -demuxers parameters to list the dexmuers and muxers Signed-off-by: Steven Liu --- cmdutils.c | 60 +++++++++++++++++++++++++++++++------------------- cmdutils.h | 14 ++++++++++++ cmdutils_common_opts.h | 2 ++ 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 469c2d5..63a46f3 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -1251,7 +1251,7 @@ static int is_device(const AVClass *avclass) return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category); } -static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only) +static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers) { AVInputFormat *ifmt = NULL; AVOutputFormat *ofmt = NULL; @@ -1269,29 +1269,33 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg, const char *name = NULL; const char *long_name = NULL; - while ((ofmt = av_oformat_next(ofmt))) { - is_dev = is_device(ofmt->priv_class); - if (!is_dev && device_only) - continue; - if ((!name || strcmp(ofmt->name, name) < 0) && - strcmp(ofmt->name, last_name) > 0) { - name = ofmt->name; - long_name = ofmt->long_name; - encode = 1; + if (muxdemuxers != 2) { + while ((ofmt = av_oformat_next(ofmt))) { + is_dev = is_device(ofmt->priv_class); + if (!is_dev && device_only) + continue; + if ((!name || strcmp(ofmt->name, name) < 0) && + strcmp(ofmt->name, last_name) > 0) { + name = ofmt->name; + long_name = ofmt->long_name; + encode = 1; + } } } - while ((ifmt = av_iformat_next(ifmt))) { - is_dev = is_device(ifmt->priv_class); - if (!is_dev && device_only) - continue; - if ((!name || strcmp(ifmt->name, name) < 0) && - strcmp(ifmt->name, last_name) > 0) { - name = ifmt->name; - long_name = ifmt->long_name; - encode = 0; + if (muxdemuxers != 1) { + while ((ifmt = av_iformat_next(ifmt))) { + is_dev = is_device(ifmt->priv_class); + if (!is_dev && device_only) + continue; + if ((!name || strcmp(ifmt->name, name) < 0) && + strcmp(ifmt->name, last_name) > 0) { + name = ifmt->name; + long_name = ifmt->long_name; + encode = 0; + } + if (name && strcmp(ifmt->name, name) == 0) + decode = 1; } - if (name && strcmp(ifmt->name, name) == 0) - decode = 1; } if (!name) break; @@ -1308,12 +1312,22 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg, int show_formats(void *optctx, const char *opt, const char *arg) { - return show_formats_devices(optctx, opt, arg, 0); + return show_formats_devices(optctx, opt, arg, 0, 0); +} + +int show_muxers(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 0, 1); +} + +int show_demuxers(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 0, 2); } int show_devices(void *optctx, const char *opt, const char *arg) { - return show_formats_devices(optctx, opt, arg, 1); + return show_formats_devices(optctx, opt, arg, 1, 0); } #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ diff --git a/cmdutils.h b/cmdutils.h index 1b96aa4..e75d8d3 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -442,6 +442,20 @@ int show_license(void *optctx, const char *opt, const char *arg); int show_formats(void *optctx, const char *opt, const char *arg); /** + * Print a listing containing all the muxers supported by the + * program (including devices). + * This option processing function does not utilize the arguments. + */ +int show_muxers(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the demuxer supported by the + * program (including devices). + * This option processing function does not utilize the arguments. + */ +int show_demuxers(void *optctx, const char *opt, const char *arg); + +/** * Print a listing containing all the devices supported by the * program. * This option processing function does not utilize the arguments. diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h index 758dac1..f7c1ca4 100644 --- a/cmdutils_common_opts.h +++ b/cmdutils_common_opts.h @@ -6,6 +6,8 @@ { "version" , OPT_EXIT, {.func_arg = show_version}, "show version" }, { "buildconf" , OPT_EXIT, {.func_arg = show_buildconf}, "show build configuration" }, { "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" }, + { "muxers" , OPT_EXIT, {.func_arg = show_muxers }, "show available muxers" }, + { "demuxers" , OPT_EXIT, {.func_arg = show_demuxers }, "show available demuxers" }, { "devices" , OPT_EXIT, {.func_arg = show_devices }, "show available devices" }, { "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" }, { "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" },