summaryrefslogtreecommitdiffstats
path: root/libdash/source
diff options
context:
space:
mode:
Diffstat (limited to 'libdash/source')
-rw-r--r--libdash/source/defaults.mk7
-rw-r--r--libdash/source/dllmain.cpp33
-rw-r--r--libdash/source/helpers/Block.h59
-rw-r--r--libdash/source/helpers/BlockStream.cpp290
-rw-r--r--libdash/source/helpers/BlockStream.h55
-rw-r--r--libdash/source/helpers/Path.cpp118
-rw-r--r--libdash/source/helpers/Path.h33
-rw-r--r--libdash/source/helpers/String.cpp53
-rw-r--r--libdash/source/helpers/String.h31
-rw-r--r--libdash/source/helpers/SyncedBlockStream.cpp250
-rw-r--r--libdash/source/helpers/SyncedBlockStream.h57
-rw-r--r--libdash/source/helpers/Time.cpp33
-rw-r--r--libdash/source/helpers/Time.h35
-rw-r--r--libdash/source/libdash.cpp20
-rw-r--r--libdash/source/manager/DASHManager.cpp45
-rw-r--r--libdash/source/manager/DASHManager.h35
-rw-r--r--libdash/source/metrics/HTTPTransaction.cpp122
-rw-r--r--libdash/source/metrics/HTTPTransaction.h68
-rw-r--r--libdash/source/metrics/TCPConnection.cpp62
-rw-r--r--libdash/source/metrics/TCPConnection.h49
-rw-r--r--libdash/source/metrics/ThroughputMeasurement.cpp46
-rw-r--r--libdash/source/metrics/ThroughputMeasurement.h43
-rw-r--r--libdash/source/mpd/AbstractMPDElement.cpp41
-rw-r--r--libdash/source/mpd/AbstractMPDElement.h41
-rw-r--r--libdash/source/mpd/AdaptationSet.cpp343
-rw-r--r--libdash/source/mpd/AdaptationSet.h138
-rw-r--r--libdash/source/mpd/BaseUrl.cpp60
-rw-r--r--libdash/source/mpd/BaseUrl.h49
-rw-r--r--libdash/source/mpd/ContentComponent.cpp98
-rw-r--r--libdash/source/mpd/ContentComponent.h62
-rw-r--r--libdash/source/mpd/Descriptor.cpp39
-rw-r--r--libdash/source/mpd/Descriptor.h43
-rw-r--r--libdash/source/mpd/MPD.cpp212
-rw-r--r--libdash/source/mpd/MPD.h107
-rw-r--r--libdash/source/mpd/Metrics.cpp51
-rw-r--r--libdash/source/mpd/Metrics.h51
-rw-r--r--libdash/source/mpd/MultipleSegmentBase.cpp60
-rw-r--r--libdash/source/mpd/MultipleSegmentBase.h51
-rw-r--r--libdash/source/mpd/Period.cpp137
-rw-r--r--libdash/source/mpd/Period.h79
-rw-r--r--libdash/source/mpd/ProgramInformation.cpp67
-rw-r--r--libdash/source/mpd/ProgramInformation.h52
-rw-r--r--libdash/source/mpd/Range.cpp40
-rw-r--r--libdash/source/mpd/Range.h42
-rw-r--r--libdash/source/mpd/Representation.cpp116
-rw-r--r--libdash/source/mpd/Representation.h75
-rw-r--r--libdash/source/mpd/RepresentationBase.cpp175
-rw-r--r--libdash/source/mpd/RepresentationBase.h89
-rw-r--r--libdash/source/mpd/Segment.cpp138
-rw-r--r--libdash/source/mpd/Segment.h69
-rw-r--r--libdash/source/mpd/SegmentBase.cpp78
-rw-r--r--libdash/source/mpd/SegmentBase.h56
-rw-r--r--libdash/source/mpd/SegmentList.cpp50
-rw-r--r--libdash/source/mpd/SegmentList.h47
-rw-r--r--libdash/source/mpd/SegmentTemplate.cpp152
-rw-r--r--libdash/source/mpd/SegmentTemplate.h61
-rw-r--r--libdash/source/mpd/SegmentTimeline.cpp32
-rw-r--r--libdash/source/mpd/SegmentTimeline.h40
-rw-r--r--libdash/source/mpd/SegmentURL.cpp90
-rw-r--r--libdash/source/mpd/SegmentURL.h56
-rw-r--r--libdash/source/mpd/SubRepresentation.cpp55
-rw-r--r--libdash/source/mpd/SubRepresentation.h50
-rw-r--r--libdash/source/mpd/Subset.cpp30
-rw-r--r--libdash/source/mpd/Subset.h41
-rw-r--r--libdash/source/mpd/Timeline.cpp49
-rw-r--r--libdash/source/mpd/Timeline.h46
-rw-r--r--libdash/source/mpd/URLType.cpp57
-rw-r--r--libdash/source/mpd/URLType.h48
-rw-r--r--libdash/source/network/AbstractChunk.cpp271
-rw-r--r--libdash/source/network/AbstractChunk.h100
-rw-r--r--libdash/source/network/DownloadStateManager.cpp100
-rw-r--r--libdash/source/network/DownloadStateManager.h50
-rw-r--r--libdash/source/portable/MultiThreading.cpp112
-rw-r--r--libdash/source/portable/MultiThreading.h70
-rw-r--r--libdash/source/portable/Networking.h27
-rw-r--r--libdash/source/sublibs.mk23
-rw-r--r--libdash/source/targetver.h18
-rw-r--r--libdash/source/xml/DOMHelper.cpp54
-rw-r--r--libdash/source/xml/DOMHelper.h35
-rw-r--r--libdash/source/xml/DOMParser.cpp160
-rw-r--r--libdash/source/xml/DOMParser.h56
-rw-r--r--libdash/source/xml/Node.cpp1029
-rw-r--r--libdash/source/xml/Node.h105
83 files changed, 7317 insertions, 0 deletions
diff --git a/libdash/source/defaults.mk b/libdash/source/defaults.mk
new file mode 100644
index 00000000..d446c620
--- /dev/null
+++ b/libdash/source/defaults.mk
@@ -0,0 +1,7 @@
+LIBNAME=libdash
+CC=g++
+AR=ar
+LD=g++
+ARFLAGS=-cr
+CFLAGS=-fPIC -c -Wall #-DDEBUG
+LDFLAGS=-shared -Wl,-soname,$(LIBNAME).so
diff --git a/libdash/source/dllmain.cpp b/libdash/source/dllmain.cpp
new file mode 100644
index 00000000..b624228b
--- /dev/null
+++ b/libdash/source/dllmain.cpp
@@ -0,0 +1,33 @@
+/*
+ * dllmain.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#if defined _WIN32 || defined _WIN64
+
+#include "targetver.h"
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
+#endif
diff --git a/libdash/source/helpers/Block.h b/libdash/source/helpers/Block.h
new file mode 100644
index 00000000..c71462e8
--- /dev/null
+++ b/libdash/source/helpers/Block.h
@@ -0,0 +1,59 @@
+/*
+ * Block.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef __BLOCK_H__
+#define __BLOCK_H__
+
+#include "config.h"
+
+namespace dash
+{
+ namespace helpers
+ {
+ struct block_t
+ {
+ uint8_t *data;
+ size_t len;
+ float millisec;
+ size_t offset;
+ };
+
+ static inline block_t* AllocBlock (size_t len)
+ {
+ block_t *block = (block_t *)malloc(sizeof(block_t));
+ block->data = new uint8_t[len];
+ block->len = len;
+ block->millisec = 0;
+ block->offset = 0;
+ return block;
+ }
+ static inline void DeleteBlock (block_t *block)
+ {
+ if(block)
+ {
+ delete [] block->data;
+ free(block);
+ block = NULL;
+ }
+ }
+ static inline block_t* DuplicateBlock (block_t *block)
+ {
+ block_t *ret = AllocBlock(block->len);
+ ret->offset = block->offset;
+
+ memcpy(ret->data, block->data, ret->len);
+
+ return block;
+ }
+ }
+}
+
+#endif
diff --git a/libdash/source/helpers/BlockStream.cpp b/libdash/source/helpers/BlockStream.cpp
new file mode 100644
index 00000000..fd34f88e
--- /dev/null
+++ b/libdash/source/helpers/BlockStream.cpp
@@ -0,0 +1,290 @@
+/*
+ * BlockStream.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "BlockStream.h"
+#include <limits>
+
+using namespace dash::helpers;
+
+BlockStream::BlockStream () :
+ length (0)
+{
+}
+BlockStream::~BlockStream ()
+{
+ this->Clear();
+}
+
+void BlockStream::PopAndDeleteFront ()
+{
+ if(this->blockqueue.empty())
+ return;
+
+ this->length -= this->blockqueue.front()->len;
+ DeleteBlock(this->blockqueue.front());
+ this->blockqueue.pop_front();
+}
+void BlockStream::PushBack (block_t *block)
+{
+ this->length += block->len;
+ this->blockqueue.push_back(block);
+}
+void BlockStream::PushFront (block_t *block)
+{
+ this->length += block->len;
+ this->blockqueue.push_front(block);
+}
+const block_t* BlockStream::GetBytes (uint32_t len)
+{
+ /* Performance Intensive */
+ if(this->length < len)
+ return NULL;
+
+ block_t *block = AllocBlock(len);
+ this->BlockQueueGetBytes(block->data, block->len);
+
+ this->length -= len;
+
+ return block;
+}
+size_t BlockStream::GetBytes (uint8_t *data, size_t len)
+{
+ /* Performance Intensive */
+ if(len > this->length)
+ len = (size_t) this->length;
+
+ this->BlockQueueGetBytes(data, len);
+
+ this->length -= len;
+
+ return len;
+}
+size_t BlockStream::PeekBytes (uint8_t *data, size_t len)
+{
+ /* Performance Intensive */
+ if(len > this->length)
+ len = (size_t) this->length;
+
+ this->BlockQueuePeekBytes(data, len, 0);
+
+ return len;
+}
+size_t BlockStream::PeekBytes (uint8_t *data, size_t len, size_t offset)
+{
+ /* Performance Intensive */
+ if(len > this->length)
+ len = (size_t) this->length;
+
+ if (offset + len > this->length)
+ len = (size_t) (this->length - offset);
+
+ this->BlockQueuePeekBytes(data, len, offset);
+
+ return len;
+}
+uint64_t BlockStream::Length () const
+{
+ return this->length;
+}
+const block_t* BlockStream::GetFront ()
+{
+ if(this->blockqueue.empty())
+ return NULL;
+
+ const block_t* ret = this->blockqueue.front();
+ this->length -= ret->len;
+ this->blockqueue.pop_front();
+
+ return ret;
+}
+const block_t* BlockStream::Front () const
+{
+ if(this->blockqueue.empty())
+ return NULL;
+
+ return this->blockqueue.front();
+}
+bool BlockStream::BlockQueueGetBytes (uint8_t *data, uint32_t len)
+{
+ uint32_t pos = 0;
+
+ block_t *block = NULL;
+
+ while(pos < len)
+ {
+ block = this->blockqueue.front();
+ if((len - pos) < (block->len))
+ {
+ memcpy(data + pos, block->data, len - pos);
+
+ this->blockqueue.pop_front();
+
+ block_t* newfront = AllocBlock(block->len - (len - pos));
+ memcpy(newfront->data, block->data + (len - pos), newfront->len);
+
+ DeleteBlock(block);
+ this->blockqueue.push_front(newfront);
+
+ return true;
+ }
+ else
+ {
+ memcpy(data + pos, block->data, block->len);
+ pos += block->len;
+
+ DeleteBlock(block);
+ this->blockqueue.pop_front();
+ }
+ }
+
+ return false;
+}
+bool BlockStream::BlockQueuePeekBytes (uint8_t *data, uint32_t len, size_t offset)
+{
+ uint32_t pos = 0;
+ int cnt = 0;
+
+ const block_t *block = NULL;
+
+ while(pos < len)
+ {
+ block = this->blockqueue.at(cnt);
+ if((offset + len - pos) < (block->len))
+ {
+ memcpy(data + pos, block->data + offset, len - pos - offset);
+ return true;
+ }
+ else
+ {
+ memcpy(data + pos, block->data + offset, block->len - offset);
+ pos += block->len;
+ }
+
+ cnt++;
+ }
+
+ return false;
+}
+uint8_t BlockStream::ByteAt (uint64_t position) const
+{
+ if(position > this->length)
+ return -1;
+
+ uint64_t pos = 0;
+
+ for(size_t i = 0; i < this->blockqueue.size(); i++)
+ {
+ const block_t *block = this->blockqueue.at(i);
+
+ if(pos + block->len > position)
+ return block->data[position - pos];
+ else
+ pos += block->len;
+ }
+
+ return -1;
+}
+const block_t* BlockStream::ToBlock ()
+{
+ if(this->length > std::numeric_limits<size_t>::max())
+ return NULL;
+
+ return BlockStream::GetBytes((size_t)this->length);
+}
+void BlockStream::Clear ()
+{
+ while(!this->blockqueue.empty())
+ {
+ DeleteBlock(this->blockqueue.front());
+ this->blockqueue.pop_front();
+ }
+
+ this->length = 0;
+}
+void BlockStream::EraseFront (uint64_t len)
+{
+ if(len > this->length)
+ len = this->length;
+
+ uint64_t actLen = 0;
+
+ while(actLen < len)
+ {
+ if(this->blockqueue.size() == 0)
+ return;
+
+ block_t *front = this->blockqueue.front();
+
+ if((actLen + front->len) <= len)
+ {
+ this->length -= front->len;
+ actLen += front->len;
+
+ DeleteBlock(front);
+ this->blockqueue.pop_front();
+ }
+ else
+ {
+ uint32_t diff = (uint32_t) (len - actLen);
+ this->length -= diff;
+ actLen += diff;
+ block_t* newfront = AllocBlock(front->len - diff);
+
+ memcpy(newfront->data, front->data + diff, newfront->len);
+
+ DeleteBlock(front);
+ this->blockqueue.pop_front();
+ this->blockqueue.push_front(newfront);
+ }
+ }
+}
+BlockStream* BlockStream::GetBlocks (uint64_t len)
+{
+ if(len > this->length)
+ return NULL;
+
+ BlockStream *blocks = new BlockStream();
+
+ uint64_t actLen = 0;
+
+ while(actLen < len)
+ {
+ block_t *front = this->blockqueue.front();
+
+ if((actLen + front->len) <= len)
+ {
+ this->length -= front->len;
+ actLen += front->len;
+
+ blocks->PushBack(front);
+ this->blockqueue.pop_front();
+ }
+ else
+ {
+ uint32_t diff = (uint32_t) (len - actLen);
+ this->length -= diff;
+ actLen += diff;
+ block_t *block = AllocBlock(diff);
+ block_t* newfront = AllocBlock(front->len - diff);
+
+ memcpy(block->data, front->data, diff);
+ blocks->PushBack(block);
+
+ memcpy(newfront->data, front->data+ diff, newfront->len);
+
+ DeleteBlock(front);
+ this->blockqueue.pop_front();
+ this->blockqueue.push_front(newfront);
+ }
+ }
+
+ return blocks;
+}
diff --git a/libdash/source/helpers/BlockStream.h b/libdash/source/helpers/BlockStream.h
new file mode 100644
index 00000000..4b8b3fd5
--- /dev/null
+++ b/libdash/source/helpers/BlockStream.h
@@ -0,0 +1,55 @@
+/*
+ * BlockStream.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef __BLOCKSTREAM_H__
+#define __BLOCKSTREAM_H__
+
+#include "config.h"
+
+#include "Block.h"
+
+namespace dash
+{
+ namespace helpers
+ {
+ class BlockStream
+ {
+ public:
+ BlockStream ();
+ virtual ~BlockStream ();
+
+ virtual void PushBack (block_t *block);
+ virtual void PushFront (block_t *block);
+ virtual const block_t* GetBytes (uint32_t len);
+ virtual size_t GetBytes (uint8_t *data, size_t len);
+ virtual size_t PeekBytes (uint8_t *data, size_t len);
+ virtual size_t PeekBytes (uint8_t *data, size_t len, size_t offset);
+ virtual const block_t* GetFront ();
+ virtual const block_t* Front () const;
+ virtual uint64_t Length () const;
+ virtual uint8_t ByteAt (uint64_t position) const;
+ virtual const block_t* ToBlock ();
+ virtual void Clear ();
+ virtual void EraseFront (uint64_t len);
+ virtual BlockStream* GetBlocks (uint64_t len);
+ virtual void PopAndDeleteFront ();
+
+ protected:
+ uint64_t length;
+ std::deque<block_t *> blockqueue;
+
+ virtual bool BlockQueueGetBytes (uint8_t *data, uint32_t len);
+ virtual bool BlockQueuePeekBytes (uint8_t *data, uint32_t len, size_t offset);
+ };
+ }
+}
+
+#endif // __BLOCKSTREAM_H__ \ No newline at end of file
diff --git a/libdash/source/helpers/Path.cpp b/libdash/source/helpers/Path.cpp
new file mode 100644
index 00000000..301d9fa0
--- /dev/null
+++ b/libdash/source/helpers/Path.cpp
@@ -0,0 +1,118 @@
+/*
+ * Path.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Path.h"
+
+using namespace dash::helpers;
+
+std::string Path::CombinePaths (const std::string &path1, const std::string &path2)
+{
+ if(path1 == "")
+ return path2;
+ if(path2 == "")
+ return path1;
+
+ char path1Last = path1.at(path1.size() - 1);
+ char path2First = path2.at(0);
+
+ if(path1Last == '/' && path2First == '/')
+ return path1 + path2.substr(1, path2.size());
+
+ if(path1Last != '/' && path2First != '/')
+ return path1 + "/" + path2;
+
+ return path1 + path2;
+}
+std::string Path::GetDirectoryPath (const std::string &path)
+{
+ int pos = path.find_last_of('/');
+
+ return path.substr(0, pos);
+}
+std::vector<std::string> Path::Split (const std::string &s, char delim)
+{
+ std::stringstream ss(s);
+ std::string item;
+ std::vector<std::string> ret;
+
+ while(std::getline(ss, item, delim))
+ ret.push_back(item);
+
+ return ret;
+}
+bool Path::GetHostPortAndPath (const std::string &url, std::string &host, size_t &port, std::string& path)
+{
+ std::string hostPort = "";
+ size_t found = 0;
+ size_t pathBegin = 0;
+
+ if (url.substr(0,7) == "http://" || url.substr(0,8) == "https://")
+ {
+ found = url.find("//");
+ pathBegin = url.find('/', found+2);
+ path = url.substr(pathBegin, std::string::npos);
+
+ hostPort = url.substr(found+2, pathBegin - (found+2));
+ found = hostPort.find(':');
+ if (found != std::string::npos)
+ {
+ port = strtoul(hostPort.substr(found+1, std::string::npos).c_str(), NULL, 10);
+ }
+ host = hostPort.substr(0, found);
+ return (host.size() > 0) && (path.size() > 0);
+ }
+ else if(url.substr(0,5) == "ndn:/")
+ {
+ found = url.find("/");
+ pathBegin = url.find('/', found+1);
+ path = url.substr(pathBegin, std::string::npos);
+
+ hostPort = url.substr(found+1, pathBegin - (found+1));
+ found = hostPort.find(':');
+ if (found != std::string::npos)
+ {
+ port = strtoul(hostPort.substr(found+1, std::string::npos).c_str(), NULL, 10);
+ }
+ host = hostPort.substr(0, found);
+ return (host.size() > 0) && (path.size() > 0);
+ }
+ else if(url.substr(0,6) == "ccnx:/")
+ {
+ found = url.find("/");
+ pathBegin = url.find('/', found+1);
+ path = url.substr(pathBegin, std::string::npos);
+
+ hostPort = url.substr(found+1, pathBegin - (found+1));
+ found = hostPort.find(':');
+ if (found != std::string::npos)
+ {
+ port = strtoul(hostPort.substr(found+1, std::string::npos).c_str(), NULL, 10);
+ }
+ host = hostPort.substr(0, found);
+ return (host.size() > 0) && (path.size() > 0);
+ }
+
+ return false;
+}
+bool Path::GetStartAndEndBytes (const std::string &byteRange, size_t &startByte, size_t &endByte)
+{
+ size_t found = 0;
+
+ found = byteRange.find('-');
+ if (found != std::string::npos && found < byteRange.size()-1 )
+ {
+ startByte = strtoul(byteRange.substr(0, found).c_str(), NULL, 10);
+ endByte = strtoul(byteRange.substr(found+1, std::string::npos).c_str(), NULL, 10);
+ return (startByte <= endByte);
+ }
+
+ return false;
+}
diff --git a/libdash/source/helpers/Path.h b/libdash/source/helpers/Path.h
new file mode 100644
index 00000000..1c791baa
--- /dev/null
+++ b/libdash/source/helpers/Path.h
@@ -0,0 +1,33 @@
+/*
+ * Path.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef PATH_H_
+#define PATH_H_
+
+#include "config.h"
+
+namespace dash
+{
+ namespace helpers
+ {
+ class Path
+ {
+ public:
+ static std::string CombinePaths (const std::string &path1, const std::string &path2);
+ static std::string GetDirectoryPath (const std::string &path);
+ static std::vector<std::string> Split (const std::string &s, char delim);
+ static bool GetHostPortAndPath (const std::string &url, std::string &host, size_t &port, std::string& path);
+ static bool GetStartAndEndBytes (const std::string &byteRange, size_t &startByte, size_t &endByte);
+ };
+ }
+}
+
+#endif /* PATH_H_ */ \ No newline at end of file
diff --git a/libdash/source/helpers/String.cpp b/libdash/source/helpers/String.cpp
new file mode 100644
index 00000000..53da5592
--- /dev/null
+++ b/libdash/source/helpers/String.cpp
@@ -0,0 +1,53 @@
+/*
+ * String.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "String.h"
+
+using namespace dash::helpers;
+
+void String::Split (const std::string &s, char delim, std::vector<std::string>& vector)
+{
+ std::stringstream ss(s);
+ std::string item;
+
+ while(std::getline(ss, item, delim))
+ vector.push_back(item);
+}
+void String::Split (const std::string &s, char delim, std::vector<uint32_t>& vector)
+{
+ size_t lengthOfString = s.length();
+ size_t pos = 0;
+ size_t i = 0;
+ uint32_t level = 0;
+
+ while (pos != std::string::npos)
+ {
+ pos = s.find(delim, i);
+
+ if (i < lengthOfString)
+ {
+ level = strtoul(s.substr(i, pos-i).c_str(), NULL, 10);
+ vector.push_back(level);
+ i = pos + 1;
+ }
+ }
+}
+bool String::ToBool (const std::string &s)
+{
+ if (s == "true" || s == "True" || s == "TRUE")
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/libdash/source/helpers/String.h b/libdash/source/helpers/String.h
new file mode 100644
index 00000000..73ac6db8
--- /dev/null
+++ b/libdash/source/helpers/String.h
@@ -0,0 +1,31 @@
+/*
+ * String.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef STRING_H_
+#define STRING_H_
+
+#include "config.h"
+
+namespace dash
+{
+ namespace helpers
+ {
+ class String
+ {
+ public:
+ static void Split (const std::string &s, char delim, std::vector<std::string>& vector);
+ static void Split (const std::string &s, char delim, std::vector<uint32_t>& vector);
+ static bool ToBool (const std::string &s);
+ };
+ }
+}
+
+#endif /* STRING_H_ */ \ No newline at end of file
diff --git a/libdash/source/helpers/SyncedBlockStream.cpp b/libdash/source/helpers/SyncedBlockStream.cpp
new file mode 100644
index 00000000..84fa63cf
--- /dev/null
+++ b/libdash/source/helpers/SyncedBlockStream.cpp
@@ -0,0 +1,250 @@
+/*
+ * SyncedBlockStream.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "SyncedBlockStream.h"
+
+using namespace dash::helpers;
+
+SyncedBlockStream::SyncedBlockStream () :
+ eos (false)
+{
+ InitializeConditionVariable (&this->full);
+ InitializeCriticalSection (&this->monitorMutex);
+}
+SyncedBlockStream::~SyncedBlockStream ()
+{
+ DeleteConditionVariable(&this->full);
+ DeleteCriticalSection(&this->monitorMutex);
+}
+
+void SyncedBlockStream::PopAndDeleteFront ()
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ BlockStream::PopAndDeleteFront();
+
+ LeaveCriticalSection(&this->monitorMutex);
+}
+void SyncedBlockStream::PushBack (block_t *block)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ BlockStream::PushBack(block);
+
+ WakeAllConditionVariable(&this->full);
+ LeaveCriticalSection(&this->monitorMutex);
+}
+void SyncedBlockStream::PushFront (block_t *block)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ BlockStream::PushFront(block);
+
+ WakeAllConditionVariable(&this->full);
+ LeaveCriticalSection(&this->monitorMutex);
+}
+const block_t* SyncedBlockStream::GetBytes (uint32_t len)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length == 0 && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return NULL;
+ }
+
+ const block_t* block = BlockStream::GetBytes(len);
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return block;
+}
+size_t SyncedBlockStream::GetBytes (uint8_t *data, size_t len)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length == 0 && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return 0;
+ }
+
+ size_t ret = BlockStream::GetBytes(data, len);
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return ret;
+}
+size_t SyncedBlockStream::PeekBytes (uint8_t *data, size_t len)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length == 0 && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return 0;
+ }
+
+ size_t ret = BlockStream::PeekBytes(data, len);
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return ret;
+}
+size_t SyncedBlockStream::PeekBytes (uint8_t *data, size_t len, size_t offset)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while((this->length == 0 || offset >= this->length) && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0 || offset >= this->length)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return 0;
+ }
+
+ size_t ret = BlockStream::PeekBytes(data, len, offset);
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return ret;
+}
+uint64_t SyncedBlockStream::Length () const
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ uint64_t len = BlockStream::Length();
+
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return len;
+}
+const block_t* SyncedBlockStream::GetFront ()
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length == 0 && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return NULL;
+ }
+
+ const block_t* block = BlockStream::GetFront();
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return block;
+}
+const block_t* SyncedBlockStream::Front () const
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length == 0 && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return NULL;
+ }
+
+ const block_t* block = BlockStream::Front();
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return block;
+}
+uint8_t SyncedBlockStream::ByteAt (uint64_t position) const
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length < position && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length < position)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return 0;
+ }
+
+ uint8_t ret = BlockStream::ByteAt(position);
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return ret;
+}
+const block_t* SyncedBlockStream::ToBlock ()
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length == 0 && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return NULL;
+ }
+
+ const block_t* block = BlockStream::ToBlock();
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return block;
+}
+void SyncedBlockStream::Clear ()
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ BlockStream::Clear();
+
+ LeaveCriticalSection(&this->monitorMutex);
+}
+void SyncedBlockStream::EraseFront (uint64_t len)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ BlockStream::EraseFront(len);
+
+ LeaveCriticalSection(&this->monitorMutex);
+}
+BlockStream* SyncedBlockStream::GetBlocks (uint64_t len)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ while(this->length == 0 && !this->eos)
+ SleepConditionVariableCS(&this->full, &this->monitorMutex, INFINITE);
+
+ if(this->length == 0)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return NULL;
+ }
+
+ BlockStream *stream = BlockStream::GetBlocks(len);
+ LeaveCriticalSection(&this->monitorMutex);
+
+ return stream;
+}
+void SyncedBlockStream::SetEOS (bool value)
+{
+ EnterCriticalSection(&this->monitorMutex);
+
+ this->eos = value;
+
+ WakeAllConditionVariable(&this->full);
+ LeaveCriticalSection(&this->monitorMutex);
+}
diff --git a/libdash/source/helpers/SyncedBlockStream.h b/libdash/source/helpers/SyncedBlockStream.h
new file mode 100644
index 00000000..9e266c60
--- /dev/null
+++ b/libdash/source/helpers/SyncedBlockStream.h
@@ -0,0 +1,57 @@
+/*
+ * SyncedBlockStream.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef __SYNCEDBLOCKSTREAM_H__
+#define __SYNCEDBLOCKSTREAM_H__
+
+#include "config.h"
+
+#include "BlockStream.h"
+#include "../portable/MultiThreading.h"
+
+namespace dash
+{
+ namespace helpers
+ {
+ class SyncedBlockStream : public BlockStream
+ {
+ public:
+ SyncedBlockStream ();
+ virtual ~SyncedBlockStream ();
+
+ virtual void PushBack (block_t *block);
+ virtual void PushFront (block_t *block);
+ virtual const block_t* GetBytes (uint32_t len);
+ virtual size_t GetBytes (uint8_t *data, size_t len);
+ virtual size_t PeekBytes (uint8_t *data, size_t len);
+ virtual size_t PeekBytes (uint8_t *data, size_t len, size_t offset);
+ virtual const block_t* GetFront ();
+ virtual const block_t* Front () const;
+ virtual uint64_t Length () const;
+ virtual uint8_t ByteAt (uint64_t position) const;
+ virtual const block_t* ToBlock ();
+ virtual void Clear ();
+ virtual void EraseFront (uint64_t len);
+ virtual BlockStream* GetBlocks (uint64_t len);
+ virtual void PopAndDeleteFront ();
+ virtual void SetEOS (bool value);
+
+ private:
+ bool eos;
+
+ mutable CRITICAL_SECTION monitorMutex;
+ mutable CONDITION_VARIABLE full;
+
+ };
+ }
+}
+
+#endif // __SYNCEDBLOCKSTREAM_H__ \ No newline at end of file
diff --git a/libdash/source/helpers/Time.cpp b/libdash/source/helpers/Time.cpp
new file mode 100644
index 00000000..e6ca2b81
--- /dev/null
+++ b/libdash/source/helpers/Time.cpp
@@ -0,0 +1,33 @@
+/*
+ * Time.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 "Time.h"
+
+using namespace dash::helpers;
+
+uint32_t Time::GetCurrentUTCTimeInSec ()
+{
+ return mktime(Time::GetCurrentUTCTime());
+}
+std::string Time::GetCurrentUTCTimeStr ()
+{
+ char timeString[30];
+ strftime(timeString, 30, "%Y-%m-%dT%H:%M:%SZ", Time::GetCurrentUTCTime());
+
+ return std::string(timeString);
+}
+struct tm* Time::GetCurrentUTCTime ()
+{
+ time_t rawTime;
+
+ time(&rawTime);
+ return gmtime(&rawTime);
+}
diff --git a/libdash/source/helpers/Time.h b/libdash/source/helpers/Time.h
new file mode 100644
index 00000000..e7de0cd9
--- /dev/null
+++ b/libdash/source/helpers/Time.h
@@ -0,0 +1,35 @@
+/*
+ * Time.h
+ *****************************************************************************
+ * 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.
+ *****************************************************************************/
+
+#ifndef DASH_HELPERS_TIME_H_
+#define DASH_HELPERS_TIME_H_
+
+#include <time.h>
+#include "config.h"
+
+namespace dash
+{
+ namespace helpers
+ {
+ class Time
+ {
+ public:
+ static uint32_t GetCurrentUTCTimeInSec ();
+ static std::string GetCurrentUTCTimeStr ();
+
+ private:
+ static struct tm* GetCurrentUTCTime ();
+
+ };
+ }
+}
+
+#endif /* DASH_HELPERS_TIME_H_ */
diff --git a/libdash/source/libdash.cpp b/libdash/source/libdash.cpp
new file mode 100644
index 00000000..f26c8224
--- /dev/null
+++ b/libdash/source/libdash.cpp
@@ -0,0 +1,20 @@
+/*
+ * libdash.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "../include/libdash.h"
+#include "manager/DASHManager.h"
+
+using namespace dash;
+
+__declspec(dllexport) IDASHManager* __cdecl CreateDashManager()
+{
+ return new DASHManager();
+} \ No newline at end of file
diff --git a/libdash/source/manager/DASHManager.cpp b/libdash/source/manager/DASHManager.cpp
new file mode 100644
index 00000000..7650111e
--- /dev/null
+++ b/libdash/source/manager/DASHManager.cpp
@@ -0,0 +1,45 @@
+/*
+ * DASHManager.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "DASHManager.h"
+
+using namespace dash;
+using namespace dash::xml;
+using namespace dash::mpd;
+using namespace dash::network;
+using namespace dash::helpers;
+
+DASHManager::DASHManager ()
+{
+}
+DASHManager::~DASHManager ()
+{
+}
+IMPD* DASHManager::Open (char *path, std::string mUrl)
+{
+ DOMParser parser(path);
+
+ uint32_t fetchTime = Time::GetCurrentUTCTimeInSec();
+
+ if (!parser.Parse(mUrl))
+ return NULL;
+
+ MPD* mpd = parser.GetRootNode()->ToMPD();
+
+ if (mpd)
+ mpd->SetFetchTime(fetchTime);
+
+ return mpd;
+}
+void DASHManager::Delete ()
+{
+ delete this;
+}
diff --git a/libdash/source/manager/DASHManager.h b/libdash/source/manager/DASHManager.h
new file mode 100644
index 00000000..99ef188b
--- /dev/null
+++ b/libdash/source/manager/DASHManager.h
@@ -0,0 +1,35 @@
+/*
+ * DASHManager.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef DASHMANAGER_H_
+#define DASHMANAGER_H_
+
+#include "config.h"
+
+#include "../xml/Node.h"
+#include "../xml/DOMParser.h"
+#include "IDASHManager.h"
+#include "../helpers/Time.h"
+
+namespace dash
+{
+ class DASHManager : public IDASHManager
+ {
+ public:
+ DASHManager ();
+ virtual ~DASHManager ();
+
+ mpd::IMPD* Open (char *path, std::string mUrl = "");
+ void Delete ();
+ };
+}
+
+#endif /* DASHMANAGER_H_ */
diff --git a/libdash/source/metrics/HTTPTransaction.cpp b/libdash/source/metrics/HTTPTransaction.cpp
new file mode 100644
index 00000000..2767b514
--- /dev/null
+++ b/libdash/source/metrics/HTTPTransaction.cpp
@@ -0,0 +1,122 @@
+/*
+ * HTTPTransaction.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "HTTPTransaction.h"
+
+using namespace dash::metrics;
+
+HTTPTransaction::HTTPTransaction () :
+ tcpId (0),
+ type (dash::metrics::Other),
+ responseCode (0),
+ interval (0),
+ url (""),
+ actualUrl (""),
+ range (""),
+ tRequest (""),
+ tResponse (""),
+ httpHeader ("")
+{
+}
+HTTPTransaction::~HTTPTransaction()
+{
+ for (size_t i = 0; i < trace.size(); i++)
+ delete trace.at(i);
+}
+
+uint32_t HTTPTransaction::TCPId () const
+{
+ return this->tcpId;
+}
+void HTTPTransaction::SetTCPId (uint32_t tcpId)
+{
+ this->tcpId = tcpId;
+}
+HTTPTransactionType HTTPTransaction::Type () const
+{
+ return this->type;
+}
+void HTTPTransaction::SetType (HTTPTransactionType type)
+{
+ this->type = type;
+}
+const std::string& HTTPTransaction::OriginalUrl () const
+{
+ return this->url;
+}
+void HTTPTransaction::SetOriginalUrl (const std::string& origUrl)
+{
+ this->url = origUrl;
+}
+const std::string& HTTPTransaction::ActualUrl () const
+{
+ return this->actualUrl;
+}
+void HTTPTransaction::SetActualUrl (const std::string& actUrl)
+{
+ this->actualUrl = actUrl;
+}
+const std::string& HTTPTransaction::Range () const
+{
+ return this->range;
+}
+void HTTPTransaction::SetRange (const std::string& range)
+{
+ this->range = range;
+}
+const std::string& HTTPTransaction::RequestSentTime () const
+{
+ return this->tRequest;
+}
+void HTTPTransaction::SetRequestSentTime (std::string tRequest)
+{
+ this->tRequest = tRequest;
+}
+const std::string& HTTPTransaction::ResponseReceivedTime () const
+{
+ return this->tResponse;
+}
+void HTTPTransaction::SetResponseReceivedTime (std::string tResponse)
+{
+ this->tResponse = tResponse;
+}
+uint16_t HTTPTransaction::ResponseCode () const
+{
+ return this->responseCode;
+}
+void HTTPTransaction::SetResponseCode (uint16_t respCode)
+{
+ this->responseCode = respCode;
+}
+uint64_t HTTPTransaction::Interval () const
+{
+ return this->interval;
+}
+void HTTPTransaction::SetInterval (uint64_t interval)
+{
+ this->interval = interval;
+}
+const std::vector<IThroughputMeasurement *>& HTTPTransaction::ThroughputTrace () const
+{
+ return (std::vector<IThroughputMeasurement *> &) this->trace;
+}
+void HTTPTransaction::AddThroughputMeasurement (ThroughputMeasurement *throuputEntry)
+{
+ this->trace.push_back(throuputEntry);
+}
+const std::string& HTTPTransaction::HTTPHeader () const
+{
+ return this->httpHeader;
+}
+void HTTPTransaction::AddHTTPHeaderLine (std::string headerLine)
+{
+ this->httpHeader.append(headerLine);
+}
diff --git a/libdash/source/metrics/HTTPTransaction.h b/libdash/source/metrics/HTTPTransaction.h
new file mode 100644
index 00000000..77c69234
--- /dev/null
+++ b/libdash/source/metrics/HTTPTransaction.h
@@ -0,0 +1,68 @@
+/*
+ * HTTPTransaction.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef HTTPTRANSACTION_H_
+#define HTTPTRANSACTION_H_
+
+#include "IHTTPTransaction.h"
+#include "ThroughputMeasurement.h"
+
+namespace dash
+{
+ namespace metrics
+ {
+ class HTTPTransaction : public IHTTPTransaction
+ {
+ public:
+ HTTPTransaction ();
+ virtual ~HTTPTransaction ();
+
+ uint32_t TCPId () const;
+ HTTPTransactionType Type () const;
+ const std::string& OriginalUrl () const;
+ const std::string& ActualUrl () const;
+ const std::string& Range () const;
+ const std::string& RequestSentTime () const;
+ const std::string& ResponseReceivedTime () const;
+ uint16_t ResponseCode () const;
+ uint64_t Interval () const;
+ const std::vector<IThroughputMeasurement *>& ThroughputTrace () const;
+ const std::string& HTTPHeader () const;
+
+ void SetTCPId (uint32_t tcpId);
+ void SetType (HTTPTransactionType type);
+ void SetOriginalUrl (const std::string& origUrl);
+ void SetActualUrl (const std::string& actUrl);
+ void SetRange (const std::string& range);
+ void SetRequestSentTime (std::string tRequest);
+ void SetResponseReceivedTime (std::string tResponse);
+ void SetResponseCode (uint16_t respCode);
+ void SetInterval (uint64_t interval);
+ void AddThroughputMeasurement (ThroughputMeasurement *throuputEntry);
+ void AddHTTPHeaderLine (std::string headerLine);
+
+ private:
+ uint32_t tcpId;
+ HTTPTransactionType type;
+ std::string url;
+ std::string actualUrl;
+ std::string range;
+ std::string tRequest;
+ std::string tResponse;
+ uint16_t responseCode;
+ uint64_t interval;
+ std::vector<ThroughputMeasurement *> trace;
+ std::string httpHeader;
+ };
+ }
+}
+
+#endif /* HTTPTRANSACTION_H_ */
diff --git a/libdash/source/metrics/TCPConnection.cpp b/libdash/source/metrics/TCPConnection.cpp
new file mode 100644
index 00000000..581b0539
--- /dev/null
+++ b/libdash/source/metrics/TCPConnection.cpp
@@ -0,0 +1,62 @@
+/*
+ * TCPConnection.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "TCPConnection.h"
+
+using namespace dash::metrics;
+
+TCPConnection::TCPConnection ()
+{
+}
+TCPConnection::~TCPConnection()
+{
+}
+
+uint32_t TCPConnection::TCPId () const
+{
+ return this->tcpId;
+}
+void TCPConnection::SetTCPId (uint32_t tcpId)
+{
+ this->tcpId = tcpId;
+}
+const std::string& TCPConnection::DestinationAddress () const
+{
+ return this->dest;
+}
+void TCPConnection::SetDestinationAddress (const std::string& destAddress)
+{
+ this->dest = destAddress;
+}
+const std::string& TCPConnection::ConnectionOpenedTime () const
+{
+ return this->tOpen;
+}
+void TCPConnection::SetConnectionOpenedTime (std::string tOpen)
+{
+ this->tOpen = tOpen;
+}
+const std::string& TCPConnection::ConnectionClosedTime () const
+{
+ return this->tClose;
+}
+void TCPConnection::SetConnectionClosedTime (std::string tClose)
+{
+ this->tClose = tClose;
+}
+uint64_t TCPConnection::ConnectionTime () const
+{
+ return this->tConnect;
+}
+void TCPConnection::SetConnectionTime (uint64_t tConnect)
+{
+ this->tConnect = tConnect;
+}
diff --git a/libdash/source/metrics/TCPConnection.h b/libdash/source/metrics/TCPConnection.h
new file mode 100644
index 00000000..d4618d7f
--- /dev/null
+++ b/libdash/source/metrics/TCPConnection.h
@@ -0,0 +1,49 @@
+/*
+ * TCPConnection.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef TCPCONNECTION_H_
+#define TCPCONNECTION_H_
+
+#include "ITCPConnection.h"
+
+namespace dash
+{
+ namespace metrics
+ {
+ class TCPConnection : public ITCPConnection
+ {
+ public:
+ TCPConnection ();
+ virtual ~TCPConnection ();
+
+ uint32_t TCPId () const;
+ const std::string& DestinationAddress () const;
+ const std::string& ConnectionOpenedTime () const;
+ const std::string& ConnectionClosedTime () const;
+ uint64_t ConnectionTime () const;
+
+ void SetTCPId (uint32_t tcpId);
+ void SetDestinationAddress (const std::string& destAddress);
+ void SetConnectionOpenedTime (std::string tOpen);
+ void SetConnectionClosedTime (std::string tClose);
+ void SetConnectionTime (uint64_t tConnect);
+
+ private:
+ uint32_t tcpId;
+ std::string dest;
+ std::string tOpen;
+ std::string tClose;
+ uint64_t tConnect;
+ };
+ }
+}
+
+#endif /* TCPCONNECTION_H_ */
diff --git a/libdash/source/metrics/ThroughputMeasurement.cpp b/libdash/source/metrics/ThroughputMeasurement.cpp
new file mode 100644
index 00000000..8d2c485e
--- /dev/null
+++ b/libdash/source/metrics/ThroughputMeasurement.cpp
@@ -0,0 +1,46 @@
+/*
+ * ThroughputMeasurement.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "ThroughputMeasurement.h"
+
+using namespace dash::metrics;
+
+ThroughputMeasurement::ThroughputMeasurement ()
+{
+}
+ThroughputMeasurement::~ThroughputMeasurement()
+{
+}
+
+const std::string& ThroughputMeasurement::StartOfPeriod () const
+{
+ return this->startOfPeriod;
+}
+void ThroughputMeasurement::SetStartOfPeriod (std::string start)
+{
+ this->startOfPeriod = start;
+}
+uint64_t ThroughputMeasurement::DurationOfPeriod () const
+{
+ return this->durationOfPeriod;
+}
+void ThroughputMeasurement::SetDurationOfPeriod (uint64_t duration)
+{
+ this->durationOfPeriod = duration;
+}
+const std::vector<uint32_t>& ThroughputMeasurement::ReceivedBytesPerTrace () const
+{
+ return this->receivedBytesPerTrace;
+}
+void ThroughputMeasurement::AddReceivedBytes (uint32_t numberOfBytes)
+{
+ this->receivedBytesPerTrace.push_back(numberOfBytes);
+}
diff --git a/libdash/source/metrics/ThroughputMeasurement.h b/libdash/source/metrics/ThroughputMeasurement.h
new file mode 100644
index 00000000..817e30d9
--- /dev/null
+++ b/libdash/source/metrics/ThroughputMeasurement.h
@@ -0,0 +1,43 @@
+/*
+ * ThroughputMeasurement.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef THROUGHPUTMEASUREMENT_H_
+#define THROUGHPUTMEASUREMENT_H_
+
+#include "IThroughputMeasurement.h"
+
+namespace dash
+{
+ namespace metrics
+ {
+ class ThroughputMeasurement : public IThroughputMeasurement
+ {
+ public:
+ ThroughputMeasurement ();
+ virtual ~ThroughputMeasurement ();
+
+ const std::string& StartOfPeriod () const;
+ uint64_t DurationOfPeriod () const;
+ const std::vector<uint32_t>& ReceivedBytesPerTrace () const;
+
+ void SetStartOfPeriod (std::string startOfPeriod);
+ void SetDurationOfPeriod (uint64_t duration);
+ void AddReceivedBytes (uint32_t numberOfBytes);
+
+ private:
+ std::string startOfPeriod;
+ uint64_t durationOfPeriod;
+ std::vector<uint32_t> receivedBytesPerTrace;
+ };
+ }
+}
+
+#endif /* THROUGHPUTMEASUREMENT_H_ */
diff --git a/libdash/source/mpd/AbstractMPDElement.cpp b/libdash/source/mpd/AbstractMPDElement.cpp
new file mode 100644
index 00000000..146d1776
--- /dev/null
+++ b/libdash/source/mpd/AbstractMPDElement.cpp
@@ -0,0 +1,41 @@
+/*
+ * AbstractMPDElement.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 "AbstractMPDElement.h"
+
+using namespace dash::mpd;
+using namespace dash::xml;
+
+AbstractMPDElement::AbstractMPDElement ()
+{
+}
+AbstractMPDElement::~AbstractMPDElement ()
+{
+ for(size_t i = 0; i < this->additionalSubNodes.size(); i++)
+ delete(this->additionalSubNodes.at(i));
+}
+
+const std::vector<INode *> AbstractMPDElement::GetAdditionalSubNodes () const
+{
+ return this->additionalSubNodes;
+}
+const std::map<std::string, std::string> AbstractMPDElement::GetRawAttributes () const
+{
+ return this->rawAttributes;
+}
+void AbstractMPDElement::AddAdditionalSubNode (INode *node)
+{
+ this->additionalSubNodes.push_back(node);
+}
+void AbstractMPDElement::AddRawAttributes (std::map<std::string, std::string> attributes)
+{
+ this->rawAttributes = attributes;
+} \ No newline at end of file
diff --git a/libdash/source/mpd/AbstractMPDElement.h b/libdash/source/mpd/AbstractMPDElement.h
new file mode 100644
index 00000000..b4235087
--- /dev/null
+++ b/libdash/source/mpd/AbstractMPDElement.h
@@ -0,0 +1,41 @@
+/*
+ * AbstractMPDElement.h
+ *****************************************************************************
+ * 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.
+ *****************************************************************************/
+
+#ifndef ABSTRACTMPDELEMENT_H_
+#define ABSTRACTMPDELEMENT_H_
+
+#include "config.h"
+
+#include "IMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class AbstractMPDElement : public virtual IMPDElement
+ {
+ public:
+ AbstractMPDElement ();
+ virtual ~AbstractMPDElement ();
+
+ virtual const std::vector<xml::INode *> GetAdditionalSubNodes () const;
+ virtual const std::map<std::string, std::string> GetRawAttributes () const;
+ virtual void AddAdditionalSubNode (xml::INode * node);
+ virtual void AddRawAttributes (std::map<std::string, std::string> attributes);
+
+ private:
+ std::vector<xml::INode *> additionalSubNodes;
+ std::map<std::string, std::string> rawAttributes;
+ };
+ }
+}
+
+#endif /* ABSTRACTMPDELEMENT_H_ */
diff --git a/libdash/source/mpd/AdaptationSet.cpp b/libdash/source/mpd/AdaptationSet.cpp
new file mode 100644
index 00000000..b1a0331f
--- /dev/null
+++ b/libdash/source/mpd/AdaptationSet.cpp
@@ -0,0 +1,343 @@
+/*
+ * AdaptationSet.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "AdaptationSet.h"
+#include <cstdlib>
+
+using namespace dash::mpd;
+
+AdaptationSet::AdaptationSet () :
+ segmentBase(NULL),
+ segmentList(NULL),
+ segmentTemplate(NULL),
+ xlinkHref(""),
+ xlinkActuate("onRequest"),
+ id(0),
+ lang(""),
+ contentType(""),
+ par(""),
+ minBandwidth(0),
+ maxBandwidth(0),
+ minWidth(0),
+ maxWidth(0),
+ minHeight(0),
+ maxHeight(0),
+ minFramerate(""),
+ maxFramerate(""),
+ segmentAlignmentIsBool(true),
+ subsegmentAlignmentIsBool(true),
+ usesSegmentAlignment(false),
+ usesSubsegmentAlignment(false),
+ segmentAlignment(0),
+ subsegmentAlignment(0),
+ isBitstreamSwitching(false)
+{
+}
+AdaptationSet::~AdaptationSet ()
+{
+ for(size_t i = 0; i < this->accessibility.size(); i++)
+ delete(this->accessibility.at(i));
+ for(size_t i = 0; i < this->role.size(); i++)
+ delete(this->role.at(i));
+ for(size_t i = 0; i < this->rating.size(); i++)
+ delete(this->rating.at(i));
+ for(size_t i = 0; i < this->viewpoint.size(); i++)
+ delete(this->viewpoint.at(i));
+ for(size_t i = 0; i < this->contentComponent.size(); i++)
+ delete(this->contentComponent.at(i));
+ for(size_t i = 0; i < this->baseURLs.size(); i++)
+ delete(this->baseURLs.at(i));
+ for(size_t i = 0; i < this->representation.size(); i++)
+ delete(this->representation.at(i));
+
+ delete(segmentBase);
+ delete(segmentList);
+ delete(segmentTemplate);
+}
+
+const std::vector<IDescriptor *>& AdaptationSet::GetAccessibility () const
+{
+ return (std::vector<IDescriptor *> &) this->accessibility;
+}
+void AdaptationSet::AddAccessibity (Descriptor *accessibility)
+{
+ this->accessibility.push_back(accessibility);
+}
+const std::vector<IDescriptor *>& AdaptationSet::GetRole () const
+{
+ return (std::vector<IDescriptor *> &) this->role;
+}
+void AdaptationSet::AddRole (Descriptor *role)
+{
+ this->role.push_back(role);
+}
+const std::vector<IDescriptor *>& AdaptationSet::GetRating () const
+{
+ return (std::vector<IDescriptor *> &) this->rating;
+}
+void AdaptationSet::AddRating (Descriptor *rating)
+{
+ this->rating.push_back(rating);
+}
+const std::vector<IDescriptor *>& AdaptationSet::GetViewpoint () const
+{
+ return (std::vector<IDescriptor *> &) this->viewpoint;
+}
+void AdaptationSet::AddViewpoint (Descriptor *viewpoint)
+{
+ this->viewpoint.push_back(viewpoint);
+}
+const std::vector<IContentComponent *>& AdaptationSet::GetContentComponent () const
+{
+ return (std::vector<IContentComponent *> &) this->contentComponent;
+}
+void AdaptationSet::AddContentComponent (ContentComponent *contentComponent)
+{
+ this->contentComponent.push_back(contentComponent);
+}
+const std::vector<IBaseUrl *>& AdaptationSet::GetBaseURLs () const
+{
+ return (std::vector<IBaseUrl *> &) this->baseURLs;
+}
+void AdaptationSet::AddBaseURL (BaseUrl *baseUrl)
+{
+ this->baseURLs.push_back(baseUrl);
+}
+ISegmentBase* AdaptationSet::GetSegmentBase () const
+{
+ return this->segmentBase;
+}
+void AdaptationSet::SetSegmentBase (SegmentBase *segmentBase)
+{
+ this->segmentBase = segmentBase;
+}
+ISegmentList* AdaptationSet::GetSegmentList () const
+{
+ return this->segmentList;
+}
+void AdaptationSet::SetSegmentList (SegmentList *segmentList)
+{
+ this->segmentList = segmentList;
+}
+ISegmentTemplate* AdaptationSet::GetSegmentTemplate () const
+{
+ return this->segmentTemplate;
+}
+void AdaptationSet::SetSegmentTemplate (SegmentTemplate *segmentTemplate)
+{
+ this->segmentTemplate = segmentTemplate;
+}
+const std::vector<IRepresentation *>& AdaptationSet::GetRepresentation () const
+{
+ return (std::vector<IRepresentation *> &) this->representation;
+}
+void AdaptationSet::AddRepresentation (Representation *representation)
+{
+ this->representation.push_back(representation);
+}
+const std::string& AdaptationSet::GetXlinkHref () const
+{
+ return this->xlinkHref;
+}
+void AdaptationSet::SetXlinkHref (const std::string& xlinkHref)
+{
+ this->xlinkHref = xlinkHref;
+}
+const std::string& AdaptationSet::GetXlinkActuate () const
+{
+ return this->xlinkActuate;
+}
+void AdaptationSet::SetXlinkActuate (const std::string& xlinkActuate)
+{
+ this->xlinkActuate = xlinkActuate;
+}
+uint32_t AdaptationSet::GetId () const
+{
+ return this->id;
+}
+void AdaptationSet::SetId (uint32_t id)
+{
+ this->id = id;
+}
+uint32_t AdaptationSet::GetGroup () const
+{
+ return this->group;
+}
+void AdaptationSet::SetGroup (uint32_t group)
+{
+ this->group = group;
+}
+const std::string& AdaptationSet::GetLang () const
+{
+ return this->lang;
+}
+void AdaptationSet::SetLang (const std::string& lang)
+{
+ this->lang = lang;
+}
+const std::string& AdaptationSet::GetContentType () const
+{
+ return this->contentType;
+}
+void AdaptationSet::SetContentType (const std::string& contentType)
+{
+ this->contentType = contentType;
+}
+const std::string& AdaptationSet::GetPar () const
+{
+ return this->par;
+}
+void AdaptationSet::SetPar (const std::string& par)
+{
+ this->par = par;
+}
+uint32_t AdaptationSet::GetMinBandwidth () const
+{
+ return this->minBandwidth;
+}
+void AdaptationSet::SetMinBandwidth (uint32_t minBandwidth)
+{
+ this->minBandwidth = minBandwidth;
+}
+uint32_t AdaptationSet::GetMaxBandwidth () const
+{
+ return this->maxBandwidth;
+}
+void AdaptationSet::SetMaxBandwidth (uint32_t maxBandwidth)
+{
+ this->maxBandwidth = maxBandwidth;
+}
+uint32_t AdaptationSet::GetMinWidth () const
+{
+ return this->minWidth;
+}
+void AdaptationSet::SetMinWidth (uint32_t minWidth)
+{
+ this->minWidth = minWidth;
+}
+uint32_t AdaptationSet::GetMaxWidth () const
+{
+ return this->maxWidth;
+}
+void AdaptationSet::SetMaxWidth (uint32_t maxWidth)
+{
+ this->maxWidth = maxWidth;
+}
+uint32_t AdaptationSet::GetMinHeight () const
+{
+ return this->minHeight;
+}
+void AdaptationSet::SetMinHeight (uint32_t minHeight)
+{
+ this->minHeight = minHeight;
+}
+uint32_t AdaptationSet::GetMaxHeight () const
+{
+ return this->maxHeight;
+}
+void AdaptationSet::SetMaxHeight (uint32_t maxHeight)
+{
+ this->maxHeight = maxHeight;
+}
+const std::string& AdaptationSet::GetMinFramerate () const
+{
+ return this->minFramerate;
+}
+void AdaptationSet::SetMinFramerate (const std::string& minFramerate)
+{
+ this->minFramerate = minFramerate;
+}
+const std::string& AdaptationSet::GetMaxFramerate () const
+{
+ return this->maxFramerate;
+}
+void AdaptationSet::SetMaxFramerate (const std::string& maxFramerate)
+{
+ this->maxFramerate = maxFramerate;
+}
+bool AdaptationSet::SegmentAlignmentIsBoolValue () const
+{
+ return this->segmentAlignmentIsBool;
+}
+bool AdaptationSet::SubsegmentAlignmentIsBoolValue () const
+{
+ return this->subsegmentAlignmentIsBool;
+}
+bool AdaptationSet::HasSegmentAlignment () const
+{
+ return this->usesSegmentAlignment;
+}
+bool AdaptationSet::HasSubsegmentAlignment () const
+{
+ return this->usesSubsegmentAlignment;
+}
+uint32_t AdaptationSet::GetSegmentAligment () const
+{
+ return this->segmentAlignment;
+}
+void AdaptationSet::SetSegmentAlignment (const std::string& segmentAlignment)
+{
+ if (segmentAlignment == "true" || segmentAlignment == "True" || segmentAlignment == "TRUE")
+ {
+ this->segmentAlignmentIsBool = true;
+ this->usesSegmentAlignment = true;
+ return;
+ }
+
+ if (segmentAlignment == "false" || segmentAlignment == "False" || segmentAlignment == "FALSE")
+ {
+ this->segmentAlignmentIsBool = true;
+ this->usesSegmentAlignment = false;
+ return;
+ }
+
+ this->segmentAlignmentIsBool = false;
+ this->segmentAlignment = strtoul(segmentAlignment.c_str(), NULL, 10);
+}
+void AdaptationSet::SetSubsegmentAlignment (const std::string& subsegmentAlignment)
+{
+ if (subsegmentAlignment == "true" || subsegmentAlignment == "True" || subsegmentAlignment == "TRUE")
+ {
+ this->subsegmentAlignmentIsBool = true;
+ this->usesSubsegmentAlignment = true;
+ return;
+ }
+
+ if (subsegmentAlignment == "false" || subsegmentAlignment == "False" || subsegmentAlignment == "FALSE")
+ {
+ this->subsegmentAlignmentIsBool = true;
+ this->usesSubsegmentAlignment = false;
+ return;
+ }
+
+ this->subsegmentAlignmentIsBool = false;
+ this->subsegmentAlignment = strtoul(subsegmentAlignment.c_str(), NULL, 10);
+}
+uint32_t AdaptationSet::GetSubsegmentAlignment () const
+{
+ return this->subsegmentAlignment;
+}
+uint8_t AdaptationSet::GetSubsegmentStartsWithSAP () const
+{
+ return this->subsegmentStartsWithSAP;
+}
+void AdaptationSet::SetSubsegmentStartsWithSAP (uint8_t subsegmentStartsWithSAP)
+{
+ this->subsegmentStartsWithSAP = subsegmentStartsWithSAP;
+}
+bool AdaptationSet::GetBitstreamSwitching () const
+{
+ return this->isBitstreamSwitching;
+}
+void AdaptationSet::SetBitstreamSwitching (bool value)
+{
+ this->isBitstreamSwitching = value;
+}
diff --git a/libdash/source/mpd/AdaptationSet.h b/libdash/source/mpd/AdaptationSet.h
new file mode 100644
index 00000000..5a17cf4a
--- /dev/null
+++ b/libdash/source/mpd/AdaptationSet.h
@@ -0,0 +1,138 @@
+/*
+ * AdaptationSet.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef ADAPTATIONSET_H_
+#define ADAPTATIONSET_H_
+
+#include "config.h"
+
+#include "IAdaptationSet.h"
+#include "RepresentationBase.h"
+#include "BaseUrl.h"
+#include "SegmentBase.h"
+#include "SegmentList.h"
+#include "SegmentTemplate.h"
+#include "ContentComponent.h"
+#include "Representation.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class AdaptationSet : public IAdaptationSet, public RepresentationBase
+ {
+ public:
+ AdaptationSet ();
+ virtual ~AdaptationSet ();
+
+ const std::vector<IDescriptor *>& GetAccessibility () const;
+ const std::vector<IDescriptor *>& GetRole () const;
+ const std::vector<IDescriptor *>& GetRating () const;
+ const std::vector<IDescriptor *>& GetViewpoint () const;
+ const std::vector<IContentComponent *>& GetContentComponent () const;
+ const std::vector<IBaseUrl *>& GetBaseURLs () const;
+ ISegmentBase* GetSegmentBase () const;
+ ISegmentList* GetSegmentList () const;
+ ISegmentTemplate* GetSegmentTemplate () const;
+ const std::vector<IRepresentation *>& GetRepresentation () const;
+ const std::string& GetXlinkHref () const;
+ const std::string& GetXlinkActuate () const;
+ uint32_t GetId () const;
+ uint32_t GetGroup () const;
+ const std::string& GetLang () const;
+ const std::string& GetContentType () const;
+ const std::string& GetPar () const;
+ uint32_t GetMinBandwidth () const;
+ uint32_t GetMaxBandwidth () const;
+ uint32_t GetMinWidth () const;
+ uint32_t GetMaxWidth () const;
+ uint32_t GetMinHeight () const;
+ uint32_t GetMaxHeight () const;
+ const std::string& GetMinFramerate () const;
+ const std::string& GetMaxFramerate () const;
+ bool SegmentAlignmentIsBoolValue () const;
+ bool HasSegmentAlignment () const;
+ uint32_t GetSegmentAligment () const;
+ bool SubsegmentAlignmentIsBoolValue () const;
+ bool HasSubsegmentAlignment () const;
+ uint32_t GetSubsegmentAlignment () const;
+ uint8_t GetSubsegmentStartsWithSAP () const;
+ bool GetBitstreamSwitching () const;
+
+ void AddAccessibity (Descriptor *accessibility);
+ void AddRole (Descriptor *role);
+ void AddRating (Descriptor *rating);
+ void AddViewpoint (Descriptor *viewpoint);
+ void AddContentComponent (ContentComponent *contentComponent);
+ void AddBaseURL (BaseUrl *baseURL);
+ void SetSegmentBase (SegmentBase *segmentBase);
+ void SetSegmentList (SegmentList *segmentList);
+ void SetSegmentTemplate (SegmentTemplate *segmentTemplate);
+ void AddRepresentation (Representation* representation);
+ void SetXlinkHref (const std::string& xlinkHref);
+ void SetXlinkActuate (const std::string& xlinkActuate);
+ void SetId (uint32_t id);
+ void SetGroup (uint32_t group);
+ void SetLang (const std::string& lang);
+ void SetContentType (const std::string& contentType);
+ void SetPar (const std::string& par);
+ void SetMinBandwidth (uint32_t minBandwidth);
+ void SetMaxBandwidth (uint32_t maxBandwidth);
+ void SetMinWidth (uint32_t minWidth);
+ void SetMaxWidth (uint32_t maxWidth);
+ void SetMinHeight (uint32_t minHeight);
+ void SetMaxHeight (uint32_t maxHeight);
+ void SetMinFramerate (const std::string& minFramerate);
+ void SetMaxFramerate (const std::string& maxFramerate);
+ void SetSegmentAlignment (const std::string& segmentAlignment);
+ void SetSubsegmentAlignment (const std::string& subsegmentAlignment);
+ void SetSubsegmentStartsWithSAP (uint8_t subsegmentStartsWithSAP);
+ void SetBitstreamSwitching (bool value);
+
+ private:
+ std::vector<Descriptor *> accessibility;
+ std::vector<Descriptor *> role;
+ std::vector<Descriptor *> rating;
+ std::vector<Descriptor *> viewpoint;
+ std::vector<ContentComponent *> contentComponent;
+ std::vector<BaseUrl *> baseURLs;
+ SegmentBase *segmentBase;
+ SegmentList *segmentList;
+ SegmentTemplate *segmentTemplate;
+ std::vector<Representation *> representation;
+ std::string xlinkHref;
+ std::string xlinkActuate;
+ uint32_t id;
+ uint32_t group;
+ std::string lang;
+ std::string contentType;
+ std::string par;
+ uint32_t minBandwidth;
+ uint32_t maxBandwidth;
+ uint32_t minWidth;
+ uint32_t maxWidth;
+ uint32_t minHeight;
+ uint32_t maxHeight;
+ std::string minFramerate;
+ std::string maxFramerate;
+ bool segmentAlignmentIsBool;
+ bool subsegmentAlignmentIsBool;
+ bool usesSegmentAlignment;
+ bool usesSubsegmentAlignment;
+ uint32_t segmentAlignment;
+ uint32_t subsegmentAlignment;
+ uint8_t subsegmentStartsWithSAP;
+ bool isBitstreamSwitching;
+ };
+ }
+}
+
+#endif /* ADAPTATIONSET_H_ */
diff --git a/libdash/source/mpd/BaseUrl.cpp b/libdash/source/mpd/BaseUrl.cpp
new file mode 100644
index 00000000..7bafe794
--- /dev/null
+++ b/libdash/source/mpd/BaseUrl.cpp
@@ -0,0 +1,60 @@
+/*
+ * BaseUrl.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "BaseUrl.h"
+
+using namespace dash::mpd;
+
+BaseUrl::BaseUrl () :
+ url(""),
+ serviceLocation(""),
+ byteRange("")
+{
+}
+BaseUrl::~BaseUrl ()
+{
+}
+
+const std::string& BaseUrl::GetUrl () const
+{
+ return this->url;
+}
+void BaseUrl::SetUrl (const std::string& url)
+{
+ this->url = url;
+}
+const std::string& BaseUrl::GetServiceLocation () const
+{
+ return this->serviceLocation;
+}
+void BaseUrl::SetServiceLocation (const std::string& serviceLocation)
+{
+ this->serviceLocation = serviceLocation;
+}
+const std::string& BaseUrl::GetByteRange () const
+{
+ return this->byteRange;
+}
+void BaseUrl::SetByteRange (const std::string& byteRange)
+{
+ this->byteRange = byteRange;
+}
+ISegment* BaseUrl::ToMediaSegment (const std::vector<IBaseUrl *>& baseurls) const
+{
+ Segment *seg = new Segment();
+
+ if(seg->Init(baseurls, this->url, this->byteRange, dash::metrics::MediaSegment))
+ return seg;
+
+ delete(seg);
+
+ return NULL;
+}
diff --git a/libdash/source/mpd/BaseUrl.h b/libdash/source/mpd/BaseUrl.h
new file mode 100644
index 00000000..0147c1ed
--- /dev/null
+++ b/libdash/source/mpd/BaseUrl.h
@@ -0,0 +1,49 @@
+/*
+ * BaseUrl.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef BASEURL_H_
+#define BASEURL_H_
+
+#include "config.h"
+
+#include "Segment.h"
+#include "IBaseUrl.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class BaseUrl : public IBaseUrl, public AbstractMPDElement
+ {
+ public:
+ BaseUrl ();
+ virtual ~BaseUrl();
+
+ const std::string& GetUrl () const;
+ const std::string& GetServiceLocation () const;
+ const std::string& GetByteRange () const;
+
+ void SetUrl (const std::string& url);
+ void SetServiceLocation (const std::string& serviceLocation);
+ void SetByteRange (const std::string& byteRange);
+
+ virtual ISegment* ToMediaSegment (const std::vector<IBaseUrl *>& baseurls) const;
+
+ private:
+ std::string url;
+ std::string serviceLocation;
+ std::string byteRange;
+ };
+ }
+}
+
+#endif /* BASEURL_H_ */
diff --git a/libdash/source/mpd/ContentComponent.cpp b/libdash/source/mpd/ContentComponent.cpp
new file mode 100644
index 00000000..ce3de857
--- /dev/null
+++ b/libdash/source/mpd/ContentComponent.cpp
@@ -0,0 +1,98 @@
+/*
+ * ContentComponent.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "ContentComponent.h"
+
+using namespace dash::mpd;
+
+ContentComponent::ContentComponent () :
+ id(0),
+ lang(""),
+ contentType(""),
+ par("")
+{
+}
+ContentComponent::~ContentComponent ()
+{
+ for(size_t i = 0; i < this->accessibility.size(); i++)
+ delete(this->accessibility.at(i));
+ for(size_t i = 0; i < this->role.size(); i++)
+ delete(this->role.at(i));
+ for(size_t i = 0; i < this->rating.size(); i++)
+ delete(this->rating.at(i));
+ for(size_t i = 0; i < this->viewpoint.size(); i++)
+ delete(this->viewpoint.at(i));
+}
+
+const std::vector<IDescriptor *>& ContentComponent::GetAccessibility () const
+{
+ return (std::vector<IDescriptor *> &)this->accessibility;
+}
+void ContentComponent::AddAccessibity (Descriptor *accessibility)
+{
+ this->accessibility.push_back(accessibility);
+}
+const std::vector<IDescriptor *>& ContentComponent::GetRole () const
+{
+ return (std::vector<IDescriptor *> &)this->role;
+}
+void ContentComponent::AddRole (Descriptor *role)
+{
+ this->role.push_back(role);
+}
+const std::vector<IDescriptor *>& ContentComponent::GetRating () const
+{
+ return (std::vector<IDescriptor *> &)this->rating;
+}
+void ContentComponent::AddRating (Descriptor *rating)
+{
+ this->rating.push_back(rating);
+}
+const std::vector<IDescriptor *>& ContentComponent::GetViewpoint () const
+{
+ return (std::vector<IDescriptor *> &)this->viewpoint;
+}
+void ContentComponent::AddViewpoint (Descriptor *viewpoint)
+{
+ this->viewpoint.push_back(viewpoint);
+}
+uint32_t ContentComponent::GetId () const
+{
+ return this->id;
+}
+void ContentComponent::SetId (uint32_t id)
+{
+ this->id = id;
+}
+const std::string& ContentComponent::GetLang () const
+{
+ return this->lang;
+}
+void ContentComponent::SetLang (const std::string& lang)
+{
+ this->lang = lang;
+}
+const std::string& ContentComponent::GetContentType () const
+{
+ return this->contentType;
+}
+void ContentComponent::SetContentType (const std::string& contentType)
+{
+ this->contentType = contentType;
+}
+const std::string& ContentComponent::GetPar () const
+{
+ return this->par;
+}
+void ContentComponent::SetPar (const std::string& par)
+{
+ this->par = par;
+}
diff --git a/libdash/source/mpd/ContentComponent.h b/libdash/source/mpd/ContentComponent.h
new file mode 100644
index 00000000..b59ab6d8
--- /dev/null
+++ b/libdash/source/mpd/ContentComponent.h
@@ -0,0 +1,62 @@
+/*
+ * ContentComponent.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef CONTENTCOMPONENT_H_
+#define CONTENTCOMPONENT_H_
+
+#include "config.h"
+
+#include "IContentComponent.h"
+#include "Descriptor.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class ContentComponent : public IContentComponent, public AbstractMPDElement
+ {
+ public:
+ ContentComponent ();
+ virtual ~ContentComponent ();
+
+ const std::vector<IDescriptor *>& GetAccessibility () const;
+ const std::vector<IDescriptor *>& GetRole () const;
+ const std::vector<IDescriptor *>& GetRating () const;
+ const std::vector<IDescriptor *>& GetViewpoint () const;
+ uint32_t GetId () const;
+ const std::string& GetLang () const;
+ const std::string& GetContentType () const;
+ const std::string& GetPar () const;
+
+ void AddAccessibity (Descriptor *accessibility);
+ void AddRole (Descriptor *role);
+ void AddRating (Descriptor *rating);
+ void AddViewpoint (Descriptor *viewpoint);
+ void SetId (uint32_t id);
+ void SetLang (const std::string& lang);
+ void SetContentType (const std::string& contentType);
+ void SetPar (const std::string& par);
+
+ private:
+ std::vector<Descriptor *> accessibility;
+ std::vector<Descriptor *> role;
+ std::vector<Descriptor *> rating;
+ std::vector<Descriptor *> viewpoint;
+ uint32_t id;
+ std::string lang;
+ std::string contentType;
+ std::string par;
+ };
+ }
+}
+
+#endif /* CONTENTCOMPONENT_H_ */
diff --git a/libdash/source/mpd/Descriptor.cpp b/libdash/source/mpd/Descriptor.cpp
new file mode 100644
index 00000000..c6eb787b
--- /dev/null
+++ b/libdash/source/mpd/Descriptor.cpp
@@ -0,0 +1,39 @@
+/*
+ * Descriptor.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Descriptor.h"
+
+using namespace dash::mpd;
+
+Descriptor::Descriptor () :
+ schemeIdUri (""),
+ value ("")
+{
+}
+Descriptor::~Descriptor ()
+{
+}
+const std::string& Descriptor::GetSchemeIdUri () const
+{
+ return this->schemeIdUri;
+}
+void Descriptor::SetSchemeIdUri (const std::string& schemeIdUri)
+{
+ this->schemeIdUri = schemeIdUri;
+}
+const std::string& Descriptor::GetValue () const
+{
+ return this->value;
+}
+void Descriptor::SetValue (const std::string& value)
+{
+ this->value = value;
+}
diff --git a/libdash/source/mpd/Descriptor.h b/libdash/source/mpd/Descriptor.h
new file mode 100644
index 00000000..5cb66b94
--- /dev/null
+++ b/libdash/source/mpd/Descriptor.h
@@ -0,0 +1,43 @@
+/*
+ * Descriptor.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef DESCRIPTOR_H_
+#define DESCRIPTOR_H_
+
+#include "config.h"
+
+#include "IDescriptor.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Descriptor : public IDescriptor, public AbstractMPDElement
+ {
+ public:
+ Descriptor ();
+ virtual ~Descriptor ();
+
+ const std::string& GetSchemeIdUri () const;
+ const std::string& GetValue () const;
+
+ void SetValue (const std::string& value);
+ void SetSchemeIdUri (const std::string& schemeIdUri);
+
+ private:
+ std::string schemeIdUri;
+ std::string value;
+ };
+ }
+}
+
+#endif /* DESCRIPTOR_H_ */
diff --git a/libdash/source/mpd/MPD.cpp b/libdash/source/mpd/MPD.cpp
new file mode 100644
index 00000000..84e0e614
--- /dev/null
+++ b/libdash/source/mpd/MPD.cpp
@@ -0,0 +1,212 @@
+/*
+ * MPD.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "MPD.h"
+
+using namespace dash::mpd;
+using namespace dash::metrics;
+
+MPD::MPD () :
+ id(""),
+ type("static"),
+ availabilityStarttime(""),
+ availabilityEndtime(""),
+ mediaPresentationDuration(""),
+ minimumUpdatePeriod(""),
+ minBufferTime(""),
+ timeShiftBufferDepth(""),
+ suggestedPresentationDelay(""),
+ maxSegmentDuration(""),
+ maxSubsegmentDuration("")
+{
+}
+MPD::~MPD ()
+{
+ for(size_t i = 0; i < this->programInformations.size(); i++)
+ delete(this->programInformations.at(i));
+ for(size_t i = 0; i < this->metrics.size(); i++)
+ delete(this->metrics.at(i));
+ for(size_t i = 0; i < this->periods.size(); i++)
+ delete(this->periods.at(i));
+ for(size_t i = 0; i < this->baseUrls.size(); i++)
+ delete(this->baseUrls.at(i));
+}
+
+const std::vector<IProgramInformation *>& MPD::GetProgramInformations () const
+{
+ return (std::vector<IProgramInformation *> &) this->programInformations;
+}
+void MPD::AddProgramInformation (ProgramInformation *programInformation)
+{
+ this->programInformations.push_back(programInformation);
+}
+const std::vector<IBaseUrl*>& MPD::GetBaseUrls () const
+{
+ return (std::vector<IBaseUrl*> &) this->baseUrls;
+}
+void MPD::AddBaseUrl (BaseUrl *url)
+{
+ this->baseUrls.push_back(url);
+}
+const std::vector<std::string>& MPD::GetLocations () const
+{
+ return this->locations;
+}
+void MPD::AddLocation (const std::string& location)
+{
+ this->locations.push_back(location);
+}
+const std::vector<IPeriod*>& MPD::GetPeriods () const
+{
+ return (std::vector<IPeriod*> &) this->periods;
+}
+void MPD::AddPeriod (Period *period)
+{
+ this->periods.push_back(period);
+}
+const std::vector<IMetrics *>& MPD::GetMetrics () const
+{
+ return (std::vector<IMetrics *> &) this->metrics;
+}
+void MPD::AddMetrics (Metrics *metrics)
+{
+ this->metrics.push_back(metrics);
+}
+const std::string& MPD::GetId () const
+{
+ return this->id;
+}
+void MPD::SetId (const std::string& id)
+{
+ this->id = id;
+}
+const std::vector<std::string>& MPD::GetProfiles () const
+{
+ return this->profiles;
+}
+void MPD::SetProfiles (const std::string& profiles)
+{
+ dash::helpers::String::Split(profiles, ',', this->profiles);
+}
+const std::string& MPD::GetType () const
+{
+ return this->type;
+}
+void MPD::SetType (const std::string& type)
+{
+ this->type = type;
+}
+const std::string& MPD::GetAvailabilityStarttime () const
+{
+ return this->availabilityStarttime;
+}
+void MPD::SetAvailabilityStarttime (const std::string& availabilityStarttime)
+{
+ this->availabilityStarttime = availabilityStarttime;
+}
+const std::string& MPD::GetAvailabilityEndtime () const
+{
+ return this->availabilityEndtime;
+}
+void MPD::SetAvailabilityEndtime (const std::string& availabilityEndtime)
+{
+ this->availabilityEndtime = availabilityEndtime;
+}
+const std::string& MPD::GetMediaPresentationDuration () const
+{
+ return this->mediaPresentationDuration;
+}
+void MPD::SetMediaPresentationDuration (const std::string& mediaPresentationDuration)
+{
+ this->mediaPresentationDuration = mediaPresentationDuration;
+}
+const std::string& MPD::GetMinimumUpdatePeriod () const
+{
+ return this->minimumUpdatePeriod;
+}
+void MPD::SetMinimumUpdatePeriod (const std::string& minimumUpdatePeriod)
+{
+ this->minimumUpdatePeriod = minimumUpdatePeriod;
+}
+const std::string& MPD::GetMinBufferTime () const
+{
+ return this->minBufferTime;
+}
+void MPD::SetMinBufferTime (const std::string& minBufferTime)
+{
+ this->minBufferTime = minBufferTime;
+}
+const std::string& MPD::GetTimeShiftBufferDepth () const
+{
+ return this->timeShiftBufferDepth;
+}
+void MPD::SetTimeShiftBufferDepth (const std::string& timeShiftBufferDepth)
+{
+ this->timeShiftBufferDepth = timeShiftBufferDepth;
+}
+const std::string& MPD::GetSuggestedPresentationDelay () const
+{
+ return this->suggestedPresentationDelay;
+}
+void MPD::SetSuggestedPresentationDelay (const std::string& suggestedPresentationDelay)
+{
+ this->suggestedPresentationDelay = suggestedPresentationDelay;
+}
+const std::string& MPD::GetMaxSegmentDuration () const
+{
+ return this->maxSegmentDuration;
+}
+void MPD::SetMaxSegmentDuration (const std::string& maxSegmentDuration)
+{
+ this->maxSegmentDuration = maxSegmentDuration;
+}
+const std::string& MPD::GetMaxSubsegmentDuration () const
+{
+ return this->maxSubsegmentDuration;
+}
+void MPD::SetMaxSubsegmentDuration (const std::string& maxSubsegmentDuration)
+{
+ this->maxSubsegmentDuration = maxSubsegmentDuration;
+}
+IBaseUrl* MPD::GetMPDPathBaseUrl () const
+{
+ return this->mpdPathBaseUrl;
+}
+void MPD::SetMPDPathBaseUrl (BaseUrl *mpdPath)
+{
+ this->mpdPathBaseUrl = mpdPath;
+}
+uint32_t MPD::GetFetchTime () const
+{
+ return this->fetchTime;
+}
+void MPD::SetFetchTime (uint32_t fetchTimeInSec)
+{
+ this->fetchTime = fetchTimeInSec;
+}
+
+
+const std::vector<ITCPConnection *>& MPD::GetTCPConnectionList () const
+{
+ return (std::vector<ITCPConnection *> &) this->tcpConnections;
+}
+void MPD::AddTCPConnection (TCPConnection *tcpConn)
+{
+ this->tcpConnections.push_back(tcpConn);
+}
+const std::vector<IHTTPTransaction *>& MPD::GetHTTPTransactionList () const
+{
+ return (std::vector<IHTTPTransaction *> &) this->httpTransactions;
+}
+void MPD::AddHTTPTransaction (HTTPTransaction *httpTransAct)
+{
+ this->httpTransactions.push_back(httpTransAct);
+}
diff --git a/libdash/source/mpd/MPD.h b/libdash/source/mpd/MPD.h
new file mode 100644
index 00000000..9bcb38af
--- /dev/null
+++ b/libdash/source/mpd/MPD.h
@@ -0,0 +1,107 @@
+/*
+ * MPD.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef MPD_H_
+#define MPD_H_
+
+#include "config.h"
+
+#include "IMPD.h"
+#include "ProgramInformation.h"
+#include "BaseUrl.h"
+#include "Period.h"
+#include "Metrics.h"
+#include "AbstractMPDElement.h"
+#include "../metrics/HTTPTransaction.h"
+#include "../metrics/TCPConnection.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class MPD : public IMPD, public AbstractMPDElement
+ {
+ public:
+ MPD ();
+ virtual ~MPD();
+
+ const std::vector<IProgramInformation *>& GetProgramInformations () const;
+ const std::vector<IBaseUrl *>& GetBaseUrls () const;
+ const std::vector<std::string>& GetLocations () const;
+ const std::vector<IPeriod *>& GetPeriods () const;
+ const std::vector<IMetrics *>& GetMetrics () const;
+ const std::string& GetId () const;
+ const std::vector<std::string>& GetProfiles () const;
+ const std::string& GetType () const;
+ const std::string& GetAvailabilityStarttime () const;
+ const std::string& GetAvailabilityEndtime () const;
+ const std::string& GetMediaPresentationDuration () const;
+ const std::string& GetMinimumUpdatePeriod () const;
+ const std::string& GetMinBufferTime () const;
+ const std::string& GetTimeShiftBufferDepth () const;
+ const std::string& GetSuggestedPresentationDelay () const;
+ const std::string& GetMaxSegmentDuration () const;
+ const std::string& GetMaxSubsegmentDuration () const;
+ IBaseUrl* GetMPDPathBaseUrl () const;
+ uint32_t GetFetchTime () const;
+
+ const std::vector<dash::metrics::ITCPConnection *>& GetTCPConnectionList () const;
+ const std::vector<dash::metrics::IHTTPTransaction *>& GetHTTPTransactionList () const;
+ void AddTCPConnection (dash::metrics::TCPConnection *tcpConn);
+ void AddHTTPTransaction (dash::metrics::HTTPTransaction *httpTransAct);
+
+ void AddProgramInformation (ProgramInformation *programInformation);
+ void AddBaseUrl (BaseUrl *url);
+ void AddLocation (const std::string& location);
+ void AddPeriod (Period *period);
+ void AddMetrics (Metrics *metrics);
+ void SetId (const std::string& id);
+ void SetProfiles (const std::string& profiles);
+ void SetType (const std::string& type);
+ void SetAvailabilityStarttime (const std::string& availabilityStarttime);
+ void SetAvailabilityEndtime (const std::string& availabilityEndtime);
+ void SetMediaPresentationDuration (const std::string& mediaPresentationDuration);
+ void SetMinimumUpdatePeriod (const std::string& minimumUpdatePeriod);
+ void SetMinBufferTime (const std::string& minBufferTime);
+ void SetTimeShiftBufferDepth (const std::string& timeShiftBufferDepth);
+ void SetSuggestedPresentationDelay (const std::string& suggestedPresentationDelay);
+ void SetMaxSegmentDuration (const std::string& maxSegmentDuration);
+ void SetMaxSubsegmentDuration (const std::string& maxSubsegmentDuration);
+ void SetMPDPathBaseUrl (BaseUrl *path);
+ void SetFetchTime (uint32_t fetchTimeInSec);
+
+ private:
+ std::vector<ProgramInformation *> programInformations;
+ std::vector<BaseUrl *> baseUrls;
+ std::vector<std::string> locations;
+ std::vector<Period *> periods;
+ std::vector<Metrics *> metrics;
+ std::string id;
+ std::vector<std::string> profiles;
+ std::string type;
+ std::string availabilityStarttime;
+ std::string availabilityEndtime;
+ std::string mediaPresentationDuration;
+ std::string minimumUpdatePeriod;
+ std::string minBufferTime;
+ std::string timeShiftBufferDepth;
+ std::string suggestedPresentationDelay;
+ std::string maxSegmentDuration;
+ std::string maxSubsegmentDuration;
+ BaseUrl *mpdPathBaseUrl;
+ uint32_t fetchTime;
+
+ std::vector<dash::metrics::TCPConnection *> tcpConnections;
+ std::vector<dash::metrics::HTTPTransaction *> httpTransactions;
+ };
+ }
+}
+#endif /* MPD_H_ */
diff --git a/libdash/source/mpd/Metrics.cpp b/libdash/source/mpd/Metrics.cpp
new file mode 100644
index 00000000..8e64dec4
--- /dev/null
+++ b/libdash/source/mpd/Metrics.cpp
@@ -0,0 +1,51 @@
+/*
+ * Metrics.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "../mpd/Metrics.h"
+
+using namespace dash::mpd;
+
+Metrics::Metrics () :
+ metrics("")
+{
+}
+Metrics::~Metrics ()
+{
+ for(size_t i = 0; i < this->reportings.size(); i++)
+ delete(this->reportings.at(i));
+ for(size_t i = 0; i < this->ranges.size(); i++)
+ delete(this->ranges.at(i));
+}
+
+const std::vector<IDescriptor *>& Metrics::GetReportings () const
+{
+ return (std::vector<IDescriptor *> &)this->reportings;
+}
+void Metrics::AddReporting (Descriptor *reporting)
+{
+ this->reportings.push_back(reporting);
+}
+const std::vector<IRange *>& Metrics::GetRanges () const
+{
+ return (std::vector<IRange *> &)this->ranges;
+}
+void Metrics::AddRange (Range *range)
+{
+ this->ranges.push_back(range);
+}
+const std::string& Metrics::GetMetrics () const
+{
+ return this->metrics;
+}
+void Metrics::SetMetrics (const std::string& metrics)
+{
+ this->metrics = metrics;
+}
diff --git a/libdash/source/mpd/Metrics.h b/libdash/source/mpd/Metrics.h
new file mode 100644
index 00000000..c879f829
--- /dev/null
+++ b/libdash/source/mpd/Metrics.h
@@ -0,0 +1,51 @@
+/*
+ * Metrics.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef METRICS_H_
+#define METRICS_H_
+
+#include "config.h"
+
+#include <string>
+#include <vector>
+
+#include "IMetrics.h"
+#include "Descriptor.h"
+#include "Range.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Metrics : public IMetrics, public AbstractMPDElement
+ {
+ public:
+ Metrics ();
+ virtual ~Metrics ();
+
+ const std::vector<IDescriptor *>& GetReportings () const;
+ const std::vector<IRange *>& GetRanges () const;
+ const std::string& GetMetrics () const;
+
+ void AddReporting (Descriptor *reporting);
+ void AddRange (Range *range);
+ void SetMetrics (const std::string& metrics);
+
+ private:
+ std::vector<Descriptor *> reportings;
+ std::vector<Range *> ranges;
+ std::string metrics;
+ };
+ }
+}
+
+#endif /* METRICS_H_ */
diff --git a/libdash/source/mpd/MultipleSegmentBase.cpp b/libdash/source/mpd/MultipleSegmentBase.cpp
new file mode 100644
index 00000000..ccfba515
--- /dev/null
+++ b/libdash/source/mpd/MultipleSegmentBase.cpp
@@ -0,0 +1,60 @@
+/*
+ * MultipleSegmentBase.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "MultipleSegmentBase.h"
+
+using namespace dash::mpd;
+
+MultipleSegmentBase::MultipleSegmentBase () :
+ bitstreamSwitching(NULL),
+ segmentTimeline(NULL),
+ duration(0),
+ startNumber(1)
+{
+}
+MultipleSegmentBase::~MultipleSegmentBase ()
+{
+ delete(this->segmentTimeline);
+ delete(this->bitstreamSwitching);
+}
+
+const ISegmentTimeline * MultipleSegmentBase::GetSegmentTimeline () const
+{
+ return (ISegmentTimeline *) this->segmentTimeline;
+}
+void MultipleSegmentBase::SetSegmentTimeline (SegmentTimeline *segmentTimeline)
+{
+ this->segmentTimeline = segmentTimeline;
+}
+const IURLType* MultipleSegmentBase::GetBitstreamSwitching () const
+{
+ return this->bitstreamSwitching;
+}
+void MultipleSegmentBase::SetBitstreamSwitching (URLType *bitstreamSwitching)
+{
+ this->bitstreamSwitching = bitstreamSwitching;
+}
+uint32_t MultipleSegmentBase::GetDuration () const
+{
+ return this->duration;
+}
+void MultipleSegmentBase::SetDuration (uint32_t duration)
+{
+ this->duration = duration;
+}
+uint32_t MultipleSegmentBase::GetStartNumber () const
+{
+ return this->startNumber;
+}
+void MultipleSegmentBase::SetStartNumber (uint32_t startNumber)
+{
+ this->startNumber = startNumber;
+}
diff --git a/libdash/source/mpd/MultipleSegmentBase.h b/libdash/source/mpd/MultipleSegmentBase.h
new file mode 100644
index 00000000..386672ce
--- /dev/null
+++ b/libdash/source/mpd/MultipleSegmentBase.h
@@ -0,0 +1,51 @@
+/*
+ * MultipleSegmentBase.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef MULTIPLESEGMENTBASE_H_
+#define MULTIPLESEGMENTBASE_H_
+
+#include "config.h"
+
+#include "IMultipleSegmentBase.h"
+#include "SegmentBase.h"
+#include "SegmentTimeline.h"
+#include "URLType.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class MultipleSegmentBase : public virtual IMultipleSegmentBase, public SegmentBase
+ {
+ public:
+ MultipleSegmentBase ();
+ virtual ~MultipleSegmentBase ();
+
+ const ISegmentTimeline* GetSegmentTimeline () const;
+ const IURLType* GetBitstreamSwitching () const;
+ uint32_t GetDuration () const;
+ uint32_t GetStartNumber () const;
+
+ void SetSegmentTimeline (SegmentTimeline *segmentTimeline);
+ void SetBitstreamSwitching (URLType *bitstreamSwitching);
+ void SetDuration (uint32_t duration);
+ void SetStartNumber (uint32_t startNumber);
+
+ protected:
+ SegmentTimeline *segmentTimeline;
+ URLType *bitstreamSwitching;
+ uint32_t duration;
+ uint32_t startNumber;
+ };
+ }
+}
+
+#endif /* MULTIPLESEGMENTBASE_H_ */
diff --git a/libdash/source/mpd/Period.cpp b/libdash/source/mpd/Period.cpp
new file mode 100644
index 00000000..291677ea
--- /dev/null
+++ b/libdash/source/mpd/Period.cpp
@@ -0,0 +1,137 @@
+/*
+ * Period.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Period.h"
+
+using namespace dash::mpd;
+
+Period::Period () :
+ segmentBase(NULL),
+ segmentList(NULL),
+ segmentTemplate(NULL),
+ xlinkActuate("onRequest"),
+ xlinkHref(""),
+ id(""),
+ start(""),
+ duration(""),
+ isBitstreamSwitching(false)
+{
+}
+Period::~Period ()
+{
+ for(size_t i = 0; i < this->baseURLs.size(); i++)
+ delete(this->baseURLs.at(i));
+ for(size_t i = 0; i < this->adaptationSets.size(); i++)
+ delete(this->adaptationSets.at(i));
+ for(size_t i = 0; i < this->subsets.size(); i++)
+ delete(this->subsets.at(i));
+ delete(segmentBase);
+ delete(segmentList);
+ delete(segmentTemplate);
+}
+
+const std::vector<IBaseUrl *>& Period::GetBaseURLs () const
+{
+ return (std::vector<IBaseUrl *> &) this->baseURLs;
+}
+void Period::AddBaseURL (BaseUrl *baseUrl)
+{
+ this->baseURLs.push_back(baseUrl);
+}
+ISegmentBase* Period::GetSegmentBase () const
+{
+ return this->segmentBase;
+}
+void Period::SetSegmentBase (SegmentBase *segmentBase)
+{
+ this->segmentBase = segmentBase;
+}
+ISegmentList* Period::GetSegmentList () const
+{
+ return this->segmentList;
+}
+void Period::SetSegmentList (SegmentList *segmentList)
+{
+ this->segmentList = segmentList;
+}
+ISegmentTemplate* Period::GetSegmentTemplate () const
+{
+ return this->segmentTemplate;
+}
+void Period::SetSegmentTemplate (SegmentTemplate *segmentTemplate)
+{
+ this->segmentTemplate = segmentTemplate;
+}
+const std::vector<IAdaptationSet*>& Period::GetAdaptationSets () const
+{
+ return (std::vector<IAdaptationSet*> &) this->adaptationSets;
+}
+void Period::AddAdaptationSet (AdaptationSet *adaptationSet)
+{
+ if(adaptationSet != NULL)
+ this->adaptationSets.push_back(adaptationSet);
+}
+const std::vector<ISubset *>& Period::GetSubsets () const
+{
+ return (std::vector<ISubset *> &) this->subsets;
+}
+void Period::AddSubset (Subset *subset)
+{
+ this->subsets.push_back(subset);
+}
+const std::string& Period::GetXlinkHref () const
+{
+ return this->xlinkHref;
+}
+void Period::SetXlinkHref (const std::string& xlinkHref)
+{
+ this->xlinkHref = xlinkHref;
+}
+const std::string& Period::GetXlinkActuate () const
+{
+ return this->xlinkActuate;
+}
+void Period::SetXlinkActuate (const std::string& xlinkActuate)
+{
+ this->xlinkActuate = xlinkActuate;
+}
+const std::string& Period::GetId () const
+{
+ return this->id;
+}
+void Period::SetId (const std::string& id)
+{
+ this->id = id;
+}
+const std::string& Period::GetStart () const
+{
+ return this->start;
+}
+void Period::SetStart (const std::string& start)
+{
+ this->start = start;
+}
+const std::string& Period::GetDuration () const
+{
+ return this->duration;
+}
+void Period::SetDuration (const std::string& duration)
+{
+ this->duration = duration;
+}
+bool Period::GetBitstreamSwitching () const
+{
+ return this->isBitstreamSwitching;
+}
+void Period::SetBitstreamSwitching (bool value)
+{
+ this->isBitstreamSwitching = value;
+}
diff --git a/libdash/source/mpd/Period.h b/libdash/source/mpd/Period.h
new file mode 100644
index 00000000..9e97f0cb
--- /dev/null
+++ b/libdash/source/mpd/Period.h
@@ -0,0 +1,79 @@
+/*
+ * Period.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef PERIOD_H_
+#define PERIOD_H_
+
+#include "config.h"
+
+#include "IPeriod.h"
+#include "BaseUrl.h"
+#include "AdaptationSet.h"
+#include "Subset.h"
+#include "SegmentBase.h"
+#include "SegmentList.h"
+#include "SegmentTemplate.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Period : public IPeriod, public AbstractMPDElement
+ {
+ public:
+ Period ();
+ virtual ~Period ();
+
+ const std::vector<IBaseUrl *>& GetBaseURLs () const;
+ ISegmentBase* GetSegmentBase () const;
+ ISegmentList* GetSegmentList () const;
+ ISegmentTemplate* GetSegmentTemplate () const;
+ const std::vector<IAdaptationSet *>& GetAdaptationSets () const;
+ const std::vector<ISubset *>& GetSubsets () const;
+ const std::string& GetXlinkHref () const;
+ const std::string& GetXlinkActuate () const;
+ const std::string& GetId () const;
+ const std::string& GetStart () const;
+ const std::string& GetDuration () const;
+ bool GetBitstreamSwitching () const;
+
+ void AddBaseURL (BaseUrl *baseURL);
+ void SetSegmentBase (SegmentBase *segmentBase);
+ void SetSegmentList (SegmentList *segmentList);
+ void SetSegmentTemplate (SegmentTemplate *segmentTemplate);
+ void AddAdaptationSet (AdaptationSet *AdaptationSet);
+ void AddSubset (Subset *subset);
+ void SetXlinkHref (const std::string& xlinkHref);
+ void SetXlinkActuate (const std::string& xlinkActuate);
+ void SetId (const std::string& id);
+ void SetStart (const std::string& start);
+ void SetDuration (const std::string& duration);
+ void SetBitstreamSwitching (bool value);
+
+ private:
+ std::vector<BaseUrl *> baseURLs;
+ SegmentBase *segmentBase;
+ SegmentList *segmentList;
+ SegmentTemplate *segmentTemplate;
+ std::vector<AdaptationSet *> adaptationSets;
+ std::vector<Subset *> subsets;
+ std::string xlinkHref;
+ std::string xlinkActuate;
+ std::string id;
+ std::string start;
+ std::string duration;
+ bool isBitstreamSwitching;
+ };
+ }
+}
+
+#endif /* PERIOD_H_ */
diff --git a/libdash/source/mpd/ProgramInformation.cpp b/libdash/source/mpd/ProgramInformation.cpp
new file mode 100644
index 00000000..2ba0d6ff
--- /dev/null
+++ b/libdash/source/mpd/ProgramInformation.cpp
@@ -0,0 +1,67 @@
+/*
+ * ProgramInformation.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "ProgramInformation.h"
+
+using namespace dash::mpd;
+
+ProgramInformation::ProgramInformation () :
+ title(""),
+ source(""),
+ copyright(""),
+ lang(""),
+ moreInformationURL("")
+{
+}
+ProgramInformation::~ProgramInformation ()
+{
+}
+
+const std::string& ProgramInformation::GetTitle () const
+{
+ return this->title;
+}
+void ProgramInformation::SetTitle (const std::string& title)
+{
+ this->title = title;
+}
+const std::string& ProgramInformation::GetSource () const
+{
+ return this->source;
+}
+void ProgramInformation::SetSource (const std::string& source)
+{
+ this->source = source;
+}
+const std::string& ProgramInformation::GetCopyright () const
+{
+ return this->copyright;
+}
+void ProgramInformation::SetCopyright (const std::string& copyright)
+{
+ this->copyright = copyright;
+}
+const std::string& ProgramInformation::GetLang () const
+{
+ return this->lang;
+}
+void ProgramInformation::SetLang (const std::string& lang)
+{
+ this->lang = lang;
+}
+const std::string& ProgramInformation::GetMoreInformationURL () const
+{
+ return this->moreInformationURL;
+}
+void ProgramInformation::SetMoreInformationURL (const std::string& moreInfoURL)
+{
+ this->moreInformationURL = moreInfoURL;
+}
diff --git a/libdash/source/mpd/ProgramInformation.h b/libdash/source/mpd/ProgramInformation.h
new file mode 100644
index 00000000..9b12f33d
--- /dev/null
+++ b/libdash/source/mpd/ProgramInformation.h
@@ -0,0 +1,52 @@
+/*
+ * ProgramInformation.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef PROGRAMINFORMATION_H_
+#define PROGRAMINFORMATION_H_
+
+#include "config.h"
+
+#include "IProgramInformation.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class ProgramInformation : public IProgramInformation, public AbstractMPDElement
+ {
+ public:
+ ProgramInformation ();
+ virtual ~ProgramInformation ();
+
+ const std::string& GetTitle () const;
+ const std::string& GetSource () const;
+ const std::string& GetCopyright () const;
+ const std::string& GetLang () const;
+ const std::string& GetMoreInformationURL () const;
+
+ void SetTitle (const std::string& title);
+ void SetSource (const std::string& source);
+ void SetCopyright (const std::string& copyright);
+ void SetLang (const std::string& lang);
+ void SetMoreInformationURL (const std::string& moreInformationURL);
+
+ private:
+ std::string title;
+ std::string source;
+ std::string copyright;
+ std::string lang;
+ std::string moreInformationURL;
+ };
+ }
+}
+
+#endif /* PROGRAMINFORMATION_H_ */
diff --git a/libdash/source/mpd/Range.cpp b/libdash/source/mpd/Range.cpp
new file mode 100644
index 00000000..6f0aed9f
--- /dev/null
+++ b/libdash/source/mpd/Range.cpp
@@ -0,0 +1,40 @@
+/*
+ * Range.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Range.h"
+
+using namespace dash::mpd;
+
+Range::Range () :
+ starttime(""),
+ duration("")
+{
+}
+Range::~Range ()
+{
+}
+
+const std::string& Range::GetStarttime () const
+{
+ return this->starttime;
+}
+void Range::SetStarttime (const std::string& starttime)
+{
+ this->starttime = starttime;
+}
+const std::string& Range::GetDuration () const
+{
+ return this->duration;
+}
+void Range::SetDuration (const std::string& duration)
+{
+ this->duration = duration;
+}
diff --git a/libdash/source/mpd/Range.h b/libdash/source/mpd/Range.h
new file mode 100644
index 00000000..f847b096
--- /dev/null
+++ b/libdash/source/mpd/Range.h
@@ -0,0 +1,42 @@
+/*
+ * Range.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef RANGE_H_
+#define RANGE_H_
+
+#include "config.h"
+
+#include "IRange.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Range : public IRange
+ {
+ public:
+ Range ();
+ virtual ~Range ();
+
+ const std::string& GetStarttime () const;
+ const std::string& GetDuration () const;
+
+ void SetStarttime (const std::string& start);
+ void SetDuration (const std::string& duration);
+
+ private:
+ std::string starttime;
+ std::string duration;
+ };
+ }
+}
+
+#endif /* RANGE_H_ */
diff --git a/libdash/source/mpd/Representation.cpp b/libdash/source/mpd/Representation.cpp
new file mode 100644
index 00000000..fab7b493
--- /dev/null
+++ b/libdash/source/mpd/Representation.cpp
@@ -0,0 +1,116 @@
+/*
+ * Representation.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Representation.h"
+
+using namespace dash::mpd;
+
+Representation::Representation () :
+ segmentBase (NULL),
+ segmentList (NULL),
+ segmentTemplate (NULL),
+ id(""),
+ bandwidth (0),
+ qualityRanking (0)
+{
+}
+Representation::~Representation ()
+{
+ for(size_t i = 0; i < this->baseURLs.size(); i++)
+ delete(this->baseURLs.at(i));
+ for(size_t i = 0; i < this->subRepresentations.size(); i++)
+ delete(this->subRepresentations.at(i));
+
+ delete(this->segmentTemplate);
+ delete(this->segmentBase);
+ delete(this->segmentList);
+}
+
+const std::vector<IBaseUrl *>& Representation::GetBaseURLs () const
+{
+ return (std::vector<IBaseUrl *> &) this->baseURLs;
+}
+void Representation::AddBaseURL (BaseUrl *baseUrl)
+{
+ this->baseURLs.push_back(baseUrl);
+}
+const std::vector<ISubRepresentation *>& Representation::GetSubRepresentations () const
+{
+ return (std::vector<ISubRepresentation *> &) this->subRepresentations;
+}
+void Representation::AddSubRepresentation (SubRepresentation *subRepresentation)
+{
+ this->subRepresentations.push_back(subRepresentation);
+}
+ISegmentBase* Representation::GetSegmentBase () const
+{
+ return this->segmentBase;
+}
+void Representation::SetSegmentBase (SegmentBase *segmentBase)
+{
+ this->segmentBase = segmentBase;
+}
+ISegmentList* Representation::GetSegmentList () const
+{
+ return this->segmentList;
+}
+void Representation::SetSegmentList (SegmentList *segmentList)
+{
+ this->segmentList = segmentList;
+}
+ISegmentTemplate* Representation::GetSegmentTemplate () const
+{
+ return this->segmentTemplate;
+}
+void Representation::SetSegmentTemplate (SegmentTemplate *segmentTemplate)
+{
+ this->segmentTemplate = segmentTemplate;
+}
+const std::string& Representation::GetId () const
+{
+ return this->id;
+}
+void Representation::SetId (const std::string &id)
+{
+ this->id = id;
+}
+uint32_t Representation::GetBandwidth () const
+{
+ return this->bandwidth;
+}
+void Representation::SetBandwidth (uint32_t bandwidth)
+{
+ this->bandwidth = bandwidth;
+}
+uint32_t Representation::GetQualityRanking () const
+{
+ return this->qualityRanking;
+}
+void Representation::SetQualityRanking (uint32_t qualityRanking)
+{
+ this->qualityRanking = qualityRanking;
+}
+const std::vector<std::string>& Representation::GetDependencyId () const
+{
+ return this->dependencyId;
+}
+void Representation::SetDependencyId (const std::string &dependencyId)
+{
+ dash::helpers::String::Split(dependencyId, ' ', this->dependencyId);
+}
+const std::vector<std::string>& Representation::GetMediaStreamStructureId () const
+{
+ return this->mediaStreamStructureId;
+}
+void Representation::SetMediaStreamStructureId (const std::string& mediaStreamStructureId)
+{
+ dash::helpers::String::Split(mediaStreamStructureId, ' ', this->mediaStreamStructureId);
+}
diff --git a/libdash/source/mpd/Representation.h b/libdash/source/mpd/Representation.h
new file mode 100644
index 00000000..a56f5828
--- /dev/null
+++ b/libdash/source/mpd/Representation.h
@@ -0,0 +1,75 @@
+/*
+ * Representation.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef REPRESENTATION_H_
+#define REPRESENTATION_H_
+
+#include "config.h"
+
+#include "IRepresentation.h"
+#include "SegmentTemplate.h"
+#include "RepresentationBase.h"
+#include "BaseUrl.h"
+#include "SubRepresentation.h"
+#include "SegmentBase.h"
+#include "SegmentList.h"
+#include "../helpers/String.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Representation : public IRepresentation, public RepresentationBase
+ {
+ public:
+ Representation ();
+ virtual ~Representation ();
+
+ const std::vector<IBaseUrl *>& GetBaseURLs () const;
+ const std::vector<ISubRepresentation *>& GetSubRepresentations () const;
+ ISegmentBase* GetSegmentBase () const;
+ ISegmentList* GetSegmentList () const;
+ ISegmentTemplate* GetSegmentTemplate () const;
+ const std::string& GetId () const;
+ uint32_t GetBandwidth () const;
+ uint32_t GetQualityRanking () const;
+ const std::vector<std::string>& GetDependencyId () const;
+ const std::vector<std::string>& GetMediaStreamStructureId () const;
+
+
+ void AddBaseURL (BaseUrl *baseURL);
+ void AddSubRepresentation (SubRepresentation *subRepresentation);
+ void SetSegmentBase (SegmentBase *segmentBase);
+ void SetSegmentList (SegmentList *segmentList);
+ void SetSegmentTemplate (SegmentTemplate *segmentTemplate);
+ void SetId (const std::string &id);
+ void SetBandwidth (uint32_t bandwidth);
+ void SetQualityRanking (uint32_t qualityRanking);
+ void SetDependencyId (const std::string &dependencyId);
+ void SetMediaStreamStructureId (const std::string &mediaStreamStructureId);
+
+ private:
+ std::vector<BaseUrl *> baseURLs;
+ std::vector<SubRepresentation *> subRepresentations;
+ SegmentBase *segmentBase;
+ SegmentList *segmentList;
+ SegmentTemplate *segmentTemplate;
+ std::string id;
+ uint32_t bandwidth;
+ uint32_t qualityRanking;
+ std::vector<std::string> dependencyId;
+ std::vector<std::string> mediaStreamStructureId;
+
+ };
+ }
+}
+
+#endif /* REPRESENTATION_H_ */
diff --git a/libdash/source/mpd/RepresentationBase.cpp b/libdash/source/mpd/RepresentationBase.cpp
new file mode 100644
index 00000000..f7b8970c
--- /dev/null
+++ b/libdash/source/mpd/RepresentationBase.cpp
@@ -0,0 +1,175 @@
+/*
+ * RepresentationBase.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "RepresentationBase.h"
+
+using namespace dash::mpd;
+
+RepresentationBase::RepresentationBase () :
+ width(0),
+ height(0),
+ sar(""),
+ frameRate(""),
+ audioSamplingRate(""),
+ mimeType(""),
+ maximumSAPPeriod(0.0),
+ startWithSAP(0),
+ maxPlayoutRate(0.0),
+ codingDependency(false),
+ scanType("")
+{
+}
+RepresentationBase::~RepresentationBase ()
+{
+ for(size_t i = 0; i < this->framePacking.size(); i++)
+ delete(this->framePacking.at(i));
+ for(size_t i = 0; i < this->audioChannelConfiguration.size(); i++)
+ delete(this->audioChannelConfiguration.at(i));
+ for(size_t i = 0; i < this->contentProtection.size(); i++)
+ delete(this->contentProtection.at(i));
+}
+
+const std::vector<IDescriptor*>& RepresentationBase::GetFramePacking () const
+{
+ return (std::vector<IDescriptor*> &) this->framePacking;
+}
+void RepresentationBase::AddFramePacking (Descriptor *framePacking)
+{
+ this->framePacking.push_back(framePacking);
+}
+const std::vector<IDescriptor*>& RepresentationBase::GetAudioChannelConfiguration () const
+{
+ return (std::vector<IDescriptor*> &) this->audioChannelConfiguration;
+}
+void RepresentationBase::AddAudioChannelConfiguration (Descriptor *audioChannelConfiguration)
+{
+ this->audioChannelConfiguration.push_back(audioChannelConfiguration);
+}
+const std::vector<IDescriptor*>& RepresentationBase::GetContentProtection () const
+{
+ return (std::vector<IDescriptor*> &) this->contentProtection;
+}
+void RepresentationBase::AddContentProtection (Descriptor *contentProtection)
+{
+ this->contentProtection.push_back(contentProtection);
+}
+const std::vector<std::string>& RepresentationBase::GetProfiles () const
+{
+ return this->profiles;
+}
+void RepresentationBase::SetProfiles (const std::string& profiles)
+{
+ dash::helpers::String::Split(profiles, ',', this->profiles);
+}
+uint32_t RepresentationBase::GetWidth () const
+{
+ return this->width;
+}
+void RepresentationBase::SetWidth (uint32_t width)
+{
+ this->width = width;
+}
+uint32_t RepresentationBase::GetHeight () const
+{
+ return this->height;
+}
+void RepresentationBase::SetHeight (uint32_t height)
+{
+ this->height = height;
+}
+std::string RepresentationBase::GetSar () const
+{
+ return this->sar;
+}
+void RepresentationBase::SetSar (const std::string& sar)
+{
+ this->sar = sar;
+}
+std::string RepresentationBase::GetFrameRate () const
+{
+ return this->frameRate;
+}
+void RepresentationBase::SetFrameRate (const std::string& frameRate)
+{
+ this->frameRate = frameRate;
+}
+std::string RepresentationBase::GetAudioSamplingRate () const
+{
+ return this->audioSamplingRate;
+}
+void RepresentationBase::SetAudioSamplingRate (const std::string& audioSamplingRate)
+{
+ this->audioSamplingRate = audioSamplingRate;
+}
+std::string RepresentationBase::GetMimeType () const
+{
+ return this->mimeType;
+}
+void RepresentationBase::SetMimeType (const std::string& mimeType)
+{
+ this->mimeType = mimeType;
+}
+const std::vector<std::string>& RepresentationBase::GetSegmentProfiles () const
+{
+ return this->segmentProfiles;
+}
+void RepresentationBase::SetSegmentProfiles (const std::string& segmentProfiles)
+{
+ dash::helpers::String::Split(segmentProfiles, ',', this->segmentProfiles);
+}
+const std::vector<std::string>& RepresentationBase::GetCodecs () const
+{
+ return this->codecs;
+}
+void RepresentationBase::SetCodecs (const std::string& codecs)
+{
+ dash::helpers::String::Split(codecs, ',', this->codecs);
+}
+double RepresentationBase::GetMaximumSAPPeriod () const
+{
+ return this->maximumSAPPeriod;
+}
+void RepresentationBase::SetMaximumSAPPeriod (double maximumSAPPeriod)
+{
+ this->maximumSAPPeriod = maximumSAPPeriod;
+}
+uint8_t RepresentationBase::GetStartWithSAP () const
+{
+ return this->startWithSAP;
+}
+void RepresentationBase::SetStartWithSAP (uint8_t startWithSAP)
+{
+ this->startWithSAP = startWithSAP;
+}
+double RepresentationBase::GetMaxPlayoutRate () const
+{
+ return this->maxPlayoutRate;
+}
+void RepresentationBase::SetMaxPlayoutRate (double maxPlayoutRate)
+{
+ this->maxPlayoutRate = maxPlayoutRate;
+}
+bool RepresentationBase::HasCodingDependency () const
+{
+ return this->codingDependency;
+}
+void RepresentationBase::SetCodingDependency (bool codingDependency)
+{
+ this->codingDependency = codingDependency;
+}
+std::string RepresentationBase::GetScanType () const
+{
+ return this->scanType;
+}
+void RepresentationBase::SetScanType (const std::string& scanType)
+{
+ this->scanType = scanType;
+}
diff --git a/libdash/source/mpd/RepresentationBase.h b/libdash/source/mpd/RepresentationBase.h
new file mode 100644
index 00000000..bb7fd287
--- /dev/null
+++ b/libdash/source/mpd/RepresentationBase.h
@@ -0,0 +1,89 @@
+/*
+ * RepresentationBase.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef REPRESENTATIONBASE_H_
+#define REPRESENTATIONBASE_H_
+
+#include "config.h"
+
+#include "IRepresentationBase.h"
+#include "Descriptor.h"
+#include "../helpers/String.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class RepresentationBase : public virtual IRepresentationBase, public AbstractMPDElement
+ {
+ public:
+ RepresentationBase ();
+ virtual ~RepresentationBase ();
+
+ const std::vector<IDescriptor *>& GetFramePacking () const;
+ const std::vector<IDescriptor *>& GetAudioChannelConfiguration () const;
+ const std::vector<IDescriptor *>& GetContentProtection () const;
+ const std::vector<std::string>& GetProfiles () const;
+ uint32_t GetWidth () const;
+ uint32_t GetHeight () const;
+ std::string GetSar () const;
+ std::string GetFrameRate () const;
+ std::string GetAudioSamplingRate () const;
+ std::string GetMimeType () const;
+ const std::vector<std::string>& GetSegmentProfiles () const;
+ const std::vector<std::string>& GetCodecs () const;
+ double GetMaximumSAPPeriod () const;
+ uint8_t GetStartWithSAP () const;
+ double GetMaxPlayoutRate () const;
+ bool HasCodingDependency () const;
+ std::string GetScanType () const;
+
+ void AddFramePacking (Descriptor *framePacking);
+ void AddAudioChannelConfiguration (Descriptor *audioChannelConfiguration);
+ void AddContentProtection (Descriptor *contentProtection);
+ void SetProfiles (const std::string& profiles);
+ void SetWidth (uint32_t width);
+ void SetHeight (uint32_t height);
+ void SetSar (const std::string& sar);
+ void SetFrameRate (const std::string& frameRate);
+ void SetAudioSamplingRate (const std::string& audioSamplingRate);
+ void SetMimeType (const std::string& mimeType);
+ void SetSegmentProfiles (const std::string& segmentProfiles);
+ void SetCodecs (const std::string& codecs);
+ void SetMaximumSAPPeriod (double maximumSAPPeroid);
+ void SetStartWithSAP (uint8_t startWithSAP);
+ void SetMaxPlayoutRate (double maxPlayoutRate);
+ void SetCodingDependency (bool codingDependency);
+ void SetScanType (const std::string& scanType);
+
+ protected:
+ std::vector<Descriptor *> framePacking;
+ std::vector<Descriptor *> audioChannelConfiguration;
+ std::vector<Descriptor *> contentProtection;
+ std::vector<std::string> profiles;
+ uint32_t width;
+ uint32_t height;
+ std::string sar;
+ std::string frameRate;
+ std::string audioSamplingRate;
+ std::string mimeType;
+ std::vector<std::string> segmentProfiles;
+ std::vector<std::string> codecs;
+ double maximumSAPPeriod;
+ uint8_t startWithSAP;
+ double maxPlayoutRate;
+ bool codingDependency;
+ std::string scanType;
+ };
+ }
+}
+#endif /* REPRESENTATIONBASE_H_ */
diff --git a/libdash/source/mpd/Segment.cpp b/libdash/source/mpd/Segment.cpp
new file mode 100644
index 00000000..31200762
--- /dev/null
+++ b/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;
+}
diff --git a/libdash/source/mpd/Segment.h b/libdash/source/mpd/Segment.h
new file mode 100644
index 00000000..6f44a6f2
--- /dev/null
+++ b/libdash/source/mpd/Segment.h
@@ -0,0 +1,69 @@
+/*
+ * Segment.h
+ *****************************************************************************
+ * 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.
+ *****************************************************************************/
+
+#ifndef SEGMENT_H_
+#define SEGMENT_H_
+
+#include "config.h"
+
+#include "../network/AbstractChunk.h"
+#include "../helpers/Path.h"
+#include "ISegment.h"
+#include "IBaseUrl.h"
+#include "../metrics/HTTPTransaction.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Segment : public network::AbstractChunk, public virtual ISegment
+ {
+ public:
+ Segment ();
+ virtual ~Segment();
+
+ bool Init (const std::vector<IBaseUrl *>& baseurls, const std::string &uri,
+ const std::string &range, dash::metrics::HTTPTransactionType type);
+ std::string& AbsoluteURI ();
+ std::string& Host ();
+ size_t Port ();
+ std::string& Path ();
+ std::string& Range ();
+ size_t StartByte ();
+ size_t EndByte ();
+ bool HasByteRange ();
+ dash::metrics::HTTPTransactionType GetType ();
+
+ void AbsoluteURI (std::string uri);
+ void Host (std::string host);
+ void Port (size_t port);
+ void Path (std::string path);
+ void Range (std::string range);
+ void StartByte (size_t startByte);
+ void EndByte (size_t endByte);
+ void HasByteRange (bool hasByteRange);
+ void SetType (dash::metrics::HTTPTransactionType type);
+
+ private:
+ std::string absoluteuri;
+ std::string host;
+ size_t port;
+ std::string path;
+ std::string range;
+ size_t startByte;
+ size_t endByte;
+ bool hasByteRange;
+ dash::metrics::HTTPTransactionType type;
+ };
+ }
+}
+
+#endif /* SEGMENT_H_ */
diff --git a/libdash/source/mpd/SegmentBase.cpp b/libdash/source/mpd/SegmentBase.cpp
new file mode 100644
index 00000000..b1d890d9
--- /dev/null
+++ b/libdash/source/mpd/SegmentBase.cpp
@@ -0,0 +1,78 @@
+/*
+ * SegmentBase.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "SegmentBase.h"
+
+using namespace dash::mpd;
+
+SegmentBase::SegmentBase () :
+ initialization(NULL),
+ representationIndex(NULL),
+ timescale(1),
+ presentationTimeOffset(0),
+ indexRange(""),
+ indexRangeExact(false)
+{
+}
+SegmentBase::~SegmentBase ()
+{
+ delete(this->initialization);
+ delete(this->representationIndex);
+}
+
+const IURLType* SegmentBase::GetInitialization () const
+{
+ return this->initialization;
+}
+void SegmentBase::SetInitialization (URLType *initialization)
+{
+ this->initialization = initialization;
+}
+const IURLType* SegmentBase::GetRepresentationIndex () const
+{
+ return this->representationIndex;
+}
+void SegmentBase::SetRepresentationIndex (URLType *representationIndex)
+{
+ this->representationIndex = representationIndex;
+}
+uint32_t SegmentBase::GetTimescale () const
+{
+ return this->timescale;
+}
+void SegmentBase::SetTimescale (uint32_t timescale)
+{
+ this->timescale = timescale;
+}
+uint32_t SegmentBase::GetPresentationTimeOffset () const
+{
+ return this->presentationTimeOffset;
+}
+void SegmentBase::SetPresentationTimeOffset (uint32_t presentationTimeOffset)
+{
+ this->presentationTimeOffset = presentationTimeOffset;
+}
+const std::string& SegmentBase::GetIndexRange () const
+{
+ return this->indexRange;
+}
+void SegmentBase::SetIndexRange (const std::string& indexRange)
+{
+ this->indexRange = indexRange;
+}
+bool SegmentBase::HasIndexRangeExact () const
+{
+ return this->indexRangeExact;
+}
+void SegmentBase::SetIndexRangeExact (bool indexRangeExact)
+{
+ this->indexRangeExact = indexRangeExact;
+}
diff --git a/libdash/source/mpd/SegmentBase.h b/libdash/source/mpd/SegmentBase.h
new file mode 100644
index 00000000..d627eb04
--- /dev/null
+++ b/libdash/source/mpd/SegmentBase.h
@@ -0,0 +1,56 @@
+/*
+ * SegmentBase.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef SEGMENTBASE_H_
+#define SEGMENTBASE_H_
+
+#include "config.h"
+
+#include "ISegmentBase.h"
+#include "URLType.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class SegmentBase : public virtual ISegmentBase, public AbstractMPDElement
+ {
+ public:
+ SegmentBase ();
+ virtual ~SegmentBase ();
+
+ const IURLType* GetInitialization () const;
+ const IURLType* GetRepresentationIndex () const;
+ uint32_t GetTimescale () const;
+ uint32_t GetPresentationTimeOffset () const;
+ const std::string& GetIndexRange () const;
+ bool HasIndexRangeExact () const;
+
+ void SetInitialization (URLType *initialization);
+ void SetRepresentationIndex (URLType *representationIndex);
+ void SetTimescale (uint32_t timescale);
+ void SetPresentationTimeOffset (uint32_t presentationTimeOffset);
+ void SetIndexRange (const std::string& indexRange);
+ void SetIndexRangeExact (bool indexRangeExact);
+
+ protected:
+ URLType *initialization;
+ URLType *representationIndex;
+ uint32_t timescale;
+ uint32_t presentationTimeOffset;
+ std::string indexRange;
+ bool indexRangeExact;
+ };
+ }
+}
+
+#endif /* SEGMENTBASE_H_ */
diff --git a/libdash/source/mpd/SegmentList.cpp b/libdash/source/mpd/SegmentList.cpp
new file mode 100644
index 00000000..d96264cb
--- /dev/null
+++ b/libdash/source/mpd/SegmentList.cpp
@@ -0,0 +1,50 @@
+/*
+ * SegmentList.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "SegmentList.h"
+
+using namespace dash::mpd;
+
+SegmentList::SegmentList () :
+ xlinkHref(""),
+ xlinkActuate("onRequest")
+{
+}
+SegmentList::~SegmentList ()
+{
+ for (size_t i = 0; i < segmentURLs.size(); i++)
+ delete(this->segmentURLs.at(i));
+}
+
+const std::vector<ISegmentURL*>& SegmentList::GetSegmentURLs () const
+{
+ return (std::vector<ISegmentURL*> &) this->segmentURLs;
+}
+void SegmentList::AddSegmentURL (SegmentURL *segmentURL)
+{
+ this->segmentURLs.push_back(segmentURL);
+}
+const std::string& SegmentList::GetXlinkHref () const
+{
+ return this->xlinkHref;
+}
+void SegmentList::SetXlinkHref (const std::string& xlinkHref)
+{
+ this->xlinkHref = xlinkHref;
+}
+const std::string& SegmentList::GetXlinkActuate () const
+{
+ return this->xlinkActuate;
+}
+void SegmentList::SetXlinkActuate (const std::string& xlinkActuate)
+{
+ this->xlinkActuate = xlinkActuate;
+}
diff --git a/libdash/source/mpd/SegmentList.h b/libdash/source/mpd/SegmentList.h
new file mode 100644
index 00000000..b743c009
--- /dev/null
+++ b/libdash/source/mpd/SegmentList.h
@@ -0,0 +1,47 @@
+/*
+ * SegmentList.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef SEGMENTLIST_H_
+#define SEGMENTLIST_H_
+
+#include "config.h"
+
+#include "ISegmentList.h"
+#include "MultipleSegmentBase.h"
+#include "SegmentURL.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class SegmentList : public ISegmentList, public MultipleSegmentBase
+ {
+ public:
+ SegmentList ();
+ virtual ~SegmentList ();
+
+ const std::vector<ISegmentURL *>& GetSegmentURLs () const;
+ const std::string& GetXlinkHref () const;
+ const std::string& GetXlinkActuate () const;
+
+ void AddSegmentURL (SegmentURL *segmetURL);
+ void SetXlinkHref (const std::string& xlinkHref);
+ void SetXlinkActuate (const std::string& xlinkActuate);
+
+ private:
+ std::vector<SegmentURL *> segmentURLs;
+ std::string xlinkHref;
+ std::string xlinkActuate;
+ };
+ }
+}
+
+#endif /* SEGMENTLIST_H_ */
diff --git a/libdash/source/mpd/SegmentTemplate.cpp b/libdash/source/mpd/SegmentTemplate.cpp
new file mode 100644
index 00000000..b92c4692
--- /dev/null
+++ b/libdash/source/mpd/SegmentTemplate.cpp
@@ -0,0 +1,152 @@
+/*
+ * SegmentTemplate.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "SegmentTemplate.h"
+
+using namespace dash::mpd;
+using namespace dash::metrics;
+
+SegmentTemplate::SegmentTemplate () :
+ media(""),
+ index(""),
+ initialization(""),
+ bitstreamSwitching("")
+{
+}
+SegmentTemplate::~SegmentTemplate ()
+{
+}
+
+const std::string& SegmentTemplate::Getmedia () const
+{
+ return this->media;
+}
+void SegmentTemplate::SetMedia (const std::string& media)
+{
+ this->media = media;
+}
+const std::string& SegmentTemplate::Getindex () const
+{
+ return this->index;
+}
+void SegmentTemplate::SetIndex (const std::string& index)
+{
+ this->index = index;
+}
+const std::string& SegmentTemplate::Getinitialization () const
+{
+ return this->initialization;
+}
+void SegmentTemplate::SetInitialization (const std::string& initialization)
+{
+ this->initialization = initialization;
+}
+const std::string& SegmentTemplate::GetbitstreamSwitching () const
+{
+ return this->bitstreamSwitching;
+}
+void SegmentTemplate::SetBitstreamSwitching (const std::string& bitstreamSwitching)
+{
+ this->bitstreamSwitching = bitstreamSwitching;
+}
+ISegment* SegmentTemplate::ToInitializationSegment (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth) const
+{
+ return ToSegment(this->initialization, baseurls, representationID, bandwidth, dash::metrics::InitializationSegment);
+}
+ISegment* SegmentTemplate::ToBitstreamSwitchingSegment (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth) const
+{
+ return ToSegment(this->bitstreamSwitching, baseurls, representationID, bandwidth, dash::metrics::BitstreamSwitchingSegment);
+}
+ISegment* SegmentTemplate::GetMediaSegmentFromNumber (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const
+{
+ return ToSegment(this->media, baseurls, representationID, bandwidth, dash::metrics::MediaSegment, number);
+}
+ISegment* SegmentTemplate::GetIndexSegmentFromNumber (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const
+{
+ return ToSegment(this->index, baseurls, representationID, bandwidth, dash::metrics::IndexSegment, number);
+}
+ISegment* SegmentTemplate::GetMediaSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const
+{
+ return ToSegment(this->media, baseurls, representationID, bandwidth, dash::metrics::MediaSegment, 0, time);
+}
+ISegment* SegmentTemplate::GetIndexSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const
+{
+ return ToSegment(this->index, baseurls, representationID, bandwidth, dash::metrics::IndexSegment, 0, time);
+}
+std::string SegmentTemplate::ReplaceParameters (const std::string& uri, const std::string& representationID, uint32_t bandwidth, uint32_t number, uint32_t time) const
+{
+ std::vector<std::string> chunks;
+ std::string replacedUri = "";
+
+ dash::helpers::String::Split(uri, '$', chunks);
+
+ if (chunks.size() > 1)
+ {
+ for(size_t i = 0; i < chunks.size(); i++)
+ {
+ if ( chunks.at(i) == "RepresentationID") {
+ chunks.at(i) = representationID;
+ continue;
+ }
+
+ if (chunks.at(i).find("Bandwidth") == 0)
+ {
+ FormatChunk(chunks.at(i), bandwidth);
+ continue;
+ }
+
+ if (chunks.at(i).find("Number") == 0)
+ {
+ FormatChunk(chunks.at(i), number);
+ continue;
+ }
+
+ if (chunks.at(i).find("Time") == 0)
+ {
+ FormatChunk(chunks.at(i), time);
+ continue;
+ }
+ }
+
+ for(size_t i = 0; i < chunks.size(); i++)
+ replacedUri += chunks.at(i);
+
+ return replacedUri;
+ }
+ else
+ {
+ replacedUri = uri;
+ return replacedUri;
+ }
+}
+void SegmentTemplate::FormatChunk (std::string& uri, uint32_t number) const
+{
+ char formattedNumber [50];
+ size_t pos = 0;
+ std::string formatTag = "%01d";
+
+ if ( (pos = uri.find("%0")) != std::string::npos)
+ formatTag = uri.substr(pos).append("d");
+
+ sprintf(formattedNumber, formatTag.c_str(), number);
+ uri = formattedNumber;
+}
+ISegment* SegmentTemplate::ToSegment (const std::string& uri, const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, HTTPTransactionType type, uint32_t number, uint32_t time) const
+{
+ Segment *seg = new Segment();
+
+ if(seg->Init(baseurls, ReplaceParameters(uri, representationID, bandwidth, number, time), "", type))
+ return seg;
+
+ delete(seg);
+
+ return NULL;
+} \ No newline at end of file
diff --git a/libdash/source/mpd/SegmentTemplate.h b/libdash/source/mpd/SegmentTemplate.h
new file mode 100644
index 00000000..e5782a83
--- /dev/null
+++ b/libdash/source/mpd/SegmentTemplate.h
@@ -0,0 +1,61 @@
+/*
+ * SegmentTemplate.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef SEGMENTTEMPLATE_H_
+#define SEGMENTTEMPLATE_H_
+
+#include "config.h"
+
+#include "ISegmentTemplate.h"
+#include "MultipleSegmentBase.h"
+#include "../helpers/String.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class SegmentTemplate : public ISegmentTemplate, public MultipleSegmentBase
+ {
+ public:
+ SegmentTemplate ();
+ virtual ~SegmentTemplate ();
+
+ const std::string& Getmedia () const;
+ const std::string& Getindex () const;
+ const std::string& Getinitialization () const;
+ const std::string& GetbitstreamSwitching () const;
+ ISegment* ToInitializationSegment (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth) const;
+ ISegment* ToBitstreamSwitchingSegment (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth) const;
+ ISegment* GetMediaSegmentFromNumber (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const;
+ ISegment* GetIndexSegmentFromNumber (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const;
+ ISegment* GetMediaSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const;
+ ISegment* GetIndexSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const;
+
+ void SetMedia (const std::string& media);
+ void SetIndex (const std::string& index);
+ void SetInitialization (const std::string& initialization);
+ void SetBitstreamSwitching (const std::string& bitstreamSwichting);
+
+ private:
+ std::string ReplaceParameters (const std::string& uri, const std::string& representationID, uint32_t bandwidth, uint32_t number, uint32_t time) const;
+ void FormatChunk (std::string& uri, uint32_t number) const;
+ ISegment* ToSegment (const std::string& uri, const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth,
+ dash::metrics::HTTPTransactionType type, uint32_t number = 0, uint32_t time = 0) const;
+
+ std::string media;
+ std::string index;
+ std::string initialization;
+ std::string bitstreamSwitching;
+ };
+ }
+}
+
+#endif /* SEGMENTTEMPLATE_H_ */
diff --git a/libdash/source/mpd/SegmentTimeline.cpp b/libdash/source/mpd/SegmentTimeline.cpp
new file mode 100644
index 00000000..8a55dc46
--- /dev/null
+++ b/libdash/source/mpd/SegmentTimeline.cpp
@@ -0,0 +1,32 @@
+/*
+ * SegmentTimeline.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "SegmentTimeline.h"
+
+using namespace dash::mpd;
+
+SegmentTimeline::SegmentTimeline ()
+{
+}
+SegmentTimeline::~SegmentTimeline ()
+{
+ for (size_t i=0; i < this->timelines.size(); i++)
+ delete(this->timelines.at(i));
+}
+
+std::vector<ITimeline *>& SegmentTimeline::GetTimelines () const
+{
+ return (std::vector<ITimeline*> &) this->timelines;
+}
+void SegmentTimeline::AddTimeline (Timeline *timeline)
+{
+ this->timelines.push_back(timeline);
+} \ No newline at end of file
diff --git a/libdash/source/mpd/SegmentTimeline.h b/libdash/source/mpd/SegmentTimeline.h
new file mode 100644
index 00000000..2d0ff2f8
--- /dev/null
+++ b/libdash/source/mpd/SegmentTimeline.h
@@ -0,0 +1,40 @@
+/*
+ * SegmentTimeline.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef SEGMENTTIMELINE_H_
+#define SEGMENTTIMELINE_H_
+
+#include "config.h"
+
+#include "ISegmentTimeline.h"
+#include "AbstractMPDElement.h"
+#include "Timeline.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class SegmentTimeline : public ISegmentTimeline, public AbstractMPDElement
+ {
+ public:
+ SegmentTimeline ();
+ virtual ~SegmentTimeline ();
+
+ std::vector<ITimeline *>& GetTimelines () const;
+ void AddTimeline (Timeline *timeline);
+
+ private:
+ std::vector<ITimeline *> timelines;
+ };
+ }
+}
+
+#endif /* SEGMENTTIMELINE_H_ */
diff --git a/libdash/source/mpd/SegmentURL.cpp b/libdash/source/mpd/SegmentURL.cpp
new file mode 100644
index 00000000..765cc969
--- /dev/null
+++ b/libdash/source/mpd/SegmentURL.cpp
@@ -0,0 +1,90 @@
+/*
+ * SegmentURL.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "SegmentURL.h"
+
+using namespace dash::mpd;
+using namespace dash::helpers;
+
+SegmentURL::SegmentURL () :
+ mediaURI(""),
+ mediaRange(""),
+ indexURI(""),
+ indexRange(""),
+ bitrate(0)
+{
+}
+SegmentURL::~SegmentURL ()
+{
+}
+
+const std::string& SegmentURL::GetMediaURI () const
+{
+ return this->mediaURI;
+}
+void SegmentURL::SetMediaURI (const std::string& mediaURI)
+{
+ this->mediaURI = mediaURI;
+}
+const std::string& SegmentURL::GetMediaRange () const
+{
+ return this->mediaRange;
+}
+void SegmentURL::SetMediaRange (const std::string& mediaRange)
+{
+ this->mediaRange = mediaRange;
+}
+const std::string& SegmentURL::GetIndexURI () const
+{
+ return this->indexURI;
+}
+uint64_t SegmentURL::GetActualRate ()
+{
+ return this->bitrate;
+}
+void SegmentURL::SetIndexURI (const std::string& indexURI)
+{
+ this->indexURI = indexURI;
+}
+const std::string& SegmentURL::GetIndexRange () const
+{
+ return this->indexRange;
+}
+void SegmentURL::SetIndexRange (const std::string& indexRange)
+{
+ this->indexRange = indexRange;
+}
+void SegmentURL::SetBitrate (const std::string& bitrate)
+{
+ this->bitrate = atoi(bitrate.c_str());
+}
+ISegment* SegmentURL::ToMediaSegment (const std::vector<IBaseUrl *>& baseurls) const
+{
+ Segment *seg = new Segment();
+
+ if(seg->Init(baseurls, this->mediaURI, this->mediaRange, dash::metrics::MediaSegment))
+ return seg;
+
+ delete(seg);
+
+ return NULL;
+}
+ISegment* SegmentURL::ToIndexSegment (const std::vector<IBaseUrl *>& baseurls) const
+{
+ Segment *seg = new Segment();
+
+ if(seg->Init(baseurls, this->indexURI, this->indexRange, dash::metrics::IndexSegment))
+ return seg;
+
+ delete(seg);
+
+ return NULL;
+}
diff --git a/libdash/source/mpd/SegmentURL.h b/libdash/source/mpd/SegmentURL.h
new file mode 100644
index 00000000..7dfdb56b
--- /dev/null
+++ b/libdash/source/mpd/SegmentURL.h
@@ -0,0 +1,56 @@
+/*
+ * SegmentURL.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef SEGMENTURL_H_
+#define SEGMENTURL_H_
+
+#include "config.h"
+
+#include "ISegmentURL.h"
+#include "../helpers/Path.h"
+#include "Segment.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class SegmentURL : public ISegmentURL, public AbstractMPDElement
+ {
+ public:
+ SegmentURL ();
+ virtual ~SegmentURL();
+
+ const std::string& GetMediaURI () const;
+ const std::string& GetMediaRange () const;
+ const std::string& GetIndexURI () const;
+ const std::string& GetIndexRange () const;
+ uint64_t GetActualRate ();
+
+ ISegment* ToMediaSegment (const std::vector<IBaseUrl *>& baseurls) const;
+ ISegment* ToIndexSegment (const std::vector<IBaseUrl *>& baseurls) const;
+
+ void SetMediaURI (const std::string& mediaURI);
+ void SetMediaRange (const std::string& mediaRange);
+ void SetIndexURI (const std::string& indexURI);
+ void SetIndexRange (const std::string& indexRange);
+ void SetBitrate (const std::string& bitrate);
+ private:
+ std::string mediaURI;
+ std::string mediaRange;
+ std::string indexURI;
+ std::string indexRange;
+ int bitrate;
+ };
+ }
+}
+
+#endif /* SEGMENTURL_H_ */
diff --git a/libdash/source/mpd/SubRepresentation.cpp b/libdash/source/mpd/SubRepresentation.cpp
new file mode 100644
index 00000000..34b11e57
--- /dev/null
+++ b/libdash/source/mpd/SubRepresentation.cpp
@@ -0,0 +1,55 @@
+/*
+ * SubRepresentation.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "SubRepresentation.h"
+
+using namespace dash::mpd;
+
+SubRepresentation::SubRepresentation () :
+ level(0),
+ bandWidth(0)
+{
+}
+SubRepresentation::~SubRepresentation ()
+{
+}
+uint32_t SubRepresentation::GetLevel () const
+{
+ return this->level;
+}
+void SubRepresentation::SetLevel (uint32_t level)
+{
+ this->level = level;
+}
+const std::vector<uint32_t>& SubRepresentation::GetDependencyLevel () const
+{
+ return this->dependencyLevel;
+}
+void SubRepresentation::SetDependencyLevel (const std::string& dependencyLevel)
+{
+ dash::helpers::String::Split(dependencyLevel, ' ', this->dependencyLevel);
+}
+uint32_t SubRepresentation::GetBandWidth () const
+{
+ return this->bandWidth;
+}
+void SubRepresentation::SetBandWidth (uint32_t bandWidth)
+{
+ this->bandWidth = bandWidth;
+}
+const std::vector<std::string>& SubRepresentation::GetContentComponent () const
+{
+ return this->contentComponent;
+}
+void SubRepresentation::SetContentComponent (const std::string& contentComponent)
+{
+ dash::helpers::String::Split(contentComponent, ' ', this->contentComponent);
+}
diff --git a/libdash/source/mpd/SubRepresentation.h b/libdash/source/mpd/SubRepresentation.h
new file mode 100644
index 00000000..f14fbfae
--- /dev/null
+++ b/libdash/source/mpd/SubRepresentation.h
@@ -0,0 +1,50 @@
+/*
+ * SubRepresentation.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef SUBREPRESENTATION_H_
+#define SUBREPRESENTATION_H_
+
+#include "config.h"
+
+#include "ISubRepresentation.h"
+#include "Descriptor.h"
+#include "RepresentationBase.h"
+#include "../helpers/String.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class SubRepresentation : public ISubRepresentation, public RepresentationBase
+ {
+ public:
+ SubRepresentation ();
+ virtual ~SubRepresentation ();
+
+ uint32_t GetLevel () const;
+ const std::vector<uint32_t>& GetDependencyLevel () const;
+ uint32_t GetBandWidth () const;
+ const std::vector<std::string>& GetContentComponent () const;
+
+ void SetLevel (uint32_t level);
+ void SetDependencyLevel (const std::string& dependencyLevel);
+ void SetBandWidth (uint32_t bandWidth);
+ void SetContentComponent (const std::string& contentComponent);
+
+ protected:
+ uint32_t level;
+ std::vector<uint32_t> dependencyLevel;
+ uint32_t bandWidth;
+ std::vector<std::string> contentComponent;
+ };
+ }
+}
+#endif /* SUBREPRESENTATION_H_ */
diff --git a/libdash/source/mpd/Subset.cpp b/libdash/source/mpd/Subset.cpp
new file mode 100644
index 00000000..6b0d2df6
--- /dev/null
+++ b/libdash/source/mpd/Subset.cpp
@@ -0,0 +1,30 @@
+/*
+ * Subset.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Subset.h"
+
+using namespace dash::mpd;
+
+Subset::Subset ()
+{
+}
+Subset::~Subset ()
+{
+}
+
+const std::vector<uint32_t>& Subset::Contains () const
+{
+ return this->subset;
+}
+void Subset::SetSubset (const std::string& subset)
+{
+ dash::helpers::String::Split(subset, ' ', this->subset);
+}
diff --git a/libdash/source/mpd/Subset.h b/libdash/source/mpd/Subset.h
new file mode 100644
index 00000000..c56eb6e2
--- /dev/null
+++ b/libdash/source/mpd/Subset.h
@@ -0,0 +1,41 @@
+/*
+ * Subset.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef SUBSET_H_
+#define SUBSET_H_
+
+#include "config.h"
+
+#include "ISubset.h"
+#include "../helpers/String.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Subset : public ISubset, public AbstractMPDElement
+ {
+ public:
+ Subset ();
+ virtual ~Subset ();
+
+ const std::vector<uint32_t>& Contains () const;
+
+ void SetSubset (const std::string& subset);
+
+ private:
+ std::vector<uint32_t> subset;
+ };
+ }
+}
+
+#endif /* SUBSET_H_ */
diff --git a/libdash/source/mpd/Timeline.cpp b/libdash/source/mpd/Timeline.cpp
new file mode 100644
index 00000000..624c6585
--- /dev/null
+++ b/libdash/source/mpd/Timeline.cpp
@@ -0,0 +1,49 @@
+/*
+ * Timeline.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Timeline.h"
+
+using namespace dash::mpd;
+
+Timeline::Timeline () :
+ startTime(0),
+ duration(0),
+ repeatCount(0)
+{
+}
+Timeline::~Timeline ()
+{
+}
+
+uint32_t Timeline::GetStartTime () const
+{
+ return this->startTime;
+}
+void Timeline::SetStartTime (uint32_t startTime)
+{
+ this->startTime = startTime;
+}
+uint32_t Timeline::GetDuration () const
+{
+ return this->duration;
+}
+void Timeline::SetDuration (uint32_t duration)
+{
+ this->duration = duration;
+}
+uint32_t Timeline::GetRepeatCount () const
+{
+ return this->repeatCount;
+}
+void Timeline::SetRepeatCount (uint32_t repeatCount)
+{
+ this->repeatCount = repeatCount;
+} \ No newline at end of file
diff --git a/libdash/source/mpd/Timeline.h b/libdash/source/mpd/Timeline.h
new file mode 100644
index 00000000..3caa331f
--- /dev/null
+++ b/libdash/source/mpd/Timeline.h
@@ -0,0 +1,46 @@
+/*
+ * Timeline.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef TIMELINE_H_
+#define TIMELINE_H_
+
+#include "config.h"
+
+#include "ITimeline.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Timeline : public ITimeline, public AbstractMPDElement
+ {
+ public:
+ Timeline ();
+ virtual ~Timeline ();
+
+ uint32_t GetStartTime () const;
+ uint32_t GetDuration () const;
+ uint32_t GetRepeatCount () const;
+
+ void SetStartTime (uint32_t startTime);
+ void SetDuration (uint32_t duration);
+ void SetRepeatCount (uint32_t repeatCount);
+
+ private:
+ uint32_t startTime;
+ uint32_t duration;
+ uint32_t repeatCount;
+ };
+ }
+}
+
+#endif /* TIMELINE_H_ */
diff --git a/libdash/source/mpd/URLType.cpp b/libdash/source/mpd/URLType.cpp
new file mode 100644
index 00000000..699672e7
--- /dev/null
+++ b/libdash/source/mpd/URLType.cpp
@@ -0,0 +1,57 @@
+/*
+ * URLType.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "URLType.h"
+
+using namespace dash::mpd;
+using namespace dash::helpers;
+using namespace dash::metrics;
+
+URLType::URLType () :
+ sourceURL(""),
+ range("")
+{
+}
+URLType::~URLType ()
+{
+}
+
+const std::string& URLType::GetSourceURL () const
+{
+ return this->sourceURL;
+}
+void URLType::SetSourceURL (const std::string& sourceURL)
+{
+ this->sourceURL = sourceURL;
+}
+const std::string& URLType::GetRange () const
+{
+ return this->range;
+}
+void URLType::SetRange (const std::string& range)
+{
+ this->range = range;
+}
+void URLType::SetType (HTTPTransactionType type)
+{
+ this->type = type;
+}
+ISegment* URLType::ToSegment (const std::vector<IBaseUrl *>& baseurls) const
+{
+ Segment *seg = new Segment();
+
+ if(seg->Init(baseurls, this->sourceURL, this->range, this->type))
+ return seg;
+
+ delete(seg);
+
+ return NULL;
+}
diff --git a/libdash/source/mpd/URLType.h b/libdash/source/mpd/URLType.h
new file mode 100644
index 00000000..1fcd00c7
--- /dev/null
+++ b/libdash/source/mpd/URLType.h
@@ -0,0 +1,48 @@
+/*
+ * URLType.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef URLTYPE_H_
+#define URLTYPE_H_
+
+#include "config.h"
+
+#include "IURLType.h"
+#include "Segment.h"
+#include "../helpers/Path.h"
+#include "AbstractMPDElement.h"
+
+namespace dash
+{
+ namespace mpd
+ {
+ class URLType : public IURLType, public AbstractMPDElement
+ {
+ public:
+ URLType ();
+ virtual ~URLType ();
+
+ const std::string& GetSourceURL () const;
+ const std::string& GetRange () const;
+ ISegment* ToSegment (const std::vector<IBaseUrl *>& baseurls) const;
+
+ void SetSourceURL (const std::string& sourceURL);
+ void SetRange (const std::string& range);
+ void SetType (dash::metrics::HTTPTransactionType type);
+
+ private:
+ std::string sourceURL;
+ std::string range;
+ dash::metrics::HTTPTransactionType type;
+ };
+ }
+}
+
+#endif /* URLTYPE_H_ */
diff --git a/libdash/source/network/AbstractChunk.cpp b/libdash/source/network/AbstractChunk.cpp
new file mode 100644
index 00000000..35774efe
--- /dev/null
+++ b/libdash/source/network/AbstractChunk.cpp
@@ -0,0 +1,271 @@
+/*
+ * AbstractChunk.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "AbstractChunk.h"
+
+using namespace dash::network;
+using namespace dash::helpers;
+using namespace dash::metrics;
+
+uint32_t AbstractChunk::BLOCKSIZE = 32768;
+
+AbstractChunk::AbstractChunk () :
+ connection (NULL),
+ dlThread (NULL),
+ bytesDownloaded (0)
+{
+}
+AbstractChunk::~AbstractChunk ()
+{
+ this->AbortDownload();
+ this->blockStream.Clear();
+ DestroyThreadPortable(this->dlThread);
+}
+
+void AbstractChunk::AbortDownload ()
+{
+ this->stateManager.CheckAndSet(IN_PROGRESS, REQUEST_ABORT);
+ this->stateManager.CheckAndWait(REQUEST_ABORT, ABORTED);
+}
+bool AbstractChunk::StartDownload ()
+{
+ if(this->stateManager.State() != NOT_STARTED)
+ return false;
+ curl_global_init(CURL_GLOBAL_ALL);
+ this->curlm = curl_multi_init();
+
+ this->curl = curl_easy_init();
+ curl_easy_setopt(this->curl, CURLOPT_URL, this->AbsoluteURI().c_str());
+ curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, CurlResponseCallback);
+ curl_easy_setopt(this->curl, CURLOPT_WRITEDATA, (void *)this);
+ /* Debug Callback */
+ curl_easy_setopt(this->curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(this->curl, CURLOPT_DEBUGFUNCTION, CurlDebugCallback);
+ curl_easy_setopt(this->curl, CURLOPT_DEBUGDATA, (void *)this);
+ curl_easy_setopt(this->curl, CURLOPT_FAILONERROR, true);
+
+ if(this->HasByteRange())
+ curl_easy_setopt(this->curl, CURLOPT_RANGE, this->Range().c_str());
+
+ curl_multi_add_handle(this->curlm, this->curl);
+ this->dlThread = CreateThreadPortable (DownloadInternalConnection, this);
+
+ if(this->dlThread == NULL)
+ return false;
+
+ this->stateManager.State(IN_PROGRESS);
+
+ return true;
+}
+bool AbstractChunk::StartDownload (IConnection *connection)
+{
+ if(this->stateManager.State() != NOT_STARTED)
+ return false;
+
+ this->connection = connection;
+ this->dlThread = CreateThreadPortable (DownloadExternalConnection, this);
+
+ if(this->dlThread == NULL)
+ return false;
+
+ this->stateManager.State(IN_PROGRESS);
+
+
+ return true;
+}
+int AbstractChunk::Read (uint8_t *data, size_t len)
+{
+ return this->blockStream.GetBytes(data, len);
+}
+int AbstractChunk::Peek (uint8_t *data, size_t len)
+{
+ return this->blockStream.PeekBytes(data, len);
+}
+int AbstractChunk::Peek (uint8_t *data, size_t len, size_t offset)
+{
+ return this->blockStream.PeekBytes(data, len, offset);
+}
+void AbstractChunk::AttachDownloadObserver (IDownloadObserver *observer)
+{
+ this->observers.push_back(observer);
+ this->stateManager.Attach(observer);
+}
+void AbstractChunk::DetachDownloadObserver (IDownloadObserver *observer)
+{
+ uint32_t pos = -1;
+
+ for(size_t i = 0; i < this->observers.size(); i++)
+ if(this->observers.at(i) == observer)
+ pos = i;
+
+ if(pos != -1)
+ this->observers.erase(this->observers.begin() + pos);
+
+ this->stateManager.Detach(observer);
+}
+void* AbstractChunk::DownloadExternalConnection (void *abstractchunk)
+{
+ AbstractChunk *chunk = (AbstractChunk *) abstractchunk;
+ block_t *block = AllocBlock(chunk->BLOCKSIZE);
+ int ret = 0;
+
+ int count = 0;
+ do
+ {
+ ret = chunk->connection->Read(block->data, block->len, chunk);
+ if(ret > 0)
+ {
+ block_t *streamblock = AllocBlock(ret);
+ memcpy(streamblock->data, block->data, ret);
+ chunk->blockStream.PushBack(streamblock);
+ chunk->bytesDownloaded += ret;
+
+ // chunk->NotifyDownloadRateChanged();
+ }
+ if(chunk->stateManager.State() == REQUEST_ABORT)
+ ret = 0;
+ count += ret;
+ }while(ret);
+
+ double speed = chunk->connection->GetAverageDownloadingSpeed();
+ double time = chunk->connection->GetDownloadingTime();
+ chunk->NotifyDownloadRateChanged(speed);
+ chunk->NotifyDownloadTimeChanged(time);
+ DeleteBlock(block);
+
+ if(chunk->stateManager.State() == REQUEST_ABORT)
+ chunk->stateManager.State(ABORTED);
+ else
+ chunk->stateManager.State(COMPLETED);
+
+ chunk->blockStream.SetEOS(true);
+
+ return NULL;
+}
+void* AbstractChunk::DownloadInternalConnection (void *abstractchunk)
+{
+ AbstractChunk *chunk = (AbstractChunk *) abstractchunk;
+
+ //chunk->response = curl_easy_perform(chunk->curl);
+ int u =1;
+
+ while(chunk->stateManager.State() != REQUEST_ABORT && u)
+ {
+ curl_multi_perform(chunk->curlm, &u);
+ }
+ double speed;
+ double size;
+ double time;
+ curl_easy_getinfo(chunk->curl, CURLINFO_SPEED_DOWNLOAD,&speed);
+ curl_easy_getinfo(chunk->curl, CURLINFO_SIZE_DOWNLOAD, &size);
+ curl_easy_getinfo(chunk->curl, CURLINFO_TOTAL_TIME, &time);
+
+ //Speed is in Bps ==> *8 for the bps
+ speed = 8*speed;
+ //size = 8*size; //Uncomment for the size in bits.
+ chunk->NotifyDownloadRateChanged(speed);
+ chunk->NotifyDownloadTimeChanged(time);
+ curl_easy_cleanup(chunk->curl);
+ //curl_global_cleanup();
+
+ curl_multi_cleanup(chunk->curlm);
+ if(chunk->stateManager.State() == REQUEST_ABORT)
+ {
+ chunk->stateManager.State(ABORTED);
+ }
+ else
+ {
+ chunk->stateManager.State(COMPLETED);
+ }
+
+ chunk->blockStream.SetEOS(true);
+
+ return NULL;
+}
+void AbstractChunk::NotifyDownloadRateChanged (double bitrate)
+{
+ for(size_t i = 0; i < this->observers.size(); i++)
+ this->observers.at(i)->OnDownloadRateChanged((uint64_t)bitrate);
+}
+void AbstractChunk::NotifyDownloadTimeChanged (double dnltime)
+{
+ for(size_t i = 0; i < this->observers.size(); i++)
+ this->observers.at(i)->OnDownloadTimeChanged(dnltime);
+}
+size_t AbstractChunk::CurlResponseCallback (void *contents, size_t size, size_t nmemb, void *userp)
+{
+ size_t realsize = size * nmemb;
+ AbstractChunk *chunk = (AbstractChunk *)userp;
+
+ if(chunk->stateManager.State() == REQUEST_ABORT)
+ return 0;
+
+ block_t *block = AllocBlock(realsize);
+
+ memcpy(block->data, contents, realsize);
+ chunk->blockStream.PushBack(block);
+
+ chunk->bytesDownloaded += realsize;
+// chunk->NotifyDownloadRateChanged();
+
+ return realsize;
+}
+size_t AbstractChunk::CurlDebugCallback (CURL *url, curl_infotype infoType, char * data, size_t length, void *userdata)
+{
+ AbstractChunk *chunk = (AbstractChunk *)userdata;
+
+ switch (infoType) {
+ case CURLINFO_TEXT:
+ break;
+ case CURLINFO_HEADER_OUT:
+ chunk->HandleHeaderOutCallback();
+ break;
+ case CURLINFO_HEADER_IN:
+ chunk->HandleHeaderInCallback(std::string(data));
+ break;
+ case CURLINFO_DATA_IN:
+ break;
+ default:
+ return 0;
+ }
+ return 0;
+}
+void AbstractChunk::HandleHeaderOutCallback ()
+{
+ HTTPTransaction *httpTransaction = new HTTPTransaction();
+
+ httpTransaction->SetOriginalUrl(this->AbsoluteURI());
+ httpTransaction->SetRange(this->Range());
+ httpTransaction->SetType(this->GetType());
+ httpTransaction->SetRequestSentTime(Time::GetCurrentUTCTimeStr());
+
+ this->httpTransactions.push_back(httpTransaction);
+}
+void AbstractChunk::HandleHeaderInCallback (std::string data)
+{
+ HTTPTransaction *httpTransaction = this->httpTransactions.at(this->httpTransactions.size()-1);
+
+ if (data.substr(0,4) == "HTTP")
+ {
+ httpTransaction->SetResponseReceivedTime(Time::GetCurrentUTCTimeStr());
+ httpTransaction->SetResponseCode(strtoul(data.substr(9,3).c_str(), NULL, 10));
+ }
+
+ httpTransaction->AddHTTPHeaderLine(data);
+}
+const std::vector<ITCPConnection *>& AbstractChunk::GetTCPConnectionList () const
+{
+ return (std::vector<ITCPConnection *> &) this->tcpConnections;
+}
+const std::vector<IHTTPTransaction *>& AbstractChunk::GetHTTPTransactionList () const
+{
+ return (std::vector<IHTTPTransaction *> &) this->httpTransactions;
+}
diff --git a/libdash/source/network/AbstractChunk.h b/libdash/source/network/AbstractChunk.h
new file mode 100644
index 00000000..794469fd
--- /dev/null
+++ b/libdash/source/network/AbstractChunk.h
@@ -0,0 +1,100 @@
+/*
+ * AbstractChunk.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef ABSTRACTCHUNK_H_
+#define ABSTRACTCHUNK_H_
+
+#include "config.h"
+
+#include "IDownloadableChunk.h"
+#include "DownloadStateManager.h"
+#include "../helpers/SyncedBlockStream.h"
+#include "../portable/Networking.h"
+#include <curl/curl.h>
+#include "../metrics/HTTPTransaction.h"
+#include "../metrics/TCPConnection.h"
+#include "../metrics/ThroughputMeasurement.h"
+#include "../helpers/Time.h"
+
+#include <chrono>
+
+namespace dash
+{
+ namespace network
+ {
+ class AbstractChunk : public virtual IDownloadableChunk
+ {
+ public:
+ AbstractChunk ();
+ virtual ~AbstractChunk ();
+
+ /*
+ * Pure virtual IChunk Interface
+ */
+ virtual std::string& AbsoluteURI () = 0;
+ virtual std::string& Host () = 0;
+ virtual size_t Port () = 0;
+ virtual std::string& Path () = 0;
+ virtual std::string& Range () = 0;
+ virtual size_t StartByte () = 0;
+ virtual size_t EndByte () = 0;
+ virtual bool HasByteRange () = 0;
+ virtual dash::metrics::HTTPTransactionType GetType() = 0;
+ /*
+ * IDownloadableChunk Interface
+ */
+ virtual bool StartDownload (IConnection *connection);
+ virtual bool StartDownload ();
+ virtual void AbortDownload ();
+ virtual int Read (uint8_t *data, size_t len);
+ virtual int Peek (uint8_t *data, size_t len);
+ virtual int Peek (uint8_t *data, size_t len, size_t offset);
+ virtual void AttachDownloadObserver (IDownloadObserver *observer);
+ virtual void DetachDownloadObserver (IDownloadObserver *observer);
+ /*
+ * Observer Notification
+ */
+ void NotifyDownloadRateChanged (double bitrate);
+ void NotifyDownloadTimeChanged (double dnltime);
+ /*
+ * IDASHMetrics
+ */
+ const std::vector<dash::metrics::ITCPConnection *>& GetTCPConnectionList () const;
+ const std::vector<dash::metrics::IHTTPTransaction *>& GetHTTPTransactionList () const;
+
+ private:
+ std::vector<IDownloadObserver *> observers;
+ THREAD_HANDLE dlThread;
+ IConnection *connection;
+ helpers::SyncedBlockStream blockStream;
+ CURL *curl;
+ CURLM *curlm;
+ CURLcode response;
+ uint64_t bytesDownloaded;
+ DownloadStateManager stateManager;
+
+ std::vector<dash::metrics::TCPConnection *> tcpConnections;
+ std::vector<dash::metrics::HTTPTransaction *> httpTransactions;
+
+ static uint32_t BLOCKSIZE;
+
+ static void* DownloadExternalConnection (void *chunk);
+ static void* DownloadInternalConnection (void *chunk);
+ static size_t CurlResponseCallback (void *contents, size_t size, size_t nmemb, void *userp);
+ static size_t CurlHeaderCallback (void *headerData, size_t size, size_t nmemb, void *userdata);
+ static size_t CurlDebugCallback (CURL *url, curl_infotype infoType, char * data, size_t length, void *userdata);
+ void HandleHeaderOutCallback ();
+ void HandleHeaderInCallback (std::string data);
+ };
+ }
+}
+
+#endif /* ABSTRACTCHUNK_H_ */
diff --git a/libdash/source/network/DownloadStateManager.cpp b/libdash/source/network/DownloadStateManager.cpp
new file mode 100644
index 00000000..5117c099
--- /dev/null
+++ b/libdash/source/network/DownloadStateManager.cpp
@@ -0,0 +1,100 @@
+/*
+ * DownloadStateManager.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "DownloadStateManager.h"
+
+using namespace dash::network;
+
+DownloadStateManager::DownloadStateManager () :
+ state (NOT_STARTED)
+{
+ InitializeConditionVariable (&this->stateChanged);
+ InitializeCriticalSection (&this->stateLock);
+}
+DownloadStateManager::~DownloadStateManager ()
+{
+ DeleteConditionVariable (&this->stateChanged);
+ DeleteCriticalSection (&this->stateLock);
+}
+
+DownloadState DownloadStateManager::State () const
+{
+ EnterCriticalSection(&this->stateLock);
+
+ DownloadState ret = this->state;
+
+ LeaveCriticalSection(&this->stateLock);
+
+ return ret;
+}
+void DownloadStateManager::State (DownloadState state)
+{
+ EnterCriticalSection(&this->stateLock);
+
+ this->state = state;
+
+ this->Notify();
+ WakeAllConditionVariable(&this->stateChanged);
+ LeaveCriticalSection(&this->stateLock);
+}
+void DownloadStateManager::WaitState (DownloadState state) const
+{
+ EnterCriticalSection(&this->stateLock);
+
+ while(this->state != state)
+ SleepConditionVariableCS(&this->stateChanged, &this->stateLock, INFINITE);
+
+ LeaveCriticalSection(&this->stateLock);
+}
+void DownloadStateManager::CheckAndWait (DownloadState check, DownloadState wait) const
+{
+ EnterCriticalSection(&this->stateLock);
+
+ if(this->state == check)
+ while(this->state != wait)
+ SleepConditionVariableCS(&this->stateChanged, &this->stateLock, INFINITE);
+
+ LeaveCriticalSection(&this->stateLock);
+}
+void DownloadStateManager::Attach (IDownloadObserver *observer)
+{
+ EnterCriticalSection(&this->stateLock);
+ this->observers.push_back(observer);
+ LeaveCriticalSection(&this->stateLock);
+}
+void DownloadStateManager::Detach (IDownloadObserver *observer)
+{
+ EnterCriticalSection(&this->stateLock);
+
+ uint32_t pos = -1;
+
+ for(size_t i = 0; i < this->observers.size(); i++)
+ if(this->observers.at(i) == observer)
+ pos = i;
+
+ if(pos != -1)
+ this->observers.erase(this->observers.begin() + pos);
+
+ LeaveCriticalSection(&this->stateLock);
+}
+void DownloadStateManager::Notify ()
+{
+ for(size_t i = 0; i < this->observers.size(); i++)
+ this->observers.at(i)->OnDownloadStateChanged(this->state);
+}
+void DownloadStateManager::CheckAndSet (DownloadState check, DownloadState set)
+{
+ EnterCriticalSection(&this->stateLock);
+
+ if(this->state == check)
+ this->state = set;
+ LeaveCriticalSection(&this->stateLock);
+}
diff --git a/libdash/source/network/DownloadStateManager.h b/libdash/source/network/DownloadStateManager.h
new file mode 100644
index 00000000..90dd770d
--- /dev/null
+++ b/libdash/source/network/DownloadStateManager.h
@@ -0,0 +1,50 @@
+/*
+ * DownloadStateManager.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef DOWNLOADSTATEMANAGER_H_
+#define DOWNLOADSTATEMANAGER_H_
+
+#include "config.h"
+
+#include "IDownloadObserver.h"
+#include "../portable/MultiThreading.h"
+
+namespace dash
+{
+ namespace network
+ {
+ class DownloadStateManager
+ {
+ public:
+ DownloadStateManager ();
+ virtual ~DownloadStateManager ();
+
+ DownloadState State () const;
+ void WaitState (DownloadState state) const;
+ void CheckAndWait (DownloadState check, DownloadState wait) const;
+ void CheckAndSet (DownloadState check, DownloadState set);
+ void State (DownloadState state);
+ void Attach (IDownloadObserver *observer);
+ void Detach (IDownloadObserver *observer);
+
+ private:
+ DownloadState state;
+ mutable CRITICAL_SECTION stateLock;
+ mutable CONDITION_VARIABLE stateChanged;
+
+ std::vector<IDownloadObserver *> observers;
+
+ void Notify ();
+ };
+ }
+}
+
+#endif /* DOWNLOADSTATEMANAGER_H_ */
diff --git a/libdash/source/portable/MultiThreading.cpp b/libdash/source/portable/MultiThreading.cpp
new file mode 100644
index 00000000..5d1fe9c0
--- /dev/null
+++ b/libdash/source/portable/MultiThreading.cpp
@@ -0,0 +1,112 @@
+#include "MultiThreading.h"
+
+THREAD_HANDLE CreateThreadPortable (void *(*start_routine) (void *), void *arg)
+{
+ #if defined _WIN32 || defined _WIN64
+ return CreateThread (0, 0, (LPTHREAD_START_ROUTINE)start_routine, (LPVOID)arg, 0, 0);
+ #else
+ THREAD_HANDLE th = (THREAD_HANDLE)malloc(sizeof(pthread_t));
+
+ if (!th)
+ {
+ std::cerr << "Error allocating thread." << std::endl;
+ return NULL;
+ }
+
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ if(int err = pthread_create(th, &attr, start_routine, arg))
+ {
+ std::cerr << strerror(err) << std::endl;
+ return NULL;
+ }
+ return th;
+ #endif
+}
+void DestroyThreadPortable (THREAD_HANDLE th)
+{
+ #if !defined _WIN32 && !defined _WIN64
+ if(th)
+ free(th);
+ #endif
+}
+
+/****************************************************************************
+* Condition variables for Windows XP and older windows sytems
+*****************************************************************************/
+#if defined WINXPOROLDER
+ void InitCondition (condition_variable_t *cv)
+ {
+ InitializeCriticalSection(&cv->waitersCountLock);
+
+ cv->waitersCount = 0;
+ cv->waitGenerationCount = 0;
+ cv->releaseCount = 0;
+
+ cv->waitingEvent = CreateEvent (NULL, // no security
+ TRUE, // manual-reset
+ FALSE, // non-signaled initially
+ NULL); // unnamed
+ }
+ void WaitCondition (condition_variable_t *cv, CRITICAL_SECTION *externalMutex)
+ {
+ EnterCriticalSection(&cv->waitersCountLock);
+
+ cv->waitersCount++;
+
+ int currentGenerationCount = cv->waitGenerationCount;
+
+ LeaveCriticalSection(&cv->waitersCountLock);
+ LeaveCriticalSection(externalMutex);
+
+ bool isWaitDone = false;
+ while(!isWaitDone)
+ {
+ WaitForSingleObject (cv->waitingEvent, INFINITE);
+ EnterCriticalSection (&cv->waitersCountLock);
+
+ isWaitDone = (cv->releaseCount > 0 && cv->waitGenerationCount != currentGenerationCount);
+ LeaveCriticalSection (&cv->waitersCountLock);
+ }
+
+ EnterCriticalSection(externalMutex);
+ EnterCriticalSection(&cv->waitersCountLock);
+
+ cv->waitersCount--;
+ cv->releaseCount--;
+ bool isLastWaiter = (cv->releaseCount == 0);
+
+ LeaveCriticalSection(&cv->waitersCountLock);
+
+ if(isLastWaiter)
+ ResetEvent(cv->waitingEvent);
+ }
+ void SignalCondition (condition_variable_t *cv)
+ {
+ EnterCriticalSection(&cv->waitersCountLock);
+
+ if(cv->waitersCount > cv->releaseCount)
+ {
+ SetEvent(cv->waitingEvent);
+ cv->releaseCount++;
+ cv->waitGenerationCount++;
+ }
+
+ LeaveCriticalSection(&cv->waitersCountLock);
+ }
+ void BroadcastCondition (condition_variable_t *cv)
+ {
+ EnterCriticalSection(&cv->waitersCountLock);
+
+ if(cv->waitersCount > 0)
+ {
+ SetEvent(cv->waitingEvent);
+ cv->releaseCount = cv->waitersCount;
+ cv->waitGenerationCount++;
+ }
+
+ LeaveCriticalSection(&cv->waitersCountLock);
+}
+#endif
diff --git a/libdash/source/portable/MultiThreading.h b/libdash/source/portable/MultiThreading.h
new file mode 100644
index 00000000..c1b45f5c
--- /dev/null
+++ b/libdash/source/portable/MultiThreading.h
@@ -0,0 +1,70 @@
+#ifndef PORTABLE_MULTITHREADING_H_
+#define PORTABLE_MULTITHREADING_H_
+
+#if defined _WIN32 || defined _WIN64
+
+ #define _WINSOCKAPI_
+ #include <Windows.h>
+ #define DeleteConditionVariable(cond_p) {}
+
+ typedef HANDLE THREAD_HANDLE;
+
+ #if defined WINXPOROLDER
+ /****************************************************************************
+ * Variables
+ *****************************************************************************/
+ struct condition_variable_t
+ {
+ int waitersCount; // Count of the number of waiters.
+ CRITICAL_SECTION waitersCountLock; // Serialize access to <waitersCount>.
+ int releaseCount; // Number of threads to release via a <BroadcastCondition> or a <SignalCondition>.
+ int waitGenerationCount; // Keeps track of the current "generation" so that we don't allow one thread to steal all the "releases" from the broadcast.
+ HANDLE waitingEvent; // A manual-reset event that's used to block and release waiting threads.
+ };
+ /****************************************************************************
+ * Prototypes
+ *****************************************************************************/
+ void InitCondition (condition_variable_t *cv);
+ void WaitCondition (condition_variable_t *cv, CRITICAL_SECTION *externalMutex);
+ void SignalCondition (condition_variable_t *cv);
+ void BroadcastCondition (condition_variable_t *cv);
+ /****************************************************************************
+ * Defines
+ *****************************************************************************/
+ #define CONDITION_VARIABLE condition_variable_t
+
+ #define InitializeConditionVariable(cond_p) InitCondition(cond_p)
+ #define SleepConditionVariableCS(cond_p, mutex_p, infinite) WaitCondition(cond_p, mutex_p) // INFINITE should be handled mor properly
+ #define WakeConditionVariable(cond_p) SignalCondition(cond_p)
+ #define WakeAllConditionVariable(cond_p) BroadcastCondition(cond_p)
+ #endif
+
+#else
+
+ #include <string.h>
+ #include <pthread.h>
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <iostream>
+
+ #define CRITICAL_SECTION pthread_mutex_t
+ #define CONDITION_VARIABLE pthread_cond_t
+
+ #define InitializeCriticalSection(mutex_p) pthread_mutex_init(mutex_p, NULL)
+ #define DeleteCriticalSection(mutex_p) pthread_mutex_destroy(mutex_p)
+ #define EnterCriticalSection(mutex_p) pthread_mutex_lock(mutex_p)
+ #define LeaveCriticalSection(mutex_p) pthread_mutex_unlock(mutex_p)
+ #define InitializeConditionVariable(cond_p) pthread_cond_init(cond_p, NULL)
+ #define DeleteConditionVariable(cond_p) pthread_cond_destroy(cond_p)
+ #define SleepConditionVariableCS(cond_p, mutex_p, infinite) pthread_cond_wait(cond_p, mutex_p) // INFINITE should be handled mor properly
+ #define WakeConditionVariable(cond_p) pthread_cond_signal(cond_p)
+ #define WakeAllConditionVariable(cond_p) pthread_cond_broadcast(cond_p)
+
+ typedef pthread_t* THREAD_HANDLE;
+
+#endif
+
+THREAD_HANDLE CreateThreadPortable (void *(*start_routine) (void *), void *arg);
+void DestroyThreadPortable (THREAD_HANDLE th);
+
+#endif // PORTABLE_MULTITHREADING_H_ \ No newline at end of file
diff --git a/libdash/source/portable/Networking.h b/libdash/source/portable/Networking.h
new file mode 100644
index 00000000..6239c3a3
--- /dev/null
+++ b/libdash/source/portable/Networking.h
@@ -0,0 +1,27 @@
+#ifndef PORTABLE_NETWORKING_H_
+#define PORTABLE_NETWORKING_H_
+
+#if defined _WIN32 || defined _WIN64
+
+#include <WinSock2.h>
+#include <WS2tcpip.h>
+
+#else
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/ip.h> /* superset of previous */
+#include <netdb.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define closesocket(socket) close(socket)
+#define WSAStartup(wVersionRequested, lpWSAData) 0
+#define WSACleanup() {}
+
+typedef unsigned char WSADATA;
+
+#endif
+
+#endif // PORTABLE_NETWORKING_H_
diff --git a/libdash/source/sublibs.mk b/libdash/source/sublibs.mk
new file mode 100644
index 00000000..69173c3b
--- /dev/null
+++ b/libdash/source/sublibs.mk
@@ -0,0 +1,23 @@
+LIBDIR=../libs
+OBJECTS=$(SOURCES:.cpp=.o)
+DIRNAME=$(shell basename $(shell pwd))
+LIBRARY=$(LIBDIR)/lib$(DIRNAME).a
+
+all: $(SOURCES) $(LIBRARY)
+
+$(LIBRARY): $(OBJECTS)
+ mkdir -p $(LIBDIR)
+ rm -f $@
+ $(AR) $(ARFLAGS) $@ $(OBJECTS)
+
+.cpp.o:
+ $(CC) $(CFLAGS) $< -o $@
+
+clean:
+ rm -f $(OBJECTS)
+
+distclean: clean
+ rm -f $(LIBRARY)
+ if test -d $(LIBDIR); then \
+ rmdir --ignore-fail-on-non-empty $(LIBDIR) ; \
+ fi
diff --git a/libdash/source/targetver.h b/libdash/source/targetver.h
new file mode 100644
index 00000000..2adeccf9
--- /dev/null
+++ b/libdash/source/targetver.h
@@ -0,0 +1,18 @@
+/*
+ * targetver.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#pragma once
+
+#if defined _WIN32 || defined _WIN64
+
+#include <SDKDDKVer.h>
+
+#endif \ No newline at end of file
diff --git a/libdash/source/xml/DOMHelper.cpp b/libdash/source/xml/DOMHelper.cpp
new file mode 100644
index 00000000..43adadc0
--- /dev/null
+++ b/libdash/source/xml/DOMHelper.cpp
@@ -0,0 +1,54 @@
+/*
+ * DOMHelper.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "DOMHelper.h"
+
+using namespace dash::xml;
+
+std::vector<Node *> DOMHelper::GetElementByTagName (Node *root, const std::string &name, bool selfContain)
+{
+ std::vector<Node *> elements;
+
+ for(unsigned int i = 0; i < root->GetSubNodes().size(); i++)
+ {
+ GetElementsByTagName(root->GetSubNodes().at(i), name, &elements, selfContain);
+ }
+
+ return elements;
+}
+std::vector<Node *> DOMHelper::GetChildElementByTagName (Node *root, const std::string &name)
+{
+ std::vector<Node *> elements;
+
+ for(unsigned int i = 0; i < root->GetSubNodes().size(); i++)
+ {
+ if(!root->GetSubNodes().at(i)->GetName().compare(name))
+ elements.push_back(root->GetSubNodes().at(i));
+ }
+
+ return elements;
+}
+void DOMHelper::GetElementsByTagName (Node *root, const std::string &name, std::vector<Node*> *elements, bool selfContain)
+{
+ if(!selfContain && !root->GetName().compare(name))
+ {
+ elements->push_back(root);
+ return;
+ }
+
+ if(!root->GetName().compare(name))
+ elements->push_back(root);
+
+ for(unsigned int i = 0; i < root->GetSubNodes().size(); i++)
+ {
+ GetElementsByTagName(root->GetSubNodes().at(i), name, elements, selfContain);
+ }
+}
diff --git a/libdash/source/xml/DOMHelper.h b/libdash/source/xml/DOMHelper.h
new file mode 100644
index 00000000..d76d425b
--- /dev/null
+++ b/libdash/source/xml/DOMHelper.h
@@ -0,0 +1,35 @@
+/*
+ * DOMHelper.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef DOMHELPER_H_
+#define DOMHELPER_H_
+
+#include "config.h"
+
+#include "Node.h"
+
+namespace dash
+{
+ namespace xml
+ {
+ class DOMHelper
+ {
+ public:
+ static std::vector<Node *> GetElementByTagName (Node *root, const std::string &name, bool selfContain);
+ static std::vector<Node *> GetChildElementByTagName (Node *root, const std::string &name);
+
+ private:
+ static void GetElementsByTagName(Node *root, const std::string &name, std::vector<Node *> *elements, bool selfContain);
+ };
+ }
+}
+
+#endif /* DOMHELPER_H_ */
diff --git a/libdash/source/xml/DOMParser.cpp b/libdash/source/xml/DOMParser.cpp
new file mode 100644
index 00000000..5feb3850
--- /dev/null
+++ b/libdash/source/xml/DOMParser.cpp
@@ -0,0 +1,160 @@
+/*
+ * DOMParser.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "DOMParser.h"
+
+using namespace dash::xml;
+using namespace dash::helpers;
+
+DOMParser::DOMParser (std::string url) :
+ url (url),
+ reader (NULL),
+ root (NULL)
+{
+ this->Init();
+}
+DOMParser::~DOMParser ()
+{
+ xmlCleanupParser();
+ delete(this->root);
+}
+
+Node* DOMParser::GetRootNode () const
+{
+ return this->root;
+}
+bool DOMParser::Parse (std::string path)
+{
+ this->reader = xmlReaderForFile(this->url.c_str(), NULL, 0);
+
+ if(this->reader == NULL)
+ return false;
+
+ if(xmlTextReaderRead(this->reader))
+ this->root = this->ProcessNode(path);
+
+ if(this->root == NULL)
+ return false;
+
+ xmlFreeTextReader(this->reader);
+
+ return true;
+}
+Node* DOMParser::ProcessNode (std::string path)
+{
+ int type = xmlTextReaderNodeType(this->reader);
+
+ if(type != WhiteSpace && type != Text)
+ {
+ while (type == Comment || type == WhiteSpace)
+ {
+ xmlTextReaderRead(this->reader);
+ type = xmlTextReaderNodeType(this->reader);
+ }
+
+ Node *node = new Node();
+ node->SetType(type);
+ if(!(strcmp("",path.c_str())))
+ node->SetMPDPath(Path::GetDirectoryPath(url));
+ else
+ node->SetMPDPath(Path::GetDirectoryPath(path));
+ if(xmlTextReaderConstName(this->reader) == NULL)
+ {
+ delete node;
+ return NULL;
+ }
+
+ std::string name = (const char *) xmlTextReaderConstName(this->reader);
+ int isEmpty = xmlTextReaderIsEmptyElement(this->reader);
+
+ node->SetName(name);
+
+ this->AddAttributesToNode(node);
+
+ if(isEmpty)
+ return node;
+
+ Node *subnode = NULL;
+ int ret = xmlTextReaderRead(this->reader);
+
+ while(ret == 1)
+ {
+ if(!strcmp(name.c_str(), (const char *) xmlTextReaderConstName(this->reader)))
+ {
+ return node;
+ }
+
+ subnode = this->ProcessNode(path);
+
+ if(subnode != NULL)
+ node->AddSubNode(subnode);
+
+ ret = xmlTextReaderRead(this->reader);
+ }
+
+ return node;
+ } else if (type == Text)
+ {
+ const char* text = (const char *) xmlTextReaderReadString(this->reader);
+
+ if(text != NULL)
+ {
+ Node *node = new Node();
+ node->SetType(type);
+ node->SetText(text);
+ return node;
+ }
+ }
+ return NULL;
+}
+void DOMParser::AddAttributesToNode (Node *node)
+{
+ if(xmlTextReaderHasAttributes(this->reader))
+ {
+ while(xmlTextReaderMoveToNextAttribute(this->reader))
+ {
+ std::string key = (const char *) xmlTextReaderConstName(this->reader);
+ std::string value = (const char *) xmlTextReaderConstValue(this->reader);
+ node->AddAttribute(key, value);
+ }
+ }
+}
+void DOMParser::Print (Node *node, int offset)
+{
+ std::stringstream ss;
+ for(int i = 0; i < offset; i++)
+ ss << " ";
+ ss << node->GetName();
+
+ std::vector<std::string> keys = node->GetAttributeKeys();
+
+ ss.clear();
+ for(unsigned int i = 0; i < keys.size(); i++)
+ {
+ ss << " " << keys.at(i) << "=" << node->GetAttributeValue(keys.at(i));
+ }
+
+ offset++;
+
+ for(unsigned int i = 0; i < node->GetSubNodes().size(); i++)
+ {
+ this->Print(node->GetSubNodes().at(i), offset);
+ }
+}
+void DOMParser::Init ()
+{
+ this->root = NULL;
+ this->reader = NULL;
+}
+void DOMParser::Print ()
+{
+ this->Print(this->root, 0);
+}
diff --git a/libdash/source/xml/DOMParser.h b/libdash/source/xml/DOMParser.h
new file mode 100644
index 00000000..a8b3a9b7
--- /dev/null
+++ b/libdash/source/xml/DOMParser.h
@@ -0,0 +1,56 @@
+/*
+ * DOMParser.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef DOMPARSER_H_
+#define DOMPARSER_H_
+
+#include "config.h"
+
+#include "Node.h"
+#include <libxml/xmlreader.h>
+#include "../helpers/Path.h"
+
+namespace dash
+{
+ namespace xml
+ {
+ enum NodeType
+ {
+ Start = 1,
+ End = 15,
+ Comment = 8,
+ WhiteSpace = 14,
+ Text = 3,
+ };
+
+ class DOMParser
+ {
+ public:
+ DOMParser (std::string url);
+ virtual ~DOMParser ();
+
+ bool Parse (std::string path = "");
+ Node* GetRootNode () const;
+ void Print ();
+
+ private:
+ xmlTextReaderPtr reader;
+ Node *root;
+ std::string url;
+
+ void Init ();
+ Node* ProcessNode (std::string);
+ void AddAttributesToNode (Node *node);
+ void Print (Node *node, int offset);
+ };
+ }
+}
+#endif /* DOMPARSER_H_ */
diff --git a/libdash/source/xml/Node.cpp b/libdash/source/xml/Node.cpp
new file mode 100644
index 00000000..d04558b6
--- /dev/null
+++ b/libdash/source/xml/Node.cpp
@@ -0,0 +1,1029 @@
+/*
+ * Node.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, 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 "Node.h"
+#include <cstdlib>
+
+using namespace dash::xml;
+using namespace dash::metrics;
+
+Node::Node ()
+{
+}
+Node::Node (const Node& other) :
+ name(other.name),
+ text(other.text),
+ type(other.type),
+ attributes(other.attributes)
+{
+ for (size_t i = 0; i < other.subNodes.size(); i++)
+ this->subNodes.push_back(new Node(*(other.subNodes.at(i))));
+}
+Node::~Node ()
+{
+ for(size_t i = 0; i < this->subNodes.size(); i++)
+ delete(this->subNodes.at(i));
+}
+
+dash::mpd::ProgramInformation* Node::ToProgramInformation () const
+{
+ dash::mpd::ProgramInformation *programInformation = new dash::mpd::ProgramInformation();
+
+ if (this->HasAttribute("lang"))
+ {
+ programInformation->SetLang(this->GetAttributeValue("lang"));
+ }
+ if (this->HasAttribute("moreInformationURL"))
+ {
+ programInformation->SetMoreInformationURL(this->GetAttributeValue("moreInformationURL"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "Title")
+ {
+ programInformation->SetTitle(subNodes.at(i)->GetText());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Source")
+ {
+ programInformation->SetSource(subNodes.at(i)->GetText());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Copyright")
+ {
+ programInformation->SetCopyright(subNodes.at(i)->GetText());
+ continue;
+ }
+ programInformation->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ programInformation->AddRawAttributes(this->attributes);
+ return programInformation;
+}
+dash::mpd::BaseUrl* Node::ToBaseUrl () const
+{
+ dash::mpd::BaseUrl *baseUrl = new dash::mpd::BaseUrl();
+
+ if(this->HasAttribute("serviceLocation"))
+ {
+ baseUrl->SetServiceLocation(this->GetAttributeValue("serviceLocation"));
+ }
+ if(this->HasAttribute("byteRange"))
+ {
+ baseUrl->SetByteRange(this->GetAttributeValue("byteRange"));
+ }
+ if (this->GetText() == "./")
+ {
+ baseUrl->SetUrl(this->mpdPath);
+ }
+ else
+ {
+ baseUrl->SetUrl(this->GetText());
+ }
+
+ baseUrl->AddRawAttributes(this->attributes);
+ return baseUrl;
+}
+dash::mpd::Descriptor* Node::ToDescriptor () const
+{
+ dash::mpd::Descriptor *descriptor = new dash::mpd::Descriptor();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ if (this->HasAttribute("schemeIdUri"))
+ {
+ descriptor->SetSchemeIdUri(this->GetAttributeValue("schemeIdUri"));
+ }
+ if (this->HasAttribute("value"))
+ {
+ descriptor->SetValue(this->GetAttributeValue("value"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ descriptor->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ descriptor->AddRawAttributes(this->attributes);
+ return descriptor;
+}
+dash::mpd::ContentComponent* Node::ToContentComponent () const
+{
+ dash::mpd::ContentComponent *contentComponent = new dash::mpd::ContentComponent();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ if (this->HasAttribute("id"))
+ {
+ contentComponent->SetId(strtoul(this->GetAttributeValue("id").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("lang"))
+ {
+ contentComponent->SetLang(this->GetAttributeValue("lang"));
+ }
+ if (this->HasAttribute("contentType"))
+ {
+ contentComponent->SetContentType(this->GetAttributeValue("contentType"));
+ }
+ if (this->HasAttribute("par"))
+ {
+ contentComponent->SetPar(this->GetAttributeValue("par"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "Accessibility")
+ {
+ contentComponent->AddAccessibity(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Role")
+ {
+ contentComponent->AddRole(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Rating")
+ {
+ contentComponent->AddRating(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Viewpoint")
+ {
+ contentComponent->AddViewpoint(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ contentComponent->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ contentComponent->AddRawAttributes(this->attributes);
+ return contentComponent;
+}
+dash::mpd::URLType* Node::ToURLType (HTTPTransactionType type) const
+{
+ dash::mpd::URLType* urlType = new dash::mpd::URLType();
+
+ if (this->HasAttribute("sourceURL"))
+ {
+ urlType->SetSourceURL(this->GetAttributeValue("sourceURL"));
+ }
+ if (this->HasAttribute("range"))
+ {
+ urlType->SetRange(this->GetAttributeValue("range"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ urlType->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ urlType->SetType(type);
+ urlType->AddRawAttributes(this->attributes);
+ return urlType;
+}
+dash::mpd::SegmentBase* Node::ToSegmentBase () const
+{
+ dash::mpd::SegmentBase* segmentBase = new dash::mpd::SegmentBase();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ SetCommonValuesForSeg(*segmentBase);
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() != "Initialization" && subNodes.at(i)->GetName() != "RepresentationIndex")
+ segmentBase->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ segmentBase->AddRawAttributes(this->attributes);
+ return segmentBase;
+}
+dash::mpd::Timeline* Node::ToTimeline () const
+{
+ dash::mpd::Timeline* timeline = new dash::mpd::Timeline();
+
+ if (this->HasAttribute("t"))
+ {
+ timeline->SetStartTime(strtoul(this->GetAttributeValue("t").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("d"))
+ {
+ timeline->SetDuration(strtoul(this->GetAttributeValue("d").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("r"))
+ {
+ timeline->SetRepeatCount(strtoul(this->GetAttributeValue("r").c_str(), NULL, 10));
+ }
+
+ timeline->AddRawAttributes(this->attributes);
+ return timeline;
+}
+dash::mpd::SegmentTimeline* Node::ToSegmentTimeline () const
+{
+ dash::mpd::SegmentTimeline* segmentTimeline = new dash::mpd::SegmentTimeline();
+
+ std::vector<Node *> subNodes = this->GetSubNodes();
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "S")
+ {
+ segmentTimeline->AddTimeline(subNodes.at(i)->ToTimeline());
+ continue;
+ }
+ segmentTimeline->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ segmentTimeline->AddRawAttributes(this->attributes);
+ return segmentTimeline;
+}
+dash::mpd::SegmentURL* Node::ToSegmentURL () const
+{
+ dash::mpd::SegmentURL *segmentUrl = new dash::mpd::SegmentURL();
+
+ if (this->HasAttribute("media"))
+ {
+ segmentUrl->SetMediaURI(this->GetAttributeValue("media"));
+ }
+ if (this->HasAttribute("mediaRange"))
+ {
+ segmentUrl->SetMediaRange(this->GetAttributeValue("mediaRange"));
+ }
+ if (this->HasAttribute("index"))
+ {
+ segmentUrl->SetIndexURI(this->GetAttributeValue("index"));
+ }
+ if (this->HasAttribute("indexRange"))
+ {
+ segmentUrl->SetIndexRange(this->GetAttributeValue("indexRange"));
+ }
+ if(this->HasAttribute("size"))
+ {
+ segmentUrl->SetBitrate(this->GetAttributeValue("size"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ segmentUrl->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ segmentUrl->AddRawAttributes(this->attributes);
+ return segmentUrl;
+}
+dash::mpd::SegmentList* Node::ToSegmentList () const
+{
+ dash::mpd::SegmentList* segmentList = new dash::mpd::SegmentList();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ SetCommonValuesForMSeg(*segmentList);
+
+ if (this->HasAttribute("xlink:href"))
+ {
+ segmentList->SetXlinkHref(this->GetAttributeValue("xlink:href"));
+ }
+ if (this->HasAttribute("xlink:actuate"))
+ {
+ segmentList->SetXlinkActuate(this->GetAttributeValue("xlink:actuate"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "SegmentURL")
+ {
+ segmentList->AddSegmentURL(subNodes.at(i)->ToSegmentURL());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() != "SegmentTimeline" && subNodes.at(i)->GetName() != "BitstreamSwitching" &&
+ subNodes.at(i)->GetName() != "Initialization" && subNodes.at(i)->GetName() != "RepresentationIndex")
+ segmentList->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ segmentList->AddRawAttributes(this->attributes);
+ return segmentList;
+}
+dash::mpd::SegmentTemplate* Node::ToSegmentTemplate () const
+{
+ dash::mpd::SegmentTemplate *segmentTemplate = new dash::mpd::SegmentTemplate();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ SetCommonValuesForMSeg(*segmentTemplate);
+
+ if (this->HasAttribute("media"))
+ {
+ segmentTemplate->SetMedia(this->GetAttributeValue("media"));
+ }
+ if (this->HasAttribute("index"))
+ {
+ segmentTemplate->SetIndex(this->GetAttributeValue("index"));
+ }
+ if (this->HasAttribute("initialization"))
+ {
+ segmentTemplate->SetInitialization(this->GetAttributeValue("initialization"));
+ }
+ if (this->HasAttribute("bitstreamSwitching"))
+ {
+ segmentTemplate->SetBitstreamSwitching(this->GetAttributeValue("bitstreamSwitching"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() != "SegmentTimeline" && subNodes.at(i)->GetName() != "BitstreamSwitching" &&
+ subNodes.at(i)->GetName() != "Initialization" && subNodes.at(i)->GetName() != "RepresentationIndex")
+ segmentTemplate->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ segmentTemplate->AddRawAttributes(this->attributes);
+ return segmentTemplate;
+}
+dash::mpd::SubRepresentation* Node::ToSubRepresentation () const
+{
+ dash::mpd::SubRepresentation* subRepresentation = new dash::mpd::SubRepresentation();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ SetCommonValuesForRep(*subRepresentation);
+
+ if (this->HasAttribute("level"))
+ {
+ subRepresentation->SetLevel(strtoul(this->GetAttributeValue("level").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("dependencyLevel"))
+ {
+ subRepresentation->SetDependencyLevel(this->GetAttributeValue("dependencyLevel"));
+ }
+ if (this->HasAttribute("bandwidth"))
+ {
+ subRepresentation->SetBandWidth(strtoul(this->GetAttributeValue("bandwidth").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("contentComponent"))
+ {
+ subRepresentation->SetContentComponent(this->GetAttributeValue("contentComponent"));
+ }
+ for (size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() != "FramePacking" && subNodes.at(i)->GetName() != "AudioChannelConfiguration" && subNodes.at(i)->GetName() != "ContentProtection")
+ subRepresentation->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ subRepresentation->AddRawAttributes(this->attributes);
+ return subRepresentation;
+}
+dash::mpd::Representation* Node::ToRepresentation () const
+{
+ dash::mpd::Representation* representation = new dash::mpd::Representation();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ SetCommonValuesForRep(*representation);
+
+ if (this->HasAttribute("id"))
+ {
+ representation->SetId(this->GetAttributeValue("id"));
+ }
+ if (this->HasAttribute("bandwidth"))
+ {
+ representation->SetBandwidth(strtoul(this->GetAttributeValue("bandwidth").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("qualityRanking"))
+ {
+ representation->SetQualityRanking(strtoul(this->GetAttributeValue("qualityRanking").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("dependencyId"))
+ {
+ representation->SetDependencyId(this->GetAttributeValue("dependencyId"));
+ }
+ if (this->HasAttribute("mediaStreamStructureId"))
+ {
+ representation->SetMediaStreamStructureId(this->GetAttributeValue("mediaStreamStructureId"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "BaseURL")
+ {
+ representation->AddBaseURL(subNodes.at(i)->ToBaseUrl());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SubRepresentation")
+ {
+ representation->AddSubRepresentation(subNodes.at(i)->ToSubRepresentation());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentBase")
+ {
+ representation->SetSegmentBase(subNodes.at(i)->ToSegmentBase());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentList")
+ {
+ representation->SetSegmentList(subNodes.at(i)->ToSegmentList());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentTemplate")
+ {
+ representation->SetSegmentTemplate(subNodes.at(i)->ToSegmentTemplate());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() != "FramePacking" && subNodes.at(i)->GetName() != "AudioChannelConfiguration" && subNodes.at(i)->GetName() != "ContentProtection")
+ representation->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ representation->AddRawAttributes(this->attributes);
+ return representation;
+}
+dash::mpd::AdaptationSet* Node::ToAdaptationSet () const
+{
+ dash::mpd::AdaptationSet *adaptationSet = new dash::mpd::AdaptationSet();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ SetCommonValuesForRep(*adaptationSet);
+
+ if (this->HasAttribute("xlink:href"))
+ {
+ adaptationSet->SetXlinkHref(this->GetAttributeValue("xlink:href"));
+ }
+ if (this->HasAttribute("xlink:actuate"))
+ {
+ adaptationSet->SetXlinkActuate(this->GetAttributeValue("xlink:actuate"));
+ }
+ if (this->HasAttribute("id"))
+ {
+ adaptationSet->SetId(strtoul(this->GetAttributeValue("id").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("group"))
+ {
+ adaptationSet->SetGroup(strtoul(this->GetAttributeValue("group").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("lang"))
+ {
+ adaptationSet->SetLang(this->GetAttributeValue("lang"));
+ }
+ if (this->HasAttribute("contentType"))
+ {
+ adaptationSet->SetContentType(this->GetAttributeValue("contentType"));
+ }
+ if (this->HasAttribute("par"))
+ {
+ adaptationSet->SetPar(this->GetAttributeValue("par"));
+ }
+ if (this->HasAttribute("minBandwidth"))
+ {
+ adaptationSet->SetMinBandwidth(strtoul(this->GetAttributeValue("minBandwidth").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("maxBandwidth"))
+ {
+ adaptationSet->SetMaxBandwidth(strtoul(this->GetAttributeValue("maxBandwidth").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("minWidth"))
+ {
+ adaptationSet->SetMinWidth(strtoul(this->GetAttributeValue("minWidth").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("maxWidth"))
+ {
+ adaptationSet->SetMaxWidth(strtoul(this->GetAttributeValue("maxWidth").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("minHeight"))
+ {
+ adaptationSet->SetMinHeight(strtoul(this->GetAttributeValue("minHeight").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("maxHeight"))
+ {
+ adaptationSet->SetMaxHeight(strtoul(this->GetAttributeValue("maxHeight").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("minFrameRate"))
+ {
+ adaptationSet->SetMinFramerate(this->GetAttributeValue("minFrameRate"));
+ }
+ if (this->HasAttribute("maxFrameRate"))
+ {
+ adaptationSet->SetMaxFramerate(this->GetAttributeValue("maxFrameRate"));
+ }
+ if (this->HasAttribute("segmentAlignment"))
+ {
+ adaptationSet->SetSegmentAlignment(this->GetAttributeValue("segmentAlignment"));
+ }
+ if (this->HasAttribute("subsegmentAlignment"))
+ {
+ adaptationSet->SetSubsegmentAlignment(this->GetAttributeValue("subsegmentAlignment"));
+ }
+ if (this->HasAttribute("subsegmentStartsWithSAP"))
+ {
+ adaptationSet->SetMaxHeight((uint8_t) strtoul(this->GetAttributeValue("subsegmentStartsWithSAP").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("bitstreamSwitching"))
+ {
+ adaptationSet->SetBitstreamSwitching(dash::helpers::String::ToBool(this->GetAttributeValue("bitstreamSwitching")));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "Accessibility")
+ {
+ adaptationSet->AddAccessibity(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Role")
+ {
+ adaptationSet->AddRole(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Rating")
+ {
+ adaptationSet->AddRating(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Viewpoint")
+ {
+ adaptationSet->AddViewpoint(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "ContentComponent")
+ {
+ adaptationSet->AddContentComponent(subNodes.at(i)->ToContentComponent());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "BaseURL")
+ {
+ adaptationSet->AddBaseURL(subNodes.at(i)->ToBaseUrl());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentBase")
+ {
+ adaptationSet->SetSegmentBase(subNodes.at(i)->ToSegmentBase());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentList")
+ {
+ adaptationSet->SetSegmentList(subNodes.at(i)->ToSegmentList());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentTemplate")
+ {
+ adaptationSet->SetSegmentTemplate(subNodes.at(i)->ToSegmentTemplate());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Representation")
+ {
+ adaptationSet->AddRepresentation(subNodes.at(i)->ToRepresentation());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() != "FramePacking" && subNodes.at(i)->GetName() != "AudioChannelConfiguration" && subNodes.at(i)->GetName() != "ContentProtection")
+ adaptationSet->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ adaptationSet->AddRawAttributes(this->attributes);
+ return adaptationSet;
+}
+dash::mpd::Subset* Node::ToSubset () const
+{
+ dash::mpd::Subset *subset = new dash::mpd::Subset();
+
+ if (this->HasAttribute("contains"))
+ {
+ subset->SetSubset(this->GetAttributeValue("contains"));
+ }
+
+ subset->AddRawAttributes(this->attributes);
+ return subset;
+}
+dash::mpd::Period* Node::ToPeriod () const
+{
+ dash::mpd::Period *period = new dash::mpd::Period();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ if (this->HasAttribute("xlink:href"))
+ {
+ period->SetXlinkHref(this->GetAttributeValue("xlink:href"));
+ }
+ if (this->HasAttribute("xlink:actuate"))
+ {
+ period->SetXlinkActuate(this->GetAttributeValue("xlink:actuate"));
+ }
+ if (this->HasAttribute("id"))
+ {
+ period->SetId(this->GetAttributeValue("id"));
+ }
+ if (this->HasAttribute("start"))
+ {
+ period->SetStart(this->GetAttributeValue("start"));
+ }
+ if (this->HasAttribute("duration"))
+ {
+ period->SetDuration(this->GetAttributeValue("duration"));
+ }
+ if (this->HasAttribute("bitstreamSwitching"))
+ {
+ period->SetBitstreamSwitching(dash::helpers::String::ToBool(this->GetAttributeValue("bitstreamSwitching")));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "BaseURL")
+ {
+ period->AddBaseURL(subNodes.at(i)->ToBaseUrl());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "AdaptationSet")
+ {
+ period->AddAdaptationSet(subNodes.at(i)->ToAdaptationSet());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Subset")
+ {
+ period->AddSubset(subNodes.at(i)->ToSubset());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentBase")
+ {
+ period->SetSegmentBase(subNodes.at(i)->ToSegmentBase());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentList")
+ {
+ period->SetSegmentList(subNodes.at(i)->ToSegmentList());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "SegmentTemplate")
+ {
+ period->SetSegmentTemplate(subNodes.at(i)->ToSegmentTemplate());
+ continue;
+ }
+ period->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ period->AddRawAttributes(this->attributes);
+ return period;
+}
+dash::mpd::Range* Node::ToRange () const
+{
+ dash::mpd::Range* range = new dash::mpd::Range();
+
+ if (this->HasAttribute("starttime"))
+ {
+ range->SetStarttime(this->GetAttributeValue("starttime"));
+ }
+ if (this->HasAttribute("duration"))
+ {
+ range->SetDuration(this->GetAttributeValue("duration"));
+ }
+
+ return range;
+}
+dash::mpd::Metrics* Node::ToMetrics () const
+{
+ dash::mpd::Metrics* metrics = new dash::mpd::Metrics();
+
+ if (this->HasAttribute("metrics"))
+ {
+ metrics->SetMetrics(this->GetAttributeValue("metrics"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "Reporting")
+ {
+ metrics->AddReporting(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Range")
+ {
+ metrics->AddRange(subNodes.at(i)->ToRange());
+ continue;
+ }
+ metrics->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ metrics->AddRawAttributes(this->attributes);
+ return metrics;
+}
+dash::mpd::MPD* Node::ToMPD () const
+{
+ dash::mpd::MPD *mpd = new dash::mpd::MPD();
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ if (this->HasAttribute("id"))
+ {
+ mpd->SetId(this->GetAttributeValue("id"));
+ }
+ if (this->HasAttribute("profiles"))
+ {
+ mpd->SetProfiles(this->GetAttributeValue("profiles"));
+ }
+ if (this->HasAttribute("type"))
+ {
+ mpd->SetType(this->GetAttributeValue("type"));
+ }
+ if (this->HasAttribute("availabilityStartTime"))
+ {
+ mpd->SetAvailabilityStarttime(this->GetAttributeValue("availabilityStartTime"));
+ }
+ if (this->HasAttribute("availabilityEndTime"))
+ {
+ mpd->SetAvailabilityEndtime(this->GetAttributeValue("availabilityEndTime"));
+ }
+ if (this->HasAttribute("mediaPresentationDuration"))
+ {
+ mpd->SetMediaPresentationDuration(this->GetAttributeValue("mediaPresentationDuration"));
+ }
+ if (this->HasAttribute("minimumUpdatePeriod"))
+ {
+ mpd->SetMinimumUpdatePeriod(this->GetAttributeValue("minimumUpdatePeriod"));
+ }
+ if (this->HasAttribute("minBufferTime"))
+ {
+ mpd->SetMinBufferTime(this->GetAttributeValue("minBufferTime"));
+ }
+ if (this->HasAttribute("timeShiftBufferDepth"))
+ {
+ mpd->SetTimeShiftBufferDepth(this->GetAttributeValue("timeShiftBufferDepth"));
+ }
+ if (this->HasAttribute("suggestedPresentationDelay"))
+ {
+ mpd->SetSuggestedPresentationDelay(this->GetAttributeValue("suggestedPresentationDelay"));
+ }
+ if (this->HasAttribute("maxSegmentDuration"))
+ {
+ mpd->SetMaxSegmentDuration(this->GetAttributeValue("maxSegmentDuration"));
+ }
+ if (this->HasAttribute("maxSubsegmentDuration"))
+ {
+ mpd->SetMaxSubsegmentDuration(this->GetAttributeValue("maxSubsegmentDuration"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "ProgramInformation")
+ {
+ mpd->AddProgramInformation(subNodes.at(i)->ToProgramInformation());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "BaseURL")
+ {
+ mpd->AddBaseUrl(subNodes.at(i)->ToBaseUrl());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Location")
+ {
+ mpd->AddLocation(subNodes.at(i)->GetText());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Period")
+ {
+ mpd->AddPeriod(subNodes.at(i)->ToPeriod());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "Metrics")
+ {
+ mpd->AddMetrics(subNodes.at(i)->ToMetrics());
+ continue;
+ }
+ mpd->AddAdditionalSubNode((xml::INode *) new Node(*(subNodes.at(i))));
+ }
+
+ dash::mpd::BaseUrl *mpdPathBaseUrl = new dash::mpd::BaseUrl();
+ mpdPathBaseUrl->SetUrl(mpdPath);
+ mpd->SetMPDPathBaseUrl(mpdPathBaseUrl);
+
+ mpd->AddRawAttributes(this->attributes);
+ return mpd;
+}
+void Node::SetMPDPath (std::string path)
+{
+ this->mpdPath = path;
+}
+
+const std::vector<INode*>& Node::GetNodes () const
+{
+ return (std::vector<INode*> &) this->subNodes;
+}
+const std::vector<Node*>& Node::GetSubNodes () const
+{
+ return this->subNodes;
+}
+void Node::AddSubNode (Node *node)
+{
+ this->subNodes.push_back(node);
+}
+const std::string& Node::GetName () const
+{
+ return this->name;
+}
+void Node::SetName (const std::string &name)
+{
+ this->name = name;
+}
+const std::string& Node::GetAttributeValue (std::string key) const
+{
+ //return this->attributes[key];
+ return this->attributes.find(key)->second;
+}
+bool Node::HasAttribute (const std::string& name) const
+{
+ if(this->attributes.find(name) != this->attributes.end())
+ return true;
+
+ return false;
+}
+void Node::AddAttribute (const std::string &key, const std::string &value)
+{
+ this->attributes[key] = value;
+}
+std::vector<std::string> Node::GetAttributeKeys () const
+{
+ std::vector<std::string> keys;
+ std::map<std::string, std::string>::const_iterator it;
+
+ for(it = this->attributes.begin(); it != this->attributes.end(); ++it)
+ {
+ keys.push_back(it->first);
+ }
+ return keys;
+}
+bool Node::HasText () const
+{
+ return false;
+}
+std::string Node::GetText () const
+{
+ if(this->type == 3)
+ return this->text;
+ else
+ {
+ if(this->subNodes.size())
+ return this->subNodes[0]->GetText();
+ else
+ return "";
+ }
+}
+void Node::SetText (const std::string &text)
+{
+ this->text = text;
+}
+void Node::Print (std::ostream &stream) const
+{
+ stream << this->name;
+ std::vector<std::string> keys = this->GetAttributeKeys();
+ for(size_t i = 0; i < keys.size(); i++)
+ stream << " " << keys.at(i) << "=" << this->GetAttributeValue(keys.at(i));
+
+ stream << std::endl;
+}
+const std::map<std::string,std::string>& Node::GetAttributes () const
+{
+ return this->attributes;
+}
+int Node::GetType () const
+{
+ return this->type;
+}
+void Node::SetType (int type)
+{
+ this->type = type;
+}
+void Node::SetCommonValuesForRep (dash::mpd::RepresentationBase& object) const
+{
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ if (this->HasAttribute("profiles"))
+ {
+ object.SetProfiles(this->GetAttributeValue("profiles"));
+ }
+ if (this->HasAttribute("width"))
+ {
+ object.SetWidth(strtoul(this->GetAttributeValue("width").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("height"))
+ {
+ object.SetHeight(strtoul(this->GetAttributeValue("height").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("sar"))
+ {
+ object.SetSar(this->GetAttributeValue("sar"));
+ }
+ if (this->HasAttribute("frameRate"))
+ {
+ object.SetFrameRate(this->GetAttributeValue("frameRate"));
+ }
+ if (this->HasAttribute("audioSamplingRate"))
+ {
+ object.SetAudioSamplingRate(this->GetAttributeValue("audioSamplingRate"));
+ }
+ if (this->HasAttribute("mimeType"))
+ {
+ object.SetMimeType(this->GetAttributeValue("mimeType"));
+ }
+ if (this->HasAttribute("segmentProfiles"))
+ {
+ object.SetSegmentProfiles(this->GetAttributeValue("segmentProfiles"));
+ }
+ if (this->HasAttribute("codecs"))
+ {
+ object.SetCodecs(this->GetAttributeValue("codecs"));
+ }
+ if (this->HasAttribute("maximumSAPPeriod"))
+ {
+ object.SetMaximumSAPPeriod(strtod(this->GetAttributeValue("maximumSAPPeriod").c_str(), NULL));
+ }
+ if (this->HasAttribute("startWithSAP"))
+ {
+ object.SetStartWithSAP((uint8_t) strtoul(this->GetAttributeValue("startWithSAP").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("maxPlayoutRate"))
+ {
+ object.SetMaxPlayoutRate(strtod(this->GetAttributeValue("maxPlayoutRate").c_str(), NULL));
+ }
+ if (this->HasAttribute("codingDependency"))
+ {
+ object.SetCodingDependency(dash::helpers::String::ToBool(this->GetAttributeValue("codingDependency")));
+ }
+ if (this->HasAttribute("scanType"))
+ {
+ object.SetScanType(this->GetAttributeValue("scanType"));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "FramePacking")
+ {
+ object.AddFramePacking(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "AudioChannelConfiguration")
+ {
+ object.AddAudioChannelConfiguration(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "ContentProtection")
+ {
+ object.AddContentProtection(subNodes.at(i)->ToDescriptor());
+ continue;
+ }
+ }
+}
+void Node::SetCommonValuesForSeg (dash::mpd::SegmentBase& object) const
+{
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ if (this->HasAttribute("timescale"))
+ {
+ object.SetTimescale(strtoul(this->GetAttributeValue("timescale").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("presentationTimeOffset"))
+ {
+ object.SetPresentationTimeOffset(strtoul(this->GetAttributeValue("presentationTimeOffset").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("indexRange"))
+ {
+ object.SetIndexRange(this->GetAttributeValue("indexRange"));
+ }
+ if (this->HasAttribute("indexRangeExact"))
+ {
+ object.SetIndexRangeExact(dash::helpers::String::ToBool(this->GetAttributeValue("indexRangeExact")));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "Initialization")
+ {
+ object.SetInitialization(subNodes.at(i)->ToURLType(dash::metrics::InitializationSegment));
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "RepresentationIndex")
+ {
+ object.SetRepresentationIndex(subNodes.at(i)->ToURLType(dash::metrics::IndexSegment));
+ continue;
+ }
+ }
+}
+void Node::SetCommonValuesForMSeg(dash::mpd::MultipleSegmentBase& object) const
+{
+ std::vector<Node *> subNodes = this->GetSubNodes();
+
+ SetCommonValuesForSeg(object);
+
+ if (this->HasAttribute("duration"))
+ {
+ object.SetDuration(strtoul(this->GetAttributeValue("duration").c_str(), NULL, 10));
+ }
+ if (this->HasAttribute("startNumber"))
+ {
+ object.SetStartNumber(strtoul(this->GetAttributeValue("startNumber").c_str(), NULL, 10));
+ }
+
+ for(size_t i = 0; i < subNodes.size(); i++)
+ {
+ if (subNodes.at(i)->GetName() == "SegmentTimeline")
+ {
+ object.SetSegmentTimeline(subNodes.at(i)->ToSegmentTimeline());
+ continue;
+ }
+ if (subNodes.at(i)->GetName() == "BitstreamSwitching")
+ {
+ object.SetBitstreamSwitching(subNodes.at(i)->ToURLType(dash::metrics::BitstreamSwitchingSegment));
+ continue;
+ }
+ }
+
+}
diff --git a/libdash/source/xml/Node.h b/libdash/source/xml/Node.h
new file mode 100644
index 00000000..552d83e5
--- /dev/null
+++ b/libdash/source/xml/Node.h
@@ -0,0 +1,105 @@
+/*
+ * Node.h
+ *****************************************************************************
+ * Copyright (C) 2012, 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.
+ *****************************************************************************/
+
+#ifndef NODE_H_
+#define NODE_H_
+
+#include "config.h"
+
+#include "INode.h"
+#include "../helpers/String.h"
+#include "../mpd/AdaptationSet.h"
+#include "../mpd/BaseUrl.h"
+#include "../mpd/ContentComponent.h"
+#include "../mpd/Descriptor.h"
+#include "../mpd/Metrics.h"
+#include "../mpd/MPD.h"
+#include "../mpd/MultipleSegmentBase.h"
+#include "../mpd/Period.h"
+#include "../mpd/ProgramInformation.h"
+#include "../mpd/Range.h"
+#include "../mpd/Representation.h"
+#include "../mpd/RepresentationBase.h"
+#include "../mpd/SegmentBase.h"
+#include "../mpd/SegmentList.h"
+#include "../mpd/SegmentTemplate.h"
+#include "../mpd/SegmentTimeline.h"
+#include "../mpd/SegmentURL.h"
+#include "../mpd/SubRepresentation.h"
+#include "../mpd/Subset.h"
+#include "../mpd/URLType.h"
+#include "IHTTPTransaction.h"
+
+namespace dash
+{
+ namespace xml
+ {
+ class Node : public INode
+ {
+ public:
+ Node ();
+ Node (const Node& other);
+ virtual ~Node ();
+
+ const std::vector<INode *>& GetNodes () const;
+ const std::vector<Node *>& GetSubNodes () const;
+ std::vector<std::string> GetAttributeKeys () const;
+ const std::string& GetName () const;
+ std::string GetText () const;
+ const std::map<std::string, std::string>& GetAttributes () const;
+ int GetType () const;
+ void SetType (int type);
+ const std::string& GetAttributeValue (std::string key) const;
+ void AddSubNode (Node *node);
+ void SetName (const std::string &name);
+ bool HasAttribute (const std::string& name) const;
+ void AddAttribute (const std::string &key, const std::string &value);
+ bool HasText () const;
+ void SetText (const std::string &text);
+ void Print (std::ostream &stream) const;
+ dash::mpd::MPD* ToMPD () const;
+ void SetMPDPath (std::string path);
+
+ private:
+ void SetCommonValuesForRep (dash::mpd::RepresentationBase& object) const;
+ void SetCommonValuesForSeg (dash::mpd::SegmentBase& object) const;
+ void SetCommonValuesForMSeg (dash::mpd::MultipleSegmentBase& object) const;
+ dash::mpd::AdaptationSet* ToAdaptationSet () const;
+ dash::mpd::BaseUrl* ToBaseUrl () const;
+ dash::mpd::ContentComponent* ToContentComponent () const;
+ dash::mpd::Descriptor* ToDescriptor () const;
+ dash::mpd::Metrics* ToMetrics () const;
+ dash::mpd::Period* ToPeriod () const;
+ dash::mpd::ProgramInformation* ToProgramInformation () const;
+ dash::mpd::Range* ToRange () const;
+ dash::mpd::Representation* ToRepresentation () const;
+ dash::mpd::SegmentBase* ToSegmentBase () const;
+ dash::mpd::SegmentList* ToSegmentList () const;
+ dash::mpd::SegmentTemplate* ToSegmentTemplate () const;
+ dash::mpd::Timeline* ToTimeline () const;
+ dash::mpd::SegmentTimeline* ToSegmentTimeline () const;
+ dash::mpd::SegmentURL* ToSegmentURL () const;
+ dash::mpd::SubRepresentation* ToSubRepresentation () const;
+ dash::mpd::Subset* ToSubset () const;
+ dash::mpd::URLType* ToURLType (dash::metrics::HTTPTransactionType transActType) const;
+
+ std::vector<Node *> subNodes;
+ std::map<std::string, std::string> attributes;
+ std::string name;
+ std::string text;
+ int type;
+ std::string mpdPath;
+
+ };
+ }
+}
+
+#endif /* NODE_H_ */