static int sdp_read_header(AVFormatContext *s,

                           AVFormatParameters *ap)

{

    RTSPState *rt = s->priv_data;

    RTSPStream *rtsp_st;

    int size, i, err;

    char *content;

    char url[1024];



    /* read the whole sdp file */

    /* XXX: better loading */

    content = av_malloc(SDP_MAX_SIZE);

    size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1);

    if (size <= 0) {

        av_free(content);

        return AVERROR_INVALIDDATA;

    }

    content[size] ='\0';



    sdp_parse(s, content);

    av_free(content);



    /* open each RTP stream */

    for(i=0;i<rt->nb_rtsp_streams;i++) {

        rtsp_st = rt->rtsp_streams[i];



        snprintf(url, sizeof(url), "rtp://%s:%d?localport=%d&ttl=%d",

                 inet_ntoa(rtsp_st->sdp_ip),

                 rtsp_st->sdp_port,

                 rtsp_st->sdp_port,

                 rtsp_st->sdp_ttl);

        if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {

            err = AVERROR_INVALIDDATA;

            goto fail;

        }

        if ((err = rtsp_open_transport_ctx(s, rtsp_st)))

            goto fail;

    }

    return 0;

 fail:

    rtsp_close_streams(rt);

    return err;

}

static int sdp_read_header(AVFormatContext *s,

                           AVFormatParameters *ap)

{

    RTSPState *rt = s->priv_data;

    RTSPStream *rtsp_st;

    int size, i, err;

    char *content;

    char url[1024];



    

    

    content = av_malloc(SDP_MAX_SIZE);

    size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1);

    if (size <= 0) {

        av_free(content);

        return AVERROR_INVALIDDATA;

    }

    content[size] ='\0';



    sdp_parse(s, content);

    av_free(content);



    

    for(i=0;i<rt->nb_rtsp_streams;i++) {

        rtsp_st = rt->rtsp_streams[i];



        snprintf(url, sizeof(url), "rtp:

                 inet_ntoa(rtsp_st->sdp_ip),

                 rtsp_st->sdp_port,

                 rtsp_st->sdp_port,

                 rtsp_st->sdp_ttl);

        if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {

            err = AVERROR_INVALIDDATA;

            goto fail;

        }

        if ((err = rtsp_open_transport_ctx(s, rtsp_st)))

            goto fail;

    }

    return 0;

 fail:

    rtsp_close_streams(rt);

    return err;

}

static int FUNC_0(AVFormatContext *VAR_0,

                           AVFormatParameters *VAR_1)

{

    RTSPState *rt = VAR_0->priv_data;

    RTSPStream *rtsp_st;

    int VAR_2, VAR_3, VAR_4;

    char *VAR_5;

    char VAR_6[1024];



    

    

    VAR_5 = av_malloc(SDP_MAX_SIZE);

    VAR_2 = get_buffer(VAR_0->pb, VAR_5, SDP_MAX_SIZE - 1);

    if (VAR_2 <= 0) {

        av_free(VAR_5);

        return AVERROR_INVALIDDATA;

    }

    VAR_5[VAR_2] ='\0';



    sdp_parse(VAR_0, VAR_5);

    av_free(VAR_5);



    

    for(VAR_3=0;VAR_3<rt->nb_rtsp_streams;VAR_3++) {

        rtsp_st = rt->rtsp_streams[VAR_3];



        snprintf(VAR_6, sizeof(VAR_6), "rtp:

                 inet_ntoa(rtsp_st->sdp_ip),

                 rtsp_st->sdp_port,

                 rtsp_st->sdp_port,

                 rtsp_st->sdp_ttl);

        if (url_open(&rtsp_st->rtp_handle, VAR_6, URL_RDWR) < 0) {

            VAR_4 = AVERROR_INVALIDDATA;

            goto fail;

        }

        if ((VAR_4 = rtsp_open_transport_ctx(VAR_0, rtsp_st)))

            goto fail;

    }

    return 0;

 fail:

    rtsp_close_streams(rt);

    return VAR_4;

}

static int FUNC_0(AVFormatContext *VAR_0,
AVFormatParameters *VAR_1)
{ RTSPState *rt = VAR_0->priv_data; RTSPStream *rtsp_st; int VAR_2, VAR_3, VAR_4; char *VAR_5; char VAR_6[1024]; VAR_5 = av_malloc(SDP_MAX_SIZE); VAR_2 = get_buffer(VAR_0->pb, VAR_5, SDP_MAX_SIZE - 1); if (VAR_2 <= 0) { av_free(VAR_5); return AVERROR_INVALIDDATA; } VAR_5[VAR_2] ='\0'; sdp_parse(VAR_0, VAR_5); av_free(VAR_5); for(VAR_3=0;VAR_3<rt->nb_rtsp_streams;VAR_3++) { rtsp_st = rt->rtsp_streams[VAR_3]; snprintf(VAR_6, sizeof(VAR_6), "rtp:
inet_ntoa(rtsp_st->sdp_ip),
rtsp_st->sdp_port,
rtsp_st->sdp_port,
rtsp_st->sdp_ttl); if (url_open(&rtsp_st->rtp_handle, VAR_6, URL_RDWR) < 0) { VAR_4 = AVERROR_INVALIDDATA; goto fail; } if ((VAR_4 = rtsp_open_transport_ctx(VAR_0, rtsp_st)))
goto fail; } return 0; fail:
rtsp_close_streams(rt); return VAR_4; }