Ejemplo n.º 1
0
 void ttclient_OnCmdChannelRemove(Channel channel)
 {
     UpdateControls();
 }
Ejemplo n.º 2
0
        private void newMuxedAudioRecording()
        {
            ttclient.StopRecordingMuxedAudioFile();

            Channel chan = new Channel();
            if (!ttclient.GetChannel(ttclient.ChannelID, ref chan))
            {
                MessageBox.Show("Must be in a channel to start muxed audio recording");
                return;
            }

            //generate a filename for the new mux file.
            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ja-JP");
            string timestamp = DateTime.Now.ToString();
            timestamp = timestamp.Replace(":", "");
            timestamp = timestamp.Replace("/", "");
            Thread.CurrentThread.CurrentCulture = currentCulture;
            string extension = "";
            switch (settings.aff)
            {
                case AudioFileFormat.AFF_MP3_64KBIT_FORMAT :
                case AudioFileFormat.AFF_MP3_128KBIT_FORMAT :
                case AudioFileFormat.AFF_MP3_256KBIT_FORMAT :
                    extension = ".mp3"; break;
                case AudioFileFormat.AFF_WAVE_FORMAT :
                    extension = ".wav";
                    break;
            }
            string filename = settings.audiofolder + "\\" + timestamp + " Conference" + extension;
            if (!ttclient.StartRecordingMuxedAudioFile(chan.audiocodec, filename, settings.aff))
                MessageBox.Show("Failed to create muxed audio file: " + filename);
            else
                AddStatusMessage("Recording to " + filename);
        }
Ejemplo n.º 3
0
 /**
  * @brief Get all the channels on the server.
  *
  * Use TeamTalk.GetChannel() to get more information about each of the
  * channels.
  * @see TeamTalk.GetServerUsers() */
 public bool GetServerChannels(out Channel[] lpChannels)
 {
     int count = 0;
     bool b = TTDLL.TT_GetServerChannels_NULL(m_ttInst, IntPtr.Zero, ref count);
     Channel[] channels = new Channel[count];
     b = TTDLL.TT_GetServerChannels(m_ttInst, channels, ref count);
     lpChannels = b ? channels : null;
     return b;
 }
Ejemplo n.º 4
0
        void UpdateControls()
        {
            ClientFlag flags = ttclient.Flags;
            UserType myusertype = ttclient.UserType;
            ServerProperties srvprop = new ServerProperties();

            if ((flags & ClientFlag.CLIENT_CONNECTED) != ClientFlag.CLIENT_CONNECTED)
                ResetControls();

            ttclient.GetServerProperties(ref srvprop);

            int userid = channels.GetSelectedUser();
            int channelid = channels.GetSelectedChannel();

            connectToolStripMenuItem.Text =
                ((flags & ClientFlag.CLIENT_CONNECTED) == ClientFlag.CLIENT_CONNECTED ||
                (flags & ClientFlag.CLIENT_CONNECTING) == ClientFlag.CLIENT_CONNECTING) ? "Disconnect" : "Connect";

            changeNicknameToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            changeStatusModeToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            enableDesktopSharingToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            enableDesktopSharingToolStripMenuItem.Checked = flags.HasFlag(ClientFlag.CLIENT_DESKTOP_ACTIVE);

            muteAllToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_SNDOUTPUT_READY);
            muteAllToolStripMenuItem.Checked = flags.HasFlag(ClientFlag.CLIENT_SNDOUTPUT_MUTE);
            storeAudioToDiskToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            storeAudioToDiskToolStripMenuItem.Checked = settings.audiofolder.Length > 0;

            User user = new User();
            if (userid > 0 && ttclient.GetUser(userid, ref user))
            {
                Debug.Assert((flags & ClientFlag.CLIENT_AUTHORIZED) == ClientFlag.CLIENT_AUTHORIZED);
                viewUserInformationToolStripMenuItem.Enabled = true;
                sendMessageToolStripMenuItem.Enabled = true;
                opDeOpToolStripMenuItem.Enabled = true;
                mutevoiceToolStripMenuItem.Enabled = true;
                mutevoiceToolStripMenuItem.Checked = user.uUserState.HasFlag(UserState.USERSTATE_MUTE_VOICE);
                kickToolStripMenuItem.Enabled = true;
                kickAndBanToolStripMenuItem.Enabled = true;
                subscriptionsToolStripMenuItem.Enabled = true;
                allowDesktopAccessToolStripMenuItem.Enabled = true;
                allowDesktopAccessToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_DESKTOPINPUT);

                userMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_USER_MSG);
                channelMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_CHANNEL_MSG);
                broadcastMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_BROADCAST_MSG);
                voiceToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_VOICE);
                videocaptureToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_VIDEOCAPTURE);
                desktopToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_DESKTOP);
                desktopAccessToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_DESKTOPINPUT);
                interceptUserMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_USER_MSG);
                interceptUserMessagesToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptChannelMessagesToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_CHANNEL_MSG);
                interceptChannelMessagesToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptvoiceToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_VOICE);
                interceptvoiceToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptvideocaptureToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_VIDEOCAPTURE);
                interceptvideocaptureToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
                interceptDesktopToolStripMenuItem.Checked = user.uLocalSubscriptions.HasFlag(Subscription.SUBSCRIBE_INTERCEPT_DESKTOP);
                interceptDesktopToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);

                advancedToolStripMenuItem.Enabled = true;

                Channel userchan = new Channel();
                if (ttclient.GetChannel(user.nChannelID, ref userchan))
                {
                    allowVoiceTransmissionToolStripMenuItem.Checked = userchan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_VOICE);
                    allowVideoTransmissionToolStripMenuItem.Checked = userchan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_VIDEOCAPTURE);
                    allowVoiceTransmissionToolStripMenuItem.Enabled = userchan.uChannelType.HasFlag(ChannelType.CHANNEL_CLASSROOM);
                    allowVideoTransmissionToolStripMenuItem.Enabled = userchan.uChannelType.HasFlag(ChannelType.CHANNEL_CLASSROOM);
                }
            }
            else
            {
                viewUserInformationToolStripMenuItem.Enabled = false;
                sendMessageToolStripMenuItem.Enabled = false;
                opDeOpToolStripMenuItem.Enabled = false;
                mutevoiceToolStripMenuItem.Enabled = false;
                kickToolStripMenuItem.Enabled = false;
                kickAndBanToolStripMenuItem.Enabled = false;
                allowDesktopAccessToolStripMenuItem.Enabled = false;
                subscriptionsToolStripMenuItem.Enabled = false;
                advancedToolStripMenuItem.Enabled = false;
                allowVoiceTransmissionToolStripMenuItem.Enabled = false;
                allowVideoTransmissionToolStripMenuItem.Enabled = false;
            }

            Channel chan = new Channel();
            if (channelid > 0 && ttclient.GetChannel(channelid, ref chan))
            {
                Debug.Assert((flags & ClientFlag.CLIENT_AUTHORIZED) == ClientFlag.CLIENT_AUTHORIZED);
                joinChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                joinNewChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                viewChannelInformationToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                createChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                updateChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                deleteChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                streamMediaFileToChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            }
            else
            {
                joinChannelToolStripMenuItem.Enabled = false;
                joinNewChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                viewChannelInformationToolStripMenuItem.Enabled = false;
                createChannelToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
                updateChannelToolStripMenuItem.Enabled = false;
                deleteChannelToolStripMenuItem.Enabled = false;
                streamMediaFileToChannelToolStripMenuItem.Enabled = false;
            }

            listUserAccountsToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
            serverPropertiesToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            saveConfigurationToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
            broadcastTestMessageToolStripMenuItem.Enabled = flags.HasFlag(ClientFlag.CLIENT_AUTHORIZED);
            serverStatisticsToolStripMenuItem.Enabled = myusertype.HasFlag(UserType.USERTYPE_ADMIN);
        }
Ejemplo n.º 5
0
 void ttserver_OnUserLeftChannel(ref User lpUser, ref Channel lpChannel)
 {
     String str = String.Format("User {0} left channel #{1}",
                    lpUser.szUsername, lpChannel.nChannelID);
     Console.WriteLine(str);
 }
