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.
5 #include "media/mp4/aac.h"
7 #include "testing/gtest/include/gtest/gtest.h"
13 TEST(AACTest
, BasicProfileTest
) {
15 uint8 buffer
[] = {0x12, 0x10};
16 std::vector
<uint8
> data
;
18 data
.assign(buffer
, buffer
+ sizeof(buffer
));
20 EXPECT_TRUE(aac
.Parse(data
));
21 EXPECT_EQ(aac
.GetOutputSamplesPerSecond(false), 44100);
22 EXPECT_EQ(aac
.channel_layout(), CHANNEL_LAYOUT_STEREO
);
25 TEST(AACTest
, ExtensionTest
) {
27 uint8 buffer
[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80};
28 std::vector
<uint8
> data
;
30 data
.assign(buffer
, buffer
+ sizeof(buffer
));
32 EXPECT_TRUE(aac
.Parse(data
));
33 EXPECT_EQ(aac
.GetOutputSamplesPerSecond(false), 48000);
34 EXPECT_EQ(aac
.GetOutputSamplesPerSecond(true), 48000);
35 EXPECT_EQ(aac
.channel_layout(), CHANNEL_LAYOUT_STEREO
);
38 TEST(AACTest
, TestImplicitSBR
) {
40 uint8 buffer
[] = {0x13, 0x10};
41 std::vector
<uint8
> data
;
43 data
.assign(buffer
, buffer
+ sizeof(buffer
));
45 EXPECT_TRUE(aac
.Parse(data
));
46 EXPECT_EQ(aac
.GetOutputSamplesPerSecond(false), 24000);
47 EXPECT_EQ(aac
.GetOutputSamplesPerSecond(true), 48000);
48 EXPECT_EQ(aac
.channel_layout(), CHANNEL_LAYOUT_STEREO
);
51 TEST(AACTest
, SixChannelTest
) {
53 uint8 buffer
[] = {0x11, 0xb0};
54 std::vector
<uint8
> data
;
56 data
.assign(buffer
, buffer
+ sizeof(buffer
));
58 EXPECT_TRUE(aac
.Parse(data
));
59 EXPECT_EQ(aac
.GetOutputSamplesPerSecond(false), 48000);
60 EXPECT_EQ(aac
.channel_layout(), CHANNEL_LAYOUT_5_1
);
63 TEST(AACTest
, DataTooShortTest
) {
65 std::vector
<uint8
> data
;
67 EXPECT_FALSE(aac
.Parse(data
));
70 EXPECT_FALSE(aac
.Parse(data
));
73 TEST(AACTest
, IncorrectProfileTest
) {
75 uint8 buffer
[] = {0x0, 0x08};
76 std::vector
<uint8
> data
;
78 data
.assign(buffer
, buffer
+ sizeof(buffer
));
80 EXPECT_FALSE(aac
.Parse(data
));
83 EXPECT_TRUE(aac
.Parse(data
));
86 EXPECT_FALSE(aac
.Parse(data
));
89 TEST(AACTest
, IncorrectFrequencyTest
) {
91 uint8 buffer
[] = {0x0f, 0x88};
92 std::vector
<uint8
> data
;
94 data
.assign(buffer
, buffer
+ sizeof(buffer
));
96 EXPECT_FALSE(aac
.Parse(data
));
100 EXPECT_TRUE(aac
.Parse(data
));
103 TEST(AACTest
, IncorrectChannelTest
) {
105 uint8 buffer
[] = {0x0e, 0x00};
106 std::vector
<uint8
> data
;
108 data
.assign(buffer
, buffer
+ sizeof(buffer
));
110 EXPECT_FALSE(aac
.Parse(data
));
113 EXPECT_TRUE(aac
.Parse(data
));