]> git.sesse.net Git - vlc/blobdiff - modules/demux/live555.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / demux / live555.cpp
index a57b1e28a26e8b789682f2eff99162414102c68a..a603f12b96441dd413b5fea67d429346ef67af62 100644 (file)
@@ -28,8 +28,6 @@
  *****************************************************************************/
 
 #include <vlc/vlc.h>
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
 
 #include <vlc_demux.h>
 #include <vlc_interface.h>
@@ -222,11 +220,11 @@ static int  Open ( vlc_object_t *p_this )
     {
         /* See if it looks like a SDP
            v, o, s fields are mandatory and in this order */
-        uint8_t *p_peek;
+        const uint8_t *p_peek;
         if( stream_Peek( p_demux->s, &p_peek, 7 ) < 7 ) return VLC_EGENERIC;
 
-        if( memcmp( (char*)p_peek, "v=0\r\n", 5 ) &&
-            memcmp( (char*)p_peek, "v=0\n", 4 ) &&
+        if( memcmp( p_peek, "v=0\r\n", 5 ) &&
+            memcmp( p_peek, "v=0\n", 4 ) &&
             ( p_peek[0] < 'a' || p_peek[0] > 'z' || p_peek[1] != '=' ) )
         {
             return VLC_EGENERIC;
@@ -370,7 +368,7 @@ error:
     if( p_sys->env ) p_sys->env->reclaim();
     if( p_sys->p_timeout )
     {
-        p_sys->p_timeout->b_die = VLC_TRUE;
+        vlc_object_kill( p_sys->p_timeout );
         vlc_thread_join( p_sys->p_timeout );
         vlc_object_detach( p_sys->p_timeout );
         vlc_object_destroy( p_sys->p_timeout );
@@ -409,7 +407,7 @@ static void Close( vlc_object_t *p_this )
     if( p_sys->env ) p_sys->env->reclaim();
     if( p_sys->p_timeout )
     {
-        p_sys->p_timeout->b_die = VLC_TRUE;
+        vlc_object_kill( p_sys->p_timeout );
         vlc_thread_join( p_sys->p_timeout );
         vlc_object_detach( p_sys->p_timeout );
         vlc_object_destroy( p_sys->p_timeout );
@@ -441,7 +439,8 @@ createnew:
     if( var_CreateGetBool( p_demux, "rtsp-http" ) )
         i_http_port = var_CreateGetInteger( p_demux, "rtsp-http-port" );
 
-    if( ( p_sys->rtsp = RTSPClient::createNew(*p_sys->env, 1 /*verbose*/,
+    if( ( p_sys->rtsp = RTSPClient::createNew(*p_sys->env,
+          p_demux->p_libvlc->i_verbose > 1,
           "VLC media player", i_http_port ) ) == NULL )
     {
         msg_Err( p_demux, "RTSPClient::createNew failed (%s)",
@@ -602,9 +601,15 @@ static int SessionsSetup( demux_t *p_demux )
                 if( !( p_sys->rtsp->setupMediaSubsession( *sub, False,
                                                    b_rtsp_tcp ? True : False ) ) )
                 {
-                    msg_Err( p_demux, "SETUP of'%s/%s' failed %s", sub->mediumName(),
-                             sub->codecName(), p_sys->env->getResultMsg() );
-                    continue;
+                    /* if we get an unsupported transport error, toggle TCP use and try again */
+                    if( !strstr(p_sys->env->getResultMsg(), "461 Unsupported Transport")
+                     || !( p_sys->rtsp->setupMediaSubsession( *sub, False,
+                                                   b_rtsp_tcp ? False : True ) ) )
+                    {
+                        msg_Err( p_demux, "SETUP of'%s/%s' failed %s", sub->mediumName(),
+                                 sub->codecName(), p_sys->env->getResultMsg() );
+                        continue;
+                    }
                 }
             }
 
@@ -669,7 +674,7 @@ static int SessionsSetup( demux_t *p_demux )
                 }
                 else if( !strncmp( sub->codecName(), "G726", 4 ) )
                 {
-                    tk->fmt.i_codec = VLC_FOURCC( 'g', '7', '2', '6' ); 
+                    tk->fmt.i_codec = VLC_FOURCC( 'g', '7', '2', '6' );
                     tk->fmt.audio.i_rate = 8000;
                     tk->fmt.audio.i_channels = 1;
                     if( !strcmp( sub->codecName()+5, "40" ) )
@@ -736,6 +741,10 @@ static int SessionsSetup( demux_t *p_demux )
                 {
                     tk->b_quicktime = VLC_TRUE;
                 }
+                else if( !strcmp( sub->codecName(), "SPEEX" ) )
+                {
+                    tk->fmt.i_codec = VLC_FOURCC( 's', 'p', 'x', ' ' );
+                }
             }
             else if( !strcmp( sub->mediumName(), "video" ) )
             {
@@ -848,16 +857,16 @@ static int SessionsSetup( demux_t *p_demux )
     delete iter;
     if( p_sys->i_track <= 0 ) i_return = VLC_EGENERIC;
 
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
     /* Retrieve the starttime if possible */
     p_sys->i_npt_start = (int64_t)( p_sys->ms->playStartTime() * (double)1000000.0 );
 #else
-    p_sys->i_npt_start = (int64_t) -1;
+    p_sys->i_npt_start = (int64_t) -1;
 #endif
     if( p_sys->i_npt_start < 0 )
         p_sys->i_npt_start = -1;
 
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
     /* Retrieve the duration if possible */
     p_sys->i_npt_length = (int64_t)( p_sys->ms->playEndTime() * (double)1000000.0 );
 #else
@@ -889,7 +898,9 @@ static int Play( demux_t *p_demux )
 
         /* Retrieve the timeout value and set up a timeout prevention thread */
         p_sys->i_timeout = p_sys->rtsp->sessionTimeoutParameter();
-        if( p_sys->i_timeout > 0 && !p_sys->p_timeout )
+        if( p_sys->i_timeout <= 0 )
+            p_sys->i_timeout = 60; /* default value from RFC2326 */
+        if( !p_sys->p_timeout )
         {
             msg_Dbg( p_demux, "We have a timeout of %d seconds",  p_sys->i_timeout );
             p_sys->p_timeout = (timeout_thread_t *)vlc_object_create( p_demux, sizeof(timeout_thread_t) );
@@ -916,11 +927,11 @@ static int Play( demux_t *p_demux )
     }
 #endif
 
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
     /* Retrieve the starttime if possible */
     p_sys->i_npt_start = (int64_t)( p_sys->ms->playStartTime() * (double)1000000.0 );
 #else
-    p_sys->i_npt_start = (int64_t) -1;
+    p_sys->i_npt_start = -1;
 #endif
     if( p_sys->i_npt_start < 0 )
     {
@@ -930,7 +941,7 @@ static int Play( demux_t *p_demux )
     else
         p_sys->i_npt = p_sys->i_npt_start;
 
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
     /* Retrieve the duration if possible */
     p_sys->i_npt_length = (int64_t)( p_sys->ms->playEndTime() * (double)1000000.0 );
 #else
@@ -1131,11 +1142,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                     msg_Dbg( p_demux, "set pos startseq: %u", p_sys->track[i]->i_start_seq );
                 }
 #endif
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
                 /* Retrieve the starttime if possible */
                 p_sys->i_npt_start = (int64_t)( p_sys->ms->playStartTime() * (double)1000000.0 );
 #else
-                p_sys->i_npt_start = (int64_t) -1;
+                p_sys->i_npt_start = -1;
 #endif
                 if( p_sys->i_npt_start < 0 )
                 {
@@ -1145,11 +1156,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 else
                     p_sys->i_npt = p_sys->i_npt_start;
 
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
                 /* Retrieve the duration if possible */
                 p_sys->i_npt_length = (int64_t)( p_sys->ms->playEndTime() * (double)1000000.0 );
 #else
-                p_sys->i_npt_length = (int64_t) -1;
+                p_sys->i_npt_length = -1;
 #endif
                 if( p_sys->i_npt_length < 0 )
                     p_sys->i_npt_length = -1;
@@ -1207,11 +1218,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 msg_Dbg( p_demux, "set pause startseq: %u", p_sys->track[i]->i_start_seq );
             }
 #endif
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
             /* Retrieve the starttime if possible */
             p_sys->i_npt_start = (int64_t)( p_sys->ms->playStartTime() * (double)1000000.0 );
 #else
-            p_sys->i_npt_start = (int64_t) -1;
+            p_sys->i_npt_start = -1;
 #endif
             if( p_sys->i_npt_start < 0 )
             {
@@ -1221,11 +1232,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             else
                 p_sys->i_npt = p_sys->i_npt_start;
 
-#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 1171929600)
+#if (LIVEMEDIA_LIBRARY_VERSION_INT >= 9999999999)
             /* Retrieve the duration if possible */
             p_sys->i_npt_length = (int64_t)( p_sys->ms->playEndTime() * (double)1000000.0 );
 #else
-            p_sys->i_npt_length = (int64_t) -1;
+            p_sys->i_npt_length = -1;
 #endif
             if( p_sys->i_npt_length < 0 )
                 p_sys->i_npt_length = -1;
@@ -1322,7 +1333,7 @@ static void StreamRead( void *p_private, unsigned int i_size,
     demux_sys_t    *p_sys = p_demux->p_sys;
     block_t        *p_block;
 
-    msg_Dbg( p_demux, "pts: %d", pts.tv_sec );
+    //msg_Dbg( p_demux, "pts: %d", pts.tv_sec );
 
     int64_t i_pts = (uint64_t)pts.tv_sec * UI64C(1000000) +
         (uint64_t)pts.tv_usec;
@@ -1476,13 +1487,13 @@ static void StreamRead( void *p_private, unsigned int i_size,
     {
         p_sys->i_npt += __MAX( 0, i_pts - p_sys->i_pcr );
         p_sys->i_pcr = i_pts;
-        msg_Dbg( p_demux, "npt update" );
+        //msg_Dbg( p_demux, "npt update" );
     }
-    else if( (tk->fmt.i_cat == VIDEO_ES) && (p_sys->i_pcr < i_pts) )
+    else if( /*tk->fmt.i_cat == VIDEO_ES &&*/ p_sys->i_pcr < i_pts )
     {
         p_sys->i_pcr = i_pts;
     }
-    msg_Dbg( p_demux, "npt %lld", p_sys->i_npt );
+    //msg_Dbg( p_demux, "npt %lld", p_sys->i_npt );
 
     if( (i_pts != tk->i_pts) && (!tk->b_muxed) )
     {
@@ -1547,7 +1558,7 @@ static void TaskInterrupt( void *p_private )
 }
 
 /*****************************************************************************
- *  
+ *
  *****************************************************************************/
 static void TimeoutPrevention( timeout_thread_t *p_timeout )
 {