OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 <vector> |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/logging.h" |
| 9 #include "base/time/time.h" |
| 10 #include "media/base/buffers.h" |
| 11 #include "media/base/media_log.h" |
| 12 #include "media/base/stream_parser_buffer.h" |
| 13 #include "media/formats/mp2t/es_parser_mpeg1audio.h" |
| 14 #include "media/formats/mp2t/es_parser_test_base.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 |
| 17 namespace media { |
| 18 class AudioDecoderConfig; |
| 19 |
| 20 namespace mp2t { |
| 21 |
| 22 class EsParserMpeg1AudioTest : public EsParserTestBase, |
| 23 public testing::Test { |
| 24 public: |
| 25 EsParserMpeg1AudioTest(); |
| 26 virtual ~EsParserMpeg1AudioTest() {} |
| 27 |
| 28 protected: |
| 29 bool Process(const std::vector<Packet>& pes_packets, bool force_timing); |
| 30 |
| 31 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(EsParserMpeg1AudioTest); |
| 33 }; |
| 34 |
| 35 EsParserMpeg1AudioTest::EsParserMpeg1AudioTest() { |
| 36 } |
| 37 |
| 38 bool EsParserMpeg1AudioTest::Process( |
| 39 const std::vector<Packet>& pes_packets, |
| 40 bool force_timing) { |
| 41 EsParserMpeg1Audio es_parser( |
| 42 base::Bind(&EsParserMpeg1AudioTest::NewAudioConfig, |
| 43 base::Unretained(this)), |
| 44 base::Bind(&EsParserMpeg1AudioTest::EmitBuffer, |
| 45 base::Unretained(this)), |
| 46 LogCB()); |
| 47 return ProcessPesPackets(&es_parser, pes_packets, force_timing); |
| 48 } |
| 49 |
| 50 TEST_F(EsParserMpeg1AudioTest, SinglePts) { |
| 51 LoadStream("sfx.mp3"); |
| 52 |
| 53 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); |
| 54 pes_packets.front().pts = base::TimeDelta::FromSeconds(10); |
| 55 |
| 56 // Note: there is no parsing of metadata as part of Mpeg2 TS, |
| 57 // so the tag starting at 0x80d with 0x54 0x41 0x47 (ascii for "TAG") |
| 58 // is not a valid Mpeg1 audio frame header. This makes the previous frame |
| 59 // invalid since there is no start code following the previous frame. |
| 60 // So instead of the 13 Mpeg1 audio frames, only 12 are considered valid. |
| 61 // Offset of frames in the file: |
| 62 // {0x20, 0x1c1, 0x277, 0x2f9, 0x3fd, 0x47f, 0x501, 0x583, |
| 63 // 0x605, 0x687, 0x73d, 0x7a5, 0x80d} |
| 64 // TODO(damienv): find a file that would be more relevant for Mpeg1 audio |
| 65 // as part of Mpeg2 TS. |
| 66 EXPECT_TRUE(Process(pes_packets, false)); |
| 67 EXPECT_EQ(1u, config_count_); |
| 68 EXPECT_EQ(12u, buffer_count_); |
| 69 } |
| 70 |
| 71 } // namespace mp2t |
| 72 } // namespace media |
OLD | NEW |