mswebcam.h 6.11 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006  Simon MORLAT (simon.morlat@linphone.org)

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 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#ifndef webcam_h
#define webcam_h

Simon Morlat's avatar
Simon Morlat committed
23
#include <mediastreamer2/mscommon.h>
24
#include <mediastreamer2/msfactory.h>
aymeric's avatar
aymeric committed
25 26 27 28 29 30 31 32 33 34 35

/**
 * @file mswebcam.h
 * @brief mediastreamer2 mswebcam.h include file
 *
 * This file provide the API needed to manage
 * soundcard filters.
 *
 */

/**
smorlat's avatar
smorlat committed
36
 * @defgroup mediastreamer2_webcam Camera API - manage video capture devices
aymeric's avatar
aymeric committed
37 38 39 40 41
 * @ingroup mediastreamer2_api
 * @{
 */

struct _MSWebCamManager{
42
	MSFactory* factory;
aymeric's avatar
aymeric committed
43
	MSList *cams;
44
	MSList *descs;
aymeric's avatar
aymeric committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58
};

/**
 * 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);
59
typedef struct _MSFilter * (*MSWebCamCreateReaderFunc)(struct _MSWebCam *obj);
60
typedef bool_t (*MSWebCamEncodeToMimeType)(struct _MSWebCam *obj, const char *mime_type);
aymeric's avatar
aymeric committed
61 62 63 64 65 66 67

struct _MSWebCamDesc{
	const char *driver_type;
	MSWebCamDetectFunc detect;
	MSWebCamInitFunc init;
	MSWebCamCreateReaderFunc create_reader;
	MSWebCamUninitFunc uninit;
68
	MSWebCamEncodeToMimeType encode_to_mime_type;
aymeric's avatar
aymeric committed
69 70 71 72 73 74 75 76 77
};

/**
 * Structure for sound card description object.
 * @var MSWebCamDesc
 */
typedef struct _MSWebCamDesc MSWebCamDesc;

struct _MSWebCam{
78
	MSWebCamManager* wbcmanager;
aymeric's avatar
aymeric committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
	MSWebCamDesc *desc;
	char *name;
	char *id;
	void *data;
};

/**
 * Structure for sound card object.
 * @var MSWebCam
 */
typedef struct _MSWebCam MSWebCam;

