Group video_device_reference

group video_device_reference

API Reference.

Typedefs

typedef pj_int32_t pjmedia_vid_dev_index

Type for device index.

typedef pjmedia_vid_dev_factory *(*pjmedia_vid_dev_factory_create_func_ptr)(pj_pool_factory*)

Enums

enum pjmedia_vid_dev_hwnd_type

Enumeration of window handle type.

Values:

enumerator PJMEDIA_VID_DEV_HWND_TYPE_NONE

Type none.

enumerator PJMEDIA_VID_DEV_HWND_TYPE_WINDOWS

Native window handle on Windows.

enumerator PJMEDIA_VID_DEV_HWND_TYPE_IOS

Native view on iOS.

enumerator PJMEDIA_VID_DEV_HWND_TYPE_ANDROID

Native window handle on Android.

enum pjmedia_vid_dev_wnd_flag

Enumeration of window flags.

Values:

enumerator PJMEDIA_VID_DEV_WND_BORDER

Window with border.

enumerator PJMEDIA_VID_DEV_WND_RESIZABLE

Window can be resized.

enum pjmedia_vid_dev_std_index

Device index constants.

Values:

enumerator PJMEDIA_VID_DEFAULT_CAPTURE_DEV

Constant to denote default capture device

enumerator PJMEDIA_VID_DEFAULT_RENDER_DEV

Constant to denote default render device

enumerator PJMEDIA_VID_INVALID_DEV

Constant to denote invalid device index.

enum pjmedia_vid_dev_cap

This enumeration identifies various video device capabilities. These video capabilities indicates what features are supported by the underlying video device implementation.

Applications get these capabilities in the pjmedia_vid_dev_info structure.

Application can also set the specific features/capabilities when opening the video stream by setting the flags member of pjmedia_vid_dev_param structure.

Once video stream is running, application can also retrieve or set some specific video capability, by using pjmedia_vid_dev_stream_get_cap() and pjmedia_vid_dev_stream_set_cap() and specifying the desired capability. The value of the capability is specified as pointer, and application needs to supply the pointer with the correct value, according to the documentation of each of the capability.

Values:

enumerator PJMEDIA_VID_DEV_CAP_FORMAT

Support for video formats. The value of this capability is represented by pjmedia_format structure.

enumerator PJMEDIA_VID_DEV_CAP_INPUT_SCALE

Support for video input scaling

enumerator PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW

Support for returning the native window handle of the video window. For renderer, this means the window handle of the renderer window, while for capture, this means the window handle of the native preview, only if the device supports PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW capability.

The value of this capability is pointer to pjmedia_vid_dev_hwnd structure.

enumerator PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE

Support for resizing video output. This capability SHOULD be implemented by renderer, to alter the video output dimension on the fly. Value is pjmedia_rect_size.

enumerator PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION

Support for setting the video window’s position. Value is pjmedia_coord specifying the window’s new coordinate.

enumerator PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE

Support for setting the video output’s visibility. The value of this capability is a pj_bool_t containing boolean PJ_TRUE or PJ_FALSE.

enumerator PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW

Support for native preview capability in capture devices. Value is pj_bool_t. With native preview, capture device can be instructed to show or hide a preview window showing video directly from the camera by setting this capability to PJ_TRUE or PJ_FALSE. Once the preview is started, application may use PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW capability to query the video window.

The value of this capability is a pj_bool_t containing boolean PJ_TRUE or PJ_FALSE.

enumerator PJMEDIA_VID_DEV_CAP_ORIENTATION

Support for changing video orientation. For a renderer device, changing video orientation in will potentially affect the size of render window, i.e: width and height swap. For a capture device, the video will be rotated but the size of the video frame will stay the same, so the video may be resized or stretched.

The value of this capability is pjmedia_orient.

enumerator PJMEDIA_VID_DEV_CAP_SWITCH

Support for fast switching to another device. A video stream with this capability allows replacing of its underlying device with another device, saving the user from opening a new video stream and gets a much faster and smoother switching action.

Note that even when this capability is supported by a device, it may not be able to switch to arbitrary device. Application must always check the return value of the operation to verify that switching has occurred.

This capability is currently write-only (i.e. set-only).

The value of this capability is pointer to pjmedia_vid_dev_switch_param structure.

enumerator PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS

Support for setting the output video window’s flags. The value of this capability is a bitmask combination of pjmedia_vid_dev_wnd_flag.

enumerator PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN

Support for setting the output video window full screen.