Ejemplo n.º 6
0
 /**
  * @brief Update a channel's properties.
  *
  * Users with ::USERRIGHT_MODIFY_CHANNELS can update all properties of
  * a channel.
  *
  * A user with channel-operator status (see TeamTalk.DoChannelOp()) can
  * also update a channel's properties, but is not able to change the
  * following properties:
  * - @c nDiskQuota
  * - @c nMaxUsers
  * - @c uChannelType
  *   - Cannot modify ::CHANNEL_PERMANENT
  *
  * Note that a channel's #BearWare.AudioCodec cannot be changed
  * if there's currently users in the channel.
  *
  * Possible errors:
  * - #ClientError ::CMDERR_NOT_LOGGEDIN
  * - #ClientError ::CMDERR_NOT_AUTHORIZED
  * - #ClientError ::CMDERR_CHANNEL_NOT_FOUND
  * - #ClientError ::CMDERR_CHANNEL_HAS_USERS
  * - #ClientError ::CMDERR_CHANNEL_ALREADY_EXISTS
  *
  * @param lpChannel A Channel-structure containing information about
  * the channel being modified. The channel member's \a nParentID
  * and \a szName are ignored.
  * @return Returns command ID which will be passed in
  * #OnCmdProcessing event when the server is processing the
  * command. -1 is returned in case of error.
  * @see DoMakeChannel */
 public int DoUpdateChannel(Channel lpChannel)
 {
     return TTDLL.TT_DoUpdateChannel(m_ttInst, ref lpChannel);
 }
Ejemplo n.º 7
0
        public void TestChannelPassword()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            string username1 = "guest1", password1 = "guest1";
            string username2 = "guest2", password2 = "guest2";

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            int cmdid;

            TTMessage msg = new TTMessage();

            Channel chan = new Channel();
            chan.nParentID = ttclient.GetRootChannelID();
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.szOpPassword = "******";
            chan.szPassword = "******";
            chan.nMaxUsers = 128;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(cmdid > 0, "join issued");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_CHANNEL_UPDATE, DEF_WAIT, ref msg));

            Channel chan2 = (Channel)msg.DataToObject();

            Assert.AreEqual(chan.szPassword, chan2.szPassword);

            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "join complete");

            //see own channel password (as operator)
            MakeUserAccount(GetCurrentMethod(), username1, password1, UserRight.USERRIGHT_VIEW_ALL_USERS);
            TeamTalk ttclient2 = NewClientInstance();

            Connect(ttclient2);
            Login(ttclient2, "test user 1", username1, username1);
            JoinRoot(ttclient2);

            Channel chan3 = new Channel();
            Assert.IsTrue(ttclient2.GetChannel(chan2.nChannelID, ref chan3));
            Assert.AreNotEqual(chan.szPassword, chan3.szPassword, "not see passwd");

            Assert.IsTrue(WaitCmdComplete(ttclient2, ttclient2.DoJoinChannelByID(chan2.nChannelID, chan2.szPassword), DEF_WAIT));

            Assert.IsTrue(ttclient2.GetChannel(chan2.nChannelID, ref chan3));
            Assert.AreNotEqual(chan.szPassword, chan3.szPassword, "not see passwd");

            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoUpdateChannel(chan2), DEF_WAIT), "unchanged channel");

            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_CHANNEL_UPDATE, DEF_WAIT));

            Assert.IsTrue(ttclient2.GetChannel(chan2.nChannelID, ref chan3));
            Assert.AreNotEqual(chan.szPassword, chan3.szPassword, "not see passwd");

            //see channel password with USERRIGHT_MODIFY_CHANNELS
            MakeUserAccount(GetCurrentMethod(), username2, password2, UserRight.USERRIGHT_MODIFY_CHANNELS);
            TeamTalk ttclient3 = NewClientInstance();

            Connect(ttclient3);
            Login(ttclient3, "test user 2", username2, username2);
            JoinRoot(ttclient3);

            //see chan passwd as operator
            Channel chan4 = new Channel();
            Assert.IsTrue(ttclient3.GetChannel(chan2.nChannelID, ref chan4));
            Assert.AreEqual(chan.szPassword, chan4.szPassword, "see passwd");

            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoChannelOpEx(ttclient2.GetMyUserID(), chan2.nChannelID, chan.szOpPassword, true), DEF_WAIT), "Op self");

            Assert.IsTrue(ttclient2.GetChannel(chan2.nChannelID, ref chan3));
            Assert.AreEqual(chan.szPassword, chan3.szPassword, "see passwd");
        }
Ejemplo n.º 8
0
        public void TestTextMessage()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL | UserRight.USERRIGHT_VIEW_ALL_USERS;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            int cmdid;

            TTMessage msg = new TTMessage();

            Channel chan = new Channel();
            chan.nParentID = ttclient.GetRootChannelID();
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.nMaxUsers = 128;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;

            TeamTalk ttclient2 = NewClientInstance();
            Connect(ttclient2);
            Login(ttclient2, ADMIN_NICKNAME, ADMIN_USERNAME, ADMIN_PASSWORD);

            //text message
            string newmessage = "this is a new message";
            TextMessage txtmsg = new TextMessage();
            txtmsg.nMsgType = TextMsgType.MSGTYPE_USER;
            txtmsg.szMessage = newmessage;
            txtmsg.nToUserID = 55555;

            cmdid = ttclient.DoTextMessage(txtmsg);
            Assert.IsTrue(cmdid > 0, "text msg err issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT), "invalid userid");

            txtmsg.nToUserID = ttclient2.GetMyUserID();
            
            cmdid = ttclient.DoTextMessage(txtmsg);
            Assert.IsTrue(cmdid > 0, "text msg issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "send tx msg to userid");

            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_USER_TEXTMSG, DEF_WAIT, ref msg), "recv text msg");
            TextMessage recv_txtmsg = (TextMessage)msg.DataToObject();

            Assert.AreEqual(txtmsg.nMsgType, recv_txtmsg.nMsgType);
            Assert.AreEqual(txtmsg.nChannelID, recv_txtmsg.nChannelID);
            Assert.AreEqual(txtmsg.szMessage, recv_txtmsg.szMessage);

            //custom message
            txtmsg.nMsgType = TextMsgType.MSGTYPE_CUSTOM;

            cmdid = ttclient.DoTextMessage(txtmsg);
            Assert.IsTrue(cmdid > 0, "custom text msg issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "send custom tx msg to userid");

            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_USER_TEXTMSG, DEF_WAIT, ref msg), "recv custom text msg");
            recv_txtmsg = (TextMessage)msg.DataToObject();

            Assert.AreEqual(txtmsg.nMsgType, recv_txtmsg.nMsgType);
            Assert.AreEqual(txtmsg.nChannelID, recv_txtmsg.nChannelID);
            Assert.AreEqual(txtmsg.szMessage, recv_txtmsg.szMessage);

            //broadcast
            txtmsg.nMsgType = TextMsgType.MSGTYPE_BROADCAST;
            
            cmdid = ttclient.DoTextMessage(txtmsg);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT), "no bcast rights");

            cmdid = ttclient2.DoTextMessage(txtmsg);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "has bcast rights");

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "has rights");
            Assert.AreEqual(cmdid, msg.nSource);

            //channel msg
            txtmsg.nMsgType = TextMsgType.MSGTYPE_CHANNEL;
            txtmsg.nChannelID = ttclient.GetRootChannelID();
            cmdid = ttclient.DoTextMessage(txtmsg);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT), "no chan msg rights");

            txtmsg.nChannelID = ttclient.GetMyChannelID();
            cmdid = ttclient2.DoTextMessage(txtmsg);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "has chan msg rights");

            cmdid = ttclient.DoTextMessage(txtmsg);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "own chan msg rights");

            cmdid = ttclient.DoLeaveChannel();
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "leave chan");

            //invalid text message
            txtmsg = new TextMessage();
            txtmsg.nMsgType = (TextMsgType)55;
            txtmsg.szMessage = "blahhhhhh";
            txtmsg.nToUserID = 55555;

            cmdid = ttclient.DoTextMessage(txtmsg);
            Assert.IsTrue(cmdid > 0, "text msg issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT, ref msg), "protocol error");
            ClientErrorMsg errmsg = (ClientErrorMsg)msg.DataToObject();
            Assert.AreEqual((int)ClientError.CMDERR_INCOMPATIBLE_PROTOCOLS, errmsg.nErrorNo);
        }
