FFmpeg coverage


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