J
johnnywww
Unregistered / Unconfirmed
GUEST, unregistred user!
我用DSPack编写了一个Render,注册后,用TBaseFilter控件的Filter Editor可以看见这个Filter,但是Filter没有Input Pin,而且Filter Editor无法退出。代码如下:
unit UGSMVideoRender;
interface
uses
Windows, ActiveX, BaseClass, DirectShow9, DSUtil, UInfGSMDataTransfer;
const
CLSID_GSMVideoTransferRender: TGUID =
'{4FD16F79-7648-41BD-9672-FC877DE8F184}';
type
IInfCarMonitorService = interface(IUnknown)
['{6A215DC7-6D65-466D-9C0E-F5135B777A36}']
procedure SetGSMDataTransfer(InfGSMDataTransfer: IInfGSMDataTransfer);
stdcall;
end;
TGSMVideoRender = class(TBCBaseRenderer, IInfCarMonitorService)
private
FCarMonitor: IInfGSMDataTransfer;
public
functiondo
RenderSample(MediaSample: IMediaSample): HResult;
override;
function CheckMediaType(MediaType: PAMMediaType): HResult;
override;
procedure SetGSMDataTransfer(InfGSMDataTransfer: IInfGSMDataTransfer);
stdcall;
end;
implementation
{ TGSMVideoRender }
function TGSMVideoRender.CheckMediaType(MediaType: PAMMediaType): HResult;
begin
if not (Assigned(MediaType)) then
begin
Result := E_POINTER;
Exit;
end;
// the major type must match
//
if IsEqualGUID(MediaType.majortype, MEDIATYPE_Video) then
begin
Result := E_INVALIDARG;
Exit;
end;
// the sub type must match
//
if IsEqualGUID(MediaType.subtype, MEDIASUBTYPE_ARGB32) then
begin
Result := E_INVALIDARG;
Exit;
end;
Result := 0;
end;
function TGSMVideoRender.DoRenderSample(
MediaSample: IMediaSample): HResult;
var
Data: PByte;
DataLen: Cardinal;
begin
if not Assigned(@MediaSample) then
begin
Result := E_POINTER;
Exit;
end;
MediaSample.GetPointer(Data);
DataLen := MediaSample.GetActualDataLength;
if (DataLen > 0) and (Assigned(FCarMonitor)) then
begin
FCarMonitor.SendData(Data, DataLen);
end;
Result := 0;
end;
procedure TGSMVideoRender.SetGSMDataTransfer(
InfGSMDataTransfer: IInfGSMDataTransfer);
begin
FCarMonitor := InfGSMDataTransfer;
end;
initialization
TBCClassFactory.CreateFilter(TGSMVideoRender, 'GSM Video Transfer Render',
CLSID_GSMVideoTransferRender, CLSID_LegacyAmFilterCategory,
MERIT_DO_NOT_USE, 0, nil);
end.
unit UGSMVideoRender;
interface
uses
Windows, ActiveX, BaseClass, DirectShow9, DSUtil, UInfGSMDataTransfer;
const
CLSID_GSMVideoTransferRender: TGUID =
'{4FD16F79-7648-41BD-9672-FC877DE8F184}';
type
IInfCarMonitorService = interface(IUnknown)
['{6A215DC7-6D65-466D-9C0E-F5135B777A36}']
procedure SetGSMDataTransfer(InfGSMDataTransfer: IInfGSMDataTransfer);
stdcall;
end;
TGSMVideoRender = class(TBCBaseRenderer, IInfCarMonitorService)
private
FCarMonitor: IInfGSMDataTransfer;
public
functiondo
RenderSample(MediaSample: IMediaSample): HResult;
override;
function CheckMediaType(MediaType: PAMMediaType): HResult;
override;
procedure SetGSMDataTransfer(InfGSMDataTransfer: IInfGSMDataTransfer);
stdcall;
end;
implementation
{ TGSMVideoRender }
function TGSMVideoRender.CheckMediaType(MediaType: PAMMediaType): HResult;
begin
if not (Assigned(MediaType)) then
begin
Result := E_POINTER;
Exit;
end;
// the major type must match
//
if IsEqualGUID(MediaType.majortype, MEDIATYPE_Video) then
begin
Result := E_INVALIDARG;
Exit;
end;
// the sub type must match
//
if IsEqualGUID(MediaType.subtype, MEDIASUBTYPE_ARGB32) then
begin
Result := E_INVALIDARG;
Exit;
end;
Result := 0;
end;
function TGSMVideoRender.DoRenderSample(
MediaSample: IMediaSample): HResult;
var
Data: PByte;
DataLen: Cardinal;
begin
if not Assigned(@MediaSample) then
begin
Result := E_POINTER;
Exit;
end;
MediaSample.GetPointer(Data);
DataLen := MediaSample.GetActualDataLength;
if (DataLen > 0) and (Assigned(FCarMonitor)) then
begin
FCarMonitor.SendData(Data, DataLen);
end;
Result := 0;
end;
procedure TGSMVideoRender.SetGSMDataTransfer(
InfGSMDataTransfer: IInfGSMDataTransfer);
begin
FCarMonitor := InfGSMDataTransfer;
end;
initialization
TBCClassFactory.CreateFilter(TGSMVideoRender, 'GSM Video Transfer Render',
CLSID_GSMVideoTransferRender, CLSID_LegacyAmFilterCategory,
MERIT_DO_NOT_USE, 0, nil);
end.