VRDEVideoIn.h revision 15071fa8e053848b4a479e9c2be14231c115f330
/** @file
* VBox Remote Desktop Extension (VRDE) - Video Input interface.
*/
/*
* Copyright (C) 2012-2013 Oracle Corporation
*
* Oracle Corporation confidential
* All rights reserved
*/
/* Define VRDE_VIDEOIN_WITH_VRDEINTERFACE to include the server VRDE interface parts. */
#endif /* VRDE_VIDEOIN_WITH_VRDEINTERFACE */
#ifdef AssertCompileSize
#else
#endif /* AssertCompileSize */
/*
* Interface for accessing a video camera device on the client.
*
* Async callbacks are used for providing feedback, reporting errors, etc.
*
* Initial version supports: Camera + Processing Unit + Streaming Control.
*
* There are 2 modes:
* 1) The virtual WebCam is already attached to the guest.
* 2) The virtual WebCam will be attached when the client has it.
*
* Initially the mode 1 is supported.
*
* Mode 1 details:
* The WebCam has some fixed functionality, according to the descriptors,
* which has been already read by the guest. So some of functions will
* not work if the client does not support them.
*
* Mode 2 details:
* Virtual WebCam descriptors are built from the client capabilities.
*
* Similarly to the smartcard, the server will inform the ConsoleVRDE that there is a WebCam.
* ConsoleVRDE creates a VRDEVIDEOIN handle and forwards virtual WebCam requests to it.
*
* Interface with VBox.
*
* Virtual WebCam ConsoleVRDE VRDE
*
* Negotiate <->
* <- VideoInDeviceNotify(Attached, DeviceId)
* -> GetDeviceDesc
* <- DeviceDesc
* 2 <- CreateCamera
* 2 CameraCreated ->
*
* CameraRequest -> Request ->
* Response <- <- Response <- Response
* Frame <- <- Frame <- Frame
* <- VideoInDeviceNotify(Detached, DeviceId)
*
* Unsupported requests fail.
* The Device Description received from the client may be used to validate WebCam requests
* in the ConsoleVRDE code, for example filter out unsupported requests.
*
*/
/* All structures in this file are packed.
* Everything is little-endian.
*/
#pragma pack(1)
/*
* The interface supports generic video input descriptors, capabilities and controls:
* * Descriptors
* + Interface
* - Input, Camera Terminal
* - Processing Unit
* + Video Streaming
* - Input Header
* - Payload Format
* - Video Frame
* - Still Image Frame
* * Video Control requests
* + Interface
* - Power Mode
* + Unit and Terminal
* camera
* - Scanning Mode (interlaced, progressive)
* - Auto-Exposure Mode
* - Auto-Exposure Priority
* - Exposure Time Absolute, Relative
* - Focus Absolute, Relative, Auto
* - Iris Absolute, Relative
* - Zoom Absolute, Relative
* - PanTilt Absolute, Relative
* - Roll Absolute, Relative
* - Privacy
* processing
* - Backlight Compensation
* - Brightness
* - Contrast
* - Gain
* - Power Line Frequency
* - Hue Manual, Auto
* - Saturation
* - Sharpness
* - Gamma
* - White Balance Temperature Manual, Auto
* - White Balance Component Manual, Auto
* - Digital Multiplier
* - Digital Multiplier Limit
* * Video Streaming requests
* + Interface
* - Synch Delay
* - Still Image Trigger
* - Generate Key Frame
* - Update Frame Segment
* - Stream Error Code
*
*
* Notes:
* * still capture uses a method similar to method 2, because the still frame will
* be send instead of video over the channel.
* Also the method 2 can be in principle emulated by both 1 and 3 on the client.
* However the client can initiate a still frame transfer, similar to hardware button trigger.
* * all control changes are async.
* * no color matching. sRGB is the default.
* * most of constants are the same as in USB Video Class spec, but they are not the same and
* should be always converted.
*/
/*
* The DEVICEDEC describes the device and provides a list of supported formats:
* VRDEVIDEOINDEVICEDESC
* VRDEVIDEOINFORMATDESC[0];
* VRDEVIDEOINFRAMEDESC[0..N-1]
* VRDEVIDEOINFORMATDESC[1];
* VRDEVIDEOINFRAMEDESC[0..M-1]
* ...
*/
typedef struct VRDEVIDEOINDEVICEDESC
{
/* An extended description may follow. */
/* An array of VRDEVIDEOINFORMATDESC follows. */
/* VRDEVIDEOINDEVICEDESC::fu32CameraControls */
/* VRDEVIDEOINDEVICEDESC::fu32ProcessingControls */
#define VRDE_VIDEOIN_F_PU_CTRL_WHITE_BALANCE_TEMPERATURE 0x00000040 /* D6: White Balance Temperature */
#define VRDE_VIDEOIN_F_PU_CTRL_WHITE_BALANCE_TEMPERATURE_AUTO 0x00001000 /* D12: White Balance Temperature, Auto */
#define VRDE_VIDEOIN_F_PU_CTRL_WHITE_BALANCE_COMPONENT_AUTO 0x00002000 /* D13: White Balance Component, Auto */
#define VRDE_VIDEOIN_F_PU_CTRL_DIGITAL_MULTIPLIER_LIMIT 0x00008000 /* D15: Digital Multiplier Limit */
/* VRDEVIDEOINDEVICEDESC::fu8DeviceCaps */
/* The video format descriptor. */
typedef struct VRDEVIDEOINFORMATDESC
{
/* Other format specific data may follow. */
/* An array of VRDEVIDEOINFRAMEDESC follows. */
/* VRDEVIDEOINFORMATDESC::u8FormatType */
#define VRDE_VIDEOIN_FORMAT_UNCOMPRESSED 0x04
#define VRDE_VIDEOIN_FORMAT_MJPEG 0x06
#define VRDE_VIDEOIN_FORMAT_MPEG2TS 0x0A
#define VRDE_VIDEOIN_FORMAT_DV 0x0C
#define VRDE_VIDEOIN_FORMAT_FRAME_BASED 0x10
#define VRDE_VIDEOIN_FORMAT_STREAM_BASED 0x12
/* VRDEVIDEOINFORMATDESC::u8FormatFlags. */
#define VRDE_VIDEOIN_F_FMT_COMPQUALITY 0x08 /* If the format supports an adjustable compression quality. */
typedef struct VRDEVIDEOINFRAMESIZE
{
typedef struct VRDEVIDEOINFRAMEDESC
{
uint8_t u8FrameId; /* The unique identifier of the frame for the corresponding format on the client. */
uint32_t u32MinFrameInterval; /* Shortest frame interval supported (at highest frame rate), in 100ns units. */
uint32_t u32MaxFrameInterval; /* Longest frame interval supported (at lowest frame rate), in 100ns units. */
/* Supported frame intervals (in 100ns units) follow if VRDE_VIDEOIN_F_FRM_DISCRETE_INTERVALS is set.
* uint32_t au32FrameIntervals[u32NumFrameIntervals];
*/
/* Other frame specific data may follow. */
/* VRDEVIDEOINFRAMEDESC::u8FrameFlags. */
#define VRDE_VIDEOIN_F_FRM_DISCRETE_INTERVALS 0x02 /* If the discrete intervals list is included. */
/*
* Controls.
*
* The same structures are used for both SET and GET requests.
* Requests are async. A callback is invoked, when the client returns a reply.
* A control change notification also uses these structures.
*
* If a control request can not be fulfilled, then VRDE_VIDEOIN_CTRLHDR_F_FAIL
* will be set and u8Status contains the error code. This replaces the VC_REQUEST_ERROR_CODE_CONTROL.
*/
typedef struct VRDEVIDEOINCTRLHDR
{
/* Control specific data follows. */
/* Control request types: VRDEVIDEOINCTRLHDR::u16RequestType. */
#define VRDE_VIDEOIN_CTRLREQ_UNDEFINED 0x00
#define VRDE_VIDEOIN_CTRLREQ_SET_CUR 0x01
#define VRDE_VIDEOIN_CTRLREQ_GET_CUR 0x81
#define VRDE_VIDEOIN_CTRLREQ_GET_MIN 0x82
#define VRDE_VIDEOIN_CTRLREQ_GET_MAX 0x83
#define VRDE_VIDEOIN_CTRLREQ_GET_RES 0x84
#define VRDE_VIDEOIN_CTRLREQ_GET_LEN 0x85
#define VRDE_VIDEOIN_CTRLREQ_GET_INFO 0x86
#define VRDE_VIDEOIN_CTRLREQ_GET_DEF 0x87
/* VRDEVIDEOINCTRLHDR::u8Flags */
#define VRDE_VIDEOIN_CTRLHDR_F_NOTIFY 0x01 /* Control change notification, the attribute is derived from u16RequestType and F_FAIL. */
/* VRDEVIDEOINCTRLHDR::u8Status if the VRDE_VIDEOIN_CTRLHDR_F_FAIL is set. */
/* Control selectors. 16 bit. High byte is the category. Low byte is the identifier.*/
#ifdef RT_MAKE_U16
#else
#define VRDE_VIDEOIN_CTRLSEL_MAKE(Lo, Hi) ((uint16_t)( (uint16_t)((uint8_t)(Hi)) << 8 | (uint8_t)(Lo) ))
#endif
typedef struct VRDEVIDEOINCTRL_VIDEO_POWER_MODE
{
typedef struct VRDEVIDEOINCTRL_CT_SCANNING_MODE
{
typedef struct VRDEVIDEOINCTRL_CT_AE_MODE
{
typedef struct VRDEVIDEOINCTRL_CT_AE_PRIORITY
{
typedef struct VRDEVIDEOINCTRL_CT_EXPOSURE_TIME_ABSOLUTE
{
typedef struct VRDEVIDEOINCTRL_CT_EXPOSURE_TIME_RELATIVE
{
typedef struct VRDEVIDEOINCTRL_CT_FOCUS_ABSOLUTE
{
typedef struct VRDEVIDEOINCTRL_CT_FOCUS_RELATIVE
{
typedef struct VRDEVIDEOINCTRL_CT_FOCUS_AUTO
{
typedef struct VRDEVIDEOINCTRL_CT_IRIS_ABSOLUTE
{
typedef struct VRDEVIDEOINCTRL_CT_IRIS_RELATIVE
{
typedef struct VRDEVIDEOINCTRL_CT_ZOOM_ABSOLUTE
{
typedef struct VRDEVIDEOINCTRL_CT_ZOOM_RELATIVE
{
typedef struct VRDEVIDEOINCTRL_CT_PANTILT_ABSOLUTE
{
typedef struct VRDEVIDEOINCTRL_CT_PANTILT_RELATIVE
{
typedef struct VRDEVIDEOINCTRL_CT_ROLL_ABSOLUTE
{
typedef struct VRDEVIDEOINCTRL_CT_ROLL_RELATIVE
{
typedef struct VRDEVIDEOINCTRL_CT_PRIVACY_MODE
{
typedef struct VRDEVIDEOINCTRL_PU_BACKLIGHT_COMPENSATION
{
typedef struct VRDEVIDEOINCTRL_PU_BRIGHTNESS
{
typedef struct VRDEVIDEOINCTRL_PU_CONTRAST
{
typedef struct VRDEVIDEOINCTRL_PU_GAIN
{
typedef struct VRDEVIDEOINCTRL_PU_POWER_LINE_FREQUENCY
{
typedef struct VRDEVIDEOINCTRL_PU_HUE
{
typedef struct VRDEVIDEOINCTRL_PU_HUE_AUTO
{
typedef struct VRDEVIDEOINCTRL_PU_SATURATION
{
typedef struct VRDEVIDEOINCTRL_PU_SHARPNESS
{
typedef struct VRDEVIDEOINCTRL_PU_GAMMA
{
typedef struct VRDEVIDEOINCTRL_PU_WHITE_BALANCE_TEMPERATURE
{
typedef struct VRDEVIDEOINCTRL_PU_WHITE_BALANCE_TEMPERATURE_AUTO
{
typedef struct VRDEVIDEOINCTRL_PU_WHITE_BALANCE_COMPONENT
{
typedef struct VRDEVIDEOINCTRL_PU_WHITE_BALANCE_COMPONENT_AUTO
{
typedef struct VRDEVIDEOINCTRL_PU_DIGITAL_MULTIPLIER
{
typedef struct VRDEVIDEOINCTRL_PU_DIGITAL_MULTIPLIER_LIMIT
{
typedef struct VRDEVIDEOINCTRL_PU_ANALOG_VIDEO_STANDARD
{
typedef struct VRDEVIDEOINCTRL_PU_ANALOG_LOCK_STATUS
{
/* Start sending video frames with this format. */
#define VRDEVIDEOINCTRL_F_VS_START_FID 0x01
#define VRDEVIDEOINCTRL_F_VS_START_EOF 0x02
typedef struct VRDEVIDEOINCTRL_VS_START
{
* The client may choose a different interval if this value is
* not supported.
*/
* Applicable if the format has VRDE_VIDEOIN_F_FMT_COMPQUALITY,
* otherwise this field is ignored.
*/
* Set by the client, read by the server.
*/
/* Stop sending video frames. */
typedef struct VRDEVIDEOINCTRL_VS_STOP
{
typedef struct VRDEVIDEOINCTRL_VS_SYNCH_DELAY
{
typedef struct VRDEVIDEOINCTRL_VS_STILL_IMAGE_TRIGGER
{
typedef struct VRDEVIDEOINCTRL_VS_GENERATE_KEY_FRAME
{
typedef struct VRDEVIDEOINCTRL_VS_UPDATE_FRAME_SEGMENT
{
typedef struct VRDEVIDEOINCTRL_VS_STREAM_ERROR_CODE
{
typedef struct VRDEVIDEOINCTRL_HW_BUTTON
{
/*
* Payload transfers. How frames are sent to the server:
* the client send a PAYLOAD packet, which has the already set format.
* The server enables the transfers by sending VRDEVIDEOINCTRL_VS_START.
*/
/* Payload header */
typedef struct VRDEVIDEOINPAYLOADHDR
{
* Allows the server to measure clock drift.
*/
/* VRDEVIDEOINPAYLOADHDR::u8HeaderInfo */
/*
* The network channel specification.
*/
/*
* The protocol uses a dynamic RDP channel.
* Everything is little-endian.
*/
#define VRDE_VIDEOIN_CHANNEL "RVIDEOIN"
/* Major functions. */
/* Status codes. */
#define VRDE_VIDEOIN_STATUS_SUCCESS 0 /* Function completed successfully. */
typedef struct VRDEVIDEOINMSGHDR
{
uint32_t u32MessageId; /* Unique id assigned by the server. The client must send a reply with the same id.
* If the client initiates a request, then this must be set to 0, because there is
* currently no client requests, which would require a response from the server.
*/
/*
* VRDE_VIDEOIN_FN_NEGOTIATE
*
* Sent by the server when the channel is established and the client replies with its capabilities.
*/
#define VRDE_VIDEOIN_NEGOTIATE_VERSION 1
#define VRDE_VIDEOIN_NEGOTIATE_CAP_VOID 0
typedef struct VRDEVIDEOINMSG_NEGOTIATE
{
/*
* VRDE_VIDEOIN_FN_NOTIFY
*
* Sent by the client when a webcam is attached or detached.
* The client must send the ATTACH notification for each webcam, which is
* already connected to the client when the VIDEOIN channel is established.
*/
#define VRDE_VIDEOIN_NOTIFY_ATTACH 0
#define VRDE_VIDEOIN_NOTIFY_DETACH 1
typedef struct VRDEVIDEOINMSG_NOTIFY
{
/* Event specific data may follow. The underlying protocol provides the length of the message. */
/*
* VRDE_VIDEOIN_FN_DEVICEDESC
*
* The server queries the description of a device.
*/
typedef struct VRDEVIDEOINMSG_DEVICEDESC_REQ
{
typedef struct VRDEVIDEOINMSG_DEVICEDESC_RSP
{
/*
* VRDEVIDEOINFORMATDESC[0]
* VRDEVIDEOINFRAMEDESC[0]
* ...
* VRDEVIDEOINFRAMEDESC[n]
* VRDEVIDEOINFORMATDESC[1]
* VRDEVIDEOINFRAMEDESC[0]
* ...
* VRDEVIDEOINFRAMEDESC[m]
* ...
*/
/*
* VRDE_VIDEOIN_FN_CONTROL
* VRDE_VIDEOIN_FN_CONTROL_NOTIFY
*
* Either sent by the server or by the client as a notification/response.
* If sent by the client as a notification, then hdr.u32MessageId must be 0.
*/
typedef struct VRDEVIDEOINMSG_CONTROL
{
/* Control specific data may follow. */
/*
* VRDE_VIDEOIN_FN_FRAME
*
* hdr.u32MessageId must be 0.
*/
typedef struct VRDEVIDEOINMSG_FRAME
{
/* The frame data follow. */
/*
* The application interface between VirtualBox and the VRDE server.
*/
#define VRDE_VIDEOIN_INTERFACE_NAME "VIDEOIN"
typedef struct VRDEVIDEOINDEVICEHANDLE
{
/* The VRDE server video input interface entry points. Interface version 1. */
typedef struct VRDEVIDEOININTERFACE
{
/* The header. */
/* Tell the server that this device will be used and associate a context with the device.
*
* @param hServer The VRDE server instance.
* @param pDeviceHandle The device reported by ATTACH notification.
* @param pvDeviceCtx The caller context associated with the pDeviceHandle.
*
* @return IPRT status code.
*/
const VRDEVIDEOINDEVICEHANDLE *pDeviceHandle,
void *pvDeviceCtx));
/* This device will be not be used anymore. The device context must not be used by the server too.
*
* @param hServer The VRDE server instance.
* @param pDeviceHandle The device reported by ATTACH notification.
*
* @return IPRT status code.
*/
const VRDEVIDEOINDEVICEHANDLE *pDeviceHandle));
/* Get a device description.
*
* @param hServer The VRDE server instance.
* @param pvUser The callers context of this request.
* @param pDeviceHandle The device reported by ATTACH notification.
*
* @return IPRT status code.
*/
void *pvUser,
const VRDEVIDEOINDEVICEHANDLE *pDeviceHandle));
*
* @param hServer The VRDE server instance.
* @param pvUser The callers context of this request.
* @param pDeviceHandle The device reported by ATTACH notification.
* @param pReq The request.
* @param cbReq Size of the request.
*
* @return IPRT status code.
*/
void *pvUser,
const VRDEVIDEOINDEVICEHANDLE *pDeviceHandle,
const VRDEVIDEOINCTRLHDR *pReq,
/*
* Notifications.
* Data structures: pvData of VRDEVIDEOINCALLBACKS::VRDECallbackVideoInNotify.
*/
typedef struct VRDEVIDEOINNOTIFYATTACH
{
typedef struct VRDEVIDEOINNOTIFYDETACH
{
/* Video input interface callbacks. */
typedef struct VRDEVIDEOINCALLBACKS
{
/** The header. */
/* Notifications.
*
* @param pvCallback The callbacks context specified in VRDEGetInterface.
* @param u32EventId The notification identifier: VRDE_VIDEOIN_NOTIFY_*.
* @param pvData The notification specific data.
* @param cbData The size of buffer pointed by pvData.
*/
const void *pvData,
/* Device description received from the client.
*
* @param pvCallback The callbacks context specified in VRDEGetInterface.
* @param rcRequest The result code of the request.
* @param pDeviceCtx The device context associated with the device in VRDEVideoInGetDeviceDesc.
* @param pvUser The pvUser parameter of VRDEVideoInGetDeviceDesc.
* @param pDeviceDesc The device description.
* @param cbDeviceDesc The size of buffer pointed by pDevice.
*/
int rcRequest,
void *pDeviceCtx,
void *pvUser,
const VRDEVIDEOINDEVICEDESC *pDeviceDesc,
/* Control response or notification.
*
* @param pvCallback The callbacks context specified in VRDEGetInterface.
* @param rcRequest The result code of the request.
* @param pDeviceCtx The device context associated with the device in VRDEVideoInGetDeviceDesc.
* @param pvUser The pvUser parameter of VRDEVideoInControl. NULL if this is a notification.
* @param pControl The control information.
* @param cbControl The size of buffer pointed by pControl.
*/
int rcRequest,
void *pDeviceCtx,
void *pvUser,
const VRDEVIDEOINCTRLHDR *pControl,
/* Frame which was received from the client.
*
* @param pvCallback The callbacks context specified in VRDEGetInterface.
* @param rcRequest The result code of the request.
* @param pDeviceCtx The device context associated with the device in VRDEVideoInGetDeviceDesc.
* @param pFrame The frame data.
* @param cbFrame The size of buffer pointed by pFrame.
*/
int rcRequest,
void *pDeviceCtx,
const VRDEVIDEOINPAYLOADHDR *pFrame,
#endif /* VRDE_VIDEOIN_WITH_VRDEINTERFACE */
#pragma pack()
#endif