9 #ifndef PACKAGER_MEDIA_BASE_MUXER_H_
10 #define PACKAGER_MEDIA_BASE_MUXER_H_
15 #include <packager/media/base/media_handler.h>
16 #include <packager/media/base/muxer_options.h>
17 #include <packager/media/event/muxer_listener.h>
18 #include <packager/media/event/progress_listener.h>
19 #include <packager/mpd/base/mpd_builder.h>
20 #include <packager/status.h>
47 const std::vector<std::shared_ptr<const StreamInfo>>& streams()
const {
57 void set_clock(std::shared_ptr<Clock> clock) { clock_ = clock; }
63 Status
Process(std::unique_ptr<StreamData> stream_data)
override;
68 MuxerListener* muxer_listener() {
return muxer_listener_.get(); }
69 ProgressListener* progress_listener() {
return progress_listener_.get(); }
71 uint64_t Now()
const {
72 auto duration = clock_->now().time_since_epoch();
74 std::chrono::duration_cast<std::chrono::seconds>(duration).count();
75 return static_cast<uint64_t
>(seconds);
79 Muxer(
const Muxer&) =
delete;
80 Muxer& operator=(
const Muxer&) =
delete;
85 virtual Status InitializeMuxer() = 0;
88 virtual Status Finalize() = 0;
92 virtual Status AddMediaSample(
size_t stream_id,
const MediaSample& sample);
96 virtual Status AddTextSample(
size_t stream_id,
const TextSample& sample);
99 virtual Status FinalizeSegment(
101 const SegmentInfo& segment_info) = 0;
105 Status ReinitializeMuxer(int64_t timestamp);
107 MuxerOptions options_;
108 std::vector<std::shared_ptr<const StreamInfo>> streams_;
109 std::vector<uint8_t> current_key_id_;
110 bool encryption_started_ =
false;
111 bool cancelled_ =
false;
113 std::unique_ptr<MuxerListener> muxer_listener_;
114 std::unique_ptr<ProgressListener> progress_listener_;
115 std::shared_ptr<Clock> clock_;
119 std::string output_file_template_;
120 size_t output_file_index_ = 1;
All the methods that are virtual are virtual for mocking.