|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef VIDEOSURFACEFILTER_H |
|
43 #define VIDEOSURFACEFILTER_H |
|
44 |
|
45 #include "directshowmediatypelist.h" |
|
46 #include "directshowsamplescheduler.h" |
|
47 #include "directshowmediatype.h" |
|
48 |
|
49 #include <QtCore/qbasictimer.h> |
|
50 #include <QtCore/qcoreevent.h> |
|
51 #include <QtCore/qmutex.h> |
|
52 #include <QtCore/qsemaphore.h> |
|
53 #include <QtCore/qstring.h> |
|
54 #include <QtCore/qwaitcondition.h> |
|
55 |
|
56 #include <dshow.h> |
|
57 |
|
58 QT_BEGIN_NAMESPACE |
|
59 class QAbstractVideoSurface; |
|
60 QT_END_NAMESPACE |
|
61 |
|
62 class DirectShowEventLoop; |
|
63 |
|
64 class VideoSurfaceFilter |
|
65 : public QObject |
|
66 , public DirectShowMediaTypeList |
|
67 , public IBaseFilter |
|
68 , public IAMFilterMiscFlags |
|
69 , public IPin |
|
70 { |
|
71 Q_OBJECT |
|
72 public: |
|
73 VideoSurfaceFilter( |
|
74 QAbstractVideoSurface *surface, DirectShowEventLoop *loop, QObject *parent = 0); |
|
75 ~VideoSurfaceFilter(); |
|
76 |
|
77 // IUnknown |
|
78 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); |
|
79 ULONG STDMETHODCALLTYPE AddRef(); |
|
80 ULONG STDMETHODCALLTYPE Release(); |
|
81 |
|
82 // IPersist |
|
83 HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID); |
|
84 |
|
85 // IMediaFilter |
|
86 HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart); |
|
87 HRESULT STDMETHODCALLTYPE Pause(); |
|
88 HRESULT STDMETHODCALLTYPE Stop(); |
|
89 |
|
90 HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *pState); |
|
91 |
|
92 HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock); |
|
93 HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **ppClock); |
|
94 |
|
95 // IBaseFilter |
|
96 HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum); |
|
97 HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin); |
|
98 |
|
99 HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); |
|
100 |
|
101 HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo); |
|
102 HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo); |
|
103 |
|
104 // IAMFilterMiscFlags |
|
105 ULONG STDMETHODCALLTYPE GetMiscFlags(); |
|
106 |
|
107 // IPin |
|
108 HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); |
|
109 HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); |
|
110 HRESULT STDMETHODCALLTYPE Disconnect(); |
|
111 HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **ppPin); |
|
112 |
|
113 HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); |
|
114 |
|
115 HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); |
|
116 HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); |
|
117 |
|
118 HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); |
|
119 |
|
120 HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); |
|
121 |
|
122 HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); |
|
123 |
|
124 HRESULT STDMETHODCALLTYPE EndOfStream(); |
|
125 |
|
126 HRESULT STDMETHODCALLTYPE BeginFlush(); |
|
127 HRESULT STDMETHODCALLTYPE EndFlush(); |
|
128 |
|
129 HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); |
|
130 |
|
131 HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); |
|
132 |
|
133 int currentMediaTypeToken(); |
|
134 HRESULT nextMediaType( |
|
135 int token, int *index, ULONG count, AM_MEDIA_TYPE **types, ULONG *fetchedCount); |
|
136 HRESULT skipMediaType(int token, int *index, ULONG count); |
|
137 HRESULT cloneMediaType(int token, int index, IEnumMediaTypes **enumeration); |
|
138 |
|
139 protected: |
|
140 void customEvent(QEvent *event); |
|
141 |
|
142 private Q_SLOTS: |
|
143 void supportedFormatsChanged(); |
|
144 void sampleReady(); |
|
145 |
|
146 private: |
|
147 HRESULT start(); |
|
148 void stop(); |
|
149 void flush(); |
|
150 |
|
151 enum |
|
152 { |
|
153 StartSurface = QEvent::User, |
|
154 StopSurface, |
|
155 FlushSurface |
|
156 }; |
|
157 |
|
158 LONG m_ref; |
|
159 FILTER_STATE m_state; |
|
160 QAbstractVideoSurface *m_surface; |
|
161 DirectShowEventLoop *m_loop; |
|
162 IFilterGraph *m_graph; |
|
163 IPin *m_peerPin; |
|
164 int m_bytesPerLine; |
|
165 HRESULT m_startResult; |
|
166 QString m_name; |
|
167 QString m_pinId; |
|
168 DirectShowMediaType m_mediaType; |
|
169 QVideoSurfaceFormat m_surfaceFormat; |
|
170 QMutex m_mutex; |
|
171 QWaitCondition m_wait; |
|
172 DirectShowSampleScheduler m_sampleScheduler; |
|
173 }; |
|
174 |
|
175 #endif |