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

Side by Side Diff: media/mp4/mp4_stream_parser_unittest.cc

Issue 10660005: Flush sample buffers when reading new segments in Media Source BMFF parser. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: FlushSamples -> SendAndFlushSamples Created 8 years, 5 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 unified diff | Download patch
« no previous file with comments | « media/mp4/mp4_stream_parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace media { 24 namespace media {
25 namespace mp4 { 25 namespace mp4 {
26 26
27 class MP4StreamParserTest : public testing::Test { 27 class MP4StreamParserTest : public testing::Test {
28 public: 28 public:
29 MP4StreamParserTest() : parser_(new MP4StreamParser) {} 29 MP4StreamParserTest() : parser_(new MP4StreamParser) {}
30 30
31 protected: 31 protected:
32 scoped_ptr<MP4StreamParser> parser_; 32 scoped_ptr<MP4StreamParser> parser_;
33 base::TimeDelta segment_start_;
33 34
34 bool AppendData(const uint8* data, size_t length) { 35 bool AppendData(const uint8* data, size_t length) {
35 parser_->Parse(data, length); 36 parser_->Parse(data, length);
36 return true; 37 return true;
37 } 38 }
38 39
39 bool AppendDataInPieces(const uint8* data, size_t length) { 40 bool AppendDataInPieces(const uint8* data, size_t length) {
40 return AppendDataInPieces(data, length, 7); 41 return AppendDataInPieces(data, length, 7);
41 } 42 }
42 43
(...skipping 22 matching lines...) Expand all
65 return true; 66 return true;
66 } 67 }
67 68
68 bool NewBuffersF(const StreamParser::BufferQueue& bufs) { 69 bool NewBuffersF(const StreamParser::BufferQueue& bufs) {
69 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers"; 70 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers";
70 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin(); 71 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin();
71 buf != bufs.end(); buf++) { 72 buf != bufs.end(); buf++) {
72 DVLOG(3) << " n=" << buf - bufs.begin() 73 DVLOG(3) << " n=" << buf - bufs.begin()
73 << ", size=" << (*buf)->GetDataSize() 74 << ", size=" << (*buf)->GetDataSize()
74 << ", dur=" << (*buf)->GetDuration().InMilliseconds(); 75 << ", dur=" << (*buf)->GetDuration().InMilliseconds();
76 EXPECT_LE(segment_start_, (*buf)->GetTimestamp());
75 } 77 }
76 return true; 78 return true;
77 } 79 }
78 80
79 bool KeyNeededF(scoped_array<uint8> init_data, int init_data_size) { 81 bool KeyNeededF(scoped_array<uint8> init_data, int init_data_size) {
80 DVLOG(1) << "KeyNeededF: " << init_data_size; 82 DVLOG(1) << "KeyNeededF: " << init_data_size;
81 return true; 83 return true;
82 } 84 }
83 85
84 void NewSegmentF(TimeDelta start_dts) { 86 void NewSegmentF(TimeDelta start_dts) {
85 DVLOG(1) << "NewSegmentF: " << start_dts.InMilliseconds(); 87 DVLOG(1) << "NewSegmentF: " << start_dts.InMilliseconds();
88 segment_start_ = start_dts;
86 } 89 }
87 90
88 void InitializeParser() { 91 void InitializeParser() {
89 parser_->Init( 92 parser_->Init(
90 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)), 93 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)),
91 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)), 94 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)),
92 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), 95 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)),
93 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), 96 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)),
94 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), 97 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)),
95 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this))); 98 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)));
96 } 99 }
97 100
98 bool ParseMP4File(const std::string& filename) { 101 bool ParseMP4File(const std::string& filename, int append_size) {
99 InitializeParser(); 102 InitializeParser();
100 103
101 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); 104 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename);
102 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 105 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(),
103 buffer->GetDataSize(), 106 buffer->GetDataSize(),
104 512)); 107 append_size));
105 return true; 108 return true;
106 } 109 }
107 }; 110 };
108 111
109 TEST_F(MP4StreamParserTest, TestParseBearDASH) { 112 TEST_F(MP4StreamParserTest, TestParseBearDASH) {
110 ParseMP4File("bear.1280x720_dash.mp4"); 113 ParseMP4File("bear.1280x720_dash.mp4", 512);
114 }
115
116 TEST_F(MP4StreamParserTest, TestMultiFragmentAppend) {
117 ParseMP4File("bear.1280x720_dash.mp4", 768432);
111 } 118 }
112 119
113 } // namespace mp4 120 } // namespace mp4
114 } // namespace media 121 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/mp4_stream_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698