Ejemplo n.º 9
0
 static void ttclient_OnCmdChannelNew(Channel channel)
 {
     string chanpath = "";
     if (ttclient.GetChannelPath(channel.nChannelID, ref chanpath))
     {
         Console.WriteLine("Added channel {0}. Audio storage: {1}", chanpath, audio_dir);
     }
 }
Ejemplo n.º 10
0
        public void TestChannelOp()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL | UserRight.USERRIGHT_VIEW_ALL_USERS;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            int cmdid;

            TTMessage msg = new TTMessage();

            Channel chan = new Channel();
            chan.nParentID = ttclient.GetRootChannelID();
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.szOpPassword = "******";
            chan.nMaxUsers = 128;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(cmdid > 0, "join issued");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "join complete");

            cmdid = ttclient.DoJoinChannelByID(ttclient.GetRootChannelID(), "");

            Assert.IsTrue(cmdid > 0, "join root issued");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "join root complete");

            TeamTalk ttclient2 = NewClientInstance();
            Connect(ttclient2);
            Login(ttclient2, ADMIN_NICKNAME, ADMIN_USERNAME, ADMIN_PASSWORD);

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "join chan");

            Assert.IsTrue(ttclient.IsChannelOperator(ttclient.GetMyUserID(), ttclient.GetMyChannelID()), "op in own chan");

            //TODO: should be possible
            //cmdid = ttclient.DoChannelOp(ttclient.GetMyUserID(), ttclient.GetMyChannelID(), false);
            //Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "de op");

            cmdid = ttclient2.DoChannelOp(ttclient.GetMyUserID(), ttclient.GetMyChannelID(), false);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "admin de op");
            Assert.IsTrue(msg.nSource == cmdid);

            cmdid = ttclient.DoChannelOp(ttclient.GetMyUserID(), ttclient.GetMyChannelID(), true);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT, ref msg), "op fail");
            Assert.IsTrue(msg.nSource == cmdid);

            Assert.IsFalse(ttclient.IsChannelOperator(ttclient.GetMyUserID(), ttclient.GetMyChannelID()), "not op in own chan");

            cmdid = ttclient.DoChannelOpEx(ttclient.GetMyUserID(), ttclient.GetMyChannelID(), chan.szOpPassword, true);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "op passwd success");
            Assert.IsTrue(msg.nSource == cmdid);

            Assert.IsTrue(ttclient.IsChannelOperator(ttclient.GetMyUserID(), ttclient.GetMyChannelID()), "op in own chan");

            cmdid = ttclient.DoKickUser(ttclient.GetMyUserID(), 0);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT), "cannot kick off server");

            cmdid = ttclient.DoKickUser(ttclient.GetMyUserID(), ttclient.GetMyChannelID());
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "kick from channel");

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "join channel");

            cmdid = ttclient2.DoKickUser(ttclient.GetMyUserID(), ttclient.GetMyChannelID());
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "kick from channel");

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "join channel");

            cmdid = ttclient2.DoKickUser(ttclient.GetMyUserID(), 0);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT), "kick from server");

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT), "no join channel");
        }
Ejemplo n.º 11
0
 static void ttclient_OnCmdChannelUpdate(Channel channel)
 {
     string chanpath = "";
     if (ttclient.GetChannelPath(channel.nChannelID, ref chanpath))
         Console.WriteLine("Updated channel {0}", chanpath);
 }
Ejemplo n.º 12
0
 static void ttclient_OnCmdChannelRemove(Channel channel)
 {
     //cannot retrieve
     Console.WriteLine("Removed channel #{0}", channel.nChannelID);
 }
Ejemplo n.º 13
0
 void ttclient_OnCmdChannelRemove(Channel chan)
 {
     treeview.Nodes.Remove(GetChannel(chan.nChannelID));
 }
Ejemplo n.º 14
0
 public static extern BearWare.ClientError TTS_MoveUser(IntPtr lpTTSInstance, int nUserID, [In] ref BearWare.Channel lpChannel);
Ejemplo n.º 15
0
        public void TestFileUpDown()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL | UserRight.USERRIGHT_UPLOAD_FILES | UserRight.USERRIGHT_DOWNLOAD_FILES;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            int cmdid;
            
            TTMessage msg = new TTMessage();

            Channel chan = new Channel();
            chan.nParentID = ttclient.GetRootChannelID();
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.szOpPassword = "******";
            chan.nMaxUsers = 128;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(cmdid > 0, "join issued");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "join complete");

            cmdid = ttclient.DoSendFile(ttclient.GetMyChannelID(), UPLOADFILE);
            Assert.IsTrue(cmdid > 0, "file upload");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "reg upload success");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 2000, ref msg));

            FileTransfer tx = (FileTransfer)msg.DataToObject();
            Assert.IsFalse(tx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), tx.nChannelID);
            Assert.AreEqual(UPLOADFILE, tx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, tx.nStatus);
            FileTransfer tx2 = new FileTransfer();
            Assert.IsTrue(ttclient.GetFileTransferInfo(tx.nTransferID, ref tx2));
            Assert.AreEqual(tx.bInbound, tx2.bInbound);
            Assert.AreEqual(tx.nChannelID, tx2.nChannelID);
            Assert.AreEqual(tx.nFileSize, tx2.nFileSize);
            Assert.AreEqual(tx.nStatus, tx2.nStatus);
            Assert.AreEqual(tx.nTransferID, tx2.nTransferID);
            //Assert.AreEqual(tx.nTransferred, tx2.nTransferred);
            Assert.AreEqual(tx.szLocalFilePath, tx2.szLocalFilePath);
            Assert.AreEqual(tx.szRemoteFileName, tx2.szRemoteFileName);

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_FILE_NEW, DEF_WAIT, ref msg));
            RemoteFile file = (RemoteFile)msg.DataToObject();

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 10000, ref msg));
            tx = (FileTransfer)msg.DataToObject();

            Assert.IsFalse(tx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), tx.nChannelID);
            Assert.AreEqual(UPLOADFILE, tx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_FINISHED, tx.nStatus);

            RemoteFile[] files;
            Assert.IsTrue(ttclient.GetChannelFiles(ttclient.GetMyChannelID(), out files));

            RemoteFile file2 = new RemoteFile();
            Assert.IsTrue(ttclient.GetChannelFile(ttclient.GetMyChannelID(), file.nFileID, ref file2));

            Assert.AreEqual(file.nFileID, file2.nFileID);
            Assert.AreEqual(file.nFileSize, file2.nFileSize);
            Assert.AreEqual(file.szFileName, file2.szFileName);
            Assert.AreEqual(file.szUsername, file2.szUsername);

            cmdid = ttclient.DoRecvFile(ttclient.GetMyChannelID(), file.nFileID, DOWNLOADFILE);
            Assert.IsTrue(cmdid > 0, "recv issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "reg down success");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 2000, ref msg));

            FileTransfer rx = (FileTransfer)msg.DataToObject();
            Assert.IsTrue(rx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), rx.nChannelID);
            Assert.AreEqual(DOWNLOADFILE, rx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, rx.nStatus);

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 10000, ref msg));
            rx = (FileTransfer)msg.DataToObject();

            Assert.IsTrue(rx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), rx.nChannelID);
            Assert.AreEqual(DOWNLOADFILE, rx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_FINISHED, rx.nStatus);

            cmdid = ttclient.DoRecvFile(ttclient.GetMyChannelID(), file.nFileID, DOWNLOADFILE);
            Assert.IsTrue(cmdid > 0, "recv issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "reg down success");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 2000, ref msg));

            rx = (FileTransfer)msg.DataToObject();
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, rx.nStatus);
            Assert.IsTrue(ttclient.CancelFileTranfer(rx.nTransferID));

            cmdid = ttclient.DoDeleteFile(ttclient.GetMyChannelID(), file.nFileID);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "delete file success");
        }
