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