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