]> git.sesse.net Git - vlc/blob - modules/access/dshow/filter.h
* configure.ac, modules/access/dshow/: brand new DirectShow input plugin.
[vlc] / modules / access / dshow / filter.h
1 /*****************************************************************************
2  * filter.h : DirectShow access module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id: filter.h,v 1.1 2003/08/24 11:17:39 gbazin Exp $
6  *
7  * Author: Gildas Bazin <gbazin@netcourrier.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <string>
28 #include <list>
29 #include <deque>
30 using namespace std;
31
32 typedef struct VLCMediaSample
33 {
34     IMediaSample *p_sample;
35     mtime_t i_timestamp;
36
37 } VLCMediaSample;
38
39 class CaptureFilter;
40
41 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt );
42 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
43                               const AM_MEDIA_TYPE *pmtSource );
44
45 /****************************************************************************
46  * Declaration of our dummy directshow filter pin class
47  ****************************************************************************/
48 class CapturePin: public IPin, public IMemInputPin
49 {
50     input_thread_t * p_input;
51
52     CaptureFilter *p_filter;
53
54     IPin *p_connected_pin;
55     AM_MEDIA_TYPE media_type;
56
57     deque<VLCMediaSample> samples_queue;
58
59     int i_ref;
60
61   public:
62     CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter );
63     virtual ~CapturePin();
64
65     /* IUnknown methods */
66     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
67     STDMETHODIMP_(ULONG) AddRef();
68     STDMETHODIMP_(ULONG) Release();
69
70     /* IPin methods */
71     STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
72     STDMETHODIMP ReceiveConnection( IPin * pConnector,
73                                     const AM_MEDIA_TYPE *pmt );
74     STDMETHODIMP Disconnect();
75     STDMETHODIMP ConnectedTo( IPin **pPin );
76     STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
77     STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
78     STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
79     STDMETHODIMP QueryId( LPWSTR * Id );
80     STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
81     STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
82     STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
83     STDMETHODIMP EndOfStream( void );
84
85     STDMETHODIMP BeginFlush( void );
86     STDMETHODIMP EndFlush( void );
87     STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
88                              double dRate );
89
90     /* IMemInputPin methods */
91     STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
92     STDMETHODIMP NotifyAllocator(  IMemAllocator *pAllocator, BOOL bReadOnly );
93     STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
94     STDMETHODIMP Receive( IMediaSample *pSample );
95     STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
96                                   long *nSamplesProcessed );
97     STDMETHODIMP ReceiveCanBlock( void );
98
99     /* Custom methods */
100     HRESULT CustomGetSample( VLCMediaSample * );
101     AM_MEDIA_TYPE CustomGetMediaType();
102 };
103
104 /****************************************************************************
105  * Declaration of our dummy directshow filter class
106  ****************************************************************************/
107 class CaptureFilter : public IBaseFilter
108 {
109     input_thread_t * p_input;
110     CapturePin *p_pin;
111     IFilterGraph * p_graph;
112
113     int i_ref;
114
115   public:
116     CaptureFilter( input_thread_t * _p_input );
117     virtual ~CaptureFilter();
118
119     /* IUnknown methods */
120     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
121     STDMETHODIMP_(ULONG) AddRef();
122     STDMETHODIMP_(ULONG) Release();
123
124     /* IPersist method */
125     STDMETHODIMP GetClassID(CLSID *pClsID);
126
127     /* IMediaFilter methods */
128     STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
129     STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
130     STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
131     STDMETHODIMP Stop();
132     STDMETHODIMP Pause();
133     STDMETHODIMP Run(REFERENCE_TIME tStart);
134
135     /* IBaseFilter methods */
136     STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
137     STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
138     STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
139     STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
140     STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
141
142     /* Custom methods */
143     CapturePin *CustomGetPin();
144 };
145
146 /****************************************************************************
147  * Declaration of our dummy directshow enumpins class
148  ****************************************************************************/
149 class CaptureEnumPins : public IEnumPins
150 {
151     input_thread_t * p_input;
152     int i_position;
153     CaptureFilter *p_filter;
154
155     int i_ref;
156
157 public:
158     CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter,
159                      CaptureEnumPins *pEnumPins );
160     virtual ~CaptureEnumPins();
161
162     // IUnknown
163     STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
164     STDMETHODIMP_(ULONG) AddRef();
165     STDMETHODIMP_(ULONG) Release();
166
167     // IEnumPins
168     STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
169     STDMETHODIMP Skip( ULONG cPins );
170     STDMETHODIMP Reset();
171     STDMETHODIMP Clone( IEnumPins **ppEnum );
172 };
173
174 /****************************************************************************
175  * Declaration of our dummy directshow enummediatypes class
176  ****************************************************************************/
177 class CaptureEnumMediaTypes : public IEnumMediaTypes
178 {
179     input_thread_t * p_input;
180     int i_position;
181     CapturePin *p_pin;
182
183     int i_ref;
184
185 public:
186     CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_pin,
187                            CaptureEnumMediaTypes *pEnumMediaTypes );
188
189     virtual ~CaptureEnumMediaTypes();
190
191     // IUnknown
192     STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
193     STDMETHODIMP_(ULONG) AddRef();
194     STDMETHODIMP_(ULONG) Release();
195
196     // IEnumMediaTypes
197     STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
198                        ULONG * pcFetched );
199     STDMETHODIMP Skip( ULONG cMediaTypes );
200     STDMETHODIMP Reset();
201     STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );
202 };