From d88f0601bb59baa6304a86de4a97c8cdb9a93618 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Sun, 16 Sep 2018 09:19:21 +0930 Subject: [PATCH] rtmp: make C_AMF_DecodeArray take a []byte This is unused. --- rtmp/amf.go | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/rtmp/amf.go b/rtmp/amf.go index b4aba4fb..8ed8eb0f 100644 --- a/rtmp/amf.go +++ b/rtmp/amf.go @@ -559,35 +559,22 @@ func C_AMF_EncodeArray(obj *C_AMFObject, dst []byte) []byte { // int AMF_DecodeArray(AMFObject *obj, const char *pBuffer, int nSize, int nArrayLen, int bDecodeName); // amf.c +993 -func C_AMF_DecodeArray(obj *C_AMFObject, pBuffer *byte, nSize, nArrayLen, bDecodeName int32) int32 { - nOriginalSize := nSize - var bError int32 = 0 +func C_AMF_DecodeArray(obj *C_AMFObject, data []byte, nArrayLen, bDecodeName int32) int32 { + nOriginalSize := len(data) obj.o_props = obj.o_props[:0] - for nArrayLen > 0 { + for ; nArrayLen > 0 && len(data) != 0; nArrayLen-- { + var prop C_AMFObjectProperty - var nRes int32 - nArrayLen-- - - if nSize <= 0 { - bError = 1 - break - } - nRes = C_AMFProp_Decode(&prop, pl2b(pBuffer, int(nSize)), bDecodeName) + nRes := C_AMFProp_Decode(&prop, data, bDecodeName) if nRes == -1 { - bError = 1 - break - } else { - nSize -= nRes - pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), int(nRes))) - obj.o_props = append(obj.o_props, prop) + return -1 } - } - if bError != 0 { - return -1 + data = data[nRes:] + obj.o_props = append(obj.o_props, prop) } - return nOriginalSize - nSize + return int32(nOriginalSize - len(data)) } // int AMF_Decode(AMFObject *obj, const char* pBuffer, int nSize, int bDecodeName);