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 */
25extern const AVInputFormat  ff_alsa_demuxer;
26extern const AVOutputFormat ff_alsa_muxer;
27extern const AVInputFormat  ff_android_camera_demuxer;
28extern const AVOutputFormat ff_audiotoolbox_muxer;
29extern const AVInputFormat  ff_avfoundation_demuxer;
30extern const AVInputFormat  ff_bktr_demuxer;
31extern const AVOutputFormat ff_caca_muxer;
32extern const AVInputFormat  ff_decklink_demuxer;
33extern const AVOutputFormat ff_decklink_muxer;
34extern const AVInputFormat  ff_dshow_demuxer;
35extern const AVInputFormat  ff_fbdev_demuxer;
36extern const AVOutputFormat ff_fbdev_muxer;
37extern const AVInputFormat  ff_gdigrab_demuxer;
38extern const AVInputFormat  ff_iec61883_demuxer;
39extern const AVInputFormat  ff_jack_demuxer;
40extern const AVInputFormat  ff_kmsgrab_demuxer;
41extern const AVInputFormat  ff_lavfi_demuxer;
42extern const AVInputFormat  ff_openal_demuxer;
43extern const AVOutputFormat ff_opengl_muxer;
44extern const AVInputFormat  ff_oss_demuxer;
45extern const AVOutputFormat ff_oss_muxer;
46extern const AVInputFormat  ff_pulse_demuxer;
47extern const AVOutputFormat ff_pulse_muxer;
48extern const AVOutputFormat ff_sdl2_muxer;
49extern const AVInputFormat  ff_sndio_demuxer;
50extern const AVOutputFormat ff_sndio_muxer;
51extern const AVInputFormat  ff_v4l2_demuxer;
52extern const AVOutputFormat ff_v4l2_muxer;
53extern const AVInputFormat  ff_vfwcap_demuxer;
54extern const AVInputFormat  ff_xcbgrab_demuxer;
55extern const AVOutputFormat ff_xv_muxer;
56
57/* external libraries */
58extern const AVInputFormat  ff_libcdio_demuxer;
59extern const AVInputFormat  ff_libdc1394_demuxer;
60
61#include "libavdevice/outdev_list.c"
62#include "libavdevice/indev_list.c"
63
64void avdevice_register_all(void)
65{
66    avpriv_register_devices(outdev_list, indev_list);
67}
68
69static 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
95static 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
121const AVInputFormat *av_input_audio_device_next(const AVInputFormat  *d)
122{
123    return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT);
124}
125
126const AVInputFormat *av_input_video_device_next(const AVInputFormat  *d)
127{
128    return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT);
129}
130
131const AVOutputFormat *av_output_audio_device_next(const AVOutputFormat *d)
132{
133    return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT);
134}
135
136const AVOutputFormat *av_output_video_device_next(const AVOutputFormat *d)
137{
138    return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT);
139}
140