forked from zhulik/go_mediainfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo_mediainfo.h
63 lines (53 loc) · 1.81 KB
/
go_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
#include <wchar.h>
#include <MediaInfoDLL/MediaInfoDLL.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <limits.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 *GoMediaInfo_New() {
return MediaInfo_New();
}
void GoMediaInfo_Delete(void *handle) {
MediaInfo_Delete(handle);
}
size_t GoMediaInfo_OpenFile(void *handle, char *name) {
return MediaInfo_Open(handle, toWchar(name));
}
size_t GoMediaInfo_OpenMemory(void *handle, char *bytes, size_t length) {
MediaInfo_Open_Buffer_Init(handle, length, 0);
MediaInfo_Open_Buffer_Continue(handle, bytes, length);
return MediaInfo_Open_Buffer_Finalize(handle);
}
void GoMediaInfo_Close(void *handle) {
MediaInfo_Close(handle);
}
const char *GoMediaInfoGet(void *handle, char *name) {
return toChar(MediaInfo_Get(handle, MediaInfo_Stream_General, 0, toWchar(name), MediaInfo_Info_Text, MediaInfo_Info_Name));
}
const char *GoVideoInfoGet(void *handle, char *name) {
return toChar(MediaInfo_Get(handle, MediaInfo_Stream_Video, 0, toWchar(name), MediaInfo_Info_Text, MediaInfo_Info_Name));
}
const char *GoAudioInfoGet(void *handle, char *name) {
return toChar(MediaInfo_Get(handle, MediaInfo_Stream_Audio, 0, toWchar(name), MediaInfo_Info_Text, MediaInfo_Info_Name));
}
const char *GoMediaInfoOption(void *handle, char *name, char *value) {
return toChar(MediaInfo_Option(handle, toWchar(name), toWchar(value)));
}
const char *GoMediaInfoInform(void *handle) {
return toChar(MediaInfo_Inform(handle, 0));
}