From 2623edfea555cfea9ee439b645d0f0683a9b4357 Mon Sep 17 00:00:00 2001 From: kpears201 Date: Thu, 14 Sep 2023 10:46:47 -0700 Subject: [PATCH 1/7] feat: Player APIs (#177) --- .gitignore | 6 +- package-lock.json | 16 +- package.json | 5 +- src/openrpc/broadcast_player.json | 380 +++++++++ src/openrpc/player.json | 814 ++++++++++++++++++++ src/openrpc/streaming_player.json | 165 ++++ src/schemas/player.json | 45 ++ src/sdks/manage/sdk.config.json | 20 +- src/sdks/provider/.npmignore | 6 + src/sdks/provider/CHANGELOG.md | 0 src/sdks/provider/CONTRIBUTING.md | 1 + src/sdks/provider/LICENSE | 1 + src/sdks/provider/NOTICE | 1 + src/sdks/provider/README.md | 26 + src/sdks/provider/Setup.js | 36 + src/sdks/provider/jest.config.json | 8 + src/sdks/provider/package.json | 51 ++ src/sdks/provider/sdk.config.json | 26 + src/sdks/provider/src/js/sdk/index.mjs | 30 + src/sdks/provider/test/suite/player.test.ts | 39 + src/sdks/provider/tsconfig.json | 5 + 21 files changed, 1674 insertions(+), 7 deletions(-) create mode 100644 src/openrpc/broadcast_player.json create mode 100644 src/openrpc/player.json create mode 100644 src/openrpc/streaming_player.json create mode 100644 src/schemas/player.json create mode 100644 src/sdks/provider/.npmignore create mode 100644 src/sdks/provider/CHANGELOG.md create mode 120000 src/sdks/provider/CONTRIBUTING.md create mode 120000 src/sdks/provider/LICENSE create mode 120000 src/sdks/provider/NOTICE create mode 100644 src/sdks/provider/README.md create mode 100644 src/sdks/provider/Setup.js create mode 100644 src/sdks/provider/jest.config.json create mode 100644 src/sdks/provider/package.json create mode 100644 src/sdks/provider/sdk.config.json create mode 100644 src/sdks/provider/src/js/sdk/index.mjs create mode 100644 src/sdks/provider/test/suite/player.test.ts create mode 100644 src/sdks/provider/tsconfig.json diff --git a/.gitignore b/.gitignore index b267a7cd3..b3f74b548 100644 --- a/.gitignore +++ b/.gitignore @@ -3,9 +3,9 @@ dist/* src/sdks/core/build/* src/sdks/core/dist/* src/sdks/core/test/transpiled-suite/* -src/sdks/discovery/build/* -src/sdks/discovery/dist/* -src/sdks/discovery/test/transpiled-suite/* +src/sdks/provider/build/* +src/sdks/provider/dist/* +src/sdks/provider/test/transpiled-suite/* src/sdks/manage/build/* src/sdks/manage/dist/* src/sdks/manage/test/transpiled-suite/* diff --git a/package-lock.json b/package-lock.json index 8e5b22a64..5cbafe99e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "Apache-2.0", "workspaces": [ "src/sdks/core", - "src/sdks/manage" + "src/sdks/manage", + "src/sdks/provider" ], "bin": { "firebolt-version": "src/js/version.mjs" @@ -1152,6 +1153,10 @@ "node": ">=6" } }, + "node_modules/@firebolt-js/provider-sdk": { + "resolved": "src/sdks/provider", + "link": true + }, "node_modules/@firebolt-js/schemas": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@firebolt-js/schemas/-/schemas-2.0.0.tgz", @@ -17055,6 +17060,15 @@ "jest-environment-jsdom": "^28.1.3", "typescript": "^4.6.4" } + }, + "src/sdks/provider": { + "version": "0.16.0-next.3", + "license": "Apache-2.0", + "devDependencies": { + "jest": "^28.1.0", + "jest-environment-jsdom": "^28.1.3", + "typescript": "^4.6.4" + } } }, "dependencies": { diff --git a/package.json b/package.json index 0edb3d3f6..70f558b3a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "workspaces": [ "src/sdks/core", - "src/sdks/manage" + "src/sdks/manage", + "src/sdks/provider" ], "scripts": { "fs:setup": "npm run clean && mkdir -p dist", @@ -67,4 +68,4 @@ "sdk" ], "license": "Apache-2.0" -} +} \ No newline at end of file diff --git a/src/openrpc/broadcast_player.json b/src/openrpc/broadcast_player.json new file mode 100644 index 000000000..251ecec39 --- /dev/null +++ b/src/openrpc/broadcast_player.json @@ -0,0 +1,380 @@ +{ + "openrpc": "1.2.4", + "info": { + "title": "BroadcastPlayer", + "description": "A module for controlling and accessing media over broadcast", + "version": "0.0.0" + }, + "methods": [ + { + "name": "create", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:broadcast" + ] + }, + { + "name": "launch-provider" + } + ], + "summary": "Creates an instance of a player that can be used to play media over broadcast. Player instance that is created should also provide firebolt capability 'xrn:firebolt:capability:player:base'. If there is no provider running but there is a provider in the catalog, it will be launched.", + "params": [ + { + "name": "request", + "summary": "The create request", + "schema": { + "$ref": "#/components/schemas/BroadcastPlayerCreateRequest" + }, + "required": true + } + ], + "result": { + "name": "playerInstance", + "schema": { + "$ref": "#/components/schemas/BroadcastPlayerInstance" + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "request", + "value": {} + } + ], + "result": { + "name": "playerInstance", + "value": { + "playerId": "123", + "windowId": "456" + } + } + } + ] + }, + { + "name": "status", + "tags": [ + { + "name": "property:readonly" + }, + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:broadcast" + ] + } + ], + "summary": "Gets the latest broadcast status for the given player", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to get the status for", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "playerStatus", + "schema": { + "$ref": "#/components/schemas/BroadcastPlayerStatus" + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + } + ], + "result": { + "name": "playerStatus", + "value": { + "locked": false, + "frequency": 695000000, + "signalStrength": 90, + "signalQuality": 90 + } + } + }, + { + "name": "Default example #2", + "params": [ + { + "name": "playerId", + "value": "app2:456" + } + ], + "result": { + "name": "playerStatus", + "value": { + "locked": true, + "frequency": 695000000, + "signalStrength": 23, + "signalQuality": 55 + } + } + } + ] + }, + { + "name": "onRequestCreate", + "summary": "Registers as a provider for creating player instances", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/BroadcastPlayerInstance", + "examples": [ + { + "playerId": "123", + "windowId": "456" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:broadcast", + "x-allow-focus": false + } + ], + "result": { + "name": "createRequest", + "summary": "The request to create a new player", + "schema": { + "$ref": "#/components/schemas/BroadcastPlayerCreateProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": {} + } + } + } + ] + }, + { + "name": "onRequestStatus", + "summary": "Registers as a provider for when broadcast player status needs to be provided", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/BroadcastPlayerStatus", + "examples": [ + { + "locked": false, + "frequency": 695000000, + "signalStrength": 90, + "signalQuality": 90 + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:broadcast", + "x-allow-focus": false + } + ], + "result": { + "name": "statusRequest", + "summary": "The request to get the status of a player", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123" + } + } + } + } + ] + }, + { + "name": "provideStatus", + "tags": [ + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:broadcast" + } + ], + "summary": "Tells listeners the current broadcast status of a player", + "params": [ + { + "name": "playerId", + "summary": "The id of the player the status is for", + "schema": { + "type": "string" + }, + "required": true + }, + { + "name": "status", + "summary": "The status", + "schema": { + "$ref": "#/components/schemas/BroadcastPlayerStatus" + }, + "required": true + } + ], + "result": { + "name": "providedResponse", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "123" + }, + { + "name": "status", + "value": { + "locked": false, + "frequency": 695000000, + "signalStrength": 90, + "signalQuality": 90 + } + } + ], + "result": { + "name": "providedResponse", + "value": null + } + } + ] + } + ], + "components": { + "schemas": { + "BroadcastPlayerCreateProviderRequest": { + "title": "BroadcastPlayerCreateProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The request to load media in the player", + "$ref": "#/components/schemas/BroadcastPlayerCreateRequest" + } + }, + "examples": [ + {} + ] + }, + "BroadcastPlayerCreateRequest": { + "title": "BroadcastPlayerCreateRequest", + "type": "object", + "required": [], + "properties": {}, + "examples": [ + {} + ] + }, + "BroadcastPlayerInstance": { + "title": "BroadcastPlayerInstance", + "type": "object", + "required": [ + "playerId", + "windowId" + ], + "properties": { + "playerId": { + "description": "The id of player which can be used to load media or control the player", + "type": "string" + }, + "windowId": { + "description": "The id of window which will render the media in, can be used to control on screen where the media is shown", + "type": "string" + } + }, + "examples": [ + { + "playerId": "123", + "windowId": "456" + }, + { + "playerId": "abc", + "windowId": "def" + } + ] + }, + "BroadcastPlayerStatus": { + "title": "BroadcastPlayerStatus", + "type": "object", + "required": [ + "locked", + "frequency", + "signalStrength", + "signalQuality" + ], + "properties": { + "locked": { + "description": "Whether the current media has been locked", + "type": "boolean" + }, + "frequency": { + "description": "The signal frequency in hertz", + "type": "integer" + }, + "signalStrength": { + "description": "The strength of the signal from 0-100", + "type": "integer", + "minimum": 0, + "maximum": 100 + }, + "signalQuality": { + "description": "The quality of the signal from 0-100", + "type": "integer", + "minimum": 0, + "maximum": 100 + } + }, + "examples": [ + { + "locked": false, + "frequency": 1, + "signalStrength": 90, + "signalQuality": 90 + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/openrpc/player.json b/src/openrpc/player.json new file mode 100644 index 000000000..26d23273b --- /dev/null +++ b/src/openrpc/player.json @@ -0,0 +1,814 @@ +{ + "openrpc": "1.2.4", + "info": { + "title": "Player", + "description": "A module for providing and using media player capabilities. This handles operations that would be associated with any player generically", + "version": "0.0.0" + }, + "methods": [ + { + "name": "load", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Loads content in a player and starts a media session", + "params": [ + { + "name": "request", + "summary": "The load request", + "schema": { + "$ref": "#/components/schemas/PlayerLoadRequest" + }, + "required": true + } + ], + "result": { + "name": "mediaSession", + "schema": { + "$ref": "#/components/schemas/PlayerMediaSession" + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "request", + "value": { + "playerId": "app1:123", + "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + } + } + ], + "result": { + "name": "mediaSession", + "value": { + "mediaSessionId": "sess1" + } + } + } + ] + }, + { + "name": "play", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Starts playing the content that was last loaded", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to start playing", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "playResponse", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + } + ], + "result": { + "name": "playResponse", + "value": null + } + } + ] + }, + { + "name": "stop", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Stops playing the content that was last loaded", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to stop", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "stopResponse", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + } + ], + "result": { + "name": "stopResponse", + "value": null + } + } + ] + }, + { + "name": "status", + "tags": [ + { + "name": "property:readonly" + }, + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Gets the latest status for the given player", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to get the status for", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "playerStatus", + "schema": { + "$ref": "#/components/schemas/PlayerStatus" + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + } + ], + "result": { + "name": "playerStatus", + "value": { + "mediaSessionId": "sess1", + "state": "PLAYING" + } + } + }, + { + "name": "Default example #2", + "params": [ + { + "name": "playerId", + "value": "app2:456" + } + ], + "result": { + "name": "playerStatus", + "value": { + "mediaSessionId": "sess1", + "state": "BLOCKED", + "blockedReason": "CONTENT_NOT_FOUND" + } + } + } + ] + }, + { + "name": "progress", + "tags": [ + { + "name": "property:readonly" + }, + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Gets the latest progress for the given player", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to get the progress for", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "playerProgress", + "schema": { + "$ref": "#/components/schemas/PlayerProgress" + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + } + ], + "result": { + "name": "playerProgress", + "value": { + "speed": 1, + "startPosition": 0, + "position": 5000, + "endPosition": 3600000, + "liveSyncTime": "2021-04-23T18:25:43.511Z" + } + } + }, + { + "name": "Default example #2", + "params": [ + { + "name": "playerId", + "value": "app2:456" + } + ], + "result": { + "name": "playerProgress", + "value": { + "speed": 3, + "startPosition": 5000, + "position": 10000, + "endPosition": 3600000, + "liveSyncTime": "2021-05-23T18:25:43.511Z" + } + } + } + ] + }, + { + "name": "onRequestLoad", + "summary": "Registers as a provider for when new media should be loaded into the player", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerMediaSession", + "examples": [ + { + "mediaSessionId": "sess1" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "loadRequest", + "summary": "The request to load new media", + "schema": { + "$ref": "#/components/schemas/PlayerLoadProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "app1:123", + "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + } + } + } + } + ] + }, + { + "name": "onRequestPlay", + "summary": "Registers as a provider for when media should start playing", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerMediaSession", + "examples": [ + { + "mediaSessionId": "sess1" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "playRequest", + "summary": "The request to start playing media", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "app1:123" + } + } + } + } + ] + }, + { + "name": "onRequestStop", + "summary": "Registers as a provider for when media should stop playing", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerMediaSession", + "examples": [ + { + "mediaSessionId": "sess1" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "stopRequest", + "summary": "The request to stop playing media", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "app1:123" + } + } + } + } + ] + }, + { + "name": "onRequestStatus", + "summary": "Registers as a provider for when player status needs to be provided", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerStatus", + "examples": [ + { + "mediaSessionId": "sess1", + "state": "IDLE" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "statusRequest", + "summary": "The request to get the status of a player", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123" + } + } + } + } + ] + }, + { + "name": "onRequestProgress", + "summary": "Registers as a provider for when player progress needs to be provided", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerProgress", + "examples": [ + { + "speed": 1, + "startPosition": 0, + "position": 5000, + "endPosition": 3600000, + "liveSyncTime": "2021-04-23T18:25:43.511Z" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "progressRequest", + "summary": "The request to stop playing media", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123" + } + } + } + } + ] + }, + { + "name": "provideStatus", + "tags": [ + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base" + } + ], + "summary": "Tells listeners the current status of a player", + "params": [ + { + "name": "playerId", + "summary": "The id of the player the status is for", + "schema": { + "type": "string" + }, + "required": true + }, + { + "name": "status", + "summary": "The status", + "schema": { + "$ref": "#/components/schemas/PlayerStatus" + }, + "required": true + } + ], + "result": { + "name": "providedResponse", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "123" + }, + { + "name": "status", + "value": { + "mediaSessionId": "sess2", + "state": "BLOCKED", + "blockedReason": "CONTENT_NOT_FOUND" + } + } + ], + "result": { + "name": "providedResponse", + "value": null + } + } + ] + }, + { + "name": "provideProgress", + "tags": [ + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base" + } + ], + "summary": "Tells listeners the current progress of a player", + "params": [ + { + "name": "playerId", + "summary": "The id of the player the progress is for", + "schema": { + "type": "string" + }, + "required": true + }, + { + "name": "progress", + "summary": "The progress", + "schema": { + "$ref": "#/components/schemas/PlayerProgress" + }, + "required": true + } + ], + "result": { + "name": "providedResponse", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "123" + }, + { + "name": "progress", + "value": { + "speed": 1, + "startPosition": 0, + "position": 5000, + "endPosition": 3600000, + "liveSyncTime": "2021-04-23T18:25:43.511Z" + } + } + ], + "result": { + "name": "providedResponse", + "value": null + } + } + ] + } + ], + "components": { + "schemas": { + "PlayerLoadRequest": { + "title": "PlayerLoadRequest", + "type": "object", + "required": [ + "playerId", + "locator" + ], + "properties": { + "playerId": { + "description": "The id of the player instance to load the locator into", + "type": "string" + }, + "locator": { + "description": "A locator to the content to load", + "type": "string", + "format": "uri" + }, + "metadata": { + "description": "An opaque set of metadata that will be relevant to the player.", + "type": "object" + }, + "autoPlay": { + "description": "Start playing immediately on load without needing to call Player.play", + "type": "boolean" + } + }, + "examples": [ + { + "playerId": "app1:123", + "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + }, + { + "playerId": "app2:345", + "locator": "https://cdn.rdkcentral.com/media/assets/asset-2.hls", + "metadata": { + "assetType": "linear" + }, + "autoPlay": true + } + ] + }, + "PlayerMediaSession": { + "title": "PlayerMediaSession", + "type": "object", + "required": [ + "mediaSessionId" + ], + "properties": { + "mediaSessionId": { + "description": "The id of media session that was started, when the content was loaded. This should be a new value on each load", + "type": "string" + } + }, + "examples": [ + { + "mediaSessionId": "sess1" + }, + { + "mediaSessionId": "sess2" + } + ] + }, + "PlayerStatus": { + "title": "PlayerStatus", + "type": "object", + "required": [ + "mediaSessionId", + "state" + ], + "properties": { + "mediaSessionId": { + "description": "The id of media session that is currently loaded", + "type": "string" + }, + "state": { + "description": "The state of the player", + "type": "string", + "enum": [ + "IDLE", + "PENDING", + "PLAYING", + "BLOCKED", + "FAILED" + ] + }, + "blockedReason": { + "description": "The state of the player", + "type": "string", + "enum": [ + "NO_NETWORK", + "CONTENT_NOT_FOUND", + "DRM_ERROR", + "NOT_ENTITLED", + "GEO_BLOCKED", + "CHANNEL_NOT_SCANNED", + "NO_SIGNAL", + "TECHNICAL_FAULT", + "CHANNEL_OFF_AIR", + "PLAYER_FAILURE" + ] + } + }, + "examples": [ + { + "mediaSessionId": "sess1", + "state": "IDLE" + }, + { + "mediaSessionId": "sess2", + "state": "BLOCKED", + "blockedReason": "CONTENT_NOT_FOUND" + } + ] + }, + "PlayerProgress": { + "title": "PlayerProgress", + "type": "object", + "required": [ + "speed", + "startPosition", + "position", + "endPosition", + "liveSyncTime" + ], + "properties": { + "speed": { + "description": "The playback speed as a multiplier", + "type": "number" + }, + "startPosition": { + "description": "The position that the media starts at in milliseconds", + "type": "integer" + }, + "position": { + "description": "The current position in milliseconds", + "type": "integer" + }, + "endPosition": { + "description": "The position that the media stops at in milliseconds", + "type": "integer" + }, + "liveSyncTime": { + "description": "The time to sync to live", + "type": "string", + "format": "date-time" + } + }, + "examples": [ + { + "speed": 1, + "startPosition": 0, + "position": 5000, + "endPosition": 3600000, + "liveSyncTime": "2021-04-23T18:25:43.511Z" + }, + { + "speed": 3, + "startPosition": 5000, + "position": 10000, + "endPosition": 3600000, + "liveSyncTime": "2021-04-23T18:25:43.511Z" + } + ] + }, + "PlayerLoadProviderRequest": { + "title": "PlayerLoadProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The request to load media in the player", + "$ref": "#/components/schemas/PlayerLoadRequest" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/openrpc/streaming_player.json b/src/openrpc/streaming_player.json new file mode 100644 index 000000000..c800b22ec --- /dev/null +++ b/src/openrpc/streaming_player.json @@ -0,0 +1,165 @@ +{ + "openrpc": "1.2.4", + "info": { + "title": "StreamingPlayer", + "description": "A module for controlling and accessing media over streaming", + "version": "0.0.0" + }, + "methods": [ + { + "name": "create", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:streaming" + ] + }, + { + "name": "launch-provider" + } + ], + "summary": "Creates an instance of a player that can be used to play media over streaming. Player instance that is created should also provide firebolt capability 'xrn:firebolt:capability:player:base'. If there is no provider running but there is a provider in the catalog, it will be launched.", + "params": [ + { + "name": "request", + "summary": "The create request", + "schema": { + "$ref": "#/components/schemas/StreamingPlayerCreateRequest" + }, + "required": true + } + ], + "result": { + "name": "playerInstance", + "schema": { + "$ref": "#/components/schemas/StreamingPlayerInstance" + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "request", + "value": {} + } + ], + "result": { + "name": "playerInstance", + "value": { + "playerId": "123", + "windowId": "456" + } + } + } + ] + }, + { + "name": "onRequestCreate", + "summary": "Registers as a provider for creating player instances", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/StreamingPlayerInstance", + "examples": [ + { + "playerId": "123", + "windowId": "456" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:streaming", + "x-allow-focus": false + } + ], + "result": { + "name": "createRequest", + "summary": "The request to create a new player", + "schema": { + "$ref": "#/components/schemas/StreamingPlayerCreateProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": {} + } + } + } + ] + } + ], + "components": { + "schemas": { + "StreamingPlayerCreateProviderRequest": { + "title": "StreamingPlayerCreateProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The request to load media in the player", + "$ref": "#/components/schemas/StreamingPlayerCreateRequest" + } + }, + "examples": [ + {} + ] + }, + "StreamingPlayerCreateRequest": { + "title": "StreamingPlayerCreateRequest", + "type": "object", + "required": [], + "properties": {}, + "examples": [ + {} + ] + }, + "StreamingPlayerInstance": { + "title": "StreamingPlayerInstance", + "type": "object", + "required": [ + "playerId", + "windowId" + ], + "properties": { + "playerId": { + "description": "The id of player which can be used to load media or control the player", + "type": "string" + }, + "windowId": { + "description": "The id of window which will render the media in, can be used to control on screen where the media is shown", + "type": "string" + } + }, + "examples": [ + { + "playerId": "123", + "windowId": "456" + }, + { + "playerId": "abc", + "windowId": "def" + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/schemas/player.json b/src/schemas/player.json new file mode 100644 index 000000000..0af4247ea --- /dev/null +++ b/src/schemas/player.json @@ -0,0 +1,45 @@ +{ + "$id": "https://meta.comcast.com/firebolt/player", + "title": "Player", + "definitions": { + "PlayerRequest": { + "title": "PlayerRequest", + "type": "object", + "required": [ + "playerId" + ], + "properties": { + "playerId": { + "description": "The id of the player instance to play in", + "type": "string" + } + }, + "examples": [ + { + "playerId": "app1:123" + }, + { + "playerId": "app2:345" + } + ] + }, + "PlayerProviderRequest": { + "title": "PlayerProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The player request", + "$ref": "#/definitions/PlayerRequest" + } + } + } + } +} \ No newline at end of file diff --git a/src/sdks/manage/sdk.config.json b/src/sdks/manage/sdk.config.json index 56d869412..0b78b215f 100644 --- a/src/sdks/manage/sdk.config.json +++ b/src/sdks/manage/sdk.config.json @@ -141,6 +141,24 @@ "manage": [ "xrn:firebolt:capability:discovery:sign-in-status" ] + }, + { + "module": "Player", + "use": [ + "xrn:firebolt:capability:player:base" + ] + }, + { + "module": "BroadcastPlayer", + "use": [ + "xrn:firebolt:capability:player:broadcast" + ] + }, + { + "module": "StreamingPlayer", + "use": [ + "xrn:firebolt:capability:player:streaming" + ] } ] -} +} \ No newline at end of file diff --git a/src/sdks/provider/.npmignore b/src/sdks/provider/.npmignore new file mode 100644 index 000000000..0e2ba4d22 --- /dev/null +++ b/src/sdks/provider/.npmignore @@ -0,0 +1,6 @@ +build/* +src/* +test/* +.DS_Store +jest.config.* +tsconfig.* \ No newline at end of file diff --git a/src/sdks/provider/CHANGELOG.md b/src/sdks/provider/CHANGELOG.md new file mode 100644 index 000000000..e69de29bb diff --git a/src/sdks/provider/CONTRIBUTING.md b/src/sdks/provider/CONTRIBUTING.md new file mode 120000 index 000000000..c97564d93 --- /dev/null +++ b/src/sdks/provider/CONTRIBUTING.md @@ -0,0 +1 @@ +../../../CONTRIBUTING.md \ No newline at end of file diff --git a/src/sdks/provider/LICENSE b/src/sdks/provider/LICENSE new file mode 120000 index 000000000..5853aaea5 --- /dev/null +++ b/src/sdks/provider/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/src/sdks/provider/NOTICE b/src/sdks/provider/NOTICE new file mode 120000 index 000000000..295f6bdb3 --- /dev/null +++ b/src/sdks/provider/NOTICE @@ -0,0 +1 @@ +../../../NOTICE \ No newline at end of file diff --git a/src/sdks/provider/README.md b/src/sdks/provider/README.md new file mode 100644 index 000000000..04710aaff --- /dev/null +++ b/src/sdks/provider/README.md @@ -0,0 +1,26 @@ +--- +title: Firebolt Provider SDK +--- + +[![semantic-release: conventional](https://img.shields.io/badge/semantic--release-conventional-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) + +# Firebolt Provider SDK +For building Firebolt compliant apps that manage Firebolt devices. + +## Usage +To install, run: + +``` +npm install @firebolt-js/provider-sdk +``` + +To use the package, import one of it's modules, e.g.: + +```js +import { Privacy } from '@firebolt-js/provider-sdk' +``` + +## Contributing +The Firebolt SDKs are built using the Firebolt OpenRPC toolset: + +See [Firebolt OpenRPC](https://www.github.com/rdkcentral/firebolt-openrpc/), for more info. diff --git a/src/sdks/provider/Setup.js b/src/sdks/provider/Setup.js new file mode 100644 index 000000000..472edc35c --- /dev/null +++ b/src/sdks/provider/Setup.js @@ -0,0 +1,36 @@ +if (!window.__firebolt) { + window.__firebolt = {} +} + +// wires up the mock transport w/out waiting +window.__firebolt.mockTransportLayer = true + +// sets a flag that mock defaults impls can use to speed things up, e.g. Lifecycle/defaults.js +window.__firebolt.automation = true + +let sendListener +let receiver + +export const transport = { + send: function(message) { + const json = JSON.parse(message) + sendListener && sendListener(json) + }, + receive: function(callback) { + // store the callback + receiver = callback + }, + onSend: function(listener) { + sendListener = listener + }, + response: function(id, result) { + let response = { + jsonrpc: '2.0', + id: id, + result: result + } + receiver && receiver(JSON.stringify(response)) + } +} + +window.__firebolt.setTransportLayer(transport) \ No newline at end of file diff --git a/src/sdks/provider/jest.config.json b/src/sdks/provider/jest.config.json new file mode 100644 index 000000000..745370cfa --- /dev/null +++ b/src/sdks/provider/jest.config.json @@ -0,0 +1,8 @@ +{ + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|js?)$", + "transform": {}, + "testPathIgnorePatterns": ["/node_modules/", "/../../../test"], + "moduleFileExtensions": ["js", "jsx", "mjs"], + "verbose": true, + "testEnvironment": "jest-environment-jsdom" + } \ No newline at end of file diff --git a/src/sdks/provider/package.json b/src/sdks/provider/package.json new file mode 100644 index 000000000..57cd83127 --- /dev/null +++ b/src/sdks/provider/package.json @@ -0,0 +1,51 @@ +{ + "name": "@firebolt-js/provider-sdk", + "version": "0.16.0-next.3", + "description": "The Firebolt Provider JS SDK", + "main": "./dist/lib/firebolt-provider.mjs", + "types": "./dist/lib/firebolt-provider.d.ts", + "exports": { + ".": "./dist/lib/firebolt-provider.mjs" + }, + "type": "module", + "scripts": { + "validate": "npx firebolt-openrpc validate --input ./dist/firebolt-provider-open-rpc.json", + "sdk": "npx firebolt-openrpc sdk --input ./dist/firebolt-provider-open-rpc.json --template ./src/js --output ./build/javascript/src", + "native": "npx firebolt-openrpc sdk --input ./dist/firebolt-provider-open-rpc.json --template ./src/js --output ./build/c/src --language ../../../node_modules/@firebolt-js/openrpc/languages/c", + "compile": "cd ../../.. && npm run compile", + "slice": "npx firebolt-openrpc slice -i ../../../dist/firebolt-open-rpc.json --sdk ./sdk.config.json -o ./dist/firebolt-provider-open-rpc.json", + "docs": "npx firebolt-openrpc docs --input ./dist/firebolt-provider-open-rpc.json --output build/docs/markdown --as-path", + "wiki": "npx firebolt-openrpc docs --input ./dist/firebolt-provider-open-rpc.json --output build/docs/markdown", + "dist:notest": "npm run clean && npm run slice && npm run validate && npm run sdk && npm run docs && npm run dist:copy && echo 'Firebolt Provider SDK /dist/ is ready.\n'", + "dist:copy": "npm run dist:copy:sdk && npm run dist:copy:docs", + "dist:copy:sdk": "mkdirp ./dist && cp -R build/javascript/src dist/lib && cp ./dist/firebolt-provider-open-rpc.json ../../../dist/firebolt-provider-open-rpc.json", + "dist:copy:docs": "mkdirp ./dist && cp -R build/docs/markdown dist/docs", + "dist": "npm run dist:notest && npm run test", + "clean": "rm -rf ./build && rm -rf ./dist", + "test:setup": "rm -rf test/transpiled-suite && npx tsc --target es6 --moduleResolution node --outDir test/transpiled-suite", + "test": "npm run test:setup && NODE_OPTIONS=--experimental-vm-modules npx --config=jest.config.json --detectOpenHandles jest", + "prepack": "node ../../js/version.mjs validate && npm run broilerplate", + "broilerplate": "rm ./CONTRIBUTING.md && cp ../../../CONTRIBUTING.md ./CONTRIBUTING.md && rm ./LICENSE && cp ../../../LICENSE ./LICENSE && rm ./NOTICE && cp ../../../NOTICE ./NOTICE" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rdkcentral/firebolt-core-sdk", + "directory": "src/sdks/provider" + }, + "author": "", + "bugs": { + "url": "https://github.com/rdkcentral/firebolt-core-sdk/issues" + }, + "homepage": "https://github.com/rdkcentral/firebolt-core-sdk#readme", + "devDependencies": { + "jest": "^28.1.0", + "jest-environment-jsdom": "^28.1.3", + "typescript": "^4.6.4" + }, + "keywords": [ + "firebolt", + "apps", + "sdk" + ], + "license": "Apache-2.0" +} \ No newline at end of file diff --git a/src/sdks/provider/sdk.config.json b/src/sdks/provider/sdk.config.json new file mode 100644 index 000000000..47da2f577 --- /dev/null +++ b/src/sdks/provider/sdk.config.json @@ -0,0 +1,26 @@ +{ + "info": { + "title": "Firebolt Provider SDK", + "x-interface-names": {} + }, + "methods": [ + { + "module": "Player", + "provide": [ + "xrn:firebolt:capability:player:base" + ] + }, + { + "module": "BroadcastPlayer", + "provide": [ + "xrn:firebolt:capability:player:broadcast" + ] + }, + { + "module": "StreamingPlayer", + "provide": [ + "xrn:firebolt:capability:player:streaming" + ] + } + ] +} \ No newline at end of file diff --git a/src/sdks/provider/src/js/sdk/index.mjs b/src/sdks/provider/src/js/sdk/index.mjs new file mode 100644 index 000000000..a9f2f5ca6 --- /dev/null +++ b/src/sdks/provider/src/js/sdk/index.mjs @@ -0,0 +1,30 @@ +/* + * Copyright 2021 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +import { setMockResponses } from './Transport/MockTransport.mjs' + +/* ${MOCK_IMPORTS} */ + +setMockResponses({ + /* ${MOCK_OBJECTS} */ +}) + +/* ${EXPORTS} */ +export { default as Log } from './Log/index.mjs' +export { default as Events } from './Events/index.mjs' +export { default as Settings } from './Settings/index.mjs' diff --git a/src/sdks/provider/test/suite/player.test.ts b/src/sdks/provider/test/suite/player.test.ts new file mode 100644 index 000000000..401c11b8b --- /dev/null +++ b/src/sdks/provider/test/suite/player.test.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2021 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +import { test, expect } from '@jest/globals' +import { Player } from '../../build/javascript/src/firebolt-provider' + +test('Player.provideStatus()', async () => { + const resp = await Player.provideStatus('abc', { + mediaSessionId: '123', + state: 'PLAYING' + }) + expect(resp).toEqual(null) +}) + +test('Player.provideProgress', async () => { + const resp = await Player.provideProgress('abc', { + startPosition: 0, + position: 60000, + endPosition: 3600000, + liveSyncTime: '2021-04-23T18:25:43.511Z', + speed: 1 + }) + expect(resp).toEqual(null) +}) diff --git a/src/sdks/provider/tsconfig.json b/src/sdks/provider/tsconfig.json new file mode 100644 index 000000000..56ff58bc8 --- /dev/null +++ b/src/sdks/provider/tsconfig.json @@ -0,0 +1,5 @@ +{ + "include": [ + "test/suite/*" + ] +} \ No newline at end of file From eaec1db247e2a586dc80c4369b042e0eaa208190 Mon Sep 17 00:00:00 2001 From: Kevin Pearson Date: Fri, 10 Nov 2023 06:58:14 -0800 Subject: [PATCH 2/7] feat: Player apis --- package-lock.json | 29 +++++++---- package.json | 2 +- src/openrpc/player.json | 90 +++++++++++++++++++++++++--------- src/sdks/provider/package.json | 2 +- 4 files changed, 88 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5cbafe99e..d0f1a6d2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@firebolt-js/openrpc": "2.1.1", + "@firebolt-js/openrpc": "2.1.2", "@firebolt-js/schemas": "2.0.0", "@saithodev/semantic-release-backmerge": "^3.2.0", "@semantic-release/changelog": "^6.0.1", @@ -1063,9 +1063,9 @@ "link": true }, "node_modules/@firebolt-js/openrpc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.1.1.tgz", - "integrity": "sha512-rWwb23ehZpKMQS8TJZiyKo6ziF1Zae/tgDXprTwuwF6vPhHV6vgb/HO1M6o+YI54VDEPDozHCL+IhN+KkT9ucw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.1.2.tgz", + "integrity": "sha512-emsNSf+on373CGwx9E/WYlC2E+fS9M03neLo7+nI3585v3I3TYHaaqhWVw7JNfyAfAxc8s6SQl1l/RQRzvkDpQ==", "dev": true, "dependencies": { "ajv": "^8.3.0", @@ -17032,7 +17032,7 @@ }, "src/sdks/core": { "name": "@firebolt-js/sdk", - "version": "0.18.0-next.7", + "version": "1.0.0", "license": "Apache-2.0", "devDependencies": { "jest": "^28.1.0", @@ -17053,7 +17053,7 @@ }, "src/sdks/manage": { "name": "@firebolt-js/manage-sdk", - "version": "0.18.0-next.7", + "version": "1.0.0", "license": "Apache-2.0", "devDependencies": { "jest": "^28.1.0", @@ -17062,7 +17062,8 @@ } }, "src/sdks/provider": { - "version": "0.16.0-next.3", + "name": "@firebolt-js/provider-sdk", + "version": "1.0.0", "license": "Apache-2.0", "devDependencies": { "jest": "^28.1.0", @@ -17876,9 +17877,9 @@ } }, "@firebolt-js/openrpc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.1.1.tgz", - "integrity": "sha512-rWwb23ehZpKMQS8TJZiyKo6ziF1Zae/tgDXprTwuwF6vPhHV6vgb/HO1M6o+YI54VDEPDozHCL+IhN+KkT9ucw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.1.2.tgz", + "integrity": "sha512-emsNSf+on373CGwx9E/WYlC2E+fS9M03neLo7+nI3585v3I3TYHaaqhWVw7JNfyAfAxc8s6SQl1l/RQRzvkDpQ==", "dev": true, "requires": { "ajv": "^8.3.0", @@ -17949,6 +17950,14 @@ } } }, + "@firebolt-js/provider-sdk": { + "version": "file:src/sdks/provider", + "requires": { + "jest": "^28.1.0", + "jest-environment-jsdom": "^28.1.3", + "typescript": "^4.6.4" + } + }, "@firebolt-js/schemas": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@firebolt-js/schemas/-/schemas-2.0.0.tgz", diff --git a/package.json b/package.json index 70f558b3a..0fe7d1cbf 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@firebolt-js/openrpc": "2.1.1", + "@firebolt-js/openrpc": "2.1.2", "@firebolt-js/schemas": "2.0.0", "@saithodev/semantic-release-backmerge": "^3.2.0", "@semantic-release/changelog": "^6.0.1", diff --git a/src/openrpc/player.json b/src/openrpc/player.json index 26d23273b..44b9c529e 100644 --- a/src/openrpc/player.json +++ b/src/openrpc/player.json @@ -18,11 +18,17 @@ ], "summary": "Loads content in a player and starts a media session", "params": [ + { + "name": "playerId", + "summary": "The id of the player to load content in", + "type": "string", + "required": true + }, { "name": "request", "summary": "The load request", "schema": { - "$ref": "#/components/schemas/PlayerLoadRequest" + "$ref": "#/components/schemas/LoadRequest" }, "required": true } @@ -37,10 +43,13 @@ { "name": "Default example #1", "params": [ + { + "name": "playerId", + "value": "app1:123" + }, { "name": "request", "value": { - "playerId": "app1:123", "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" } } @@ -76,9 +85,9 @@ } ], "result": { - "name": "playResponse", + "name": "mediaSession", "schema": { - "const": null + "$ref": "#/components/schemas/PlayerMediaSession" } }, "examples": [ @@ -91,8 +100,10 @@ } ], "result": { - "name": "playResponse", - "value": null + "name": "mediaSession", + "value": { + "mediaSessionId": "sess1" + } } } ] @@ -119,9 +130,9 @@ } ], "result": { - "name": "stopResponse", + "name": "mediaSession", "schema": { - "const": null + "$ref": "#/components/schemas/PlayerMediaSession" } }, "examples": [ @@ -134,8 +145,10 @@ } ], "result": { - "name": "stopResponse", - "value": null + "name": "mediaSession", + "value": { + "mediaSessionId": "sess1" + } } } ] @@ -315,8 +328,10 @@ "value": { "correlationId": "abc", "parameters": { - "playerId": "app1:123", - "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + "playerId": "123", + "request": { + "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + } } } } @@ -361,7 +376,7 @@ "value": { "correlationId": "abc", "parameters": { - "playerId": "app1:123" + "playerId": "123" } } } @@ -406,7 +421,7 @@ "value": { "correlationId": "abc", "parameters": { - "playerId": "app1:123" + "playerId": "123" } } } @@ -627,18 +642,13 @@ ], "components": { "schemas": { - "PlayerLoadRequest": { - "title": "PlayerLoadRequest", + "LoadRequest": { + "title": "LoadRequest", "type": "object", "required": [ - "playerId", "locator" ], "properties": { - "playerId": { - "description": "The id of the player instance to load the locator into", - "type": "string" - }, "locator": { "description": "A locator to the content to load", "type": "string", @@ -655,11 +665,9 @@ }, "examples": [ { - "playerId": "app1:123", "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" }, { - "playerId": "app2:345", "locator": "https://cdn.rdkcentral.com/media/assets/asset-2.hls", "metadata": { "assetType": "linear" @@ -668,6 +676,42 @@ } ] }, + "PlayerLoadRequest": { + "title": "PlayerLoadRequest", + "type": "object", + "required": [ + "playerId", + "request" + ], + "properties": { + "playerId": { + "description": "The id of the player instance to load the locator into", + "type": "string" + }, + "request": { + "description": "A request detailing what to load in the given player", + "$ref": "#/components/schemas/LoadRequest" + } + }, + "examples": [ + { + "playerId": "app1:123", + "request": { + "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + } + }, + { + "playerId": "app2:345", + "request": { + "locator": "https://cdn.rdkcentral.com/media/assets/asset-2.hls", + "metadata": { + "assetType": "linear" + }, + "autoPlay": true + } + } + ] + }, "PlayerMediaSession": { "title": "PlayerMediaSession", "type": "object", diff --git a/src/sdks/provider/package.json b/src/sdks/provider/package.json index 57cd83127..7866d98ae 100644 --- a/src/sdks/provider/package.json +++ b/src/sdks/provider/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/provider-sdk", - "version": "0.16.0-next.3", + "version": "1.0.0", "description": "The Firebolt Provider JS SDK", "main": "./dist/lib/firebolt-provider.mjs", "types": "./dist/lib/firebolt-provider.d.ts", From 334ca700417e7a8389f0261e450a1f2dccfd6e9b Mon Sep 17 00:00:00 2001 From: Kevin Pearson Date: Fri, 10 Nov 2023 07:36:36 -0800 Subject: [PATCH 3/7] feat: Player apis --- src/openrpc/player.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/openrpc/player.json b/src/openrpc/player.json index 44b9c529e..3034cec5a 100644 --- a/src/openrpc/player.json +++ b/src/openrpc/player.json @@ -21,7 +21,9 @@ { "name": "playerId", "summary": "The id of the player to load content in", - "type": "string", + "schema": { + "type": "string" + }, "required": true }, { From 1e23ca232d72f733c0dc14c1539fec007a1b8a34 Mon Sep 17 00:00:00 2001 From: Kevin Pearson Date: Fri, 10 Nov 2023 08:37:50 -0800 Subject: [PATCH 4/7] feat: Player apis --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fe7d1cbf..d2f5c65c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdks", - "version": "1.0.0", + "version": "1.0.0-player", "description": "The Firebolt JS SDK", "type": "module", "bin": { From 439ebbb77d7b8405886c4c2d6013009a1d4100f4 Mon Sep 17 00:00:00 2001 From: Kevin Pearson Date: Fri, 10 Nov 2023 08:53:00 -0800 Subject: [PATCH 5/7] feat: Player apis --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d2f5c65c7..0fe7d1cbf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdks", - "version": "1.0.0-player", + "version": "1.0.0", "description": "The Firebolt JS SDK", "type": "module", "bin": { From f8139e754ed8703cd03dfda40dee31a23bb690d6 Mon Sep 17 00:00:00 2001 From: Kevin Pearson Date: Mon, 13 Nov 2023 15:07:57 -0800 Subject: [PATCH 6/7] player apis --- package-lock.json | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24de6ef60..50a535160 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "Apache-2.0", "workspaces": [ "src/sdks/core", - "src/sdks/manage" + "src/sdks/manage", + "src/sdks/provider" ], "bin": { "firebolt-version": "src/js/version.mjs" @@ -18,7 +19,7 @@ "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@firebolt-js/openrpc": "2.1.1", + "@firebolt-js/openrpc": "2.1.2", "@firebolt-js/schemas": "2.0.0", "@saithodev/semantic-release-backmerge": "^3.2.0", "@semantic-release/changelog": "^6.0.1", @@ -1070,9 +1071,9 @@ "link": true }, "node_modules/@firebolt-js/openrpc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.1.1.tgz", - "integrity": "sha512-rWwb23ehZpKMQS8TJZiyKo6ziF1Zae/tgDXprTwuwF6vPhHV6vgb/HO1M6o+YI54VDEPDozHCL+IhN+KkT9ucw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.1.2.tgz", + "integrity": "sha512-emsNSf+on373CGwx9E/WYlC2E+fS9M03neLo7+nI3585v3I3TYHaaqhWVw7JNfyAfAxc8s6SQl1l/RQRzvkDpQ==", "dev": true, "dependencies": { "ajv": "^8.3.0", @@ -1160,6 +1161,10 @@ "node": ">=6" } }, + "node_modules/@firebolt-js/provider-sdk": { + "resolved": "src/sdks/provider", + "link": true + }, "node_modules/@firebolt-js/schemas": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@firebolt-js/schemas/-/schemas-2.0.0.tgz", @@ -16935,6 +16940,7 @@ } }, "src/sdks/core": { + "name": "@firebolt-js/sdk", "version": "1.0.0", "license": "Apache-2.0", "devDependencies": { @@ -16944,6 +16950,16 @@ } }, "src/sdks/manage": { + "name": "@firebolt-js/manage-sdk", + "version": "1.0.0", + "license": "Apache-2.0", + "devDependencies": { + "jest": "^28.1.0", + "jest-environment-jsdom": "^28.1.3", + "typescript": "^4.6.4" + } + }, + "src/sdks/provider": { "version": "1.0.0", "license": "Apache-2.0", "devDependencies": { @@ -16953,4 +16969,4 @@ } } } -} \ No newline at end of file +} From aa5bbe181cb7078c6828541a34e9fd80e6225c90 Mon Sep 17 00:00:00 2001 From: Kevin Pearson Date: Fri, 12 Jan 2024 12:06:19 -0800 Subject: [PATCH 7/7] feat: add more player APIs --- package-lock.json | 19 +- src/openrpc/player.json | 1141 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 1072 insertions(+), 88 deletions(-) diff --git a/package-lock.json b/package-lock.json index ead30bca5..4ee0a8339 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "Apache-2.0", "workspaces": [ "src/sdks/core", - "src/sdks/manage" + "src/sdks/manage", + "src/sdks/provider" ], "bin": { "firebolt-version": "src/js/version.mjs" @@ -1160,6 +1161,10 @@ "node": ">=6" } }, + "node_modules/@firebolt-js/provider-sdk": { + "resolved": "src/sdks/provider", + "link": true + }, "node_modules/@firebolt-js/schemas": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@firebolt-js/schemas/-/schemas-2.0.0.tgz", @@ -16970,6 +16975,16 @@ "prettier": "^3.1.0", "typescript": "^4.6.4" } + }, + "src/sdks/provider": { + "name": "@firebolt-js/provider-sdk", + "version": "1.0.0", + "license": "Apache-2.0", + "devDependencies": { + "jest": "^28.1.0", + "jest-environment-jsdom": "^28.1.3", + "typescript": "^4.6.4" + } } } -} \ No newline at end of file +} diff --git a/src/openrpc/player.json b/src/openrpc/player.json index 3034cec5a..80190a3e8 100644 --- a/src/openrpc/player.json +++ b/src/openrpc/player.json @@ -155,6 +155,185 @@ } ] }, + { + "name": "setPosition", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Tells the player to set its position to the given offset in the media", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to set the position for", + "schema": { + "type": "string" + }, + "required": true + }, + { + "name": "position", + "summary": "The position the player should seek to in milliseconds", + "schema": { + "type": "integer", + "minimum": 0 + }, + "required": true + } + ], + "result": { + "name": "setPositionResponse", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "position", + "value": 10000 + } + ], + "result": { + "name": "setPositionResponse", + "value": null + } + }, + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "position", + "value": 600000 + } + ], + "result": { + "name": "setPositionResponse", + "value": null + } + } + ] + }, + { + "name": "setSpeed", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Tells the player to set its speed", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to set the position for", + "schema": { + "type": "string" + }, + "required": true + }, + { + "name": "speed", + "summary": "The speed to set as a multiplier of the default speed. Negative values would cause the media to rewind. Use 0 to pause", + "schema": { + "type": "number" + }, + "required": true + } + ], + "result": { + "name": "setSpeedResponse", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Set speed to 2", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "speed", + "value": 2 + } + ], + "result": { + "name": "setSpeedResponse", + "value": null + } + }, + { + "name": "Set speed to 0.5", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "speed", + "value": 0.5 + } + ], + "result": { + "name": "setSpeedResponse", + "value": null + } + }, + { + "name": "Set speed to -2", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "speed", + "value": -2 + } + ], + "result": { + "name": "setSpeedResponse", + "value": null + } + }, + { + "name": "Set speed to 0", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "speed", + "value": 0 + } + ], + "result": { + "name": "setSpeedResponse", + "value": null + } + } + ] + }, { "name": "status", "tags": [ @@ -293,92 +472,533 @@ ] }, { - "name": "onRequestLoad", - "summary": "Registers as a provider for when new media should be loaded into the player", - "params": [], + "name": "tracks", "tags": [ - { - "name": "event", - "x-response": { - "$ref": "#/components/schemas/PlayerMediaSession", - "examples": [ - { - "mediaSessionId": "sess1" - } - ] - } - }, { "name": "capabilities", - "x-provides": "xrn:firebolt:capability:player:base", - "x-allow-focus": false + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Gets the supported tracks for the current playing media", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to get the tracks for", + "schema": { + "type": "string" + }, + "required": true } ], "result": { - "name": "loadRequest", - "summary": "The request to load new media", + "name": "playerTracks", "schema": { - "$ref": "#/components/schemas/PlayerLoadProviderRequest" + "$ref": "#/components/schemas/PlayerTracks" } }, "examples": [ { - "name": "Default Example", - "params": [], + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + } + ], "result": { - "name": "Default Result", + "name": "playerTracks", "value": { - "correlationId": "abc", - "parameters": { - "playerId": "123", - "request": { - "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + "audio": [ + { + "trackId": "123", + "language": "en", + "audioDescription": false, + "type": "PCM", + "selected": true } - } + ], + "captions": [ + { + "trackId": "123", + "language": "en", + "name": "CC1", + "selected": true + } + ] } } } ] }, { - "name": "onRequestPlay", - "summary": "Registers as a provider for when media should start playing", - "params": [], + "name": "setAudioTrack", "tags": [ { - "name": "event", - "x-response": { - "$ref": "#/components/schemas/PlayerMediaSession", - "examples": [ - { - "mediaSessionId": "sess1" - } - ] + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Selects the given audio track", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to set the track for", + "schema": { + "type": "string" + }, + "required": true + }, + { + "name": "trackId", + "summary": "The id of the track to select", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "setAudioTrackResult", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "trackId", + "value": "Audio1" + } + ], + "result": { + "name": "setAudioTrackResult", + "value": null + } + } + ] + }, + { + "name": "setCaptionsTrack", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:player:base" + ] + } + ], + "summary": "Selects the given captions track", + "params": [ + { + "name": "playerId", + "summary": "The id of the player to set the track for", + "schema": { + "type": "string" + }, + "required": true + }, + { + "name": "trackId", + "summary": "The id of the track to select", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "setCaptionsTrackResult", + "schema": { + "const": null + } + }, + "examples": [ + { + "name": "Default example #1", + "params": [ + { + "name": "playerId", + "value": "app1:123" + }, + { + "name": "trackId", + "value": "CC1" + } + ], + "result": { + "name": "setAudioTrackResult", + "value": null + } + } + ] + }, + { + "name": "onRequestLoad", + "summary": "Registers as a provider for when new media should be loaded into the player", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerMediaSession", + "examples": [ + { + "mediaSessionId": "sess1" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "loadRequest", + "summary": "The request to load new media", + "schema": { + "$ref": "#/components/schemas/PlayerLoadProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123", + "request": { + "locator": "https://cdn.rdkcentral.com/media/assets/asset.hls" + } + } + } + } + } + ] + }, + { + "name": "onRequestPlay", + "summary": "Registers as a provider for when media should start playing", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerMediaSession", + "examples": [ + { + "mediaSessionId": "sess1" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "playRequest", + "summary": "The request to start playing media", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123" + } + } + } + } + ] + }, + { + "name": "onRequestStop", + "summary": "Registers as a provider for when media should stop playing", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerMediaSession", + "examples": [ + { + "mediaSessionId": "sess1" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "stopRequest", + "summary": "The request to stop playing media", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123" + } + } + } + } + ] + }, + { + "name": "onRequestStatus", + "summary": "Registers as a provider for when player status needs to be provided", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerStatus", + "examples": [ + { + "mediaSessionId": "sess1", + "state": "IDLE" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "statusRequest", + "summary": "The request to get the status of a player", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123" + } + } + } + } + ] + }, + { + "name": "onRequestProgress", + "summary": "Registers as a provider for when player progress needs to be provided", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "$ref": "#/components/schemas/PlayerProgress", + "examples": [ + { + "speed": 1, + "startPosition": 0, + "position": 5000, + "endPosition": 3600000, + "liveSyncTime": "2021-04-23T18:25:43.511Z" + } + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "progressRequest", + "summary": "The request to stop playing media", + "schema": { + "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123" + } + } + } + } + ] + }, + { + "name": "onRequestSetPosition", + "summary": "Registers as a provider for when media position should be set", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "const": null, + "examples": [ + null + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "setPositionRequest", + "summary": "The request to set position in the media", + "schema": { + "$ref": "#/components/schemas/PlayerSetPositionProviderRequest" + } + }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123", + "position": 10000 + } + } + } + } + ] + }, + { + "name": "onRequestSetSpeed", + "summary": "Registers as a provider for when media speed should be set", + "params": [], + "tags": [ + { + "name": "event", + "x-response": { + "const": null, + "examples": [ + null + ] + } + }, + { + "name": "capabilities", + "x-provides": "xrn:firebolt:capability:player:base", + "x-allow-focus": false + } + ], + "result": { + "name": "setSpeedRequest", + "summary": "The request to set speed in the media", + "schema": { + "$ref": "#/components/schemas/PlayerSetSpeedProviderRequest" + } + }, + "examples": [ + { + "name": "Set Speed to 2", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123", + "speed": 2 + } + } + } + }, + { + "name": "Set Speed to 0.5", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123", + "speed": 0.5 + } + } + } + }, + { + "name": "Set Speed to -2", + "params": [], + "result": { + "name": "Default Result", + "value": { + "correlationId": "abc", + "parameters": { + "playerId": "123", + "speed": -2 + } + } } }, { - "name": "capabilities", - "x-provides": "xrn:firebolt:capability:player:base", - "x-allow-focus": false - } - ], - "result": { - "name": "playRequest", - "summary": "The request to start playing media", - "schema": { - "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" - } - }, - "examples": [ - { - "name": "Default Example", + "name": "Set Speed to 0", "params": [], "result": { "name": "Default Result", "value": { "correlationId": "abc", "parameters": { - "playerId": "123" + "playerId": "123", + "speed": 0 } } } @@ -386,17 +1006,33 @@ ] }, { - "name": "onRequestStop", - "summary": "Registers as a provider for when media should stop playing", + "name": "onRequestTracks", + "summary": "Registers as a provider for when player tracks needs to be provided", "params": [], "tags": [ { "name": "event", "x-response": { - "$ref": "#/components/schemas/PlayerMediaSession", + "$ref": "#/components/schemas/PlayerTracks", "examples": [ { - "mediaSessionId": "sess1" + "audio": [ + { + "trackId": "123", + "language": "en", + "audioDescription": false, + "type": "PCM", + "selected": true + } + ], + "captions": [ + { + "trackId": "123", + "language": "en", + "name": "CC1", + "selected": true + } + ] } ] } @@ -408,8 +1044,8 @@ } ], "result": { - "name": "stopRequest", - "summary": "The request to stop playing media", + "name": "tracksRequest", + "summary": "The request to get the tracks of a player", "schema": { "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" } @@ -431,19 +1067,16 @@ ] }, { - "name": "onRequestStatus", - "summary": "Registers as a provider for when player status needs to be provided", + "name": "onRequestSetAudioTrack", + "summary": "Registers as a provider for setting the audio track", "params": [], "tags": [ { "name": "event", "x-response": { - "$ref": "#/components/schemas/PlayerStatus", + "const": null, "examples": [ - { - "mediaSessionId": "sess1", - "state": "IDLE" - } + null ] } }, @@ -454,10 +1087,10 @@ } ], "result": { - "name": "statusRequest", - "summary": "The request to get the status of a player", + "name": "setTracksRequest", + "summary": "The request to set the audio track of a player", "schema": { - "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + "$ref": "#/components/schemas/PlayerSetAudioTrackProviderRequest" } }, "examples": [ @@ -469,7 +1102,8 @@ "value": { "correlationId": "abc", "parameters": { - "playerId": "123" + "playerId": "123", + "trackId": "Audio1" } } } @@ -477,22 +1111,16 @@ ] }, { - "name": "onRequestProgress", - "summary": "Registers as a provider for when player progress needs to be provided", + "name": "onRequestSetCaptionsTrack", + "summary": "Registers as a provider for setting the captions track", "params": [], "tags": [ { "name": "event", "x-response": { - "$ref": "#/components/schemas/PlayerProgress", + "const": null, "examples": [ - { - "speed": 1, - "startPosition": 0, - "position": 5000, - "endPosition": 3600000, - "liveSyncTime": "2021-04-23T18:25:43.511Z" - } + null ] } }, @@ -503,10 +1131,10 @@ } ], "result": { - "name": "progressRequest", - "summary": "The request to stop playing media", + "name": "setTracksRequest", + "summary": "The request to set the captions track of a player", "schema": { - "$ref": "https://meta.comcast.com/firebolt/player#/definitions/PlayerProviderRequest" + "$ref": "#/components/schemas/PlayerSetCaptionsTrackProviderRequest" } }, "examples": [ @@ -518,7 +1146,8 @@ "value": { "correlationId": "abc", "parameters": { - "playerId": "123" + "playerId": "123", + "trackId": "CC1" } } } @@ -854,6 +1483,346 @@ "$ref": "#/components/schemas/PlayerLoadRequest" } } + }, + "AudioTrack": { + "title": "AudioTrack", + "type": "object", + "required": [ + "trackId", + "language", + "audioDescription", + "type", + "selected" + ], + "properties": { + "trackId": { + "description": "The id of the track", + "type": "string" + }, + "language": { + "description": "The language of the audio", + "$ref": "https://meta.comcast.com/firebolt/localization#/definitions/Language" + }, + "audioDescription": { + "description": "Whether this track supports audio description", + "type": "boolean" + }, + "type": { + "description": "The type of track", + "type": "string", + "enum": [ + "PCM", + "AC3", + "EAC3", + "AAC" + ] + }, + "selected": { + "description": "Whether this track is currently selected", + "type": "boolean" + } + }, + "examples": [ + { + "trackId": "Audio1", + "language": "en", + "audioDescription": false, + "type": "PCM", + "selected": true + }, + { + "trackId": "Audio2", + "language": "es", + "audioDescription": true, + "type": "AC3", + "selected": false + } + ] + }, + "CaptionsTrack": { + "title": "CaptionsTrack", + "type": "object", + "required": [ + "trackId", + "selected" + ], + "properties": { + "trackId": { + "description": "The id of the track", + "type": "string" + }, + "language": { + "description": "The language of the captions", + "$ref": "https://meta.comcast.com/firebolt/localization#/definitions/Language" + }, + "name": { + "description": "The name of track", + "type": "string" + }, + "selected": { + "description": "Whether this track is currently selected", + "type": "boolean" + } + }, + "examples": [ + { + "trackId": "CC1", + "language": "en", + "selected": true + }, + { + "trackId": "CC2", + "name": "ClosedCaptions2", + "selected": false + } + ] + }, + "PlayerTracks": { + "title": "PlayerTracks", + "type": "object", + "required": [ + "audio", + "captions" + ], + "properties": { + "audio": { + "description": "The list of audio tracks", + "type": "array", + "items": { + "$ref": "#/components/schemas/AudioTrack" + } + }, + "captions": { + "description": "The list of captions tracks", + "type": "array", + "items": { + "$ref": "#/components/schemas/CaptionsTrack" + } + } + }, + "examples": [ + { + "audio": [ + { + "trackId": "Audio1", + "language": "en", + "audioDescription": false, + "type": "PCM", + "selected": true + }, + { + "trackId": "Audio2", + "language": "es", + "audioDescription": true, + "type": "AC3", + "selected": false + } + ], + "captions": [ + { + "trackId": "CC1", + "language": "en", + "selected": true + }, + { + "trackId": "CC2", + "name": "ClosedCaptions2", + "selected": false + } + ] + } + ] + }, + "PlayerSetPositionRequest": { + "title": "PlayerSetPositionRequest", + "type": "object", + "required": [ + "playerId", + "position" + ], + "properties": { + "playerId": { + "description": "The id of the player to set the position for", + "type": "string" + }, + "position": { + "description": "The position the player should seek to in milliseconds", + "type": "integer", + "minimum": 0 + } + }, + "examples": [ + { + "playerId": "app1:123", + "position": 10000 + }, + { + "playerId": "app2:345", + "position": 600000 + } + ] + }, + "PlayerSetPositionProviderRequest": { + "title": "PlayerSetPositionProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The request to set position in the player", + "$ref": "#/components/schemas/PlayerSetPositionRequest" + } + } + }, + "PlayerSetSpeedRequest": { + "title": "PlayerSetSpeedRequest", + "type": "object", + "required": [ + "playerId", + "speed" + ], + "properties": { + "playerId": { + "description": "The id of the player to set the speed for", + "type": "string" + }, + "speed": { + "description": "The speed to set as a multiplier of the default speed. Negative values would cause the media to rewind. Use 0 to pause", + "type": "number" + } + }, + "examples": [ + { + "playerId": "app1:123", + "speed": 2 + }, + { + "playerId": "app2:345", + "speed": 0.5 + }, + { + "playerId": "app2:345", + "speed": -2 + }, + { + "playerId": "app2:345", + "speed": 0 + } + ] + }, + "PlayerSetSpeedProviderRequest": { + "title": "PlayerSetSpeedProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The request to set speed in the player", + "$ref": "#/components/schemas/PlayerSetSpeedRequest" + } + } + }, + "PlayerSetAudioTrackRequest": { + "title": "PlayerSetAudioTrackRequest", + "type": "object", + "required": [ + "playerId", + "trackId" + ], + "properties": { + "playerId": { + "description": "The id of the player to set the track for", + "type": "string" + }, + "trackId": { + "description": "The id of the track to use for audio", + "type": "string" + } + }, + "examples": [ + { + "playerId": "app1:123", + "trackId": "Audio1" + }, + { + "playerId": "app1:123", + "trackId": "Audio2" + } + ] + }, + "PlayerSetAudioTrackProviderRequest": { + "title": "PlayerSetAudioTrackProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The request to set audio track in the player", + "$ref": "#/components/schemas/PlayerSetAudioTrackRequest" + } + } + }, + "PlayerSetCaptionsTrackRequest": { + "title": "PlayerSetCaptionsTrackRequest", + "type": "object", + "required": [ + "playerId" + ], + "properties": { + "playerId": { + "description": "The id of the player to set the track for", + "type": "string" + }, + "trackId": { + "description": "The id of the track to use for captions. Leave off to turn off captions", + "type": "string" + } + }, + "examples": [ + { + "playerId": "app1:123", + "trackId": "Audio1" + }, + { + "playerId": "app1:123" + } + ] + }, + "PlayerSetCaptionsTrackProviderRequest": { + "title": "PlayerSetCaptionsTrackProviderRequest", + "type": "object", + "required": [ + "correlationId", + "parameters" + ], + "properties": { + "correlationId": { + "type": "string", + "description": "An id to correlate the provider response with this request" + }, + "parameters": { + "description": "The request to set captions track in the player", + "$ref": "#/components/schemas/PlayerSetCaptionsTrackRequest" + } + } } } }