Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into windows-2022
Browse files Browse the repository at this point in the history
  • Loading branch information
garethsb committed May 19, 2023
2 parents 323a759 + 694539a commit d683757
Show file tree
Hide file tree
Showing 29 changed files with 388 additions and 54 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
- name: install conan
if: matrix.use_conan == true
run: |
pip install conan
pip install conan~=1.47
conan config set general.revisions_enabled=1
- name: install cmake
Expand Down Expand Up @@ -577,6 +577,8 @@ jobs:
apt-get install -y software-properties-common
apt-get --allow-unauthenticated update -q
apt-get --allow-unauthenticated install -y curl g++ git make patch zlib1g-dev libssl-dev bsdmainutils dnsutils unzip
# ubuntu-14.04 ca-certificates are out of date
git config --global http.sslVerify false
curl -sS https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tar.xz | tar -xJ
cd Python-3.6.9
./configure
Expand All @@ -600,7 +602,7 @@ jobs:
- name: install conan
if: matrix.use_conan == true
run: |
pip install conan
pip install conan~=1.47
conan config set general.revisions_enabled=1
- name: install cmake
Expand Down Expand Up @@ -1073,4 +1075,4 @@ jobs:
git config --global user.name 'test-results-uploader'
git config --global user.email '[email protected]'
git commit -qm "Badges for README at ${{ env.GITHUB_COMMIT }}"
git push -f `git remote` badges-${{ env.GITHUB_COMMIT }}:badges
git push -f `git remote` badges-${{ env.GITHUB_COMMIT }}:badges
2 changes: 1 addition & 1 deletion .github/workflows/src/build-setup.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: install conan
if: matrix.use_conan == true
run: |
pip install conan
pip install conan~=1.47
conan config set general.revisions_enabled=1
- name: install cmake
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/src/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ jobs:
apt-get install -y software-properties-common
apt-get --allow-unauthenticated update -q
apt-get --allow-unauthenticated install -y curl g++ git make patch zlib1g-dev libssl-dev bsdmainutils dnsutils unzip
# ubuntu-14.04 ca-certificates are out of date
git config --global http.sslVerify false
curl -sS https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tar.xz | tar -xJ
cd Python-3.6.9
./configure
Expand Down
2 changes: 1 addition & 1 deletion Development/cmake/NmosCppConan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include(${CMAKE_CURRENT_BINARY_DIR}/conan.cmake)
# it would be nice to output a message if its a more recent version than tested, like:
# "Found Conan version 99.99 that is higher than the current tested version: " ${CONAN_VERSION_CUR})
set(CONAN_VERSION_MIN "1.47.0")
set(CONAN_VERSION_CUR "1.53.0")
set(CONAN_VERSION_CUR "1.59.0")
conan_check(VERSION ${CONAN_VERSION_MIN} REQUIRED)

set(NMOS_CPP_CONAN_BUILD_LIBS "missing" CACHE STRING "Semicolon separated list of libraries to build rather than download")
Expand Down
1 change: 1 addition & 0 deletions Development/cmake/NmosCppLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ set(NMOS_CPP_NMOS_HEADERS
nmos/api_downgrade.h
nmos/api_utils.h
nmos/api_version.h
nmos/asset.h
nmos/capabilities.h
nmos/certificate_handlers.h
nmos/certificate_settings.h
Expand Down
12 changes: 12 additions & 0 deletions Development/cpprest/host_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/range/adaptor/filtered.hpp>
#include <boost/range/algorithm/find.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include "cpprest/asyncrt_utils.h" // for utility::conversions

#if defined(_WIN32)
Expand Down Expand Up @@ -328,6 +330,16 @@ namespace web
}
return addresses; // empty if host_name cannot be resolved
}

// get the associated network interface name from an IP address
utility::string_t get_interface_name(const utility::string_t& address, const std::vector<web::hosts::experimental::host_interface>& host_interfaces)
{
const auto interface = boost::range::find_if(host_interfaces, [&](const web::hosts::experimental::host_interface& interface)
{
return interface.addresses.end() != boost::range::find(interface.addresses, address);
});
return host_interfaces.end() != interface ? interface->name : utility::string_t{};
}
}
}
}
3 changes: 3 additions & 0 deletions Development/cpprest/host_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace web

std::vector<utility::string_t> host_names(const utility::string_t& address);
std::vector<utility::string_t> host_addresses(const utility::string_t& host_name);

// get the associated network interface name from an IP address
utility::string_t get_interface_name(const utility::string_t& address, const std::vector<web::hosts::experimental::host_interface>& host_interfaces = web::hosts::experimental::host_interfaces());
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Development/cpprest/uri_schemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ namespace web

