unit Unit2;
interface
uses
Forms, Windows;
type
TbbMPEG =
class
const
szbbMPEGDLL = '
bbMPEG.dll';
// Name der Biblothek
szbbMPEGInit = '
bbMPEGInit';
// bbMPEG initialisieren
szbbMPEGAppWnd = '
bbMPEGAppWnd';
// Handle des ParentWindow
szbbMPEGMakeMPEG = '
bbMPEGMakeMPEG';
// bbMPEG ausführen
szbbMPEGShutdown = '
bbMPEGShutdown';
// bbMPEG deinitialisieren
szbbMPEGSetFocus = '
bbMPEGSetFocus';
type
TmakeMPEGRecInfo =
Record
doVideo : Byte;
// if non-zero, video encoding is performed
width : Cardinal;
// video width, if not even the last column is ignored
height : Cardinal;
// video height, if not even the last row is ignored
startFrame : Cardinal;
// first video frame number
endFrame : Cardinal;
// last video frame number
startSample : Cardinal;
// first audio sample
endSample : Cardinal;
// last audio sample
doAudio : Byte;
// if non-zero, audio encoding is performed
audioRate : Cardinal;
// audio sample rate, only 32000, 44100 and 48000 allowed
stereo : Byte;
// non-zero indicates stereo samples
sampleSize : Cardinal;
// size in bits of samples, must be 16
outputFilename : PChar;
// pointer to a NULL terminated output filename
getVideo : Pointer;
{bbGetVideo;} // pointer to a get audio callback function
getAudio : Pointer;
{bbGetAudio;} // pointer to a get video callback function
end;
PmakeMPEGRecInfo = ^TmakeMPEGRecInfo;
type
TFNbbMPEGInit =
function : Integer;
cdecl {$IFDEF WIN32} stdcall {$ENDIF};
TFNbbMPEGMakeMPEG =
function (makeInfo: PmakeMPEGRecInfo): Integer;
cdecl {$IFDEF WIN32} stdcall {$ENDIF};
TFNbbMPEGAppWnd =
procedure (AppWnd: HWND);
cdecl {$IFDEF WIN32} stdcall {$ENDIF};
TFNbbMPEGShutdown =
procedure cdecl;
{$IFDEF WIN32} stdcall {$ENDIF};
TFNbbMPEGSetFocus =
procedure cdecl;
{$IFDEF WIN32} stdcall {$ENDIF};
private
fbbMPEGLib : THandle;
fbbMPEGInit : TFNbbMPEGInit;
fbbMPEGMakeMPEG : TFNbbMPEGMakeMPEG;
fbbMPEGAppWnd : TFNbbMPEGAppWnd;
fbbMPEGShutdown : TFNbbMPEGShutdown;
fbbMPEGSetFocus : TFNbbMPEGSetFocus;
fOutputFilename :
String;
function GetEntryPoints : boolean;
public
constructor Create;
destructor Destroy;
override;
function Execute: Integer;
published
property outputFilename:
String write fOutputFilename;
end;
implementation
function TbbMPEG.GetEntryPoints: boolean;
begin
@fbbMPEGInit :=
NIL;
@fbbMPEGMakeMPEG :=
NIL;
@fbbMPEGShutdown :=
NIL;
@fbbMPEGSetFocus :=
NIL;
fbbMPEGLib := LoadLibrary(@szbbMPEGDLL[1]);
Result := (fbbMPEGLib <> INVALID_HANDLE_VALUE)
and (fbbMPEGLib <> 0);
if Result
then begin
@fbbMPEGInit := GetProcAddress(fbbMPEGLib, @szbbMPEGInit[1]);
if not Assigned(fbbMPEGInit)
then Result := False;
@fbbMPEGMakeMPEG := GetProcAddress(fbbMPEGLib, @szbbMPEGMakeMPEG[1]);
if not Assigned(fbbMPEGMakeMPEG)
then Result := False;
@fbbMPEGAppWnd := GetProcAddress(fbbMPEGLib, @szbbMPEGAppWnd[1]);
if not Assigned(fbbMPEGAppWnd)
then Result := False;
@fbbMPEGShutdown := GetProcAddress(fbbMPEGLib, @szbbMPEGShutdown[1]);
if not Assigned(fbbMPEGShutdown)
then Result := False;
@fbbMPEGSetFocus := GetProcAddress(fbbMPEGLib, @szbbMPEGSetFocus[1]);
if not Assigned(fbbMPEGSetFocus)
then Result := False;
end;
end;
constructor TbbMPEG.Create;
begin
inherited Create;
end;
destructor TbbMPEG.Destroy;
begin
if Assigned(fbbMPEGShutdown)
then fbbMPEGShutdown;
// call bbMPEG's shutdown routine
if (fbbMPEGLib <> INVALID_HANDLE_VALUE)
and (fbbMPEGLib <> 0)
then FreeLibrary(fbbMPEGLib);
inherited;
end;
function TbbMPEG.Execute: Integer;
var
makeMPEGInfo : TmakeMPEGRecInfo;
begin
Result := -1;
FillChar(makeMPEGInfo, SizeOf(makeMPEGInfo), 0);
// zero the buffer
if GetEntryPoints
and (fbbMPEGInit = 0)
then begin
fbbMPEGSetFocus;
// does not need to be called, just there if needed
makeMPEGInfo.outputFilename := PChar(fOutputFilename);
// output MPEG filename
Result := fbbMPEGMakeMPEG(@makeMPEGInfo);
// call the makeMPEG routine to create an MPEG
end;
end;
end.