{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "description": "Describes a receiver",
    "title": "Receiver resource",
    "additionalProperties": false,
    "properties": {
        "sender_id": {
            "description": "ID of the Sender subscribed to by this Receiver. This will be null if the receiver has not been configured to receive anything, or if it is receiving from a non-NMOS sender.",
            "type": [
                "string",
                "null"
            ],
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "master_enable": {
            "description": "Master on/off control for receiver",
            "type": "boolean",
            "default": true
        },
        "activation":{
            "description": "Parameters concerned with activation of the transport parameters",
            "type": "object",
            "additionalProperties": false,
            "properties":{
                "mode": {
                    "description": "Mode of activation: immediate (on message receipt), scheduled_absolute (when internal clock >= requested_time), scheduled_relative (when internal clock >= time of message receipt + requested_time), or null (no activation scheduled)",
                    "type": [
                        "string",
                        "null"
                    ],
                    "enum": [
                        "activate_immediate",
                        "activate_scheduled_absolute",
                        "activate_scheduled_relative",
                        null
                    ]
                },
                "requested_time": {
                    "description": "String formatted TAI timestamp (<seconds>:<nanoseconds>) indicating time (absolute or relative) for activation",
                    "type": [
                        "string",
                        "null"
                    ],
                    "pattern": "^[0-9]+:[0-9]+$"
                }
            }
        },
        "transport_file":{
            "type": "object",
            "description": "Transport file parameters",
            "additionalProperties": false,
            "properties":{
                "data":{
                    "description": "Content of the transport file",
                    "type": [
                        "string",
                        "null"
                    ]
                },
                "type":{
                    "description": "IANA assigned media type for file (e.g application/sdp)",
                    "type": [
                        "string",
                        "null"
                    ]
                }
            }
        },
        "transport_params": {
            "description": "Transport-specific parameters",
            "oneOf": [
                {
                    "description": "Describes RTP Receiver transport parameters. The constraints in this schema are minimum constraints, but may be further constrained at the constraints endpoint.",
                    "type": "array",
                    "items": {
                        "type": "object",
                        "title": "Receiver Input",
                        "additionalProperties": false,
                        "properties": {
                            "source_ip": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "description": "Source IP address of RTP packets in unicast mode, source filter for source specific multicast. A null value indicates that the receiver has not yet been configured.",
                                "anyOf": [
                                    {
                                        "format": "ipv4"
                                    },
                                    {
                                        "format": "ipv6"
                                    },
                                    {
                                        "type": "null"
                                    }
                                ]
                            },
                            "multicast_ip":{
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "description": "IP multicast group address used in multicast operation only. Should be set to null during unicast operation.",
                                "anyOf": [
                                    {
                                        "format": "ipv4"
                                    },
                                    {
                                        "format": "ipv6"
                                    },
                                    {
                                        "type": "null"
                                    }
                                ]
                            },
                            "interface_ip":{
                                "type": "string",
                                "description": "IP address of the network interface the receiver should use. The receiver should provide an enum in the constraints endpoint, which should contain 'auto', and the available interface addresses. If set to auto in multicast mode the receiver should determine which interface to use for itself. The behaviour of auto is undefined in unicast mode, and controllers should supply a specific interface address.",
                                "anyOf": [
                                    {
                                        "format": "ipv4"
                                    },
                                    {
                                        "format": "ipv6"
                                    },
                                    {
                                        "pattern": "^auto$"
                                    }
                                ],
                                "default": "auto"
                            },
                            "destination_port": {
                                "type": "integer",
                                "description": "destination port for RTP packets",
                                "minimum": 1,
                                "maximum": 65535,
                                "default": 5004
                            },
                            "fec_enabled": {
                                "type": "boolean",
                                "description": "FEC usage on/off",
                                "default": false
                            },
                            "fec_destination_ip": {
                                "type": "string",
                                "description": "May be used if NAT is being used at the destination (auto = rtp_dest_ip)",
                                "anyOf": [
                                    {
                                        "format": "ipv4"
                                    },
                                    {
                                        "format": "ipv6"
                                    },
                                    {
                                        "pattern": "^auto$"
                                    }
                                ],
                                "default": "auto"
                            },
                            "fec_type": {
                                "type": "string",
                                "description": "forward error correction mode to apply",
                                "enum": [
                                    "XOR",
                                    "Reed-Solomon"
                                ],
                                "default": "XOR"
                            },
                            "fec_mode": {
                                "type": "string",
                                "description": "forward error correction mode to apply",
                                "enum": [
                                    "1D",
                                    "2D"
                                ],
                                "default": "1D"
                            },
                            "fec1D_destination_port": {
                                "type": [
                                    "integer",
                                    "string"
                                ],
                                "description": "destination port for RTP Column FEC packets (auto = RTP dest_port+2)",
                                "minimum": 1,
                                "maximum": 65535,
                                "pattern": "^auto$",
                                "default": "auto"
                            },
                            "fec2D_destination_port": {
                                "type": [
                                    "integer",
                                    "string"
                                ],
                                "description": "destination port for RTP Row FEC packets (auto = RTP dest_port+4)",
                                "minimum": 1,
                                "maximum": 65535,
                                "pattern": "^auto$",
                                "default": "auto"
                            },
                            "rtcp_destination_ip": {
                                "type": "string",
                                "description": "Destination IP address of RTCP packets (auto = same as RTP dest_ip)",
                                "anyOf": [
                                    {
                                        "format": "ipv4"
                                    },
                                    {
                                        "format": "ipv6"
                                    },
                                    {
                                        "pattern": "^auto$"
                                    }
                                ],
                                "default": "auto"
                            },
                            "rtcp_enabled": {
                                "type": "boolean",
                                "description": "rtcp on/off",
                                "default": false
                            },
                            "rtcp_destination_port": {
                                "type": [
                                    "integer",
                                    "string"
                                ],
                                "description": "destination port for RTCP packets (auto = RTP dest_port+1 )",
                                "minimum": 1,
                                "maximum": 65535,
                                "pattern": "^auto$",
                                "default": "auto"
                            },
                            "rtp_enabled": {
                                "type": "boolean",
                                "description": "RTP reception active/inactive",
                                "default": true
                            }
                        }
                    },
                    "maxItems": 2
                }

            ]
        }
    }
}
