[vlc-commits] demux: adaptative: don't set playlist url as baseurl

Francois Cartegnie git at videolan.org
Tue Sep 22 00:38:49 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep 11 11:18:08 2015 +0200| [f8e451e3be9bea68cd80713b1cc6edf4edef5a81] | committer: Francois Cartegnie

demux: adaptative: don't set playlist url as baseurl

We need playlist url as another extra level as some playlists have
the good idea to set baseurl to relative path :/

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

 .../demux/adaptative/playlist/AbstractPlaylist.cpp |   21 +++++++++++++-------
 .../demux/adaptative/playlist/AbstractPlaylist.hpp |    2 ++
 modules/demux/dash/mpd/IsoffMainParser.cpp         |    3 +--
 modules/demux/hls/playlist/Parser.cpp              |    6 +-----
 4 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/modules/demux/adaptative/playlist/AbstractPlaylist.cpp b/modules/demux/adaptative/playlist/AbstractPlaylist.cpp
index 254c9b2..422ff08 100644
--- a/modules/demux/adaptative/playlist/AbstractPlaylist.cpp
+++ b/modules/demux/adaptative/playlist/AbstractPlaylist.cpp
@@ -60,6 +60,12 @@ void AbstractPlaylist::addBaseUrl(const std::string &url)
 {
     baseUrls.push_back(url);
 }
+
+void AbstractPlaylist::setPlaylistUrl(const std::string &url)
+{
+    playlistUrl = url;
+}
+
 void AbstractPlaylist::addPeriod(BasePeriod *period)
 {
     periods.push_back(period);
@@ -72,14 +78,15 @@ void AbstractPlaylist::setType(const std::string &type_)
 
 Url AbstractPlaylist::getUrlSegment() const
 {
+    Url ret;
+
     if (!baseUrls.empty())
-        return Url(baseUrls.front());
-    else
-    {
-        std::stringstream ss;
-        ss << Helper::getDirectoryPath(stream->psz_url) << "/";
-        return Url(ss.str());
-    }
+        ret = Url(baseUrls.front());
+
+    if( !ret.hasScheme() && !playlistUrl.empty() )
+        ret.prepend( Url(playlistUrl) );
+
+    return ret;
 }
 
 vlc_object_t * AbstractPlaylist::getVLCObject() const
diff --git a/modules/demux/adaptative/playlist/AbstractPlaylist.hpp b/modules/demux/adaptative/playlist/AbstractPlaylist.hpp
index bb67591..7d932dd 100644
--- a/modules/demux/adaptative/playlist/AbstractPlaylist.hpp
+++ b/modules/demux/adaptative/playlist/AbstractPlaylist.hpp
@@ -45,6 +45,7 @@ namespace adaptative
 
                 void    addPeriod               (BasePeriod *period);
                 void    addBaseUrl              (const std::string &);
+                void    setPlaylistUrl          (const std::string &);
 
                 virtual Url         getUrlSegment() const; /* impl */
                 vlc_object_t *      getVLCObject()  const;
@@ -70,6 +71,7 @@ namespace adaptative
                 stream_t                           *stream;
                 std::vector<BasePeriod *>           periods;
                 std::vector<std::string>            baseUrls;
+                std::string                         playlistUrl;
                 std::string                         type;
         };
     }
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index 5fd77b0..d39a82d 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -67,8 +67,7 @@ void IsoffMainParser::setMPDBaseUrl(Node *root)
     for(size_t i = 0; i < baseUrls.size(); i++)
         mpd->addBaseUrl(baseUrls.at(i)->getText());
 
-    if(baseUrls.empty())
-        mpd->addBaseUrl(Helper::getDirectoryPath(playlisturl).append("/"));
+    mpd->setPlaylistUrl( Helper::getDirectoryPath(playlisturl).append("/") );
 }
 
 MPD* IsoffMainParser::getMPD()
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 5822dfd..e9802ff 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -319,11 +319,7 @@ M3U8 * Parser::parse(const std::string &playlisturl)
         return NULL;
 
     if(!playlisturl.empty())
-    {
-        size_t pos = playlisturl.find_last_of('/');
-        if(pos != std::string::npos)
-            playlist->addBaseUrl(playlisturl.substr(0, pos + 1));
-    }
+        playlist->setPlaylistUrl( Helper::getDirectoryPath(playlisturl).append("/") );
 
     BasePeriod *period = new (std::nothrow) BasePeriod( playlist );
     if(!period)



More information about the vlc-commits mailing list