/// <summary> /// Show video. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonVideo_Click(object sender, EventArgs e) { try { // If in call. if (_inComingCall != null && _inComingCall.Call != null) { if (_isVideoValid) { // If video window exists. if (_inComingCall.Call.VideoWindow != null && _videoCallWindow == null) { // Get the video window id. int videoWindowID = _inComingCall.Call.VideoWindow.GetVideoWindowID(); if (videoWindowID >= 0) { // Show the incoming video. _videoCallWindow = new Net.PjSip.UI.VideoIncomingWindow(videoWindowID, "Remote Video - " + _contactName, _inComingCall.Call.ID, 640, 480); _videoCallWindow.OnVideoIncomingClosing += VideoIncoming_OnVideoIncomingClosing; _videoCallWindow.Show(this); // Enabled. buttonVideo.Enabled = false; // Start the video. _inComingCall.Call.StartVideoTransmit(); } } else { // Window state. bool windowState = _videoCallWindow.GetActiveState(); // If still active. if (windowState) { // Show the video. _videoCallWindow.ShowVideoWindow(); // Start the video. _inComingCall.Call.StartVideoTransmit(); } // Enabled. buttonVideo.Enabled = false; } } } } catch { } }
/// <summary> /// On call state. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Call_OnCallState(object sender, Param.CallStateParam e) { // Set the contact name. e.ContactName = _contactName; // If call is disconnected. if ((e.State == Nequeo.Net.PjSip.InviteSessionState.PJSIP_INV_STATE_DISCONNECTED) || (e.State == Nequeo.Net.PjSip.InviteSessionState.PJSIP_INV_STATE_NULL)) { // Stop the play if not already stopped. if (_playerStarted) { StopPlayer(); } try { // Close the video window if any. if (_videoCallWindow != null) { _videoCallWindow.SetActiveState(false); _videoCallWindow.Close(); } } catch { } _videoCallWindow = null; // Close the window. _callEnded?.Invoke(); } else { UISync.Execute(() => { // If incomming. if ((e.State == Nequeo.Net.PjSip.InviteSessionState.PJSIP_INV_STATE_INCOMING)) { } }); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonHold_Click(object sender, EventArgs e) { if (_inComingCall != null && _inComingCall.Call != null) { // Is the call on hold. if (_inComingCall.Call.CallOnHold) { try { // Un hold the call. _inComingCall.Call.Hold(); } catch { } } else { try { // Hold the call. _inComingCall.Call.Hold(); } catch { } try { // Close the video window if any. if (_videoCallWindow != null) { _videoCallWindow.SetActiveState(false); _videoCallWindow.Close(); } } catch { } _videoCallWindow = null; // No video. buttonVideo.Enabled = false; } } }