static int udp_read_packet(AVFormatContext *s,

                           AVPacket *pkt)

{

    AVFormatContext *ic;

    AVStream *st;

    RTSPStream *rtsp_st;

    fd_set rfds;

    int fd1, fd2, fd_max, n, i, ret;

    char buf[RTP_MAX_PACKET_LENGTH];

    struct timeval tv;



    for(;;) {

        if (rtsp_abort_req)

            return -EIO;

        FD_ZERO(&rfds);

        fd_max = -1;

        for(i = 0; i < s->nb_streams; i++) {

            st = s->streams[i];

            rtsp_st = st->priv_data;

            ic = rtsp_st->ic;

            /* currently, we cannot probe RTCP handle because of blocking restrictions */

            rtp_get_file_handles(url_fileno(&ic->pb), &fd1, &fd2);

            if (fd1 > fd_max)

                fd_max = fd1;

            FD_SET(fd1, &rfds);

        }

        /* XXX: also add proper API to abort */

        tv.tv_sec = 0;

        tv.tv_usec = 500000;

        n = select(fd_max + 1, &rfds, NULL, NULL, &tv);

        if (n > 0) {

            for(i = 0; i < s->nb_streams; i++) {

                st = s->streams[i];

                rtsp_st = st->priv_data;

                ic = rtsp_st->ic;

                rtp_get_file_handles(url_fileno(&ic->pb), &fd1, &fd2);

                if (FD_ISSET(fd1, &rfds)) {

                    ret = url_read(url_fileno(&ic->pb), buf, sizeof(buf));

                    if (ret >= 0 && 

                        rtp_parse_packet(ic, pkt, buf, ret) == 0) {

                        pkt->stream_index = i;

                        return ret;

                    }

                }

            }

        }

    }

}

static int udp_read_packet(AVFormatContext *s,

                           AVPacket *pkt)

{

    AVFormatContext *ic;

    AVStream *st;

    RTSPStream *rtsp_st;

    fd_set rfds;

    int fd1, fd2, fd_max, n, i, ret;

    char buf[RTP_MAX_PACKET_LENGTH];

    struct timeval tv;



    for(;;) {

        if (rtsp_abort_req)

            return -EIO;

        FD_ZERO(&rfds);

        fd_max = -1;

        for(i = 0; i < s->nb_streams; i++) {

            st = s->streams[i];

            rtsp_st = st->priv_data;

            ic = rtsp_st->ic;

            

            rtp_get_file_handles(url_fileno(&ic->pb), &fd1, &fd2);

            if (fd1 > fd_max)

                fd_max = fd1;

            FD_SET(fd1, &rfds);

        }

        

        tv.tv_sec = 0;

        tv.tv_usec = 500000;

        n = select(fd_max + 1, &rfds, NULL, NULL, &tv);

        if (n > 0) {

            for(i = 0; i < s->nb_streams; i++) {

                st = s->streams[i];

                rtsp_st = st->priv_data;

                ic = rtsp_st->ic;

                rtp_get_file_handles(url_fileno(&ic->pb), &fd1, &fd2);

                if (FD_ISSET(fd1, &rfds)) {

                    ret = url_read(url_fileno(&ic->pb), buf, sizeof(buf));

                    if (ret >= 0 && 

                        rtp_parse_packet(ic, pkt, buf, ret) == 0) {

                        pkt->stream_index = i;

                        return ret;

                    }

                }

            }

        }

    }

}

static int FUNC_0(AVFormatContext *VAR_0,

                           AVPacket *VAR_1)

{

    AVFormatContext *ic;

    AVStream *st;

    RTSPStream *rtsp_st;

    fd_set rfds;

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;

    char VAR_8[RTP_MAX_PACKET_LENGTH];

    struct timeval VAR_9;



    for(;;) {

        if (rtsp_abort_req)

            return -EIO;

        FD_ZERO(&rfds);

        VAR_4 = -1;

        for(VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) {

            st = VAR_0->streams[VAR_6];

            rtsp_st = st->priv_data;

            ic = rtsp_st->ic;

            

            rtp_get_file_handles(url_fileno(&ic->pb), &VAR_2, &VAR_3);

            if (VAR_2 > VAR_4)

                VAR_4 = VAR_2;

            FD_SET(VAR_2, &rfds);

        }

        

        VAR_9.tv_sec = 0;

        VAR_9.tv_usec = 500000;

        VAR_5 = select(VAR_4 + 1, &rfds, NULL, NULL, &VAR_9);

        if (VAR_5 > 0) {

            for(VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) {

                st = VAR_0->streams[VAR_6];

                rtsp_st = st->priv_data;

                ic = rtsp_st->ic;

                rtp_get_file_handles(url_fileno(&ic->pb), &VAR_2, &VAR_3);

                if (FD_ISSET(VAR_2, &rfds)) {

                    VAR_7 = url_read(url_fileno(&ic->pb), VAR_8, sizeof(VAR_8));

                    if (VAR_7 >= 0 && 

                        rtp_parse_packet(ic, VAR_1, VAR_8, VAR_7) == 0) {

                        VAR_1->stream_index = VAR_6;

                        return VAR_7;

                    }

                }

            }

        }

    }

}

static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{ AVFormatContext *ic; AVStream *st; RTSPStream *rtsp_st; fd_set rfds; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; char VAR_8[RTP_MAX_PACKET_LENGTH]; struct timeval VAR_9; for(;;) { if (rtsp_abort_req)
return -EIO; FD_ZERO(&rfds); VAR_4 = -1; for(VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) { st = VAR_0->streams[VAR_6]; rtsp_st = st->priv_data; ic = rtsp_st->ic; rtp_get_file_handles(url_fileno(&ic->pb), &VAR_2, &VAR_3); if (VAR_2 > VAR_4)
VAR_4 = VAR_2; FD_SET(VAR_2, &rfds); } VAR_9.tv_sec = 0; VAR_9.tv_usec = 500000; VAR_5 = select(VAR_4 + 1, &rfds, NULL, NULL, &VAR_9); if (VAR_5 > 0) { for(VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) { st = VAR_0->streams[VAR_6]; rtsp_st = st->priv_data; ic = rtsp_st->ic; rtp_get_file_handles(url_fileno(&ic->pb), &VAR_2, &VAR_3); if (FD_ISSET(VAR_2, &rfds)) { VAR_7 = url_read(url_fileno(&ic->pb), VAR_8, sizeof(VAR_8)); if (VAR_7 >= 0 &&
rtp_parse_packet(ic, VAR_1, VAR_8, VAR_7) == 0) { VAR_1->stream_index = VAR_6; return VAR_7; } } } } } }