1 // Copyright 2014 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.
5 #include "media/formats/mp4/es_descriptor.h"
7 #include "testing/gtest/include/gtest/gtest.h"
13 TEST(ESDescriptorTest
, SingleByteLengthTest
) {
16 0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x40,
17 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 0x00, 0x00, 0x00, 0x00, 0x05, 0x02, 0x12, 0x10,
21 std::vector
<uint8
> data
;
23 data
.assign(buffer
, buffer
+ sizeof(buffer
));
25 EXPECT_EQ(es_desc
.object_type(), kForbidden
);
26 EXPECT_TRUE(es_desc
.Parse(data
));
27 EXPECT_EQ(es_desc
.object_type(), kISO_14496_3
);
28 EXPECT_EQ(es_desc
.decoder_specific_info().size(), 2u);
29 EXPECT_EQ(es_desc
.decoder_specific_info()[0], 0x12);
30 EXPECT_EQ(es_desc
.decoder_specific_info()[1], 0x10);
33 TEST(ESDescriptorTest
, NonAACTest
) {
36 0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x66,
37 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x05, 0x02, 0x12, 0x10,
41 std::vector
<uint8
> data
;
43 data
.assign(buffer
, buffer
+ sizeof(buffer
));
45 EXPECT_TRUE(es_desc
.Parse(data
));
46 EXPECT_NE(es_desc
.object_type(), kISO_14496_3
);
47 EXPECT_EQ(es_desc
.decoder_specific_info().size(), 2u);
48 EXPECT_EQ(es_desc
.decoder_specific_info()[0], 0x12);
49 EXPECT_EQ(es_desc
.decoder_specific_info()[1], 0x10);
52 TEST(ESDescriptorTest
, MultiByteLengthTest
) {
55 0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80,
56 0x80, 0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
58 0x80, 0x80, 0x80, 0x02, 0x12, 0x10, 0x06, 0x01,
61 std::vector
<uint8
> data
;
63 data
.assign(buffer
, buffer
+ sizeof(buffer
));
65 EXPECT_TRUE(es_desc
.Parse(data
));
66 EXPECT_EQ(es_desc
.object_type(), kISO_14496_3
);
67 EXPECT_EQ(es_desc
.decoder_specific_info().size(), 2u);
68 EXPECT_EQ(es_desc
.decoder_specific_info()[0], 0x12);
69 EXPECT_EQ(es_desc
.decoder_specific_info()[1], 0x10);
72 TEST(ESDescriptorTest
, FiveByteLengthTest
) {
75 0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80,
76 0x80, 0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00,
77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
78 0x80, 0x80, 0x80, 0x80, 0x02, 0x12, 0x10, 0x06,
81 std::vector
<uint8
> data
;
83 data
.assign(buffer
, buffer
+ sizeof(buffer
));
85 EXPECT_TRUE(es_desc
.Parse(data
));
86 EXPECT_EQ(es_desc
.object_type(), kISO_14496_3
);
87 EXPECT_EQ(es_desc
.decoder_specific_info().size(), 0u);