mirror of https://bitbucket.org/ausocean/av.git
rtmp: added comments above C_RTMP_Close and C_CloseInternal to indicate location in C library, and reordered to better resemble C library
This commit is contained in:
parent
7e6b2ee0b2
commit
9b67dc1ef0
192
rtmp/rtmp.go
192
rtmp/rtmp.go
|
@ -382,96 +382,6 @@ func C_RTMP_SetupURL(r *C_RTMP, u string) int32 {
|
|||
return 1
|
||||
}
|
||||
|
||||
func C_RTMP_Close(r *C_RTMP) {
|
||||
C_CloseInternal(r, 0)
|
||||
}
|
||||
|
||||
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 {
|
||||
if r.m_stream_id > 0 {
|
||||
i = int32(r.m_stream_id)
|
||||
if r.Link.protocol&RTMP_FEATURE_WRITE != 0 {
|
||||
C.SendFCUnpublish(r)
|
||||
}
|
||||
C.SendDeleteStream(r, float64(i))
|
||||
}
|
||||
C.RTMPSockBuf_Close(&r.m_sb)
|
||||
}
|
||||
|
||||
r.m_stream_id = -1
|
||||
r.m_sb.sb_socket = -1
|
||||
r.m_nBWCheckCounter = 0
|
||||
r.m_nBytesIn = 0
|
||||
r.m_nBytesInSent = 0
|
||||
|
||||
if r.m_read.flags&RTMP_READ_HEADER != 0 {
|
||||
//C.free(unsafe.Pointer(r.m_read.buf))
|
||||
r.m_read.buf = nil
|
||||
}
|
||||
|
||||
r.m_read.dataType = 0
|
||||
r.m_read.flags = 0
|
||||
r.m_read.status = 0
|
||||
r.m_read.nResumeTS = 0
|
||||
r.m_read.nIgnoredFrameCounter = 0
|
||||
r.m_read.nIgnoredFlvFrameCounter = 0
|
||||
|
||||
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.free(unsafe.Pointer(*(**C_RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn),
|
||||
//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
|
||||
C.AV_clear(r.m_methodCalls, r.m_numCalls)
|
||||
|
||||
r.m_methodCalls = nil
|
||||
r.m_numCalls = 0
|
||||
r.m_numInvokes = 0
|
||||
|
||||
r.m_bPlaying = C.uchar(0)
|
||||
r.m_sb.sb_size = 0
|
||||
|
||||
r.m_msgCounter = 0
|
||||
r.m_resplen = 0
|
||||
r.m_unackd = 0
|
||||
|
||||
if ((r.Link.lFlags & RTMP_LF_FTCU) != 0) && (reconnect == 0) {
|
||||
//C.free(unsafe.Pointer(r.Link.app.av_val))
|
||||
r.Link.app.av_val = nil
|
||||
r.Link.lFlags ^= RTMP_LF_FAPU
|
||||
}
|
||||
|
||||
if reconnect == 0 {
|
||||
//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
|
||||
func C_RTMP_Connect0(r *C_RTMP, service *C.sockaddr) int {
|
||||
|
@ -1169,6 +1079,14 @@ func C_SendFCPublish(r *C_RTMP) int32 {
|
|||
return int32(C_RTMP_SendPacket(r, &packet, 0))
|
||||
}
|
||||
|
||||
// int SendFCUnpublish(RTMP *r);
|
||||
// rtmp.c +1875
|
||||
func C_SendFCUnpublish(r *C_RTMP) int32 {
|
||||
/*
|
||||
*/
|
||||
return 0
|
||||
}
|
||||
|
||||
// int SendPublish(RTMP* r);
|
||||
// rtmp.c +1908
|
||||
func C_SendPublish(r *C_RTMP) int32 {
|
||||
|
@ -2208,6 +2126,100 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
// void RTMP_Close(RTMP *r);
|
||||
// rtmp.c +4168
|
||||
func C_RTMP_Close(r *C_RTMP) {
|
||||
C_CloseInternal(r, 0)
|
||||
}
|
||||
|
||||
// static void CloseInternal(RTMP *r, int reconnect);
|
||||
// rtmp.c +4175
|
||||
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 {
|
||||
if r.m_stream_id > 0 {
|
||||
i = int32(r.m_stream_id)
|
||||
if r.Link.protocol&RTMP_FEATURE_WRITE != 0 {
|
||||
C.SendFCUnpublish(r)
|
||||
}
|
||||
C.SendDeleteStream(r, float64(i))
|
||||
}
|
||||
C.RTMPSockBuf_Close(&r.m_sb)
|
||||
}
|
||||
|
||||
r.m_stream_id = -1
|
||||
r.m_sb.sb_socket = -1
|
||||
r.m_nBWCheckCounter = 0
|
||||
r.m_nBytesIn = 0
|
||||
r.m_nBytesInSent = 0
|
||||
|
||||
if r.m_read.flags&RTMP_READ_HEADER != 0 {
|
||||
//C.free(unsafe.Pointer(r.m_read.buf))
|
||||
r.m_read.buf = nil
|
||||
}
|
||||
|
||||
r.m_read.dataType = 0
|
||||
r.m_read.flags = 0
|
||||
r.m_read.status = 0
|
||||
r.m_read.nResumeTS = 0
|
||||
r.m_read.nIgnoredFrameCounter = 0
|
||||
r.m_read.nIgnoredFlvFrameCounter = 0
|
||||
|
||||
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.free(unsafe.Pointer(*(**C_RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn),
|
||||
//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
|
||||
C.AV_clear(r.m_methodCalls, r.m_numCalls)
|
||||
|
||||
r.m_methodCalls = nil
|
||||
r.m_numCalls = 0
|
||||
r.m_numInvokes = 0
|
||||
|
||||
r.m_bPlaying = C.uchar(0)
|
||||
r.m_sb.sb_size = 0
|
||||
|
||||
r.m_msgCounter = 0
|
||||
r.m_resplen = 0
|
||||
r.m_unackd = 0
|
||||
|
||||
if ((r.Link.lFlags & RTMP_LF_FTCU) != 0) && (reconnect == 0) {
|
||||
//C.free(unsafe.Pointer(r.Link.app.av_val))
|
||||
r.Link.app.av_val = nil
|
||||
r.Link.lFlags ^= RTMP_LF_FAPU
|
||||
}
|
||||
|
||||
if reconnect == 0 {
|
||||
//C.free(unsafe.Pointer(r.Link.playpath0.av_val))
|
||||
r.Link.playpath0.av_val = nil
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// int RTMPSockBuf_Fill(RTMPSockBuf* sb);
|
||||
// rtmp.c +4253
|
||||
func C_RTMPSockBuf_Fill(sb *C_RTMPSockBuf) int {
|
||||
|
|
Loading…
Reference in New Issue