Project import generated by Copybara.
GitOrigin-RevId: 1138530ad1578c5d6615b3e3d041775c75d310c4
This commit is contained in:
@@ -52,7 +52,7 @@ proto_library(
|
||||
proto_library(
|
||||
name = "calculator_options_proto",
|
||||
srcs = ["calculator_options.proto"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
@@ -87,7 +87,6 @@ proto_library(
|
||||
srcs = ["packet_generator.proto"],
|
||||
visibility = [
|
||||
"//mediapipe:__subpackages__",
|
||||
"//mediapipe/packet_generator:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -187,7 +186,9 @@ mediapipe_cc_proto_library(
|
||||
mediapipe_cc_proto_library(
|
||||
name = "packet_generator_cc_proto",
|
||||
srcs = ["packet_generator.proto"],
|
||||
visibility = ["//mediapipe:__subpackages__"],
|
||||
visibility = [
|
||||
"//mediapipe:__subpackages__",
|
||||
],
|
||||
deps = [":packet_generator_proto"],
|
||||
)
|
||||
|
||||
@@ -220,7 +221,7 @@ mediapipe_cc_proto_library(
|
||||
testonly = 1,
|
||||
srcs = ["test_calculators.proto"],
|
||||
cc_deps = [":calculator_cc_proto"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":test_calculators_proto"],
|
||||
)
|
||||
|
||||
@@ -1086,7 +1087,6 @@ cc_library(
|
||||
copts = select({
|
||||
"//conditions:default": [],
|
||||
"//mediapipe:apple": [
|
||||
"-std=c++11",
|
||||
"-ObjC++",
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -111,9 +111,9 @@ TEST(CalculatorTest, SourceProcessOrder) {
|
||||
output0_type.SetAny();
|
||||
output1_type.SetAny();
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
output_stream_managers.Index(0).Initialize("output0", &output0_type));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
output_stream_managers.Index(1).Initialize("output1", &output1_type));
|
||||
|
||||
PacketSet input_side_packets(tool::CreateTagMap({}).ValueOrDie());
|
||||
@@ -158,22 +158,22 @@ TEST(CalculatorTest, SourceProcessOrder) {
|
||||
// Tests registration of a calculator within a namespace.
|
||||
// DeadEndCalculator is registered in namespace "mediapipe::test_ns".
|
||||
TEST(CalculatorTest, CreateByName) {
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByName( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByName( //
|
||||
"mediapipe.test_ns.DeadEndCalculator"));
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByName( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByName( //
|
||||
".mediapipe.test_ns.DeadEndCalculator"));
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"alpha", ".mediapipe.test_ns.DeadEndCalculator"));
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"alpha", "mediapipe.test_ns.DeadEndCalculator"));
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"mediapipe", "mediapipe.test_ns.DeadEndCalculator"));
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"mediapipe.test_ns.sub_ns", "DeadEndCalculator"));
|
||||
|
||||
EXPECT_EQ(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
@@ -204,23 +204,23 @@ TEST(CalculatorTest, CreateByNameWhitelisted) {
|
||||
absl::make_unique< ::mediapipe::test_ns::whitelisted_ns::DeadCalculator>);
|
||||
|
||||
// A whitelisted calculator can be found in its own namespace.
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"", "mediapipe.test_ns.whitelisted_ns.DeadCalculator"));
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"mediapipe.sub_ns", "test_ns.whitelisted_ns.DeadCalculator"));
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"mediapipe.sub_ns", "mediapipe.EndCalculator"));
|
||||
|
||||
// A whitelisted calculator can be found in the top-level namespace.
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"", "DeadCalculator"));
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"mediapipe", "DeadCalculator"));
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"mediapipe.test_ns.sub_ns", "DeadCalculator"));
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"", "EndCalculator"));
|
||||
MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( //
|
||||
"mediapipe.test_ns.sub_ns", "EndCalculator"));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ TEST(CalculatorContractTest, Calculator) {
|
||||
output_stream: "egraph_topical_detection"
|
||||
)");
|
||||
CalculatorContract contract;
|
||||
MEDIAPIPE_EXPECT_OK(contract.Initialize(node));
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
EXPECT_EQ(contract.Inputs().NumEntries(), 4);
|
||||
EXPECT_EQ(contract.Outputs().NumEntries(), 1);
|
||||
EXPECT_EQ(contract.InputSidePackets().NumEntries(), 1);
|
||||
@@ -59,7 +59,7 @@ TEST(CalculatorContractTest, CalculatorOptions) {
|
||||
[mediapipe.CalculatorContractTestOptions.ext] { test_field: 1.0 }
|
||||
})");
|
||||
CalculatorContract contract;
|
||||
MEDIAPIPE_EXPECT_OK(contract.Initialize(node));
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
const auto& test_options =
|
||||
contract.Options().GetExtension(CalculatorContractTestOptions::ext);
|
||||
EXPECT_EQ(test_options.test_field(), 1.0);
|
||||
@@ -80,7 +80,7 @@ TEST(CalculatorContractTest, PacketGenerator) {
|
||||
output_side_packet: "content_fingerprint"
|
||||
)");
|
||||
CalculatorContract contract;
|
||||
MEDIAPIPE_EXPECT_OK(contract.Initialize(node));
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
EXPECT_EQ(contract.InputSidePackets().NumEntries(), 1);
|
||||
EXPECT_EQ(contract.OutputSidePackets().NumEntries(), 4);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ TEST(CalculatorContractTest, StatusHandler) {
|
||||
input_side_packet: "SPEC:task_specification"
|
||||
)");
|
||||
CalculatorContract contract;
|
||||
MEDIAPIPE_EXPECT_OK(contract.Initialize(node));
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
EXPECT_EQ(contract.InputSidePackets().NumEntries(), 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
++index) {
|
||||
const EdgeInfo& edge_info =
|
||||
validated_graph_->OutputSidePacketInfos()[index];
|
||||
RETURN_IF_ERROR(output_side_packets_[index].Initialize(
|
||||
MP_RETURN_IF_ERROR(output_side_packets_[index].Initialize(
|
||||
edge_info.name, edge_info.packet_type));
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
for (int index = 0; index < validated_graph_->InputStreamInfos().size();
|
||||
++index) {
|
||||
const EdgeInfo& edge_info = validated_graph_->InputStreamInfos()[index];
|
||||
RETURN_IF_ERROR(input_stream_managers_[index].Initialize(
|
||||
MP_RETURN_IF_ERROR(input_stream_managers_[index].Initialize(
|
||||
edge_info.name, edge_info.packet_type, edge_info.back_edge));
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
for (int index = 0; index < validated_graph_->OutputStreamInfos().size();
|
||||
++index) {
|
||||
const EdgeInfo& edge_info = validated_graph_->OutputStreamInfos()[index];
|
||||
RETURN_IF_ERROR(output_stream_managers_[index].Initialize(
|
||||
MP_RETURN_IF_ERROR(output_stream_managers_[index].Initialize(
|
||||
edge_info.name, edge_info.packet_type));
|
||||
}
|
||||
|
||||
@@ -313,8 +313,8 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
}
|
||||
|
||||
if (!::mediapipe::ContainsKey(executors_, "")) {
|
||||
RETURN_IF_ERROR(InitializeDefaultExecutor(*default_executor_options,
|
||||
use_application_thread));
|
||||
MP_RETURN_IF_ERROR(InitializeDefaultExecutor(*default_executor_options,
|
||||
use_application_thread));
|
||||
}
|
||||
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -345,7 +345,7 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
std::max({validated_graph_->Config().node().size(),
|
||||
validated_graph_->Config().packet_generator().size(), 1}));
|
||||
}
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
CreateDefaultThreadPool(default_executor_options, num_threads));
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
@@ -359,12 +359,12 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
<< "validated_graph is not initialized.";
|
||||
validated_graph_ = std::move(validated_graph);
|
||||
|
||||
RETURN_IF_ERROR(InitializeExecutors());
|
||||
RETURN_IF_ERROR(InitializePacketGeneratorGraph(side_packets));
|
||||
RETURN_IF_ERROR(InitializeStreams());
|
||||
RETURN_IF_ERROR(InitializeCalculatorNodes());
|
||||
MP_RETURN_IF_ERROR(InitializeExecutors());
|
||||
MP_RETURN_IF_ERROR(InitializePacketGeneratorGraph(side_packets));
|
||||
MP_RETURN_IF_ERROR(InitializeStreams());
|
||||
MP_RETURN_IF_ERROR(InitializeCalculatorNodes());
|
||||
#ifdef MEDIAPIPE_PROFILER_AVAILABLE
|
||||
RETURN_IF_ERROR(InitializeProfiler());
|
||||
MP_RETURN_IF_ERROR(InitializeProfiler());
|
||||
#endif
|
||||
|
||||
initialized_ = true;
|
||||
@@ -380,7 +380,7 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
const CalculatorGraphConfig& input_config,
|
||||
const std::map<std::string, Packet>& side_packets) {
|
||||
auto validated_graph = absl::make_unique<ValidatedGraphConfig>();
|
||||
RETURN_IF_ERROR(validated_graph->Initialize(input_config));
|
||||
MP_RETURN_IF_ERROR(validated_graph->Initialize(input_config));
|
||||
return Initialize(std::move(validated_graph), side_packets);
|
||||
}
|
||||
|
||||
@@ -390,8 +390,8 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
const std::map<std::string, Packet>& side_packets,
|
||||
const std::string& graph_type, const Subgraph::SubgraphOptions* options) {
|
||||
auto validated_graph = absl::make_unique<ValidatedGraphConfig>();
|
||||
RETURN_IF_ERROR(validated_graph->Initialize(input_configs, input_templates,
|
||||
graph_type, options));
|
||||
MP_RETURN_IF_ERROR(validated_graph->Initialize(input_configs, input_templates,
|
||||
graph_type, options));
|
||||
return Initialize(std::move(validated_graph), side_packets);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ CalculatorGraph::~CalculatorGraph() {}
|
||||
<< "\" because it doesn't exist.";
|
||||
}
|
||||
auto observer = absl::make_unique<internal::OutputStreamObserver>();
|
||||
RETURN_IF_ERROR(observer->Initialize(
|
||||
MP_RETURN_IF_ERROR(observer->Initialize(
|
||||
stream_name, &any_packet_type_, std::move(packet_callback),
|
||||
&output_stream_managers_[output_stream_index]));
|
||||
graph_output_streams_.push_back(std::move(observer));
|
||||
@@ -427,7 +427,7 @@ CalculatorGraph::AddOutputStreamPoller(const std::string& stream_name) {
|
||||
<< "\" because it doesn't exist.";
|
||||
}
|
||||
auto internal_poller = std::make_shared<internal::OutputStreamPollerImpl>();
|
||||
RETURN_IF_ERROR(internal_poller->Initialize(
|
||||
MP_RETURN_IF_ERROR(internal_poller->Initialize(
|
||||
stream_name, &any_packet_type_,
|
||||
std::bind(&CalculatorGraph::UpdateThrottledNodes, this,
|
||||
std::placeholders::_1, std::placeholders::_2),
|
||||
@@ -479,7 +479,7 @@ CalculatorGraph::AddOutputStreamPoller(const std::string& stream_name) {
|
||||
RET_CHECK(graph_input_streams_.empty()).SetNoLogging()
|
||||
<< "When using graph input streams, call StartRun() instead of Run() so "
|
||||
"that AddPacketToInputStream() and CloseInputStream() can be called.";
|
||||
RETURN_IF_ERROR(StartRun(extra_side_packets, {}));
|
||||
MP_RETURN_IF_ERROR(StartRun(extra_side_packets, {}));
|
||||
return WaitUntilDone();
|
||||
}
|
||||
|
||||
@@ -488,8 +488,8 @@ CalculatorGraph::AddOutputStreamPoller(const std::string& stream_name) {
|
||||
const std::map<std::string, Packet>& stream_headers) {
|
||||
RET_CHECK(initialized_).SetNoLogging()
|
||||
<< "CalculatorGraph is not initialized.";
|
||||
RETURN_IF_ERROR(PrepareForRun(extra_side_packets, stream_headers));
|
||||
RETURN_IF_ERROR(profiler_->Start(executors_[""].get()));
|
||||
MP_RETURN_IF_ERROR(PrepareForRun(extra_side_packets, stream_headers));
|
||||
MP_RETURN_IF_ERROR(profiler_->Start(executors_[""].get()));
|
||||
scheduler_.Start();
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
@@ -570,7 +570,7 @@ CalculatorGraph::PrepareGpu(const std::map<std::string, Packet>& side_packets) {
|
||||
}
|
||||
}
|
||||
for (const auto& name_executor : gpu_resources->GetGpuExecutors()) {
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
SetExecutorInternal(name_executor.first, name_executor.second));
|
||||
}
|
||||
}
|
||||
@@ -755,7 +755,7 @@ CalculatorGraph::PrepareGpu(const std::map<std::string, Packet>& side_packets) {
|
||||
return ::mediapipe::InvalidArgumentErrorBuilder(MEDIAPIPE_LOC)
|
||||
<< "WaitUntilIdle called on a graph with source nodes.";
|
||||
}
|
||||
RETURN_IF_ERROR(scheduler_.WaitUntilIdle());
|
||||
MP_RETURN_IF_ERROR(scheduler_.WaitUntilIdle());
|
||||
VLOG(2) << "Scheduler idle.";
|
||||
::mediapipe::Status status = ::mediapipe::OkStatus();
|
||||
if (GetCombinedErrors(&status)) {
|
||||
@@ -766,7 +766,7 @@ CalculatorGraph::PrepareGpu(const std::map<std::string, Packet>& side_packets) {
|
||||
|
||||
::mediapipe::Status CalculatorGraph::WaitUntilDone() {
|
||||
VLOG(2) << "Waiting for scheduler to terminate...";
|
||||
RETURN_IF_ERROR(scheduler_.WaitUntilDone());
|
||||
MP_RETURN_IF_ERROR(scheduler_.WaitUntilDone());
|
||||
VLOG(2) << "Scheduler terminated.";
|
||||
|
||||
return FinishRun();
|
||||
@@ -1186,7 +1186,7 @@ Packet CalculatorGraph::GetServicePacket(const GraphServiceBase& service) {
|
||||
if (name.empty()) {
|
||||
scheduler_.SetExecutor(executor.get());
|
||||
} else {
|
||||
RETURN_IF_ERROR(scheduler_.SetNonDefaultExecutor(name, executor.get()));
|
||||
MP_RETURN_IF_ERROR(scheduler_.SetNonDefaultExecutor(name, executor.get()));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
@@ -1225,7 +1225,7 @@ bool CalculatorGraph::IsReservedExecutorName(const std::string& name) {
|
||||
::mediapipe::Status CalculatorGraph::FinishRun() {
|
||||
// Check for any errors that may have occurred.
|
||||
::mediapipe::Status status = ::mediapipe::OkStatus();
|
||||
RETURN_IF_ERROR(profiler_->Stop());
|
||||
MP_RETURN_IF_ERROR(profiler_->Stop());
|
||||
GetCombinedErrors(&status);
|
||||
CleanupAfterRun(&status);
|
||||
return status;
|
||||
|
||||
@@ -77,17 +77,17 @@ typedef ::mediapipe::StatusOr<OutputStreamPoller> StatusOrPoller;
|
||||
// #include "mediapipe/framework/calculator_framework.h"
|
||||
//
|
||||
// mediapipe::CalculatorGraphConfig config;
|
||||
// RETURN_IF_ERROR(mediapipe::tool::ParseGraphFromString(kGraphStr, &config));
|
||||
// mediapipe::CalculatorGraph graph;
|
||||
// RETURN_IF_ERROR(graph.Initialize(config));
|
||||
// MP_RETURN_IF_ERROR(mediapipe::tool::ParseGraphFromString(kGraphStr,
|
||||
// &config)); mediapipe::CalculatorGraph graph;
|
||||
// MP_RETURN_IF_ERROR(graph.Initialize(config));
|
||||
//
|
||||
// std::map<std::string, mediapipe::Packet> extra_side_packets;
|
||||
// extra_side_packets["video_id"] = mediapipe::MakePacket<std::string>(
|
||||
// "3edb9503834e9b42");
|
||||
// RETURN_IF_ERROR(graph.Run(extra_side_packets));
|
||||
// MP_RETURN_IF_ERROR(graph.Run(extra_side_packets));
|
||||
//
|
||||
// // Run again (demonstrating the more concise initializer list syntax).
|
||||
// RETURN_IF_ERROR(graph.Run(
|
||||
// MP_RETURN_IF_ERROR(graph.Run(
|
||||
// {{"video_id", mediapipe::MakePacket<std::string>("Ex-uGhDzue4")}}));
|
||||
// // See mediapipe/framework/graph_runner.h for an interface
|
||||
// // to insert and extract packets from a graph as it runs.
|
||||
@@ -186,15 +186,15 @@ class CalculatorGraph {
|
||||
// subsequent call to StartRun can be attempted.
|
||||
//
|
||||
// Example:
|
||||
// RETURN_IF_ERROR(graph.StartRun(...));
|
||||
// MP_RETURN_IF_ERROR(graph.StartRun(...));
|
||||
// while (true) {
|
||||
// if (graph.HasError() || want_to_stop) break;
|
||||
// RETURN_IF_ERROR(graph.AddPacketToInputStream(...));
|
||||
// MP_RETURN_IF_ERROR(graph.AddPacketToInputStream(...));
|
||||
// }
|
||||
// for (const std::string& stream : streams) {
|
||||
// RETURN_IF_ERROR(graph.CloseInputStream(stream));
|
||||
// MP_RETURN_IF_ERROR(graph.CloseInputStream(stream));
|
||||
// }
|
||||
// RETURN_IF_ERROR(graph.WaitUntilDone());
|
||||
// MP_RETURN_IF_ERROR(graph.WaitUntilDone());
|
||||
::mediapipe::Status StartRun(
|
||||
const std::map<std::string, Packet>& extra_side_packets) {
|
||||
return StartRun(extra_side_packets, {});
|
||||
|
||||
@@ -77,27 +77,27 @@ TEST(CalculatorGraphBounds, ImmediateHandlerBounds) {
|
||||
)");
|
||||
CalculatorGraph graph;
|
||||
std::vector<Packet> output_packets;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream("output", [&](const Packet& p) {
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.ObserveOutputStream("output", [&](const Packet& p) {
|
||||
output_packets.push_back(p);
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
|
||||
// Add four packets into the graph.
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
Packet p = MakePacket<int>(33).At(Timestamp(i));
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream("input", p));
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream("input", p));
|
||||
}
|
||||
|
||||
// Four packets arrive at the output only if timestamp bounds are propagated.
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
EXPECT_EQ(output_packets.size(), 4);
|
||||
|
||||
// Eventually four packets arrive.
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllPacketSources());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllPacketSources());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
EXPECT_EQ(output_packets.size(), 4);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,14 +136,14 @@ TEST_F(CalculatorGraphEventLoopTest, WellProvisionedEventLoop) {
|
||||
|
||||
// Start MediaPipe graph.
|
||||
CalculatorGraph graph(graph_config);
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun(
|
||||
MP_ASSERT_OK(graph.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&CalculatorGraphEventLoopTest::AddThreadSafeVectorSink,
|
||||
this, std::placeholders::_1))}}));
|
||||
|
||||
// Insert 100 packets at the rate the calculator can keep up with.
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_numbers", Adopt(new int(i)).At(Timestamp(i))));
|
||||
// Wait for all packets to be received by the sink.
|
||||
while (true) {
|
||||
@@ -167,13 +167,13 @@ TEST_F(CalculatorGraphEventLoopTest, WellProvisionedEventLoop) {
|
||||
|
||||
// Insert 100 more packets at rate the graph can't keep up.
|
||||
for (int i = 100; i < 200; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_numbers", Adopt(new int(i)).At(Timestamp(i))));
|
||||
}
|
||||
// Don't wait but just close the input stream.
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
// Wait properly via the API until the graph is done.
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
// Check final results.
|
||||
{
|
||||
absl::ReaderMutexLock lock(&output_packets_mutex_);
|
||||
@@ -225,7 +225,7 @@ TEST_F(CalculatorGraphEventLoopTest, FailingEventLoop) {
|
||||
|
||||
// Start MediaPipe graph.
|
||||
CalculatorGraph graph(graph_config);
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun(
|
||||
MP_ASSERT_OK(graph.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&CalculatorGraphEventLoopTest::AddThreadSafeVectorSink,
|
||||
this, std::placeholders::_1))}}));
|
||||
@@ -243,7 +243,7 @@ TEST_F(CalculatorGraphEventLoopTest, FailingEventLoop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
status = graph.WaitUntilDone();
|
||||
ASSERT_THAT(status.message(),
|
||||
testing::HasSubstr("Meant to fail (magicstringincludedhere)."));
|
||||
@@ -270,7 +270,7 @@ TEST_F(CalculatorGraphEventLoopTest, StepByStepSchedulerLoop) {
|
||||
|
||||
// Start MediaPipe graph.
|
||||
CalculatorGraph graph(graph_config);
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun(
|
||||
MP_ASSERT_OK(graph.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&CalculatorGraphEventLoopTest::AddThreadSafeVectorSink,
|
||||
this, std::placeholders::_1))}}));
|
||||
@@ -278,16 +278,16 @@ TEST_F(CalculatorGraphEventLoopTest, StepByStepSchedulerLoop) {
|
||||
// Add packet one at a time, we should be able to syncrhonize the output for
|
||||
// each addition in the step by step mode.
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_numbers", Adopt(new int(i)).At(Timestamp(i))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
absl::ReaderMutexLock lock(&output_packets_mutex_);
|
||||
ASSERT_EQ(i + 1, output_packets_.size());
|
||||
}
|
||||
// Don't wait but just close the input stream.
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
// Wait properly via the API until the graph is done.
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
|
||||
// Test setting the stream header.
|
||||
@@ -310,7 +310,7 @@ TEST_F(CalculatorGraphEventLoopTest, SetStreamHeader) {
|
||||
&graph_config));
|
||||
|
||||
CalculatorGraph graph(graph_config);
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun(
|
||||
MP_ASSERT_OK(graph.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&CalculatorGraphEventLoopTest::AddThreadSafeVectorSink,
|
||||
this, std::placeholders::_1))}}));
|
||||
@@ -327,15 +327,15 @@ TEST_F(CalculatorGraphEventLoopTest, SetStreamHeader) {
|
||||
header->width = 320;
|
||||
header->height = 240;
|
||||
// With stream header set, the StartRun should succeed.
|
||||
MEDIAPIPE_ASSERT_OK(graph2.StartRun(
|
||||
MP_ASSERT_OK(graph2.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&CalculatorGraphEventLoopTest::AddThreadSafeVectorSink,
|
||||
this, std::placeholders::_1))}},
|
||||
{{"input_numbers", Adopt(header.release())}}));
|
||||
// Don't wait but just close the input stream.
|
||||
MEDIAPIPE_ASSERT_OK(graph2.CloseInputStream("input_numbers"));
|
||||
MP_ASSERT_OK(graph2.CloseInputStream("input_numbers"));
|
||||
// Wait properly via the API until the graph is done.
|
||||
MEDIAPIPE_ASSERT_OK(graph2.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph2.WaitUntilDone());
|
||||
}
|
||||
|
||||
// Test ADD_IF_NOT_FULL mode for graph input streams (by creating more packets
|
||||
@@ -369,7 +369,7 @@ TEST_F(CalculatorGraphEventLoopTest, TryToAddPacketToInputStream) {
|
||||
CalculatorGraph::GraphInputStreamAddMode::ADD_IF_NOT_FULL);
|
||||
|
||||
// Start MediaPipe graph.
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun(
|
||||
MP_ASSERT_OK(graph.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&CalculatorGraphEventLoopTest::AddThreadSafeVectorSink,
|
||||
this, std::placeholders::_1))},
|
||||
@@ -397,9 +397,9 @@ TEST_F(CalculatorGraphEventLoopTest, TryToAddPacketToInputStream) {
|
||||
|
||||
EXPECT_GE(fail_count, kNumInputPackets - kMaxQueueSize - 1);
|
||||
// Don't wait but just close the input stream.
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
// Wait properly via the API until the graph is done.
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
|
||||
// Verify that "max_queue_size: -1" disables throttling of graph-input-streams.
|
||||
@@ -426,18 +426,18 @@ TEST_F(CalculatorGraphEventLoopTest, ThrottlingDisabled) {
|
||||
CalculatorGraph::GraphInputStreamAddMode::ADD_IF_NOT_FULL);
|
||||
|
||||
// Start MediaPipe graph.
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({{"blocking_mutex", mutex_side_packet}}));
|
||||
MP_ASSERT_OK(graph.StartRun({{"blocking_mutex", mutex_side_packet}}));
|
||||
|
||||
// Lock the mutex so that the BlockingPassThroughCalculator cannot read any
|
||||
// of these packets.
|
||||
mutex->Lock();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
MP_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
"input_numbers", Adopt(new int(i)).At(Timestamp(i))));
|
||||
}
|
||||
mutex->Unlock();
|
||||
MEDIAPIPE_EXPECT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MEDIAPIPE_EXPECT_OK(graph.WaitUntilDone());
|
||||
MP_EXPECT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MP_EXPECT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
|
||||
// Verify that the graph input stream throttling code still works if we run the
|
||||
@@ -467,8 +467,7 @@ TEST_F(CalculatorGraphEventLoopTest, ThrottleGraphInputStreamTwice) {
|
||||
// Run the graph twice.
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
// Start MediaPipe graph.
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
graph.StartRun({{"blocking_mutex", mutex_side_packet}}));
|
||||
MP_ASSERT_OK(graph.StartRun({{"blocking_mutex", mutex_side_packet}}));
|
||||
|
||||
// Lock the mutex so that the BlockingPassThroughCalculator cannot read any
|
||||
// of these packets.
|
||||
@@ -485,8 +484,8 @@ TEST_F(CalculatorGraphEventLoopTest, ThrottleGraphInputStreamTwice) {
|
||||
ASSERT_FALSE(status.ok());
|
||||
EXPECT_EQ(status.code(), ::mediapipe::StatusCode::kUnavailable);
|
||||
EXPECT_THAT(status.message(), testing::HasSubstr("Graph is throttled."));
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,7 +514,7 @@ TEST_F(CalculatorGraphEventLoopTest, WaitToAddPacketToInputStream) {
|
||||
|
||||
// Start MediaPipe graph.
|
||||
CalculatorGraph graph(graph_config);
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun(
|
||||
MP_ASSERT_OK(graph.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&CalculatorGraphEventLoopTest::AddThreadSafeVectorSink,
|
||||
this, std::placeholders::_1))}}));
|
||||
@@ -534,9 +533,9 @@ TEST_F(CalculatorGraphEventLoopTest, WaitToAddPacketToInputStream) {
|
||||
EXPECT_EQ(0, fail_count);
|
||||
|
||||
// Don't wait but just close the input stream.
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_numbers"));
|
||||
// Wait properly via the API until the graph is done.
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
|
||||
absl::ReaderMutexLock lock(&output_packets_mutex_);
|
||||
ASSERT_EQ(kNumInputPackets, output_packets_.size());
|
||||
|
||||
@@ -188,7 +188,7 @@ TEST(CalculatorGraphStoppingTest, CloseAllPacketSources) {
|
||||
)",
|
||||
&graph_config));
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
MP_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
|
||||
// Observe output packets, and call CloseAllPacketSources after kNumPackets.
|
||||
std::vector<Packet> out_packets;
|
||||
@@ -196,37 +196,37 @@ TEST(CalculatorGraphStoppingTest, CloseAllPacketSources) {
|
||||
std::vector<int> event_packets;
|
||||
std::vector<int> event_out_packets;
|
||||
int kNumPackets = 8;
|
||||
MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
MP_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
"input_out", [&](const Packet& packet) {
|
||||
out_packets.push_back(packet);
|
||||
if (out_packets.size() >= kNumPackets) {
|
||||
MEDIAPIPE_EXPECT_OK(graph.CloseAllPacketSources());
|
||||
MP_EXPECT_OK(graph.CloseAllPacketSources());
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
MP_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
"count_out", [&](const Packet& packet) {
|
||||
count_packets.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
MP_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
"event", [&](const Packet& packet) {
|
||||
event_packets.push_back(packet.Get<int>());
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
MP_ASSERT_OK(graph.ObserveOutputStream( //
|
||||
"event_out", [&](const Packet& packet) {
|
||||
event_out_packets.push_back(packet.Get<int>());
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
for (int i = 0; i < kNumPackets; ++i) {
|
||||
MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
MP_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
"input", MakePacket<int>(i).At(Timestamp(i))));
|
||||
}
|
||||
|
||||
// The graph run should complete with no error status.
|
||||
MEDIAPIPE_EXPECT_OK(graph.WaitUntilDone());
|
||||
MP_EXPECT_OK(graph.WaitUntilDone());
|
||||
EXPECT_EQ(kNumPackets, out_packets.size());
|
||||
EXPECT_LE(kNumPackets, count_packets.size());
|
||||
std::vector<int> expected_events = {1, 2};
|
||||
@@ -254,11 +254,11 @@ TEST(CalculatorGraphStoppingTest, DeadlockReporting) {
|
||||
)",
|
||||
&config));
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
graph.SetGraphInputStreamAddMode(
|
||||
CalculatorGraph::GraphInputStreamAddMode::WAIT_TILL_NOT_FULL);
|
||||
std::vector<Packet> out_packets;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.ObserveOutputStream("out_1", [&out_packets](const Packet& packet) {
|
||||
out_packets.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -278,15 +278,15 @@ TEST(CalculatorGraphStoppingTest, DeadlockReporting) {
|
||||
};
|
||||
|
||||
// Start the graph.
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({
|
||||
MP_ASSERT_OK(graph.StartRun({
|
||||
{"callback_1", AdoptAsUniquePtr(new auto(callback_1))},
|
||||
}));
|
||||
|
||||
// Add 3 packets to "in_1" with no packets on "in_2".
|
||||
// This causes throttling and deadlock with max_queue_size 2.
|
||||
semaphore.Release(3);
|
||||
MEDIAPIPE_EXPECT_OK(add_packet("in_1", 1));
|
||||
MEDIAPIPE_EXPECT_OK(add_packet("in_1", 2));
|
||||
MP_EXPECT_OK(add_packet("in_1", 1));
|
||||
MP_EXPECT_OK(add_packet("in_1", 2));
|
||||
EXPECT_FALSE(add_packet("in_1", 3).ok());
|
||||
|
||||
::mediapipe::Status status = graph.WaitUntilIdle();
|
||||
@@ -295,7 +295,7 @@ TEST(CalculatorGraphStoppingTest, DeadlockReporting) {
|
||||
status.message(),
|
||||
testing::HasSubstr("Detected a deadlock due to input throttling"));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
EXPECT_FALSE(graph.WaitUntilDone().ok());
|
||||
ASSERT_EQ(0, out_packets.size());
|
||||
}
|
||||
@@ -319,11 +319,11 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) {
|
||||
)",
|
||||
&config));
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
graph.SetGraphInputStreamAddMode(
|
||||
CalculatorGraph::GraphInputStreamAddMode::WAIT_TILL_NOT_FULL);
|
||||
std::vector<Packet> out_packets;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.ObserveOutputStream("out_1", [&out_packets](const Packet& packet) {
|
||||
out_packets.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -343,7 +343,7 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) {
|
||||
};
|
||||
|
||||
// Start the graph.
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({
|
||||
MP_ASSERT_OK(graph.StartRun({
|
||||
{"callback_1", AdoptAsUniquePtr(new auto(callback_1))},
|
||||
}));
|
||||
|
||||
@@ -351,19 +351,19 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) {
|
||||
// This grows the input stream "in_1" to max-queue-size 10.
|
||||
semaphore.Release(9);
|
||||
for (int i = 1; i <= 9; ++i) {
|
||||
MEDIAPIPE_EXPECT_OK(add_packet("in_1", i));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_EXPECT_OK(add_packet("in_1", i));
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
}
|
||||
|
||||
// Advance the timestamp-bound and flush "in_1".
|
||||
semaphore.Release(1);
|
||||
MEDIAPIPE_EXPECT_OK(add_packet("in_2", 30));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_EXPECT_OK(add_packet("in_2", 30));
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
|
||||
// Fill up input stream "in_1", with the semaphore blocked and deadlock
|
||||
// resolution disabled.
|
||||
for (int i = 11; i < 23; ++i) {
|
||||
MEDIAPIPE_EXPECT_OK(add_packet("in_1", i));
|
||||
MP_EXPECT_OK(add_packet("in_1", i));
|
||||
}
|
||||
|
||||
// Adding any more packets fails with error "Graph is throttled".
|
||||
@@ -374,9 +374,9 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) {
|
||||
// Allow the 12 blocked calls to "callback_1" to complete.
|
||||
semaphore.Release(12);
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
ASSERT_EQ(21, out_packets.size());
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -103,14 +103,14 @@ Timestamp CalculatorNode::SourceProcessOrder(
|
||||
|
||||
// TODO Propagate types between calculators when SetAny is used.
|
||||
|
||||
RETURN_IF_ERROR(InitializeOutputSidePackets(
|
||||
MP_RETURN_IF_ERROR(InitializeOutputSidePackets(
|
||||
node_type_info.OutputSidePacketTypes(), output_side_packets));
|
||||
|
||||
RETURN_IF_ERROR(InitializeInputSidePackets(output_side_packets));
|
||||
MP_RETURN_IF_ERROR(InitializeInputSidePackets(output_side_packets));
|
||||
|
||||
RETURN_IF_ERROR(InitializeOutputStreamHandler(
|
||||
MP_RETURN_IF_ERROR(InitializeOutputStreamHandler(
|
||||
node_config.output_stream_handler(), node_type_info.OutputStreamTypes()));
|
||||
RETURN_IF_ERROR(InitializeOutputStreams(output_stream_managers));
|
||||
MP_RETURN_IF_ERROR(InitializeOutputStreams(output_stream_managers));
|
||||
|
||||
calculator_state_ = absl::make_unique<CalculatorState>(
|
||||
name_, node_id_, node_config.calculator(), node_config,
|
||||
@@ -142,7 +142,7 @@ Timestamp CalculatorNode::SourceProcessOrder(
|
||||
|
||||
// Use calculator or graph specified InputStreamHandler, or the default ISH
|
||||
// already set from graph.
|
||||
RETURN_IF_ERROR(InitializeInputStreamHandler(
|
||||
MP_RETURN_IF_ERROR(InitializeInputStreamHandler(
|
||||
use_calc_specified ? handler_config : node_config.input_stream_handler(),
|
||||
node_type_info.InputStreamTypes()));
|
||||
|
||||
@@ -216,7 +216,7 @@ Timestamp CalculatorNode::SourceProcessOrder(
|
||||
RET_CHECK_LE(0, node_type_info.InputStreamBaseIndex());
|
||||
InputStreamManager* current_input_stream_managers =
|
||||
&input_stream_managers[node_type_info.InputStreamBaseIndex()];
|
||||
RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers(
|
||||
MP_RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers(
|
||||
current_input_stream_managers));
|
||||
|
||||
// Set all the mirrors.
|
||||
@@ -278,7 +278,7 @@ Timestamp CalculatorNode::SourceProcessOrder(
|
||||
::mediapipe::Status CalculatorNode::ConnectShardsToStreams(
|
||||
CalculatorContext* calculator_context) {
|
||||
RET_CHECK(calculator_context);
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
input_stream_handler_->SetupInputShards(&calculator_context->Inputs()));
|
||||
return output_stream_handler_->SetupOutputShards(
|
||||
&calculator_context->Outputs());
|
||||
@@ -338,7 +338,7 @@ void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) {
|
||||
|
||||
const PacketTypeSet* input_side_packet_types =
|
||||
&validated_graph_->CalculatorInfos()[node_id_].InputSidePacketTypes();
|
||||
RETURN_IF_ERROR(input_side_packet_handler_.PrepareForRun(
|
||||
MP_RETURN_IF_ERROR(input_side_packet_handler_.PrepareForRun(
|
||||
input_side_packet_types, all_side_packets,
|
||||
[this]() { CalculatorNode::InputSidePacketsReady(); },
|
||||
std::move(error_callback)));
|
||||
@@ -361,7 +361,7 @@ void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) {
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(calculator_context_manager_.PrepareForRun(std::bind(
|
||||
MP_RETURN_IF_ERROR(calculator_context_manager_.PrepareForRun(std::bind(
|
||||
&CalculatorNode::ConnectShardsToStreams, this, std::placeholders::_1)));
|
||||
|
||||
auto calculator_statusor = CreateCalculator(
|
||||
@@ -426,7 +426,7 @@ void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) {
|
||||
"Open() on node \"$0\" returned tool::StatusStop() which should only be "
|
||||
"used to signal that a source node is done producing data.",
|
||||
DebugName());
|
||||
RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute(
|
||||
MP_RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute(
|
||||
"Calculator::Open() for node \"$0\" failed: ", DebugName());
|
||||
needs_to_close_ = true;
|
||||
|
||||
@@ -519,7 +519,7 @@ void CalculatorNode::CloseOutputStreams(OutputStreamShardSet* outputs) {
|
||||
status_ = kStateClosed;
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute(
|
||||
MP_RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute(
|
||||
"Calculator::Close() for node \"$0\" failed: ", DebugName());
|
||||
|
||||
VLOG(2) << "Closed node " << DebugName();
|
||||
@@ -745,7 +745,7 @@ std::string CalculatorNode::DebugName() const {
|
||||
}
|
||||
output_stream_handler_->PostProcess(input_timestamp);
|
||||
if (node_stopped) {
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
CloseNode(::mediapipe::OkStatus(), /*graph_run_ended=*/false));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
|
||||
@@ -159,7 +159,7 @@ class CalculatorNodeTest : public ::testing::Test {
|
||||
input_side_packets_.emplace("input_b", Adopt(new int(42)));
|
||||
|
||||
node_.reset(new CalculatorNode());
|
||||
MEDIAPIPE_ASSERT_OK(node_->Initialize(
|
||||
MP_ASSERT_OK(node_->Initialize(
|
||||
&validated_graph_, 2, input_stream_managers_.get(),
|
||||
output_stream_managers_.get(), output_side_packets_.get(),
|
||||
&buffer_size_hint_, graph_profiler_));
|
||||
@@ -190,7 +190,7 @@ class CalculatorNodeTest : public ::testing::Test {
|
||||
++index) {
|
||||
const EdgeInfo& edge_info =
|
||||
validated_graph_.OutputSidePacketInfos()[index];
|
||||
RETURN_IF_ERROR(output_side_packets_[index].Initialize(
|
||||
MP_RETURN_IF_ERROR(output_side_packets_[index].Initialize(
|
||||
edge_info.name, edge_info.packet_type));
|
||||
}
|
||||
// END OF: code is copied from
|
||||
@@ -203,7 +203,7 @@ class CalculatorNodeTest : public ::testing::Test {
|
||||
for (int index = 0; index < validated_graph_.InputStreamInfos().size();
|
||||
++index) {
|
||||
const EdgeInfo& edge_info = validated_graph_.InputStreamInfos()[index];
|
||||
RETURN_IF_ERROR(input_stream_managers_[index].Initialize(
|
||||
MP_RETURN_IF_ERROR(input_stream_managers_[index].Initialize(
|
||||
edge_info.name, edge_info.packet_type, edge_info.back_edge));
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ class CalculatorNodeTest : public ::testing::Test {
|
||||
for (int index = 0; index < validated_graph_.OutputStreamInfos().size();
|
||||
++index) {
|
||||
const EdgeInfo& edge_info = validated_graph_.OutputStreamInfos()[index];
|
||||
RETURN_IF_ERROR(output_stream_managers_[index].Initialize(
|
||||
MP_RETURN_IF_ERROR(output_stream_managers_[index].Initialize(
|
||||
edge_info.name, edge_info.packet_type));
|
||||
}
|
||||
// END OF: code is copied from CalculatorGraph::InitializeStreams.
|
||||
@@ -277,7 +277,7 @@ TEST_F(CalculatorNodeTest, Initialize) {
|
||||
|
||||
TEST_F(CalculatorNodeTest, PrepareForRun) {
|
||||
InitializeEnvironment(/*use_tags=*/false);
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
EXPECT_TRUE(node_->Prepared());
|
||||
EXPECT_FALSE(node_->Opened());
|
||||
@@ -296,11 +296,11 @@ TEST_F(CalculatorNodeTest, PrepareForRun) {
|
||||
|
||||
TEST_F(CalculatorNodeTest, Open) {
|
||||
InitializeEnvironment(/*use_tags=*/false);
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
EXPECT_EQ(0, ready_for_open_count_);
|
||||
SimulateParentOpenNode();
|
||||
MEDIAPIPE_EXPECT_OK(node_->OpenNode());
|
||||
MP_EXPECT_OK(node_->OpenNode());
|
||||
|
||||
EXPECT_TRUE(node_->Prepared());
|
||||
EXPECT_TRUE(node_->Opened());
|
||||
@@ -319,10 +319,10 @@ TEST_F(CalculatorNodeTest, Open) {
|
||||
|
||||
TEST_F(CalculatorNodeTest, Process) {
|
||||
InitializeEnvironment(/*use_tags=*/false);
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
SimulateParentOpenNode();
|
||||
MEDIAPIPE_EXPECT_OK(node_->OpenNode());
|
||||
MP_EXPECT_OK(node_->OpenNode());
|
||||
|
||||
OutputStreamShard stream_a_shard;
|
||||
stream_a_shard.SetSpec(stream_a_manager_->Spec());
|
||||
@@ -332,7 +332,7 @@ TEST_F(CalculatorNodeTest, Process) {
|
||||
// Expects that a CalculatorContext has been prepared.
|
||||
EXPECT_NE(nullptr, cc_);
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
|
||||
cc_ = nullptr;
|
||||
node_->EndScheduling();
|
||||
@@ -356,10 +356,10 @@ TEST_F(CalculatorNodeTest, Process) {
|
||||
|
||||
TEST_F(CalculatorNodeTest, ProcessSeveral) {
|
||||
InitializeEnvironment(/*use_tags=*/false);
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
SimulateParentOpenNode();
|
||||
MEDIAPIPE_EXPECT_OK(node_->OpenNode());
|
||||
MP_EXPECT_OK(node_->OpenNode());
|
||||
|
||||
OutputStreamShard stream_a_shard;
|
||||
stream_a_shard.SetSpec(stream_a_manager_->Spec());
|
||||
@@ -369,7 +369,7 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) {
|
||||
EXPECT_EQ(1, schedule_count_);
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
EXPECT_NE(nullptr, cc_);
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
EXPECT_EQ(1, schedule_count_);
|
||||
|
||||
@@ -383,7 +383,7 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) {
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
// Expects that a CalculatorContext has been prepared.
|
||||
EXPECT_NE(nullptr, cc_);
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
EXPECT_EQ(3, schedule_count_);
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
@@ -397,13 +397,13 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) {
|
||||
// The max parallelism is already reached.
|
||||
EXPECT_FALSE(node_->TryToBeginScheduling());
|
||||
EXPECT_NE(nullptr, cc_);
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
EXPECT_EQ(4, schedule_count_);
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
|
||||
EXPECT_NE(nullptr, cc_);
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
|
||||
cc_ = nullptr;
|
||||
node_->EndScheduling();
|
||||
@@ -425,10 +425,10 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) {
|
||||
|
||||
TEST_F(CalculatorNodeTest, Close) {
|
||||
InitializeEnvironment(/*use_tags=*/false);
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
SimulateParentOpenNode();
|
||||
MEDIAPIPE_EXPECT_OK(node_->OpenNode());
|
||||
MP_EXPECT_OK(node_->OpenNode());
|
||||
|
||||
OutputStreamShard stream_a_shard;
|
||||
stream_a_shard.SetSpec(stream_a_manager_->Spec());
|
||||
@@ -438,11 +438,11 @@ TEST_F(CalculatorNodeTest, Close) {
|
||||
stream_a_manager_->Close();
|
||||
// The max parallelism is already reached.
|
||||
EXPECT_FALSE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
EXPECT_TRUE(node_->Closed());
|
||||
EXPECT_EQ(2, schedule_count_);
|
||||
|
||||
@@ -464,10 +464,10 @@ TEST_F(CalculatorNodeTest, Close) {
|
||||
|
||||
TEST_F(CalculatorNodeTest, CleanupAfterRun) {
|
||||
InitializeEnvironment(/*use_tags=*/false);
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
SimulateParentOpenNode();
|
||||
MEDIAPIPE_EXPECT_OK(node_->OpenNode());
|
||||
MP_EXPECT_OK(node_->OpenNode());
|
||||
OutputStreamShard stream_a_shard;
|
||||
stream_a_shard.SetSpec(stream_a_manager_->Spec());
|
||||
stream_a_shard.Add(new int(1), Timestamp(1));
|
||||
@@ -476,11 +476,11 @@ TEST_F(CalculatorNodeTest, CleanupAfterRun) {
|
||||
stream_a_manager_->Close();
|
||||
// The max parallelism is already reached.
|
||||
EXPECT_FALSE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
// Call ProcessNode again for the node to see the end of the stream.
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
// The max parallelism is already reached.
|
||||
EXPECT_FALSE(node_->TryToBeginScheduling());
|
||||
@@ -501,10 +501,10 @@ TEST_F(CalculatorNodeTest, CleanupAfterRun) {
|
||||
}
|
||||
|
||||
void CalculatorNodeTest::TestCleanupAfterRunTwice() {
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
SimulateParentOpenNode();
|
||||
MEDIAPIPE_EXPECT_OK(node_->OpenNode());
|
||||
MP_EXPECT_OK(node_->OpenNode());
|
||||
OutputStreamShard stream_a_shard;
|
||||
stream_a_shard.SetSpec(stream_a_manager_->Spec());
|
||||
stream_a_shard.Add(new int(1), Timestamp(1));
|
||||
@@ -513,20 +513,20 @@ void CalculatorNodeTest::TestCleanupAfterRunTwice() {
|
||||
stream_a_manager_->Close();
|
||||
// The max parallelism is already reached.
|
||||
EXPECT_FALSE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
// We should get Timestamp::Done here.
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
node_->CleanupAfterRun(::mediapipe::OkStatus());
|
||||
|
||||
stream_a_manager_->PrepareForRun(nullptr);
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(PrepareNodeForRun());
|
||||
MP_ASSERT_OK(PrepareNodeForRun());
|
||||
|
||||
SimulateParentOpenNode();
|
||||
MEDIAPIPE_EXPECT_OK(node_->OpenNode());
|
||||
MP_EXPECT_OK(node_->OpenNode());
|
||||
stream_a_manager_->ResetShard(&stream_a_shard);
|
||||
stream_a_shard.Add(new int(2), Timestamp(4));
|
||||
stream_a_shard.Add(new int(3), Timestamp(8));
|
||||
@@ -534,14 +534,14 @@ void CalculatorNodeTest::TestCleanupAfterRunTwice() {
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
stream_a_manager_->Close();
|
||||
EXPECT_FALSE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
// We should get Timestamp::Done here.
|
||||
EXPECT_TRUE(node_->TryToBeginScheduling());
|
||||
MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
MP_EXPECT_OK(node_->ProcessNode(cc_));
|
||||
node_->EndScheduling();
|
||||
// The max parallelism is already reached.
|
||||
EXPECT_FALSE(node_->TryToBeginScheduling());
|
||||
|
||||
@@ -117,7 +117,7 @@ TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) {
|
||||
CalculatorGraph graph(graph_config);
|
||||
// Runs the graph twice.
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun(
|
||||
MP_ASSERT_OK(graph.StartRun(
|
||||
{{"callback", MakePacket<std::function<void(const Packet&)>>(std::bind(
|
||||
&ParallelExecutionTest::AddThreadSafeVectorSink, this,
|
||||
std::placeholders::_1))}}));
|
||||
@@ -134,15 +134,15 @@ TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) {
|
||||
EXPECT_EQ(0, fail_count);
|
||||
|
||||
// Doesn't wait but just close the input stream.
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input"));
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input"));
|
||||
// Waits properly via the API until the graph is done.
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
|
||||
absl::ReaderMutexLock lock(&output_packets_mutex_);
|
||||
ASSERT_EQ(kTotalNums - kTotalNums / 4, output_packets_.size());
|
||||
int index = 1;
|
||||
for (const Packet& packet : output_packets_) {
|
||||
MEDIAPIPE_ASSERT_OK(packet.ValidateAsType<int>());
|
||||
MP_ASSERT_OK(packet.ValidateAsType<int>());
|
||||
EXPECT_EQ(index + 2, packet.Get<int>());
|
||||
EXPECT_EQ(Timestamp(index), packet.Timestamp());
|
||||
if (++index % 4 == 0) {
|
||||
|
||||
@@ -40,7 +40,7 @@ bool IsLegacyCalculator(const std::string& package_name,
|
||||
internal::StaticAccessToCalculatorBaseRegistry::CreateByNameInNamespace(
|
||||
package_name, node_class),
|
||||
_ << "Unable to find Calculator \"" << node_class << "\"");
|
||||
RETURN_IF_ERROR(static_access_to_calculator_base->GetContract(contract))
|
||||
MP_RETURN_IF_ERROR(static_access_to_calculator_base->GetContract(contract))
|
||||
.SetPrepend()
|
||||
<< node_class << ": ";
|
||||
return ::mediapipe::OkStatus();
|
||||
|
||||
@@ -238,8 +238,8 @@ std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
|
||||
std::string name;
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i), &tag,
|
||||
&index, &name));
|
||||
MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i),
|
||||
&tag, &index, &name));
|
||||
// Add a source for each input stream.
|
||||
auto* node = config.add_node();
|
||||
node->set_calculator("CalculatorRunnerSourceCalculator");
|
||||
@@ -250,8 +250,8 @@ std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
|
||||
std::string name;
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i), &tag,
|
||||
&index, &name));
|
||||
MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i),
|
||||
&tag, &index, &name));
|
||||
// Add a sink for each output stream.
|
||||
auto* node = config.add_node();
|
||||
node->set_calculator("CalculatorRunnerSinkCalculator");
|
||||
@@ -276,12 +276,12 @@ std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
|
||||
}
|
||||
|
||||
graph_ = absl::make_unique<CalculatorGraph>();
|
||||
RETURN_IF_ERROR(graph_->Initialize(config));
|
||||
MP_RETURN_IF_ERROR(graph_->Initialize(config));
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
|
||||
::mediapipe::Status CalculatorRunner::Run() {
|
||||
RETURN_IF_ERROR(BuildGraph());
|
||||
MP_RETURN_IF_ERROR(BuildGraph());
|
||||
// Set the input side packets for the sources.
|
||||
std::map<std::string, Packet> input_side_packets;
|
||||
int positional_index = -1;
|
||||
@@ -289,8 +289,8 @@ std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
|
||||
std::string name;
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i), &tag,
|
||||
&index, &name));
|
||||
MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i),
|
||||
&tag, &index, &name));
|
||||
const CalculatorRunner::StreamContents* contents;
|
||||
if (index == -1) {
|
||||
// positional_index considers the case when the tag is empty, which is
|
||||
@@ -310,8 +310,8 @@ std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
|
||||
std::string name;
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_side_packet(i),
|
||||
&tag, &index, &name));
|
||||
MP_RETURN_IF_ERROR(tool::ParseTagIndexName(
|
||||
node_config_.input_side_packet(i), &tag, &index, &name));
|
||||
const Packet* packet;
|
||||
if (index == -1) {
|
||||
packet = &input_side_packets_->Get(tag, ++positional_index);
|
||||
@@ -326,8 +326,8 @@ std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
|
||||
std::string name;
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i), &tag,
|
||||
&index, &name));
|
||||
MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i),
|
||||
&tag, &index, &name));
|
||||
CalculatorRunner::StreamContents* contents;
|
||||
if (index == -1) {
|
||||
contents = &outputs_->Get(tag, ++positional_index);
|
||||
@@ -339,15 +339,15 @@ std::map<std::string, int64> CalculatorRunner::GetCountersValues() {
|
||||
input_side_packets.emplace(absl::StrCat(kSinkPrefix, name),
|
||||
Adopt(new auto(contents)));
|
||||
}
|
||||
RETURN_IF_ERROR(graph_->Run(input_side_packets));
|
||||
MP_RETURN_IF_ERROR(graph_->Run(input_side_packets));
|
||||
|
||||
positional_index = -1;
|
||||
for (int i = 0; i < node_config_.output_side_packet_size(); ++i) {
|
||||
std::string name;
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_side_packet(i),
|
||||
&tag, &index, &name));
|
||||
MP_RETURN_IF_ERROR(tool::ParseTagIndexName(
|
||||
node_config_.output_side_packet(i), &tag, &index, &name));
|
||||
Packet& contents = output_side_packets_->Get(
|
||||
tag, (index == -1) ? ++positional_index : index);
|
||||
ASSIGN_OR_RETURN(contents, graph_->GetOutputSidePacket(name));
|
||||
|
||||
@@ -150,7 +150,7 @@ TEST(CalculatorRunner, RunsCalculator) {
|
||||
const int input_side_packet_content = 10 + iter;
|
||||
runner.MutableSidePackets()->Index(0) =
|
||||
Adopt(new int(input_side_packet_content));
|
||||
MEDIAPIPE_ASSERT_OK(runner.Run());
|
||||
MP_ASSERT_OK(runner.Run());
|
||||
EXPECT_EQ(input_side_packet_content,
|
||||
runner.OutputSidePackets().Tag("SIDE_OUTPUT").Get<int>());
|
||||
const auto& outputs = runner.Outputs();
|
||||
@@ -204,7 +204,7 @@ TEST(CalculatorRunner, MultiTagTestCalculatorOk) {
|
||||
->Get("", ts % 2)
|
||||
.packets.push_back(Adopt(new int(ts)).At(Timestamp(ts)));
|
||||
}
|
||||
MEDIAPIPE_ASSERT_OK(runner.Run());
|
||||
MP_ASSERT_OK(runner.Run());
|
||||
|
||||
const auto& outputs = runner.Outputs();
|
||||
ASSERT_EQ(3, outputs.NumEntries());
|
||||
|
||||
@@ -76,7 +76,7 @@ TEST(CollectionTest, MixedTagAndIndexUsage) {
|
||||
auto tags_statusor =
|
||||
tool::CreateTagMap({"TAG_A:a", "TAG_B:1:b", "TAG_A:2:c", "TAG_B:d",
|
||||
"TAG_C:0:e", "TAG_A:1:f"});
|
||||
MEDIAPIPE_ASSERT_OK(tags_statusor);
|
||||
MP_ASSERT_OK(tags_statusor);
|
||||
|
||||
internal::Collection<int> collection1(std::move(tags_statusor.ValueOrDie()));
|
||||
collection1.Get("TAG_A", 0) = 100;
|
||||
@@ -452,9 +452,8 @@ template <typename T>
|
||||
}
|
||||
|
||||
TEST(CollectionTest, TestCollectionWithPointersIntAndString) {
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
TestCollectionWithPointers<int>({3, 7, -2, 0, 4, -3}, 17, 10));
|
||||
MEDIAPIPE_ASSERT_OK(TestCollectionWithPointers<std::string>(
|
||||
MP_ASSERT_OK(TestCollectionWithPointers<int>({3, 7, -2, 0, 4, -3}, 17, 10));
|
||||
MP_ASSERT_OK(TestCollectionWithPointers<std::string>(
|
||||
{"a0", "a1", "a2", "b0", "b1", "c0"}, "inject1", "inject2"));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ proto_library(
|
||||
mediapipe_cc_proto_library(
|
||||
name = "proto_descriptor_cc_proto",
|
||||
srcs = ["proto_descriptor.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
deps = [":proto_descriptor_proto"],
|
||||
)
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ inline StatusBuilder RetCheckImpl(const ::mediapipe::Status& status,
|
||||
return ::mediapipe::RetCheckFailSlowPath(MEDIAPIPE_LOC, #cond)
|
||||
|
||||
#define RET_CHECK_OK(status) \
|
||||
RETURN_IF_ERROR(::mediapipe::RetCheckImpl((status), #status, MEDIAPIPE_LOC))
|
||||
MP_RETURN_IF_ERROR( \
|
||||
::mediapipe::RetCheckImpl((status), #status, MEDIAPIPE_LOC))
|
||||
|
||||
#define RET_CHECK_FAIL() return ::mediapipe::RetCheckFailSlowPath(MEDIAPIPE_LOC)
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ inline std::string* MediaPipeCheckOpHelper(::mediapipe::Status v,
|
||||
while (auto _result = ::mediapipe::MediaPipeCheckOpHelper(val, #val)) \
|
||||
LOG(level) << *(_result)
|
||||
|
||||
// To be consistent with MEDIAPIPE_EXPECT_OK, we add prefix MEDIAPIPE_ to
|
||||
// To be consistent with MP_EXPECT_OK, we add prefix MEDIAPIPE_ to
|
||||
// CHECK_OK, QCHECK_OK, and DCHECK_OK. We prefer to use the marcos with
|
||||
// MEDIAPIPE_ prefix in mediapipe's codebase.
|
||||
#define MEDIAPIPE_CHECK_OK(val) MEDIAPIPE_DO_CHECK_OK(val, FATAL)
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
//
|
||||
// For example:
|
||||
// ::mediapipe::Status MultiStepFunction() {
|
||||
// RETURN_IF_ERROR(Function(args...));
|
||||
// RETURN_IF_ERROR(foo.Method(args...));
|
||||
// MP_RETURN_IF_ERROR(Function(args...));
|
||||
// MP_RETURN_IF_ERROR(foo.Method(args...));
|
||||
// return ::mediapipe::OkStatus();
|
||||
// }
|
||||
//
|
||||
@@ -42,8 +42,8 @@
|
||||
//
|
||||
// For example:
|
||||
// ::mediapipe::Status MultiStepFunction() {
|
||||
// RETURN_IF_ERROR(Function(args...)) << "in MultiStepFunction";
|
||||
// RETURN_IF_ERROR(foo.Method(args...)).Log(base_logging::ERROR)
|
||||
// MP_RETURN_IF_ERROR(Function(args...)) << "in MultiStepFunction";
|
||||
// MP_RETURN_IF_ERROR(foo.Method(args...)).Log(base_logging::ERROR)
|
||||
// << "while processing query: " << query.DebugString();
|
||||
// return ::mediapipe::OkStatus();
|
||||
// }
|
||||
@@ -58,8 +58,8 @@
|
||||
// return std::move(builder.Log(base_logging::WARNING).Attach(...));
|
||||
// }
|
||||
//
|
||||
// RETURN_IF_ERROR(foo()).With(TeamPolicy);
|
||||
// RETURN_IF_ERROR(bar()).With(TeamPolicy);
|
||||
// MP_RETURN_IF_ERROR(foo()).With(TeamPolicy);
|
||||
// MP_RETURN_IF_ERROR(bar()).With(TeamPolicy);
|
||||
//
|
||||
// Changing the return type allows the macro to be used with Task and Rpc
|
||||
// interfaces. See `::mediapipe::TaskReturn` and `rpc::RpcSetStatus` for
|
||||
@@ -67,8 +67,8 @@
|
||||
//
|
||||
// void Read(StringPiece name, ::mediapipe::Task* task) {
|
||||
// int64 id;
|
||||
// RETURN_IF_ERROR(GetIdForName(name, &id)).With(TaskReturn(task));
|
||||
// RETURN_IF_ERROR(ReadForId(id)).With(TaskReturn(task));
|
||||
// MP_RETURN_IF_ERROR(GetIdForName(name, &id)).With(TaskReturn(task));
|
||||
// MP_RETURN_IF_ERROR(ReadForId(id)).With(TaskReturn(task));
|
||||
// task->Return();
|
||||
// }
|
||||
//
|
||||
@@ -77,11 +77,11 @@
|
||||
// `::mediapipe::Status` type. E.g.
|
||||
//
|
||||
// []() -> ::mediapipe::Status {
|
||||
// RETURN_IF_ERROR(Function(args...));
|
||||
// RETURN_IF_ERROR(foo.Method(args...));
|
||||
// MP_RETURN_IF_ERROR(Function(args...));
|
||||
// MP_RETURN_IF_ERROR(foo.Method(args...));
|
||||
// return ::mediapipe::OkStatus();
|
||||
// }
|
||||
#define RETURN_IF_ERROR(expr) \
|
||||
#define MP_RETURN_IF_ERROR(expr) \
|
||||
STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
|
||||
if (::mediapipe::status_macro_internal::StatusAdaptorForMacros \
|
||||
status_macro_internal_adaptor = {(expr), __FILE__, __LINE__}) { \
|
||||
@@ -124,7 +124,7 @@
|
||||
// well as a `::mediapipe::StatusBuilder` object populated with the error and
|
||||
// named by a single underscore `_`. The expression typically uses the
|
||||
// builder to modify the status and is returned directly in manner similar
|
||||
// to RETURN_IF_ERROR. The expression may, however, evaluate to any type
|
||||
// to MP_RETURN_IF_ERROR. The expression may, however, evaluate to any type
|
||||
// returnable by the function, including (void). For example:
|
||||
//
|
||||
// Example: Adjusting the error message.
|
||||
@@ -175,7 +175,7 @@
|
||||
// because it thinks you might want the else to bind to the first if. This
|
||||
// leads to problems with code like:
|
||||
//
|
||||
// if (do_expr) RETURN_IF_ERROR(expr) << "Some message";
|
||||
// if (do_expr) MP_RETURN_IF_ERROR(expr) << "Some message";
|
||||
//
|
||||
// The "switch (0) case 0:" idiom is used to suppress this.
|
||||
#define STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
|
||||
|
||||
@@ -18,11 +18,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "mediapipe/framework/deps/status.h"
|
||||
|
||||
// EXPECT_OK marco is already defined in our external dependency library
|
||||
// protobuf. To be consistent with MEDIAPIPE_EXPECT_OK, we also add prefix
|
||||
// MEDIAPIPE_ to ASSERT_OK. We prefer to use the marcos with MEDIAPIPE_ prefix
|
||||
// in mediapipe's codebase.
|
||||
#define MEDIAPIPE_EXPECT_OK(statement) EXPECT_TRUE((statement).ok())
|
||||
#define MEDIAPIPE_ASSERT_OK(statement) ASSERT_TRUE((statement).ok())
|
||||
#define MP_EXPECT_OK(statement) EXPECT_TRUE((statement).ok())
|
||||
#define MP_ASSERT_OK(statement) ASSERT_TRUE((statement).ok())
|
||||
|
||||
#endif // MEDIAPIPE_DEPS_STATUS_MATCHERS_H_
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace mediapipe {
|
||||
TEST(Status, OK) {
|
||||
EXPECT_EQ(OkStatus().code(), ::mediapipe::StatusCode::kOk);
|
||||
EXPECT_EQ(OkStatus().error_message(), "");
|
||||
MEDIAPIPE_EXPECT_OK(OkStatus());
|
||||
MEDIAPIPE_ASSERT_OK(OkStatus());
|
||||
MP_EXPECT_OK(OkStatus());
|
||||
MP_ASSERT_OK(OkStatus());
|
||||
EXPECT_EQ(OkStatus(), Status());
|
||||
Status s;
|
||||
EXPECT_TRUE(s.ok());
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace internal {
|
||||
/*calculator_run_in_parallel=*/false);
|
||||
const CollectionItemId& id = tag_map->BeginId();
|
||||
input_stream_ = absl::make_unique<InputStreamManager>();
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
input_stream_->Initialize(stream_name, packet_type, /*back_edge=*/false));
|
||||
RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers(
|
||||
MP_RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers(
|
||||
input_stream_.get()));
|
||||
output_stream_manager->AddMirror(input_stream_handler_.get(), id);
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -74,7 +74,7 @@ void GraphOutputStream::PrepareForRun(
|
||||
RET_CHECK_EQ(num_packets_dropped, 0).SetNoLogging()
|
||||
<< absl::Substitute("Dropped $0 packet(s) on input stream \"$1\".",
|
||||
num_packets_dropped, input_stream_->Name());
|
||||
RETURN_IF_ERROR(packet_callback_(packet));
|
||||
MP_RETURN_IF_ERROR(packet_callback_(packet));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
@@ -83,8 +83,8 @@ void GraphOutputStream::PrepareForRun(
|
||||
const std::string& stream_name, const PacketType* packet_type,
|
||||
std::function<void(InputStreamManager*, bool*)> queue_size_callback,
|
||||
OutputStreamManager* output_stream_manager) {
|
||||
RETURN_IF_ERROR(GraphOutputStream::Initialize(stream_name, packet_type,
|
||||
output_stream_manager));
|
||||
MP_RETURN_IF_ERROR(GraphOutputStream::Initialize(stream_name, packet_type,
|
||||
output_stream_manager));
|
||||
input_stream_handler_->SetQueueSizeCallbacks(queue_size_callback,
|
||||
queue_size_callback);
|
||||
return ::mediapipe::OkStatus();
|
||||
|
||||
@@ -56,8 +56,8 @@ class GraphServiceTest : public ::testing::Test {
|
||||
output_stream: "out"
|
||||
}
|
||||
)");
|
||||
MEDIAPIPE_ASSERT_OK(graph_.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(graph_.Initialize(config));
|
||||
MP_ASSERT_OK(
|
||||
graph_.ObserveOutputStream("out", [this](const Packet& packet) {
|
||||
output_packets_.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -72,26 +72,26 @@ TEST_F(GraphServiceTest, SetOnGraph) {
|
||||
EXPECT_EQ(graph_.GetServiceObject(kTestService).get(), nullptr);
|
||||
auto service_object =
|
||||
std::make_shared<TestServiceObject>(TestServiceObject{{"delta", 3}});
|
||||
MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
EXPECT_EQ(graph_.GetServiceObject(kTestService), service_object);
|
||||
|
||||
service_object = std::make_shared<TestServiceObject>(
|
||||
TestServiceObject{{"delta", 5}, {"count", 0}});
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
EXPECT_EQ(graph_.GetServiceObject(kTestService), service_object);
|
||||
}
|
||||
|
||||
TEST_F(GraphServiceTest, UseInCalculator) {
|
||||
auto service_object = std::make_shared<TestServiceObject>(
|
||||
TestServiceObject{{"delta", 5}, {"count", 0}});
|
||||
MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph_.StartRun({}));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(graph_.StartRun({}));
|
||||
MP_ASSERT_OK(
|
||||
graph_.AddPacketToInputStream("in", MakePacket<int>(3).At(Timestamp(0))));
|
||||
MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph_.WaitUntilDone());
|
||||
EXPECT_EQ(PacketValues<int>(output_packets_), (std::vector<int>{8}));
|
||||
EXPECT_EQ(1, (*service_object)["count"]);
|
||||
}
|
||||
@@ -104,8 +104,8 @@ TEST_F(GraphServiceTest, Contract) {
|
||||
output_stream: "out"
|
||||
)");
|
||||
CalculatorContract contract;
|
||||
MEDIAPIPE_EXPECT_OK(contract.Initialize(node));
|
||||
MEDIAPIPE_EXPECT_OK(TestServiceCalculator::GetContract(&contract));
|
||||
MP_EXPECT_OK(contract.Initialize(node));
|
||||
MP_EXPECT_OK(TestServiceCalculator::GetContract(&contract));
|
||||
EXPECT_THAT(
|
||||
contract.ServiceRequests(),
|
||||
UnorderedElementsAre(Key(kTestService.key), Key(kAnotherService.key)));
|
||||
@@ -125,28 +125,28 @@ TEST_F(GraphServiceTest, OptionalIsOptional) {
|
||||
// Provide only required service.
|
||||
auto service_object = std::make_shared<TestServiceObject>(
|
||||
TestServiceObject{{"delta", 5}, {"count", 0}});
|
||||
MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(graph_.StartRun({}));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_EXPECT_OK(graph_.StartRun({}));
|
||||
MP_ASSERT_OK(
|
||||
graph_.AddPacketToInputStream("in", MakePacket<int>(3).At(Timestamp(0))));
|
||||
MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph_.WaitUntilDone());
|
||||
EXPECT_EQ(PacketValues<int>(output_packets_), (std::vector<int>{8}));
|
||||
}
|
||||
|
||||
TEST_F(GraphServiceTest, OptionalIsAvailable) {
|
||||
auto service_object = std::make_shared<TestServiceObject>(
|
||||
TestServiceObject{{"delta", 5}, {"count", 0}});
|
||||
MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object));
|
||||
MP_EXPECT_OK(
|
||||
graph_.SetServiceObject(kAnotherService, std::make_shared<int>(100)));
|
||||
|
||||
MEDIAPIPE_EXPECT_OK(graph_.StartRun({}));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_EXPECT_OK(graph_.StartRun({}));
|
||||
MP_ASSERT_OK(
|
||||
graph_.AddPacketToInputStream("in", MakePacket<int>(3).At(Timestamp(0))));
|
||||
MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph_.WaitUntilDone());
|
||||
EXPECT_EQ(PacketValues<int>(output_packets_), (std::vector<int>{108}));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ TEST(ValidatedGraphConfigTest, InitializeGraphFromProtos) {
|
||||
)");
|
||||
|
||||
GraphValidation validation_1;
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
MP_EXPECT_OK(
|
||||
validation_1.Validate({config_1, config_2}, {}, {}, "PassThroughGraph"));
|
||||
CalculatorGraph graph_1;
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
MP_EXPECT_OK(
|
||||
graph_1.Initialize({config_1, config_2}, {}, {}, "PassThroughGraph"));
|
||||
EXPECT_THAT(
|
||||
graph_1.Config(),
|
||||
@@ -79,9 +79,9 @@ TEST(ValidatedGraphConfigTest, InitializeGraphFromProtos) {
|
||||
)")));
|
||||
|
||||
GraphValidation validation_2;
|
||||
MEDIAPIPE_EXPECT_OK(validation_2.Validate({config_1, config_2}, {}));
|
||||
MP_EXPECT_OK(validation_2.Validate({config_1, config_2}, {}));
|
||||
CalculatorGraph graph_2;
|
||||
MEDIAPIPE_EXPECT_OK(graph_2.Initialize({config_1, config_2}, {}));
|
||||
MP_EXPECT_OK(graph_2.Initialize({config_1, config_2}, {}));
|
||||
EXPECT_THAT(
|
||||
graph_2.Config(),
|
||||
EqualsProto(::mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
@@ -164,11 +164,11 @@ TEST(ValidatedGraphConfigTest, InitializeTemplateFromProtos) {
|
||||
})");
|
||||
|
||||
GraphValidation validation_1;
|
||||
MEDIAPIPE_EXPECT_OK(validation_1.Validate({config_2}, {config_1}, {},
|
||||
"PassThroughGraph", &options));
|
||||
MP_EXPECT_OK(validation_1.Validate({config_2}, {config_1}, {},
|
||||
"PassThroughGraph", &options));
|
||||
CalculatorGraph graph_1;
|
||||
MEDIAPIPE_EXPECT_OK(graph_1.Initialize({config_2}, {config_1}, {},
|
||||
"PassThroughGraph", &options));
|
||||
MP_EXPECT_OK(graph_1.Initialize({config_2}, {config_1}, {},
|
||||
"PassThroughGraph", &options));
|
||||
EXPECT_THAT(
|
||||
graph_1.Config(),
|
||||
EqualsProto(::mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
@@ -185,9 +185,9 @@ TEST(ValidatedGraphConfigTest, InitializeTemplateFromProtos) {
|
||||
)")));
|
||||
|
||||
GraphValidation validation_2;
|
||||
MEDIAPIPE_EXPECT_OK(validation_2.Validate({config_2}, {config_1}));
|
||||
MP_EXPECT_OK(validation_2.Validate({config_2}, {config_1}));
|
||||
CalculatorGraph graph_2;
|
||||
MEDIAPIPE_EXPECT_OK(graph_2.Initialize({config_2}, {config_1}));
|
||||
MP_EXPECT_OK(graph_2.Initialize({config_2}, {config_1}));
|
||||
EXPECT_THAT(
|
||||
graph_2.Config(),
|
||||
EqualsProto(::mediapipe::ParseTextProtoOrDie<CalculatorGraphConfig>(R"(
|
||||
|
||||
@@ -42,9 +42,8 @@ class InputStreamManagerTest : public ::testing::Test {
|
||||
|
||||
packet_type_.Set<std::string>();
|
||||
input_stream_manager_ = absl::make_unique<InputStreamManager>();
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->Initialize("a_test",
|
||||
&packet_type_,
|
||||
/*back_edge=*/false));
|
||||
MP_ASSERT_OK(input_stream_manager_->Initialize("a_test", &packet_type_,
|
||||
/*back_edge=*/false));
|
||||
|
||||
queue_full_callback_ =
|
||||
std::bind(&InputStreamManagerTest::ReportQueueBecomesFull, this,
|
||||
@@ -99,7 +98,7 @@ TEST_F(InputStreamManagerTest, AddPackets) {
|
||||
packets.push_back(MakePacket<std::string>("packet 3").At(Timestamp(30)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_TRUE(notify_);
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
@@ -116,7 +115,7 @@ TEST_F(InputStreamManagerTest, MovePackets) {
|
||||
packets.push_back(MakePacket<std::string>("packet 3").At(Timestamp(30)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->MovePackets(&packets, ¬ify_)); // Notification
|
||||
EXPECT_TRUE(notify_);
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
@@ -182,7 +181,7 @@ TEST_F(InputStreamManagerTest, AddPacketsOnlyPreStream) {
|
||||
MakePacket<std::string>("packet 1").At(Timestamp::PreStream()));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -210,7 +209,7 @@ TEST_F(InputStreamManagerTest, AddPacketsOnlyPostStream) {
|
||||
MakePacket<std::string>("packet 1").At(Timestamp::PostStream()));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -260,7 +259,7 @@ TEST_F(InputStreamManagerTest, PopPacketAtTimestamp) {
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(input_stream_manager_->QueueHead().IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -319,8 +318,8 @@ TEST_F(InputStreamManagerTest, PopPacketAtTimestamp) {
|
||||
num_packets_dropped_ = 0;
|
||||
popped_packet_ = Packet();
|
||||
stream_is_done_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp::Done(), ¬ify_));
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(Timestamp::Done(),
|
||||
¬ify_));
|
||||
EXPECT_TRUE(notify_);
|
||||
popped_packet_ = input_stream_manager_->PopPacketAtTimestamp(
|
||||
Timestamp(40), &num_packets_dropped_, &stream_is_done_);
|
||||
@@ -344,7 +343,7 @@ TEST_F(InputStreamManagerTest, PopQueueHead) {
|
||||
MakePacket<std::string>(expected_value_at_30).At(Timestamp(30)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(input_stream_manager_->QueueHead().IsEmpty());
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_TRUE(notify_);
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
@@ -385,8 +384,8 @@ TEST_F(InputStreamManagerTest, PopQueueHead) {
|
||||
num_packets_dropped_ = 0;
|
||||
popped_packet_ = Packet();
|
||||
stream_is_done_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp::Done(), ¬ify_));
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(Timestamp::Done(),
|
||||
¬ify_));
|
||||
EXPECT_TRUE(notify_);
|
||||
popped_packet_ = input_stream_manager_->PopQueueHead(&stream_is_done_);
|
||||
EXPECT_TRUE(popped_packet_.IsEmpty());
|
||||
@@ -412,7 +411,7 @@ TEST_F(InputStreamManagerTest, Close) {
|
||||
packets.push_back(MakePacket<std::string>("packet 3").At(Timestamp(30)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -436,7 +435,7 @@ TEST_F(InputStreamManagerTest, ReuseInputStreamManager) {
|
||||
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -465,7 +464,7 @@ TEST_F(InputStreamManagerTest, ReuseInputStreamManager) {
|
||||
packets.push_back(MakePacket<std::string>("packet 3").At(Timestamp(30)));
|
||||
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -487,7 +486,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) {
|
||||
packets.push_back(MakePacket<std::string>("packet 2").At(Timestamp(20)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -495,7 +494,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) {
|
||||
notify_ = false;
|
||||
packets.clear();
|
||||
packets.push_back(MakePacket<std::string>("packet 3").At(Timestamp(30)));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // No notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
// Notification isn't triggered since the queue is already non-empty.
|
||||
@@ -511,7 +510,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) {
|
||||
packets.clear();
|
||||
packets.push_back(MakePacket<std::string>("packet 4").At(Timestamp(60)));
|
||||
packets.push_back(MakePacket<std::string>("packet 5").At(Timestamp(70)));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -519,7 +518,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) {
|
||||
|
||||
TEST_F(InputStreamManagerTest, SetHeader) {
|
||||
Packet header = MakePacket<std::string>("blah");
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetHeader(header));
|
||||
MP_ASSERT_OK(input_stream_manager_->SetHeader(header));
|
||||
|
||||
EXPECT_EQ(header.Get<std::string>(),
|
||||
input_stream_manager_->Header().Get<std::string>());
|
||||
@@ -532,13 +531,13 @@ TEST_F(InputStreamManagerTest, BackwardsInTime) {
|
||||
packets.push_back(MakePacket<std::string>("packet 2").At(Timestamp(20)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(50), ¬ify_)); // No notification
|
||||
// The queue is already non-empty.
|
||||
EXPECT_FALSE(notify_);
|
||||
@@ -572,7 +571,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTime) {
|
||||
popped_packet_ = Packet();
|
||||
packets.clear();
|
||||
packets.push_back(MakePacket<std::string>("packet 4").At(Timestamp(110)));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -599,7 +598,7 @@ TEST_F(InputStreamManagerTest, SelectBackwardsInTime) {
|
||||
packets.push_back(MakePacket<std::string>("packet 2").At(Timestamp(20)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -643,7 +642,7 @@ TEST_F(InputStreamManagerTest, TimestampBound) {
|
||||
packets.push_back(MakePacket<std::string>("packet 2").At(Timestamp(20)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -652,19 +651,19 @@ TEST_F(InputStreamManagerTest, TimestampBound) {
|
||||
EXPECT_EQ(Timestamp(10),
|
||||
input_stream_manager_->MinTimestampOrBound(&is_empty));
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(30), ¬ify_)); // No notification.
|
||||
EXPECT_FALSE(notify_);
|
||||
EXPECT_EQ(Timestamp(10),
|
||||
input_stream_manager_->MinTimestampOrBound(&is_empty));
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(40), ¬ify_)); // No notification.
|
||||
EXPECT_FALSE(notify_);
|
||||
EXPECT_EQ(Timestamp(10),
|
||||
input_stream_manager_->MinTimestampOrBound(&is_empty));
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(50), ¬ify_)); // No notification.
|
||||
EXPECT_FALSE(notify_);
|
||||
|
||||
@@ -701,19 +700,19 @@ TEST_F(InputStreamManagerTest, TimestampBound) {
|
||||
// TODO These notifications may be bad if they schedule a
|
||||
// Calculator Process() call at times that are irrelevant.
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(60), ¬ify_)); // Notification.
|
||||
EXPECT_TRUE(notify_);
|
||||
EXPECT_EQ(Timestamp(60),
|
||||
input_stream_manager_->MinTimestampOrBound(&is_empty));
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(70), ¬ify_)); // Notification.
|
||||
EXPECT_TRUE(notify_);
|
||||
EXPECT_EQ(Timestamp(70),
|
||||
input_stream_manager_->MinTimestampOrBound(&is_empty));
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(80), ¬ify_)); // Notification.
|
||||
EXPECT_TRUE(notify_);
|
||||
EXPECT_EQ(Timestamp(80),
|
||||
@@ -722,7 +721,7 @@ TEST_F(InputStreamManagerTest, TimestampBound) {
|
||||
notify_ = false;
|
||||
packets.clear();
|
||||
packets.push_back(MakePacket<std::string>("packet 3").At(Timestamp(90)));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_TRUE(notify_);
|
||||
|
||||
@@ -756,7 +755,7 @@ TEST_F(InputStreamManagerTest, QueueSizeTest) {
|
||||
packets.push_back(MakePacket<std::string>("packet 3").At(Timestamp(30)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -773,7 +772,7 @@ TEST_F(InputStreamManagerTest, QueueSizeTest) {
|
||||
packets.push_back(MakePacket<std::string>("packet 4").At(Timestamp(60)));
|
||||
packets.push_back(MakePacket<std::string>("packet 5").At(Timestamp(70)));
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -785,8 +784,8 @@ TEST_F(InputStreamManagerTest, QueueSizeTest) {
|
||||
TEST_F(InputStreamManagerTest, InputReleaseTest) {
|
||||
packet_type_.Set<LifetimeTracker::Object>();
|
||||
input_stream_manager_ = absl::make_unique<InputStreamManager>();
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->Initialize("a_test", &packet_type_,
|
||||
/*back_edge=*/false));
|
||||
MP_ASSERT_OK(input_stream_manager_->Initialize("a_test", &packet_type_,
|
||||
/*back_edge=*/false));
|
||||
input_stream_manager_->PrepareForRun();
|
||||
input_stream_manager_->SetQueueSizeCallbacks(queue_full_callback_,
|
||||
queue_not_full_callback_);
|
||||
@@ -798,12 +797,9 @@ TEST_F(InputStreamManagerTest, InputReleaseTest) {
|
||||
};
|
||||
|
||||
input_stream_manager_->SetMaxQueueSize(3);
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets({new_packet()}, ¬ify_));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets({new_packet()}, ¬ify_));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets({new_packet()}, ¬ify_));
|
||||
MP_ASSERT_OK(input_stream_manager_->AddPackets({new_packet()}, ¬ify_));
|
||||
MP_ASSERT_OK(input_stream_manager_->AddPackets({new_packet()}, ¬ify_));
|
||||
MP_ASSERT_OK(input_stream_manager_->AddPackets({new_packet()}, ¬ify_));
|
||||
EXPECT_EQ(3, tracker.live_count());
|
||||
|
||||
popped_packet_ = input_stream_manager_->PopPacketAtTimestamp(
|
||||
@@ -843,7 +839,7 @@ TEST_F(InputStreamManagerTest, AddPacketsAfterPreStreamUntimed) {
|
||||
packets.push_back(MakePacket<std::string>("packet 2").At(Timestamp(10)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -859,7 +855,7 @@ TEST_F(InputStreamManagerTest, AddPacketsBeforePostStreamUntimed) {
|
||||
MakePacket<std::string>("packet 2").At(Timestamp::PostStream()));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
@@ -872,18 +868,18 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) {
|
||||
packets.push_back(MakePacket<std::string>("packet 2").At(Timestamp(20)));
|
||||
EXPECT_TRUE(input_stream_manager_->IsEmpty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_FALSE(input_stream_manager_->IsEmpty());
|
||||
EXPECT_TRUE(notify_);
|
||||
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(50), ¬ify_)); // No notification
|
||||
EXPECT_FALSE(notify_);
|
||||
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(
|
||||
Timestamp(40), ¬ify_)); // Set Timestamp bound backwards in time
|
||||
EXPECT_FALSE(notify_);
|
||||
|
||||
@@ -891,7 +887,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) {
|
||||
packets.push_back(MakePacket<std::string>("packet 3")
|
||||
.At(Timestamp(30))); // Backwards in time
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // No notification
|
||||
// Notification isn't triggered since the queue is already non-empty.
|
||||
EXPECT_FALSE(notify_);
|
||||
@@ -909,7 +905,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) {
|
||||
packets.push_back(MakePacket<std::string>("packet 4").At(Timestamp(110)));
|
||||
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_TRUE(notify_);
|
||||
|
||||
@@ -921,7 +917,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) {
|
||||
.At(Timestamp(130))); // Backwards in time
|
||||
|
||||
notify_ = false;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification
|
||||
EXPECT_TRUE(notify_);
|
||||
}
|
||||
|
||||
@@ -53,8 +53,7 @@ class OutputStreamManagerTest : public ::testing::Test {
|
||||
std::placeholders::_1, std::placeholders::_2);
|
||||
|
||||
output_stream_manager_ = absl::make_unique<OutputStreamManager>();
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
output_stream_manager_->Initialize("a_test", &packet_type_));
|
||||
MP_ASSERT_OK(output_stream_manager_->Initialize("a_test", &packet_type_));
|
||||
output_stream_manager_->PrepareForRun(error_callback_);
|
||||
output_stream_shard_.SetSpec(output_stream_manager_->Spec());
|
||||
output_stream_manager_->ResetShard(&output_stream_shard_);
|
||||
@@ -68,10 +67,9 @@ class OutputStreamManagerTest : public ::testing::Test {
|
||||
input_stream_handler_ = std::move(status_or_handler.ValueOrDie());
|
||||
const CollectionItemId& id = tag_map->BeginId();
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_manager_.Initialize("a_test",
|
||||
&packet_type_,
|
||||
/*back_edge=*/false));
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers(
|
||||
MP_ASSERT_OK(input_stream_manager_.Initialize("a_test", &packet_type_,
|
||||
/*back_edge=*/false));
|
||||
MP_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers(
|
||||
&input_stream_manager_));
|
||||
output_stream_manager_->AddMirror(input_stream_handler_.get(), id);
|
||||
input_stream_handler_->PrepareForRun(headers_ready_callback_,
|
||||
@@ -695,7 +693,7 @@ TEST_F(OutputStreamManagerTest, AddPacketAndMovePacket) {
|
||||
output_stream_shard_.AddPacket(packet_1);
|
||||
// packet_1 has an extra copy in the output stream.
|
||||
ASSERT_FALSE(packet_1.IsEmpty());
|
||||
MEDIAPIPE_ASSERT_OK(packet_1.ValidateAsType<std::string>());
|
||||
MP_ASSERT_OK(packet_1.ValidateAsType<std::string>());
|
||||
EXPECT_EQ("packet 1", packet_1.Get<std::string>());
|
||||
|
||||
Packet packet_2 = MakePacket<std::string>("packet 2").At(Timestamp(20));
|
||||
|
||||
@@ -130,7 +130,7 @@ class Packet {
|
||||
// // use an adaptor which returns void.
|
||||
// ASSIGN_OR_RETURN(auto detection, p.ConsumeOrCopy<Detection>(),
|
||||
// _.With([](const ::mediapipe::Status& status) {
|
||||
// EXPECT_OK(status);
|
||||
// MP_EXPECT_OK(status);
|
||||
// // Use CHECK_OK to crash and report a usable line
|
||||
// // number (which the ValueOrDie alternative does not).
|
||||
// // Include a return statement if the return value is
|
||||
@@ -495,7 +495,7 @@ inline Packet& Packet::operator=(const Packet& packet) {
|
||||
template <typename T>
|
||||
inline ::mediapipe::StatusOr<std::unique_ptr<T>> Packet::Consume() {
|
||||
// If type validation fails, returns error.
|
||||
RETURN_IF_ERROR(ValidateAsType<T>());
|
||||
MP_RETURN_IF_ERROR(ValidateAsType<T>());
|
||||
// Clients who use this function are responsible for ensuring that no
|
||||
// other thread is doing anything with this Packet.
|
||||
if (holder_.unique()) {
|
||||
@@ -518,7 +518,7 @@ template <typename T>
|
||||
inline ::mediapipe::StatusOr<std::unique_ptr<T>> Packet::ConsumeOrCopy(
|
||||
bool* was_copied,
|
||||
typename std::enable_if<!std::is_array<T>::value>::type*) {
|
||||
RETURN_IF_ERROR(ValidateAsType<T>());
|
||||
MP_RETURN_IF_ERROR(ValidateAsType<T>());
|
||||
// If holder is the sole owner of the underlying data, consumes this packet.
|
||||
if (!holder_->HolderIsOfType<packet_internal::ForeignHolder<T>>() &&
|
||||
holder_.unique()) {
|
||||
@@ -549,7 +549,7 @@ inline ::mediapipe::StatusOr<std::unique_ptr<T>> Packet::ConsumeOrCopy(
|
||||
bool* was_copied,
|
||||
typename std::enable_if<std::is_array<T>::value &&
|
||||
std::extent<T>::value != 0>::type*) {
|
||||
RETURN_IF_ERROR(ValidateAsType<T>());
|
||||
MP_RETURN_IF_ERROR(ValidateAsType<T>());
|
||||
// If holder is the sole owner of the underlying data, consumes this packet.
|
||||
if (!holder_->HolderIsOfType<packet_internal::ForeignHolder<T>>() &&
|
||||
holder_.unique()) {
|
||||
|
||||
@@ -102,14 +102,14 @@ namespace {
|
||||
internal::StaticAccessToGeneratorRegistry::CreateByNameInNamespace(
|
||||
validated_graph.Package(), generator_name),
|
||||
_ << generator_name << " is not a valid PacketGenerator.");
|
||||
RETURN_IF_ERROR(static_access->Generate(generator_config.options(),
|
||||
input_side_packet_set,
|
||||
output_side_packet_set))
|
||||
MP_RETURN_IF_ERROR(static_access->Generate(generator_config.options(),
|
||||
input_side_packet_set,
|
||||
output_side_packet_set))
|
||||
.SetPrepend()
|
||||
<< generator_name << "::Generate() failed. ";
|
||||
|
||||
RETURN_IF_ERROR(ValidatePacketSet(node_type_info.OutputSidePacketTypes(),
|
||||
*output_side_packet_set))
|
||||
MP_RETURN_IF_ERROR(ValidatePacketSet(node_type_info.OutputSidePacketTypes(),
|
||||
*output_side_packet_set))
|
||||
.SetPrepend()
|
||||
<< generator_name
|
||||
<< "::Generate() output packets were of incorrect type: ";
|
||||
@@ -364,7 +364,8 @@ PacketGeneratorGraph::~PacketGeneratorGraph() {}
|
||||
validated_graph_ = validated_graph;
|
||||
executor_ = executor;
|
||||
base_packets_ = input_side_packets;
|
||||
RETURN_IF_ERROR(validated_graph_->CanAcceptSidePackets(input_side_packets));
|
||||
MP_RETURN_IF_ERROR(
|
||||
validated_graph_->CanAcceptSidePackets(input_side_packets));
|
||||
return ExecuteGenerators(&base_packets_, &non_base_generators_,
|
||||
/*initial=*/true);
|
||||
}
|
||||
@@ -383,12 +384,13 @@ PacketGeneratorGraph::~PacketGeneratorGraph() {}
|
||||
}
|
||||
std::vector<int> non_scheduled_generators;
|
||||
|
||||
RETURN_IF_ERROR(validated_graph_->CanAcceptSidePackets(input_side_packets));
|
||||
MP_RETURN_IF_ERROR(
|
||||
validated_graph_->CanAcceptSidePackets(input_side_packets));
|
||||
// This type check on the required side packets is redundant with
|
||||
// error checking in ExecuteGenerators, but we do it now to fail early.
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
validated_graph_->ValidateRequiredSidePackets(*output_side_packets));
|
||||
RETURN_IF_ERROR(ExecuteGenerators(
|
||||
MP_RETURN_IF_ERROR(ExecuteGenerators(
|
||||
output_side_packets, &non_scheduled_generators, /*initial=*/false));
|
||||
RET_CHECK(non_scheduled_generators.empty())
|
||||
<< "Some Generators were unrunnable (validation should have failed).\n"
|
||||
|
||||
@@ -62,7 +62,7 @@ TEST(PacketGeneratorTest, FillExpectationsOnConfig) {
|
||||
config.add_input_side_packet("of_inputs");
|
||||
config.add_output_side_packet("any_number_of");
|
||||
config.add_output_side_packet("output_side_packets");
|
||||
MEDIAPIPE_EXPECT_OK(tool::RunGeneratorFillExpectations(config));
|
||||
MP_EXPECT_OK(tool::RunGeneratorFillExpectations(config));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -86,7 +86,7 @@ TEST(PacketTest, UsesLvalueAndRvalueReferencePacketAtFunctions) {
|
||||
// with the given timestamp.
|
||||
EXPECT_TRUE(packet1.IsEmpty()); // NOLINT used after std::move().
|
||||
ASSERT_FALSE(packet2.IsEmpty());
|
||||
MEDIAPIPE_ASSERT_OK(packet2.ValidateAsType<int>());
|
||||
MP_ASSERT_OK(packet2.ValidateAsType<int>());
|
||||
EXPECT_EQ(0, packet2.Get<int>());
|
||||
EXPECT_EQ(Timestamp(100), packet2.Timestamp());
|
||||
|
||||
@@ -97,8 +97,8 @@ TEST(PacketTest, UsesLvalueAndRvalueReferencePacketAtFunctions) {
|
||||
// has the given timestamp.
|
||||
ASSERT_FALSE(packet3.IsEmpty());
|
||||
ASSERT_FALSE(packet4.IsEmpty());
|
||||
MEDIAPIPE_ASSERT_OK(packet3.ValidateAsType<int>());
|
||||
MEDIAPIPE_ASSERT_OK(packet4.ValidateAsType<int>());
|
||||
MP_ASSERT_OK(packet3.ValidateAsType<int>());
|
||||
MP_ASSERT_OK(packet4.ValidateAsType<int>());
|
||||
EXPECT_EQ(1, packet3.Get<int>());
|
||||
EXPECT_EQ(1, packet4.Get<int>());
|
||||
EXPECT_EQ(Timestamp(), packet3.Timestamp());
|
||||
@@ -111,7 +111,7 @@ TEST(PacketTest, HandlesUniquePtr) {
|
||||
{AdoptAsUniquePtr(static_cast<MyClassBase*>(new MyClass)),
|
||||
AdoptAsUniquePtr<MyClassBase>(new MyClass),
|
||||
Adopt(new std::unique_ptr<MyClassBase>(new MyClass))}) {
|
||||
MEDIAPIPE_EXPECT_OK(packet.ValidateAsType<std::unique_ptr<MyClassBase>>());
|
||||
MP_EXPECT_OK(packet.ValidateAsType<std::unique_ptr<MyClassBase>>());
|
||||
}
|
||||
bool exists = false;
|
||||
Packet packet = AdoptAsUniquePtr<MyClassBase>(new MyClass(&exists));
|
||||
@@ -192,7 +192,7 @@ TEST(PacketTest, ValidateAsProtoMessageLite) {
|
||||
auto proto_ptr = absl::make_unique<::mediapipe::PacketTestProto>();
|
||||
proto_ptr->add_x(123);
|
||||
Packet packet = Adopt(proto_ptr.release());
|
||||
MEDIAPIPE_EXPECT_OK(packet.ValidateAsProtoMessageLite());
|
||||
MP_EXPECT_OK(packet.ValidateAsProtoMessageLite());
|
||||
Packet packet2 = MakePacket<int>(3);
|
||||
::mediapipe::Status status = packet2.ValidateAsProtoMessageLite();
|
||||
EXPECT_EQ(status.code(), ::mediapipe::StatusCode::kInvalidArgument);
|
||||
|
||||
@@ -277,7 +277,6 @@ cc_library(
|
||||
copts = select({
|
||||
"//conditions:default": [],
|
||||
"//mediapipe:apple": [
|
||||
"-std=c++11",
|
||||
"-ObjC++",
|
||||
],
|
||||
"//mediapipe:macos": [],
|
||||
|
||||
@@ -224,7 +224,7 @@ void GraphProfiler::Reset() {
|
||||
Pause();
|
||||
// If specified, write a final profile.
|
||||
if (IsTraceLogEnabled(profiler_config_)) {
|
||||
RETURN_IF_ERROR(WriteProfile());
|
||||
MP_RETURN_IF_ERROR(WriteProfile());
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class GraphProfilerTestPeer : public testing::Test {
|
||||
|
||||
std::vector<CalculatorProfile> Profiles() {
|
||||
std::vector<CalculatorProfile> result;
|
||||
MEDIAPIPE_EXPECT_OK(profiler_.GetCalculatorProfiles(&result));
|
||||
MP_EXPECT_OK(profiler_.GetCalculatorProfiles(&result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1078,28 +1078,28 @@ TEST(GraphProfilerTest, ParallelReads) {
|
||||
absl::Mutex out_1_mutex;
|
||||
std::vector<Packet> out_1_packets;
|
||||
CalculatorGraph graph;
|
||||
ASSERT_OK(graph.Initialize(config));
|
||||
ASSERT_OK(graph.ObserveOutputStream("out_1", [&](const Packet& packet) {
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.ObserveOutputStream("out_1", [&](const Packet& packet) {
|
||||
absl::MutexLock lock(&out_1_mutex);
|
||||
out_1_packets.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MEDIAPIPE_EXPECT_OK(graph.StartRun(
|
||||
MP_EXPECT_OK(graph.StartRun(
|
||||
{{"range_step", MakePacket<std::pair<uint32, uint32>>(1000, 1)}}));
|
||||
|
||||
// Repeatedly poll for profile data while the graph runs.
|
||||
while (true) {
|
||||
std::vector<CalculatorProfile> profiles;
|
||||
ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles));
|
||||
MP_ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles));
|
||||
EXPECT_EQ(2, profiles.size());
|
||||
absl::MutexLock lock(&out_1_mutex);
|
||||
if (out_1_packets.size() >= 1001) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
std::vector<CalculatorProfile> profiles;
|
||||
ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles));
|
||||
MP_ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles));
|
||||
// GraphProfiler internally uses map and the profile order is not fixed.
|
||||
if (profiles[0].name() == "RangeCalculator") {
|
||||
EXPECT_EQ(1000, profiles[0].process_runtime().count(0));
|
||||
|
||||
@@ -413,7 +413,7 @@ class GraphTracerE2ETest : public ::testing::Test {
|
||||
simulation_clock_->ThreadStart();
|
||||
clock_->SleepUntil(StartTime());
|
||||
simulation_clock_->ThreadFinish();
|
||||
MEDIAPIPE_ASSERT_OK(graph_.SetExecutor("", executor));
|
||||
MP_ASSERT_OK(graph_.SetExecutor("", executor));
|
||||
}
|
||||
|
||||
void SetUpRealClock() { clock_ = ::mediapipe::Clock::RealClock(); }
|
||||
@@ -490,31 +490,30 @@ class GraphTracerE2ETest : public ::testing::Test {
|
||||
};
|
||||
|
||||
// Start the graph with the callbacks.
|
||||
MEDIAPIPE_ASSERT_OK(graph_.Initialize(
|
||||
graph_config_, {
|
||||
{"callback_0", Adopt(new auto(wait_0))},
|
||||
}));
|
||||
MP_ASSERT_OK(graph_.Initialize(graph_config_,
|
||||
{
|
||||
{"callback_0", Adopt(new auto(wait_0))},
|
||||
}));
|
||||
graph_.profiler()->SetClock(simulation_clock_);
|
||||
std::vector<Packet> out_packets;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph_.ObserveOutputStream("output_0", [&](const Packet& packet) {
|
||||
out_packets.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
simulation_clock_->ThreadStart();
|
||||
MEDIAPIPE_ASSERT_OK(graph_.StartRun({}));
|
||||
MP_ASSERT_OK(graph_.StartRun({}));
|
||||
|
||||
// The first 6 packets to send into the graph at 5001 us intervals.
|
||||
for (int ts = 10000; ts < 70000; ts += 10000) {
|
||||
clock_->Sleep(absl::Microseconds(5001));
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
graph_.AddPacketToInputStream("input_0", PacketAt(ts)));
|
||||
MP_EXPECT_OK(graph_.AddPacketToInputStream("input_0", PacketAt(ts)));
|
||||
}
|
||||
|
||||
// Wait for all packets to be processed.
|
||||
MEDIAPIPE_ASSERT_OK(graph_.CloseAllPacketSources());
|
||||
MP_ASSERT_OK(graph_.CloseAllPacketSources());
|
||||
clock_->Sleep(absl::Microseconds(240000 + 0));
|
||||
MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph_.WaitUntilDone());
|
||||
simulation_clock_->ThreadFinish();
|
||||
|
||||
// Validate the graph run.
|
||||
@@ -557,26 +556,26 @@ class GraphTracerE2ETest : public ::testing::Test {
|
||||
}
|
||||
|
||||
// Start the graph with the callbacks.
|
||||
MEDIAPIPE_ASSERT_OK(graph_.Initialize(
|
||||
graph_config_, {
|
||||
{"max_in_flight", MakePacket<int>(4)},
|
||||
{"callback_0", Adopt(new auto(wait_0))},
|
||||
{"callback_1", Adopt(new auto(wait_1))},
|
||||
{"callback_2", Adopt(new auto(wait_2))},
|
||||
}));
|
||||
MP_ASSERT_OK(graph_.Initialize(graph_config_,
|
||||
{
|
||||
{"max_in_flight", MakePacket<int>(4)},
|
||||
{"callback_0", Adopt(new auto(wait_0))},
|
||||
{"callback_1", Adopt(new auto(wait_1))},
|
||||
{"callback_2", Adopt(new auto(wait_2))},
|
||||
}));
|
||||
graph_.profiler()->SetClock(simulation_clock_);
|
||||
std::vector<Packet> out_packets;
|
||||
MEDIAPIPE_ASSERT_OK(graph_.ObserveOutputStream(
|
||||
"output_packets_0", [&](const Packet& packet) {
|
||||
out_packets.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MP_ASSERT_OK(graph_.ObserveOutputStream("output_packets_0",
|
||||
[&](const Packet& packet) {
|
||||
out_packets.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
simulation_clock_->ThreadStart();
|
||||
MEDIAPIPE_ASSERT_OK(graph_.StartRun({}));
|
||||
MP_ASSERT_OK(graph_.StartRun({}));
|
||||
|
||||
// Wait for all packets to be added and processed.
|
||||
clock_->Sleep(absl::Microseconds(160000 + 0));
|
||||
MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph_.WaitUntilDone());
|
||||
simulation_clock_->ThreadFinish();
|
||||
|
||||
// Validate the graph run.
|
||||
@@ -614,7 +613,7 @@ TEST_F(GraphTracerE2ETest, PassThroughGraphProfile) {
|
||||
graph_config_.mutable_profiler_config()->set_trace_log_disabled(true);
|
||||
RunPassThroughGraph();
|
||||
std::vector<CalculatorProfile> profiles;
|
||||
MEDIAPIPE_EXPECT_OK(graph_.profiler()->GetCalculatorProfiles(&profiles));
|
||||
MP_EXPECT_OK(graph_.profiler()->GetCalculatorProfiles(&profiles));
|
||||
EXPECT_EQ(1, profiles.size());
|
||||
CalculatorProfile expected =
|
||||
::mediapipe::ParseTextProtoOrDie<CalculatorProfile>(R"(
|
||||
@@ -930,7 +929,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLogFile) {
|
||||
graph_config_.mutable_profiler_config()->set_trace_log_interval_usec(-1);
|
||||
RunDemuxInFlightGraph();
|
||||
GraphProfile profile;
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
MP_EXPECT_OK(
|
||||
ReadGraphProfile(absl::StrCat(log_path, 0, ".binarypb"), &profile));
|
||||
EXPECT_EQ(89, profile.graph_trace(0).calculator_trace().size());
|
||||
}
|
||||
@@ -1143,7 +1142,7 @@ TEST_F(GraphTracerE2ETest, LoggingHappensWithDefaultPath) {
|
||||
SetUpDemuxInFlightGraph();
|
||||
graph_config_.mutable_profiler_config()->set_trace_log_disabled(false);
|
||||
RunDemuxInFlightGraph();
|
||||
MEDIAPIPE_EXPECT_OK(mediapipe::file::Exists(log_path));
|
||||
MP_EXPECT_OK(mediapipe::file::Exists(log_path));
|
||||
}
|
||||
|
||||
TEST_F(GraphTracerE2ETest, GpuTaskTrace) {
|
||||
@@ -1279,7 +1278,7 @@ TEST_F(GraphTracerE2ETest, GpuTracing) {
|
||||
&graph_config_));
|
||||
|
||||
// Create the CalculatorGraph with only trace_enabled set.
|
||||
MEDIAPIPE_ASSERT_OK(graph_.Initialize(graph_config_, {}));
|
||||
MP_ASSERT_OK(graph_.Initialize(graph_config_, {}));
|
||||
// Check that GPU profiling is enabled wihout running the graph.
|
||||
// This graph with GlFlatColorCalculator cannot run on desktop.
|
||||
EXPECT_NE(nullptr, graph_.profiler()->CreateGlProfilingHelper());
|
||||
|
||||
@@ -54,7 +54,7 @@ mediapipe_cc_proto_library(
|
||||
name = "default_input_stream_handler_cc_proto",
|
||||
srcs = ["default_input_stream_handler.proto"],
|
||||
cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":default_input_stream_handler_proto"],
|
||||
)
|
||||
|
||||
@@ -62,7 +62,7 @@ mediapipe_cc_proto_library(
|
||||
name = "fixed_size_input_stream_handler_cc_proto",
|
||||
srcs = ["fixed_size_input_stream_handler.proto"],
|
||||
cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":fixed_size_input_stream_handler_proto"],
|
||||
)
|
||||
|
||||
@@ -70,7 +70,7 @@ mediapipe_cc_proto_library(
|
||||
name = "sync_set_input_stream_handler_cc_proto",
|
||||
srcs = ["sync_set_input_stream_handler.proto"],
|
||||
cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":sync_set_input_stream_handler_proto"],
|
||||
)
|
||||
|
||||
@@ -78,7 +78,7 @@ mediapipe_cc_proto_library(
|
||||
name = "timestamp_align_input_stream_handler_cc_proto",
|
||||
srcs = ["timestamp_align_input_stream_handler.proto"],
|
||||
cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":timestamp_align_input_stream_handler_proto"],
|
||||
)
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class BarrierInputStreamHandlerTest : public ::testing::Test {
|
||||
id < input_tag_map->EndId(); ++id) {
|
||||
const std::string& stream_name = names[id.value()];
|
||||
name_to_id_[stream_name] = id;
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_managers_[id.value()].Initialize(
|
||||
MP_ASSERT_OK(input_stream_managers_[id.value()].Initialize(
|
||||
stream_name, &packet_type_, /*back_edge=*/false));
|
||||
}
|
||||
SetupInputStreamHandler(input_tag_map);
|
||||
@@ -89,9 +89,9 @@ class BarrierInputStreamHandlerTest : public ::testing::Test {
|
||||
/*calculator_run_in_parallel=*/false);
|
||||
ASSERT_TRUE(status_or_handler.ok());
|
||||
input_stream_handler_ = std::move(status_or_handler.ValueOrDie());
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers(
|
||||
MP_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers(
|
||||
input_stream_managers_.get()));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
calculator_context_manager_.PrepareForRun(setup_shards_callback_));
|
||||
input_stream_handler_->PrepareForRun(headers_ready_callback_,
|
||||
notification_callback_,
|
||||
|
||||
@@ -53,34 +53,34 @@ TEST(DefaultInputStreamHandlerTest, NoBatchingWorks) {
|
||||
tool::AddVectorSink("output1", &config, &sink_1);
|
||||
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(1)).At(Timestamp(1))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// No packets expected as the second stream is not ready to be processed.
|
||||
EXPECT_EQ(0, sink_0.size());
|
||||
EXPECT_EQ(0, sink_1.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input1", Adopt(new int(2)).At(Timestamp(2))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// First stream can produce output because the timestamp bound of the second
|
||||
// stream is higher.
|
||||
EXPECT_EQ(1, sink_0.size());
|
||||
EXPECT_EQ(0, sink_1.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(2)).At(Timestamp(2))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// Both streams have packets at the same timestamp, therefore both can produce
|
||||
// packets.
|
||||
EXPECT_EQ(2, sink_0.size());
|
||||
EXPECT_EQ(1, sink_1.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
|
||||
// This test shows the effect of batching on the DefaultInputStreamHandler.
|
||||
@@ -107,43 +107,43 @@ TEST(DefaultInputStreamHandlerTest, Batches) {
|
||||
tool::AddVectorSink("output0", &config, &sink);
|
||||
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(1)).At(Timestamp(1))));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// There shouldn't be any outputs until a set of two packets is batched.
|
||||
EXPECT_TRUE(sink.empty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(2)).At(Timestamp(2))));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// There should be two packets, processed during a single invocation.
|
||||
ASSERT_EQ(2, sink.size());
|
||||
EXPECT_THAT(std::vector<int>({sink[0].Get<int>(), sink[1].Get<int>()}),
|
||||
testing::ElementsAre(1, 2));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(3)).At(Timestamp(3))));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// There shouldn't be any outputs until another set of two packets is batched.
|
||||
EXPECT_EQ(2, sink.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(4)).At(Timestamp(4))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// The new batch was complete. There should be two more output packets.
|
||||
ASSERT_EQ(4, sink.size());
|
||||
EXPECT_THAT(std::vector<int>({sink[0].Get<int>(), sink[1].Get<int>(),
|
||||
sink[2].Get<int>(), sink[3].Get<int>()}),
|
||||
testing::ElementsAre(1, 2, 3, 4));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
|
||||
// This test shows that any packets get flushed (outputted) when the input
|
||||
@@ -171,32 +171,32 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) {
|
||||
tool::AddVectorSink("output0", &config, &sink);
|
||||
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(1)).At(Timestamp(1))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// There shouldn't be any outputs until a set of two packets is batched.
|
||||
EXPECT_TRUE(sink.empty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(2)).At(Timestamp(2))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// There should be two packets, processed during a single invocation.
|
||||
ASSERT_EQ(2, sink.size());
|
||||
EXPECT_THAT(std::vector<int>({sink[0].Get<int>(), sink[1].Get<int>()}),
|
||||
testing::ElementsAre(1, 2));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(3)).At(Timestamp(3))));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// There shouldn't be any outputs until another set of two packets is batched.
|
||||
EXPECT_EQ(2, sink.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
|
||||
// When the streams are done, the packets currently being batched should be
|
||||
// flushed out.
|
||||
@@ -237,45 +237,45 @@ TEST(DefaultInputStreamHandlerTest, DoesntPropagateTimestampWhenBatching) {
|
||||
std::vector<Packet> sink;
|
||||
tool::AddVectorSink("output", &config, &sink);
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(0)).At(Timestamp(0))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
EXPECT_TRUE(sink.empty());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(1)).At(Timestamp(1))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input1", Adopt(new int(1)).At(Timestamp(1))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// Both calculators have packet 1. First node is currently batching and it
|
||||
// propagates the first input timestamp in the batch. Therefore, the
|
||||
// second node should produce output for the packet at 0.
|
||||
EXPECT_EQ(1, sink.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(2)).At(Timestamp(2))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input1", Adopt(new int(2)).At(Timestamp(2))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// Due to batching on the first node, timestamp is not propagated for the
|
||||
// packet at timestamp 2. Therefore, the second node cannot process the packet
|
||||
// at timestamp 1.
|
||||
EXPECT_EQ(1, sink.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input0", Adopt(new int(3)).At(Timestamp(3))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input1", Adopt(new int(3)).At(Timestamp(3))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// Batching is complete on the first node. It produced outputs at timestamp 1,
|
||||
// 2, and 3. The first node can now process the input packets at timestamps 1,
|
||||
// 2, and 3 as well.
|
||||
EXPECT_EQ(4, sink.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
EXPECT_EQ(4, sink.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,8 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPackets) {
|
||||
std::vector<Packet> output_packets;
|
||||
tool::AddVectorSink("output_packets", &graph_config, &output_packets);
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.Run());
|
||||
MP_ASSERT_OK(graph.Initialize(graph_config));
|
||||
MP_ASSERT_OK(graph.Run());
|
||||
|
||||
// The TestSlowCalculator consumes one packet after every tenth packet
|
||||
// is sent. All other packets are dropped by the FixedSizeInputStreamHandler.
|
||||
@@ -209,10 +209,10 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPacketsInFullStream) {
|
||||
std::vector<Packet> output_packets;
|
||||
tool::AddVectorSink("output_packets", &graph_config, &output_packets);
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.Initialize(graph_config, {{"max_count", MakePacket<int>(10)},
|
||||
{"batch_size", MakePacket<int>(10)}}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.Run());
|
||||
MP_ASSERT_OK(graph.Run());
|
||||
}
|
||||
|
||||
// Tests FixedSizeInputStreamHandler with several input streams running
|
||||
@@ -249,8 +249,8 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
&output_packets[i]);
|
||||
}
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
{
|
||||
::mediapipe::ThreadPool pool(3);
|
||||
@@ -262,15 +262,15 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
std::string stream_name = absl::StrCat("in_", w);
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
Packet p = MakePacket<int>(i).At(Timestamp(i));
|
||||
MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p));
|
||||
MP_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p));
|
||||
absl::SleepFor(absl::Microseconds(100));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
EXPECT_EQ(output_packets[i].size(), output_packets[0].size());
|
||||
for (int j = 0; j < output_packets[i].size(); j++) {
|
||||
@@ -320,27 +320,27 @@ TEST_P(FixedSizeInputStreamHandlerTest, LateArrivalDrop) {
|
||||
&output_packets[i]);
|
||||
}
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
MP_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
in_streams[0], MakePacket<int>(i).At(Timestamp(i))));
|
||||
}
|
||||
for (int i = 3; i <= 7; i++) {
|
||||
MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
MP_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
in_streams[1], MakePacket<int>(i).At(Timestamp(i))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
}
|
||||
// At this point everything before ts 5 should be dropped.
|
||||
for (int i = 4; i <= 7; i++) {
|
||||
MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
MP_EXPECT_OK(graph.AddPacketToInputStream(
|
||||
in_streams[2], MakePacket<int>(i).At(Timestamp(i))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
}
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
|
||||
if (GetParam()) {
|
||||
EXPECT_THAT(TimestampValues(output_packets[0]),
|
||||
|
||||
@@ -89,9 +89,9 @@ class ImmediateInputStreamHandlerTest : public ::testing::Test {
|
||||
/*calculator_run_in_parallel=*/false);
|
||||
ASSERT_TRUE(status_or_handler.ok());
|
||||
input_stream_handler_ = std::move(status_or_handler.ValueOrDie());
|
||||
MEDIAPIPE_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers(
|
||||
MP_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers(
|
||||
input_stream_managers_.get()));
|
||||
MEDIAPIPE_ASSERT_OK(cc_manager_.PrepareForRun(setup_shards_callback_));
|
||||
MP_ASSERT_OK(cc_manager_.PrepareForRun(setup_shards_callback_));
|
||||
input_stream_handler_->PrepareForRun(headers_ready_callback_,
|
||||
notification_callback_,
|
||||
schedule_callback_, error_callback_);
|
||||
|
||||
@@ -77,14 +77,14 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
|
||||
input_stream_handler { input_stream_handler: "MuxInputStreamHandler" }
|
||||
})");
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
for (int i = 0; i < 2000; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input", Adopt(new int(i)).At(Timestamp(i))));
|
||||
}
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -84,14 +84,14 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) {
|
||||
# MuxInputStreamHandler set in GetContract().
|
||||
})");
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
for (int i = 0; i < 2000; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input", Adopt(new int(i)).At(Timestamp(i))));
|
||||
}
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
|
||||
// Copied from pass_through_calculator.cc, and modified to specify
|
||||
@@ -218,8 +218,8 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
&output_packets[i]);
|
||||
}
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(graph_config, {}));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
{
|
||||
::mediapipe::ThreadPool pool(NUM_STREAMS);
|
||||
@@ -231,15 +231,15 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) {
|
||||
std::string stream_name = absl::StrCat("in_", w);
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
Packet p = MakePacket<int>(i).At(Timestamp(i));
|
||||
MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p));
|
||||
MP_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p));
|
||||
absl::SleepFor(absl::Microseconds(100));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
for (int i = 0; i < NUM_STREAMS; ++i) {
|
||||
EXPECT_EQ(output_packets[i].size(), output_packets[0].size());
|
||||
for (int j = 0; j < output_packets[i].size(); j++) {
|
||||
|
||||
@@ -266,16 +266,16 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) {
|
||||
VLOG(2) << "Modified configuration: " << modified_config.DebugString();
|
||||
|
||||
// Setup and run the graph.
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(
|
||||
MP_ASSERT_OK(graph.Initialize(
|
||||
modified_config,
|
||||
{{"lambda", MakePacket<ProcessFunction>(InputsToDebugString)}}));
|
||||
std::deque<Packet> outputs;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.ObserveOutputStream("output", [&outputs](const Packet& packet) {
|
||||
outputs.push_back(packet);
|
||||
return ::mediapipe::OkStatus();
|
||||
}));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
for (int command_index = 0; command_index < shuffled_commands.size();
|
||||
/* command_index is incremented by the inner loop. */) {
|
||||
int initial_command_index = command_index;
|
||||
@@ -295,14 +295,14 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) {
|
||||
VLOG(1) << "Adding (" << stream_name << ", Timestamp: " << timestamp
|
||||
<< ")";
|
||||
if (timestamp == Timestamp::Done()) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream(stream_name));
|
||||
MP_ASSERT_OK(graph.CloseInputStream(stream_name));
|
||||
} else {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
stream_name, MakePacket<int>(0).At(timestamp)));
|
||||
}
|
||||
}
|
||||
// Ensure that we produce all packets which we can.
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
|
||||
// Check the output strings (ignoring order, since calculator may
|
||||
// have run in parallel).
|
||||
@@ -319,7 +319,7 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) {
|
||||
EXPECT_THAT(actual_strings,
|
||||
testing::UnorderedElementsAreArray(expected_strings));
|
||||
}
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,38 +49,38 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
|
||||
tool::AddVectorSink("output_camera", &config, &sink_camera);
|
||||
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_camera", Adopt(new int(1)).At(Timestamp(101))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// The timestamp base stream's packet is output immediately.
|
||||
EXPECT_EQ(0, sink_video.size());
|
||||
ASSERT_EQ(1, sink_camera.size());
|
||||
EXPECT_EQ(1, sink_camera[0].Get<int>());
|
||||
EXPECT_EQ(Timestamp(101), sink_camera[0].Timestamp());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_camera", Adopt(new int(2)).At(Timestamp(102))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// The timestamp base stream's packet is output immediately.
|
||||
EXPECT_EQ(0, sink_video.size());
|
||||
ASSERT_EQ(2, sink_camera.size());
|
||||
EXPECT_EQ(2, sink_camera[1].Get<int>());
|
||||
EXPECT_EQ(Timestamp(102), sink_camera[1].Timestamp());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_video", Adopt(new int(1)).At(Timestamp(1))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// No packet is output. The packet added to input_video is buffered in the
|
||||
// input stream.
|
||||
EXPECT_EQ(0, sink_video.size());
|
||||
EXPECT_EQ(2, sink_camera.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_camera", Adopt(new int(3)).At(Timestamp(103))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// Both input streams have a packet. The following equivalence of timestamps
|
||||
// is established:
|
||||
// input_video input_camera
|
||||
@@ -96,23 +96,23 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) {
|
||||
EXPECT_EQ(3, sink_camera[2].Get<int>());
|
||||
EXPECT_EQ(Timestamp(103), sink_camera[2].Timestamp());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_camera", Adopt(new int(4)).At(Timestamp(104))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// The timestamp base stream does not receive special treatment now.
|
||||
EXPECT_EQ(1, sink_video.size());
|
||||
EXPECT_EQ(3, sink_camera.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_video", Adopt(new int(4)).At(Timestamp(4))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
EXPECT_EQ(1, sink_video.size());
|
||||
ASSERT_EQ(4, sink_camera.size());
|
||||
EXPECT_EQ(4, sink_camera[3].Get<int>());
|
||||
EXPECT_EQ(Timestamp(104), sink_camera[3].Timestamp());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
ASSERT_EQ(2, sink_video.size());
|
||||
EXPECT_EQ(4, sink_camera.size());
|
||||
EXPECT_EQ(4, sink_video[1].Get<int>());
|
||||
@@ -145,21 +145,21 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) {
|
||||
tool::AddVectorSink("output_camera", &config, &sink_camera);
|
||||
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
// Video timestamps start from 0 seconds. Video frame rate is 2 fps.
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_video", Adopt(new int(0)).At(Timestamp(0))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// No packets expected as the timestamp base stream has not seen any packet.
|
||||
EXPECT_EQ(0, sink_video.size());
|
||||
EXPECT_EQ(0, sink_camera.size());
|
||||
|
||||
// Camera timestamps start from 100 seconds. Camera frame rate is 1 fps.
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_camera", Adopt(new int(0)).At(Timestamp(100000000))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
// Both input streams have a packet. The following equivalence of timestamps
|
||||
// is established:
|
||||
// input_video input_camera
|
||||
@@ -171,17 +171,17 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) {
|
||||
EXPECT_EQ(0, sink_camera[0].Get<int>());
|
||||
EXPECT_EQ(Timestamp(100000000), sink_camera[0].Timestamp());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_video", Adopt(new int(1)).At(Timestamp(500000))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
EXPECT_EQ(1, sink_video.size());
|
||||
EXPECT_EQ(1, sink_camera.size());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_video", Adopt(new int(2)).At(Timestamp(1000000))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_camera", Adopt(new int(1)).At(Timestamp(101000000))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
ASSERT_EQ(3, sink_video.size());
|
||||
ASSERT_EQ(3, sink_camera.size());
|
||||
EXPECT_EQ(1, sink_video[1].Get<int>());
|
||||
@@ -193,8 +193,8 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) {
|
||||
EXPECT_EQ(1, sink_camera[2].Get<int>());
|
||||
EXPECT_EQ(Timestamp(101000000), sink_camera[2].Timestamp());
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
ASSERT_EQ(3, sink_video.size());
|
||||
ASSERT_EQ(3, sink_camera.size());
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ TemplateSubgraph::~TemplateSubgraph() {}
|
||||
options.GetExtension(TemplateSubgraphOptions::ext).dict();
|
||||
tool::TemplateExpander expander;
|
||||
CalculatorGraphConfig config;
|
||||
RETURN_IF_ERROR(expander.ExpandTemplates(arguments, templ_, &config));
|
||||
MP_RETURN_IF_ERROR(expander.ExpandTemplates(arguments, templ_, &config));
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ bool GraphRegistry::IsRegistered(const std::string& ns,
|
||||
local_factories_.IsRegistered(ns, type_name)
|
||||
? local_factories_.Invoke(ns, type_name)
|
||||
: global_factories_->Invoke(ns, type_name);
|
||||
RETURN_IF_ERROR(maker.status());
|
||||
MP_RETURN_IF_ERROR(maker.status());
|
||||
return maker.ValueOrDie()->GetConfig(graph_options);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,17 +48,17 @@ class SubgraphTest : public ::testing::Test {
|
||||
tool::AddVectorSink("quads", &config, &quads);
|
||||
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
|
||||
constexpr int kCount = 5;
|
||||
for (int i = 0; i < kCount; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"in", MakePacket<int>(i).At(Timestamp(i))));
|
||||
}
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("in"));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseInputStream("in"));
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
|
||||
EXPECT_EQ(dubs.size(), kCount);
|
||||
EXPECT_EQ(quads.size(), kCount);
|
||||
|
||||
@@ -82,10 +82,7 @@ mediapipe_cc_proto_library(
|
||||
"//mediapipe/framework:calculator_cc_proto",
|
||||
"//mediapipe/framework/deps:proto_descriptor_cc_proto",
|
||||
],
|
||||
visibility = [
|
||||
"//mediapipe/framework:__subpackages__",
|
||||
"//mediapipe/java/com/google/mediapipe/framework:__subpackages__",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":calculator_graph_template_proto"],
|
||||
)
|
||||
|
||||
@@ -93,7 +90,7 @@ mediapipe_cc_proto_library(
|
||||
name = "source_cc_proto",
|
||||
srcs = ["source.proto"],
|
||||
cc_deps = ["//mediapipe/framework:calculator_cc_proto"],
|
||||
visibility = ["//mediapipe/framework:__subpackages__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":source_proto"],
|
||||
)
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST(FillPacketSetTest, Success) {
|
||||
.Set<double>(
|
||||
// double2
|
||||
);
|
||||
MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
|
||||
std::map<std::string, Packet> all_side_packets;
|
||||
all_side_packets["side_packet1"] = MakePacket<int>(70);
|
||||
@@ -87,7 +87,7 @@ TEST(FillPacketSetTest, MissingSidePacketError) {
|
||||
.Set<double>(
|
||||
// double2
|
||||
);
|
||||
MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
|
||||
std::map<std::string, Packet> all_side_packets;
|
||||
all_side_packets["side_packet1"] = MakePacket<int>(70);
|
||||
@@ -125,7 +125,7 @@ TEST(FillPacketSetTest, MissingSidePacketOk) {
|
||||
.Set<double>(
|
||||
// double2
|
||||
);
|
||||
MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
|
||||
std::map<std::string, Packet> all_side_packets;
|
||||
all_side_packets["side_packet1"] = MakePacket<int>(70);
|
||||
@@ -169,7 +169,7 @@ TEST(FillPacketSetTest, WrongSidePacketType) {
|
||||
.Set<double>(
|
||||
// double2
|
||||
);
|
||||
MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types));
|
||||
|
||||
std::map<std::string, Packet> all_side_packets;
|
||||
all_side_packets["side_packet1"] = MakePacket<float>(3.0f); // Wrong Type.
|
||||
|
||||
@@ -72,7 +72,7 @@ bool IsLengthDelimited(WireFormatLite::WireType wire_type) {
|
||||
uint32 fake_tag = WireFormatLite::MakeTag(1, wire_type);
|
||||
while (data_size > 0) {
|
||||
std::string number;
|
||||
RETURN_IF_ERROR(ReadFieldValue(fake_tag, in, &number));
|
||||
MP_RETURN_IF_ERROR(ReadFieldValue(fake_tag, in, &number));
|
||||
RET_CHECK_LE(number.size(), data_size);
|
||||
field_values->push_back(number);
|
||||
data_size -= number.size();
|
||||
@@ -92,10 +92,10 @@ bool IsLengthDelimited(WireFormatLite::WireType wire_type) {
|
||||
if (field_number == field_id) {
|
||||
if (!IsLengthDelimited(wire_type) &&
|
||||
IsLengthDelimited(WireFormatLite::GetTagWireType(tag))) {
|
||||
RETURN_IF_ERROR(ReadPackedValues(wire_type, in, field_values));
|
||||
MP_RETURN_IF_ERROR(ReadPackedValues(wire_type, in, field_values));
|
||||
} else {
|
||||
std::string value;
|
||||
RETURN_IF_ERROR(ReadFieldValue(tag, in, &value));
|
||||
MP_RETURN_IF_ERROR(ReadFieldValue(tag, in, &value));
|
||||
field_values->push_back(value);
|
||||
}
|
||||
} else {
|
||||
@@ -155,12 +155,12 @@ std::vector<FieldValue>* FieldAccess::mutable_field_values() {
|
||||
FieldAccess access(field_id, !proto_path.empty()
|
||||
? WireFormatLite::TYPE_MESSAGE
|
||||
: field_type);
|
||||
RETURN_IF_ERROR(access.SetMessage(*message));
|
||||
MP_RETURN_IF_ERROR(access.SetMessage(*message));
|
||||
std::vector<std::string>& v = *access.mutable_field_values();
|
||||
if (!proto_path.empty()) {
|
||||
RET_CHECK(index >= 0 && index < v.size());
|
||||
RETURN_IF_ERROR(ReplaceFieldRange(&v[index], proto_path, length, field_type,
|
||||
field_values));
|
||||
MP_RETURN_IF_ERROR(ReplaceFieldRange(&v[index], proto_path, length,
|
||||
field_type, field_values));
|
||||
} else {
|
||||
RET_CHECK(index >= 0 && index <= v.size());
|
||||
RET_CHECK(index + length >= 0 && index + length <= v.size());
|
||||
@@ -182,11 +182,11 @@ std::vector<FieldValue>* FieldAccess::mutable_field_values() {
|
||||
FieldAccess access(field_id, !proto_path.empty()
|
||||
? WireFormatLite::TYPE_MESSAGE
|
||||
: field_type);
|
||||
RETURN_IF_ERROR(access.SetMessage(message));
|
||||
MP_RETURN_IF_ERROR(access.SetMessage(message));
|
||||
std::vector<std::string>& v = *access.mutable_field_values();
|
||||
if (!proto_path.empty()) {
|
||||
RET_CHECK(index >= 0 && index < v.size());
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
GetFieldRange(v[index], proto_path, length, field_type, field_values));
|
||||
} else {
|
||||
RET_CHECK(index >= 0 && index <= v.size());
|
||||
@@ -243,7 +243,7 @@ template <typename T>
|
||||
void (*writer)(T, proto_ns::io::CodedOutputStream*),
|
||||
const std::string& text, CodedOutputStream* out) {
|
||||
T value;
|
||||
RETURN_IF_ERROR(ParseValue<T>(text, &value));
|
||||
MP_RETURN_IF_ERROR(ParseValue<T>(text, &value));
|
||||
(*writer)(value, out);
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
@@ -370,7 +370,7 @@ static ::mediapipe::Status DeserializeValue(const FieldValue& bytes,
|
||||
result->reserve(text_values.size());
|
||||
for (const std::string& text_value : text_values) {
|
||||
FieldValue field_value;
|
||||
RETURN_IF_ERROR(SerializeValue(text_value, field_type, &field_value));
|
||||
MP_RETURN_IF_ERROR(SerializeValue(text_value, field_type, &field_value));
|
||||
result->push_back(field_value);
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -383,7 +383,7 @@ static ::mediapipe::Status DeserializeValue(const FieldValue& bytes,
|
||||
result->reserve(field_values.size());
|
||||
for (const FieldValue& field_value : field_values) {
|
||||
std::string text_value;
|
||||
RETURN_IF_ERROR(DeserializeValue(field_value, field_type, &text_value));
|
||||
MP_RETURN_IF_ERROR(DeserializeValue(field_value, field_type, &text_value));
|
||||
result->push_back(text_value);
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
|
||||
@@ -92,7 +92,7 @@ class SimulationClockTest : public ::testing::Test {
|
||||
auto executor = std::make_shared<SimulationClockExecutor>(4);
|
||||
simulation_clock_ = executor->GetClock();
|
||||
clock_ = simulation_clock_.get();
|
||||
MEDIAPIPE_ASSERT_OK(graph_.SetExecutor("", executor));
|
||||
MP_ASSERT_OK(graph_.SetExecutor("", executor));
|
||||
}
|
||||
|
||||
// Initialize the test clock as a RealClock.
|
||||
@@ -213,20 +213,20 @@ TEST_F(SimulationClockTest, InFlight) {
|
||||
SetUpInFlightGraph();
|
||||
std::vector<Packet> out_packets;
|
||||
tool::AddVectorSink("output_packets_0", &graph_config_, &out_packets);
|
||||
MEDIAPIPE_ASSERT_OK(graph_.Initialize(
|
||||
graph_config_, {
|
||||
{"max_in_flight", MakePacket<int>(2)},
|
||||
{"callback_0", Adopt(new auto(wait_0))},
|
||||
{"callback_1", Adopt(new auto(wait_1))},
|
||||
}));
|
||||
MEDIAPIPE_ASSERT_OK(graph_.StartRun({}));
|
||||
MP_ASSERT_OK(graph_.Initialize(graph_config_,
|
||||
{
|
||||
{"max_in_flight", MakePacket<int>(2)},
|
||||
{"callback_0", Adopt(new auto(wait_0))},
|
||||
{"callback_1", Adopt(new auto(wait_1))},
|
||||
}));
|
||||
MP_ASSERT_OK(graph_.StartRun({}));
|
||||
simulation_clock_->ThreadStart();
|
||||
|
||||
// Add 10 input packets to the graph, one each 10 ms, starting after 11 ms
|
||||
// of clock time. Timestamps lag clock times by 1 ms.
|
||||
clock_->Sleep(absl::Microseconds(11000));
|
||||
for (uint64 ts = 10000; ts <= 100000; ts += 10000) {
|
||||
MEDIAPIPE_EXPECT_OK(graph_.AddPacketToInputStream(
|
||||
MP_EXPECT_OK(graph_.AddPacketToInputStream(
|
||||
"input_packets_0", MakePacket<uint64>(ts).At(Timestamp(ts))));
|
||||
clock_->Sleep(absl::Microseconds(10000));
|
||||
}
|
||||
@@ -234,8 +234,8 @@ TEST_F(SimulationClockTest, InFlight) {
|
||||
// Wait for 100 ms of clock time, then close the graph.
|
||||
clock_->Sleep(absl::Microseconds(100000));
|
||||
simulation_clock_->ThreadFinish();
|
||||
MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph_.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph_.WaitUntilDone());
|
||||
|
||||
// Validate the graph run.
|
||||
EXPECT_THAT(TimestampValues(out_packets),
|
||||
|
||||
@@ -58,14 +58,14 @@ TEST(CallbackFromGeneratorTest, TestAddVectorSink) {
|
||||
tool::AddVectorSink("input_packets", &graph_config, &dumped_data);
|
||||
graph_config.add_input_stream("input_packets");
|
||||
CalculatorGraph graph(graph_config);
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_packets", MakePacket<int>(i).At(Timestamp(i))));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle());
|
||||
MP_ASSERT_OK(graph.WaitUntilIdle());
|
||||
}
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_packets"));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_packets"));
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
ASSERT_EQ(10, dumped_data.size());
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
EXPECT_EQ(Timestamp(i), dumped_data[i].Timestamp());
|
||||
@@ -87,18 +87,18 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) {
|
||||
Packet summary_packet;
|
||||
tool::AddSidePacketSink("num_of_packets", &config, &summary_packet);
|
||||
CalculatorGraph graph;
|
||||
MEDIAPIPE_ASSERT_OK(graph.Initialize(config));
|
||||
MP_ASSERT_OK(graph.Initialize(config));
|
||||
|
||||
// Run the graph twice.
|
||||
int max_count = 100;
|
||||
for (int run = 0; run < 1; ++run) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({}));
|
||||
MP_ASSERT_OK(graph.StartRun({}));
|
||||
for (int i = 0; i < max_count; ++i) {
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"input_packets", MakePacket<int>(i).At(Timestamp(i))));
|
||||
}
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_packets"));
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseInputStream("input_packets"));
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
EXPECT_EQ(max_count, summary_packet.Get<int>());
|
||||
EXPECT_EQ(Timestamp::PostStream(), summary_packet.Timestamp());
|
||||
}
|
||||
@@ -124,24 +124,24 @@ TEST(CallbackTest, TestAddMultiStreamCallback) {
|
||||
&graph_config, &cb_packet);
|
||||
|
||||
CalculatorGraph graph(graph_config);
|
||||
MEDIAPIPE_ASSERT_OK(graph.StartRun({cb_packet}));
|
||||
MP_ASSERT_OK(graph.StartRun({cb_packet}));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
MP_ASSERT_OK(graph.AddPacketToInputStream(
|
||||
"foo", MakePacket<int>(10).At(Timestamp(1))));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.AddPacketToInputStream("bar", MakePacket<int>(5).At(Timestamp(1))));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.AddPacketToInputStream("foo", MakePacket<int>(7).At(Timestamp(2))));
|
||||
// no bar input at 2
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.AddPacketToInputStream("foo", MakePacket<int>(4).At(Timestamp(3))));
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
MP_ASSERT_OK(
|
||||
graph.AddPacketToInputStream("bar", MakePacket<int>(5).At(Timestamp(3))));
|
||||
|
||||
MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone());
|
||||
MP_ASSERT_OK(graph.CloseAllInputStreams());
|
||||
MP_ASSERT_OK(graph.WaitUntilDone());
|
||||
|
||||
EXPECT_THAT(sums, testing::ElementsAre(15, 7, 9));
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ TEST(StatusTest, CombinedStatus) {
|
||||
errors.clear();
|
||||
errors.emplace_back(::mediapipe::StatusCode::kOk, "error_with_this_string");
|
||||
errors.emplace_back(::mediapipe::StatusCode::kOk, "error_with_that_string");
|
||||
MEDIAPIPE_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors));
|
||||
MP_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors));
|
||||
|
||||
errors.clear();
|
||||
MEDIAPIPE_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors));
|
||||
MP_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors));
|
||||
}
|
||||
|
||||
// Verify tool::StatusInvalid() and tool::StatusFail() and the alternatives
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace tool {
|
||||
{config->mutable_input_stream(), config->mutable_output_stream(),
|
||||
config->mutable_input_side_packet(),
|
||||
config->mutable_output_side_packet()}) {
|
||||
RETURN_IF_ERROR(TransformStreamNames(streams, transform));
|
||||
MP_RETURN_IF_ERROR(TransformStreamNames(streams, transform));
|
||||
}
|
||||
for (auto& node : *config->mutable_node()) {
|
||||
for (auto* streams :
|
||||
{node.mutable_input_stream(), node.mutable_output_stream(),
|
||||
node.mutable_input_side_packet(),
|
||||
node.mutable_output_side_packet()}) {
|
||||
RETURN_IF_ERROR(TransformStreamNames(streams, transform));
|
||||
MP_RETURN_IF_ERROR(TransformStreamNames(streams, transform));
|
||||
}
|
||||
if (!node.name().empty()) {
|
||||
node.set_name(transform(node.name()));
|
||||
@@ -76,11 +76,11 @@ namespace tool {
|
||||
for (auto& generator : *config->mutable_packet_generator()) {
|
||||
for (auto* streams : {generator.mutable_input_side_packet(),
|
||||
generator.mutable_output_side_packet()}) {
|
||||
RETURN_IF_ERROR(TransformStreamNames(streams, transform));
|
||||
MP_RETURN_IF_ERROR(TransformStreamNames(streams, transform));
|
||||
}
|
||||
}
|
||||
for (auto& status_handler : *config->mutable_status_handler()) {
|
||||
RETURN_IF_ERROR(TransformStreamNames(
|
||||
MP_RETURN_IF_ERROR(TransformStreamNames(
|
||||
status_handler.mutable_input_side_packet(), transform));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -164,28 +164,29 @@ static ::mediapipe::Status PrefixNames(int subgraph_index,
|
||||
const CalculatorGraphConfig::Node& subgraph_node,
|
||||
CalculatorGraphConfig* subgraph_config) {
|
||||
std::map<std::string, std::string> stream_map;
|
||||
RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map,
|
||||
subgraph_config->input_stream(),
|
||||
subgraph_node.input_stream()))
|
||||
MP_RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map,
|
||||
subgraph_config->input_stream(),
|
||||
subgraph_node.input_stream()))
|
||||
.SetPrepend()
|
||||
<< "while processing the input streams of subgraph node "
|
||||
<< subgraph_node.calculator() << ": ";
|
||||
RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map,
|
||||
subgraph_config->output_stream(),
|
||||
subgraph_node.output_stream()))
|
||||
MP_RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map,
|
||||
subgraph_config->output_stream(),
|
||||
subgraph_node.output_stream()))
|
||||
.SetPrepend()
|
||||
<< "while processing the output streams of subgraph node "
|
||||
<< subgraph_node.calculator() << ": ";
|
||||
std::map<std::string, std::string> side_packet_map;
|
||||
RETURN_IF_ERROR(FindCorrespondingStreams(&side_packet_map,
|
||||
subgraph_config->input_side_packet(),
|
||||
subgraph_node.input_side_packet()))
|
||||
MP_RETURN_IF_ERROR(FindCorrespondingStreams(
|
||||
&side_packet_map, subgraph_config->input_side_packet(),
|
||||
subgraph_node.input_side_packet()))
|
||||
.SetPrepend()
|
||||
<< "while processing the input side packets of subgraph node "
|
||||
<< subgraph_node.calculator() << ": ";
|
||||
RETURN_IF_ERROR(FindCorrespondingStreams(
|
||||
&side_packet_map, subgraph_config->output_side_packet(),
|
||||
subgraph_node.output_side_packet()))
|
||||
MP_RETURN_IF_ERROR(
|
||||
FindCorrespondingStreams(&side_packet_map,
|
||||
subgraph_config->output_side_packet(),
|
||||
subgraph_node.output_side_packet()))
|
||||
.SetPrepend()
|
||||
<< "while processing the output side packets of subgraph node "
|
||||
<< subgraph_node.calculator() << ": ";
|
||||
@@ -197,22 +198,22 @@ static ::mediapipe::Status PrefixNames(int subgraph_index,
|
||||
};
|
||||
for (auto& node : *subgraph_config->mutable_node()) {
|
||||
name_map = &stream_map;
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
TransformStreamNames(node.mutable_input_stream(), replace_names));
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
TransformStreamNames(node.mutable_output_stream(), replace_names));
|
||||
name_map = &side_packet_map;
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
TransformStreamNames(node.mutable_input_side_packet(), replace_names));
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
TransformStreamNames(node.mutable_output_side_packet(), replace_names));
|
||||
}
|
||||
name_map = &side_packet_map;
|
||||
for (auto& generator : *subgraph_config->mutable_packet_generator()) {
|
||||
RETURN_IF_ERROR(TransformStreamNames(generator.mutable_input_side_packet(),
|
||||
replace_names));
|
||||
RETURN_IF_ERROR(TransformStreamNames(generator.mutable_output_side_packet(),
|
||||
replace_names));
|
||||
MP_RETURN_IF_ERROR(TransformStreamNames(
|
||||
generator.mutable_input_side_packet(), replace_names));
|
||||
MP_RETURN_IF_ERROR(TransformStreamNames(
|
||||
generator.mutable_output_side_packet(), replace_names));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
@@ -235,12 +236,12 @@ static ::mediapipe::Status PrefixNames(int subgraph_index,
|
||||
std::vector<CalculatorGraphConfig> subgraphs;
|
||||
for (auto it = subgraph_nodes_start; it != nodes->end(); ++it) {
|
||||
const auto& node = *it;
|
||||
RETURN_IF_ERROR(ValidateSubgraphFields(node));
|
||||
MP_RETURN_IF_ERROR(ValidateSubgraphFields(node));
|
||||
ASSIGN_OR_RETURN(auto subgraph, graph_registry->CreateByName(
|
||||
config->package(), node.calculator(),
|
||||
&node.options()));
|
||||
RETURN_IF_ERROR(PrefixNames(subgraph_counter++, &subgraph));
|
||||
RETURN_IF_ERROR(ConnectSubgraphStreams(node, &subgraph));
|
||||
MP_RETURN_IF_ERROR(PrefixNames(subgraph_counter++, &subgraph));
|
||||
MP_RETURN_IF_ERROR(ConnectSubgraphStreams(node, &subgraph));
|
||||
subgraphs.push_back(subgraph);
|
||||
}
|
||||
nodes->erase(subgraph_nodes_start, nodes->end());
|
||||
|
||||
@@ -213,7 +213,7 @@ TEST(SubgraphExpansionTest, TransformStreamNames) {
|
||||
}
|
||||
)");
|
||||
auto add_foo = [](absl::string_view s) { return absl::StrCat(s, "_foo"); };
|
||||
MEDIAPIPE_EXPECT_OK(tool::TransformStreamNames(
|
||||
MP_EXPECT_OK(tool::TransformStreamNames(
|
||||
(*config.mutable_node())[0].mutable_input_stream(), add_foo));
|
||||
EXPECT_THAT(config, mediapipe::EqualsProto(expected_config));
|
||||
}
|
||||
@@ -258,7 +258,7 @@ TEST(SubgraphExpansionTest, TransformNames) {
|
||||
auto add_prefix = [](absl::string_view s) {
|
||||
return absl::StrCat("__sg0_", s);
|
||||
};
|
||||
MEDIAPIPE_EXPECT_OK(tool::TransformNames(&config, add_prefix));
|
||||
MP_EXPECT_OK(tool::TransformNames(&config, add_prefix));
|
||||
EXPECT_THAT(config, mediapipe::EqualsProto(expected_config));
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreams) {
|
||||
}
|
||||
)");
|
||||
std::map<std::string, std::string> stream_map;
|
||||
MEDIAPIPE_EXPECT_OK(tool::FindCorrespondingStreams(
|
||||
MP_EXPECT_OK(tool::FindCorrespondingStreams(
|
||||
&stream_map, config1.input_stream(), config2.node()[0].input_stream()));
|
||||
EXPECT_THAT(stream_map,
|
||||
testing::UnorderedElementsAre(testing::Pair("input_1", "foo"),
|
||||
@@ -416,8 +416,7 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) {
|
||||
output_side_packet: "flop"
|
||||
}
|
||||
)");
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
tool::ConnectSubgraphStreams(supergraph.node()[0], &subgraph));
|
||||
MP_EXPECT_OK(tool::ConnectSubgraphStreams(supergraph.node()[0], &subgraph));
|
||||
EXPECT_THAT(subgraph, mediapipe::EqualsProto(expected_subgraph));
|
||||
}
|
||||
|
||||
@@ -455,7 +454,7 @@ TEST(SubgraphExpansionTest, ExpandSubgraphs) {
|
||||
output_side_packet: "__sg0_side"
|
||||
}
|
||||
)");
|
||||
MEDIAPIPE_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
@@ -521,7 +520,7 @@ TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) {
|
||||
executor: "custom_thread_pool"
|
||||
}
|
||||
)");
|
||||
MEDIAPIPE_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph));
|
||||
EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ void TagMap::InitializeNames(
|
||||
std::string tag;
|
||||
int index;
|
||||
std::string name;
|
||||
RETURN_IF_ERROR(ParseTagIndexName(tag_index_name, &tag, &index, &name));
|
||||
MP_RETURN_IF_ERROR(ParseTagIndexName(tag_index_name, &tag, &index, &name));
|
||||
|
||||
// Get a reference to the tag data (possibly creating it).
|
||||
TagData& tag_data = mapping_[tag];
|
||||
|
||||
@@ -56,7 +56,7 @@ class TagMap {
|
||||
static ::mediapipe::StatusOr<std::shared_ptr<TagMap>> Create(
|
||||
const proto_ns::RepeatedPtrField<ProtoString>& tag_index_names) {
|
||||
std::shared_ptr<TagMap> output(new TagMap());
|
||||
RETURN_IF_ERROR(output->Initialize(tag_index_names));
|
||||
MP_RETURN_IF_ERROR(output->Initialize(tag_index_names));
|
||||
return std::move(output);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class TagMap {
|
||||
static ::mediapipe::StatusOr<std::shared_ptr<TagMap>> Create(
|
||||
const TagAndNameInfo& info) {
|
||||
std::shared_ptr<TagMap> output(new TagMap());
|
||||
RETURN_IF_ERROR(output->Initialize(info));
|
||||
MP_RETURN_IF_ERROR(output->Initialize(info));
|
||||
return std::move(output);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,37 +26,35 @@ namespace {
|
||||
|
||||
TEST(TagMapTest, Create) {
|
||||
// Create using tags.
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMapFromTags({}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH"}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH1", "BLAH2"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMapFromTags({}));
|
||||
MP_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH1", "BLAH2"}));
|
||||
// Tags must be uppercase.
|
||||
EXPECT_FALSE(tool::CreateTagMapFromTags({"blah1", "BLAH2"}).ok());
|
||||
|
||||
// Create with TAG:<index>:names.
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"blah"}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"blah1", "blah2"}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH:blah"}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH1:blah1", "BLAH2:blah2"}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH:0:blah1", "BLAH:1:blah2"}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH:blah1", "BLAH:1:blah2"}));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap(
|
||||
MP_EXPECT_OK(tool::CreateTagMap({}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"blah"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"blah1", "blah2"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"BLAH:blah"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"BLAH1:blah1", "BLAH2:blah2"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"BLAH:0:blah1", "BLAH:1:blah2"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"BLAH:blah1", "BLAH:1:blah2"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap(
|
||||
{"A:2:a2", "B:1:b1", "C:c0", "A:0:a0", "B:b0", "A:1:a1"}));
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
tool::CreateTagMap({"w", "A:2:a2", "x", "B:1:b1", "C:c0", "y", "A:0:a0",
|
||||
"B:b0", "z", "A:1:a1"}));
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
tool::CreateTagMap({"A:2:a2", "w", "x", "B:1:b1", "C:c0", "y", "A:0:a0",
|
||||
"B:b0", "z", "A:1:a1"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"w", "A:2:a2", "x", "B:1:b1", "C:c0", "y",
|
||||
"A:0:a0", "B:b0", "z", "A:1:a1"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"A:2:a2", "w", "x", "B:1:b1", "C:c0", "y",
|
||||
"A:0:a0", "B:b0", "z", "A:1:a1"}));
|
||||
|
||||
// Reuse name.
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"a", "A:a"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"a", "A:a"}));
|
||||
// Reuse name.
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"a", "a"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"a", "a"}));
|
||||
// Reuse name.
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"C:c", "a", "a"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"C:c", "a", "a"}));
|
||||
// Reuse name.
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"A:a", "B:a"}));
|
||||
MP_EXPECT_OK(tool::CreateTagMap({"A:a", "B:a"}));
|
||||
|
||||
// Reuse same tag.
|
||||
EXPECT_FALSE(tool::CreateTagMap({"BLAH:blah1", "BLAH:blah2"}).ok());
|
||||
@@ -71,20 +69,20 @@ TEST(TagMapTest, Create) {
|
||||
tool::CreateTagMap({"blah0", "BLAH:1:blah1", "BLAH:2:blah2"}).ok());
|
||||
|
||||
// Create using an index.
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap(0));
|
||||
MEDIAPIPE_EXPECT_OK(tool::CreateTagMap(3));
|
||||
MP_EXPECT_OK(tool::CreateTagMap(0));
|
||||
MP_EXPECT_OK(tool::CreateTagMap(3));
|
||||
// Negative number of entries.
|
||||
EXPECT_FALSE(tool::CreateTagMap(-1).ok());
|
||||
|
||||
// Create using a TagAndNameInfo.
|
||||
tool::TagAndNameInfo info;
|
||||
info.names = {"blah1", "blah2"};
|
||||
MEDIAPIPE_EXPECT_OK(tool::TagMap::Create(info));
|
||||
MP_EXPECT_OK(tool::TagMap::Create(info));
|
||||
info.tags = {"BLAH1", "BLAH2", "BLAH3"};
|
||||
// Number of tags and names do not match.
|
||||
EXPECT_FALSE(tool::TagMap::Create(info).ok());
|
||||
info.names.push_back("blah3");
|
||||
MEDIAPIPE_EXPECT_OK(tool::TagMap::Create(info));
|
||||
MP_EXPECT_OK(tool::TagMap::Create(info));
|
||||
}
|
||||
|
||||
void TestSuccessTagMap(const std::vector<std::string>& tag_index_names,
|
||||
@@ -296,11 +294,11 @@ TEST(TagMapTest, SameAs) {
|
||||
if (std::get<1>(parameters)) {
|
||||
auto statusor_tag_map =
|
||||
tool::CreateTagMapFromTags(std::get<2>(parameters));
|
||||
MEDIAPIPE_ASSERT_OK(statusor_tag_map);
|
||||
MP_ASSERT_OK(statusor_tag_map);
|
||||
tag_maps.push_back(std::move(statusor_tag_map.ValueOrDie()));
|
||||
} else {
|
||||
auto statusor_tag_map = tool::CreateTagMap(std::get<2>(parameters));
|
||||
MEDIAPIPE_ASSERT_OK(statusor_tag_map);
|
||||
MP_ASSERT_OK(statusor_tag_map);
|
||||
tag_maps.push_back(std::move(statusor_tag_map.ValueOrDie()));
|
||||
}
|
||||
}
|
||||
@@ -327,7 +325,7 @@ void TestDebugString(const ::mediapipe::StatusOr<std::shared_ptr<tool::TagMap>>&
|
||||
statusor_tag_map,
|
||||
const std::vector<std::string>& canonical_entries,
|
||||
Matcher short_string_matcher) {
|
||||
MEDIAPIPE_ASSERT_OK(statusor_tag_map);
|
||||
MP_ASSERT_OK(statusor_tag_map);
|
||||
tool::TagMap& tag_map = *statusor_tag_map.ValueOrDie();
|
||||
std::string debug_string = tag_map.DebugString();
|
||||
std::string short_string = tag_map.ShortDebugString();
|
||||
|
||||
@@ -604,7 +604,8 @@ class TemplateExpanderImpl {
|
||||
? mediapipe::SimpleDtoa(args[i].num())
|
||||
: args[i].str();
|
||||
std::vector<FieldValue> r;
|
||||
RETURN_IF_ERROR(ProtoUtilLite::Serialize({text_value}, field_type, &r));
|
||||
MP_RETURN_IF_ERROR(
|
||||
ProtoUtilLite::Serialize({text_value}, field_type, &r));
|
||||
result->push_back(r[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ mediapipe::Status ReadFile(const std::string& proto_source, bool read_text,
|
||||
proto_ns::Message* result) {
|
||||
std::ifstream ifs(proto_source);
|
||||
proto_ns::io::IstreamInputStream in(&ifs);
|
||||
RETURN_IF_ERROR(ReadProto(&in, read_text, proto_source, result));
|
||||
MP_RETURN_IF_ERROR(ReadProto(&in, read_text, proto_source, result));
|
||||
return mediapipe::OkStatus();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ mediapipe::Status WriteFile(const std::string& proto_output, bool write_text,
|
||||
const proto_ns::Message& message) {
|
||||
std::ofstream ofs(proto_output, std::ofstream::out | std::ofstream::trunc);
|
||||
proto_ns::io::OstreamOutputStream out(&ofs);
|
||||
RETURN_IF_ERROR(WriteProto(message, write_text, proto_output, &out));
|
||||
MP_RETURN_IF_ERROR(WriteProto(message, write_text, proto_output, &out));
|
||||
return mediapipe::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace tool {
|
||||
|
||||
::mediapipe::Status ValidateInput(const InputCollection& input_collection) {
|
||||
if (!input_collection.name().empty()) {
|
||||
RETURN_IF_ERROR(tool::ValidateName(input_collection.name())).SetPrepend()
|
||||
MP_RETURN_IF_ERROR(tool::ValidateName(input_collection.name())).SetPrepend()
|
||||
<< "InputCollection " << input_collection.name()
|
||||
<< " has improperly specified name: ";
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace tool {
|
||||
for (const auto& tag_and_name : tags_and_names) {
|
||||
std::string tag;
|
||||
std::string name;
|
||||
RETURN_IF_ERROR(ParseTagAndName(tag_and_name, &tag, &name));
|
||||
MP_RETURN_IF_ERROR(ParseTagAndName(tag_and_name, &tag, &name));
|
||||
if (!tag.empty()) {
|
||||
info->tags.push_back(tag);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace tool {
|
||||
tags_and_names->Clear();
|
||||
if (info.tags.empty()) {
|
||||
for (const auto& name : info.names) {
|
||||
RETURN_IF_ERROR(ValidateName(name));
|
||||
MP_RETURN_IF_ERROR(ValidateName(name));
|
||||
*tags_and_names->Add() = name;
|
||||
}
|
||||
} else {
|
||||
@@ -83,8 +83,8 @@ namespace tool {
|
||||
<< " does not match the number of tags " << info.tags.size();
|
||||
}
|
||||
for (int i = 0; i < info.tags.size(); ++i) {
|
||||
RETURN_IF_ERROR(ValidateTag(info.tags[i]));
|
||||
RETURN_IF_ERROR(ValidateName(info.names[i]));
|
||||
MP_RETURN_IF_ERROR(ValidateTag(info.tags[i]));
|
||||
MP_RETURN_IF_ERROR(ValidateName(info.names[i]));
|
||||
*tags_and_names->Add() = absl::StrCat(info.tags[i], ":", info.names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace mediapipe {
|
||||
namespace {
|
||||
|
||||
TEST(ValidateNameTest, ValidateName) {
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateName("humphrey"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateName("humphrey_bogart"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateName("humphrey_bogart_1899"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateName("aa"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateName("b1"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateName("_1"));
|
||||
MP_EXPECT_OK(tool::ValidateName("humphrey"));
|
||||
MP_EXPECT_OK(tool::ValidateName("humphrey_bogart"));
|
||||
MP_EXPECT_OK(tool::ValidateName("humphrey_bogart_1899"));
|
||||
MP_EXPECT_OK(tool::ValidateName("aa"));
|
||||
MP_EXPECT_OK(tool::ValidateName("b1"));
|
||||
MP_EXPECT_OK(tool::ValidateName("_1"));
|
||||
EXPECT_FALSE(tool::ValidateName("").ok());
|
||||
EXPECT_FALSE(tool::ValidateName("humphrey bogart").ok());
|
||||
EXPECT_FALSE(tool::ValidateName("humphreyBogart").ok());
|
||||
@@ -54,12 +54,12 @@ TEST(ValidateNameTest, ValidateName) {
|
||||
}
|
||||
|
||||
TEST(ValidateNameTest, ValidateTag) {
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateTag("MALE"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateTag("MALE_ACTOR"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateTag("ACTOR_1899"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateTag("AA"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateTag("B1"));
|
||||
MEDIAPIPE_EXPECT_OK(tool::ValidateTag("_1"));
|
||||
MP_EXPECT_OK(tool::ValidateTag("MALE"));
|
||||
MP_EXPECT_OK(tool::ValidateTag("MALE_ACTOR"));
|
||||
MP_EXPECT_OK(tool::ValidateTag("ACTOR_1899"));
|
||||
MP_EXPECT_OK(tool::ValidateTag("AA"));
|
||||
MP_EXPECT_OK(tool::ValidateTag("B1"));
|
||||
MP_EXPECT_OK(tool::ValidateTag("_1"));
|
||||
EXPECT_FALSE(tool::ValidateTag("").ok());
|
||||
EXPECT_FALSE(tool::ValidateTag("MALE ACTOR").ok());
|
||||
EXPECT_FALSE(tool::ValidateTag("MALEaCTOR").ok());
|
||||
@@ -82,24 +82,22 @@ TEST(ValidateNameTest, ParseTagAndName) {
|
||||
std::string name;
|
||||
tag = "blah";
|
||||
name = "blah";
|
||||
MEDIAPIPE_EXPECT_OK(tool::ParseTagAndName("MALE:humphrey", &tag, &name));
|
||||
MP_EXPECT_OK(tool::ParseTagAndName("MALE:humphrey", &tag, &name));
|
||||
EXPECT_EQ("MALE", tag);
|
||||
EXPECT_EQ("humphrey", name);
|
||||
tag = "blah";
|
||||
name = "blah";
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
tool::ParseTagAndName("ACTOR:humphrey_bogart", &tag, &name));
|
||||
MP_EXPECT_OK(tool::ParseTagAndName("ACTOR:humphrey_bogart", &tag, &name));
|
||||
EXPECT_EQ("ACTOR", tag);
|
||||
EXPECT_EQ("humphrey_bogart", name);
|
||||
tag = "blah";
|
||||
name = "blah";
|
||||
MEDIAPIPE_EXPECT_OK(
|
||||
tool::ParseTagAndName("ACTOR_1899:humphrey_1899", &tag, &name));
|
||||
MP_EXPECT_OK(tool::ParseTagAndName("ACTOR_1899:humphrey_1899", &tag, &name));
|
||||
EXPECT_EQ("ACTOR_1899", tag);
|
||||
EXPECT_EQ("humphrey_1899", name);
|
||||
tag = "blah";
|
||||
name = "blah";
|
||||
MEDIAPIPE_EXPECT_OK(tool::ParseTagAndName("humphrey_bogart", &tag, &name));
|
||||
MP_EXPECT_OK(tool::ParseTagAndName("humphrey_bogart", &tag, &name));
|
||||
EXPECT_EQ("", tag);
|
||||
EXPECT_EQ("humphrey_bogart", name);
|
||||
|
||||
@@ -122,7 +120,7 @@ TEST(ValidateNameTest, ParseTagAndName) {
|
||||
EXPECT_EQ("", name);
|
||||
tag = "blah";
|
||||
name = "blah";
|
||||
MEDIAPIPE_EXPECT_OK(tool::ParseTagAndName("ACTOR:humphrey", &tag, &name));
|
||||
MP_EXPECT_OK(tool::ParseTagAndName("ACTOR:humphrey", &tag, &name));
|
||||
EXPECT_EQ("ACTOR", tag);
|
||||
EXPECT_EQ("humphrey", name);
|
||||
|
||||
@@ -166,8 +164,8 @@ void TestPassParseTagIndexName(const std::string& tag_index_name,
|
||||
std::string actual_tag = "UNTOUCHED";
|
||||
int actual_index = -100;
|
||||
std::string actual_name = "untouched";
|
||||
MEDIAPIPE_ASSERT_OK(tool::ParseTagIndexName(tag_index_name, &actual_tag,
|
||||
&actual_index, &actual_name))
|
||||
MP_ASSERT_OK(tool::ParseTagIndexName(tag_index_name, &actual_tag,
|
||||
&actual_index, &actual_name))
|
||||
<< "With tag_index_name " << tag_index_name;
|
||||
EXPECT_EQ(expected_tag, actual_tag)
|
||||
<< "With tag_index_name " << tag_index_name;
|
||||
@@ -280,8 +278,7 @@ void TestPassParseTagIndex(const std::string& tag_index,
|
||||
const int expected_index) {
|
||||
std::string actual_tag = "UNTOUCHED";
|
||||
int actual_index = -100;
|
||||
MEDIAPIPE_ASSERT_OK(
|
||||
tool::ParseTagIndex(tag_index, &actual_tag, &actual_index))
|
||||
MP_ASSERT_OK(tool::ParseTagIndex(tag_index, &actual_tag, &actual_index))
|
||||
<< "With tag_index" << tag_index;
|
||||
EXPECT_EQ(expected_tag, actual_tag) << "With tag_index " << tag_index;
|
||||
EXPECT_EQ(expected_index, actual_index) << "With tag_index " << tag_index;
|
||||
@@ -360,22 +357,22 @@ TEST(ValidateNameTest, GetTagAndNameInfo) {
|
||||
fields.Clear();
|
||||
fields.Add()->assign("transcoded_input_file");
|
||||
tool::TagAndNameInfo info;
|
||||
MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
ASSERT_EQ(0, info.tags.size());
|
||||
ASSERT_EQ(1, info.names.size());
|
||||
EXPECT_EQ(fields.Get(0), info.names[0]);
|
||||
MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
EXPECT_THAT(node_config2, EqualsProto(node_config1));
|
||||
|
||||
// Single input using tags.
|
||||
fields.Clear();
|
||||
fields.Add()->assign("FILE:transcoded_input_file");
|
||||
MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
ASSERT_EQ(1, info.tags.size());
|
||||
ASSERT_EQ(1, info.names.size());
|
||||
EXPECT_EQ("FILE", info.tags[0]);
|
||||
EXPECT_EQ("transcoded_input_file", info.names[0]);
|
||||
MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
EXPECT_THAT(node_config2, EqualsProto(node_config1));
|
||||
|
||||
// Mixing indexes and tags.
|
||||
@@ -390,7 +387,7 @@ TEST(ValidateNameTest, GetTagAndNameInfo) {
|
||||
fields.Add()->assign("TAG2:input2");
|
||||
fields.Add()->assign("TAG3:input3");
|
||||
fields.Add()->assign("TAG4:input4");
|
||||
MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
ASSERT_EQ(4, info.tags.size());
|
||||
ASSERT_EQ(4, info.names.size());
|
||||
EXPECT_EQ("TAG1", info.tags[0]);
|
||||
@@ -401,7 +398,7 @@ TEST(ValidateNameTest, GetTagAndNameInfo) {
|
||||
EXPECT_EQ("input2", info.names[1]);
|
||||
EXPECT_EQ("input3", info.names[2]);
|
||||
EXPECT_EQ("input4", info.names[3]);
|
||||
MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
EXPECT_THAT(node_config2, EqualsProto(node_config1));
|
||||
|
||||
// Valid configuration with more than one input using indexes.
|
||||
@@ -410,14 +407,14 @@ TEST(ValidateNameTest, GetTagAndNameInfo) {
|
||||
fields.Add()->assign("input2");
|
||||
fields.Add()->assign("input3");
|
||||
fields.Add()->assign("input4");
|
||||
MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info));
|
||||
ASSERT_EQ(0, info.tags.size());
|
||||
ASSERT_EQ(4, info.names.size());
|
||||
EXPECT_EQ("input1", info.names[0]);
|
||||
EXPECT_EQ("input2", info.names[1]);
|
||||
EXPECT_EQ("input3", info.names[2]);
|
||||
EXPECT_EQ("input4", info.names[3]);
|
||||
MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy));
|
||||
EXPECT_THAT(node_config2, EqualsProto(node_config1));
|
||||
|
||||
// Add an invalid character into the name.
|
||||
|
||||
@@ -52,13 +52,13 @@ namespace tool {
|
||||
<< " is not a registered packet generator.");
|
||||
|
||||
CalculatorContract contract;
|
||||
RETURN_IF_ERROR(contract.Initialize(config));
|
||||
MP_RETURN_IF_ERROR(contract.Initialize(config));
|
||||
|
||||
{
|
||||
LegacyCalculatorSupport::Scoped<CalculatorContract> s(&contract);
|
||||
RETURN_IF_ERROR(static_access->FillExpectations(
|
||||
config.options(), &contract.InputSidePackets(),
|
||||
&contract.OutputSidePackets()))
|
||||
MP_RETURN_IF_ERROR(static_access->FillExpectations(
|
||||
config.options(), &contract.InputSidePackets(),
|
||||
&contract.OutputSidePackets()))
|
||||
.SetPrepend()
|
||||
<< config.packet_generator() << "::FillExpectations failed: ";
|
||||
}
|
||||
@@ -89,30 +89,30 @@ namespace tool {
|
||||
PacketTypeSet output_side_packet_types(output_side_packets->TagMap());
|
||||
|
||||
// Fill the PacketTypeSets with type information.
|
||||
RETURN_IF_ERROR(static_access->FillExpectations(extendable_options,
|
||||
&input_side_packet_types,
|
||||
&output_side_packet_types))
|
||||
MP_RETURN_IF_ERROR(static_access->FillExpectations(extendable_options,
|
||||
&input_side_packet_types,
|
||||
&output_side_packet_types))
|
||||
.SetPrepend()
|
||||
<< packet_generator_name << "::FillExpectations failed: ";
|
||||
// Check that the types were filled well.
|
||||
std::vector<::mediapipe::Status> statuses;
|
||||
statuses.push_back(ValidatePacketTypeSet(input_side_packet_types));
|
||||
statuses.push_back(ValidatePacketTypeSet(output_side_packet_types));
|
||||
RETURN_IF_ERROR(tool::CombinedStatus(
|
||||
MP_RETURN_IF_ERROR(tool::CombinedStatus(
|
||||
absl::StrCat(packet_generator_name, "::FillExpectations failed: "),
|
||||
statuses));
|
||||
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
ValidatePacketSet(input_side_packet_types, input_side_packets))
|
||||
.SetPrepend()
|
||||
<< packet_generator_name
|
||||
<< "::FillExpectations expected different input type than those given: ";
|
||||
RETURN_IF_ERROR(static_access->Generate(extendable_options,
|
||||
input_side_packets,
|
||||
output_side_packets))
|
||||
MP_RETURN_IF_ERROR(static_access->Generate(extendable_options,
|
||||
input_side_packets,
|
||||
output_side_packets))
|
||||
.SetPrepend()
|
||||
<< packet_generator_name << "::Generate failed: ";
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
ValidatePacketSet(output_side_packet_types, *output_side_packets))
|
||||
.SetPrepend()
|
||||
<< packet_generator_name
|
||||
|
||||
@@ -146,9 +146,10 @@ std::string DebugName(const CalculatorGraphConfig& config,
|
||||
const GraphRegistry* graph_registry,
|
||||
CalculatorGraphConfig* output_graph_config) {
|
||||
*output_graph_config = input_graph_config;
|
||||
RETURN_IF_ERROR(tool::ExpandSubgraphs(output_graph_config, graph_registry));
|
||||
MP_RETURN_IF_ERROR(
|
||||
tool::ExpandSubgraphs(output_graph_config, graph_registry));
|
||||
|
||||
RETURN_IF_ERROR(AddPredefinedExecutorConfigs(output_graph_config));
|
||||
MP_RETURN_IF_ERROR(AddPredefinedExecutorConfigs(output_graph_config));
|
||||
|
||||
// Populate each node with the graph level input stream handler if a
|
||||
// stream handler wasn't explicitly provided.
|
||||
@@ -217,7 +218,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
const CalculatorGraphConfig::Node& node, int node_index) {
|
||||
node_.type = NodeType::CALCULATOR;
|
||||
node_.index = node_index;
|
||||
RETURN_IF_ERROR(contract_.Initialize(node));
|
||||
MP_RETURN_IF_ERROR(contract_.Initialize(node));
|
||||
contract_.SetNodeName(
|
||||
CanonicalNodeName(validated_graph.Config(), node_index));
|
||||
|
||||
@@ -228,7 +229,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
for (const auto& input_stream_info : node.input_stream_info()) {
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
tool::ParseTagIndex(input_stream_info.tag_index(), &tag, &index));
|
||||
CollectionItemId id = contract_.Inputs().GetId(tag, index);
|
||||
if (!id.IsValid()) {
|
||||
@@ -260,8 +261,8 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
}
|
||||
#endif
|
||||
LegacyCalculatorSupport::Scoped<CalculatorContract> s(&contract_);
|
||||
RETURN_IF_ERROR(VerifyCalculatorWithContract(validated_graph.Package(),
|
||||
node_class, &contract_));
|
||||
MP_RETURN_IF_ERROR(VerifyCalculatorWithContract(validated_graph.Package(),
|
||||
node_class, &contract_));
|
||||
|
||||
// Validate result of FillExpectations or GetContract.
|
||||
std::vector<::mediapipe::Status> statuses;
|
||||
@@ -303,7 +304,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
const PacketGeneratorConfig& node, int node_index) {
|
||||
node_.type = NodeType::PACKET_GENERATOR;
|
||||
node_.index = node_index;
|
||||
RETURN_IF_ERROR(contract_.Initialize(node));
|
||||
MP_RETURN_IF_ERROR(contract_.Initialize(node));
|
||||
|
||||
// Run FillExpectations.
|
||||
const std::string& node_class = node.packet_generator();
|
||||
@@ -314,9 +315,9 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
_ << "Unable to find PacketGenerator \"" << node_class << "\"");
|
||||
{
|
||||
LegacyCalculatorSupport::Scoped<CalculatorContract> s(&contract_);
|
||||
RETURN_IF_ERROR(static_access->FillExpectations(
|
||||
node.options(), &contract_.InputSidePackets(),
|
||||
&contract_.OutputSidePackets()))
|
||||
MP_RETURN_IF_ERROR(static_access->FillExpectations(
|
||||
node.options(), &contract_.InputSidePackets(),
|
||||
&contract_.OutputSidePackets()))
|
||||
.SetPrepend()
|
||||
<< node_class << ": ";
|
||||
}
|
||||
@@ -345,7 +346,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
const StatusHandlerConfig& node, int node_index) {
|
||||
node_.type = NodeType::STATUS_HANDLER;
|
||||
node_.index = node_index;
|
||||
RETURN_IF_ERROR(contract_.Initialize(node));
|
||||
MP_RETURN_IF_ERROR(contract_.Initialize(node));
|
||||
|
||||
// Run FillExpectations.
|
||||
const std::string& node_class = node.status_handler();
|
||||
@@ -356,14 +357,14 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
_ << "Unable to find StatusHandler \"" << node_class << "\"");
|
||||
{
|
||||
LegacyCalculatorSupport::Scoped<CalculatorContract> s(&contract_);
|
||||
RETURN_IF_ERROR(static_access->FillExpectations(
|
||||
node.options(), &contract_.InputSidePackets()))
|
||||
MP_RETURN_IF_ERROR(static_access->FillExpectations(
|
||||
node.options(), &contract_.InputSidePackets()))
|
||||
.SetPrepend()
|
||||
<< node_class << ": ";
|
||||
}
|
||||
|
||||
// Validate result of FillExpectations.
|
||||
RETURN_IF_ERROR(ValidatePacketTypeSet(contract_.InputSidePackets()))
|
||||
MP_RETURN_IF_ERROR(ValidatePacketTypeSet(contract_.InputSidePackets()))
|
||||
.SetPrepend()
|
||||
<< node_class << "::FillExpectations failed to validate: ";
|
||||
return ::mediapipe::OkStatus();
|
||||
@@ -380,13 +381,13 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
<< input_config.DebugString();
|
||||
#endif
|
||||
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
PerformBasicTransforms(input_config, graph_registry, &config_));
|
||||
|
||||
// Initialize the basic node information.
|
||||
RETURN_IF_ERROR(InitializeGeneratorInfo());
|
||||
RETURN_IF_ERROR(InitializeCalculatorInfo());
|
||||
RETURN_IF_ERROR(InitializeStatusHandlerInfo());
|
||||
MP_RETURN_IF_ERROR(InitializeGeneratorInfo());
|
||||
MP_RETURN_IF_ERROR(InitializeCalculatorInfo());
|
||||
MP_RETURN_IF_ERROR(InitializeStatusHandlerInfo());
|
||||
|
||||
sorted_nodes_.reserve(generators_.size() + calculators_.size());
|
||||
// Initialize sorted_nodes_ to list generators before calculators.
|
||||
@@ -407,11 +408,11 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
|
||||
// Initialize the side packet information.
|
||||
bool need_sorting = false;
|
||||
RETURN_IF_ERROR(InitializeSidePacketInfo(&need_sorting));
|
||||
MP_RETURN_IF_ERROR(InitializeSidePacketInfo(&need_sorting));
|
||||
// Initialize the stream information.
|
||||
RETURN_IF_ERROR(InitializeStreamInfo(&need_sorting));
|
||||
MP_RETURN_IF_ERROR(InitializeStreamInfo(&need_sorting));
|
||||
if (need_sorting) {
|
||||
RETURN_IF_ERROR(TopologicalSortNodes());
|
||||
MP_RETURN_IF_ERROR(TopologicalSortNodes());
|
||||
|
||||
// Clear the information from the unsorted analysis.
|
||||
side_packet_to_producer_.clear();
|
||||
@@ -424,26 +425,27 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
owned_packet_types_.clear();
|
||||
|
||||
// Recompute on sorted graph.
|
||||
RETURN_IF_ERROR(InitializeSidePacketInfo(nullptr));
|
||||
RETURN_IF_ERROR(InitializeStreamInfo(nullptr));
|
||||
MP_RETURN_IF_ERROR(InitializeSidePacketInfo(nullptr));
|
||||
MP_RETURN_IF_ERROR(InitializeStreamInfo(nullptr));
|
||||
}
|
||||
|
||||
// Fill in all the upstream fields now that we are assured of having
|
||||
// things in the right order and all the output streams have been
|
||||
// created.
|
||||
RETURN_IF_ERROR(FillUpstreamFieldForBackEdges());
|
||||
MP_RETURN_IF_ERROR(FillUpstreamFieldForBackEdges());
|
||||
|
||||
// Set Any types based on what they connect to.
|
||||
RETURN_IF_ERROR(ResolveAnyTypes(&input_streams_, &output_streams_));
|
||||
RETURN_IF_ERROR(ResolveAnyTypes(&input_side_packets_, &output_side_packets_));
|
||||
MP_RETURN_IF_ERROR(ResolveAnyTypes(&input_streams_, &output_streams_));
|
||||
MP_RETURN_IF_ERROR(
|
||||
ResolveAnyTypes(&input_side_packets_, &output_side_packets_));
|
||||
|
||||
// Validate consistency of side packets and streams.
|
||||
RETURN_IF_ERROR(ValidateSidePacketTypes());
|
||||
RETURN_IF_ERROR(ValidateStreamTypes());
|
||||
MP_RETURN_IF_ERROR(ValidateSidePacketTypes());
|
||||
MP_RETURN_IF_ERROR(ValidateStreamTypes());
|
||||
|
||||
RETURN_IF_ERROR(ComputeSourceDependence());
|
||||
MP_RETURN_IF_ERROR(ComputeSourceDependence());
|
||||
|
||||
RETURN_IF_ERROR(ValidateExecutors());
|
||||
MP_RETURN_IF_ERROR(ValidateExecutors());
|
||||
|
||||
#if !defined(MEDIAPIPE_MOBILE)
|
||||
VLOG(1) << "ValidatedGraphConfig produced canonical config:\n"
|
||||
@@ -459,7 +461,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
graph_registry =
|
||||
graph_registry ? graph_registry : &GraphRegistry::global_graph_registry;
|
||||
auto status_or_config = graph_registry->CreateByName("", graph_type, options);
|
||||
RETURN_IF_ERROR(status_or_config.status());
|
||||
MP_RETURN_IF_ERROR(status_or_config.status());
|
||||
return Initialize(status_or_config.ValueOrDie(), graph_registry);
|
||||
}
|
||||
|
||||
@@ -525,8 +527,8 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
::mediapipe::Status ValidatedGraphConfig::InitializeSidePacketInfo(
|
||||
bool* need_sorting_ptr) {
|
||||
for (NodeTypeInfo* node_type_info : sorted_nodes_) {
|
||||
RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info));
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info));
|
||||
MP_RETURN_IF_ERROR(
|
||||
AddOutputSidePacketsForNode(node_type_info, need_sorting_ptr));
|
||||
}
|
||||
if (need_sorting_ptr && *need_sorting_ptr) {
|
||||
@@ -537,7 +539,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
RET_CHECK(node_type_info->Node().type ==
|
||||
NodeTypeInfo::NodeType::STATUS_HANDLER);
|
||||
RET_CHECK_EQ(node_type_info->Node().index, index);
|
||||
RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info));
|
||||
MP_RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info));
|
||||
}
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
@@ -616,7 +618,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
NodeTypeInfo::NodeRef virtual_node{
|
||||
NodeTypeInfo::NodeType::GRAPH_INPUT_STREAM,
|
||||
index + config_.node_size()};
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
AddOutputStream(virtual_node, name, owned_packet_types_.back().get()));
|
||||
}
|
||||
|
||||
@@ -624,12 +626,13 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
RET_CHECK(node_type_info.Node().type == NodeTypeInfo::NodeType::CALCULATOR);
|
||||
// Add input streams before outputs (so back edges from a node to
|
||||
// itself must be marked).
|
||||
RETURN_IF_ERROR(AddInputStreamsForNode(&node_type_info, need_sorting_ptr));
|
||||
RETURN_IF_ERROR(AddOutputStreamsForNode(&node_type_info));
|
||||
MP_RETURN_IF_ERROR(
|
||||
AddInputStreamsForNode(&node_type_info, need_sorting_ptr));
|
||||
MP_RETURN_IF_ERROR(AddOutputStreamsForNode(&node_type_info));
|
||||
}
|
||||
|
||||
// Validate tag-name-indexes for graph output streams.
|
||||
RETURN_IF_ERROR(tool::TagMap::Create(config_.output_stream()).status());
|
||||
MP_RETURN_IF_ERROR(tool::TagMap::Create(config_.output_stream()).status());
|
||||
return ::mediapipe::OkStatus();
|
||||
}
|
||||
|
||||
@@ -639,7 +642,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
node_type_info->SetOutputStreamBaseIndex(output_streams_.size());
|
||||
const tool::TagMap& tag_map = *node_type_info->OutputStreamTypes().TagMap();
|
||||
for (CollectionItemId id = tag_map.BeginId(); id < tag_map.EndId(); ++id) {
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
AddOutputStream(node_type_info->Node(), tag_map.Names()[id.value()],
|
||||
&node_type_info->OutputStreamTypes().Get(id)));
|
||||
}
|
||||
@@ -677,7 +680,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) {
|
||||
if (input_stream_info.back_edge()) {
|
||||
std::string tag;
|
||||
int index;
|
||||
RETURN_IF_ERROR(
|
||||
MP_RETURN_IF_ERROR(
|
||||
tool::ParseTagIndex(input_stream_info.tag_index(), &tag, &index));
|
||||
CollectionItemId id = input_stream_types.GetId(tag, index);
|
||||
RET_CHECK(id.IsValid());
|
||||
|
||||
Reference in New Issue
Block a user