Shaka Packager SDK
pes_packet.h
1 // Copyright 2016 Google LLC. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_H_
8 #define PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_H_
9 
10 #include <cstdint>
11 #include <vector>
12 
13 #include <packager/macros/classes.h>
14 
15 namespace shaka {
16 namespace media {
17 namespace mp2t {
18 
20 class PesPacket {
21  public:
22  PesPacket();
23  ~PesPacket();
24 
26  uint8_t stream_id() const { return stream_id_; }
28  void set_stream_id(uint8_t stream_id) { stream_id_ = stream_id; }
29 
31  bool has_dts() const { return dts_ >= 0; }
33  bool has_pts() const { return pts_ >= 0; }
34 
36  int64_t dts() const { return dts_; }
38  void set_dts(int64_t dts) {
39  dts_ = dts;
40  }
41 
43  int64_t pts() const { return pts_; }
45  void set_pts(int64_t pts) {
46  pts_ = pts;
47  }
48 
50  bool is_key_frame() const { return is_key_frame_; }
52  void set_is_key_frame(bool is_key_frame) { is_key_frame_ = is_key_frame; }
53 
54  const std::vector<uint8_t>& data() const { return data_; }
56  std::vector<uint8_t>* mutable_data() { return &data_; }
57 
58  private:
59  uint8_t stream_id_ = 0;
60 
61  // These values mean "not set" when the value is less than 0.
62  int64_t dts_ = -1;
63  int64_t pts_ = -1;
64  bool is_key_frame_ = false;
65 
66  std::vector<uint8_t> data_;
67 
68  DISALLOW_COPY_AND_ASSIGN(PesPacket);
69 };
70 
71 } // namespace mp2t
72 } // namespace media
73 } // namespace shaka
74 
75 #endif // PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_H_
Class that carries PES packet information.
Definition: pes_packet.h:20
void set_pts(int64_t pts)
Definition: pes_packet.h:45
uint8_t stream_id() const
Definition: pes_packet.h:26
void set_is_key_frame(bool is_key_frame)
Definition: pes_packet.h:52
std::vector< uint8_t > * mutable_data()
Definition: pes_packet.h:56
void set_dts(int64_t dts)
Definition: pes_packet.h:38
void set_stream_id(uint8_t stream_id)
Definition: pes_packet.h:28
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66