BufferFilter.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 
00026 [uuid("63EF0035-3FFE-4c41-9230-4346E028BE20")]
00027 interface IBufferFilter : public IUnknown
00028 {
00029         STDMETHOD(SetBuffers) (int nBuffers) = 0;
00030         STDMETHOD_(int, GetBuffers) () = 0;
00031         STDMETHOD_(int, GetFreeBuffers) () = 0;
00032         STDMETHOD(SetPriority) (DWORD dwPriority = THREAD_PRIORITY_NORMAL) = 0;
00033 };
00034 
00035 [uuid("DA2B3D77-2F29-4fd2-AC99-DEE4A8A13BF0")]
00036 class CBufferFilter : public CTransformFilter, public IBufferFilter
00037 {
00038         int m_nSamplesToBuffer;
00039 
00040 public:
00041         CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr);
00042         virtual ~CBufferFilter();
00043 
00044         DECLARE_IUNKNOWN
00045     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00046 
00047         // IBufferFilter
00048         STDMETHODIMP SetBuffers(int nBuffers);
00049         STDMETHODIMP_(int) GetBuffers();
00050         STDMETHODIMP_(int) GetFreeBuffers();
00051         STDMETHODIMP SetPriority(DWORD dwPriority = THREAD_PRIORITY_NORMAL);
00052 
00053         HRESULT Receive(IMediaSample* pSample);
00054         HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
00055     HRESULT CheckInputType(const CMediaType* mtIn);
00056     HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
00057     HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
00058     HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
00059         HRESULT StopStreaming();
00060 };
00061 
00062 class CBufferFilterOutputPin : public CTransformOutputPin
00063 {
00064         class CBufferFilterOutputQueue : public COutputQueue
00065         {
00066         public:
00067                 CBufferFilterOutputQueue(IPin* pInputPin, HRESULT* phr,
00068                                 DWORD dwPriority = THREAD_PRIORITY_NORMAL,
00069                                 BOOL bAuto = FALSE, BOOL bQueue = TRUE,
00070                                 LONG lBatchSize = 1, BOOL bBatchExact = FALSE,
00071                                 LONG lListSize = DEFAULTCACHE,
00072                                 bool bFlushingOpt = false)
00073                         : COutputQueue(pInputPin, phr, bAuto, bQueue, lBatchSize, bBatchExact, lListSize, dwPriority, bFlushingOpt)
00074                 {
00075                 }
00076 
00077                 int GetQueueCount()
00078                 {
00079                         return m_List ? m_List->GetCount() : -1;
00080                 }
00081 
00082                 bool SetPriority(DWORD dwPriority)
00083                 {
00084                         return m_hThread ? !!::SetThreadPriority(m_hThread, dwPriority) : false;
00085                 }
00086         };
00087 
00088 public:
00089         CBufferFilterOutputPin(CTransformFilter* pFilter, HRESULT* phr);
00090 
00091         CAutoPtr<CBufferFilterOutputQueue> m_pOutputQueue;
00092 
00093         HRESULT Active();
00094     HRESULT Inactive();
00095 
00096         HRESULT Deliver(IMediaSample* pMediaSample);
00097     HRESULT DeliverEndOfStream();
00098     HRESULT DeliverBeginFlush();
00099         HRESULT DeliverEndFlush();
00100     HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
00101 };

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