add a replace argument to Source::set_segment_descriptor()

This allows for a segment descriptor to be replaced, which previously was not
possible
This commit is contained in:
Paul Davis
2025-10-14 10:09:37 -06:00
parent 768f2dc768
commit 4b5efcee86
2 changed files with 12 additions and 4 deletions

View File

@@ -154,7 +154,7 @@ public:
std::string captured_for() const { return _captured_for; }
bool get_segment_descriptor (TimelineRange const &, SegmentDescriptor&);
int set_segment_descriptor (SegmentDescriptor const &);
int set_segment_descriptor (SegmentDescriptor const &, bool replace = false);
protected:
DataType _type;

View File

@@ -559,14 +559,22 @@ Source::get_segment_descriptor (TimelineRange const & range, SegmentDescriptor&
}
int
Source::set_segment_descriptor (SegmentDescriptor const & sr)
Source::set_segment_descriptor (SegmentDescriptor const & sr, bool replace)
{
/* We disallow any overlap between segments. They must describe non-overlapping ranges */
for (auto const & sd : segment_descriptors) {
for (auto i = segment_descriptors.begin(); i != segment_descriptors.end(); ++i) {
SegmentDescriptor& sd (*i);
if (coverage_exclusive_ends (sd.position(), sd.position() + sd.extent(),
sr.position(), sr.position() + sr.extent()) != Temporal::OverlapNone) {
return -1;
if (replace) {
segment_descriptors.erase (i);
break;
} else {
return -1;
}
}
}