aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Samain <jsamain+fdio@cisco.com>2017-09-07 17:15:41 +0200
committerJacques Samain <jsamain+fdio@cisco.com>2017-09-07 17:15:41 +0200
commit0078209a7630579e7a016bd3c6cdcbba9a175b6d (patch)
tree18bb7626f622c6d32038f6085fcfa5de41503b35
parent98a684367149583c1b1eb4d4f35eef123972ccf9 (diff)
Handling end of segmentList event in live
Change-Id: I28be520c1c47e457826c7481a7507d0ef6c2bbbf Signed-off-by: Jacques Samain <jsamain+fdio@cisco.com>
-rw-r--r--MPD/MPDWrapper.cpp28
-rw-r--r--MPD/MPDWrapper.h1
2 files changed, 21 insertions, 8 deletions
diff --git a/MPD/MPDWrapper.cpp b/MPD/MPDWrapper.cpp
index f0bce82b..6d6fa9e5 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);
@@ -125,7 +127,6 @@ void MPDWrapper::findVideoRepresentation (IMPD* mpd)
if(this->videoRepresentation)
{
uint32_t time = this->videoRepresentations->find(this->videoRepresentation)->second->getTime(this->videoSegmentNumber);
-
uint32_t id = atoi(this->videoRepresentation->GetId().c_str());
for(size_t i = 0; i < representations.size(); i++)
{
@@ -281,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:
@@ -303,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);
@@ -531,7 +532,7 @@ std::vector<dash::mpd::IBaseUrl *> MPDWrapper::resolveBaseUrl (viper::managers::
{
urls.push_back(mpd->GetMPDPathBaseUrl());
}
-
+
return urls;
}
@@ -620,20 +621,25 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
while((this->isStopping == false) && segmentNumber >= representationStream->getSize())
{
SleepConditionVariableCS(&this->mpdUpdate, &this->monitorMutex, INFINITE);
+ this->hasReachedEndOfList = true;
switch(type)
{
case viper::managers::StreamType::AUDIO:
representation = this->audioRepresentation;
representations = this->audioRepresentations;
+ segmentNumber = this->audioSegmentNumber;
break;
case viper::managers::StreamType::VIDEO:
representation = this->videoRepresentation;
representations = this->videoRepresentations;
+ segmentNumber = this->videoSegmentNumber;
break;
default:
break;
}
representationStream = representations->find(representation)->second;
+ if(this->hasReachedEndOfList)
+ segmentNumber += 1;
}
if(this->isStopping)
{
@@ -653,6 +659,11 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
default:
break;
}
+ if(this->hasReachedEndOfList)
+ {
+ segmentNumber += 1;
+ this->hasReachedEndOfList = false;
+ }
}
uint64_t segDuration = 0;
//Returns the segmentDuration in milliseconds
@@ -662,6 +673,7 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
MediaObject *media = new MediaObject(seg, representation, withFeedBack);
media->SetSegmentDuration(segDuration);
segmentNumber++;
+
switch(type)
{
case viper::managers::StreamType::AUDIO:
@@ -726,7 +738,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:
@@ -828,7 +840,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:
@@ -862,7 +874,7 @@ std::string MPDWrapper::getRepresentationID (viper::managers::StreamType type)
{
std::string id = "";
EnterCriticalSection(&this->monitorMutex);
-
+
switch(type)
{
case viper::managers::StreamType::AUDIO:
diff --git a/MPD/MPDWrapper.h b/MPD/MPDWrapper.h
index 902fa3dc..cf6275d8 100644
--- a/MPD/MPDWrapper.h
+++ b/MPD/MPDWrapper.h
@@ -125,6 +125,7 @@ private:
size_t videoSegmentNumber;
size_t audioSegmentNumber;
bool isStopping;
+ bool hasReachedEndOfList;
};
}
}