TeamTalk 5 C-API DLL Version 5.15A
Loading...
Searching...
No Matches
Video Capture and Image Display

This section explains how to initialize a video device and display captured images on the user's display. More...

Classes

struct  VideoFormat
 A struct containing the properties of a video capture format. More...
 
struct  VideoFrame
 A RGB32 image where the pixels can be accessed directly in an allocated frameBuffer. More...
 
struct  VideoCaptureDevice
 A struct containing the properties of a video capture device. More...
 

Macros

#define TT_VIDEOFORMATS_MAX   1024
 

Typedefs

typedef enum FourCC FourCC
 The picture format used by a capture device.
 
typedef struct VideoFormat VideoFormat
 A struct containing the properties of a video capture format.
 
typedef struct VideoFrame VideoFrame
 A RGB32 image where the pixels can be accessed directly in an allocated frameBuffer.
 
typedef struct VideoCaptureDevice VideoCaptureDevice
 A struct containing the properties of a video capture device.
 

Enumerations

enum  FourCC { FOURCC_NONE = 0 , FOURCC_I420 = 100 , FOURCC_YUY2 = 101 , FOURCC_RGB32 = 102 }
 The picture format used by a capture device. More...
 

Functions

TEAMTALKDLL_API TTBOOL TT_GetVideoCaptureDevices (IN OUT VideoCaptureDevice *lpVideoDevices, IN OUT INT32 *lpnHowMany)
 Get the list of devices available for video capture.
 
TEAMTALKDLL_API TTBOOL TT_InitVideoCaptureDevice (IN TTInstance *lpTTInstance, IN const TTCHAR *szDeviceID, IN const VideoFormat *lpVideoFormat)
 Initialize a video capture device.
 
TEAMTALKDLL_API TTBOOL TT_CloseVideoCaptureDevice (IN TTInstance *lpTTInstance)
 Close a video capture device.
 
TEAMTALKDLL_API TTBOOL TT_PaintVideoFrame (IN HDC hDC, IN INT32 XDest, IN INT32 YDest, IN INT32 nDestWidth, IN INT32 nDestHeight, IN VideoFrame *lpVideoFrame)
 Paint user's video frame using a Windows' DC (device context).
 
TEAMTALKDLL_API TTBOOL TT_PaintVideoFrameEx (IN HDC hDC, IN INT32 XDest, IN INT32 YDest, IN INT32 nDestWidth, IN INT32 nDestHeight, IN INT32 XSrc, IN INT32 YSrc, IN INT32 nSrcWidth, IN INT32 nSrcHeight, IN VideoFrame *lpVideoFrame)
 Paint user's video frame using a Windows' DC (device context).
 
TEAMTALKDLL_API VideoFrameTT_AcquireUserVideoCaptureFrame (IN TTInstance *lpTTInstance, IN INT32 nUserID)
 Extract a user's video capture frame for display.
 
TEAMTALKDLL_API TTBOOL TT_ReleaseUserVideoCaptureFrame (IN TTInstance *lpTTInstance, IN VideoFrame *lpVideoFrame)
 Delete a user's video frame, acquired through TT_AcquireUserVideoCaptureFrame(), so its allocated resources can be released.
 

Detailed Description

This section explains how to initialize a video device and display captured images on the user's display.

The client is able to capture video and present them to the user application in RGB32-format and transmit the image in encoded format to other users.

Sections:

Initialize Video Capture Device

This section explains how to detect and configure video capture devices.

To capture video the user application must first query the available capture devices by calling TT_GetVideoCaptureDevices. A VideoCaptureDevice supports a certain number of capture formats each described in the videoFormats member of VideoFormat.

Once a device has been chosen the TT_InitVideoCaptureDevice must be called for the client instance to start capturing video frames. Use the szDevice member of VideoCaptureDevice as the device identifier for the video capture device and pass a VideoFormat from the videoFormats array of VideoCaptureDevice. Check out section Audio and Video Codecs on how to configure the video codec.

