mirror of https://bitbucket.org/ausocean/av.git
Implemented writeFrame in go, next is rtmp write frame
This commit is contained in:
parent
132cf79f4c
commit
157ac833db
10
rtmp/rtmp.go
10
rtmp/rtmp.go
|
@ -30,7 +30,7 @@ package rtmp
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo CFLAGS: -I/usr/local/include/librtmp
|
#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 <stdlib.h>
|
||||||
#include <rtmp.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 {
|
func (s *session) writeFrame(data []byte) uint {
|
||||||
if !C.RTMP_IsConnected(rtmp) {
|
if C.RTMP_IsConnected(s.rtmp) <= 0 {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
// If RTMP_Write returns less than or equal to zero then something is wrong
|
||||||
if !C.RTMP_Write(s.rtmp, (const char*)(*C.char)(unsafe.Pointer(&data[0])), C.uint(dataLength)) {
|
if C.RTMP_Write(s.rtmp, (*C.char)(unsafe.Pointer(&data[0])), C.int(len(data))) <= 0 {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -118,7 +118,7 @@ func (s *session) Write(data []byte) (int, error) {
|
||||||
if s.rtmp == nil {
|
if s.rtmp == nil {
|
||||||
return 0, Err(3)
|
return 0, Err(3)
|
||||||
}
|
}
|
||||||
ret := s.writeFrame(data, len(data))
|
ret := s.writeFrame(data)
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
return 0, Err(ret)
|
return 0, Err(ret)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue