本文整理汇总了C++中ComPtr::AddBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::AddBuffer方法的具体用法?C++ ComPtr::AddBuffer怎么用?C++ ComPtr::AddBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComPtr
的用法示例。
在下文中一共展示了ComPtr::AddBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HRC
HRESULT MFAAC::Encoder::EnsureCapacity(ComPtr<IMFSample> &sample, DWORD length)
{
HRESULT hr;
ComPtr<IMFMediaBuffer> buffer;
DWORD currentLength;
if (!sample) {
HRC(CreateEmptySample(sample, buffer, length));
} else {
HRC(sample->GetBufferByIndex(0, &buffer));
}
HRC(buffer->GetMaxLength(¤tLength));
if (currentLength < length) {
HRC(sample->RemoveAllBuffers());
HRC(MFCreateMemoryBuffer(length, &buffer));
HRC(sample->AddBuffer(buffer));
} else {
buffer->SetCurrentLength(0);
}
packetBuffer.reserve(length);
return S_OK;
fail:
return hr;
}
示例2: FromMFSample
HRESULT CBufferPacket::FromMFSample(IMFSample *pSample, IBufferPacket **ppBufferPacket)
{
if (pSample == nullptr || ppBufferPacket == nullptr)
{
return E_INVALIDARG;
}
ComPtr<IBufferPacket> spPacket;
DWORD cBuffers = 0;
HRESULT hr = CBufferPacket::CreateInstance(&spPacket);
if (SUCCEEDED(hr))
{
hr = pSample->GetBufferCount(&cBuffers);
}
if (SUCCEEDED(hr))
{
for (DWORD nIndex = 0; nIndex < cBuffers; ++nIndex)
{
ComPtr<IMFMediaBuffer> spMediaBuffer;
ComPtr<IMediaBufferWrapper> spBufferWrapper;
// Get buffer from the sample
hr = pSample->GetBufferByIndex(nIndex, &spMediaBuffer);
if (FAILED(hr))
{
break;
}
// Create buffer wrapper
hr = CreateMediaBufferWrapper(spMediaBuffer.Get(), &spBufferWrapper);
if (FAILED(hr))
{
break;
}
// Add buffer to the package
hr = spPacket->AddBuffer(spBufferWrapper.Get());
if (FAILED(hr))
{
break;
}
}
}
if (SUCCEEDED(hr))
{
*ppBufferPacket = spPacket.Detach();
}
TRACEHR_RET(hr);
}