From 51e5858dda6fb386024df0dce2bc38270f1bff02 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期五, 26 七月 2019 10:59:28 +0800 Subject: [PATCH] remove log --- apipassive.go | 50 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 37 insertions(+), 13 deletions(-) diff --git a/apipassive.go b/apipassive.go index 5bcd8e7..cfa027c 100644 --- a/apipassive.go +++ b/apipassive.go @@ -5,7 +5,10 @@ #include "libcffmpeg.h" */ import "C" -import "unsafe" +import ( + "fmt" + "unsafe" +) // FireRecorder fire recorder func (h *GoFFMPEG) FireRecorder(id int64) { @@ -21,18 +24,20 @@ } // GetInfoRecorder info -func (h *GoFFMPEG) GetInfoRecorder(index *int, path *string) { +func (h *GoFFMPEG) GetInfoRecorder() (int, string) { var i C.int = -1 var l C.int p := C.wrap_fn_info_recorder(h.ffmpeg, &i, &l) - if i == -1 { - return - } - defer C.free(unsafe.Pointer(p)) + // if p == nil { + // return -1, "" + // } + path := C.GoString(p) + C.free(unsafe.Pointer(p)) - *index = int(i) - *path = C.GoString(p) + fmt.Println("Go get info : ", path, " len: ", l) + + return int(i), path } // BuildDecoder build decoder @@ -41,16 +46,35 @@ } // 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 } -- Gitblit v1.8.0