private void BoostRxButton_Click(object sender, RoutedEventArgs e) { foreach (ListBoxItem lbi in CallList.SelectedItems) { PJSIP.AudioMedia am = ((Call)lbi.Tag).getAudioMedia(); am.adjustRxLevel(float.Parse(RxTextBox.Text)); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { sm = new SipManager(Application.Current.Dispatcher.Thread); Refresh(); sm.AccountStateChange += sm_AccountStateChange; sm.CallStateChange += sm_CallStateChange; sm.CallMediaStateChange += sm_CallMediaStateChange; sm.IncomingCall += sm_IncomingCall; } catch (Exception ex) { MessageBox.Show(ex.Message); } System.Timers.Timer timer = new System.Timers.Timer(250); timer.Elapsed += (a, b) => { foreach (Call call in sm.Calls.Values.ToList()) { /*for (int i = 0; i < call.getInfo().media.Count; ++i) * { * //if (call.getInfo().media[i].type == PJSIP.pjmedia_type.PJMEDIA_TYPE_AUDIO) * //{ * Console.WriteLine(call.getInfo().media[i].type + " : " + call.getInfo().media[i].status.ToString() + " : " + PJSIP.AudioMedia.typecastFromMedia(call.getMedia((uint)i)).getPortInfo().listeners.Count); * //} * } * * Console.WriteLine(call.hasMedia()); * * if (call.getAudioMedia() == null) continue; * Console.WriteLine("RX:" + call.getAudioMedia().getRxLevel() + " TX:" + call.getAudioMedia().getTxLevel()); * PJSIP.AudioMedia ep = PJSIP.Endpoint.instance().audDevManager().getCaptureDevMedia(); * PJSIP.IntVector iv = ep.getPortInfo().listeners; * Console.WriteLine(iv.Contains(call.getAudioMedia().getPortInfo().portId)); * foreach (int v in iv) * { * Console.Write(v + " "); * } * Console.WriteLine("port:"+call.getAudioMedia().getPortInfo().portId);*/ PJSIP.AudioMedia ep = call.getAudioMedia(); //PJSIP.Endpoint.instance().audDevManager().getCaptureDevMedia(); if (ep != null) { Console.WriteLine("RX:" + ep.getRxLevel() + " TX:" + ep.getTxLevel()); } } }; timer.Start(); }
private void Refresh() { Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Normal, (ThreadStart) delegate() { if (sm.DefaultAccount != null) { RegisteredLabel.Content = sm.DefaultAccount.getInfo().regStatusText; } TotalCallsLabel.Text = sm.Calls.Count + " Calls"; CallList.Items.Clear(); foreach (Call call in sm.Calls.Values.ToList()) { PJSIP.CallInfo info = call.getInfo(); PJSIP.AudioMedia am = call.getAudioMedia(); int count = 0; if (am != null) { PJSIP.ConfPortInfo pi = am.getPortInfo(); PJSIP.IntVector iv = pi.listeners; count = iv.Count; } ListBoxItem lbi = new ListBoxItem(); lbi.Content = count + " - " + call.getCallerDisplay() + " " + (call.IsHeld ? "HOLDING" : (call.IsBridged ? "CONFERENCE" : info.stateText)) + " " + call.getCallDurationString(); lbi.Tag = call; CallList.Items.Add(lbi); } CallLogList.Items.Clear(); foreach (CallLog log in sm.CallLogManager.CallLogs) { ListBoxItem lbi = new ListBoxItem(); lbi.Content = log.LogType + " " + log.Name + " " + log.Number + " " + log.DurationString; lbi.Tag = log; CallLogList.Items.Add(lbi); } } ); }