]> git.sesse.net Git - vlc/blobdiff - modules/demux/live555.cpp
Disable timeout usage under WIN32 with live555.
[vlc] / modules / demux / live555.cpp
index d03b77618c7821adb3cd82ac97865ce651a73521..c3d33754a03ec3d985404fecef4e497542346d52 100644 (file)
@@ -42,7 +42,7 @@
 #include <vlc_plugin.h>
 #include <vlc_input.h>
 #include <vlc_demux.h>
-#include <vlc_interface.h>
+#include <vlc_dialog.h>
 #include <vlc_network.h>
 #include <vlc_url.h>
 
@@ -107,28 +107,28 @@ vlc_module_begin ()
         set_callbacks( Open, Close )
         add_bool( "rtsp-tcp", 0, NULL,
                   N_("Use RTP over RTSP (TCP)"),
-                  N_("Use RTP over RTSP (TCP)"), true );
+                  N_("Use RTP over RTSP (TCP)"), true )
         add_integer( "rtp-client-port", -1, NULL,
                   N_("Client port"),
-                  N_("Port to use for the RTP source of the session"), true );
+                  N_("Port to use for the RTP source of the session"), true )
         add_bool( "rtsp-mcast", false, NULL,
                   N_("Force multicast RTP via RTSP"),
-                  N_("Force multicast RTP via RTSP"), true );
+                  N_("Force multicast RTP via RTSP"), true )
         add_bool( "rtsp-http", 0, NULL,
                   N_("Tunnel RTSP and RTP over HTTP"),
-                  N_("Tunnel RTSP and RTP over HTTP"), true );
+                  N_("Tunnel RTSP and RTP over HTTP"), true )
         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 );
+                    CACHING_TEXT, CACHING_LONGTEXT, true )
         add_bool(   "rtsp-kasenna", false, NULL, KASENNA_TEXT,
-                    KASENNA_LONGTEXT, true );
+                    KASENNA_LONGTEXT, true )
         add_string( "rtsp-user", NULL, NULL, USER_TEXT,
-                    USER_LONGTEXT, true );
+                    USER_LONGTEXT, true )
         add_string( "rtsp-pwd", NULL, NULL, PASS_TEXT,
-                    PASS_LONGTEXT, true );
+                    PASS_LONGTEXT, true )
 vlc_module_end ()
 
 
@@ -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 )
     {
@@ -481,7 +479,6 @@ static int Connect( demux_t *p_demux )
     char *p_sdp       = NULL;
     int  i_http_port  = 0;
     int  i_ret        = VLC_SUCCESS;
-    int timeout;
 
     if( p_sys->url.i_port == 0 ) p_sys->url.i_port = 554;
     if( p_sys->url.psz_username || p_sys->url.psz_password )
@@ -544,30 +541,43 @@ describe:
     authenticator.setUsernameAndPassword( (const char*)psz_user,
                                           (const char*)psz_pwd );
 
-    timeout = var_CreateGetInteger(p_demux, "ipv4-timeout");
-    timeout /= 1000;
+#if defined(WIN32)
+#   warning "Disabled live555 timeout because of buggy library"
+    const int i_timeout = 0;
+#else
+    const int i_timeout = var_CreateGetInteger(p_demux, "ipv4-timeout") / 1000;
+#endif
 
 #if LIVEMEDIA_LIBRARY_VERSION_INT >= 1223337600
     psz_options = p_sys->rtsp->sendOptionsCmd( psz_url, psz_user, psz_pwd,
-                                               &authenticator, timeout );
+                                               &authenticator, i_timeout );
 #else
     psz_options = p_sys->rtsp->sendOptionsCmd( psz_url, psz_user, psz_pwd,
                                                &authenticator );
 #endif
-    if( psz_options )
+    if( psz_options == NULL && authenticator.realm() != NULL )
     {
-        p_sys->b_get_param = strstr( psz_options, "GET_PARAMETER" ) ? true : false ;
+        // try again, with the realm set this time
 #if LIVEMEDIA_LIBRARY_VERSION_INT >= 1223337600
-        p_sdp = p_sys->rtsp->describeWithPassword( psz_url, (const char*)psz_user, (const char*)psz_pwd,
-                                          var_GetBool( p_demux, "rtsp-kasenna" ), timeout );
+        psz_options = p_sys->rtsp->sendOptionsCmd( psz_url, psz_user, psz_pwd,
+                                               &authenticator, i_timeout );
 #else
-        p_sdp = p_sys->rtsp->describeWithPassword( psz_url, (const char*)psz_user, (const char*)psz_pwd,
-                                          var_GetBool( p_demux, "rtsp-kasenna" ) );
+        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 ;
     delete [] psz_options;
 
+#if LIVEMEDIA_LIBRARY_VERSION_INT >= 1223337600
+    p_sdp = p_sys->rtsp->describeWithPassword( psz_url, (const char*)psz_user, (const char*)psz_pwd,
+                                          var_GetBool( p_demux, "rtsp-kasenna" ), i_timeout );
+#else
+    p_sdp = p_sys->rtsp->describeWithPassword( psz_url, (const char*)psz_user, (const char*)psz_pwd,
+                                          var_GetBool( p_demux, "rtsp-kasenna" ) );
+#endif
+
     if( p_sdp == NULL )
     {
         /* failure occurred */
@@ -597,17 +607,14 @@ describe:
 
         if( i_code == 401 )
         {
-            int i_result;
             msg_Dbg( p_demux, "authentication failed" );
 
             free( psz_user );
             free( psz_pwd );
-            psz_user = psz_pwd = NULL;
-
-            i_result = intf_UserLoginPassword( p_demux, _("RTSP authentication"),
-                           _("Please enter a valid login name and a password."),
-                                                   &psz_user, &psz_pwd );
-            if( i_result == DIALOG_OK_YES )
+            dialog_Login( p_demux, &psz_user, &psz_pwd,
+                          _("RTSP authentication"),
+                        _("Please enter a valid login name and a password.") );
+            if( psz_user != NULL && psz_pwd != NULL )
             {
                 msg_Dbg( p_demux, "retrying with user=%s, pwd=%s",
                          psz_user, psz_pwd );
@@ -783,6 +790,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;
             }
@@ -1023,7 +1031,13 @@ static int SessionsSetup( demux_t *p_demux )
     /* Retrieve the duration if possible */
     p_sys->i_npt_length = p_sys->ms->playEndTime();
 
+    /* */
     msg_Dbg( p_demux, "setup start: %f stop:%f", p_sys->i_npt_start, p_sys->i_npt_length );
+
+    /* */
+    p_sys->b_no_data = true;
+    p_sys->i_no_data_ti = 0;
+
     return i_return;
 }
 
@@ -1033,7 +1047,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 )
     {
@@ -1326,7 +1339,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         case DEMUX_SET_RATE:
         {
             double f_scale, f_old_scale;
-            int i;
 
             if( !p_sys->rtsp || (p_sys->i_npt_length <= 0) ||
                 var_GetBool( p_demux, "rtsp-kasenna" ) )
@@ -1371,8 +1383,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             p_sys->i_pcr = 0;
             p_sys->i_npt = 0.0;
 
-            es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
-
             *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;
@@ -1458,14 +1468,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 );
@@ -1475,6 +1485,8 @@ static int RollOverTcp( demux_t *p_demux )
     p_sys->rtsp = NULL;
     p_sys->track = NULL;
     p_sys->i_track = 0;
+    p_sys->b_no_data = true;
+    p_sys->i_no_data_ti = 0;
 
     /* Reopen rtsp client */
     if( ( i_return = Connect( p_demux ) ) != VLC_SUCCESS )