[vlc-devel] [PATCH 1/9] dash: added url parsing to chunk
Hugo Beauzée-Luyssen
beauze.h at gmail.com
Mon Mar 12 10:47:33 CET 2012
Hello,
On Fri, Mar 9, 2012 at 7:05 PM, <Christopher at mailsrv.uni-klu.ac.at> wrote:
> From: Christopher Mueller <christopher.mueller at itec.aau.at>
>
> ---
> modules/stream_filter/dash/http/Chunk.cpp | 34 ++++++++++++++++++++++++++++-
> modules/stream_filter/dash/http/Chunk.h | 16 ++++++++++++-
> 2 files changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/modules/stream_filter/dash/http/Chunk.cpp b/modules/stream_filter/dash/http/Chunk.cpp
> index 430e855..a3ecf7e 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,20 @@ 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);
You must clean the url using vlc_UrlClean.
Also, what if the url isn't absolute? (If this is in another patch, my
apologies, will read it in a few minutes)
> +
> + 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;
> }
> void Chunk::addOptionalUrl (const std::string& url)
> {
> @@ -80,3 +96,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..a4b41f1 100644
> --- a/modules/stream_filter/dash/http/Chunk.h
> +++ b/modules/stream_filter/dash/http/Chunk.h
> @@ -25,6 +25,12 @@
> #ifndef CHUNK_H_
> #define CHUNK_H_
>
> +#include <vlc_common.h>
> +#include <vlc_plugin.h>
> +#include <vlc_stream.h>
> +#include <vlc_network.h>
> +#include <vlc_url.h>
> +
> #include <vector>
> #include <string>
> #include <stdint.h>
> @@ -41,6 +47,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 +63,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;
> };
> }
> }
> --
> 1.7.0.4
>
Regards,
--
Hugo Beauzée-Luyssen
More information about the vlc-devel
mailing list