public bool SendControl(int friendNumber, ToxAvCallControl control, out ToxAvErrorCallControl error) { ThrowIfDisposed(); error = ToxAvErrorCallControl.Ok; return(ToxAvFunctions.CallControl(_toxAv, ToxTools.Map(friendNumber), control, ref error)); }
public bool SendControl(uint friendNumber, ToxAvCallControl control, out ToxAvErrorCallControl error) { ThrowIfDisposed(); error = ToxAvErrorCallControl.Ok; return(ToxAvFunctions.CallControl(AvHandle, friendNumber, control, ref error)); }
public bool Hangup(int friendNumber) { // stop ringing this.StopRingingSound(); ToxAvErrorCallControl error = ToxAvErrorCallControl.Ok; if (!this.toxAv.SendControl(friendNumber, ToxAvCallControl.Cancel, out error)) { Logger.Log(LogLevel.Error, "Could not cancel a call for friend: " + error); return(false); } bool enableRecording = true; bool enablePlayback = true; bool enableVideo = true; if (this.callInfo != null) { enableRecording = this.callInfo.RecordingDevice.IsEnabled; enablePlayback = this.callInfo.PlaybackDevice.IsEnabled; enableVideo = this.callInfo.VideoDevice.IsEnabled; this.callInfo.FriendCallState = ToxAvFriendCallState.Finished; this.callInfo.Dispose(); this.callInfo = null; } // enable local audio/video monitors this.RestartRecordingMonitor(enableRecording); this.RestartPlaybackMonitor(enablePlayback); this.RestartVideoMonitor(enableVideo); return(true); }
public void RelayError(ToxAvErrorCallControl error) { if (error != ToxAvErrorCallControl.Ok) { Debug.WriteLine("An unexpected error occurred when sending a call control: " + error); } }
public bool EnableFriendVideo(bool enableFriendVideo) { if (this.callInfo != null) { ToxAvCallControl videoControl = enableFriendVideo ? ToxAvCallControl.ShowVideo : ToxAvCallControl.HideVideo; ToxAvErrorCallControl videoError = ToxAvErrorCallControl.Ok; if (!this.toxAv.SendControl(this.callInfo.FriendNumber, videoControl, out videoError)) { Logger.Log(LogLevel.Error, "Could not change video receiving: " + videoError); } return(true); } else { return(false); } }
public bool EnablePlayback(bool enablePlayback) { if (this.callInfo != null) { if (!enablePlayback) { this.callInfo.EnablePlayback(false); } ToxAvCallControl audioControl = enablePlayback ? ToxAvCallControl.UnmuteAudio : ToxAvCallControl.MuteAudio; ToxAvErrorCallControl audioError = ToxAvErrorCallControl.Ok; if (!this.toxAv.SendControl(this.callInfo.FriendNumber, audioControl, out audioError)) { Logger.Log(LogLevel.Error, "Could not change audio receiving: " + audioError); } ToxAvFriendCallState friendCallState = this.callInfo.FriendCallState; if (enablePlayback) { friendCallState |= ToxAvFriendCallState.SendingAudio; } else { friendCallState &= ~ToxAvFriendCallState.SendingAudio; } this.callInfo.FriendCallState = friendCallState; if (enablePlayback) { this.callInfo.EnablePlayback(true); } return(true); } else { return(this.RestartPlaybackMonitor(enablePlayback)); } }
public void Kill() { // stop ringing this.StopRingingSound(); if (this.callInfo != null) { ToxAvErrorCallControl error = ToxAvErrorCallControl.Ok; if (!this.toxAv.SendControl(this.callInfo.FriendNumber, ToxAvCallControl.Cancel, out error)) { Logger.Log(LogLevel.Error, "Could not cancel a call for friend: " + error); } this.callInfo.FriendCallState = ToxAvFriendCallState.Finished; this.callInfo.Dispose(); this.callInfo = null; } this.RestartRecordingMonitor(false); this.RestartPlaybackMonitor(false); this.RestartRingingDevice(false); this.RestartVideoMonitor(false); }
internal static extern bool CallControl(ToxAvHandle toxAv, uint friendNumber, ToxAvCallControl control, ref ToxAvErrorCallControl error);
public static extern Boolean CallControl(ToxAvHandle toxAv, UInt32 friendNumber, ToxAvCallControl control, ref ToxAvErrorCallControl error);
public void RelayError(ToxAvErrorCallControl error) { if (error != ToxAvErrorCallControl.Ok) Debug.WriteLine("An unexpected error occurred when sending a call control: " + error); }
public bool Answer(int friendNumber, bool enableRecording, bool enablePlayback, bool enableLocalVideo, bool enableFriendVideo) { // stop ringing this.StopRingingSound(); if (this.callInfo != null) { Logger.Log(LogLevel.Warning, "Tried to answer a call but there is already one in progress"); return(false); } ToxAvErrorAnswer error = ToxAvErrorAnswer.Ok; if (!this.toxAv.Answer(friendNumber, DefaultAudioBitrate, DefaultVideoBitrate, out error)) { Logger.Log(LogLevel.Error, "Could not answer call for friend: " + error); return(false); } ToxAvCallControl audioControl = enablePlayback ? ToxAvCallControl.UnmuteAudio : ToxAvCallControl.MuteAudio; ToxAvErrorCallControl audioError = ToxAvErrorCallControl.Ok; if (!this.toxAv.SendControl(friendNumber, audioControl, out audioError)) { Logger.Log(LogLevel.Error, "Could not change audio receiving: " + audioError); } ToxAvCallControl videoControl = enableFriendVideo ? ToxAvCallControl.ShowVideo : ToxAvCallControl.HideVideo; ToxAvErrorCallControl videoError = ToxAvErrorCallControl.Ok; if (!this.toxAv.SendControl(friendNumber, videoControl, out videoError)) { Logger.Log(LogLevel.Error, "Could not change video receiving: " + videoError); } // disable local audio/video monitors this.RestartRecordingMonitor(false); this.RestartPlaybackMonitor(false); this.RestartVideoMonitor(false); ToxAvFriendCallState friendCallState = ToxAvFriendCallState.Paused; if (enableRecording) { friendCallState |= ToxAvFriendCallState.ReceivingAudio; } if (enablePlayback) { friendCallState |= ToxAvFriendCallState.SendingAudio; } if (enableLocalVideo) { friendCallState |= ToxAvFriendCallState.ReceivingVideo; } if (enableFriendVideo) { friendCallState |= ToxAvFriendCallState.SendingVideo; } this.callInfo = new CallInfo(friendNumber, enableRecording, enablePlayback, enableLocalVideo, enableFriendVideo); this.callInfo.FriendCallState = friendCallState; this.callInfo.RecordingDevice.OnMicVolumeChanged += this.OnAudioDeviceMicVolumeChanged; this.callInfo.RecordingDevice.OnMicDataAvailable += this.OnAudioDeviceMicDataAvailable; this.callInfo.VideoDevice.OnFrameAvailable += this.OnVideoDeviceFrameAvailable; var audioBitrateError = ToxAvErrorSetBitrate.Ok; bool audioBitrateSet = this.toxAv.SetAudioBitrate(friendNumber, DefaultAudioBitrate, out audioBitrateError); if (!audioBitrateSet) { Logger.Log(LogLevel.Error, string.Format("Could not set audio bitrate to {0}, error: {1}", DefaultAudioBitrate, audioBitrateError)); } var videoBitrateError = ToxAvErrorSetBitrate.Ok; bool videoBitrateSet = this.toxAv.SetVideoBitrate(friendNumber, DefaultVideoBitrate, out videoBitrateError); if (!videoBitrateSet) { Logger.Log(LogLevel.Error, string.Format("Could not set video bitrate to {0}, error: {1}", DefaultVideoBitrate, videoBitrateError)); } if (audioBitrateSet) { this.callInfo.AudioBitrate = DefaultAudioBitrate; } if (videoBitrateSet) { this.callInfo.VideoBitrate = DefaultVideoBitrate; } if (enableRecording) { this.callInfo.RecordingDevice.StartRecording(); } if (enableLocalVideo) { this.callInfo.VideoDevice.StartRecording(); } return(true); }