2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 #define MERIT64(merit) (((UINT64)(merit))<<16)
25 #define MERIT64_DO_NOT_USE MERIT64(MERIT_DO_NOT_USE)
26 #define MERIT64_DO_USE MERIT64(MERIT_DO_NOT_USE+1)
27 #define MERIT64_UNLIKELY (MERIT64(MERIT_UNLIKELY))
28 #define MERIT64_NORMAL (MERIT64(MERIT_NORMAL))
29 #define MERIT64_PREFERRED (MERIT64(MERIT_PREFERRED))
30 #define MERIT64_ABOVE_DSHOW (MERIT64(1)<<32)
37 struct {union {UINT64 val
; struct {UINT64 low
:16, mid
:32, high
:16;};};} m_merit
;
38 CAtlList
<GUID
> m_types
;
41 CFGFilter(const CLSID
& clsid
, CStringW name
= L
"", UINT64 merit
= MERIT64_DO_USE
);
42 virtual ~CFGFilter() {}
44 CLSID
GetCLSID() {return m_clsid
;}
45 CStringW
GetName() {return m_name
;}
46 UINT64
GetMerit() {return m_merit
.val
;}
47 DWORD
GetMeritForDirectShow() {return m_merit
.mid
;}
48 const CAtlList
<GUID
>& GetTypes() const;
49 void SetTypes(const CAtlList
<GUID
>& types
);
50 void AddType(const GUID
& majortype
, const GUID
& subtype
);
51 bool CheckTypes(const CAtlArray
<GUID
>& types
, bool fExactMatch
);
53 CAtlList
<CString
> m_protocols
, m_extensions
, m_chkbytes
; // TODO: subtype?
55 virtual HRESULT
Create(IBaseFilter
** ppBF
, CInterfaceList
<IUnknown
, &IID_IUnknown
>& pUnks
) = 0;
58 class CFGFilterRegistry
: public CFGFilter
61 CStringW m_DisplayName
;
62 CComPtr
<IMoniker
> m_pMoniker
;
64 void ExtractFilterData(BYTE
* p
, UINT len
);
67 CFGFilterRegistry(IMoniker
* pMoniker
, UINT64 merit
= MERIT64_DO_USE
);
68 CFGFilterRegistry(CStringW DisplayName
, UINT64 merit
= MERIT64_DO_USE
);
69 CFGFilterRegistry(const CLSID
& clsid
, UINT64 merit
= MERIT64_DO_USE
);
71 CStringW
GetDisplayName() {return m_DisplayName
;}
72 IMoniker
* GetMoniker() {return m_pMoniker
;}
74 HRESULT
Create(IBaseFilter
** ppBF
, CInterfaceList
<IUnknown
, &IID_IUnknown
>& pUnks
);
78 class CFGFilterInternal
: public CFGFilter
81 CFGFilterInternal(CStringW name
= L
"", UINT64 merit
= MERIT64_DO_USE
) : CFGFilter(__uuidof(T
), name
, merit
) {}
83 HRESULT
Create(IBaseFilter
** ppBF
, CInterfaceList
<IUnknown
, &IID_IUnknown
>& pUnks
)
85 CheckPointer(ppBF
, E_POINTER
);
88 CComPtr
<IBaseFilter
> pBF
= new T(NULL
, &hr
);
89 if(FAILED(hr
)) return hr
;
97 class CFGFilterFile
: public CFGFilter
104 CFGFilterFile(const CLSID
& clsid
, CString path
, CStringW name
= L
"", UINT64 merit
= MERIT64_DO_USE
);
106 HRESULT
Create(IBaseFilter
** ppBF
, CInterfaceList
<IUnknown
, &IID_IUnknown
>& pUnks
);
109 class CFGFilterVideoRenderer
: public CFGFilter
115 CFGFilterVideoRenderer(HWND hWnd
, const CLSID
& clsid
, CStringW name
= L
"", UINT64 merit
= MERIT64_DO_USE
);
117 HRESULT
Create(IBaseFilter
** ppBF
, CInterfaceList
<IUnknown
, &IID_IUnknown
>& pUnks
);
122 struct filter_t
{int index
; CFGFilter
* pFGF
; int group
; bool exactmatch
, autodelete
;};
123 static int filter_cmp(const void* a
, const void* b
);
124 CAtlList
<filter_t
> m_filters
;
125 CAtlList
<CFGFilter
*> m_sortedfilters
;
129 virtual ~CFGFilterList();
131 bool IsEmpty() {return m_filters
.IsEmpty();}
133 void Insert(CFGFilter
* pFGF
, int group
, bool exactmatch
= false, bool autodelete
= true);
135 POSITION
GetHeadPosition();
136 CFGFilter
* GetNext(POSITION
& pos
);