TeamTalk 4 .NET DLL  Version 4.5A
Desktop Sharing

A user can transmit a desktop window to other users in a channel by passing the handle of a window to the TeamTalk client DLL. The TeamTalk client then converts the window to a bitmap image which is transmitted to the server. The server then forwards the bitmap image to all other users in the channel. More...

Classes

struct  BearWare.DesktopWindow
 A struct containing the properties of a shared desktop window. More...
 

Enumerations

enum  BearWare.BitmapFormat : uint {
  BearWare.BMP_NONE = 0, BearWare.BMP_RGB8_PALETTE = 1, BearWare.BMP_RGB16_555 = 2, BearWare.BMP_RGB24 = 3,
  BearWare.BMP_RGB32 = 4
}
 The bitmap format used for a BearWare.DesktopWindow. More...
 
enum  BearWare.DesktopProtocol : uint { BearWare.DESKTOPPROTOCOL_ZLIB_1 = 1 }
 The protocols supported for transferring a BearWare.DesktopWindow. More...
 

Functions

int BearWare.TeamTalk4.SendDesktopWindow (System.IntPtr lpBitmap, int nBitmapSize, DesktopWindow lpDesktopWindow, BitmapFormat nConvertBmpFormat)
 Transmit a desktop window (bitmap) to users in the same channel. More...
 
bool BearWare.TeamTalk4.CloseDesktopWindow ()
 Close the current desktop session. More...
 
static System.Drawing.Color BearWare.TeamTalk4.Palette_GetColorTable (BitmapFormat nBmpPalette, int nIndex)
 Get RGB values of the palette for the bitmap format. More...
 
int BearWare.TeamTalk4.SendDesktopWindowFromHWND (System.IntPtr hWnd, BitmapFormat nBitmapFormat, DesktopProtocol nDesktopProtocol)
 Transmit the specified window in a desktop session. More...
 
bool BearWare.TeamTalk4.PaintDesktopWindow (int nUserID, System.IntPtr hDC, int XDest, int YDest, int nDestWidth, int nDestHeight)
 Paint user's desktop window using a Windows' DC (device context). More...
 
bool BearWare.TeamTalk4.PaintDesktopWindowEx (int nUserID, System.IntPtr hDC, int XDest, int YDest, int nDestWidth, int nDestHeight, int XSrc, int YSrc, int nSrcWidth, int nSrcHeight)
 Paint user's desktop window using a Windows' DC (device context). More...
 
bool BearWare.TeamTalk4.SendDesktopCursorPosition (int nUserID, int nPosX, int nPosY)
 Send the position of mouse cursor to users in the same channel. More...
 
bool BearWare.TeamTalk4.GetUserDesktopWindow (int nUserID, System.IntPtr lpBitmap, ref int lpnBitmapSize, ref DesktopWindow lpDesktopWindow)
 Get a user's desktop window (bitmap image). More...
 
bool BearWare.TeamTalk4.GetUserDesktopCursor (int nSrcUserID, int nDestUserID, ref int lpnPosX, ref int lpnPosY)
 Get the mouse cursor position of a user. More...
 

Detailed Description

A user can transmit a desktop window to other users in a channel by passing the handle of a window to the TeamTalk client DLL. The TeamTalk client then converts the window to a bitmap image which is transmitted to the server. The server then forwards the bitmap image to all other users in the channel.

Send Desktop Window (or bitmap)

Before sending a desktop window to a channel the handle (identifier) of the window to share must first be found. It is, however, possible to simply send a raw bitmap by calling TeamTalk4.SendDesktopWindow().

Windows Desktop Sharing

TeamTalk for Windows provides the following functions for obtaining different HWNDs:

Once the HWND of the window to share has been found use the following function for sending the window to the channel:

Displaying Shared Desktop Window (or bitmap)

When a shared desktop window is received the event TeamTalk4.OnUserDesktopWindow() is posted to the local client instance. TeamTalk4.GetUserDesktopWindow() can then be called to obtain a bitmap image of the shared window.

Desktop Cursor Sharing