inline utility::string_t http_scheme(bool secure) { return secure ? uri_schemes::https : uri_schemes::http; }
inline utility::string_t ws_scheme(bool secure) { return secure ? uri_schemes::wss : uri_schemes::ws; }

inline bool is_secure_uri_scheme(const utility::string_t& scheme)
{
return uri_schemes::https == scheme || uri_schemes::wss == scheme;
}
}

#endif
1 change: 1 addition & 0 deletions Development/cpprest/ws_listener_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ namespace web
if (!init)
{
server.init_asio();
server.set_reuse_addr(true);
init = true;
}
else
Expand Down
21 changes: 20 additions & 1 deletion Development/nmos-cpp-node/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
{
// Custom settings for the example node implementation

// node_tags, device_tags: used in resource tags fields
// "Each tag has a single key, but MAY have multiple values."
// See https://specs.amwa.tv/is-04/releases/v1.3.2/docs/APIs_-_Common_Keys.html#tags
// {
// "tag_1": [ "tag_1_value_1", "tag_1_value_2" ],
// "tag_2": [ "tag_2_value_1" ]
// }
//"node_tags": {},
//"device_tags": {},

// how_many: provides for very basic testing of a node with many sub-resources of each type
//"how_many": 4,

Expand Down Expand Up @@ -181,11 +191,20 @@
//"settings_port": 3209,
//"logging_port": 5106,

// addresses [registry, node]: addresses on which to listen for each API, or empty string for the wildcard address
// addresses [registry, node]: IP addresses on which to listen for each API, or empty string for the wildcard address

// server_address [registry, node]: if specified, this becomes the default address on which to listen for each API instead of the wildcard address
//"server_address": "",

// addresses [registry, node]: IP addresses on which to listen for specific APIs

//"settings_address": "127.0.0.1",
//"logging_address": "",

// client_address [registry, node]: IP address of the network interface to bind client connections
// for now, only supporting HTTP/HTTPS client connections on Linux
//"client_address": "",

// logging_limit [registry, node]: maximum number of log events cached for the Logging API
//"logging_limit": 1234,

Expand Down
15 changes: 14 additions & 1 deletion Development/nmos-cpp-node/node_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ namespace impl
// custom settings for the example node implementation
namespace fields
{
// node_tags, device_tags: used in resource tags fields
// "Each tag has a single key, but MAY have multiple values."
// See https://specs.amwa.tv/is-04/releases/v1.3.2/docs/APIs_-_Common_Keys.html#tags
// {
// "tag_1": [ "tag_1_value_1", "tag_1_value_2" ],
// "tag_2": [ "tag_2_value_1" ]
// }
const web::json::field_as_value_or node_tags{ U("node_tags"), web::json::value::object() };
const web::json::field_as_value_or device_tags{ U("device_tags"), web::json::value::object() };

// how_many: provides for very basic testing of a node with many sub-resources of each type
const web::json::field_as_integer_or how_many{ U("how_many"), 1 };

Expand Down Expand Up @@ -295,6 +305,7 @@ void node_implementation_init(nmos::node_model& model, slog::base_gate& gate)
// example node
{
auto node = nmos::make_node(node_id, clocks, nmos::make_node_interfaces(interfaces), model.settings);
node.data[nmos::fields::tags] = impl::fields::node_tags(model.settings);
if (!insert_resource_after(delay_millis, model.node_resources, std::move(node), gate)) throw node_implementation_init_exception();
}

Expand Down Expand Up @@ -338,7 +349,9 @@ void node_implementation_init(nmos::node_model& model, slog::base_gate& gate)
auto sender_ids = impl::make_ids(seed_id, nmos::types::sender, rtp_sender_ports, how_many);
if (0 <= nmos::fields::events_port(model.settings)) boost::range::push_back(sender_ids, impl::make_ids(seed_id, nmos::types::sender, ws_sender_ports, how_many));
auto receiver_ids = impl::make_ids(seed_id, nmos::types::receiver, receiver_ports, how_many);
if (!insert_resource_after(delay_millis, model.node_resources, nmos::make_device(device_id, node_id, sender_ids, receiver_ids, model.settings), gate)) throw node_implementation_init_exception();
auto device = nmos::make_device(device_id, node_id, sender_ids, receiver_ids, model.settings);
device.data[nmos::fields::tags] = impl::fields::device_tags(model.settings);
if (!insert_resource_after(delay_millis, model.node_resources, std::move(device), gate)) throw node_implementation_init_exception();
}

// example sources, flows and senders
Expand Down
13 changes: 11 additions & 2 deletions Development/nmos-cpp-registry/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,26 @@
//"mdns_port": 3208,
//"schemas_port": 3208,

// addresses [registry, node]: addresses on which to listen for each API, or empty string for the wildcard address
// addresses [registry, node]: IP addresses on which to listen for each API, or empty string for the wildcard address

// server_address [registry, node]: if specified, this becomes the default address on which to listen for each API instead of the wildcard address
//"server_address": "",

// addresses [registry, node]: IP addresses on which to listen for specific APIs

//"settings_address": "127.0.0.1",
//"logging_address": "",

// addresses [registry]: addresses on which to listen for each API, or empty string for the wildcard address
// addresses [registry]: IP addresses on which to listen for specific APIs

//"admin_address": "",
//"mdns_address": "",
//"schemas_address": "",

// client_address [registry, node]: IP address of the network interface to bind client connections
// for now, only supporting HTTP/HTTPS client connections on Linux
//"client_address": "",

// query_ws_paging_default/query_ws_paging_limit [registry]: default/maximum number of events per message when using the Query WebSocket API (a client may request a lower limit)
//"query_ws_paging_default": 10,
//"query_ws_paging_limit": 100,
Expand Down
3 changes: 0 additions & 3 deletions Development/nmos/api_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,6 @@ namespace nmos
};
}

