rtsp: Simplify code for forming the remote peer url

Message ID 1375339904-75311-1-git-send-email-martin@martin.st
State Committed
Commit fd8f91e3f44a2bdbefaaebead388133c5fdd3423
Headers show

Commit Message

Martin Storsjö Aug. 1, 2013, 6:51 a.m.
---
 libavformat/rtsp.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Anton Khirnov Aug. 1, 2013, 7:36 a.m. | #1
On Thu,  1 Aug 2013 09:51:44 +0300, Martin Storsjö <martin@martin.st> wrote:
> ---
>  libavformat/rtsp.c |   13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index db96bc6..266f052 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1483,18 +1483,15 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
>  
>          case RTSP_LOWER_TRANSPORT_UDP: {
>              char url[1024], options[30] = "";
> +            const char *peer = host;
>  
>              if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC)
>                  av_strlcpy(options, "?connect=1", sizeof(options));
>              /* Use source address if specified */
> -            if (reply->transports[0].source[0]) {
> -                ff_url_join(url, sizeof(url), "rtp", NULL,
> -                            reply->transports[0].source,
> -                            reply->transports[0].server_port_min, "%s", options);
> -            } else {
> -                ff_url_join(url, sizeof(url), "rtp", NULL, host,
> -                            reply->transports[0].server_port_min, "%s", options);
> -            }
> +            if (reply->transports[0].source[0])
> +                peer = reply->transports[0].source;
> +            ff_url_join(url, sizeof(url), "rtp", NULL, peer,
> +                        reply->transports[0].server_port_min, "%s", options);
>              if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
>                  ff_rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
>                  err = AVERROR_INVALIDDATA;
> -- 
> 1.7.9.4
> 

Looks sane

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index db96bc6..266f052 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1483,18 +1483,15 @@  int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
 
         case RTSP_LOWER_TRANSPORT_UDP: {
             char url[1024], options[30] = "";
+            const char *peer = host;
 
             if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC)
                 av_strlcpy(options, "?connect=1", sizeof(options));
             /* Use source address if specified */
-            if (reply->transports[0].source[0]) {
-                ff_url_join(url, sizeof(url), "rtp", NULL,
-                            reply->transports[0].source,
-                            reply->transports[0].server_port_min, "%s", options);
-            } else {
-                ff_url_join(url, sizeof(url), "rtp", NULL, host,
-                            reply->transports[0].server_port_min, "%s", options);
-            }
+            if (reply->transports[0].source[0])
+                peer = reply->transports[0].source;
+            ff_url_join(url, sizeof(url), "rtp", NULL, peer,
+                        reply->transports[0].server_port_min, "%s", options);
             if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
                 ff_rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
                 err = AVERROR_INVALIDDATA;