Commit e50f11bb authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: dash: fix byte range signedness and simplify

parent 608f6ca6
...@@ -32,7 +32,6 @@ using namespace dash::http; ...@@ -32,7 +32,6 @@ using namespace dash::http;
Chunk::Chunk () : Chunk::Chunk () :
startByte (0), startByte (0),
endByte (0), endByte (0),
hasByteRange (false),
port (0), port (0),
isHostname (false), isHostname (false),
length (0), length (0),
...@@ -41,11 +40,11 @@ Chunk::Chunk () : ...@@ -41,11 +40,11 @@ Chunk::Chunk () :
{ {
} }
int Chunk::getEndByte () const size_t Chunk::getEndByte () const
{ {
return endByte; return endByte;
} }
int Chunk::getStartByte () const size_t Chunk::getStartByte () const
{ {
return startByte; return startByte;
} }
...@@ -53,11 +52,11 @@ const std::string& Chunk::getUrl () const ...@@ -53,11 +52,11 @@ const std::string& Chunk::getUrl () const
{ {
return url; return url;
} }
void Chunk::setEndByte (int endByte) void Chunk::setEndByte (size_t endByte)
{ {
this->endByte = endByte; this->endByte = endByte;
} }
void Chunk::setStartByte (int startByte) void Chunk::setStartByte (size_t startByte)
{ {
this->startByte = startByte; this->startByte = startByte;
} }
...@@ -85,14 +84,11 @@ void Chunk::addOptionalUrl (const std::string& url) ...@@ -85,14 +84,11 @@ void Chunk::addOptionalUrl (const std::string& url)
{ {
this->optionalUrls.push_back(url); this->optionalUrls.push_back(url);
} }
bool Chunk::useByteRange () bool Chunk::usesByteRange () const
{ {
return this->hasByteRange; return (startByte != endByte);
}
void Chunk::setUseByteRange (bool value)
{
this->hasByteRange = value;
} }
void Chunk::setBitrate (uint64_t bitrate) void Chunk::setBitrate (uint64_t bitrate)
{ {
this->bitrate = bitrate; this->bitrate = bitrate;
......
...@@ -47,8 +47,8 @@ namespace dash ...@@ -47,8 +47,8 @@ namespace dash
public: public:
Chunk (); Chunk ();
int getEndByte () const; size_t getEndByte () const;
int getStartByte () const; size_t getStartByte () const;
const std::string& getUrl () const; const std::string& getUrl () const;
bool hasHostname () const; bool hasHostname () const;
const std::string& getHostname () const; const std::string& getHostname () const;
...@@ -63,12 +63,11 @@ namespace dash ...@@ -63,12 +63,11 @@ namespace dash
void setConnection (IHTTPConnection *connection); void setConnection (IHTTPConnection *connection);
void setBytesRead (uint64_t bytes); void setBytesRead (uint64_t bytes);
void setLength (uint64_t length); void setLength (uint64_t length);
void setEndByte (int endByte); void setEndByte (size_t endByte);
void setStartByte (int startByte); void setStartByte (size_t startByte);
void setUrl (const std::string& url); void setUrl (const std::string& url);
void addOptionalUrl (const std::string& url); void addOptionalUrl (const std::string& url);
bool useByteRange (); bool usesByteRange () const;
void setUseByteRange (bool value);
void setBitrate (uint64_t bitrate); void setBitrate (uint64_t bitrate);
int getBitrate (); int getBitrate ();
...@@ -77,9 +76,8 @@ namespace dash ...@@ -77,9 +76,8 @@ namespace dash
std::string path; std::string path;
std::string hostname; std::string hostname;
std::vector<std::string> optionalUrls; std::vector<std::string> optionalUrls;
int startByte; size_t startByte;
int endByte; size_t endByte;
bool hasByteRange;
int bitrate; int bitrate;
int port; int port;
bool isHostname; bool isHostname;
......
...@@ -76,7 +76,7 @@ std::string HTTPConnection::prepareRequest (Chunk *chunk) ...@@ -76,7 +76,7 @@ std::string HTTPConnection::prepareRequest (Chunk *chunk)
{ {
std::string request; std::string request;
if(!chunk->useByteRange()) if(!chunk->usesByteRange())
{ {
request = "GET " + chunk->getPath() + " HTTP/1.1" + "\r\n" + request = "GET " + chunk->getPath() + " HTTP/1.1" + "\r\n" +
"Host: " + chunk->getHostname() + "\r\n" + "Host: " + chunk->getHostname() + "\r\n" +
......
...@@ -88,7 +88,7 @@ int PersistentConnection::read (void *p_buffer, siz ...@@ -88,7 +88,7 @@ int PersistentConnection::read (void *p_buffer, siz
std::string PersistentConnection::prepareRequest (Chunk *chunk) std::string PersistentConnection::prepareRequest (Chunk *chunk)
{ {
std::string request; std::string request;
if(!chunk->useByteRange()) if(!chunk->usesByteRange())
{ {
request = "GET " + chunk->getPath() + " HTTP/1.1" + "\r\n" + request = "GET " + chunk->getPath() + " HTTP/1.1" + "\r\n" +
"Host: " + chunk->getHostname() + "\r\n\r\n"; "Host: " + chunk->getHostname() + "\r\n\r\n";
......
...@@ -35,8 +35,8 @@ using namespace dash::http; ...@@ -35,8 +35,8 @@ using namespace dash::http;
Segment::Segment(const Representation *parent, bool isinit) : Segment::Segment(const Representation *parent, bool isinit) :
ICanonicalUrl( parent ), ICanonicalUrl( parent ),
startByte (-1), startByte (0),
endByte (-1), endByte (0),
parentRepresentation( parent ), parentRepresentation( parent ),
init( isinit ) init( isinit )
{ {
...@@ -71,11 +71,10 @@ dash::http::Chunk* Segment::toChunk () ...@@ -71,11 +71,10 @@ dash::http::Chunk* Segment::toChunk ()
{ {
Chunk *chunk = new Chunk(); Chunk *chunk = new Chunk();
if(this->startByte != -1 && this->endByte != -1) if(startByte != endByte)
{ {
chunk->setUseByteRange(true); chunk->setStartByte(startByte);
chunk->setStartByte(this->startByte); chunk->setEndByte(endByte);
chunk->setEndByte(this->endByte);
} }
chunk->setUrl( getUrlSegment() ); chunk->setUrl( getUrlSegment() );
......
...@@ -58,8 +58,8 @@ namespace dash ...@@ -58,8 +58,8 @@ namespace dash
protected: protected:
std::string sourceUrl; std::string sourceUrl;
int startByte; size_t startByte;
int endByte; size_t endByte;
const Representation* parentRepresentation; const Representation* parentRepresentation;
int size; int size;
bool init; bool init;
......
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