Ejemplo n.º 1
0
 void Call()
 {
     if (_call != null)
     {
         _call.Connected    -= CallOnConnected;
         _call.Disconnected -= CallOnDisconnected;
         _call.Hangup();
         _call = null;
     }
     _call = _client.Call("stream", new CallSettings
     {
         VideoCodec = VideoCodec.H264,
         VideoFlags = new VideoFlags
         {
             ReceiveVideo = false,
             SendVideo    = true,
         }
     });
     if (_call == null)
     {
         return;
     }
     _call.SetVideoSource(Camera.current, 640, 640 * Screen.height / Screen.width);
     _call.Connected    += CallOnConnected;
     _call.Disconnected += CallOnDisconnected;
     _call.Start();
 }
Ejemplo n.º 2
0
    private void OnMouseDown()
    {
        if (_call == null)
        {
            _call = _client.Call(Callee, CallSettings);
            if (_call == null)
            {
                return;
            }
            BindCallEventHandlers();
            _call.Start();

            _callButtonText.text       = "Hangup";
            _callButton.material.color = ButtonHangupColor;
        }
        else
        {
            _call.Hangup();
        }
    }
Ejemplo n.º 3
0
        public void StartWork()
        {
            if (entry.State == WorkState.Success || entry.State == WorkState.HungUpByRemote)
            {
                OnWorkCompleted(entry.State);
                return;
            }

            if (!entry.IsValid)
            {
                OnWorkCompleted(entry.State);
                return;
            }

            try
            {
                started = true;
                WaitForValidDateEndTime();

                entry.Progress = 0;
                entry.State    = WorkState.Init;

                ringingTimer.Start();
                call = extension.CreateCall(entry.DialedNumber);

                call.CallStateChanged  += call_CallStateChanged;
                call.DtmfStarted       += call_DtmfStarted;
                call.CallErrorOccurred += call_CallErrorOccurred;


                call.Start();
            }
            catch (Exception ex)
            {
                OnWorkCompleted(WorkState.CallError);
            }
        }
Ejemplo n.º 4
0
        public void StartWork()
        {
            if (entry.State == WorkState.Success || entry.State == WorkState.HungUpByRemote)
            {
                OnWorkCompleted(entry.State);
                return;
            }

            if (!entry.IsValid)
            {
                OnWorkCompleted(entry.State);
                return;
            }

            try
            {
                started = true;
                WaitForValidDateEndTime();

                entry.Progress = 0;
                entry.State = WorkState.Init;

                ringingTimer.Start();
                call = extension.CreateCall(entry.DialedNumber);

                call.CallStateChanged += call_CallStateChanged;
                call.DtmfStarted += call_DtmfStarted;
                call.CallErrorOccurred += call_CallErrorOccurred;

                call.Start();
            }
            catch (Exception ex)
            {
                OnWorkCompleted(WorkState.CallError);
            }
        }
Ejemplo n.º 5
0
        private void CallPressed(string phoneNumber)
        {
            Logger.Log("Calling " + phoneNumber);

            WaveStreamPlayback waveStream = null;

            initiatedCall = apiExt.CreateCall(UsedPhoneNumber, phoneNumber, phoneNumber);
            if (initiatedCall == null)
                return;
            bool transferStarted = false;
            initiatedCall.CallStateChanged += (sender, e) =>
            {
                try
                {

                    if (e.Item == CallState.Answered)
                    {
                        if (transferStarted)
                        {
                            initiatedCall.DisconnectAudioSender(waveStream);
                            waveStream.Dispose();

                            var tts = new TextToSpeech();

                            tts.Stopped += (sender1, e1)=>{
                                                              tts.Dispose();
                                                              initiatedCall.HangUp();
                                                          };

                            initiatedCall.ConnectAudioSender(tts);
                            tts.AddAndStartText(string.Format("Calling {0} has failed. Please try again later.", phoneNumber));
                            return;
                        }

                        var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OPSCallAssistant.Resources.ringback.wav");
                        waveStream = new WaveStreamPlayback(stream, true, true);

                        initiatedCall.ConnectAudioSender(waveStream);
                        waveStream.StartStreaming();

                        transferStarted = true;
                        initiatedCall.BlindTransfer(phoneNumber);

                    }
                    if (e.Item.IsCallEnded())
                    {
                        if (waveStream != null)
                            waveStream.Dispose();
                    }
                }
                catch(Exception ex)
                {
                    Logger.Log(ex.Message);
                    Logger.Log(ex.StackTrace);
                }

                var k = 65;

            };
            initiatedCall.Start();
        }
Ejemplo n.º 6
0
        private void CallPressed(string phoneNumber)
        {
            Logger.Log("Calling " + phoneNumber);

            WaveStreamPlayback waveStream = null;

            initiatedCall = apiExt.CreateCall(UsedPhoneNumber, phoneNumber, phoneNumber);
            if (initiatedCall == null)
            {
                return;
            }
            bool transferStarted = false;

            initiatedCall.CallStateChanged += (sender, e) =>
            {
                try
                {
                    if (e.Item == CallState.Answered)
                    {
                        if (transferStarted)
                        {
                            initiatedCall.DisconnectAudioSender(waveStream);
                            waveStream.Dispose();

                            var tts = new TextToSpeech();

                            tts.Stopped += (sender1, e1) => {
                                tts.Dispose();
                                initiatedCall.HangUp();
                            };

                            initiatedCall.ConnectAudioSender(tts);
                            tts.AddAndStartText(string.Format("Calling {0} has failed. Please try again later.", phoneNumber));
                            return;
                        }

                        var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OPSCallAssistant.Resources.ringback.wav");
                        waveStream = new WaveStreamPlayback(stream, true, true);

                        initiatedCall.ConnectAudioSender(waveStream);
                        waveStream.StartStreaming();

                        transferStarted = true;
                        initiatedCall.BlindTransfer(phoneNumber);
                    }
                    if (e.Item.IsCallEnded())
                    {
                        if (waveStream != null)
                        {
                            waveStream.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message);
                    Logger.Log(ex.StackTrace);
                }

                var k = 65;
            };
            initiatedCall.Start();
        }