00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <atlbase.h>
00025 #include <atlcoll.h>
00026 #include <afxtempl.h>
00027 #include "MatroskaFile.h"
00028
00029 #define MAXCLUSTERTIME 1000
00030 #define MAXBLOCKS 50
00031
00032 class CMatroskaMuxerInputPin : public CBaseInputPin
00033 {
00034 CAutoPtr<MatroskaWriter::TrackEntry> m_pTE;
00035 CAutoPtrArray<MatroskaWriter::CBinary> m_pVorbisHdrs;
00036
00037 bool m_fActive;
00038 CCritSec m_csReceive;
00039
00040 REFERENCE_TIME m_rtLastStart, m_rtLastStop;
00041
00042 public:
00043 CMatroskaMuxerInputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
00044 virtual ~CMatroskaMuxerInputPin();
00045
00046 DECLARE_IUNKNOWN;
00047 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00048
00049 MatroskaWriter::TrackEntry* GetTrackEntry() {return m_pTE;}
00050
00051 REFERENCE_TIME m_rtDur;
00052
00053 CCritSec m_csQueue;
00054 CAutoPtrList<MatroskaWriter::BlockGroup> m_blocks;
00055 bool m_fEndOfStreamReceived;
00056
00057 HRESULT CheckMediaType(const CMediaType* pmt);
00058 HRESULT BreakConnect();
00059 HRESULT CompleteConnect(IPin* pPin);
00060 HRESULT Active(), Inactive();
00061
00062 STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
00063 STDMETHODIMP BeginFlush();
00064 STDMETHODIMP EndFlush();
00065
00066 STDMETHODIMP Receive(IMediaSample* pSample);
00067 STDMETHODIMP EndOfStream();
00068 };
00069
00070 class CMatroskaMuxerOutputPin : public CBaseOutputPin
00071 {
00072 public:
00073 CMatroskaMuxerOutputPin(TCHAR* pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
00074 virtual ~CMatroskaMuxerOutputPin();
00075
00076 DECLARE_IUNKNOWN;
00077 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00078
00079 HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
00080
00081 HRESULT CheckMediaType(const CMediaType* pmt);
00082 HRESULT GetMediaType(int iPosition, CMediaType* pmt);
00083
00084 STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
00085 };
00086
00087 [uuid("38E2D43D-915D-493C-B373-888DB16EE3DC")]
00088 interface IMatroskaMuxer : public IUnknown
00089 {
00090 STDMETHOD (CorrectTimeOffset) (bool fNegative, bool fPositive) = 0;
00091
00092 };
00093
00094 [uuid("1E1299A2-9D42-4F12-8791-D79E376F4143")]
00095 class CMatroskaMuxerFilter
00096 : public CBaseFilter
00097 , public CCritSec
00098 , public CAMThread
00099 , public IAMFilterMiscFlags
00100 , public IMediaSeeking
00101 , public IMatroskaMuxer
00102 {
00103 protected:
00104 CAutoPtrList<CMatroskaMuxerInputPin> m_pInputs;
00105 CAutoPtr<CMatroskaMuxerOutputPin> m_pOutput;
00106
00107 REFERENCE_TIME m_rtCurrent;
00108
00109 bool m_fNegative, m_fPositive;
00110
00111 enum {CMD_EXIT, CMD_RUN};
00112 DWORD ThreadProc();
00113
00114 public:
00115 CMatroskaMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr);
00116 virtual ~CMatroskaMuxerFilter();
00117
00118 DECLARE_IUNKNOWN;
00119 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00120
00121 void AddInput();
00122 UINT GetTrackNumber(CBasePin* pPin);
00123
00124 int GetPinCount();
00125 CBasePin* GetPin(int n);
00126
00127 STDMETHODIMP Stop();
00128 STDMETHODIMP Pause();
00129 STDMETHODIMP Run(REFERENCE_TIME tStart);
00130
00131
00132
00133 STDMETHODIMP_(ULONG) GetMiscFlags();
00134
00135
00136
00137 STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
00138 STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
00139 STDMETHODIMP IsFormatSupported(const GUID* pFormat);
00140 STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
00141 STDMETHODIMP GetTimeFormat(GUID* pFormat);
00142 STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
00143 STDMETHODIMP SetTimeFormat(const GUID* pFormat);
00144 STDMETHODIMP GetDuration(LONGLONG* pDuration);
00145 STDMETHODIMP GetStopPosition(LONGLONG* pStop);
00146 STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
00147 STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
00148 STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
00149 STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
00150 STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
00151 STDMETHODIMP SetRate(double dRate);
00152 STDMETHODIMP GetRate(double* pdRate);
00153 STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
00154
00155
00156
00157 STDMETHODIMP CorrectTimeOffset(bool fNegative, bool fPositive);
00158 };
00159