Fixed some serious bugs

This commit is contained in:
saxon 2018-07-28 23:10:57 +09:30
parent 4847728ddf
commit bb1f63d8bd
1 changed files with 16 additions and 12 deletions

View File

@ -184,8 +184,8 @@ var (
av_audioCodecs = AVC("audioCodecs")
av_videoCodecs = AVC("videoCodecs")
av_videoFunction = AVC("videoFunction")
av_pageUrl = AVC("av_pageUrl")
av_objectEncoding = AVC("av_objectEncoding")
av_pageUrl = AVC("pageUrl")
av_objectEncoding = AVC("objectEncoding")
)
var packetSize = [...]int{12, 8, 4, 1}
@ -959,9 +959,9 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
enc = (*byte)(unsafe.Pointer(packet.m_body))
enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
(*C.char)(unsafe.Pointer(pend)), &av_connect)))
// enc = amfEncodeString(enc, pend, &av_connect)
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
//(*C.char)(unsafe.Pointer(pend)), &av_connect)))
enc = amfEncodeString(enc, pend, &av_connect)
r.m_numInvokes += 1
enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNumber((*C.char)(unsafe.Pointer(enc)),
(*C.char)(unsafe.Pointer(pend)), C.double(r.m_numInvokes))))
@ -1728,19 +1728,23 @@ func amfEncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
return nil
}
if bv.av_len < 65536 {
*(*C.char)(outputPtr) = C.AMF_STRING
*(*byte)(outputPtr) = AMF_STRING
incBytePtr(outputPtr, 1)
outputPtr = unsafe.Pointer(amfEncodeInt16((*byte)(outputPtr),
(*byte)(outendPtr), (int16)(bv.av_len)))
outputPtr = unsafe.Pointer(C.AMF_EncodeInt16((*C.char)(outputPtr), (*C.char)(
outendPtr), C.short(bv.av_len)))
//outputPtr = unsafe.Pointer(amfEncodeInt16((*byte)(outputPtr),
//(*byte)(outendPtr), (int16)(bv.av_len)))
} else {
*(*C.char)(outputPtr) = C.AMF_LONG_STRING
*(*byte)(outputPtr) = AMF_LONG_STRING
incBytePtr(outputPtr, 1)
outputPtr = unsafe.Pointer(amfEncodeInt32((*byte)(outputPtr),
(*byte)(outendPtr), (int32)(bv.av_len)))
outputPtr = unsafe.Pointer(C.AMF_EncodeInt32((*C.char)(outputPtr), (*C.char)(
outendPtr), C.int(bv.av_len)))
//outputPtr = unsafe.Pointer(amfEncodeInt32((*byte)(outputPtr),
//(*byte)(outendPtr), (int32)(bv.av_len)))
}
memmove(unsafe.Pointer(outputPtr), unsafe.Pointer(bv.av_val), uintptr(bv.av_len))
//C.memcpy(unsafe.Pointer(outputPtr), unsafe.Pointer(bv.av_val), (C.size_t)(bv.av_len))
incBytePtr(outputPtr, int(bv.av_len))
outputPtr = incBytePtr(outputPtr, int(bv.av_len))
return (*byte)(outputPtr)
}