problems implementing IAMWstDecoder COM interface in dotnet
From: Henrik K (hkninmsdn_at_newsgroup.nospam)
Date: 03/16/05
- Next message: Eugene: "Re: Annoying NullReferenceException..."
- Previous message: M Thomas: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 16 Mar 2005 04:27:05 -0800
I'm currently trying to implement a interface to a directx teletext
filter in
dotnet.
The filter has a interface which I would like to use. The only thing I
have
is the following header file from the directx SDK:
DECLARE_INTERFACE_(IAMWstDecoder, IUnknown)
{
public:
//
// Decoder options to be used by apps
//
// What is the decoder's level
STDMETHOD(GetDecoderLevel)(THIS_ AM_WST_LEVEL *lpLevel) PURE ;
// STDMETHOD(SetDecoderLevel)(THIS_ AM_WST_LEVEL Level) PURE ;
// Which of the services is being currently used
STDMETHOD(GetCurrentService)(THIS_ AM_WST_SERVICE *lpService) PURE ;
// STDMETHOD(SetCurrentService)(THIS_ AM_WST_SERVICE Service) PURE ;
// Query/Set the service state (On/Off)
// supported state values are AM_WSTState_On and AM_WSTState_Off
STDMETHOD(GetServiceState)(THIS_ AM_WST_STATE *lpState) PURE ;
STDMETHOD(SetServiceState)(THIS_ AM_WST_STATE State) PURE ;
//
// Output options to be used by downstream filters
//
// What size, bitdepth etc should the output video be
STDMETHOD(GetOutputFormat)(THIS_ LPBITMAPINFOHEADER lpbmih) PURE ;
// GetOutputFormat() method, if successful, returns
// 1. S_FALSE if no output format has so far been defined by
downstream
filters
// 2. S_OK if an output format has already been defined by downstream
filters
STDMETHOD(SetOutputFormat)(THIS_ LPBITMAPINFO lpbmi) PURE ;
// Specify physical color to be used in colorkeying the background
// for overlay mixing
STDMETHOD(GetBackgroundColor)(THIS_ DWORD *pdwPhysColor) PURE ;
STDMETHOD(SetBackgroundColor)(THIS_ DWORD dwPhysColor) PURE ;
// Specify if whole output bitmap should be redrawn for each sample
STDMETHOD(GetRedrawAlways)(THIS_ LPBOOL lpbOption) PURE ;
STDMETHOD(SetRedrawAlways)(THIS_ BOOL bOption) PURE ;
// Specify if the caption text background should be opaque/transparent
STDMETHOD(GetDrawBackgroundMode)(THIS_ AM_WST_DRAWBGMODE *lpMode) PURE
;
STDMETHOD(SetDrawBackgroundMode)(THIS_ AM_WST_DRAWBGMODE Mode) PURE ;
// supported mode values are AM_WST_DrawBGMode_Opaque and
// AM_WST_DrawBGMode_Transparent
STDMETHOD(SetAnswerMode)(THIS_ BOOL bAnswer) PURE ;
STDMETHOD(GetAnswerMode)(THIS_ BOOL* pbAnswer) PURE ;
STDMETHOD(SetHoldPage)(THIS_ BOOL bHoldPage) PURE ;
STDMETHOD(GetHoldPage)(THIS_ BOOL* pbHoldPage) PURE ;
STDMETHOD(GetCurrentPage)(THIS_ PAM_WST_PAGE pWstPage) PURE;
STDMETHOD(SetCurrentPage)(THIS_ AM_WST_PAGE WstPage) PURE;
} ;
I've translated this to C# and it looks like follows:
[ComVisible(true), ComImport,
Guid("70bc06e0-5666-11d3-a184-00105aef9f33"),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
public interface IAMWstDecoder
{
int GetDecoderLevel([Out] out AM_WST_LEVEL lpLevel);
int setDecoderLevel([In] AM_WST_LEVEL lpLevel);
int GetCurrentService([Out] out AM_WST_SERVICE lpService);
int setCurrentService([In] AM_WST_SERVICE lpService);
int GetServiceState([Out] out AM_WST_STATE lpState);
int setServiceState([In] AM_WST_STATE State);
int GetOutputFormat([Out] out BITMAPINFOHEADER lpbmih);
int SetOutputFormat([In] LPBITMAPINFO lpbmi);
int GetBackgroundColor([Out] out long pdwPhysColor);
int SetBackgroundColor([In] long dwPhysColor);
int GetRedrawAlways([Out] out bool lpbOption);
int SetRedrawAlways([In] bool bOption);
int GetDrawBackgroundMode([Out]out AM_WST_DRAWBGMODE lpMode);
int SetDrawBackgroundMode([In] AM_WST_DRAWBGMODE Mode);
int SetAnswerMode([In] bool bAnswer);
int getAnswerMode([Out] out bool Answer);
int SetHoldPage([In] bool bHoldPage);
int getHoldPage([Out] out bool HoldPage);
int GetCurrentPage([Out] out AM_WST_PAGE pWstPage);
int setCurrentPage([In] AM_WST_PAGE WstPage);
}
my problem is when I try to cast my filter to the interface:
graphBuilder.FindFilterByName("WST Decoder", WSTfilter)
exception->WST = CType(WSTfilter, DShowNET.IAMWstDecoder)
I get the
following exception:
System.InvalidCastException: Specified cast is not valid.
I don't know if this is the right group to ask this kind of question
since
I've implemented other interfaces before which were in a IDL file, and
this interface is defined in a .h file so I don't know what I've done
wrong
Thanks in advance
- Next message: Eugene: "Re: Annoying NullReferenceException..."
- Previous message: M Thomas: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|