Ejemplo n.º 16
0
        void ttclient_OnCmdChannelUpdate(Channel chan)
        {
            if ((chan.uChannelType & ChannelType.CHANNEL_CLASSROOM) == ChannelType.CHANNEL_DEFAULT)
                return;

            TreeNode chanNode = GetChannel(chan.nChannelID);
            Debug.Assert(chanNode != null);

            List<TreeNode> users = new List<TreeNode>();
            foreach (TreeNode userNode in chanNode.Nodes)
            {
                if (userNode.ImageIndex == (int)ImageIndex.USER)
                    users.Add(userNode);
            }
            foreach (TreeNode userNode in users)
            {
                User user = new User();
                if (ttclient.GetUser((int)userNode.Tag, ref user))
                {
                    userNode.Text = String.Format("{0} [Voice={1}, Video={2}, Desktop={3}, MediaFile={4}]",
                        user.szNickname,
                        chan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_VOICE),
                        chan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_VIDEOCAPTURE),
                        chan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_DESKTOP),
                        chan.GetTransmitStreamTypes(user.nUserID).HasFlag(StreamType.STREAMTYPE_MEDIAFILE_AUDIO | StreamType.STREAMTYPE_MEDIAFILE_VIDEO));
                }
            }
        }
Ejemplo n.º 17
0
        public void TestChannelCommands()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            int cmdid;
            TTMessage msg = new TTMessage();

            TeamTalk ttclient2 = NewClientInstance();
            Connect(ttclient2);
            Login(ttclient2, ADMIN_NICKNAME, ADMIN_USERNAME, ADMIN_PASSWORD);

            Channel chan = new Channel();
            chan.nParentID = ttclient2.GetRootChannelID();
            chan.uChannelType = ChannelType.CHANNEL_PERMANENT | ChannelType.CHANNEL_SOLO_TRANSMIT;
            chan.nUserData = 555666;
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.szPassword = "******";
            chan.szOpPassword = "******";
            chan.nMaxUsers = 128;
            chan.nDiskQuota = 5548726;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;
            chan.audiocfg = new AudioConfig(true);

            //ensure channel doesn't already exists
            WaitCmdComplete(ttclient2, ttclient2.DoRemoveChannel(ttclient2.GetChannelIDFromPath(chan.szName)), DEF_WAIT);

            cmdid = ttclient2.DoMakeChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_CHANNEL_NEW, DEF_WAIT, ref msg), "add chan");
            Channel chan2 = (Channel)msg.DataToObject();
            Channel permChan = chan2;

            Assert.AreEqual(chan.nParentID, chan2.nParentID);
            Assert.AreEqual(chan.uChannelType, chan2.uChannelType);
            Assert.AreEqual(chan.nUserData, chan2.nUserData);
            Assert.AreEqual(chan.szName, chan2.szName);
            Assert.AreEqual(chan.szTopic, chan2.szTopic);
            Assert.AreEqual(chan.szPassword, chan2.szPassword);
            Assert.AreEqual(chan.szOpPassword, chan2.szOpPassword);
            Assert.AreEqual(chan.nMaxUsers, chan2.nMaxUsers);
            Assert.AreEqual(chan.nDiskQuota, chan2.nDiskQuota);
            Assert.AreEqual(chan.audiocodec.nCodec, chan2.audiocodec.nCodec);
            Assert.AreEqual(chan.audiocodec.opus.nApplication, chan2.audiocodec.opus.nApplication);
            Assert.AreEqual(chan.audiocodec.opus.nChannels, chan2.audiocodec.opus.nChannels);
            Assert.AreEqual(chan.audiocodec.opus.nBitRate, chan2.audiocodec.opus.nBitRate);
            Assert.AreEqual(chan.audiocodec.opus.nComplexity, chan2.audiocodec.opus.nComplexity);
            Assert.AreEqual(chan.audiocodec.opus.nTxIntervalMSec, chan2.audiocodec.opus.nTxIntervalMSec);
            Assert.AreEqual(chan.audiocodec.opus.nSampleRate, chan2.audiocodec.opus.nSampleRate);
            Assert.AreEqual(chan.audiocodec.opus.bDTX, chan2.audiocodec.opus.bDTX);
            Assert.AreEqual(chan.audiocodec.opus.bFEC, chan2.audiocodec.opus.bFEC);
            Assert.AreEqual(chan.audiocodec.opus.bVBR, chan2.audiocodec.opus.bVBR);
            Assert.AreEqual(chan.audiocodec.opus.bVBRConstraint, chan2.audiocodec.opus.bVBRConstraint);
            Assert.AreEqual(chan.audiocfg.bEnableAGC, chan2.audiocfg.bEnableAGC);
            Assert.AreEqual(chan.audiocfg.nGainLevel, chan2.audiocfg.nGainLevel);

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            Assert.IsTrue(ttclient.GetMyUserRights().HasFlag(UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL));
            Assert.IsFalse(ttclient.GetMyUserRights().HasFlag(UserRight.USERRIGHT_MODIFY_CHANNELS));

            cmdid = ttclient.DoJoinChannelByID(chan2.nChannelID, chan.szPassword);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "join complete");

            chan.uChannelType = ChannelType.CHANNEL_CLASSROOM;
            chan.nMaxUsers = 1024;
            chan.nParentID = chan2.nChannelID;
            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_CHANNEL_NEW, DEF_WAIT, ref msg), "join complete");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT));
            chan2 = (Channel)msg.DataToObject();

            Assert.AreEqual(chan.nParentID, chan2.nParentID);
            Assert.AreEqual(chan.uChannelType, chan2.uChannelType);
            Assert.AreEqual(chan.szName, chan2.szName);
            Assert.AreEqual(chan.szTopic, chan2.szTopic);
            //Assert.AreEqual(chan.szPassword, chan2.szPassword);
            //Assert.AreEqual(chan.szOpPassword, chan2.szOpPassword);
            Assert.AreNotEqual(chan.nMaxUsers, chan2.nMaxUsers);
            Assert.AreNotEqual(chan.nDiskQuota, chan2.nDiskQuota);
            Assert.AreEqual(chan.audiocodec.nCodec, chan2.audiocodec.nCodec);
            Assert.AreEqual(chan.audiocodec.opus.nApplication, chan2.audiocodec.opus.nApplication);
            Assert.AreEqual(chan.audiocodec.opus.nChannels, chan2.audiocodec.opus.nChannels);
            Assert.AreEqual(chan.audiocodec.opus.nBitRate, chan2.audiocodec.opus.nBitRate);
            Assert.AreEqual(chan.audiocodec.opus.nComplexity, chan2.audiocodec.opus.nComplexity);
            Assert.AreEqual(chan.audiocodec.opus.nTxIntervalMSec, chan2.audiocodec.opus.nTxIntervalMSec);
            Assert.AreEqual(chan.audiocodec.opus.nSampleRate, chan2.audiocodec.opus.nSampleRate);
            Assert.AreEqual(chan.audiocodec.opus.bDTX, chan2.audiocodec.opus.bDTX);
            Assert.AreEqual(chan.audiocodec.opus.bFEC, chan2.audiocodec.opus.bFEC);
            Assert.AreEqual(chan.audiocodec.opus.bVBR, chan2.audiocodec.opus.bVBR);
            Assert.AreEqual(chan.audiocodec.opus.bVBRConstraint, chan2.audiocodec.opus.bVBRConstraint);
            Assert.AreEqual(chan.audiocfg.bEnableAGC, chan2.audiocfg.bEnableAGC);
            Assert.AreEqual(chan.audiocfg.nGainLevel, chan2.audiocfg.nGainLevel);
            //Assert.AreEqual(chan.audiocfg.bEnableEchoCancellation, chan2.audiocfg.bEnableEchoCancellation);
            //Assert.AreEqual(chan.audiocfg.nEchoSuppress, chan2.audiocfg.nEchoSuppress);
            //Assert.AreEqual(chan.audiocfg.nEchoSuppressActive, chan2.audiocfg.nEchoSuppressActive);

            chan.nChannelID = chan2.nChannelID;
            chan.szName = "new channel name";
            cmdid = ttclient.DoUpdateChannel(chan);

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_CHANNEL_UPDATE, DEF_WAIT, ref msg), "update complete");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT));

            chan2 = (Channel)msg.DataToObject();

            Assert.AreEqual(chan.nParentID, chan2.nParentID);
            Assert.AreEqual(chan.nChannelID, chan2.nChannelID);
            Assert.AreEqual(chan.uChannelType, chan2.uChannelType);
            Assert.AreEqual(chan.szName, chan2.szName);
            Assert.AreEqual(chan.szTopic, chan2.szTopic);
            //Assert.AreEqual(chan.szPassword, chan2.szPassword);
            //Assert.AreEqual(chan.szOpPassword, chan2.szOpPassword);
            Assert.AreNotEqual(chan.nMaxUsers, chan2.nMaxUsers);
            Assert.AreNotEqual(chan.nDiskQuota, chan2.nDiskQuota);
            Assert.AreEqual(chan.audiocodec.nCodec, chan2.audiocodec.nCodec);
            Assert.AreEqual(chan.audiocodec.opus.nApplication, chan2.audiocodec.opus.nApplication);
            Assert.AreEqual(chan.audiocodec.opus.nChannels, chan2.audiocodec.opus.nChannels);
            Assert.AreEqual(chan.audiocodec.opus.nBitRate, chan2.audiocodec.opus.nBitRate);
            Assert.AreEqual(chan.audiocodec.opus.nComplexity, chan2.audiocodec.opus.nComplexity);
            Assert.AreEqual(chan.audiocodec.opus.nTxIntervalMSec, chan2.audiocodec.opus.nTxIntervalMSec);
            Assert.AreEqual(chan.audiocodec.opus.nSampleRate, chan2.audiocodec.opus.nSampleRate);
            Assert.AreEqual(chan.audiocodec.opus.bDTX, chan2.audiocodec.opus.bDTX);
            Assert.AreEqual(chan.audiocodec.opus.bFEC, chan2.audiocodec.opus.bFEC);
            Assert.AreEqual(chan.audiocodec.opus.bVBR, chan2.audiocodec.opus.bVBR);
            Assert.AreEqual(chan.audiocodec.opus.bVBRConstraint, chan2.audiocodec.opus.bVBRConstraint);
            Assert.AreEqual(chan.audiocfg.bEnableAGC, chan2.audiocfg.bEnableAGC);
            Assert.AreEqual(chan.audiocfg.nGainLevel, chan2.audiocfg.nGainLevel);

            string chpath = "";
            Assert.IsTrue(ttclient.GetChannelPath(chan2.nChannelID, ref chpath));
            Assert.AreEqual(chan2.nChannelID, ttclient.GetChannelIDFromPath(chpath));

            User[] users;
            Assert.IsTrue(ttclient.GetChannelUsers(chan2.nChannelID, out users));

            //ensure UserRight.USERRIGHT_MODIFY_CHANNELS can update
            chan.szName = "foobar";
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoUpdateChannel(chan), DEF_WAIT));

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_CHANNEL_UPDATE, DEF_WAIT, ref msg), "update complete");
            Assert.IsTrue(ttclient.GetChannel(chan.nChannelID, ref chan2));
            Assert.AreEqual(chan2.szName, chan.szName);

            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoJoinChannelByID(permChan.nChannelID, permChan.szPassword), DEF_WAIT));
            chan = permChan;

            //non-op cannot update
            Assert.IsTrue(WaitCmdError(ttclient, ttclient.DoUpdateChannel(chan), DEF_WAIT));

            //make op
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoChannelOp(ttclient.GetMyUserID(), chan.nChannelID, true), DEF_WAIT));

            //update as op
            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoUpdateChannel(chan), DEF_WAIT));

            //cannot update perm
            chan.uChannelType = ChannelType.CHANNEL_DEFAULT;
            Assert.IsTrue(WaitCmdError(ttclient, ttclient.DoUpdateChannel(chan), DEF_WAIT));

            //cannot update name
            chan = permChan;
            chan.szName = "fod2";
            Assert.IsTrue(WaitCmdError(ttclient, ttclient.DoUpdateChannel(chan), DEF_WAIT));

            //update as op
            chan = permChan;
            chan.szTopic = "a new topic";
            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoUpdateChannel(chan), DEF_WAIT));

            //no remove as op
            Assert.IsTrue(WaitCmdError(ttclient, ttclient.DoRemoveChannel(chan.nChannelID), DEF_WAIT));

            //remove with rights
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoRemoveChannel(chan.nChannelID), DEF_WAIT));
        }
