[vlc-commits] demux: adaptive: add duration when splitting using index
Francois Cartegnie
git at videolan.org
Fri Jun 10 16:07:22 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jun 8 18:09:05 2016 +0200| [e67651833d800e7eee3f35fc411965d64fa4b16e] | committer: Francois Cartegnie
demux: adaptive: add duration when splitting using index
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e67651833d800e7eee3f35fc411965d64fa4b16e
---
modules/demux/adaptive/playlist/SegmentInformation.cpp | 14 +++++++++-----
modules/demux/adaptive/playlist/SegmentInformation.hpp | 1 +
modules/demux/dash/mp4/IndexReader.cpp | 3 ++-
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index 018a4f8..e1a65a0 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp
@@ -477,7 +477,7 @@ void SegmentInformation::setSegmentTemplate(MediaSegmentTemplate *templ)
}
static void insertIntoSegment(std::vector<ISegment *> &seglist, size_t start,
- size_t end, stime_t time)
+ size_t end, stime_t time, stime_t duration)
{
std::vector<ISegment *>::iterator segIt;
for(segIt = seglist.begin(); segIt < seglist.end(); ++segIt)
@@ -488,6 +488,7 @@ static void insertIntoSegment(std::vector<ISegment *> &seglist, size_t start,
{
SubSegment *subsegment = new SubSegment(segment, start, (end != 0) ? end : 0);
subsegment->startTime.Set(time);
+ subsegment->duration.Set(duration);
segment->addSubSegment(subsegment);
break;
}
@@ -502,7 +503,7 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
stime_t prevtime = 0;
const uint64_t i_timescale = inheritTimescale();
- SplitPoint split = {0,0};
+ SplitPoint split = {0,0,0};
std::vector<SplitPoint>::const_iterator splitIt;
for(splitIt = splitlist.begin(); splitIt < splitlist.end(); ++splitIt)
{
@@ -510,7 +511,8 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
if(splitIt != splitlist.begin())
{
/* do previous splitpoint */
- insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime);
+ const stime_t duration = (split.duration * i_timescale / CLOCK_FREQ);
+ insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime, duration);
}
prevstart = split.offset;
prevtime = split.time * i_timescale / CLOCK_FREQ;
@@ -518,11 +520,13 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
if(splitlist.size() == 1)
{
- insertIntoSegment(seglist, prevstart, 0, prevtime);
+ const stime_t duration = (split.duration * i_timescale / CLOCK_FREQ);
+ insertIntoSegment(seglist, prevstart, 0, prevtime, duration);
}
else if(splitlist.size() > 1)
{
- insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime);
+ const stime_t duration = (split.duration * i_timescale / CLOCK_FREQ);
+ insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime, duration);
}
}
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.hpp b/modules/demux/adaptive/playlist/SegmentInformation.hpp
index a5c97f6..859af00 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.hpp
@@ -63,6 +63,7 @@ namespace adaptive
public:
size_t offset;
mtime_t time;
+ mtime_t duration;
};
void SplitUsingIndex(std::vector<SplitPoint>&);
diff --git a/modules/demux/dash/mp4/IndexReader.cpp b/modules/demux/dash/mp4/IndexReader.cpp
index 92a2727..d539d22 100644
--- a/modules/demux/dash/mp4/IndexReader.cpp
+++ b/modules/demux/dash/mp4/IndexReader.cpp
@@ -52,8 +52,9 @@ bool IndexReader::parseIndex(block_t *p_block, BaseRepresentation *rep, uint64_t
{
splitlist.push_back(point);
point.offset += sidx->p_items[i].i_referenced_size;
- point.time += CLOCK_FREQ * sidx->p_items[i].i_subsegment_duration /
+ point.duration = CLOCK_FREQ * sidx->p_items[i].i_subsegment_duration /
sidx->i_timescale;
+ point.time += point.duration;
}
rep->SplitUsingIndex(splitlist);
rep->getPlaylist()->debug();
More information about the vlc-commits
mailing list