Commit fb4b0f0c authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptative: fill result vectors by reference

parent b304141f
...@@ -59,7 +59,8 @@ void BaseRepresentation::debug(vlc_object_t *obj, int indent) const ...@@ -59,7 +59,8 @@ void BaseRepresentation::debug(vlc_object_t *obj, int indent) const
std::string text(indent, ' '); std::string text(indent, ' ');
text.append("Representation"); text.append("Representation");
msg_Dbg(obj, "%s", text.c_str()); msg_Dbg(obj, "%s", text.c_str());
std::vector<ISegment *> list = getSegments(); std::vector<ISegment *> list;
getSegments(list);
std::vector<ISegment *>::const_iterator l; std::vector<ISegment *>::const_iterator l;
for(l = list.begin(); l != list.end(); ++l) for(l = list.begin(); l != list.end(); ++l)
(*l)->debug(obj, indent + 1); (*l)->debug(obj, indent + 1);
......
...@@ -69,10 +69,8 @@ AbstractPlaylist * SegmentInformation::getPlaylist() const ...@@ -69,10 +69,8 @@ AbstractPlaylist * SegmentInformation::getPlaylist() const
return NULL; return NULL;
} }
vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const std::size_t SegmentInformation::getSegments(SegmentInfoType type, vector<ISegment *> &retSegments) const
{ {
vector<ISegment *> retSegments;
switch (type) switch (type)
{ {
case INFOTYPE_INIT: case INFOTYPE_INIT:
...@@ -136,28 +134,28 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const ...@@ -136,28 +134,28 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const
} }
if( retSegments.empty() && parent ) if( retSegments.empty() && parent )
return parent->getSegments( type ); return parent->getSegments( type, retSegments );
else else
return retSegments; return retSegments.size();
} }
vector<ISegment *> SegmentInformation::getSegments() const std::size_t SegmentInformation::getSegments(vector<ISegment *> &retSegments) const
{ {
vector<ISegment *> retSegments;
for(int i=0; i<InfoTypeCount; i++) for(int i=0; i<InfoTypeCount; i++)
{ {
vector<ISegment *> segs = getSegments(static_cast<SegmentInfoType>(i)); vector<ISegment *> segs;
retSegments.insert( retSegments.end(), segs.begin(), segs.end() ); if( getSegments(static_cast<SegmentInfoType>(i), segs) )
retSegments.insert( retSegments.end(), segs.begin(), segs.end() );
} }
return retSegments; return retSegments.size();
} }
ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) const ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) const
{ {
ISegment *segment = NULL; ISegment *segment = NULL;
vector<ISegment *> retSegments = getSegments( type ); vector<ISegment *> retSegments;
const size_t size = retSegments.size(); const size_t size = getSegments( type, retSegments );
if( size ) if( size )
{ {
/* check if that's a template (fixme: find a better way) */ /* check if that's a template (fixme: find a better way) */
...@@ -192,7 +190,8 @@ bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) con ...@@ -192,7 +190,8 @@ bool SegmentInformation::getSegmentNumberByTime(mtime_t time, uint64_t *ret) con
} }
else else
{ {
const std::vector<ISegment *> segments = getSegments(INFOTYPE_MEDIA); std::vector<ISegment *> segments;
getSegments(INFOTYPE_MEDIA, segments);
std::vector<ISegment *>::const_iterator it; std::vector<ISegment *>::const_iterator it;
*ret = 0; *ret = 0;
for(it = segments.begin(); it != segments.end(); ++it) for(it = segments.begin(); it != segments.end(); ++it)
...@@ -254,7 +253,8 @@ void SegmentInformation::collectTimelines(std::vector<SegmentTimeline *> *timeli ...@@ -254,7 +253,8 @@ void SegmentInformation::collectTimelines(std::vector<SegmentTimeline *> *timeli
void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const void SegmentInformation::getDurationsRange(mtime_t *min, mtime_t *max) const
{ {
/* FIXME: cache stuff in segment holders */ /* FIXME: cache stuff in segment holders */
std::vector<ISegment *> seglist = getSegments(INFOTYPE_MEDIA); std::vector<ISegment *> seglist;
getSegments(INFOTYPE_MEDIA, seglist);
std::vector<ISegment *>::const_iterator it; std::vector<ISegment *>::const_iterator it;
mtime_t total = 0; mtime_t total = 0;
for(it = seglist.begin(); it != seglist.end(); ++it) for(it = seglist.begin(); it != seglist.end(); ++it)
...@@ -344,7 +344,8 @@ static void insertIntoSegment(std::vector<ISegment *> &seglist, size_t start, ...@@ -344,7 +344,8 @@ static void insertIntoSegment(std::vector<ISegment *> &seglist, size_t start,
void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist) void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
{ {
std::vector<ISegment *> seglist = getSegments(INFOTYPE_MEDIA); std::vector<ISegment *> seglist;
getSegments(INFOTYPE_MEDIA, seglist);
std::vector<SplitPoint>::const_iterator splitIt; std::vector<SplitPoint>::const_iterator splitIt;
size_t start = 0, end = 0; size_t start = 0, end = 0;
mtime_t time = 0; mtime_t time = 0;
......
...@@ -82,8 +82,8 @@ namespace adaptative ...@@ -82,8 +82,8 @@ namespace adaptative
virtual void mergeWith(SegmentInformation *, mtime_t); virtual void mergeWith(SegmentInformation *, mtime_t);
protected: protected:
std::vector<ISegment *> getSegments() const; std::size_t getSegments(std::vector<ISegment *> &) const;
std::vector<ISegment *> getSegments(SegmentInfoType) const; std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&) const;
std::vector<SegmentInformation *> childs; std::vector<SegmentInformation *> childs;
SegmentInformation *parent; SegmentInformation *parent;
......
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