-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathcapabilities.h
79 lines (68 loc) · 5.29 KB
/
capabilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef NMOS_CAPABILITIES_H
#define NMOS_CAPABILITIES_H
#include "cpprest/json_utils.h"
#include "nmos/rational.h"
namespace nmos
{
// BCP-004-01 Receiver Capabilities
// See https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/docs/1.0._Receiver_Capabilities.html
namespace fields
{
const web::json::field_as_value_or constraint_sets{ U("constraint_sets"), {} };
}
template <typename T> inline std::vector<T> no_enum() { return std::vector<T>(); }
template <typename T> inline T no_minimum() { return (std::numeric_limits<T>::max)(); }
template <typename T> inline T no_maximum() { return (std::numeric_limits<T>::min)(); }
template <> nmos::rational inline no_minimum() { return (std::numeric_limits<int64_t>::max)(); }
template <> nmos::rational inline no_maximum() { return 0; }
// See https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/docs/1.0._Receiver_Capabilities.html#string-constraint-keywords
web::json::value make_caps_string_constraint(const std::vector<utility::string_t>& enum_values = {}, const utility::string_t& pattern = {});
// See https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/docs/1.0._Receiver_Capabilities.html#integer-and-number-constraint-keywords
web::json::value make_caps_integer_constraint(const std::vector<int64_t>& enum_values = {}, int64_t minimum = no_minimum<int64_t>(), int64_t maximum = no_maximum<int64_t>());
// See https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/docs/1.0._Receiver_Capabilities.html#integer-and-number-constraint-keywords
web::json::value make_caps_number_constraint(const std::vector<double>& enum_values = {}, double minimum = no_minimum<double>(), double maximum = no_maximum<double>());
// See https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/docs/1.0._Receiver_Capabilities.html#boolean-constraint-keywords
web::json::value make_caps_boolean_constraint(const std::vector<bool>& enum_values = {});
// See https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/docs/1.0._Receiver_Capabilities.html#rational-constraint-keywords
web::json::value make_caps_rational_constraint(const std::vector<nmos::rational>& enum_values = {}, const nmos::rational& minimum = no_minimum<nmos::rational>(), const nmos::rational& maximum = no_maximum<nmos::rational>());
bool match_string_constraint(const utility::string_t& value, const web::json::value& constraint);
bool match_integer_constraint(int64_t value, const web::json::value& constraint);
bool match_number_constraint(double value, const web::json::value& constraint);
bool match_boolean_constraint(bool value, const web::json::value& constraint);
bool match_rational_constraint(const nmos::rational& value, const web::json::value& constraint);
bool match_constraint(const web::json::value& value, const web::json::value& constraint);
// NMOS Parameter Registers - Capabilities register
// See https://specs.amwa.tv/nmos-parameter-registers/branches/main/capabilities/
namespace caps
{
namespace meta
{
const web::json::field_as_string_or label{ U("urn:x-nmos:cap:meta:label"), U("") };
const web::json::field_as_integer_or preference{ U("urn:x-nmos:cap:meta:preference"), 0 };
const web::json::field_as_bool_or enabled{ U("urn:x-nmos:cap:meta:enabled"), true };
}
namespace format
{
const web::json::field_as_value_or media_type{ U("urn:x-nmos:cap:format:media_type"), {} }; // string
const web::json::field_as_value_or grain_rate{ U("urn:x-nmos:cap:format:grain_rate"), {} }; // rational
const web::json::field_as_value_or frame_width{ U("urn:x-nmos:cap:format:frame_width"), {} }; // integer
const web::json::field_as_value_or frame_height{ U("urn:x-nmos:cap:format:frame_height"), {} }; // integer
const web::json::field_as_value_or interlace_mode{ U("urn:x-nmos:cap:format:interlace_mode"), {} }; // string
const web::json::field_as_value_or colorspace{ U("urn:x-nmos:cap:format:colorspace"), {} }; // string
const web::json::field_as_value_or transfer_characteristic{ U("urn:x-nmos:cap:format:transfer_characteristic"), {} }; // string
const web::json::field_as_value_or color_sampling{ U("urn:x-nmos:cap:format:color_sampling"), {} }; // string
const web::json::field_as_value_or component_depth{ U("urn:x-nmos:cap:format:component_depth"), {} }; // integer
const web::json::field_as_value_or channel_count{ U("urn:x-nmos:cap:format:channel_count"), {} }; // integer
const web::json::field_as_value_or sample_rate{ U("urn:x-nmos:cap:format:sample_rate"), {} }; // rational
const web::json::field_as_value_or sample_depth{ U("urn:x-nmos:cap:format:sample_depth"), {} }; // integer
const web::json::field_as_value_or event_type{ U("urn:x-nmos:cap:format:event_type"), {} }; // string
}
namespace transport
{
const web::json::field_as_value_or packet_time{ U("urn:x-nmos:cap:transport:packet_time"), {} }; // number
const web::json::field_as_value_or max_packet_time{ U("urn:x-nmos:cap:transport:max_packet_time"), {} }; // number
const web::json::field_as_value_or st2110_21_sender_type{ U("urn:x-nmos:cap:transport:st2110_21_sender_type"), {} }; // string
}
}
}
#endif