-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.c
More file actions
38 lines (28 loc) · 907 Bytes
/
log.c
File metadata and controls
38 lines (28 loc) · 907 Bytes
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
// CGO bridge for FFmpeg logging callbacks.
// This file is compiled inline with log.go via CGO.
// It bridges FFmpeg's C logging system to Go callbacks.
#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);
}