Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: media/formats/mp2t/es_parser_adts_unittest.cc

Issue 399433003: Mpeg2 TS - Fail when no valid timestamp in the ADTS parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 <algorithm>
6 #include <vector>
7
8 #include "base/bind.h"
9 #include "base/command_line.h"
10 #include "base/files/memory_mapped_file.h"
11 #include "base/logging.h"
12 #include "base/path_service.h"
13 #include "base/time/time.h"
14 #include "media/base/buffers.h"
15 #include "media/base/stream_parser_buffer.h"
16 #include "media/base/test_data_util.h"
17 #include "media/formats/mp2t/es_parser_adts.h"
18 #include "media/formats/mp2t/es_parser_test_base.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20
21 namespace media {
22 class AudioDecoderConfig;
23
24 namespace mp2t {
25
26 class EsParserAdtsTest : public EsParserTestBase,
27 public testing::Test {
28 public:
29 EsParserAdtsTest();
30 virtual ~EsParserAdtsTest() {}
31
32 protected:
33 bool Process(const std::vector<Packet>& pes_packets, bool force_timing);
34
35 std::vector<Packet> GenerateFixedSizePesPacket(size_t pes_size);
36
37 private:
38 DISALLOW_COPY_AND_ASSIGN(EsParserAdtsTest);
39 };
40
41 EsParserAdtsTest::EsParserAdtsTest() {
42 }
43
44 bool EsParserAdtsTest::Process(
45 const std::vector<Packet>& pes_packets,
46 bool force_timing) {
47 EsParserAdts es_parser(
48 base::Bind(&EsParserAdtsTest::NewAudioConfig, base::Unretained(this)),
49 base::Bind(&EsParserAdtsTest::EmitBuffer, base::Unretained(this)),
50 false);
51 return ProcessPesPackets(&es_parser, pes_packets, force_timing);
52 }
53
54 std::vector<EsParserTestBase::Packet>
55 EsParserAdtsTest::GenerateFixedSizePesPacket(size_t pes_size) {
56 DCHECK_GT(stream_.size(), 0u);
57 std::vector<Packet> pes_packets;
58
59 Packet cur_pes_packet;
60 cur_pes_packet.offset = 0;
61 cur_pes_packet.pts = kNoTimestamp();
62 while (cur_pes_packet.offset < stream_.size()) {
63 pes_packets.push_back(cur_pes_packet);
64 cur_pes_packet.offset += pes_size;
65 }
66 ComputePacketSize(&pes_packets);
67
68 return pes_packets;
69 }
70
71 TEST_F(EsParserAdtsTest, NoInitialPts) {
72 LoadStream("bear.adts");
73 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512);
74 EXPECT_FALSE(Process(pes_packets, false));
75 EXPECT_EQ(0u, buffer_count_);
76 }
77
78 TEST_F(EsParserAdtsTest, SinglePts) {
79 LoadStream("bear.adts");
80
81 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512);
82 pes_packets.front().pts = base::TimeDelta::FromSeconds(10);
83
84 EXPECT_TRUE(Process(pes_packets, false));
85 EXPECT_EQ(1u, config_count_);
86 EXPECT_EQ(45u, buffer_count_);
87 }
88
89 } // namespace mp2t
90 } // namespace media
91
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698