'Parse the next metadata value.'

def _parse_value(self, data):

    if (ord(data[0]) == FLV_DATA_TYPE_NUMBER):
        value = struct.unpack(u'>d', data[1:9])[0]
        return (9, value)
    if (ord(data[0]) == FLV_DATA_TYPE_BOOL):
        return (2, bool(data[1]))
    if (ord(data[0]) == FLV_DATA_TYPE_STRING):
        length = ((ord(data[1]) << 8) + ord(data[2]))
        return ((length + 3), data[3:(length + 3)])
    if (ord(data[0]) == FLV_DATA_TYPE_ECMARRAY):
        init_length = len(data)
        num = struct.unpack(u'>I', data[1:5])[0]
        data = data[5:]
        result = {}
        for _ in range(num):
            length = ((ord(data[0]) << 8) + ord(data[1]))
            key = data[2:(length + 2)]
            data = data[(length + 2):]
            (length, value) = self._parse_value(data)
            if (not length):
                return (0, result)
            result[key] = value
            data = data[length:]
        return ((init_length - len(data)), result)
    log.info(u'unknown    code:    %x.    Stop    metadata    parser', ord(data[0]))
    return (0, None)
