7 #include "packager/media/base/media_handler.h"
13 std::shared_ptr<MediaHandler> handler) {
15 return Status(error::INVALID_ARGUMENT,
"Invalid output stream index");
16 if (output_handlers_.find(output_stream_index) != output_handlers_.end()) {
17 return Status(error::ALREADY_EXISTS,
18 "The handler at the specified index already exists.");
20 output_handlers_[output_stream_index] =
21 std::make_pair(handler, handler->num_input_streams_++);
22 next_output_stream_index_ = output_stream_index + 1;
29 auto handler_it = output_handlers_.find(input_stream_index);
30 if (handler_it == output_handlers_.end()) {
31 return Status(error::NOT_FOUND,
32 "No output handler exist at the specified index.");
34 return handler_it->second.first->FlushStream(handler_it->second.second);
38 return stream_index >= 0 && stream_index < num_input_streams_;
42 int output_stream_index = stream_data->stream_index;
43 auto handler_it = output_handlers_.find(output_stream_index);
44 if (handler_it == output_handlers_.end()) {
45 return Status(error::NOT_FOUND,
46 "No output handler exist at the specified index.");
48 stream_data->stream_index = handler_it->second.second;
49 return handler_it->second.first->Process(std::move(stream_data));