/// <summary>
        /// Reads data from a byte stream
        /// </summary>
        /// <typeparam name="T">A value type.</typeparam>
        /// <param name="byteStream">A valid IMFByteStream instance.</param>
        /// <param name="buffer">An array of T that receives the data.</param>
        /// <param name="offset">An index offset in buffer at which to begin storing the data read from the byte stream.</param>
        /// <param name="count">The maximum number of items to be read from the byte stream.</param>
        /// <param name="itemsRead">The total number of values read into the buffer.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        public static HResult Read <T>(this IMFByteStream byteStream, T[] buffer, int offset, int count, out int itemsRead) where T : struct
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("value");
            }

            if (offset > buffer.Length)
            {
                throw new ArgumentNullException("offset");
            }

            if ((offset + count) > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            ArraySegment <T> arraySegment = new ArraySegment <T>(buffer, offset, count);

            return(IMFByteStreamExtensions.Read <T>(byteStream, arraySegment, out itemsRead));
        }
 /// <summary>
 /// Reads data from a byte stream
 /// </summary>
 /// <param name="byteStream">A valid IMFByteStream instance.</param>
 /// <param name="buffer">A byte array that receives the data.</param>
 /// <param name="offset">An offset from the start of the buffer at which to begin storing the data read from the byte stream.</param>
 /// <param name="count">The maximum number of bytes to be read from the byte stream.</param>
 /// <param name="bytesRead">The total number of bytes read into the buffer.</param>
 /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
 public static HResult Read(this IMFByteStream byteStream, byte[] buffer, int offset, int count, out int bytesRead)
 {
     return(IMFByteStreamExtensions.Read <byte>(byteStream, buffer, offset, count, out bytesRead));
 }