Represents a handle for an instance of toxav.
Inheritance: SharpTox.Core.SafeHandleZeroOrMinusOneIsInvalid
Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        /// <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();
        }
Exemplo n.º 4
0
        /// <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();
        }
Exemplo n.º 5
0
        /// <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)
                {
                }
            }
        }
Exemplo n.º 6
0
        //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;
        }
Exemplo n.º 7
0
 public static extern ToxAvError Hangup(ToxAvHandle toxAv, int callIndex);
Exemplo n.º 8
0
 public static extern ToxAvError Cancel(ToxAvHandle toxAv, int callIndex, int peerId, string reason);
Exemplo n.º 9
0
 public static extern void RegisterVideoReceiveCallback(ToxAvHandle toxAv, ToxAvDelegates.VideoReceiveCallback callback, IntPtr userData);
Exemplo n.º 10
0
 public static extern int PrepareVideoFrame(ToxAvHandle toxAv, int callIndex, byte[] dest, int destMax, IntPtr image);
Exemplo n.º 11
0
 public static extern ToxAvCallState GetCallState(ToxAvHandle toxAv, int callIndex);
Exemplo n.º 12
0
 public static extern ToxAvError Call(ToxAvHandle toxav, ref int call_index, int friend_number, ref ToxAvCodecSettings settings, int ringing_seconds);
Exemplo n.º 13
0
 public static extern int CapabilitySupported(ToxAvHandle toxav, int call_index, ToxAvCapabilities capability);
Exemplo n.º 14
0
 public static extern ToxAvError SendAudio(ToxAvHandle toxAv, int callIndex, byte[] frame, uint frame_size);
Exemplo n.º 15
0
 public static extern ToxAvError SendAudio(ToxAvHandle toxav, int call_index, byte[] frame, uint frame_size);
Exemplo n.º 16
0
 public static extern int GetPeerID(ToxAvHandle toxav, int call_index, int peer);
Exemplo n.º 17
0
 public static extern ToxAvError KillTransmission(ToxAvHandle toxav, int call_index);
Exemplo n.º 18
0
 public static extern ToxAvError PrepareTransmission(ToxAvHandle toxav, int call_index, uint jbuf_size, uint VAD_treshold, int video_supported);
Exemplo n.º 19
0
 public static extern ToxAvError StopCall(ToxAvHandle toxav, int call_index);
Exemplo n.º 20
0
 public static extern ToxAvError StopCall(ToxAvHandle toxAv, int callIndex);
Exemplo n.º 21
0
 public static extern IntPtr GetTox(ToxAvHandle toxav);
Exemplo n.º 22
0
 public static extern ToxAvError KillTransmission(ToxAvHandle toxAv, int callIndex);
Exemplo n.º 23
0
 public static extern int HasActivity(ToxAvHandle toxav, int call_index, short[] pcm, ushort frame_size, float ref_energy);
Exemplo n.º 24
0
 public static extern int CapabilitySupported(ToxAvHandle toxAv, int callIndex, ToxAvCapabilities capability);
Exemplo n.º 25
0
 public static extern ToxAvCallState GetCallState(ToxAvHandle toxav, int call_index);
Exemplo n.º 26
0
 public static extern ToxAvError ChangeSettings(ToxAvHandle toxav, int call_index, ref ToxAvCodecSettings settings);
Exemplo n.º 27
0
 public static extern int GetPeerCodecSettings(ToxAvHandle toxav, int call_index, int peer, ref ToxAvCodecSettings settings);
Exemplo n.º 28
0
 public static extern int PrepareVideoFrame(ToxAvHandle toxav, int call_index, byte[] dest, int dest_max, IntPtr image);
Exemplo n.º 29
0
 public static extern void RegisterCallstateCallback(ToxAvHandle toxav, ToxAvDelegates.CallstateCallback callback, ToxAvCallbackID id, IntPtr userdata);
Exemplo n.º 30
0
 public static extern int PrepareAudioFrame(ToxAvHandle toxAv, int callIndex, byte[] dest, int destMax, short[] frame, int frameSize);
Exemplo n.º 31
0
 public static extern void RegisterVideoReceiveCallback(ToxAvHandle toxav, ToxAvDelegates.VideoReceiveCallback callback, IntPtr userdata);
Exemplo n.º 32
0
 public static extern ToxAvError Call(ToxAvHandle toxAv, ref int callIndex, int friend_number, ref ToxAvCodecSettings settings, int ringingSeconds);
Exemplo n.º 33
0
 public static extern ToxAvError Reject(ToxAvHandle toxav, int call_index, string reason);
Exemplo n.º 34
0
 public static extern ToxAvError Reject(ToxAvHandle toxAv, int callIndex, string reason);
Exemplo n.º 35
0
 public static extern ToxAvError Hangup(ToxAvHandle toxav, int call_index);
Exemplo n.º 36
0
 public static extern ToxAvError ChangeSettings(ToxAvHandle toxAv, int callIndex, ref ToxAvCodecSettings settings);
Exemplo n.º 37
0
        /// <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();
        }
Exemplo n.º 38
0
 public static extern ToxAvError PrepareTransmission(ToxAvHandle toxAv, int callIndex, int videoSupported);
Exemplo n.º 39
0
 public static extern uint DoInterval(ToxAvHandle toxAv);
Exemplo n.º 40
0
 public static extern ToxAvError SendVideo(ToxAvHandle toxAv, int callIndex, byte[] frame, uint frameSize);
Exemplo n.º 41
0
 public static extern int GetActiveCount(ToxAvHandle toxav);
Exemplo n.º 42
0
 public static extern int GetPeerID(ToxAvHandle toxAv, int callIndex, int peer);
Exemplo n.º 43
0
 public static extern int PrepareAudioFrame(ToxAvHandle toxav, int call_index, byte[] dest, int dest_max, ushort[] frame, int frame_size);
Exemplo n.º 44
0
 public static extern IntPtr GetTox(ToxAvHandle toxAv);
Exemplo n.º 45
0
 public static extern int SetVadTreshold(ToxAvHandle toxav, int callIndex, uint treshold);
Exemplo n.º 46
0
 public static extern int GetPeerCodecSettings(ToxAvHandle toxAv, int callIndex, int peer, ref ToxAvCodecSettings settings);
Exemplo n.º 47
0
 public static extern ToxAvError Cancel(ToxAvHandle toxav, int call_index, int peer_id, string reason);
Exemplo n.º 48
0
 public static extern void Do(ToxAvHandle toxAv);
Exemplo n.º 49
0
 internal static extern void RegisterAudioReceiveFrameCallback(ToxAvHandle toxAv, ToxAvDelegates.AudioReceiveFrameCallback callback, IntPtr userData);
Exemplo n.º 50
0
 public static extern void RegisterCallstateCallback(ToxAvHandle toxAv, ToxAvDelegates.CallstateCallback callback, ToxAvCallbackID id, IntPtr userData);
Exemplo n.º 51
0
 public static extern int HasActivity(ToxAvHandle toxAv, int callIndex, short[] pcm, ushort frameSize, float refEnergy);