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 Oct 31, 2023
2 parents d683757 + f7bd2f7 commit c183d98
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 28 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,25 @@ jobs:
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
# build and install openssl
curl -OsSk https://www.openssl.org/source/openssl-1.1.1v.tar.gz
tar xzf openssl-1.1.1v.tar.gz
cd openssl-1.1.1v
./config --prefix=/usr/local/custom-openssl --libdir=lib --openssldir=/etc/ssl
make -j1 depend
make -j8
make install_sw
cd ..
# install ffi.h, which is required for python build
apt install libffi-dev
# build and install python
curl -sSk https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tar.xz | tar -xJ
cd Python-3.11.5
./configure -C --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto
make -j8
make install
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.6 3
ln -s /usr/local/bin/python3.6 /usr/bin/python
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 3
ln -s /usr/local/bin/python3.11 /usr/bin/python
curl -sS https://bootstrap.pypa.io/pip/3.6/get-pip.py | python
curl -sS https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz | tar -xJ
echo "`pwd`/node-v12.16.2-linux-x64/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -1075,4 +1087,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
22 changes: 17 additions & 5 deletions .github/workflows/src/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,25 @@ jobs:
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
# build and install openssl
curl -OsSk https://www.openssl.org/source/openssl-1.1.1v.tar.gz
tar xzf openssl-1.1.1v.tar.gz
cd openssl-1.1.1v
./config --prefix=/usr/local/custom-openssl --libdir=lib --openssldir=/etc/ssl
make -j1 depend
make -j8
make install_sw
cd ..
# install ffi.h, which is required for python build
apt install libffi-dev
# build and install python
curl -sSk https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tar.xz | tar -xJ
cd Python-3.11.5
./configure -C --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto
make -j8
make install
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.6 3
ln -s /usr/local/bin/python3.6 /usr/bin/python
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 3
ln -s /usr/local/bin/python3.11 /usr/bin/python
curl -sS https://bootstrap.pypa.io/pip/3.6/get-pip.py | python
curl -sS https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz | tar -xJ
echo "`pwd`/node-v12.16.2-linux-x64/bin" >> $GITHUB_PATH
Expand Down
2 changes: 2 additions & 0 deletions Development/cmake/NmosCppLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ set(NMOS_CPP_NMOS_SOURCES
nmos/resource.cpp
nmos/resources.cpp
nmos/schemas_api.cpp
nmos/sdp_attributes.cpp
nmos/sdp_utils.cpp
nmos/server.cpp
nmos/server_utils.cpp
Expand Down Expand Up @@ -887,6 +888,7 @@ set(NMOS_CPP_NMOS_HEADERS
nmos/resource.h
nmos/resources.h
nmos/schemas_api.h
nmos/sdp_attributes.h
nmos/sdp_utils.h
nmos/server.h
nmos/server_utils.h
Expand Down
3 changes: 3 additions & 0 deletions Development/nmos-cpp-node/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
//"discovery_backoff_max": 30,
//"discovery_backoff_factor": 1.5,

// service_name_prefix [registry, node]: used as a prefix in the advertised service names ("<prefix>_<api>_<host>:<port>", e.g. "nmos-cpp_node_127-0-0-1:3212")
//"service_name_prefix": "nmos-cpp"

// registry_address [node]: IP address or host name used to construct request URLs for registry APIs (if not discovered via DNS-SD)
//"registry_address": ip-address-string,

Expand Down
3 changes: 3 additions & 0 deletions Development/nmos-cpp-registry/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
//"discovery_backoff_max": 30,
//"discovery_backoff_factor": 1.5,

// service_name_prefix [registry, node]: used as a prefix in the advertised service names ("<prefix>_<api>_<host>:<port>", e.g. "nmos-cpp_node_127-0-0-1:3212")
//"service_name_prefix": "nmos-cpp"

// port numbers [registry, node]: ports to which clients should connect for each API

// http_port [registry, node]: if specified, this becomes the default port for each HTTP API and the next higher port becomes the default for each WebSocket API
Expand Down
10 changes: 5 additions & 5 deletions Development/nmos/mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace nmos
// IS-09 System API does not use authorization
// See https://github.com/AMWA-TV/is-09/issues/21
if (nmos::service_types::system == service) return false;

const auto client_authorization = false;
return client_authorization;
}
Expand Down Expand Up @@ -294,9 +294,9 @@ namespace nmos
return{};
}

inline std::string service_base_name(const nmos::service_type& service)
inline std::string service_base_name(const nmos::service_type& service, const nmos::settings& settings)
{
return "nmos-cpp_" + service_api(service);
return utility::us2s(nmos::fields::service_name_prefix(settings)) + "_" + service_api(service);
}

