Skip to content
Permalink
Browse files

LAV Video Decoder で再生停止後の再開が正常に行われない現象の回避策を追加

  • Loading branch information
DBCTRADO committed Nov 30, 2019
1 parent cf982c9 commit 75839e63c2167985da31fe65a8e22b09b2bfd3a1
Showing with 62 additions and 0 deletions.
  1. +62 −0 LibISDB/Windows/Viewer/ViewerFilter.cpp
@@ -36,6 +36,9 @@
#include <dvdmedia.h>
#include "../../Base/DebugDef.hpp"

// LAV Video Decoder で一度再生を停止すると再開が正常に行われない現象の回避策を行う
#define LAV_VIDEO_DECODER_WORKAROUND


//const CLSID CLSID_NullRenderer = {0xc1f400a4, 0x3f08, 0x11d3, {0x9f, 0x0b, 0x00, 0x60, 0x08, 0x03, 0x9e, 0x37}};
EXTERN_C const CLSID CLSID_NullRenderer;
@@ -141,6 +144,53 @@ HRESULT SetVideoMediaType(CMediaType *pMediaType, BYTE VideoStreamType, int Widt
}


#ifdef LAV_VIDEO_DECODER_WORKAROUND


interface __declspec(uuid("8B81E022-52C7-4B89-9F11-ACFD063AABB4")) IPinSegmentEx : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE EndOfSegment(void) = 0;
};


bool IsLAVVideoDecoderName(const String &Name)
{
return StringCompareI(Name.c_str(), LIBISDB_STR("LAV Video Decoder")) == 0;
}


void LAVVideoDecoder_NotifyEndOfSegment(COMPointer<IBaseFilter> &Filter, const String &Name)
{
if (Filter && IsLAVVideoDecoderName(Name)) {
IPin *pPin = DirectShow::GetFilterPin(Filter.Get(), PINDIR_INPUT);
if (pPin != nullptr) {
IPinSegmentEx *pPinSegmentEx;
if (SUCCEEDED(pPin->QueryInterface(IID_PPV_ARGS(&pPinSegmentEx)))) {
LIBISDB_TRACE(LIBISDB_STR("Call IPinSegmentEx::EndOfSegment()\n"));
pPinSegmentEx->EndOfSegment();
pPinSegmentEx->Release();
}
}
}
}


void LAVVideoDecoder_NotifyNewSegment(COMPointer<IBaseFilter> &Filter, const String &Name)
{
if (Filter && IsLAVVideoDecoderName(Name)) {
IPin *pPin = DirectShow::GetFilterPin(Filter.Get(), PINDIR_INPUT);
if (pPin != nullptr) {
LIBISDB_TRACE(LIBISDB_STR("Call IPin::NewSegment()\n"));
pPin->NewSegment(0, 0, 1.0);
pPin->Release();
}
}
}


#endif // LAV_VIDEO_DECODER_WORKAROUND


} // namespace


@@ -826,6 +876,10 @@ bool ViewerFilter::Play()
if (!Lock.TryLock(LOCK_TIMEOUT))
return false;

#ifdef LAV_VIDEO_DECODER_WORKAROUND
LAVVideoDecoder_NotifyNewSegment(m_VideoDecoderFilter, m_VideoDecoderName);
#endif

return FilterGraph::Play();
}

@@ -843,6 +897,10 @@ bool ViewerFilter::Stop()
m_SourceFilter->Flush();
}

#ifdef LAV_VIDEO_DECODER_WORKAROUND
LAVVideoDecoder_NotifyEndOfSegment(m_VideoDecoderFilter, m_VideoDecoderName);
#endif

return FilterGraph::Stop();
}

@@ -860,6 +918,10 @@ bool ViewerFilter::Pause()
m_SourceFilter->Flush();
}

#ifdef LAV_VIDEO_DECODER_WORKAROUND
LAVVideoDecoder_NotifyEndOfSegment(m_VideoDecoderFilter, m_VideoDecoderName);
#endif

return FilterGraph::Pause();
}

0 comments on commit 75839e6

Please sign in to comment.
You can’t perform that action at this time.