2013-09-24 01:35:40 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-08-21 22:40:44 +00:00
|
|
|
#include <gtest/gtest.h>
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-08-21 22:40:44 +00:00
|
|
|
#include "media/formats/mp4/es_descriptor.h"
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2013-09-24 01:35:40 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
namespace mp4 {
|
|
|
|
|
|
|
|
TEST(ESDescriptorTest, SingleByteLengthTest) {
|
|
|
|
ESDescriptor es_desc;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t buffer[] = {0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x40, 0x15,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x05, 0x02, 0x12, 0x10, 0x06, 0x01, 0x02};
|
|
|
|
std::vector<uint8_t> data;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
data.assign(buffer, buffer + sizeof(buffer));
|
|
|
|
|
|
|
|
EXPECT_EQ(es_desc.object_type(), kForbidden);
|
|
|
|
EXPECT_TRUE(es_desc.Parse(data));
|
|
|
|
EXPECT_EQ(es_desc.object_type(), kISO_14496_3);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info().size(), 2u);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info()[0], 0x12);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info()[1], 0x10);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ESDescriptorTest, NonAACTest) {
|
|
|
|
ESDescriptor es_desc;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t buffer[] = {0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x66, 0x15,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x05, 0x02, 0x12, 0x10, 0x06, 0x01, 0x02};
|
|
|
|
std::vector<uint8_t> data;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
data.assign(buffer, buffer + sizeof(buffer));
|
|
|
|
|
|
|
|
EXPECT_TRUE(es_desc.Parse(data));
|
|
|
|
EXPECT_NE(es_desc.object_type(), kISO_14496_3);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info().size(), 2u);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info()[0], 0x12);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info()[1], 0x10);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ESDescriptorTest, MultiByteLengthTest) {
|
|
|
|
ESDescriptor es_desc;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t buffer[] = {0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80, 0x80,
|
|
|
|
0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x80, 0x80, 0x80,
|
|
|
|
0x02, 0x12, 0x10, 0x06, 0x01, 0x02};
|
|
|
|
std::vector<uint8_t> data;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
data.assign(buffer, buffer + sizeof(buffer));
|
|
|
|
|
|
|
|
EXPECT_TRUE(es_desc.Parse(data));
|
|
|
|
EXPECT_EQ(es_desc.object_type(), kISO_14496_3);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info().size(), 2u);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info()[0], 0x12);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info()[1], 0x10);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ESDescriptorTest, FiveByteLengthTest) {
|
|
|
|
ESDescriptor es_desc;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t buffer[] = {0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80, 0x80,
|
|
|
|
0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x80, 0x80, 0x80,
|
|
|
|
0x80, 0x02, 0x12, 0x10, 0x06, 0x01, 0x02};
|
|
|
|
std::vector<uint8_t> data;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
data.assign(buffer, buffer + sizeof(buffer));
|
|
|
|
|
|
|
|
EXPECT_TRUE(es_desc.Parse(data));
|
|
|
|
EXPECT_EQ(es_desc.object_type(), kISO_14496_3);
|
|
|
|
EXPECT_EQ(es_desc.decoder_specific_info().size(), 0u);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|