[vlc-commits] commit: stream_filter/httplive.c: use hls->url.psz_path in relative_URI() for segments. (Jean-Paul Saman )

git at videolan.org git at videolan.org
Wed Dec 29 16:51:16 CET 2010


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Wed Dec 29 14:49:55 2010 +0100| [60ab123e3ccf9b5432c7e46ef7cc52ce361e71fb] | committer: Jean-Paul Saman 

stream_filter/httplive.c: use hls->url.psz_path in relative_URI() for segments.

The function relative_URI() only took the base path from the meta index file into account.
This caused it to miss subdirectories mentioned in the .m3u8 files referenced from the
meta index file. Instead of looking at the base of the meta index file it now looks at
the base path (hls->url.psz_path) from the HLS stream itself for segments.

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

 modules/stream_filter/httplive.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 91070ee..95e7be2 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -339,7 +339,7 @@ static char *parse_Attributes(const char *line, const char *attr)
     return NULL;
 }
 
-static char *relative_URI(stream_t *s, const char *uri, char *psz_uri)
+static char *relative_URI(stream_t *s, const char *uri, const char *path)
 {
     stream_sys_t *p_sys = s->p_sys;
 
@@ -347,8 +347,9 @@ static char *relative_URI(stream_t *s, const char *uri, char *psz_uri)
     if (p != NULL)
         return NULL;
 
+    char *psz_uri = NULL;
     if (asprintf(&psz_uri, "%s://%s%s/%s", p_sys->m3u8.psz_protocol,
-                 p_sys->m3u8.psz_host, p_sys->m3u8.psz_path, uri) < 0)
+                 p_sys->m3u8.psz_host, path ? path : p_sys->m3u8.psz_path, uri) < 0)
         return NULL;
 
     return psz_uri;
@@ -369,8 +370,16 @@ static void parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_rea
         return;
     }
 
-    char *psz_uri = NULL;
-    psz_uri = relative_URI(s, uri, psz_uri);
+    char *psz_path = strdup(hls->url.psz_path);
+    if (psz_path == NULL)
+    {
+        p_sys->b_error = true;
+        return;
+    }
+    char *p = strrchr(psz_path, '/');
+    if (p) *p = '\0';
+    char *psz_uri = relative_URI(s, uri, psz_path);
+    free(psz_path);
 
     vlc_mutex_lock(&hls->lock);
     segment_t *segment = segment_New(hls, duration, psz_uri ? psz_uri : uri);
@@ -442,8 +451,7 @@ static void parse_StreamInformation(stream_t *s, vlc_array_t **hls_stream,
 
     msg_Info(s, "bandwidth adaption detected (program-id=%d, bandwidth=%"PRIu64").", id, bw);
 
-    char *psz_uri = NULL;
-    psz_uri = relative_URI(s, uri, psz_uri);
+    char *psz_uri = relative_URI(s, uri, NULL);
 
     hls_stream_t *hls = hls_New(*hls_stream, id, bw, psz_uri ? psz_uri : uri);
     if (hls == NULL)



More information about the vlc-commits mailing list