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