Shaka Packager SDK
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/base/optional.h"
16 #include "packager/file/file.h"
17 #include "packager/file/file_closer.h"
18 #include "packager/media/formats/mp2t/continuity_counter.h"
19 #include "packager/media/base/buffer_writer.h"
20 
21 namespace shaka {
22 namespace media {
23 namespace mp2t {
24 
25 class PesPacket;
26 class ProgramMapTableWriter;
27 
30 class TsWriter {
31  public:
32  explicit TsWriter(std::unique_ptr<ProgramMapTableWriter> pmt_writer);
33  virtual ~TsWriter();
34 
38  virtual bool NewSegment(BufferWriter* buffer);
39 
41  virtual void SignalEncrypted();
42 
48  virtual bool AddPesPacket(std::unique_ptr<PesPacket> pes_packet, BufferWriter* buffer);
49 
50  private:
51  TsWriter(const TsWriter&) = delete;
52  TsWriter& operator=(const TsWriter&) = delete;
53 
54  // True if further segments generated by this instance should be encrypted.
55  bool encrypted_ = false;
56 
57  ContinuityCounter pat_continuity_counter_;
58  ContinuityCounter elementary_stream_continuity_counter_;
59 
60  std::unique_ptr<ProgramMapTableWriter> pmt_writer_;
61 };
62 
63 } // namespace mp2t
64 } // namespace media
65 } // namespace shaka
66 
67 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_WRITER_H_
shaka::media::mp2t::TsWriter::AddPesPacket
virtual bool AddPesPacket(std::unique_ptr< PesPacket > pes_packet, BufferWriter *buffer)
Definition: ts_writer.cc:189
shaka::media::BufferWriter
Definition: buffer_writer.h:23
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::media::mp2t::TsWriter::SignalEncrypted
virtual void SignalEncrypted()
Signals the writer that the rest of the segments are encrypted.
Definition: ts_writer.cc:185
shaka::media::mp2t::ContinuityCounter
Definition: continuity_counter.h:16
shaka::media::mp2t::TsWriter
Definition: ts_writer.h:30
shaka::media::mp2t::TsWriter::NewSegment
virtual bool NewSegment(BufferWriter *buffer)
Definition: ts_writer.cc:168