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