本文整理汇总了C++中CStreamSwitcherOutputPin::DeliverBeginFlush方法的典型用法代码示例。如果您正苦于以下问题:C++ CStreamSwitcherOutputPin::DeliverBeginFlush方法的具体用法?C++ CStreamSwitcherOutputPin::DeliverBeginFlush怎么用?C++ CStreamSwitcherOutputPin::DeliverBeginFlush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStreamSwitcherOutputPin
的用法示例。
在下文中一共展示了CStreamSwitcherOutputPin::DeliverBeginFlush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
//.........这里部分代码省略.........