Ejemplo n.º 18
0
 void ttserver_OnUserKicked(ref User lpKicker, ref User lpKickee, ref Channel lpChannel)
 {
     String str = String.Format("User {0} kicked by {1}",
                     lpKicker.szUsername, lpKickee.szUsername);
     Console.WriteLine(str);
 }
Ejemplo n.º 19
0
        public void TestMoveUserCommands()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            int cmdid;
            TTMessage msg = new TTMessage();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);

            TeamTalk ttclient2 = NewClientInstance();
            Connect(ttclient2);
            Login(ttclient2, ADMIN_NICKNAME, ADMIN_USERNAME, ADMIN_PASSWORD);

            Channel chan = new Channel();
            chan.nParentID = ttclient2.GetRootChannelID();
            chan.uChannelType = ChannelType.CHANNEL_DEFAULT;
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.szPassword = "******";
            chan.szOpPassword = "******";
            chan.nMaxUsers = 128;
            chan.nDiskQuota = 5548726;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;
            chan.audiocfg = new AudioConfig(true);

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "join complete");

            cmdid = ttclient.DoMoveUser(ttclient.GetMyUserID(), ttclient.GetRootChannelID());
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT, ref msg), "move failure");

            cmdid = ttclient2.DoMoveUser(ttclient.GetMyUserID(), ttclient.GetRootChannelID());
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "move failure");

            Assert.AreEqual(ttclient.GetRootChannelID(), ttclient.GetMyChannelID());
        }
Ejemplo n.º 20
0
 void ttserver_OnChannelUpdated(ref Channel lpChannel, ref User lpUser)
 {
     String str = String.Format("Channel #{0} updated",
                    lpChannel.nChannelID);
     Console.WriteLine(str);
 }
