int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,

                           const uint8_t *name, uint8_t *dst, int dst_size)

{

    int namelen = strlen(name);

    int len;



    while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) {

        len = ff_amf_tag_size(data, data_end);

        if (len < 0)

            len = data_end - data;

        data += len;

    }

    if (data_end - data < 3)

        return -1;

    data++;

    for (;;) {

        int size = bytestream_get_be16(&data);

        if (!size)

            break;

        if (data + size >= data_end || data + size < data)

            return -1;

        data += size;

        if (size == namelen && !memcmp(data-size, name, namelen)) {

            switch (*data++) {

            case AMF_DATA_TYPE_NUMBER:

                snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));

                break;

            case AMF_DATA_TYPE_BOOL:

                snprintf(dst, dst_size, "%s", *data ? "true" : "false");

                break;

            case AMF_DATA_TYPE_STRING:

                len = bytestream_get_be16(&data);

                av_strlcpy(dst, data, FFMIN(len+1, dst_size));

                break;

            default:

                return -1;

            }

            return 0;

        }

        len = ff_amf_tag_size(data, data_end);

        if (len < 0 || data + len >= data_end || data + len < data)

            return -1;

        data += len;

    }

    return -1;

}

int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,

                           const uint8_t *name, uint8_t *dst, int dst_size)

{

    int namelen = strlen(name);

    int len;



    while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) {

        len = ff_amf_tag_size(data, data_end);

        if (len < 0)

            len = data_end - data;

        data += len;

    }

    if (data_end - data < 3)

        return -1;

    data++;

    for (;;) {

        int size = bytestream_get_be16(&data);

        if (!size)

            break;

        if (data + size >= data_end || data + size < data)

            return -1;

        data += size;

        if (size == namelen && !memcmp(data-size, name, namelen)) {

            switch (*data++) {

            case AMF_DATA_TYPE_NUMBER:

                snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));

                break;

            case AMF_DATA_TYPE_BOOL:

                snprintf(dst, dst_size, "%s", *data ? "true" : "false");

                break;

            case AMF_DATA_TYPE_STRING:

                len = bytestream_get_be16(&data);

                av_strlcpy(dst, data, FFMIN(len+1, dst_size));

                break;

            default:

                return -1;

            }

            return 0;

        }

        len = ff_amf_tag_size(data, data_end);

        if (len < 0 || data + len >= data_end || data + len < data)

            return -1;

        data += len;

    }

    return -1;

}

        if (data + size >= data_end || data + size < data)         if (len < 0 || data + len >= data_end || data + len < data)
int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,

                           const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4)

{

    int VAR_5 = strlen(VAR_2);

    int VAR_6;



    while (*VAR_0 != AMF_DATA_TYPE_OBJECT && VAR_0 < VAR_1) {

        VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);

        if (VAR_6 < 0)

            VAR_6 = VAR_1 - VAR_0;

        VAR_0 += VAR_6;

    }

    if (VAR_1 - VAR_0 < 3)

        return -1;

    VAR_0++;

    for (;;) {

        int VAR_7 = bytestream_get_be16(&VAR_0);

        if (!VAR_7)

            break;

        if (VAR_0 + VAR_7 >= VAR_1 || VAR_0 + VAR_7 < VAR_0)

            return -1;

        VAR_0 += VAR_7;

        if (VAR_7 == VAR_5 && !memcmp(VAR_0-VAR_7, VAR_2, VAR_5)) {

            switch (*VAR_0++) {

            case AMF_DATA_TYPE_NUMBER:

                snprintf(VAR_3, VAR_4, "%g", av_int2double(AV_RB64(VAR_0)));

                break;

            case AMF_DATA_TYPE_BOOL:

                snprintf(VAR_3, VAR_4, "%s", *VAR_0 ? "true" : "false");

                break;

            case AMF_DATA_TYPE_STRING:

                VAR_6 = bytestream_get_be16(&VAR_0);

                av_strlcpy(VAR_3, VAR_0, FFMIN(VAR_6+1, VAR_4));

                break;

            default:

                return -1;

            }

            return 0;

        }

        VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);

        if (VAR_6 < 0 || VAR_0 + VAR_6 >= VAR_1 || VAR_0 + VAR_6 < VAR_0)

            return -1;

        VAR_0 += VAR_6;

    }

    return -1;

}

int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,
const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4)
{ int VAR_5 = strlen(VAR_2); int VAR_6; while (*VAR_0 != AMF_DATA_TYPE_OBJECT && VAR_0 < VAR_1) { VAR_6 = ff_amf_tag_size(VAR_0, VAR_1); if (VAR_6 < 0)
VAR_6 = VAR_1 - VAR_0; VAR_0 += VAR_6; } if (VAR_1 - VAR_0 < 3)
return -1; VAR_0++; for (;;) { int VAR_7 = bytestream_get_be16(&VAR_0); if (!VAR_7)
break; if (VAR_0 + VAR_7 >= VAR_1 || VAR_0 + VAR_7 < VAR_0)
return -1; VAR_0 += VAR_7; if (VAR_7 == VAR_5 && !memcmp(VAR_0-VAR_7, VAR_2, VAR_5)) { switch (*VAR_0++) { case AMF_DATA_TYPE_NUMBER:
snprintf(VAR_3, VAR_4, "%g", av_int2double(AV_RB64(VAR_0))); break; case AMF_DATA_TYPE_BOOL:
snprintf(VAR_3, VAR_4, "%s", *VAR_0 ? "true" : "false"); break; case AMF_DATA_TYPE_STRING:
VAR_6 = bytestream_get_be16(&VAR_0); av_strlcpy(VAR_3, VAR_0, FFMIN(VAR_6+1, VAR_4)); break; default:
return -1; } return 0; } VAR_6 = ff_amf_tag_size(VAR_0, VAR_1); if (VAR_6 < 0 || VAR_0 + VAR_6 >= VAR_1 || VAR_0 + VAR_6 < VAR_0)
return -1; VAR_0 += VAR_6; } return -1; }