enumerator PJMEDIA_VID_DEV_CAP_MAX

End of standard capability

Functions

pjmedia_vid_subsys *pjmedia_get_vid_subsys(void)

Get the video subsystem.

Returns

The video subsystem.

pj_status_t pjmedia_vid_driver_init(unsigned drv_idx, pj_bool_t refresh)

Initialize the video driver.

Parameters
  • drv_idx – The index of the video driver.

  • refresh – Specify non-zero to refresh the video driver.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

void pjmedia_vid_driver_deinit(unsigned drv_idx)

Deinitialize the video driver.

Parameters

drv_idx – The index of the video driver.

void pjmedia_vid_dev_switch_param_default(pjmedia_vid_dev_switch_param *p)

Initialize pjmedia_vid_dev_switch_param.

Parameters

p – Parameter to be initialized.

const char *pjmedia_vid_dev_cap_name(pjmedia_vid_dev_cap cap, const char **p_desc)

Get string info for the specified capability.

Parameters
  • cap – The capability ID.

  • p_desc – Optional pointer which will be filled with longer description about the capability.

Returns

Capability name.

pj_status_t pjmedia_vid_dev_param_set_cap(pjmedia_vid_dev_param *param, pjmedia_vid_dev_cap cap, const void *pval)

Set a capability field value in pjmedia_vid_dev_param structure. This will also set the flags field for the specified capability in the structure.

Parameters
  • param – The structure.

  • cap – The video capability which value is to be set.

  • pval – Pointer to value. Please see the type of value to be supplied in the pjmedia_vid_dev_cap documentation.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_param_get_cap(const pjmedia_vid_dev_param *param, pjmedia_vid_dev_cap cap, void *pval)

Get a capability field value from pjmedia_vid_dev_param structure. This function will return PJMEDIA_EVID_INVCAP error if the flag for that capability is not set in the flags field in the structure.

Parameters
  • param – The structure.

  • cap – The video capability which value is to be retrieved.

  • pval – Pointer to value. Please see the type of value to be supplied in the pjmedia_vid_dev_cap documentation.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_refresh(void)

Refresh the list of video devices installed in the system. This function will only refresh the list of videoo device so all active video streams will be unaffected. After refreshing the device list, application MUST make sure to update all index references to video devices (i.e. all variables of type pjmedia_vid_dev_index) before calling any function that accepts video device index as its parameter.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

unsigned pjmedia_vid_dev_count(void)

Get the number of video devices installed in the system.

Returns

The number of video devices installed in the system.

pj_status_t pjmedia_vid_dev_get_info(pjmedia_vid_dev_index id, pjmedia_vid_dev_info *info)

Get device information.

Parameters
  • id – The video device ID.

  • info – The device information which will be filled in by this function once it returns successfully.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_lookup(const char *drv_name, const char *dev_name, pjmedia_vid_dev_index *id)

Lookup device index based on the driver and device name.

Parameters
  • drv_name – The driver name.

  • dev_name – The device name.

  • id – Pointer to store the returned device ID.

Returns

PJ_SUCCESS if the device can be found.

pj_status_t pjmedia_vid_dev_default_param(pj_pool_t *pool, pjmedia_vid_dev_index id, pjmedia_vid_dev_param *param)

Initialize the video device parameters with default values for the specified device.

Parameters
  • id – The video device ID.

  • param – The video device parameters which will be initialized by this function once it returns successfully.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_create(pjmedia_vid_dev_param *param, const pjmedia_vid_dev_cb *cb, void *user_data, pjmedia_vid_dev_stream **p_strm)

Open video stream object using the specified parameters. If stream is created successfully, this function will return PJ_SUCCESS and the stream pointer will be returned in the p_strm argument.

The opened stream may have been opened with different size and fps than the requested values in the param argument. Application should check the actual size and fps that the stream was opened with by inspecting the values in the param argument and see if they have changed. Also if the device ID in the param specifies default device, it may be replaced with the actual device ID upon return.

Parameters
  • param – On input, it specifies the video device parameters to be used for the stream. On output, this will be set to the actual video device parameters used to open the stream.

  • cb – Pointer to structure containing video stream callbacks.

  • user_data – Arbitrary user data, which will be given back in the callbacks.

  • p_strm – Pointer to receive the video stream.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_get_param(pjmedia_vid_dev_stream *strm, pjmedia_vid_dev_param *param)

Get the running parameters for the specified video stream.

