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/pes_packet.h"
19 
20 namespace edash_packager {
21 namespace media {
22 namespace mp2t {
23 
25  public:
28 
32  int GetNext();
33 
34  private:
35  int counter_ = 0;
36  DISALLOW_COPY_AND_ASSIGN(ContinuityCounter);
37 };
38 
41 class TsWriter {
42  public:
43  TsWriter();
44  virtual ~TsWriter();
45 
48  virtual bool Initialize(const StreamInfo& stream_info);
49 
53  virtual bool NewSegment(const std::string& file_name);
54 
58  virtual bool FinalizeSegment();
59 
64  virtual bool AddPesPacket(scoped_ptr<PesPacket> pes_packet);
65 
66  private:
67  std::vector<uint8_t> psi_ts_packets_;
68 
69  uint32_t time_scale_ = 0u;
70 
71  ContinuityCounter pmt_continuity_counter_;
72  ContinuityCounter pat_continuity_counter_;
73  ContinuityCounter elementary_stream_continuity_counter_;
74 
75  scoped_ptr<File, FileCloser> current_file_;
76 
77  DISALLOW_COPY_AND_ASSIGN(TsWriter);
78 };
79 
80 } // namespace mp2t
81 } // namespace media
82 } // namespace edash_packager
83 
84 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
Abstract class holds stream information.
Definition: stream_info.h:26
virtual bool Initialize(const StreamInfo &stream_info)
Definition: ts_writer.cc:386
virtual bool NewSegment(const std::string &file_name)
Definition: ts_writer.cc:439
virtual bool AddPesPacket(scoped_ptr< PesPacket > pes_packet)
Definition: ts_writer.cc:466