static const utility::string_t received_time{ U("X-Received-Time") };
static const utility::string_t actual_method{ U("X-Actual-Method") };

// make handler to set appropriate response headers, and error response body if indicated
web::http::experimental::listener::route_handler make_api_finally_handler(slog::base_gate& gate)
{
Expand Down
3 changes: 3 additions & 0 deletions Development/nmos/api_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ namespace nmos

namespace details
{
const utility::string_t received_time{ U("X-Received-Time") };
const utility::string_t actual_method{ U("X-Actual-Method") };

// exception to skip other route handlers and then send the response (see add_api_finally_handler)
struct to_api_finally_handler {};

Expand Down
20 changes: 20 additions & 0 deletions Development/nmos/asset.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef NMOS_ASSET_H
#define NMOS_ASSET_H

#include "cpprest/json_utils.h"

// Asset Distinguishing Information
// See https://specs.amwa.tv/bcp-002-02/
// and https://specs.amwa.tv/nmos-parameter-registers/branches/main/tags/
namespace nmos
{
namespace fields
{
const web::json::field_as_value_or asset_manufacturer{ U("urn:x-nmos:tag:asset:manufacturer/v1.0"), web::json::value::array() };
const web::json::field_as_value_or asset_product_name{ U("urn:x-nmos:tag:asset:product/v1.0"), web::json::value::array() };
const web::json::field_as_value_or asset_instance_id{ U("urn:x-nmos:tag:asset:instance-id/v1.0"), web::json::value::array() };
const web::json::field_as_value_or asset_function{ U("urn:x-nmos:tag:asset:function/v1.0"), web::json::value::array() };
}
}

#endif
48 changes: 48 additions & 0 deletions Development/nmos/channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,52 @@ namespace nmos

return channel_order.str();
}

// See SMPTE ST 2110-30:2017 Section 6.2.2 Channel Order Convention
std::vector<nmos::channel_symbol> parse_fmtp_channel_order(const utility::string_t& channel_order)
{
std::vector<nmos::channel_symbol> channels;

const auto first = channel_order.data();
const auto last = first + channel_order.size();
auto it = first;

// check prefix

static const auto prefix = U("SMPTE2110.(");
auto pit = &prefix[0];
while (it != last && *pit != U('\0') && *it == *pit) ++it, ++pit;
if (*pit != U('\0')) return {};

// parse comma-separated channel group symbols

while (true)
{
const auto git = it;
while (it != last && *it != U(')') && *it != U(',')) ++it;
if (it == last) return {};

const channel_group_symbol symbol(utility::string_t(git, it));

// hm, does not handle 22.2 Surround ('222'), SDI audio group ('SGRP') or Undefined ('U01' to 'U64')
auto group = std::find_if(details::channel_groups.begin(), details::channel_groups.end(),
[&](const std::pair<std::vector<channel_symbol>, channel_group_symbol>& group)
{
return symbol == group.second;
});
if (details::channel_groups.end() == group) return {};
channels.insert(channels.end(), group->first.begin(), group->first.end());

if (*it == U(')')) break;
++it;
}

// check suffix

if (it == last) return {};
++it;
if (it != last) return {};

return channels;
}
}
1 change: 1 addition & 0 deletions Development/nmos/channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ namespace nmos

// See SMPTE ST 2110-30:2017 Section 6.2.2 Channel Order Convention
utility::string_t make_fmtp_channel_order(const std::vector<channel_symbol>& channels);
std::vector<nmos::channel_symbol> parse_fmtp_channel_order(const utility::string_t& channel_order);
}

#endif
Loading

0 comments on commit d683757

Please sign in to comment.