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 <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "media/mp4/box_reader.h" | 10 #include "media/mp4/box_reader.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 bool err; | 174 bool err; |
175 scoped_ptr<BoxReader> reader( | 175 scoped_ptr<BoxReader> reader( |
176 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), LogCB(), &err)); | 176 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), LogCB(), &err)); |
177 | 177 |
178 std::vector<PsshBox> kids; | 178 std::vector<PsshBox> kids; |
179 EXPECT_TRUE(reader->SkipBytes(16) && reader->ReadAllChildren(&kids)); | 179 EXPECT_TRUE(reader->SkipBytes(16) && reader->ReadAllChildren(&kids)); |
180 EXPECT_EQ(2u, kids.size()); | 180 EXPECT_EQ(2u, kids.size()); |
181 EXPECT_EQ(kids[0].val, 0xdeadbeef); // Ensure order is preserved | 181 EXPECT_EQ(kids[0].val, 0xdeadbeef); // Ensure order is preserved |
182 } | 182 } |
183 | 183 |
184 TEST_F(BoxReaderTest, TestSkippingBloc) { | 184 TEST_F(BoxReaderTest, SkippingBloc) { |
185 static const uint8 kData[] = { | 185 static const uint8 kData[] = { |
186 0x00, 0x00, 0x00, 0x09, 'b', 'l', 'o', 'c', 0x00 | 186 0x00, 0x00, 0x00, 0x09, 'b', 'l', 'o', 'c', 0x00 |
187 }; | 187 }; |
188 | 188 |
189 std::vector<uint8> buf(kData, kData + sizeof(kData)); | 189 std::vector<uint8> buf(kData, kData + sizeof(kData)); |
190 | 190 |
191 bool err; | 191 bool err; |
192 scoped_ptr<BoxReader> reader( | 192 scoped_ptr<BoxReader> reader( |
193 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), LogCB(), &err)); | 193 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), LogCB(), &err)); |
194 | 194 |
195 EXPECT_FALSE(err); | 195 EXPECT_FALSE(err); |
196 EXPECT_TRUE(reader); | 196 EXPECT_TRUE(reader); |
197 EXPECT_EQ(FOURCC_BLOC, reader->type()); | 197 EXPECT_EQ(FOURCC_BLOC, reader->type()); |
198 } | 198 } |
199 | 199 |
200 } // namespace mp4 | 200 } // namespace mp4 |
201 } // namespace media | 201 } // namespace media |
OLD | NEW |