inline std::set<nmos::api_version> service_versions(const nmos::service_type& service, const nmos::settings& settings)
Expand All @@ -312,7 +312,7 @@ namespace nmos
{
// this just serves as an example of a possible service naming strategy
// replacing '.' with '-', since although '.' is legal in service names, some DNS-SD implementations just don't like it
return boost::algorithm::replace_all_copy(details::service_base_name(service) + "_" + utility::us2s(nmos::get_host(settings)) + ":" + utility::us2s(utility::ostringstreamed(details::service_port(service, settings))), ".", "-");
return boost::algorithm::replace_all_copy(details::service_base_name(service, settings) + "_" + utility::us2s(nmos::get_host(settings)) + ":" + utility::us2s(utility::ostringstreamed(details::service_port(service, settings))), ".", "-");
}

// helper function for registering addresses when the host name is explicitly configured
Expand Down Expand Up @@ -695,7 +695,7 @@ namespace nmos
// use a short timeout that's long enough to ensure the daemon's cache is exhausted
// when no cancellation token is specified
const auto timeout = token.is_cancelable() ? nmos::fields::discovery_backoff_max(settings) : 1;

return resolve_service(discovery, mode, service, browse_domain, versions, priorities, protocols, authorization, true, std::chrono::seconds(timeout), token);
}
}
Expand Down
61 changes: 61 additions & 0 deletions Development/nmos/sdp_attributes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "nmos/sdp_attributes.h"

#include "cpprest/json_utils.h"

namespace nmos
{
namespace details
{
// hm, forward declaration for function in nmos/sdp_utils.cpp
std::pair<sdp::address_type, bool> get_address_type_multicast(const utility::string_t& address);
}

namespace sdp_attributes
{
web::json::value make_extmap(const extmap& extmap)
{
using web::json::value_of;

const bool keep_order = true;

return value_of({
{ sdp::fields::name, sdp::attributes::extmap },
{ sdp::fields::value, value_of({
{ sdp::fields::local_id, extmap.local_id },
{ extmap.direction != sdp::direction{} ? sdp::fields::direction.key : U(""), extmap.direction.name },
{ sdp::fields::uri, extmap.uri },
{ !extmap.ext_attributes.empty() ? sdp::fields::extensionattributes.key : U(""), extmap.ext_attributes },
}, keep_order) }
}, keep_order);
}

extmap parse_extmap(const web::json::value& extmap)
{
return{ sdp::fields::local_id(extmap), sdp::direction(sdp::fields::direction(extmap)), sdp::fields::uri(extmap), sdp::fields::extensionattributes(extmap) };
}

web::json::value make_hkep(const hkep& hkep)
{
using web::json::value_of;

const bool keep_order = true;

return value_of({
{ sdp::fields::name, sdp::attributes::hkep },
{ sdp::fields::value, value_of({
{ sdp::fields::port, hkep.port },
{ sdp::fields::network_type, sdp::network_types::internet.name },
{ sdp::fields::address_type, details::get_address_type_multicast(hkep.unicast_address).first.name },
{ sdp::fields::unicast_address, hkep.unicast_address },
{ sdp::fields::node_id, hkep.node_id },
{ sdp::fields::port_id, hkep.port_id },
}, keep_order) }
}, keep_order);
}

hkep parse_hkep(const web::json::value& hkep)
{
return{ sdp::fields::port(hkep), sdp::fields::unicast_address(hkep), sdp::fields::node_id(hkep), sdp::fields::port_id(hkep) };
}
}
}
48 changes: 48 additions & 0 deletions Development/nmos/sdp_attributes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef NMOS_SDP_ATTRIBUTES_H
#define NMOS_SDP_ATTRIBUTES_H

#include "sdp/json.h"

namespace nmos
{
namespace sdp_attributes
{
// RTP Header Extensions
// See https://tools.ietf.org/html/rfc5285#section-5
struct extmap
{
uint64_t local_id;
sdp::direction direction;
utility::string_t uri;
utility::string_t ext_attributes;

extmap() : local_id() {}
extmap(uint64_t local_id, const utility::string_t& uri) : local_id(local_id), uri(uri) {}
extmap(uint64_t local_id, const sdp::direction& direction, const utility::string_t& uri) : local_id(local_id), direction(direction), uri(uri) {}
extmap(uint64_t local_id, const utility::string_t& uri, const utility::string_t& ext_attributes) : local_id(local_id), uri(uri), ext_attributes(ext_attributes) {}
extmap(uint64_t local_id, const sdp::direction& direction, const utility::string_t& uri, const utility::string_t& ext_attributes) : local_id(local_id), direction(direction), uri(uri), ext_attributes(ext_attributes) {}
};

web::json::value make_extmap(const extmap& extmap);
extmap parse_extmap(const web::json::value& extmap);

// HDCP Key Exchange Protocol (HKEP) Signalling
// See VSF TR-10-5:2022 Internet Protocol Media Experience (IPMX): HDCP Key Exchange Protocol, Section 10
// at https://videoservicesforum.com/download/technical_recommendations/VSF_TR-10-5_2022-03-22.pdf
struct hkep
{
uint64_t port;
utility::string_t unicast_address;
utility::string_t node_id;
utility::string_t port_id;

hkep() : port() {}
hkep(uint64_t port, const utility::string_t& unicast_address, const utility::string_t& node_id, const utility::string_t& port_id) : port(port), unicast_address(unicast_address), node_id(node_id), port_id(port_id) {}
};

web::json::value make_hkep(const hkep& hkep);
hkep parse_hkep(const web::json::value& hkep);
}
}

