1 /*
2 * Register all the grabbing devices.
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "libavformat/internal.h"
22 #include "avdevice.h"
23
24 /* devices */
25 extern const AVInputFormat ff_alsa_demuxer;
26 extern const AVOutputFormat ff_alsa_muxer;
27 extern const AVInputFormat ff_android_camera_demuxer;
28 extern const AVOutputFormat ff_audiotoolbox_muxer;
29 extern const AVInputFormat ff_avfoundation_demuxer;
30 extern const AVInputFormat ff_bktr_demuxer;
31 extern const AVOutputFormat ff_caca_muxer;
32 extern const AVInputFormat ff_decklink_demuxer;
33 extern const AVOutputFormat ff_decklink_muxer;
34 extern const AVInputFormat ff_dshow_demuxer;
35 extern const AVInputFormat ff_fbdev_demuxer;
36 extern const AVOutputFormat ff_fbdev_muxer;
37 extern const AVInputFormat ff_gdigrab_demuxer;
38 extern const AVInputFormat ff_iec61883_demuxer;
39 extern const AVInputFormat ff_jack_demuxer;
40 extern const AVInputFormat ff_kmsgrab_demuxer;
41 extern const AVInputFormat ff_lavfi_demuxer;
42 extern const AVInputFormat ff_openal_demuxer;
43 extern const AVOutputFormat ff_opengl_muxer;
44 extern const AVInputFormat ff_oss_demuxer;
45 extern const AVOutputFormat ff_oss_muxer;
46 extern const AVInputFormat ff_pulse_demuxer;
47 extern const AVOutputFormat ff_pulse_muxer;
48 extern const AVOutputFormat ff_sdl2_muxer;
49 extern const AVInputFormat ff_sndio_demuxer;
50 extern const AVOutputFormat ff_sndio_muxer;
51 extern const AVInputFormat ff_v4l2_demuxer;
52 extern const AVOutputFormat ff_v4l2_muxer;
53 extern const AVInputFormat ff_vfwcap_demuxer;
54 extern const AVInputFormat ff_xcbgrab_demuxer;
55 extern const AVOutputFormat ff_xv_muxer;
56
57 /* external libraries */
58 extern const AVInputFormat ff_libcdio_demuxer;
59 extern const AVInputFormat ff_libdc1394_demuxer;
60
61 #include "libavdevice/outdev_list.c"
62 #include "libavdevice/indev_list.c"
63
avdevice_register_all(void)64 void avdevice_register_all(void)
65 {
66 avpriv_register_devices(outdev_list, indev_list);
67 }
68
next_input(const AVInputFormat * prev,AVClassCategory c2)69 static const void *next_input(const AVInputFormat *prev, AVClassCategory c2)
70 {
71 const AVClass *pc;
72 const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_INPUT;
73 AVClassCategory category = AV_CLASS_CATEGORY_NA;
74 const AVInputFormat *fmt = NULL;
75 int i = 0;
76
77 while (prev && (fmt = indev_list[i])) {
78 i++;
79 if (prev == fmt)
80 break;
81 }
82
83 do {
84 fmt = indev_list[i++];
85 if (!fmt)
86 break;
87 pc = fmt->priv_class;
88 if (!pc)
89 continue;
90 category = pc->category;
91 } while (category != c1 && category != c2);
92 return fmt;
93 }
94
next_output(const AVOutputFormat * prev,AVClassCategory c2)95 static const void *next_output(const AVOutputFormat *prev, AVClassCategory c2)
96 {
97 const AVClass *pc;
98 const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_OUTPUT;
99 AVClassCategory category = AV_CLASS_CATEGORY_NA;
100 const AVOutputFormat *fmt = NULL;
101 int i = 0;
102
103 while (prev && (fmt = outdev_list[i])) {
104 i++;
105 if (prev == fmt)
106 break;
107 }
108
109 do {
110 fmt = outdev_list[i++];
111 if (!fmt)
112 break;
113 pc = fmt->priv_class;
114 if (!pc)
115 continue;
116 category = pc->category;
117 } while (category != c1 && category != c2);
118 return fmt;
119 }
120
av_input_audio_device_next(const AVInputFormat * d)121 const AVInputFormat *av_input_audio_device_next(const AVInputFormat *d)
122 {
123 return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT);
124 }
125
av_input_video_device_next(const AVInputFormat * d)126 const AVInputFormat *av_input_video_device_next(const AVInputFormat *d)
127 {
128 return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT);
129 }
130
av_output_audio_device_next(const AVOutputFormat * d)131 const AVOutputFormat *av_output_audio_device_next(const AVOutputFormat *d)
132 {
133 return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT);
134 }
135
av_output_video_device_next(const AVOutputFormat * d)136 const AVOutputFormat *av_output_video_device_next(const AVOutputFormat *d)
137 {
138 return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT);
139 }
140