[v2,4/5] rtsp: Remove the separate filter_source variable

Message ID 1318504831-10325-4-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Oct. 13, 2011, 11:20 a.m.
Read it as a flag from the flags field instead.
---
 libavformat/rtsp.c |    6 ++----
 libavformat/rtsp.h |    4 ----
 2 files changed, 2 insertions(+), 8 deletions(-)

Comments

Anton Khirnov Oct. 13, 2011, 3:27 p.m. | #1
On Thu, 13 Oct 2011 14:20:30 +0300, Martin Storsjö <martin@martin.st> wrote:
> Read it as a flag from the flags field instead.
> ---
>  libavformat/rtsp.c |    6 ++----
>  libavformat/rtsp.h |    4 ----
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 23c7b24..52a657b 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1235,7 +1235,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
>          case RTSP_LOWER_TRANSPORT_UDP: {
>              char url[1024], options[30] = "";
>  
> -            if (rt->filter_source)
> +            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]) {
> @@ -1331,8 +1331,6 @@ int ff_rtsp_connect(AVFormatContext *s)
>          lower_transport_mask  = 1 << RTSP_LOWER_TRANSPORT_TCP;
>          rt->control_transport = RTSP_MODE_TUNNEL;
>      }
> -    if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC)
> -        rt->filter_source = 1;
>  
>  redirect:
>      /* extract hostname and port */
> @@ -1370,7 +1368,7 @@ redirect:
>                  lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
>                  rt->control_transport = RTSP_MODE_TUNNEL;
>              } else if (!strcmp(option, "filter_src")) {
> -                rt->filter_source = 1;
> +                rt->rtsp_flags |= RTSP_FLAG_FILTER_SRC;
>              } else {
>                  /* Write options back into the buffer, using memmove instead
>                   * of strcpy since the strings may overlap. */
> diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
> index ba87c53..f427bd3 100644
> --- a/libavformat/rtsp.h
> +++ b/libavformat/rtsp.h
> @@ -317,10 +317,6 @@ typedef struct RTSPState {
>      /** Reusable buffer for receiving packets */
>      uint8_t* recvbuf;
>  
> -    /** Filter incoming UDP packets - receive packets only from the right
> -     * source address and port. */
> -    int filter_source;
> -

I'd move those docs to the RTSP_FLAG_FILTER_SRC definition.

Otherwise seems ok.
Martin Storsjö Oct. 17, 2011, 11:43 a.m. | #2
On Thu, 13 Oct 2011, Anton Khirnov wrote:

>
> On Thu, 13 Oct 2011 14:20:30 +0300, Martin Storsjö <martin@martin.st> wrote:
>> Read it as a flag from the flags field instead.
>> ---
>>  libavformat/rtsp.c |    6 ++----
>>  libavformat/rtsp.h |    4 ----
>>  2 files changed, 2 insertions(+), 8 deletions(-)
>>
>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>> index 23c7b24..52a657b 100644
>> --- a/libavformat/rtsp.c
>> +++ b/libavformat/rtsp.c
>> @@ -1235,7 +1235,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
>>          case RTSP_LOWER_TRANSPORT_UDP: {
>>              char url[1024], options[30] = "";
>>
>> -            if (rt->filter_source)
>> +            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]) {
>> @@ -1331,8 +1331,6 @@ int ff_rtsp_connect(AVFormatContext *s)
>>          lower_transport_mask  = 1 << RTSP_LOWER_TRANSPORT_TCP;
>>          rt->control_transport = RTSP_MODE_TUNNEL;
>>      }
>> -    if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC)
>> -        rt->filter_source = 1;
>>
>>  redirect:
>>      /* extract hostname and port */
>> @@ -1370,7 +1368,7 @@ redirect:
>>                  lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
>>                  rt->control_transport = RTSP_MODE_TUNNEL;
>>              } else if (!strcmp(option, "filter_src")) {
>> -                rt->filter_source = 1;
>> +                rt->rtsp_flags |= RTSP_FLAG_FILTER_SRC;
>>              } else {
>>                  /* Write options back into the buffer, using memmove instead
>>                   * of strcpy since the strings may overlap. */
>> diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
>> index ba87c53..f427bd3 100644
>> --- a/libavformat/rtsp.h
>> +++ b/libavformat/rtsp.h
>> @@ -317,10 +317,6 @@ typedef struct RTSPState {
>>      /** Reusable buffer for receiving packets */
>>      uint8_t* recvbuf;
>>
>> -    /** Filter incoming UDP packets - receive packets only from the right
>> -     * source address and port. */
>> -    int filter_source;
>> -
>
> I'd move those docs to the RTSP_FLAG_FILTER_SRC definition.

Changed locally, so that this comment is added to that definition in patch 
#3, where it is added.

// Martin

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 23c7b24..52a657b 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1235,7 +1235,7 @@  int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
         case RTSP_LOWER_TRANSPORT_UDP: {
             char url[1024], options[30] = "";
 
-            if (rt->filter_source)
+            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]) {
@@ -1331,8 +1331,6 @@  int ff_rtsp_connect(AVFormatContext *s)
         lower_transport_mask  = 1 << RTSP_LOWER_TRANSPORT_TCP;
         rt->control_transport = RTSP_MODE_TUNNEL;
     }
-    if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC)
-        rt->filter_source = 1;
 
 redirect:
     /* extract hostname and port */
@@ -1370,7 +1368,7 @@  redirect:
                 lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
                 rt->control_transport = RTSP_MODE_TUNNEL;
             } else if (!strcmp(option, "filter_src")) {
-                rt->filter_source = 1;
+                rt->rtsp_flags |= RTSP_FLAG_FILTER_SRC;
             } else {
                 /* Write options back into the buffer, using memmove instead
                  * of strcpy since the strings may overlap. */
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index ba87c53..f427bd3 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -317,10 +317,6 @@  typedef struct RTSPState {
     /** Reusable buffer for receiving packets */
     uint8_t* recvbuf;
 
-    /** Filter incoming UDP packets - receive packets only from the right
-     * source address and port. */
-    int filter_source;
-
     /**
      * A mask with all requested transport methods
      */