mirror of https://bitbucket.org/ausocean/av.git
rtmp: uncommented usage of C_RTMP_Close - created todos in C_CloseInternal
This commit is contained in:
parent
ba9ce9b37f
commit
7e6b2ee0b2
34
rtmp/rtmp.go
34
rtmp/rtmp.go
|
@ -158,7 +158,7 @@ func startSession(rtmp *C_RTMP, u string, timeout uint32) (*C_RTMP, error) {
|
|||
rtmp.Link.timeout = connect_timeout
|
||||
if C_RTMP_SetupURL(rtmp, u) == 0 {
|
||||
// if C.RTMP_SetupURL(rtmp, C.CString(u)) == 0 {
|
||||
//C.RTMP_Close(rtmp)
|
||||
C_RTMP_Close(rtmp)
|
||||
//C.RTMP_Free(rtmp)
|
||||
return nil, errors.New("rtmp startSession: Failed to setup URL!")
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ func startSession(rtmp *C_RTMP, u string, timeout uint32) (*C_RTMP, error) {
|
|||
//C.RTMP_SetBufferMS(rtmp, 3600*1000)
|
||||
if C_RTMP_Connect(rtmp, nil) == 0 {
|
||||
//if C.RTMP_Connect(rtmp, nil) == 0 {
|
||||
//C.RTMP_Close(rtmp)
|
||||
C_RTMP_Close(rtmp)
|
||||
//C.RTMP_Free(rtmp)
|
||||
return nil, errors.New("rtmp startSession: Failed to connect!")
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ func startSession(rtmp *C_RTMP, u string, timeout uint32) (*C_RTMP, error) {
|
|||
// TODO: port this
|
||||
if C_RTMP_ConnectStream(rtmp, 0) == 0 {
|
||||
//if C.RTMP_ConnectStream(rtmp, 0) == 0 {
|
||||
//C.RTMP_Close(rtmp)
|
||||
C_RTMP_Close(rtmp)
|
||||
//C.RTMP_Free(rtmp)
|
||||
return nil, errors.New("rtmp startSession: Failed to connect stream!")
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ func endSession(rtmp *C_RTMP) uint32 {
|
|||
return 3
|
||||
}
|
||||
|
||||
//C.RTMP_Close(rtmp)
|
||||
C_RTMP_Close(rtmp)
|
||||
//C.RTMP_Free(rtmp)
|
||||
return 0
|
||||
}
|
||||
|
@ -382,12 +382,16 @@ func C_RTMP_SetupURL(r *C_RTMP, u string) int32 {
|
|||
return 1
|
||||
}
|
||||
|
||||
/*
|
||||
func rtmpClose(r *C_RTMP) {
|
||||
closeInternal(r, 0)
|
||||
func C_RTMP_Close(r *C_RTMP) {
|
||||
C_CloseInternal(r, 0)
|
||||
}
|
||||
|
||||
func closeInternal(r *C_RTMP, reconnect int32) {
|
||||
func C_CloseInternal(r *C_RTMP, reconnect int32) {
|
||||
// TODO: port SendFCUnpublish
|
||||
// TODO: port SendDeleteStream
|
||||
// TODO: port RTMPSockBuf_Close
|
||||
// TODO: port AV_Clear
|
||||
/*
|
||||
var i int32
|
||||
|
||||
if C_RTMP_IsConnected(r) != 0 {
|
||||
|
@ -422,21 +426,23 @@ func closeInternal(r *C_RTMP, reconnect int32) {
|
|||
r.m_write.m_nBytesRead = 0
|
||||
C.RTMPPacket_Free(&r.m_write)
|
||||
|
||||
// NOTE: C frees - not using in our case
|
||||
for i := 0; i < int(r.m_channelsAllocatedIn); i++ {
|
||||
if *(**C_RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), i,
|
||||
int(unsafe.Sizeof(&r.m_write)))) != nil {
|
||||
|
||||
C.RTMPPacket_Free(*(**C_RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), i,
|
||||
int(unsafe.Sizeof(&r.m_write)))))
|
||||
//C.RTMPPacket_Free(*(**C_RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), i,
|
||||
//int(unsafe.Sizeof(&r.m_write)))))
|
||||
|
||||
//C.free(unsafe.Pointer(*(**C_RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn),
|
||||
i, int(unsafe.Sizeof(&r.m_write))))))
|
||||
//i, int(unsafe.Sizeof(&r.m_write))))))
|
||||
|
||||
*(**C_RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn),
|
||||
i, int(unsafe.Sizeof(&r.m_write)))) = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//C.free(unsafe.Pointer(r.m_vecChannelsOut))
|
||||
r.m_vecChannelsOut = nil
|
||||
r.m_channelsAllocatedOut = 0
|
||||
|
@ -463,8 +469,8 @@ func closeInternal(r *C_RTMP, reconnect int32) {
|
|||
//C.free(unsafe.Pointer(r.Link.playpath0.av_val))
|
||||
r.Link.playpath0.av_val = nil
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// int RTMP_Connect0(RTMP *r, struct sockaddr* service);
|
||||
// rtmp.c +906
|
||||
|
@ -839,7 +845,7 @@ func C_ReadN(r *C_RTMP, buffer *byte, n int) int {
|
|||
|
||||
if nBytes == 0 {
|
||||
log.Println("RTMP socket closed by peer")
|
||||
// C.RTMP_Close(r)
|
||||
C_RTMP_Close(r)
|
||||
break
|
||||
}
|
||||
|
||||
|
@ -865,7 +871,7 @@ func C_WriteN(r *C_RTMP, buffer unsafe.Pointer, n int) int {
|
|||
}
|
||||
|
||||
// TODO: port this
|
||||
//C.RTMP_Close(r)
|
||||
C_RTMP_Close(r)
|
||||
n = 1
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue