Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: media/formats/mp4/mp4_stream_parser_unittest.cc

Issue 348623003: Fix muxed MP4 parsing so it won't crash on partial media segment appends. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix run skipping bug. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/mp4/mp4_stream_parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/mp4/mp4_stream_parser_unittest.cc
diff --git a/media/formats/mp4/mp4_stream_parser_unittest.cc b/media/formats/mp4/mp4_stream_parser_unittest.cc
index ef0bd44b3a548e5da5bf16c99b92f19a0f20d812..8805c05c3a75d6e7a4f55bfd7ba6f4dc1fbcfec3 100644
--- a/media/formats/mp4/mp4_stream_parser_unittest.cc
+++ b/media/formats/mp4/mp4_stream_parser_unittest.cc
@@ -31,7 +31,8 @@ static const char kMp4InitDataType[] = "video/mp4";
class MP4StreamParserTest : public testing::Test {
public:
MP4StreamParserTest()
- : configs_received_(false) {
+ : configs_received_(false),
+ lower_bound_(base::TimeDelta::Max()) {
std::set<int> audio_object_types;
audio_object_types.insert(kISO_14496_3);
parser_.reset(new MP4StreamParser(audio_object_types, false));
@@ -40,6 +41,7 @@ class MP4StreamParserTest : public testing::Test {
protected:
scoped_ptr<MP4StreamParser> parser_;
bool configs_received_;
+ base::TimeDelta lower_bound_;
bool AppendData(const uint8* data, size_t length) {
return parser_->Parse(data, length);
@@ -73,7 +75,6 @@ class MP4StreamParserTest : public testing::Test {
return true;
}
-
void DumpBuffers(const std::string& label,
const StreamParser::BufferQueue& buffers) {
DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size();
@@ -96,6 +97,24 @@ class MP4StreamParserTest : public testing::Test {
if (!text_map.empty())
return false;
+ // Find the second highest timestamp so that we know what the
+ // timestamps on the next set of buffers must be >= than.
+ base::TimeDelta audio = !audio_buffers.empty() ?
+ audio_buffers.back()->GetDecodeTimestamp() : kNoTimestamp();
+ base::TimeDelta video = !video_buffers.empty() ?
+ video_buffers.back()->GetDecodeTimestamp() : kNoTimestamp();
+ base::TimeDelta second_highest_timestamp =
+ (audio == kNoTimestamp() ||
+ (video != kNoTimestamp() && audio > video)) ? video : audio;
+
+ DCHECK(second_highest_timestamp != kNoTimestamp());
+
+ if (lower_bound_ != kNoTimestamp() &&
+ second_highest_timestamp < lower_bound_) {
+ return false;
+ }
+
+ lower_bound_ = second_highest_timestamp;
return true;
}
@@ -108,10 +127,12 @@ class MP4StreamParserTest : public testing::Test {
void NewSegmentF() {
DVLOG(1) << "NewSegmentF";
+ lower_bound_ = kNoTimestamp();
}
void EndOfSegmentF() {
DVLOG(1) << "EndOfSegmentF()";
+ lower_bound_ = base::TimeDelta::Max();
}
void InitializeParser() {
« no previous file with comments | « media/formats/mp4/mp4_stream_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698