OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/base/stream_parser_buffer.h" | 11 #include "media/base/stream_parser_buffer.h" |
12 #include "media/formats/mp2t/es_parser_adts.h" | 12 #include "media/formats/mp2t/es_parser_adts.h" |
13 #include "media/formats/mp2t/es_parser_test_base.h" | 13 #include "media/formats/mp2t/es_parser_test_base.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 class AudioDecoderConfig; | 17 class AudioDecoderConfig; |
18 | 18 |
19 namespace mp2t { | 19 namespace mp2t { |
20 namespace { | |
21 const char kAac44100PacketTimestamp[] = "(0) (23) (46) (69)"; | |
22 } | |
20 | 23 |
21 class EsParserAdtsTest : public EsParserTestBase, | 24 class EsParserAdtsTest : public EsParserTestBase, |
22 public testing::Test { | 25 public testing::Test { |
23 public: | 26 public: |
24 EsParserAdtsTest(); | 27 EsParserAdtsTest(); |
25 | 28 |
26 protected: | 29 protected: |
27 bool Process(const std::vector<Packet>& pes_packets, bool force_timing); | 30 bool Process(const std::vector<Packet>& pes_packets, bool force_timing); |
28 | 31 |
29 private: | 32 private: |
30 DISALLOW_COPY_AND_ASSIGN(EsParserAdtsTest); | 33 DISALLOW_COPY_AND_ASSIGN(EsParserAdtsTest); |
31 }; | 34 }; |
32 | 35 |
33 EsParserAdtsTest::EsParserAdtsTest() { | 36 EsParserAdtsTest::EsParserAdtsTest() { |
34 } | 37 } |
35 | 38 |
36 bool EsParserAdtsTest::Process( | 39 bool EsParserAdtsTest::Process( |
37 const std::vector<Packet>& pes_packets, | 40 const std::vector<Packet>& pes_packets, |
38 bool force_timing) { | 41 bool force_timing) { |
39 EsParserAdts es_parser( | 42 EsParserAdts es_parser( |
40 base::Bind(&EsParserAdtsTest::NewAudioConfig, base::Unretained(this)), | 43 base::Bind(&EsParserAdtsTest::NewAudioConfig, base::Unretained(this)), |
41 base::Bind(&EsParserAdtsTest::EmitBuffer, base::Unretained(this)), | 44 base::Bind(&EsParserAdtsTest::EmitBuffer, base::Unretained(this)), |
42 false); | 45 false); |
chcunningham
2016/06/13 23:34:06
IIUC, this false means you don't have SBR in your
yucliu1
2016/06/14 00:06:10
No one use |force_timing|. So replace it with |sbr
| |
43 return ProcessPesPackets(&es_parser, pes_packets, force_timing); | 46 return ProcessPesPackets(&es_parser, pes_packets, force_timing); |
44 } | 47 } |
45 | 48 |
46 TEST_F(EsParserAdtsTest, NoInitialPts) { | 49 TEST_F(EsParserAdtsTest, NoInitialPts) { |
47 LoadStream("bear.adts"); | 50 LoadStream("bear.adts"); |
48 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); | 51 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); |
49 // Process should succeed even without timing info, we should just skip the | 52 // Process should succeed even without timing info, we should just skip the |
50 // audio frames without timing info, but still should be able to parse and | 53 // audio frames without timing info, but still should be able to parse and |
51 // play the stream after that. | 54 // play the stream after that. |
52 EXPECT_TRUE(Process(pes_packets, false)); | 55 EXPECT_TRUE(Process(pes_packets, false)); |
(...skipping 13 matching lines...) Expand all Loading... | |
66 } | 69 } |
67 | 70 |
68 TEST_F(EsParserAdtsTest, AacLcAdts) { | 71 TEST_F(EsParserAdtsTest, AacLcAdts) { |
69 LoadStream("sfx.adts"); | 72 LoadStream("sfx.adts"); |
70 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); | 73 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); |
71 pes_packets.front().pts = base::TimeDelta::FromSeconds(1); | 74 pes_packets.front().pts = base::TimeDelta::FromSeconds(1); |
72 EXPECT_TRUE(Process(pes_packets, false)); | 75 EXPECT_TRUE(Process(pes_packets, false)); |
73 EXPECT_EQ(1u, config_count_); | 76 EXPECT_EQ(1u, config_count_); |
74 EXPECT_EQ(14u, buffer_count_); | 77 EXPECT_EQ(14u, buffer_count_); |
75 } | 78 } |
79 | |
80 TEST_F(EsParserAdtsTest, AacSampleRate) { | |
81 std::vector<Packet> pes_packets = | |
82 LoadPacketsFromFiles("aac-44100-packet-%d", 4); | |
83 | |
84 pes_packets.front().pts = base::TimeDelta::FromSeconds(0); | |
85 EXPECT_TRUE(Process(pes_packets, false)); | |
86 EXPECT_EQ(4u, buffer_count_); | |
87 EXPECT_EQ(kAac44100PacketTimestamp, buffer_timestamps_); | |
88 } | |
76 } // namespace mp2t | 89 } // namespace mp2t |
77 } // namespace media | 90 } // namespace media |
78 | 91 |
OLD | NEW |