On Thu, Dec 17, 2015 at 1:58 PM, Luca Barbato <lu_z...@gentoo.org> wrote:
> ---
>  libavformat/rtsp.c | 74 
> +++++++++++++++++++++++++++++-------------------------
>  1 file changed, 40 insertions(+), 34 deletions(-)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 4beb275..0c53e3e 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2233,13 +2233,51 @@ static void append_source_addrs(char *buf, int size, 
> const char *name,
>          av_strlcatf(buf, size, ",%s", addrs[i]->addr);
>  }
>
> +static int open_rtp_stream(AVFormatContext *s, RTSPStream *rtsp_st)
> +{
> +    RTSPState *rt = s->priv_data;
> +    AVDictionary *opts = map_to_opts(rt);
> +    char url[1024], namebuf[50];
> +    int err;
> +
> +    err = getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip,
> +                      sizeof(rtsp_st->sdp_ip),
> +                      namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
> +    if (err) {
> +        av_log(s, AV_LOG_ERROR, "getnameinfo: %s\n", gai_strerror(err));
> +        err = AVERROR(EIO);
> +        goto fail;
> +    }
> +    ff_url_join(url, sizeof(url), "rtp", NULL,
> +                namebuf, rtsp_st->sdp_port,
> +                "?localport=%d&ttl=%d&connect=%d&write_to_source=%d",
> +                rtsp_st->sdp_port, rtsp_st->sdp_ttl,
> +                rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0,
> +                rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0);
> +
> +    append_source_addrs(url, sizeof(url), "sources",
> +                        rtsp_st->nb_include_source_addrs,
> +                        rtsp_st->include_source_addrs);
> +    append_source_addrs(url, sizeof(url), "block",
> +                        rtsp_st->nb_exclude_source_addrs,
> +                        rtsp_st->exclude_source_addrs);
> +    err = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
> +                   &s->interrupt_callback, &opts);
> +    if (err < 0)
> +        err = AVERROR_INVALIDDATA;
> +
> +fail:
> +    av_dict_free(&opts);
> +
> +    return err;
> +}
> +
>  static int sdp_read_header(AVFormatContext *s)
>  {
>      RTSPState *rt = s->priv_data;
>      RTSPStream *rtsp_st;
>      int size, i, err;
>      char *content;
> -    char url[1024];
>
>      if (!ff_network_init())
>          return AVERROR(EIO);
> @@ -2267,43 +2305,11 @@ static int sdp_read_header(AVFormatContext *s)
>
>      /* open each RTP stream */
>      for (i = 0; i < rt->nb_rtsp_streams; i++) {
> -        char namebuf[50];
>          rtsp_st = rt->rtsp_streams[i];
>
>          if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) {
> -            AVDictionary *opts = map_to_opts(rt);
> -
> -            err = getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip,
> -                              sizeof(rtsp_st->sdp_ip),
> -                              namebuf, sizeof(namebuf), NULL, 0, 
> NI_NUMERICHOST);
> -            if (err) {
> -                av_log(s, AV_LOG_ERROR, "getnameinfo: %s\n", 
> gai_strerror(err));
> -                err = AVERROR(EIO);
> -                av_dict_free(&opts);
> +            if ((err = open_rtp_stream(s, rtsp_st)) < 0)
>                  goto fail;
> -            }
> -            ff_url_join(url, sizeof(url), "rtp", NULL,
> -                        namebuf, rtsp_st->sdp_port,
> -                        "?localport=%d&ttl=%d&connect=%d&write_to_source=%d",
> -                        rtsp_st->sdp_port, rtsp_st->sdp_ttl,
> -                        rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0,
> -                        rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0);
> -
> -            append_source_addrs(url, sizeof(url), "sources",
> -                                rtsp_st->nb_include_source_addrs,
> -                                rtsp_st->include_source_addrs);
> -            append_source_addrs(url, sizeof(url), "block",
> -                                rtsp_st->nb_exclude_source_addrs,
> -                                rtsp_st->exclude_source_addrs);
> -            err = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
> -                           &s->interrupt_callback, &opts);
> -
> -            av_dict_free(&opts);
> -
> -            if (err < 0) {
> -                err = AVERROR_INVALIDDATA;
> -                goto fail;
> -            }
>          }
>          if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st)))
>              goto fail;
> --
> 2.6.1

is this still needed?
-- 
Vittorio
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to