From f814ce75c31239d282a4476d30db70f431062e4e Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Tue, 27 Jan 2015 14:35:01 -0800 Subject: [PATCH] Log a warning if there is a gap in media timeline Change-Id: I39bdd3adeaa1d191bbc429ee91cbad3b8018afbf --- packager/mpd/base/mpd_builder.cc | 32 +++++++++++++++++-------------- packager/mpd/base/xml/xml_node.cc | 4 ++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index 9f52a010f3..902d185bfe 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -690,25 +690,20 @@ bool Representation::HasRequiredMediaInfoFields() { 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, uint64_t duration, uint64_t size) const { - if (segment_infos_.empty() || segment_infos_.back().duration != duration) + if (segment_infos_.empty()) return false; // Contiguous segment. const SegmentInfo& previous = segment_infos_.back(); const uint64_t previous_segment_end_time = 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; - - // A gap since previous. - if (previous_segment_end_time < start_time) - return false; + } // No out of order segments. const uint64_t previous_segment_start_time = @@ -718,22 +713,31 @@ bool Representation::IsContiguous(uint64_t start_time, "with start_time == " << 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; } // No overlapping segments. - const uint64_t kRoundingErrorGrace = 5; if (start_time < previous_segment_end_time - kRoundingErrorGrace) { 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 " << previous_segment_end_time << "."; - DCHECK(false); return false; } - // Within rounding error grace but technically not contiguous interms of MPD. + // Within rounding error grace but technically not contiguous in terms of MPD. return false; } diff --git a/packager/mpd/base/xml/xml_node.cc b/packager/mpd/base/xml/xml_node.cc index 25d7441607..28d45e9502 100644 --- a/packager/mpd/base/xml/xml_node.cc +++ b/packager/mpd/base/xml/xml_node.cc @@ -231,13 +231,13 @@ void XmlNode::SetContent(const std::string& content) { } ScopedXmlPtr::type XmlNode::PassScopedPtr() { - DLOG(INFO) << "Passing node_."; + DVLOG(2) << "Passing node_."; DCHECK(node_); return node_.Pass(); } xmlNodePtr XmlNode::Release() { - DLOG(INFO) << "Releasing node_."; + DVLOG(2) << "Releasing node_."; DCHECK(node_); return node_.release(); }