Exemplo n.º 1
0
        /// <summary>
        /// <p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p> Begins an asynchronous read operation from the stream. </p>
        /// </summary>
        /// <param name="bRef"><dd> <p> Pointer to a buffer that receives the data. The caller must allocate the buffer. </p> </dd></param>
        /// <param name="cb"><dd> <p> Size of the buffer in bytes. </p> </dd></param>
        /// <param name="callbackRef"><dd> <p> Pointer to the <strong><see cref="SharpDX.MediaFoundation.IAsyncCallback"/></strong> interface of a callback object. The caller must implement this interface. </p> </dd></param>
        /// <param name="context"><dd> <p> Pointer to the <strong><see cref="SharpDX.ComObject"/></strong> interface of a state object, defined by the caller. This parameter can be <strong><c>null</c></strong>. You can use this object to hold state information. The object is returned to the caller when the callback is invoked. </p> </dd></param>
        /// <returns><p>If this method succeeds, it returns <strong><see cref="SharpDX.Result.Ok"/></strong>. Otherwise, it returns an <strong><see cref="SharpDX.Result"/></strong> error code.</p></returns>
        /// <remarks>
        /// <p> When all of the data has been read into the buffer, the callback object's <strong><see cref="SharpDX.MediaFoundation.IAsyncCallback.Invoke"/></strong> method is called. At that point, the application should call <strong><see cref="SharpDX.MediaFoundation.IByteStream.EndRead"/></strong> to complete the asynchronous request. </p><p> Do not read from, write to, free, or reallocate the buffer while an asynchronous read is pending. </p><p>This interface is available on the following platforms if the Windows Media Format 11 SDK redistributable components are installed:</p><ul> <li>Windows?XP with Service Pack?2 (SP2) and later.</li> <li>Windows?XP Media Center Edition?2005 with KB900325 (Windows?XP Media Center Edition?2005) and KB925766 (October 2006 Update Rollup for Windows?XP Media Center Edition) installed.</li> </ul>
        /// </remarks>
        /// <msdn-id>ms704810</msdn-id>
        /// <unmanaged>HRESULT IMFByteStream::BeginRead([Out, Buffer] unsigned char* pb,[In] unsigned int cb,[In] IMFAsyncCallback* pCallback,[In] IUnknown* punkState)</unmanaged>
        /// <unmanaged-short>IMFByteStream::BeginRead</unmanaged-short>
        public unsafe void BeginRead(byte[] bRef, int offset, int count, SharpDX.MediaFoundation.IAsyncCallback callbackRef, object context)
        {
            var handle = GCHandle.Alloc(context);

            try
            {
                fixed(void *ptr = &bRef[offset])
                BeginRead__((System.IntPtr)ptr, count, /*TODO callbackRef*/ IntPtr.Zero, GCHandle.ToIntPtr(handle));
            } finally
            {
                if (handle.IsAllocated)
                {
                    handle.Free();
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// <p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p> Begins an asynchronous write operation to the stream. </p>
 /// </summary>
 /// <param name="bRef"><dd> <p> Pointer to a buffer containing the data to write. </p> </dd></param>
 /// <param name="offset">The offset within the buffer to begin writing at.</param>
 /// <param name="count"><dd> <p> Size of the buffer in bytes. </p> </dd></param>
 /// <param name="callbackRef"><dd> <p> Pointer to the <strong><see cref="SharpDX.MediaFoundation.IAsyncCallback"/></strong> interface of a callback object. The caller must implement this interface. </p> </dd></param>
 /// <param name="context"><dd> <p> Pointer to the <strong><see cref="SharpDX.ComObject"/></strong> interface of a state object, defined by the caller. This parameter can be <strong><c>null</c></strong>. You can use this object to hold state information. The object is returned to the caller when the callback is invoked. </p> </dd></param>
 /// <returns><p>If this method succeeds, it returns <strong><see cref="SharpDX.Result.Ok"/></strong>. Otherwise, it returns an <strong><see cref="SharpDX.Result"/></strong> error code.</p></returns>
 /// <remarks>
 /// <p> When all of the data has been written to the stream, the callback object's <strong><see cref="SharpDX.MediaFoundation.IAsyncCallback.Invoke"/></strong> method is called. At that point, the application should call <strong><see cref="SharpDX.MediaFoundation.IByteStream.EndWrite"/></strong> to complete the asynchronous request. </p><p> Do not reallocate, free, or write to the buffer while an asynchronous write is still pending. </p><p>This interface is available on the following platforms if the Windows Media Format 11 SDK redistributable components are installed:</p><ul> <li>Windows?XP with Service Pack?2 (SP2) and later.</li> <li>Windows?XP Media Center Edition?2005 with KB900325 (Windows?XP Media Center Edition?2005) and KB925766 (October 2006 Update Rollup for Windows?XP Media Center Edition) installed.</li> </ul>
 /// </remarks>
 /// <msdn-id>ms694005</msdn-id>
 /// <unmanaged>HRESULT IMFByteStream::BeginWrite([In, Buffer] const unsigned char* pb,[In] unsigned int cb,[In] IMFAsyncCallback* pCallback,[In] IUnknown* punkState)</unmanaged>
 /// <unmanaged-short>IMFByteStream::BeginWrite</unmanaged-short>
 public unsafe void BeginWrite(byte[] bRef, int offset, int count, SharpDX.MediaFoundation.IAsyncCallback callbackRef, object context)
 {
     fixed(void *ptr = &bRef[offset])
     BeginWrite_((System.IntPtr)ptr, count, callbackRef, context != null ? Marshal.GetIUnknownForObject(context) : IntPtr.Zero);
 }