7 #include "packager/media/base/media_handler.h" 12 std::string StreamDataTypeToString(StreamDataType type) {
14 case StreamDataType::kStreamInfo:
16 case StreamDataType::kMediaSample:
17 return "media sample";
18 case StreamDataType::kTextSample:
20 case StreamDataType::kSegmentInfo:
21 return "segment info";
22 case StreamDataType::kScte35Event:
23 return "scte35 event";
24 case StreamDataType::kCueEvent:
26 case StreamDataType::kUnknown:
33 std::shared_ptr<MediaHandler> handler) {
34 if (output_handlers_.find(output_stream_index) != output_handlers_.end()) {
35 return Status(error::ALREADY_EXISTS,
36 "The handler at the specified index already exists.");
38 output_handlers_[output_stream_index] =
39 std::make_pair(handler, handler->num_input_streams_++);
40 next_output_stream_index_ = output_stream_index + 1;
50 for (
auto& pair : output_handlers_) {
52 return Status(error::INVALID_ARGUMENT,
"Invalid output stream index");
53 status = pair.second.first->Initialize();
64 const size_t output_stream_index = input_stream_index;
69 return stream_index < num_input_streams_;
73 size_t output_stream_index = stream_data->stream_index;
74 auto handler_it = output_handlers_.find(output_stream_index);
75 if (handler_it == output_handlers_.end()) {
76 return Status(error::NOT_FOUND,
77 "No output handler exist at the specified index.");
79 stream_data->stream_index = handler_it->second.second;
80 return handler_it->second.first->Process(std::move(stream_data));
84 auto handler_it = output_handlers_.find(output_stream_index);
85 if (handler_it == output_handlers_.end()) {
86 return Status(error::NOT_FOUND,
87 "No output handler exist at the specified index.");
89 return handler_it->second.first->OnFlushRequest(handler_it->second.second);
93 for (
const auto& pair : output_handlers_) {
94 Status status = pair.second.first->OnFlushRequest(pair.second.second);
All the methods that are virtual are virtual for mocking.