static int get_http_header_data(MMSHContext *mmsh)

{

    MMSContext *mms = &mmsh->mms;

    int res, len;

    ChunkType chunk_type;



    for (;;) {

        len = 0;

        res = chunk_type = get_chunk_header(mmsh, &len);

        if (res < 0) {

            return res;

        } else if (chunk_type == CHUNK_TYPE_ASF_HEADER){

            // get asf header and stored it

            if (!mms->header_parsed) {

                if (mms->asf_header) {

                    if (len != mms->asf_header_size) {

                        mms->asf_header_size = len;

                        av_dlog(NULL, "Header len changed from %d to %d\n",

                                mms->asf_header_size, len);

                        av_freep(&mms->asf_header);

                    }

                }

                mms->asf_header = av_mallocz(len);

                if (!mms->asf_header) {

                    return AVERROR(ENOMEM);

                }

                mms->asf_header_size = len;

            }

            if (len > mms->asf_header_size) {

                av_log(NULL, AV_LOG_ERROR,

                       "Asf header packet len = %d exceed the asf header buf size %d\n",

                       len, mms->asf_header_size);

                return AVERROR(EIO);

            }

            res = ffurl_read_complete(mms->mms_hd, mms->asf_header, len);

            if (res != len) {

                av_log(NULL, AV_LOG_ERROR,

                       "Recv asf header data len %d != expected len %d\n", res, len);

                return AVERROR(EIO);

            }

            mms->asf_header_size = len;

            if (!mms->header_parsed) {

                res = ff_mms_asf_header_parser(mms);

                mms->header_parsed = 1;

                return res;

            }

        } else if (chunk_type == CHUNK_TYPE_DATA) {

            // read data packet and do padding

            return read_data_packet(mmsh, len);

        } else {

            if (len) {

                if (len > sizeof(mms->in_buffer)) {

                    av_log(NULL, AV_LOG_ERROR,

                           "Other packet len = %d exceed the in_buffer size %zu\n",

                           len, sizeof(mms->in_buffer));

                    return AVERROR(EIO);

                }

                res = ffurl_read_complete(mms->mms_hd, mms->in_buffer, len);

                if (res != len) {

                    av_log(NULL, AV_LOG_ERROR, "Read other chunk type data failed!\n");

                    return AVERROR(EIO);

                } else {

                    av_dlog(NULL, "Skip chunk type %d \n", chunk_type);

                    continue;

                }

            }

        }

    }

    return 0;

}

static int get_http_header_data(MMSHContext *mmsh)

{

    MMSContext *mms = &mmsh->mms;

    int res, len;

    ChunkType chunk_type;



    for (;;) {

        len = 0;

        res = chunk_type = get_chunk_header(mmsh, &len);

        if (res < 0) {

            return res;

        } else if (chunk_type == CHUNK_TYPE_ASF_HEADER){

            

            if (!mms->header_parsed) {

                if (mms->asf_header) {

                    if (len != mms->asf_header_size) {

                        mms->asf_header_size = len;

                        av_dlog(NULL, "Header len changed from %d to %d\n",

                                mms->asf_header_size, len);

                        av_freep(&mms->asf_header);

                    }

                }

                mms->asf_header = av_mallocz(len);

                if (!mms->asf_header) {

                    return AVERROR(ENOMEM);

                }

                mms->asf_header_size = len;

            }

            if (len > mms->asf_header_size) {

                av_log(NULL, AV_LOG_ERROR,

                       "Asf header packet len = %d exceed the asf header buf size %d\n",

                       len, mms->asf_header_size);

                return AVERROR(EIO);

            }

            res = ffurl_read_complete(mms->mms_hd, mms->asf_header, len);

            if (res != len) {

                av_log(NULL, AV_LOG_ERROR,

                       "Recv asf header data len %d != expected len %d\n", res, len);

                return AVERROR(EIO);

            }

            mms->asf_header_size = len;

            if (!mms->header_parsed) {

                res = ff_mms_asf_header_parser(mms);

                mms->header_parsed = 1;

                return res;

            }

        } else if (chunk_type == CHUNK_TYPE_DATA) {

            

            return read_data_packet(mmsh, len);

        } else {

            if (len) {

                if (len > sizeof(mms->in_buffer)) {

                    av_log(NULL, AV_LOG_ERROR,

                           "Other packet len = %d exceed the in_buffer size %zu\n",

                           len, sizeof(mms->in_buffer));

                    return AVERROR(EIO);

                }

                res = ffurl_read_complete(mms->mms_hd, mms->in_buffer, len);

                if (res != len) {

                    av_log(NULL, AV_LOG_ERROR, "Read other chunk type data failed!\n");

                    return AVERROR(EIO);

                } else {

                    av_dlog(NULL, "Skip chunk type %d \n", chunk_type);

                    continue;

                }

            }

        }

    }

    return 0;

}

static int FUNC_0(MMSHContext *VAR_0)

