hardcoded decklink mode fix
This commit is contained in:
@@ -101,7 +101,7 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
};
|
||||
std::vector<FlowResource> flow_resources;
|
||||
|
||||
control_server->register_command("add_writer", [&](const nlohmann::json& msg) {
|
||||
control_server->register_command("add_writer", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
auto flow_id = msg["flow_id"].get<std::string>();
|
||||
auto port_id = msg["port_id"].get<std::string>();
|
||||
auto flow_def = msg["flow_def"].dump();
|
||||
@@ -112,14 +112,15 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
auto status = mxlCreateFlowWriter(mxl_instance_, flow_def.c_str(), nullptr, &writer, &config_info, &created);
|
||||
if (status != MXL_STATUS_OK || !writer) {
|
||||
spdlog::error("Failed to create flow writer for flow {}: status={}", flow_id, static_cast<int>(status));
|
||||
return;
|
||||
return {{"ok", false}, {"error", "failed to create flow writer"}};
|
||||
}
|
||||
spdlog::info("Created flow writer on port '{}' flow {} (created={})", port_id, flow_id, created);
|
||||
flow_resources.push_back({port_id, writer, nullptr});
|
||||
node->on_add_writer(port_id, writer);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("add_reader", [&](const nlohmann::json& msg) {
|
||||
control_server->register_command("add_reader", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
auto flow_id = msg["flow_id"].get<std::string>();
|
||||
auto port_id = msg["port_id"].get<std::string>();
|
||||
|
||||
@@ -127,14 +128,15 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
auto status = mxlCreateFlowReader(mxl_instance_, flow_id.c_str(), nullptr, &reader);
|
||||
if (status != MXL_STATUS_OK || !reader) {
|
||||
spdlog::error("Failed to create flow reader for flow {}: status={}", flow_id, static_cast<int>(status));
|
||||
return;
|
||||
return {{"ok", false}, {"error", "failed to create flow reader"}};
|
||||
}
|
||||
spdlog::info("Created flow reader on port '{}' flow {}", port_id, flow_id);
|
||||
flow_resources.push_back({port_id, nullptr, reader});
|
||||
node->on_add_reader(port_id, reader);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("remove_writer", [&](const nlohmann::json& msg) {
|
||||
control_server->register_command("remove_writer", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
auto port_id = msg["port_id"].get<std::string>();
|
||||
node->on_remove_writer(port_id);
|
||||
for (auto it = flow_resources.begin(); it != flow_resources.end(); ++it) {
|
||||
@@ -145,9 +147,10 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
}
|
||||
}
|
||||
spdlog::info("Removed writer on port '{}'", port_id);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("remove_reader", [&](const nlohmann::json& msg) {
|
||||
control_server->register_command("remove_reader", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
auto port_id = msg["port_id"].get<std::string>();
|
||||
node->on_remove_reader(port_id);
|
||||
for (auto it = flow_resources.begin(); it != flow_resources.end(); ++it) {
|
||||
@@ -158,26 +161,30 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
}
|
||||
}
|
||||
spdlog::info("Removed reader on port '{}'", port_id);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("configure", [&](const nlohmann::json& msg) {
|
||||
control_server->register_command("configure", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
if (msg.contains("params")) {
|
||||
node->configure(msg["params"]);
|
||||
spdlog::info("Reconfigured node '{}'", node_id_);
|
||||
}
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("status", [&](const nlohmann::json& /*msg*/) {
|
||||
control_server->register_command("status", [&](const nlohmann::json& /*msg*/) -> nlohmann::json {
|
||||
nlohmann::json resp;
|
||||
resp["event"] = "status";
|
||||
resp["node_id"] = node_id_;
|
||||
resp["data"] = node->status();
|
||||
control_server->send_event(resp);
|
||||
return resp;
|
||||
});
|
||||
|
||||
control_server->register_command("shutdown", [&](const nlohmann::json& /*msg*/) {
|
||||
control_server->register_command("shutdown", [&](const nlohmann::json& /*msg*/) -> nlohmann::json {
|
||||
spdlog::info("Shutdown command received");
|
||||
g_running = false;
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
nlohmann::json ready_event;
|
||||
|
||||
Reference in New Issue
Block a user