static int rtp_open(URLContext *h, const char *uri, int flags)

{

    RTPContext *s;

    int port, is_output, ttl, local_port;

    char hostname[256];

    char buf[1024];

    char path[1024];

    const char *p;



    is_output = (flags & URL_WRONLY);



    s = av_mallocz(sizeof(RTPContext));

    if (!s)

        return AVERROR(ENOMEM);

    h->priv_data = s;



    url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,

              path, sizeof(path), uri);

    /* extract parameters */

    ttl = -1;

    local_port = -1;

    p = strchr(uri, '?');

    if (p) {

        if (find_info_tag(buf, sizeof(buf), "ttl", p)) {

            ttl = strtol(buf, NULL, 10);

        }

        if (find_info_tag(buf, sizeof(buf), "localport", p)) {

            local_port = strtol(buf, NULL, 10);

        }

    }



    build_udp_url(buf, sizeof(buf),

                  hostname, port, local_port, ttl);

    if (url_open(&s->rtp_hd, buf, flags) < 0)

        goto fail;

    local_port = udp_get_local_port(s->rtp_hd);

    /* XXX: need to open another connection if the port is not even */



    /* well, should suppress localport in path */



    build_udp_url(buf, sizeof(buf),

                  hostname, port + 1, local_port + 1, ttl);

    if (url_open(&s->rtcp_hd, buf, flags) < 0)

        goto fail;



    /* just to ease handle access. XXX: need to suppress direct handle

       access */

    s->rtp_fd = udp_get_file_handle(s->rtp_hd);

    s->rtcp_fd = udp_get_file_handle(s->rtcp_hd);



    h->max_packet_size = url_get_max_packet_size(s->rtp_hd);

    h->is_streamed = 1;

    return 0;



 fail:

    if (s->rtp_hd)

        url_close(s->rtp_hd);

    if (s->rtcp_hd)

        url_close(s->rtcp_hd);

    av_free(s);

    return AVERROR(EIO);

}

static int rtp_open(URLContext *h, const char *uri, int flags)

{

    RTPContext *s;

    int port, is_output, ttl, local_port;

    char hostname[256];

    char buf[1024];

    char path[1024];

    const char *p;



    is_output = (flags & URL_WRONLY);



    s = av_mallocz(sizeof(RTPContext));

    if (!s)

        return AVERROR(ENOMEM);

    h->priv_data = s;



    url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,

              path, sizeof(path), uri);

    

    ttl = -1;

    local_port = -1;

    p = strchr(uri, '?');

    if (p) {

        if (find_info_tag(buf, sizeof(buf), "ttl", p)) {

            ttl = strtol(buf, NULL, 10);

        }

        if (find_info_tag(buf, sizeof(buf), "localport", p)) {

            local_port = strtol(buf, NULL, 10);

        }

    }



    build_udp_url(buf, sizeof(buf),

                  hostname, port, local_port, ttl);

    if (url_open(&s->rtp_hd, buf, flags) < 0)

        goto fail;

    local_port = udp_get_local_port(s->rtp_hd);

    



    



    build_udp_url(buf, sizeof(buf),

                  hostname, port + 1, local_port + 1, ttl);

    if (url_open(&s->rtcp_hd, buf, flags) < 0)

        goto fail;



    



    s->rtp_fd = udp_get_file_handle(s->rtp_hd);

    s->rtcp_fd = udp_get_file_handle(s->rtcp_hd);



    h->max_packet_size = url_get_max_packet_size(s->rtp_hd);

    h->is_streamed = 1;

    return 0;



 fail:

    if (s->rtp_hd)

        url_close(s->rtp_hd);

    if (s->rtcp_hd)

        url_close(s->rtcp_hd);

    av_free(s);

    return AVERROR(EIO);

}

static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)

