BlackSun
10th May 2002, 08:23
Hi There,
I am having problems with getting the interface from the DirectVobSub filter using DirectShow.
I think the problem come with the pLangs:
char* pLangs[32] // pLangs[] needs to be preallocated before calling, use LANG_LEN for the length
Seems that I am not declaring it properly. Any help appreciated ;)
------------------------------------------------------------------------
unit DVobSubControls;
interface
uses DirectShow, ActiveX, Windows, Classes, Dialogs, SysUtils;
const
CLSID_DVobSubDecoder : TGuid = '{9852A670-F845-491B-9BE6-EBD841B8A613}';
IID_IDirectVobSubFilter : TGUID = (D1:$3a58b97b;D2:$a2cc;D3:$46b3;D4:($8A,$57,$48,$FA,$B1,$53,$AE,$EE));
IID_IDirectVobSubFilter2 : TGUID = (D1:$639a5c61;D2:$0d72;D3:$4921;D4:($AD,$1A,$B9,$C5,$EC,$A4,$CB,$AF));
// {639A5C61-0D72-4921-AD1A-B9C5ECA4CBAF}
type TLangs=array[1..32] of array[1..256] of char;
type MyLangs=array[1..256] of array[1..32] of char;
type
IDirectVobSubFilter = interface(IUnknown)
['{3A58B97B-A2CC-46b3-8A57-48FAB153AEEE}']
function get_MyFilterData(out fn:Char; out fFlipPicture:boolean; out fHideSubs: boolean; out fNoYUY2Colors:boolean): HResult; stdcall;
function put_MyFilterData(fn:Char; fFlipPicture:boolean; fHideSubs: boolean; fNoYUY2Colors:boolean): HResult; stdcall;
function get_VobSubSettings(out fBuffer:boolean; out iSelected:integer; out nLangs:integer; out pLangs:MyLangs): HResult; stdcall;
function put_VobSubSettings(fBuffer:boolean; iSelected:integer): HResult; stdcall;
function get_TextSettings(out lf:LOGFONT; out color:COLORREF; out fShadow:boolean; out fOutline:boolean; out fAdvancedRenderer:boolean): HResult; stdcall;
function put_TextSettings(lf:LOGFONT; color:COLORREF; fShadow:boolean; fOutline:boolean; fAdvancedRenderer:boolean): HResult; stdcall;
function UnknownFunction: HResult; stdcall;
end;
type
IDirectVobSubFilter2 = interface(IDirectVobSubFilter)
['{639A5C61-0D72-4921-AD1A-B9C5ECA4CBAF}']
function get_FileName(out fn:wChar): HResult; stdcall;
function UnknownFunction: HResult; stdcall;
end;
var
FGrp: IGraphBuilder;
function FindFilter(Cid: TGuid): IBaseFilter;
function IsDVobSubUsed: Boolean;
procedure GetTextSettings(out lf:LOGFONT; out color:COLORREF; out fShadow:boolean; out fOutline:boolean; out fAdvancedRenderer:boolean);
procedure SetTextSettings(lf:LOGFONT; color:COLORREF; fShadow:boolean; fOutline:boolean; fAdvancedRenderer:boolean);
procedure GetVobSubFilename(out fn:wchar);
implementation
procedure GetVobSubFilename(out fn:wchar);
var DVobSub: IbaseFilter;
Setup: IDirectVobSubFilter2;
v: integer;
begin
if FGrp = nil then Exit;
DVobSub:= FindFilter(CLSID_DVobSubDecoder); if DVobSub = nil then Exit;
DVobSub.QueryInterface(IID_IDirectVobSubFilter2, Setup);
if Setup = nil then begin DVobSub:= nil; exit; end;
Setup.get_FileName(fn);
DVobSub:= nil;
Setup:= nil;
end;
procedure SetTextSettings(lf:LOGFONT; color:COLORREF; fShadow:boolean; fOutline:boolean; fAdvancedRenderer:boolean);
var DVobSub: IBasefilter;
Setup: IDirectVobSubFilter;
v: Integer;
begin
if FGrp = nil then Exit;
DVobSub:= FindFilter(CLSID_DVobSubDecoder); if DVobSub = nil then Exit;
DVobSub.QueryInterface(IID_IDirectVobSubFilter, Setup);
if Setup = nil then begin DVobSub:= nil; exit; end;
// v:= Value; if v <-128 then v:=-128; if v>128 then v:=128;
Setup.put_TextSettings(lf,color,fShadow,fOutline,fAdvancedRenderer);
DVobSub:= nil;
Setup:= nil;
end;
procedure GetTextSettings(out lf:LOGFONT; out color:COLORREF; out fShadow:boolean; out fOutline:boolean; out fAdvancedRenderer:boolean);
var DVobSub: IbaseFilter;
Setup: IDirectVobSubFilter;
v: integer;
begin
if FGrp = nil then Exit;
DVobSub:= FindFilter(CLSID_DVobSubDecoder); if DVobSub = nil then Exit;
DVobSub.QueryInterface(IID_IDirectVobSubFilter, Setup);
if Setup = nil then begin DVobSub:= nil; exit; end;
Setup.get_TextSettings(lf,color,fShadow,fOutline,fAdvancedRenderer);
DVobSub:= nil;
Setup:= nil;
end;
function IsDVobSubUsed: Boolean;
begin
Result:= FindFilter(CLSID_DVobSubDecoder) <> nil;
end;
function FindFilter(Cid: TGUID): IBaseFilter;
var EnumF: IEnumFilters;
Fetched: ULong;
Fi: IBaseFilter;
g: TGuid;
FFi: TFilterInfo;
begin
Result:= nil;
if FGrp = nil then Exit;
FGrp.EnumFilters(EnumF);
while EnumF.Next(1, Fi, @Fetched)=S_Ok do begin
Fi.GetClassID(G);
Fi.QueryFilterInfo(FFi);
if IsEqualGUID(g, cid) then begin Result:= Fi; end;
end;
Fi:= nil;
EnumF:= nil;
end;
end.
-----------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define LANG_LEN 256
// {3A58B97B-A2CC-46b3-8A57-48FAB153AEEE}
DEFINE_GUID(IID_IDirectVobSubFilter,
0x3a58b97b, 0xa2cc, 0x46b3, 0x8a, 0x57, 0x48, 0xfa, 0xb1, 0x53, 0xae, 0xee);
DECLARE_INTERFACE_(IDirectVobSubFilter, IUnknown)
{
STDMETHOD(get_MyFilterData) (THIS_
char* fn, // obsolete, replaced by get_FileName
bool* fFlipPicture,
bool* fHideSubs,
bool* fNoYUY2Colors
) PURE;
STDMETHOD(put_MyFilterData) (THIS_
char* fn, // obsolete, replaced by put_FileName
bool fFlipPicture,
bool fHideSubs,
bool fNoYUY2Colors
) PURE;
STDMETHOD(get_VobSubSettings) (THIS_ // obsolete, replaced by get_VobSubSettings2 and get_Languages
bool* fBuffer,
int* iSelected,
int* nLangs,
char* pLangs[32] // pLangs[] needs to be preallocated before calling, use LANG_LEN for the length
) PURE;
STDMETHOD(put_VobSubSettings) (THIS_ // obsolete, replaced by put_VobSubSettings2 and put_Languages
bool fBuffer,
int iSelected
) PURE;
STDMETHOD(get_TextSettings) (THIS_
LOGFONT* lf,
COLORREF* color,
bool* fShadow,
bool* fOutline,
bool* fAdvancedRenderer
) PURE;
STDMETHOD(put_TextSettings) (THIS_
LOGFONT* lf,
COLORREF color,
bool fShadow,
bool fOutline,
bool fAdvancedRenderer
) PURE;
};
// {639A5C61-0D72-4921-AD1A-B9C5ECA4CBAF}
DEFINE_GUID(IID_IDirectVobSubFilter2,
0x639a5c61, 0xd72, 0x4921, 0xad, 0x1a, 0xb9, 0xc5, 0xec, 0xa4, 0xcb, 0xaf);
DECLARE_INTERFACE_(IDirectVobSubFilter2, IDirectVobSubFilter)
{
STDMETHOD(get_FileName) (THIS_
WCHAR* fn
) PURE;
STDMETHOD(put_FileName) (THIS_
WCHAR* fn
) PURE;
STDMETHOD(get_Languages) (THIS_
int* iSelected,
int* nLangs,
WCHAR* pLangs[32] // pLangs[] needs to be preallocated before calling, use LANG_LEN for the length
) PURE;
STDMETHOD(put_Languages) (THIS_
int iSelected
) PURE;
STDMETHOD(get_MyFilterData2) (THIS_
bool* fDoPreBuffering,
bool* fOSD
) PURE;
STDMETHOD(put_MyFilterData2) (THIS_
bool fDoPreBuffering,
bool fOSD
) PURE;
STDMETHOD(get_TextSettings2) (THIS_
bool* fOverridePlacement,
int* xperc,
int* yperc
) PURE;
STDMETHOD(put_TextSettings2) (THIS_
bool fOverridePlacement,
int xperc,
int yperc
) PURE;
STDMETHOD(get_VobSubSettings2) (THIS_
bool* fBuffer,
bool* fOnlyShowForcedSubs
) PURE;
STDMETHOD(put_VobSubSettings2) (THIS_
bool fBuffer,
bool fOnlyShowForcedSubs
) PURE;
STDMETHOD(get_Timing) (THIS_
int* delay,
int* speed
) PURE;
STDMETHOD(put_Timing) (THIS_
int delay,
int speed
) PURE;
};
// {CA0372C1-2DF8-426d-842C-AD7C7D720741}
DEFINE_GUID(IID_IDirectVobSubFilterZoom,
0xca0372c1, 0x2df8, 0x426d, 0x84, 0x2c, 0xad, 0x7c, 0x7d, 0x72, 0x7, 0x41);
DECLARE_INTERFACE_(IDirectVobSubFilterZoom, IUnknown)
{
STDMETHOD(get_ZoomRect) (THIS_
NORMALIZEDRECT* rect
) PURE;
STDMETHOD(put_ZoomRect) (THIS_
NORMALIZEDRECT rect
) PURE;
};
#ifdef __cplusplus
}
#endif
I am having problems with getting the interface from the DirectVobSub filter using DirectShow.
I think the problem come with the pLangs:
char* pLangs[32] // pLangs[] needs to be preallocated before calling, use LANG_LEN for the length
Seems that I am not declaring it properly. Any help appreciated ;)
------------------------------------------------------------------------
unit DVobSubControls;
interface
uses DirectShow, ActiveX, Windows, Classes, Dialogs, SysUtils;
const
CLSID_DVobSubDecoder : TGuid = '{9852A670-F845-491B-9BE6-EBD841B8A613}';
IID_IDirectVobSubFilter : TGUID = (D1:$3a58b97b;D2:$a2cc;D3:$46b3;D4:($8A,$57,$48,$FA,$B1,$53,$AE,$EE));
IID_IDirectVobSubFilter2 : TGUID = (D1:$639a5c61;D2:$0d72;D3:$4921;D4:($AD,$1A,$B9,$C5,$EC,$A4,$CB,$AF));
// {639A5C61-0D72-4921-AD1A-B9C5ECA4CBAF}
type TLangs=array[1..32] of array[1..256] of char;
type MyLangs=array[1..256] of array[1..32] of char;
type
IDirectVobSubFilter = interface(IUnknown)
['{3A58B97B-A2CC-46b3-8A57-48FAB153AEEE}']
function get_MyFilterData(out fn:Char; out fFlipPicture:boolean; out fHideSubs: boolean; out fNoYUY2Colors:boolean): HResult; stdcall;
function put_MyFilterData(fn:Char; fFlipPicture:boolean; fHideSubs: boolean; fNoYUY2Colors:boolean): HResult; stdcall;
function get_VobSubSettings(out fBuffer:boolean; out iSelected:integer; out nLangs:integer; out pLangs:MyLangs): HResult; stdcall;
function put_VobSubSettings(fBuffer:boolean; iSelected:integer): HResult; stdcall;
function get_TextSettings(out lf:LOGFONT; out color:COLORREF; out fShadow:boolean; out fOutline:boolean; out fAdvancedRenderer:boolean): HResult; stdcall;
function put_TextSettings(lf:LOGFONT; color:COLORREF; fShadow:boolean; fOutline:boolean; fAdvancedRenderer:boolean): HResult; stdcall;
function UnknownFunction: HResult; stdcall;
end;
type
IDirectVobSubFilter2 = interface(IDirectVobSubFilter)
['{639A5C61-0D72-4921-AD1A-B9C5ECA4CBAF}']
function get_FileName(out fn:wChar): HResult; stdcall;
function UnknownFunction: HResult; stdcall;
end;
var
FGrp: IGraphBuilder;
function FindFilter(Cid: TGuid): IBaseFilter;
function IsDVobSubUsed: Boolean;
procedure GetTextSettings(out lf:LOGFONT; out color:COLORREF; out fShadow:boolean; out fOutline:boolean; out fAdvancedRenderer:boolean);
procedure SetTextSettings(lf:LOGFONT; color:COLORREF; fShadow:boolean; fOutline:boolean; fAdvancedRenderer:boolean);
procedure GetVobSubFilename(out fn:wchar);
implementation
procedure GetVobSubFilename(out fn:wchar);
var DVobSub: IbaseFilter;
Setup: IDirectVobSubFilter2;
v: integer;
begin
if FGrp = nil then Exit;
DVobSub:= FindFilter(CLSID_DVobSubDecoder); if DVobSub = nil then Exit;
DVobSub.QueryInterface(IID_IDirectVobSubFilter2, Setup);
if Setup = nil then begin DVobSub:= nil; exit; end;
Setup.get_FileName(fn);
DVobSub:= nil;
Setup:= nil;
end;
procedure SetTextSettings(lf:LOGFONT; color:COLORREF; fShadow:boolean; fOutline:boolean; fAdvancedRenderer:boolean);
var DVobSub: IBasefilter;
Setup: IDirectVobSubFilter;
v: Integer;
begin
if FGrp = nil then Exit;
DVobSub:= FindFilter(CLSID_DVobSubDecoder); if DVobSub = nil then Exit;
DVobSub.QueryInterface(IID_IDirectVobSubFilter, Setup);
if Setup = nil then begin DVobSub:= nil; exit; end;
// v:= Value; if v <-128 then v:=-128; if v>128 then v:=128;
Setup.put_TextSettings(lf,color,fShadow,fOutline,fAdvancedRenderer);
DVobSub:= nil;
Setup:= nil;
end;
procedure GetTextSettings(out lf:LOGFONT; out color:COLORREF; out fShadow:boolean; out fOutline:boolean; out fAdvancedRenderer:boolean);
var DVobSub: IbaseFilter;
Setup: IDirectVobSubFilter;
v: integer;
begin
if FGrp = nil then Exit;
DVobSub:= FindFilter(CLSID_DVobSubDecoder); if DVobSub = nil then Exit;
DVobSub.QueryInterface(IID_IDirectVobSubFilter, Setup);
if Setup = nil then begin DVobSub:= nil; exit; end;
Setup.get_TextSettings(lf,color,fShadow,fOutline,fAdvancedRenderer);
DVobSub:= nil;
Setup:= nil;
end;
function IsDVobSubUsed: Boolean;
begin
Result:= FindFilter(CLSID_DVobSubDecoder) <> nil;
end;
function FindFilter(Cid: TGUID): IBaseFilter;
var EnumF: IEnumFilters;
Fetched: ULong;
Fi: IBaseFilter;
g: TGuid;
FFi: TFilterInfo;
begin
Result:= nil;
if FGrp = nil then Exit;
FGrp.EnumFilters(EnumF);
while EnumF.Next(1, Fi, @Fetched)=S_Ok do begin
Fi.GetClassID(G);
Fi.QueryFilterInfo(FFi);
if IsEqualGUID(g, cid) then begin Result:= Fi; end;
end;
Fi:= nil;
EnumF:= nil;
end;
end.
-----------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define LANG_LEN 256
// {3A58B97B-A2CC-46b3-8A57-48FAB153AEEE}
DEFINE_GUID(IID_IDirectVobSubFilter,
0x3a58b97b, 0xa2cc, 0x46b3, 0x8a, 0x57, 0x48, 0xfa, 0xb1, 0x53, 0xae, 0xee);
DECLARE_INTERFACE_(IDirectVobSubFilter, IUnknown)
{
STDMETHOD(get_MyFilterData) (THIS_
char* fn, // obsolete, replaced by get_FileName
bool* fFlipPicture,
bool* fHideSubs,
bool* fNoYUY2Colors
) PURE;
STDMETHOD(put_MyFilterData) (THIS_
char* fn, // obsolete, replaced by put_FileName
bool fFlipPicture,
bool fHideSubs,
bool fNoYUY2Colors
) PURE;
STDMETHOD(get_VobSubSettings) (THIS_ // obsolete, replaced by get_VobSubSettings2 and get_Languages
bool* fBuffer,
int* iSelected,
int* nLangs,
char* pLangs[32] // pLangs[] needs to be preallocated before calling, use LANG_LEN for the length
) PURE;
STDMETHOD(put_VobSubSettings) (THIS_ // obsolete, replaced by put_VobSubSettings2 and put_Languages
bool fBuffer,
int iSelected
) PURE;
STDMETHOD(get_TextSettings) (THIS_
LOGFONT* lf,
COLORREF* color,
bool* fShadow,
bool* fOutline,
bool* fAdvancedRenderer
) PURE;
STDMETHOD(put_TextSettings) (THIS_
LOGFONT* lf,
COLORREF color,
bool fShadow,
bool fOutline,
bool fAdvancedRenderer
) PURE;
};
// {639A5C61-0D72-4921-AD1A-B9C5ECA4CBAF}
DEFINE_GUID(IID_IDirectVobSubFilter2,
0x639a5c61, 0xd72, 0x4921, 0xad, 0x1a, 0xb9, 0xc5, 0xec, 0xa4, 0xcb, 0xaf);
DECLARE_INTERFACE_(IDirectVobSubFilter2, IDirectVobSubFilter)
{
STDMETHOD(get_FileName) (THIS_
WCHAR* fn
) PURE;
STDMETHOD(put_FileName) (THIS_
WCHAR* fn
) PURE;
STDMETHOD(get_Languages) (THIS_
int* iSelected,
int* nLangs,
WCHAR* pLangs[32] // pLangs[] needs to be preallocated before calling, use LANG_LEN for the length
) PURE;
STDMETHOD(put_Languages) (THIS_
int iSelected
) PURE;
STDMETHOD(get_MyFilterData2) (THIS_
bool* fDoPreBuffering,
bool* fOSD
) PURE;
STDMETHOD(put_MyFilterData2) (THIS_
bool fDoPreBuffering,
bool fOSD
) PURE;
STDMETHOD(get_TextSettings2) (THIS_
bool* fOverridePlacement,
int* xperc,
int* yperc
) PURE;
STDMETHOD(put_TextSettings2) (THIS_
bool fOverridePlacement,
int xperc,
int yperc
) PURE;
STDMETHOD(get_VobSubSettings2) (THIS_
bool* fBuffer,
bool* fOnlyShowForcedSubs
) PURE;
STDMETHOD(put_VobSubSettings2) (THIS_
bool fBuffer,
bool fOnlyShowForcedSubs
) PURE;
STDMETHOD(get_Timing) (THIS_
int* delay,
int* speed
) PURE;
STDMETHOD(put_Timing) (THIS_
int delay,
int speed
) PURE;
};
// {CA0372C1-2DF8-426d-842C-AD7C7D720741}
DEFINE_GUID(IID_IDirectVobSubFilterZoom,
0xca0372c1, 0x2df8, 0x426d, 0x84, 0x2c, 0xad, 0x7c, 0x7d, 0x72, 0x7, 0x41);
DECLARE_INTERFACE_(IDirectVobSubFilterZoom, IUnknown)
{
STDMETHOD(get_ZoomRect) (THIS_
NORMALIZEDRECT* rect
) PURE;
STDMETHOD(put_ZoomRect) (THIS_
NORMALIZEDRECT rect
) PURE;
};
#ifdef __cplusplus
}
#endif