private async void CallStateChangedHandler(object sender, ToxAvEventArgs.CallStateEventArgs e) { if (e.FriendNumber != _friendNumber) return; if (e.State.HasFlag(ToxAvFriendCallState.ReceivingAudio) || e.State.HasFlag(ToxAvFriendCallState.SendingAudio)) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { State = CallState.DuringCall; }); } _friendIsReceivingAudio = e.State.HasFlag(ToxAvFriendCallState.ReceivingAudio); if (e.State.HasFlag(ToxAvFriendCallState.Finished) || e.State.HasFlag(ToxAvFriendCallState.Error)) { StopAudioGraph(); await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { State = CallState.Default; }); } }
private void toxav_OnInvite(object sender, ToxAvEventArgs.CallStateEventArgs e) { //TODO: notify the user of another incoming call if (call != null) return; Dispatcher.BeginInvoke(((Action)(() => { var friend = ViewModel.GetFriendObjectByNumber(toxav.GetPeerID(e.CallIndex, 0)); if (friend != null) { friend.CallIndex = e.CallIndex; friend.IsCalling = true; } }))); }
private void toxav_OnStart(object sender, ToxAvEventArgs.CallStateEventArgs e) { var settings = toxav.GetPeerCodecSettings(e.CallIndex, 0); if (call != null) call.Start(config.InputDevice, config.OutputDevice, settings, config.VideoDevice); Dispatcher.BeginInvoke(((Action)(() => { if (settings.CallType == ToxAvCallType.Video) { VideoImageRow.Height = new GridLength(300); VideoGridSplitter.IsEnabled = true; } int friendnumber = toxav.GetPeerID(e.CallIndex, 0); var callingFriend = ViewModel.GetFriendObjectByNumber(friendnumber); if (callingFriend != null) { callingFriend.IsCalling = false; callingFriend.IsCallingToFriend = false; CallButton.Visibility = Visibility.Collapsed; if (callingFriend.Selected) { HangupButton.Visibility = Visibility.Visible; VideoButton.Visibility = Visibility.Visible; } ViewModel.CallingFriend = callingFriend; } }))); call.SetTimerCallback(timerCallback); }
private void toxav_OnEnd(object sender, ToxAvEventArgs.CallStateEventArgs e) { Dispatcher.BeginInvoke(((Action)(() => { EndCall(); CallButton.Visibility = Visibility.Visible; HangupButton.Visibility = Visibility.Collapsed; VideoButton.Visibility = Visibility.Collapsed; VideoButton.IsChecked = false; }))); }
private void toxav_OnReceivedAudio(object sender, ToxAvEventArgs.AudioDataEventArgs e) { if (call == null) return; call.ProcessAudioFrame(e.Data); }
private void toxav_OnReceivedGroupAudio(object sender, ToxAvEventArgs.GroupAudioDataEventArgs e) { var group = Dispatcher.Invoke(() => ViewModel.GetGroupObjectByNumber(e.GroupNumber)); if (group == null) return; var peer = group.PeerList.GetPeerByPublicKey(tox.GetGroupPeerPublicKey(e.GroupNumber, e.PeerNumber)); if (peer == null || peer.Ignored || peer.Muted) return; if (call != null && call.GetType() == typeof(ToxGroupCall)) ((ToxGroupCall)call).ProcessAudioFrame(e.Data, e.Channels); }
private void CallStateChangedHandler(object sender, ToxAvEventArgs.CallStateEventArgs e) { if ((e.FriendNumber == _friendInCall) && (e.State.HasFlag(ToxAvFriendCallState.Finished) || e.State.HasFlag(ToxAvFriendCallState.Error))) { _friendInCall = -1; } CallStateChanged?.Invoke(this, e); }
private async void CallRequestReceivedHandler(object sender, ToxAvEventArgs.CallRequestEventArgs e) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { State = CallState.IncomingCall; }); }
private void VideoFrameReceivedHandler(object sender, ToxAvEventArgs.VideoFrameEventArgs e) { if (VideoFrameReceived != null) VideoFrameReceived(this, e); }
private void AudioFrameReceivedHandler(object sender, ToxAvEventArgs.AudioFrameEventArgs e) { if (AudioFrameReceived != null) AudioFrameReceived(this, e); }
private void VideoBitrateChangedHandler(object sender, ToxAvEventArgs.BitrateStatusEventArgs e) { if (VideoBitrateChanged != null) VideoBitrateChanged(this, e); }
private void CallStateChangedHandler(object sender, ToxAvEventArgs.CallStateEventArgs e) { if (CallStateChanged != null) CallStateChanged(this, e); }
private void CallRequestReceivedHandler(object sender, ToxAvEventArgs.CallRequestEventArgs e) { if (CallRequestReceived != null) CallRequestReceived(this, e); }
private void VideoFrameReceivedHandler(object sender, ToxAvEventArgs.VideoFrameEventArgs e) { VideoFrameReceived?.Invoke(this, e); }
private void VideoBitrateChangedHandler(object sender, ToxAvEventArgs.BitrateStatusEventArgs e) { VideoBitrateChanged?.Invoke(this, e); }
private void AudioFrameReceivedHandler(object sender, ToxAvEventArgs.AudioFrameEventArgs e) { if (e.FriendNumber != _friendNumber) return; _receiveBuffer.Post(e.Frame.Data); }
private void toxav_OnReceivedVideo(object sender, ToxAvEventArgs.VideoDataEventArgs e) { if (Dispatcher.Invoke(() => (call == null || call.GetType() == typeof(ToxGroupCall) || call.Ended || ViewModel.IsGroupSelected || call.FriendNumber != ViewModel.SelectedChatNumber))) return; ProcessVideoFrame(e.Frame); }
private void toxav_OnPeerCodecSettingsChanged(object sender, ToxAvEventArgs.CallStateEventArgs e) { Dispatcher.BeginInvoke(((Action)(() => { if (call == null || call.GetType() == typeof(ToxGroupCall) || e.CallIndex != call.CallIndex) return; if (toxav.GetPeerCodecSettings(e.CallIndex, 0).CallType != ToxAvCallType.Video) { VideoImageRow.Height = new GridLength(0); VideoGridSplitter.IsEnabled = false; VideoChatImage.Source = null; } else if (ViewModel.IsFriendSelected && toxav.GetPeerID(e.CallIndex, 0) == ViewModel.SelectedChatNumber) { VideoImageRow.Height = new GridLength(300); VideoGridSplitter.IsEnabled = true; } }))); }
private void AudioFrameReceivedHandler(object sender, ToxAvEventArgs.AudioFrameEventArgs e) { if (_player == null || _waveProvider == null) return; var bytes = new byte[e.Frame.Data.Length*2]; Buffer.BlockCopy(e.Frame.Data, 0, bytes, 0, e.Frame.Data.Length); _waveProvider.AddSamples(bytes, 0, bytes.Length); }
private void CallRequestReceivedHandler(object sender, ToxAvEventArgs.CallRequestEventArgs e) { // Automatically decline call request if we have an ongoing call. // TODO: Instead of this, tell the user about the situation and let him/her decide if he/she want to hang up the current call and answer the new one! if (_friendInCall != -1) { _toxAv.SendControl(e.FriendNumber, ToxAvCallControl.Cancel); return; } _friendInCall = e.FriendNumber; CallRequestReceived?.Invoke(this, e); }