{

    MMSContext *mms = &VAR_0->mms;

    int VAR_1, VAR_2;

    ChunkType chunk_type;



    for (;;) {

        VAR_2 = 0;

        VAR_1 = chunk_type = get_chunk_header(VAR_0, &VAR_2);

        if (VAR_1 < 0) {

            return VAR_1;

        } else if (chunk_type == CHUNK_TYPE_ASF_HEADER){

            

            if (!mms->header_parsed) {

                if (mms->asf_header) {

                    if (VAR_2 != mms->asf_header_size) {

                        mms->asf_header_size = VAR_2;

                        av_dlog(NULL, "Header VAR_2 changed from %d to %d\n",

                                mms->asf_header_size, VAR_2);

                        av_freep(&mms->asf_header);

                    }

                }

                mms->asf_header = av_mallocz(VAR_2);

                if (!mms->asf_header) {

                    return AVERROR(ENOMEM);

                }

                mms->asf_header_size = VAR_2;

            }

            if (VAR_2 > mms->asf_header_size) {

                av_log(NULL, AV_LOG_ERROR,

                       "Asf header packet VAR_2 = %d exceed the asf header buf size %d\n",

                       VAR_2, mms->asf_header_size);

                return AVERROR(EIO);

            }

            VAR_1 = ffurl_read_complete(mms->mms_hd, mms->asf_header, VAR_2);

            if (VAR_1 != VAR_2) {

                av_log(NULL, AV_LOG_ERROR,

                       "Recv asf header data VAR_2 %d != expected VAR_2 %d\n", VAR_1, VAR_2);

                return AVERROR(EIO);

            }

            mms->asf_header_size = VAR_2;

            if (!mms->header_parsed) {

                VAR_1 = ff_mms_asf_header_parser(mms);

                mms->header_parsed = 1;

                return VAR_1;

            }

        } else if (chunk_type == CHUNK_TYPE_DATA) {

            

            return read_data_packet(VAR_0, VAR_2);

        } else {

            if (VAR_2) {

                if (VAR_2 > sizeof(mms->in_buffer)) {

                    av_log(NULL, AV_LOG_ERROR,

                           "Other packet VAR_2 = %d exceed the in_buffer size %zu\n",

                           VAR_2, sizeof(mms->in_buffer));

                    return AVERROR(EIO);

                }

                VAR_1 = ffurl_read_complete(mms->mms_hd, mms->in_buffer, VAR_2);

                if (VAR_1 != VAR_2) {

                    av_log(NULL, AV_LOG_ERROR, "Read other chunk type data failed!\n");

                    return AVERROR(EIO);

                } else {

                    av_dlog(NULL, "Skip chunk type %d \n", chunk_type);

                    continue;

                }

            }

        }

    }

    return 0;

}

static int FUNC_0(MMSHContext *VAR_0)
{ MMSContext *mms = &VAR_0->mms; int VAR_1, VAR_2; ChunkType chunk_type; for (;;) { VAR_2 = 0; VAR_1 = chunk_type = get_chunk_header(VAR_0, &VAR_2); if (VAR_1 < 0) { return VAR_1; } else if (chunk_type == CHUNK_TYPE_ASF_HEADER){ if (!mms->header_parsed) { if (mms->asf_header) { if (VAR_2 != mms->asf_header_size) { mms->asf_header_size = VAR_2; av_dlog(NULL, "Header VAR_2 changed from %d to %d\n",
mms->asf_header_size, VAR_2); av_freep(&mms->asf_header); } } mms->asf_header = av_mallocz(VAR_2); if (!mms->asf_header) { return AVERROR(ENOMEM); } mms->asf_header_size = VAR_2; } if (VAR_2 > mms->asf_header_size) { av_log(NULL, AV_LOG_ERROR,
"Asf header packet VAR_2 = %d exceed the asf header buf size %d\n",
VAR_2, mms->asf_header_size); return AVERROR(EIO); } VAR_1 = ffurl_read_complete(mms->mms_hd, mms->asf_header, VAR_2); if (VAR_1 != VAR_2) { av_log(NULL, AV_LOG_ERROR,
"Recv asf header data VAR_2 %d != expected VAR_2 %d\n", VAR_1, VAR_2); return AVERROR(EIO); } mms->asf_header_size = VAR_2; if (!mms->header_parsed) { VAR_1 = ff_mms_asf_header_parser(mms); mms->header_parsed = 1; return VAR_1; } } else if (chunk_type == CHUNK_TYPE_DATA) { return read_data_packet(VAR_0, VAR_2); } else { if (VAR_2) { if (VAR_2 > sizeof(mms->in_buffer)) { av_log(NULL, AV_LOG_ERROR,
"Other packet VAR_2 = %d exceed the in_buffer size %zu\n",
VAR_2, sizeof(mms->in_buffer)); return AVERROR(EIO); } VAR_1 = ffurl_read_complete(mms->mms_hd, mms->in_buffer, VAR_2); if (VAR_1 != VAR_2) { av_log(NULL, AV_LOG_ERROR, "Read other chunk type data failed!\n"); return AVERROR(EIO); } else { av_dlog(NULL, "Skip chunk type %d \n", chunk_type); continue; } } } } return 0; }