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

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: Fix rebase: do not set dts in adts parser. 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
« no previous file with comments | « media/formats/mp2t/es_parser_adts.cc ('k') | media/formats/mp2t/es_parser_h264_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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/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"
15
16 namespace media {
17 class AudioDecoderConfig;
18
19 namespace mp2t {
20
21 class EsParserAdtsTest : public EsParserTestBase,
22 public testing::Test {
23 public:
24 EsParserAdtsTest();
25 virtual ~EsParserAdtsTest() {}
26
27 protected:
28 bool Process(const std::vector<Packet>& pes_packets, bool force_timing);
29
30 std::vector<Packet> GenerateFixedSizePesPacket(size_t pes_size);
31
32 private:
33 DISALLOW_COPY_AND_ASSIGN(EsParserAdtsTest);
34 };
35
36 EsParserAdtsTest::EsParserAdtsTest() {
37 }
38
39 bool EsParserAdtsTest::Process(
40 const std::vector<Packet>& pes_packets,
41 bool force_timing) {
42 EsParserAdts es_parser(
43 base::Bind(&EsParserAdtsTest::NewAudioConfig, base::Unretained(this)),
44 base::Bind(&EsParserAdtsTest::EmitBuffer, base::Unretained(this)),
45 false);
46 return ProcessPesPackets(&es_parser, pes_packets, force_timing);
47 }
48
49 std::vector<EsParserTestBase::Packet>
50 EsParserAdtsTest::GenerateFixedSizePesPacket(size_t pes_size) {
51 DCHECK_GT(stream_.size(), 0u);
52 std::vector<Packet> pes_packets;
53
54 Packet cur_pes_packet;
55 cur_pes_packet.offset = 0;
56 cur_pes_packet.pts = kNoTimestamp();
57 while (cur_pes_packet.offset < stream_.size()) {
58 pes_packets.push_back(cur_pes_packet);
59 cur_pes_packet.offset += pes_size;
60 }
61 ComputePacketSize(&pes_packets);
62
63 return pes_packets;
64 }
65
66 TEST_F(EsParserAdtsTest, NoInitialPts) {
67 LoadStream("bear.adts");
68 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512);
69 EXPECT_FALSE(Process(pes_packets, false));
70 EXPECT_EQ(0u, buffer_count_);
71 }
72
73 TEST_F(EsParserAdtsTest, SinglePts) {
74 LoadStream("bear.adts");
75
76 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512);
77 pes_packets.front().pts = base::TimeDelta::FromSeconds(10);
78
79 EXPECT_TRUE(Process(pes_packets, false));
80 EXPECT_EQ(1u, config_count_);
81 EXPECT_EQ(45u, buffer_count_);
82 }
83
84 } // namespace mp2t
85 } // namespace media
86
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_adts.cc ('k') | media/formats/mp2t/es_parser_h264_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698