fix: fabric-bridge build - use NodeRunner::run, get writer config from node base class
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace dmf_node {
|
||||
@@ -21,8 +22,8 @@ public:
|
||||
virtual std::vector<PortDef> input_ports() const = 0;
|
||||
virtual std::vector<PortDef> output_ports() const = 0;
|
||||
virtual void configure(const nlohmann::json& params) = 0;
|
||||
virtual void on_add_writer(const std::string& port_id, mxlFlowWriter writer) = 0;
|
||||
virtual void on_add_reader(const std::string& port_id, mxlFlowReader reader) = 0;
|
||||
virtual void on_add_writer(const std::string& port_id, mxlFlowWriter writer) {}
|
||||
virtual void on_add_reader(const std::string& port_id, mxlFlowReader reader) {}
|
||||
virtual void on_remove_writer(const std::string& port_id) = 0;
|
||||
virtual void on_remove_reader(const std::string& port_id) = 0;
|
||||
virtual void process() = 0;
|
||||
@@ -31,8 +32,15 @@ public:
|
||||
void set_mxl_instance(mxlInstance instance) { mxl_instance_ = instance; }
|
||||
mxlInstance get_mxl_instance() const { return mxl_instance_; }
|
||||
|
||||
void set_writer_config(const std::string& port_id, const mxlFlowConfigInfo& config) { writer_configs_[port_id] = config; }
|
||||
void set_reader_config(const std::string& port_id, const mxlFlowConfigInfo& config) { reader_configs_[port_id] = config; }
|
||||
const mxlFlowConfigInfo* get_writer_config(const std::string& port_id) const { auto it = writer_configs_.find(port_id); return it != writer_configs_.end() ? &it->second : nullptr; }
|
||||
const mxlFlowConfigInfo* get_reader_config(const std::string& port_id) const { auto it = reader_configs_.find(port_id); return it != reader_configs_.end() ? &it->second : nullptr; }
|
||||
|
||||
private:
|
||||
mxlInstance mxl_instance_ = nullptr;
|
||||
std::unordered_map<std::string, mxlFlowConfigInfo> writer_configs_;
|
||||
std::unordered_map<std::string, mxlFlowConfigInfo> reader_configs_;
|
||||
};
|
||||
|
||||
} // namespace dmf_node
|
||||
|
||||
@@ -118,8 +118,8 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
}
|
||||
spdlog::info("Created flow writer on port '{}' flow {} (created={})", port_id, flow_id, created);
|
||||
flow_resources.push_back({port_id, writer, nullptr});
|
||||
node->set_writer_config(port_id, config_info);
|
||||
node->on_add_writer(port_id, writer);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("add_reader", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
@@ -134,8 +134,10 @@ int NodeRunner::exec(std::unique_ptr<Node> node) {
|
||||
}
|
||||
spdlog::info("Created flow reader on port '{}' flow {}", port_id, flow_id);
|
||||
flow_resources.push_back({port_id, nullptr, reader});
|
||||
mxlFlowConfigInfo config{};
|
||||
mxlFlowReaderGetConfigInfo(reader, &config);
|
||||
node->set_reader_config(port_id, config);
|
||||
node->on_add_reader(port_id, reader);
|
||||
return {{"ok", true}};
|
||||
});
|
||||
|
||||
control_server->register_command("remove_writer", [&](const nlohmann::json& msg) -> nlohmann::json {
|
||||
|
||||
@@ -241,9 +241,10 @@ void FabricBridgeNode::run_target() {
|
||||
}
|
||||
target_ = tgt;
|
||||
|
||||
mxlFlowConfigInfo config{};
|
||||
mxlFlowWriterGetConfigInfo(*writer_, &config);
|
||||
grain_rate_ = config.common.grainRate;
|
||||
auto* config = get_writer_config("video_out");
|
||||
if (config) {
|
||||
grain_rate_ = config->common.grainRate;
|
||||
}
|
||||
|
||||
mxlFabricsTargetConfig target_cfg{};
|
||||
target_cfg.version = MXL_FABRICS_API_VERSION;
|
||||
|
||||
@@ -2,10 +2,5 @@
|
||||
#include <dmf-node/node_runner.hpp>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
dmf_node::NodeRunner runner;
|
||||
if (!runner.parse_args(argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
auto node = std::make_unique<dmf_node::FabricBridgeNode>();
|
||||
return runner.exec(std::move(node));
|
||||
return dmf_node::NodeRunner::run<dmf_node::FabricBridgeNode>(argc, argv);
|
||||
}
|
||||
Reference in New Issue
Block a user