Ejemplo n.º 1
0
        /// <summary>
        /// Loads a wav file for playback.
        /// </summary>
        public void LoadRecordWavFile(string filePath)
        {
            if (!initialized)
            {
                return;
            }

            if (wavRecorder != null)
            {
                audioConnector.Disconnect(recordDataMixer, wavRecorder);
                wavRecorder.Dispose();
                wavRecorder = null;
            }

            wavRecorder = new WaveStreamRecorder(filePath);

            audioConnector.Connect(recordDataMixer, wavRecorder);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads a wav file for playback.
        /// </summary>
        public void LoadRecordWavFile(string filePath)
        {
            if (!_initialized)
            {
                return;
            }

            if (_wavRecorder != null)
            {
                _audioConnector.Disconnect(_phoneCallAudioReceiver, _wavRecorder);
                _audioConnector.Disconnect(AudioEnhancer, _wavRecorder);
                _wavRecorder.Dispose();
                _wavRecorder = null;
            }

            _wavRecorder = new WaveStreamRecorder(filePath);

            _audioConnector.Connect(_phoneCallAudioReceiver, _wavRecorder);
            _audioConnector.Connect(AudioEnhancer, _wavRecorder);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Releases the recorder object
 /// </summary>
 private void CloseRecorder()
 {
     try
     {
         if (waveStreamRecorder != null)
         {
             waveStreamRecorder.StopStreaming();
             OnIntroductionStoped(waveStreamRecorder);
             waveStreamRecorder.StopStreaming();
             waveStreamRecorder.Dispose();
         }
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 4
0
        protected override void ElapsedVoice(object sender, EventArgs eventArgs)
        {
            if (SoundTimer != null)
            {
                SoundTimer.Stop();
                SoundTimer.Elapsed -= ElapsedVoice;
                SoundTimer.Dispose();
            }
            Connector.Disconnect(_camera.AudioChannel, WaveStreamRecorder);

            WaveStreamRecorder.Stop();

            WaveStreamRecorder.Dispose();

            VadFilter.Enabled = true;
            IsSoundDetected   = false;
            Log.Motion("Sound recording has stopped");

            OnGetFilePath(new VoIPEventArgs <string>(SoundFilePath));
        }
Ejemplo n.º 5
0
        private void CallEnded()
        {
            _log.Info("Audio position at " + _wavRecorder.Stream.Position);
            _log.Info("Call Completed");
            _wavRecorder.StopStreaming();
            _connector.Disconnect(_audioReceiver, _mixer);
            _connector.Disconnect(_mixer, _wavRecorder);
            _wavRecorder.Stream.Flush();
            _wavRecorder.Dispose();
            _wavRecorder = null;
            _audioReceiver.Detach();
            _log.Info("Call tear down done");

            // Wake up the main thread
            _complete = true;
            lock (_sync)
            {
                Monitor.Pulse(_sync);
            }
        }
Ejemplo n.º 6
0
        public void StopRecording()
        {
            recording_duration = DateTime.Now.Subtract(recording_started);
            var new_filename = String.Empty;

            switch (format)
            {
            case RecordingFileFormat.MP3:
                if (mp3_recorder.IsStreaming)
                {
                    ConnectOrDisconnectAudioReceiver(mp3_recorder, false);
                    mp3_recorder.StopStreaming();
                    mp3_recorder.Dispose();
                    new_filename = String.Format("{0}_{1}_{2}{3}{4}_{5}{6}{7}_{8}.mp3", session.Caller, session.Callee, recording_started.Year, recording_started.Month.ToString("D2"), recording_started.Day.ToString("D2"), recording_started.Hour.ToString("D2"), recording_started.Minute.ToString("D2"), recording_started.Second.ToString("D2"), recording_duration.ToString("hhmmss"));
                }
                break;

            case RecordingFileFormat.WAV:
                if (wav_recorder.IsStreaming)
                {
                    ConnectOrDisconnectAudioReceiver(wav_recorder, false);
                    wav_recorder.StopStreaming();
                    wav_recorder.Dispose();
                    new_filename = String.Format("{0}_{1}_{2}{3}{4}_{5}{6}{7}_{8}.wav", session.Caller, session.Callee, recording_started.Year, recording_started.Month.ToString("D2"), recording_started.Day.ToString("D2"), recording_started.Hour.ToString("D2"), recording_started.Minute.ToString("D2"), recording_started.Second.ToString("D2"), recording_duration.ToString("hhmmss"));
                }
                break;

            default:
                throw new NotImplementedException();
            }

            var path = Path.Combine(SettingsHelper.RecordingPath, extension_subpath);

            CreateFolderIfNecessery(path);
            File.Move(recorder_filename, Path.Combine(path, new_filename));
        }
Ejemplo n.º 7
0
        void call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            InvokeGUIThread(() => { lbl_CallState.Text = e.State.ToString(); lblEstatusLlamada.Text = e.State.ToString(); });

            if (e.State == CallState.Answered)
            {
                InvokeGUIThread(() => {
                    wplayer.controls.stop();
                    crearFolio();
                    ALlamadaData.bCurso = true;

                    string sRuta = string.Format(@"{0}\mpy\records\nws", Path.GetTempPath());
                    if (!Directory.Exists(sRuta))
                    {
                        Directory.CreateDirectory(sRuta);
                    }
                });

                StartDevices();
                SendDTMFSingnal();

                sFechaInicio = DateTime.Now;
                sRecordName  = AProspeccionData.bCurso ? string.Format("pcll-{1}.wav", Path.GetTempPath(), AProspeccionData.iIdLlamada) : string.Format("Folio-{0}-{1}{2}{3}{4}{5}{6}.wav", iIdFolio, sFechaInicio.Day, sFechaInicio.Month, sFechaInicio.Year, sFechaInicio.Hour, sFechaInicio.Minute, sFechaInicio.Second);
                filename     = string.Format(@"{0}\mpy\records\nws\{1}", Path.GetTempPath(), sRecordName);

                recorder = new WaveStreamRecorder(filename);  // new recorder object
                _connector.Connect(_microphone, recorder);    // connects the outgoing voice to the recorder
                _connector.Connect(_mediaReceiver, recorder); // connects the incoming voice to the recorder

                _mediaSender.AttachToCall(_call);
                _mediaReceiver.AttachToCall(_call);
                recorder.Start();  // starts the recording

                InvokeGUIThread(() => {
                    timer1.Start();
                    txtDisplay.Text     = "" + ((IPhoneCall)sender).DialInfo.SIPCallerID.DisplayName;
                    lblExtEntrante.Text = "" + ((IPhoneCall)sender).DialInfo.SIPCallerID.DisplayName;

                    if (!AProspeccionData.bCurso)
                    {
                        // Valida despues de mostrar la modal para registrar la llamada
                        if (RegistrarLlamadaModal.Show(iIdFolio, filename) == DialogResult.Yes)
                        {
                            Cliente ACliente = new Cliente();
                            Caso NoCliente;
                            if (bSeguimiento)
                            {
                                NoCliente = new Caso().ClienteCaso(iIdFolioSeguimiento);
                            }
                            else
                            {
                                NoCliente = new Caso().ClienteCaso(iIdFolio);
                            }
                        }
                    }
                });
            }
            else if (e.State == CallState.InCall)
            {
                StartDevices();
            }

            if (e.State == CallState.LocalHeld || e.State == CallState.InactiveHeld)
            {
                StopDevices();
                InvokeGUIThread(() => {
                    lnkHold.Text         = "Unhold";
                    lnkHold.Image        = Properties.Resources.resume_button_48px;
                    lnkHold.NoFocusImage = Properties.Resources.resume_button_48px;
                });
            }
            else
            {
                InvokeGUIThread(() => {
                    lnkHold.Text         = "Hold";
                    lnkHold.Image        = Properties.Resources.pause_48px;
                    lnkHold.NoFocusImage = Properties.Resources.pause_48px;
                });
            }

            if (e.State.IsCallEnded())
            {
                StopDevices();

                _mediaSender.Detach();
                _mediaReceiver.Detach();

                WireDownCallEvents();

                if (recorder != null)
                {
                    recorder.Dispose();
                    recorder = null;
                }

                _call = null;

                timer1.Stop();

                InvokeGUIThread(() => {
                    wplayer.controls.stop();
                    txtDisplay.Text     = String.Empty;
                    lblExtEntrante.Text = string.Empty;
                    lblTiempo.Text      = string.Empty;

                    if (pnlLlamada.Visible == true)
                    {
                        frmTelefono.Animate2(pnlLlamada, frmTelefono.Effect.Slide, 150, 360);
                        frmTelefono.Animate(pnlKeyPad, frmTelefono.Effect.Slide, 150, 360);
                    }

                    lnkPickUpInCall.Visible      = true;
                    lnkVolverLLamada.Visible     = false;
                    pnlTransferirLlamada.Visible = false;
                    txtNoTransferir.Text         = string.Empty;
                    lnkConfigurar.Enabled        = true;
                    lnkHangUp.Location           = new Point(150, 94);
                    AProspeccionData.bCurso      = false;

                    string sFilePath = "";
                    if (bSeguimiento && iIdFolioSeguimiento != 0)
                    {
                        sFilePath = string.Format(@"{0}\mpy\records\nws\Folio-{1}-{2}{3}{4}{5}{6}{7}.wav", Path.GetTempPath(), iIdFolioSeguimiento, sFechaInicio.Day, sFechaInicio.Month, sFechaInicio.Year, sFechaInicio.Hour, sFechaInicio.Minute, sFechaInicio.Second);
                        File.Move(filename, sFilePath);
                        CasoHistorial _UpdRecord = new CasoHistorial();
                        _UpdRecord.UpdateHistorialRecord(iIdHistorialFolio, sFilePath);
                    }

                    if (ALlamadaData.bCurso)
                    {
                        if (sFilePath == "")
                        {
                            string FullPath = string.Format("{0}/{1}/Records/", FTPCredentials.Path, ConnectionString.FolderConnection);
                            FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(filename), filename);
                            File.Delete(filename);
                        }
                        else
                        {
                            string FullPath = string.Format("{0}/{1}/Records/", FTPCredentials.Path, ConnectionString.FolderConnection);
                            FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(sFilePath), sFilePath);
                            File.Delete(sFilePath);
                        }
                        ALlamadaData.bCurso = false;
                    }
                });
            }
        }