Chromium Code Reviews| 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 sbr_in_mimetype); |
| 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(const std::vector<Packet>& pes_packets, |
| 37 const std::vector<Packet>& pes_packets, | 40 bool sbr_in_mimetype) { |
| 38 bool force_timing) { | |
| 39 EsParserAdts es_parser( | 41 EsParserAdts es_parser( |
| 40 base::Bind(&EsParserAdtsTest::NewAudioConfig, base::Unretained(this)), | 42 base::Bind(&EsParserAdtsTest::NewAudioConfig, base::Unretained(this)), |
| 41 base::Bind(&EsParserAdtsTest::EmitBuffer, base::Unretained(this)), | 43 base::Bind(&EsParserAdtsTest::EmitBuffer, base::Unretained(this)), |
| 42 false); | 44 sbr_in_mimetype); |
| 43 return ProcessPesPackets(&es_parser, pes_packets, force_timing); | 45 return ProcessPesPackets(&es_parser, pes_packets, false /* force_timing */); |
|
chcunningham
2016/06/14 00:13:07
Missed one ;)
yucliu1
2016/06/14 00:23:28
Which one is missing?
yucliu1
2016/06/14 22:01:05
Ping~ I'm not sure what I'm missing here.
chcunningham
2016/06/14 23:27:41
sorry, I just mean that your comment says force_ti
yucliu1
2016/06/14 23:42:25
Ah, this one should be force_timing. It's used in
| |
| 44 } | 46 } |
| 45 | 47 |
| 46 TEST_F(EsParserAdtsTest, NoInitialPts) { | 48 TEST_F(EsParserAdtsTest, NoInitialPts) { |
| 47 LoadStream("bear.adts"); | 49 LoadStream("bear.adts"); |
| 48 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); | 50 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); |
| 49 // Process should succeed even without timing info, we should just skip the | 51 // 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 | 52 // audio frames without timing info, but still should be able to parse and |
| 51 // play the stream after that. | 53 // play the stream after that. |
| 52 EXPECT_TRUE(Process(pes_packets, false)); | 54 EXPECT_TRUE(Process(pes_packets, false /* sbr_in_mimetype */)); |
| 53 EXPECT_EQ(1u, config_count_); | 55 EXPECT_EQ(1u, config_count_); |
| 54 EXPECT_EQ(0u, buffer_count_); | 56 EXPECT_EQ(0u, buffer_count_); |
| 55 } | 57 } |
| 56 | 58 |
| 57 TEST_F(EsParserAdtsTest, SinglePts) { | 59 TEST_F(EsParserAdtsTest, SinglePts) { |
| 58 LoadStream("bear.adts"); | 60 LoadStream("bear.adts"); |
| 59 | 61 |
| 60 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); | 62 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); |
| 61 pes_packets.front().pts = base::TimeDelta::FromSeconds(10); | 63 pes_packets.front().pts = base::TimeDelta::FromSeconds(10); |
| 62 | 64 |
| 63 EXPECT_TRUE(Process(pes_packets, false)); | 65 EXPECT_TRUE(Process(pes_packets, false /* sbr_in_mimetype */)); |
| 64 EXPECT_EQ(1u, config_count_); | 66 EXPECT_EQ(1u, config_count_); |
| 65 EXPECT_EQ(45u, buffer_count_); | 67 EXPECT_EQ(45u, buffer_count_); |
| 66 } | 68 } |
| 67 | 69 |
| 68 TEST_F(EsParserAdtsTest, AacLcAdts) { | 70 TEST_F(EsParserAdtsTest, AacLcAdts) { |
| 69 LoadStream("sfx.adts"); | 71 LoadStream("sfx.adts"); |
| 70 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); | 72 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512); |
| 71 pes_packets.front().pts = base::TimeDelta::FromSeconds(1); | 73 pes_packets.front().pts = base::TimeDelta::FromSeconds(1); |
| 72 EXPECT_TRUE(Process(pes_packets, false)); | 74 EXPECT_TRUE(Process(pes_packets, false /* sbr_in_mimetype */)); |
| 73 EXPECT_EQ(1u, config_count_); | 75 EXPECT_EQ(1u, config_count_); |
| 74 EXPECT_EQ(14u, buffer_count_); | 76 EXPECT_EQ(14u, buffer_count_); |
| 75 } | 77 } |
| 78 | |
| 79 TEST_F(EsParserAdtsTest, AacSampleRate) { | |
| 80 std::vector<Packet> pes_packets = | |
| 81 LoadPacketsFromFiles("aac-44100-packet-%d", 4); | |
| 82 | |
| 83 pes_packets.front().pts = base::TimeDelta::FromSeconds(0); | |
| 84 EXPECT_TRUE(Process(pes_packets, true /* sbr_in_mimetype */)); | |
| 85 EXPECT_EQ(4u, buffer_count_); | |
| 86 EXPECT_EQ(kAac44100PacketTimestamp, buffer_timestamps_); | |
| 87 } | |
| 76 } // namespace mp2t | 88 } // namespace mp2t |
| 77 } // namespace media | 89 } // namespace media |
| 78 | 90 |
| OLD | NEW |