diff options
Diffstat (limited to 'demuxer')
-rw-r--r-- | demuxer/Demuxers/LAVFDemuxer.cpp | 7 | ||||
-rw-r--r-- | demuxer/LAVSplitter/PacketAllocator.cpp | 27 | ||||
-rw-r--r-- | demuxer/LAVSplitter/PacketAllocator.h | 13 | ||||
-rw-r--r-- | demuxer/LAVSplitter/dllmain.cpp | 1 |
4 files changed, 41 insertions, 7 deletions
diff --git a/demuxer/Demuxers/LAVFDemuxer.cpp b/demuxer/Demuxers/LAVFDemuxer.cpp index deb032cf..1c28c839 100644 --- a/demuxer/Demuxers/LAVFDemuxer.cpp +++ b/demuxer/Demuxers/LAVFDemuxer.cpp @@ -596,11 +596,8 @@ STDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce) av_opt_set_int(m_avFormat, "correct_ts_overflow", !m_pBluRay, 0); - // TODO: AVFMT_FLAG_KEEP_SIDE_DATA should be ON for all formats - if (m_bMatroska || m_bMPEGTS) - m_avFormat->flags |= AVFMT_FLAG_KEEP_SIDE_DATA; - else - m_avFormat->flags &= ~AVFMT_FLAG_KEEP_SIDE_DATA; + // preserve side-data in the packets properly + m_avFormat->flags |= AVFMT_FLAG_KEEP_SIDE_DATA; m_timeOpening = time(nullptr); int ret = avformat_find_stream_info(m_avFormat, nullptr); diff --git a/demuxer/LAVSplitter/PacketAllocator.cpp b/demuxer/LAVSplitter/PacketAllocator.cpp index a70f08c6..d04f584c 100644 --- a/demuxer/LAVSplitter/PacketAllocator.cpp +++ b/demuxer/LAVSplitter/PacketAllocator.cpp @@ -70,6 +70,8 @@ STDMETHODIMP_(ULONG) CMediaPacketSample::Release() SAFE_DELETE(m_pPacket); SetPointer(nullptr, 0); + SAFE_DELETE(m_pSideData); + /* This may cause us to be deleted */ // Our refcount is reliably 0 thus no-one will mess with us m_pAllocator->ReleaseBuffer(this); @@ -83,9 +85,34 @@ STDMETHODIMP CMediaPacketSample::SetPacket(Packet *pPacket) m_pPacket = pPacket; SetPointer(pPacket->GetData(), (LONG)pPacket->GetDataSize()); + SAFE_DELETE(m_pSideData); + + if (pPacket->GetNumSideData() > 0) { + m_pSideData = new MediaSideDataFFMpeg(); + m_pSideData->side_data = pPacket->GetSideData(); + m_pSideData->side_data_elems = pPacket->GetNumSideData(); + } + return S_OK; } +STDMETHODIMP CMediaPacketSample::SetSideData(GUID guidType, const BYTE *pData, size_t size) +{ + return E_NOTIMPL; +} + +STDMETHODIMP CMediaPacketSample::GetSideData(GUID guidType, const BYTE **pData, size_t *pSize) +{ + if (guidType == IID_MediaSideDataFFMpeg && m_pSideData) { + *pData = (const BYTE *)m_pSideData; + *pSize = sizeof(MediaSideDataFFMpeg); + + return S_OK; + } + + return E_INVALIDARG; +} + CPacketAllocator::CPacketAllocator(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT *phr) : CBaseAllocator(pName, pUnk, phr, TRUE, TRUE) { diff --git a/demuxer/LAVSplitter/PacketAllocator.h b/demuxer/LAVSplitter/PacketAllocator.h index 08cddab1..ba5d82b3 100644 --- a/demuxer/LAVSplitter/PacketAllocator.h +++ b/demuxer/LAVSplitter/PacketAllocator.h @@ -22,13 +22,16 @@ #pragma once +#include "IMediaSideData.h" +#include "IMediaSideDataFFmpeg.h" + interface __declspec(uuid("0B2EE323-0ED8-452D-B31E-B9B4DE2C0C39")) -ILAVMediaSample : public IUnknown { +ILAVMediaSample : public IUnknown { STDMETHOD(SetPacket)(Packet *pPacket) PURE; }; -class CMediaPacketSample : public CMediaSample, public ILAVMediaSample +class CMediaPacketSample : public CMediaSample, public ILAVMediaSample, public IMediaSideData { public: CMediaPacketSample(LPCTSTR pName, CBaseAllocator *pAllocator, HRESULT *phr); @@ -38,10 +41,16 @@ public: STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release(); + // ILAVMediaSamples STDMETHODIMP SetPacket(Packet *pPacket); + // IMediaSideData + STDMETHODIMP SetSideData(GUID guidType, const BYTE *pData, size_t size); + STDMETHODIMP GetSideData(GUID guidType, const BYTE **pData, size_t *pSize); + protected: Packet *m_pPacket = nullptr; + MediaSideDataFFMpeg *m_pSideData = nullptr; }; class CPacketAllocator : public CBaseAllocator diff --git a/demuxer/LAVSplitter/dllmain.cpp b/demuxer/LAVSplitter/dllmain.cpp index 5f42bf5e..a68ff5b4 100644 --- a/demuxer/LAVSplitter/dllmain.cpp +++ b/demuxer/LAVSplitter/dllmain.cpp @@ -36,6 +36,7 @@ #include "registry.h" #include "IGraphRebuildDelegate.h" +#include "IMediaSideDataFFmpeg.h" // The GUID we use to register the splitter media types DEFINE_GUID(MEDIATYPE_LAVSplitter, |