示例#1
0
        public int Decode(byte[] pBuffer, int bufferOffset, int nSize, bool bDecodeName)
        {
            int nOriginalSize = nSize;
            bool bError = false; // if there is an error while decoding - try to at least find the end mark 0x000009

            while (nSize >= 3)
            {
                if (RTMP.ReadInt24(pBuffer, bufferOffset) == 0x00000009)
                {
                    nSize -= 3;
                    bError = false;
                    break;
                }

                if (bError)
                {
                    nSize--;
                    bufferOffset++;
                    continue;
                }

                AMFObjectProperty prop = new AMFObjectProperty();
                int nRes = prop.Decode(pBuffer, bufferOffset, nSize, bDecodeName);
                if (nRes == -1)
                    bError = true;
                else
                {
                    nSize -= nRes;
                    bufferOffset += nRes;
                    m_properties.Add(prop);
                }
            }

            if (bError) return -1;

            return nOriginalSize - nSize;
        }
示例#2
0
        public int DecodeArray(byte[] buffer, int offset, int nSize, int nArrayLen, bool bDecodeName)
        {
            int nOriginalSize = nSize;
            bool bError = false;

            while (nArrayLen > 0)
            {
                nArrayLen--;

                AMFObjectProperty prop = new AMFObjectProperty();
                int nRes = prop.Decode(buffer, offset, nSize, bDecodeName);
                if (nRes == -1)
                    bError = true;
                else
                {
                    nSize -= nRes;
                    offset += nRes;
                    m_properties.Add(prop);
                }
            }
            if (bError)
                return -1;

            return nOriginalSize - nSize;
        }