DCL 4.0
Loading...
Searching...
No Matches
MediaInfoDLL.h
Go to the documentation of this file.
1/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2 *
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the License.html file in the root of the source tree.
5 */
6
7//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8//
9// Public DLL interface implementation
10// Wrapper for MediaInfo Library
11// See MediaInfo.h for help
12//
13//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
14
15#ifndef MediaInfoDLLH
16#define MediaInfoDLLH
17
18//***************************************************************************
19// Platforms (from libzen)
20//***************************************************************************
21
22/*---------------------------------------------------------------------------*/
23/*Win32*/
24#if defined(__NT__) || defined(_WIN32) || defined(WIN32)
25#ifndef WIN32
26#define WIN32
27#endif
28#ifndef _WIN32
29#define _WIN32
30#endif
31#ifndef __WIN32__
32#define __WIN32__ 1
33#endif
34#endif
35
36/*---------------------------------------------------------------------------*/
37/*Win64*/
38#if defined(_WIN64) || defined(WIN64)
39#ifndef WIN64
40#define WIN64
41#endif
42#ifndef _WIN64
43#define _WIN64
44#endif
45#ifndef __WIN64__
46#define __WIN64__ 1
47#endif
48#endif
49
50/*---------------------------------------------------------------------------*/
51/*Windows*/
52#if defined(WIN32) || defined(WIN64)
53#ifndef WINDOWS
54#define WINDOWS
55#endif
56#ifndef _WINDOWS
57#define _WINDOWS
58#endif
59#ifndef __WINDOWS__
60#define __WINDOWS__ 1
61#endif
62#endif
63
64/*---------------------------------------------------------------------------*/
65/*Unix (Linux, HP, Sun, BeOS...)*/
66#if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) || defined(__unix) || defined(__unix__) || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
67#ifndef UNIX
68#define UNIX
69#endif
70#ifndef _UNIX
71#define _UNIX
72#endif
73#ifndef __UNIX__
74#define __UNIX__ 1
75#endif
76#endif
77
78/*---------------------------------------------------------------------------*/
79/*MacOS Classic*/
80#if defined(macintosh)
81#ifndef MACOS
82#define MACOS
83#endif
84#ifndef _MACOS
85#define _MACOS
86#endif
87#ifndef __MACOS__
88#define __MACOS__ 1
89#endif
90#endif
91
92/*---------------------------------------------------------------------------*/
93/*MacOS X*/
94#if defined(__APPLE__) && defined(__MACH__)
95#ifndef MACOSX
96#define MACOSX
97#endif
98#ifndef _MACOSX
99#define _MACOSX
100#endif
101#ifndef __MACOSX__
102#define __MACOSX__ 1
103#endif
104#endif
105
106/*Test of targets*/
107#if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX)
108#pragma message Multiple platforms ? ? ?
109#endif
110
111#if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX)
112#pragma message No known platforms, assume default
113#endif
114
115/*-------------------------------------------------------------------------*/
116#if defined(_WIN32) || defined(WIN32)
117#ifdef _UNICODE
118#ifndef MEDIAINFODLL_NAME
119#define MEDIAINFODLL_NAME L"MediaInfo.dll"
120#endif // MEDIAINFODLL_NAME
121#else //_UNICODE
122#ifndef MEDIAINFODLL_NAME
123#define MEDIAINFODLL_NAME "MediaInfo.dll"
124#endif // MEDIAINFODLL_NAME
125#endif //_UNICODE
126#elif defined(__APPLE__) && defined(__MACH__)
127#ifndef MEDIAINFODLL_NAME
128#define MEDIAINFODLL_NAME "libmediainfo.0.dylib"
129#endif // MEDIAINFODLL_NAME
130#define __stdcall
131#ifdef __cplusplus
132#include <new> //for size_t
133#else /* __cplusplus */
134#include <stddef.h> //for size_t
135#endif /* __cplusplus */
136#else
137#ifndef MEDIAINFODLL_NAME
138#define MEDIAINFODLL_NAME "libmediainfo.so.0"
139#endif // MEDIAINFODLL_NAME
140#define __stdcall
141#endif
142
143/*-------------------------------------------------------------------------*/
144/*Char types */
145#undef __T
146#define __T(__x) __T(__x)
147#if defined(UNICODE) || defined(_UNICODE)
148typedef wchar_t MediaInfo_Char;
149#undef __T
150#define __T(__x) L##__x
151#define MEDIAINFO_Ansi ""
152#else
153typedef char MediaInfo_Char;
154#undef __T
155#define __T(__x) __x
156#define MEDIAINFO_Ansi "A"
157#endif
158/*-------------------------------------------------------------------------*/
159
160/*-------------------------------------------------------------------------*/
161/*8-bit int */
162typedef unsigned char MediaInfo_int8u;
163/*-------------------------------------------------------------------------*/
164
165/*-------------------------------------------------------------------------*/
166/*64-bit int */
167#if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
168#undef MAXTYPE_INT
169#define MAXTYPE_INT 64
170typedef unsigned long long MediaInfo_int64u;
171#elif defined(__WIN32__) || defined(_WIN32)
172#undef MAXTYPE_INT
173#define MAXTYPE_INT 64
174typedef unsigned __int64 MediaInfo_int64u;
175#else
176#pragma message This machine has no 64 - bit integer type ?
177#endif
178/*-------------------------------------------------------------------------*/
179
180/*-------------------------------------------------------------------------*/
181/*NULL */
182#ifndef NULL
183#define NULL 0
184#endif
185/*-------------------------------------------------------------------------*/
186
199
213
223
232
233#ifdef __cplusplus
234extern "C"
235{
236#endif /* __cplusplus */
237
238#ifdef MEDIAINFO_GLIBC
239#include <gmodule.h>
240 static GModule *MediaInfo_Module = NULL;
241#elif defined(_WIN32) || defined(WIN32)
242#include <windows.h>
243static HMODULE MediaInfo_Module = NULL;
244#else
245#ifdef MACOSX
246#include <CoreFoundation/CFBundle.h>
247#endif
248
249#include <dlfcn.h>
250static void *MediaInfo_Module = NULL;
251#endif
252 static size_t Module_Count = 0;
253
254#ifdef MEDIAINFO_GLIBC
255#define MEDIAINFO_ASSIGN(_Name, _Name2) \
256 if (!g_module_symbol(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2, (gpointer *)&MediaInfo_##_Name)) \
257 Errors++;
258#define MEDIAINFOLIST_ASSIGN(_Name, _Name2) \
259 if (!g_module_symbol(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2, (gpointer *)&MediaInfoList_##_Name)) \
260 Errors++;
261#elif defined(_WIN32) || defined(WIN32)
262#define MEDIAINFO_ASSIGN(_Name, _Name2) \
263 MediaInfo_##_Name = (MEDIAINFO_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
264 if (MediaInfo_##_Name == NULL) \
265 Errors++;
266#define MEDIAINFOLIST_ASSIGN(_Name, _Name2) \
267 MediaInfoList_##_Name = (MEDIAINFOLIST_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
268 if (MediaInfoList_##_Name == NULL) \
269 Errors++;
270#else
271#define MEDIAINFO_ASSIGN(_Name, _Name2) \
272 MediaInfo_##_Name = (MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
273 if (MediaInfo_##_Name == NULL) \
274 Errors++;
275#define MEDIAINFOLIST_ASSIGN(_Name, _Name2) \
276 MediaInfoList_##_Name = (MEDIAINFOLIST_##_Name)dlsym(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
277 if (MediaInfoList_##_Name == NULL) \
278 Errors++;
279#endif
280
281 typedef void *(__stdcall *MEDIAINFO_New)();
282 static MEDIAINFO_New MediaInfo_New;
283 typedef void *(__stdcall *MEDIAINFOLIST_New)();
284 static MEDIAINFOLIST_New MediaInfoList_New;
285 typedef void(__stdcall *MEDIAINFO_Delete)(void *);
286 static MEDIAINFO_Delete MediaInfo_Delete;
287 typedef void(__stdcall *MEDIAINFOLIST_Delete)(void *);
288 static MEDIAINFOLIST_Delete MediaInfoList_Delete;
289 typedef size_t(__stdcall *MEDIAINFO_Open)(void *, const MediaInfo_Char *);
290 static MEDIAINFO_Open MediaInfo_Open;
291 typedef size_t(__stdcall *MEDIAINFOLIST_Open)(void *, const MediaInfo_Char *, const MediaInfo_fileoptions_C);
292 static MEDIAINFOLIST_Open MediaInfoList_Open;
293 typedef size_t(__stdcall *MEDIAINFO_Open_Buffer_Init)(void *, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset);
294 static MEDIAINFO_Open_Buffer_Init MediaInfo_Open_Buffer_Init;
295 typedef size_t(__stdcall *MEDIAINFO_Open_Buffer_Continue)(void *, MediaInfo_int8u *Buffer, size_t Buffer_Size);
296 static MEDIAINFO_Open_Buffer_Continue MediaInfo_Open_Buffer_Continue;
297 typedef MediaInfo_int64u(__stdcall *MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void *);
298 static MEDIAINFO_Open_Buffer_Continue_GoTo_Get MediaInfo_Open_Buffer_Continue_GoTo_Get;
300 static MEDIAINFO_Open_Buffer_Finalize MediaInfo_Open_Buffer_Finalize;
301 typedef size_t(__stdcall *MEDIAINFO_Open_NextPacket)(void *);
302 static MEDIAINFO_Open_NextPacket MediaInfo_Open_NextPacket;
303 typedef void(__stdcall *MEDIAINFO_Close)(void *);
304 static MEDIAINFO_Close MediaInfo_Close;
305 typedef void(__stdcall *MEDIAINFOLIST_Close)(void *, size_t);
306 static MEDIAINFOLIST_Close MediaInfoList_Close;
307 typedef const MediaInfo_Char *(__stdcall *MEDIAINFO_Inform)(void *, size_t Reserved);
308 static MEDIAINFO_Inform MediaInfo_Inform;
309 typedef const MediaInfo_Char *(__stdcall *MEDIAINFOLIST_Inform)(void *, size_t, size_t Reserved);
310 static MEDIAINFOLIST_Inform MediaInfoList_Inform;
311 typedef const MediaInfo_Char *(__stdcall *MEDIAINFO_GetI)(void *, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
312 static MEDIAINFO_GetI MediaInfo_GetI;
313 typedef const MediaInfo_Char *(__stdcall *MEDIAINFOLIST_GetI)(void *, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
314 static MEDIAINFOLIST_GetI MediaInfoList_GetI;
315 typedef const MediaInfo_Char *(__stdcall *MEDIAINFO_Get)(void *, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char *Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch);
316 static MEDIAINFO_Get MediaInfo_Get;
317 typedef const MediaInfo_Char *(__stdcall *MEDIAINFOLIST_Get)(void *, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char *Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch);
318 static MEDIAINFOLIST_Get MediaInfoList_Get;
319 typedef size_t(__stdcall *MEDIAINFO_Output_Buffer_Get)(void *, const MediaInfo_Char *Parameter);
320 static MEDIAINFO_Output_Buffer_Get MediaInfo_Output_Buffer_Get;
321 typedef size_t(__stdcall *MEDIAINFO_Output_Buffer_GetI)(void *, size_t Pos);
322 static MEDIAINFO_Output_Buffer_GetI MediaInfo_Output_Buffer_GetI;
323 typedef const MediaInfo_Char *(__stdcall *MEDIAINFO_Option)(void *, const MediaInfo_Char *Parameter, const MediaInfo_Char *Value);
324 static MEDIAINFO_Option MediaInfo_Option;
325 typedef const MediaInfo_Char *(__stdcall *MEDIAINFOLIST_Option)(void *, const MediaInfo_Char *Parameter, const MediaInfo_Char *Value);
326 static MEDIAINFOLIST_Option MediaInfoList_Option;
327 typedef size_t(__stdcall *MEDIAINFO_State_Get)(void *);
328 static MEDIAINFO_State_Get MediaInfo_State_Get;
329 typedef size_t(__stdcall *MEDIAINFOLIST_State_Get)(void *);
330 static MEDIAINFOLIST_State_Get MediaInfoList_State_Get;
331 typedef size_t(__stdcall *MEDIAINFO_Count_Get)(void *, MediaInfo_stream_C StreamKind, size_t StreamNumber);
332 static MEDIAINFO_Count_Get MediaInfo_Count_Get;
333 typedef size_t(__stdcall *MEDIAINFOLIST_Count_Get)(void *, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber);
334 static MEDIAINFOLIST_Count_Get MediaInfoList_Count_Get;
335 typedef size_t(__stdcall *MEDIAINFO_Count_Get_Files)(void *);
336 static MEDIAINFO_Count_Get_Files MediaInfo_Count_Get_Files;
337 typedef size_t(__stdcall *MEDIAINFOLIST_Count_Get_Files)(void *);
338 static MEDIAINFOLIST_Count_Get_Files MediaInfoList_Count_Get_Files;
339
340 static size_t MediaInfoDLL_Load()
341 {
342 size_t Errors = 0;
343
344 if (Module_Count > 0)
345 {
346 Module_Count++;
347 return 1;
348 }
349
350 /* Load library */
351#ifdef MEDIAINFO_GLIBC
352 MediaInfo_Module = g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY);
353#elif defined(_WIN32) || defined(WIN32)
354 MediaInfo_Module = LoadLibrary(MEDIAINFODLL_NAME);
355#else
356#ifdef MACOSX
357 MediaInfo_Module = dlopen("@executable_path/" MEDIAINFODLL_NAME, RTLD_LAZY);
358 if (!MediaInfo_Module)
359 {
360 CFBundleRef mainBundle = CFBundleGetMainBundle();
361
362 // get full app path and delete app name
363 CFURLRef app_url = CFBundleCopyExecutableURL(mainBundle);
364 CFURLRef app_path_url = CFURLCreateCopyDeletingLastPathComponent(NULL, app_url);
365
366 CFStringRef app_path = CFURLCopyFileSystemPath(app_path_url, kCFURLPOSIXPathStyle);
367
368 CFMutableStringRef mut_app_path = CFStringCreateMutableCopy(NULL, NULL, app_path);
369 CFStringAppend(mut_app_path, CFSTR("/"));
370 CFStringAppend(mut_app_path, CFSTR(MEDIAINFODLL_NAME));
371 CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
372 const char *fullPath = CFStringGetCStringPtr(mut_app_path, encodingMethod);
373
374 MediaInfo_Module = dlopen(fullPath, RTLD_LAZY);
375
376 CFRelease(app_url);
377 CFRelease(app_path_url);
378 CFRelease(app_path);
379 CFRelease(mut_app_path);
380 }
381#endif /* MACOSX*/
382
383 if (!MediaInfo_Module)
384 MediaInfo_Module = dlopen(MEDIAINFODLL_NAME, RTLD_LAZY);
385 if (!MediaInfo_Module)
386 MediaInfo_Module = dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY);
387 if (!MediaInfo_Module)
388 MediaInfo_Module = dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
389 if (!MediaInfo_Module)
390 MediaInfo_Module = dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
391 if (!MediaInfo_Module)
392 MediaInfo_Module = dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
393 if (!MediaInfo_Module)
394 MediaInfo_Module = dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
395#endif
396 if (!MediaInfo_Module)
397 return (size_t)-1;
398
399 /* Load methods */
400 MEDIAINFO_ASSIGN(New, "New")
401 MEDIAINFOLIST_ASSIGN(New, "New")
402 MEDIAINFO_ASSIGN(Delete, "Delete")
403 MEDIAINFOLIST_ASSIGN(Delete, "Delete")
404 MEDIAINFO_ASSIGN(Open, "Open")
405 MEDIAINFOLIST_ASSIGN(Open, "Open")
406 MEDIAINFO_ASSIGN(Open_Buffer_Init, "Open_Buffer_Init")
407 MEDIAINFO_ASSIGN(Open_Buffer_Continue, "Open_Buffer_Continue")
408 MEDIAINFO_ASSIGN(Open_Buffer_Continue_GoTo_Get, "Open_Buffer_Continue_GoTo_Get")
409 MEDIAINFO_ASSIGN(Open_Buffer_Finalize, "Open_Buffer_Finalize")
410 MEDIAINFO_ASSIGN(Open_NextPacket, "Open_NextPacket")
411 MEDIAINFO_ASSIGN(Close, "Close")
412 MEDIAINFOLIST_ASSIGN(Close, "Close")
413 MEDIAINFO_ASSIGN(Inform, "Inform")
414 MEDIAINFOLIST_ASSIGN(Inform, "Inform")
415 MEDIAINFO_ASSIGN(GetI, "GetI")
416 MEDIAINFOLIST_ASSIGN(GetI, "GetI")
417 MEDIAINFO_ASSIGN(Get, "Get")
418 MEDIAINFOLIST_ASSIGN(Get, "Get")
419 MEDIAINFO_ASSIGN(Output_Buffer_Get, "Output_Buffer_Get")
420 MEDIAINFO_ASSIGN(Output_Buffer_GetI, "Output_Buffer_GetI")
421 MEDIAINFO_ASSIGN(Option, "Option")
422 MEDIAINFOLIST_ASSIGN(Option, "Option")
423 MEDIAINFO_ASSIGN(State_Get, "State_Get")
424 MEDIAINFOLIST_ASSIGN(State_Get, "State_Get")
425 MEDIAINFO_ASSIGN(Count_Get, "Count_Get")
426 MEDIAINFOLIST_ASSIGN(Count_Get, "Count_Get")
427 MEDIAINFOLIST_ASSIGN(Count_Get_Files, "Count_Get_Files")
428 if (Errors > 0)
429 {
430 // Unload DLL with errors
431#ifdef MEDIAINFO_GLIBC
432 g_module_close(MediaInfo_Module);
433#elif defined(_WIN32) || defined(WIN32)
434 FreeLibrary(MediaInfo_Module);
435#else
436 dlclose(MediaInfo_Module);
437#endif
438 MediaInfo_Module = NULL;
439 return (size_t)-1;
440 }
441
442 Module_Count++;
443 return (size_t)1;
444 }
445
446 static size_t MediaInfoDLL_IsLoaded()
447 {
448 if (MediaInfo_Module)
449 return 1;
450 else
451 return 0;
452 }
453
454 static void MediaInfoDLL_UnLoad()
455 {
456 Module_Count--;
457 if (Module_Count > 0)
458 return;
459
460#ifdef MEDIAINFO_GLIBC
461 g_module_close(MediaInfo_Module);
462#elif defined(_WIN32) || defined(WIN32)
463 FreeLibrary(MediaInfo_Module);
464#else
465 dlclose(MediaInfo_Module);
466#endif
467 MediaInfo_Module = NULL;
468 }
469
470#ifdef __cplusplus
471}
472#endif /*__cplusplus*/
473
474/***************************************************************************/
475/***************************************************************************/
476/***************************************************************************/
477
478#ifdef __cplusplus
479// DLL C++ wrapper for C functions
480
481//---------------------------------------------------------------------------
482#include <string>
483#include <sstream>
484//---------------------------------------------------------------------------
485
486namespace MediaInfoDLL
487{
488
489 //---------------------------------------------------------------------------
490 // MediaInfo_Char types
491#undef __T
492#define __T(__x) __T(__x)
493#if defined(UNICODE) || defined(_UNICODE)
494 typedef wchar_t Char;
495#undef __T
496#define __T(__x) L##__x
497#else
498 typedef char Char;
499#undef __T
500#define __T(__x) __x
501#endif
502#if 0
503 typedef std::basic_string<Char> String;
504 typedef std::basic_stringstream<Char> StringStream;
505 typedef std::basic_istringstream<Char> iStringStream;
506 typedef std::basic_ostringstream<Char> oStringStream;
507 typedef std::basic_istringstream<Char> tiStringStream; // Legacy
508 typedef std::basic_ostringstream<Char> toStringStream; // Legacy
509#endif
510 const size_t Error = (size_t)(-1);
511 //---------------------------------------------------------------------------
512
513 //---------------------------------------------------------------------------
515 enum stream_t
516 {
517 Stream_General,
518 Stream_Video,
519 Stream_Audio,
520 Stream_Text,
521 Stream_Other,
522 Stream_Image,
523 Stream_Menu,
524 Stream_Max
525 };
526
528 enum info_t
529 {
530 Info_Name,
531 Info_Text,
532 Info_Measure,
533 Info_Options,
534 Info_Name_Text,
535 Info_Measure_Text,
536 Info_Info,
537 Info_HowTo,
538 Info_Max
539 };
540
545 enum infooptions_t
546 {
547 InfoOption_ShowInInform,
548 InfoOption_Reserved,
549 InfoOption_ShowInSupported,
550 InfoOption_TypeOfValue,
551 InfoOption_Max
552 };
553
555 enum fileoptions_t
556 {
557 FileOption_Nothing = 0x00,
558 FileOption_NoRecursive = 0x01,
559 FileOption_CloseAll = 0x02,
560 FileOption_Max = 0x04
561 };
562
563 const MediaInfo_Char* Unable_Load_DLL = __T("Unable to load ") MEDIAINFODLL_NAME;
564#define MEDIAINFO_TEST_VOID \
565 if (!MediaInfo_Module) \
566 { \
567 MediaInfoDLL_Load(); \
568 if (!MediaInfo_Module) \
569 return; \
570 }
571#define MEDIAINFO_TEST_INT \
572 if (!MediaInfo_Module) \
573 { \
574 MediaInfoDLL_Load(); \
575 if (!MediaInfo_Module) \
576 return 0; \
577 }
578#define MEDIAINFO_TEST_STRING \
579 if (!MediaInfo_Module) \
580 { \
581 MediaInfoDLL_Load(); \
582 if (!MediaInfo_Module) \
583 return Unable_Load_DLL; \
584 }
585#define MEDIAINFO_TEST_STRING_STATIC \
586 if (!MediaInfo_Module) \
587 { \
588 MediaInfoDLL_Load(); \
589 if (!MediaInfo_Module) \
590 return Unable_Load_DLL; \
591 }
592
593#if 0
594 //---------------------------------------------------------------------------
595 class MediaInfo
596 {
597 public:
598 MediaInfo()
599 {
600 if (!MediaInfo_Module)
601 MediaInfoDLL_Load();
602 if (!MediaInfo_Module)
603 {
604 Handle = NULL;
605 return;
606 };
607 Handle = MediaInfo_New();
608 };
609 ~MediaInfo()
610 {
611 MEDIAINFO_TEST_VOID;
612 MediaInfo_Delete(Handle);
613 };
614
615 // File
616 size_t Open(const String &File)
617 {
618 MEDIAINFO_TEST_INT;
619 return MediaInfo_Open(Handle, File.c_str());
620 };
621 size_t Open_Buffer_Init(MediaInfo_int64u File_Size = (MediaInfo_int64u)-1, MediaInfo_int64u File_Offset = 0)
622 {
623 MEDIAINFO_TEST_INT;
624 return MediaInfo_Open_Buffer_Init(Handle, File_Size, File_Offset);
625 };
626 size_t Open_Buffer_Continue(MediaInfo_int8u *Buffer, size_t Buffer_Size)
627 {
628 MEDIAINFO_TEST_INT;
629 return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size);
630 };
631 MediaInfo_int64u Open_Buffer_Continue_GoTo_Get()
632 {
633 MEDIAINFO_TEST_INT;
634 return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle);
635 };
636 size_t Open_Buffer_Finalize()
637 {
638 MEDIAINFO_TEST_INT;
639 return MediaInfo_Open_Buffer_Finalize(Handle);
640 };
641 size_t Open_NextPacket()
642 {
643 MEDIAINFO_TEST_INT;
644 return MediaInfo_Open_NextPacket(Handle);
645 };
646 // size_t Save () {MEDIAINFO_TEST_INT; return MediaInfo_Save(Handle);};
647 void Close()
648 {
649 MEDIAINFO_TEST_VOID;
650 return MediaInfo_Close(Handle);
651 };
652
653 // General information
654 String Inform()
655 {
656 MEDIAINFO_TEST_STRING;
657 return MediaInfo_Inform(Handle, 0);
658 };
659 String Get(stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind = Info_Text)
660 {
661 MEDIAINFO_TEST_STRING;
662 return MediaInfo_GetI(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);
663 };
664 String Get(stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind = Info_Text, info_t SearchKind = Info_Name)
665 {
666 MEDIAINFO_TEST_STRING;
667 return MediaInfo_Get(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);
668 };
669 // size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfo_SetI (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());};
670 // size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfo_Set (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());};
671 size_t Output_Buffer_Get(const String &Value) { return MediaInfo_Output_Buffer_Get(Handle, Value.c_str()); }
672 size_t Output_Buffer_Get(size_t Pos) { return MediaInfo_Output_Buffer_GetI(Handle, Pos); }
673 String Option(const String &Option, const String &Value = __T(""))
674 {
675 MEDIAINFO_TEST_STRING;
676 return MediaInfo_Option(Handle, Option.c_str(), Value.c_str());
677 };
678 static String Option_Static(const String &Option, const String &Value = __T(""))
679 {
680 if (!MediaInfo_Module)
681 MediaInfoDLL_Load();
682 MEDIAINFO_TEST_STRING_STATIC;
683 return MediaInfo_Option(NULL, Option.c_str(), Value.c_str());
684 };
685 size_t State_Get()
686 {
687 MEDIAINFO_TEST_INT;
688 return MediaInfo_State_Get(Handle);
689 };
690 size_t Count_Get(stream_t StreamKind, size_t StreamNumber = (size_t)-1)
691 {
692 MEDIAINFO_TEST_INT;
693 return MediaInfo_Count_Get(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber);
694 };
695
696 bool IsReady() { return (Handle != nullptr && MediaInfo_Module != nullptr); }
697
698 private:
699 void *Handle;
700 };
701
702 class MediaInfoList
703 {
704 public:
705 MediaInfoList()
706 {
707 MediaInfoDLL_Load();
708 if (!MediaInfoDLL_IsLoaded())
709 {
710 Handle = NULL;
711 return;
712 };
713 Handle = MediaInfoList_New();
714 };
715 ~MediaInfoList()
716 {
717 MEDIAINFO_TEST_VOID;
718 MediaInfoList_Delete(Handle);
719 MediaInfoDLL_UnLoad();
720 };
721
722 // File
723 size_t Open(const String &File, const fileoptions_t Options = FileOption_Nothing)
724 {
725 MEDIAINFO_TEST_INT;
726 return MediaInfoList_Open(Handle, File.c_str(), (MediaInfo_fileoptions_C)Options);
727 };
728 // size_t Save (size_t FilePos) {MEDIAINFO_TEST_INT; return MediaInfoList_Save(Handle, FilePos);};
729 void Close(size_t FilePos = (size_t)-1)
730 {
731 MEDIAINFO_TEST_VOID;
732 return MediaInfoList_Close(Handle, FilePos);
733 };
734
735 // General information
736 String Inform(size_t FilePos = (size_t)-1)
737 {
738 MEDIAINFO_TEST_STRING;
739 return MediaInfoList_Inform(Handle, FilePos, 0);
740 };
741 String Get(size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind = Info_Text)
742 {
743 MEDIAINFO_TEST_STRING;
744 return MediaInfoList_GetI(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);
745 };
746 String Get(size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind = Info_Text, info_t SearchKind = Info_Name)
747 {
748 MEDIAINFO_TEST_STRING;
749 return MediaInfoList_Get(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);
750 };
751 // size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfoList_SetI (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());};
752 // size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T("")) {MEDIAINFO_TEST_INT; return MediaInfoList_Set (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());};
753 String Option(const String &Option, const String &Value = __T(""))
754 {
755 MEDIAINFO_TEST_STRING;
756 return MediaInfoList_Option(Handle, Option.c_str(), Value.c_str());
757 };
758 static String Option_Static(const String &Option, const String &Value = __T(""))
759 {
760 MEDIAINFO_TEST_STRING_STATIC;
761 return MediaInfoList_Option(NULL, Option.c_str(), Value.c_str());
762 };
763 size_t State_Get()
764 {
765 MEDIAINFO_TEST_INT;
766 return MediaInfoList_State_Get(Handle);
767 };
768 size_t Count_Get(size_t FilePos, stream_t StreamKind, size_t StreamNumber = (size_t)-1)
769 {
770 MEDIAINFO_TEST_INT;
771 return MediaInfoList_Count_Get(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber);
772 };
773 size_t Count_Get()
774 {
775 MEDIAINFO_TEST_INT;
776 return MediaInfoList_Count_Get_Files(Handle);
777 };
778
779 bool IsReady() { return (Handle && MediaInfo_Module) ? true : false; }
780
781 private:
782 void *Handle;
783 };
784
785#endif
786} // NameSpace
787#endif /*__cplusplus*/
788
789#endif
#define __int64
Definition __xtoa.cpp:15
#define NULL
Definition Config.h:340
const MediaInfo_Char *(__stdcall * MEDIAINFO_Inform)(void *, size_t Reserved)
size_t(__stdcall * MEDIAINFO_Open)(void *, const MediaInfo_Char *)
size_t(__stdcall * MEDIAINFO_Count_Get_Files)(void *)
enum MediaInfo_stream_t MediaInfo_stream_C
Kinds of Stream.
const MediaInfo_Char *(__stdcall * MEDIAINFO_GetI)(void *, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo)
#define MEDIAINFO_ASSIGN(_Name, _Name2)
const MediaInfo_Char *(__stdcall * MEDIAINFOLIST_Get)(void *, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char *Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch)
enum MediaInfo_infooptions_t MediaInfo_infooptions_C
Option if InfoKind = Info_Options.
const MediaInfo_Char *(__stdcall * MEDIAINFO_Option)(void *, const MediaInfo_Char *Parameter, const MediaInfo_Char *Value)
const MediaInfo_Char *(__stdcall * MEDIAINFOLIST_Option)(void *, const MediaInfo_Char *Parameter, const MediaInfo_Char *Value)
size_t(__stdcall * MEDIAINFO_Count_Get)(void *, MediaInfo_stream_C StreamKind, size_t StreamNumber)
size_t(__stdcall * MEDIAINFO_State_Get)(void *)
const MediaInfo_Char *(__stdcall * MEDIAINFOLIST_GetI)(void *, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo)
void(__stdcall * MEDIAINFO_Close)(void *)
void *(__stdcall * MEDIAINFOLIST_New)()
void(__stdcall * MEDIAINFOLIST_Close)(void *, size_t)
#define MEDIAINFODLL_NAME
void *(__stdcall * MEDIAINFO_New)()
const MediaInfo_Char *(__stdcall * MEDIAINFO_Get)(void *, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char *Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch)
#define MEDIAINFOLIST_ASSIGN(_Name, _Name2)
char MediaInfo_Char
MediaInfo_infooptions_t
Option if InfoKind = Info_Options.
@ MediaInfo_InfoOption_ShowInInform
@ MediaInfo_InfoOption_Reserved
@ MediaInfo_InfoOption_Max
@ MediaInfo_InfoOption_TypeOfValue
@ MediaInfo_InfoOption_ShowInSupported
size_t(__stdcall * MEDIAINFO_Output_Buffer_GetI)(void *, size_t Pos)
MediaInfo_fileoptions_t
File opening options.
@ MediaInfo_FileOption_CloseAll
@ MediaInfo_FileOption_Max
@ MediaInfo_FileOption_NoRecursive
@ MediaInfo_FileOption_Nothing
void(__stdcall * MEDIAINFOLIST_Delete)(void *)
size_t(__stdcall * MEDIAINFO_Open_Buffer_Init)(void *, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset)
MediaInfo_int64u(__stdcall * MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void *)
#define __stdcall
enum MediaInfo_info_t MediaInfo_info_C
Kinds of Info.
size_t(__stdcall * MEDIAINFO_Open_NextPacket)(void *)
MediaInfo_stream_t
Kinds of Stream.
@ MediaInfo_Stream_Audio
@ MediaInfo_Stream_Image
@ MediaInfo_Stream_Other
@ MediaInfo_Stream_Max
@ MediaInfo_Stream_General
@ MediaInfo_Stream_Menu
@ MediaInfo_Stream_Text
@ MediaInfo_Stream_Video
size_t(__stdcall * MEDIAINFOLIST_Count_Get_Files)(void *)
void(__stdcall * MEDIAINFO_Delete)(void *)
const MediaInfo_Char *(__stdcall * MEDIAINFOLIST_Inform)(void *, size_t, size_t Reserved)
size_t(__stdcall * MEDIAINFOLIST_Open)(void *, const MediaInfo_Char *, const MediaInfo_fileoptions_C)
size_t(__stdcall * MEDIAINFOLIST_State_Get)(void *)
MediaInfo_info_t
Kinds of Info.
@ MediaInfo_Info_Name
@ MediaInfo_Info_Text
@ MediaInfo_Info_HowTo
@ MediaInfo_Info_Max
@ MediaInfo_Info_Measure
@ MediaInfo_Info_Name_Text
@ MediaInfo_Info_Info
@ MediaInfo_Info_Options
@ MediaInfo_Info_Measure_Text
size_t(__stdcall * MEDIAINFO_Open_Buffer_Finalize)(void *)
enum MediaInfo_fileoptions_t MediaInfo_fileoptions_C
File opening options.
unsigned char MediaInfo_int8u
size_t(__stdcall * MEDIAINFO_Output_Buffer_Get)(void *, const MediaInfo_Char *Parameter)
size_t(__stdcall * MEDIAINFOLIST_Count_Get)(void *, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber)
size_t(__stdcall * MEDIAINFO_Open_Buffer_Continue)(void *, MediaInfo_int8u *Buffer, size_t Buffer_Size)
#define __T(str)
Definition Object.h:44