Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2008-2010 Teluu Inc. (http://www.teluu.com) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #ifndef __PJMEDIA_VIDEODEV_VIDEODEV_H__ |
| 20 | #define __PJMEDIA_VIDEODEV_VIDEODEV_H__ |
| 21 | |
| 22 | /** |
| 23 | * @file videodev.h |
| 24 | * @brief Video device API. |
| 25 | */ |
| 26 | #include <pjmedia-videodev/config.h> |
| 27 | #include <pjmedia-videodev/errno.h> |
Benny Prijono | 934af0f | 2011-07-12 03:05:35 +0000 | [diff] [blame] | 28 | #include <pjmedia/event.h> |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 29 | #include <pjmedia/frame.h> |
| 30 | #include <pjmedia/format.h> |
| 31 | #include <pj/pool.h> |
| 32 | |
| 33 | |
| 34 | PJ_BEGIN_DECL |
| 35 | |
| 36 | /** |
| 37 | * @defgroup video_device_reference Video Device API Reference |
| 38 | * @ingroup video_device_api |
| 39 | * @brief API Reference |
| 40 | * @{ |
| 41 | */ |
| 42 | |
| 43 | /** |
| 44 | * Type for device index. |
| 45 | */ |
| 46 | typedef pj_int32_t pjmedia_vid_dev_index; |
| 47 | |
| 48 | /** |
Nanang Izzuddin | 6e2fcc3 | 2011-07-22 04:49:36 +0000 | [diff] [blame] | 49 | * Enumeration of window handle type. |
| 50 | */ |
| 51 | typedef enum pjmedia_vid_dev_hwnd_type |
| 52 | { |
| 53 | /** |
| 54 | * Type none. |
| 55 | */ |
| 56 | PJMEDIA_VID_DEV_HWND_TYPE_NONE, |
| 57 | |
| 58 | /** |
| 59 | * Native window handle on Windows. |
| 60 | */ |
| 61 | PJMEDIA_VID_DEV_HWND_TYPE_WINDOWS |
| 62 | |
| 63 | } pjmedia_vid_dev_hwnd_type; |
| 64 | |
| 65 | /** |
| 66 | * Type for window handle. |
| 67 | */ |
| 68 | typedef struct pjmedia_vid_dev_hwnd |
| 69 | { |
| 70 | /** |
| 71 | * The window handle type. |
| 72 | */ |
| 73 | pjmedia_vid_dev_hwnd_type type; |
| 74 | |
| 75 | /** |
| 76 | * The window handle. |
| 77 | */ |
| 78 | union |
| 79 | { |
Sauw Ming | edc3050 | 2011-07-22 08:28:53 +0000 | [diff] [blame] | 80 | struct { |
| 81 | void *hwnd; /**< HWND */ |
| 82 | } win; |
| 83 | struct { |
| 84 | void *window; /**< Window */ |
| 85 | void *display; /**< Display */ |
| 86 | } x11; |
| 87 | struct { |
| 88 | void *window; /**< Window */ |
| 89 | } cocoa; |
| 90 | struct { |
| 91 | void *window; /**< Window */ |
| 92 | } ios; |
| 93 | void *window; |
| 94 | } info; |
Nanang Izzuddin | 6e2fcc3 | 2011-07-22 04:49:36 +0000 | [diff] [blame] | 95 | |
| 96 | } pjmedia_vid_dev_hwnd; |
| 97 | |
| 98 | /** |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 99 | * Device index constants. |
| 100 | */ |
| 101 | enum |
| 102 | { |
| 103 | /** |
| 104 | * Constant to denote default capture device |
| 105 | */ |
| 106 | PJMEDIA_VID_DEFAULT_CAPTURE_DEV = -1, |
| 107 | |
| 108 | /** |
| 109 | * Constant to denote default render device |
| 110 | */ |
| 111 | PJMEDIA_VID_DEFAULT_RENDER_DEV = -2, |
| 112 | |
| 113 | /** |
| 114 | * Constant to denote invalid device index. |
| 115 | */ |
| 116 | PJMEDIA_VID_INVALID_DEV = -3 |
| 117 | }; |
| 118 | |
| 119 | |
| 120 | /** |
| 121 | * This enumeration identifies various video device capabilities. These video |
| 122 | * capabilities indicates what features are supported by the underlying |
| 123 | * video device implementation. |
| 124 | * |
| 125 | * Applications get these capabilities in the #pjmedia_vid_dev_info structure. |
| 126 | * |
| 127 | * Application can also set the specific features/capabilities when opening |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 128 | * the video stream by setting the \a flags member of #pjmedia_vid_dev_param |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 129 | * structure. |
| 130 | * |
| 131 | * Once video stream is running, application can also retrieve or set some |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 132 | * specific video capability, by using #pjmedia_vid_dev_stream_get_cap() and |
| 133 | * #pjmedia_vid_dev_stream_set_cap() and specifying the desired capability. The |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 134 | * value of the capability is specified as pointer, and application needs to |
| 135 | * supply the pointer with the correct value, according to the documentation |
| 136 | * of each of the capability. |
| 137 | */ |
| 138 | typedef enum pjmedia_vid_dev_cap |
| 139 | { |
| 140 | /** |
| 141 | * Support for video formats. The value of this capability |
| 142 | * is represented by #pjmedia_format structure. |
| 143 | */ |
| 144 | PJMEDIA_VID_DEV_CAP_FORMAT = 1, |
| 145 | |
| 146 | /** |
| 147 | * Support for video input scaling |
| 148 | */ |
| 149 | PJMEDIA_VID_DEV_CAP_INPUT_SCALE = 2, |
| 150 | |
| 151 | /** |
| 152 | * The application can provide a window for the renderer to |
| 153 | * display the video. |
| 154 | */ |
| 155 | PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW = 4, |
| 156 | |
| 157 | /** |
| 158 | * Support for resizing video output. This capability SHOULD be |
| 159 | * implemented by renderer, to alter the video output dimension on the fly. |
| 160 | * Value is pjmedia_rect_size. |
| 161 | */ |
| 162 | PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE = 8, |
| 163 | |
| 164 | /** |
Sauw Ming | 46cdaa8 | 2011-06-20 06:16:08 +0000 | [diff] [blame] | 165 | * Support for setting the video window's position. |
| 166 | * Value is pjmedia_coord specifying the window's new coordinate. |
| 167 | */ |
| 168 | PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION = 16, |
| 169 | |
| 170 | /** |
| 171 | * Support for setting the video output's visibility. |
| 172 | * The value of this capability is a pj_bool_t containing boolean |
| 173 | * PJ_TRUE or PJ_FALSE. |
| 174 | */ |
| 175 | PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE = 32, |
| 176 | |
| 177 | /** |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 178 | * End of capability |
| 179 | */ |
| 180 | PJMEDIA_VID_DEV_CAP_MAX = 16384 |
| 181 | |
| 182 | } pjmedia_vid_dev_cap; |
| 183 | |
| 184 | /** |
| 185 | * Device information structure returned by #pjmedia_vid_dev_get_info(). |
| 186 | */ |
| 187 | typedef struct pjmedia_vid_dev_info |
| 188 | { |
Nanang Izzuddin | f4ee415 | 2011-07-12 03:20:36 +0000 | [diff] [blame] | 189 | /** The device ID */ |
| 190 | pjmedia_vid_dev_index id; |
| 191 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 192 | /** The device name */ |
| 193 | char name[64]; |
| 194 | |
| 195 | /** The underlying driver name */ |
| 196 | char driver[32]; |
| 197 | |
| 198 | /** |
| 199 | * The supported direction of the video device, i.e. whether it supports |
| 200 | * capture only, render only, or both. |
| 201 | */ |
| 202 | pjmedia_dir dir; |
| 203 | |
| 204 | /** Specify whether the device supports callback */ |
| 205 | pj_bool_t has_callback; |
| 206 | |
| 207 | /** Device capabilities, as bitmask combination of #pjmedia_vid_dev_cap */ |
| 208 | unsigned caps; |
| 209 | |
| 210 | /** Number of video formats supported by this device */ |
| 211 | unsigned fmt_cnt; |
| 212 | |
| 213 | /** |
| 214 | * Array of supported video formats. Some fields in each supported video |
| 215 | * format may be set to zero or of "unknown" value, to indicate that the |
| 216 | * value is unknown or should be ignored. When these value are not set |
| 217 | * to zero, it indicates that the exact format combination is being used. |
| 218 | */ |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 219 | pjmedia_format fmt[PJMEDIA_VID_DEV_INFO_FMT_CNT]; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 220 | |
| 221 | } pjmedia_vid_dev_info; |
| 222 | |
| 223 | |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 224 | /** Forward declaration for pjmedia_vid_dev_stream */ |
| 225 | typedef struct pjmedia_vid_dev_stream pjmedia_vid_dev_stream; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 226 | |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 227 | typedef struct pjmedia_vid_dev_cb |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 228 | { |
| 229 | /** |
| 230 | * This callback is called by capturer stream when it has captured the |
| 231 | * whole packet worth of video samples. |
| 232 | * |
| 233 | * @param stream The video stream. |
| 234 | * @param user_data User data associated with the stream. |
| 235 | * @param frame Captured frame. |
| 236 | * |
| 237 | * @return Returning non-PJ_SUCCESS will cause the video |
| 238 | * stream to stop |
| 239 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 240 | pj_status_t (*capture_cb)(pjmedia_vid_dev_stream *stream, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 241 | void *user_data, |
| 242 | pjmedia_frame *frame); |
| 243 | |
| 244 | /** |
| 245 | * This callback is called by renderer stream when it needs additional |
| 246 | * data to be rendered by the device. Application must fill in the whole |
| 247 | * of output buffer with video samples. |
| 248 | * |
| 249 | * The frame argument contains the following values: |
| 250 | * - timestamp Rendering timestamp, in samples. |
| 251 | * - buf Buffer to be filled out by application. |
| 252 | * - size The size requested in bytes, which will be equal |
| 253 | * to the size of one whole packet. |
| 254 | * |
| 255 | * @param stream The video stream. |
| 256 | * @param user_data User data associated with the stream. |
| 257 | * @param frame Video frame, which buffer is to be filled in by |
| 258 | * the application. |
| 259 | * |
| 260 | * @return Returning non-PJ_SUCCESS will cause the video |
| 261 | * stream to stop |
| 262 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 263 | pj_status_t (*render_cb)(pjmedia_vid_dev_stream *stream, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 264 | void *user_data, |
| 265 | pjmedia_frame *frame); |
| 266 | |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 267 | } pjmedia_vid_dev_cb; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 268 | |
| 269 | |
| 270 | /** |
| 271 | * This structure specifies the parameters to open the video stream. |
| 272 | */ |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 273 | typedef struct pjmedia_vid_dev_param |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 274 | { |
| 275 | /** |
| 276 | * The video direction. This setting is mandatory. |
| 277 | */ |
| 278 | pjmedia_dir dir; |
| 279 | |
| 280 | /** |
| 281 | * The video capture device ID. This setting is mandatory if the video |
| 282 | * direction includes input/capture direction. |
| 283 | */ |
| 284 | pjmedia_vid_dev_index cap_id; |
| 285 | |
| 286 | /** |
| 287 | * The video render device ID. This setting is mandatory if the video |
| 288 | * direction includes output/render direction. |
| 289 | */ |
| 290 | pjmedia_vid_dev_index rend_id; |
| 291 | |
| 292 | /** |
| 293 | * Video clock rate. This setting is mandatory if the video |
| 294 | * direction includes input/capture direction |
| 295 | */ |
| 296 | unsigned clock_rate; |
| 297 | |
| 298 | /** |
| 299 | * Video frame rate. This setting is mandatory if the video |
| 300 | * direction includes input/capture direction |
| 301 | */ |
Sauw Ming | b1b17d2 | 2010-12-20 11:02:48 +0000 | [diff] [blame] | 302 | // pjmedia_ratio frame_rate; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 303 | |
| 304 | /** |
| 305 | * This flags specifies which of the optional settings are valid in this |
| 306 | * structure. The flags is bitmask combination of pjmedia_vid_dev_cap. |
| 307 | */ |
| 308 | unsigned flags; |
| 309 | |
| 310 | /** |
| 311 | * Set the video format. This setting is mandatory. |
| 312 | */ |
| 313 | pjmedia_format fmt; |
| 314 | |
| 315 | /** |
| 316 | * Window for the renderer to display the video. This setting is optional, |
| 317 | * and will only be used if PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW is set in |
| 318 | * the flags. |
| 319 | */ |
Nanang Izzuddin | 6e2fcc3 | 2011-07-22 04:49:36 +0000 | [diff] [blame] | 320 | pjmedia_vid_dev_hwnd window; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 321 | |
| 322 | /** |
| 323 | * Video display size. This setting is optional, and will only be used |
| 324 | * if PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE is set in the flags. |
| 325 | */ |
| 326 | pjmedia_rect_size disp_size; |
| 327 | |
Sauw Ming | 46cdaa8 | 2011-06-20 06:16:08 +0000 | [diff] [blame] | 328 | /** |
| 329 | * Video window position. This setting is optional, and will only be used |
| 330 | * if PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION is set in the flags. |
| 331 | */ |
| 332 | pjmedia_coord window_pos; |
| 333 | |
| 334 | /** |
| 335 | * Video window's visibility. This setting is optional, and will only be |
| 336 | * used if PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE is set in the flags. |
| 337 | */ |
| 338 | pj_bool_t window_hide; |
| 339 | |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 340 | } pjmedia_vid_dev_param; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 341 | |
| 342 | |
| 343 | /** Forward declaration for video device factory */ |
| 344 | typedef struct pjmedia_vid_dev_factory pjmedia_vid_dev_factory; |
| 345 | |
| 346 | /* typedef for factory creation function */ |
| 347 | typedef pjmedia_vid_dev_factory* |
| 348 | (*pjmedia_vid_dev_factory_create_func_ptr)(pj_pool_factory*); |
| 349 | |
| 350 | |
| 351 | /** |
| 352 | * Get string info for the specified capability. |
| 353 | * |
| 354 | * @param cap The capability ID. |
| 355 | * @param p_desc Optional pointer which will be filled with longer |
| 356 | * description about the capability. |
| 357 | * |
| 358 | * @return Capability name. |
| 359 | */ |
| 360 | PJ_DECL(const char*) pjmedia_vid_dev_cap_name(pjmedia_vid_dev_cap cap, |
| 361 | const char **p_desc); |
| 362 | |
| 363 | |
| 364 | /** |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 365 | * Set a capability field value in #pjmedia_vid_dev_param structure. This will |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 366 | * also set the flags field for the specified capability in the structure. |
| 367 | * |
| 368 | * @param param The structure. |
| 369 | * @param cap The video capability which value is to be set. |
| 370 | * @param pval Pointer to value. Please see the type of value to |
| 371 | * be supplied in the pjmedia_vid_dev_cap documentation. |
| 372 | * |
| 373 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 374 | * error code. |
| 375 | */ |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 376 | PJ_DECL(pj_status_t) |
| 377 | pjmedia_vid_dev_param_set_cap(pjmedia_vid_dev_param *param, |
| 378 | pjmedia_vid_dev_cap cap, |
| 379 | const void *pval); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 380 | |
| 381 | |
| 382 | /** |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 383 | * Get a capability field value from #pjmedia_vid_dev_param structure. This |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 384 | * function will return PJMEDIA_EVID_INVCAP error if the flag for that |
| 385 | * capability is not set in the flags field in the structure. |
| 386 | * |
| 387 | * @param param The structure. |
| 388 | * @param cap The video capability which value is to be retrieved. |
| 389 | * @param pval Pointer to value. Please see the type of value to |
| 390 | * be supplied in the pjmedia_vid_dev_cap documentation. |
| 391 | * |
| 392 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 393 | * error code. |
| 394 | */ |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 395 | PJ_DECL(pj_status_t) |
| 396 | pjmedia_vid_dev_param_get_cap(const pjmedia_vid_dev_param *param, |
| 397 | pjmedia_vid_dev_cap cap, |
| 398 | void *pval); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 399 | |
| 400 | /** |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 401 | * Initialize the video device subsystem. This will register all supported |
| 402 | * video device factories to the video device subsystem. This function may be |
| 403 | * called more than once, but each call to this function must have the |
| 404 | * corresponding #pjmedia_vid_dev_subsys_shutdown() call. |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 405 | * |
| 406 | * @param pf The pool factory. |
| 407 | * |
| 408 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 409 | * error code. |
| 410 | */ |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 411 | PJ_DECL(pj_status_t) pjmedia_vid_dev_subsys_init(pj_pool_factory *pf); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 412 | |
| 413 | |
| 414 | /** |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 415 | * Get the pool factory registered to the video device subsystem. |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 416 | * |
| 417 | * @return The pool factory. |
| 418 | */ |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 419 | PJ_DECL(pj_pool_factory*) pjmedia_vid_dev_subsys_get_pool_factory(void); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 420 | |
| 421 | |
| 422 | /** |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 423 | * Shutdown the video device subsystem. This will destroy all video device |
| 424 | * factories registered in the video device subsystem. Note that currently |
| 425 | * opened video streams may or may not be closed, depending on the |
| 426 | * implementation of the video device factories. |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 427 | * |
| 428 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 429 | * error code. |
| 430 | */ |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 431 | PJ_DECL(pj_status_t) pjmedia_vid_dev_subsys_shutdown(void); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 432 | |
| 433 | |
| 434 | /** |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 435 | * Register a supported video device factory to the video device subsystem. |
| 436 | * This function can only be called after calling |
| 437 | * #pjmedia_vid_dev_subsys_init(). |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 438 | * |
| 439 | * @param vdf The video device factory. |
| 440 | * |
| 441 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 442 | * error code. |
| 443 | */ |
| 444 | PJ_DECL(pj_status_t) |
| 445 | pjmedia_vid_register_factory(pjmedia_vid_dev_factory_create_func_ptr vdf); |
| 446 | |
| 447 | |
| 448 | /** |
Sauw Ming | e90ece8 | 2011-06-09 04:05:44 +0000 | [diff] [blame] | 449 | * Unregister a video device factory from the video device subsystem. This |
| 450 | * function can only be called after calling #pjmedia_vid_dev_subsys_init(). |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 451 | * Devices from this factory will be unlisted. If a device from this factory |
| 452 | * is currently in use, then the behavior is undefined. |
| 453 | * |
| 454 | * @param vdf The video device factory. |
| 455 | * |
| 456 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 457 | * error code. |
| 458 | */ |
| 459 | PJ_DECL(pj_status_t) |
| 460 | pjmedia_vid_unregister_factory(pjmedia_vid_dev_factory_create_func_ptr vdf); |
| 461 | |
| 462 | |
| 463 | /** |
Sauw Ming | 7f7c5bd | 2011-06-21 09:33:01 +0000 | [diff] [blame] | 464 | * Refresh the list of video devices installed in the system. This function |
| 465 | * will only refresh the list of videoo device so all active video streams will |
| 466 | * be unaffected. After refreshing the device list, application MUST make sure |
| 467 | * to update all index references to video devices (i.e. all variables of type |
| 468 | * pjmedia_vid_dev_index) before calling any function that accepts video device |
| 469 | * index as its parameter. |
| 470 | * |
| 471 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 472 | * error code. |
| 473 | */ |
| 474 | PJ_DECL(pj_status_t) pjmedia_vid_dev_refresh(void); |
| 475 | |
| 476 | |
| 477 | /** |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 478 | * Get the number of video devices installed in the system. |
| 479 | * |
| 480 | * @return The number of video devices installed in the system. |
| 481 | */ |
| 482 | PJ_DECL(unsigned) pjmedia_vid_dev_count(void); |
| 483 | |
| 484 | |
| 485 | /** |
| 486 | * Get device information. |
| 487 | * |
| 488 | * @param id The video device ID. |
| 489 | * @param info The device information which will be filled in by this |
| 490 | * function once it returns successfully. |
| 491 | * |
| 492 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 493 | * error code. |
| 494 | */ |
| 495 | PJ_DECL(pj_status_t) pjmedia_vid_dev_get_info(pjmedia_vid_dev_index id, |
| 496 | pjmedia_vid_dev_info *info); |
| 497 | |
| 498 | |
| 499 | /** |
| 500 | * Lookup device index based on the driver and device name. |
| 501 | * |
| 502 | * @param drv_name The driver name. |
| 503 | * @param dev_name The device name. |
| 504 | * @param id Pointer to store the returned device ID. |
| 505 | * |
| 506 | * @return PJ_SUCCESS if the device can be found. |
| 507 | */ |
| 508 | PJ_DECL(pj_status_t) pjmedia_vid_dev_lookup(const char *drv_name, |
| 509 | const char *dev_name, |
| 510 | pjmedia_vid_dev_index *id); |
| 511 | |
| 512 | |
| 513 | /** |
| 514 | * Initialize the video device parameters with default values for the |
| 515 | * specified device. |
| 516 | * |
| 517 | * @param id The video device ID. |
| 518 | * @param param The video device parameters which will be initialized |
| 519 | * by this function once it returns successfully. |
| 520 | * |
| 521 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 522 | * error code. |
| 523 | */ |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 524 | PJ_DECL(pj_status_t) |
| 525 | pjmedia_vid_dev_default_param(pj_pool_t *pool, |
| 526 | pjmedia_vid_dev_index id, |
| 527 | pjmedia_vid_dev_param *param); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 528 | |
| 529 | |
| 530 | /** |
Benny Prijono | e9f70d8 | 2011-03-25 08:38:26 +0000 | [diff] [blame] | 531 | * Open video stream object using the specified parameters. If stream is |
| 532 | * created successfully, this function will return PJ_SUCCESS and the |
| 533 | * stream pointer will be returned in the p_strm argument. |
| 534 | * |
| 535 | * The opened stream may have been opened with different size and fps |
| 536 | * than the requested values in the \a param argument. Application should |
| 537 | * check the actual size and fps that the stream was opened with by inspecting |
| 538 | * the values in the \a param argument and see if they have changed. Also |
| 539 | * if the device ID in the \a param specifies default device, it may be |
| 540 | * replaced with the actual device ID upon return. |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 541 | * |
| 542 | * @param param Sound device parameters to be used for the stream. |
| 543 | * @param cb Pointer to structure containing video stream |
| 544 | * callbacks. |
| 545 | * @param user_data Arbitrary user data, which will be given back in the |
| 546 | * callbacks. |
| 547 | * @param p_strm Pointer to receive the video stream. |
| 548 | * |
| 549 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 550 | * error code. |
| 551 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 552 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_create( |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 553 | pjmedia_vid_dev_param *param, |
| 554 | const pjmedia_vid_dev_cb *cb, |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 555 | void *user_data, |
| 556 | pjmedia_vid_dev_stream **p_strm); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 557 | |
| 558 | /** |
| 559 | * Get the running parameters for the specified video stream. |
| 560 | * |
| 561 | * @param strm The video stream. |
| 562 | * @param param Video stream parameters to be filled in by this |
| 563 | * function once it returns successfully. |
| 564 | * |
| 565 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 566 | * error code. |
| 567 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 568 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_param( |
| 569 | pjmedia_vid_dev_stream *strm, |
Sauw Ming | 5291a2d | 2011-07-15 07:52:44 +0000 | [diff] [blame] | 570 | pjmedia_vid_dev_param *param); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 571 | |
| 572 | /** |
| 573 | * Get the value of a specific capability of the video stream. |
| 574 | * |
| 575 | * @param strm The video stream. |
| 576 | * @param cap The video capability which value is to be retrieved. |
| 577 | * @param value Pointer to value to be filled in by this function |
| 578 | * once it returns successfully. Please see the type |
| 579 | * of value to be supplied in the pjmedia_vid_dev_cap |
| 580 | * documentation. |
| 581 | * |
| 582 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 583 | * error code. |
| 584 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 585 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_cap( |
| 586 | pjmedia_vid_dev_stream *strm, |
| 587 | pjmedia_vid_dev_cap cap, |
| 588 | void *value); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 589 | |
| 590 | /** |
| 591 | * Set the value of a specific capability of the video stream. |
| 592 | * |
| 593 | * @param strm The video stream. |
| 594 | * @param cap The video capability which value is to be set. |
| 595 | * @param value Pointer to value. Please see the type of value to |
| 596 | * be supplied in the pjmedia_vid_dev_cap documentation. |
| 597 | * |
| 598 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 599 | * error code. |
| 600 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 601 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_set_cap( |
| 602 | pjmedia_vid_dev_stream *strm, |
| 603 | pjmedia_vid_dev_cap cap, |
| 604 | const void *value); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 605 | |
| 606 | /** |
| 607 | * Start the stream. |
| 608 | * |
| 609 | * @param strm The video stream. |
| 610 | * |
| 611 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 612 | * error code. |
| 613 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 614 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_start( |
| 615 | pjmedia_vid_dev_stream *strm); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 616 | |
Benny Prijono | 934af0f | 2011-07-12 03:05:35 +0000 | [diff] [blame] | 617 | /** |
| 618 | * Get the event publisher object for the video stream. Caller typically use |
| 619 | * the returned object to subscribe or unsubscribe events from the video |
| 620 | * stream. |
| 621 | * |
| 622 | * @param strm The video stream. |
| 623 | * |
| 624 | * @return The event publisher object. |
| 625 | */ |
| 626 | PJ_DECL(pjmedia_event_publisher*) |
| 627 | pjmedia_vid_dev_stream_get_event_publisher(pjmedia_vid_dev_stream *strm); |
| 628 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 629 | /* Get/put frame API for passive stream */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 630 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_frame( |
| 631 | pjmedia_vid_dev_stream *strm, |
| 632 | pjmedia_frame *frame); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 633 | |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 634 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_put_frame( |
| 635 | pjmedia_vid_dev_stream *strm, |
| 636 | const pjmedia_frame *frame); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 637 | |
| 638 | /** |
| 639 | * Stop the stream. |
| 640 | * |
| 641 | * @param strm The video stream. |
| 642 | * |
| 643 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 644 | * error code. |
| 645 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 646 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_stop( |
| 647 | pjmedia_vid_dev_stream *strm); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 648 | |
| 649 | /** |
| 650 | * Destroy the stream. |
| 651 | * |
| 652 | * @param strm The video stream. |
| 653 | * |
| 654 | * @return PJ_SUCCESS on successful operation or the appropriate |
| 655 | * error code. |
| 656 | */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 657 | PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_destroy( |
| 658 | pjmedia_vid_dev_stream *strm); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 659 | |
| 660 | |
| 661 | /** |
| 662 | * @} |
| 663 | */ |
| 664 | |
| 665 | PJ_END_DECL |
| 666 | |
| 667 | |
| 668 | #endif /* __PJMEDIA_VIDEODEV_VIDEODEV_H__ */ |