TeamTalk 5 .NET DLL
Version 5.11A
|
The following sections gives a step-by-step tour of how to build an application which uses the TeamTalk .NET DLL to transmit voice and video. This chapter assumes the developer has read the section TeamTalk SDK Contents on how to configure Visual Studio to work with the TeamTalk client DLL.
In order for the user application to interact with other clients a TeamTalk server must first be set up. Section TeamTalk Server Setup Guide explains how to do this. The job of the TeamTalk server is to provide user autentication and keep track of users. Once a client is connected and has been authenticated the client is presented with a tree structure where each node is a so-called "channel" which the client can join and from there interact with the other users who are in the same channel.
The following six steps explains how to build a TeamTalk client:
A new client instance is created by instantiating the BearWare.TeamTalk5-class. Once the new instance has been created its current state can be retrieved by calling the function TeamTalkBase.GetFlags() which will return a bitmask describing the client's current state. Initially after creating the client instance a call to TeamTalkBase.GetFlags() will return a bitmask with the value ClientFlag.CLIENT_CLOSED since no operations have been performed on the client.
Here a code-snip which shows how to instantiate the BearWare.TeamTalk5 class.
Before connecting to a server it is a good idea to setup the user's sound and video devices. Sound devices are initialized using the TeamTalkBase.InitSoundInputDevice() and TeamTalkBase.InitSoundOutputDevice() functions. The video capture device is initialized using TeamTalkBase.InitVideoCaptureDevice(). Initializing the video capture device can be quite tricky because there's many properties which needs to be configured. Look at the SDK sample applications to see how it is done.
Once sound and video devices has been initialized the function TeamTalkBase.GetFlags() will return a mask containing ClientFlag.CLIENT_SNDINPUT_READY, ClientFlag.CLIENT_SNDOUTPUT_READY and ClientFlag.CLIENT_VIDEOCAPTURE_READY.
Here a code-snip which shows how to extract extract sound and video devices:
Calling TeamTalkBase.Connect() will make the client connect to the server running on the IP-address and port numbers specified as parameters to the function. After this call the TeamTalkBase.GetFlags() function will have the ClientFlag.CLIENT_CONNECTING bit set.
If the TeamTalkBase.Connect() call fails the TeamTalkBase.OnConnectionFailed() event will be posted by the client instance and the ClientFlag.CLIENT_CONNECTING bit will be cleared.
If the TeamTalkBase.Connect() is successful the TeamTalkBase.OnConnectSuccess() event will be posted by the client instance and the ClientFlag.CLIENT_CONNECTED bit will be set and ClientFlag.CLIENT_CONNECTING will be cleared.
Here is a code-snip which shows how to connect to a server:
Once connected the user application can call TeamTalkBase.DoLogin() to log on to the server. All functions with the prefix Do*
are client to server commands (see Client/Server Commands). The TeamTalkBase.DoLogin() requires that the user application provides a username and password for a user account on the server.
If the server rejects the login the TeamTalkBase.OnCmdError() event is posted along with an error code (see ClientError).
If the server accepts the login information the TeamTalkBase.OnCmdMyselfLoggedIn() event is posted and the the client instance will have the ClientFlag.CLIENT_AUTHORIZED set.
For every channel on the server a TeamTalkBase.OnCmdChannelNew() event will be posted and a TeamTalkBase.OnCmdUserLoggedIn() will be posted for every user on the server. The TeamTalkBase.OnCmdUserJoinedChannel() will also be posted for every user who is in a channel.
Here's a code-snip which shows how to log on to a server:
Now that the client is connected and authorized it is possible to join a channel on the server. This is done by either calling the function TeamTalkBase.DoJoinChannel() to create a new channel or by calling TeamTalkBase.DoJoinChannelByID() to join an existing channel.
If using the TeamTalkBase.DoJoinChannelByID() command to join a channel the ID of the channel must be retrieved and also the password needed (if any) to join the channel. The ID of a channel is posted in the TeamTalkBase.OnCmdChannelNew() event and the password must be known by the user.
If the call to TeamTalkBase.DoJoinChannelByID() is successful the event TeamTalkBase.OnCmdUserJoinedChannel() is posted and if the server rejected the command to join the TeamTalkBase.OnCmdError() event is posted.
Here is a code-snip for joining a channel:
Having joined a channel now enables the client instance to start transmitting audio and video to the other users in the channel by calling TeamTalkBase.EnableVoiceTransmission() and TeamTalkBase.StartVideoCaptureTransmission().
When the other users in the channel starts receiving audio they will receive the TeamTalkBase.OnUserStateChange() event. If video is also being transmitted the event TeamTalkBase.OnUserVideoCapture() will be posted for every video frame which is received.
Here's a code-snip on how to transmit and display data: