]> git.sesse.net Git - vlc/blobdiff - modules/demux/live555.cpp
Remove UI64_C
[vlc] / modules / demux / live555.cpp
index 2f7667cf74b2313d3bcc9acbd084d45e75d6abd1..1968117073f624db7f5821ad5b3e38bb15f6a695 100644 (file)
@@ -31,6 +31,9 @@
 # include "config.h"
 #endif
 
+#define __STDC_CONSTANT_MACROS 1
+#include <inttypes.h>
+
 #include <vlc/vlc.h>
 
 #include <vlc_demux.h>
@@ -81,7 +84,7 @@ static void Close( vlc_object_t * );
 
 vlc_module_begin();
     set_description( _("RTP/RTSP/SDP demuxer (using Live555)" ) );
-    set_capability( "demux2", 50 );
+    set_capability( "demux", 50 );
     set_shortname( "RTP/RTSP");
     set_callbacks( Open, Close );
     add_shortcut( "live" );
@@ -457,8 +460,7 @@ static int Connect( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     Authenticator authenticator;
-    bool b_firstpass = true;
-
+    bool b_firstpass  = true;
     char *psz_user    = NULL;
     char *psz_pwd     = NULL;
     char *psz_url     = NULL;
@@ -466,27 +468,32 @@ static int Connect( demux_t *p_demux )
     char *p_sdp       = NULL;
     int  i_http_port  = 0;
     int  i_ret        = VLC_SUCCESS;
+    int i_lefttries;
 
-    psz_url = (char*)malloc( strlen( p_sys->psz_path ) + 8 );
-    if( !psz_url ) return VLC_ENOMEM;
-
+    if( p_sys->url.i_port == 0 ) p_sys->url.i_port = 554;
     if( p_sys->url.psz_username || p_sys->url.psz_password )
     {
-        sprintf( psz_url, "rtsp://%s%s", p_sys->url.psz_host,
-                 p_sys->url.psz_path );
+        int err;
+        err = asprintf( &psz_url, "rtsp://%s:%d%s", p_sys->url.psz_host,
+                        p_sys->url.i_port, p_sys->url.psz_path );
+        if( err == -1 ) return VLC_ENOMEM;
 
         psz_user = strdup( p_sys->url.psz_username );
         psz_pwd  = strdup( p_sys->url.psz_password );
     }
     else
     {
-        sprintf( psz_url, "rtsp://%s", p_sys->psz_path );
+        int err;
+        err = asprintf( &psz_url, "rtsp://%s", p_sys->psz_path );
+        if( err == -1 ) return VLC_ENOMEM;
 
         psz_user = var_CreateGetString( p_demux, "rtsp-user" );
         psz_pwd  = var_CreateGetString( p_demux, "rtsp-pwd" );
     }
 
+    i_lefttries = 3;
 createnew:
+    i_lefttries--;
     if( p_demux->b_die || p_demux->b_error )
     {
         free( psz_user );
@@ -546,7 +553,10 @@ describe:
         else
         {
             const char *psz_tmp = strstr( psz_error, "RTSP" );
-            sscanf( psz_tmp, "RTSP/%*s%3u", &i_code );
+            if( psz_tmp )
+                sscanf( psz_tmp, "RTSP/%*s%3u", &i_code );
+            else
+                i_code = 0;
         }
         msg_Dbg( p_demux, "DESCRIBE failed with %d: %s", i_code, psz_error );
 
@@ -593,7 +603,8 @@ describe:
             msg_Dbg( p_demux, "connection timeout, retrying" );
             if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp );
             p_sys->rtsp = NULL;
-            goto createnew;
+            if( i_lefttries > 0 )
+                goto createnew;
         }
         i_ret = VLC_EGENERIC;
     }
@@ -1530,11 +1541,11 @@ static void StreamRead( void *p_private, unsigned int i_size,
 
     //msg_Dbg( p_demux, "pts: %d", pts.tv_sec );
 
-    int64_t i_pts = (uint64_t)pts.tv_sec * UI64C(1000000) +
+    int64_t i_pts = (uint64_t)pts.tv_sec * UINT64_C(1000000) +
         (uint64_t)pts.tv_usec;
 
     /* XXX Beurk beurk beurk Avoid having negative value XXX */
-    i_pts &= UI64C(0x00ffffffffffffff);
+    i_pts &= UINT64_C(0x00ffffffffffffff);
 
     if( tk->b_quicktime && tk->p_es == NULL )
     {