forked from csnewman/ffmpeg-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.c
34 lines (25 loc) · 752 Bytes
/
log.c
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
#include <libavutil/bprint.h>
#include <libavutil/avutil.h>
void ffgLogCallback(void* ctx, int level, void* msg);
void ffg_log_callback(void* avcl, int level, const char* fmt, va_list vl) {
// Respect log level to save formatting cost
if (level >= 0) {
level &= 0xff;
}
if (level > av_log_get_level())
return;
AVBPrint msg;
char *msg_buf;
av_bprint_init(&msg, 0, AV_BPRINT_SIZE_UNLIMITED);
av_vbprintf(&msg, fmt, vl);
av_bprint_finalize(&msg, &msg_buf);
ffgLogCallback(avcl, level, msg_buf);
}
void ffg_set_log() {
av_log_set_callback(ffg_log_callback);
}
typedef const char* (*itemNameFunc) (void* ctx);
const char* invokeItemNameFunc(itemNameFunc f, void* ctx)
{
return f(ctx);
}