diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 02811cb8..752b8beb 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -355,7 +355,7 @@ func (s *session) Write(data []byte) (int, error) { return 0, Err(3) } // TODO: port this - if C.RTMP_IsConnected(s.rtmp) == 0 { + if rtmpIsConnected(s.rtmp) == 0 { return 0, Err(1) } //if C.RTMP_Write(s.rtmp,(*C.char)(unsafe.Pointer(&data[0])),C.int(len(data))) == 0 { @@ -365,6 +365,13 @@ func (s *session) Write(data []byte) (int, error) { return len(data), nil } +func rtmpIsConnected(r *C.RTMP) int { + if r.m_sb.sb_socket != -1 { + return 1 + } + return 0 +} + func startSession(rtmp *C.RTMP, u string, timeout uint32) (*C.RTMP, error) { connect_timeout := C.int(timeout) rtmp = rtmpAlloc() @@ -489,7 +496,7 @@ func rtmpClose(r *C.RTMP) { func closeInternal(r *C.RTMP, reconnect int32) { var i int32 - if C.RTMP_IsConnected(r) != 0 { + if rtmpIsConnected(r) != 0 { if r.m_stream_id > 0 { i = int32(r.m_stream_id) if r.Link.protocol&RTMP_FEATURE_WRITE != 0 { @@ -691,7 +698,7 @@ func rtmpConnectStream(r *C.RTMP, seekTime int32) int { r.m_mediaChannel = 0 // TODO: port is connected and read packet - for r.m_bPlaying == 0 && C.RTMP_IsConnected(r) != 0 && + for r.m_bPlaying == 0 && rtmpIsConnected(r) != 0 && C.RTMP_ReadPacket(r, &packet) != 0 { // TODO: port is ready