Discussion:
Custom Interfaces for querying from Filters?
(too old to reply)
BartMan
2006-04-18 21:30:01 UTC
Permalink
Greetings,

I was wondering if it is possible to add custom interfaces (ATL created) to
a render filter and make it so it is exposed by allowing the user to query
for it?

For example I was looking at the sampvid project in directshow, and noticed
the "NonDelegatingQueryInterface" function. I was wondering if I can also
expose a custom interface by using this method?
(ie:) Inside my render filter

CComPtr<IFoo> m_spIFoo; // Interface object created somewhere.

// Reference the IID_IFoo for the interface object.
STDMETHODIMP CVideoRenderer::NonDelegatingQueryInterface(REFIID riid,void
**ppv)
{
// ... Code removed to make eaiser for post
if (riid == IID_IFoo)
{
return m_spIFoo.CopyTo(ppv);
}
return E_FAIL;
}

Then the user could query for my filter for specific items:
CComPtr<IFoo> m_spTest;
m_spMyRenderFilter->QueryInterface(IID_Foo, (LPVOID *) &m_spTest);

Thanks in advance for any suggestions!
The March Hare [MVP]
2006-04-18 21:35:06 UTC
Permalink
Post by BartMan
I was wondering if it is possible to add custom interfaces (ATL created) to
a render filter and make it so it is exposed by allowing the user to query
for it?
Not sure what you mean by ATL created, but you can add custom interfaces to
the sampvid sample. I have done exactly that. IIRC, it has a custom
interface already to set the text value. Otherwise, see the ezrgb sample
for an example.
--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution
BartMan
2006-04-19 02:28:01 UTC
Permalink
Post by The March Hare [MVP]
Not sure what you mean by ATL created, but you can add custom interfaces to
the sampvid sample. I have done exactly that. IIRC, it has a custom
interface already to set the text value. Otherwise, see the ezrgb sample
for an example.
I was creating a simple ATL Com object, and trying to use that interface
within the filter via the #import "" method, but the interface method in
those filter examples seem like a much eaiser method.

Thanks for the information, I am going to try it out with my filter!
The March Hare [MVP]
2006-04-19 02:43:59 UTC
Permalink
Post by BartMan
I was creating a simple ATL Com object, and trying to use that interface
within the filter via the #import "" method, but the interface method in
those filter examples seem like a much eaiser method.
AFAIK, ATL and the dshow baseclasses are incompatible. It's fairly
straightforward to create a custom interface by looking at the samples.
The VC 7.1 filter wizard on my downloads page also does this but it doesn't
produce a renderer filter (source, transform and in-place only).
--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution
BartMan
2006-04-20 12:54:02 UTC
Permalink
Post by The March Hare [MVP]
AFAIK, ATL and the dshow baseclasses are incompatible. It's fairly
straightforward to create a custom interface by looking at the samples.
The VC 7.1 filter wizard on my downloads page also does this but it doesn't
produce a renderer filter (source, transform and in-place only).
Good to know about the ATL, will have to check out your wizards for filters.

Thanks again!
The March Hare [MVP]
2006-04-20 13:11:13 UTC
Permalink
Post by BartMan
Post by The March Hare [MVP]
AFAIK, ATL and the dshow baseclasses are incompatible. It's fairly
straightforward to create a custom interface by looking at the samples.
The VC 7.1 filter wizard on my downloads page also does this but it doesn't
produce a renderer filter (source, transform and in-place only).
Good to know about the ATL, will have to check out your wizards for filters.
Thanks again!
No problem... good luck.
--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution
Arto
2006-04-24 11:17:01 UTC
Permalink
In my experience, ATL actually works quite well to create at least some types
of DirectShow filters. I've used it to create several renderers. ATL gives a
lot for free, e.g. base classes for creating Windows (even Window
applications) and Dialogs. The only trick is to avoid linking in the stuff in
the dllentry.cpp file in the base classes and let ATL handle that instead.
This mans that you need to explicitly register your filters using the
IFilterMapper2 interface if you want them to be available for Intelligent
Connect (there's an example in the DirectShow documentation). If you just use
basic ATL to register your DLL then you can still build graphs with your
filter but you need to add the filter to the graph explicitly.

I remember there were some linker issues related to instantiatiation of
certain base classes but I was able to weed them all out. Unfortunately I
don't remember the details right now.

Arto
Post by The March Hare [MVP]
AFAIK, ATL and the dshow baseclasses are incompatible. It's fairly
straightforward to create a custom interface by looking at the samples.
The VC 7.1 filter wizard on my downloads page also does this but it doesn't
produce a renderer filter (source, transform and in-place only).
Continue reading on narkive:
Loading...