[vlc-commits] commit: rtsp: pass proper PLAY requests to VoD (Pierre Ynard )

git at videolan.org git at videolan.org
Fri Dec 17 12:56:01 CET 2010


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Fri Dec 17 12:54:43 2010 +0100| [66c6214f24d3f0391e38c837bfa7ad9f73392464] | committer: Pierre Ynard 

rtsp: pass proper PLAY requests to VoD

Half of it is still unimplemented, so it's just sweeping under the
VLM rug

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

 modules/stream_out/rtp.h  |    4 ++--
 modules/stream_out/rtsp.c |   19 ++++++++-----------
 modules/stream_out/vod.c  |   35 +++++++++++++++++++++++++----------
 src/network/httpd.c       |    4 ++--
 4 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/modules/stream_out/rtp.h b/modules/stream_out/rtp.h
index f901249..e09ab10 100644
--- a/modules/stream_out/rtp.h
+++ b/modules/stream_out/rtp.h
@@ -92,10 +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 * );
 
-void vod_start(vod_media_t *p_media, const char *psz_session);
+int 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);
-void vod_seek(vod_media_t *p_media, const char *psz_session, int64_t time);
 
 const char *vod_get_mux(const vod_media_t *p_media);
 int vod_init_id(vod_media_t *p_media, const char *psz_session, int es_id,
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index ae8d3f2..8402b7d 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -1014,23 +1014,20 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                 }
                 if (vod)
                 {
-                    /* TODO: fix that crap, this is barely RTSP */
-
-                    /* We want to seek before unpausing, but it won't
-                     * work if the instance is not running yet. */
                     bool running = (sout_id != NULL);
-                    if (!running)
-                        vod_start(rtsp->vod_media, psz_session);
+                    int64_t start = -1, end = -1;
 
                     if (range != NULL)
                     {
-                        int64_t time = ParseNPT (range + 4);
-                        vod_seek(rtsp->vod_media, psz_session, time);
+                        start = ParseNPT (range + 4);
+                        range = strchr(range, '-');
+                        if (range != NULL && *(range + 1))
+                            end = ParseNPT (range + 1);
                     }
 
-                    /* This is the thing to do to unpause... */
-                    if (running)
-                        vod_start(rtsp->vod_media, psz_session);
+                    if (vod_play(rtsp->vod_media, psz_session, start, end,
+                                 running) != VLC_SUCCESS)
+                        answer->i_status = 457;
                 }
             }
             vlc_mutex_unlock( &rtsp->lock );
diff --git a/modules/stream_out/vod.c b/modules/stream_out/vod.c
index 1773477..be4f62a 100644
--- a/modules/stream_out/vod.c
+++ b/modules/stream_out/vod.c
@@ -541,11 +541,32 @@ char *SDPGenerateVoD( const vod_media_t *p_media, const char *rtsp_url )
     return psz_sdp;
 }
 
-void vod_start(vod_media_t *p_media, const char *psz_session)
+/* 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)
 {
-    /* We're passing the #vod{} sout chain here */
-    CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media,
-                psz_session, 0, "vod");
+    if (p_media->i_length > 0 && (start > p_media->i_length
+                                  || end > p_media->i_length))
+        return VLC_EGENERIC;
+
+    /* We want to seek before unpausing, but it won't
+     * work if the instance is not running yet. */
+
+    if (!running)
+        /* We're passing the #vod{} sout chain here */
+        CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media,
+                    psz_session, 0, "vod");
+    if (start >= 0)
+        CommandPush(p_media->p_vod, RTSP_CMD_TYPE_SEEK, p_media,
+                    psz_session, start, NULL);
+    if (running)
+        /* 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)
@@ -560,12 +581,6 @@ void vod_stop(vod_media_t *p_media, const char *psz_session)
                 psz_session, 0, NULL);
 }
 
-void vod_seek(vod_media_t *p_media, const char *psz_session, int64_t time)
-{
-    CommandPush(p_media->p_vod, RTSP_CMD_TYPE_SEEK, p_media,
-                psz_session, time, NULL);
-}
-
 
 const char *vod_get_mux(const vod_media_t *p_media)
 {
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 48f1692..9ec1e6e 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -310,8 +310,8 @@ static const http_status_info http_reason[] =
     { 454, "Session not found" },
     { 455, "Method not valid in this State" },
     { 456, "Header field not valid for resource" },
-  /*{ 457, "Invalid range" },
-    { 458, "Read-only parameter" },*/
+    { 457, "Invalid range" },
+  /*{ 458, "Read-only parameter" },*/
     { 459, "Aggregate operation not allowed" },
     { 460, "Non-aggregate operation not allowed" },
     { 461, "Unsupported transport" },



More information about the vlc-commits mailing list