diff mbox

[FFmpeg-devel,v1] add show_demuxers and show_muxers

Message ID 20161104122025.14805-1-lq@chinaffmpeg.org
State Accepted
Commit acd87dfc05b5c4d8ebf6832fe7c0aa13b9cc0c5f
Headers show

Commit Message

Liu Steven Nov. 4, 2016, 12:20 p.m. UTC
add -muxers and -demuxers parameters to list the dexmuers and muxers

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 cmdutils.c             |   66 +++++++++++++++++++++++++++++++----------------
 cmdutils.h             |   14 ++++++++++
 cmdutils_common_opts.h |    2 +
 3 files changed, 59 insertions(+), 23 deletions(-)

Comments

Steven Liu Nov. 7, 2016, 1:45 p.m. UTC | #1
ping

2016-11-04 20:20 GMT+08:00 Steven Liu <lq@chinaffmpeg.org>:

> add -muxers and -demuxers parameters to list the dexmuers and muxers
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  cmdutils.c             |   66 ++++++++++++++++++++++++++++++
> +----------------
>  cmdutils.h             |   14 ++++++++++
>  cmdutils_common_opts.h |    2 +
>  3 files changed, 59 insertions(+), 23 deletions(-)
>
> diff --git a/cmdutils.c b/cmdutils.c
> index 469c2d5..44fe64c 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -75,6 +75,12 @@ static FILE *report_file;
>  static int report_file_level = AV_LOG_DEBUG;
>  int hide_banner = 0;
>
> +enum show_muxdemuxers {
> +    SHOW_DEFAULT,
> +    SHOW_DEMUXERS,
> +    SHOW_MUXERS,
> +};
> +
>  void init_opts(void)
>  {
>      av_dict_set(&sws_dict, "flags", "bicubic", 0);
> @@ -1251,7 +1257,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 +1275,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 !=SHOW_DEMUXERS) {
> +            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 != SHOW_MUXERS) {
> +            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 +1318,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, SHOW_DEFAULT);
> +}
> +
> +int show_muxers(void *optctx, const char *opt, const char *arg)
> +{
> +    return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS);
> +}
> +
> +int show_demuxers(void *optctx, const char *opt, const char *arg)
> +{
> +    return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS);
>  }
>
>  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, SHOW_DEFAULT);
>  }
>
>  #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" },
> --
> 1.7.1
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Michael Niedermayer Nov. 8, 2016, 12:56 a.m. UTC | #2
On Fri, Nov 04, 2016 at 08:20:25PM +0800, Steven Liu wrote:
> add -muxers and -demuxers parameters to list the dexmuers and muxers
> 
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  cmdutils.c             |   66 +++++++++++++++++++++++++++++++----------------
>  cmdutils.h             |   14 ++++++++++
>  cmdutils_common_opts.h |    2 +
>  3 files changed, 59 insertions(+), 23 deletions(-)

applied

thx

[...]
diff mbox

Patch

diff --git a/cmdutils.c b/cmdutils.c
index 469c2d5..44fe64c 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -75,6 +75,12 @@  static FILE *report_file;
 static int report_file_level = AV_LOG_DEBUG;
 int hide_banner = 0;
 
+enum show_muxdemuxers {
+    SHOW_DEFAULT,
+    SHOW_DEMUXERS,
+    SHOW_MUXERS,
+};
+
 void init_opts(void)
 {
     av_dict_set(&sws_dict, "flags", "bicubic", 0);
@@ -1251,7 +1257,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 +1275,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 !=SHOW_DEMUXERS) {
+            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 != SHOW_MUXERS) {
+            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 +1318,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, SHOW_DEFAULT);
+}
+
+int show_muxers(void *optctx, const char *opt, const char *arg)
+{
+    return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS);
+}
+
+int show_demuxers(void *optctx, const char *opt, const char *arg)
+{
+    return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS);
 }
 
 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, SHOW_DEFAULT);
 }
 
 #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" },