Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 5/6] fftools: avradio support
Date: Sat, 22 Jul 2023 21:29:56 +0200
Message-ID: <20230722192957.703-5-michael@niedermayer.cc> (raw)
In-Reply-To: <20230722192957.703-1-michael@niedermayer.cc>

This avoids keeping diffs to fftools in the libavradio repository
---
 fftools/ffmpeg.c     |  7 +++++
 fftools/ffplay.c     |  6 ++++
 fftools/ffprobe.c    |  6 ++++
 fftools/opt_common.c | 66 ++++++++++++++++++++++++++++++++++++++++----
 fftools/opt_common.h | 27 ++++++++++++++++++
 5 files changed, 107 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 6130fd06fc..e9fbc8b636 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -95,6 +95,10 @@
 
 #include "libavdevice/avdevice.h"
 
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#endif
+
 #include "libswresample/swresample.h"
 
 #include "libavfilter/avfilter.h"
@@ -1331,6 +1335,9 @@ int main(int argc, char **argv)
 
 #if CONFIG_AVDEVICE
     avdevice_register_all();
+#endif
+#if CONFIG_AVRADIO
+    avradio_register_all();
 #endif
     avformat_network_init();
 
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 5212ad053e..f2e70b2de6 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -45,6 +45,9 @@
 #include "libavutil/bprint.h"
 #include "libavformat/avformat.h"
 #include "libavdevice/avdevice.h"
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#endif
 #include "libswscale/swscale.h"
 #include "libavutil/opt.h"
 #include "libavcodec/avfft.h"
@@ -3651,6 +3654,9 @@ int main(int argc, char **argv)
     /* register all codecs, demux and protocols */
 #if CONFIG_AVDEVICE
     avdevice_register_all();
+#endif
+#if CONFIG_AVRADIO
+    avradio_register_all();
 #endif
     avformat_network_init();
 
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a39185f6fe..51a0c2483b 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -56,6 +56,9 @@
 #include "libavutil/timestamp.h"
 #include "libavdevice/avdevice.h"
 #include "libavdevice/version.h"
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#endif
 #include "libswscale/swscale.h"
 #include "libswscale/version.h"
 #include "libswresample/swresample.h"
@@ -4109,6 +4112,9 @@ int main(int argc, char **argv)
 #if CONFIG_AVDEVICE
     avdevice_register_all();
 #endif
+#if CONFIG_AVRADIO
+    avradio_register_all();
+#endif
 
     show_banner(argc, argv, options);
     ret = parse_options(NULL, argc, argv, options, opt_input_file);
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 913932c914..f556d95afe 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -51,6 +51,11 @@
 #include "libavdevice/avdevice.h"
 #include "libavdevice/version.h"
 
+#if CONFIG_AVRADIO
+#include "libavradio/avradio.h"
+#include "libavradio/version.h"
+#endif
+
 #include "libavfilter/avfilter.h"
 #include "libavfilter/version.h"
 
@@ -187,6 +192,9 @@ static void print_all_libs_info(int flags, int level)
     PRINT_LIB_INFO(avutil,     AVUTIL,     flags, level);
     PRINT_LIB_INFO(avcodec,    AVCODEC,    flags, level);
     PRINT_LIB_INFO(avformat,   AVFORMAT,   flags, level);
+#if CONFIG_AVRADIO
+    PRINT_LIB_INFO(avradio,    AVRADIO,    flags, level);
+#endif
     PRINT_LIB_INFO(avdevice,   AVDEVICE,   flags, level);
     PRINT_LIB_INFO(avfilter,   AVFILTER,   flags, level);
     PRINT_LIB_INFO(swscale,    SWSCALE,    flags, level);
@@ -844,6 +852,13 @@ static int is_device(const AVClass *avclass)
     return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
 }
 
