[FFmpeg-devel] [PATCH] RTSP alternate protocol 2-3/3

Benoit Fouet benoit.fouet
Mon Feb 11 09:39:38 CET 2008


Hi,

Ronald S. Bultje wrote:
> Index: ffmpeg/libavformat/rtsp.c
> ===================================================================
> --- ffmpeg.orig/libavformat/rtsp.c	2008-02-09 10:03:20.000000000 -0500
> +++ ffmpeg/libavformat/rtsp.c	2008-02-09 10:06:39.000000000 -0500
> @@ -870,7 +870,7 @@
>          transport[0] = '\0';
>  
>          /* RTP/UDP */
> -        if (protocol & (1 << RTSP_PROTOCOL_RTP_UDP)) {
> +	if (protocol == RTSP_PROTOCOL_RTP_UDP) {
>   

unrelated

>              char buf[256];
>  
>              /* first try in specified port range */
> @@ -901,14 +901,14 @@
>          }
>  
>          /* RTP/TCP */
> -        else if (protocol & (1 << RTSP_PROTOCOL_RTP_TCP)) {
> +        else if (protocol == RTSP_PROTOCOL_RTP_TCP) {
>              if (transport[0] != '\0')
>                  av_strlcat(transport, ",", sizeof(transport));
>              snprintf(transport + strlen(transport), sizeof(transport) - strlen(transport) - 1,
>                       "RTP/AVP/TCP");
>          }
>  
> -        else if (protocol & (1 << RTSP_PROTOCOL_RTP_UDP_MULTICAST)) {
> +        else if (protocol == RTSP_PROTOCOL_RTP_UDP_MULTICAST) {
>              if (transport[0] != '\0')
>                  av_strlcat(transport, ",", sizeof(transport));
>              snprintf(transport + strlen(transport),
> @@ -925,6 +925,10 @@
>                   "Transport: %s\r\n",
>                   rtsp_st->control_url, transport);
>          rtsp_send_cmd(s, cmd, reply, NULL);
> +        if (reply->status_code == 461 /* Unsupported protocol */ && i == 0) {
> +            err = 1;
> +            goto fail;
> +        } else
>          if (reply->status_code != RTSP_STATUS_OK ||
>              reply->nb_transports != 1) {
>              err = AVERROR_INVALIDDATA;
> @@ -1048,7 +1052,7 @@
>      }
>  
>      if (!protocol_mask)
> -        protocol_mask = rtsp_default_protocols;
> +        protocol_mask = (1 << RTSP_PROTOCOL_RTP_LAST) - 1;
>  
>      /* open the tcp connexion */
>      snprintf(tcpname, sizeof(tcpname), "tcp://%s:%d", host, port);
> @@ -1080,9 +1084,18 @@
>          goto fail;
>      }
>  
> -    err = make_setup_request(s, host, port, protocol_mask);
> -    if (err)
> -        goto fail;
> +    do {
> +        int protocol = ff_log2_tab[protocol_mask & ~(protocol_mask - 1)];
> +
> +        err = make_setup_request(s, host, port, protocol);
> +        if (err < 0)
> +            goto fail;
>   

cosmetics, and why have you changed the check ? was there something
wrong with it ?

> +        protocol_mask &= ~(1 << protocol);
> +        if (protocol_mask == 0 && err == 1) {
> +            err = AVERROR_INVALIDDATA;
> +            goto fail;
> +        }
> +    } while (err != 0);
>   

IIRC, while (!err) is prefered

>  
>      rt->state = RTSP_STATE_IDLE;
>      rt->seek_timestamp = 0; /* default is to start stream at position
> Index: ffmpeg/libavformat/rtsp.h
> ===================================================================
> --- ffmpeg.orig/libavformat/rtsp.h	2008-02-09 10:02:35.000000000 -0500
> +++ ffmpeg/libavformat/rtsp.h	2008-02-09 10:03:25.000000000 -0500
> @@ -29,6 +29,8 @@
>      RTSP_PROTOCOL_RTP_UDP = 0,
>      RTSP_PROTOCOL_RTP_TCP = 1,
>      RTSP_PROTOCOL_RTP_UDP_MULTICAST = 2,
> +    /**< This is not part of public API and shouldn't be used outside of ffmpeg */
> +    RTSP_PROTOCOL_RTP_LAST
>   

doxy comment prefix should be /**, not /**<

>  };
>  
>  #define RTSP_DEFAULT_PORT   554
>   
> ------------------------------------------------------------------------
>
> Index: ffmpeg/libavformat/rtsp.c
> ===================================================================
> --- ffmpeg.orig/libavformat/rtsp.c	2008-01-18 14:43:40.000000000 -0500
> +++ ffmpeg/libavformat/rtsp.c	2008-01-18 14:44:33.000000000 -0500
> @@ -928,9 +928,8 @@
>          if (reply->status_code == 461 /* Unsupported protocol */ && i == 0) {
>              err = 1;
>              goto fail;
> -        } else
> -        if (reply->status_code != RTSP_STATUS_OK ||
> -            reply->nb_transports != 1) {
> +        } else if (reply->status_code != RTSP_STATUS_OK ||
> +                   reply->nb_transports != 1) {
>              err = AVERROR_INVALIDDATA;
>              goto fail;
>          }
>   
> ------------------------------------------------------------------------
>
>   

-- 
Ben
Purple Labs S.A.
www.purplelabs.com




More information about the ffmpeg-devel mailing list