chenqiyang
2021-08-27 6a63c4281fbe7e17103115320cd276397d733081
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/*
 * Copyright (c) 2010-2019 Belledonne Communications SARL.
 *
 * This file is part of mediastreamer2.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
 
#ifndef webcam_h
#define webcam_h
 
#include <mediastreamer2/mscommon.h>
#include <mediastreamer2/msfactory.h>
 
/**
 * @file mswebcam.h
 * @brief mediastreamer2 mswebcam.h include file
 *
 * This file provide the API needed to manage
 * soundcard filters.
 *
 */
 
/**
 * @defgroup mediastreamer2_webcam Camera API - manage video capture devices
 * @ingroup mediastreamer2_api
 * @{
 */
 
struct _MSWebCamManager{
    MSFactory* factory;
    MSList *cams;
    MSList *descs;
};
 
/**
 * Structure for webcam manager object.
 * @var MSWebCamManager
 */
typedef struct _MSWebCamManager MSWebCamManager;
 
 
struct _MSWebCam;
 
typedef void (*MSWebCamDetectFunc)(MSWebCamManager *obj);
typedef void (*MSWebCamInitFunc)(struct _MSWebCam *obj);
typedef void (*MSWebCamUninitFunc)(struct _MSWebCam *obj);
typedef struct _MSFilter * (*MSWebCamCreateReaderFunc)(struct _MSWebCam *obj);
typedef bool_t (*MSWebCamEncodeToMimeType)(struct _MSWebCam *obj, const char *mime_type);
 
struct _MSWebCamDesc{
    const char *driver_type;
    MSWebCamDetectFunc detect;
    MSWebCamInitFunc init;
    MSWebCamCreateReaderFunc create_reader;
    MSWebCamUninitFunc uninit;
    MSWebCamEncodeToMimeType encode_to_mime_type;
};
 
/**
 * Structure for sound card description object.
 * @var MSWebCamDesc
 */
typedef struct _MSWebCamDesc MSWebCamDesc;
 
struct _MSWebCam{
    MSWebCamManager* wbcmanager;
    MSWebCamDesc *desc;
    char *name;
    char *id;
    void *data;
};
 
/**
 * Structure for sound card object.
 * @var MSWebCam
 */
typedef struct _MSWebCam MSWebCam;
 
