Beispiel #1
0
        private void CheckControls()
        {
            btnDisconnect.Enabled = currCall != null;

            if (cbDestinationType.SelectedIndex >= 0 &&
                textDestination.Text.Length > 0 &&
                cbAddress.SelectedIndex >= 0)
            {
                TAddress         addr     = (TAddress)cbAddress.SelectedItem;
                LINEADDRESSTYPES addrType = (LINEADDRESSTYPES)cbDestinationType.SelectedItem;

                btnDial.Enabled = (currCall == null && (addr.get_AddressCapability(ADDRESS_CAPABILITY.AC_ADDRESSTYPES) & (int)addrType) != 0);
            }
            else
            {
                btnDial.Enabled = false;
            }
        }
Beispiel #2
0
        private void OnDial(object sender, EventArgs e)
        {
            TAddress         addr     = (TAddress)cbAddress.SelectedItem;
            LINEADDRESSTYPES addrType = (LINEADDRESSTYPES)cbDestinationType.SelectedItem;

            TAPIMEDIATYPES mediaType = TAPIMEDIATYPES.AUDIO;

            if (addr.QueryMediaType(TAPIMEDIATYPES.VIDEO))
            {
                mediaType |= TAPIMEDIATYPES.VIDEO;
            }

            try
            {
                addr.Open(mediaType);
            }
            catch (TapiException ex)
            {
                // Invalid media mode? Try just datamodem for unimodem.
                if (ex.ErrorCode == unchecked ((int)0x80040004))
                {
                    try
                    {
                        addr.Open(TAPIMEDIATYPES.DATAMODEM);
                    }
                    catch
                    {
                        toolStripStatusLabel1.Text = ex.Message;
                    }
                }
                else
                {
                    toolStripStatusLabel1.Text = ex.Message;
                }
            }

            // Create a call -- this should always succeed
            currCall = addr.CreateCall(textDestination.Text, addrType, mediaType);
            if (currCall != null)
            {
                // Get the playback terminal from the call
                try
                {
                    playbackTerminal = currCall.RequestTerminal(
                        TTerminal.FilePlaybackTerminal,
                        TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);
                    if (playbackTerminal != null)
                    {
                        playbackTerminal.MediaPlayList = new string[] { PLAY_FILENAME };
                        //string[] names = playbackTerminal.MediaPlayList;
                        //playbackTerminal.Name;
                        //currCall.SelectTerminalOnCall(playbackTerminal);
                    }
                    else
                    {
                        MessageBox.Show("Failed to retrieve playback terminal.");
                    }
                }
                catch (TapiException ex)
                {
                    MessageBox.Show(ex.Message);
                }


                //// If the address supports media streams, then select terminals on it.
                //if (addr.SupportsMediaStreams)
                //{
                //    // This walks through the streams of the call and selects the default terminal
                //    // for each one.
                //    currCall.SelectDefaultTerminals();
                //}

                try
                {
                    // Connect the call
                    currCall.Connect(false);
                    toolStripStatusLabel1.Text = "Placing call...";
                }
                catch (TapiException ex)
                {
                    toolStripStatusLabel1.Text = ex.Message;
                }
            }
        }