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