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 {
34 bool is_subsegment =
false;
35 bool is_encrypted =
false;
36 int64_t start_timestamp = -1;
41 std::shared_ptr<EncryptionConfig> key_rotation_encryption_config;
46 size_t stream_index =
static_cast<size_t>(-1);
47 StreamDataType stream_data_type = StreamDataType::kUnknown;
49 std::shared_ptr<PeriodInfo> period_info;
50 std::shared_ptr<StreamInfo> stream_info;
51 std::shared_ptr<MediaSample> media_sample;
52 std::shared_ptr<MediaEvent> media_event;
53 std::shared_ptr<SegmentInfo> segment_info;
78 std::shared_ptr<MediaHandler> handler);
82 return SetHandler(next_output_stream_index_, handler);
101 virtual Status Process(std::unique_ptr<StreamData> stream_data) = 0;
115 std::shared_ptr<PeriodInfo> period_info) {
116 std::unique_ptr<StreamData> stream_data(
new StreamData);
117 stream_data->stream_index = stream_index;
118 stream_data->stream_data_type = StreamDataType::kPeriodInfo;
119 stream_data->period_info = std::move(period_info);
120 return Dispatch(std::move(stream_data));
125 std::shared_ptr<StreamInfo> stream_info) {
126 std::unique_ptr<StreamData> stream_data(
new StreamData);
127 stream_data->stream_index = stream_index;
128 stream_data->stream_data_type = StreamDataType::kStreamInfo;
129 stream_data->stream_info = std::move(stream_info);
130 return Dispatch(std::move(stream_data));
135 std::shared_ptr<MediaSample> media_sample) {
136 std::unique_ptr<StreamData> stream_data(
new StreamData);
137 stream_data->stream_index = stream_index;
138 stream_data->stream_data_type = StreamDataType::kMediaSample;
139 stream_data->media_sample = std::move(media_sample);
140 return Dispatch(std::move(stream_data));
145 std::shared_ptr<MediaEvent> media_event) {
146 std::unique_ptr<StreamData> stream_data(
new StreamData);
147 stream_data->stream_index = stream_index;
148 stream_data->stream_data_type = StreamDataType::kMediaEvent;
149 stream_data->media_event = std::move(media_event);
150 return Dispatch(std::move(stream_data));
155 std::shared_ptr<SegmentInfo> segment_info) {
156 std::unique_ptr<StreamData> stream_data(
new StreamData);
157 stream_data->stream_index = stream_index;
158 stream_data->stream_data_type = StreamDataType::kSegmentInfo;
159 stream_data->segment_info = std::move(segment_info);
160 return Dispatch(std::move(stream_data));
169 bool initialized() {
return initialized_; }
170 size_t num_input_streams()
const {
return num_input_streams_; }
171 size_t next_output_stream_index()
const {
return next_output_stream_index_; }
172 const std::map<size_t, std::pair<std::shared_ptr<MediaHandler>,
size_t>>&
174 return output_handlers_;
178 MediaHandler(
const MediaHandler&) =
delete;
179 MediaHandler& operator=(
const MediaHandler&) =
delete;
181 bool initialized_ =
false;
183 size_t num_input_streams_ = 0;
185 size_t next_output_stream_index_ = 0;
188 std::map<size_t, std::pair<std::shared_ptr<MediaHandler>,
size_t>>
195 #endif // PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_