[FFmpeg-devel] [PATCH 3/8] lavd/avdevice: add device iterators

Lukasz Marek lukasz.m.luki at gmail.com
Sat Feb 22 23:33:37 CET 2014


TODO: minor bump, update doc/APIChanges

Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
---
 libavdevice/avdevice.c | 40 ++++++++++++++++++++++++++++++++++++++++
 libavdevice/avdevice.h | 16 ++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index 9e2b7d5..1031afd 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -37,6 +37,46 @@ const char * avdevice_license(void)
     return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
 }
 
+AVInputFormat *av_input_audio_device_next(AVInputFormat  *d)
+{
+    AVInputFormat *o = av_iformat_next(d);
+    while (o && (!o->priv_class ||
+          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT &&
+           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_VIDEO_INPUT)))
+        o = av_iformat_next(o);
+    return o;
+}
+
+AVInputFormat *av_input_video_device_next(AVInputFormat  *d)
+{
+    AVInputFormat *o = av_iformat_next(d);
+    while (o && (!o->priv_class ||
+          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT &&
+           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_VIDEO_INPUT)))
+        o = av_iformat_next(o);
+    return o;
+}
+
+AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d)
+{
+    AVOutputFormat *o = av_oformat_next(d);
+    while (o && (!o->priv_class ||
+          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT &&
+           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_VIDEO_OUTPUT)))
+        o = av_oformat_next(o);
+    return o;
+}
+
+AVOutputFormat *av_output_video_device_next(AVOutputFormat *d)
+{
+    AVOutputFormat *o = av_oformat_next(d);
+    while (o && (!o->priv_class ||
+          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT &&
+           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_VIDEO_OUTPUT)))
+        o = av_oformat_next(o);
+    return o;
+}
+
 int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToDevMessageType type,
                                         void *data, size_t data_size)
 {
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index 28344ca..47bf8f4 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -66,6 +66,22 @@ const char *avdevice_license(void);
  */
 void avdevice_register_all(void);
 
+/**
+ * If d is NULL, returns the first registered input audio/video device,
+ * if d is non-NULL, returns the next registered input audio/video device after d
+ * or NULL if d is the last one.
+ */
+AVInputFormat *av_input_audio_device_next(AVInputFormat  *d);
+AVInputFormat *av_input_video_device_next(AVInputFormat  *d);
+
+/**
+ * If d is NULL, returns the first registered output audio/video device,
+ * if d is non-NULL, returns the next registered output audio/video device after d
+ * or NULL if d is the last one.
+ */
+AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d);
+AVOutputFormat *av_output_video_device_next(AVOutputFormat *d);
+
 typedef struct AVDeviceRect {
     int x;      /**< x coordinate of top left corner */
     int y;      /**< y coordinate of top left corner */
-- 
1.8.3.2



More information about the ffmpeg-devel mailing list