#ifdef __cplusplus
extern "C"{
#endif

/**
 * Retreive a webcam manager object.
 *
 * Returns: MSWebCamManager if successfull, NULL otherwise.
 */
100
MS2_PUBLIC MS2_DEPRECATED MSWebCamManager * ms_web_cam_manager_get(void);
101

102 103 104 105
/**
 * Returns the factory from the webcam object.
 * @param c MSWebCam used to get to the factory.
 */
106
MS2_PUBLIC MSFactory * ms_web_cam_get_factory(MSWebCam *c);
aymeric's avatar
aymeric committed
107 108

/**
109
 * Destroy the webcam manager object.
110
 * You usually don't need this function, ms_factory_destroy() doing the job for you.
aymeric's avatar
aymeric committed
111
 */
112
MS2_PUBLIC void ms_web_cam_manager_destroy(MSWebCamManager* scm);
aymeric's avatar
aymeric committed
113 114

/**
115
 * Retreive a webcam object based on its name.
aymeric's avatar
aymeric committed
116
 *
117
 * @param m    A webcam manager containing webcam.
aymeric's avatar
aymeric committed
118 119 120 121
 * @param id   A name for card to search.
 *
 * Returns: MSWebCam if successfull, NULL otherwise.
 */
Simon Morlat's avatar
Simon Morlat committed
122
MS2_PUBLIC MSWebCam * ms_web_cam_manager_get_cam(MSWebCamManager *m, const char *id);
aymeric's avatar
aymeric committed
123 124

/**
125
 * Retreive the default webcam object.
aymeric's avatar
aymeric committed
126
 *
127
 * @param m    A webcam manager containing webcams.
aymeric's avatar
aymeric committed
128 129 130
 *
 * Returns: MSWebCam if successfull, NULL otherwise.
 */
Simon Morlat's avatar
Simon Morlat committed
131
MS2_PUBLIC MSWebCam * ms_web_cam_manager_get_default_cam(MSWebCamManager *m);
aymeric's avatar
aymeric committed
132 133 134 135 136 137 138 139

/**
 * Retreive the list of webcam objects.
 *
 * @param m    A webcam manager containing webcams.
 *
 * Returns: MSList of cards if successfull, NULL otherwise.
 */
Simon Morlat's avatar
Simon Morlat committed
140
MS2_PUBLIC const MSList * ms_web_cam_manager_get_list(MSWebCamManager *m);
aymeric's avatar
aymeric committed
141 142

/**
143
 * Add a webcam object in a webcam  manager's list.
aymeric's avatar
aymeric committed
144
 *
smorlat's avatar
smorlat committed
145 146
 * @param m    A webcam  manager containing webcams
 * @param c    A web cam object.
aymeric's avatar
aymeric committed
147 148
 *
 */
Simon Morlat's avatar
Simon Morlat committed
149
MS2_PUBLIC void ms_web_cam_manager_add_cam(MSWebCamManager *m, MSWebCam *c);
150 151 152
	
MS2_PUBLIC void ms_web_cam_set_manager(MSWebCamManager*m, MSWebCam *c);
	
smorlat's avatar
smorlat committed
153
/**
154
 * Add a webcam object on top of list of the webcam  manager's list.
smorlat's avatar
smorlat committed
155 156 157 158 159
 *
 * @param m    A webcam  manager containing webcams
 * @param c    A web cam object.
 *
 */
Simon Morlat's avatar
Simon Morlat committed
160
MS2_PUBLIC void ms_web_cam_manager_prepend_cam(MSWebCamManager *m, MSWebCam *c);
smorlat's avatar
smorlat committed
161 162


aymeric's avatar
aymeric committed
163
/**
164
 * Register a webcam descriptor in a webcam manager.
aymeric's avatar
aymeric committed
165
 *
166 167
 * @param m      A webcam manager containing sound cards.
 * @param desc   A webcam descriptor object.
aymeric's avatar
aymeric committed
168 169
 *
 */
Simon Morlat's avatar
Simon Morlat committed
170
MS2_PUBLIC void ms_web_cam_manager_register_desc(MSWebCamManager *m, MSWebCamDesc *desc);
aymeric's avatar
aymeric committed
171

172 173 174 175 176 177

/**
 * Ask all registered MSWebCamDesc to detect the webcams again.
 *
 * @param m A webcam manager
**/
Simon Morlat's avatar
Simon Morlat committed
178
MS2_PUBLIC void ms_web_cam_manager_reload(MSWebCamManager *m);
179

aymeric's avatar
aymeric committed
180 181 182
/**
 * Create an INPUT filter based on the selected camera.
 *
183
 * @param obj      A webcam object.
aymeric's avatar
aymeric committed
184 185 186
 *
 * Returns: A MSFilter if successfull, NULL otherwise.
 */
187
MS2_PUBLIC struct _MSFilter * ms_web_cam_create_reader(MSWebCam *obj);
aymeric's avatar
aymeric committed
188 189 190 191 192 193 194 195

/**
 * Create a new webcam object.
 *
 * @param desc   A webcam description object.
 *
 * Returns: MSWebCam if successfull, NULL otherwise.
 */
Simon Morlat's avatar
Simon Morlat committed
196
MS2_PUBLIC MSWebCam * ms_web_cam_new(MSWebCamDesc *desc);
aymeric's avatar
aymeric committed
197 198 199 200 201 202

/**
 * Destroy webcam object.
 *
 * @param obj   A MSWebCam object.
 */
Simon Morlat's avatar
Simon Morlat committed
203
MS2_PUBLIC void ms_web_cam_destroy(MSWebCam *obj);
aymeric's avatar
aymeric committed
204 205 206 207 208 209 210 211 212 213 214


/**
 * 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.
 */
Simon Morlat's avatar
Simon Morlat committed
215
MS2_PUBLIC const char *ms_web_cam_get_driver_type(const MSWebCam *obj);
aymeric's avatar
aymeric committed
216 217 218 219 220 221 222 223

/**
 * Retreive a webcam's name.
 *
 * @param obj   A webcam object.
 *
 * Returns: a string if successfull, NULL otherwise.
 */
Simon Morlat's avatar
Simon Morlat committed
224
MS2_PUBLIC const char *ms_web_cam_get_name(const MSWebCam *obj);
aymeric's avatar
aymeric committed
225 226 227 228 229 230 231 232

/**
 * Retreive webcam's id: ($driver_type: $name).
 *
 * @param obj    A webcam object.
 *
 * Returns: A string if successfull, NULL otherwise.
 */
Simon Morlat's avatar
Simon Morlat committed
233
MS2_PUBLIC const char *ms_web_cam_get_string_id(MSWebCam *obj);
aymeric's avatar
aymeric committed
234 235


236 237
/*specific methods for static image:*/

Simon Morlat's avatar
Simon Morlat committed
238
MS2_PUBLIC void ms_static_image_set_default_image(const char *path);
239
MS2_PUBLIC const char *ms_static_image_get_default_image(void);
240

Simon Morlat's avatar
Simon Morlat committed
241 242 243 244
/** method for the "nowebcam" filter */
#define MS_STATIC_IMAGE_SET_IMAGE \
	MS_FILTER_METHOD(MS_STATIC_IMAGE_ID,0,const char)

aymeric's avatar
aymeric committed
245 246 247 248 249 250 251
#ifdef __cplusplus
}
#endif

/** @} */

#endif