コード例 #1
0
 /// <summary>
 /// Reset a buffer header. Resets all header variables to default values.
 /// </summary>
 internal void Reset()
 {
     if (this.Ptr != null && (IntPtr)this.Ptr != IntPtr.Zero)
     {
         MMALBuffer.mmal_buffer_header_reset(this.Ptr);
     }
 }
コード例 #2
0
 /// <summary>
 /// Acquire a buffer header. Acquiring a buffer header increases a reference counter on it and makes
 /// sure that the buffer header won't be recycled until all the references to it are gone.
 /// </summary>
 internal void Acquire()
 {
     if (this.Ptr != null && (IntPtr)this.Ptr != IntPtr.Zero)
     {
         MMALBuffer.mmal_buffer_header_acquire(this.Ptr);
     }
 }
コード例 #3
0
 /// <summary>
 /// Acquire a buffer header. Acquiring a buffer header increases a reference counter on it and makes
 /// sure that the buffer header won't be recycled until all the references to it are gone.
 /// </summary>
 internal void Acquire()
 {
     if (this.CheckState())
     {
         MMALBuffer.mmal_buffer_header_acquire(this.Ptr);
     }
 }
コード例 #4
0
 /// <summary>
 /// Reset a buffer header. Resets all header variables to default values.
 /// </summary>
 internal void Reset()
 {
     if (this.CheckState())
     {
         MMALBuffer.mmal_buffer_header_reset(this.Ptr);
     }
 }
コード例 #5
0
        /// <summary>
        /// Gathers all data in this payload and returns as a byte array.
        /// </summary>
        /// <returns>A byte array containing the image frame.</returns>
        internal byte[] GetBufferData()
        {
            if (MMALCameraConfig.Debug)
            {
                MMALLog.Logger.Debug("Getting data from buffer");
            }

            MMALCheck(MMALBuffer.mmal_buffer_header_mem_lock(this.Ptr), "Unable to lock buffer header.");

            try
            {
                var ps     = this.Ptr->data + this.Offset;
                var buffer = new byte[(int)this.Ptr->Length];
                Marshal.Copy((IntPtr)ps, buffer, 0, buffer.Length);
                MMALBuffer.mmal_buffer_header_mem_unlock(this.Ptr);

                return(buffer);
            }
            catch
            {
                // If something goes wrong, unlock the header.
                MMALBuffer.mmal_buffer_header_mem_unlock(this.Ptr);
                MMALLog.Logger.Warn("Unable to handle data. Returning null.");
                return(null);
            }
        }
コード例 #6
0
 /// <summary>
 /// Release a buffer header. Releasing a buffer header will decrease its reference counter and when no more references are left,
 /// the buffer header will be recycled by calling its 'release' callback function.
 /// </summary>
 internal void Release()
 {
     if (this.Ptr != null && (IntPtr)this.Ptr != IntPtr.Zero)
     {
         MMALBuffer.mmal_buffer_header_release(this.Ptr);
     }
     this.Dispose();
 }
コード例 #7
0
        /// <summary>
        /// Release a buffer header. Releasing a buffer header will decrease its reference counter and when no more references are left,
        /// the buffer header will be recycled by calling its 'release' callback function.
        /// </summary>
        internal void Release()
        {
            if (this.CheckState())
            {
                if (MMALCameraConfig.Debug)
                {
                    MMALLog.Logger.Debug("Releasing buffer.");
                }

                MMALBuffer.mmal_buffer_header_release(this.Ptr);
            }
            else
            {
                MMALLog.Logger.Warn("Input buffer null, could not release.");
            }

            this.Dispose();
        }
コード例 #8
0
        /// <summary>
        /// Gathers all data in this payload and returns as a byte array
        /// </summary>
        /// <returns></returns>
        internal byte[] GetBufferData()
        {
            MMALCheck(MMALBuffer.mmal_buffer_header_mem_lock(this.Ptr), "Unable to lock buffer header.");

            try
            {
                var ps     = this.Ptr->data + this.Offset;
                var buffer = Array.CreateInstance(typeof(byte), (int)this.Ptr->Length) as byte[];
                Marshal.Copy((IntPtr)ps, buffer, 0, buffer.Length);
                MMALBuffer.mmal_buffer_header_mem_unlock(this.Ptr);

                return(buffer);
            }
            catch
            {
                //If something goes wrong, unlock the header.
                MMALBuffer.mmal_buffer_header_mem_unlock(this.Ptr);
                MMALLog.Logger.Warn("Unable to handle data. Returning null.");
                return(null);
            }
        }
コード例 #9
0
        internal void ReadIntoBuffer(byte[] source, bool eof)
        {
            MMALCheck(MMALBuffer.mmal_buffer_header_mem_lock(this.Ptr), "Unable to lock buffer header.");
            var ptrAlloc = Marshal.AllocHGlobal(source.Length);

            this.Ptr->data      = (byte *)ptrAlloc;
            this.Ptr->allocSize = (uint)source.Length;
            this.Ptr->length    = (uint)source.Length;

            if (eof)
            {
                this.Ptr->flags = (uint)MMALBufferProperties.MMAL_BUFFER_HEADER_FLAG_EOS;
            }

            try
            {
                fixed(byte *pSource = source)
                {
                    var ps = pSource;

                    byte *pt = (byte *)ptrAlloc;

                    for (int i = 0; i < source.Length; i++)
                    {
                        *pt = *ps;
                        pt++;
                        ps++;
                    }
                }

                MMALBuffer.mmal_buffer_header_mem_unlock(this.Ptr);
            }
            catch
            {
                //If something goes wrong, unlock the header.
                MMALBuffer.mmal_buffer_header_mem_unlock(this.Ptr);
                Marshal.FreeHGlobal(ptrAlloc);
                MMALLog.Logger.Warn("Unable to write data to buffer.");
            }
        }
コード例 #10
0
 /// <summary>
 /// Reset a buffer header. Resets all header variables to default values.
 /// </summary>
 internal void Reset()
 {
     MMALBuffer.mmal_buffer_header_reset(this.Ptr);
 }
コード例 #11
0
 /// <summary>
 /// Release a buffer header. Releasing a buffer header will decrease its reference counter and when no more references are left,
 /// the buffer header will be recycled by calling its 'release' callback function.
 /// </summary>
 internal void Release()
 {
     MMALBuffer.mmal_buffer_header_release(this.Ptr);
     this.Dispose();
 }
コード例 #12
0
 /// <summary>
 /// Acquire a buffer header. Acquiring a buffer header increases a reference counter on it and makes
 /// sure that the buffer header won't be recycled until all the references to it are gone.
 /// </summary>
 internal void Acquire()
 {
     MMALBuffer.mmal_buffer_header_acquire(this.Ptr);
 }