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