IWMSDataContainerCallback::OnRead
Previous | Next |
IWMSDataContainerCallback::OnRead
The OnRead method returns the results of the IWMSDataContainer::Read method call.
Syntax
HRESULT OnRead( HRESULT hr, DWORD dwActualBytesTransferred, DWORD dwChangeType, QWORD qwChangeParameter, QWORD qwContext );
Parameters
hr
[in] HRESULT containing the result of the IWMSDataContainer::Read method call.
dwActualBytesTransferred
[in] DWORD containing the number of bytes of data transferred.
dwChangeType
[in] DWORD reserved for future use. Set this parameter to NULL.
qwChangeParameter
[in] QWORD reserved for future use. Set this parameter to NULL.
qwContext
[in] QWORD containing a value defined by the server to identify which IWMSDataContainer::Read request the plug-in is responding to when it calls OnRead. The plug-in must pass this value back unaltered.
Return Values
If the method succeeds, the plug-in must return S_OK. To report an error, the plug-in can return any HRESULT other than S_OK. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving plug-in error information, see Identifying Plug-in Errors.
Remarks
It is recommended that, if possible, your plug-in read at least one second of data before calling this method.
Example Code
The following example applies only to data contained in a file.
HRESULT STDMETHODCALLTYPE CDataContainer::Read( BYTE *pbBuffer, QWORD qwReadPosition, DWORD dwMaxDataSize, IWMSDataContainerCallback *pCallback, QWORD qwContext ) { HRESULT hr = S_OK; BOOL fSuccess = FALSE; // TODO: Allocate (not shown) and initialize an OVERLAPPED // structure. The pOverLapped variable is a pointer to // this structure. See the CreateFile() documentation in the // MSDN library for more information. // If you opened the container by using the // FILE_FLAG_OVERLAPPED flag, an OVERLAPPED structure is // required for a read operation. pOverlapped->Offset = LODWORD( qwReadPosition ); pOverlapped ->OffsetHigh = ( LONG ) HIDWORD( qwReadPosition ); pOverlapped ->hEvent = NULL; // Read the file. fSuccess = ReadFile( m_hFile, pbBuffer, dwMaxDataSize, &m_dwBytesTransferred ), ( LPOVERLAPPED ) pOverLapped ); // TODO: Specify HRESULT for read operation. // Respond to the server. hr = m_pCallback->OnRead( hr, m_dwBytesTransferred, 0, 0, qwContext ); return( S_OK ); }
Requirements
Header: datacontainer.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.
See Also
Previous | Next |