[vlc-devel] [PATCH] RealVideo Support

Remi Denis-Courmont rdenis at simphalempin.com
Fri May 23 08:47:48 CEST 2008


On Fri, 23 May 2008 10:59:47 +0800, Wang Bo <silencewang at msn.com> wrote:
> --- a/configure.ac
> +++ b/configure.ac
> @@ -483,7 +483,7 @@ dnl Check for system libs needed
>  need_libc=false
> 
>  dnl Check for usual libc functions
> -AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull
strsep
> isatty vasprintf asprintf swab sigrelse getpwuid_r memalign
posix_memalign
> if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r
> lrintf daemon scandir fork bsearch lstat strlcpy strdup strndup strnlen
> atof lldiv posix_fadvise posix_madvise uselocale])
> +AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull
strsep
> isatty vasprintf asprintf swab sigrelse getpwuid_r memalign
posix_memalign
> if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r
> lrintf daemon scandir fork bsearch lstat strlcpy strdup strndup strnlen
> atof lldiv posix_fadvise posix_madvise])
>  AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)])
>  AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)])
>  AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)])


What is this doing here?? Looks totally wrong.

> @@ -3439,6 +3439,7 @@ AC_ARG_ENABLE(real,
>    [  --enable-real           Real audio module (default disabled)])
>  if test "${enable_real}" = "yes"; then
>    VLC_ADD_PLUGIN([realaudio])
> +  VLC_ADD_PLUGIN([realvideo])
>  fi
> 
>  dnl

You should update the help text here.

> @@ -5909,6 +5910,8 @@ AS_IF([test "${enable_loader}" = "yes"],
>      VLC_ADD_LIBS([quicktime],[../../libs/loader/libloader.la -lpthread])
>      VLC_ADD_CPPFLAGS([realaudio],[-I../../@top_srcdir@/libs/loader
> -DLOADER])
>      VLC_ADD_LIBS([realaudio],[../../libs/loader/libloader.la])
> +    VLC_ADD_CPPFLAGS([realvideo],[-I../../@top_srcdir@/libs/loader
> -DLOADER])
> +    VLC_ADD_LIBS([realvideo],[../../libs/loader/libloader.la])
>    ])
> 
>  AC_ARG_WITH(,[Components:])

You can add identical flags to multiple plugins with a single VLC_ADD_*
invocation.

> @@ -127,12 +148,21 @@ static int RtspReadLine( void *p_userdata, uint8_t
> *p_buffer, int i_buffer )
> 
>      char *psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, 0 );
> 
> -    //fprintf(stderr, "ReadLine: %s\n", psz);
> -
> -    if( psz ) strncpy( (char *)p_buffer, psz, i_buffer );
> +    if ( psz )
> +    {
> +        if( strlen( psz ) > i_buffer - 1 )
> +        {
> +            msg_Warn( p_access, "Real RtspReadLine read a too long
> line");
> +            strncpy( (char *)p_buffer, psz + strlen(psz) - i_buffer +
10,
> i_buffer - 1 );
> +        }
> +        else
> +            strncpy( (char *)p_buffer, psz, i_buffer - 1 );
> +    }

Please don't put functions names in warnings. Users are not developers.

>      else *p_buffer = 0;
> 
> -    free( psz );
> +    p_buffer[ i_buffer -1 ] = '\0';
> +
> +    if( psz ) free( psz );

free() already checks for pointer NULLity, no need to do it yourself.

> @@ -209,7 +242,7 @@ static int Open( vlc_object_t *p_this )
>              psz_server = strdup("unknown");
>      }
> 
> -    if( strstr( psz_server, "Real" ) || strstr( psz_server, "Helix" ) )
> +    if( strstr( psz_server, "Real" ) || strstr( psz_server, "Helix" )||
> strstr( psz_server, "Vatata" ) )
>      {
>          uint32_t bandwidth = 10485800;
>          rmff_header_t *h;

Hmm, what is Vatata? looks like a debug statement, or change not directly
related to RealVideo -> separate patch.

> @@ -249,11 +284,11 @@ static int Open( vlc_object_t *p_this )
>      var_Create( p_access, "realrtsp-caching",
>                  VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
> 
> -    free( psz_server );
> +    if( psz_server ) free( psz_server );
>      return VLC_SUCCESS;
> 
>   error:
> -    free( psz_server );
> +    if( psz_server ) free( psz_server );
>      Close( p_this );
>      return VLC_EGENERIC;
>  }
> @@ -267,7 +302,7 @@ static void Close( vlc_object_t * p_this )
>      access_sys_t *p_sys = p_access->p_sys;
> 
>      if( p_sys->p_rtsp ) rtsp_close( p_sys->p_rtsp );
> -    free( p_sys->p_rtsp );
> +    if( p_sys->p_rtsp ) free( p_sys->p_rtsp );
>      free( p_sys );
>  }
> 

