| 1 |
/* This file is part of the KDE project. |
| 2 |
|
| 3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
|
| 5 |
This library is free software: you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU Lesser General Public License as published by |
| 7 |
the Free Software Foundation, either version 2.1 or 3 of the License. |
| 8 |
|
| 9 |
This library is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public License |
| 15 |
along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef PHONON_QBASEFILTER_H |
| 19 |
#define PHONON_QBASEFILTER_H |
| 20 |
|
| 21 |
#include "phononds9_namespace.h" |
| 22 |
|
| 23 |
#include <QtCore/QString> |
| 24 |
#include <QtCore/QList> |
| 25 |
#include <QtCore/QMutex> |
| 26 |
|
| 27 |
#include <dshow.h> |
| 28 |
|
| 29 |
QT_BEGIN_NAMESPACE |
| 30 |
|
| 31 |
namespace Phonon |
| 32 |
{ |
| 33 |
namespace DS9 |
| 34 |
{ |
| 35 |
class QPin; |
| 36 |
class QBaseFilter : public IBaseFilter, public IMediaSeeking, public IMediaPosition |
| 37 |
{ |
| 38 |
public: |
| 39 |
QBaseFilter(const CLSID &clsid); |
| 40 |
virtual ~QBaseFilter(); |
| 41 |
|
| 42 |
//implementation from IUnknown |
| 43 |
STDMETHODIMP QueryInterface(REFIID iid, void** out); |
| 44 |
STDMETHODIMP_(ULONG) AddRef(); |
| 45 |
STDMETHODIMP_(ULONG) Release(); |
| 46 |
|
| 47 |
//implementation from IPersist |
| 48 |
STDMETHODIMP GetClassID(CLSID *); |
| 49 |
|
| 50 |
//implementation from IMediaFilter |
| 51 |
STDMETHODIMP Stop(); |
| 52 |
STDMETHODIMP Pause(); |
| 53 |
STDMETHODIMP Run(REFERENCE_TIME); |
| 54 |
STDMETHODIMP GetState(DWORD, FILTER_STATE*); |
| 55 |
STDMETHODIMP SetSyncSource(IReferenceClock*); |
| 56 |
STDMETHODIMP GetSyncSource(IReferenceClock**); |
| 57 |
|
| 58 |
//implementation from IBaseFilter |
| 59 |
STDMETHODIMP EnumPins(IEnumPins**); |
| 60 |
STDMETHODIMP FindPin(LPCWSTR, IPin**); |
| 61 |
STDMETHODIMP QueryFilterInfo(FILTER_INFO*); |
| 62 |
STDMETHODIMP JoinFilterGraph(IFilterGraph*, LPCWSTR); |
| 63 |
STDMETHODIMP QueryVendorInfo(LPWSTR*); |
| 64 |
|
| 65 |
//implementation from IMediaSeeking |
| 66 |
STDMETHODIMP GetCapabilities(DWORD *pCapabilities); |
| 67 |
STDMETHODIMP CheckCapabilities(DWORD *pCapabilities); |
| 68 |
STDMETHODIMP IsFormatSupported(const GUID *pFormat); |
| 69 |
STDMETHODIMP QueryPreferredFormat(GUID *pFormat); |
| 70 |
STDMETHODIMP GetTimeFormat(GUID *pFormat); |
| 71 |
STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat); |
| 72 |
STDMETHODIMP SetTimeFormat(const GUID *pFormat); |
| 73 |
STDMETHODIMP GetDuration(LONGLONG *pDuration); |
| 74 |
STDMETHODIMP GetStopPosition(LONGLONG *pStop); |
| 75 |
STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent); |
| 76 |
STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat); |
| 77 |
STDMETHODIMP SetPositions(LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags); |
| 78 |
STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop); |
| 79 |
STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest); |
| 80 |
STDMETHODIMP SetRate(double dRate); |
| 81 |
STDMETHODIMP GetRate(double *dRate); |
| 82 |
STDMETHODIMP GetPreroll(LONGLONG *pllPreroll); |
| 83 |
|
| 84 |
//implementation from IMediaPosition |
| 85 |
STDMETHODIMP get_Duration(REFTIME *plength); |
| 86 |
STDMETHODIMP put_CurrentPosition(REFTIME llTime); |
| 87 |
STDMETHODIMP get_CurrentPosition(REFTIME *pllTime); |
| 88 |
STDMETHODIMP get_StopTime(REFTIME *pllTime); |
| 89 |
STDMETHODIMP put_StopTime(REFTIME llTime); |
| 90 |
STDMETHODIMP get_PrerollTime(REFTIME *pllTime); |
| 91 |
STDMETHODIMP put_PrerollTime(REFTIME llTime); |
| 92 |
STDMETHODIMP put_Rate(double dRate); |
| 93 |
STDMETHODIMP get_Rate(double *pdRate); |
| 94 |
STDMETHODIMP CanSeekForward(LONG *pCanSeekForward); |
| 95 |
STDMETHODIMP CanSeekBackward(LONG *pCanSeekBackward); |
| 96 |
|
| 97 |
//implementation from IDispatch (coming from IMediaPosition) |
| 98 |
STDMETHODIMP GetTypeInfoCount(UINT *pctinfo); |
| 99 |
STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); |
| 100 |
STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); |
| 101 |
STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, |
| 102 |
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); |
| 103 |
|
| 104 |
//own methods |
| 105 |
const QList<QPin *> pins() const; |
| 106 |
void addPin(QPin *pin); |
| 107 |
void removePin(QPin *pin); |
| 108 |
IFilterGraph *graph() const; |
| 109 |
FILTER_STATE state() const; |
| 110 |
|
| 111 |
|
| 112 |
//reimplement this if you want specific processing of media sample |
| 113 |
virtual HRESULT processSample(IMediaSample *); |
| 114 |
|
| 115 |
private: |
| 116 |
QList<QPin*> outputPins() const; |
| 117 |
QList<QPin*> inputPins() const; |
| 118 |
|
| 119 |
void *getUpStreamInterface(const IID &iid) const; |
| 120 |
IMediaSeeking *getUpstreamMediaSeeking(); |
| 121 |
IMediaPosition *getUpstreamMediaPosition(); |
| 122 |
|
| 123 |
LONG m_refCount; |
| 124 |
CLSID m_clsid; |
| 125 |
QString m_name; |
| 126 |
IReferenceClock *m_clock; |
| 127 |
IFilterGraph *m_graph; |
| 128 |
FILTER_STATE m_state; |
| 129 |
QList<QPin *> m_pins; |
| 130 |
mutable QMutex m_mutex; |
| 131 |
}; |
| 132 |
} |
| 133 |
} |
| 134 |
QT_END_NAMESPACE |
| 135 |
|
| 136 |
#endif |