void Mpeg4Recorder_MultiplexFinished3(object sender, VoIPEventArgs <bool> e) { _connector3.Disconnect(_mjpegConnection3.AudioChannel, _mpeg4Recorder3.AudioRecorder); _connector3.Disconnect(_mjpegConnection3.VideoChannel, _mpeg4Recorder3.VideoRecorder); _mpeg4Recorder3.MultiplexFinished -= Mpeg4Recorder_MultiplexFinished3; _mpeg4Recorder3.Dispose(); }
void PhoneCall_CallStateChanged(object sender, VoIPEventArgs <CallState> e) { switch (e.Item) { case CallState.InCall: OnNotifyAction(string.Format("Caller '{0}' is in '{1}' menu.", PhoneCall.OtherParty, currentMenu.Name)); currentMenu.StartIntroduction(); break; case CallState.Completed: OnNotifyAction(string.Format("{0} hanged up the call.", PhoneCall.OtherParty)); currentMenu.StopIntroduction(); Close(); break; case CallState.Error: case CallState.Rejected: case CallState.Cancelled: case CallState.Busy: Close(); break; case CallState.Transferring: OnNotifyAction(string.Format("{0} call is transfering.", PhoneCall.OtherParty)); break; } }
/// <summary> /// This will be called when an incoming call received. /// </summary> private void SoftPhone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { IPhoneCall call = e.Item; SubscribeToCallEvents(call); // automatically rejected for some reason if (call.CallState == CallState.Error) { CallHistory.Add(call); return; } // add to call container PhoneCalls.Add(call); // if no call is in progress, select the incoming call as current call and attach the audio to hear the ringtone if (SelectedCall == null) { SelectedCall = call; MediaHandlers.AttachAudio(call); } // raise IncomingCall event OnIncomingCall(call); }
/// <summary> /// There are certain situations when the call cannot be created, for example the dialed number is not available /// or maybe there is no endpoint to the dialed PBX, or simply the telephone line is busy. /// This event handling is for displaying these events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void call_CallErrorOccured(object sender, VoIPEventArgs <CallError> e) { InvokeGUIThread(() => { //labelCallStateInfo.Text = e.Item.ToString(); }); }
/// <summary> /// Occurs when an incoming call request has received. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void softPhone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { Console.WriteLine("Incoming call from {0}", e.Item.DialInfo); call = e.Item; WireUpCallEvents(); OnIncomingCallReceived(e.Item); }
static void softphone_IncomigCall(object sender, VoIPEventArgs <Ozeki.VoIP.IPhoneCall> e) { try { ILine line = null; line = GetLinesMap()[GetLineKey(1)]; if (line == null) { return; } lock (line) { line.Status = LineStatus.Ringing; line.Number = FixPhoneNumber(e.Item.DialInfo.CallerID); line.LastUpdate = DateTime.UtcNow; } var callHandler = new CallHandler(e.Item); callHandler.Completed += callHandler_Completed; lock (_callHandlers) _callHandlers.Add(callHandler); callHandler.Start(); } catch (Exception ex) { } }
void OPSClientOnSessionCompleted(object sender, VoIPEventArgs <ISession> vo_ip_event_args) { Debug.WriteLine("{0} - Call completed", vo_ip_event_args.Item.SessionID); lock (sync) { if (vo_ip_event_args.Item.TalkDuration.TotalSeconds < 60) { stats.NumberOfSessionsTalkDurationLessThenAMinute++; } else { stats.NumberOfSessionsTalkDurationOverAMinute++; } } var stats_handler = StatisticsChanged; if (stats_handler != null) { stats_handler(this, new VoIPEventArgs <Statistics>(stats)); } var handler = SessionCompleted; if (handler != null) { handler(this, vo_ip_event_args); } }
/// <summary> /// This will be called when the level of the microphone has changed. /// </summary> private void Microphone_LevelChanged(object sender, VoIPEventArgs <float> e) { MicrophoneLevel = e.Item; OnPropertyChanged("MicrophoneLevel"); OnMicrophoneLevelChanged(e.Item); }
void PhoneCall_DtmfReceived(object sender, VoIPEventArgs <DtmfSignal> e) { DtmfSignal dtmfSignal = e.Item; OnNotifyAction(string.Format("{0} sent the following DTMF sign: {1}", PhoneCall.OtherParty, (int)dtmfSignal.Signal)); currentMenu.CommandReceived((int)dtmfSignal.Signal); }
/// <summary> /// This will be called when the level of the speaker has changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Speaker_LevelChanged(object sender, VoIPEventArgs <float> e) { SpeakerLevel = e.Item; OnPropertyChanged("SpeakerLevel"); OnSpeakerLevelChanged(e.Item); }
private void PhoneLineStateChanged(object sender, VoIPEventArgs <PhoneLineState> e) { _log.Debug("Line state changed to " + e.Item.ToString()); if (e.Item == PhoneLineState.RegistrationSucceeded) { _log.Info("Line Registered"); Dial(); } else if (e.Item == PhoneLineState.UnregSucceeded) { _log.Info("Line Unregistered"); _phoneLine = null; _softPhone = null; _complete = true; lock (_sync) { Monitor.Pulse(_sync); } } else if (e.Item == PhoneLineState.RegistrationFailed) { _log.Info("Registration failed. Try again"); Register(); } }
void OPSClientOnSessionCreated(object sender, VoIPEventArgs <ISession> e) { Debug.WriteLine("{0} - Call created", e.Item.SessionID); e.Item.SessionStateChanged += ((o, args) => { if (args.Item == SessionState.NotFound) { lock (sync) { stats.NumberOfDroppedSessions++; } var stats_handler = StatisticsChanged; if (stats_handler != null) { stats_handler(this, new VoIPEventArgs <Statistics>(stats)); } } Debug.WriteLine("{0} - Call state changed: {1}", e.Item.SessionID, e.Item.State); }); var handler = SessionCreated; if (handler != null) { handler(this, e); } }
private void ClientOnSessionCreated(object sender, VoIPEventArgs <ISession> e) { var session = e.Item; Logger.Log(string.Format("Session created: source:{0}, callerId:{1}, dialed:{2}, destination:{3}", e.Item.Source, e.Item.CallerId, e.Item.DialedNumber, e.Item.Destination)); if (CurrentUser != null && (CurrentUser.Extensions.Contains(e.Item.Source) || CurrentUser.Extensions.Contains(e.Item.Destination))) { Logger.Log("Current user will be notified."); try { var url = string.Format(_settingsRepository.GetUserInfo().ServerURL, Uri.EscapeDataString(e.Item.Source), Uri.EscapeDataString(e.Item.CallerId), Uri.EscapeDataString(e.Item.DialedNumber), Uri.EscapeDataString(e.Item.Destination), Uri.EscapeDataString(e.Item.CallDirection.ToString()), Uri.EscapeDataString(UsedPhoneNumber), Uri.EscapeDataString(e.Item.SessionID)); new Uri(url); Messenger.Default.Send(new NotificationMessage <object>(new CallInfo(e.Item, url, UsedPhoneNumber), ShowCall)); } catch (Exception ex) { Logger.Log(ex.Message); Logger.Log(ex.StackTrace); } } else { Logger.Log("Current user will not be notified."); } }
void ClientOnSessionCompleted(object sender, VoIPEventArgs <ISession> event_args) { var session = event_args.Item; if (session == null) { return; } session.SessionStateChanged -= ItemOnSessionStateChanged; view.CompleteSession(session); view.RemoveSessionFromUser(session.Caller); view.RemoveSessionFromUser(session.Callee); var number_stats = user_statistics_container.GetPhoneNumberStatistics(session.Caller); if (number_stats != null) { number_stats.CompleteCall(); } number_stats = user_statistics_container.GetPhoneNumberStatistics(session.Callee); if (number_stats != null) { number_stats.CompleteCall(); } view.ShowUserStatistics(user_statistics_container); }
static void softphone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { call = e.Item; caller = call.DialInfo.CallerID; call.CallStateChanged += call_CallStateChanged; call.Answer(); }
private void softphone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { if (call == null) { System.Windows.Application.Current.Dispatcher.Invoke(() => { call = e.Item; caller = call.DialInfo.CallerDisplay; call.CallStateChanged += call_CallStateChanged; CzyOdebrac czyookno = new CzyOdebrac(caller); if (czyookno.ShowDialog().Value) { if (call != null) { call.Answer(); } } else { if (call != null) { call.Reject(); } } }); } }
private void softPhone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { _log.Debug("Incoming call handler start"); CallHandler handler = new CallHandler(); handler.HandleCall(e.Item); _log.Debug("Incoming call handler end"); }
public void softphone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { caller.Text = e.Item.DialInfo.CallerDisplay.ToString(); call = e.Item; call.CallStateChanged += call_CallStateChanged; cStateDirection.Text = "In"; main.agentCurrentFromNumber = e.Item.DialInfo.ToString(); }
private void SoftPhone_inComingCall(object sender, VoIPEventArgs <IPhoneCall> e) { InvokeGUIThread(mymsg = ("Incoming call from: " + e.Item.DialInfo.ToString())); PhoneCall = e.Item; WireUpCallEvents(); InComingCall = true; }
private void phoneLine_PhoneLineStateChanged(object sender, VoIPEventArgs <PhoneLineState> e) { _log.Debug("Line state changed to " + e.Item.ToString()); if (e.Item == PhoneLineState.RegistrationSucceeded) { _log.Info("Line Registered"); } }
void softphone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { var handler = IncomigCall; if (handler != null) { handler(this, e); } }
protected virtual void OnGetFilePath(VoIPEventArgs <string> e) { var handler = GetFilePath; if (handler != null) { handler(this, e); } }
private void softPhone_inComingCall(object sender, VoIPEventArgs <IPhoneCall> e) { InvokeGUIThread(() => { lb_Log.Items.Add("Incoming call from: " + e.Item.DialInfo.ToString()); tb_Display.Text = "Ringing (" + e.Item.DialInfo.Dialed + ")"; }); reDialNumber = e.Item.DialInfo.Dialed; call = e.Item; WireUpCallEvents(); inComingCall = true; }
private void SoftPhone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { call = e.Item; WireUpCallEvents(); if (SoftPhoneInComingCall != null) { SoftPhoneInComingCall.Invoke(call.DialInfo.CallerDisplay); } }
void Mpeg4RecorderMultiplexFinished(object sender, VoIPEventArgs <bool> e) { Mpeg4Recorder.Dispose(); Mpeg4Recorder.MultiplexFinished -= Mpeg4RecorderMultiplexFinished; OnGetFilePath(new VoIPEventArgs <string>(MotionFilePath)); Log.Write("The captured video has been saved"); }
/// <summary> /// Displays DTMF signals /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void call_DtmfReceived(object sender, VoIPEventArgs <DtmfInfo> e) { DtmfInfo dtmfInfo = e.Item; InvokeGUIThread(() => { labelCallStateInfo.Text = String.Format("DTMF signal received: {0} ", dtmfInfo.Signal.Signal); }); }
void Mpeg4RecorderMultiplexFinished(object sender, VoIPEventArgs <bool> e) { Mpeg4Recorder.Dispose(); _microphone.Dispose(); OnGetFilePath(new VoIPEventArgs <string>(MotionFilePath)); MotionFilePath = String.Empty; Mpeg4Recorder.MultiplexFinished -= Mpeg4RecorderMultiplexFinished; }
/// <summary> /// Incoming call events that occur in IAPIExtension. /// </summary> /// <param name="sender">The SoftPhone.</param> /// <param name="e">The incomming call.</param> void extension_IncomingCall(object sender, VoIPEventArgs <ICall> e) { OnNotifyAction(string.Format("Incoming call received, caller is {0}", e.Item.OtherParty)); CustomerCall call = new CustomerCall(e.Item, ivrProject.GetNewMenuroot()); call.NotifyAction += new EventHandler <VoIPEventArgs <string> >(call_NotifyAction); call.Closing += new EventHandler(call_Closing); call.PhoneCall.Accept(); activeCalls.Add(call); }
void PresenterOnExtensionsListAvailable(object sender, VoIPEventArgs <List <ExtensionInfo> > vo_ip_event_args) { InvokeGUI(() => ClearListViewItems(lv_Extension)); foreach (var info in vo_ip_event_args.Item) { var item = GetItemFromExtensionInfo(info); InvokeGUI(() => AddItemToListView(lv_Extension, item)); } }
/// <summary> /// Hattın durumunun değiştiği zaman çalışan fonksiyon /// </summary> /// <param name="sender"></param> /// <param name="e"></param> ////////////private void phoneLine_PhoneLineInformation(object sender, VoIPEventArgs<PhoneLineState> e) ////////////{ //////////// phoneLineInformation = e.Item; //////////// InvokeGUIThread(() => //////////// { //////////// labelIdentifier.Text = ((IPhoneLine)sender).SIPAccount.RegisterName; //////////// if (e.Item == PhoneLineState.RegistrationSucceeded) //////////// { //////////// labelRegStatus.Text = "Online"; //////////// labelCallStateInfo.Text = "Kayıt Başarılı."; //////////// } //////////// else //////////// labelCallStateInfo.Text = e.Item.ToString(); //////////// }); ////////////} /// <summary> /// Çağrı geldiği zaman çalışır. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void softPhone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e) { InvokeGUIThread(() => { labelCallStateInfo.Text = "Incoming call"; labelDialingNumber.Text = String.Format("from {0}", e.Item.DialInfo); call = e.Item; WireUpCallEvents(); inComingCall = true; }); }
void ClientOnLoginCompleted(object sender, VoIPEventArgs<LoginResult> e) { view.CloseWaitWindow(window); view.SetState((e.Item == LoginResult.Success) ? LoginState.LoggingIn : LoginState.LoggedOut); if (e.Item != LoginResult.Success) view.ShowError("Connection failed", String.Format("Failed to connect to server: {0}", e.Item)); else { view.Connected = true; view.Close(); } client.LoginCompleted -= ClientOnLoginCompleted; }
/// <summary> /// Message received for logging. /// </summary> /// <param name="sender"></param> /// <param name="e">message</param> void call_NotifyAction(object sender, VoIPEventArgs<string> e) { OnNotifyAction(e.Item); }
void PhoneCall_CallStateChanged(object sender, VoIPEventArgs<CallState> e) { switch (e.Item) { case CallState.InCall: OnNotifyAction(string.Format("Caller '{0}' is in '{1}' menu.", PhoneCall.OtherParty, currentMenu.Name)); currentMenu.StartIntroduction(); break; case CallState.Completed: OnNotifyAction(string.Format("{0} hanged up the call.", PhoneCall.OtherParty)); currentMenu.StopIntroduction(); Close(); break; case CallState.Error: case CallState.Rejected: case CallState.Cancelled: case CallState.Busy: Close(); break; case CallState.Transferring: OnNotifyAction(string.Format("{0} call is transfering.",PhoneCall.OtherParty)); break; } }
/// <summary> /// Occurs when an incoming call request has received. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void softPhone_IncomingCall(object sender, VoIPEventArgs<IPhoneCall> e) { // incoming calls disabled. as per issue: // https://brightvision.jira.com/browse/PLATFORM-1976 /** / InvokeGUIThread(() => { call = e.Item; WireUpCallEvents(); inComingCall = true; }); /**/ }
/// <summary> /// Displays DTMF signals /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void call_DtmfReceived(object sender, VoIPEventArgs<OzTuple<VoIPMediaType, DtmfSignal>> e) { InvokeGUIThread(() => { //labelCallStateInfo.Text = String.Format("DTMF signal received: {0} ", e.Item.Item2.Signal); }); }
private void call_CallStateChanged(object sender, VoIPEventArgs<CallState> e) { callstate = e.Item; 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; m_MediaUtility.Stop(); recorder.StartStreaming(); //recorder.IsStreaming = true; } catch (Ozeki.Common.Exceptions.MediaException me) { if (CallState_Changed != null) { AudioId = Guid.Empty; 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 { recorder.StopStreaming(); //recorder.IsStreaming = false; EndCall(); if (m_RingTimeOut) return; this.WireDownCallEvents(); call = null; recorder.Dispose(); recorder = null; CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); string fileNameTmp = String.Format(@"{0}\tmpwav\{1}_.wav", commonData.ApplicationFolderPath, AudioId); string fileNameCache = String.Format(@"{0}\cachewav\{1}_.wav", commonData.ApplicationFolderPath, AudioId); File.Copy(fileNameTmp, fileNameCache); m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } catch { //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; } } else if (e.Item == CallState.Cancelled) { AudioId = Guid.Empty; EndCall(); if (m_RingTimeOut) return; m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Rejected) { AudioId = Guid.Empty; EndCall(); m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Busy || e.Item == CallState.Error) { AudioId = Guid.Empty; EndCall(); 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 }); } }
void softphoneEngine_SpeakerLevelChanged(object sender, VoIPEventArgs<float> e) { UpdateSpeakerLevel(e.Item); }
protected virtual void OnGetFilePath(VoIPEventArgs<string> e) { var handler = GetFilePath; if (handler != null) handler(this, e); }
/// <summary> /// This will be called when an incoming call received. /// </summary> private void SoftPhone_IncomingCall(object sender, VoIPEventArgs<IPhoneCall> e) { IPhoneCall call = e.Item; SubscribeToCallEvents(call); // automatically rejected for some reason if (call.CallState == CallState.Error) { CallHistory.Add(call); return; } // add to call container PhoneCalls.Add(call); // if no call is in progress, select the incoming call as current call and attach the audio to hear the ringtone if (SelectedCall == null) { SelectedCall = call; MediaHandlers.AttachAudio(call); } // raise IncomingCall event OnIncomingCall(call); }
/// <summary> /// This will be called when the state of a phone line has changed. /// </summary> private void Line_PhoneLineStateChanged(object sender, VoIPEventArgs<PhoneLineState> e) { IPhoneLine line = sender as IPhoneLine; if (line == null) return; PhoneLineState state = e.Item; // registration succeeded, subscribe for MWI if (state == PhoneLineState.RegistrationSucceeded) { line.SubscribeToMWI(); } OnPhoneLineStateChanged(line); OnPropertyChanged("SelectedLine.RegisteredInfo"); }
/// <summary> /// This will be called when an instant message received through a phone line. /// </summary> private void Line_OutofDialogInstantMessageReceived(object sender, VoIPEventArgs<MessageDataPackage> e) { IPhoneLine line = sender as IPhoneLine; if (line == null) return; MessageDataPackage data = e.Item; AddInstantMessage(data.Originator, data.Data); }
/// <summary> /// This will be called when a message summary received. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Line_MessageSummaryReceived(object sender, VoIPEventArgs<VoIPMessageSummary> e) { IPhoneLine line = sender as IPhoneLine; if (line == null) return; OnMessageSummaryReceived(new MessageSummaryArgs(line, e.Item)); }
/// <summary> /// This will be called when an instant message received through a call. /// </summary> private void Call_InstantMessageDataReceived(object sender, VoIPEventArgs<MessageDataPackage> e) { IPhoneCall call = sender as IPhoneCall; if (call == null) return; MessageDataPackage data = e.Item; OnCallInstantMessageReceived(new PhoneCallInstantMessageArgs(call, data)); }
/// <summary> /// Incoming call events that occur in IAPIExtension. /// </summary> /// <param name="sender">The SoftPhone.</param> /// <param name="e">The incomming call.</param> void extension_IncomingCall(object sender, VoIPEventArgs<ICall> e) { OnNotifyAction(string.Format("Incoming call received, caller is {0}", e.Item.OtherParty)); CustomerCall call = new CustomerCall(e.Item, ivrProject.GetNewMenuroot()); call.NotifyAction += new EventHandler<VoIPEventArgs<string>>(call_NotifyAction); call.Closing += new EventHandler(call_Closing); call.PhoneCall.Accept(); activeCalls.Add(call); }
void softphoneEngine_MicrophoneLevelChanged(object sender, VoIPEventArgs<float> e) { UpdateMicrophoneLevel(e.Item); }
void currentMenu_StepIntoMenu(object sender, VoIPEventArgs<IVRMenuElementBase> e) { repeatTimer.Stop(); if (e.Item == null)//If event param is null it's indicates the exit command, close the call. { PhoneCall.HangUp(); Close(); return; } UnSubscribeCurrentMenuEvents(); currentMenu = e.Item; OnNotifyAction(string.Format("Caller '{0}' is in '{1}' menu.", PhoneCall.OtherParty, currentMenu.Name)); SubscribeCurrentMenuEvents(); currentMenu.StartIntroduction(); }
/// <summary> /// There are certain situations when the call cannot be created, for example the dialed number is not available /// or maybe there is no endpoint to the dialed PBX, or simply the telephone line is busy. /// This event handling is for displaying these events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void call_CallErrorOccured(object sender, VoIPEventArgs<CallError> e) { InvokeGUIThread(() => { //labelCallStateInfo.Text = e.Item.ToString(); }); }
void Mpeg4RecorderMultiplexFinished(object sender, VoIPEventArgs<bool> e) { Mpeg4Recorder.Dispose(); Mpeg4Recorder.MultiplexFinished -= Mpeg4RecorderMultiplexFinished; OnGetFilePath(new VoIPEventArgs<string>(MotionFilePath)); Log.Write("The captured video has been saved"); }
/// <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> /// This will be called when the level of the speaker has changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Speaker_LevelChanged(object sender, VoIPEventArgs<float> e) { SpeakerLevel = e.Item; OnPropertyChanged("SpeakerLevel"); OnSpeakerLevelChanged(e.Item); }
/// <summary> /// Occurs when phone line state has changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void phoneLine_PhoneLineInformation(object sender, VoIPEventArgs<PhoneLineState> e) { phoneLineInformation = e.Item; InvokeGUIThread(() => { if (e.Item == PhoneLineState.RegistrationSucceeded) { m_PhoneRegisterSuccessful = true; this.PhoneRegisterSuccess(); } else if (e.Item == PhoneLineState.RegistrationRequested) { } else if (e.Item == PhoneLineState.RegistrationFailed) { m_PhoneRegisterSuccessful = false; } }); }
/// <summary> /// This will be called when the level of the microphone has changed. /// </summary> private void Microphone_LevelChanged(object sender, VoIPEventArgs<float> e) { MicrophoneLevel = e.Item; OnPropertyChanged("MicrophoneLevel"); OnMicrophoneLevelChanged(e.Item); }
/// <summary> /// This will be called when an error occurred during the call. /// </summary> private void Call_CallErrorOccured(object sender, VoIPEventArgs<CallError> e) { IPhoneCall call = sender as IPhoneCall; if (sender == null) return; MediaHandlers.DetachAudio(); MediaHandlers.DetachVideo(); DisposeCall(call); OnPhoneCallStateChanged(call); }
void currentMenu_CallTransferRequired(object sender, VoIPEventArgs<string> e) { OnNotifyAction(string.Format("It is transefering the call '{0}' to '{1}'", PhoneCall.OtherParty, e.Item)); PhoneCall.BlindTransfer(e.Item); }
void PhoneCall_CallErrorOccured(object sender, VoIPEventArgs<CallError> e) { OnNotifyAction(string.Format("Some error occure in the following {0} call", PhoneCall)); }
/// <summary> /// This will be called when the state of a call has changed. /// </summary> private void Call_CallStateChanged(object sender, VoIPEventArgs<CallState> e) { IPhoneCall call = sender as IPhoneCall; if (call == null) return; CallState state = e.Item; OnPhoneCallStateChanged(call); CheckStopRingback(); CheckStopRingtone(); // start ringtones if (state.IsRinging()) { if (call.IsIncoming) MediaHandlers.StartRingtone(); else MediaHandlers.StartRingback(); return; } // call has been answered if (state == CallState.Answered) { return; } // attach media to the selected call when the remote party sends media data if (state.IsRemoteMediaCommunication()) { if (SelectedCall.Equals(call)) { MediaHandlers.AttachAudio(call); MediaHandlers.AttachAudio(call); } return; } // detach media from the selected call in hold state or when the call has ended if (state == CallState.LocalHeld || state == CallState.InactiveHeld || state.IsCallEnded()) { if (SelectedCall.Equals(call)) { MediaHandlers.DetachAudio(); MediaHandlers.DetachVideo(); } } // call has ended, clean up if (state.IsCallEnded()) { DisposeCall(call); CallHistory.Add(call); PhoneCalls.Remove(call); return; } }
void PhoneCall_DtmfReceived(object sender, VoIPEventArgs<DtmfSignal> e) { DtmfSignal dtmfSignal = e.Item; OnNotifyAction(string.Format("{0} sent the following DTMF sign: {1}", PhoneCall.OtherParty, (int)dtmfSignal.Signal)); currentMenu.CommandReceived((int)dtmfSignal.Signal); }
/// <summary> /// This will be called when the other party stopped DTMF signaling. /// </summary> private void Call_DtmfReceived(object sender, VoIPEventArgs<DtmfInfo> e) { DtmfSignal signal = e.Item.Signal; MediaHandlers.StopDtmf(signal.Signal); }
void currentMenu_IntroductionStoped(object sender, VoIPEventArgs<Ozeki.Media.MediaHandlers.VoIPMediaHandler> e) { mediaManager.DeAttachVoIPHandlerToCall(e.Item); }
/// <summary> /// This will be called when the other party started DTMF signaling. /// </summary> private void Call_DtmfStarted(object sender, VoIPEventArgs<DtmfInfo> e) { int signal = e.Item.Signal.Signal; MediaHandlers.StartDtmf(signal); }