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_
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/time/time.h"
17 class AudioDecoderConfig
;
18 class StreamParserBuffer
;
19 class VideoDecoderConfig
;
24 class EsParserTestBase
{
29 // Offset in the stream.
32 // Size of the packet.
35 // Timestamp of the packet.
40 virtual ~EsParserTestBase();
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
,
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
);
67 std::vector
<uint8
> stream_
;
69 // Number of decoder configs received from the ES parser.
72 // Number of buffers generated while parsing the ES stream.
75 // Timestamps of buffers generated while parsing the ES stream.
76 std::string buffer_timestamps_
;
79 // Timestamps of buffers generated while parsing the ES stream.
80 std::stringstream buffer_timestamps_stream_
;
82 DISALLOW_COPY_AND_ASSIGN(EsParserTestBase
);
88 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_TEST_BASE_H_