/* Copyright 2022 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_TASKS_CC_CORE_TASK_RUNNER_H_ #define MEDIAPIPE_TASKS_CC_CORE_TASK_RUNNER_H_ #if defined(OS_POSIX) || defined(OS_FUCHSIA) #include <unistd.h> #endif #include <atomic> #include <functional> #include <map> #include <memory> #include <optional> #include <string> #include <vector> #include "absl/base/thread_annotations.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/synchronization/mutex.h" #include "mediapipe/framework/calculator.pb.h" #include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/executor.h" #include "tensorflow/lite/core/api/op_resolver.h" namespace mediapipe { #if !MEDIAPIPE_DISABLE_GPU class GpuResources; #endif // !MEDIAPIPE_DISABLE_GPU namespace tasks { namespace core { ErrorFn; // Mapping from the MediaPipe calculator graph stream/side packet names to the // packets. using PacketMap = std::map<std::string, Packet>; // A callback method to get output packets from the task runner. PacketsCallback; // The mediapipe task runner class. // The runner has two processing modes: synchronous mode and asynchronous mode. // In the synchronous mode, clients send input data using the blocking API, // Process(), and wait until the results are returned from the same method. // In the asynchronous mode, clients send input data using the non-blocking // method, Send(), and receive the results in the user-defined PacketsCallback // at a later point in time. // As the two processing modes are incompatible, each TaskRunner instance can // operate in only one processing mode, which is defined at construction time // based on whether a PacketsCallback is provided (asynchronous mode) or not // (synchronous mode). class TaskRunner { … }; } // namespace core } // namespace tasks } // namespace mediapipe #endif // MEDIAPIPE_TASKS_CC_CORE_TASK_RUNNER_H_