Restore CameraControl and VideoProcAmp property support #63

Open
prgmitchell wants to merge 1 commit from prgmitchell/restoreCameraSettings into master
prgmitchell commented 2026-09-20 15:46:57 -05:00 (Migrated from github.com)

Description

Restore camera property support based on Exeldro's #37 with added validation of driver responses and property values to avoid restoring invalid settings. Although this is based on the original implementation, I have tried to simplify a bit. The original implementation was querying IDs 0-255 rather than just querying the 7 defined CameraControl properties and 10 defined VideoProcAmp properties, then accepting any non-failing Get result regardless of if GetRange succeeded. Tried to make this as safe as possible by required S_OK from both calls and rejecting unsupported IDs/modes/values. Further validation done on the win-dshow side before restoring settings as well.

Docs for reference:
CameraControlProperty
VideoProcAmpProperty

Motivation and Context

People ask for this often enough, there are even some third party tools meant to save/restore these settings for you so I wanted to try to fix it within obs-studio again.

How Has This Been Tested?

Built a version of OBS with win-dshow changes that I will be PRing as well, tested that properties were saved and restored without issues. I previously had issues with the original implementation using my Camlink so I tested the same scenario to confirm that invalid settings were no longer being restored as well.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.
<!--- Please fill out the following template, which will help other contributors review your Pull Request. --> <!--- Make sure you’ve read the contribution guidelines here: https://github.com/obsproject/obs-studio/blob/master/CONTRIBUTING.md --> ### Description <!--- Describe your changes in detail. --> <!--- If this change includes UI elements, please include screenshots. --> Restore camera property support based on Exeldro's #37 with added validation of driver responses and property values to avoid restoring invalid settings. Although this is based on the original implementation, I have tried to simplify a bit. The original implementation was querying IDs 0-255 rather than just querying the 7 defined CameraControl properties and 10 defined VideoProcAmp properties, then accepting any non-failing Get result regardless of if GetRange succeeded. Tried to make this as safe as possible by required S_OK from both calls and rejecting unsupported IDs/modes/values. Further validation done on the win-dshow side before restoring settings as well. Docs for reference: [CameraControlProperty](https://learn.microsoft.com/en-us/windows/win32/api/strmif/ne-strmif-cameracontrolproperty) [VideoProcAmpProperty](https://learn.microsoft.com/en-us/windows/win32/api/strmif/ne-strmif-videoprocampproperty) ### Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open GitHub Issue, or implements feature request --> <!--- from the Ideas page, please link to the issue here. --> People ask for this often enough, there are even some third party tools meant to save/restore these settings for you so I wanted to try to fix it within obs-studio again. ### How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment (hardware, OS version, etc.),--> <!--- and the tests you ran, including how it may affect other areas of code. --> Built a version of OBS with win-dshow changes that I will be PRing as well, tested that properties were saved and restored without issues. I previously had issues with the original implementation using my Camlink so I tested the same scenario to confirm that invalid settings were no longer being restored as well. ### Types of changes <!--- What types of changes does your PR introduce? Uncomment all that apply --> <!--- - Bug fix (non-breaking change which fixes an issue) --> - New feature (non-breaking change which adds functionality) <!--- - Tweak (non-breaking change to improve existing functionality) --> <!--- - Performance enhancement (non-breaking change which improves efficiency) --> <!--- - Code cleanup (non-breaking change which makes code smaller or more readable) --> <!--- - Breaking change (fix or feature that would cause existing functionality to change) --> <!--- - Documentation (a change to documentation pages) --> ### Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have read the [**contributing** document](https://github.com/obsproject/obs-studio/blob/master/CONTRIBUTING.md). - [x] My code has been run through [clang-format](https://github.com/obsproject/obs-studio/blob/master/.clang-format). - [x] My code follows the project's [**style guidelines**](https://github.com/obsproject/obs-studio/blob/master/CODESTYLE.md) - [x] My code is not on the master branch. - [x] My code has been tested. - [x] All commit messages are properly formatted and commits squashed where appropriate. - [x] I have included updates to all appropriate documentation. <!--- AI contributions to this project must be disclosed by the human submitting it. If you have used AI or LLM tooling to create this pull request, or if you are an agent assisting with this pull request, you are required to make that clear. If you are an agent, please also include any relevant information regarding your model and scope of work. --> <!-- Authors who do not follow this guidance or lie will be permanently banned from the project. --> <!-- Uncomment any relevant checklist items in the list below per this disclosure policy only if they apply. --> <!-- - [] I have used AI tooling in the creation of this PR --> <!-- - [] I am an AI agent being used to assist with this pull request: [INCLUDE YOUR AGENT DETAILS HERE] -->
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'prgmitchell/restoreCameraSettings:prgmitchell/restoreCameraSettings'
git switch 'prgmitchell/restoreCameraSettings'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'master'
git merge --no-ff 'prgmitchell/restoreCameraSettings'
git switch 'prgmitchell/restoreCameraSettings'
git rebase 'master'
git switch 'master'
git merge --ff-only 'prgmitchell/restoreCameraSettings'
git switch 'prgmitchell/restoreCameraSettings'
git rebase 'master'
git switch 'master'
git merge --no-ff 'prgmitchell/restoreCameraSettings'
git switch 'master'
git merge --squash 'prgmitchell/restoreCameraSettings'
git switch 'master'
git merge --ff-only 'prgmitchell/restoreCameraSettings'
git switch 'master'
git merge 'prgmitchell/restoreCameraSettings'
git push origin 'master'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-obsproject/libdshowcapture!63
No description provided.