예제 #1
0
파일: ToxAv.cs 프로젝트: hexafluoride/Detox
        /// <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="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();
        }
예제 #3
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();
        }
예제 #4
0
파일: ToxAv.cs 프로젝트: Tornjk/SharpTox
        /// <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)
                {
                }
            }
        }