| | |
| | | #include "libcffmpeg.h" |
| | | */ |
| | | import "C" |
| | | import "unsafe" |
| | | import ( |
| | | "unsafe" |
| | | ) |
| | | |
| | | // FireRecorder fire recorder |
| | | func (h *GoFFMPEG) FireRecorder(id int64) { |
| | | C.wrap_fn_fire_recorder(h.ffmpeg, C.long(id)) |
| | | func (h *GoFFMPEG) FireRecorder(sid string, id int64) { |
| | | csid := C.CString(sid) |
| | | defer C.free(unsafe.Pointer(csid)) |
| | | C.wrap_fn_fire_recorder(h.ffmpeg, csid, C.long(id)) |
| | | } |
| | | |
| | | // BuildRecorder build recorder |
| | | func (h *GoFFMPEG) BuildRecorder(output string, mind, maxd int) { |
| | | func (h *GoFFMPEG) BuildRecorder(sid, output string, mind, maxd int) { |
| | | out := C.CString(output) |
| | | defer C.free(unsafe.Pointer(out)) |
| | | csid := C.CString(sid) |
| | | defer C.free(unsafe.Pointer(csid)) |
| | | |
| | | C.wrap_fn_recorder(h.ffmpeg, out, C.int(mind), C.int(maxd)) |
| | | C.wrap_fn_recorder(h.ffmpeg, csid, out, C.int(mind), C.int(maxd)) |
| | | } |
| | | |
| | | // GetInfoRecorder info |
| | | func (h *GoFFMPEG) GetInfoRecorder(index *int, path *string) { |
| | | func (h *GoFFMPEG) GetInfoRecorder() (string, int, string) { |
| | | var i C.int = -1 |
| | | var l C.int |
| | | var sid *C.char |
| | | p := C.wrap_fn_info_recorder(h.ffmpeg, &sid, &i, &l) |
| | | // if p == nil { |
| | | // return -1, "" |
| | | // } |
| | | path := C.GoString(p) |
| | | C.free(unsafe.Pointer(p)) |
| | | |
| | | p := C.wrap_fn_info_recorder(h.ffmpeg, &i, &l) |
| | | if i == -1 { |
| | | return |
| | | } |
| | | defer C.free(unsafe.Pointer(p)) |
| | | goid := C.GoString(sid) |
| | | C.free(unsafe.Pointer(sid)) |
| | | // fmt.Println("Go get info : ", path, " len: ", l) |
| | | |
| | | *index = int(i) |
| | | *path = C.GoString(p) |
| | | return goid, int(i), path |
| | | } |
| | | |
| | | // BuildDecoder build decoder |
| | |
| | | } |
| | | |
| | | // GetPicDecoder get pic from decoder |
| | | func (h *GoFFMPEG) GetPicDecoder(data *[]byte, wid, hei *int) { |
| | | func (h *GoFFMPEG) GetPicDecoder() ([]byte, int, int) { |
| | | var width C.int |
| | | var height C.int |
| | | |
| | | p := C.wrap_fn_decoder_pic(h.ffmpeg, &width, &height) |
| | | if width == 0 && height == 0 { |
| | | return |
| | | return nil, 0, 0 |
| | | } |
| | | defer C.free(unsafe.Pointer(p)) |
| | | *data = C.GoBytes(p, width*height*3) |
| | | *wid = int(width) |
| | | *hei = int(height) |
| | | d := C.GoBytes(p, width*height*3) |
| | | wid := int(width) |
| | | hei := int(height) |
| | | |
| | | return d, wid, hei |
| | | } |
| | | |
| | | //GetAVPacket get AVPacket |
| | | func (h *GoFFMPEG) GetAVPacket() ([]byte, int, int) { |
| | | var key C.int |
| | | var size C.int |
| | | |
| | | p := C.wrap_fn_get_avpacket(h.ffmpeg, &size, &key) |
| | | if size <= 0 { |
| | | return nil, 0, -1 |
| | | } |
| | | defer C.free(unsafe.Pointer(p)) |
| | | d := C.GoBytes(p, size) |
| | | s := int(size) |
| | | k := int(key) |
| | | |
| | | return d, s, k |
| | | } |