TeamTalk 4 .NET DLL  Version 4.5A
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  BearWare.CaptureFormat
 A struct containing the properties of a video capture format. More...
 
struct  BearWare.VideoFrame
 A RGB32 image where the pixels can be accessed directly in an allocated imageBuffer. More...
 
struct  BearWare.VideoCaptureDevice
 A struct containing the properties of a video capture device. More...
 
struct  BearWare.MediaFileInfo
 Struct describing the audio and video format used by a media file. More...
 

Enumerations

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

Functions

bool BearWare.TeamTalk4.GetVideoCaptureDevices (out VideoCaptureDevice[] lpVideoDevices)
 Get the list of devices available for video capture. More...
 
bool BearWare.TeamTalk4.InitVideoCaptureDevice (string szDeviceID, CaptureFormat lpCaptureFormat, VideoCodec lpVideoCodec)
 Initialize a video capture device. More...
 
bool BearWare.TeamTalk4.CloseVideoCaptureDevice ()
 Close a video capture device. More...
 
bool BearWare.TeamTalk4.PaintVideoFrame (int nUserID, System.IntPtr hDC, int XDest, int YDest, int nDestWidth, int nDestHeight)
 Paint user's video frame using a Windows' DC (device context). More...
 
bool BearWare.TeamTalk4.PaintVideoFrameEx (int nUserID, System.IntPtr hDC, int XDest, int YDest, int nDestWidth, int nDestHeight, int XSrc, int YSrc, int nSrcWidth, int nSrcHeight)
 Paint user's video frame using a Windows' DC (device context). More...
 
bool BearWare.TeamTalk4.GetUserVideoFrame (int nUserID, ref System.Drawing.Bitmap lpPicture)
 Get or query the raw RGB32 bitmap data of a user's video frame. More...
 
bool BearWare.TeamTalk4.AcquireUserVideoFrame (int nUserID, ref VideoFrame lpVideoFrame)
 Extract a user's video frame by making TeamTalk allocate the image buffer. More...
 
bool BearWare.TeamTalk4.ReleaseUserVideoFrame (int nUserID)
 Delete a user's video frame, acquired through TeamTalk4.AcquireUserVideoFrame(), so its allocated resources can be released. More...
 

Variables

const int BearWare.TeamTalk4.TT_CAPTUREFORMATS_MAX = 128
 

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.

Initialize Video Capture Device

To capture video the user application must first query the available capture devices by calling TeamTalk4.GetVideoCaptureDevices(). A BearWare.VideoCaptureDevice supports a certain number of capture formats each described in the captureFormats member of BearWare.CaptureFormat.

Once a device has been chosen the TeamTalk4.InitVideoCaptureDevice() must be called for the client instance to start capturing video frames. Use the szDevice member of BearWare.VideoCaptureDevice as the device identifier for the video capture device and pass a BearWare.CaptureFormat from the captureFormats array of BearWare.VideoCaptureDevice. The lpVideoCodec parameter of TeamTalk4.InitVideoCaptureDevice() can be passed as NULL if the captured video frames do not need to be transmitted. 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 TeamTalk4.OnUserVideoFrame() is posted to the application and TeamTalk4.GetUserVideoFrame() can be used to extract the RGB32 image. On Windows it's also possible to call TeamTalk4.PaintVideoFrame() to make the client instance paint on a HWND by getting its HDC.

Enumeration Type Documentation

enum BearWare.FourCC : uint

The picture format used by a capture device.

See Also
CaptureFormat
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.

Function Documentation

bool BearWare.TeamTalk4.GetVideoCaptureDevices ( out VideoCaptureDevice[]  lpVideoDevices)

Get the list of devices available for video capture.

Parameters
lpVideoDevicesAn output array of BearWare.VideoCaptureDevice-stucts which will receive the available video capture devices
See Also
TeamTalk4.InitVideoCaptureDevice
bool BearWare.TeamTalk4.InitVideoCaptureDevice ( string  szDeviceID,
CaptureFormat  lpCaptureFormat,
VideoCodec  lpVideoCodec 
)

Initialize a video capture device.

Parameters
szDeviceIDThe device idenfier szDeviceID of BearWare.VideoCaptureDevice.
lpCaptureFormatThe capture format to use, i.e. frame-rate, resolution and picture format.
lpVideoCodecVideo codec to use for transmission. Use NULL or set nCodec of BearWare.VideoCodec to Codec NO_CODEC if capture device should only be used for testing locally.
See Also
TeamTalk4.GetVideoCaptureDevices
TeamTalk4.CloseVideoCaptureDevice
TeamTalk4.EnableTransmission
bool BearWare.TeamTalk4.CloseVideoCaptureDevice ( )

Close a video capture device.

See Also
TeamTalk4.InitVideoCaptureDevice
bool BearWare.TeamTalk4.PaintVideoFrame ( int  nUserID,
System.IntPtr  hDC,
int  XDest,
int  YDest,
int  nDestWidth,
int  nDestHeight 
)

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

Same as calling TeamTalk4.PaintVideoFrameEx() like this:

ttclient.PaintVideoFrameEx(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.

bool BearWare.TeamTalk4.PaintVideoFrameEx ( int  nUserID,
System.IntPtr  hDC,
int  XDest,
int  YDest,
int  nDestWidth,
int  nDestHeight,
int  XSrc,
int  YSrc,
int  nSrcWidth,
int  nSrcHeight 
)

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

An application can either paint using TeamTalk4.GetUserVideoFrame() 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
nUserIDThe user's ID. 0 for local user.
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.
See Also
TeamTalk4.GetUserVideoFrame
bool BearWare.TeamTalk4.GetUserVideoFrame ( int  nUserID,
ref System.Drawing.Bitmap  lpPicture 
)

Get or query the raw RGB32 bitmap data of a user's video frame.

Parameters
nUserIDThe user's ID. 0 for local client instance.
lpPictureReference to a bitmap which will receive the video frame. If the lpPicture reference is null or not the proper size a new Bitmap object will be allocated and returned instead. Ensure to ALWAYS call with the same lpPicture reference for each nUserID, otherwise a new Bitmap object will be allocated each time and cause the application to use a significant amount of memory.
See Also
PaintVideoFrame
bool BearWare.TeamTalk4.AcquireUserVideoFrame ( int  nUserID,
ref VideoFrame  lpVideoFrame 
)

Extract a user's video frame by making TeamTalk allocate the image buffer.

Unlike TeamTalk4.GetUserVideoFrame() this function does not require that the user preallocates a buffer which will contain the image data. Instead the image buffer is allocated in internally. REMEMBER, however, to call TeamTalk4.ReleaseUserVideoFrame() when the image has been processed so the resources allocated by TeamTalk can be released.

Parameters
nUserIDThe user's ID. 0 for local user.
lpVideoFrameThe struct which will contain the image data. Note that it's the frameBuffer member of BearWare.VideoFrame which will contain the image data allocated internally by TeamTalk.
Returns
Returns TRUE if a video frame was successfully put in the lpVideoFrame parameter.
See Also
GetUserVideoFrame
ReleaseUserVideoFrame
bool BearWare.TeamTalk4.ReleaseUserVideoFrame ( int  nUserID)

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

Parameters
nUserIDThe user's ID. 0 for local user.
Returns
Returns TRUE if a video frame was successfully put in the lpVideoFrame parameter.
See Also
AcquireUserVideoFrame
GetUserVideoFrame

Variable Documentation

const int BearWare.TeamTalk4.TT_CAPTUREFORMATS_MAX = 128

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