It is also possible to share the position of the mouse cursor when sharing a desktop window. Use TeamTalk4.SendDesktopCursorPosition() to transmit the position of the mouse cursor. When the position is received the event TeamTalk4.OnUserDesktopCursor() is posted to the local client instance. TeamTalk4.GetUserDesktopCursor() can then be used to obtain the cursor position.

Enumeration Type Documentation

enum BearWare.BitmapFormat : uint

The bitmap format used for a BearWare.DesktopWindow.

Enumerator
BMP_NONE 

Used to denote nothing selected.

BMP_RGB8_PALETTE 

The bitmap is a 256-colored bitmap requiring a palette. The default 256 colored palette is the Netscape browser-safe palette. Use TeamTalk4.Palette_GetColorTable() to access or change the palette.

BMP_RGB16_555 

The bitmap is a 16-bit colored bitmap.

BMP_RGB24 

The bitmap is a 24-bit colored bitmap.

BMP_RGB32 

The bitmap is a 32-bit colored bitmap.

The protocols supported for transferring a BearWare.DesktopWindow.

So far only one, UDP-based, protocol is supported.

Enumerator
DESKTOPPROTOCOL_ZLIB_1 

Desktop protocol based on ZLIB for image compression and UDP for data transmission.

Function Documentation

int BearWare.TeamTalk4.SendDesktopWindow ( System.IntPtr  lpBitmap,
int  nBitmapSize,
DesktopWindow  lpDesktopWindow,
BitmapFormat  nConvertBmpFormat 
)

Transmit a desktop window (bitmap) to users in the same channel.

When TeamTalk4.SendDesktopWindow() is called the first time a new desktop session will be started. To update the current desktop session call TeamTalk4.SendDesktopWindow() again once the previous desktop transmission has finished. Tracking progress of the current desktop transmission is done by checking for the TeamTalk4.OnDesktopTransferUpdate() event. While the desktop transmission is active the flag ClientFlag CLIENT_TX_DESKTOP will be set on the local client instance.

If the desktop window (bitmap) changes size (width/height) or format a new desktop session will be started. Also if the user changes channel a new desktop session will be started. Check nSessionID of BearWare.DesktopWindow to see if a new desktop session is started or the TeamTalk4.OnUserDesktopWindow() event.

Remote users will get the TeamTalk4.OnUserDesktopWindow() event and can call TeamTalk4.GetUserDesktopWindow() to retrieve the desktop window.

Note
Requires server version 4.3.0.1490 or later.
Parameters
lpBitmapPointer to bitmap buffer.
nBitmapSizeSize of bitmap buffer lpBitmap in bytes. The size of the bitmap can be calculated using the BearWare.DesktopWindow-struct's nBytesPerLine multiplied by the nHeight.
lpDesktopWindowProperties of the bitmap. Set the nSessionID property to 0.
nConvertBmpFormatBefore transmission convert the bitmap to this format.
Returns
TRUE if desktop window is queued for transmission. FALSE if nBitmapSize is invalid or if a desktop transmission is already active.
-1 on error. 0 if bitmap has no changes. Greater than 0 on success.
See Also
TeamTalk4.CloseDesktopWindow()
TeamTalk4.SendDesktopCursorPosition()
bool BearWare.TeamTalk4.CloseDesktopWindow ( )

Close the current desktop session.

Closing the desktop session will cause the users receiving the current desktop session to see the desktop session ID change to 0 in the TeamTalk4.OnUserDesktopWindow() event.

static System.Drawing.Color BearWare.TeamTalk4.Palette_GetColorTable ( BitmapFormat  nBmpPalette,
int  nIndex 
)
static

Get RGB values of the palette for the bitmap format.

This currently only applies to bitmaps of format BitmapFormat BMP_RGB8_PALETTE.

Note that the pointer returned is non-const which means the palette can be overwritten with a custom palette. The custom palette will then be used internally during bitmap conversion.

Parameters
nBmpPaletteThe bitmap format. Currently only BitmapFormat BMP_RGB8_PALETTE is supported.
nIndexThe index in the color table of the RGB values to extract.
Returns
Pointer to RGB colors. First byte is Red, second Blue and third Green. Returns NULL if the color-index is invalid.
int BearWare.TeamTalk4.SendDesktopWindowFromHWND ( System.IntPtr  hWnd,
BitmapFormat  nBitmapFormat,
DesktopProtocol  nDesktopProtocol 
)

