[vlc-devel] [PATCH] realrtsp pause seek
Rémi Denis-Courmont
rdenis at simphalempin.com
Fri May 23 16:03:38 CEST 2008
Le Friday 23 May 2008 13:50:58 Wang Bo, vous avez écrit :
> @@ -120,6 +121,25 @@ static int RtspRead( void *p_userdata, uint8_t
> *p_buffer, int i_buffer ) return net_Read( p_access, p_sys->fd, 0,
> p_buffer, i_buffer, true ); }
>
> +static int RtspReadAndSkip( void * p_userdata )
> +{
> + access_t *p_access = (access_t *)p_userdata;
> + access_sys_t *p_sys = p_access->p_sys;
> + char buf[10240];
> + mtime_t time_wait = 500000;
> + int size, total=0;
> +
> + /*msg_Dbg( p_access, "Try RtspReadAndSkip ");*/
> + do {
> + size = net_ReadNonBlock( p_access, p_sys->fd, 0, buf, 10240,
> time_wait ); + /*if ( size > 0 ) buf[size] = 0;
> + msg_Dbg( p_access, "skip %d byte [0]%c [0] %d
> %s", size, buf[0], buf[0], buf);*/ + total += size;
> + }while( size > 0 );
Usage of net_ReadNonBlock looks wrong here.
> @@ -127,11 +147,19 @@ 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, "read data exceed the buffer size , simple
> skip some datas!"); + strncpy( (char *)p_buffer, psz +
> strlen(psz) - i_buffer + 10, i_buffer - 1 ); + }
> + else
> + strncpy( (char *)p_buffer, psz, i_buffer - 1 );
> + }
> else *p_buffer = 0;
>
> + p_buffer[ i_buffer -1 ] = '\0';
Not sure if i_buffer can be zero here.
> @@ -209,7 +238,8 @@ static int Open( vlc_object_t *p_this )
> psz_server = strdup("unknown");
> }
>
> - if( strstr( psz_server, "Real" ) || strstr( psz_server, "Helix" ) )
> + /* vatata is another rtsp/p2p streaming server which support real/rmvb
> streaming */ + if( strstr( psz_server, "Real" ) || strstr( psz_server,
> "Helix" )|| strstr( psz_server, "Vatata" ) ) {
> uint32_t bandwidth = 10485800;
> rmff_header_t *h;
This does not belong in a pause patch.
> + RtspReadAndSkip( p_access );
> + /* skip data which have sent to player, so next play will play the
> correct position */
Probably not the right way to resync.
> @@ -347,7 +423,9 @@ static int Control( access_t *p_access, int i_query,
> case ACCESS_SET_PAUSE_STATE:
> - /* Nothing to do */
> + pb_bool = (bool*)va_arg( args, bool* );
> + if ( ! pb_bool )
> + return Seek( p_access, p_access->info.i_pos );
> break;
ACCESS_SET_PAUSE_STATE takes a bool, not a bool*.
> @@ -337,7 +345,12 @@ int rtsp_request_describe( rtsp_client_t *rtsp, const
> char *what )
>
> int rtsp_request_setup( rtsp_client_t *rtsp, const char *what )
> {
> + if(! what )
> + {
> + return 500;
> + }
Can this actually happen? If not, better assert().
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list