aboutsummaryrefslogtreecommitdiffstats
path: root/Input
diff options
context:
space:
mode:
Diffstat (limited to 'Input')
-rw-r--r--Input/DASHManager.cpp21
-rw-r--r--Input/DASHManager.h25
-rw-r--r--Input/DASHReceiver.cpp291
-rw-r--r--Input/DASHReceiver.h44
-rw-r--r--Input/ICNConnectionConsumerApi.cpp8
-rw-r--r--Input/IDASHManagerObserver.h1
-rw-r--r--Input/IDASHReceiverObserver.h1
-rw-r--r--Input/MediaObject.cpp22
-rw-r--r--Input/MediaObject.h6
9 files changed, 235 insertions, 184 deletions
diff --git a/Input/DASHManager.cpp b/Input/DASHManager.cpp
index a86263dc..4d52a638 100644
--- a/Input/DASHManager.cpp
+++ b/Input/DASHManager.cpp
@@ -17,8 +17,9 @@ using namespace libdash::framework::buffer;
using namespace dash;
using namespace dash::network;
using namespace dash::mpd;
+using namespace libdash::framework::mpd;
-DASHManager::DASHManager(viper::managers::StreamType type, uint32_t maxCapacity, IDASHManagerObserver* stream, IMPD* mpd, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop) :
+DASHManager::DASHManager(viper::managers::StreamType type, uint32_t maxCapacity, IDASHManagerObserver* stream, MPDWrapper* mpdWrapper, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop) :
readSegmentCount (0),
receiver (NULL),
multimediaStream (stream),
@@ -33,7 +34,7 @@ DASHManager::DASHManager(viper::managers::StreamType type, uint32_t maxCapacity,
this->buffer = new Buffer<MediaObject>(maxCapacity,libdash::framework::buffer::VIDEO);
this->buffer->attachObserver(this);
- this->receiver = new DASHReceiver(mpd, this, this->buffer, maxCapacity, this->isICN(), this->icnAlpha, this->beta, this->drop);
+ this->receiver = new DASHReceiver(type, mpdWrapper, this, this->buffer, maxCapacity, this->isICN(), this->icnAlpha, this->beta, this->drop);
}
DASHManager::~DASHManager()
{
@@ -107,14 +108,14 @@ void DASHManager::clear()
this->buffer->clear();
}
-void DASHManager::setRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+void DASHManager::setRepresentation()
{
- this->receiver->SetRepresentation(period, adaptationSet, representation);
+ this->receiver->SetRepresentation();
}
void DASHManager::enqueueRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
{
- this->receiver->SetRepresentation(period, adaptationSet, representation);
+// this->receiver->SetRepresentation(period, adaptationSet, representation);
}
void DASHManager::onSegmentDownloaded()
@@ -159,3 +160,13 @@ void DASHManager::onBufferStateChanged(BufferType type, uint32_t fillstateInPerc
if(this->adaptationLogic->isBufferBased())
this->receiver->OnSegmentBufferStateChanged(fillstateInPercent, maxC);
}
+
+void DASHManager::updateMPD(IMPD* mpd)
+{
+// this->receiver->updateMPD(mpd);
+}
+
+void DASHManager::fetchMPD()
+{
+ this->multimediaStream->fetchMPD();
+}
diff --git a/Input/DASHManager.h b/Input/DASHManager.h
index 2b723426..6bd54da9 100644
--- a/Input/DASHManager.h
+++ b/Input/DASHManager.h
@@ -22,18 +22,21 @@
#include "../Managers/IStreamObserver.h"
#include "../Buffer/IBufferObserver.h"
-
namespace libdash
{
namespace framework
{
+namespace mpd
+{
+class MPDWrapper;
+}
namespace input
{
class DASHManager : public IDASHReceiverObserver, public IBufferObserver
{
public:
- DASHManager (viper::managers::StreamType type, uint32_t maxCapacity, IDASHManagerObserver *multimediaStream, dash::mpd::IMPD *mpd, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop);
+ DASHManager (viper::managers::StreamType type, uint32_t maxCapacity, IDASHManagerObserver *multimediaStream, libdash::framework::mpd::MPDWrapper *mpdWrapper, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop);
virtual ~DASHManager ();
bool start();
@@ -43,7 +46,8 @@ public:
void setLooping(bool looping);
void setPositionInMsec(uint32_t millisec);
void clear();
- void setRepresentation(dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
+// void setRepresentation(dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
+ void setRepresentation();
void enqueueRepresentation(dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
void onSegmentDownloaded();
@@ -58,19 +62,20 @@ public:
void setTargetDownloadingTime(double);
MediaObject* getSegment();
void onBufferStateChanged(BufferType type, uint32_t fillstateInPercent, int maxC);
+ void updateMPD(dash::mpd::IMPD* mpd);
+ void fetchMPD();
private:
- float beta;
- float drop;
- buffer::Buffer<MediaObject> *buffer;
- DASHReceiver *receiver;
- uint32_t readSegmentCount;
- IDASHManagerObserver *multimediaStream;
+ float beta;
+ float drop;
+ buffer::Buffer<MediaObject> *buffer;
+ DASHReceiver *receiver;
+ uint32_t readSegmentCount;
+ IDASHManagerObserver *multimediaStream;
bool isRunning;
bool icn;
double icnAlpha;
bool noDecoding;
-
libdash::framework::adaptation::IAdaptationLogic *adaptationLogic;
};
}
diff --git a/Input/DASHReceiver.cpp b/Input/DASHReceiver.cpp
index bbfe3e35..aaa75205 100644
--- a/Input/DASHReceiver.cpp
+++ b/Input/DASHReceiver.cpp
@@ -19,44 +19,47 @@ using namespace dash::mpd;
using duration_in_seconds = std::chrono::duration<double, std::ratio<1, 1> >;
-DASHReceiver::DASHReceiver (IMPD *mpd, IDASHReceiverObserver *obs, Buffer<MediaObject> *buffer, uint32_t bufferSize, bool icnEnabled, double icnAlpha, float beta, float drop) :
- mpd (mpd),
- period (NULL),
- adaptationSet (NULL),
- representation (NULL),
- adaptationSetStream (NULL),
- representationStream (NULL),
- segmentNumber (0),
- observer (obs),
- buffer (buffer),
- bufferSize (bufferSize),
- isBuffering (false),
- withFeedBack (false),
- icn (icnEnabled),
- icnAlpha (icnAlpha),
- previousQuality (0),
- isPaused (false),
- threadComplete (false),
- isScheduledPaced (false),
- targetDownload (0.0),
- downloadingTime (0.0),
- bufferLevelAtUpdate (0),
- isBufferBased (false),
- isLooping (false),
- beta (beta),
- drop (drop)
+DASHReceiver::DASHReceiver (viper::managers::StreamType type, MPDWrapper *mpdWrapper, IDASHReceiverObserver *obs, Buffer<MediaObject> *buffer, uint32_t bufferSize, bool icnEnabled, double icnAlpha, float beta, float drop) :
+ type (type),
+ mpdWrapper (mpdWrapper),
+// period (NULL),
+// adaptationSet (NULL),
+// representation (NULL),
+ adaptationSetStream (NULL),
+// representationStream (NULL),
+ segmentNumber (0),
+ observer (obs),
+ buffer (buffer),
+ bufferSize (bufferSize),
+ isBuffering (false),
+ withFeedBack (false),
+ icn (icnEnabled),
+ icnAlpha (icnAlpha),
+ previousQuality (0),
+ isPaused (false),
+ threadComplete (false),
+ isScheduledPaced (false),
+ targetDownload (0.0),
+ downloadingTime (0.0),
+ bufferLevelAtUpdate (0),
+ isBufferBased (false),
+ isLooping (false),
+ beta (beta),
+ drop (drop),
+ bufferingThread (NULL),
+ mpdFetcherThread (NULL)
{
readMax = 32768;
readBuffer = (uint8_t*)malloc(sizeof(uint8_t)*readMax);
- this->period = this->mpd->GetPeriods().at(0);
- this->adaptationSet = this->period->GetAdaptationSets().at(0);
- this->representation = this->adaptationSet->GetRepresentation().at(0);
+// this->period = this->mpd->GetPeriods().at(0);
+// this->adaptationSet = this->period->GetAdaptationSets().at(0);
+// this->representation = this->adaptationSet->GetRepresentation().at(0);
- this->adaptationSetStream = new AdaptationSetStream(mpd, period, adaptationSet);
- this->representationStream = adaptationSetStream->getRepresentationStream(this->representation);
+ this->adaptationSetStream = new AdaptationSetStream(type, mpdWrapper);
+// this->representationStream = adaptationSetStream->getRepresentationStream(this->representation);
this->segmentOffset = CalculateSegmentOffset();
- this->representationStream->setSegmentOffset(this->segmentOffset);
-
+// this->representationStream->setSegmentOffset(this->segmentOffset);
+ this->mpdWrapper->setSegmentOffset(type, this->segmentOffset);
this->conn = NULL;
this->initConn = NULL;
readMax = 32768;
@@ -103,7 +106,15 @@ bool DASHReceiver::Start ()
this->isBuffering = false;
return false;
}
-
+ //if dynamic, set up the fetching loop
+ if(!strcmp(this->mpdWrapper->getType().c_str(), "dynamic"))
+ {
+ this->mpdFetcherThread = createThreadPortable(DoMPDFetching, this);
+ if(this->mpdFetcherThread == NULL)
+ {
+ std::cout << "mpd Fetcher thread is NULL. Need to think of how to handle this?" << std::endl;
+ }
+ }
return true;
}
void DASHReceiver::Stop()
@@ -119,83 +130,43 @@ void DASHReceiver::Stop()
JoinThread(this->bufferingThread);
destroyThreadPortable(this->bufferingThread);
}
- this->period = this->mpd->GetPeriods().at(0);
- this->adaptationSet = this->period->GetAdaptationSets().at(0);
- this->representation = this->adaptationSet->GetRepresentation().at(0);
+ if(this->mpdFetcherThread != NULL)
+ {
+ JoinThread(this->mpdFetcherThread);
+ destroyThreadPortable(this->mpdFetcherThread);
+ }
}
MediaObject* DASHReceiver::GetNextSegment ()
{
- ISegment *seg = NULL;
EnterCriticalSection(&this->monitorPausedMutex);
while(this->isPaused)
SleepConditionVariableCS(&this->paused, &this->monitorPausedMutex, INFINITE);
- if(!strcmp(this->mpd->GetType().c_str(), "static"))
- {
- if(this->segmentNumber >= this->representationStream->getSize())
- {
- qDebug("looping? : %s\n", this->isLooping ? "YES" : "NO");
- if(this->isLooping)
- {
- this->segmentNumber = 0;
- }
- else
- {
- LeaveCriticalSection(&this->monitorPausedMutex);
- return NULL;
- }
- }
- }
- seg = this->representationStream->getMediaSegment(this->segmentNumber);
-
- if (seg != NULL)
- {
- std::vector<IRepresentation *> rep = this->adaptationSet->GetRepresentation();
-
- this->NotifyQualityDownloading(this->representation->GetBandwidth());
+ MediaObject *media = this->mpdWrapper->getNextSegment(type, isLooping, this->segmentNumber, withFeedBack);
- MediaObject *media = new MediaObject(seg, this->representation,this->withFeedBack);
- this->segmentNumber++;
- LeaveCriticalSection(&this->monitorPausedMutex);
- return media;
- }
+ if(media)
+ this->NotifyQualityDownloading(media->GetRepresentationBandwidth());
LeaveCriticalSection(&this->monitorPausedMutex);
- return NULL;
+ return media;
}
MediaObject* DASHReceiver::GetSegment (uint32_t segNum)
{
- ISegment *seg = NULL;
-
- if(segNum >= this->representationStream->getSize())
- return NULL;
-
- seg = this->representationStream->getMediaSegment(segNum);
-
- if (seg != NULL)
- {
- MediaObject *media = new MediaObject(seg, this->representation);
- return media;
- }
-
- return NULL;
+ return this->mpdWrapper->getSegment(type, segNum);
}
+
MediaObject* DASHReceiver::GetInitSegment ()
{
- ISegment *seg = NULL;
-
- seg = this->representationStream->getInitializationSegment();
-
- if (seg != NULL)
- {
- MediaObject *media = new MediaObject(seg, this->representation);
- return media;
- }
+ return this->mpdWrapper->getInitSegment(type);
+}
- return NULL;
+MediaObject* DASHReceiver::GetInitSegmentWithoutLock ()
+{
+ return this->mpdWrapper->getInitSegmentWithoutLock(type);
}
-MediaObject* DASHReceiver::FindInitSegment (dash::mpd::IRepresentation *representation)
+
+MediaObject* DASHReceiver::FindInitSegment (int representation)
{
if (!this->InitSegmentExists(representation))
return NULL;
@@ -224,45 +195,9 @@ void DASHReceiver::NotifyQualityDownloading (uint32_t quality)
this->observer->notifyQualityDownloading(quality);
}
-void DASHReceiver::SetRepresentation (IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+void DASHReceiver::SetRepresentation ()
{
- EnterCriticalSection(&this->monitorMutex);
-
- bool periodChanged = false;
-
- if (this->representation == representation)
- {
- LeaveCriticalSection(&this->monitorMutex);
- return;
- }
-
- this->representation = representation;
-
- if (this->adaptationSet != adaptationSet)
- {
- this->adaptationSet = adaptationSet;
-
- if (this->period != period)
- {
- this->period = period;
- periodChanged = true;
- }
-
- delete this->adaptationSetStream;
- this->adaptationSetStream = NULL;
-
- this->adaptationSetStream = new AdaptationSetStream(this->mpd, this->period, this->adaptationSet);
- }
-
- this->representationStream = this->adaptationSetStream->getRepresentationStream(this->representation);
- this->DownloadInitSegment(this->representation);
-
- if (periodChanged)
- {
- this->segmentNumber = 0;
- this->CalculateSegmentOffset();
- }
- LeaveCriticalSection(&this->monitorMutex);
+ this->DownloadInitSegmentWithoutLock();
}
libdash::framework::adaptation::IAdaptationLogic* DASHReceiver::GetAdaptationLogic ()
@@ -271,19 +206,13 @@ libdash::framework::adaptation::IAdaptationLogic* DASHReceiver::GetAdaptationLog
}
dash::mpd::IRepresentation* DASHReceiver::GetRepresentation ()
{
- return this->representation;
+ return NULL;
}
uint32_t DASHReceiver::CalculateSegmentOffset ()
{
- if (mpd->GetType() == "static")
- return 0;
-
- uint32_t firstSegNum = this->representationStream->getFirstSegmentNumber();
- uint32_t currSegNum = this->representationStream->getCurrentSegmentNumber();
- uint32_t startSegNum = currSegNum - 2*bufferSize;
-
- return (startSegNum > firstSegNum) ? startSegNum : firstSegNum;
+ return this->mpdWrapper->calculateSegmentOffset(type, bufferSize);
}
+
void DASHReceiver::NotifySegmentDownloaded ()
{
this->observer->onSegmentDownloaded();
@@ -291,14 +220,32 @@ void DASHReceiver::NotifySegmentDownloaded ()
void DASHReceiver::NotifyBitrateChange(dash::mpd::IRepresentation *representation)
{
- if(this->representation != representation)
+// if(this->representation != representation)
+// {
+// this->representation = representation;
+// this->SetRepresentation(this->period,this->adaptationSet,this->representation);
+// }
+}
+void DASHReceiver::DownloadInitSegmentWithoutLock ()
+{
+ int rep = std::stoi(this->mpdWrapper->getRepresentationIDWithoutLock(type).c_str());
+ if (this->InitSegmentExists(rep))
+ return;
+
+ MediaObject *initSeg = NULL;
+ initSeg = this->GetInitSegmentWithoutLock();
+
+ if (initSeg)
{
- this->representation = representation;
- this->SetRepresentation(this->period,this->adaptationSet,this->representation);
+ initSeg->StartDownload(this->initConn);
+ this->initSegments[rep] = initSeg;
+ initSeg->WaitFinished();
}
}
-void DASHReceiver::DownloadInitSegment (IRepresentation* rep)
+
+void DASHReceiver::DownloadInitSegment ()
{
+ int rep = std::stoi(this->mpdWrapper->getRepresentationID(type).c_str());
if (this->InitSegmentExists(rep))
return;
@@ -312,7 +259,8 @@ void DASHReceiver::DownloadInitSegment (IRepresentatio
initSeg->WaitFinished();
}
}
-bool DASHReceiver::InitSegmentExists (IRepresentation* rep)
+
+bool DASHReceiver::InitSegmentExists (int rep)
{
if (this->initSegments.find(rep) != this->initSegments.end())
return true;
@@ -358,20 +306,18 @@ void DASHReceiver::OnEOS(bool value)
bool DASHReceiver::PushBack(MediaObject *mediaObject)
{
- MediaObject *init = this->FindInitSegment(mediaObject->GetRepresentation());
+ MediaObject *init = this->FindInitSegment(mediaObject->GetRepresentationID());
mediaObject->AddInitSegment(init);
//TODO the read should be in a function
//Grab the infos for the analytics: bitrate, fps
- dash::mpd::IRepresentation* datRep = mediaObject->GetRepresentation();
uint32_t bitrate = 0;
int fps = 0;
uint32_t quality = 0;
- bitrate = datRep->GetBandwidth();
- quality = datRep->GetHeight();
+ bitrate = mediaObject->GetRepresentationBandwidth();
+ quality = mediaObject->GetRepresentationHeight();
fps = this->bufferLevelAtUpdate;
this->observer->notifyStatistics((int)this->segmentNumber - 1, bitrate, fps, quality);
-
return(this->buffer->pushBack(mediaObject));
}
@@ -380,7 +326,7 @@ void* DASHReceiver::DoBuffering (void *recei
{
DASHReceiver *dashReceiver = (DASHReceiver *) receiver;
- dashReceiver->DownloadInitSegment(dashReceiver->GetRepresentation());
+ dashReceiver->DownloadInitSegment();
MediaObject *media = dashReceiver->GetNextSegment();
dashReceiver->NotifyCheckedAdaptationLogic();
@@ -426,6 +372,25 @@ void* DASHReceiver::DoBuffering (void *recei
return NULL;
}
+void* DASHReceiver::DoMPDFetching (void* receiver)
+{
+ DASHReceiver* dashReceiver = (DASHReceiver*) receiver;
+ uint32_t currTime = TimeResolver::getCurrentTimeInSec();
+ uint32_t publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
+ uint32_t period = TimeResolver::getDurationInSec(dashReceiver->mpdWrapper->getMinimumUpdatePeriod());
+ while(dashReceiver->isBuffering)
+ {
+ while(dashReceiver->isBuffering && currTime < publishedTime + period)
+ {
+ usleep(((publishedTime + period) - currTime) * 1000000);
+ currTime = TimeResolver::getCurrentTimeInSec();
+ }
+ dashReceiver->observer->fetchMPD();
+ publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
+ period = TimeResolver::getDurationInSec(dashReceiver->mpdWrapper->getMinimumUpdatePeriod());
+ }
+}
+
//can Push video to buffer in the renderer
bool DASHReceiver::CanPush ()
{
@@ -454,4 +419,30 @@ void DASHReceiver::SetDrop (float drop)
this->drop = drop;
}
+void DASHReceiver::updateMPD(IMPD* mpd)
+{
+// EnterCriticalSection(&this->monitorMutex);
+ //First we need to find the new segmentNumber -> what is the segment time now?
+// uint32_t time = this->representationStream->getTime(this->segmentNumber);
+// printf("old segmentNumber!: %d\n", this->segmentNumber);
+// printf("time: %u\n", time);
+ //Second, replace the MPD with the new one
+// delete(this->mpd);
+// this->mpd = mpd;
+//
+ //Third, Update all the structures associated to the mpd
+// this->period = this->mpd->GetPeriods().at(0);
+// this->adaptationSet = this->period->GetAdaptationSets().at(0);
+// this->representation = this->adaptationSet->GetRepresentation().at(0);
+// delete(this->adaptationSetStream);
+// this->adaptationSetStream = new AdaptationSetStream(mpd, period, adaptationSet);
+// this->representationStream = adaptationSetStream->getRepresentationStream(this->representation);
+// this->segmentOffset = CalculateSegmentOffset();
+// this->representationStream->setSegmentOffset(this->segmentOffset);
+//
+ //Fourth, Set the new segmentNumber by finding the index of the segment associated to 'uint32_t time' in the new mpd
+// this->segmentNumber = this->representationStream->getSegmentNumber(time);
+// printf("new segmentNumber!: %d\n", this->segmentNumber);
+// LeaveCriticalSection(&this->monitorMutex);
+}
diff --git a/Input/DASHReceiver.h b/Input/DASHReceiver.h
index a2893b4d..cf56166b 100644
--- a/Input/DASHReceiver.h
+++ b/Input/DASHReceiver.h
@@ -14,7 +14,7 @@
#include "libdash.h"
#include "IMPD.h"
-
+#include "../MPD/MPDWrapper.h"
#include "../Input/MediaObject.h"
#include "IDASHReceiverObserver.h"
#include "../MPD/AdaptationSetStream.h"
@@ -28,6 +28,10 @@ namespace libdash
{
namespace framework
{
+namespace mpd
+{
+class AdaptationSetStream;
+}
namespace adaptation
{
class IAdaptationLogic;
@@ -44,7 +48,7 @@ class MediaObject;
class DASHReceiver
{
public:
- DASHReceiver(dash::mpd::IMPD *mpd, IDASHReceiverObserver *obs, buffer::Buffer<MediaObject> *buffer, uint32_t bufferSize, bool icnEnabled, double icnAlpha, float beta, float drop);
+ DASHReceiver(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, IDASHReceiverObserver *obs, buffer::Buffer<MediaObject> *buffer, uint32_t bufferSize, bool icnEnabled, double icnAlpha, float beta, float drop);
virtual ~DASHReceiver();
bool Start();
@@ -52,15 +56,18 @@ public:
input::MediaObject* GetNextSegment();
input::MediaObject* GetSegment(uint32_t segmentNumber);
input::MediaObject* GetInitSegment();
- input::MediaObject* FindInitSegment(dash::mpd::IRepresentation *representation);
+ input::MediaObject* GetInitSegmentWithoutLock();
+// input::MediaObject* FindInitSegment(dash::mpd::IRepresentation *representation);
+ input::MediaObject* FindInitSegment(int representation);
uint32_t GetPosition();
void SetPosition(uint32_t segmentNumber);
void SetLooping(bool isLoopinp);
void SetPositionInMsecs(uint32_t milliSecs);
dash::mpd::IRepresentation* GetRepresentation();
- void SetRepresentation(dash::mpd::IPeriod *period,
- dash::mpd::IAdaptationSet *adaptationSet,
- dash::mpd::IRepresentation *representation);
+// void SetRepresentation(dash::mpd::IPeriod *period,
+// dash::mpd::IAdaptationSet *adaptationSet,
+// dash::mpd::IRepresentation *representation);
+ void SetRepresentation();
void SetAdaptationLogic(adaptation::IAdaptationLogic *_adaptationLogic);
libdash::framework::adaptation::IAdaptationLogic* GetAdaptationLogic();
void NotifyQualityDownloading(uint32_t quality);
@@ -78,21 +85,24 @@ public:
bool CanPush();
void SetBeta(float beta);
void SetDrop(float drop);
+ void updateMPD(dash::mpd::IMPD* mpd);
private:
float beta;
float drop;
bool withFeedBack;
bool isBufferBased;
- std::map<dash::mpd::IRepresentation*, MediaObject*> initSegments;
+// std::map<dash::mpd::IRepresentation*, MediaObject*> initSegments;
+ std::map<int, MediaObject*> initSegments;
libdash::framework::buffer::Buffer<MediaObject> *buffer;
IDASHReceiverObserver *observer;
- dash::mpd::IMPD *mpd;
- dash::mpd::IPeriod *period;
- dash::mpd::IAdaptationSet *adaptationSet;
- dash::mpd::IRepresentation *representation;
+ libdash::framework::mpd::MPDWrapper *mpdWrapper;
+// dash::mpd::IMPD *mpd;
+// dash::mpd::IPeriod *period;
+// dash::mpd::IAdaptationSet *adaptationSet;
+// dash::mpd::IRepresentation *representation;
mpd::AdaptationSetStream *adaptationSetStream;
- mpd::IRepresentationStream *representationStream;
+// mpd::IRepresentationStream *representationStream;
uint32_t segmentNumber;
uint32_t positionInMsecs;
uint32_t segmentOffset;
@@ -109,6 +119,7 @@ private:
IICNConnection *conn;
IICNConnection *initConn;
THREAD_HANDLE bufferingThread;
+ THREAD_HANDLE mpdFetcherThread;
bool isBuffering;
bool icn;
double icnAlpha;
@@ -116,11 +127,16 @@ private:
int bufferLevelAtUpdate;
int readMax;
uint8_t *readBuffer;
+ viper::managers::StreamType type;
uint32_t CalculateSegmentOffset();
void NotifySegmentDownloaded();
- void DownloadInitSegment(dash::mpd::IRepresentation* rep);
- bool InitSegmentExists(dash::mpd::IRepresentation* rep);
+// void DownloadInitSegment(dash::mpd::IRepresentation* rep);
+ void DownloadInitSegment();
+ void DownloadInitSegmentWithoutLock();
+// bool InitSegmentExists(dash::mpd::IRepresentation* rep);
+ bool InitSegmentExists(int rep);
static void* DoBuffering(void *receiver);
+ static void* DoMPDFetching(void * data);
};
}
}
diff --git a/Input/ICNConnectionConsumerApi.cpp b/Input/ICNConnectionConsumerApi.cpp
index 8f28e5ce..04b378df 100644
--- a/Input/ICNConnectionConsumerApi.cpp
+++ b/Input/ICNConnectionConsumerApi.cpp
@@ -68,7 +68,7 @@ ICNConnectionConsumerApi::ICNConnectionConsumerApi(double alpha, float beta, flo
}
if(!configFile)
{
- qDebug("beta %f, drop %f", this->beta, this->drop);
+// qDebug("beta %f, drop %f", this->beta, this->drop);
// this->myConsumer->setSocketOption(RaaqmTransportOptions::BETA_VALUE, this->beta);
// this->myConsumer->setSocketOption(RaaqmTransportOptions::DROP_FACTOR, this->drop);
}
@@ -104,8 +104,8 @@ void ICNConnectionConsumerApi::Init(IChunk *chunk) {
m_isFinished = false;
res = false;
- qDebug("ICN_Connection:\tINTIATED_to_name %s\n", m_name.c_str());
- qDebug("ICN_Connection:\tSTARTING DOWNLOAD %s\n", m_name.c_str());
+ Debug("ICN_Connection:\tINTIATED_to_name %s\n", m_name.c_str());
+ Debug("ICN_Connection:\tSTARTING DOWNLOAD %s\n", m_name.c_str());
}
void ICNConnectionConsumerApi::InitForMPD(const std::string& url)
@@ -118,7 +118,6 @@ void ICNConnectionConsumerApi::InitForMPD(const std::string& url)
res = false;
dataPos = 0;
datSize = 0;
-
Debug("ICN_Connection:\tINTIATED_for_mpd %s\n", m_name.c_str());
}
@@ -134,7 +133,6 @@ int ICNConnectionConsumerApi::Read(uint8_t *data, size_t len)
std::string s(m_name.c_str());
hTTPClientConnection->get(s);
response = hTTPClientConnection->response();
- std::cout << m_name.c_str()<< " SIZE:" << response.size() << std::endl;
this->res = true;
this->dataPos = 0;
}
diff --git a/Input/IDASHManagerObserver.h b/Input/IDASHManagerObserver.h
index c5df8fe9..1003d8a1 100644
--- a/Input/IDASHManagerObserver.h
+++ b/Input/IDASHManagerObserver.h
@@ -34,6 +34,7 @@ public:
virtual void notifyQualityDownloading (uint32_t quality) = 0;
virtual bool canPush() = 0;
virtual int getBufferLevel() = 0;
+ virtual void fetchMPD() = 0;
};
}
}
diff --git a/Input/IDASHReceiverObserver.h b/Input/IDASHReceiverObserver.h
index 0a334aa2..f6a2baa1 100644
--- a/Input/IDASHReceiverObserver.h
+++ b/Input/IDASHReceiverObserver.h
@@ -28,6 +28,7 @@ public:
virtual void notifyQualityDownloading(uint32_t quality) = 0;
virtual bool canPush() = 0;
virtual int getBufferLevel() = 0;
+ virtual void fetchMPD() = 0;
};
}
}
diff --git a/Input/MediaObject.cpp b/Input/MediaObject.cpp
index ae6b9f6b..f479a886 100644
--- a/Input/MediaObject.cpp
+++ b/Input/MediaObject.cpp
@@ -26,6 +26,9 @@ MediaObject::MediaObject(ISegment *segment, IRepresentation *rep, bool withFeedB
this->initSeg = NULL;
InitializeConditionVariable (&this->stateChanged);
InitializeCriticalSection (&this->stateLock);
+ this->representationBandwidth = rep->GetBandwidth();
+ this->representationHeight = rep->GetHeight();
+ this->representationId = std::stoi(rep->GetId());
}
MediaObject::~MediaObject()
@@ -44,6 +47,21 @@ MediaObject::~MediaObject()
this->segment = NULL;
}
+uint32_t MediaObject::GetRepresentationBandwidth()
+{
+ return this->representationBandwidth;
+}
+
+uint32_t MediaObject::GetRepresentationHeight()
+{
+ return this->representationHeight;
+}
+
+int MediaObject::GetRepresentationID()
+{
+ return this->representationId;
+}
+
void MediaObject::SetFeedBack(bool flag)
{
this->withFeedBack = flag;
@@ -57,9 +75,13 @@ void MediaObject::AddInitSegment(MediaObject* initSeg)
int MediaObject::ReadInitSegment(uint8_t* data, size_t len)
{
if(this->initSeg)
+ {
return this->initSeg->Peek(data,len);
+ }
else
+ {
return 0;
+ }
}
bool MediaObject::StartDownload()
diff --git a/Input/MediaObject.h b/Input/MediaObject.h
index 9d5c7826..1edd69af 100644
--- a/Input/MediaObject.h
+++ b/Input/MediaObject.h
@@ -57,6 +57,9 @@ public:
const std::vector<dash::metrics::IHTTPTransaction *>& GetHTTPTransactionList() const;
void SetAdaptationLogic(framework::adaptation::IAdaptationLogic *_adaptationLogic);
void SetDASHReceiver(input::DASHReceiver *_dashReceiver);
+ uint32_t GetRepresentationBandwidth();
+ uint32_t GetRepresentationHeight();
+ int GetRepresentationID();
private:
dash::mpd::ISegment *segment;
@@ -70,6 +73,9 @@ private:
adaptation::IAdaptationLogic *adaptationLogic;
mutable CRITICAL_SECTION stateLock;
mutable CONDITION_VARIABLE stateChanged;
+ uint32_t representationBandwidth;
+ uint32_t representationHeight;
+ int representationId;
};
}
}