summaryrefslogtreecommitdiff
path: root/chromium/media/formats/mp4/es_descriptor_unittest.cc
blob: 04e9eae062c552e8c480e0381c5d8049d40ef3d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/formats/mp4/es_descriptor.h"

#include <stdint.h>

#include "testing/gtest/include/gtest/gtest.h"

namespace media {

namespace mp4 {

TEST(ESDescriptorTest, SingleByteLengthTest) {
  ESDescriptor es_desc;
  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;

  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;
  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;

  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;
  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;

  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;
  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;

  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