#endif
2 changes: 1 addition & 1 deletion Development/nmos/sdp_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace nmos

// For now, only the default payload format is covered.
//std::vector<std::pair<rtpmap_t, fmtp_t>> alternative_rtpmap_fmtp;

// Timestamp Reference Clock Source Signalling ("a=ts-refclk:")
// See https://tools.ietf.org/html/rfc7273#section-4
struct ts_refclk_t
Expand Down
3 changes: 3 additions & 0 deletions Development/nmos/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ namespace nmos
const web::json::field_as_integer_or discovery_backoff_max{ U("discovery_backoff_max"), 30 };
const web::json::field_with_default<double> discovery_backoff_factor{ U("discovery_backoff_factor"), 1.5 };

// service_name_prefix [registry, node]: used as a prefix in the advertised service names ("<prefix>_<api>_<host>:<port>", e.g. "nmos-cpp_node_127-0-0-1:3212")
const web::json::field_as_string_or service_name_prefix{ U("service_name_prefix"), U("nmos-cpp") };

// registry_address [node]: IP address or host name used to construct request URLs for registry APIs (if not discovered via DNS-SD)
const web::json::field_as_string registry_address{ U("registry_address") };

Expand Down
32 changes: 31 additions & 1 deletion Development/sdp/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ namespace sdp
// See https://tools.ietf.org/html/rfc7273
const utility::string_t ts_refclk{ U("ts-refclk") };
const utility::string_t mediaclk{ U("mediaclk") };

// See VSF TR-10-5:2022 Internet Protocol Media Experience (IPMX): HDCP Key Exchange Protocol, Section 10
// at https://videoservicesforum.com/download/technical_recommendations/VSF_TR-10-5_2022-03-22.pdf
const utility::string_t hkep{ U("hkep") };

// See https://tools.ietf.org/html/rfc5285#section-5
const utility::string_t extmap{ U("extmap") };
}

namespace fields
Expand Down Expand Up @@ -195,6 +202,18 @@ namespace sdp

// a=mediaclk:[id=<clock id> ]<clock source>[=<clock parameters>]
// See https://tools.ietf.org/html/rfc7273#section-5

// a=hkep:<port> <nettype> <addrtype> <unicast-address> <node-id> <port-id>
// See VSF TR-10-5:2022 Internet Protocol Media Experience (IPMX): HDCP Key Exchange Protocol, Section 10
// at https://videoservicesforum.com/download/technical_recommendations/VSF_TR-10-5_2022-03-22.pdf
const web::json::field_as_string node_id{ U("node_id") };
const web::json::field_as_string port_id{ U("port_id") };

// a=extmap:<value>["/"<direction>] <URI> <extensionattributes>
// See https://tools.ietf.org/html/rfc5285#section-5
const web::json::field<uint64_t> local_id{ U("local_id") };
const web::json::field_as_string_or direction{ U("direction"), {} }; // see sdp::direction
const web::json::field_as_string_or extensionattributes{ U("extensionattributes"), {} };
}

// make a named value (useful for attributes)
Expand Down Expand Up @@ -299,6 +318,16 @@ namespace sdp
// IPv6
const address_type IP6{ U("IP6") };
}

// Direction
DEFINE_STRING_ENUM(direction)
namespace directions
{
const direction recvonly{ U("recvonly") };
const direction sendrecv{ U("sendrecv") };
const direction sendonly{ U("sendonly") };
const direction inactive{ U("inactive") };
}
}

// Session Description Protocol (SDP) Source Filters
Expand Down Expand Up @@ -424,7 +453,8 @@ namespace sdp

// See https://tools.ietf.org/html/rfc4175
// and SMPTE ST 2110-20:2022 Section 7 Session Description Protocol (SDP) Considerations
// and VSF TR-05:2018
// and VSF TR-05:2018 Essential Formats and Descriptions for Interoperability of SMPTE ST 2110-20 Video Signals
// at https://videoservicesforum.net/download/technical_recommendations/VSF_TR-05_2018-06-23.pdf

// ST 2110-20:2022 Section 7.2 Required Media Type Parameters
const web::json::field_as_string sampling{ U("sampling") }; // see sdp::sampling
Expand Down
Loading

0 comments on commit c183d98

Please sign in to comment.