Display Captured Video

When a video frame becomes available the event CLIENTEVENT_USER_VIDEOCAPTURE is posted to the application and TT_AcquireUserVideoCaptureFrame can be used to extract the RGB32 image. On Windows it's also possible to call TT_PaintVideoFrame to make the client instance paint on a HWND by getting its HDC, otherwise use the VideoFrame's frame buffer pointer to access the bitmap data.

Macro Definition Documentation

◆ TT_VIDEOFORMATS_MAX

#define TT_VIDEOFORMATS_MAX   1024

The maximum number of video formats which will be queried for a VideoCaptureDevice.

Definition at line 101 of file TeamTalk.h.

Typedef Documentation

◆ FourCC

typedef enum FourCC FourCC

The picture format used by a capture device.

See also
VideoFormat
VideoCaptureDevice

◆ VideoFormat

typedef struct VideoFormat VideoFormat

A struct containing the properties of a video capture format.

A struct for holding a supported video capture format by a VideoCaptureDevice.

◆ VideoFrame

typedef struct VideoFrame VideoFrame

A RGB32 image where the pixels can be accessed directly in an allocated frameBuffer.

Use TT_AcquireUserVideoCaptureFrame() to acquire a user's image and remember to call TT_ReleaseUserVideoCaptureFrame() when the image has been processed so TeamTalk can release its resources.

◆ VideoCaptureDevice

A struct containing the properties of a video capture device.

The information retrieved from the video capture device is used to initialize the video capture device using the TT_InitVideoCaptureDevice function.

See also
TT_GetVideoCaptureDevices

Enumeration Type Documentation

◆ FourCC

enum FourCC

The picture format used by a capture device.

See also
VideoFormat
VideoCaptureDevice
Enumerator
FOURCC_NONE 

Internal use to denote no supported formats.

FOURCC_I420 

Prefered image format with the lowest bandwidth usage. A 640x480 pixel image takes up 460.800 bytes.

FOURCC_YUY2 

Image format where a 640x480 pixel images takes up 614.400 bytes.

FOURCC_RGB32 

The image format with the highest bandwidth usage. A 640x480 pixel images takes up 1.228.880 bytes.

Definition at line 818 of file TeamTalk.h.

Function Documentation

◆ TT_GetVideoCaptureDevices()

TEAMTALKDLL_API TTBOOL TT_GetVideoCaptureDevices ( IN OUT VideoCaptureDevice lpVideoDevices,
IN OUT INT32 *  lpnHowMany 
)

Get the list of devices available for video capture.

Parameters
lpVideoDevicesArray of VideoCaptureDevice-stucts where lpnHowMany hold the size of the array. Pass NULL to query the number of devices.
lpnHowManyThis is both an input and output parameter. If lpVideoDevices is NULL lpnHowMany will after the call hold the number of devices, otherwise it should hold the size of the lpVideoDevices array.
See also
TT_InitVideoCaptureDevice

◆ TT_InitVideoCaptureDevice()

TEAMTALKDLL_API TTBOOL TT_InitVideoCaptureDevice ( IN TTInstance lpTTInstance,
IN const TTCHAR szDeviceID,
IN const VideoFormat lpVideoFormat 
)

Initialize a video capture device.

To transmit video capture data to a channel call TT_StartVideoCaptureTransmission()

Parameters
lpTTInstancePointer to client instance created by TT_InitTeamTalk.
szDeviceIDThe device idenfier szDeviceID of VideoCaptureDevice.
lpVideoFormatThe capture format to use, i.e. frame-rate, resolution and picture format.
See also
TT_GetVideoCaptureDevices
TT_CloseVideoCaptureDevice

◆ TT_CloseVideoCaptureDevice()

TEAMTALKDLL_API TTBOOL TT_CloseVideoCaptureDevice ( IN TTInstance lpTTInstance)

Close a video capture device.

See also
TT_InitVideoCaptureDevice

◆ TT_PaintVideoFrame()

