7 #ifndef PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_
8 #define PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_
14 #include "packager/media/base/status.h"
41 std::shared_ptr<MediaHandler> handler);
45 return SetHandler(next_output_stream_index_, handler);
49 enum class StreamDataType {
70 StreamDataType stream_data_type;
72 std::unique_ptr<PeriodInfo> period_info;
73 std::unique_ptr<StreamInfo> stream_info;
74 std::unique_ptr<EncryptionConfig> encryption_config;
75 std::unique_ptr<MediaSample> media_sample;
76 std::unique_ptr<MediaEvent> media_event;
77 std::unique_ptr<SegmentInfo> segment_info;
84 virtual Status Process(std::unique_ptr<StreamData> stream_data) = 0;
98 std::unique_ptr<PeriodInfo> period_info) {
99 std::unique_ptr<StreamData> stream_data(
new StreamData);
100 stream_data->stream_index = stream_index;
101 stream_data->period_info = std::move(period_info);
102 return Dispatch(std::move(stream_data));
107 std::unique_ptr<StreamInfo> stream_info) {
108 std::unique_ptr<StreamData> stream_data(
new StreamData);
109 stream_data->stream_index = stream_index;
110 stream_data->stream_info = std::move(stream_info);
111 return Dispatch(std::move(stream_data));
117 std::unique_ptr<EncryptionConfig> encryption_config) {
118 std::unique_ptr<StreamData> stream_data(
new StreamData);
119 stream_data->stream_index = stream_index;
120 stream_data->encryption_config = std::move(encryption_config);
121 return Dispatch(std::move(stream_data));
126 std::unique_ptr<MediaSample> media_sample) {
127 std::unique_ptr<StreamData> stream_data(
new StreamData);
128 stream_data->stream_index = stream_index;
129 stream_data->media_sample = std::move(media_sample);
130 return Dispatch(std::move(stream_data));
135 std::unique_ptr<MediaEvent> media_event) {
136 std::unique_ptr<StreamData> stream_data(
new StreamData);
137 stream_data->stream_index = stream_index;
138 stream_data->media_event = std::move(media_event);
139 return Dispatch(std::move(stream_data));
144 std::unique_ptr<SegmentInfo> segment_info) {
145 std::unique_ptr<StreamData> stream_data(
new StreamData);
146 stream_data->stream_index = stream_index;
147 stream_data->segment_info = std::move(segment_info);
148 return Dispatch(std::move(stream_data));
151 int num_input_streams()
const {
return num_input_streams_; }
154 MediaHandler(
const MediaHandler&) =
delete;
155 MediaHandler& operator=(
const MediaHandler&) =
delete;
158 int num_input_streams_ = 0;
160 int next_output_stream_index_ = 0;
163 std::map<int, std::pair<std::shared_ptr<MediaHandler>,
int>> output_handlers_;
169 #endif // PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_