Ejemplo n.º 21
0
        public void TestUserAccountRights()
        {
            TeamTalk ttclient = NewClientInstance();
            Connect(ttclient);
            Login(ttclient, ADMIN_NICKNAME, ADMIN_USERNAME, ADMIN_PASSWORD);

            TTMessage msg = new TTMessage();
            string BANIPADDR = "192.25.2.1";
            UserAccount account = new UserAccount();
            account.szInitChannel = "";
            account.autoOperatorChannels = new int[TeamTalk.TT_CHANNELS_OPERATOR_MAX];
            account.szUsername = "******";
            account.szPassword = "******";
            account.szNote = "the note";
            account.nUserData = 456;
            account.uUserRights = UserRight.USERRIGHT_NONE;
            account.uUserType = UserType.USERTYPE_DEFAULT;
            account.nAudioCodecBpsLimit = 22000;

            int cmdid = ttclient.DoNewUserAccount(account);
            WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT);

            TeamTalk ttclient2 = NewClientInstance();
            Connect(ttclient2);

            Login(ttclient2, "blah", account.szUsername, account.szPassword);

            UserAccount account2 = new UserAccount();
            Assert.IsTrue(ttclient2.GetMyUserAccount(ref account2), "get account");

            Assert.AreEqual(account.szUsername, account2.szUsername);
            //Assert.AreEqual(account.szPassword, account2.szPassword);
            Assert.AreEqual(account.nUserData, account2.nUserData);
            Assert.AreEqual(account.szInitChannel, account2.szInitChannel);
            Assert.AreEqual(account.szNote, account2.szNote);
            Assert.AreEqual(account.uUserRights, account2.uUserRights);
            Assert.AreEqual(account.uUserType, account2.uUserType);
            Assert.AreEqual(account.nAudioCodecBpsLimit, account2.nAudioCodecBpsLimit);

            CollectionAssert.AreEqual(account.autoOperatorChannels, account2.autoOperatorChannels);

            Channel chan = new Channel();
            chan.nParentID = ttclient2.GetRootChannelID();
            chan.szName = "foobar";

            //USERRIGHT_NONE
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoJoinChannelByID(ttclient2.GetRootChannelID(), ""), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoSendFile(ttclient2.GetMyChannelID(), UPLOADFILE), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoBanUser(ttclient2.GetMyUserID(), 0), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoBanIPAddress(BANIPADDR, 0), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoUnBanUser(BANIPADDR, 0), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoListBans(0, 0, 200), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoNewUserAccount(account), DEF_WAIT));

            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoLeaveChannel(), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoMakeChannel(chan), DEF_WAIT));
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoJoinChannel(chan), DEF_WAIT));
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoLogout(), DEF_WAIT));

            //USERRIGHT_CREATE_TEMPORARY_CHANNEL
            account.uUserRights |= UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL;
            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoNewUserAccount(account), DEF_WAIT));

            Login(ttclient2, "blah", account.szUsername, account.szPassword);
            Assert.IsTrue(ttclient2.GetMyUserAccount(ref account2), "get account");
            Assert.AreEqual(account.uUserRights, account2.uUserRights);
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoJoinChannel(chan), DEF_WAIT));

            chan.szName = "foobar2";
            chan.nChannelID = 0;
            chan.audiocodec.nCodec = Codec.SPEEX_CODEC;
            chan.audiocodec.speex.nBandmode = 1;
            chan.audiocodec.speex.nTxIntervalMSec = 40;
            chan.audiocodec.speex.nQuality = 10;
            chan.audiocodec.speex.bStereoPlayback = false;
            Assert.IsTrue(WaitCmdError(ttclient2, ttclient2.DoJoinChannel(chan), DEF_WAIT));
            chan.audiocodec.speex.nQuality = 2;
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoJoinChannel(chan), DEF_WAIT));

            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoLogout(), DEF_WAIT));

            //USERRIGHT_BAN_USERS
            account.uUserRights |= UserRight.USERRIGHT_BAN_USERS;
            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoNewUserAccount(account), DEF_WAIT));

            Login(ttclient2, "blah", account.szUsername, account.szPassword);
            Assert.IsTrue(ttclient2.GetMyUserAccount(ref account2), "get account");
            Assert.AreEqual(account.uUserRights, account2.uUserRights);
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoBanUser(ttclient2.GetMyUserID(), 0), DEF_WAIT));
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoBanIPAddress(BANIPADDR, 0), DEF_WAIT));
            ttclient2.OnCmdBannedUser += new TeamTalk.ListBannedUser(ttclient2_OnCmdBannedUser);
            bannedusers.Clear();
            Assert.IsTrue(WaitCmdComplete(ttclient2, ttclient2.DoListBans(0, 0, 200), DEF_WAIT));

            BannedUser b = bannedusers.First<BannedUser>(m => m.szUsername == account2.szUsername);
            Assert.IsTrue(bannedusers.Count(m => m.szIPAddress == BANIPADDR) == 1);

            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoUnBanUser(b.szIPAddress, 0), DEF_WAIT));
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoUnBanUser(BANIPADDR, 0), DEF_WAIT));
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoLogout(), DEF_WAIT));

            //USERRIGHT_UPLOAD_FILES
            account.uUserRights |= UserRight.USERRIGHT_UPLOAD_FILES;
            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoNewUserAccount(account), DEF_WAIT));

            Login(ttclient2, "blah", account.szUsername, account.szPassword);
            Assert.IsTrue(ttclient2.GetMyUserAccount(ref account2), "get account");
            Assert.AreEqual(account.uUserRights, account2.uUserRights);
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoJoinChannel(chan), DEF_WAIT));
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoSendFile(ttclient2.GetMyChannelID(), UPLOADFILE), 20000));
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_FILETRANSFER, 20000, ref msg));
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, ((FileTransfer)msg.DataToObject()).nStatus);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_FILETRANSFER, 20000, ref msg));
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_FINISHED, ((FileTransfer)msg.DataToObject()).nStatus);
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoLogout(), DEF_WAIT));

            //USERRIGHT_DOWNLOAD_FILES
            account.uUserRights |= UserRight.USERRIGHT_DOWNLOAD_FILES;
            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoNewUserAccount(account), DEF_WAIT));

            Login(ttclient2, "blah", account.szUsername, account.szPassword);
            Assert.IsTrue(ttclient2.GetMyUserAccount(ref account2), "get account");
            Assert.AreEqual(account.uUserRights, account2.uUserRights);
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoJoinChannel(chan), DEF_WAIT));
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoSendFile(ttclient2.GetMyChannelID(), UPLOADFILE), 20000));
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_FILETRANSFER, 20000, ref msg));
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, ((FileTransfer)msg.DataToObject()).nStatus);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_FILETRANSFER, 20000, ref msg));
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_FINISHED, ((FileTransfer)msg.DataToObject()).nStatus);
            RemoteFile[] files;
            Assert.IsTrue(ttclient2.GetChannelFiles(ttclient2.GetMyChannelID(), out files));
            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoRecvFile(files[0].nChannelID, files[0].nFileID, DOWNLOADFILE), 20000));
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_FILETRANSFER, 20000, ref msg));
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, ((FileTransfer)msg.DataToObject()).nStatus);
            Assert.IsTrue(WaitForEvent(ttclient2, ClientEvent.CLIENTEVENT_FILETRANSFER, 20000, ref msg));
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_FINISHED, ((FileTransfer)msg.DataToObject()).nStatus);

            Assert.IsTrue(WaitCmdSuccess(ttclient2, ttclient2.DoLogout(), DEF_WAIT));

            //TODO: remaining rights
            //UserRight.USERRIGHT_KICK_USERS
            //UserRight.USERRIGHT_MOVE_USERS
            //UserRight.USERRIGHT_
            //UserRight.USERRIGHT_MODIFY_CHANNELS

            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoSaveConfig(), DEF_WAIT));

            cmdid = ttclient.DoDeleteUserAccount(account.szUsername);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT));

            cmdid = ttclient.DoDeleteUserAccount("godj3g");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_ERROR, DEF_WAIT));
        }
Ejemplo n.º 22
0
 /**
  * @brief Get the channel with a specific ID.
  *
  * @param nChannelID The ID of the channel to get information about.
  * @param lpChannel A preallocated struct which will receive the
  * channel's properties.
  * @return FALSE if unable to retrieve channel otherwise TRUE. */
 public bool GetChannel(int nChannelID, ref Channel lpChannel)
 {
     return TTDLL.TT_GetChannel(m_ttInst, nChannelID, ref lpChannel);
 }
