Changed return type of process method in MPPTaskRunner

This commit is contained in:
Prianka Liz Kariat 2023-03-02 19:35:05 +05:30
parent 87ba86ace2
commit 6d7f172e9f
2 changed files with 10 additions and 4 deletions

View File

@ -17,6 +17,8 @@
#include "mediapipe/framework/calculator.pb.h" #include "mediapipe/framework/calculator.pb.h"
#include "mediapipe/tasks/cc/core/task_runner.h" #include "mediapipe/tasks/cc/core/task_runner.h"
#include <optional>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
@ -72,8 +74,6 @@ NS_ASSUME_NONNULL_BEGIN
* caller's responsibility to synchronize access to this method across multiple threads and to * caller's responsibility to synchronize access to this method across multiple threads and to
* ensure that the input packet timestamps are in order. * ensure that the input packet timestamps are in order.
*/ */
- (absl::StatusOr<mediapipe::tasks::core::PacketMap>)process:
(const mediapipe::tasks::core::PacketMap &)packetMap;
- (std::optional<mediapipe::tasks::core::PacketMap>) - (std::optional<mediapipe::tasks::core::PacketMap>)
processPacketMap:(const mediapipe::tasks::core::PacketMap &)packetMap processPacketMap:(const mediapipe::tasks::core::PacketMap &)packetMap
error:(NSError **)error; error:(NSError **)error;

View File

@ -50,8 +50,14 @@ using TaskRunnerCpp = ::mediapipe::tasks::core::TaskRunner;
return self; return self;
} }
- (absl::StatusOr<PacketMap>)process:(const PacketMap &)packetMap { - (std::optional<PacketMap>)processPacketMap:(const PacketMap &)packetMap error:(NSError **)error {
return _cppTaskRunner->Process(packetMap); absl::StatusOr<PacketMap> resultPacketMap = _cppTaskRunner->Process(packetMap);
if (![MPPCommonUtils checkCppError:resultPacketMap.status() toError:error]) {
return std::nullopt;
}
return resultPacketMap.value();
}
- (BOOL)sendPacketMap:(const PacketMap &)packetMap error:(NSError **)error { - (BOOL)sendPacketMap:(const PacketMap &)packetMap error:(NSError **)error {
absl::Status sendStatus = _cppTaskRunner->Send(packetMap); absl::Status sendStatus = _cppTaskRunner->Send(packetMap);
return [MPPCommonUtils checkCppError:sendStatus toError:error]; return [MPPCommonUtils checkCppError:sendStatus toError:error];