Log a warning if there is a gap in media timeline

Change-Id: I39bdd3adeaa1d191bbc429ee91cbad3b8018afbf
This commit is contained in:
KongQun Yang 2015-01-27 14:35:01 -08:00
parent a99af5a015
commit f814ce75c3
2 changed files with 20 additions and 16 deletions

View File

@ -690,25 +690,20 @@ bool Representation::HasRequiredMediaInfoFields() {
return true; return true;
} }
// In Debug builds, some of the irregular cases crash. It is probably a
// programming error but in production, it might not be best to stop the
// pipeline, especially for live.
bool Representation::IsContiguous(uint64_t start_time, bool Representation::IsContiguous(uint64_t start_time,
uint64_t duration, uint64_t duration,
uint64_t size) const { uint64_t size) const {
if (segment_infos_.empty() || segment_infos_.back().duration != duration) if (segment_infos_.empty())
return false; return false;
// Contiguous segment. // Contiguous segment.
const SegmentInfo& previous = segment_infos_.back(); const SegmentInfo& previous = segment_infos_.back();
const uint64_t previous_segment_end_time = const uint64_t previous_segment_end_time =
previous.start_time + previous.duration * (previous.repeat + 1); previous.start_time + previous.duration * (previous.repeat + 1);
if (previous_segment_end_time == start_time) if (previous_segment_end_time == start_time &&
segment_infos_.back().duration == duration) {
return true; return true;
}
// A gap since previous.
if (previous_segment_end_time < start_time)
return false;
// No out of order segments. // No out of order segments.
const uint64_t previous_segment_start_time = const uint64_t previous_segment_start_time =
@ -718,18 +713,27 @@ bool Representation::IsContiguous(uint64_t start_time,
"with start_time == " << start_time "with start_time == " << start_time
<< " but the previous segment starts at " << previous.start_time << " but the previous segment starts at " << previous.start_time
<< "."; << ".";
DCHECK(false); return false;
}
// A gap since previous.
const uint64_t kRoundingErrorGrace = 5;
if (previous_segment_end_time + kRoundingErrorGrace < start_time) {
LOG(WARNING) << "Found a gap of size "
<< (start_time - previous_segment_end_time)
<< " > kRoundingErrorGrace (" << kRoundingErrorGrace
<< "). The new segment starts at " << start_time
<< " but the previous segment ends at "
<< previous_segment_end_time << ".";
return false; return false;
} }
// No overlapping segments. // No overlapping segments.
const uint64_t kRoundingErrorGrace = 5;
if (start_time < previous_segment_end_time - kRoundingErrorGrace) { if (start_time < previous_segment_end_time - kRoundingErrorGrace) {
LOG(WARNING) LOG(WARNING)
<< "Segments shold not be overlapping. The new segment starts at " << "Segments should not be overlapping. The new segment starts at "
<< start_time << " but the previous segment ends at " << start_time << " but the previous segment ends at "
<< previous_segment_end_time << "."; << previous_segment_end_time << ".";
DCHECK(false);
return false; return false;
} }

View File

@ -231,13 +231,13 @@ void XmlNode::SetContent(const std::string& content) {
} }
ScopedXmlPtr<xmlNode>::type XmlNode::PassScopedPtr() { ScopedXmlPtr<xmlNode>::type XmlNode::PassScopedPtr() {
DLOG(INFO) << "Passing node_."; DVLOG(2) << "Passing node_.";
DCHECK(node_); DCHECK(node_);
return node_.Pass(); return node_.Pass();
} }
xmlNodePtr XmlNode::Release() { xmlNodePtr XmlNode::Release() {
DLOG(INFO) << "Releasing node_."; DVLOG(2) << "Releasing node_.";
DCHECK(node_); DCHECK(node_);
return node_.release(); return node_.release();
} }