FFmpeg coverage


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