]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtsp.c
configure: Make sure 'compile' calls make with 'V=1'.
[vlc] / modules / stream_out / rtsp.c
index 8437c7379a04d4c7bcac8738c6ae4e413d643507..523a1d4afdb6700c9e1bf0741e66c6940ece43ce 100644 (file)
@@ -30,7 +30,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_sout.h>
 
 #include <vlc_httpd.h>
@@ -138,6 +138,8 @@ void RtspUnsetup( rtsp_stream_t *rtsp )
 
     free( rtsp->psz_path );
     vlc_mutex_destroy( &rtsp->lock );
+
+    free( rtsp );
 }
 
 
@@ -348,6 +350,9 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
     const char *psz_session = NULL, *psz;
     char control[sizeof("rtsp://[]:12345") + NI_MAXNUMERICHOST
                   + strlen( rtsp->psz_path )];
+    time_t now;
+
+    time (&now);
 
     if( answer == NULL || query == NULL || cl == NULL )
         return VLC_SUCCESS;
@@ -376,6 +381,22 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
     answer->i_body = 0;
     answer->p_body = NULL;
 
+    httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
+
+    /* Date: is always allowed, and sometimes mandatory with RTSP/2.0. */
+    struct tm ut;
+    if (gmtime_r (&now, &ut) != NULL)
+    {   /* RFC1123 format, GMT is mandatory */
+        static const char wdays[7][4] = {
+            "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+        static const char mons[12][4] = {
+            "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+        httpd_MsgAdd (answer, "Date", "%s, %02u %s %04u %02u:%02u:%02u GMT",
+                      wdays[ut.tm_wday], ut.tm_mday, mons[ut.tm_mon],
+                      1900 + ut.tm_year, ut.tm_hour, ut.tm_min, ut.tm_sec);
+    }
+
     if( query->i_proto != HTTPD_PROTO_RTSP )
     {
         answer->i_status = 505;
@@ -600,13 +621,21 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
             rtsp_session_t *ses;
             answer->i_status = 200;
 
+            psz_session = httpd_MsgGet( query, "Session" );
+            const char *range = httpd_MsgGet (query, "Range");
+            if (range && strncmp (range, "npt=", 4))
+            {
+                answer->i_status = 501;
+                break;
+            }
+
             vlc_mutex_lock( &rtsp->lock );
             ses = RtspClientGet( rtsp, psz_session );
             if( ses != NULL )
             {
                 /* FIXME: we really need to limit the number of tracks... */
                 char info[ses->trackc * ( strlen( control )
-                                  + sizeof("/trackID=123;seq=65535, ") ) + 1];
+                              + sizeof("url=/trackID=123;seq=65535, ") ) + 1];
                 size_t infolen = 0;
 
                 for( int i = 0; i < ses->trackc; i++ )
@@ -620,7 +649,8 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                             rtp_add_sink( tr->id, tr->fd, false );
                         }
                         infolen += sprintf( info + infolen,
-                                            "%s/trackID=%u;seq=%u, ", control,
+                                            "url=%s/trackID=%u;seq=%u, ",
+                                            control,
                                             rtp_get_num( tr->id ),
                                             rtp_get_seq( tr->id ) );
                     }
@@ -633,7 +663,6 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
             }
             vlc_mutex_unlock( &rtsp->lock );
 
-            httpd_MsgAdd( answer, "Range", "npt=now-" );
             if( httpd_MsgGet( query, "Scale" ) != NULL )
                 httpd_MsgAdd( answer, "Scale", "1." );
             break;
@@ -689,7 +718,6 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
             return VLC_EGENERIC;
     }
 
-    httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
     if( psz_session )
         httpd_MsgAdd( answer, "Session", "%s"/*;timeout=5*/, psz_session );