Shaka Packager SDK
ts_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_TS_WRITER_H_
8 #define PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
9 
10 #include <list>
11 #include <map>
12 #include <memory>
13 #include <optional>
14 #include <vector>
15 
16 #include <packager/file.h>
17 #include <packager/file/file_closer.h>
18 #include <packager/media/base/buffer_writer.h>
19 #include <packager/media/formats/mp2t/continuity_counter.h>
20 #include <optional>
21 
22 namespace shaka {
23 namespace media {
24 namespace mp2t {
25 
26 class PesPacket;
27 class ProgramMapTableWriter;
28 
31 class TsWriter {
32  public:
33  explicit TsWriter(std::unique_ptr<ProgramMapTableWriter> pmt_writer);
34  virtual ~TsWriter();
35 
39  virtual bool NewSegment(BufferWriter* buffer);
40 
42  virtual void SignalEncrypted();
43 
49  virtual bool AddPesPacket(std::unique_ptr<PesPacket> pes_packet, BufferWriter* buffer);
50 
51  private:
52  TsWriter(const TsWriter&) = delete;
53  TsWriter& operator=(const TsWriter&) = delete;
54 
55  // True if further segments generated by this instance should be encrypted.
56  bool encrypted_ = false;
57 
58  ContinuityCounter pat_continuity_counter_;
59  ContinuityCounter elementary_stream_continuity_counter_;
60 
61  std::unique_ptr<ProgramMapTableWriter> pmt_writer_;
62 };
63 
64 } // namespace mp2t
65 } // namespace media
66 } // namespace shaka
67 
68 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
virtual bool NewSegment(BufferWriter *buffer)
Definition: ts_writer.cc:169
virtual bool AddPesPacket(std::unique_ptr< PesPacket > pes_packet, BufferWriter *buffer)
Definition: ts_writer.cc:190
virtual void SignalEncrypted()
Signals the writer that the rest of the segments are encrypted.
Definition: ts_writer.cc:186
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66