|
| 1 | +# Summary |
| 2 | + |
| 3 | +Provide the [JS Bindings API described in the obs-browser |
| 4 | +readme](https://github.com/obsproject/obs-browser#js-bindings) to browser-panels |
| 5 | +(docked UI panels). |
| 6 | + |
| 7 | +# Motivation |
| 8 | + |
| 9 | +OBS users can embed web UI in OBS that allows them to see information related to |
| 10 | +their broadcast while they are streaming (e.g. Twitch Chat, Stream Statistics). |
| 11 | +However embedded UI does not have access to respond to OBS events or control |
| 12 | +OBS. |
| 13 | + |
| 14 | +Developers have requested JS APIs for UI panels previously in [GitHub |
| 15 | +comments](https://github.com/obsproject/obs-browser/pull/312#issuecomment-975668271) |
| 16 | +and on ideas.obsproject.com: [Allow use of obs javascript apis in Custom |
| 17 | +Browser |
| 18 | +Docks](https://ideas.obsproject.com/posts/1623/allow-use-of-obs-javascript-apis-in-custom-browser-docks). |
| 19 | + |
| 20 | +I'd like to create an embedded web UI that can add and remove browser sources |
| 21 | +from a scene to streamline the experience of using Twitch's Guest Star features. |
| 22 | +Unifying the JavaScript API bridge between browser sources and UI panels could |
| 23 | +be the first step to enable this and other future use cases. |
| 24 | + |
| 25 | +# Drawbacks |
| 26 | + |
| 27 | +* Opening new APIs to UI panel creates opportunities for security issues where |
| 28 | + they were previously isolated to browser-sources. |
| 29 | +* This change requires permissions settings for UI panels where there were none |
| 30 | + before. |
| 31 | + |
| 32 | +# Additional Information |
| 33 | + |
| 34 | +## Alternatives |
| 35 | + |
| 36 | +**Configure obs-websocket when setting up a service and provide a means to |
| 37 | +exchange the port and password.** |
| 38 | + |
| 39 | +The OBS websocket plugin provides the APIs needed to control OBS from anything |
| 40 | +that can connect to the local websocket. An alternative workflow for creating |
| 41 | +scene sources from a UI panel would require users to copy and paste the port, |
| 42 | +password, and IP address into UI to allow it to control OBS. This requires more |
| 43 | +setup from users and creates an opportunity to break the UI connection (changing |
| 44 | +any of the values or disabling the server). |
| 45 | + |
| 46 | +If the websocket plugin could be configured during service setup (sharing the |
| 47 | +password with the service) and there were some way to detect changes in the |
| 48 | +websocket that would break the connection then this could be a viable |
| 49 | +alternative. |
| 50 | + |
| 51 | +**The [custom URL scheme RFC](https://github.com/obsproject/rfcs/pull/10) could |
| 52 | +allow UI panels to control sources.** |
| 53 | + |
| 54 | +I'm not sure if the current web browser would let OSB users acknowledge that the |
| 55 | +app is open. However this wouldn't provide the two way communication (i.e. |
| 56 | +events are missing) to keep OBS UI in sync with a UI panel. |
| 57 | + |
| 58 | +## Proposal Specifics |
| 59 | + |
| 60 | +In this RFC I'm proposing that we provide JavaScript API parity between |
| 61 | +browser sources |
| 62 | +([obs-browser-source.cpp](https://github.com/obsproject/obs-browser/blob/master/obs-browser-source.cpp)) |
| 63 | +and browser panels |
| 64 | +([browser-panel.cpp](https://github.com/obsproject/obs-browser/blob/master/panel/browser-panel.cpp)). |
| 65 | +This requires an introduction of the "Page permissions" concept to UI panels. |
| 66 | +An initial implementation could leave out the UI for managing these permissions, |
| 67 | +only opening permissions when panels are added via services. |
0 commit comments