Home | History | Annotate | Download | only in mp4
      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.
      4 
      5 #include "media/mp4/es_descriptor.h"
      6 
      7 #include "testing/gtest/include/gtest/gtest.h"
      8 
      9 namespace media {
     10 
     11 namespace mp4 {
     12 
     13 TEST(ESDescriptorTest, SingleByteLengthTest) {
     14   ESDescriptor es_desc;
     15   uint8 buffer[] = {
     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,
     19     0x06, 0x01, 0x02
     20   };
     21   std::vector<uint8> data;
     22 
     23   data.assign(buffer, buffer + sizeof(buffer));
     24 
     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);
     31 }
     32 
     33 TEST(ESDescriptorTest, NonAACTest) {
     34   ESDescriptor es_desc;
     35   uint8 buffer[] = {
     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,
     39     0x06, 0x01, 0x02
     40   };
     41   std::vector<uint8> data;
     42 
     43   data.assign(buffer, buffer + sizeof(buffer));
     44 
     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);
     50 }
     51 
     52 TEST(ESDescriptorTest, MultiByteLengthTest) {
     53   ESDescriptor es_desc;
     54   uint8 buffer[] = {
     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,
     59     0x02
     60   };
     61   std::vector<uint8> data;
     62 
     63   data.assign(buffer, buffer + sizeof(buffer));
     64 
     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);
     70 }
     71 
     72 TEST(ESDescriptorTest, FiveByteLengthTest) {
     73   ESDescriptor es_desc;
     74   uint8 buffer[] = {
     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,
     79     0x01, 0x02
     80   };
     81   std::vector<uint8> data;
     82 
     83   data.assign(buffer, buffer + sizeof(buffer));
     84 
     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);
     88 }
     89 
     90 }  // namespace mp4
     91 
     92 }  // namespace media
     93