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