コード例 #1
0
ファイル: MediaCaptureInternal.cs プロジェクト: yusharth/psi
        /// <summary>
        /// Begin streaming buffers.
        /// </summary>
        public unsafe void StreamBuffers()
        {
            if (LinuxVideoInterop.ReqBufs(this.handle, NumberOfDriverBuffers, LinuxVideoInterop.Memory.MemoryMapping) != NumberOfDriverBuffers)
            {
                throw new IOException("Could not allocate buffers.");
            }

            try
            {
                // enque and memory map all the buffers
                for (var i = 0u; i < NumberOfDriverBuffers; i++)
                {
                    var buf = LinuxVideoInterop.QueryBuf(this.handle, i);
                    LinuxVideoInterop.EnqueBuffer(this.handle, buf);
                    this.buffers[i] = new BufferInfo()
                    {
                        Initialized = true,
                        Start       = LinuxVideoInterop.MemoryMap(this.handle, buf),
                        Buffer      = buf,
                    };
                }

                LinuxVideoInterop.StreamOn(this.handle);
                this.background = new Thread(new ThreadStart(this.ProcessFrames))
                {
                    IsBackground = true
                };
                this.isStopping = false;
                this.background.Start();
            }
            catch
            {
                for (var i = 0u; i < NumberOfDriverBuffers; i++)
                {
                    var buf = this.buffers[i];
                    if (buf.Initialized)
                    {
                        LinuxVideoInterop.MemoryUnmap(buf.Buffer);
                    }
                }

                throw;
            }
        }
コード例 #2
0
ファイル: MediaCaptureInternal.cs プロジェクト: yusharth/psi
 /// <summary>
 /// Dispose image frame (re-enqueuing underlying driver buffer).
 /// </summary>
 public void Dispose()
 {
     LinuxVideoInterop.EnqueBuffer(this.handle, this.buffer);
 }