📄 vidrenderer.pas
字号:
// Set the new size and position
WindowFlags := SWP_NOZORDER or SWP_FRAMECHANGED or SWP_NOACTIVATE;
ASSERT(IsWindow(fRenderer.Handle));
bSuccess := SetWindowPos(fRenderer.Handle, // Window handle
HWND_TOP, // Put it at the top
Left, // Left position
Top, // Top position
Width, // Window width
Height, // Window height
WindowFlags); // Show window flags
ASSERT(bSuccess);
{$IFDEF DEBUG}
DbgLog(Self,'SWP failed error : ' + inttohex(GetLastError,8));
{$ENDIF}
if not bSuccess then Result := E_INVALIDARG
else Result := NOERROR;
end;
function TVideoRenderer.GetWindowPosition(out pLeft, pTop, pWidth, pHeight: Longint): HResult; stdcall;
var
WindowRect : TRect;
begin
if not CheckConnected(FInputPin,Result) then Exit;
// Get the current window coordinates
GetWindowRect(fRenderer.Handle,WindowRect);
// Convert the RECT into left,top,width and height values
pLeft := WindowRect.left;
pTop := WindowRect.top;
pWidth := WindowRect.right - WindowRect.left;
pHeight := WindowRect.bottom - WindowRect.top;
Result := NOERROR;
end;
function TVideoRenderer.GetMinIdealImageSize(out pWidth, pHeight: Longint): HResult; stdcall;
var
State : TFilterState;
DefaultRect : TRect;
begin
if not CheckConnected(FInputPin,Result) then Exit;
// Must not be stopped for this to work correctly
GetState(0,State);
if (State = State_Stopped) then
begin
Result := VFW_E_WRONG_STATE;
Exit;
end;
DefaultRect := Rect(0,0,DEFWIDTH,DEFHEIGHT);
pWidth := DefaultRect.Right - DefaultRect.Left;
pHeight := DefaultRect.Bottom - DefaultRect.Top;
Result := NOERROR;
end;
function TVideoRenderer.GetMaxIdealImageSize(out pWidth, pHeight: Longint): HResult; stdcall;
var
State : TFilterState;
DefaultRect : TRect;
begin
if not CheckConnected(FInputPin,Result) then Exit;
// Must not be stopped for this to work correctly
GetState(0,State);
if (State = State_Stopped) then
begin
Result := VFW_E_WRONG_STATE;
Exit;
end;
DefaultRect := Rect(0,0,DEFWIDTH,DEFHEIGHT);
pWidth := DefaultRect.Right - DefaultRect.Left;
pHeight := DefaultRect.Bottom - DefaultRect.Top;
Result := NOERROR;
end;
function TVideoRenderer.GetRestorePosition(out pLeft, pTop, pWidth, pHeight: Longint): HResult; stdcall;
var
Place : TWindowPlacement;
WorkArea : TRect;
begin
if not CheckConnected(FInputPin,Result) then Exit;
// Use GetWindowPlacement to find the restore position
Place.length := sizeof(TWindowPlacement);
GetWindowPlacement(fRenderer.Handle,@Place);
// We must take into account any task bar present
if SystemParametersInfo(SPI_GETWORKAREA,0,@WorkArea,0) then
begin
if (fRenderer.ParentWindow = 0) then
begin
inc(Place.rcNormalPosition.top,WorkArea.top);
inc(Place.rcNormalPosition.bottom,WorkArea.top);
inc(Place.rcNormalPosition.left,WorkArea.left);
inc(Place.rcNormalPosition.right,WorkArea.left);
end;
end;
// Convert the RECT into left,top,width and height values
pLeft := Place.rcNormalPosition.left;
pTop := Place.rcNormalPosition.top;
pWidth := Place.rcNormalPosition.right - Place.rcNormalPosition.left;
pHeight := Place.rcNormalPosition.bottom - Place.rcNormalPosition.top;
Result := NOERROR;
end;
function TVideoRenderer.HideCursor(HideCursor: LongBool): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.IsCursorHidden(out CursorHidden: LongBool): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
(*** IBasicVideo methods ******************************************************)
function TVideoRenderer.get_AvgTimePerFrame(out pAvgTimePerFrame: TRefTime): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
pAvgTimePerFrame := fFormat.AvgTimePerFrame;
Result := NOERROR;
end;
function TVideoRenderer.get_BitRate(out pBitRate: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
pBitRate := fFormat.dwBitRate;
Result := NOERROR;
end;
function TVideoRenderer.get_BitErrorRate(out pBitErrorRate: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
pBitErrorRate := fFormat.dwBitErrorRate;
Result := NOERROR;
end;
function TVideoRenderer.get_VideoWidth(out pVideoWidth: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
pVideoWidth := fFormat.bmiHeader.biWidth;
Result := NOERROR;
end;
function TVideoRenderer.get_VideoHeight(out pVideoHeight: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
pVideoHeight := fFormat.bmiHeader.biHeight;
Result := NOERROR;
end;
function TVideoRenderer.put_SourceLeft(SourceLeft: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_SourceLeft(out pSourceLeft: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.put_SourceWidth(SourceWidth: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_SourceWidth(out pSourceWidth: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.put_SourceTop(SourceTop: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_SourceTop(out pSourceTop: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.put_SourceHeight(SourceHeight: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_SourceHeight(out pSourceHeight: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.put_DestinationLeft(DestinationLeft: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_DestinationLeft(out pDestinationLeft: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.put_DestinationWidth(DestinationWidth: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_DestinationWidth(out pDestinationWidth: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.put_DestinationTop(DestinationTop: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_DestinationTop(out pDestinationTop: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.put_DestinationHeight(DestinationHeight: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.get_DestinationHeight(out pDestinationHeight: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.SetSourcePosition(Left, Top, Width, Height: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.GetSourcePosition(out pLeft, pTop, pWidth, pHeight: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.SetDefaultSourcePosition: HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.SetDestinationPosition(Left, Top, Width, Height: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.GetDestinationPosition(out pLeft, pTop, pWidth, pHeight: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.SetDefaultDestinationPosition: HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.GetVideoSize(out pWidth, Height: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
pWidth := fFormat.bmiHeader.biWidth;
Height := fFormat.bmiHeader.biHeight;
Result := NOERROR;
end;
function TVideoRenderer.GetVideoPaletteEntries(StartIndex, Entries: Longint; out pRetrieved: Longint; out pPalette): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.GetCurrentImage(var BufferSize: Longint; var pDIBImage): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.IsUsingDefaultSource: HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
function TVideoRenderer.IsUsingDefaultDestination: HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
(*** IBasicVideo2 methods *****************************************************)
function TVideoRenderer.GetPreferredAspectRatio(out plAspectX, plAspectY: Longint): HResult; stdcall;
begin
if not CheckConnected(FInputPin,Result) then Exit;
Result := E_NOTIMPL;
end;
(*** IAMFilterMiscFlags methods ***********************************************)
function TVideoRenderer.GetMiscFlags: ULONG; stdcall;
begin
Result := AM_FILTER_MISC_FLAGS_IS_RENDERER;
end;
(******************************************************************************)
initialization
TBCClassFactory.CreateFilter(TVideoRenderer, '_Delphi Video Renderer',
CLSID_VideoRenderer, CLSID_LegacyAmFilterCategory, MERIT_DO_NOT_USE,
0, nil
);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -