private void CloseDevices() { microphone.Stop(); connector.Disconnect(microphone, mediaSender); speaker.Stop(); connector.Disconnect(mediaReceiver, speaker); mediaSender.Detach(); mediaReceiver.Detach(); CzasRozmowy_Label.Dispatcher.Invoke(() => { if (call != null) { if (rozmawiajacyUzytkownik != null) { //rozmawiajacyUzytkownik.wiadomosci.Add(DateTime.Now.ToShortTimeString() + " zakończono rozmowę"); } } CzasRozmowy_Label.Visibility = Visibility.Hidden; ZakonczRozmowe_Button.IsEnabled = false; }); if (stoper != null) { stoper.Stop(); } rozmawiajacyUzytkownik = null; }
private void call_CallStateChanged(object sender, CallStateChangedArgs e) { InvokeGUIThread(mymsg = "Call state: {0}." + e.State); if (e.State == CallState.Answered) { StartDevices(); MediaReciever.AttachToCall(PhoneCall); MediaSender.AttachToCall(PhoneCall); InvokeGUIThread(mymsg = "Call started" + e.State); } if (e.State.IsCallEnded() == true) { StopDevices(); MediaReciever.Detach(); MediaSender.Detach(); WireDownCallEvents(); PhoneCall = null; InvokeGUIThread(mymsg = "Call ended" + e.State); } }
static void CloseDevices() { microphone.Dispose(); speaker.Dispose(); mediaReceiver.Detach(); mediaSender.Detach(); connector.Dispose(); }
private void call_CallStateChanged(object sender, CallStateChangedArgs e) { switch (e.State) { case CallState.Ringing: StateChanged?.Invoke(PhoneState.Ringing); break; case CallState.InCall: StateChanged?.Invoke(PhoneState.InCall); break; default: StateChanged?.Invoke(PhoneState.Other); break; } RaiseMessage?.Invoke(e.State.ToString()); if (e.State == CallState.Answered) { if (microphone != null) { microphone.Start(); } if (speaker != null) { speaker.Start(); } mediaSender.AttachToCall(call); mediaReceiver.AttachToCall(call); return; } if (e.State.IsCallEnded()) { if (microphone != null) { microphone.Stop(); } if (speaker != null) { speaker.Stop(); } mediaSender.Detach(); mediaReceiver.Detach(); UnsubscribeFromCallEvents(sender as IPhoneCall); call = null; StateChanged?.Invoke(PhoneState.CallEnded); } }
/// <summary> /// If the call ends, we won't need our speaker and microphone anymore to communicate, /// until we enter into a call again, so we are calling the StopDevices() method. /// The mediaHandlers are getting detached from the call object /// (since we are not using our microphone and speaker, we have no media to send). /// We won't need the call's events anymore, becouse our call is about to be ended, /// and with setting the call to null, we are ending it. /// </summary> public void CallFinished() { StopDevices(); mediaReceiver.Detach(); mediaSender.Detach(); WireDownCallEvents(); call = null; }
/// <summary> /// If the call ends, we won't need our speaker and microphone anymore to communicate, /// until we enter into a call again, so we are calling the StopDevices() method. /// The mediaHandlers are getting detached from the call object /// (since we are not using our microphone and speaker, we have no media to send). /// We won't need the call's events anymore, becouse our call is about to be ended, /// and with setting the call to null, we are ending it. /// </summary> public void CallFinished() { StopDevices(); _mediaReceiver.Detach(); _mediaSender.Detach(); DisconnectMedia(); WireDownCallEvents(); _call = null; }
static void CloseDevices() { Console.WriteLine("CloseDevices()"); //phoneLine.Dispose(); // nowo dodane microphone.Dispose(); speaker.Dispose(); mediaReceiver.Detach(); mediaSender.Detach(); connector.Dispose(); }
private void call_CallStateChanged(object sender, CallStateChangedArgs e) { _message = new List <string>(); _message.Add(e.State.ToString()); StopMp3Ring(); if (e.State == CallState.Answered) { StartDevices(); _mediaReceiver.AttachToCall(_call); _mediaSender.AttachToCall(_call); //InvokeGUIThread(() => { lb_Log.Items.Add("Call started."); }); } if (e.State == CallState.InCall) { //btn_Hold.Enabled = true; //btn_Hold.Text = "Hold"; StartDevices(); } if (e.State.IsRinging()) { StartMP3Ring("Ringing.mp3"); } if (e.State == CallState.Busy) { StartMP3Ring("Busy.mp3"); } if (e.State.IsCallEnded()) { //_localHeld = false; StopDevices(); _mediaReceiver.Detach(); _mediaSender.Detach(); WireDownCallEvents(); _call = null; //InvokeGUIThread(() => { lb_Log.Items.Add("Call ended."); tb_Display.Text = string.Empty; }); } if (e.State == CallState.LocalHeld) { StopDevices(); } }
/// <summary> /// Occurs when the phone call state has changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void call_CallStateChanged(object sender, VoIPEventArgs <CallState> e) { InvokeGUIThread(() => { labelCallStateInfo.Text = e.Item.ToString(); }); switch (e.Item) { case CallState.InCall: if (microphone != null) { microphone.Start(); } connector.Connect(microphone, mediaSender); if (speaker != null) { speaker.Start(); } connector.Connect(mediaReceiver, speaker); mediaSender.AttachToCall(call); mediaReceiver.AttachToCall(call); break; case CallState.Completed: if (microphone != null) { microphone.Stop(); } connector.Disconnect(microphone, mediaSender); if (speaker != null) { speaker.Stop(); } connector.Disconnect(mediaReceiver, speaker); mediaSender.Detach(); mediaReceiver.Detach(); WireDownCallEvents(); call = null; InvokeGUIThread(() => { labelDialingNumber.Text = string.Empty; }); break; case CallState.Cancelled: WireDownCallEvents(); call = null; break; } }
private void call_CallStateChanged(object sender, CallStateChangedArgs e) { if (e.State == CallState.Answered) { //player.Stop(); StartDevices(); _mediaReceiver.AttachToCall(frmSipAccount._call); _mediaSender.AttachToCall(frmSipAccount._call); AsynThread(() => { lb_Log.Items.Add("Call started."); }); } if (e.State == CallState.InCall) { //isCalling = false; player.Stop(); StartDevices(); } if (e.State.IsCallEnded()) { StopDevices(); _mediaReceiver.Detach(); _mediaSender.Detach(); UnSubcribeCallEvents(); } if (e.State == CallState.LocalHeld) { AsynThread(() => { lb_Log.Items.Add("Call Hold."); }); StopDevices(); } if (e.State == CallState.Ringing) { AsynThread(() => { //if (isCalling) // playSound(calling); //else playSound(ringing); }); } DispatchAsync(() => { var handler = CallStateChanged; if (handler != null) { handler(this, e); } }); }
public void CloseDevices() { Console.WriteLine("closeDevices"); phoneLine.Dispose(); microphone.Dispose(); speaker.Dispose(); mediaReceiver.Detach(); mediaSender.Detach(); connector.Dispose(); mp3Player.Stop(); mp3Player.Dispose(); }
/// <summary> /// Disconnecting the microphone and speaker from the call /// </summary> private void DisconnectDevicesFromCall() { if (microphone != null) { microphone.Stop(); } connector.Disconnect(microphone, mediaSender); if (speaker != null) { speaker.Stop(); } connector.Disconnect(mediaReceiver, speaker); mediaSender.Detach(); mediaReceiver.Detach(); }
private void call_CallStateChanged(object sender, CallStateChangedArgs e) { InvokeGUIThread(() => { lb_Log.Items.Add("Callstate changed." + e.State.ToString()); tb_Display.Text = e.State.ToString(); }); if (e.State == CallState.Answered) { btn_Hold.Enabled = true; btn_Hold.Text = "Hold"; StartDevices(); mediaReceiver.AttachToCall(call); mediaSender.AttachToCall(call); InvokeGUIThread(() => { lb_Log.Items.Add("Call started."); }); } if (e.State == CallState.InCall) { btn_Hold.Enabled = true; btn_Hold.Text = "Hold"; StartDevices(); } if (e.State.IsCallEnded() == true) { localHeld = false; StopDevices(); mediaReceiver.Detach(); mediaSender.Detach(); WireDownCallEvents(); call = null; InvokeGUIThread(() => { lb_Log.Items.Add("Call ended."); tb_Display.Text = string.Empty; }); } if (e.State == CallState.LocalHeld) { StopDevices(); } }
void call_CallStateChanged(object sender, CallStateChangedArgs e) { InvokeGUIThread(() => { lbl_CallState.Text = e.State.ToString(); }); if (e.State == CallState.Answered) { StartDevices(); _mediaSender.AttachToCall(_call); _mediaReceiver.AttachToCall(_call); InvokeGUIThread(() => { tb_Display.Text = "In call with: " + ((IPhoneCall)sender).DialInfo.Dialed; }); } else if (e.State == CallState.InCall) { StartDevices(); } if (e.State == CallState.LocalHeld || e.State == CallState.InactiveHeld) { StopDevices(); InvokeGUIThread(() => { btn_Hold.Text = "Unhold"; }); } else { InvokeGUIThread(() => { btn_Hold.Text = "Hold"; }); } if (e.State.IsCallEnded()) { StopDevices(); _mediaSender.Detach(); _mediaReceiver.Detach(); WireDownCallEvents(); _call = null; InvokeGUIThread(() => { tb_Display.Text = String.Empty; }); ClearUserInfos(); } }
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); } }
private void Call_CallStateChanged(object sender, CallStateChangedArgs e) { IPhoneCall grCall = sender as IPhoneCall; _grCall = grCall; MyCallState tmp = MyCallState.DoNotthing; if (e.State == CallState.Answered) { StartDevices(); mediaReceiver.AttachToCall(call); mediaSender.AttachToCall(call); videoReceiver.AttachToCall(call); videoSender.AttachToCall(call); tmp = MyCallState.Answered; } if (e.State == CallState.InCall) { StartDevices(); tmp = MyCallState.InCall; CallDuration(); } if (e.State.IsCallEnded() == true) { StopDevices(); mediaReceiver.Detach(); mediaSender.Detach(); videoSender.Detach(); videoReceiver.Detach(); WireDownCallEvents(); call = null; tmp = MyCallState.CallEnd; Instance.IsLocalCameraUsed = false; timer.Stop(); } if (e.State == CallState.LocalHeld) { StopDevices(); } if (e.State == CallState.Busy) { StopDevices(); tmp = MyCallState.Busy; } if (e.State == CallState.Cancelled) { StopDevices(); tmp = MyCallState.Canceled; } if (e.State == CallState.Completed) { tmp = MyCallState.CallEnd; } if (CallStateChange != null) { CallStateChange.Invoke(tmp); } }
private void call_CallStateChanged(object sender, CallStateChangedArgs e) { try { InvokeGUIThread(() => { lb_Log.Items.Add("Callstate changed." + e.State.ToString()); });// tb_Display.Text = e.State.ToString(); if (e.State == CallState.Answered) { player.Stop(); StartDevices(); _mediaReceiver.AttachToCall(_call); _mediaSender.AttachToCall(_call); SetupAnswered(); InvokeGUIThread(() => { lb_Log.Items.Add("Call started."); }); } if (e.State == CallState.InCall) { player.Stop(); StartDevices(); InvokeGUIThread(() => { }); } if (e.State.IsCallEnded() || e.State == CallState.Rejected) { StopDevices(); _mediaReceiver.Detach(); _mediaSender.Detach(); UnSubcribedCallEvents(); if (isInComingCompleted) { isInComingCompleted = false; InvokeGUIThread(() => { }); } InvokeGUIThread(() => { }); _call = null; EndCalling(); InvokeGUIThread(() => { lb_Log.Items.Add("Call ended."); playSound(hangup); }); } if (e.State == CallState.LocalHeld) { InvokeGUIThread(() => { lb_Log.Items.Add("Call Holding."); }); StopDevices(); } if (e.State == CallState.RemoteHeld) { InvokeGUIThread(() => { lb_Log.Items.Add("Callee Holding."); }); InvokeGUIThread(() => { playSound(holding); }); } if (e.State == CallState.Ringing) { InvokeGUIThread(() => { if (isCalling) { playSound(calling); } else { playSound(ringing); } }); } DispatchAsync(() => { var handler = CallStateChanged; if (handler != null) { handler(this, e); } }); } catch (Exception ex) { } }
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; } }); } }
/// <summary> /// Detaches the media handlers from the phone call. /// </summary> public void DetachAudio() { _phoneCallAudioSender.Detach(); _phoneCallAudioReceiver.Detach(); AudioEnhancer.Stop(); }
public void call_CallStateChanged(object sender, CallStateChangedArgs e) { InvokeGUIThread(() => { lb_Log.Items.Add("Callstate changed." + e.State.ToString()); }); // tb_Display.Text = e.State.ToString(); if (e.State == CallState.Answered) { player.Stop(); StartDevices(); _mediaReceiver.AttachToCall(_call); _mediaSender.AttachToCall(_call); InvokeGUIThread(() => { lb_Log.Items.Add("Call started."); }); } if (e.State == CallState.InCall) { isCalling = false; player.Stop(); StartDevices(); InvokeGUIThread(() => { btnHangup.Enabled = true; btnHold.Enabled = true; btnHangup.BackColor = Color.Red; btnHangup.ForeColor = Color.Snow; btnHold.BackColor = Color.Red; btnHold.ForeColor = Color.Snow; }); } if (e.State.IsCallEnded()) { StopDevices(); _mediaReceiver.Detach(); _mediaSender.Detach(); WireDownCallEvents(); if (isInComingCompleted) { isInComingCompleted = false; InvokeGUIThread(() => { btnAccpect.Enabled = false; btnAccpect.BackColor = Color.Teal; btnAccpect.ForeColor = Color.DimGray; btnHold.Enabled = false; btnHangup.Enabled = false; btnHold.BackColor = Color.Teal; btnHold.ForeColor = Color.DimGray; btnHangup.BackColor = Color.Teal; btnHangup.ForeColor = Color.DimGray; }); } InvokeGUIThread(() => { btnHold.Enabled = false; btnHangup.Enabled = false; btnHold.BackColor = Color.Teal; btnHold.ForeColor = Color.DimGray; btnHangup.BackColor = Color.Teal; btnHangup.ForeColor = Color.DimGray; }); _call = null; InvokeGUIThread(() => { lb_Log.Items.Add("Call ended."); playSound(hangup); }); } if (e.State == CallState.LocalHeld) { InvokeGUIThread(() => { lb_Log.Items.Add("Call Hold."); }); StopDevices(); } if (e.State == CallState.RemoteHeld) { InvokeGUIThread(() => { playSound(holding); }); } if (e.State == CallState.Ringing) { InvokeGUIThread(() => { if (isCalling) { playSound(calling); } else { playSound(ringing); } }); } DispatchAsync(() => { var handler = CallStateChanged; if (handler != null) { handler(this, e); } }); }