-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Move webcam to plugin #4628
Move webcam to plugin #4628
Conversation
…into webcam-plugins
…into webcam-plugins
…into webcam-plugins
Ok, see 077702b (also did a small bugfix in 673a986). And of course I managed to break the tests, so there's also fa0fd53 🙈 A couple of TODOs from that refactoring:
Overall I think this is a cleaner approach, since it doesn't throw a bunch of webcam specifics into the plugin settings (or the normal settings for the matter) but keeps it contained in ONE spot during platform init and in a settings overlay. Deprecation handling is also done in a non-webcam-specific way, and longterm this option in the settings might also help with future deprecations. And there's way less |
Webcam, WebcamCompatibility and RatioEnum have nothing to do with the config anymore but are rather WebcamProviderPlugin specific, so let's move them into their own octoprint.schema.webcam package.
Ok, also couldn't resist to do 823d214 because I really couldn't see why something that isn't part of the config format anymore (or ever was) was pushed into |
87f7726
to
4b2a2aa
Compare
From my understanding the last open topic is this one: #4628 (comment) What shall we do there? |
Replied in the thread. |
Done :) Resolved the thread above. From my side, this would be it for now. I will test everything again on Saturday just to make sure nothing broke while addressing the change requests. |
FYI, still recovering from a nasty sinusitis. 1.9.0rc1 is off the table for 2022 because of that. I'll see if I can still get around to give this a final review (and hopefully merge it) before leaving the office for the year, but since I also have to prep some stuff for the 10 year anniversary show and take care of some other stuff that needs to be done this month, let alone am not 100% fit still, I can't promise it. Rest assured though it's scheduled for 1.9.0rc1 and pretty much number 1 on the deadline-less part of the Todo list. |
No stress! I'll be still around next year :) Enjoy the holidays and make sure to recover! |
If anyone is trying to set stuff from the webcam compat layer, we now get a log entry, or multiple if needed. Long term we might want to return an error on the API
Also use API methods of plugin manager instead of accessing internal control properties directly.
I did some final touch-ups, but I think now this can be merged. Since we will no longer support configuring things like the stream URL and similar on the REST API, I've added some logging to the API endpoint when incoming settings data contains affected settings. That way there will be at least a paper trail as to why the settings aren't being written. We can remove it sometime down the road, or just leave it in. In any case, this change in behaviour will require a heads-up in the release notes for REST API consumers/users. I don't know if there are any third party clients out there that offer configuration of webcam settings, or plugins that for some reason do that through the settings endpoint, but we should give them a warning just in case. |
Oh wow! Thanks for your amazing help on this one! :) I think the most important ones are the plugins interacting with the camera in some form and I guess apps. Technically consuming the webcam should continue to work as usual but configuration does change. |
Since OctoPrint/OctoPrint#4628 we need to use `#classicwebcam_container` otherwise all controls and text information provided by this plugin is `display:none`.
What does this PR do and why is it necessary?
This PR moves the webcam code into a plugin "Classic webcam" and allows other plugins to provide one or more webcams in the same way. This is a big PR and I expect much discussion, please don't put high priority on this :)
Configuration
Every webcam has a set of configurations as well as a template that will be loaded into the Control tab on the web interface. The webcam settings now allow the user to select a default webcam that is used for backwards compatibility as well as for timelapse creation.
The webcam configuration consists of three elements: Basic attributes, extras and compatibility settings. All values are optional.
Basic attributes are similar to what existed before and contain flip, rotate and the snapshot URL. A name and display name are added to identify the webcam. Extras are a dictionary with webcam specific data, e.g. WebRTC server or anything else needed for the frontend to display the webcam. Compatibility data are all fields that were removed from the old webcam configuration: Stream URL, cache buster, stream timeout, stream ratio, WebRTC server.
The compatibility data of the default webcam (if it provides any) is used to populate the old settings field for
/api/settings
. This allows old clients, e.g. the Cura plugin or apps, to keep functioning with no changes. In a future release this mapping might be removed, but it also allows webcam to offer a "common ground solution" that can be used by clients that don't want to support many different webcam solutions.Timelapse
The timelapse code (Python and web) was updated to rely on the default webcam for taking the timelapse. It's also feasible to add a webcam setting to the timelapse configuration in the future.
Settings
The
webcam
section of/api/settings
is now composed using global settings and the webcams provided by plugins. No fields were removed ensuring full backwards compatibility. Thewebcams
anddefaultWebcam
fields were added. As described above, the values of the default webcam are used to populate the old fields likesnapshotUrl
andstreamUrl
. In a future release of OctoPrint this mapping can be removedClassic Webcam plugin
The webcam implementation from OctoPrint was moved into the
classicwebcam
plugin (name up for debate). This caused a lot of code additions and removals, but basically code from the Control tab and settings got moved into the plugin. The plugin migrates the old settings into the new format by moving data from the global settings space into the plugin's settings.The logic to unload the webcam stream was changed to use the intersection API. This allows the webcam to be started and stopped when the user changes the selected webcam.
How was it tested? How can it be tested by the reviewer?
Tested on my local test instance. To test, simply check out the branch. All data is migrated automatically.
Any background context you want to provide?
This is a preparation in providing a standalone WebRTC plugin. As WebRTC is highly diverse, this setup allows different WebRTC plugins for different servers or even completely different streaming technologies in the future. It also allows plugins like multicam to show their webcams easily in the control tab.
What are the relevant tickets if any?
/
Screenshots (if appropriate)
Screen.Recording.2022-08-21.at.11.43.36.mov
Further notes
Advice required: I had to use the
force=True
flag when migrating the settings, I'm not sure why and if there are any implications. Seeclassicwebcam/__init__.py
line 95 and below.Open Tasks (from discussion below)
WebcamSubWizard
to plugin