API 2: Do not redirect from MEDIAPIPE_REGISTER_NODE to REGISTER_CALCULATOR

The problem with redirecting is that the calling code has to include API 1 code (often third_party/mediapipe/framework/calculator_framework.h), even though they are only using API 2 functionality (albeit deprecated). This can lead to weird issues, e.g. MakePacket<T> confusingly does not return a Packet<T>, but a Packet, because it's using the API 1 version.

PiperOrigin-RevId: 588798455
This commit is contained in:
MediaPipe Team 2023-12-07 08:17:56 -08:00 committed by Copybara-Service
parent fad3785721
commit 66655a15b2
2 changed files with 10 additions and 11 deletions

View File

@ -81,15 +81,13 @@ cc_library(
srcs = ["node.cc"], srcs = ["node.cc"],
hdrs = ["node.h"], hdrs = ["node.h"],
deps = [ deps = [
":const_str",
":contract", ":contract",
":packet",
":port",
"//mediapipe/framework:calculator_base", "//mediapipe/framework:calculator_base",
"//mediapipe/framework:calculator_context", "//mediapipe/framework:calculator_context",
"//mediapipe/framework:calculator_contract", "//mediapipe/framework:calculator_contract",
"//mediapipe/framework:subgraph", "//mediapipe/framework:subgraph",
"//mediapipe/framework/deps:no_destructor", "//mediapipe/framework/deps:registration",
"@com_google_absl//absl/status",
], ],
) )

View File

@ -1,17 +1,15 @@
#ifndef MEDIAPIPE_FRAMEWORK_API2_NODE_H_ #ifndef MEDIAPIPE_FRAMEWORK_API2_NODE_H_
#define MEDIAPIPE_FRAMEWORK_API2_NODE_H_ #define MEDIAPIPE_FRAMEWORK_API2_NODE_H_
#include <functional> #include <memory>
#include <string> #include <type_traits>
#include "mediapipe/framework/api2/const_str.h" #include "absl/status/status.h"
#include "mediapipe/framework/api2/contract.h" #include "mediapipe/framework/api2/contract.h"
#include "mediapipe/framework/api2/packet.h"
#include "mediapipe/framework/api2/port.h"
#include "mediapipe/framework/calculator_base.h" #include "mediapipe/framework/calculator_base.h"
#include "mediapipe/framework/calculator_context.h" #include "mediapipe/framework/calculator_context.h"
#include "mediapipe/framework/calculator_contract.h" #include "mediapipe/framework/calculator_contract.h"
#include "mediapipe/framework/deps/no_destructor.h" #include "mediapipe/framework/deps/registration.h"
#include "mediapipe/framework/subgraph.h" #include "mediapipe/framework/subgraph.h"
namespace mediapipe { namespace mediapipe {
@ -178,7 +176,10 @@ class SubgraphImpl : public Subgraph,
absl::make_unique<mediapipe::internal::CalculatorBaseFactoryFor<Impl>>) absl::make_unique<mediapipe::internal::CalculatorBaseFactoryFor<Impl>>)
// This macro is used to register a non-split-contract calculator. Deprecated. // This macro is used to register a non-split-contract calculator. Deprecated.
#define MEDIAPIPE_REGISTER_NODE(name) REGISTER_CALCULATOR(name) #define MEDIAPIPE_REGISTER_NODE(name) \
MEDIAPIPE_REGISTER_FACTORY_FUNCTION_QUALIFIED( \
mediapipe::CalculatorBaseRegistry, calculator_registration, #name, \
absl::make_unique<mediapipe::internal::CalculatorBaseFactoryFor<name>>)
// This macro is used to define a subgraph that does not use automatic // This macro is used to define a subgraph that does not use automatic
// registration. Deprecated. // registration. Deprecated.