Esempio n. 1
0
        internal AudioStream open(int samplerate, AudioFormat format, ChannelsLayout channelslayout, AudioStream.FrameReadyFunction frameready)
        {
            this._framedelegate = new AudioStream.FrameReadyFunction(frameready);
            var error = new StringBuilder(1024);

            var audstream = Imports._player_openaudio(Player._player, info.ind, samplerate, format, channelslayout, Marshal.GetFunctionPointerForDelegate(frameready), error);

            BBRException.CheckError(error, $"open_audio");

            return(new AudioStream(this, audstream));
        }
Esempio n. 2
0
        internal VideoStream open(FrameReadyFunction frameready)
        {
            this._framedelegate = new VideoStream.FrameReadyFunction(frameready);
            var error = new StringBuilder(1024);

            var vidstream = Imports._player_openvideo(Player._player, info.ind, Marshal.GetFunctionPointerForDelegate(this._framedelegate), error);

            BBRException.CheckError(error, $"open_video");

            return(new VideoStream(this, vidstream));
        }
Esempio n. 3
0
        private void Initialize(string filename)
        {
            Interop.staticinit.Initialize2();

            if (!File.Exists(filename))
            {
                throw new FileNotFoundException(filename);
            }
            var error = new StringBuilder(1024);

            _player = Imports.openplayer(filename, error);

            BBRException.CheckError(error, $"error opening {filename}");

            Imports.player_set_callbacks(this._player,
                                         this._eosdelegate != null ? Marshal.GetFunctionPointerForDelegate(this._eosdelegate) : IntPtr.Zero,
                                         this._flusheddelegate != null ? Marshal.GetFunctionPointerForDelegate(this._flusheddelegate) : IntPtr.Zero);

            this.VideoStreams = Enumerable.Range(0, get_videostreamcount()).Select(_n => new VideoStream(this, _n)).ToArray();
            this.AudioStreams = Enumerable.Range(0, get_audiostreamcount()).Select(_n => new AudioStream(this, _n)).ToArray();
        }
Esempio n. 4
0
        public VideoFrame AllocateFrame(FrameAllocateFunction allocfunc, FrameLockFunction lockfunc, FrameUnlockFunction unlockfunc)
        {
            var error = new StringBuilder(1024);

            var _allocfunc  = allocfunc != null ? new FrameAllocateFunction(allocfunc) : null;
            var _lockfunc   = lockfunc != null ? new FrameLockFunction(lockfunc) : null;
            var _unlockfunc = allocfunc != null ? new FrameUnlockFunction(unlockfunc) : null;

            var func1 = _allocfunc != null?Marshal.GetFunctionPointerForDelegate(_allocfunc) : IntPtr.Zero;

            var func2 = _lockfunc != null?Marshal.GetFunctionPointerForDelegate(_lockfunc) : IntPtr.Zero;

            var func3 = _unlockfunc != null?Marshal.GetFunctionPointerForDelegate(_unlockfunc) : IntPtr.Zero;

            var frame = Imports._player_vid_allocframe(stream, func1, func2, func3);

            BBRException.CheckError(error, $"open_video");
            var result = new VideoFrame(this, frame)
            {
                _allocfunc = _allocfunc, _lockfunc = _lockfunc, _unlockfunc = _unlockfunc
            };

            return(result);
        }