[vlc-commits] dash: added url parsing to chunk

Christopher Mueller git at videolan.org
Tue Mar 20 15:14:35 CET 2012


vlc | branch: master | Christopher Mueller <christopher.mueller at itec.aau.at> | Fri Mar  9 15:56:38 2012 +0100| [1cad10dc04100d7d7eba52238b926e130863ff75] | committer: Hugo Beauzée-Luyssen

dash: added url parsing to chunk

Signed-off-by: Hugo Beauzée-Luyssen <beauze.h at gmail.com>

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

 modules/stream_filter/dash/http/Chunk.cpp |   36 ++++++++++++++++++++++++++++-
 modules/stream_filter/dash/http/Chunk.h   |   13 +++++++++-
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/modules/stream_filter/dash/http/Chunk.cpp b/modules/stream_filter/dash/http/Chunk.cpp
index 430e855..250f04d 100644
--- a/modules/stream_filter/dash/http/Chunk.cpp
+++ b/modules/stream_filter/dash/http/Chunk.cpp
@@ -32,7 +32,9 @@ using namespace dash::http;
 Chunk::Chunk        () :
        startByte    (0),
        endByte      (0),
-       hasByteRange (false)
+       hasByteRange (false),
+       port         (0),
+       isHostname   (false)
 {
 }
 
@@ -59,6 +61,22 @@ void                Chunk::setStartByte     (int startByte)
 void                Chunk::setUrl           (const std::string& url )
 {
     this->url = url;
+
+    if(this->url.compare(0, 4, "http"))
+    {
+        this->isHostname = false;
+        return;
+    }
+
+    vlc_url_t url_components;
+    vlc_UrlParse(&url_components, url.c_str(), 0);
+
+    this->path          = url_components.psz_path;
+    this->port          = url_components.i_port ? url_components.i_port : 80;
+    this->hostname      = url_components.psz_host;
+    this->isHostname    = true;
+
+    vlc_UrlClean(&url_components);
 }
 void                Chunk::addOptionalUrl   (const std::string& url)
 {
@@ -80,3 +98,19 @@ int                 Chunk::getBitrate       ()
 {
     return this->bitrate;
 }
+bool                Chunk::hasHostname     () const
+{
+    return this->isHostname;
+}
+const std::string&  Chunk::getHostname     () const
+{
+    return this->hostname;
+}
+const std::string&  Chunk::getPath         () const
+{
+    return this->path;
+}
+int                 Chunk::getPort         () const
+{
+    return this->port;
+}
diff --git a/modules/stream_filter/dash/http/Chunk.h b/modules/stream_filter/dash/http/Chunk.h
index ce589d7..be6284f 100644
--- a/modules/stream_filter/dash/http/Chunk.h
+++ b/modules/stream_filter/dash/http/Chunk.h
@@ -25,6 +25,9 @@
 #ifndef CHUNK_H_
 #define CHUNK_H_
 
+#include <vlc_common.h>
+#include <vlc_url.h>
+
 #include <vector>
 #include <string>
 #include <stdint.h>
@@ -41,6 +44,11 @@ namespace dash
                 int                 getEndByte      () const;
                 int                 getStartByte    () const;
                 const std::string&  getUrl          () const;
+                bool                hasHostname     () const;
+                const std::string&  getHostname     () const;
+                const std::string&  getPath         () const;
+                int                 getPort         () const;
+
                 void                setEndByte      (int endByte);
                 void                setStartByte    (int startByte);
                 void                setUrl          (const std::string& url);
@@ -52,12 +60,15 @@ namespace dash
 
             private:
                 std::string                 url;
+                std::string                 path;
+                std::string                 hostname;
                 std::vector<std::string>    optionalUrls;
                 int                         startByte;
                 int                         endByte;
                 bool                        hasByteRange;
                 int                         bitrate;
-
+                int                         port;
+                bool                        isHostname;
         };
     }
 }



More information about the vlc-commits mailing list