Ported amfEncodeEcmaArray - need to test

This commit is contained in:
saxon 2018-07-31 07:30:34 +09:30
parent f4ce5dff9d
commit a1a8289a7f
1 changed files with 31 additions and 1 deletions

View File

@ -1171,7 +1171,7 @@ func amfEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
return nil return nil
} }
*(*byte)(unsafe.Pointer(pBuffer)) = AMF_OBJECT *pBuffer = AMF_OBJECT
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1)) pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
for i := 0; i < int(obj.o_num); i++ { for i := 0; i < int(obj.o_num); i++ {
@ -1194,6 +1194,36 @@ func amfEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
return pBuffer return pBuffer
} }
func amfEncodeEcmaArray(obj *AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
if int(uintptr(unsafe.Pointer(pBuffer)))+4 >= int(uintptr(unsafe.Pointer(pBufEnd))) {
return nil
}
*pBuffer = AMF_ECMA_ARRAY
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
pBuffer = amfEncodeInt32(pBuffer, pBufEnd, int32(obj.o_num))
for i := 0; i < int(obj.o_num); i++ {
res := amfPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer(
obj.o_props), i, int(unsafe.Sizeof(*obj.o_props)))), pBuffer, pBufEnd)
if res == nil {
log.Println("amfEncodeEcmaArray: failed to encode property!")
break
} else {
pBuffer = res
}
}
if int(uintptr(unsafe.Pointer(pBuffer)))+3 >= int(uintptr(unsafe.Pointer(pBufEnd))) {
return nil
}
pBuffer = amfEncodeInt24(pBuffer, pBufEnd, AMF_OBJECT_END)
return pBuffer
}
func rtmpConnectStream(r *C.RTMP, seekTime int32) int { func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
var packet C.RTMPPacket var packet C.RTMPPacket
memset((*byte)(unsafe.Pointer(&packet)), 0, int(unsafe.Sizeof(packet))) memset((*byte)(unsafe.Pointer(&packet)), 0, int(unsafe.Sizeof(packet)))