/// <summary> /// Starts recording the audio into a wav file. /// </summary> public void StartWavRecording() { if (wavRecorder == null) { return; } wavRecorder.StartStreaming(); }
private void CallAnswered() { _callID = _call.CallID; _log.Info("Call Answered. Call ID: " + _callID); _log.Info(String.Format("Recording to {0}", _wavFileName)); _audioReceiver.AttachToCall(_call); _wavRecorder.DataSent += WavRecorderDataReceived; _wavRecorder.StartStreaming(); }
/// <summary> /// Indicates the introduction has finished. It's starts the voice record. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Narrator_IntroductionFinished(object sender, EventArgs e) { Narrator.Finished -= Narrator_IntroductionFinished; waveStreamRecorder = new WaveStreamRecorder(Path.Combine(Environment.CurrentDirectory, string.Format("IVRVoiceMesage{0}.wav", DateTime.Now.ToFileTime()))); OnIntroductionStarting(waveStreamRecorder); waveStreamRecorder.StartStreaming(); Narrator.Finished += narrator_PostIntroductionFinished; }
public void StartRecording() { recording_started = DateTime.Now; switch (format) { case RecordingFileFormat.MP3: ConnectOrDisconnectAudioReceiver(mp3_recorder, true); mp3_recorder.StartStreaming(); break; case RecordingFileFormat.WAV: ConnectOrDisconnectAudioReceiver(wav_recorder, true); wav_recorder.StartStreaming(); break; } }
void workDelayRecording_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { #region combine mic and receiver in record if (callstate == CallState.InCall) { this.Invoke(new Action(delegate() { memStreamRecorder = new MemoryStream(); recorder = new WaveStreamRecorder(memStreamRecorder); memStreamRecorder = new MemoryStream(); recorder = new WaveStreamRecorder(memStreamRecorder); recorder.Stopped += new EventHandler<EventArgs>(recorder_Stopped); connector.Connect(m_UserMicrophone, mixer); connector.Connect(mediaReceiver, mixer); connector.Connect(mixer, recorder); recorder.StartStreaming(); //recorder.IsStreaming = true; })); } #endregion }
/// <summary> /// Occurs when the phone call state has changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void call_CallStateChanged1(object sender, VoIPEventArgs<CallState> e) { this.InvokeGUIThread(() => { if (e.Item == CallState.Ringing) { m_TimeStart = DateTime.Now.TimeOfDay; m_StartTimeOutCounter = true; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Ring); } else if (e.Item == CallState.InCall) { try { m_StartTimeOutCounter = false; mixer = new AudioMixerMediaHandler(); mixerMic = new AudioMixerMediaHandler(); mixerReceiver = new AudioMixerMediaHandler(); AudioId = Guid.NewGuid(); CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); if (m_UserMicrophone != null) m_UserMicrophone.Start(); if (m_UserSpeaker != null) m_UserSpeaker.Start(); connector.Connect(m_UserMicrophone, mediaSender); connector.Connect(mediaReceiver, m_UserSpeaker); m_MediaUtility.Stop(); //m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); mediaSender.AttachToCall(call); mediaReceiver.AttachToCall(call); #region combine mic and receiver in record string fileName = String.Format(@"{0}\\tmpwav\\{1}_.wav", commonData.ApplicationFolderPath, AudioId); recorder = new WaveStreamRecorder(fileName); recorder.Stopped += new EventHandler<EventArgs>(recorder_Stopped); connector.Connect(m_UserMicrophone, mixer); connector.Connect(mediaReceiver, mixer); connector.Connect(mixer, recorder); #endregion #region record mic fileName = String.Format(@"{0}\\tmpwav\\{1}_mic.wav", commonData.ApplicationFolderPath, AudioId); recorderMic = new WaveStreamRecorder(fileName); recorderMic.Stopped += new EventHandler<EventArgs>(recorder_Stopped1); connector.Connect(m_UserMicrophone, mixerMic); connector.Connect(mixerMic, recorderMic); #endregion #region record receiver fileName = String.Format(@"{0}\\tmpwav\\{1}_receiver.wav", commonData.ApplicationFolderPath, AudioId); recorderReceiver = new WaveStreamRecorder(fileName); recorderReceiver.Stopped += new EventHandler<EventArgs>(recorder_Stopped2); connector.Connect(mediaReceiver, mixerReceiver); connector.Connect(mixerReceiver, recorderReceiver); #endregion recorder.StartStreaming(); //recorder.IsStreaming = true; recorderReceiver.StartStreaming(); //recorderReceiver.IsStreaming = true; recorderMic.StartStreaming(); //recorderMic.IsStreaming = true; } catch(Ozeki.Common.Exceptions.MediaException me) { if (CallState_Changed != null) { CallState_Changed(this, new CallStateChangedArgs() { PhoneCallState = CallState.Rejected }); } if (call != null) call.HangUp(); //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); MessageBox.Show("Your mic or speaker is not working. Please change your mic or speaker in the Phone Settings.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (e.Item == CallState.Completed) { try { if (m_UserMicrophone != null) m_UserMicrophone.Stop(); if (m_UserSpeaker != null) m_UserSpeaker.Stop(); connector.Disconnect(m_UserMicrophone, mediaSender); connector.Disconnect(mediaReceiver, m_UserSpeaker); if (recorder != null) { recorder.StopStreaming(); //recorder.IsStreaming = false; } if (recorderMic != null) { recorderMic.StopStreaming(); //recorderMic.IsStreaming = false; } if (recorderReceiver != null) { recorderReceiver.StopStreaming(); //recorderReceiver.IsStreaming = false; } connector.Disconnect(m_UserMicrophone, mixer); connector.Disconnect(mediaReceiver, mixer); connector.Disconnect(mixer, recorder); connector.Disconnect(m_UserSpeaker, mixerMic); connector.Disconnect(mixerMic, recorderMic); connector.Disconnect(mixerMic, recorderMic); connector.Disconnect(mixerReceiver, recorderReceiver); mediaSender.Detach(); mediaReceiver.Detach(); if (m_RingTimeOut) return; //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); //call.HangUp(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); recorder.Dispose(); mixer.Dispose(); recorder = null; mixer = null; recorderMic.Dispose(); mixerMic.Dispose(); recorderMic = null; mixerMic = null; mixerReceiver.Dispose(); recorderReceiver.Dispose(); mixerReceiver = null; recorderReceiver = null; WaitUntilTheRecordEndProcess(); } catch { //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; } } else if (e.Item == CallState.Cancelled) { if (m_RingTimeOut) return; m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Rejected) { m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Busy || e.Item == CallState.Error) { m_RingTimeOut = true; m_StartTimeOutCounter = false; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Busy); //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); call.HangUp(); call = null; //MessageBox.Show("Error encountered. Please check the format of the number you are calling.", "Bright Sales", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.WireDownCallEvents(); //call = null; } if (CallState_Changed != null) CallState_Changed(this, new CallStateChangedArgs() { PhoneCallState = e.Item, AudioId = AudioId }); }); }
/// <summary> /// Indicates the introduction has finished. It's starts the voice record. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Narrator_IntroductionFinished(object sender, EventArgs e) { Narrator.Finished -= Narrator_IntroductionFinished; waveStreamRecorder = new WaveStreamRecorder(Path.Combine(Environment.CurrentDirectory, string.Format("IVRVoiceMesage{0}.wav", DateTime.Now.ToFileTime()))); OnIntroductionStarting(waveStreamRecorder); waveStreamRecorder.StartStreaming(); Narrator.Finished += narrator_PostIntroductionFinished; }