Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
ts_writer.h
1 // Copyright 2016 Google Inc. 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 <vector>
14 
15 #include "packager/file/file.h"
16 #include "packager/file/file_closer.h"
17 #include "packager/media/formats/mp2t/continuity_counter.h"
18 
19 namespace shaka {
20 namespace media {
21 namespace mp2t {
22 
23 class PesPacket;
24 class ProgramMapTableWriter;
25 
28 class TsWriter {
29  public:
30  explicit TsWriter(std::unique_ptr<ProgramMapTableWriter> pmt_writer);
31  virtual ~TsWriter();
32 
37  virtual bool NewSegment(const std::string& file_name);
38 
40  virtual void SignalEncrypted();
41 
45  virtual bool FinalizeSegment();
46 
51  virtual bool AddPesPacket(std::unique_ptr<PesPacket> pes_packet);
52 
53  private:
54  TsWriter(const TsWriter&) = delete;
55  TsWriter& operator=(const TsWriter&) = delete;
56 
57  // True if further segments generated by this instance should be encrypted.
58  bool encrypted_ = false;
59 
60  ContinuityCounter pat_continuity_counter_;
61  ContinuityCounter elementary_stream_continuity_counter_;
62 
63  std::unique_ptr<ProgramMapTableWriter> pmt_writer_;
64 
65  std::unique_ptr<File, FileCloser> current_file_;
66 };
67 
68 } // namespace mp2t
69 } // namespace media
70 } // namespace shaka
71 
72 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
virtual bool NewSegment(const std::string &file_name)
Definition: ts_writer.cc:166
virtual bool AddPesPacket(std::unique_ptr< PesPacket > pes_packet)
Definition: ts_writer.cc:205
virtual bool FinalizeSegment()
Definition: ts_writer.cc:201
virtual void SignalEncrypted()
Signals the writer that the rest of the segments are encrypted.
Definition: ts_writer.cc:197