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);
98 virtual Status Process(std::unique_ptr<StreamData> stream_data) = 0;
112 std::shared_ptr<PeriodInfo> period_info) {
113 std::unique_ptr<StreamData> stream_data(
new StreamData);
114 stream_data->stream_index = stream_index;
115 stream_data->stream_data_type = StreamDataType::kPeriodInfo;
116 stream_data->period_info = std::move(period_info);
117 return Dispatch(std::move(stream_data));
122 std::shared_ptr<StreamInfo> stream_info) {
123 std::unique_ptr<StreamData> stream_data(
new StreamData);
124 stream_data->stream_index = stream_index;
125 stream_data->stream_data_type = StreamDataType::kStreamInfo;
126 stream_data->stream_info = std::move(stream_info);
127 return Dispatch(std::move(stream_data));
132 std::shared_ptr<MediaSample> media_sample) {
133 std::unique_ptr<StreamData> stream_data(
new StreamData);
134 stream_data->stream_index = stream_index;
135 stream_data->stream_data_type = StreamDataType::kMediaSample;
136 stream_data->media_sample = std::move(media_sample);
137 return Dispatch(std::move(stream_data));
142 std::shared_ptr<MediaEvent> media_event) {
143 std::unique_ptr<StreamData> stream_data(
new StreamData);
144 stream_data->stream_index = stream_index;
145 stream_data->stream_data_type = StreamDataType::kMediaEvent;
146 stream_data->media_event = std::move(media_event);
147 return Dispatch(std::move(stream_data));
152 std::shared_ptr<SegmentInfo> segment_info) {
153 std::unique_ptr<StreamData> stream_data(
new StreamData);
154 stream_data->stream_index = stream_index;
155 stream_data->stream_data_type = StreamDataType::kSegmentInfo;
156 stream_data->segment_info = std::move(segment_info);
157 return Dispatch(std::move(stream_data));
163 bool initialized() {
return initialized_; }
164 size_t num_input_streams()
const {
return num_input_streams_; }
165 size_t next_output_stream_index()
const {
return next_output_stream_index_; }
166 const std::map<size_t, std::pair<std::shared_ptr<MediaHandler>,
size_t>>&
168 return output_handlers_;
172 MediaHandler(
const MediaHandler&) =
delete;
173 MediaHandler& operator=(
const MediaHandler&) =
delete;
175 bool initialized_ =
false;
177 size_t num_input_streams_ = 0;
179 size_t next_output_stream_index_ = 0;
182 std::map<size_t, std::pair<std::shared_ptr<MediaHandler>,
size_t>>
189 #endif // PACKAGER_MEDIA_BASE_MEDIA_HANDLER_H_