/// <summary> /// Writes asynchronously data to 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 contain the data to write.</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> /// <returns>A task that represents the asynchronous write operation. The task's result contain the number of items written.</returns> public static Task <int> WriteAsync <T>(this IMFByteStream byteStream, T[] buffer, int offset, int count) 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.WriteAsync <T>(byteStream, arraySegment)); }
/// <summary> /// Writes asynchronously data to a byte stream /// </summary> /// <param name="byteStream">A valid IMFByteStream instance.</param> /// <param name="buffer">A byte array that contain the data to write.</param> /// <param name="offset">An offset from the start of the buffer at which begin the data to write to the byte stream.</param> /// <param name="count">The maximum number of bytes to be written to the byte stream.</param> /// <returns>A task that represents the asynchronous write operation. The task's result contain the number of bytes written.</returns> public static Task <int> WriteAsync(this IMFByteStream byteStream, byte[] buffer, int offset, int count) { return(IMFByteStreamExtensions.WriteAsync <byte>(byteStream, buffer, offset, count)); }