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.
8 #include "base/logging.h"
9 #include "base/time/time.h"
10 #include "media/base/buffers.h"
11 #include "media/base/stream_parser_buffer.h"
12 #include "media/formats/mp2t/es_parser_adts.h"
13 #include "media/formats/mp2t/es_parser_test_base.h"
14 #include "testing/gtest/include/gtest/gtest.h"
17 class AudioDecoderConfig
;
21 class EsParserAdtsTest
: public EsParserTestBase
,
22 public testing::Test
{
27 bool Process(const std::vector
<Packet
>& pes_packets
, bool force_timing
);
30 DISALLOW_COPY_AND_ASSIGN(EsParserAdtsTest
);
33 EsParserAdtsTest::EsParserAdtsTest() {
36 bool EsParserAdtsTest::Process(
37 const std::vector
<Packet
>& pes_packets
,
39 EsParserAdts
es_parser(
40 base::Bind(&EsParserAdtsTest::NewAudioConfig
, base::Unretained(this)),
41 base::Bind(&EsParserAdtsTest::EmitBuffer
, base::Unretained(this)),
43 return ProcessPesPackets(&es_parser
, pes_packets
, force_timing
);
46 TEST_F(EsParserAdtsTest
, NoInitialPts
) {
47 LoadStream("bear.adts");
48 std::vector
<Packet
> pes_packets
= GenerateFixedSizePesPacket(512);
49 // 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
51 // play the stream after that.
52 EXPECT_TRUE(Process(pes_packets
, false));
53 EXPECT_EQ(1u, config_count_
);
54 EXPECT_EQ(0u, buffer_count_
);
57 TEST_F(EsParserAdtsTest
, SinglePts
) {
58 LoadStream("bear.adts");
60 std::vector
<Packet
> pes_packets
= GenerateFixedSizePesPacket(512);
61 pes_packets
.front().pts
= base::TimeDelta::FromSeconds(10);
63 EXPECT_TRUE(Process(pes_packets
, false));
64 EXPECT_EQ(1u, config_count_
);
65 EXPECT_EQ(45u, buffer_count_
);