MatroskaMuxer.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
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         // TODO: chapters
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         // IAMFilterMiscFlags
00132 
00133         STDMETHODIMP_(ULONG) GetMiscFlags();
00134 
00135         // IMediaSeeking
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         // IMatroskaMuxer
00156 
00157         STDMETHODIMP CorrectTimeOffset(bool fNegative, bool fPositive);
00158 };
00159 

Generated on Tue Dec 13 14:47:10 2005 for guliverkli by  doxygen 1.4.5