Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to define an Interface for Directshow filter

46 views
Skip to first unread message

Sanjay

unread,
May 7, 2002, 6:19:23 AM5/7/02
to
Hi,
I think im missing something here. Ive written my own filter and
although i can access its property page, i would like to define another
simple interface within the filter to use programmatically.
What is the "best way" to access some functions in my filter
programmatically!

Any direction on this from experience would be super!
Thanks,
Sanjay
Stuttgart.


The March Hare

unread,
May 7, 2002, 8:46:13 AM5/7/02
to
The best way I've found to locate this type of thing is to check out the SDM
samples. For this one I used the ezrgb filter. In particular look at the
following methods and their declarations--or read a book on COM your choice
:) Compile the sample and then try to add another get/put pair like the
ones below.

/
// Return the current effect selected
//
STDMETHODIMP CEZrgb24::get_IPEffect(int *IPEffect,REFTIME *start,REFTIME
*length)
{
CAutoLock cAutolock(&m_EZrgb24Lock);
CheckPointer(IPEffect,E_POINTER);
CheckPointer(start,E_POINTER);
CheckPointer(length,E_POINTER);

*IPEffect = m_effect;
*start = COARefTime(m_effectStartTime);
*length = COARefTime(m_effectTime);

return NOERROR;

} // get_IPEffect


//
// put_IPEffect
//
// Set the required video effect
//
STDMETHODIMP CEZrgb24::put_IPEffect(int IPEffect,REFTIME start,REFTIME
length)
{
CAutoLock cAutolock(&m_EZrgb24Lock);

m_effect = IPEffect;
m_effectStartTime = COARefTime(start);
m_effectTime = COARefTime(length);

SetDirty(TRUE);
return NOERROR;

} // put_IPEffect

"Sanjay" <sanjay.k...@ejay.de> wrote in message
news:OeZ3LBb9BHA.2396@tkmsftngp05...

gz

unread,
May 9, 2002, 5:00:44 AM5/9/02
to
I do this:

1. Create an interface IDL file, name it "iMyFilter.idl", for example.

2. Add something like the following:

------------------------------------------------------------------
[
uuid(A50BB7CA-6B1B-48f0-8610-FFDFD6CE391E),
version(1.0),
helpstring("HermitClub Socket Source Filter Type Library")
]
library MyFilterLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
object,
uuid(53717E55-F35E-47c0-B48A-4F8C1D931020),
helpstring("IMyFilter Interface"),
pointer_default(unique)
]
interface IMyFilter: IUnknown
{
HRESULT Test();
};
};
-----------------------------------------------------------------

3. Add the IDL file to your project.

4. Derive the filter class from your interface, for example:

-----------------------------------------------------------------
#include "iMyFilter.h"
class CMyFilter : public CSource, IMyFilter
-----------------------------------------------------------------

5. Declare the following methods in the "public" section of the class:

-----------------------------------------------------------------
public:
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
STDMETHODIMP Test();
-----------------------------------------------------------------

6. Implements the above methods. For NonDelegatingQueryInterface, do
something like this:

-----------------------------------------------------------------
STDMETHODIMP CMyFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
CheckPointer(ppv, E_POINTER);
if (riid == IID_IMyFilter) {
return GetInterface((IMyFilter*) this, ppv);
} else {
return CSource::NonDelegatingQueryInterface(riid, ppv);
}
}
-----------------------------------------------------------------

7. The following procedures describe how to incorporate the IDL into your
Visual C++ project:

a) Add a file named "iMyFilter_i.c" to the project (it doesn't exist so
we are merely adding a reference)
b) Bring up the "Project Settings" dialog box and select "All
Configurations"
c) Expand the file list and select iMyFilter.idl
d) Click on the "MIDL" tab
e) For "Output header file name:" enter "iMyFilter.h"
f) Check the "Stubless Proxies" box
g) For "UUID File:" enter "iMyFilter_i.c"

8. Compile! (I hope I didn't forget anything, but this is roughly the way
to implment an interface for your filters.)

I hope this helps.

Gary


"The March Hare" <ph...@ndsm.maps> wrote in message
news:O9mQwUc9BHA.1864@tkmsftngp07...

Sanjay

unread,
May 13, 2002, 12:28:16 PM5/13/02
to
Hey, super, i really appreciate the time you guys have spend with my
problem.
Here is what i found i was doing wrong:
The GUID definition for my interface within my filter was...e.g

DEFINE_GUID(IID_IIPMYInterface,
0xfd5010a3, 0x8ebe, 0x11ce, 0x81, 0x83, 0x00, 0xaa, 0x00, 0x57, 0x7d,
0xa1);

Now if you want to use an instance of this filter from within another
program and want to use QueryInterface to obtain the desired interface
(IIPMYInteface) then the above declaration within the filter should be...

static const GUID IID_IIPMYInterface = {0xfd5010a3, 0x8ebe, 0x11ce, 0x81,
0x83, 0x00, 0xaa, 0x00, 0x57, 0x7d, 0xa1};

I already had an implementation similar to the one mentioned by March
Hare...except with another interface containing my own functions within the
filter.
I messed up the GUID declaration and that was it...
sorry guys , pilot error :)
Thanks so much again!
Sanjay

"gz" <gary....@eyemailtech.com> wrote in message
news:3cda37d5$1...@news.nntpserver.com...

0 new messages