Support unrar64.dll
[xy_vsfilter.git] / src / apps / mplayerc / FGFilter.h
blob0a8d025ef9e82766c39ef51ec5fba833c8db17fe
1 /*
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)
8 * any later version.
9 *
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
22 #pragma once
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)
32 class CFGFilter
34 protected:
35 CLSID m_clsid;
36 CStringW m_name;
37 struct {union {UINT64 val; struct {UINT64 low:16, mid:32, high:16;};};} m_merit;
38 CAtlList<GUID> m_types;
40 public:
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
60 protected:
61 CStringW m_DisplayName;
62 CComPtr<IMoniker> m_pMoniker;
64 void ExtractFilterData(BYTE* p, UINT len);
66 public:
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);
77 template<class T>
78 class CFGFilterInternal : public CFGFilter
80 public:
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);
87 HRESULT hr = S_OK;
88 CComPtr<IBaseFilter> pBF = new T(NULL, &hr);
89 if(FAILED(hr)) return hr;
91 *ppBF = pBF.Detach();
93 return hr;
97 class CFGFilterFile : public CFGFilter
99 protected:
100 CString m_path;
101 HINSTANCE m_hInst;
103 public:
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
111 protected:
112 HWND m_hWnd;
114 public:
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);
120 class CFGFilterList
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;
127 public:
128 CFGFilterList();
129 virtual ~CFGFilterList();
131 bool IsEmpty() {return m_filters.IsEmpty();}
132 void RemoveAll();
133 void Insert(CFGFilter* pFGF, int group, bool exactmatch = false, bool autodelete = true);
135 POSITION GetHeadPosition();
136 CFGFilter* GetNext(POSITION& pos);