forked from zelenin/go-mediainfo
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediainfo.h
66 lines (54 loc) · 1.54 KB
/
mediainfo.h
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
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <MediaInfoDLL/MediaInfoDLL.h>
const wchar_t *toWchar(const char *c)
{
const size_t cSize = strlen(c) + 1;
wchar_t *wc = malloc(cSize * sizeof(wchar_t));
mbstowcs(wc, c, cSize);
return wc;
}
const char *toChar(const wchar_t *c)
{
const size_t cSize = wcslen(c) + 1;
char *wc = malloc(cSize * sizeof(char));
wcstombs(wc, c, cSize);
return wc;
}
void *OpenFile(char *filePath)
{
void *handle = MediaInfo_New();
if (!handle)
{
return NULL;
}
size_t res = MediaInfo_Open(handle, toWchar(filePath));
if (!res)
{
return NULL;
}
return handle;
}
void CloseFile(void *handle)
{
MediaInfo_Close(handle);
MediaInfo_Delete(handle);
}
const char *Get(void *handle, MediaInfo_stream_C streamKind, size_t StreamNumber, char *Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch)
{
return toChar(MediaInfo_Get(handle, streamKind, StreamNumber, toWchar(Parameter), KindOfInfo, KindOfSearch));
}
const char *GetI(void *handle, MediaInfo_stream_C streamKind, size_t StreamNumber, unsigned long Parameter, MediaInfo_info_C KindOfInfo)
{
return toChar(MediaInfo_GetI(handle, streamKind, StreamNumber, Parameter, KindOfInfo));
}
const char *Option(void *handle, char *Parameter, char *Value)
{
return toChar(MediaInfo_Option(handle, toWchar(Parameter), toWchar(Value)));
}
const char *Inform(void *handle, size_t Reserved)
{
return toChar(MediaInfo_Inform(handle, Reserved));
}