unit mp4Impl;
interface
uses
Windows;
const
TITLEMAXLEN=1024;
DLLNAME = 'xxx.dll';
//函数定义
TMP4Title_Init=function(filename:pchar):boolean; stdcall;
TMP4Title_Uninit=procedure(); stdcall;
TMP4Title_GetChapterCount=function(mtype:TChapterType=ChapterTypeAny):integer; stdcall;
TMP4Title_GetChapter=function(pArr:TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):integer; stdcall;
TMP4Title_AddChapter=function(pArr: TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):boolean; stdcall;
TMP4Title_DelChapter=function(timepos:integer; mtype:TChapterType=ChapterTypeAny):boolean;stdcall;
TMP4Title_DelAllChapter=procedure(mtype:TChapterType=ChapterTypeAny);stdcall;
//接口封装
TMP4InfoAPI=record
private
FHandle: THandle;
FMP4TitleInit: TMP4Title_Init;
FMP4TitleUninit: TMP4Title_Uninit;
FMP4TitleGetChapterCount: TMP4Title_GetChapterCount;
FMP4TitleGetChapter: TMP4Title_GetChapter;
FMP4TitleAddChapter: TMP4Title_AddChapter;
FMP4TitleDelChapter: TMP4Title_DelChapter;
FMP4TitleDelAllChapter: TMP4Title_DelAllChapter;
public
function init(): Boolean;
procedure Free;
function MP4TitleInit(filename:pchar):boolean;
procedure MP4TitleUninit();
function MP4TitleGetChapterCount(mtype:TChapterType=ChapterTypeAny):integer;
function MP4TitleGetChapter(pArr:TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):integer;
function MP4TitleAddChapter(pArr: TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):boolean;
function MP4TitleDelChapter(timepos:integer; mtype:TChapterType=ChapterTypeAny):boolean;
procedure MP4TitleDelAllChapter(mtype:TChapterType=ChapterTypeAny);
end;
implementation
//函数入口名
const
SMP4TitleInit = 'mp4info_init';
SMP4TitleUninit = 'mp4info_uninit';
SMP4TitleGetChapterCount = 'mp4info_getchaptercount';
SMP4TitleGetChapter = 'mp4info_getchapter';
SMP4TitleAddChapter = 'mp4info_addchapter';
SMP4TitleDelChapter = 'mp4info_addchapter';
SMP4TitleDelAllChapter = 'mp4info_delallchapter';
{ TMP4InfoAPI }
procedure TMP4InfoAPI.Free;
begin
if FHandle <> 0 then
begin
FreeLibrary(FHandle);
FHandle := 0;
FillChar(Self, SizeOf(Self), 0);
end;
end;
function TMP4InfoAPI.init: Boolean; //动态加载动态库,初始化函数入口
begin
FHandle := 0;
Windows.InterlockedExchange(Integer(FHandle), LoadLibrary(MP4INFODLLNAME));
if FHandle <> 0 then
begin
FMP4TitleInit := GetProcAddress(FHandle, SMP4TitleInit);
FMP4TitleUninit := GetProcAddress(FHandle, SMP4TitleUninit);
FMP4TitleGetChapterCount := GetProcAddress(FHandle, SMP4TitleGetChapterCount);
FMP4TitleGetChapter := GetProcAddress(FHandle, SMP4TitleGetChapter);
FMP4TitleAddChapter := GetProcAddress(FHandle, SMP4TitleAddChapter);
FMP4TitleDelChapter := GetProcAddress(FHandle, SMP4TitleDelChapter);
FMP4TitleDelAllChapter := GetProcAddress(FHandle, SMP4TitleDelAllChapter);
end;
Result:=FHandle<>0;
end;
function TMP4InfoAPI.MP4TitleAddChapter(pArr: TChaptArr; count: integer;
mtype: TChapterType): boolean;
begin
result := False;
if Assigned(FMP4TitleAddChapter) then
result := FMP4TitleAddChapter(pArr, count, mtype);
end;
procedure TMP4InfoAPI.MP4TitleDelAllChapter(mtype: TChapterType);
begin
MP4TitleDelAllChapter(mtype);
end;
function TMP4InfoAPI.MP4TitleDelChapter(timepos: integer;
mtype: TChapterType): boolean;
begin
result := False;
if Assigned(FMP4TitleDelChapter) then
result := FMP4TitleDelChapter(timepos, mtype);
end;
function TMP4InfoAPI.MP4TitleGetChapter(pArr: TChaptArr; count: integer;
mtype: TChapterType): integer;
begin
result := 0;
if Assigned(FMP4TitleGetChapter) then
result := FMP4TitleGetChapter(pArr, count, mtype);
end;
function TMP4InfoAPI.MP4TitleGetChapterCount(mtype: TChapterType): integer;
begin
result := 0;
if Assigned(FMP4TitleGetChapterCount) then
result := FMP4TitleGetChapterCount(mtype);
end;
function TMP4InfoAPI.MP4TitleInit(filename: pchar): boolean;
begin
result := FMP4TitleInit(filename);
end;
procedure TMP4InfoAPI.MP4TitleUninit;
begin
FMP4TitleUninit;
end;
end.
interface
uses
Windows;
const
TITLEMAXLEN=1024;
DLLNAME = 'xxx.dll';
//函数定义
TMP4Title_Init=function(filename:pchar):boolean; stdcall;
TMP4Title_Uninit=procedure(); stdcall;
TMP4Title_GetChapterCount=function(mtype:TChapterType=ChapterTypeAny):integer; stdcall;
TMP4Title_GetChapter=function(pArr:TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):integer; stdcall;
TMP4Title_AddChapter=function(pArr: TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):boolean; stdcall;
TMP4Title_DelChapter=function(timepos:integer; mtype:TChapterType=ChapterTypeAny):boolean;stdcall;
TMP4Title_DelAllChapter=procedure(mtype:TChapterType=ChapterTypeAny);stdcall;
//接口封装
TMP4InfoAPI=record
private
FHandle: THandle;
FMP4TitleInit: TMP4Title_Init;
FMP4TitleUninit: TMP4Title_Uninit;
FMP4TitleGetChapterCount: TMP4Title_GetChapterCount;
FMP4TitleGetChapter: TMP4Title_GetChapter;
FMP4TitleAddChapter: TMP4Title_AddChapter;
FMP4TitleDelChapter: TMP4Title_DelChapter;
FMP4TitleDelAllChapter: TMP4Title_DelAllChapter;
public
function init(): Boolean;
procedure Free;
function MP4TitleInit(filename:pchar):boolean;
procedure MP4TitleUninit();
function MP4TitleGetChapterCount(mtype:TChapterType=ChapterTypeAny):integer;
function MP4TitleGetChapter(pArr:TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):integer;
function MP4TitleAddChapter(pArr: TChaptArr; count:integer;
mtype:TChapterType=ChapterTypeAny):boolean;
function MP4TitleDelChapter(timepos:integer; mtype:TChapterType=ChapterTypeAny):boolean;
procedure MP4TitleDelAllChapter(mtype:TChapterType=ChapterTypeAny);
end;
implementation
//函数入口名
const
SMP4TitleInit = 'mp4info_init';
SMP4TitleUninit = 'mp4info_uninit';
SMP4TitleGetChapterCount = 'mp4info_getchaptercount';
SMP4TitleGetChapter = 'mp4info_getchapter';
SMP4TitleAddChapter = 'mp4info_addchapter';
SMP4TitleDelChapter = 'mp4info_addchapter';
SMP4TitleDelAllChapter = 'mp4info_delallchapter';
{ TMP4InfoAPI }
procedure TMP4InfoAPI.Free;
begin
if FHandle <> 0 then
begin
FreeLibrary(FHandle);
FHandle := 0;
FillChar(Self, SizeOf(Self), 0);
end;
end;
function TMP4InfoAPI.init: Boolean; //动态加载动态库,初始化函数入口
begin
FHandle := 0;
Windows.InterlockedExchange(Integer(FHandle), LoadLibrary(MP4INFODLLNAME));
if FHandle <> 0 then
begin
FMP4TitleInit := GetProcAddress(FHandle, SMP4TitleInit);
FMP4TitleUninit := GetProcAddress(FHandle, SMP4TitleUninit);
FMP4TitleGetChapterCount := GetProcAddress(FHandle, SMP4TitleGetChapterCount);
FMP4TitleGetChapter := GetProcAddress(FHandle, SMP4TitleGetChapter);
FMP4TitleAddChapter := GetProcAddress(FHandle, SMP4TitleAddChapter);
FMP4TitleDelChapter := GetProcAddress(FHandle, SMP4TitleDelChapter);
FMP4TitleDelAllChapter := GetProcAddress(FHandle, SMP4TitleDelAllChapter);
end;
Result:=FHandle<>0;
end;
function TMP4InfoAPI.MP4TitleAddChapter(pArr: TChaptArr; count: integer;
mtype: TChapterType): boolean;
begin
result := False;
if Assigned(FMP4TitleAddChapter) then
result := FMP4TitleAddChapter(pArr, count, mtype);
end;
procedure TMP4InfoAPI.MP4TitleDelAllChapter(mtype: TChapterType);
begin
MP4TitleDelAllChapter(mtype);
end;
function TMP4InfoAPI.MP4TitleDelChapter(timepos: integer;
mtype: TChapterType): boolean;
begin
result := False;
if Assigned(FMP4TitleDelChapter) then
result := FMP4TitleDelChapter(timepos, mtype);
end;
function TMP4InfoAPI.MP4TitleGetChapter(pArr: TChaptArr; count: integer;
mtype: TChapterType): integer;
begin
result := 0;
if Assigned(FMP4TitleGetChapter) then
result := FMP4TitleGetChapter(pArr, count, mtype);
end;
function TMP4InfoAPI.MP4TitleGetChapterCount(mtype: TChapterType): integer;
begin
result := 0;
if Assigned(FMP4TitleGetChapterCount) then
result := FMP4TitleGetChapterCount(mtype);
end;
function TMP4InfoAPI.MP4TitleInit(filename: pchar): boolean;
begin
result := FMP4TitleInit(filename);
end;
procedure TMP4InfoAPI.MP4TitleUninit;
begin
FMP4TitleUninit;
end;
end.