mirror of https://bitbucket.org/ausocean/av.git
Started moving functionality to rtmp.go
This commit is contained in:
parent
5ff305e71a
commit
6b4ece57e5
12
rtmp/rtmp.go
12
rtmp/rtmp.go
|
@ -86,12 +86,22 @@ func (s *session) Open() error {
|
||||||
return nil
|
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
|
// Write writes a frame (flv tag) to the rtmp connection
|
||||||
func (s *session) Write(data []byte) (int, error) {
|
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 := C.write_frame(s.rtmp, (*C.char)(unsafe.Pointer(&data[0])), C.uint(len(data)))
|
ret := s.writeFrame(data, len(data))
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
return 0, Err(ret)
|
return 0, Err(ret)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue