[vlc-commits] commit: rtsp: return an error when the client tries to seek a broadcast stream ( Pierre Ynard )

git at videolan.org git at videolan.org
Fri Dec 17 13:58:46 CET 2010


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Fri Dec 17 13:57:48 2010 +0100| [eeddb68f4c7b3e60db74f78f0fa936d74adfe898] | committer: Pierre Ynard 

rtsp: return an error when the client tries to seek a broadcast stream

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eeddb68f4c7b3e60db74f78f0fa936d74adfe898
---

 modules/stream_out/rtsp.c |   40 ++++++++++++++++++++++++++--------------
 1 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index 8402b7d..aa2df0a 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -582,14 +582,14 @@ static int64_t ParseNPT (const char *str)
         sec += ((hour * 60) + min) * 60;
     else
     if (sscanf (str, "%f", &sec) != 1)
-        sec = 0.;
+        sec = -1;
 
     if (loc != (locale_t)0)
     {
         uselocale (oldloc);
         freelocale (loc);
     }
-    return sec * CLOCK_FREQ;
+    return sec < 0 ? -1 : sec * CLOCK_FREQ;
 }
 
 
@@ -934,10 +934,32 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
             answer->i_status = 200;
 
             psz_session = httpd_MsgGet( query, "Session" );
+            int64_t start = -1, end = -1;
             const char *range = httpd_MsgGet (query, "Range");
-            if (range != NULL && strncmp (range, "npt=", 4))
+            if (range != NULL)
             {
-                answer->i_status = 501;
+                if (strncmp (range, "npt=", 4))
+                {
+                    answer->i_status = 501;
+                    break;
+                }
+
+                start = ParseNPT (range + 4);
+                range = strchr(range, '-');
+                if (range != NULL && *(range + 1))
+                    end = ParseNPT (range + 1);
+
+                if (end >= 0 && end < start)
+                {
+                    answer->i_status = 457;
+                    break;
+                }
+            }
+            /* We accept start times of 0 even for broadcast streams
+             * that already started */
+            if (!vod && (start > 0 || end >= 0))
+            {
+                answer->i_status = 456;
                 break;
             }
 
@@ -1015,16 +1037,6 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                 if (vod)
                 {
                     bool running = (sout_id != NULL);
-                    int64_t start = -1, end = -1;
-
-                    if (range != NULL)
-                    {
-                        start = ParseNPT (range + 4);
-                        range = strchr(range, '-');
-                        if (range != NULL && *(range + 1))
-                            end = ParseNPT (range + 1);
-                    }
-
                     if (vod_play(rtsp->vod_media, psz_session, start, end,
                                  running) != VLC_SUCCESS)
                         answer->i_status = 457;



More information about the vlc-commits mailing list