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;
32 for (
auto& pair : output_handlers_) {
33 status = pair.second.first->Initialize();
44 auto handler_it = output_handlers_.find(input_stream_index);
45 if (handler_it == output_handlers_.end()) {
46 return Status(error::NOT_FOUND,
47 "No output handler exist at the specified index.");
49 return handler_it->second.first->FlushStream(handler_it->second.second);
53 return stream_index >= 0 && stream_index < num_input_streams_;
57 int output_stream_index = stream_data->stream_index;
58 auto handler_it = output_handlers_.find(output_stream_index);
59 if (handler_it == output_handlers_.end()) {
60 return Status(error::NOT_FOUND,
61 "No output handler exist at the specified index.");
63 stream_data->stream_index = handler_it->second.second;
64 return handler_it->second.first->Process(std::move(stream_data));