Skip to content

Commit

Permalink
* Initial submit for tests general (0), Senders (2), Outputs (3), Rec…
Browse files Browse the repository at this point in the history
…eivers (4) (#761)

Based on IS-11 Test Plan v0.6
Senders contains tests 2.0, 2.1 and 2.2
Receivers contains tests 4.1 and 4.2

Signed-off-by: ggeorgea <[email protected]>
Co-authored-by: Gareth Sylvester-Bradley <[email protected]>
  • Loading branch information
gwgeorgea and garethsb authored Apr 27, 2023
1 parent 2a2e7ce commit 4da3b4a
Show file tree
Hide file tree
Showing 4 changed files with 1,795 additions and 46 deletions.
100 changes: 98 additions & 2 deletions nmostesting/IS04Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re
from copy import deepcopy
from fractions import Fraction
from . import TestHelper

from .NMOSUtils import NMOSUtils
from copy import deepcopy


class IS04Utils(NMOSUtils):
Expand Down Expand Up @@ -71,6 +72,101 @@ def get_resources(self, resource, url=None):
return toReturn

@staticmethod
def comparable_parameter_constraint_value(value):
if isinstance(value, dict):
return Fraction(value["numerator"], value.get("denominator", 1))
return value

@staticmethod
def comparable_parameter_constraint(param_constraint):
result = deepcopy(param_constraint)
if "minimum" in result:
result["minimum"] = IS04Utils.comparable_parameter_constraint_value(
result["minimum"]
)
if "maximum" in result:
result["maximum"] = IS04Utils.comparable_parameter_constraint_value(
result["maximum"]
)
if "enum" in result:
for i, value in enumerate(result["enum"]):
result["enum"][i] = IS04Utils.comparable_parameter_constraint_value(
value
)
return result

@staticmethod
def comparable_constraint_set(constraint_set):
result = {
k: IS04Utils.comparable_parameter_constraint(v)
if re.match("^urn:x-nmos:cap:(?!meta:)", k)
else v
for k, v in constraint_set.items()
}
# could also remove urn:x-nmos:cap:meta:label?
if "urn:x-nmos:cap:meta:preference" not in result:
result["urn:x-nmos:cap:meta:preference"] = 0
if "urn:x-nmos:cap:meta:enabled" not in result:
result["urn:x-nmos:cap:meta:enabled"] = True
return result

@staticmethod
def comparable_constraint_sets(constraint_sets):
return [IS04Utils.comparable_constraint_set(_) for _ in constraint_sets]

@staticmethod
def compare_constraint_sets(lhs, rhs):
"""Check that two Constraint Sets arrays are closely equivalent"""
return TestHelper.compare_json(
IS04Utils.comparable_constraint_sets(lhs),
IS04Utils.comparable_constraint_sets(rhs),
)

@staticmethod
def make_sampling(flow_components):
samplers = {
# Red-Green-Blue-Alpha
"RGBA": {"R": (1, 1), "G": (1, 1), "B": (1, 1), "A": (1, 1)},
# Red-Green-Blue
"RGB": {"R": (1, 1), "G": (1, 1), "B": (1, 1)},
# Non-constant luminance YCbCr
"YCbCr-4:4:4": {"Y": (1, 1), "Cb": (1, 1), "Cr": (1, 1)},
"YCbCr-4:2:2": {"Y": (1, 1), "Cb": (2, 1), "Cr": (2, 1)},
"YCbCr-4:2:0": {"Y": (1, 1), "Cb": (2, 2), "Cr": (2, 2)},
"YCbCr-4:1:1": {"Y": (1, 1), "Cb": (4, 1), "Cr": (4, 1)},
# Constant luminance YCbCr
"CLYCbCr-4:4:4": {"Yc": (1, 1), "Cbc": (1, 1), "Crc": (1, 1)},
"CLYCbCr-4:2:2": {"Yc": (1, 1), "Cbc": (2, 1), "Crc": (2, 1)},
"CLYCbCr-4:2:0": {"Yc": (1, 1), "Cbc": (2, 2), "Crc": (2, 2)},
# Constant intensity ICtCp
"ICtCp-4:4:4": {"I": (1, 1), "Ct": (1, 1), "Cp": (1, 1)},
"ICtCp-4:2:2": {"I": (1, 1), "Ct": (2, 1), "Cp": (2, 1)},
"ICtCp-4:2:0": {"I": (1, 1), "Ct": (2, 2), "Cp": (2, 2)},
# XYZ
"XYZ": {"X": (1, 1), "Y": (1, 1), "Z": (1, 1)},
# Key signal represented as a single component
"KEY": {"Key": (1, 1)},
# Sampling signaled by the payload
"UNSPECIFIED": {},
}

max_w, max_h = 0, 0
for component in flow_components:
w, h = component["width"], component["height"]
if w > max_w:
max_w = w
if h > max_h:
max_h = h

components_sampler = {}
for component in flow_components:
w, h = component["width"], component["height"]
components_sampler[component["name"]] = (max_w / w, max_h / h)

for sampling, sampler in samplers.items():
if sampler == components_sampler:
return sampling

def downgrade_resource(resource_type, resource_data, requested_version):
"""Downgrades given resource data to requested version"""
version_major, version_minor = [int(x) for x in requested_version[1:].split(".")]
Expand Down
14 changes: 4 additions & 10 deletions nmostesting/NMOSTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
from .suites import IS0902Test
# from .suites import IS1001Test
from .suites import IS1101Test
from .suites import IS1102Test
from .suites import BCP00301Test
from .suites import BCP0050101Test
from .suites import BCP0060101Test
Expand Down Expand Up @@ -342,19 +341,14 @@
"specs": [{
"spec_key": "is-11",
"api_key": "streamcompatibility"
}],
"class": IS1101Test.IS1101Test
},
"IS-11-02": {
"name": "IS-11 Interaction with IS-04",
"specs": [{
}, {
"spec_key": "is-04",
"api_key": "node"
}, {
"spec_key": "is-11",
"api_key": "streamcompatibility"
"spec_key": "is-05",
"api_key": "connection"
}],
"class": IS1102Test.IS1102Test
"class": IS1101Test.IS1101Test
},
"BCP-003-01": {
"name": "BCP-003-01 Secure Communication",
Expand Down
Loading

0 comments on commit 4da3b4a

Please sign in to comment.