protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); mNativeEventsListener.Start(); if (!rtServiceManager.Instance.IsStarted) { rtServiceManager.Instance.Start(); } SipService sipService = rtServiceManager.Instance.SipService; if (sipService != null && sipService.RegistrationState != SipSessionState.Connected) { if (sipService != null && sipService.SipActiveAVCall == null) { if (sipService.Stop(false)) { if (sipService.Start()) { sipService.Register(); } } } } }
internal void UpdateAudioButtons() { AudioRoute availAudioRoutes = AudioRoute.None; AudioRoute currentAudioRoute = AudioRoute.None; SipAVCall avCall = null; SipService sipService = BackgroundProcessController.Instance.SipService; if (sipService != null) { avCall = sipService.SipActiveAVCall; if (avCall != null) { availAudioRoutes = sipService.AvailableAudioRoutes; currentAudioRoute = sipService.AudioRoute; } } IsEarpieceButtonEnabled = ((availAudioRoutes & AudioRoute.Earpiece) != AudioRoute.None); IsSpeakerButtonEnabled = ((availAudioRoutes & AudioRoute.Speakerphone) != AudioRoute.None); IsBluetoothButtonEnabled = ((availAudioRoutes & AudioRoute.Bluetooth) != AudioRoute.None); EarpieceButtonBorder = (currentAudioRoute == AudioRoute.Earpiece) ? accentBrush : borderBrush; SpeakerButtonBorder = (currentAudioRoute == AudioRoute.Speakerphone) ? accentBrush : borderBrush; BluetoothButtonBorder = (currentAudioRoute == AudioRoute.Bluetooth) ? accentBrush : borderBrush; }
void mNativeEventsListener_onAVCallEvent(object sender, SipAVCallEventArgs e) { this.Dispatcher.BeginInvoke((System.Threading.ThreadStart) delegate { mViewModel.CallState = e.State; if ((e.State == SipAVCallState.Incoming || e.State == SipAVCallState.InCall) && !(mViewModel is CallStatusViewModel)) { SipService sipService = BackgroundProcessController.Instance.SipService; if (sipService != null) { SipAVCall avCall = sipService.SipActiveAVCall; if (avCall != null && avCall.UriRemote != null) { mViewModel.Page.NavigationService.Navigate(new Uri(NavigationUri.BuildReceiveCallUriString("/CallPage.xaml", avCall.UriRemote.getUserName(), avCall.WithVideo), UriKind.Relative)); return; } } } if (mViewModel is CallStatusViewModel) { (mViewModel as CallStatusViewModel).Update(); } if (e.SipCode > 299) { mViewModel.CallStateText = e.Description; } }); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); SipService sipService = BackgroundProcessController.Instance.SipService; // Register for the Obscured/Unobscured events PhoneApplicationFrame rootFrame = ((App)Application.Current).RootFrame; rootFrame.Obscured += ((CallStatusViewModel)this.ViewModel).RootFrame_Obscured; rootFrame.Unobscured += ((CallStatusViewModel)this.ViewModel).RootFrame_Unobscured; NavigationUriCall navigationUri = NavigationUri.Build(e.Uri) as NavigationUriCall; // navigationUri could be null if the app was put on the background Debug.Assert(navigationUri != null || sipService.SipActiveAVCall != null); if (navigationUri != null) { switch (navigationUri.Type) { case NavigationUriType.MakeCall: { Debug.Assert(!String.IsNullOrEmpty(navigationUri.RemoteParty)); base.ViewModel.RemotePartyDisplayName = base.ViewModel.RemotePartyNumber = navigationUri.RemoteParty; rtSipUri toUri = BackgroundProcessController.Instance.rtSipUriNew(UriUtils.GetValidSipUri(navigationUri.RemoteParty), navigationUri.RemoteParty); bool bSuccess = navigationUri.WithVideo ? (rtServiceManager.Instance.SipService.MakeCallAudioVideo(toUri, null) != null) : (rtServiceManager.Instance.SipService.MakeCallAudio(toUri, null) != null); if (!bSuccess) { base.ViewModel.CallState = SipAVCallState.Terminated; } break; } case NavigationUriType.ReceiveCall: { break; } default: { Debug.Assert(false); break; } } } // Re-bind MediaElements explictly, so video will play after app has been resumed bigHead.SetBinding(MediaElement.SourceProperty, new System.Windows.Data.Binding("BigHeadPreviewUri")); littleHead.SetBinding(MediaElement.SourceProperty, new System.Windows.Data.Binding("LittleHeadPreviewUri")); ((CallStatusViewModel)this.ViewModel).Update(); }
private void CameraToggleButton_Click(object sender, System.Windows.RoutedEventArgs e) { SipService sipService = BackgroundProcessController.Instance.SipService; if (sipService != null) { CameraSensorLocation newCameraSensorLocation = (sipService.CameraLocation == CameraSensorLocation.Back) ? CameraSensorLocation.Front : CameraSensorLocation.Back; sipService.CameraLocation = newCameraSensorLocation; ((CallStatusViewModel)this.ViewModel).CameraLocation = newCameraSensorLocation; } }
private void HangUpButton_Click(object sender, System.Windows.RoutedEventArgs e) { ((CallStatusViewModel)this.ViewModel).IsHangUpButtonEnabled = false; SipService sipService = BackgroundProcessController.Instance.SipService; SipAVCall avCall = (sipService != null) ? sipService.SipActiveAVCall : null; if (avCall != null) { avCall.HangUp(null); } }
public void Stop() { SipService sipService = rtServiceManager.Instance.SipService; if (sipService != null) { sipService.SetDebugMessageListener(null); sipService.SetAudioStateChangedListener(null); sipService.SetSipStackStateChangedListener(null); sipService.SetSipRegistrationStateChangedListener(null); sipService.SetSipAVCallStateChangedListener(null); } }
public void SetAudioRoute(AudioRoute newRoute) { SipService sipService = BackgroundProcessController.Instance.SipService; if (sipService != null && newRoute != sipService.AudioRoute) { sipService.AudioRoute = newRoute; // Disable all audio route buttons, so the user doesn't press them again and again. // The buttons will get re-enabled if required when the audio route changes. DisableAllAudioRouteButtons(); } }
private void HoldButton_Click(object sender, System.Windows.RoutedEventArgs e) { SipService sipService = BackgroundProcessController.Instance.SipService; SipAVCall avCall = (sipService != null) ? sipService.SipActiveAVCall : null; if (avCall != null) { if ((avCall.HoldState & SipHoldStateState.LocalHeld) != SipHoldStateState.LocalHeld) { avCall.Hold(null); } else { avCall.Resume(null); } } }
virtual internal void Update() { String remotePartyDisplayName = null; String remotePartyNumber = null; SipService sipService = rtServiceManager.Instance.SipService; SipAVCallState callState = SipAVCallState.None; SipSessionState registrationState = SipSessionState.None; if (sipService != null) { registrationState = sipService.RegistrationState; SipAVCall avCall = rtServiceManager.Instance.SipService.SipActiveAVCall; if (avCall != null) { if (avCall.UriRemote != null) { remotePartyDisplayName = avCall.UriRemote.getDisplayName(); remotePartyNumber = avCall.UriRemote.getUserName(); if (String.IsNullOrEmpty(remotePartyDisplayName)) { remotePartyDisplayName = remotePartyNumber; } } callState = avCall.State; } } RegistrationState = registrationState; if (!String.IsNullOrEmpty(remotePartyDisplayName)) // Keep previsous text { RemotePartyDisplayName = remotePartyDisplayName; } if (!String.IsNullOrEmpty(remotePartyNumber)) // Keep previsous text { RemotePartyNumber = remotePartyNumber; } if (callState != SipAVCallState.None)// Keep previsous text { CallState = callState; } }
void buttonSaveSettings_Click(object sender, RoutedEventArgs e) { buttonSaveSettings.IsEnabled = false; SaveSettings(); new Thread(() => { SipService sipService = rtServiceManager.Instance.SipService; if (sipService != null && sipService.SipActiveAVCall == null) { if (sipService.Stop(false)) { rtServiceManager.Instance.UpdateSipConfig(); if (sipService.Start()) { sipService.Register(); } } } }).Start(); }
override internal void Update() { base.Update(); bool mediaActivated = false; bool callActived = false; bool videoActivated = false; SipAVCall avCall = null; SipHoldStateState holdState = SipHoldStateState.None; CameraSensorLocation cameraLocation = CameraSensorLocation.Front; SipService sipService = BackgroundProcessController.Instance.SipService; if (sipService != null) { avCall = sipService.SipActiveAVCall; } if (avCall != null) { mediaActivated = (avCall.State == SipAVCallState.InCall || avCall.State == SipAVCallState.EarlyMedia); callActived = (avCall.State != SipAVCallState.Terminated && avCall.State != SipAVCallState.Terminating); videoActivated = (mediaActivated && avCall.WithVideo); holdState = avCall.HoldState; cameraLocation = sipService.CameraLocation; } IsHangUpButtonEnabled = callActived; IsHoldButtonEnabled = mediaActivated; IsHoldButtonChecked = ((holdState & SipHoldStateState.LocalHeld) == SipHoldStateState.LocalHeld); IsCameraToggleButtonEnabled = videoActivated; LittleHeadVisibility = videoActivated ? Visibility.Visible : Visibility.Collapsed; LittleHeadPreviewUri = videoActivated ? (cameraLocation == CameraSensorLocation.Back ? rearFacingCameraStreamUri : frontFacingCameraStreamUri) : null; CameraLocation = cameraLocation; BigHeadVisibility = videoActivated ? Visibility.Visible : Visibility.Collapsed; BigHeadPreviewUri = videoActivated ? renderStreamUri : null; HoldState = holdState; UpdateAudioButtons(); }
/// <summary> /// Starts the manager /// </summary> /// <returns></returns> public bool Start() { bool ret = true; LOG.Debug("Start Service Manager"); mStarted = this.ConfigurationService.Start(); mStarted &= this.ScreenService.Start(); // Update SIP configuration UpdateSipConfig(); // Set codecs. Not part of the configuration because apply to all SIP service instances (global) SipService.SetCodecs(rt_tdav_codec_id_t.tdav_codec_id_all); // Start SIP service mStarted &= this.SipService.Start(); mStarted &= this.ContactService.Start(); mStarted &= this.HistoryService.Start(); #if !WINRT mStarted &= this.SoundService.Start(); #endif mStarted &= this.StateMonitorService.Start(); // Register plugins // MediaSessionMgr.registerAudioPluginFromFile("audio_webrtc.dll"); /* * // Set user preferences (global defaults) * // could be changed per session * rtMediaSessionMgr.defaultsSetVolume(this.ConfigurationService.Get(Configuration.ConfFolder.GENERAL, Configuration.ConfEntry.AUDIO_VOLUME, Configuration.DEFAULT_GENERAL_AUDIO_VOLUME)); * if (this.configurationService.Get(Configuration.ConfFolder.QOS, Configuration.ConfEntry.SESSION_TIMERS, Configuration.DEFAULT_QOS_SESSION_TIMERS)) * { * rtMediaSessionMgr.defaultsSetInviteSessionTimers( * this.configurationService.Get(Configuration.ConfFolder.QOS, Configuration.ConfEntry.SESSION_TIMERS_TIMEOUT, Configuration.DEFAULT_QOS_SESSION_TIMERS_TIMEOUT), * this.configurationService.Get(Configuration.ConfFolder.QOS, Configuration.ConfEntry.SESSION_TIMERS_REFRESHER, Configuration.DEFAULT_QOS_SESSION_TIMERS_REFRESHER)); * } * else * { * rtMediaSessionMgr.defaultsSetInviteSessionTimers(0, BogheCore.Utils.StringUtils.nullptr); * } * rtMediaSessionMgr.defaultsSetPrefVideoSize( * (rt_tmedia_pref_video_size_t)Enum.Parse(typeof(rt_tmedia_pref_video_size_t), this.configurationService.Get(Configuration.ConfFolder.QOS, Configuration.ConfEntry.PREF_VIDEO_SIZE, Configuration.DEFAULT_QOS_PREF_VIDEO_SIZE), true) * ); * * rtMediaSessionMgr.defaultsSetSRtpMode( * (rt_tmedia_srtp_mode_t)Enum.Parse(typeof(rt_tmedia_srtp_mode_t), this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.SRTP_MODE, Configuration.DEFAULT_SECURITY_SRTP_MODE), true) * ); * * rtMediaSessionMgr.defaultsSetSRtpType( * (rt_tmedia_srtp_type_t)Enum.Parse(typeof(rt_tmedia_srtp_type_t), this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.SRTP_TYPE, Configuration.DEFAULT_SECURITY_SRTP_TYPE), true) * ); * * rtMediaSessionMgr.defaultsSetProfile( * (rt_tmedia_profile_t)Enum.Parse(typeof(rt_tmedia_profile_t), this.configurationService.Get(Configuration.ConfFolder.MEDIA, Configuration.ConfEntry.PROFILE, Configuration.DEFAULT_MEDIA_PROFILE), true) * ); * * rtMediaSessionMgr.defaultsSetRtpSymetricEnabled( * this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.USE_SYMETRIC_RTP, Configuration.DEFAULT_NATT_USE_SYMETRIC_RTP) * ); * rtMediaSessionMgr.defaultsSetIceEnabled( * this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.USE_ICE, Configuration.DEFAULT_NATT_USE_ICE) * ); * */ return(ret); }