From 66655a15b21d1076a85491189fe03b89f57bee24 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Thu, 7 Dec 2023 08:17:56 -0800 Subject: [PATCH] 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 confusingly does not return a Packet, but a Packet, because it's using the API 1 version. PiperOrigin-RevId: 588798455 --- mediapipe/framework/api2/BUILD | 6 ++---- mediapipe/framework/api2/node.h | 15 ++++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/mediapipe/framework/api2/BUILD b/mediapipe/framework/api2/BUILD index 5c5ec04ea..f7e5b3325 100644 --- a/mediapipe/framework/api2/BUILD +++ b/mediapipe/framework/api2/BUILD @@ -81,15 +81,13 @@ cc_library( srcs = ["node.cc"], hdrs = ["node.h"], deps = [ - ":const_str", ":contract", - ":packet", - ":port", "//mediapipe/framework:calculator_base", "//mediapipe/framework:calculator_context", "//mediapipe/framework:calculator_contract", "//mediapipe/framework:subgraph", - "//mediapipe/framework/deps:no_destructor", + "//mediapipe/framework/deps:registration", + "@com_google_absl//absl/status", ], ) diff --git a/mediapipe/framework/api2/node.h b/mediapipe/framework/api2/node.h index 58cebf1ea..6d5e3da71 100644 --- a/mediapipe/framework/api2/node.h +++ b/mediapipe/framework/api2/node.h @@ -1,17 +1,15 @@ #ifndef MEDIAPIPE_FRAMEWORK_API2_NODE_H_ #define MEDIAPIPE_FRAMEWORK_API2_NODE_H_ -#include -#include +#include +#include -#include "mediapipe/framework/api2/const_str.h" +#include "absl/status/status.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_context.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" namespace mediapipe { @@ -178,7 +176,10 @@ class SubgraphImpl : public Subgraph, absl::make_unique>) // 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>) // This macro is used to define a subgraph that does not use automatic // registration. Deprecated.