DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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/media/file/file.h"
16 #include "packager/media/file/file_closer.h"
17 #include "packager/media/formats/mp2t/continuity_counter.h"
18 #include "packager/media/formats/mp2t/pes_packet.h"
19 #include "packager/media/formats/mp2t/program_map_table_writer.h"
20 
21 namespace shaka {
22 namespace media {
23 
24 class StreamInfo;
25 
26 namespace mp2t {
27 
30 class TsWriter {
31  public:
32  TsWriter();
33  virtual ~TsWriter();
34 
38  virtual bool Initialize(const StreamInfo& stream_info);
39 
44  virtual bool NewSegment(const std::string& file_name);
45 
47  virtual void SignalEncrypted();
48 
52  virtual bool FinalizeSegment();
53 
58  virtual bool AddPesPacket(std::unique_ptr<PesPacket> pes_packet);
59 
62  std::unique_ptr<ProgramMapTableWriter> table_writer);
63 
64  private:
65  // True if further segments generated by this instance should be encrypted.
66  bool encrypted_ = false;
67 
68  ContinuityCounter pmt_continuity_counter_;
69  ContinuityCounter pat_continuity_counter_;
70  ContinuityCounter elementary_stream_continuity_counter_;
71 
72  std::unique_ptr<ProgramMapTableWriter> pmt_writer_;
73 
74  std::unique_ptr<File, FileCloser> current_file_;
75 
76  DISALLOW_COPY_AND_ASSIGN(TsWriter);
77 };
78 
79 } // namespace mp2t
80 } // namespace media
81 } // namespace shaka
82 
83 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
Abstract class holds stream information.
Definition: stream_info.h:60
virtual bool NewSegment(const std::string &file_name)
Definition: ts_writer.cc:198
virtual bool AddPesPacket(std::unique_ptr< PesPacket > pes_packet)
Definition: ts_writer.cc:237
void SetProgramMapTableWriterForTesting(std::unique_ptr< ProgramMapTableWriter > table_writer)
Only for testing.
Definition: ts_writer.cc:249
virtual bool FinalizeSegment()
Definition: ts_writer.cc:233
virtual bool Initialize(const StreamInfo &stream_info)
Definition: ts_writer.cc:164
virtual void SignalEncrypted()
Signals the writer that the rest of the segments are encrypted.
Definition: ts_writer.cc:229