Alternative way to define the files used by iOS in ui.
[chromium-blink-merge.git] / media / mp4 / aac_unittest.cc
blobc9f888caa4a6b87a3d697b4c96abfcc7108e1ef5
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"
9 namespace media {
11 namespace mp4 {
13 TEST(AACTest, BasicProfileTest) {
14 AAC aac;
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) {
26 AAC aac;
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) {
39 AAC aac;
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) {
52 AAC aac;
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) {
64 AAC aac;
65 std::vector<uint8> data;
67 EXPECT_FALSE(aac.Parse(data));
69 data.push_back(0x12);
70 EXPECT_FALSE(aac.Parse(data));
73 TEST(AACTest, IncorrectProfileTest) {
74 AAC aac;
75 uint8 buffer[] = {0x0, 0x08};
76 std::vector<uint8> data;
78 data.assign(buffer, buffer + sizeof(buffer));
80 EXPECT_FALSE(aac.Parse(data));
82 data[0] = 0x08;
83 EXPECT_TRUE(aac.Parse(data));
85 data[0] = 0x28;
86 EXPECT_FALSE(aac.Parse(data));
89 TEST(AACTest, IncorrectFrequencyTest) {
90 AAC aac;
91 uint8 buffer[] = {0x0f, 0x88};
92 std::vector<uint8> data;
94 data.assign(buffer, buffer + sizeof(buffer));
96 EXPECT_FALSE(aac.Parse(data));
98 data[0] = 0x0e;
99 data[1] = 0x08;
100 EXPECT_TRUE(aac.Parse(data));
103 TEST(AACTest, IncorrectChannelTest) {
104 AAC aac;
105 uint8 buffer[] = {0x0e, 0x00};
106 std::vector<uint8> data;
108 data.assign(buffer, buffer + sizeof(buffer));
110 EXPECT_FALSE(aac.Parse(data));
112 data[1] = 0x08;
113 EXPECT_TRUE(aac.Parse(data));
116 } // namespace mp4
118 } // namespace media