diff options
author | Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr> | 2017-03-29 18:00:06 +0200 |
---|---|---|
committer | Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr> | 2017-03-30 18:58:33 +0200 |
commit | 3137acdd5a45285dab9903f9d41560c63eca8523 (patch) | |
tree | 38bd8525a9e214d848a73fc40e81ddb182cf91b6 /src/libdash/source/mpd/Segment.cpp | |
parent | 9b30fc10fb1cbebe651e5a107e8ca5b24de54675 (diff) |
first commit
Change-Id: I8412b8e7d966c2fbc508b537fd9a9bbcfc628ca8
Signed-off-by: Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr>
Diffstat (limited to 'src/libdash/source/mpd/Segment.cpp')
-rw-r--r-- | src/libdash/source/mpd/Segment.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/src/libdash/source/mpd/Segment.cpp b/src/libdash/source/mpd/Segment.cpp new file mode 100644 index 00000000..31200762 --- /dev/null +++ b/src/libdash/source/mpd/Segment.cpp @@ -0,0 +1,138 @@ +/* + * Segment.cpp + ***************************************************************************** + * Copyright (C) 2013, bitmovin Softwareentwicklung OG, All Rights Reserved + * + * Email: libdash-dev@vicky.bitmovin.net + * + * This source code and its use and distribution, is subject to the terms + * and conditions of the applicable license agreement. + *****************************************************************************/ + +#include "Segment.h" + +using namespace dash::mpd; +using namespace dash::helpers; +using namespace dash::metrics; + +Segment::Segment () : + host(""), + port(0), + path(""), + startByte(0), + endByte(0), + hasByteRange(false) +{ +} +Segment::~Segment () +{ +} + +bool Segment::Init (const std::vector<IBaseUrl *>& baseurls, const std::string &uri, const std::string &range, HTTPTransactionType type) +{ + std::string host = ""; + size_t port = 80; + std::string path = ""; + size_t startByte = 0; + size_t endByte = 0; + + this->absoluteuri = ""; + + for(size_t i = 0; i < baseurls.size(); i++) + this->absoluteuri = Path::CombinePaths(this->absoluteuri, baseurls.at(i)->GetUrl()); + + this->absoluteuri = Path::CombinePaths(this->absoluteuri, uri); + + if (uri != "" && dash::helpers::Path::GetHostPortAndPath(this->absoluteuri, host, port, path)) + { + this->host = host; + this->port = port; + this->path = path; + + if (range != "" && dash::helpers::Path::GetStartAndEndBytes(range, startByte, endByte)) + { + this->range = range; + this->hasByteRange = true; + this->startByte = startByte; + this->endByte = endByte; + } + + this->type = type; + + return true; + } + + return false; +} +std::string& Segment::AbsoluteURI () +{ + return this->absoluteuri; +} +std::string& Segment::Host () +{ + return this->host; +} +size_t Segment::Port () +{ + return this->port; +} +std::string& Segment::Path () +{ + return this->path; +} +std::string& Segment::Range () +{ + return this->range; +} +size_t Segment::StartByte () +{ + return this->startByte; +} +size_t Segment::EndByte () +{ + return this->endByte; +} +bool Segment::HasByteRange () +{ + return this->hasByteRange; +} +void Segment::AbsoluteURI (std::string uri) +{ + this->absoluteuri = uri; +} +void Segment::Host (std::string host) +{ + this->host = host; +} +void Segment::Port (size_t port) +{ + this->port = port; +} +void Segment::Path (std::string path) +{ + this->path = path; +} +void Segment::Range (std::string range) +{ + this->range = range; +} +void Segment::StartByte (size_t startByte) +{ + this->startByte = startByte; +} +void Segment::EndByte (size_t endByte) +{ + this->endByte = endByte; +} +void Segment::HasByteRange (bool hasByteRange) +{ + this->hasByteRange = hasByteRange; +} +HTTPTransactionType Segment::GetType () +{ + return this->type; +} +void Segment::SetType (HTTPTransactionType type) +{ + this->type = type; +} |