本文整理汇总了C++中CStreamSwitcherOutputPin::CurrentAllocator方法的典型用法代码示例。如果您正苦于以下问题:C++ CStreamSwitcherOutputPin::CurrentAllocator方法的具体用法?C++ CStreamSwitcherOutputPin::CurrentAllocator怎么用?C++ CStreamSwitcherOutputPin::CurrentAllocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStreamSwitcherOutputPin
的用法示例。
在下文中一共展示了CStreamSwitcherOutputPin::CurrentAllocator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBuffer
STDMETHODIMP CStreamSwitcherAllocator::GetBuffer(
IMediaSample** ppBuffer,
REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
DWORD dwFlags)
{
HRESULT hr = VFW_E_NOT_COMMITTED;
if (!m_bCommitted) {
return hr;
}
/*
TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() + %x\n"), this);
m_pPin->m_evBlock.Wait();
TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() - %x\n"), this);
*/
if (m_fMediaTypeChanged) {
if (!m_pPin || !m_pPin->m_pFilter) {
return hr;
}
CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pPin->m_pFilter))->GetOutputPin();
if (!pOut || !pOut->CurrentAllocator()) {
return hr;
}
ALLOCATOR_PROPERTIES Properties, Actual;
if (FAILED(pOut->CurrentAllocator()->GetProperties(&Actual))) {
return hr;
}
if (FAILED(GetProperties(&Properties))) {
return hr;
}
if (!m_bCommitted || Properties.cbBuffer < Actual.cbBuffer) {
Properties.cbBuffer = Actual.cbBuffer;
if (FAILED(Decommit())) {
return hr;
}
if (FAILED(SetProperties(&Properties, &Actual))) {
return hr;
}
if (FAILED(Commit())) {
return hr;
}
ASSERT(Actual.cbBuffer >= Properties.cbBuffer);
if (Actual.cbBuffer < Properties.cbBuffer) {
return hr;
}
}
}
hr = CMemAllocator::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
if (m_fMediaTypeChanged && SUCCEEDED(hr)) {
(*ppBuffer)->SetMediaType(&m_mt);
m_fMediaTypeChanged = false;
}
return hr;
}
示例2: Receive
STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
{
AM_MEDIA_TYPE* pmt = nullptr;
if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
const CMediaType mt(*pmt);
DeleteMediaType(pmt), pmt = nullptr;
SetMediaType(&mt);
}
// DAMN!!!!!! this doesn't work if the stream we are blocking
// shares the same thread with another stream, mpeg splitters
// are usually like that. Our nicely built up multithreaded
// strategy is useless because of this, ARRRRRRGHHHHHH.
#ifdef BLOCKSTREAM
if (m_fCanBlock) {
m_evBlock.Wait();
}
#endif
if (!IsActive()) {
#ifdef BLOCKSTREAM
if (m_fCanBlock) {
return S_FALSE;
}
#endif
TRACE(_T("&^$#@ : a stupid fix for this stupid problem\n"));
//Sleep(32);
return E_FAIL; // a stupid fix for this stupid problem
}
CAutoLock cAutoLock(&m_csReceive);
CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
ASSERT(pOut->GetConnected());
HRESULT hr = __super::Receive(pSample);
if (S_OK != hr) {
return hr;
}
if (m_SampleProps.dwStreamId != AM_STREAM_MEDIA) {
return pOut->Deliver(pSample);
}
//
ALLOCATOR_PROPERTIES props, actual;
hr = m_pAllocator->GetProperties(&props);
hr = pOut->CurrentAllocator()->GetProperties(&actual);
REFERENCE_TIME rtStart = 0, rtStop = 0;
if (S_OK == pSample->GetTime(&rtStart, &rtStop)) {
//
}
long cbBuffer = pSample->GetActualDataLength();
CMediaType mtOut = m_mt;
mtOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CreateNewOutputMediaType(mtOut, cbBuffer);
bool fTypeChanged = false;
if (mtOut != pOut->CurrentMediaType() || cbBuffer > actual.cbBuffer) {
fTypeChanged = true;
m_SampleProps.dwSampleFlags |= AM_SAMPLE_TYPECHANGED/*|AM_SAMPLE_DATADISCONTINUITY|AM_SAMPLE_TIMEDISCONTINUITY*/;
/*
if (CComQIPtr<IPinConnection> pPC = pOut->CurrentPinConnection())
{
HANDLE hEOS = CreateEvent(nullptr, FALSE, FALSE, nullptr);
hr = pPC->NotifyEndOfStream(hEOS);
hr = pOut->DeliverEndOfStream();
WaitForSingleObject(hEOS, 3000);
CloseHandle(hEOS);
hr = pOut->DeliverBeginFlush();
hr = pOut->DeliverEndFlush();
}
*/
if (props.cBuffers < 8 && mtOut.majortype == MEDIATYPE_Audio) {
props.cBuffers = 8;
}
props.cbBuffer = cbBuffer;
if (actual.cbAlign != props.cbAlign
|| actual.cbPrefix != props.cbPrefix
|| actual.cBuffers < props.cBuffers
|| actual.cbBuffer < props.cbBuffer) {
hr = pOut->DeliverBeginFlush();
hr = pOut->DeliverEndFlush();
hr = pOut->CurrentAllocator()->Decommit();
hr = pOut->CurrentAllocator()->SetProperties(&props, &actual);
hr = pOut->CurrentAllocator()->Commit();
}
}
//.........这里部分代码省略.........