TEAMTALKDLL_API TTBOOL TT_PaintVideoFrame ( IN HDC  hDC,
IN INT32  XDest,
IN INT32  YDest,
IN INT32  nDestWidth,
IN INT32  nDestHeight,
IN VideoFrame lpVideoFrame 
)

Paint user's video frame using a Windows' DC (device context).

Same as calling TT_PaintVideoFrameEx() like this:

TT_PaintVideoFrameEx(lpTTInstance, nUserID, hDC, 
                     XDest, YDest, nDestWidth,
                     nDestHeight, 0, 0, 
                     src_bmp_width, src_bmp_height);

src_bmp_width and src_bmp_height are extracted internally from the source image.

◆ TT_PaintVideoFrameEx()

TEAMTALKDLL_API TTBOOL TT_PaintVideoFrameEx ( IN HDC  hDC,
IN INT32  XDest,
IN INT32  YDest,
IN INT32  nDestWidth,
IN INT32  nDestHeight,
IN INT32  XSrc,
IN INT32  YSrc,
IN INT32  nSrcWidth,
IN INT32  nSrcHeight,
IN VideoFrame lpVideoFrame 
)

Paint user's video frame using a Windows' DC (device context).

An application can either paint using TT_AcquireUserVideoCaptureFrame which provides a raw RGB32 array of the image or the application can ask the client instance to paint the image using this function.

Typically this paint operation will be called in the WM_PAINT message. Here is how the client instance paints internally:

StretchDIBits(hDC, nPosX, nPosY, nWidth, nHeight, XSrc, YSrc, 
              nSrcWidth, nSrcHeight, frame_buf, &bmi,
              DIB_RGB_COLORS, SRCCOPY);
Parameters
hDCThe handle to the Windows device context.
XDestCoordinate of left corner where to start painting.
YDestCoordinate or top corner where to start painting.
nDestWidthThe width of the image.
nDestHeightThe height of the image.
XSrcThe left coordinate in the source bitmap of where to start reading.
YSrcThe top left coordinate in the source bitmap of where to start reading.
nSrcWidthThe number of width pixels to read from source bitmap.
nSrcHeightThe number of height pixels to read from source bitmap.
lpVideoFrameVideo frame retrieved by TT_AcquireUserVideoCaptureFrame()
See also
TT_AcquireUserVideoCaptureFrame

◆ TT_AcquireUserVideoCaptureFrame()

TEAMTALKDLL_API VideoFrame * TT_AcquireUserVideoCaptureFrame ( IN TTInstance lpTTInstance,
IN INT32  nUserID 
)

Extract a user's video capture frame for display.

The VideoFrame extracted from the client instance will contain a pointer to the image's frame buffer, so a RGB32 bitmap can be displayed in a window control.

To release the acquired VideoFrame call TT_ReleaseUserVideoCaptureFrame().

A video capture frame comes from a user's STREAMTYPE_VIDEOCAPTURE.

Parameters
lpTTInstancePointer to client instance created by TT_InitTeamTalk.
nUserIDThe user's ID. 0 for local user.
Returns
Returns video frame which will contain the image data. Note that it's the frameBuffer member of VideoFrame which will contain the image data allocated internally by TeamTalk. Returns NULL if no video frame could be acquired.
See also
TT_ReleaseUserVideoCaptureFrame

◆ TT_ReleaseUserVideoCaptureFrame()

TEAMTALKDLL_API TTBOOL TT_ReleaseUserVideoCaptureFrame ( IN TTInstance lpTTInstance,
IN VideoFrame lpVideoFrame 
)

Delete a user's video frame, acquired through TT_AcquireUserVideoCaptureFrame(), so its allocated resources can be released.

Parameters
lpTTInstancePointer to client instance created by TT_InitTeamTalk.
lpVideoFramePointer to VideoFrame which should be deallocated.
Returns
Returns TRUE If a video frame was successfully deallocated.
See also
TT_AcquireUserVideoCaptureFrame