/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="tox"></param> /// <param name="maxCalls"></param> public ToxAv(ToxHandle tox, int maxCalls) { _tox = tox; _toxAv = ToxAvFunctions.New(tox, maxCalls); if (_toxAv == null || _toxAv.IsInvalid) throw new Exception("Could not create a new instance of toxav."); MaxCalls = maxCalls; }
/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="tox"></param> /// <param name="maxCalls"></param> public ToxAv(ToxHandle tox, int maxCalls) { _tox = tox; _toxAv = ToxAvFunctions.New(tox, maxCalls); if (_toxAv == null || _toxAv.IsInvalid) { throw new Exception("Could not create a new instance of toxav."); } MaxCalls = maxCalls; }
/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="tox"></param> /// <param name="settings"></param> /// <param name="max_calls"></param> public ToxAv(ToxHandle tox, ToxAvCodecSettings settings, int max_calls) { toxav = ToxAvFunctions.New(tox, max_calls); if (toxav == null || toxav.IsInvalid) { throw new Exception("Could not create a new instance of toxav."); } MaxCalls = max_calls; CodecSettings = settings; Invoker = new InvokeDelegate(dummyinvoker); callbacks(); }
/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="tox"></param> internal ToxAv(ToxHandle tox) { _tox = tox; var error = ToxAvErrorNew.Ok; _toxAv = ToxAvFunctions.New(tox, ref error); if (_toxAv == null || _toxAv.IsInvalid || error != ToxAvErrorNew.Ok) { throw new Exception("Could not create a new instance of toxav."); } //register audio/video callbacks early on //due to toxav being silly, we can't start calls without registering those beforehand RegisterAudioVideoCallbacks(); }
/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="toxHandle"></param> public ToxAv([NotNull] ToxHandle toxHandle) { if (toxHandle.IsInvalid) { throw new ArgumentException(nameof(toxHandle)); } this.toxHandle = toxHandle; var error = ToxAvErrorNew.Ok; this.AvHandle = ToxAvFunctions.New(toxHandle, ref error); if (this.AvHandle == null || this.AvHandle.IsInvalid || error != ToxAvErrorNew.Ok) { throw new Exception("Could not create a new instance of toxav."); } //register audio/video callbacks early on //due to toxav being silly, we can't start calls without registering those beforehand this.release = RegisterAudioVideoCallbacks(); Action RegisterAudioVideoCallbacks() { this.OnVideoFrameReceived += StubVideoFrameReceive; this.OnAudioFrameReceived += StubAudioFrameReceive; return(() => { this.OnVideoFrameReceived -= StubVideoFrameReceive; this.OnAudioFrameReceived -= StubAudioFrameReceive; }); void StubVideoFrameReceive(object sender, ToxAvEventArgs.VideoFrameEventArgs e) { } void StubAudioFrameReceive(object sender, ToxAvEventArgs.AudioFrameEventArgs e) { } } }
//dispose pattern as described on msdn for a class that uses a safe handle private void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_cancelEvent != null) { _cancelEvent.Set(); Thread.Sleep(0); if (_canceledEvent != null && !_canceledEvent.WaitOne(0)) { _canceledEvent.WaitOne(2000); } _cancelEvent.Close(); _cancelEvent = null; } if (_canceledEvent != null) { _canceledEvent.Close(); _canceledEvent = null; } } if (_toxAv != null && !_toxAv.IsInvalid && !_toxAv.IsClosed) { _toxAv.Dispose(); _toxAv = null; } _disposed = true; }
public static extern ToxAvError Hangup(ToxAvHandle toxAv, int callIndex);
public static extern ToxAvError Cancel(ToxAvHandle toxAv, int callIndex, int peerId, string reason);
public static extern void RegisterVideoReceiveCallback(ToxAvHandle toxAv, ToxAvDelegates.VideoReceiveCallback callback, IntPtr userData);
public static extern int PrepareVideoFrame(ToxAvHandle toxAv, int callIndex, byte[] dest, int destMax, IntPtr image);
public static extern ToxAvCallState GetCallState(ToxAvHandle toxAv, int callIndex);
public static extern ToxAvError Call(ToxAvHandle toxav, ref int call_index, int friend_number, ref ToxAvCodecSettings settings, int ringing_seconds);
public static extern int CapabilitySupported(ToxAvHandle toxav, int call_index, ToxAvCapabilities capability);
public static extern ToxAvError SendAudio(ToxAvHandle toxAv, int callIndex, byte[] frame, uint frame_size);
public static extern ToxAvError SendAudio(ToxAvHandle toxav, int call_index, byte[] frame, uint frame_size);
public static extern int GetPeerID(ToxAvHandle toxav, int call_index, int peer);
public static extern ToxAvError KillTransmission(ToxAvHandle toxav, int call_index);
public static extern ToxAvError PrepareTransmission(ToxAvHandle toxav, int call_index, uint jbuf_size, uint VAD_treshold, int video_supported);
public static extern ToxAvError StopCall(ToxAvHandle toxav, int call_index);
public static extern ToxAvError StopCall(ToxAvHandle toxAv, int callIndex);
public static extern IntPtr GetTox(ToxAvHandle toxav);
public static extern ToxAvError KillTransmission(ToxAvHandle toxAv, int callIndex);
public static extern int HasActivity(ToxAvHandle toxav, int call_index, short[] pcm, ushort frame_size, float ref_energy);
public static extern int CapabilitySupported(ToxAvHandle toxAv, int callIndex, ToxAvCapabilities capability);
public static extern ToxAvCallState GetCallState(ToxAvHandle toxav, int call_index);
public static extern ToxAvError ChangeSettings(ToxAvHandle toxav, int call_index, ref ToxAvCodecSettings settings);
public static extern int GetPeerCodecSettings(ToxAvHandle toxav, int call_index, int peer, ref ToxAvCodecSettings settings);
public static extern int PrepareVideoFrame(ToxAvHandle toxav, int call_index, byte[] dest, int dest_max, IntPtr image);
public static extern void RegisterCallstateCallback(ToxAvHandle toxav, ToxAvDelegates.CallstateCallback callback, ToxAvCallbackID id, IntPtr userdata);
public static extern int PrepareAudioFrame(ToxAvHandle toxAv, int callIndex, byte[] dest, int destMax, short[] frame, int frameSize);
public static extern void RegisterVideoReceiveCallback(ToxAvHandle toxav, ToxAvDelegates.VideoReceiveCallback callback, IntPtr userdata);
public static extern ToxAvError Call(ToxAvHandle toxAv, ref int callIndex, int friend_number, ref ToxAvCodecSettings settings, int ringingSeconds);
public static extern ToxAvError Reject(ToxAvHandle toxav, int call_index, string reason);
public static extern ToxAvError Reject(ToxAvHandle toxAv, int callIndex, string reason);
public static extern ToxAvError Hangup(ToxAvHandle toxav, int call_index);
public static extern ToxAvError ChangeSettings(ToxAvHandle toxAv, int callIndex, ref ToxAvCodecSettings settings);
/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="tox"></param> /// <param name="settings"></param> /// <param name="max_calls"></param> public ToxAv(ToxHandle tox, ToxAvCodecSettings settings, int max_calls) { toxav = ToxAvFunctions.New(tox, max_calls); if (toxav == null || toxav.IsInvalid) throw new Exception("Could not create a new instance of toxav."); MaxCalls = max_calls; CodecSettings = settings; Invoker = new InvokeDelegate(dummyinvoker); callbacks(); }
public static extern ToxAvError PrepareTransmission(ToxAvHandle toxAv, int callIndex, int videoSupported);
public static extern uint DoInterval(ToxAvHandle toxAv);
public static extern ToxAvError SendVideo(ToxAvHandle toxAv, int callIndex, byte[] frame, uint frameSize);
public static extern int GetActiveCount(ToxAvHandle toxav);
public static extern int GetPeerID(ToxAvHandle toxAv, int callIndex, int peer);
public static extern int PrepareAudioFrame(ToxAvHandle toxav, int call_index, byte[] dest, int dest_max, ushort[] frame, int frame_size);
public static extern IntPtr GetTox(ToxAvHandle toxAv);
public static extern int SetVadTreshold(ToxAvHandle toxav, int callIndex, uint treshold);
public static extern int GetPeerCodecSettings(ToxAvHandle toxAv, int callIndex, int peer, ref ToxAvCodecSettings settings);
public static extern ToxAvError Cancel(ToxAvHandle toxav, int call_index, int peer_id, string reason);
public static extern void Do(ToxAvHandle toxAv);
internal static extern void RegisterAudioReceiveFrameCallback(ToxAvHandle toxAv, ToxAvDelegates.AudioReceiveFrameCallback callback, IntPtr userData);
public static extern void RegisterCallstateCallback(ToxAvHandle toxAv, ToxAvDelegates.CallstateCallback callback, ToxAvCallbackID id, IntPtr userData);
public static extern int HasActivity(ToxAvHandle toxAv, int callIndex, short[] pcm, ushort frameSize, float refEnergy);