Shaka Packager SDK
ts_muxer.h
1 // Copyright 2016 Google LLC. 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_MUXER_H_
8 #define PACKAGER_MEDIA_FORMATS_MP2T_TS_MUXER_H_
9 
10 #include <packager/macros/classes.h>
11 #include <packager/media/base/muxer.h>
12 #include <packager/media/formats/mp2t/ts_segmenter.h>
13 
14 namespace shaka {
15 namespace media {
16 namespace mp2t {
17 
20 class TsMuxer : public Muxer {
21  public:
22  explicit TsMuxer(const MuxerOptions& muxer_options);
23  ~TsMuxer() override;
24 
25  private:
26  // Muxer implementation.
27  Status InitializeMuxer() override;
28  Status Finalize() override;
29  Status AddMediaSample(size_t stream_id, const MediaSample& sample) override;
30  Status FinalizeSegment(size_t stream_id,
31  const SegmentInfo& sample) override;
32 
33  Status WriteSegment(const std::string& segment_path,
34  BufferWriter* segment_buffer);
35  Status CloseFile(std::unique_ptr<File, FileCloser> file);
36 
37  void FireOnMediaStartEvent();
38  void FireOnMediaEndEvent();
39 
40  std::unique_ptr<TsSegmenter> segmenter_;
41  int64_t sample_durations_[2] = {0, 0};
42  size_t num_samples_ = 0;
43 
44  // Used in single segment mode.
45  std::unique_ptr<File, FileCloser> output_file_;
46 
47  // Keeps track of segment ranges in single segment mode.
48  MuxerListener::MediaRanges media_ranges_;
49 
50  uint64_t total_duration_ = 0;
51 
52  DISALLOW_COPY_AND_ASSIGN(TsMuxer);
53 };
54 
55 } // namespace mp2t
56 } // namespace media
57 } // namespace shaka
58 
59 #endif // PACKAGER_MEDIA_FORMATS_MP2T_TS_MUXER_H_
Class to hold a media sample.
Definition: media_sample.h:25
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:19