+static int is_radio(const AVClass *avclass)
+{
+    if (!avclass)
+        return 0;
+    return avclass->category == AV_CLASS_CATEGORY_RADIO_INPUT;
+}
+
 static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
 {
     void *ifmt_opaque = NULL;
@@ -851,12 +866,13 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
     void *ofmt_opaque = NULL;
     const AVOutputFormat *ofmt = NULL;
     const char *last_name;
-    int is_dev;
+    int is_dev, is_rad;
+    const char *name[3] = {"File formats:", "Devices:", "Radios:"};
 
     printf("%s\n"
            " D. = Demuxing supported\n"
            " .E = Muxing supported\n"
-           " --\n", device_only ? "Devices:" : "File formats:");
+           " --\n", name[device_only]);
     last_name = "000";
     for (;;) {
         int decode = 0;
@@ -868,7 +884,9 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
             ofmt_opaque = NULL;
             while ((ofmt = av_muxer_iterate(&ofmt_opaque))) {
                 is_dev = is_device(ofmt->priv_class);
-                if (!is_dev && device_only)
+                if (!is_dev && device_only == 1)
+                    continue;
+                if (device_only == 2)
                     continue;
                 if ((!name || strcmp(ofmt->name, name) < 0) &&
                     strcmp(ofmt->name, last_name) > 0) {
@@ -882,7 +900,10 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
             ifmt_opaque = NULL;
             while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) {
                 is_dev = is_device(ifmt->priv_class);
-                if (!is_dev && device_only)
+                is_rad = is_radio(ifmt->priv_class);
+                if (!is_dev && device_only == 1)
+                    continue;
+                if (!is_rad && device_only == 2)
                     continue;
                 if ((!name || strcmp(ifmt->name, name) < 0) &&
                     strcmp(ifmt->name, last_name) > 0) {
@@ -927,6 +948,11 @@ int show_devices(void *optctx, const char *opt, const char *arg)
     return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT);
 }
 
+int show_radios(void *optctx, const char *opt, const char *arg)
+{
+    return show_formats_devices(optctx, opt, arg, 2, SHOW_DEFAULT);
+}
+
 int show_protocols(void *optctx, const char *opt, const char *arg)
 {
     void *opaque = NULL;
@@ -1335,7 +1361,7 @@ static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts)
     int ret;
     AVDeviceInfoList *device_list = NULL;
 
-    if (!fmt || !fmt->priv_class  || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
+    if (!fmt || !fmt->priv_class  || (!AV_IS_INPUT_DEVICE(fmt->priv_class->category) && fmt->priv_class->category != AV_CLASS_CATEGORY_RADIO_INPUT))
         return AVERROR(EINVAL);
 
     printf("Auto-detected sources for %s:\n", fmt->name);
@@ -1468,3 +1494,33 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
     return ret;
 }
 #endif /* CONFIG_AVDEVICE */
+
+#if CONFIG_AVRADIO
+int show_radio_sources(void *optctx, const char *opt, const char *arg)
+{
+    const AVInputFormat *fmt = NULL;
+    char *dev = NULL;
+    AVDictionary *opts = NULL;
+    int ret = 0;
+    int error_level = av_log_get_level();
+
+    av_log_set_level(AV_LOG_WARNING);
+
+    if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
+        goto fail;
+
+    do {
+        fmt = av_input_radio_next(fmt);
+        if (fmt) {
+            if (dev && !av_match_name(dev, fmt->name))
+                continue;
+            print_device_sources(fmt, opts);
+        }
+    } while (fmt);
+  fail:
+    av_dict_free(&opts);
+    av_free(dev);
+    av_log_set_level(error_level);
+    return ret;
+}
+#endif /* CONFIG_AVRADIO */
diff --git a/fftools/opt_common.h b/fftools/opt_common.h
index ea1d16e769..b64ab07e10 100644
--- a/fftools/opt_common.h
+++ b/fftools/opt_common.h
@@ -39,6 +39,15 @@ int show_sinks(void *optctx, const char *opt, const char *arg);
 int show_sources(void *optctx, const char *opt, const char *arg);
 #endif
 
+#if CONFIG_AVRADIO
+/**
+ * Print a listing containing autodetected sources of the input radio.
+ * Device name with options may be passed as an argument to limit results.
+ */
+int show_radio_sources(void *optctx, const char *opt, const char *arg);
+#endif
+
+
 #if CONFIG_AVDEVICE
 #define CMDUTILS_COMMON_OPTIONS_AVDEVICE                                                                                \
     { "sources"    , OPT_EXIT | HAS_ARG, { .func_arg = show_sources },                                                  \
@@ -50,6 +59,15 @@ int show_sources(void *optctx, const char *opt, const char *arg);
 #define CMDUTILS_COMMON_OPTIONS_AVDEVICE
 #endif
 
+#if CONFIG_AVRADIO
+#define CMDUTILS_COMMON_OPTIONS_AVRADIO                                                                                 \
+    { "radio_sources"    , OPT_EXIT | HAS_ARG, { .func_arg = show_radio_sources },                                      \
+      "list sources of the input device", "device" },                                                                   \
+
+#else
+#define CMDUTILS_COMMON_OPTIONS_AVRADIO
+#endif
+
 /**
  * Print the license of the program to stdout. The license depends on
  * the license of the libraries compiled into the program.
@@ -105,6 +123,13 @@ int show_demuxers(void *optctx, const char *opt, const char *arg);
  */
 int show_devices(void *optctx, const char *opt, const char *arg);
 
+/**
+ * Print a listing containing all the radios supported by the
+ * program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_radios(void *optctx, const char *opt, const char *arg);
+
 /**
  * Print a listing containing all the codecs supported by the
  * program.
@@ -208,6 +233,7 @@ int opt_cpucount(void *optctx, const char *opt, const char *arg);
     { "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" },                \
+    { "radios",      OPT_EXIT,             { .func_arg = show_radios },      "show available radios" },                 \
     { "codecs",      OPT_EXIT,             { .func_arg = show_codecs },      "show available codecs" },                 \
     { "decoders",    OPT_EXIT,             { .func_arg = show_decoders },    "show available decoders" },               \
     { "encoders",    OPT_EXIT,             { .func_arg = show_encoders },    "show available encoders" },               \
@@ -227,5 +253,6 @@ int opt_cpucount(void *optctx, const char *opt, const char *arg);
     { "cpucount",    HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpucount },     "force specific cpu count", "count" },     \
     { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner},     "do not show program banner", "hide_banner" },          \
     CMDUTILS_COMMON_OPTIONS_AVDEVICE                                                                                    \
+    CMDUTILS_COMMON_OPTIONS_AVRADIO                                                                                     \
 
 #endif /* FFTOOLS_OPT_COMMON_H */
-- 
2.17.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2023-07-22 19:30 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-22 19:29 [FFmpeg-devel] [PATCH 1/6] configure: libavradio support Michael Niedermayer
2023-07-22 19:29 ` [FFmpeg-devel] [PATCH 2/6] avutil/log: Add AV_CLASS_CATEGORY_RADIO_INPUT Michael Niedermayer
2023-07-22 20:30   ` Paul B Mahol
2023-07-22 19:29 ` [FFmpeg-devel] [PATCH 3/6] avformat: add support for demuxers/inputs from avradio Michael Niedermayer
2023-07-22 20:35   ` Paul B Mahol
2023-07-22 19:29 ` [FFmpeg-devel] [PATCH 4/6] avdevice/utils: add test for AV_CLASS_CATEGORY_RADIO_INPUT Michael Niedermayer
2023-07-22 19:29 ` Michael Niedermayer [this message]
2023-07-22 21:39   ` [FFmpeg-devel] [PATCH 5/6] fftools: avradio support Lynne
2023-07-23 15:23     ` Michael Niedermayer
2023-07-23 18:49       ` Tomas Härdin
2023-07-23 19:01         ` James Almer
2023-07-23 22:56           ` Michael Niedermayer
2023-07-24  8:19             ` Nicolas George
2023-07-24 15:57               ` Michael Niedermayer
2023-07-24 22:30               ` Tomas Härdin
2023-07-25 14:17             ` Tomas Härdin
2023-07-24 20:19           ` Tomas Härdin
2023-07-25  9:37             ` Nicolas George
2023-07-26 10:37             ` Michael Niedermayer
2023-07-27 13:05               ` Tomas Härdin
2023-07-27 18:36                 ` Michael Niedermayer
2023-07-27 18:48                   ` Nicolas George
     [not found]                   ` <CC2992B9-B047-4724-8DE5-01C02CBE31FD@cosmin.at>
2023-08-01 19:51                     ` Cosmin Stejerean
2023-08-01 20:06                       ` Paul B Mahol
2023-08-02 12:46                         ` Michael Niedermayer
2023-08-02 13:00                           ` Paul B Mahol
2023-08-02 13:01                             ` Michael Niedermayer
2023-07-24  8:13         ` Nicolas George
2023-07-24 20:22           ` Tomas Härdin
2023-07-25  9:33             ` Nicolas George
2023-07-25  9:51               ` Kieran Kunhya
2023-07-25  9:56                 ` Nicolas George
2023-07-25 10:16                   ` Kieran Kunhya
2023-07-25 13:55                     ` Nicolas George
2023-07-25 14:37                       ` Kieran Kunhya
2023-07-27 17:56                         ` Nicolas George
2023-07-28 11:07                           ` Kieran Kunhya
2023-07-30 13:04                             ` [FFmpeg-devel] What is FFmpeg and what should it be Nicolas George
2023-07-30 17:07                               ` Andrey Turkin
2023-07-30 18:29                                 ` Kieran Kunhya
2023-07-30 18:54                                   ` Nicolas George
2023-08-01  7:48                                 ` Rémi Denis-Courmont
2023-07-31 13:56                               ` Tomas Härdin
2023-08-03 13:25                                 ` Nicolas George
2023-08-03 20:50                                   ` Tomas Härdin
2023-08-02  1:44                               ` Vittorio Giovara
2023-08-02 12:55                                 ` Michael Niedermayer
2023-08-02 12:59                                   ` Jean-Baptiste Kempf
2023-08-02 14:12                                     ` Brad Isbell
2023-08-02 14:19                                       ` Nicolas George
2023-08-02 14:26                                       ` Michael Niedermayer
2023-08-02 14:30                                         ` Nicolas George
     [not found]                                           ` <A3B35B92-8333-4637-B4AA-FA9D9750E784@cosmin.at>
2023-08-02 15:46                                             ` Cosmin Stejerean
2023-08-03 15:40                                               ` Michael Niedermayer
2023-08-02 14:20                                     ` Michael Niedermayer
2023-08-02 14:44                                       ` Jean-Baptiste Kempf
2023-08-03 17:45                                         ` Michael Niedermayer
2023-08-03 18:24                                           ` Kieran Kunhya
2023-08-03 19:25                                             ` Michael Niedermayer
2023-08-03 20:04                                               ` Kieran Kunhya
2023-08-04 17:09                                                 ` Michael Niedermayer
2023-08-04 17:35                                                   ` Nicolas George
2023-08-04 23:17                                                     ` Kieran Kunhya
2023-08-05 18:55                                         ` Michael Niedermayer
2023-08-05 19:17                                           ` Paul B Mahol
2023-08-05 23:32                                           ` Vittorio Giovara
2023-08-06  8:28                                             ` Tomas Härdin
2023-08-06 19:53                                             ` Michael Niedermayer
2023-08-07 15:39                                               ` Rémi Denis-Courmont
2023-08-08 15:22                                                 ` Michael Niedermayer
2023-08-08 15:37                                                   ` Paul B Mahol
2023-08-08 18:53                                                   ` Rémi Denis-Courmont
2023-08-09 15:59                                                     ` Michael Niedermayer
2023-08-09 16:24                                                       ` Paul B Mahol
2023-08-10 12:39                                                     ` Nicolas George
2023-08-10 14:58                                                       ` Vittorio Giovara
2023-08-12 17:12                                                         ` Michael Niedermayer
2023-08-10 15:01                                                       ` James Almer
2023-08-10 15:43                                                       ` Jean-Baptiste Kempf
2023-08-10 18:39                                                       ` Tomas Härdin
2023-08-03 11:38                               ` Tomas Härdin
2023-08-03 13:29                                 ` Nicolas George
2023-07-25 12:02                   ` [FFmpeg-devel] [PATCH 5/6] fftools: avradio support Tomas Härdin
2023-07-22 19:29 ` [FFmpeg-devel] [PATCH 6/6] tools/uncoded_frame: " Michael Niedermayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230722192957.703-5-michael@niedermayer.cc \
    --to=michael@niedermayer.cc \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git