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,
33 const SegmentInfo& sample) override;
34
35 Status WriteSegment(const std::string& segment_path,
36 BufferWriter* segment_buffer);
37 Status CloseFile(std::unique_ptr<File, FileCloser> file);
38
39 void FireOnMediaStartEvent();
40 void FireOnMediaEndEvent();
41
42 std::unique_ptr<TsSegmenter> segmenter_;
43 int64_t sample_durations_[2] = {0, 0};
44 size_t num_samples_ = 0;
45
46 // Used in single segment mode.
47 std::unique_ptr<File, FileCloser> output_file_;
48
49 // Keeps track of segment ranges in single segment mode.
50 MuxerListener::MediaRanges media_ranges_;
51
52 uint64_t total_duration_ = 0;
53
54 DISALLOW_COPY_AND_ASSIGN(TsMuxer);
55};
56
57} // namespace mp2t
58} // namespace media
59} // namespace shaka
60
61#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.