#ifdef __cplusplus
extern "C"{
#endif
 
/**
 * Retrieve a webcam manager object.
 *
 * @returns: MSWebCamManager if successfull, NULL otherwise.
 * @deprecated use ms_factory_get_web_cam_manager().
 */
MS2_PUBLIC MS2_DEPRECATED MSWebCamManager * ms_web_cam_manager_get(void);
 
/**
 * Returns the factory from the webcam object.
 * @param c MSWebCam used to get to the factory.
 */
MS2_PUBLIC MSFactory * ms_web_cam_get_factory(MSWebCam *c);
 
/**
 * Create a webcam manager object.
 * You usually do not need this function, instead get the webcam manager from a factory
 * with ms_factory_get_web_cam_manager().
 */
MS2_PUBLIC MSWebCamManager * ms_web_cam_manager_new(void);
 
/**
 * Destroy the webcam manager object.
 * You usually don't need this function, ms_factory_destroy() doing the job for you.
 */
MS2_PUBLIC void ms_web_cam_manager_destroy(MSWebCamManager* scm);
 
/**
 * Retreive a webcam object based on its name.
 *
 * @param m    A webcam manager containing webcam.
 * @param id   A name for card to search.
 *
 * Returns: MSWebCam if successfull, NULL otherwise.
 */
MS2_PUBLIC MSWebCam * ms_web_cam_manager_get_cam(MSWebCamManager *m, const char *id);
 
/**
 * Retreive the default webcam object.
 *
 * @param m    A webcam manager containing webcams.
 *
 * Returns: MSWebCam if successfull, NULL otherwise.
 */
MS2_PUBLIC MSWebCam * ms_web_cam_manager_get_default_cam(MSWebCamManager *m);
 
/**
 * Retreive the list of webcam objects.
 *
 * @param m    A webcam manager containing webcams.
 *
 * Returns: MSList of cards if successfull, NULL otherwise.
 */
MS2_PUBLIC const MSList * ms_web_cam_manager_get_list(MSWebCamManager *m);
 
/**
 * Add a webcam object in a webcam  manager's list.
 *
 * @param m    A webcam  manager containing webcams
 * @param c    A web cam object.
 *
 */
MS2_PUBLIC void ms_web_cam_manager_add_cam(MSWebCamManager *m, MSWebCam *c);
 
MS2_PUBLIC MSWebCam * ms_web_cam_manager_create_cam(MSWebCamManager *m, MSWebCamDesc *desc);
 
MS2_PUBLIC void ms_web_cam_set_manager(MSWebCamManager*m, MSWebCam *c);
    
/**
 * Add a webcam object on top of list of the webcam  manager's list.
 *
 * @param m    A webcam  manager containing webcams
 * @param c    A web cam object.
 *
 */
MS2_PUBLIC void ms_web_cam_manager_prepend_cam(MSWebCamManager *m, MSWebCam *c);
 
 
/**
 * Register a webcam descriptor in a webcam manager.
 *
 * @param m      A webcam manager containing sound cards.
 * @param desc   A webcam descriptor object.
 *
 */
MS2_PUBLIC void ms_web_cam_manager_register_desc(MSWebCamManager *m, MSWebCamDesc *desc);
 
 
/**
 * Ask all registered MSWebCamDesc to detect the webcams again.
 *
 * @param m A webcam manager
**/
MS2_PUBLIC void ms_web_cam_manager_reload(MSWebCamManager *m);
 
/**
 * Create an INPUT filter based on the selected camera.
 *
 * @param obj      A webcam object.
 *
 * Returns: A MSFilter if successfull, NULL otherwise.
 */
MS2_PUBLIC struct _MSFilter * ms_web_cam_create_reader(MSWebCam *obj);
 
/**
 * Create a new webcam object.
 *
 * @param desc   A webcam description object.
 *
 * Returns: MSWebCam if successfull, NULL otherwise.
 */
MS2_PUBLIC MSWebCam * ms_web_cam_new(MSWebCamDesc *desc);
 
/**
 * Destroy webcam object.
 *
 * @param obj   A MSWebCam object.
 */
MS2_PUBLIC void ms_web_cam_destroy(MSWebCam *obj);
 
 
/**
 * Retreive a webcam's driver type string.
 *
 * Internal driver types are either: "V4L V4LV2"
 *
 * @param obj   A webcam object.
 *
 * Returns: a string if successfull, NULL otherwise.
 */
MS2_PUBLIC const char *ms_web_cam_get_driver_type(const MSWebCam *obj);
 
/**
 * Retreive a webcam's name.
 *
 * @param obj   A webcam object.
 *
 * Returns: a string if successfull, NULL otherwise.
 */
MS2_PUBLIC const char *ms_web_cam_get_name(const MSWebCam *obj);
 
/**
 * Retreive webcam's id: ($driver_type: $name).
 *
 * @param obj    A webcam object.
 *
 * Returns: A string if successfull, NULL otherwise.
 */
MS2_PUBLIC const char *ms_web_cam_get_string_id(MSWebCam *obj);
 
 
/*specific methods for static image:*/
 
MS2_PUBLIC void ms_static_image_set_default_image(const char *path);
MS2_PUBLIC const char *ms_static_image_get_default_image(void);
 
/** method for the "nowebcam" filter */
#define MS_STATIC_IMAGE_SET_IMAGE \
    MS_FILTER_METHOD(MS_STATIC_IMAGE_ID,0,const char)
 
#ifdef __cplusplus
}
#endif
 
/** @} */
 
#endif