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

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

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/logging.h"
7 #include "media/base/stream_parser_buffer.h"
8 #include "media/base/test_data_util.h"
9 #include "media/mp4/mp4_stream_parser.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using ::testing::_;
14 using base::TimeDelta;
15
16 namespace media {
17
18 class MP4StreamParserTest : public testing::Test {
19 public:
20 MP4StreamParserTest() : parser_(new MP4StreamParser) {}
21
22 protected:
23 scoped_ptr<MP4StreamParser> parser_;
24
25 bool AppendData(const uint8* data, size_t length) {
26 parser_->Parse(data, length);
27 return true;
28 }
29
30 bool AppendDataInPieces(const uint8* data, size_t length) {
31 return AppendDataInPieces(data, length, 7);
32 }
33
34 bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size) {
35 const uint8* start = data;
36 const uint8* end = data + length;
37 while (start < end) {
38 size_t append_size = std::min(piece_size,
39 static_cast<size_t>(end - start));
40 if (!AppendData(start, append_size))
41 return false;
42 start += append_size;
43 }
44 return true;
45 }
46 // HERE
47
48
49 void InitF(bool init_ok, base::TimeDelta duration) {
50 DVLOG(1) << "InitF: ok=" << init_ok
51 << ", dur=" << duration.InMilliseconds();
52 }
53
54 bool NewConfigF(const AudioDecoderConfig& ac,
55 const VideoDecoderConfig& vc) {
56 DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig()
57 << ", video=" << vc.IsValidConfig();
58 return true;
59 }
60
61 bool NewBuffersF(const StreamParser::BufferQueue& bufs) {
62 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers";
63 for (auto buf = bufs.begin(); buf != bufs.end(); buf++) {
64 DVLOG(3) << " n=" << buf - bufs.begin()
65 << ", size=" << (*buf)->GetDataSize()
66 << ", dur=" << (*buf)->GetDuration().InMilliseconds();
67 }
68 return true;
69 }
70
71 bool KeyNeededF(scoped_array<uint8> init_data, int init_data_size) {
72 DVLOG(1) << "KeyNeededF: " << init_data_size;
73 return true;
74 }
75
76 void InitializeParser() {
77 parser_->Init(
78 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)),
79 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)),
80 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)),
81 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)),
82 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)));
83 }
84
85 bool ParseMP4File(const std::string& filename,
86 const base::TimeDelta& duration) {
87 InitializeParser();
88
89 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename);
90 if (!AppendDataInPieces(buffer->GetData(), buffer->GetDataSize(), 512))
91 return false;
92
93 return true;
94 }
95 };
96
97 TEST_F(MP4StreamParserTest, TestParseVideo) {
98 ParseMP4File("google_track1_dash.mp4",
99 base::TimeDelta::FromMilliseconds(0));
100 }
101
102 TEST_F(MP4StreamParserTest, TestParseAudio) {
103 ParseMP4File("google_track2_dash.mp4",
104 base::TimeDelta::FromMilliseconds(0));
105 }
106
107 TEST_F(MP4StreamParserTest, TestParseAudioCENC) {
108 ParseMP4File("dash_audio_cenc_gold.mp4",
109 base::TimeDelta::FromMilliseconds(0));
110 }
111
112 TEST_F(MP4StreamParserTest, TestParseAudioClear) {
113 ParseMP4File("dash_audio_clear.mp4",
114 base::TimeDelta::FromMilliseconds(0));
115 }
116
117 TEST_F(MP4StreamParserTest, TestParseVideoCENC) {
118 ParseMP4File("dash_video_cenc_gold.mp4",
119 base::TimeDelta::FromMilliseconds(0));
120 }
121
122 TEST_F(MP4StreamParserTest, TestParseVideoClear) {
123 ParseMP4File("dash_video_clear.mp4",
124 base::TimeDelta::FromMilliseconds(0));
125 }
126
127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698