As already noted, free() checks for NULL internally.

> @@ -295,6 +350,8 @@ static block_t *BlockRead( access_t *p_access )
>      p_block->i_buffer = real_get_rdt_chunk( p_access->p_sys->p_rtsp,
> &pheader,
>                                              &p_block->p_buffer );
> 
> +    /*msg_Dbg( p_access, "real_get_rdt_chunk ok " );*/
> +    /*need update p_sys->i_pos ? maybe i_pos is response to
> stream_Tell!*/
>      return p_block;
>  }
> 

This change can probably be removed.

> @@ -311,7 +389,8 @@ static int Seek( access_t *p_access, int64_t i_pos )
>  
>
*****************************************************************************/
>  static int Control( access_t *p_access, int i_query, va_list args )
>  {
> -    bool   *pb_bool;
> +    access_sys_t *p_sys = p_access->p_sys;
> +    bool         *pb_bool;
>      int          *pi_int;
>      int64_t      *pi_64;
> 
> @@ -320,15 +399,14 @@ static int Control( access_t *p_access, int
i_query,
> va_list args )
>          /* */
>          case ACCESS_CAN_SEEK:
>          case ACCESS_CAN_FASTSEEK:
> -            pb_bool = (bool*)va_arg( args, bool* );
> -            *pb_bool = false;//p_sys->b_seekable;
> +            pb_bool = (bool *)va_arg( args, bool * );
> +            *pb_bool = p_sys->b_seekable; // false;//p_sys->b_seekable;
>              break;

Hmm... comments look weird.

> @@ -347,7 +425,29 @@ static int Control( access_t *p_access, int i_query,
> va_list args )
> 
>          /* */
>          case ACCESS_SET_PAUSE_STATE:
> -            /* Nothing to do */
> +            pb_bool = (bool*)va_arg( args, bool* );
> +//            break;
> +
> +            /* use this will be make sound bad */
> +            if ( pb_bool )
> +            {
> +                rtsp_request_pause(  p_sys->p_rtsp, NULL );
> +                RtspReadAndSkip( p_access );
> +            }

Not sure if pb_bool can legally be NULL by the calling conventions.

> @@ -355,7 +455,6 @@ static int Control( access_t *p_access, int i_query,
> va_list args )
>          case ACCESS_SET_SEEKPOINT:
>          case ACCESS_SET_PRIVATE_ID_STATE:
>          case ACCESS_GET_META:
> -        case ACCESS_GET_CONTENT_TYPE:
>              return VLC_EGENERIC;
> 
>          default:

Why is the last case removed?

> diff --git a/modules/access/rtsp/real.c b/modules/access/rtsp/real.c
> index da499ec..2de7c0f 100644
> --- a/modules/access/rtsp/real.c
> +++ b/modules/access/rtsp/real.c
> @@ -22,10 +22,8 @@
>   * along with this program; if not, write to the Free Software
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
> 02110-1301, USA.
>  
>
*****************************************************************************/
> -
> -#ifdef HAVE_CONFIG_H
> -# include "config.h"
> -#endif
> +#include <stdio.h>
> +#include <string.h>
> 
>  #include <vlc/vlc.h>
> 

Why is config.h removed?

> @@ -162,37 +160,37 @@ static void hash(char *field, char *param)
>    b = ((b << 0x17) | (b >> 0x09)) + c;
> 
>    a = ((~d | b) ^ c)  + LE_32((param+0x00)) + a - 0x0BD6DDBC;
> -  a = ((a << 0x06) | (a >> 0x1a)) + b;
> +  a = ((a << 0x06) | (a >> 0x1a)) + b;
>    d = ((~c | a) ^ b)  + LE_32((param+0x1c)) + d + 0x432AFF97;
> -  d = ((d << 0x0a) | (d >> 0x16)) + a;
> +  d = ((d << 0x0a) | (d >> 0x16)) + a;
>    c = ((~b | d) ^ a)  + LE_32((param+0x38)) + c - 0x546BDC59;
> -  c = ((c << 0x0f) | (c >> 0x11)) + d;
> +  c = ((c << 0x0f) | (c >> 0x11)) + d;
>    b = ((~a | c) ^ d)  + LE_32((param+0x14)) + b - 0x036C5FC7;
> -  b = ((b << 0x15) | (b >> 0x0b)) + c;
> +  b = ((b << 0x15) | (b >> 0x0b)) + c;
>    a = ((~d | b) ^ c)  + LE_32((param+0x30)) + a + 0x655B59C3;
> -  a = ((a << 0x06) | (a >> 0x1a)) + b;
> +  a = ((a << 0x06) | (a >> 0x1a)) + b;
>    d = ((~c | a) ^ b)  + LE_32((param+0x0C)) + d - 0x70F3336E;
> -  d = ((d << 0x0a) | (d >> 0x16)) + a;
> +  d = ((d << 0x0a) | (d >> 0x16)) + a;
>    c = ((~b | d) ^ a)  + LE_32((param+0x28)) + c - 0x00100B83;
> -  c = ((c << 0x0f) | (c >> 0x11)) + d;
> +  c = ((c << 0x0f) | (c >> 0x11)) + d;
>    b = ((~a | c) ^ d)  + LE_32((param+0x04)) + b - 0x7A7BA22F;
> -  b = ((b << 0x15) | (b >> 0x0b)) + c;
> +  b = ((b << 0x15) | (b >> 0x0b)) + c;
>    a = ((~d | b) ^ c)  + LE_32((param+0x20)) + a + 0x6FA87E4F;
> -  a = ((a << 0x06) | (a >> 0x1a)) + b;
> +  a = ((a << 0x06) | (a >> 0x1a)) + b;
>    d = ((~c | a) ^ b)  + LE_32((param+0x3c)) + d - 0x01D31920;
> -  d = ((d << 0x0a) | (d >> 0x16)) + a;
> +  d = ((d << 0x0a) | (d >> 0x16)) + a;
>    c = ((~b | d) ^ a)  + LE_32((param+0x18)) + c - 0x5CFEBCEC;
> -  c = ((c << 0x0f) | (c >> 0x11)) + d;
> +  c = ((c << 0x0f) | (c >> 0x11)) + d;
>    b = ((~a | c) ^ d)  + LE_32((param+0x34)) + b + 0x4E0811A1;
> -  b = ((b << 0x15) | (b >> 0x0b)) + c;
> +  b = ((b << 0x15) | (b >> 0x0b)) + c;
>    a = ((~d | b) ^ c)  + LE_32((param+0x10)) + a - 0x08AC817E;
> -  a = ((a << 0x06) | (a >> 0x1a)) + b;
> +  a = ((a << 0x06) | (a >> 0x1a)) + b;
>    d = ((~c | a) ^ b)  + LE_32((param+0x2c)) + d - 0x42C50DCB;
> -  d = ((d << 0x0a) | (d >> 0x16)) + a;
> +  d = ((d << 0x0a) | (d >> 0x16)) + a;
>    c = ((~b | d) ^ a)  + LE_32((param+0x08)) + c + 0x2AD7D2BB;
> -  c = ((c << 0x0f) | (c >> 0x11)) + d;
> +  c = ((c << 0x0f) | (c >> 0x11)) + d;
>    b = ((~a | c) ^ d)  + LE_32((param+0x24)) + b - 0x14792C6F;
> -  b = ((b << 0x15) | (b >> 0x0b)) + c;
> +  b = ((b << 0x15) | (b >> 0x0b)) + c;
> 
>    lprintf("hash output: %x %x %x %x\n", a, b, c, d);
> 

I don't understand why this is patched.

> @@ -480,7 +481,7 @@ rmff_header_t *real_parse_sdp(char *data, char
> **stream_rules, uint32_t bandwidt
> 
>      if (!desc->stream[i]->mlti_data) {
>        len = 0;
> -      free( buf );
> +      if( buf ) free( buf );
>        buf = NULL;
>      } else
>        len=select_mlti_data(desc->stream[i]->mlti_data,
> @@ -531,13 +532,13 @@ rmff_header_t *real_parse_sdp(char *data, char
> **stream_rules, uint32_t bandwidt
>    rmff_fix_header(header);
> 
>    if( desc ) sdpplin_free( desc );
> -  free( buf );
> +  if( buf ) free(buf);
>    return header;
> 
>  error:
>    if( desc ) sdpplin_free( desc );
>    if( header ) rmff_free_header( header );
> -  free( buf );
> +  if( buf ) free( buf );
>    return NULL;
>  }
> 

free()...

etc etc

-- 
Rémi Denis-Courmont
http://www.remlab.net




More information about the vlc-devel mailing list