Transmit the specified window in a desktop session.

Same as TeamTalk4.SendDesktopWindow() except the properties for the BearWare.DesktopWindow are extracted automatically.

Parameters
hWndWindows handle for the window to transmit.
nBitmapFormatBitmap format to use for the transmitted image.
nDesktopProtocolThe protocol to use for transmitting the image.
Returns
See TeamTalk4.SendDesktopWindow().
bool BearWare.TeamTalk4.PaintDesktopWindow ( int  nUserID,
System.IntPtr  hDC,
int  XDest,
int  YDest,
int  nDestWidth,
int  nDestHeight 
)

Paint user's desktop window using a Windows' DC (device context).

Same as calling TT_PaintDesktopWindowEx() like this:

TT_PaintDesktopWindowEx(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.PaintDesktopWindowEx ( int  nUserID,
System.IntPtr  hDC,
int  XDest,
int  YDest,
int  nDestWidth,
int  nDestHeight,
int  XSrc,
int  YSrc,
int  nSrcWidth,
int  nSrcHeight 
)

Paint user's desktop window using a Windows' DC (device context).

An application can either paint a bitmap by using TeamTalk4.GetUserDesktopWindow() which provides a pointer to a bitmap 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.
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.
Returns
TRUE on success. FALSE on error, e.g. if user doesn't exist.
See Also
TeamTalk4.GetUserDesktopWindow()
bool BearWare.TeamTalk4.SendDesktopCursorPosition ( int  nUserID,
int  nPosX,
int  nPosY 
)

Send the position of mouse cursor to users in the same channel.

It's only possible to send the mouse cursor position if there's a desktop session which is currently active.

Note
Requires server version 4.3.0.1490 or later.
Parameters
nUserIDFor now set to 0.
nPosXX coordinate of mouse cursor. Max is 65535.
nPosYY coordinate of mouse cursor. Max is 65535.
See Also
TeamTalk4.SendDesktopWindow()
bool BearWare.TeamTalk4.GetUserDesktopWindow ( int  nUserID,
System.IntPtr  lpBitmap,
ref int  lpnBitmapSize,
ref DesktopWindow  lpDesktopWindow 
)

Get a user's desktop window (bitmap image).

A user's desktop window can be extracted when the TeamTalk4.OnUserDesktopWindow() is received.

A desktop window is simply a bitmap image. This method is used for copying the user's bitmap image to a pre-allocated buffer.

To know the properties of the bitmap call this method with lpBitmap set to NULL and extract the properties in lpDesktopWindow. The size of the buffer to allocate will be nBytesPerLine multiplied by nHeight in the BearWare.DesktopWindow.

For BitmapFormat BMP_RGB8_PALETTE bitmaps check out TeamTalk4.Palette_GetColorTable().

Parameters
nUserIDThe user's ID.
lpBitmapPointer to a pre-allocated buffer where the bitmap data will be copied to. Pass NULL to query the byte size of the bitmap, so it can be written to lpnBitmapSize and lpDesktopWindow.
lpnBitmapSizeSize of the allocated bitmap buffer lpBitmap. If lpBitmap is NULL the size of the bitmap will be written to this parameter.
lpDesktopWindowThe properties of the shared desktop window. Pass NULL to lpBitmap to query the properties of the desktop window.
Returns
FALSE if there's no active desktop window for this user.
See Also
TeamTalk4.SendDesktopWindow()
bool BearWare.TeamTalk4.GetUserDesktopCursor ( int  nSrcUserID,
int  nDestUserID,
ref int  lpnPosX,
ref int  lpnPosY 
)

Get the mouse cursor position of a user.

The mouse cursor position will be available when the TeamTalk4.OnUserDesktopCursor() is received and there's an active desktop session.

A mouse cursor position is transmitted using TeamTalk4.SendDesktopCursorPosition().

Parameters
nSrcUserIDThe owner of the cursor.
nDestUserIDThe owner of the desktop session where the cursor is pointing to.
lpnPosXOutput parameter for X coordinate.
lpnPosYOutput parameter for Y coordinate.