Using my rtmpSendPacket func - tested and working

This commit is contained in:
saxon 2018-07-28 21:41:42 +09:30
parent 8285941eec
commit e059095c74
1 changed files with 16 additions and 11 deletions

View File

@ -943,8 +943,8 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
var enc *byte
if cp != nil {
//return rtmpSendPacket(r, cp, 1)
return int(C.RTMP_SendPacket(r, cp, 1))
return rtmpSendPacket(r, cp, 1)
//return int(C.RTMP_SendPacket(r, cp, 1))
}
packet.m_nChannel = 0x03
@ -1106,8 +1106,8 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
packet.m_nBodySize = C.uint32_t(int(uintptr(decBytePtr(unsafe.Pointer(enc),
int(uintptr(unsafe.Pointer(packet.m_body)))))))
return int(C.RTMP_SendPacket(r, &packet, 1))
// return rtmpSendPacket(r, &packet, 1)
//return int(C.RTMP_SendPacket(r, &packet, 1))
return rtmpSendPacket(r, &packet, 1)
}
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
@ -1269,11 +1269,11 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
var packets unsafe.Pointer
if packet.m_nChannel >= r.m_channelsAllocatedOut {
log.Println("Resize")
n := int(packet.m_nChannel + 10)
// TODO: port this
packets = realloc(unsafe.Pointer(r.m_vecChannelsOut),
int(unsafe.Sizeof(packet)*uintptr(n)))
packets = C.realloc(unsafe.Pointer(r.m_vecChannelsOut), C.size_t(
unsafe.Sizeof(packet)*uintptr(n)))
//packets = realloc(unsafe.Pointer(r.m_vecChannelsOut),
//int(unsafe.Sizeof(packet)*uintptr(n)))
if uintptr(packets) == uintptr(0) {
//C.free(unsafe.Pointer(r.m_vecChannelsOut))
@ -1282,10 +1282,13 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
return 0
}
r.m_vecChannelsOut = (**C.RTMPPacket)(packets)
// TODO: replace this with my memset
C.memset(incPtr(unsafe.Pointer(r.m_vecChannelsOut), int(r.m_channelsAllocatedOut),
int(unsafe.Sizeof(packet))), 0, C.size_t(unsafe.Sizeof(packet)*
uintptr(n-int(r.m_channelsAllocatedOut))))
//memset((*byte)(incPtr(unsafe.Pointer(r.m_vecChannelsOut), int(
//r.m_channelsAllocatedOut), int(unsafe.Sizeof(packet))), 0, int(
//unsafe.Sizeof(packet)*uintptr(n-int(r.m_channelsAllocatedOut)))))
r.m_channelsAllocatedOut = C.int(n)
}
prevPacket = *(**C.RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsOut),
@ -1492,7 +1495,8 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
var method C.AVal
var ptr unsafe.Pointer
ptr = incBytePtr(unsafe.Pointer(packet.m_body), 1)
amfDecodeString((*byte)(ptr), &method)
C.AMF_DecodeString((*C.char)(ptr), &method)
//amfDecodeString((*byte)(ptr), &method)
if debugMode {
log.Printf("Invoking %v", method.av_val)
@ -1501,7 +1505,8 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
if queue != 0 {
var txn int
ptr = incBytePtr(ptr, 3+int(method.av_len))
txn = int(amfDecodeNumber((*byte)(ptr)))
txn = int(C.AMF_DecodeNumber((*C.char)(ptr)))
//txn = int(amfDecodeNumber((*byte)(ptr)))
// TODO: port this
C.AV_queue(&r.m_methodCalls, (*C.int)(unsafe.Pointer(&r.m_numCalls)), &method,
C.int(txn))