diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 6e0a159f..37ff46df 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -43,10 +43,10 @@ int end_session(RTMP* rtmp); import "C" import ( - "errors" + _"errors" _ "fmt" - "log" - "math" + _"log" + _"math" "reflect" "strconv" "unsafe" @@ -77,7 +77,7 @@ func AVC(str string) C.AVal { // av_setDataFrame is a static const global in rtmp.c var setDataFrame = AVC("@setDataFrame") - +/* // Session provides an interface for sending flv tags over rtmp. type Session interface { Open() error @@ -116,6 +116,19 @@ func (s *session) Open() error { return nil } +// Close terminates the rtmp connection +func (s *session) Close() error { + if s.rtmp == nil { + return Err(3) + } + ret := C.end_session(s.rtmp) + s.rtmp = nil + if ret != 0 { + return Err(ret) + } + return nil +} + // Write writes a frame (flv tag) to the rtmp connection func (s *session) Write(data []byte) (int, error) { if s.rtmp == nil { @@ -530,16 +543,15 @@ func AV_queue(vals **C.RTMP_METHOD, num *int, av *AVal, txn int ) { memmove(tmp, unsafe.Pointer(av.av_val), int(av.av_len)) indxPtr(tpm,av.av_len) = '\0' } + */ + + // memmove copies n bytes from "from" to "to". //go:linkname memmove runtime.memmove func memmove(to, from unsafe.Pointer, n uintptr) -func indxPtr(ptr unsafe.Pointer, indx, typeSize int) unsafe.Pointer { - -} - // sliceToPtr get's the address of the first data element and returns as unsafe // pointer func sliceToPtr(data []byte) unsafe.Pointer { @@ -559,25 +571,12 @@ func ptrToSlice(data unsafe.Pointer, size int) []byte { // incPtr attempts to replicate C like pointer arithmatic functionality func incPtr(ptr unsafe.Pointer, inc, typeSize int) unsafe.Pointer { - return unsafe.Pointer(uintptr(ptr) + uintptr(inc)) + return unsafe.Pointer(uintptr(ptr) + uintptr(inc*typeSize)) } // incPtr attempts to replicate C like pointer arithmatic functionality func decPtr(ptr unsafe.Pointer, dec, typeSize int) unsafe.Pointer { - return unsafe.Pointer(uintptr(ptr) - uintptr(inc)) -} - -// Close terminates the rtmp connection -func (s *session) Close() error { - if s.rtmp == nil { - return Err(3) - } - ret := C.end_session(s.rtmp) - s.rtmp = nil - if ret != 0 { - return Err(ret) - } - return nil + return unsafe.Pointer(uintptr(ptr) - uintptr(dec*typeSize)) } var rtmpErrs = [...]string{