Skip to content

Commit cb66439

Browse files
IS-12 support (#330)
* Create IS-12 websocket server * Remove incorrect comment * Add `control_protocol_ws_port` to node example config * Use lock to protect websockets * Fix to obtain the event_ws position from the ws_handlers * Create Root block, Device manager and Class manager nmos resources * Add readonly on Get propertry support. Add callback to retrieve control classes from control_protocol_state * Fix declaration of nmos::experimental::control_classes for Linux * Move functions around * Update IS-12 schemas * Tidy up make_nc_class_manager * Add NcObject's GetSequenceItem * Fix GetSequenceItem and add GetSequenceLength * Code tidy up * Add SetSequenceItem, AddSequenceItem, RemoveSequenceItem, FindMembersByPath * Fix AddSequenceItem * Fix FindMembersByPath * Add FindMembersByRole and FindMembersByClassId * Add GetControlClass, and GetDataType * Bump up ubuntu 14.04 to use python 3.7 to overcome ERROR: module 'asyncio' has no attribute 'get_running_loop' and CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team * Fix ModuleNotFoundError: No module named '_ctypes' * Fixing python3.7 install * Bump up to python3.8 * Add NcIdentBeacon, NcReceiverMonitor and NcReceiverMonitorProtected * Use control_protocol_ws_port to construct request URLs for the Control Protocol websocket, or negative to disable the control protocol features * Remove unused code * Fix find_members_by_path and write log on method * Remove un-used code * Add Log gate to method * Move nc_class_id definition from control_protocol_resource to control_protocol_utils * Add nested block examples * Extract IS-12 version from the rx ws path * Add helper functions to create non-standard control class, and general tidy up * Use of nc_class_id struct and method_id struct for map key * Remove un-used code * Add support for allowing user to insert non-standard control class method handler * Fix 'nmos::experimental::control_class' constructor initialization * Fix indentation * Use better error instead of `out of bounds` * Add non-standard Example class based on nmos-device-control-mock * Update log messages * Fix is_nc_block() * Tidy-up function signatures * Add subscription support * Update outdated IS-12 links * Tidy up, less casting * Add description to nc_object to simplify create nc_xxx class * Move nc helper functions to nc utils * look before accessing control_protocol_state * pusback allows on NcBlock only * Add control protocol unit tests * Add more unit tests * Add NcPropertyConstraintsNumber, NcPropertyConstraintsString, NcParameterConstraintsNumber, NcParameterConstraintsString datatypes * Tidy up make_nc_class_descriptor * Fix to handle empty NCP URL path * Code fix to construct nc_property_changed_event_data, thanks for @maweit reviewing * Insert root block resource to the model will also inserting all its nested control protocol resources to the model as suggested by @maweit * Add IS-12 to Readme * Add tounchpoint support and link Receiver-Monitor with IS-04/IS-05 Receiver * Add new headers to makefile * Set IS-12 nmos resource with relevant nmos::type * Clean up on how to construct propertry changed event * Add constraints support, see https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Constraints.html * Update comments * typo * Add primitive types * Add a simple temperature sensor example, which pumps out new temperature value in a time interval * Fix non-standard class's method handing * Remove un-used code and fix typo * Test readonly on set_sequence_item and add_sequence_item * Enhance level 0 datatype constraints validation * Return property_deprecated(298) if property is marked as deprecated * Code tidy-up * Enhance non-standard example control method handlers, add level 2 and level 0 constraints implementation to example control * Prevent comparsion warning * Reject Set on non-sequence value to sequence property * Fix runtime and property sequence constraints validation * Add method parameters constriants validation, and check method deprecation * Add comments * No arguments object to those methods which do not require any arguments * Add deprecated property and deprecated method to Example Control Class * Add logging for contraints validation * Add property changed callback to perform application-specific operations to complete the property changed * Add authorization support to IS-12 * Prevent warning C26800 * Add ncp authorization field to IS-04 controls array of an NMOS Device * Update comments * Return parameter_error (417) instead of bad_oid (404) in event of bad role while doing find_members_by_path * Add non-standard class method with the necessary parameters * Update node config JSON to include is12_versions * Apply suggestions from code review Co-authored-by: jonathan-r-thorpe <[email protected]> * Update Development/nmos-cpp-node/node_implementation.cpp Co-authored-by: jonathan-r-thorpe <[email protected]> * Remove commented out code * Update comments * Added Receiver Monitor Protected and Ident Beacon workers to control_protocol_resources * Apply suggestions from code review Co-authored-by: jonathan-r-thorpe <[email protected]> * Typo * Fix example_control to use the number within the level 2 runtime constraints * Add nc_ident_beacon resource type * Tidy up receiver_monitor, receiver_monitor_protected and ident_beacon resources * Update Development/nmos/control_protocol_ws_api.cpp Co-authored-by: jonathan-r-thorpe <[email protected]> * Update Development/nmos/json_fields.h Co-authored-by: jonathan-r-thorpe <[email protected]> * Change varaible names and function names for better description * Update IS-12 Readme * Update IS-12 Readme * Update Development/nmos/control_protocol_handlers.h Co-authored-by: jonathan-r-thorpe <[email protected]> --------- Co-authored-by: jonathan-r-thorpe <[email protected]> Co-authored-by: Jonathan Thorpe (Sony) <[email protected]>
1 parent eede555 commit cb66439

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+8582
-12
lines changed

Development/cmake/NmosCppLibraries.cmake

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,80 @@ target_include_directories(nmos_is10_schemas PUBLIC
760760
list(APPEND NMOS_CPP_TARGETS nmos_is10_schemas)
761761
add_library(nmos-cpp::nmos_is10_schemas ALIAS nmos_is10_schemas)
762762

763+
# nmos_is12_schemas library
764+
765+
set(NMOS_IS12_SCHEMAS_HEADERS
766+
nmos/is12_schemas/is12_schemas.h
767+
)
768+
769+
set(NMOS_IS12_V1_0_TAG v1.0.x)
770+
771+
set(NMOS_IS12_V1_0_SCHEMAS_JSON
772+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/base-message.json
773+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/command-message.json
774+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/command-response-message.json
775+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/error-message.json
776+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/event-data.json
777+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/notification-message.json
778+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/property-changed-event-data.json
779+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/subscription-message.json
780+
third_party/is-12/${NMOS_IS12_V1_0_TAG}/APIs/schemas/subscription-response-message.json
781+
)
782+
783+
set(NMOS_IS12_SCHEMAS_JSON_MATCH "third_party/is-12/([^/]+)/APIs/schemas/([^;]+)\\.json")
784+
set(NMOS_IS12_SCHEMAS_SOURCE_REPLACE "${CMAKE_CURRENT_BINARY_DIR_REPLACE}/nmos/is12_schemas/\\1/\\2.cpp")
785+
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}")
786+
787+
foreach(JSON ${NMOS_IS12_V1_0_SCHEMAS_JSON})
788+
string(REGEX REPLACE "${NMOS_IS12_SCHEMAS_JSON_MATCH}" "${NMOS_IS12_SCHEMAS_SOURCE_REPLACE}" SOURCE "${JSON}")
789+
string(REGEX REPLACE "${NMOS_IS12_SCHEMAS_JSON_MATCH}" "\\1" NS "${JSON}")
790+
string(REGEX REPLACE "${NMOS_IS12_SCHEMAS_JSON_MATCH}" "\\2" VAR "${JSON}")
791+
string(MAKE_C_IDENTIFIER "${NS}" NS)
792+
string(MAKE_C_IDENTIFIER "${VAR}" VAR)
793+
794+
file(WRITE "${SOURCE}.in" "\
795+
// Auto-generated from: ${JSON}\n\
796+
\n\
797+
namespace nmos\n\
798+
{\n\
799+
namespace is12_schemas\n\
800+
{\n\
801+
namespace ${NS}\n\
802+
{\n\
803+
const char* ${VAR} = R\"-auto-generated-(")
804+
805+
file(READ "${JSON}" RAW)
806+
file(APPEND "${SOURCE}.in" "${RAW}")
807+
808+
file(APPEND "${SOURCE}.in" ")-auto-generated-\";\n\
809+
}\n\
810+
}\n\
811+
}\n")
812+
813+
configure_file("${SOURCE}.in" "${SOURCE}" COPYONLY)
814+
endforeach()
815+
816+
add_library(
817+
nmos_is12_schemas STATIC
818+
${NMOS_IS12_SCHEMAS_HEADERS}
819+
${NMOS_IS12_V1_0_SCHEMAS_SOURCES}
820+
)
821+
822+
source_group("nmos\\is12_schemas\\Header Files" FILES ${NMOS_IS12_SCHEMAS_HEADERS})
823+
source_group("nmos\\is12_schemas\\${NMOS_IS12_V1_0_TAG}\\Source Files" FILES ${NMOS_IS12_V1_0_SCHEMAS_SOURCES})
824+
825+
target_link_libraries(
826+
nmos_is12_schemas PRIVATE
827+
nmos-cpp::compile-settings
828+
)
829+
target_include_directories(nmos_is12_schemas PUBLIC
830+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
831+
$<INSTALL_INTERFACE:${NMOS_CPP_INSTALL_INCLUDEDIR}>
832+
)
833+
834+
list(APPEND NMOS_CPP_TARGETS nmos_is12_schemas)
835+
add_library(nmos-cpp::nmos_is12_schemas ALIAS nmos_is12_schemas)
836+
763837
# nmos-cpp library
764838

765839
set(NMOS_CPP_BST_SOURCES
@@ -851,6 +925,13 @@ set(NMOS_CPP_NMOS_SOURCES
851925
nmos/connection_api.cpp
852926
nmos/connection_events_activation.cpp
853927
nmos/connection_resources.cpp
928+
nmos/control_protocol_handlers.cpp
929+
nmos/control_protocol_methods.cpp
930+
nmos/control_protocol_resource.cpp
931+
nmos/control_protocol_resources.cpp
932+
nmos/control_protocol_state.cpp
933+
nmos/control_protocol_utils.cpp
934+
nmos/control_protocol_ws_api.cpp
854935
nmos/did_sdid.cpp
855936
nmos/events_api.cpp
856937
nmos/events_resources.cpp
@@ -937,6 +1018,16 @@ set(NMOS_CPP_NMOS_HEADERS
9371018
nmos/connection_api.h
9381019
nmos/connection_events_activation.h
9391020
nmos/connection_resources.h
1021+
nmos/control_protocol_handlers.h
1022+
nmos/control_protocol_methods.h
1023+
nmos/control_protocol_nmos_channel_mapping_resource_type.h
1024+
nmos/control_protocol_nmos_resource_type.h
1025+
nmos/control_protocol_resource.h
1026+
nmos/control_protocol_resources.h
1027+
nmos/control_protocol_state.h
1028+
nmos/control_protocol_typedefs.h
1029+
nmos/control_protocol_utils.h
1030+
nmos/control_protocol_ws_api.h
9401031
nmos/device_type.h
9411032
nmos/did_sdid.h
9421033
nmos/event_type.h
@@ -956,6 +1047,7 @@ set(NMOS_CPP_NMOS_HEADERS
9561047
nmos/is08_versions.h
9571048
nmos/is09_versions.h
9581049
nmos/is10_versions.h
1050+
nmos/is12_versions.h
9591051
nmos/issuers.h
9601052
nmos/json_fields.h
9611053
nmos/json_schema.h
@@ -1105,6 +1197,7 @@ target_link_libraries(
11051197
nmos-cpp::nmos_is08_schemas
11061198
nmos-cpp::nmos_is09_schemas
11071199
nmos-cpp::nmos_is10_schemas
1200+
nmos-cpp::nmos_is12_schemas
11081201
nmos-cpp::mdns
11091202
nmos-cpp::slog
11101203
nmos-cpp::OpenSSL

Development/cmake/NmosCppTest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ set(NMOS_CPP_TEST_NMOS_TEST_SOURCES
4343
nmos/test/api_utils_test.cpp
4444
nmos/test/capabilities_test.cpp
4545
nmos/test/channels_test.cpp
46+
nmos/test/control_protocol_test.cpp
4647
nmos/test/did_sdid_test.cpp
4748
nmos/test/event_type_test.cpp
4849
nmos/test/json_validator_test.cpp

Development/nmos-cpp-node/config.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
// is10_versions [registry, node]: used to specify the enabled API versions for a version-locked configuration
105105
//"is10_versions": ["v1.0"],
106106

107+
// is12_versions [node]: used to specify the enabled API versions for a version-locked configuration
108+
//"is12_versions": ["v1.0"],
109+
107110
// pri [registry, node]: used for the 'pri' TXT record; specifying nmos::service_priorities::no_priority (maximum value) disables advertisement completely
108111
//"pri": 100,
109112

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

148153
// 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)
149154
//"listen_backlog": 0,
@@ -364,5 +369,19 @@
364369
// If the Resource Server fails to verify a token using all public keys available it MUST reject the token."
365370
//"service_unavailable_retry_after": 5,
366371

372+
// manufacturer_name [node]: the manufacturer name of the NcDeviceManager used for NMOS Control Protocol
373+
// See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncdevicemanager
374+
//"manufacturer_name": "",
375+
376+
// product_name/product_key/product_revision_level [node]: the product description of the NcDeviceManager used for NMOS Control Protocol
377+
// See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncproduct
378+
//"product_name": "",
379+
//"product_key": "",
380+
//"product_revision_level": "",
381+
382+
// serial_number [node]: the serial number of the NcDeviceManager used for NMOS Control Protocol
383+
// See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncdevicemanager
384+
//"serial_number": "",
385+
367386
"don't worry": "about trailing commas"
368387
}

Development/nmos-cpp-node/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "nmos/server_utils.h" // for make_http_listener_config
1919
#include "node_implementation.h"
2020

21+
#include "nmos/control_protocol_state.h"
22+
2123
int main(int argc, char* argv[])
2224
{
2325
// Construct our data models including mutexes to protect them
@@ -137,13 +139,22 @@ int main(int argc, char* argv[])
137139
.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
138140
}
139141

142+
nmos::experimental::control_protocol_state control_protocol_state;
143+
if (0 <= nmos::fields::control_protocol_ws_port(node_model.settings))
144+
{
145+
node_implementation
146+
.on_get_control_class_descriptor(nmos::make_get_control_protocol_class_descriptor_handler(control_protocol_state))
147+
.on_get_control_datatype_descriptor(nmos::make_get_control_protocol_datatype_descriptor_handler(control_protocol_state))
148+
.on_get_control_protocol_method_descriptor(nmos::make_get_control_protocol_method_descriptor_handler(control_protocol_state));
149+
}
150+
140151
// Set up the node server
141152

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

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

146-
node_server.thread_functions.push_back([&] { node_implementation_thread(node_model, gate); });
157+
node_server.thread_functions.push_back([&] { node_implementation_thread(node_model, control_protocol_state, gate); });
147158

148159
// only implement communication with OCSP server if http_listener supports OCSP stapling
149160
// cf. preprocessor conditions in nmos::make_http_listener_config

0 commit comments

Comments
 (0)