Parameters
  • strm – The video stream.

  • param – Video stream parameters to be filled in by this function once it returns successfully.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_get_cap(pjmedia_vid_dev_stream *strm, pjmedia_vid_dev_cap cap, void *value)

Get the value of a specific capability of the video stream.

Parameters
  • strm – The video stream.

  • cap – The video capability which value is to be retrieved.

  • value – Pointer to value to be filled in by this function once it returns successfully. Please see the type of value to be supplied in the pjmedia_vid_dev_cap documentation.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_set_cap(pjmedia_vid_dev_stream *strm, pjmedia_vid_dev_cap cap, const void *value)

Set the value of a specific capability of the video stream.

Parameters
  • strm – The video stream.

  • cap – The video capability which value is to be set.

  • value – Pointer to value. Please see the type of value to be supplied in the pjmedia_vid_dev_cap documentation.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_start(pjmedia_vid_dev_stream *strm)

Start the stream.

Parameters

strm – The video stream.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_bool_t pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm)

Query whether the stream has been started.

Parameters

strm – The video stream

Returns

PJ_TRUE if the video stream has been started.

pj_status_t pjmedia_vid_dev_stream_get_frame(pjmedia_vid_dev_stream *strm, pjmedia_frame *frame)

Request one frame from the stream. Application needs to call this function periodically only if the stream doesn’t support “active interface”, i.e. the pjmedia_vid_dev_info.has_callback member is PJ_FALSE.

Parameters
  • strm – The video stream.

  • frame – The video frame to be filled by the device.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_put_frame(pjmedia_vid_dev_stream *strm, const pjmedia_frame *frame)

Put one frame to the stream. Application needs to call this function periodically only if the stream doesn’t support “active interface”, i.e. the pjmedia_vid_dev_info.has_callback member is PJ_FALSE.

Parameters
  • strm – The video stream.

  • frame – The video frame to put to the device.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_stop(pjmedia_vid_dev_stream *strm)

Stop the stream.

Parameters

strm – The video stream.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_stream_destroy(pjmedia_vid_dev_stream *strm)

Destroy the stream.

Parameters

strm – The video stream.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_dev_subsys_init(pj_pool_factory *pf)

Initialize the video device subsystem. This will register all supported video device factories to the video device subsystem. This function may be called more than once, but each call to this function must have the corresponding pjmedia_vid_dev_subsys_shutdown() call.

Parameters

pf – The pool factory.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_pool_factory *pjmedia_vid_dev_subsys_get_pool_factory(void)

Get the pool factory registered to the video device subsystem.

Returns

The pool factory.

pj_status_t pjmedia_vid_dev_subsys_shutdown(void)

Shutdown the video device subsystem. This will destroy all video device factories registered in the video device subsystem. Note that currently opened video streams may or may not be closed, depending on the implementation of the video device factories.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_register_factory(pjmedia_vid_dev_factory_create_func_ptr vdf, pjmedia_vid_dev_factory *factory)

Register a supported video device factory to the video device subsystem. Application can either register a function to create the factory, or an instance of an already created factory.

This function can only be called after calling pjmedia_vid_dev_subsys_init().

Parameters
  • vdf – The factory creation function. Either vdf or factory argument must be specified.

  • factory – Factory instance. Either vdf or factory argument must be specified.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

pj_status_t pjmedia_vid_unregister_factory(pjmedia_vid_dev_factory_create_func_ptr vdf, pjmedia_vid_dev_factory *factory)

Unregister a video device factory from the video device subsystem. This function can only be called after calling pjmedia_vid_dev_subsys_init(). Devices from this factory will be unlisted. If a device from this factory is currently in use, then the behavior is undefined.

Parameters
  • vdf – The video device factory. Either vdf or factory argument must be specified.

  • factory – The factory instance. Either vdf or factory argument must be specified.

Returns

PJ_SUCCESS on successful operation or the appropriate error code.

struct pjmedia_vid_dev_hwnd
#include <videodev.h>

Type for window handle.

struct pjmedia_vid_dev_switch_param
#include <videodev.h>

Parameter for switching device with PJMEDIA_VID_DEV_CAP_SWITCH capability. Initialize this with pjmedia_vid_dev_switch_param_default()

struct pjmedia_vid_dev_info
#include <videodev.h>

Device information structure returned by pjmedia_vid_dev_get_info().

struct pjmedia_vid_dev_cb
struct pjmedia_vid_dev_param
#include <videodev.h>

This structure specifies the parameters to open the video stream.

struct pjmedia_vid_driver
struct pjmedia_vid_subsys