video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-09-20 be9c1d1f659b0ff31f656424c478e83a4f7c53b5
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
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef _goffmpeg_lib_c_wrapper_cffmpeg_h_
#define _goffmpeg_lib_c_wrapper_cffmpeg_h_
 
#ifdef __cplusplus
extern "C"{
#endif
 
#include <stdlib.h>
#include <stdint.h>
 
typedef void* cffmpeg;
 
typedef cffmpeg(*lib_cffmpeg_create)();
typedef void (*lib_cffmpeg_destroy)(const cffmpeg);
typedef void (*lib_cffmpeg_run)(const cffmpeg, const char*);
typedef void (*lib_cffmpeg_scale)(const cffmpeg, const int, const int, const int);
typedef void (*lib_cffmpeg_gb28181)(const cffmpeg);
typedef void (*lib_cffmpeg_cpu)(const cffmpeg);
typedef void (*lib_cffmpeg_recorder)(const cffmpeg, const char*, const char*, int, int, int);
typedef void (*lib_cffmpeg_fire_recorder)(const cffmpeg, const char*, const int64_t);
typedef void (*lib_cffmpeg_info_recorder)(const cffmpeg, int*, char**, int*, char**, int*);
typedef void (*lib_cffmpeg_decoder)(const cffmpeg);
typedef void*(*lib_cffmpeg_pic)(const cffmpeg, int*, int*, int64_t*);
typedef void*(*lib_cffmpeg_avpacket)(const cffmpeg, int*, int*);
typedef void*(*lib_cffmpeg_decode_jpeg)(const char*, int*, int*);
 
static lib_cffmpeg_create              fn_create = NULL;
static lib_cffmpeg_destroy             fn_destroy = NULL;
static lib_cffmpeg_run                 fn_run = NULL;
static lib_cffmpeg_scale               fn_scale = NULL;
static lib_cffmpeg_gb28181             fn_gb28181 = NULL;
static lib_cffmpeg_cpu                 fn_cpu = NULL;
static lib_cffmpeg_recorder            fn_recorder = NULL;
static lib_cffmpeg_fire_recorder       fn_fire_recorder = NULL;
static lib_cffmpeg_info_recorder       fn_info_recorder = NULL;
static lib_cffmpeg_decoder             fn_decoder = NULL;
static lib_cffmpeg_pic                 fn_decoder_pic = NULL;
static lib_cffmpeg_avpacket            fn_get_avpacket = NULL;
static lib_cffmpeg_decode_jpeg         fn_dec_jpeg = NULL;
 
typedef void* libcffmpeg;
libcffmpeg init_libcffmpeg(const char *so_file);
void release_libcffmpeg(libcffmpeg lib);
 
cffmpeg wrap_fn_create();
void wrap_fn_destroy(const cffmpeg h);
void wrap_fn_run(const cffmpeg h, const char* input);
void wrap_fn_scale(const cffmpeg h, const int wid, const int hei, const int flags);
void wrap_fn_run_gb28181(const cffmpeg h);
void wrap_fn_use_cpu(const cffmpeg h);
void wrap_fn_recorder(const cffmpeg h, const char* id, const char* dir, int mind, int maxd, int audio);
void wrap_fn_fire_recorder(const cffmpeg h, const char *sid, const int64_t id);
void wrap_fn_info_recorder(const cffmpeg, int* index, char** recid, int* recidLen, char** fpath, int* pathLen);
void wrap_fn_decoder(const cffmpeg h);
void* wrap_fn_decoder_pic(const cffmpeg h, int* wid, int* hei, int64_t *id);
void* wrap_fn_get_avpacket(const cffmpeg h, int* size, int* key);
void* wrap_fn_decode_jpeg(const char* file, int* wid, int* hei);
 
 
// for encoder
typedef void* cencoder;
 
typedef cencoder (*lib_cffmpeg_create_encoder)(const int w, const int h, const int fps, const int br, const int scale_flag, const int gi);
typedef void (*lib_cffmpeg_destroy_encoder)(cencoder h);
typedef int (*lib_cffmpeg_encode)(cencoder hdl, uint8_t *in, const int w, const int h, uint8_t **out, int *size, int *key);
 
static lib_cffmpeg_create_encoder fn_create_encoder = NULL;
static lib_cffmpeg_destroy_encoder fn_destroy_encoder = NULL;
static lib_cffmpeg_encode fn_encode = NULL;
 
cencoder wrap_fn_create_encoder(const int w, const int h, const int fps, const int br, const int scale_flag, const int gi);
void wrap_fn_destroy_encoder(const cencoder h);
void* wrap_fn_encode(cencoder hdl, void *in, const int w, const int h, int *out_size, int *key);
 
#ifdef __cplusplus
}
#endif
 
#endif