X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Flive555.cpp;h=8af2a35a681f331662bc7123ba3335111bcaa380;hb=fa4bde0b26a6c7a2a617362ea0b17144686e39fe;hp=d09e3eb12235f7254ff52c5a08d5e944fdf76a65;hpb=c502ce6e81ae4fb29bb72d07bca717d54e7f7c10;p=vlc diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp index d09e3eb122..8af2a35a68 100644 --- a/modules/demux/live555.cpp +++ b/modules/demux/live555.cpp @@ -40,7 +40,7 @@ #include #include - +#include #include #include #include @@ -120,7 +120,7 @@ vlc_module_begin () add_integer( "rtsp-http-port", 80, NULL, N_("HTTP tunnel port"), N_("Port to use for tunneling the RTSP/RTP over HTTP."), - true ); + true ) add_integer("rtsp-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, true ); add_bool( "rtsp-kasenna", false, NULL, KASENNA_TEXT, @@ -235,8 +235,6 @@ static int Open ( vlc_object_t *p_this ) demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys = NULL; - MediaSubsessionIterator *iter = NULL; - MediaSubsession *sub = NULL; int i, i_return; int i_error = VLC_EGENERIC; @@ -398,14 +396,14 @@ error: { live_track_t *tk = p_sys->track[i]; - if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed ); + if( tk->b_muxed ) stream_Delete( tk->p_out_muxed ); es_format_Clean( &tk->fmt ); free( tk->p_buffer ); free( tk ); } if( p_sys->i_track ) free( p_sys->track ); - if( p_sys->p_out_asf ) stream_DemuxDelete( p_sys->p_out_asf ); + if( p_sys->p_out_asf ) stream_Delete( p_sys->p_out_asf ); if( p_sys->rtsp && p_sys->ms ) p_sys->rtsp->teardownMediaSession( *p_sys->ms ); if( p_sys->p_timeout ) { @@ -439,14 +437,14 @@ static void Close( vlc_object_t *p_this ) { live_track_t *tk = p_sys->track[i]; - if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed ); + if( tk->b_muxed ) stream_Delete( tk->p_out_muxed ); es_format_Clean( &tk->fmt ); free( tk->p_buffer ); free( tk ); } if( p_sys->i_track ) free( p_sys->track ); - if( p_sys->p_out_asf ) stream_DemuxDelete( p_sys->p_out_asf ); + if( p_sys->p_out_asf ) stream_Delete( p_sys->p_out_asf ); if( p_sys->rtsp && p_sys->ms ) p_sys->rtsp->teardownMediaSession( *p_sys->ms ); if( p_sys->p_timeout ) { @@ -554,6 +552,17 @@ describe: psz_options = p_sys->rtsp->sendOptionsCmd( psz_url, psz_user, psz_pwd, &authenticator ); #endif + if( psz_options == NULL && authenticator.realm() != NULL ) + { + // try again, with the realm set this time +#if LIVEMEDIA_LIBRARY_VERSION_INT >= 1223337600 + psz_options = p_sys->rtsp->sendOptionsCmd( psz_url, psz_user, psz_pwd, + &authenticator, timeout ); +#else + psz_options = p_sys->rtsp->sendOptionsCmd( psz_url, psz_user, psz_pwd, + &authenticator ); +#endif + } if( psz_options ) { p_sys->b_get_param = strstr( psz_options, "GET_PARAMETER" ) ? true : false ; @@ -627,7 +636,7 @@ describe: } else { - msg_Dbg( p_demux, "connection timeout, retrying" ); + msg_Dbg( p_demux, "connection timeout" ); if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp ); p_sys->rtsp = NULL; } @@ -783,6 +792,7 @@ static int SessionsSetup( demux_t *p_demux ) tk->p_buffer = (uint8_t *)malloc( 65536 ); if( !tk->p_buffer ) { + free( tk ); delete iter; return VLC_ENOMEM; } @@ -1033,7 +1043,6 @@ static int SessionsSetup( demux_t *p_demux ) static int Play( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; - int i; if( p_sys->rtsp ) { @@ -1231,14 +1240,14 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) pi64 = (int64_t*)va_arg( args, int64_t * ); if( p_sys->i_npt_length > 0 ) { - *pi64 = p_sys->i_npt_length * 1000000.0; + *pi64 = (int64_t)((double)p_sys->i_npt_length * 1000000.0); return VLC_SUCCESS; } return VLC_EGENERIC; case DEMUX_GET_POSITION: pf = (double*)va_arg( args, double* ); - if( p_sys->i_npt_length > 0 && p_sys->i_npt > 0) + if( (p_sys->i_npt_length > 0) && (p_sys->i_npt > 0) ) { *pf = ( (double)p_sys->i_npt / (double)p_sys->i_npt_length ); return VLC_SUCCESS; @@ -1247,12 +1256,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) case DEMUX_SET_POSITION: case DEMUX_SET_TIME: - if( p_sys->rtsp && p_sys->i_npt_length > 0 ) + if( p_sys->rtsp && (p_sys->i_npt_length > 0) ) { int i; float time; - if( i_query == DEMUX_SET_TIME && p_sys->i_npt > 0 ) + if( (i_query == DEMUX_SET_TIME) && (p_sys->i_npt > 0) ) { i64 = (int64_t)va_arg( args, int64_t ); time = (float)((double)i64 / (double)1000000.0); /* in second */ @@ -1313,54 +1322,67 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) #endif return VLC_SUCCESS; -#if 0 case DEMUX_CAN_CONTROL_RATE: pb = (bool*)va_arg( args, bool * ); pb2 = (bool*)va_arg( args, bool * ); - *pb = p_sys->rtsp != NULL && p_sys->i_npt_length > 0 && !var_GetBool( p_demux, "rtsp-kasenna" ); + *pb = (p_sys->rtsp != NULL) && + (p_sys->i_npt_length > 0) && + !var_GetBool( p_demux, "rtsp-kasenna" ); *pb2 = false; return VLC_SUCCESS; case DEMUX_SET_RATE: { - double f_scale; + double f_scale, f_old_scale; - if( !p_sys->rtsp || p_sys->i_npt_length <= 0 || var_GetBool( p_demux, "rtsp-kasenna" ) ) + if( !p_sys->rtsp || (p_sys->i_npt_length <= 0) || + var_GetBool( p_demux, "rtsp-kasenna" ) ) return VLC_EGENERIC; - /* TODO we might want to ensure that the new rate is different from - * old rate after playMediaSession... - * I have no idea how the server map the requested rate to the - * ones it supports. - * ex: - * current is x2 we request x1.5 if the server return x2 we will - * never succeed to return to x1. - * In this case we should retry with a lower rate until we have - * one (even x1). + /* According to RFC 2326 p56 chapter 12.35 a RTSP server that + * supports Scale should: + * + * "The server should try to approximate the viewing rate, but may + * restrict the range of scale values that it supports. The response + * MUST contain the actual scale value chosen by the server." + * + * Scale = 1 indicates normal play + * Scale > 1 indicates fast forward + * Scale < 1 && Scale > 0 indicates slow motion + * Scale < 0 value indicates rewind */ pi_int = (int*)va_arg( args, int * ); - f_scale = (double)INPUT_RATE_DEFAULT / (*p_int); + f_scale = (double)INPUT_RATE_DEFAULT / (*pi_int); + f_old_scale = p_sys->ms->scale(); /* Passing -1 for the start and end time will mean liveMedia won't - * create a Range: section for the RTSP message. The server should - * pick up from the current position */ + * create a Range: section for the RTSP message. The server should + * pick up from the current position */ if( !p_sys->rtsp->playMediaSession( *p_sys->ms, -1, -1, f_scale ) ) { msg_Err( p_demux, "PLAY with Scale %0.2f failed %s", f_scale, p_sys->env->getResultMsg() ); return VLC_EGENERIC; } + + if( p_sys->ms->scale() == f_old_scale ) + { + msg_Err( p_demux, "no scale change using old Scale %0.2f", + p_sys->ms->scale() ); + return VLC_EGENERIC; + } + /* ReSync the stream */ p_sys->i_npt_start = 0; p_sys->i_pcr = 0; - p_sys->i_npt = 0.; + p_sys->i_npt = 0.0; - *pi_int = (int)( INPUT_RATE_DEFAULT / p_sys->ms->scale() + 0.5 ); + *pi_int = (int)( INPUT_RATE_DEFAULT / p_sys->ms->scale() ); + msg_Dbg( p_demux, "PLAY with new Scale %0.2f (%d)", p_sys->ms->scale(), (*pi_int) ); return VLC_SUCCESS; } -#endif case DEMUX_SET_PAUSE_STATE: { @@ -1442,14 +1464,14 @@ static int RollOverTcp( demux_t *p_demux ) { live_track_t *tk = p_sys->track[i]; - if( tk->b_muxed ) stream_DemuxDelete( tk->p_out_muxed ); + if( tk->b_muxed ) stream_Delete( tk->p_out_muxed ); if( tk->p_es ) es_out_Del( p_demux->out, tk->p_es ); es_format_Clean( &tk->fmt ); free( tk->p_buffer ); free( tk ); } if( p_sys->i_track ) free( p_sys->track ); - if( p_sys->p_out_asf ) stream_DemuxDelete( p_sys->p_out_asf ); + if( p_sys->p_out_asf ) stream_Delete( p_sys->p_out_asf ); p_sys->rtsp->teardownMediaSession( *p_sys->ms ); Medium::close( p_sys->ms );