FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavdevice/alldevices.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 3 47 6.4%
Functions: 1 7 14.3%
Branches: 0 28 0.0%

Line Branch Exec Source
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 "libavutil/attributes.h"
22 #include "libavutil/attributes_internal.h"
23 #include "libavformat/avformat_internal.h"
24 #include "libavformat/demux.h"
25 #include "libavformat/mux.h"
26 #include "avdevice.h"
27
28 FF_VISIBILITY_PUSH_HIDDEN
29 /* devices */
30 extern const FFInputFormat ff_alsa_demuxer;
31 extern const FFOutputFormat ff_alsa_muxer;
32 extern const FFInputFormat ff_android_camera_demuxer;
33 extern const FFOutputFormat ff_audiotoolbox_muxer;
34 extern const FFInputFormat ff_avfoundation_demuxer;
35 extern const FFInputFormat ff_bktr_demuxer;
36 extern const FFOutputFormat ff_caca_muxer;
37 extern const FFInputFormat ff_decklink_demuxer;
38 extern const FFOutputFormat ff_decklink_muxer;
39 extern const FFInputFormat ff_dshow_demuxer;
40 extern const FFInputFormat ff_fbdev_demuxer;
41 extern const FFOutputFormat ff_fbdev_muxer;
42 extern const FFInputFormat ff_gdigrab_demuxer;
43 extern const FFInputFormat ff_iec61883_demuxer;
44 extern const FFInputFormat ff_jack_demuxer;
45 extern const FFInputFormat ff_kmsgrab_demuxer;
46 extern const FFInputFormat ff_lavfi_demuxer;
47 extern const FFInputFormat ff_openal_demuxer;
48 extern const FFOutputFormat ff_opengl_muxer;
49 extern const FFInputFormat ff_oss_demuxer;
50 extern const FFOutputFormat ff_oss_muxer;
51 extern const FFInputFormat ff_pulse_demuxer;
52 extern const FFOutputFormat ff_pulse_muxer;
53 extern const FFOutputFormat ff_sdl2_muxer;
54 extern const FFInputFormat ff_sndio_demuxer;
55 extern const FFOutputFormat ff_sndio_muxer;
56 extern const FFInputFormat ff_v4l2_demuxer;
57 extern const FFOutputFormat ff_v4l2_muxer;
58 extern const FFInputFormat ff_vfwcap_demuxer;
59 extern const FFInputFormat ff_xcbgrab_demuxer;
60 extern const FFOutputFormat ff_xv_muxer;
61
62 /* external libraries */
63 extern const FFInputFormat ff_libcdio_demuxer;
64 extern const FFInputFormat ff_libdc1394_demuxer;
65 FF_VISIBILITY_POP_HIDDEN
66
67 #include "libavdevice/outdev_list.c"
68 #include "libavdevice/indev_list.c"
69
70 8068 av_cold void avdevice_register_all(void)
71 {
72 8068 avpriv_register_devices(outdev_list, indev_list);
73 8068 }
74
75 static av_cold const void *next_input(const AVInputFormat *prev, AVClassCategory c2)
76 {
77 const AVClass *pc;
78 const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_INPUT;
79 AVClassCategory category = AV_CLASS_CATEGORY_NA;
80 const FFInputFormat *fmt = NULL;
81 int i = 0;
82
83 while (prev && (fmt = indev_list[i])) {
84 i++;
85 if (prev == &fmt->p)
86 break;
87 }
88
89 do {
90 fmt = indev_list[i++];
91 if (!fmt)
92 break;
93 pc = fmt->p.priv_class;
94 if (!pc)
95 continue;
96 category = pc->category;
97 } while (category != c1 && category != c2);
98 return fmt;
99 }
100
101 static av_cold const void *next_output(const AVOutputFormat *prev, AVClassCategory c2)
102 {
103 const AVClass *pc;
104 const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_OUTPUT;
105 AVClassCategory category = AV_CLASS_CATEGORY_NA;
106 const FFOutputFormat *fmt = NULL;
107 int i = 0;
108
109 while (prev && (fmt = outdev_list[i])) {
110 i++;
111 if (prev == &fmt->p)
112 break;
113 }
114
115 do {
116 fmt = outdev_list[i++];
117 if (!fmt)
118 break;
119 pc = fmt->p.priv_class;
120 if (!pc)
121 continue;
122 category = pc->category;
123 } while (category != c1 && category != c2);
124 return fmt;
125 }
126
127 av_cold const AVInputFormat *av_input_audio_device_next(const AVInputFormat *d)
128 {
129 return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT);
130 }
131
132 av_cold const AVInputFormat *av_input_video_device_next(const AVInputFormat *d)
133 {
134 return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT);
135 }
136
137 av_cold const AVOutputFormat *av_output_audio_device_next(const AVOutputFormat *d)
138 {
139 return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT);
140 }
141
142 av_cold const AVOutputFormat *av_output_video_device_next(const AVOutputFormat *d)
143 {
144 return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT);
145 }
146