コード例 #1
0
ファイル: AutoAttendantForm.cs プロジェクト: oldfox94/itapi3
        private void AnswerCall()
        {
            SetStatusMessage("Answering Call...");
            if (playbackTerminal != null)
            {
                playbackTerminal.Dispose();
                playbackTerminal = null;
            }

            // Get the playback terminal from the call
            try
            {
                playbackTerminal = activeCall.RequestTerminal(TTerminal.FilePlaybackTerminal,
                                                              TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);
                if (playbackTerminal != null)
                {
                    playbackTerminal.MediaPlayList = new string[] { PLAY_FILENAME };
                    activeCall.SelectTerminalOnCall(playbackTerminal);
                    activeCall.Answer();
                }
                else
                {
                    MessageBox.Show("Failed to retrieve playback terminal.");
                    activeCall.Disconnect(DISCONNECT_CODE.DC_REJECTED);
                }
            }
            catch (TapiException ex)
            {
                MessageBox.Show(ex.Message);
                activeCall.Disconnect(DISCONNECT_CODE.DC_NORMAL);
            }
        }
コード例 #2
0
 private void RecordConversation(string fileName)
 {
     // This code only works on XP or better (TAPI 3.1).
     if (currCall != null)
     {
         try
         {
             recordTerminal = currCall.RequestTerminal(
                 TTerminal.FileRecordingTerminal,
                 TAPIMEDIATYPES.MULTITRACK, TERMINAL_DIRECTION.TD_RENDER);
             if (recordTerminal != null)
             {
                 recordTerminal.RecordFileName = fileName;
                 currCall.SelectTerminalOnCall(recordTerminal);
                 recordTerminal.Start();
             }
             else
             {
                 MessageBox.Show("Failed to retrieve terminal.");
             }
         }
         catch (TapiException ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                selectedAddress.Open(TAPIMEDIATYPES.AUDIO);
            }
            catch (TapiException ex)
            {
                MessageBox.Show(ex.Message);
            }

            currCall = selectedAddress.CreateCall(textBox1.Text, LINEADDRESSTYPES.PhoneNumber, TAPIMEDIATYPES.AUDIO);
            if (currCall != null)
            {
                try
                {
                    currCall.Connect(false);
                }
                catch (TapiException ex)
                {
                    MessageBox.Show(ex.Message);
                }

                // This must be done AFTER call is connected.  Otherwise it will not
                // associate the terminal.  This is a requirement of TAPI3 itself.
                try
                {
                    playbackTerminal = currCall.RequestTerminal(
                        TTerminal.FilePlaybackTerminal,
                        TAPIMEDIATYPES.AUDIO, JulMar.Tapi3.TERMINAL_DIRECTION.TD_CAPTURE);
                    if (playbackTerminal != null)
                    {
                        playbackTerminal.MediaPlayList = new string[] { MESSAGE_PROMPT };
                        currCall.SelectTerminalOnCall(playbackTerminal);
                    }
                    else
                    {
                        MessageBox.Show("Failed to retrieve playback terminal.");
                    }
                }
                catch (TapiException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #4
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;
                }
            }
        }