示例#1
0
        private void OnFileTerminal(object sender, TapiFileTerminalEventArgs e)
        {
            // We are interested in TMS_IDLE because we will un-select playback and
            // select recording
            if (e.State == TERMINAL_MEDIA_STATE.TMS_IDLE)
            {
                if (e.Terminal.Direction == TERMINAL_DIRECTION.TD_RENDER &&
                    playbackTerminal != null)
                {
                    try
                    {
                        // Remove the playback terminal
                        currCall.UnselectTerminalOnCall(playbackTerminal);
                        playbackTerminal.Dispose();
                        playbackTerminal = null;

                        // Generate a custom tone on the call.
                        currCall.GenerateCustomTones(new TCustomTone[] { new TCustomTone(700, 500, 0, 0xFFFF) }, 500);

                        // Disconnect the call
                        currCall.Disconnect(DISCONNECT_CODE.DC_NORMAL);
                    }
                    catch (TapiException ex)
                    {
                        MessageBox.Show(ex.Message);
                        currCall.Disconnect(DISCONNECT_CODE.DC_NORMAL);
                    }
                }
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
文件: mf2040.cs 项目: uvigii/cls
        private void DisplayVideoWindow(TStream stm, TAPIMEDIATYPES mediaType, TERMINAL_DIRECTION direction)
        {
            TTerminal t = stm.FindTerminal(mediaType, direction);

            if (t != null)
            {
                IVideoWindow videoWindow = t.QueryInterface(typeof(IVideoWindow)) as IVideoWindow;
                if (videoWindow != null)
                {
                    videoWindow.Owner       = (direction == TERMINAL_DIRECTION.TD_RENDER) ? localVidPlaceholder.Handle.ToInt32() : remoteVidPlaceholder.Handle.ToInt32();
                    videoWindow.WindowStyle = 0x40800000; // WS_CHILD | WS_BORDER;
                    videoWindow.SetWindowPosition(0, 0, localVidPlaceholder.Width, localVidPlaceholder.Height);
                    videoWindow.Visible = 1;
                }
            }
        }
示例#4
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);
                }
            }
        }
示例#5
0
        private void tapi_TE_CALLSTATE(object sender, TapiCallStateEventArgs e)
        {
            if (e.State == CALL_STATE.CS_CONNECTED && playbackTerminal != null)
            {
                // Start the playback message..
                playbackTerminal.Start();
            }
            else if (e.State == CALL_STATE.CS_DISCONNECTED)
            {
                // Stop recording when the call terminates.
                if (recordTerminal != null)
                {
                    recordTerminal.Stop();
                }

                recordTerminal   = null;
                playbackTerminal = null;
            }
        }
示例#6
0
 private void OnMediaEvent(object sender, TapiCallMediaEventArgs e)
 {
     // When the video rendering stream activates, popup the video window if it's available.
     if (e.Event == CALL_MEDIA_EVENT.CME_STREAM_ACTIVE)
     {
         TStream stm = e.Stream;
         if (stm.Direction == TERMINAL_DIRECTION.TD_RENDER &&
             stm.MediaType == TAPIMEDIATYPES.VIDEO)
         {
             TTerminal t = stm.FindTerminal(stm.MediaType, stm.Direction);
             if (t != null)
             {
                 IVideoWindow vw = t.QueryInterface(typeof(IVideoWindow)) as IVideoWindow;
                 if (vw != null)
                 {
                     // Position to the right
                     vw.SetWindowPosition(this.Left + this.Width + 2, this.Top, vw.Width, vw.Height);
                     vw.Visible = 1;
                 }
             }
         }
         else if (currCall != null &&
                  stm.Direction == TERMINAL_DIRECTION.TD_CAPTURE &&
                  stm.MediaType == TAPIMEDIATYPES.AUDIO &&
                  playbackTerminal != null)
         {
             try
             {
                 playbackTerminal.Start();
                 toolStripStatusLabel1.Text = "File Playback Terminal started ";
             }
             catch (TapiException ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
示例#7
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;
                }
            }
        }