Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The server calls the Read method to read data from the data container into a buffer.
HRESULT Read(
BYTE* pbBuffer,
QWORD qwOffset,
DWORD dwMaxDataSize,
DWORD dwFlags,
IWMSDataContainerCallback* pCallback,
QWORD qwContext
);
Arguments
pbBuffer |
[in] Pointer to a BYTE identifying the buffer to be filled with data from the data container. |
qwOffset |
[in] QWORD value specifying the offset in bytes from which the data should be read. This must be WMS_DATA_CONTAINER_NONSEEKABLE for data containers that do not support seeking. For example, a live source cannot be seekable, but a file can be. |
dwMaxDataSize |
[in] DWORD value specifying the maximum data size in bytes to be read from the data container. |
dwFlags |
[in] Reserved for future use. |
pCallback |
[in] Pointer to the IWMSDataContainerCallbackIWMSDataContainerCallback Interface. The plug-in calls IWMSDataContainerCallback::OnRead to respond to the server. |
qwContext |
[in] QWORD containing a value defined by the server to identify which Read request the plug-in is responding to when it calls IWMSDataContainerCallback::OnRead. The plug-in must pass this value back unaltered. |
Return Value
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 IWMSEventLogIWMSEventLog 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.
Example
The following example illustrates a possible implementation of a data source plug-in that reads from a file system.
HRESULT STDMETHODCALLTYPE
CDataContainer::Read(
BYTE *pbBuffer,
QWORD qwReadPosition,
DWORD dwMaxDataSize,
IWMSDataContainerCallback *pCallback,
QWORD qwContext
)
{
HRESULT hr = S_OK;
// If this data container is not open, then quit.
if( ( INVALID_HANDLE_VALUE == m_hFile )
{
hr = E_UNEXPECTED;
return ( hr );
}
// 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.
pOvrlp->Offset = LODWORD( qwReadPosition );
pOvrlp->OffsetHigh = ( LONG ) HIDWORD( qwReadPosition );
pOvrlp->hEvent = NULL;
// Read the file.
fSuccess = ReadFile(
m_hFile,
pbBuffer,
dwMaxDataSize,
m_dwBytesTransferred ),
( LPOVERLAPPED ) pOvrlp
);
return( hr );
}
Requirements
Header: datacontainer.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.