Started moving functionality to rtmp.go

This commit is contained in:
Saxon Milton 2018-06-28 02:53:50 +09:30
parent 5ff305e71a
commit 6b4ece57e5
1 changed files with 11 additions and 1 deletions

View File

@ -86,12 +86,22 @@ func (s *session) Open() error {
return nil
}
func (s *session) writeFrame(data []byte, dataLength uint) uint {
if !C.RTMP_IsConnected(rtmp) {
return 1
}
if !C.RTMP_Write(s.rtmp, (const char*)(*C.char)(unsafe.Pointer(&data[0])), C.uint(dataLength)) {
return 2
}
return 0
}
// Write writes a frame (flv tag) to the rtmp connection
func (s *session) Write(data []byte) (int, error) {
if s.rtmp == nil {
return 0, Err(3)
}
ret := C.write_frame(s.rtmp, (*C.char)(unsafe.Pointer(&data[0])), C.uint(len(data)))
ret := s.writeFrame(data, len(data))
if ret != 0 {
return 0, Err(ret)
}