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#include <vector>
12
13#include <packager/macros/classes.h>
14#include <packager/media/base/encryption_config.h>
15#include <packager/media/base/muxer.h>
16#include <packager/media/formats/mp2t/ts_segmenter.h>
17
18namespace shaka {
19namespace media {
20namespace mp2t {
21
24class TsMuxer : public Muxer {
25 public:
26 explicit TsMuxer(const MuxerOptions& muxer_options);
27 ~TsMuxer() override;
28
29 private:
30 // Muxer implementation.
31 Status InitializeMuxer() override;
32 Status Finalize() override;
33 Status AddMediaSample(size_t stream_id, const MediaSample& sample) override;
34 Status FinalizeSegment(size_t stream_id, const SegmentInfo& sample) override;
35
36 Status WriteSegment(const std::string& segment_path,
37 BufferWriter* segment_buffer);
38 Status CloseFile(std::unique_ptr<File, FileCloser> file);
39
40 // Encrypts |segment_buffer| in-place if AES-128 is active.
41 void EncryptSegmentIfNeeded(BufferWriter* segment_buffer);
42
43 void FireOnMediaStartEvent();
44 void FireOnMediaEndEvent();
45
46 std::unique_ptr<TsSegmenter> segmenter_;
47 // Populated when protection_scheme == kAes128ProtectionScheme.
48 EncryptionConfig aes128_encryption_config_;
49 int64_t sample_durations_[2] = {0, 0};
50 size_t num_samples_ = 0;
51
52 // Used in single segment mode.
53 std::unique_ptr<File, FileCloser> output_file_;
54
55 // Keeps track of segment ranges in single segment mode.
56 MuxerListener::MediaRanges media_ranges_;
57
58 uint64_t total_duration_ = 0;
59
60 DISALLOW_COPY_AND_ASSIGN(TsMuxer);
61};
62
63} // namespace mp2t
64} // namespace media
65} // namespace shaka
66
67#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.