Ejemplo n.º 23
0
        public void TestAudioCodecs()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL |
                                         UserRight.USERRIGHT_TRANSMIT_VOICE;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            InitSound(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);

            Channel chan = BuildDefaultChannel(ttclient, "Opus");
            Assert.AreEqual(chan.audiocodec.nCodec, Codec.OPUS_CODEC);

            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoJoinChannel(chan), DEF_WAIT));

            Channel chan2 = new Channel();
            Assert.IsTrue(ttclient.GetChannel(ttclient.GetMyChannelID(), ref chan2));
            Assert.AreEqual(chan.audiocodec.nCodec, chan2.audiocodec.nCodec);
            Assert.AreEqual(chan.audiocodec.opus.bDTX, chan2.audiocodec.opus.bDTX);
            Assert.AreEqual(chan.audiocodec.opus.bFEC, chan2.audiocodec.opus.bFEC);
            Assert.AreEqual(chan.audiocodec.opus.bVBR, chan2.audiocodec.opus.bVBR);
            Assert.AreEqual(chan.audiocodec.opus.bVBRConstraint, chan2.audiocodec.opus.bVBRConstraint);
            Assert.AreEqual(chan.audiocodec.opus.nApplication, chan2.audiocodec.opus.nApplication);
            Assert.AreEqual(chan.audiocodec.opus.nBitRate, chan2.audiocodec.opus.nBitRate);
            Assert.AreEqual(chan.audiocodec.opus.nChannels, chan2.audiocodec.opus.nChannels);
            Assert.AreEqual(chan.audiocodec.opus.nComplexity, chan2.audiocodec.opus.nComplexity);
            Assert.AreEqual(chan.audiocodec.opus.nTxIntervalMSec, chan2.audiocodec.opus.nTxIntervalMSec);
            Assert.AreEqual(chan.audiocodec.opus.nSampleRate, chan2.audiocodec.opus.nSampleRate);

            chan.szName = "Speex";
            chan.audiocodec.nCodec = Codec.SPEEX_CODEC;
            chan.audiocodec.speex.bStereoPlayback = true;
            chan.audiocodec.speex.nBandmode = 2;
            chan.audiocodec.speex.nTxIntervalMSec = 80;
            chan.audiocodec.speex.nQuality = 7;

            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoJoinChannel(chan), DEF_WAIT));
            Assert.IsTrue(ttclient.GetChannel(ttclient.GetMyChannelID(), ref chan2));

            Assert.AreEqual(chan.audiocodec.nCodec, chan2.audiocodec.nCodec);
            Assert.AreEqual(chan.audiocodec.speex.bStereoPlayback, chan2.audiocodec.speex.bStereoPlayback);
            Assert.AreEqual(chan.audiocodec.speex.nBandmode, chan2.audiocodec.speex.nBandmode);
            Assert.AreEqual(chan.audiocodec.speex.nTxIntervalMSec, chan2.audiocodec.speex.nTxIntervalMSec);
            Assert.AreEqual(chan.audiocodec.speex.nQuality, chan2.audiocodec.speex.nQuality);

            chan.szName = "Speex VBR";
            chan.audiocodec.nCodec = Codec.SPEEX_VBR_CODEC;
            chan.audiocodec.speex_vbr.bDTX = true;
            chan.audiocodec.speex_vbr.bStereoPlayback = true;
            chan.audiocodec.speex_vbr.nBandmode = 2;
            chan.audiocodec.speex_vbr.nBitRate = 22300;
            chan.audiocodec.speex_vbr.nMaxBitRate = 30000;
            chan.audiocodec.speex_vbr.nTxIntervalMSec = 80;
            chan.audiocodec.speex_vbr.nQuality = 4;

            Assert.IsTrue(WaitCmdSuccess(ttclient, ttclient.DoJoinChannel(chan), DEF_WAIT));
            Assert.IsTrue(ttclient.GetChannel(ttclient.GetMyChannelID(), ref chan2));

            Assert.AreEqual(chan.audiocodec.nCodec, chan2.audiocodec.nCodec);
            Assert.AreEqual(chan.audiocodec.speex_vbr.bDTX, chan2.audiocodec.speex_vbr.bDTX);
            Assert.AreEqual(chan.audiocodec.speex_vbr.bStereoPlayback, chan2.audiocodec.speex_vbr.bStereoPlayback);
            Assert.AreEqual(chan.audiocodec.speex_vbr.nBandmode, chan2.audiocodec.speex_vbr.nBandmode);
            Assert.AreEqual(chan.audiocodec.speex_vbr.nBitRate, chan2.audiocodec.speex_vbr.nBitRate);
            Assert.AreEqual(chan.audiocodec.speex_vbr.nMaxBitRate, chan2.audiocodec.speex_vbr.nMaxBitRate);
            Assert.AreEqual(chan.audiocodec.speex_vbr.nTxIntervalMSec, chan2.audiocodec.speex_vbr.nTxIntervalMSec);
            Assert.AreEqual(chan.audiocodec.speex_vbr.nQuality, chan2.audiocodec.speex_vbr.nQuality);

        }
Ejemplo n.º 24
0
        private void allowVideoTransmissionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            User user = new User();
            Channel chan = new Channel();
            if (ttclient.GetUser(channels.GetSelectedUser(), ref user) &&
                ttclient.GetChannel(user.nChannelID, ref chan))
            {
                if (allowVideoTransmissionToolStripMenuItem.Checked)
                {
                    if (chan.GetTransmitStreamTypes(user.nUserID) == StreamType.STREAMTYPE_NONE &&
                        chan.GetTransmitUserCount() >= TeamTalk.TT_TRANSMITUSERS_MAX)
                        MessageBox.Show("Maximum users to transmit is " + TeamTalk.TT_TRANSMITUSERS_MAX.ToString());
                    else
                        chan.AddTransmitUser(user.nUserID, StreamType.STREAMTYPE_VIDEOCAPTURE);
                }
                else
                    chan.RemoveTransmitUser(user.nUserID, StreamType.STREAMTYPE_VIDEOCAPTURE);

                ttclient.DoUpdateChannel(chan);
            }
        }
Ejemplo n.º 25
0
        void VoiceTxRx(TeamTalk ttclient, int TEST_DURATION, int VOICE_TX_DURATION, int SILENCE_DURATION)
        {
            Debug.WriteLine("Total Duration {0} {1} {2}", TEST_DURATION, VOICE_TX_DURATION, SILENCE_DURATION);
            Channel chan = new Channel();
            Assert.IsTrue(ttclient.GetChannel(ttclient.ChannelID, ref chan));
            TTMessage msg = new TTMessage();

            int tx_interval = chan.audiocodec.opus.nTxIntervalMSec;
            int test_duration = 0, voice_tx_duration;
            while (test_duration < TEST_DURATION)
            {
                Debug.WriteLine("Duration {0}", test_duration);

                voice_tx_duration = 0;
                AudioBlock block;

                Assert.IsTrue(ttclient.EnableVoiceTransmission(true));

                Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_STATECHANGE, 1000, ref msg));
                Assert.IsTrue(((User)msg.DataToObject()).uUserState.HasFlag(UserState.USERSTATE_VOICE));

                do
                {
                    Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_AUDIOBLOCK, 1000));
                    block = ttclient.AcquireUserAudioBlock(StreamType.STREAMTYPE_VOICE, ttclient.UserID);
                    Assert.IsTrue(block.nStreamID > 0);
                    Assert.IsTrue(ttclient.ReleaseUserAudioBlock(block));
                }
                while ((voice_tx_duration += tx_interval) < VOICE_TX_DURATION);

                Assert.IsTrue(ttclient.EnableVoiceTransmission(false));

                Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_STATECHANGE, 5000, ref msg));
                Assert.IsFalse(((User)msg.DataToObject()).uUserState.HasFlag(UserState.USERSTATE_VOICE));

                WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_NONE, SILENCE_DURATION);

                //drain queue
                do
                {
                    block = ttclient.AcquireUserAudioBlock(StreamType.STREAMTYPE_VOICE, ttclient.UserID);
                    if(block.nStreamID>0)
                        ttclient.ReleaseUserAudioBlock(block);
                }
                while(block.nStreamID>0);

                while(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_AUDIOBLOCK, 0))


                test_duration += voice_tx_duration;
                test_duration += SILENCE_DURATION;
            }
        }
Ejemplo n.º 26
0
 void ttclient_OnCmdChannelNew(Channel channel)
 {
     UpdateControls();
 }
Ejemplo n.º 27
0
 private static Channel BuildDefaultChannel(TeamTalk ttclient, string name)
 {
     Channel chan = new Channel(true);
     chan.nParentID = ttclient.GetRootChannelID();
     chan.szName = name;
     chan.szTopic = "a topic";
     chan.nMaxUsers = 128;
     chan.audiocodec.nCodec = Codec.OPUS_CODEC;
     chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
     chan.audiocodec.opus.nChannels = 1;
     chan.audiocodec.opus.nBitRate = 64000;
     chan.audiocodec.opus.nComplexity = 5;
     chan.audiocodec.opus.nTxIntervalMSec = 20;
     chan.audiocodec.opus.nSampleRate = 48000;
     chan.audiocodec.opus.bDTX = true;
     chan.audiocodec.opus.bFEC = true;
     chan.audiocodec.opus.bVBR = true;
     chan.audiocodec.opus.bVBRConstraint = false;
     return chan;
 }
Ejemplo n.º 28
0
 private void joinChannelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     int channelid = channels.GetSelectedChannel();
     if (channelid <= 0)
         return;
     //check if password protected
     Channel chan = new Channel();
     if (!ttclient.GetChannel(channelid, ref chan))
         return;
     string passwd = "";
     if (chan.bPassword)
         passwd = InputBox.Get("Join channel", "Password");
     ttclient.DoJoinChannelByID(channelid, passwd);
 }
