Skip to content

Commit

Permalink
Merge branch 'master' into bcp-003-03-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lo-simon committed Mar 7, 2024
2 parents b101b74 + cb66439 commit 74f81ca
Show file tree
Hide file tree
Showing 52 changed files with 8,582 additions and 12 deletions.
93 changes: 93 additions & 0 deletions Development/cmake/NmosCppLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,80 @@ target_include_directories(nmos_is10_schemas PUBLIC
list(APPEND NMOS_CPP_TARGETS nmos_is10_schemas)
add_library(nmos-cpp::nmos_is10_schemas ALIAS nmos_is10_schemas)

# nmos_is12_schemas library

set(NMOS_IS12_SCHEMAS_HEADERS
nmos/is12_schemas/is12_schemas.h
)

set(NMOS_IS12_V1_0_TAG v1.0.x)

set(NMOS_IS12_V1_0_SCHEMAS_JSON
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/base-message.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/command-message.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/command-response-message.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/error-message.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/event-data.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/notification-message.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/property-changed-event-data.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/subscription-message.json
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/subscription-response-message.json
)

set(NMOS_IS12_SCHEMAS_JSON_MATCH "third_party/is-12/([^/]+)/APIs/schemas/([^;]+)\\.json")
set(NMOS_IS12_SCHEMAS_SOURCE_REPLACE "${CMAKE_CURRENT_BINARY_DIR_REPLACE}/nmos/is12_schemas/\\1/\\2.cpp")
string(REGEX REPLACE "${NMOS_IS12_SCHEMAS_JSON_MATCH}(;|$)" "${NMOS_IS12_SCHEMAS_SOURCE_REPLACE}\\3" NMOS_IS12_V1_0_SCHEMAS_SOURCES "${NMOS_IS12_V1_0_SCHEMAS_JSON}")

foreach(JSON ${NMOS_IS12_V1_0_SCHEMAS_JSON})
string(REGEX REPLACE "${NMOS_IS12_SCHEMAS_JSON_MATCH}" "${NMOS_IS12_SCHEMAS_SOURCE_REPLACE}" SOURCE "${JSON}")
string(REGEX REPLACE "${NMOS_IS12_SCHEMAS_JSON_MATCH}" "\\1" NS "${JSON}")
string(REGEX REPLACE "${NMOS_IS12_SCHEMAS_JSON_MATCH}" "\\2" VAR "${JSON}")
string(MAKE_C_IDENTIFIER "${NS}" NS)
string(MAKE_C_IDENTIFIER "${VAR}" VAR)

file(WRITE "${SOURCE}.in" "\
// Auto-generated from: ${JSON}\n\
\n\
namespace nmos\n\
{\n\
namespace is12_schemas\n\
{\n\
namespace ${NS}\n\
{\n\
const char* ${VAR} = R\"-auto-generated-(")

file(READ "${JSON}" RAW)
file(APPEND "${SOURCE}.in" "${RAW}")

file(APPEND "${SOURCE}.in" ")-auto-generated-\";\n\
}\n\
}\n\
}\n")

configure_file("${SOURCE}.in" "${SOURCE}" COPYONLY)
endforeach()

add_library(
nmos_is12_schemas STATIC
${NMOS_IS12_SCHEMAS_HEADERS}
${NMOS_IS12_V1_0_SCHEMAS_SOURCES}
)

source_group("nmos\\is12_schemas\\Header Files" FILES ${NMOS_IS12_SCHEMAS_HEADERS})
source_group("nmos\\is12_schemas\\${NMOS_IS12_V1_0_TAG}\\Source Files" FILES ${NMOS_IS12_V1_0_SCHEMAS_SOURCES})

target_link_libraries(
nmos_is12_schemas PRIVATE
nmos-cpp::compile-settings
)
target_include_directories(nmos_is12_schemas PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${NMOS_CPP_INSTALL_INCLUDEDIR}>
)

list(APPEND NMOS_CPP_TARGETS nmos_is12_schemas)
add_library(nmos-cpp::nmos_is12_schemas ALIAS nmos_is12_schemas)

# nmos-cpp library

set(NMOS_CPP_BST_SOURCES
Expand Down Expand Up @@ -851,6 +925,13 @@ set(NMOS_CPP_NMOS_SOURCES
nmos/connection_api.cpp
nmos/connection_events_activation.cpp
nmos/connection_resources.cpp
nmos/control_protocol_handlers.cpp
nmos/control_protocol_methods.cpp
nmos/control_protocol_resource.cpp
nmos/control_protocol_resources.cpp
nmos/control_protocol_state.cpp
nmos/control_protocol_utils.cpp
nmos/control_protocol_ws_api.cpp
nmos/did_sdid.cpp
nmos/est_behaviour.cpp
nmos/est_certificate_handlers.cpp
Expand Down Expand Up @@ -940,6 +1021,16 @@ set(NMOS_CPP_NMOS_HEADERS
nmos/connection_api.h
nmos/connection_events_activation.h
nmos/connection_resources.h
nmos/control_protocol_handlers.h
nmos/control_protocol_methods.h
nmos/control_protocol_nmos_channel_mapping_resource_type.h
nmos/control_protocol_nmos_resource_type.h
nmos/control_protocol_resource.h
nmos/control_protocol_resources.h
nmos/control_protocol_state.h
nmos/control_protocol_typedefs.h
nmos/control_protocol_utils.h
nmos/control_protocol_ws_api.h
nmos/device_type.h
nmos/did_sdid.h
nmos/est_behaviour.h
Expand All @@ -963,6 +1054,7 @@ set(NMOS_CPP_NMOS_HEADERS
nmos/is08_versions.h
nmos/is09_versions.h
nmos/is10_versions.h
nmos/is12_versions.h
nmos/issuers.h
nmos/json_fields.h
nmos/json_schema.h
Expand Down Expand Up @@ -1112,6 +1204,7 @@ target_link_libraries(
nmos-cpp::nmos_is08_schemas
nmos-cpp::nmos_is09_schemas
nmos-cpp::nmos_is10_schemas
nmos-cpp::nmos_is12_schemas
nmos-cpp::mdns
nmos-cpp::slog
nmos-cpp::OpenSSL
Expand Down
1 change: 1 addition & 0 deletions Development/cmake/NmosCppTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ set(NMOS_CPP_TEST_NMOS_TEST_SOURCES
nmos/test/api_utils_test.cpp
nmos/test/capabilities_test.cpp
nmos/test/channels_test.cpp
nmos/test/control_protocol_test.cpp
nmos/test/did_sdid_test.cpp
nmos/test/event_type_test.cpp
nmos/test/json_validator_test.cpp
Expand Down
19 changes: 19 additions & 0 deletions Development/nmos-cpp-node/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
// is10_versions [registry, node]: used to specify the enabled API versions for a version-locked configuration
//"is10_versions": ["v1.0"],

// is12_versions [node]: used to specify the enabled API versions for a version-locked configuration
//"is12_versions": ["v1.0"],

// pri [registry, node]: used for the 'pri' TXT record; specifying nmos::service_priorities::no_priority (maximum value) disables advertisement completely
//"pri": 100,

Expand Down Expand Up @@ -144,6 +147,8 @@
//"channelmapping_port": 3215,
// system_port [node]: used to construct request URLs for the System API (if not discovered via DNS-SD)
//"system_port": 10641,
// control_protocol_ws_port [node]: used to construct request URLs for the Control Protocol websocket, or negative to disable the control protocol features
//"control_protocol_ws_port": 3218,

// listen_backlog [registry, node]: the maximum length of the queue of pending connections, or zero for the implementation default (the implementation may not honour this value)
//"listen_backlog": 0,
Expand Down Expand Up @@ -364,5 +369,19 @@
// If the Resource Server fails to verify a token using all public keys available it MUST reject the token."
//"service_unavailable_retry_after": 5,

// manufacturer_name [node]: the manufacturer name of the NcDeviceManager used for NMOS Control Protocol
// See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncdevicemanager
//"manufacturer_name": "",

// product_name/product_key/product_revision_level [node]: the product description of the NcDeviceManager used for NMOS Control Protocol
// See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncproduct
//"product_name": "",
//"product_key": "",
//"product_revision_level": "",

// serial_number [node]: the serial number of the NcDeviceManager used for NMOS Control Protocol
// See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncdevicemanager
//"serial_number": "",

"don't worry": "about trailing commas"
}
13 changes: 12 additions & 1 deletion Development/nmos-cpp-node/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "nmos/server_utils.h" // for make_http_listener_config
#include "node_implementation.h"

#include "nmos/control_protocol_state.h"

int main(int argc, char* argv[])
{
// Construct our data models including mutexes to protect them
Expand Down Expand Up @@ -137,13 +139,22 @@ int main(int argc, char* argv[])
.on_request_authorization_code(nmos::experimental::make_request_authorization_code_handler(gate)); // may be omitted, only required for OAuth client which is using the Authorization Code Flow to obtain the access token
}

nmos::experimental::control_protocol_state control_protocol_state;
if (0 <= nmos::fields::control_protocol_ws_port(node_model.settings))
{
node_implementation
.on_get_control_class_descriptor(nmos::make_get_control_protocol_class_descriptor_handler(control_protocol_state))
.on_get_control_datatype_descriptor(nmos::make_get_control_protocol_datatype_descriptor_handler(control_protocol_state))
.on_get_control_protocol_method_descriptor(nmos::make_get_control_protocol_method_descriptor_handler(control_protocol_state));
}

// Set up the node server

auto node_server = nmos::experimental::make_node_server(node_model, node_implementation, log_model, gate);

// Add the underlying implementation, which will set up the node resources, etc.

node_server.thread_functions.push_back([&] { node_implementation_thread(node_model, gate); });
node_server.thread_functions.push_back([&] { node_implementation_thread(node_model, control_protocol_state, gate); });

// only implement communication with OCSP server if http_listener supports OCSP stapling
// cf. preprocessor conditions in nmos::make_http_listener_config
Expand Down
Loading

0 comments on commit 74f81ca

Please sign in to comment.