Shaka Packager SDK
Loading...
Searching...
No Matches
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 PACKAGER_MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_
6#define PACKAGER_MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_
7
8#include <cstdint>
9#include <memory>
10
11#include <packager/macros/classes.h>
12#include <packager/media/base/byte_queue.h>
13#include <packager/media/formats/mp2t/ts_section.h>
14
15namespace shaka {
16namespace media {
17namespace mp2t {
18
19class EsParser;
20
21class TsSectionPes : public TsSection {
22 public:
23 explicit TsSectionPes(std::unique_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 bool 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 std::unique_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 shaka
66
67#endif
68
All the methods that are virtual are virtual for mocking.