aboutsummaryrefslogtreecommitdiffstats
path: root/MPD/MPDWrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MPD/MPDWrapper.cpp')
-rw-r--r--MPD/MPDWrapper.cpp55
1 files changed, 38 insertions, 17 deletions
diff --git a/MPD/MPDWrapper.cpp b/MPD/MPDWrapper.cpp
index 1e085546..0b1d9596 100644
--- a/MPD/MPDWrapper.cpp
+++ b/MPD/MPDWrapper.cpp
@@ -28,7 +28,9 @@ MPDWrapper::MPDWrapper(IMPD *mpd):
videoSegmentOffset (0),
audioSegmentOffset (0),
videoSegmentNumber (0),
- audioSegmentNumber (0)
+ audioSegmentNumber (0),
+ hasReachedEndOfList (false)
+
{
InitializeConditionVariable (&this->mpdUpdate);
InitializeCriticalSection(&this->monitorMutex);
@@ -102,7 +104,7 @@ void MPDWrapper::findAudioAdaptationSet (IMPD* mpd)
return;
}
}
- //Not found in the new set of adaptation logc => select the first one
+ //Not found in the new set of adaptation logc => select the first one
this->audioAdaptationSet = adaptationSets.at(0);
}
@@ -280,7 +282,7 @@ void MPDWrapper::initializeAdaptationSetStream (viper::managers::StreamType type
IAdaptationSet *adaptationSet = NULL;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations = NULL;
EnterCriticalSection(&this->monitorMutex);
-
+
switch(type)
{
case viper::managers::StreamType::AUDIO:
@@ -302,7 +304,7 @@ void MPDWrapper::initializeAdaptationSetStream (viper::managers::StreamType type
default:
return;
}
-
+
for (size_t i = 0; i < adaptationSet->GetRepresentation().size(); i++)
{
IRepresentation *representation = adaptationSet->GetRepresentation().at(i);
@@ -530,7 +532,7 @@ std::vector<dash::mpd::IBaseUrl *> MPDWrapper::resolveBaseUrl (viper::managers::
{
urls.push_back(mpd->GetMPDPathBaseUrl());
}
-
+
return urls;
}
@@ -622,14 +624,7 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
while((this->isStopping == false) && segmentNumber >= representationStream->getSize())
{
SleepConditionVariableCS(&this->mpdUpdate, &this->monitorMutex, INFINITE);
-
- if(this->isStopping)
- {
- LeaveCriticalSection(&this->monitorMutex);
- return NULL;
- }
-
- //Need to update representationStream here as it was updated with the mpd:
+ this->hasReachedEndOfList = true;
switch(type)
{
case viper::managers::StreamType::AUDIO:
@@ -648,6 +643,31 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
break;
}
representationStream = representations->find(representation)->second;
+ if(this->hasReachedEndOfList)
+ segmentNumber += 1;
+ }
+ if(this->isStopping)
+ {
+ LeaveCriticalSection(&this->monitorMutex);
+ return NULL;
+ }
+
+ //Need to update representationStream here as it was updated with the mpd:
+ switch(type)
+ {
+ case viper::managers::StreamType::AUDIO:
+ segmentNumber = this->audioSegmentNumber;
+ break;
+ case viper::managers::StreamType::VIDEO:
+ segmentNumber = this->videoSegmentNumber;
+ break;
+ default:
+ break;
+ }
+ if(this->hasReachedEndOfList)
+ {
+ segmentNumber += 1;
+ this->hasReachedEndOfList = false;
}
}
uint64_t segDuration = 0;
@@ -687,6 +707,7 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
}
media->SetSegmentDuration(segDuration);
segmentNumber++;
+
switch(type)
{
case viper::managers::StreamType::AUDIO:
@@ -710,7 +731,7 @@ MediaObject* MPDWrapper::getSegment (viper::managers::StreamType type, uint32_t
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
EnterCriticalSection(&this->monitorMutex);
-
+
switch(type)
{
case viper::managers::StreamType::AUDIO:
@@ -751,7 +772,7 @@ MediaObject* MPDWrapper::getInitSegment (viper::managers::StreamType type)
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
EnterCriticalSection(&this->monitorMutex);
-
+
switch(type)
{
case viper::managers::StreamType::AUDIO:
@@ -853,7 +874,7 @@ uint32_t MPDWrapper::calculateSegmentOffset (viper::managers::StreamType type, u
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
EnterCriticalSection(&this->monitorMutex);
-
+
switch(type)
{
case viper::managers::StreamType::AUDIO:
@@ -887,7 +908,7 @@ std::string MPDWrapper::getRepresentationID (viper::managers::StreamType type)
{
std::string id = "";
EnterCriticalSection(&this->monitorMutex);
-
+
switch(type)
{
case viper::managers::StreamType::AUDIO: