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 <vector>
13 
14 #include "packager/base/memory/scoped_ptr.h"
15 #include "packager/media/base/media_stream.h"
16 #include "packager/media/file/file.h"
17 #include "packager/media/file/file_closer.h"
18 #include "packager/media/formats/mp2t/continuity_counter.h"
19 #include "packager/media/formats/mp2t/pes_packet.h"
20 #include "packager/media/formats/mp2t/program_map_table_writer.h"
21 
22 namespace shaka {
23 namespace media {
24 namespace mp2t {
25 
28 class TsWriter {
29  public:
30  TsWriter();
31  virtual ~TsWriter();
32 
36  virtual bool Initialize(const StreamInfo& stream_info);
37 
42  virtual bool NewSegment(const std::string& file_name);
43 
45  virtual void SignalEncrypted();
46 
50  virtual bool FinalizeSegment();
51 
56  virtual bool AddPesPacket(scoped_ptr<PesPacket> pes_packet);
57 
60  scoped_ptr<ProgramMapTableWriter> table_writer);
61 
62  private:
63  // True if further segments generated by this instance should be encrypted.
64  bool encrypted_ = false;
65 
66  ContinuityCounter pmt_continuity_counter_;
67  ContinuityCounter pat_continuity_counter_;
68  ContinuityCounter elementary_stream_continuity_counter_;
69 
70  scoped_ptr<ProgramMapTableWriter> pmt_writer_;
71 
72  scoped_ptr<File, FileCloser> current_file_;
73 
74  DISALLOW_COPY_AND_ASSIGN(TsWriter);
75 };
76 
77 } // namespace mp2t
78 } // namespace media
79 } // namespace shaka
80 
81 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
Abstract class holds stream information.
Definition: stream_info.h:26
virtual bool NewSegment(const std::string &file_name)
Definition: ts_writer.cc:199
void SetProgramMapTableWriterForTesting(scoped_ptr< ProgramMapTableWriter > table_writer)
Only for testing.
Definition: ts_writer.cc:250
virtual bool AddPesPacket(scoped_ptr< PesPacket > pes_packet)
Definition: ts_writer.cc:238
virtual bool FinalizeSegment()
Definition: ts_writer.cc:234
virtual bool Initialize(const StreamInfo &stream_info)
Definition: ts_writer.cc:165
virtual void SignalEncrypted()
Signals the writer that the rest of the segments are encrypted.
Definition: ts_writer.cc:230