a
554325746@qq.com
2019-07-15 e6c8834e2aa2f3c1f46e588d94ae8ec6aa6c8dec
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
package goffmpeg
 
/*
#include <stdlib.h>
*/
import "C"
import (
    "unsafe"
)
 
// RecorderFunc C function pointer GO
type RecorderFunc func(*string, *int)
 
// DecoderFunc C func pointer go
type DecoderFunc func(*[]byte, *int, *int)
 
var (
    funcRecorder RecorderFunc
    funcDecoder  DecoderFunc
)
 
//export cb_rec_proxy
func cb_rec_proxy(path *C.char, index C.int) {
    if funcRecorder != nil {
        p := C.GoString(path)
        i := int(index)
        funcRecorder(&p, &i)
    }
}
 
//export cb_dec_proxy
func cb_dec_proxy(data *C.uchar, w, h C.int) {
    if funcDecoder != nil {
        d := C.GoBytes(unsafe.Pointer(data), w*h*3)
        C.free(unsafe.Pointer(data))
        wid := int(w)
        hei := int(h)
        funcDecoder(&d, &wid, &hei)
    }
}