Closed jotaen4tinypilot closed 1 year ago
@mtlynch I slotted this ticket for 2.5.1 as suggestion, because I thought it would make sense to get it done timely (though after all other H264 work in any event). Please feel free to defer. My estimate would be “medium”.
I’ve updated the issue description with an actionable task list. I’d see most value in the first two items, because they will eliminate a lot of code repetitions; the last two (revising the naming) would be nice for code hygiene, but optional or at least deferable in my eyes.
Thanks, @jotaen4tinypilot. I think we should just do all of them this sprint. The last two are deferable, but they also seem like only a straightforward couple hours of work, if that.
Currently, we have two video settings:
jpegQuality
andvideoFps
. In order for us to get and set the value, and to retrieve the default value, we need (per setting):controllers.js
api.py
update.settings
That totals at almost 200 LOC per setting, so 400 LOC for both. The code is practically identical.
I assume we have intentionally opted for duplication and fine-granularity when originally implementing this, because back then it probably wasn’t as clear how the video settings feature would evolve over time.
I think the situation is much clearer now. We are also about to bring in a third parameter
h264Bitrate
, which will work in the exact same way as the existing two – adding another 200 LOC.So I think it should be safe for us to invest into a clean-up at this point.
Refactoring goals
video
. That’s helpful for the controller functions and the api endpoints, because it acts as a namespace. However, the prefixes are not really necessary within those scopes, e.g. when it comes to the names of the JSON properties or internal variables.FPS
→Frame Rate
andJPEG Quality
toQuality
. We should therefore revise the terminology in the code too:fps
→frameRate
, because “fps” is just the unit, whereas “frame rate” is “the actual thing”.jpegQuality
→mjpegQuality
, so that we establish two consistent prefixesmjpeg
andh264
for the respective streaming modes. (Reminder: the frame rate setting, in contrast, applies to both streaming modes likewise, so it’s not exclusive to MJPEG, and hence shouldn’t be prefixed.)Tasks / PRs
(Prioritised)
video
prefix, unless it acts as “namespace”