- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjmedia/include/pjmedia-videodev/videodev.h
r5125 r5513 24 24 * @brief Video device API. 25 25 */ 26 #include <pjmedia-videodev/config.h> 27 #include <pjmedia-videodev/errno.h> 28 #include <pjmedia/event.h> 29 #include <pjmedia/frame.h> 30 #include <pjmedia/format.h> 31 #include <pj/pool.h> 26 #include <pjmedia/videodev.h> 32 27 33 28 … … 35 30 36 31 /** 37 * @defgroup video_device_reference Video DeviceAPI Reference38 * @ingroup video_ device_api32 * @defgroup video_device_reference Video Subsystem API Reference 33 * @ingroup video_subsystem_api 39 34 * @brief API Reference 40 35 * @{ 41 36 */ 42 37 43 /**44 * Type for device index.45 */46 typedef pj_int32_t pjmedia_vid_dev_index;47 48 /**49 * Enumeration of window handle type.50 */51 typedef enum pjmedia_vid_dev_hwnd_type52 {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 /**64 * Native view on iOS.65 */66 PJMEDIA_VID_DEV_HWND_TYPE_IOS,67 68 /**69 * Native window handle on Android.70 */71 PJMEDIA_VID_DEV_HWND_TYPE_ANDROID72 73 } pjmedia_vid_dev_hwnd_type;74 75 /**76 * Type for window handle.77 */78 typedef struct pjmedia_vid_dev_hwnd79 {80 /**81 * The window handle type.82 */83 pjmedia_vid_dev_hwnd_type type;84 85 /**86 * The window handle.87 */88 union89 {90 struct {91 void *hwnd; /**< HWND */92 } win;93 struct {94 void *window; /**< Window */95 void *display; /**< Display */96 } x11;97 struct {98 void *window; /**< Window */99 } cocoa;100 struct {101 void *window; /**< Window */102 } ios;103 struct {104 void *window; /**< Native window */105 } android;106 void *window;107 } info;108 109 } pjmedia_vid_dev_hwnd;110 111 /**112 * Parameter for switching device with PJMEDIA_VID_DEV_CAP_SWITCH capability.113 * Initialize this with pjmedia_vid_dev_switch_param_default()114 */115 typedef struct pjmedia_vid_dev_switch_param116 {117 /**118 * Target device ID to switch to. Once the switching is successful, the119 * video stream will use this device and the old device will be closed.120 */121 pjmedia_vid_dev_index target_id;122 123 } pjmedia_vid_dev_switch_param;124 125 126 /**127 * Enumeration of window flags.128 */129 typedef enum pjmedia_vid_dev_wnd_flag130 {131 /**132 * Window with border.133 */134 PJMEDIA_VID_DEV_WND_BORDER = 1,135 136 /**137 * Window can be resized.138 */139 PJMEDIA_VID_DEV_WND_RESIZABLE = 2140 141 } pjmedia_vid_dev_wnd_flag;142 143 144 /**145 * Device index constants.146 */147 enum pjmedia_vid_dev_std_index148 {149 /**150 * Constant to denote default capture device151 */152 PJMEDIA_VID_DEFAULT_CAPTURE_DEV = -1,153 154 /**155 * Constant to denote default render device156 */157 PJMEDIA_VID_DEFAULT_RENDER_DEV = -2,158 159 /**160 * Constant to denote invalid device index.161 */162 PJMEDIA_VID_INVALID_DEV = -3163 };164 165 166 /**167 * This enumeration identifies various video device capabilities. These video168 * capabilities indicates what features are supported by the underlying169 * video device implementation.170 *171 * Applications get these capabilities in the #pjmedia_vid_dev_info structure.172 *173 * Application can also set the specific features/capabilities when opening174 * the video stream by setting the \a flags member of #pjmedia_vid_dev_param175 * structure.176 *177 * Once video stream is running, application can also retrieve or set some178 * specific video capability, by using #pjmedia_vid_dev_stream_get_cap() and179 * #pjmedia_vid_dev_stream_set_cap() and specifying the desired capability. The180 * value of the capability is specified as pointer, and application needs to181 * supply the pointer with the correct value, according to the documentation182 * of each of the capability.183 */184 typedef enum pjmedia_vid_dev_cap185 {186 /**187 * Support for video formats. The value of this capability188 * is represented by #pjmedia_format structure.189 */190 PJMEDIA_VID_DEV_CAP_FORMAT = 1,191 192 /**193 * Support for video input scaling194 */195 PJMEDIA_VID_DEV_CAP_INPUT_SCALE = 2,196 197 /**198 * Support for returning the native window handle of the video window.199 * For renderer, this means the window handle of the renderer window,200 * while for capture, this means the window handle of the native preview,201 * only if the device supports PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW202 * capability.203 *204 * The value of this capability is pointer to pjmedia_vid_dev_hwnd205 * structure.206 */207 PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW = 4,208 209 /**210 * Support for resizing video output. This capability SHOULD be211 * implemented by renderer, to alter the video output dimension on the fly.212 * Value is pjmedia_rect_size.213 */214 PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE = 8,215 216 /**217 * Support for setting the video window's position.218 * Value is pjmedia_coord specifying the window's new coordinate.219 */220 PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION = 16,221 222 /**223 * Support for setting the video output's visibility.224 * The value of this capability is a pj_bool_t containing boolean225 * PJ_TRUE or PJ_FALSE.226 */227 PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE = 32,228 229 /**230 * Support for native preview capability in capture devices. Value is231 * pj_bool_t. With native preview, capture device can be instructed to232 * show or hide a preview window showing video directly from the camera233 * by setting this capability to PJ_TRUE or PJ_FALSE. Once the preview234 * is started, application may use PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW235 * capability to query the video window.236 *237 * The value of this capability is a pj_bool_t containing boolean238 * PJ_TRUE or PJ_FALSE.239 */240 PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW = 64,241 242 /**243 * Support for changing video orientation. For a renderer device,244 * changing video orientation in will potentially affect the size of245 * render window, i.e: width and height swap. For a capture device,246 * the video will be rotated but the size of the video frame247 * will stay the same, so the video may be resized or stretched.248 *249 * The value of this capability is pjmedia_orient.250 */251 PJMEDIA_VID_DEV_CAP_ORIENTATION = 128,252 253 /**254 * Support for fast switching to another device. A video stream with this255 * capability allows replacing of its underlying device with another256 * device, saving the user from opening a new video stream and gets a much257 * faster and smoother switching action.258 *259 * Note that even when this capability is supported by a device, it may260 * not be able to switch to arbitrary device. Application must always261 * check the return value of the operation to verify that switching has262 * occurred.263 *264 * This capability is currently write-only (i.e. set-only).265 *266 * The value of this capability is pointer to pjmedia_vid_dev_switch_param267 * structure.268 */269 PJMEDIA_VID_DEV_CAP_SWITCH = 256,270 271 /**272 * Support for setting the output video window's flags.273 * The value of this capability is a bitmask combination of274 * #pjmedia_vid_dev_wnd_flag.275 */276 PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS = 512,277 278 /**279 * End of standard capability280 */281 PJMEDIA_VID_DEV_CAP_MAX = 16384282 283 } pjmedia_vid_dev_cap;284 285 /**286 * Device information structure returned by #pjmedia_vid_dev_get_info().287 */288 typedef struct pjmedia_vid_dev_info289 {290 /** The device ID */291 pjmedia_vid_dev_index id;292 293 /** The device name */294 char name[64];295 296 /** The underlying driver name */297 char driver[32];298 299 /**300 * The supported direction of the video device, i.e. whether it supports301 * capture only, render only, or both.302 */303 pjmedia_dir dir;304 305 /**306 * Specify whether the device supports callback. Devices that implement307 * "active interface" will actively call the callbacks to give or ask for308 * video frames. If the device doesn't support callback, application309 * must actively request or give video frames from/to the device by using310 * pjmedia_vid_dev_stream_get_frame()/pjmedia_vid_dev_stream_put_frame().311 */312 pj_bool_t has_callback;313 314 /** Device capabilities, as bitmask combination of #pjmedia_vid_dev_cap */315 unsigned caps;316 317 /** Number of video formats supported by this device */318 unsigned fmt_cnt;319 320 /**321 * Array of supported video formats. Some fields in each supported video322 * format may be set to zero or of "unknown" value, to indicate that the323 * value is unknown or should be ignored. When these value are not set324 * to zero, it indicates that the exact format combination is being used.325 */326 pjmedia_format fmt[PJMEDIA_VID_DEV_INFO_FMT_CNT];327 328 } pjmedia_vid_dev_info;329 330 331 /** Forward declaration for pjmedia_vid_dev_stream */332 typedef struct pjmedia_vid_dev_stream pjmedia_vid_dev_stream;333 334 typedef struct pjmedia_vid_dev_cb335 {336 /**337 * This callback is called by capturer stream when it has captured the338 * whole packet worth of video samples.339 *340 * @param stream The video stream.341 * @param user_data User data associated with the stream.342 * @param frame Captured frame.343 *344 * @return Returning non-PJ_SUCCESS will cause the video345 * stream to stop346 */347 pj_status_t (*capture_cb)(pjmedia_vid_dev_stream *stream,348 void *user_data,349 pjmedia_frame *frame);350 351 /**352 * This callback is called by renderer stream when it needs additional353 * data to be rendered by the device. Application must fill in the whole354 * of output buffer with video samples.355 *356 * The frame argument contains the following values:357 * - timestamp Rendering timestamp, in samples.358 * - buf Buffer to be filled out by application.359 * - size The size requested in bytes, which will be equal360 * to the size of one whole packet.361 *362 * @param stream The video stream.363 * @param user_data User data associated with the stream.364 * @param frame Video frame, which buffer is to be filled in by365 * the application.366 *367 * @return Returning non-PJ_SUCCESS will cause the video368 * stream to stop369 */370 pj_status_t (*render_cb)(pjmedia_vid_dev_stream *stream,371 void *user_data,372 pjmedia_frame *frame);373 374 } pjmedia_vid_dev_cb;375 376 377 /**378 * This structure specifies the parameters to open the video stream.379 */380 typedef struct pjmedia_vid_dev_param381 {382 /**383 * The video direction. This setting is mandatory.384 */385 pjmedia_dir dir;386 387 /**388 * The video capture device ID. This setting is mandatory if the video389 * direction includes input/capture direction.390 */391 pjmedia_vid_dev_index cap_id;392 393 /**394 * The video render device ID. This setting is mandatory if the video395 * direction includes output/render direction.396 */397 pjmedia_vid_dev_index rend_id;398 399 /**400 * Video clock rate. This setting is mandatory if the video401 * direction includes input/capture direction402 */403 unsigned clock_rate;404 405 /**406 * Video frame rate. This setting is mandatory if the video407 * direction includes input/capture direction408 */409 // pjmedia_ratio frame_rate;410 411 /**412 * This flags specifies which of the optional settings are valid in this413 * structure. The flags is bitmask combination of pjmedia_vid_dev_cap.414 */415 unsigned flags;416 417 /**418 * Set the video format. This setting is mandatory.419 */420 pjmedia_format fmt;421 422 /**423 * Window for the renderer to display the video. This setting is optional,424 * and will only be used if PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW is set in425 * the flags.426 */427 pjmedia_vid_dev_hwnd window;428 429 /**430 * Video display size. This setting is optional, and will only be used431 * if PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE is set in the flags.432 */433 pjmedia_rect_size disp_size;434 435 /**436 * Video window position. This setting is optional, and will only be used437 * if PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION is set in the flags.438 */439 pjmedia_coord window_pos;440 441 /**442 * Video window's visibility. This setting is optional, and will only be443 * used if PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE is set in the flags.444 */445 pj_bool_t window_hide;446 447 /**448 * Enable built-in preview. This setting is optional and is only used449 * if PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW capability is supported and450 * set in the flags.451 */452 pj_bool_t native_preview;453 454 /**455 * Video orientation. This setting is optional and is only used if456 * PJMEDIA_VID_DEV_CAP_ORIENTATION capability is supported and is457 * set in the flags.458 */459 pjmedia_orient orient;460 461 /**462 * Video window flags. This setting is optional, and will only be used463 * if PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS is set in the flags.464 */465 unsigned window_flags;466 467 } pjmedia_vid_dev_param;468 469 470 /** Forward declaration for video device factory */471 typedef struct pjmedia_vid_dev_factory pjmedia_vid_dev_factory;472 473 /* typedef for factory creation function */474 typedef pjmedia_vid_dev_factory*475 (*pjmedia_vid_dev_factory_create_func_ptr)(pj_pool_factory*);476 477 /**478 * Initialize pjmedia_vid_dev_switch_param.479 *480 * @param p Parameter to be initialized.481 */482 PJ_INLINE(void)483 pjmedia_vid_dev_switch_param_default(pjmedia_vid_dev_switch_param *p)484 {485 pj_bzero(p, sizeof(*p));486 p->target_id = PJMEDIA_VID_INVALID_DEV;487 }488 489 /**490 * Get string info for the specified capability.491 *492 * @param cap The capability ID.493 * @param p_desc Optional pointer which will be filled with longer494 * description about the capability.495 *496 * @return Capability name.497 */498 PJ_DECL(const char*) pjmedia_vid_dev_cap_name(pjmedia_vid_dev_cap cap,499 const char **p_desc);500 501 502 /**503 * Set a capability field value in #pjmedia_vid_dev_param structure. This will504 * also set the flags field for the specified capability in the structure.505 *506 * @param param The structure.507 * @param cap The video capability which value is to be set.508 * @param pval Pointer to value. Please see the type of value to509 * be supplied in the pjmedia_vid_dev_cap documentation.510 *511 * @return PJ_SUCCESS on successful operation or the appropriate512 * error code.513 */514 PJ_DECL(pj_status_t)515 pjmedia_vid_dev_param_set_cap(pjmedia_vid_dev_param *param,516 pjmedia_vid_dev_cap cap,517 const void *pval);518 519 520 /**521 * Get a capability field value from #pjmedia_vid_dev_param structure. This522 * function will return PJMEDIA_EVID_INVCAP error if the flag for that523 * capability is not set in the flags field in the structure.524 *525 * @param param The structure.526 * @param cap The video capability which value is to be retrieved.527 * @param pval Pointer to value. Please see the type of value to528 * be supplied in the pjmedia_vid_dev_cap documentation.529 *530 * @return PJ_SUCCESS on successful operation or the appropriate531 * error code.532 */533 PJ_DECL(pj_status_t)534 pjmedia_vid_dev_param_get_cap(const pjmedia_vid_dev_param *param,535 pjmedia_vid_dev_cap cap,536 void *pval);537 38 538 39 /** … … 611 112 612 113 /** 613 * Refresh the list of video devices installed in the system. This function614 * will only refresh the list of videoo device so all active video streams will615 * be unaffected. After refreshing the device list, application MUST make sure616 * to update all index references to video devices (i.e. all variables of type617 * pjmedia_vid_dev_index) before calling any function that accepts video device618 * index as its parameter.619 *620 * @return PJ_SUCCESS on successful operation or the appropriate621 * error code.622 */623 PJ_DECL(pj_status_t) pjmedia_vid_dev_refresh(void);624 625 626 /**627 * Get the number of video devices installed in the system.628 *629 * @return The number of video devices installed in the system.630 */631 PJ_DECL(unsigned) pjmedia_vid_dev_count(void);632 633 634 /**635 * Get device information.636 *637 * @param id The video device ID.638 * @param info The device information which will be filled in by this639 * function once it returns successfully.640 *641 * @return PJ_SUCCESS on successful operation or the appropriate642 * error code.643 */644 PJ_DECL(pj_status_t) pjmedia_vid_dev_get_info(pjmedia_vid_dev_index id,645 pjmedia_vid_dev_info *info);646 647 648 /**649 * Lookup device index based on the driver and device name.650 *651 * @param drv_name The driver name.652 * @param dev_name The device name.653 * @param id Pointer to store the returned device ID.654 *655 * @return PJ_SUCCESS if the device can be found.656 */657 PJ_DECL(pj_status_t) pjmedia_vid_dev_lookup(const char *drv_name,658 const char *dev_name,659 pjmedia_vid_dev_index *id);660 661 662 /**663 * Initialize the video device parameters with default values for the664 * specified device.665 *666 * @param id The video device ID.667 * @param param The video device parameters which will be initialized668 * by this function once it returns successfully.669 *670 * @return PJ_SUCCESS on successful operation or the appropriate671 * error code.672 */673 PJ_DECL(pj_status_t)674 pjmedia_vid_dev_default_param(pj_pool_t *pool,675 pjmedia_vid_dev_index id,676 pjmedia_vid_dev_param *param);677 678 679 /**680 * Open video stream object using the specified parameters. If stream is681 * created successfully, this function will return PJ_SUCCESS and the682 * stream pointer will be returned in the p_strm argument.683 *684 * The opened stream may have been opened with different size and fps685 * than the requested values in the \a param argument. Application should686 * check the actual size and fps that the stream was opened with by inspecting687 * the values in the \a param argument and see if they have changed. Also688 * if the device ID in the \a param specifies default device, it may be689 * replaced with the actual device ID upon return.690 *691 * @param param On input, it specifies the video device parameters692 * to be used for the stream. On output, this will be693 * set to the actual video device parameters used to694 * open the stream.695 * @param cb Pointer to structure containing video stream696 * callbacks.697 * @param user_data Arbitrary user data, which will be given back in the698 * callbacks.699 * @param p_strm Pointer to receive the video stream.700 *701 * @return PJ_SUCCESS on successful operation or the appropriate702 * error code.703 */704 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_create(705 pjmedia_vid_dev_param *param,706 const pjmedia_vid_dev_cb *cb,707 void *user_data,708 pjmedia_vid_dev_stream **p_strm);709 710 /**711 * Get the running parameters for the specified video stream.712 *713 * @param strm The video stream.714 * @param param Video stream parameters to be filled in by this715 * function once it returns successfully.716 *717 * @return PJ_SUCCESS on successful operation or the appropriate718 * error code.719 */720 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_param(721 pjmedia_vid_dev_stream *strm,722 pjmedia_vid_dev_param *param);723 724 /**725 * Get the value of a specific capability of the video stream.726 *727 * @param strm The video stream.728 * @param cap The video capability which value is to be retrieved.729 * @param value Pointer to value to be filled in by this function730 * once it returns successfully. Please see the type731 * of value to be supplied in the pjmedia_vid_dev_cap732 * documentation.733 *734 * @return PJ_SUCCESS on successful operation or the appropriate735 * error code.736 */737 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_cap(738 pjmedia_vid_dev_stream *strm,739 pjmedia_vid_dev_cap cap,740 void *value);741 742 /**743 * Set the value of a specific capability of the video stream.744 *745 * @param strm The video stream.746 * @param cap The video capability which value is to be set.747 * @param value Pointer to value. Please see the type of value to748 * be supplied in the pjmedia_vid_dev_cap documentation.749 *750 * @return PJ_SUCCESS on successful operation or the appropriate751 * error code.752 */753 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_set_cap(754 pjmedia_vid_dev_stream *strm,755 pjmedia_vid_dev_cap cap,756 const void *value);757 758 /**759 * Start the stream.760 *761 * @param strm The video stream.762 *763 * @return PJ_SUCCESS on successful operation or the appropriate764 * error code.765 */766 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_start(767 pjmedia_vid_dev_stream *strm);768 769 /**770 * Query whether the stream has been started.771 *772 * @param strm The video stream773 *774 * @return PJ_TRUE if the video stream has been started.775 */776 PJ_DECL(pj_bool_t) pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm);777 778 779 /**780 * Request one frame from the stream. Application needs to call this function781 * periodically only if the stream doesn't support "active interface", i.e.782 * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE.783 *784 * @param strm The video stream.785 * @param frame The video frame to be filled by the device.786 *787 * @return PJ_SUCCESS on successful operation or the appropriate788 * error code.789 */790 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_frame(791 pjmedia_vid_dev_stream *strm,792 pjmedia_frame *frame);793 794 /**795 * Put one frame to the stream. Application needs to call this function796 * periodically only if the stream doesn't support "active interface", i.e.797 * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE.798 *799 * @param strm The video stream.800 * @param frame The video frame to put to the device.801 *802 * @return PJ_SUCCESS on successful operation or the appropriate803 * error code.804 */805 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_put_frame(806 pjmedia_vid_dev_stream *strm,807 const pjmedia_frame *frame);808 809 /**810 * Stop the stream.811 *812 * @param strm The video stream.813 *814 * @return PJ_SUCCESS on successful operation or the appropriate815 * error code.816 */817 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_stop(818 pjmedia_vid_dev_stream *strm);819 820 /**821 * Destroy the stream.822 *823 * @param strm The video stream.824 *825 * @return PJ_SUCCESS on successful operation or the appropriate826 * error code.827 */828 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_destroy(829 pjmedia_vid_dev_stream *strm);830 831 832 /**833 114 * @} 834 115 */
Note: See TracChangeset
for help on using the changeset viewer.