Commit d7ace43f authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: add MPD merging for updates

parent ec5b75ba
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "MPD.h" #include "MPD.h"
#include "Helper.h" #include "Helper.h"
#include "dash.hpp" #include "dash.hpp"
#include "SegmentTimeline.h"
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_stream.h> #include <vlc_stream.h>
...@@ -59,7 +60,7 @@ MPD::~MPD () ...@@ -59,7 +60,7 @@ MPD::~MPD ()
delete(programInfo.Get()); delete(programInfo.Get());
} }
const std::vector<Period*>& MPD::getPeriods () const const std::vector<Period*>& MPD::getPeriods ()
{ {
return this->periods; return this->periods;
} }
...@@ -110,7 +111,7 @@ vlc_object_t * MPD::getVLCObject() const ...@@ -110,7 +111,7 @@ vlc_object_t * MPD::getVLCObject() const
return VLC_OBJECT(stream); return VLC_OBJECT(stream);
} }
Period* MPD::getFirstPeriod() const Period* MPD::getFirstPeriod()
{ {
std::vector<Period *> periods = getPeriods(); std::vector<Period *> periods = getPeriods();
...@@ -132,3 +133,19 @@ Period* MPD::getNextPeriod(Period *period) ...@@ -132,3 +133,19 @@ Period* MPD::getNextPeriod(Period *period)
return NULL; return NULL;
} }
void MPD::mergeWith(MPD *updatedMPD)
{
availabilityEndTime.Set(updatedMPD->availabilityEndTime.Get());
/* Only merge timelines for now */
for(size_t i = 0; i < periods.size() && i < updatedMPD->periods.size(); i++)
{
std::vector<SegmentTimeline *> timelines;
std::vector<SegmentTimeline *> timelinesUpdate;
periods.at(i)->collectTimelines(&timelines);
updatedMPD->periods.at(i)->collectTimelines(&timelinesUpdate);
for(size_t j = 0; j < timelines.size() && j < timelinesUpdate.size(); j++)
timelines.at(j)->mergeWith(*timelinesUpdate.at(j));
}
}
...@@ -56,10 +56,12 @@ namespace dash ...@@ -56,10 +56,12 @@ namespace dash
virtual Url getUrlSegment() const; /* impl */ virtual Url getUrlSegment() const; /* impl */
vlc_object_t * getVLCObject() const; vlc_object_t * getVLCObject() const;
virtual const std::vector<Period *>& getPeriods() const; virtual const std::vector<Period *>& getPeriods();
virtual Period* getFirstPeriod() const; virtual Period* getFirstPeriod();
virtual Period* getNextPeriod(Period *period); virtual Period* getNextPeriod(Period *period);
void mergeWith(MPD *);
Property<time_t> duration; Property<time_t> duration;
Property<time_t> playbackStart; Property<time_t> playbackStart;
Property<time_t> availabilityEndTime; Property<time_t> availabilityEndTime;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment