Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

filter.h

00001 /*****************************************************************************
00002  * filter.h : DirectShow access module for vlc
00003  *****************************************************************************
00004  * Copyright (C) 2002 the VideoLAN team
00005  * $Id: filter.h 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Author: Gildas Bazin <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include <string>
00028 #include <list>
00029 #include <deque>
00030 using namespace std;
00031 
00032 #ifndef _MSC_VER
00033 #   include <wtypes.h>
00034 #   include <unknwn.h>
00035 #   include <ole2.h>
00036 #   include <limits.h>
00037 #   define _WINGDI_ 1
00038 #   define AM_NOVTABLE
00039 #   define _OBJBASE_H_
00040 #   undef _X86_
00041 #   define _I64_MAX LONG_LONG_MAX
00042 #   define LONGLONG long long
00043 #endif
00044 
00045 #include <dshow.h>
00046 
00047 extern const GUID MEDIASUBTYPE_I420;
00048 extern const GUID MEDIASUBTYPE_PREVIEW_VIDEO;
00049 
00050 typedef struct VLCMediaSample
00051 {
00052     IMediaSample *p_sample;
00053     mtime_t i_timestamp;
00054 
00055 } VLCMediaSample;
00056 
00057 class CaptureFilter;
00058 
00059 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt );
00060 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
00061                               const AM_MEDIA_TYPE *pmtSource );
00062 
00063 int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type);
00064 
00065 /****************************************************************************
00066  * Declaration of our dummy directshow filter pin class
00067  ****************************************************************************/
00068 class CapturePin: public IPin, public IMemInputPin
00069 {
00070     friend class CaptureEnumMediaTypes;
00071 
00072     vlc_object_t *p_input;
00073     access_sys_t *p_sys;
00074     CaptureFilter  *p_filter;
00075 
00076     IPin *p_connected_pin;
00077 
00078     AM_MEDIA_TYPE *media_types;
00079     size_t media_type_count;
00080 
00081     AM_MEDIA_TYPE cx_media_type;
00082 
00083     deque<VLCMediaSample> samples_queue;
00084 
00085     long i_ref;
00086 
00087   public:
00088     CapturePin( vlc_object_t *_p_input, access_sys_t *p_sys,
00089                 CaptureFilter *_p_filter,
00090                 AM_MEDIA_TYPE *mt, size_t mt_count );
00091     virtual ~CapturePin();
00092 
00093     /* IUnknown methods */
00094     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
00095     STDMETHODIMP_(ULONG) AddRef();
00096     STDMETHODIMP_(ULONG) Release();
00097 
00098     /* IPin methods */
00099     STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
00100     STDMETHODIMP ReceiveConnection( IPin * pConnector,
00101                                     const AM_MEDIA_TYPE *pmt );
00102     STDMETHODIMP Disconnect();
00103     STDMETHODIMP ConnectedTo( IPin **pPin );
00104     STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
00105     STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
00106     STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
00107     STDMETHODIMP QueryId( LPWSTR * Id );
00108     STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
00109     STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
00110     STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
00111     STDMETHODIMP EndOfStream( void );
00112 
00113     STDMETHODIMP BeginFlush( void );
00114     STDMETHODIMP EndFlush( void );
00115     STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
00116                              double dRate );
00117 
00118     /* IMemInputPin methods */
00119     STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
00120     STDMETHODIMP NotifyAllocator(  IMemAllocator *pAllocator, BOOL bReadOnly );
00121     STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
00122     STDMETHODIMP Receive( IMediaSample *pSample );
00123     STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
00124                                   long *nSamplesProcessed );
00125     STDMETHODIMP ReceiveCanBlock( void );
00126 
00127     /* Custom methods */
00128     HRESULT CustomGetSample( VLCMediaSample * );
00129     AM_MEDIA_TYPE &CustomGetMediaType();
00130 };
00131 
00132 /****************************************************************************
00133  * Declaration of our dummy directshow filter class
00134  ****************************************************************************/
00135 class CaptureFilter : public IBaseFilter
00136 {
00137     friend class CapturePin;
00138 
00139     vlc_object_t   *p_input;
00140     CapturePin     *p_pin;
00141     IFilterGraph   *p_graph;
00142     //AM_MEDIA_TYPE  media_type;
00143     FILTER_STATE   state;
00144 
00145     long i_ref;
00146 
00147   public:
00148     CaptureFilter( vlc_object_t *_p_input, access_sys_t *p_sys,
00149                    AM_MEDIA_TYPE *mt, size_t mt_count );
00150     virtual ~CaptureFilter();
00151 
00152     /* IUnknown methods */
00153     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
00154     STDMETHODIMP_(ULONG) AddRef();
00155     STDMETHODIMP_(ULONG) Release();
00156 
00157     /* IPersist method */
00158     STDMETHODIMP GetClassID(CLSID *pClsID);
00159 
00160     /* IMediaFilter methods */
00161     STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
00162     STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
00163     STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
00164     STDMETHODIMP Stop();
00165     STDMETHODIMP Pause();
00166     STDMETHODIMP Run(REFERENCE_TIME tStart);
00167 
00168     /* IBaseFilter methods */
00169     STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
00170     STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
00171     STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
00172     STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
00173     STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
00174 
00175     /* Custom methods */
00176     CapturePin *CustomGetPin();
00177 };
00178 
00179 /****************************************************************************
00180  * Declaration of our dummy directshow enumpins class
00181  ****************************************************************************/
00182 class CaptureEnumPins : public IEnumPins
00183 {
00184     vlc_object_t *p_input;
00185     CaptureFilter  *p_filter;
00186 
00187     int i_position;
00188     long i_ref;
00189 
00190 public:
00191     CaptureEnumPins( vlc_object_t *_p_input, CaptureFilter *_p_filter,
00192                      CaptureEnumPins *pEnumPins );
00193     virtual ~CaptureEnumPins();
00194 
00195     // IUnknown
00196     STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
00197     STDMETHODIMP_(ULONG) AddRef();
00198     STDMETHODIMP_(ULONG) Release();
00199 
00200     // IEnumPins
00201     STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
00202     STDMETHODIMP Skip( ULONG cPins );
00203     STDMETHODIMP Reset();
00204     STDMETHODIMP Clone( IEnumPins **ppEnum );
00205 };
00206 
00207 /****************************************************************************
00208  * Declaration of our dummy directshow enummediatypes class
00209  ****************************************************************************/
00210 class CaptureEnumMediaTypes : public IEnumMediaTypes
00211 {
00212     vlc_object_t *p_input;
00213     CapturePin     *p_pin;
00214     AM_MEDIA_TYPE cx_media_type;
00215 
00216     size_t i_position;
00217     long i_ref;
00218 
00219 public:
00220     CaptureEnumMediaTypes( vlc_object_t *_p_input, CapturePin *_p_pin,
00221                            CaptureEnumMediaTypes *pEnumMediaTypes );
00222 
00223     virtual ~CaptureEnumMediaTypes();
00224 
00225     // IUnknown
00226     STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
00227     STDMETHODIMP_(ULONG) AddRef();
00228     STDMETHODIMP_(ULONG) Release();
00229 
00230     // IEnumMediaTypes
00231     STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
00232                        ULONG * pcFetched );
00233     STDMETHODIMP Skip( ULONG cMediaTypes );
00234     STDMETHODIMP Reset();
00235     STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );
00236 };

Generated on Tue Dec 20 10:14:24 2005 for vlc-0.8.4a by  doxygen 1.4.2