summaryrefslogtreecommitdiff
path: root/chromium/media/formats/mp2t/ts_section_pes.h
blob: 405fd3b74de60a3663e32444c5e43d21563de506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_
#define MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_

#include <stdint.h>

#include <memory>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "media/base/byte_queue.h"
#include "media/formats/mp2t/ts_section.h"

namespace media {
namespace mp2t {

class EsParser;
class TimestampUnroller;

class TsSectionPes : public TsSection {
 public:
  TsSectionPes(std::unique_ptr<EsParser> es_parser,
               TimestampUnroller* timestamp_unroller);
  ~TsSectionPes() override;

  // TsSection implementation.
  bool Parse(bool payload_unit_start_indicator,
             const uint8_t* buf,
             int size) override;
  void Flush() override;
  void Reset() override;

 private:
  // Emit a reassembled PES packet.
  // Return true if successful.
  // |emit_for_unknown_size| is used to force emission for PES packets
  // whose size is unknown.
  bool Emit(bool emit_for_unknown_size);

  // Parse a PES packet, return true if successful.
  bool ParseInternal(const uint8_t* raw_pes, int raw_pes_size);

  void ResetPesState();

  // Bytes of the current PES.
  ByteQueue pes_byte_queue_;

  // ES parser.
  std::unique_ptr<EsParser> es_parser_;

  // Do not start parsing before getting a unit start indicator.
  bool wait_for_pusi_;

  // Used to unroll PTS and DTS.
  TimestampUnroller* const timestamp_unroller_;

  DISALLOW_COPY_AND_ASSIGN(TsSectionPes);
};

}  // namespace mp2t
}  // namespace media

#endif  // MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_