Add some instrumentation for jank in URLRequest::Start.
[chromium-blink-merge.git] / media / formats / mp2t / es_parser_test_base.h
blob433bbe134e5cbb95ecccafccf28644837c1ab828
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.
5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_TEST_BASE_H_
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_TEST_BASE_H_
8 #include <sstream>
9 #include <string>
10 #include <vector>
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/time/time.h"
16 namespace media {
17 class AudioDecoderConfig;
18 class StreamParserBuffer;
19 class VideoDecoderConfig;
21 namespace mp2t {
22 class EsParser;
24 class EsParserTestBase {
25 public:
26 struct Packet {
27 Packet();
29 // Offset in the stream.
30 size_t offset;
32 // Size of the packet.
33 size_t size;
35 // Timestamp of the packet.
36 base::TimeDelta pts;
39 EsParserTestBase();
40 virtual ~EsParserTestBase();
42 protected:
43 void LoadStream(const char* filename);
45 // ES parser callbacks.
46 void NewAudioConfig(const AudioDecoderConfig& config);
47 void NewVideoConfig(const VideoDecoderConfig& config);
48 void EmitBuffer(scoped_refptr<StreamParserBuffer> buffer);
50 // Process the PES packets using the given ES parser.
51 // When |force_timing| is true, even the invalid negative timestamps will be
52 // given to the ES parser.
53 // Return true if successful, false otherwise.
54 bool ProcessPesPackets(EsParser* es_parser,
55 const std::vector<Packet>& pes_packets,
56 bool force_timing);
58 // Assume the offsets are known, compute the size of each packet.
59 // The last packet is assumed to cover the end of the stream.
60 // Packets are assumed to be in stream order.
61 void ComputePacketSize(std::vector<Packet>* packets);
63 // Generate some fixed size PES packets of |stream_|.
64 std::vector<Packet> GenerateFixedSizePesPacket(size_t pes_size);
66 // ES stream.
67 std::vector<uint8> stream_;
69 // Number of decoder configs received from the ES parser.
70 size_t config_count_;
72 // Number of buffers generated while parsing the ES stream.
73 size_t buffer_count_;
75 // Timestamps of buffers generated while parsing the ES stream.
76 std::string buffer_timestamps_;
78 private:
79 // Timestamps of buffers generated while parsing the ES stream.
80 std::stringstream buffer_timestamps_stream_;
82 DISALLOW_COPY_AND_ASSIGN(EsParserTestBase);
85 } // namespace mp2t
86 } // namespace media
88 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_TEST_BASE_H_