{
	"$schema"     : "http://json-schema.org/draft-04/schema#",
	"id"          : "https://www.dvb.org/metadata/css/css-mrs.mi-1.1.1#",
	"title"       : "DVB Companion Screens and Streams - CSS-MRS Material Information message representation Schema",
	"description" : "Material Resolution Service response or update response containing Material Information",
	
	"type"       : "object",
	"properties" : {
		"version" : { "enum" : [ "1.1" ] },
		"rev"     : { "type" : "string" },
		"repollingInterval" : { "$ref" : "css-core-1.1.1#/definitions/zeroOrPositiveInteger" },
		"materials" : {
			"type"     : "object",
			"minItems" : 0,
			"patternProperties" : {
				"^.+$" : { "$ref" : "#/definitions/material" }
			}
		},
		"syncTimelineInformation" : {
			"type"     : "array",
			"minItems" : 0,
			"items"    : { "$ref" : "#/definitions/syncTimelineInformation" }
		},
		"updateMaterial" : {
			"type"     : "array",
			"minItems" : 0,
			"items"    : { "$ref" : "#/definitions/updateElement" }
		},
		"updateTimelineSync" : {
			"type"     : "array",
			"minItems" : 0,
			"items"    : { "$ref" : "#/definitions/updateElement" }
		}
	},
	"oneOf" : [
		{
			"properties" : {
				"type" : { "enum" : [ "response" ] }
			},
			"required" : [ "type", "version", "rev", "repollingInterval", "materials", "syncTimelineInformation" ],
			"not"      : { 
				"properties" : { "patchData" : { } },
				"required"   : [ "patchData" ]
			}
		},
		{
			"properties" : {
				"type"            : { "enum" : [ "update" ] },
				"updateVersionNo" : { "$ref" : "css-core-1.1.1#/definitions/integerAsString" },
				"patchData"       : { "$ref" : "css-core-1.1.1#/definitions/jsonPatchSyncTimelineInformation" }
			},
			"required" : [ "type", "updateVersionNo" ]
		}
	],
	"additionalProperties" : true,
	
	"definitions" : {
	
		"material" : {
			"type"       : "object",
			"properties" : {
				"parents" : {
					"type"     : "array",
					"minItems" : 0,
					"items"    : { "type" : "string" }
				},
				"contentIdStem" : { "$ref" : "css-core-1.1.1#/definitions/contentIdStem" },
				"ids" : {
					"type"     : "array",
					"minItems" : 1,
					"items"    : { "$ref" : "css-core-1.1.1#/definitions/id" }
				},
				"timelineProperties" : {
					"allOf" : [
						{ "$ref"     : "css-core-1.1.1#/definitions/timelineProperties" },
						{ "required" : [ "accuracy" ] }
					]
				},
				"triggerEventInfo" : {
					"type"       : "object",
					"properties" : {
						"contentIdStem" : { "$ref" : "css-core-1.1.1#/definitions/contentIdStem" },
						"triggerEvents" : { "$ref" : "css-core-1.1.1#/definitions/triggerEvents" }
					},
					"required" : [ "contentIdStem", "triggerEvents" ]
				},
				"private" : { "$ref" : "css-core-1.1.1#/definitions/private" }
			},
			"required" : [ "ids", "parents" ],
			"additionalProperties" : true
		},
		
		"syncTimelineInformation" : {
			"type"       : "object",
			"properties" : {
				"contentIdStem"       : { "$ref" : "css-core-1.1.1#/definitions/contentIdStem" },
				"leadupContentIdStem" : { "$ref" : "css-core-1.1.1#/definitions/contentIdStem" },
				"timelineSelector"    : { "$ref" : "css-core-1.1.1#/definitions/timelineSelector" },
				"timelineProperties"  : {
					"allOf" : [
						{ "$ref"     : "css-core-1.1.1#/definitions/timelineProperties" },
						{ "required" : [ "accuracy" ] }
					]
				},
				"mappings" : {
					"type"     : "array",
					"minItems" : 0,
					"items"    : { "$ref" : "css-core-1.1.1#/definitions/mapping" }
				},
				"private" : { "$ref" : "css-core-1.1.1#/definitions/private" }
			},
			"required" : [ "contentIdStem", "timelineSelector", "timelineProperties", "mappings" ],
			"additionalProperties" : true
		},

		"updateElement" : {
			"type"       : "object",
			"properties" : {
				"url"                  : { "type" : "string", "format" : "uri" },
				"mimeType"             : { "type" : "string" },
				"protocolSpecificData" : { "type" : "string" }
			},
			"required" : [ "url", "mimeType" ],
			"additionalProperties" : true
		}
	}
}
