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.
.gif)
| Previous | Next |
IWMSBufferAllocator::AllocateBuffer
The AllocateBuffer method initializes an INSSBuffer object.
Syntax
HRESULT AllocateBuffer( DWORD dwMaxBufferSize, INSSBuffer** ppBuffer );
Parameters
dwMaxBufferSize
[in] DWORD containing the maximum size of the buffer in bytes. This must be less than 16 MB (16,777,216 bytes).
ppBuffer
[out] Pointer to a pointer to an INSSBuffer interface.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
| Return code | Number | Description |
| E_INVALIDARG | 0x80070057 | One or both parameters are not valid. |
| E_OUTOFMEMORY | 0x8007000E | The method failed to allocate memory. |
Remarks
This method is used internally mainly by media parser, data sink, and data source plug-ins. Custom plug-in applications include, but are not limited to, data source and cache proxy plug-ins.
Example Code
The following example uses the IWMSBufferAllocator object to allocate a buffer to hold the written playlist file.
HRESULT STDMETHODCALLTYPE
CSDKSamplePlaylistParser::WritePlaylist(
IXMLDOMDocument *pPlayList,
IWMSPlaylistParserCallback *pCallback,
QWORD qwContext)
{
IXMLDOMNode *pAttrNode, *pNode;
IXMLDOMNodeList *pNodeList;
IXMLDOMNamedNodeMap *pNodeAttr;
IWMSBufferAllocator *pBufAllocator;
INSSBuffer *pBuffer;
CComBSTR bstrAttrName, bstrAttrValue, bstrTemp;
CComVariant varValue;
int i, j;
long lLength, lLength2;
HRESULT hr;
bstrTemp = "media";
hr = pPlayList->getElementsByTagName(bstrTemp, &pNodeList);
if (FAILED(hr)) goto EXIT;
hr = pNodeList->get_length(&lLength);
if (FAILED(hr)) goto EXIT;
bstrTemp = "";
for (i=0; i < lLength; i++)
{
hr = pNodeList->get_item((long)i, &pNode);
if (FAILED(hr)) goto EXIT;
hr = pNode->get_attributes(&pNodeAttr);
if (FAILED(hr)) goto EXIT;
hr = pNodeAttr->get_length(&lLength2);
if (FAILED(hr)) goto EXIT;
for (j=0; j < lLength2; j++)
{
hr = pNodeAttr->get_item((long)j, &pAttrNode);
if (FAILED(hr)) goto EXIT;
hr = pAttrNode->get_nodeName(&bstrAttrName);
if (FAILED(hr)) goto EXIT;
if( bstrAttrName == "src" )
{
hr = pAttrNode->get_nodeValue(&varValue);
if (FAILED(hr)) goto EXIT;
bstrTemp.Append(varValue.bstrVal);
bstrTemp.Append("\r\n");
break;
}
}
}
if( bstrTemp.ByteLength() > 0 )
{
m_spClassFactory.QueryInterface(&pBufAllocator);
pBufAllocator->AllocateBuffer(bstrTemp.ByteLength(), &pBuffer);
BYTE *pBuf;
pBuffer->SetLength(bstrTemp.ByteLength());
pBuffer->GetBuffer(&pBuf);
memcpy(pBuf, (char *)bstrTemp.m_str, bstrTemp.ByteLength());
hr = S_OK;
pCallback->OnWritePlaylist(hr, pBuffer, qwContext);
return( hr );
}
EXIT:
// TODO: Release temporary COM objects.
return( hr );
}
Requirements
Header: wmsbuffer.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.
See Also
- INSSBuffer Interface
- IWMSBufferAllocator Interface
- IWMSBufferAllocator::AllocatePageSizeBuffer
- IWMSDataSourcePlugin::OpenDataContainer
- IWMSDataSourcePlugin::OpenDirectory
- IWMSPacket::AppendHeader
- IWMSPlaylistParserPlugin::CreatePlaylistParser
- IWMSStreamHeaderList::CloneStreamHeaderList
| Previous | Next |