7 #ifndef PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_
8 #define PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_
14 #include "packager/media/base/media_sample.h"
15 #include "packager/media/base/status.h"
16 #include "packager/media/base/stream_info.h"
21 enum class StreamDataType {
36 bool is_subsegment =
false;
37 bool is_encrypted =
false;
38 uint64_t start_timestamp = 0;
39 uint64_t duration = 0;
45 StreamDataType stream_data_type;
47 std::unique_ptr<PeriodInfo> period_info;
48 std::unique_ptr<StreamInfo> stream_info;
49 std::unique_ptr<EncryptionConfig> encryption_config;
50 std::unique_ptr<MediaSample> media_sample;
51 std::unique_ptr<MediaEvent> media_event;
52 std::unique_ptr<SegmentInfo> segment_info;
77 std::shared_ptr<MediaHandler> handler);
81 return SetHandler(next_output_stream_index_, handler);
97 virtual Status Process(std::unique_ptr<StreamData> stream_data) = 0;
105 bool initialized() {
return initialized_; }
106 int num_input_streams() {
return num_input_streams_; }
110 Status
Dispatch(std::unique_ptr<StreamData> stream_data);
114 std::unique_ptr<PeriodInfo> period_info) {
115 std::unique_ptr<StreamData> stream_data(
new StreamData);
116 stream_data->stream_index = stream_index;
117 stream_data->period_info = std::move(period_info);
118 return Dispatch(std::move(stream_data));
123 std::unique_ptr<StreamInfo> stream_info) {
124 std::unique_ptr<StreamData> stream_data(
new StreamData);
125 stream_data->stream_index = stream_index;
126 stream_data->stream_info = std::move(stream_info);
127 return Dispatch(std::move(stream_data));
133 std::unique_ptr<EncryptionConfig> encryption_config) {
134 std::unique_ptr<StreamData> stream_data(
new StreamData);
135 stream_data->stream_index = stream_index;
136 stream_data->encryption_config = std::move(encryption_config);
137 return Dispatch(std::move(stream_data));
142 std::unique_ptr<MediaSample> media_sample) {
143 std::unique_ptr<StreamData> stream_data(
new StreamData);
144 stream_data->stream_index = stream_index;
145 stream_data->media_sample = std::move(media_sample);
146 return Dispatch(std::move(stream_data));
151 std::unique_ptr<MediaEvent> media_event) {
152 std::unique_ptr<StreamData> stream_data(
new StreamData);
153 stream_data->stream_index = stream_index;
154 stream_data->media_event = std::move(media_event);
155 return Dispatch(std::move(stream_data));
160 std::unique_ptr<SegmentInfo> segment_info) {
161 std::unique_ptr<StreamData> stream_data(
new StreamData);
162 stream_data->stream_index = stream_index;
163 stream_data->segment_info = std::move(segment_info);
164 return Dispatch(std::move(stream_data));
167 int num_input_streams()
const {
return num_input_streams_; }
168 int next_output_stream_index()
const {
return next_output_stream_index_; }
171 MediaHandler(
const MediaHandler&) =
delete;
172 MediaHandler& operator=(
const MediaHandler&) =
delete;
174 bool initialized_ =
false;
176 int num_input_streams_ = 0;
178 int next_output_stream_index_ = 0;
181 std::map<int, std::pair<std::shared_ptr<MediaHandler>,
int>> output_handlers_;
187 #endif // PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_