[vlc-commits] commit: rtsp: check Range validity before starting to process the request ( Pierre Ynard )

git at videolan.org git at videolan.org
Thu Dec 23 14:20:50 CET 2010


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Thu Dec 23 14:20:09 2010 +0100| [6ef65eaf97a49ad52ac55a6a4d120a5f9014cd64] | committer: Pierre Ynard 

rtsp: check Range validity before starting to process the request

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

 modules/stream_out/rtp.h  |    6 ++++--
 modules/stream_out/rtsp.c |   29 ++++++++++++++++++-----------
 modules/stream_out/vod.c  |   23 ++++++++++++++++-------
 3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/modules/stream_out/rtp.h b/modules/stream_out/rtp.h
index e09ab10..89a0120 100644
--- a/modules/stream_out/rtp.h
+++ b/modules/stream_out/rtp.h
@@ -92,8 +92,10 @@ int rtp_get_fmt( vlc_object_t *obj, es_format_t *p_fmt, const char *mux,
 int  OpenVoD ( vlc_object_t * );
 void CloseVoD( vlc_object_t * );
 
-int vod_play(vod_media_t *p_media, const char *psz_session,
-             int64_t start, int64_t end, bool running);
+int vod_check_range(vod_media_t *p_media, const char *psz_session,
+                    int64_t start, int64_t end);
+void vod_play(vod_media_t *p_media, const char *psz_session,
+              int64_t start, int64_t end, bool running);
 void vod_pause(vod_media_t *p_media, const char *psz_session);
 void vod_stop(vod_media_t *p_media, const char *psz_session);
 
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index aa2df0a..c216539 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -954,15 +954,24 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                     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;
-            }
 
+                if (vod)
+                {
+                    if (vod_check_range(rtsp->vod_media, psz_session,
+                                        start, end) != VLC_SUCCESS)
+                    {
+                        answer->i_status = 457;
+                        break;
+                    }
+                }
+                /* We accept start times of 0 even for broadcast streams
+                 * that already started */
+                else if (start > 0 || end >= 0)
+                {
+                    answer->i_status = 456;
+                    break;
+                }
+            }
             vlc_mutex_lock( &rtsp->lock );
             ses = RtspClientGet( rtsp, psz_session );
             if( ses != NULL )
@@ -1037,9 +1046,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                 if (vod)
                 {
                     bool running = (sout_id != NULL);
-                    if (vod_play(rtsp->vod_media, psz_session, start, end,
-                                 running) != VLC_SUCCESS)
-                        answer->i_status = 457;
+                    vod_play(rtsp->vod_media, psz_session, start, end, running);
                 }
             }
             vlc_mutex_unlock( &rtsp->lock );
diff --git a/modules/stream_out/vod.c b/modules/stream_out/vod.c
index be4f62a..d8fdd9b 100644
--- a/modules/stream_out/vod.c
+++ b/modules/stream_out/vod.c
@@ -541,16 +541,27 @@ char *SDPGenerateVoD( const vod_media_t *p_media, const char *rtsp_url )
     return psz_sdp;
 }
 
-/* TODO: add support in the VLM for queueing proper PLAY requests with
- * start and end times, fetch whether the input is seekable... and then
- * clean this up and remove the running argument */
-int vod_play(vod_media_t *p_media, const char *psz_session,
-             int64_t start, int64_t end, bool running)
+int vod_check_range(vod_media_t *p_media, const char *psz_session,
+                    int64_t start, int64_t end)
 {
+    (void) psz_session;
+
     if (p_media->i_length > 0 && (start > p_media->i_length
                                   || end > p_media->i_length))
         return VLC_EGENERIC;
 
+    return VLC_SUCCESS;
+}
+
+/* TODO: add support in the VLM for queueing proper PLAY requests with
+ * start and end times, fetch whether the input is seekable... and then
+ * clean this up and remove the running argument */
+void vod_play(vod_media_t *p_media, const char *psz_session,
+              int64_t start, int64_t end, bool running)
+{
+    if (vod_check_range(p_media, psz_session, start, end) != VLC_SUCCESS)
+        return;
+
     /* We want to seek before unpausing, but it won't
      * work if the instance is not running yet. */
 
@@ -565,8 +576,6 @@ int vod_play(vod_media_t *p_media, const char *psz_session,
         /* This is the thing to do to unpause... */
         CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media,
                     psz_session, 0, "vod");
-
-    return VLC_SUCCESS;
 }
 
 void vod_pause(vod_media_t *p_media, const char *psz_session)



More information about the vlc-commits mailing list