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., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 #include "gstdshowutil.h"
26 #include "gstdshowfakesrc.h"
28 _COM_SMARTPTR_TYPEDEF(IDMOWrapperFilter, __uuidof(IDMOWrapperFilter));
31 gst_dshow_get_pin_from_filter (IBaseFilter *filter, PIN_DIRECTION pindir)
33 IEnumPinsPtr enumpins;
37 hres = filter->EnumPins (&enumpins);
42 while (enumpins->Next (1, &pin, NULL) == S_OK)
44 PIN_DIRECTION pindirtmp;
45 hres = pin->QueryDirection (&pindirtmp);
46 if (hres == S_OK && pindir == pindirtmp) {
56 gst_dshow_find_filter(CLSID input_majortype, CLSID input_subtype,
57 CLSID output_majortype, CLSID output_subtype,
58 PreferredFilter *preferred_filters)
63 IFilterMapper2Ptr mapper;
64 IEnumMonikerPtr enum_moniker;
69 /* First, see if any of our preferred filters is available.
70 * If not, we fall back to the highest-ranked installed filter */
71 if (preferred_filters) {
72 while (preferred_filters->filter_guid)
74 /* If the filter is a DMO, we need to do this a bit differently */
75 if (preferred_filters->dmo_category)
77 IDMOWrapperFilterPtr wrapper;
79 hres = CoCreateInstance (CLSID_DMOWrapperFilter, NULL,
81 IID_IBaseFilter, (void **)&filter);
82 if (SUCCEEDED(hres)) {
83 hres = filter->QueryInterface (&wrapper);
84 if (SUCCEEDED(hres)) {
85 hres = wrapper->Init (*preferred_filters->filter_guid,
86 *preferred_filters->dmo_category);
95 hres = CoCreateInstance (*preferred_filters->filter_guid,
97 IID_IBaseFilter, (void **)&filter);
102 /* Continue to the next filter */
107 hres = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
108 IID_IFilterMapper2, (void **) &mapper);
112 inTypes[0] = input_majortype;
113 inTypes[1] = input_subtype;
114 outTypes[0] = output_majortype;
115 outTypes[1] = output_subtype;
117 hres = mapper->EnumMatchingFilters (&enum_moniker, 0,
118 FALSE, MERIT_DO_NOT_USE+1,
119 TRUE, 1, inTypes, NULL, NULL, FALSE,
120 TRUE, 1, outTypes, NULL, NULL);
124 enum_moniker->Reset ();
126 while(enum_moniker->Next (1, &moniker, &fetched) == S_OK)
128 hres = moniker->BindToObject(NULL, NULL,
129 IID_IBaseFilter, (void**)&filter);
130 if(SUCCEEDED(hres)) {