DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs 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 edash_packager {
23 namespace media {
24 namespace mp2t {
25 
28 class TsWriter {
29  public:
30  TsWriter();
31  virtual ~TsWriter();
32 
39  virtual bool Initialize(const StreamInfo& stream_info,
40  bool will_be_encrypted);
41 
46  virtual bool NewSegment(const std::string& file_name);
47 
50  void SignalEncypted();
51 
55  virtual bool FinalizeSegment();
56 
61  virtual bool AddPesPacket(scoped_ptr<PesPacket> pes_packet);
62 
65  scoped_ptr<ProgramMapTableWriter> table_writer);
66 
67  private:
68  // True if further segments generated by this instance should be encrypted.
69  bool encrypted_ = false;
70  // The stream will be encrypted some time later.
71  bool will_be_encrypted_ = false;
72 
73  ContinuityCounter pmt_continuity_counter_;
74  ContinuityCounter pat_continuity_counter_;
75  ContinuityCounter elementary_stream_continuity_counter_;
76 
77  scoped_ptr<ProgramMapTableWriter> pmt_writer_;
78 
79  scoped_ptr<File, FileCloser> current_file_;
80 
81  DISALLOW_COPY_AND_ASSIGN(TsWriter);
82 };
83 
84 } // namespace mp2t
85 } // namespace media
86 } // namespace edash_packager
87 
88 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
Abstract class holds stream information.
Definition: stream_info.h:26
void SetProgramMapTableWriterForTesting(scoped_ptr< ProgramMapTableWriter > table_writer)
Only for testing.
Definition: ts_writer.cc:256
virtual bool NewSegment(const std::string &file_name)
Definition: ts_writer.cc:201
virtual bool AddPesPacket(scoped_ptr< PesPacket > pes_packet)
Definition: ts_writer.cc:244
virtual bool Initialize(const StreamInfo &stream_info, bool will_be_encrypted)
Definition: ts_writer.cc:165