[vlc-commits] dash: Handle relative URL

Hugo Beauzée-Luyssen git at videolan.org
Fri Jan 6 12:40:37 CET 2012


vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Jan  5 12:20:47 2012 +0100| [a90c1374304a712b6329015132d3ce3956a6ea1f] | committer: Jean-Baptiste Kempf

dash: Handle relative URL

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/stream_filter/dash/mpd/BasicCMParser.cpp |   19 ++++++++++++++++---
 modules/stream_filter/dash/mpd/BasicCMParser.h   |    1 +
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index 9b5f0f2..708b577 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -42,11 +42,19 @@ using namespace dash::xml;
 
 BasicCMParser::BasicCMParser( Node *root, stream_t *p_stream ) :
     root( root ),
-    mpd( NULL )
+    mpd( NULL ),
+    p_stream( p_stream )
 {
     this->url = p_stream->psz_access;
     this->url += "://";
-    this->url += p_stream->psz_path;
+    //Only append without the mpd file.
+    std::string path = p_stream->psz_path;
+    size_t      it = path.find_last_of( '/', path.length() - 1 );
+    if ( it != std::string::npos )
+        this->url.append( path, 0, it );
+    else
+        this->url += p_stream->psz_path;
+    this->url += '/';
 }
 
 BasicCMParser::~BasicCMParser   ()
@@ -374,7 +382,12 @@ bool BasicCMParser::parseSegment(Segment *seg, const std::map<std::string, std::
     //FIXME: When not present, the sourceUrl attribute should be computed
     //using BaseURL and the range attribute.
     if ( it != attr.end() )
-        seg->setSourceUrl( it->second );
+    {
+        std::string     url = it->second;
+        if ( url.find( this->p_stream->psz_access ) != 0 ) //Relative url
+            url = this->url + url;
+        seg->setSourceUrl( url );
+    }
     return true;
 }
 
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h
index e76f577..07de212 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.h
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.h
@@ -80,6 +80,7 @@ namespace dash
                 dash::xml::Node *root;
                 MPD             *mpd;
                 std::string     url;
+                stream_t        *p_stream;
         };
     }
 }



More information about the vlc-commits mailing list