{

    RTPContext *s;

    int VAR_3, VAR_4, VAR_5, VAR_6;

    char VAR_7[256];

    char VAR_8[1024];

    char VAR_9[1024];

    const char *VAR_10;



    VAR_4 = (VAR_2 & URL_WRONLY);



    s = av_mallocz(sizeof(RTPContext));

    if (!s)

        return AVERROR(ENOMEM);

    VAR_0->priv_data = s;



    url_split(NULL, 0, NULL, 0, VAR_7, sizeof(VAR_7), &VAR_3,

              VAR_9, sizeof(VAR_9), VAR_1);

    

    VAR_5 = -1;

    VAR_6 = -1;

    VAR_10 = strchr(VAR_1, '?');

    if (VAR_10) {

        if (find_info_tag(VAR_8, sizeof(VAR_8), "VAR_5", VAR_10)) {

            VAR_5 = strtol(VAR_8, NULL, 10);

        }

        if (find_info_tag(VAR_8, sizeof(VAR_8), "localport", VAR_10)) {

            VAR_6 = strtol(VAR_8, NULL, 10);

        }

    }



    build_udp_url(VAR_8, sizeof(VAR_8),

                  VAR_7, VAR_3, VAR_6, VAR_5);

    if (url_open(&s->rtp_hd, VAR_8, VAR_2) < 0)

        goto fail;

    VAR_6 = udp_get_local_port(s->rtp_hd);

    



    



    build_udp_url(VAR_8, sizeof(VAR_8),

                  VAR_7, VAR_3 + 1, VAR_6 + 1, VAR_5);

    if (url_open(&s->rtcp_hd, VAR_8, VAR_2) < 0)

        goto fail;



    



    s->rtp_fd = udp_get_file_handle(s->rtp_hd);

    s->rtcp_fd = udp_get_file_handle(s->rtcp_hd);



    VAR_0->max_packet_size = url_get_max_packet_size(s->rtp_hd);

    VAR_0->is_streamed = 1;

    return 0;



 fail:

    if (s->rtp_hd)

        url_close(s->rtp_hd);

    if (s->rtcp_hd)

        url_close(s->rtcp_hd);

    av_free(s);

    return AVERROR(EIO);

}

static int FUNC_0(URLContext *VAR_0, const char *VAR_1, int VAR_2)
{ RTPContext *s; int VAR_3, VAR_4, VAR_5, VAR_6; char VAR_7[256]; char VAR_8[1024]; char VAR_9[1024]; const char *VAR_10; VAR_4 = (VAR_2 & URL_WRONLY); s = av_mallocz(sizeof(RTPContext)); if (!s)
return AVERROR(ENOMEM); VAR_0->priv_data = s; url_split(NULL, 0, NULL, 0, VAR_7, sizeof(VAR_7), &VAR_3,
VAR_9, sizeof(VAR_9), VAR_1); VAR_5 = -1; VAR_6 = -1; VAR_10 = strchr(VAR_1, '?'); if (VAR_10) { if (find_info_tag(VAR_8, sizeof(VAR_8), "VAR_5", VAR_10)) { VAR_5 = strtol(VAR_8, NULL, 10); } if (find_info_tag(VAR_8, sizeof(VAR_8), "localport", VAR_10)) { VAR_6 = strtol(VAR_8, NULL, 10); } } build_udp_url(VAR_8, sizeof(VAR_8),
VAR_7, VAR_3, VAR_6, VAR_5); if (url_open(&s->rtp_hd, VAR_8, VAR_2) < 0)
goto fail; VAR_6 = udp_get_local_port(s->rtp_hd); build_udp_url(VAR_8, sizeof(VAR_8),
VAR_7, VAR_3 + 1, VAR_6 + 1, VAR_5); if (url_open(&s->rtcp_hd, VAR_8, VAR_2) < 0)
goto fail; s->rtp_fd = udp_get_file_handle(s->rtp_hd); s->rtcp_fd = udp_get_file_handle(s->rtcp_hd); VAR_0->max_packet_size = url_get_max_packet_size(s->rtp_hd); VAR_0->is_streamed = 1; return 0; fail:
if (s->rtp_hd)
url_close(s->rtp_hd); if (s->rtcp_hd)
url_close(s->rtcp_hd); av_free(s); return AVERROR(EIO); }