-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediaInfoDLL.pas
191 lines (166 loc) · 9.08 KB
/
MediaInfoDLL.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
unit MediaInfoDll;
{
MediaInfoLib (MediaInfo.dll v0.7.7.6) Interface for Delphi
(c)2008 by Norbert Mereg (Icebob)
http://MediaArea.net/MediaInfo
}
interface
uses
{$IFDEF WIN32}
Windows;
{$ELSE}
Wintypes, WinProcs;
{$ENDIF}
type TMIStreamKind =
(
Stream_General,
Stream_Video,
Stream_Audio,
Stream_Text,
Stream_Other,
Stream_Image,
Stream_Menu,
Stream_Max
);
type TMIInfo =
(
Info_Name,
Info_Text,
Info_Measure,
Info_Options,
Info_Name_Text,
Info_Measure_Text,
Info_Info,
Info_HowTo,
Info_Max
);
type TMIInfoOption =
(
InfoOption_ShowInInform,
InfoOption_Reserved,
InfoOption_ShowInSupported,
InfoOption_TypeOfValue,
InfoOption_Max
);
{$IFDEF STATIC}
// Unicode methods
function MediaInfo_New(): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
procedure MediaInfo_Delete(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF}; external 'MediaInfo.Dll';
function MediaInfo_Open(Handle: Cardinal; File__: PWideChar): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
procedure MediaInfo_Close(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfo_Inform(Handle: Cardinal; Reserved: Integer): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfo_GetI(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text
function MediaInfo_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PWideChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
function MediaInfo_Option(Handle: Cardinal; Option: PWideChar; Value: PWideChar): PWideChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfo_State_Get(Handle: Cardinal): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfo_Count_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
// Ansi methods
function MediaInfoA_New(): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
procedure MediaInfoA_Delete(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfoA_Open(Handle: Cardinal; File__: PChar): Cardinal cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
procedure MediaInfoA_Close(Handle: Cardinal) cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfoA_Inform(Handle: Cardinal; Reserved: Integer): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfoA_GetI(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text
function MediaInfoA_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll'; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
function MediaInfoA_Option(Handle: Cardinal; Option: PChar; Value: PChar): PChar cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfoA_State_Get(Handle: Cardinal): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
function MediaInfoA_Count_Get(Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl {$IFDEF WIN32} stdcall {$ENDIF};external 'MediaInfo.Dll';
{$ELSE}
var
IsMediaInfoLoaded: THandle = 0;
// Unicode methods
MediaInfo_New: function (): Cardinal cdecl stdcall;
MediaInfo_Delete: procedure (Handle: Cardinal) cdecl stdcall;
MediaInfo_Open: function (Handle: Cardinal; File__: PWideChar): Cardinal cdecl stdcall;
MediaInfo_Close: procedure (Handle: Cardinal) cdecl stdcall;
MediaInfo_Inform: function (Handle: Cardinal; Reserved: Integer): PWideChar cdecl stdcall;
MediaInfo_GetI: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PWideChar cdecl stdcall; //Default: KindOfInfo=Info_Text,
MediaInfo_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PWideChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PWideChar cdecl stdcall; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
MediaInfo_Option: function (Handle: Cardinal; Option: PWideChar; Value: PWideChar): PWideChar cdecl stdcall;
MediaInfo_State_Get: function (Handle: Cardinal): Integer cdecl stdcall;
MediaInfo_Count_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl stdcall;
// Ansi methods
MediaInfoA_New: function (): Cardinal cdecl stdcall;
MediaInfoA_Delete: procedure (Handle: Cardinal) cdecl stdcall;
MediaInfoA_Open: function (Handle: Cardinal; File__: PChar): Cardinal cdecl stdcall;
MediaInfoA_Close: procedure (Handle: Cardinal) cdecl stdcall;
MediaInfoA_Inform: function (Handle: Cardinal; Reserved: Integer): PChar cdecl stdcall;
MediaInfoA_GetI: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: Integer; KindOfInfo: TMIInfo): PChar cdecl stdcall; //Default: KindOfInfo=Info_Text
MediaInfoA_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer; Parameter: PChar; KindOfInfo: TMIInfo; KindOfSearch: TMIInfo): PChar cdecl stdcall; //Default: KindOfInfo=Info_Text, KindOfSearch=Info_Name
MediaInfoA_Option: function (Handle: Cardinal; Option: PChar; Value: PChar): PChar cdecl stdcall;
MediaInfoA_State_Get: function (Handle: Cardinal): Integer cdecl stdcall;
MediaInfoA_Count_Get: function (Handle: Cardinal; StreamKind: TMIStreamKind; StreamNumber: Integer): Integer cdecl stdcall;
function MediaInfoDLL_Load(LibPath: string): boolean; overload;
function MediaInfoDLL_Load: boolean; overload;
procedure UnLoadMediaInfoLibrary;
{$ENDIF}
implementation
{$IFNDEF STATIC}
function MI_GetProcAddress(Name: PChar; var Addr: Pointer): boolean;
begin
Addr := GetProcAddress(IsMediaInfoLoaded, Name);
Result := Addr <> nil;
end;
function MediaInfoDLL_Load(LibPath: string): boolean;
begin
Result := False;
if IsMediaInfoLoaded = 0 then
IsMediaInfoLoaded := LoadLibrary(PChar(LibPath));
if IsMediaInfoLoaded <> 0 then
begin
MI_GetProcAddress('MediaInfo_New', @MediaInfo_New);
MI_GetProcAddress('MediaInfo_Delete', @MediaInfo_Delete);
MI_GetProcAddress('MediaInfo_Open', @MediaInfo_Open);
MI_GetProcAddress('MediaInfo_Close', @MediaInfo_Close);
MI_GetProcAddress('MediaInfo_Inform', @MediaInfo_Inform);
MI_GetProcAddress('MediaInfo_GetI', @MediaInfo_GetI);
MI_GetProcAddress('MediaInfo_Get', @MediaInfo_Get);
MI_GetProcAddress('MediaInfo_Option', @MediaInfo_Option);
MI_GetProcAddress('MediaInfo_State_Get', @MediaInfo_State_Get);
MI_GetProcAddress('MediaInfo_Count_Get', @MediaInfo_Count_Get);
MI_GetProcAddress('MediaInfoA_New', @MediaInfoA_New);
MI_GetProcAddress('MediaInfoA_Delete', @MediaInfoA_Delete);
MI_GetProcAddress('MediaInfoA_Open', @MediaInfoA_Open);
MI_GetProcAddress('MediaInfoA_Close', @MediaInfoA_Close);
MI_GetProcAddress('MediaInfoA_Inform', @MediaInfoA_Inform);
MI_GetProcAddress('MediaInfoA_GetI', @MediaInfoA_GetI);
MI_GetProcAddress('MediaInfoA_Get', @MediaInfoA_Get);
MI_GetProcAddress('MediaInfoA_Option', @MediaInfoA_Option);
MI_GetProcAddress('MediaInfoA_State_Get', @MediaInfoA_State_Get);
MI_GetProcAddress('MediaInfoA_Count_Get', @MediaInfoA_Count_Get);
Result := True;
end;
end;
function MediaInfoDLL_Load: boolean;
begin
Result:=MediaInfoDLL_Load('MediaInfo.dll');
end;
procedure UnLoadMediaInfoLibrary;
begin
if IsMediaInfoLoaded <> 0 then begin
FreeLibrary(IsMediaInfoLoaded);
IsMediaInfoLoaded := 0;
MediaInfo_New:= nil;
MediaInfo_Delete:= nil;
MediaInfo_Open:= nil;
MediaInfo_Close:= nil;
MediaInfo_Inform:= nil;
MediaInfo_GetI:= nil;
MediaInfo_Get:= nil;
MediaInfo_Option:= nil;
MediaInfo_State_Get:= nil;
MediaInfo_Count_Get:= nil;
MediaInfoA_New:= nil;
MediaInfoA_Delete:= nil;
MediaInfoA_Open:= nil;
MediaInfoA_Close:= nil;
MediaInfoA_Inform:= nil;
MediaInfoA_GetI:= nil;
MediaInfoA_Get:= nil;
MediaInfoA_Option:= nil;
MediaInfoA_State_Get:= nil;
MediaInfoA_Count_Get:= nil;
end;
end;
{$ENDIF}
end.