Ported and using RTMPPacket_Free - tested and working

This commit is contained in:
saxon 2018-08-11 14:34:52 +09:30
parent 9cde6f49f7
commit 1ed14d523d
1 changed files with 11 additions and 3 deletions

View File

@ -1720,18 +1720,27 @@ func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
packet.m_packetType == RTMP_PACKET_TYPE_VIDEO || packet.m_packetType == RTMP_PACKET_TYPE_VIDEO ||
packet.m_packetType == RTMP_PACKET_TYPE_INFO { packet.m_packetType == RTMP_PACKET_TYPE_INFO {
log.Println("C_RTMP_ConnectStream: got packet before play()! Ignoring.") log.Println("C_RTMP_ConnectStream: got packet before play()! Ignoring.")
C.RTMPPacket_Free(&packet) C_RTMPPacket_Free(&packet)
continue continue
} }
// TODO: port this // TODO: port this
C.RTMP_ClientPacket(r, &packet) C.RTMP_ClientPacket(r, &packet)
C.RTMPPacket_Free(&packet) C_RTMPPacket_Free(&packet)
} }
} }
return int(r.m_bPlaying) return int(r.m_bPlaying)
} }
// void RTMPPacket_Free(RTMPPacket* p);
// rtmp.c +203
func C_RTMPPacket_Free(p *C.RTMPPacket) {
if p.m_body != nil {
C.free(decBytePtr(unsafe.Pointer(p.m_body), RTMP_MAX_HEADER_SIZE))
p.m_body = nil
}
}
// int RTMP_ReadPacket(RTMP* r, RTMPPacket* packet); // int RTMP_ReadPacket(RTMP* r, RTMPPacket* packet);
// rtmp.c +3550 // rtmp.c +3550
func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 { func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
@ -2372,7 +2381,6 @@ func C_WriteN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
for n > 0 { for n > 0 {
var nBytes int var nBytes int
// TODO: port this if necessary
nBytes = int(C_RTMPSockBuf_Send(&r.m_sb, (*byte)(ptr), int32(n))) nBytes = int(C_RTMPSockBuf_Send(&r.m_sb, (*byte)(ptr), int32(n)))
if nBytes < 0 { if nBytes < 0 {