Ejemplo n.º 29
0
        public void TestRecordAudio()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_TRANSMIT_VOICE;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            InitSound(ttclient);
            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            JoinRoot(ttclient);
            
            TTMessage msg = new TTMessage();

            Channel chan = new Channel();
            Assert.IsTrue(ttclient.GetChannel(ttclient.GetMyChannelID(), ref chan), "get channel");
            Assert.IsTrue(ttclient.StartRecordingMuxedAudioFile(chan.audiocodec, MUXRECORDFILENAME, AudioFileFormat.AFF_WAVE_FORMAT),
                          "Record to file");

            Assert.IsTrue(ttclient.Flags.HasFlag(ClientFlag.CLIENT_MUX_AUDIOFILE), "Mux record enabled");

            Assert.IsTrue(ttclient.EnableVoiceTransmission(true), "voice tx disable");

            int cmdid = ttclient.DoSubscribe(ttclient.GetMyUserID(), Subscription.SUBSCRIBE_VOICE);
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "subscribe voice");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_STATECHANGE, 2000, ref msg), "user state change");

            User user = (User)msg.DataToObject();
            Assert.IsTrue(user.uUserState.HasFlag(UserState.USERSTATE_VOICE), "user state has voice");

            Assert.IsTrue(ttclient.SetUserMediaStorageDir(ttclient.GetMyUserID(), MEDIAFOLDER, "", AudioFileFormat.AFF_WAVE_FORMAT),
                          "Record user audio files");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_RECORD_MEDIAFILE, 1000, ref msg), "Record media file event");

            MediaFileInfo fileinfo = (MediaFileInfo)msg.DataToObject();
            Assert.AreEqual(ttclient.GetMyUserID(), user.nUserID, "Self record voice");
            Assert.IsTrue(fileinfo.nStatus == MediaFileStatus.MFS_STARTED, "Started recording");

            Assert.IsTrue(ttclient.SetUserStoppedPlaybackDelay(ttclient.GetMyUserID(), StreamType.STREAMTYPE_VOICE, 2000),
                          "Stop voice stopped delay");
            Assert.IsTrue(ttclient.SetUserVolume(ttclient.GetMyUserID(), StreamType.STREAMTYPE_VOICE, SoundLevel.SOUND_VOLUME_MAX / 2));
            Assert.IsTrue(ttclient.SetUserVolume(ttclient.GetMyUserID(), StreamType.STREAMTYPE_MEDIAFILE_AUDIO, SoundLevel.SOUND_VOLUME_MAX / 2));
            Assert.IsTrue(ttclient.SetUserMute(ttclient.GetMyUserID(), StreamType.STREAMTYPE_VOICE, true));
            Assert.IsTrue(ttclient.SetUserMute(ttclient.GetMyUserID(), StreamType.STREAMTYPE_MEDIAFILE_AUDIO, true));
            Assert.IsTrue(ttclient.SetUserStereo(ttclient.GetMyUserID(), StreamType.STREAMTYPE_MEDIAFILE_AUDIO, true, false));
            Assert.IsTrue(ttclient.SetUserStereo(ttclient.GetMyUserID(), StreamType.STREAMTYPE_VOICE, false, true));

            Assert.IsTrue(ttclient.EnableVoiceTransmission(false), "voice disable");

            Assert.IsFalse(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_STATECHANGE, 1000, ref msg), "no user state change");

            Assert.IsTrue(ttclient.GetUser(ttclient.GetMyUserID(), ref user), "Get self");
            Assert.AreEqual(2000, user.nStoppedDelayVoice, "Voice stopped delay eq 2000");
            Assert.AreEqual(SoundLevel.SOUND_VOLUME_MAX / 2, user.nVolumeVoice);
            Assert.AreEqual(SoundLevel.SOUND_VOLUME_MAX / 2, user.nVolumeMediaFile);
            Assert.IsTrue(user.uUserState.HasFlag(UserState.USERSTATE_MUTE_VOICE));
            Assert.IsTrue(user.uUserState.HasFlag(UserState.USERSTATE_MUTE_MEDIAFILE));
            Assert.AreEqual(false, user.stereoPlaybackVoice[0]);
            Assert.AreEqual(true, user.stereoPlaybackVoice[1]);
            Assert.AreEqual(true, user.stereoPlaybackMediaFile[0]);
            Assert.AreEqual(false, user.stereoPlaybackMediaFile[1]);

            Assert.IsTrue(user.uUserState.HasFlag(UserState.USERSTATE_VOICE), "Voice active");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_RECORD_MEDIAFILE, 3000, ref msg), "Record media file event stop");
            fileinfo = (MediaFileInfo)msg.DataToObject();

            Assert.IsTrue(fileinfo.nStatus == MediaFileStatus.MFS_FINISHED, "Ended recording");

            Assert.IsTrue(ttclient.GetUser(ttclient.GetMyUserID(), ref user), "Get self");
            Assert.IsFalse(user.uUserState.HasFlag(UserState.USERSTATE_VOICE), "Voice inactive");

            Assert.IsTrue(ttclient.StopRecordingMuxedAudioFile(), "Stop mux record");
        }
Ejemplo n.º 30
0
 public static extern BearWare.ClientError TTS_MakeChannel(IntPtr lpTTSInstance, [In, Out] ref BearWare.Channel lpChannel);
Ejemplo n.º 31
0
        public void TestLogin()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL | UserRight.USERRIGHT_VIEW_ALL_USERS;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            int cmdid;
            cmdid = ttclient.DoLogout();
            Assert.IsTrue(cmdid > 0, "logout issued");

            cmdid = ttclient.DoLogin(NICKNAME, USERNAME, PASSWORD);
            Assert.IsTrue(cmdid > 0, "login issued 2");

            Channel chan = new Channel();
            chan.nParentID = ttclient.GetRootChannelID();
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.nMaxUsers = 128;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(cmdid > 0, "join issued");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "join complete");

            cmdid = ttclient.DoJoinChannelByID(ttclient.GetRootChannelID(), "");

            Assert.IsTrue(cmdid > 0, "join root issued");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "join root complete");

            cmdid = ttclient.DoLeaveChannel();
            Assert.IsTrue(cmdid > 0, "leave root issued");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "leave root complete");

            String newnick = "New Nickname";
            cmdid = ttclient.DoChangeNickname(newnick);
            TTMessage msg = new TTMessage();
            while (WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_USER_UPDATE, DEF_WAIT, ref msg))
            {
                if (((User)msg.DataToObject()).nUserID == ttclient.GetMyUserID())
                    break;
            }
            Assert.AreEqual(ttclient.GetMyUserID(), ((User)msg.DataToObject()).nUserID, "me updated nick");
            Assert.AreEqual(newnick, ((User)msg.DataToObject()).szNickname, "me updated nick");

            int mode = 34343;
            string newstatus = "New Status";
            cmdid = ttclient.DoChangeStatus(mode, newstatus);
            while (WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_USER_UPDATE, DEF_WAIT, ref msg))
            {
                if (((User)msg.DataToObject()).nUserID == ttclient.GetMyUserID())
                    break;
            }
            Assert.AreEqual(ttclient.GetMyUserID(), ((User)msg.DataToObject()).nUserID, "me updated status");
            Assert.AreEqual(newstatus, ((User)msg.DataToObject()).szStatusMsg, "me updated status");
            Assert.AreEqual(mode, ((User)msg.DataToObject()).nStatusMode, "me updated status");
        }
Ejemplo n.º 32
0
 public static extern BearWare.ClientError TTS_UpdateChannel(IntPtr lpTTSInstance, [In] ref BearWare.Channel lpChannel);
Ejemplo n.º 33
0
        void ttclient_OnCmdChannelNew(Channel chan)
        {
            TreeNode parent = GetChannel(chan.nParentID);
            if (parent == null)
            {
                //it's the root channel

                //user servername as root channel name
                ServerProperties prop = new ServerProperties();
                ttclient.GetServerProperties(ref prop);
                TreeNode newnode = new TreeNode(prop.szServerName, (int)ImageIndex.CHANNEL, (int)ImageIndex.CHANNEL);
                newnode.Tag = chan.nChannelID;
                treeview.Nodes.Add(newnode);
            }
            else
            {
                TreeNode newnode = new TreeNode(chan.szName, (int)ImageIndex.CHANNEL, (int)ImageIndex.CHANNEL);
                newnode.Tag = chan.nChannelID;
                parent.Nodes.Add(newnode);
            }
        }