Browse Source

rtmp-services: Add JSONSchema definitions for services

Matt Gajownik 3 years ago
parent
commit
2960669f9a

+ 1 - 0
plugins/rtmp-services/data/package.json

@@ -1,4 +1,5 @@
 {
+	"$schema": "schema/package-schema.json",
 	"url": "https://obsproject.com/obs2_update/rtmp-services",
 	"version": 197,
 	"files": [

+ 47 - 0
plugins/rtmp-services/data/schema/package-schema.json

@@ -0,0 +1,47 @@
+{
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "type": "object",
+    "properties": {
+        "url": {
+            "$ref": "#/definitions/saneUrl",
+            "description": "Points to the base URL of hosted package.json and services.json files, used to automatically fetch the latest version."
+        },
+        "version": {
+            "type": "integer"
+        },
+        "files": {
+            "type": "array",
+            "items": {
+                "type": "object",
+                "properties": {
+                    "name": {
+                        "type": "string",
+                        "description": "Filename to read,, containing service definitions."
+                    },
+                    "version": {
+                        "type": "integer",
+                        "description": "This value should be bumped any time the file defined by the 'name' field is changed. This value will be used when determining whether a new version is available."
+                    }
+                },
+                "required": [
+                    "name",
+                    "version"
+                ]
+            },
+            "description": "List of files to read, each containing a list of services.",
+            "additionalProperties": false
+        }
+    },
+    "required": [
+        "url",
+        "version",
+        "files"
+    ],
+    "definitions": {
+        "saneUrl": {
+            "type": "string",
+            "format": "uri",
+            "pattern": "^https?://"
+        }
+    }
+}

+ 212 - 0
plugins/rtmp-services/data/schema/service-schema-v3.json

@@ -0,0 +1,212 @@
+{
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "type": "object",
+    "properties": {
+        "format_version": {
+            "type": "integer",
+            "description": "Identifier for parsing this file.\n- v3 introduced 'ffmpeg_hls_muxer' to services/recommended/output\n - v2 introduced 'alt_names' to services"
+        },
+        "services": {
+            "type": "array",
+            "items": {
+                "type": "object",
+                "properties": {
+                    "name": {
+                        "type": "string",
+                        "description": "Name of the streaming service. Will be displayed in the Service dropdown.",
+                        "minLength": 1
+                    },
+                    "common": {
+                        "type": "boolean",
+                        "description": "Whether or not the service is shown in the list before it is expanded to all services by the user.",
+                        "default": false
+                    },
+                    "stream_key_link": {
+                        "$ref": "#/definitions/saneUrl",
+                        "description": "Link where a logged-in user can find the 'stream key', presented as a button alongside the stream key field."
+                    },
+                    "servers": {
+                        "type": "array",
+                        "description": "List of servers.",
+                        "items": {
+                            "type": "object",
+                            "properties": {
+                                "name": {
+                                    "type": "string",
+                                    "description": "Name of the server (e.g. location, primary/backup), displayed in the Server dropdown.",
+                                    "minLength": 1
+                                },
+                                "url": {
+                                    "$ref": "#/definitions/serviceUri",
+                                    "description": "RTMP(S) or HLS URL of the ingest server.",
+                                    "minLength": 1
+                                }
+                            },
+                            "additionalProperties": false,
+                            "required": [
+                                "name",
+                                "url"
+                            ]
+                        },
+                        "default": [
+                            {
+                                "name": "",
+                                "url": ""
+                            }
+                        ],
+                        "minItems": 1,
+                        "additionalItems": true
+                    },
+                    "recommended": {
+                        "type": "object",
+                        "description": "Recommended service settings. Users will be unable to choose values outside of these by default, so choose recommended values carefully.",
+                        "properties": {
+                            "keyint": {
+                                "type": "integer",
+                                "description": "Keyframe interval (seconds)."
+                            },
+                            "max video bitrate": {
+                                "type": "integer",
+                                "description": "Highest supported video bitrate (kbps)."
+                            },
+                            "max audio bitrate": {
+                                "type": "integer",
+                                "description": "Highest supported audio bitrate (kbps)."
+                            },
+                            "x264opts": {
+                                "type": "string",
+                                "description": "Additional x264 encoder options. Space-separated.",
+                                "pattern": "^(\\S+=\\S+\\s*)+$"
+                            },
+                            "output": {
+                                "type": "string",
+                                "description": "OBS output module used.",
+                                "enum": [
+                                    "rtmp_output",
+                                    "ffmpeg_hls_muxer",
+                                    "ftl_output"
+                                ]
+                            },
+                            "profile": {
+                                "type": "string",
+                                "description": "H.264 Profile.",
+                                "minLength": 1,
+                                "enum": [
+                                    "high",
+                                    "main",
+                                    "baseline"
+                                ]
+                            },
+                            "bframes": {
+                                "type": "integer",
+                                "description": "Maximum allowed number of B-Frames."
+                            },
+                            "supported resolutions": {
+                                "type": "array",
+                                "description": "List of supported resolutions in format {width}x{height}",
+                                "items": {
+                                    "$ref": "#/definitions/resolution"
+                                },
+                                "minItems": 1,
+                                "additionalItems": true
+                            },
+                            "max fps": {
+                                "type": "integer",
+                                "description": "Maximum supported framerate."
+                            },
+                            "bitrate matrix": {
+                                "type": "array",
+                                "description": "List of resolutions and frame rate combinations with their recommended maximum bitrate.",
+                                "items": {
+                                    "type": "object",
+                                    "properties": {
+                                        "res": {
+                                            "$ref": "#/definitions/resolution",
+                                            "description": "Resolution in format {width}x{height}"
+                                        },
+                                        "fps": {
+                                            "type": "integer",
+                                            "description": "Frame rate"
+                                        },
+                                        "max bitrate": {
+                                            "type": "integer",
+                                            "description": "Maximum bitrate in kbps."
+                                        }
+                                    },
+                                    "minItems": 1,
+                                    "additionalProperties": false,
+                                    "required": [
+                                        "res",
+                                        "fps",
+                                        "max bitrate"
+                                    ]
+                                },
+                                "default": [
+                                    {
+                                        "res": "",
+                                        "fps": "",
+                                        "max bitrate": ""
+                                    }
+                                ],
+                                "additionalItems": true
+                            }
+                        },
+                        "additionalProperties": false
+                    },
+                    "more_info_link": {
+                        "$ref": "#/definitions/saneUrl",
+                        "description": "Link that provides additional info about the service, presented in the UI as a button next to the services dropdown."
+                    },
+                    "alt_names": {
+                        "type": "array",
+                        "description": "Previous names of the service used for migrating existing users to the updated entry.",
+                        "items": {
+                            "type": "string",
+                            "minLength": 1
+                        },
+                        "default": [
+                            ""
+                        ]
+                    }
+                },
+                "additionalProperties": false,
+                "required": [
+                    "name",
+                    "servers"
+                ]
+            },
+            "additionalItems": true
+        }
+    },
+    "additionalProperties": true,
+    "required": [
+        "format_version",
+        "services"
+    ],
+    "definitions": {
+        "resolution": {
+            "type": "string",
+            "pattern": "^\\d+x\\d+$",
+            "default": ""
+        },
+        "saneUrl": {
+            "type": "string",
+            "format": "uri",
+            "pattern": "^https?://.+",
+            "default": "https://"
+        },
+        "serviceUri": {
+            "anyOf": [
+                {
+                    "type": "string",
+                    "format": "uri",
+                    "pattern": "^(https|http|rtmps|rtmp|srt|rist)?://"
+                },
+                {
+                    "type": "string",
+                    "format": "hostname"
+                }
+            ]
+        }
+    }
+}

+ 1 - 0
plugins/rtmp-services/data/services.json

@@ -1,4 +1,5 @@
 {
+    "$schema": "schema/service-schema-v3.json",
     "format_version": 3,
     "services": [
         {