1 // Copyright 2013 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_MP2T_TS_SECTION_PES_H_ 6 #define MEDIA_MP2T_TS_SECTION_PES_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "media/base/byte_queue.h" 12 #include "media/mp2t/ts_section.h" 13 14 namespace media { 15 namespace mp2t { 16 17 class EsParser; 18 19 class TsSectionPes : public TsSection { 20 public: 21 explicit TsSectionPes(scoped_ptr<EsParser> es_parser); 22 virtual ~TsSectionPes(); 23 24 // TsSection implementation. 25 virtual bool Parse(bool payload_unit_start_indicator, 26 const uint8* buf, int size) OVERRIDE; 27 virtual void Flush() OVERRIDE; 28 virtual void Reset() OVERRIDE; 29 30 private: 31 // Emit a reassembled PES packet. 32 // Return true if successful. 33 // |emit_for_unknown_size| is used to force emission for PES packets 34 // whose size is unknown. 35 bool Emit(bool emit_for_unknown_size); 36 37 // Parse a PES packet, return true if successful. 38 bool ParseInternal(const uint8* raw_pes, int raw_pes_size); 39 40 void ResetPesState(); 41 42 // Bytes of the current PES. 43 ByteQueue pes_byte_queue_; 44 45 // ES parser. 46 scoped_ptr<EsParser> es_parser_; 47 48 // Do not start parsing before getting a unit start indicator. 49 bool wait_for_pusi_; 50 51 // Used to unroll PTS and DTS. 52 bool previous_pts_valid_; 53 int64 previous_pts_; 54 bool previous_dts_valid_; 55 int64 previous_dts_; 56 57 DISALLOW_COPY_AND_ASSIGN(TsSectionPes); 58 }; 59 60 } // namespace mp2t 61 } // namespace media 62 63 #endif 64 65