public CallInfo(int friendNumber, bool enableRecording, bool enablePlayback, bool enableLocalVideo, bool enableFriendVideo) { this.FriendNumber = friendNumber; this.RecordingDevice = new RecordingDevice(enableRecording); this.PlaybackDevice = new PlaybackDevice(enablePlayback); this.VideoDevice = new VideoDevice(enableLocalVideo); this.friendCallState = ToxAvFriendCallState.Finished; }
public bool EnableLocalVideo(bool enableLocalVideo) { if (this.callInfo != null) { if (!enableLocalVideo) { callInfo.EnableVideo(false); if (this.callInfo.VideoDevice.IsRecording) { this.callInfo.VideoDevice.StopRecording(); } } ToxAvFriendCallState friendCallState = this.callInfo.FriendCallState; if (enableLocalVideo) { friendCallState |= ToxAvFriendCallState.ReceivingVideo; } else { friendCallState &= ~ToxAvFriendCallState.ReceivingVideo; } this.callInfo.FriendCallState = friendCallState; if (enableLocalVideo) { callInfo.EnableVideo(true); if (!this.callInfo.VideoDevice.IsRecording) { this.callInfo.VideoDevice.StartRecording(); } } return(true); } else { return(this.RestartVideoMonitor(enableLocalVideo)); } }
public bool EnableRecording(bool enableRecording) { if (this.callInfo != null) { if (!enableRecording) { callInfo.EnableRecording(false); if (this.callInfo.RecordingDevice.IsRecording) { this.callInfo.RecordingDevice.StopRecording(); } } ToxAvFriendCallState friendCallState = this.callInfo.FriendCallState; if (enableRecording) { friendCallState |= ToxAvFriendCallState.ReceivingAudio; } else { friendCallState &= ~ToxAvFriendCallState.ReceivingAudio; } this.callInfo.FriendCallState = friendCallState; if (enableRecording) { callInfo.EnableRecording(true); if (!this.callInfo.RecordingDevice.IsRecording) { this.callInfo.RecordingDevice.StartRecording(); } } return(true); } else { return(this.RestartRecordingMonitor(enableRecording)); } }
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 CallStateEventArgs(uint friendNumber, ToxAvFriendCallState state) : base(friendNumber) { this.State = state; }
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); }