OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 public: | 31 public: |
32 MP4StreamParserTest() | 32 MP4StreamParserTest() |
33 : configs_received_(false) { | 33 : configs_received_(false) { |
34 std::set<int> audio_object_types; | 34 std::set<int> audio_object_types; |
35 audio_object_types.insert(kISO_14496_3); | 35 audio_object_types.insert(kISO_14496_3); |
36 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 36 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
37 } | 37 } |
38 | 38 |
39 protected: | 39 protected: |
40 scoped_ptr<MP4StreamParser> parser_; | 40 scoped_ptr<MP4StreamParser> parser_; |
41 base::TimeDelta segment_start_; | |
42 bool configs_received_; | 41 bool configs_received_; |
43 | 42 |
44 bool AppendData(const uint8* data, size_t length) { | 43 bool AppendData(const uint8* data, size_t length) { |
45 return parser_->Parse(data, length); | 44 return parser_->Parse(data, length); |
46 } | 45 } |
47 | 46 |
48 bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size) { | 47 bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size) { |
49 const uint8* start = data; | 48 const uint8* start = data; |
50 const uint8* end = data + length; | 49 const uint8* end = data + length; |
51 while (start < end) { | 50 while (start < end) { |
(...skipping 11 matching lines...) Expand all Loading... |
63 << ", dur=" << duration.InMilliseconds(); | 62 << ", dur=" << duration.InMilliseconds(); |
64 } | 63 } |
65 | 64 |
66 bool NewConfigF(const AudioDecoderConfig& ac, const VideoDecoderConfig& vc) { | 65 bool NewConfigF(const AudioDecoderConfig& ac, const VideoDecoderConfig& vc) { |
67 DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig() | 66 DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig() |
68 << ", video=" << vc.IsValidConfig(); | 67 << ", video=" << vc.IsValidConfig(); |
69 configs_received_ = true; | 68 configs_received_ = true; |
70 return true; | 69 return true; |
71 } | 70 } |
72 | 71 |
73 bool NewBuffersF(const StreamParser::BufferQueue& bufs) { | 72 |
74 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers"; | 73 void DumpBuffers(const std::string& label, |
75 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin(); | 74 const StreamParser::BufferQueue& buffers) { |
76 buf != bufs.end(); buf++) { | 75 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); |
77 DVLOG(3) << " n=" << buf - bufs.begin() | 76 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); |
| 77 buf != buffers.end(); buf++) { |
| 78 DVLOG(3) << " n=" << buf - buffers.begin() |
78 << ", size=" << (*buf)->data_size() | 79 << ", size=" << (*buf)->data_size() |
79 << ", dur=" << (*buf)->duration().InMilliseconds(); | 80 << ", dur=" << (*buf)->duration().InMilliseconds(); |
80 EXPECT_GE((*buf)->timestamp(), segment_start_); | |
81 } | 81 } |
| 82 } |
| 83 |
| 84 bool NewBuffersF(const StreamParser::BufferQueue& audio_buffers, |
| 85 const StreamParser::BufferQueue& video_buffers) { |
| 86 DumpBuffers("audio_buffers", audio_buffers); |
| 87 DumpBuffers("video_buffers", video_buffers); |
82 return true; | 88 return true; |
83 } | 89 } |
84 | 90 |
85 bool NewTextBuffersF(TextTrack* text_track, | 91 bool NewTextBuffersF(TextTrack* text_track, |
86 const StreamParser::BufferQueue& buffers) { | 92 const StreamParser::BufferQueue& buffers) { |
87 return true; | 93 return true; |
88 } | 94 } |
89 | 95 |
90 void KeyNeededF(const std::string& type, | 96 void KeyNeededF(const std::string& type, |
91 scoped_ptr<uint8[]> init_data, int init_data_size) { | 97 scoped_ptr<uint8[]> init_data, int init_data_size) { |
92 DVLOG(1) << "KeyNeededF: " << init_data_size; | 98 DVLOG(1) << "KeyNeededF: " << init_data_size; |
93 EXPECT_EQ(kMp4InitDataType, type); | 99 EXPECT_EQ(kMp4InitDataType, type); |
94 EXPECT_TRUE(init_data.get()); | 100 EXPECT_TRUE(init_data.get()); |
95 EXPECT_GT(init_data_size, 0); | 101 EXPECT_GT(init_data_size, 0); |
96 } | 102 } |
97 | 103 |
98 scoped_ptr<TextTrack> AddTextTrackF( | 104 scoped_ptr<TextTrack> AddTextTrackF( |
99 TextKind kind, | 105 TextKind kind, |
100 const std::string& label, | 106 const std::string& label, |
101 const std::string& language) { | 107 const std::string& language) { |
102 return scoped_ptr<TextTrack>(); | 108 return scoped_ptr<TextTrack>(); |
103 } | 109 } |
104 | 110 |
105 void NewSegmentF(TimeDelta start_dts) { | 111 void NewSegmentF() { |
106 DVLOG(1) << "NewSegmentF: " << start_dts.InMilliseconds(); | 112 DVLOG(1) << "NewSegmentF"; |
107 segment_start_ = start_dts; | |
108 } | 113 } |
109 | 114 |
110 void EndOfSegmentF() { | 115 void EndOfSegmentF() { |
111 DVLOG(1) << "EndOfSegmentF()"; | 116 DVLOG(1) << "EndOfSegmentF()"; |
112 } | 117 } |
113 | 118 |
114 void InitializeParser() { | 119 void InitializeParser() { |
115 parser_->Init( | 120 parser_->Init( |
116 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)), | 121 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)), |
117 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)), | 122 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)), |
118 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), | 123 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), |
119 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), | |
120 base::Bind(&MP4StreamParserTest::NewTextBuffersF, | 124 base::Bind(&MP4StreamParserTest::NewTextBuffersF, |
121 base::Unretained(this)), | 125 base::Unretained(this)), |
122 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), | 126 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), |
123 base::Bind(&MP4StreamParserTest::AddTextTrackF, base::Unretained(this)), | 127 base::Bind(&MP4StreamParserTest::AddTextTrackF, base::Unretained(this)), |
124 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)), | 128 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)), |
125 base::Bind(&MP4StreamParserTest::EndOfSegmentF, | 129 base::Bind(&MP4StreamParserTest::EndOfSegmentF, |
126 base::Unretained(this)), | 130 base::Unretained(this)), |
127 LogCB()); | 131 LogCB()); |
128 } | 132 } |
129 | 133 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 EXPECT_TRUE(AppendDataInPieces(buffer->data() + kFirstMoofOffset, | 207 EXPECT_TRUE(AppendDataInPieces(buffer->data() + kFirstMoofOffset, |
204 buffer->data_size() - kFirstMoofOffset, | 208 buffer->data_size() - kFirstMoofOffset, |
205 512)); | 209 512)); |
206 } | 210 } |
207 | 211 |
208 // TODO(strobe): Create and test media which uses CENC auxiliary info stored | 212 // TODO(strobe): Create and test media which uses CENC auxiliary info stored |
209 // inside a private box | 213 // inside a private box |
210 | 214 |
211 } // namespace mp4 | 215 } // namespace mp4 |
212 } // namespace media | 216 } // namespace media |
OLD | NEW |