obsproject / obs-browser

CEF-based OBS Studio browser plugin
GNU General Public License v2.0
776 stars 220 forks source link

Add scene browser controls #312

Closed gxalpha closed 2 years ago

gxalpha commented 3 years ago

Description

Adds the scene controls which are already described in the permissions string ("Advanced access to OBS (Change scenes, Start/Stop replay buffer, etc.)").

To access the scenes available or the current scene, you need READ_ONLY, to change the scenes you need ADVANCED permission.

While I was at it, I also added functions to get and change transitions. These follow the same pattern.

Motivation and Context

See above.

How Has This Been Tested?

macOS 12, compiled and run

All the functions can be called by JS and do what they are supposed to. No memory leaks found.

Types of changes

Checklist:

RytoEX commented 2 years ago

Bumping this to OBS Studio 27.2 per discussion with @WizardCM to allow more time to review without holding back 27.1.

dkonopka commented 2 years ago

@gxalpha, @WizardCM I'm wondering if merging this PR will open doors to the issue of checking the current status of the scene via js API? https://github.com/obsproject/obs-browser/issues/255

gxalpha commented 2 years ago

Made the setTransition function cleaner, now depends on

@dkonopka I think it does open such doors

NimitzDEV commented 2 years ago

I have a different question, I was wondering are those APIs can be available to Custom Browser Docks, tested on OBS 27.1.3 doesn't seem to support it. If you could support it to be used in Custom Browser Docks, it can give developers the chance to make a custom look control panel. Would love to hear some advice from you.

gxalpha commented 2 years ago

I would have to defer to @WizardCM on that I think. Also this should probably either be an issue or a post on the ideas page as it's not directly related to the PR.

notr1ch commented 2 years ago

I'm not sold on the permissions for some of these. Since browser sources default to read-only access, enumerating scenes, collections and profiles presents a real privacy risk to users. For example if someone streams with multiple profiles and one is an adult content site, a browser source page could surreptitiously record this.

I think the permissions need to be more granular so there is a separation between read-only fixed data and read-only user data.

gxalpha commented 2 years ago

Removed scene collection and profile related functions.

notr1ch commented 2 years ago

I would consider scene names potentially sensitive user data too, but removing that might be a bit much. I'd still like to see an extra permission for reading "user data".

gxalpha commented 2 years ago

This would make it All, Advanced, Basic, Read (User), Read (OBS), None (in that order), right? Also, would we be ok with breaking all existing setups (which probably aren't that many as of yet, considering the capabilities in 27.1 are rather limited), which currently are set to Read and make them Read (OBS)? Unfortunately, I don't think we can just rely on changing the default and not touching things the user set manually, since due to a bug introduced with the initial undo/redo (fixed only recently), right now approximately all defaults are also saved in the scene collection.

WizardCM commented 2 years ago

@gxalpha I think that's fine, let's do it.

gxalpha commented 2 years ago

Added the new permission and tested it works.

image

I also hope the JSDoc definitions are correct, but I'm not sure (I don't know how to test them :D). Perhaps @VodBox wants to take a quick look.