aboutsummaryrefslogtreecommitdiffstats
path: root/Input
diff options
context:
space:
mode:
Diffstat (limited to 'Input')
-rw-r--r--Input/DASHManager.cpp4
-rw-r--r--Input/DASHManager.h1
-rw-r--r--Input/DASHReceiver.cpp41
-rw-r--r--Input/DASHReceiver.h2
-rw-r--r--Input/IDASHManagerObserver.h1
-rw-r--r--Input/IDASHReceiverObserver.h1
6 files changed, 44 insertions, 6 deletions
diff --git a/Input/DASHManager.cpp b/Input/DASHManager.cpp
index 0c393353..b3ff8305 100644
--- a/Input/DASHManager.cpp
+++ b/Input/DASHManager.cpp
@@ -160,3 +160,7 @@ void DASHManager::onBufferStateChanged(BufferType type, uint32_t fillstateInPerc
if(this->adaptationLogic->isBufferBased())
this->receiver->OnSegmentBufferStateChanged(fillstateInPercent, maxC);
}
+void DASHManager::fetchMPD()
+{
+ this->multimediaStream->fetchMPD();
+}
diff --git a/Input/DASHManager.h b/Input/DASHManager.h
index 3b9bf005..4bd301e7 100644
--- a/Input/DASHManager.h
+++ b/Input/DASHManager.h
@@ -61,6 +61,7 @@ public:
void setTargetDownloadingTime(double);
MediaObject* getSegment();
void onBufferStateChanged(BufferType type, uint32_t fillstateInPercent, int maxC);
+ void fetchMPD();
private:
float beta;
diff --git a/Input/DASHReceiver.cpp b/Input/DASHReceiver.cpp
index 74415bfa..0d77bdf2 100644
--- a/Input/DASHReceiver.cpp
+++ b/Input/DASHReceiver.cpp
@@ -42,7 +42,8 @@ DASHReceiver::DASHReceiver (viper::managers::StreamType type, MPDWrappe
isLooping (false),
beta (beta),
drop (drop),
- bufferingThread (NULL)
+ bufferingThread (NULL),
+ mpdFetcherThread (NULL)
{
readMax = 32768;
readBuffer = (uint8_t*)malloc(sizeof(uint8_t)*readMax);
@@ -95,6 +96,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()
@@ -260,8 +270,8 @@ void DASHReceiver::NotifyCheckedAdaptationLogic()
//Is only called when this->adaptationLogic->IsBufferBased
void DASHReceiver::OnSegmentBufferStateChanged(uint32_t fillstateInPercent, int maxC)
{
- this->adaptationLogic->bufferUpdate(this->observer->getBufferLevel(), maxC);
this->bufferLevelAtUpdate = this->observer->getBufferLevel();
+ this->adaptationLogic->bufferUpdate(this->bufferLevelAtUpdate, maxC);
}
void DASHReceiver::OnEOS(bool value)
{
@@ -274,14 +284,14 @@ bool DASHReceiver::PushBack(MediaObject *mediaObject)
mediaObject->AddInitSegment(init);
//TODO the read should be in a function
- //Grab the infos for the analytics: bitrate, fps
+ //Grab the infos for the analytics: bitrate, bufferLevel
uint32_t bitrate = 0;
- int fps = 0;
+ int bufferLevel = 0;
uint32_t quality = 0;
bitrate = mediaObject->GetRepresentationBandwidth();
quality = mediaObject->GetRepresentationHeight();
- fps = this->bufferLevelAtUpdate;
- this->observer->notifyStatistics((int)this->segmentNumber - 1, bitrate, fps, quality);
+ bufferLevel = this->bufferLevelAtUpdate;
+ this->observer->notifyStatistics((int)this->segmentNumber - 1, bitrate, bufferLevel, quality);
return(this->buffer->pushBack(mediaObject));
}
@@ -335,6 +345,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 ()
{
diff --git a/Input/DASHReceiver.h b/Input/DASHReceiver.h
index a6db0382..e5b48adf 100644
--- a/Input/DASHReceiver.h
+++ b/Input/DASHReceiver.h
@@ -107,6 +107,7 @@ private:
IICNConnection *conn;
IICNConnection *initConn;
THREAD_HANDLE bufferingThread;
+ THREAD_HANDLE mpdFetcherThread;
bool isBuffering;
bool icn;
double icnAlpha;
@@ -122,6 +123,7 @@ private:
void DownloadInitSegmentWithoutLock();
bool InitSegmentExists(std::string rep);
static void* DoBuffering(void *receiver);
+ static void* DoMPDFetching(void * data);
};
}
}
diff --git a/Input/IDASHManagerObserver.h b/Input/IDASHManagerObserver.h
index 0f2d95df..57f15726 100644
--- a/Input/IDASHManagerObserver.h
+++ b/Input/IDASHManagerObserver.h
@@ -33,6 +33,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;
};
}
}