2 * Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
26 #include "gstdshowutil.h"
27 #include "gstdshowfakesrc.h"
30 gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir)
32 CComPtr<IEnumPins> enumpins;
36 hres = filter->EnumPins (&enumpins);
41 while (enumpins->Next (1, &pin, NULL) == S_OK)
43 PIN_DIRECTION pindirtmp;
44 hres = pin->QueryDirection (&pindirtmp);
45 if (hres == S_OK && pindir == pindirtmp) {
55 gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
56 CLSID output_majortype, CLSID output_subtype,
57 PreferredFilter *preferred_filters)
62 CComPtr<IFilterMapper2> mapper;
63 CComPtr<IEnumMoniker> enum_moniker;
64 CComPtr<IMoniker> moniker;
68 /* First, see if any of our preferred filters is available.
69 * If not, we fall back to the highest-ranked installed filter */
70 if (preferred_filters) {
71 while (preferred_filters->filter_guid)
73 /* If the filter is a DMO, we need to do this a bit differently */
74 if (preferred_filters->dmo_category)
76 CComPtr<IDMOWrapperFilter> wrapper;
78 hres = CoCreateInstance (CLSID_DMOWrapperFilter, NULL,
80 IID_IBaseFilter, (void **)&filter);
81 if (SUCCEEDED(hres)) {
82 hres = filter->QueryInterface (&wrapper);
83 if (SUCCEEDED(hres)) {
84 hres = wrapper->Init (*preferred_filters->filter_guid,
85 *preferred_filters->dmo_category);
94 hres = CoCreateInstance (*preferred_filters->filter_guid,
96 IID_IBaseFilter, (void **)&filter);
101 /* Continue to the next filter */
106 hres = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
107 IID_IFilterMapper2, (void **) &mapper);
111 inTypes[0] = input_majortype;
112 inTypes[1] = input_subtype;
113 outTypes[0] = output_majortype;
114 outTypes[1] = output_subtype;
116 hres = mapper->EnumMatchingFilters (&enum_moniker, 0,
117 FALSE, MERIT_DO_NOT_USE+1,
118 TRUE, 1, inTypes, NULL, NULL, FALSE,
119 TRUE, 1, outTypes, NULL, NULL);
123 enum_moniker->Reset ();
125 while(enum_moniker->Next (1, &moniker, &fetched) == S_OK)
127 hres = moniker->BindToObject(NULL, NULL,
128 IID_IBaseFilter, (void**)&filter);
129 if(SUCCEEDED(hres)) {