Implemented writeFrame in go, next is rtmp write frame

This commit is contained in:
saxon 2018-07-05 12:38:02 +09:30
parent 132cf79f4c
commit 157ac833db
1 changed files with 5 additions and 5 deletions

View File

@ -30,7 +30,7 @@ package rtmp
/*
#cgo CFLAGS: -I/usr/local/include/librtmp
#cgo LDFLAGS: -lrtmp -lz -Wl,-rpath=/usr/local/lib
#cgo LDFLAGS: -lrtmp -Wl,-rpath=/usr/local/lib
#include <stdlib.h>
#include <rtmp.h>
@ -98,11 +98,11 @@ func (s *session) rtmpWrite(rtmp *C.RTMP, data []byte) bool {
*/
func (s *session) writeFrame(data []byte) uint {
if !C.RTMP_IsConnected(rtmp) {
if C.RTMP_IsConnected(s.rtmp) <= 0 {
return 1
}
if !C.RTMP_Write(s.rtmp, (const char*)(*C.char)(unsafe.Pointer(&data[0])), C.uint(dataLength)) {
// If RTMP_Write returns less than or equal to zero then something is wrong
if C.RTMP_Write(s.rtmp, (*C.char)(unsafe.Pointer(&data[0])), C.int(len(data))) <= 0 {
return 2
}
/*
@ -118,7 +118,7 @@ func (s *session) Write(data []byte) (int, error) {
if s.rtmp == nil {
return 0, Err(3)
}
ret := s.writeFrame(data, len(data))
ret := s.writeFrame(data)
if ret != 0 {
return 0, Err(ret)
}