// Copyright 2019 The MediaPipe Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef MEDIAPIPE_FRAMEWORK_INPUT_STREAM_HANDLER_H_ #define MEDIAPIPE_FRAMEWORK_INPUT_STREAM_HANDLER_H_ #include <atomic> #include <functional> #include <list> #include <memory> #include <string> #include <utility> #include <vector> // TODO: Move protos in another CL after the C++ code migration. #include "mediapipe/framework/calculator_context.h" #include "mediapipe/framework/calculator_context_manager.h" #include "mediapipe/framework/collection.h" #include "mediapipe/framework/collection_item_id.h" #include "mediapipe/framework/deps/registration.h" #include "mediapipe/framework/input_stream_manager.h" #include "mediapipe/framework/input_stream_shard.h" #include "mediapipe/framework/mediapipe_options.pb.h" #include "mediapipe/framework/packet.h" #include "mediapipe/framework/packet_set.h" #include "mediapipe/framework/packet_type.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/tool/tag_map.h" namespace mediapipe { // Indicates the operation the node is ready for. enum class NodeReadiness { … }; // Abstract base class for input stream handlers. // // The input stream handler is invoked every time a Packet is enqueued or the // next timestamp bound is set in any of the input streams and actually decides // whether a calculator node's Process() should be called. The input stream // handler owns and manages the InputStreamManager objects. The operations // performed by OutputStreamHandler on an InputStreamManager object need to go // through its input stream handler. // // Derived classes are required to implement the following member functions: // // NodeReadiness GetNodeReadiness(Timestamp* min_stream_timestamp); // void FillInputSet(Timestamp input_timestamp, // InputStreamShardSet* input_set); // class InputStreamHandler { … }; using InputStreamHandlerRegistry = GlobalFactoryRegistry< std::unique_ptr<InputStreamHandler>, std::shared_ptr<tool::TagMap>, CalculatorContextManager*, const MediaPipeOptions&, bool>; } // namespace mediapipe // Macro for registering the input stream handler. #define REGISTER_INPUT_STREAM_HANDLER(name) … #endif // MEDIAPIPE_FRAMEWORK_INPUT_STREAM_HANDLER_H_