chromium/third_party/mediapipe/src/mediapipe/tasks/cc/core/task_runner.cc

/* 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.
==============================================================================*/

#include "mediapipe/tasks/cc/core/task_runner.h"

#include <algorithm>
#include <atomic>
#include <functional>
#include <iterator>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/substitute.h"
#include "absl/synchronization/mutex.h"
#include "mediapipe/framework/calculator.pb.h"
#include "mediapipe/framework/calculator_framework.h"
#include "mediapipe/framework/executor.h"
#include "mediapipe/framework/port/status_macros.h"
#include "mediapipe/framework/tool/name_util.h"
#include "mediapipe/tasks/cc/common.h"
#include "mediapipe/tasks/cc/core/model_resources_cache.h"
#include "tensorflow/lite/core/api/op_resolver.h"

#if !MEDIAPIPE_DISABLE_GPU
#include "mediapipe/gpu/gpu_shared_data_internal.h"
#endif  // !MEDIAPIPE_DISABLE_GPU

namespace mediapipe {
namespace tasks {
namespace core {
namespace {

absl::StatusOr<Timestamp> ValidateAndGetPacketTimestamp(
    const PacketMap& packet_map) {}

absl::StatusOr<PacketMap> GenerateOutputPacketMap(
    const std::vector<Packet>& packets,
    const std::vector<std::string>& stream_names) {}

}  // namespace

/* static */
#if !MEDIAPIPE_DISABLE_GPU
absl::StatusOr<std::unique_ptr<TaskRunner>> TaskRunner::Create(
    CalculatorGraphConfig config,
    std::unique_ptr<tflite::OpResolver> op_resolver,
    PacketsCallback packets_callback,
    std::shared_ptr<Executor> default_executor,
    std::optional<PacketMap> input_side_packets,
    std::shared_ptr<::mediapipe::GpuResources> resources,
    std::optional<ErrorFn> error_fn, bool disable_default_service) {
#else
absl::StatusOr<std::unique_ptr<TaskRunner>> TaskRunner::Create(
    CalculatorGraphConfig config,
    std::unique_ptr<tflite::OpResolver> op_resolver,
    PacketsCallback packets_callback,
    std::shared_ptr<Executor> default_executor,
    std::optional<PacketMap> input_side_packets,
    std::optional<ErrorFn> error_fn, bool disable_default_service) {}

absl::Status TaskRunner::Initialize(
    CalculatorGraphConfig config,
    std::unique_ptr<tflite::OpResolver> op_resolver,
    std::shared_ptr<Executor> default_executor,
    std::optional<PacketMap> input_side_packets,
    std::optional<ErrorFn> error_fn, bool disable_default_service) {}

absl::Status TaskRunner::Start() {}

absl::StatusOr<PacketMap> TaskRunner::Process(PacketMap inputs) {}

absl::Status TaskRunner::Send(PacketMap inputs) {}

absl::Status TaskRunner::Close() {}

absl::Status TaskRunner::Restart() {}

}  // namespace core
}  // namespace tasks
}  // namespace mediapipe