Shaka Packager SDK
program_map_table_writer.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_PROGRAM_MAP_TABLE_WRITER_H_
8 #define PACKAGER_MEDIA_FORMATS_MP2T_PROGRAM_MAP_TABLE_WRITER_H_
9 
10 #include <cstdint>
11 #include <vector>
12 
13 #include <packager/media/base/buffer_writer.h>
14 // TODO(kqyang): Move codec to codec.h.
15 #include <packager/media/base/stream_info.h>
16 #include <packager/media/formats/mp2t/continuity_counter.h>
17 
18 namespace shaka {
19 namespace media {
20 
21 class BufferWriter;
22 
23 namespace mp2t {
24 
27  public:
28  explicit ProgramMapTableWriter(Codec codec);
29  virtual ~ProgramMapTableWriter() = default;
30 
32  // Virtual for testing.
33  virtual bool EncryptedSegmentPmt(BufferWriter* writer);
34 
36  // Virtual for testing.
37  virtual bool ClearSegmentPmt(BufferWriter* writer);
38 
39  // The pid can be 13 bits long but 8 bits is sufficient for this library.
40  // This is the minimum PID that can be used for PMT.
41  static const uint8_t kPmtPid = 0x20;
42 
43  // This is arbitrary number that is not reserved by the spec.
44  static const uint8_t kElementaryPid = 0x50;
45 
46  protected:
48  Codec codec() const { return codec_; }
49 
50  private:
52  ProgramMapTableWriter& operator=(const ProgramMapTableWriter&) = delete;
53 
54  // Writes descriptors for PMT (only needed for encrypted PMT).
55  virtual bool WriteDescriptors(BufferWriter* writer) const = 0;
56 
57  const Codec codec_;
58  ContinuityCounter continuity_counter_;
59  BufferWriter clear_pmt_;
60  BufferWriter encrypted_pmt_;
61 };
62 
65  public:
66  explicit VideoProgramMapTableWriter(Codec codec);
67  ~VideoProgramMapTableWriter() override = default;
68 
69  private:
72  delete;
73 
74  bool WriteDescriptors(BufferWriter* writer) const override;
75 };
76 
79  public:
81  const std::vector<uint8_t>& audio_specific_config);
82  ~AudioProgramMapTableWriter() override = default;
83 
84  private:
87  delete;
88 
89  // Writers descriptors for PMT (only needed for encrypted PMT).
90  bool WriteDescriptors(BufferWriter* descriptors) const override;
91 
92  const std::vector<uint8_t> audio_specific_config_;
93 };
94 
95 } // namespace mp2t
96 } // namespace media
97 } // namespace shaka
98 
99 #endif // PACKAGER_MEDIA_FORMATS_MP2T_PROGRAM_MAP_TABLE_WRITER_H_
ProgramMapTableWriter for video codecs.
Puts PMT into TS packets and writes them to buffer.
virtual bool EncryptedSegmentPmt(BufferWriter *writer)
Writes TS packets with PMT for encrypted segments.
virtual bool ClearSegmentPmt(BufferWriter *writer)
Writes TS packets with PMT for clear segments.
ProgramMapTableWriter for video codecs.
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66