This also adds an avpriv function to register devices in
libavformat
... | ... |
@@ -144,7 +144,8 @@ distclean:: clean |
144 | 144 |
version.h libavutil/ffversion.h libavcodec/codec_names.h \ |
145 | 145 |
libavcodec/bsf_list.c libavformat/protocol_list.c \ |
146 | 146 |
libavcodec/codec_list.c libavcodec/parser_list.c \ |
147 |
- libavformat/muxer_list.c libavformat/demuxer_list.c |
|
147 |
+ libavformat/muxer_list.c libavformat/demuxer_list.c \ |
|
148 |
+ libavdevice/indev_list.c libavdevice/outdev_list.c |
|
148 | 149 |
ifeq ($(SRC_LINK),src) |
149 | 150 |
$(RM) src |
150 | 151 |
endif |
... | ... |
@@ -568,6 +568,12 @@ add_suffix(){ |
568 | 568 |
for v; do echo ${v}${suffix}; done |
569 | 569 |
} |
570 | 570 |
|
571 |
+remove_suffix(){ |
|
572 |
+ suffix=$1 |
|
573 |
+ shift |
|
574 |
+ for v; do echo ${v%$suffix}; done |
|
575 |
+} |
|
576 |
+ |
|
571 | 577 |
set_all(){ |
572 | 578 |
value=$1 |
573 | 579 |
shift |
... | ... |
@@ -3525,17 +3531,18 @@ find_things(){ |
3525 | 3525 |
sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file" |
3526 | 3526 |
} |
3527 | 3527 |
|
3528 |
-OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c) |
|
3529 |
-INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c) |
|
3530 | 3528 |
FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c) |
3531 | 3529 |
|
3532 | 3530 |
find_things_extern(){ |
3533 | 3531 |
thing=$1 |
3534 | 3532 |
pattern=$2 |
3535 | 3533 |
file=$source_path/$3 |
3536 |
- sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file" |
|
3534 |
+ out=${4:-$thing} |
|
3535 |
+ sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file" |
|
3537 | 3536 |
} |
3538 | 3537 |
|
3538 |
+OUTDEV_LIST=$(find_things_extern muxer AVOutputFormat libavdevice/alldevices.c outdev) |
|
3539 |
+INDEV_LIST=$(find_things_extern demuxer AVInputFormat libavdevice/alldevices.c indev) |
|
3539 | 3540 |
MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c) |
3540 | 3541 |
DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat libavformat/allformats.c) |
3541 | 3542 |
ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c) |
... | ... |
@@ -7027,7 +7034,17 @@ print_enabled_components(){ |
7027 | 7027 |
shift 3 |
7028 | 7028 |
echo "static const $struct_name * const $name[] = {" > $TMPH |
7029 | 7029 |
for c in $*; do |
7030 |
- enabled $c && printf " &ff_%s,\n" $c >> $TMPH |
|
7030 |
+ if enabled $c; then |
|
7031 |
+ case $name in |
|
7032 |
+ indev_list) |
|
7033 |
+ c=$(add_suffix _demuxer $(remove_suffix _indev $c)) |
|
7034 |
+ ;; |
|
7035 |
+ outdev_list) |
|
7036 |
+ c=$(add_suffix _muxer $(remove_suffix _outdev $c)) |
|
7037 |
+ ;; |
|
7038 |
+ esac |
|
7039 |
+ printf " &ff_%s,\n" $c >> $TMPH |
|
7040 |
+ fi |
|
7031 | 7041 |
done |
7032 | 7042 |
echo " NULL };" >> $TMPH |
7033 | 7043 |
cp_if_changed $TMPH $file |
... | ... |
@@ -7036,6 +7053,8 @@ print_enabled_components(){ |
7036 | 7036 |
print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST |
7037 | 7037 |
print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST |
7038 | 7038 |
print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST |
7039 |
+print_enabled_components libavdevice/indev_list.c AVInputFormat indev_list $INDEV_LIST |
|
7040 |
+print_enabled_components libavdevice/outdev_list.c AVOutputFormat outdev_list $OUTDEV_LIST |
|
7039 | 7041 |
print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list $DEMUXER_LIST |
7040 | 7042 |
print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list $MUXER_LIST |
7041 | 7043 |
print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST |
... | ... |
@@ -22,57 +22,152 @@ |
22 | 22 |
#include "libavutil/thread.h" |
23 | 23 |
#include "avdevice.h" |
24 | 24 |
|
25 |
-#define REGISTER_OUTDEV(X, x) \ |
|
26 |
- { \ |
|
27 |
- extern AVOutputFormat ff_##x##_muxer; \ |
|
28 |
- if (CONFIG_##X##_OUTDEV) \ |
|
29 |
- av_register_output_format(&ff_##x##_muxer); \ |
|
25 |
+#if FF_API_NEXT |
|
26 |
+#include "libavformat/internal.h" |
|
27 |
+#endif |
|
28 |
+ |
|
29 |
+/* devices */ |
|
30 |
+extern AVInputFormat ff_alsa_demuxer; |
|
31 |
+extern AVOutputFormat ff_alsa_muxer; |
|
32 |
+extern AVInputFormat ff_avfoundation_demuxer; |
|
33 |
+extern AVInputFormat ff_bktr_demuxer; |
|
34 |
+extern AVOutputFormat ff_caca_muxer; |
|
35 |
+extern AVInputFormat ff_decklink_demuxer; |
|
36 |
+extern AVOutputFormat ff_decklink_muxer; |
|
37 |
+extern AVInputFormat ff_libndi_newtek_demuxer; |
|
38 |
+extern AVOutputFormat ff_libndi_newtek_muxer; |
|
39 |
+extern AVInputFormat ff_dshow_demuxer; |
|
40 |
+extern AVInputFormat ff_fbdev_demuxer; |
|
41 |
+extern AVOutputFormat ff_fbdev_muxer; |
|
42 |
+extern AVInputFormat ff_gdigrab_demuxer; |
|
43 |
+extern AVInputFormat ff_iec61883_demuxer; |
|
44 |
+extern AVInputFormat ff_jack_demuxer; |
|
45 |
+extern AVInputFormat ff_kmsgrab_demuxer; |
|
46 |
+extern AVInputFormat ff_lavfi_demuxer; |
|
47 |
+extern AVInputFormat ff_openal_demuxer; |
|
48 |
+extern AVOutputFormat ff_opengl_muxer; |
|
49 |
+extern AVInputFormat ff_oss_demuxer; |
|
50 |
+extern AVOutputFormat ff_oss_muxer; |
|
51 |
+extern AVInputFormat ff_pulse_demuxer; |
|
52 |
+extern AVOutputFormat ff_pulse_muxer; |
|
53 |
+extern AVOutputFormat ff_sdl2_muxer; |
|
54 |
+extern AVInputFormat ff_sndio_demuxer; |
|
55 |
+extern AVOutputFormat ff_sndio_muxer; |
|
56 |
+extern AVInputFormat ff_v4l2_demuxer; |
|
57 |
+extern AVOutputFormat ff_v4l2_muxer; |
|
58 |
+extern AVInputFormat ff_vfwcap_demuxer; |
|
59 |
+extern AVInputFormat ff_xcbgrab_demuxer; |
|
60 |
+extern AVOutputFormat ff_xv_muxer; |
|
61 |
+ |
|
62 |
+/* external libraries */ |
|
63 |
+extern AVInputFormat ff_libcdio_demuxer; |
|
64 |
+extern AVInputFormat ff_libdc1394_demuxer; |
|
65 |
+ |
|
66 |
+#include "libavdevice/outdev_list.c" |
|
67 |
+#include "libavdevice/indev_list.c" |
|
68 |
+ |
|
69 |
+const AVOutputFormat *av_outdev_iterate(void **opaque) |
|
70 |
+{ |
|
71 |
+ uintptr_t i = (uintptr_t)*opaque; |
|
72 |
+ const AVOutputFormat *f = outdev_list[i]; |
|
73 |
+ |
|
74 |
+ if (f) |
|
75 |
+ *opaque = (void*)(i + 1); |
|
76 |
+ return f; |
|
77 |
+} |
|
78 |
+ |
|
79 |
+const AVInputFormat *av_indev_iterate(void **opaque) |
|
80 |
+{ |
|
81 |
+ uintptr_t i = (uintptr_t)*opaque; |
|
82 |
+ const AVInputFormat *f = indev_list[i]; |
|
83 |
+ |
|
84 |
+ if (f) |
|
85 |
+ *opaque = (void*)(i + 1); |
|
86 |
+ return f; |
|
87 |
+} |
|
88 |
+ |
|
89 |
+#if FF_API_NEXT |
|
90 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
91 |
+static AVOnce av_device_next_init = AV_ONCE_INIT; |
|
92 |
+ |
|
93 |
+static void av_device_init_next(void) |
|
94 |
+{ |
|
95 |
+ AVOutputFormat *prevout = NULL, *out; |
|
96 |
+ AVInputFormat *previn = NULL, *in; |
|
97 |
+ void *i = 0; |
|
98 |
+ |
|
99 |
+ while ((out = (AVOutputFormat*)av_outdev_iterate(&i))) { |
|
100 |
+ if (prevout) |
|
101 |
+ prevout->next = out; |
|
102 |
+ prevout = out; |
|
30 | 103 |
} |
31 | 104 |
|
32 |
-#define REGISTER_INDEV(X, x) \ |
|
33 |
- { \ |
|
34 |
- extern AVInputFormat ff_##x##_demuxer; \ |
|
35 |
- if (CONFIG_##X##_INDEV) \ |
|
36 |
- av_register_input_format(&ff_##x##_demuxer); \ |
|
105 |
+ i = 0; |
|
106 |
+ while ((in = (AVInputFormat*)av_indev_iterate(&i))) { |
|
107 |
+ if (previn) |
|
108 |
+ previn->next = in; |
|
109 |
+ previn = in; |
|
37 | 110 |
} |
38 | 111 |
|
39 |
-#define REGISTER_INOUTDEV(X, x) REGISTER_OUTDEV(X, x); REGISTER_INDEV(X, x) |
|
112 |
+ avpriv_register_devices(outdev_list, indev_list); |
|
113 |
+} |
|
40 | 114 |
|
41 |
-static void register_all(void) |
|
115 |
+void avdevice_register_all(void) |
|
42 | 116 |
{ |
43 |
- /* devices */ |
|
44 |
- REGISTER_INOUTDEV(ALSA, alsa); |
|
45 |
- REGISTER_INDEV (AVFOUNDATION, avfoundation); |
|
46 |
- REGISTER_INDEV (BKTR, bktr); |
|
47 |
- REGISTER_OUTDEV (CACA, caca); |
|
48 |
- REGISTER_INOUTDEV(DECKLINK, decklink); |
|
49 |
- REGISTER_INOUTDEV(LIBNDI_NEWTEK, libndi_newtek); |
|
50 |
- REGISTER_INDEV (DSHOW, dshow); |
|
51 |
- REGISTER_INOUTDEV(FBDEV, fbdev); |
|
52 |
- REGISTER_INDEV (GDIGRAB, gdigrab); |
|
53 |
- REGISTER_INDEV (IEC61883, iec61883); |
|
54 |
- REGISTER_INDEV (JACK, jack); |
|
55 |
- REGISTER_INDEV (KMSGRAB, kmsgrab); |
|
56 |
- REGISTER_INDEV (LAVFI, lavfi); |
|
57 |
- REGISTER_INDEV (OPENAL, openal); |
|
58 |
- REGISTER_OUTDEV (OPENGL, opengl); |
|
59 |
- REGISTER_INOUTDEV(OSS, oss); |
|
60 |
- REGISTER_INOUTDEV(PULSE, pulse); |
|
61 |
- REGISTER_OUTDEV (SDL2, sdl2); |
|
62 |
- REGISTER_INOUTDEV(SNDIO, sndio); |
|
63 |
- REGISTER_INOUTDEV(V4L2, v4l2); |
|
64 |
- REGISTER_INDEV (VFWCAP, vfwcap); |
|
65 |
- REGISTER_INDEV (XCBGRAB, xcbgrab); |
|
66 |
- REGISTER_OUTDEV (XV, xv); |
|
67 |
- |
|
68 |
- /* external libraries */ |
|
69 |
- REGISTER_INDEV (LIBCDIO, libcdio); |
|
70 |
- REGISTER_INDEV (LIBDC1394, libdc1394); |
|
117 |
+ ff_thread_once(&av_device_next_init, av_device_init_next); |
|
71 | 118 |
} |
72 | 119 |
|
73 |
-void avdevice_register_all(void) |
|
120 |
+static void *device_next(void *prev, int output, |
|
121 |
+ AVClassCategory c1, AVClassCategory c2) |
|
122 |
+{ |
|
123 |
+ const AVClass *pc; |
|
124 |
+ AVClassCategory category = AV_CLASS_CATEGORY_NA; |
|
125 |
+ |
|
126 |
+ ff_thread_once(&av_device_next_init, av_device_init_next); |
|
127 |
+ |
|
128 |
+ if (!prev && !(prev = (output ? (void*)outdev_list[0] : (void*)indev_list[0]))) |
|
129 |
+ return NULL; |
|
130 |
+ |
|
131 |
+ do { |
|
132 |
+ if (output) { |
|
133 |
+ if (!(prev = ((AVOutputFormat *)prev)->next)) |
|
134 |
+ break; |
|
135 |
+ pc = ((AVOutputFormat *)prev)->priv_class; |
|
136 |
+ } else { |
|
137 |
+ if (!(prev = ((AVInputFormat *)prev)->next)) |
|
138 |
+ break; |
|
139 |
+ pc = ((AVInputFormat *)prev)->priv_class; |
|
140 |
+ } |
|
141 |
+ if (!pc) |
|
142 |
+ continue; |
|
143 |
+ category = pc->category; |
|
144 |
+ } while (category != c1 && category != c2); |
|
145 |
+ return prev; |
|
146 |
+} |
|
147 |
+ |
|
148 |
+AVInputFormat *av_input_audio_device_next(AVInputFormat *d) |
|
149 |
+{ |
|
150 |
+ return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT, |
|
151 |
+ AV_CLASS_CATEGORY_DEVICE_INPUT); |
|
152 |
+} |
|
153 |
+ |
|
154 |
+AVInputFormat *av_input_video_device_next(AVInputFormat *d) |
|
155 |
+{ |
|
156 |
+ return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, |
|
157 |
+ AV_CLASS_CATEGORY_DEVICE_INPUT); |
|
158 |
+} |
|
159 |
+ |
|
160 |
+AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d) |
|
74 | 161 |
{ |
75 |
- static AVOnce control = AV_ONCE_INIT; |
|
162 |
+ return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT, |
|
163 |
+ AV_CLASS_CATEGORY_DEVICE_OUTPUT); |
|
164 |
+} |
|
76 | 165 |
|
77 |
- ff_thread_once(&control, register_all); |
|
166 |
+AVOutputFormat *av_output_video_device_next(AVOutputFormat *d) |
|
167 |
+{ |
|
168 |
+ return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT, |
|
169 |
+ AV_CLASS_CATEGORY_DEVICE_OUTPUT); |
|
78 | 170 |
} |
171 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
172 |
+#endif |
|
173 |
+ |
... | ... |
@@ -78,52 +78,6 @@ const char * avdevice_license(void) |
78 | 78 |
return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; |
79 | 79 |
} |
80 | 80 |
|
81 |
-static void *device_next(void *prev, int output, |
|
82 |
- AVClassCategory c1, AVClassCategory c2) |
|
83 |
-{ |
|
84 |
- const AVClass *pc; |
|
85 |
- AVClassCategory category = AV_CLASS_CATEGORY_NA; |
|
86 |
- do { |
|
87 |
- if (output) { |
|
88 |
- if (!(prev = av_oformat_next(prev))) |
|
89 |
- break; |
|
90 |
- pc = ((AVOutputFormat *)prev)->priv_class; |
|
91 |
- } else { |
|
92 |
- if (!(prev = av_iformat_next(prev))) |
|
93 |
- break; |
|
94 |
- pc = ((AVInputFormat *)prev)->priv_class; |
|
95 |
- } |
|
96 |
- if (!pc) |
|
97 |
- continue; |
|
98 |
- category = pc->category; |
|
99 |
- } while (category != c1 && category != c2); |
|
100 |
- return prev; |
|
101 |
-} |
|
102 |
- |
|
103 |
-AVInputFormat *av_input_audio_device_next(AVInputFormat *d) |
|
104 |
-{ |
|
105 |
- return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT, |
|
106 |
- AV_CLASS_CATEGORY_DEVICE_INPUT); |
|
107 |
-} |
|
108 |
- |
|
109 |
-AVInputFormat *av_input_video_device_next(AVInputFormat *d) |
|
110 |
-{ |
|
111 |
- return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, |
|
112 |
- AV_CLASS_CATEGORY_DEVICE_INPUT); |
|
113 |
-} |
|
114 |
- |
|
115 |
-AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d) |
|
116 |
-{ |
|
117 |
- return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT, |
|
118 |
- AV_CLASS_CATEGORY_DEVICE_OUTPUT); |
|
119 |
-} |
|
120 |
- |
|
121 |
-AVOutputFormat *av_output_video_device_next(AVOutputFormat *d) |
|
122 |
-{ |
|
123 |
- return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT, |
|
124 |
- AV_CLASS_CATEGORY_DEVICE_OUTPUT); |
|
125 |
-} |
|
126 |
- |
|
127 | 81 |
int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToDevMessageType type, |
128 | 82 |
void *data, size_t data_size) |
129 | 83 |
{ |
... | ... |
@@ -66,6 +66,29 @@ const char *avdevice_configuration(void); |
66 | 66 |
const char *avdevice_license(void); |
67 | 67 |
|
68 | 68 |
/** |
69 |
+ * Iterate over all registered output devices. |
|
70 |
+ * |
|
71 |
+ * @param opaque a pointer where libavdevice will store the iteration state. Must |
|
72 |
+ * point to NULL to start the iteration. |
|
73 |
+ * |
|
74 |
+ * @return the next registered output device or NULL when the iteration is |
|
75 |
+ * finished |
|
76 |
+ */ |
|
77 |
+const AVOutputFormat *av_outdev_iterate(void **opaque); |
|
78 |
+ |
|
79 |
+/** |
|
80 |
+ * Iterate over all registered input devices. |
|
81 |
+ * |
|
82 |
+ * @param opaque a pointer where libavdevice will store the iteration state. Must |
|
83 |
+ * point to NULL to start the iteration. |
|
84 |
+ * |
|
85 |
+ * @return the next registered input device or NULL when the iteration is |
|
86 |
+ * finished |
|
87 |
+ */ |
|
88 |
+const AVInputFormat *av_indev_iterate(void **opaque); |
|
89 |
+ |
|
90 |
+#if FF_API_NEXT |
|
91 |
+/** |
|
69 | 92 |
* Initialize libavdevice and register all the input and output devices. |
70 | 93 |
*/ |
71 | 94 |
void avdevice_register_all(void); |
... | ... |
@@ -77,6 +100,7 @@ void avdevice_register_all(void); |
77 | 77 |
* if d is non-NULL, returns the next registered input audio/video device after d |
78 | 78 |
* or NULL if d is the last one. |
79 | 79 |
*/ |
80 |
+attribute_deprecated |
|
80 | 81 |
AVInputFormat *av_input_audio_device_next(AVInputFormat *d); |
81 | 82 |
|
82 | 83 |
/** |
... | ... |
@@ -86,6 +110,7 @@ AVInputFormat *av_input_audio_device_next(AVInputFormat *d); |
86 | 86 |
* if d is non-NULL, returns the next registered input audio/video device after d |
87 | 87 |
* or NULL if d is the last one. |
88 | 88 |
*/ |
89 |
+attribute_deprecated |
|
89 | 90 |
AVInputFormat *av_input_video_device_next(AVInputFormat *d); |
90 | 91 |
|
91 | 92 |
/** |
... | ... |
@@ -95,6 +120,7 @@ AVInputFormat *av_input_video_device_next(AVInputFormat *d); |
95 | 95 |
* if d is non-NULL, returns the next registered output audio/video device after d |
96 | 96 |
* or NULL if d is the last one. |
97 | 97 |
*/ |
98 |
+attribute_deprecated |
|
98 | 99 |
AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d); |
99 | 100 |
|
100 | 101 |
/** |
... | ... |
@@ -104,7 +130,9 @@ AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d); |
104 | 104 |
* if d is non-NULL, returns the next registered output audio/video device after d |
105 | 105 |
* or NULL if d is the last one. |
106 | 106 |
*/ |
107 |
+attribute_deprecated |
|
107 | 108 |
AVOutputFormat *av_output_video_device_next(AVOutputFormat *d); |
109 |
+#endif |
|
108 | 110 |
|
109 | 111 |
typedef struct AVDeviceRect { |
110 | 112 |
int x; /**< x coordinate of top left corner */ |
... | ... |
@@ -25,6 +25,9 @@ |
25 | 25 |
#include "rdt.h" |
26 | 26 |
#include "url.h" |
27 | 27 |
#include "version.h" |
28 |
+#if FF_API_NEXT |
|
29 |
+#include "internal.h" |
|
30 |
+#endif |
|
28 | 31 |
|
29 | 32 |
/* (de)muxers */ |
30 | 33 |
extern AVOutputFormat ff_a64_muxer; |
... | ... |
@@ -480,6 +483,7 @@ const AVOutputFormat *av_muxer_iterate(void **opaque) |
480 | 480 |
{ |
481 | 481 |
uintptr_t i = (uintptr_t)*opaque; |
482 | 482 |
const AVOutputFormat *f = muxer_list[i]; |
483 |
+ |
|
483 | 484 |
if (f) |
484 | 485 |
*opaque = (void*)(i + 1); |
485 | 486 |
return f; |
... | ... |
@@ -498,6 +502,9 @@ const AVInputFormat *av_demuxer_iterate(void **opaque){ |
498 | 498 |
FF_DISABLE_DEPRECATION_WARNINGS |
499 | 499 |
static AVOnce av_format_next_init = AV_ONCE_INIT; |
500 | 500 |
|
501 |
+static const AVInputFormat * const *indev_list = NULL; |
|
502 |
+static const AVOutputFormat * const *outdev_list = NULL; |
|
503 |
+ |
|
501 | 504 |
static void av_format_init_next(void) |
502 | 505 |
{ |
503 | 506 |
AVOutputFormat *prevout = NULL, *out; |
... | ... |
@@ -510,30 +517,61 @@ static void av_format_init_next(void) |
510 | 510 |
prevout = out; |
511 | 511 |
} |
512 | 512 |
|
513 |
+ if (outdev_list) { |
|
514 |
+ for (int j = 0; (out = (AVOutputFormat*)outdev_list[j]); j++) { |
|
515 |
+ if (prevout) |
|
516 |
+ prevout->next = out; |
|
517 |
+ prevout = out; |
|
518 |
+ } |
|
519 |
+ } |
|
520 |
+ |
|
513 | 521 |
i = 0; |
514 | 522 |
while ((in = (AVInputFormat*)av_demuxer_iterate(&i))) { |
515 | 523 |
if (previn) |
516 | 524 |
previn->next = in; |
517 | 525 |
previn = in; |
518 | 526 |
} |
527 |
+ |
|
528 |
+ if (indev_list) { |
|
529 |
+ for (int j = 0; (in = (AVInputFormat*)indev_list[j]); j++) { |
|
530 |
+ if (previn) |
|
531 |
+ previn->next = in; |
|
532 |
+ previn = in; |
|
533 |
+ } |
|
534 |
+ } |
|
535 |
+ |
|
536 |
+} |
|
537 |
+ |
|
538 |
+void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputFormat * const i[]) |
|
539 |
+{ |
|
540 |
+ static AVMutex avpriv_register_devices_mutex = AV_MUTEX_INITIALIZER; |
|
541 |
+ ff_mutex_lock(&avpriv_register_devices_mutex); |
|
542 |
+ outdev_list = o; |
|
543 |
+ indev_list = i; |
|
544 |
+ av_format_init_next(); |
|
545 |
+ ff_mutex_unlock(&avpriv_register_devices_mutex); |
|
519 | 546 |
} |
520 | 547 |
|
521 | 548 |
AVInputFormat *av_iformat_next(const AVInputFormat *f) |
522 | 549 |
{ |
523 | 550 |
ff_thread_once(&av_format_next_init, av_format_init_next); |
551 |
+ |
|
524 | 552 |
if (f) |
525 | 553 |
return f->next; |
526 | 554 |
else |
527 |
- return demuxer_list[0]; |
|
555 |
+ /* If there are no demuxers but input devices, then return the first input device. |
|
556 |
+ * This will still return null if both there are both no demuxers or input devices. */ |
|
557 |
+ return demuxer_list[0] ? (AVInputFormat*)demuxer_list[0] : (indev_list ? (AVInputFormat*)indev_list[0] : NULL); |
|
528 | 558 |
} |
529 | 559 |
|
530 | 560 |
AVOutputFormat *av_oformat_next(const AVOutputFormat *f) |
531 | 561 |
{ |
532 | 562 |
ff_thread_once(&av_format_next_init, av_format_init_next); |
563 |
+ |
|
533 | 564 |
if (f) |
534 | 565 |
return f->next; |
535 | 566 |
else |
536 |
- return muxer_list[0]; |
|
567 |
+ return muxer_list[0] ? (AVOutputFormat*)muxer_list[0] : (outdev_list ? (AVOutputFormat*)outdev_list[0] : NULL); |
|
537 | 568 |
} |
538 | 569 |
|
539 | 570 |
void av_register_all(void) |
... | ... |
@@ -118,10 +118,18 @@ enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, |
118 | 118 |
AVInputFormat *av_find_input_format(const char *short_name) |
119 | 119 |
{ |
120 | 120 |
AVInputFormat *fmt = NULL; |
121 |
+#if FF_API_NEXT |
|
122 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
123 |
+ while ((fmt = av_iformat_next(fmt))) |
|
124 |
+ if (av_match_name(short_name, fmt->name)) |
|
125 |
+ return fmt; |
|
126 |
+FF_ENABLE_DEPRECATION_WARNINGS |
|
127 |
+#else |
|
121 | 128 |
void *i = 0; |
122 | 129 |
while ((fmt = av_demuxer_iterate(&i))) |
123 | 130 |
if (av_match_name(short_name, fmt->name)) |
124 | 131 |
return fmt; |
132 |
+#endif |
|
125 | 133 |
return NULL; |
126 | 134 |
} |
127 | 135 |
|
... | ... |
@@ -703,4 +703,11 @@ int ff_unlock_avformat(void); |
703 | 703 |
*/ |
704 | 704 |
void ff_format_set_url(AVFormatContext *s, char *url); |
705 | 705 |
|
706 |
+#if FF_API_NEXT |
|
707 |
+/** |
|
708 |
+ * Register devices in deprecated format linked list. |
|
709 |
+ */ |
|
710 |
+void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputFormat * const i[]); |
|
711 |
+#endif |
|
712 |
+ |
|
706 | 713 |
#endif /* AVFORMAT_INTERNAL_H */ |