diff --git a/rtmp/RTMP.go b/rtmp/RTMP.go index f5754b8e..579f1651 100644 --- a/rtmp/RTMP.go +++ b/rtmp/RTMP.go @@ -38,6 +38,7 @@ import ( _ "fmt" "sync" "unsafe" + "bitbucket.org/ausocean/av/tools" ) // RTMPSession provides a crude interface for sending flv tags over rtmp @@ -68,7 +69,7 @@ func NewRTMPSession(url string, connectTimeout uint) (session *rtmpSession) { // constructor func (s *rtmpSession) StartSession() error { if !s.running { - if !uintToBool(uint(C.RTMP_start_session(C.CString(s.url), C.uint(s.timeout)))) { + if !tools.UintToBool(uint(C.RTMP_start_session(C.CString(s.url), C.uint(s.timeout)))) { return errors.New("RTMP start error! Check rtmp log for details!") } s.running = true @@ -86,7 +87,7 @@ func (s *rtmpSession) WriteFrame(data []byte, dataLength uint) error { if s.running { dataCopy := make([]byte, len(data)) copy(dataCopy, data) - if !uintToBool(uint(C.RTMP_write_frame((*C.char)(unsafe.Pointer(&dataCopy[0])), C.uint(dataLength)))) { + if !tools.UintToBool(uint(C.RTMP_write_frame((*C.char)(unsafe.Pointer(&dataCopy[0])), C.uint(dataLength)))) { return errors.New("RTMP write error! Check rtmp log for details!") } } else { @@ -98,7 +99,7 @@ func (s *rtmpSession) WriteFrame(data []byte, dataLength uint) error { // EndSession terminates the rtmp connection func (s *rtmpSession) EndSession() error { if s.running { - if !uintToBool(uint(C.RTMP_end_session())) { + if !tools.UintToBool(uint(C.RTMP_end_session())) { return errors.New("RTMP end session error! Check rtmp log for details!") } s.running = false @@ -107,8 +108,3 @@ func (s *rtmpSession) EndSession() error { } return nil } - -// uintToBool takes a uint and returns the bool equivalent -func uintToBool(x uint) bool { - return x != 0 -} diff --git a/tools/helpers.go b/tools/helpers.go index e076b010..ad1e4ec1 100644 --- a/tools/helpers.go +++ b/tools/helpers.go @@ -39,3 +39,8 @@ func BoolToByte(in bool) (out byte) { } return } + +// uintToBool takes a uint and returns the bool equivalent +func UintToBool(x uint) bool { + return x != 0 +}