Skip to content

Commit a64e1e1

Browse files
Add MXL domain ID retrieval and auto resolution for transport parameters in node implementation
1 parent e3ad404 commit a64e1e1

1 file changed

Lines changed: 41 additions & 4 deletions

File tree

Development/nmos-cpp-node/node_implementation.cpp

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ namespace impl
138138

139139
nmos::interlace_mode get_interlace_mode(const nmos::settings& settings);
140140

141+
// Effective MXL domain id from settings, or a repeatable default when omitted (used by resolve_auto)
142+
nmos::id get_mxl_domain_id(const nmos::settings& settings);
143+
144+
web::json::value resolve_mxl_auto_value(const web::json::value& constraint, const nmos::id& fallback);
145+
141146
// the different kinds of 'port' (standing for the format/media type/event type) implemented by the example node
142147
// each 'port' of the example node has a source, flow, sender and/or compatible receiver
143148
DEFINE_STRING_ENUM(port)
@@ -2073,10 +2078,11 @@ nmos::connection_resource_auto_resolver make_node_implementation_auto_resolver(c
20732078
const auto ws_receiver_ids = impl::make_ids(seed_id, nmos::types::receiver, ws_receiver_ports, how_many);
20742079
const auto mxl_receiver_ports = boost::copy_range<std::vector<impl::port>>(receiver_ports | boost::adaptors::filtered(impl::is_mxl_port));
20752080
const auto mxl_receiver_ids = impl::make_ids(seed_id, nmos::types::receiver, mxl_receiver_ports, how_many);
2081+
const auto mxl_domain_id = impl::get_mxl_domain_id(settings);
20762082

20772083
// although which properties may need to be defaulted depends on the resource type,
20782084
// the default value will almost always be different for each resource
2079-
return [rtp_sender_ids, rtp_receiver_ids, ws_sender_ids, ws_sender_uri, ws_receiver_ids, mxl_sender_ids, mxl_receiver_ids](const nmos::resource& resource, const nmos::resource& connection_resource, value& transport_params)
2085+
return [rtp_sender_ids, rtp_receiver_ids, ws_sender_ids, ws_sender_uri, ws_receiver_ids, mxl_sender_ids, mxl_receiver_ids, mxl_domain_id](const nmos::resource& resource, const nmos::resource& connection_resource, value& transport_params)
20802086
{
20812087
const std::pair<nmos::id, nmos::type> id_type{ connection_resource.id, connection_resource.type };
20822088
// this code relies on the specific constraints added by node_implementation_thread
@@ -2113,13 +2119,22 @@ nmos::connection_resource_auto_resolver make_node_implementation_auto_resolver(c
21132119
}
21142120
else if (mxl_sender_ids.end() != boost::range::find(mxl_sender_ids, id_type.first))
21152121
{
2116-
nmos::details::resolve_auto(transport_params[0], nmos::fields::mxl_domain_id, [&] { return web::json::front(nmos::fields::constraint_enum(constraints.at(0).at(nmos::fields::mxl_domain_id))); });
2117-
nmos::details::resolve_auto(transport_params[0], nmos::fields::mxl_flow_id, [&] { return web::json::front(nmos::fields::constraint_enum(constraints.at(0).at(nmos::fields::mxl_flow_id))); });
2122+
nmos::details::resolve_auto(transport_params[0], nmos::fields::mxl_domain_id, [&]
2123+
{
2124+
return impl::resolve_mxl_auto_value(constraints.at(0).at(nmos::fields::mxl_domain_id), mxl_domain_id);
2125+
});
2126+
nmos::details::resolve_auto(transport_params[0], nmos::fields::mxl_flow_id, [&]
2127+
{
2128+
return impl::resolve_mxl_auto_value(constraints.at(0).at(nmos::fields::mxl_flow_id), nmos::fields::flow_id(resource.data).as_string());
2129+
});
21182130
}
21192131
else if (mxl_receiver_ids.end() != boost::range::find(mxl_receiver_ids, id_type.first))
21202132
{
21212133
// BCP-007-03: mxl_flow_id does not use "auto" on receivers (UUID or null only).
2122-
nmos::details::resolve_auto(transport_params[0], nmos::fields::mxl_domain_id, [&] { return web::json::front(nmos::fields::constraint_enum(constraints.at(0).at(nmos::fields::mxl_domain_id))); });
2134+
nmos::details::resolve_auto(transport_params[0], nmos::fields::mxl_domain_id, [&]
2135+
{
2136+
return impl::resolve_mxl_auto_value(constraints.at(0).at(nmos::fields::mxl_domain_id), mxl_domain_id);
2137+
});
21232138
}
21242139
};
21252140
}
@@ -2427,6 +2442,28 @@ nmos::create_device_model_object_handler make_create_device_model_object_handler
24272442

24282443
namespace impl
24292444
{
2445+
nmos::id get_mxl_domain_id(const nmos::settings& settings)
2446+
{
2447+
const auto seed_id = nmos::experimental::fields::seed_id(settings);
2448+
return fields::mxl_domain_id(settings).empty()
2449+
? nmos::make_repeatable_id(seed_id, U("/x-nmos/mxl/domain"))
2450+
: fields::mxl_domain_id(settings);
2451+
}
2452+
2453+
web::json::value resolve_mxl_auto_value(const web::json::value& constraint, const nmos::id& fallback)
2454+
{
2455+
using web::json::value;
2456+
if (constraint.has_field(nmos::fields::constraint_enum))
2457+
{
2458+
const auto& en = nmos::fields::constraint_enum(constraint);
2459+
if (en.is_array() && 0 != en.as_array().size())
2460+
{
2461+
return web::json::front(en);
2462+
}
2463+
}
2464+
return value::string(fallback);
2465+
}
2466+
24302467
nmos::interlace_mode get_interlace_mode(const nmos::settings& settings)
24312468
{
24322469
if (settings.has_field(impl::fields::interlace_mode))

0 commit comments

Comments
 (0)