OLD | NEW |
(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 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_TEST_BASE_H_ |
| 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_TEST_BASE_H_ |
| 7 |
| 8 #include <sstream> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" |
| 15 |
| 16 namespace media { |
| 17 class AudioDecoderConfig; |
| 18 class StreamParserBuffer; |
| 19 class VideoDecoderConfig; |
| 20 |
| 21 namespace mp2t { |
| 22 class EsParser; |
| 23 |
| 24 class EsParserTestBase { |
| 25 public: |
| 26 struct Packet { |
| 27 Packet(); |
| 28 |
| 29 // Offset in the stream. |
| 30 size_t offset; |
| 31 |
| 32 // Size of the packet. |
| 33 size_t size; |
| 34 |
| 35 // Timestamp of the packet. |
| 36 base::TimeDelta pts; |
| 37 }; |
| 38 |
| 39 EsParserTestBase(); |
| 40 virtual ~EsParserTestBase(); |
| 41 |
| 42 protected: |
| 43 void LoadStream(const char* filename); |
| 44 |
| 45 // ES parser callbacks. |
| 46 void NewAudioConfig(const AudioDecoderConfig& config); |
| 47 void NewVideoConfig(const VideoDecoderConfig& config); |
| 48 void EmitBuffer(scoped_refptr<StreamParserBuffer> buffer); |
| 49 |
| 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); |
| 57 |
| 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); |
| 62 |
| 63 // ES stream. |
| 64 std::vector<uint8> stream_; |
| 65 |
| 66 // Number of decoder configs received from the ES parser. |
| 67 size_t config_count_; |
| 68 |
| 69 // Number of buffers generated while parsing the ES stream. |
| 70 size_t buffer_count_; |
| 71 |
| 72 // Timestamps of buffers generated while parsing the ES stream. |
| 73 std::string buffer_timestamps_; |
| 74 |
| 75 private: |
| 76 // Timestamps of buffers generated while parsing the ES stream. |
| 77 std::stringstream buffer_timestamps_stream_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(EsParserTestBase); |
| 80 }; |
| 81 |
| 82 } // namespace mp2t |
| 83 } // namespace media |
| 84 |
| 85 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_TEST_BASE_H_ |
OLD | NEW |