Commit 1cad10dc authored by Christopher Mueller's avatar Christopher Mueller Committed by Hugo Beauzée-Luyssen

dash: added url parsing to chunk

Signed-off-by: default avatarHugo Beauzée-Luyssen <beauze.h@gmail.com>
parent f7f78e8a
......@@ -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;
}
......@@ -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;
};
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment