Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add camera support for windows. #12572

Merged
merged 5 commits into from
Jan 15, 2020
Merged

Conversation

shenweip
Copy link
Contributor

@shenweip shenweip commented Jan 13, 2020

Implement this with MF api,referenced some Microsoft docs and samples.
I tested Invizimals, it works fine on my laptop(with a Microsoft HD Webcam).
Preview:
2
Also has a basic support for multi camera switching.
3

EDIT by hrydgard: Helps #12337

@hrydgard
Copy link
Owner

Very cool! How far back in Windows versions does this API work? Is it supported on Vista?

I was dreading doing this because of DirectShow which I still have nightmares about (only slightly kidding)...

@hrydgard hrydgard added this to the v1.10.0 milestone Jan 13, 2020
@shenweip
Copy link
Contributor Author

Accordings to docs, most of them are supported on vista, maybe few are not supported though,like MFEnumDeviceSources function.It has a full support on win7.I think not many users on vista?

@hrydgard
Copy link
Owner

It's just that I don't want a change to our minimum requirements to be accidental, it should be intentional. Currently PPSSPP supports Vista and forwards, so it would be good to be sure - if this API doesn't work there, we could simply disable it on Vista, keeping PPSSPP working for Vista users even though they won't get this feature.

@shenweip
Copy link
Contributor Author

Yeah, it's right, I will comfirm this through VMware.

UI/NativeApp.cpp Outdated
@@ -879,6 +888,11 @@ void NativeShutdownGraphics() {
winAudioBackend = nullptr;
#endif

#ifdef _WIN32
delete winCamera;
Copy link
Contributor

@Florin9doi Florin9doi Jan 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (winCamera) { delete } ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really necessary as delete handles nullptr, but it's fine either way I think.

Don't implemente on vista and UWP,they don't have a full support for this.
@Florin9doi
Copy link
Contributor

Florin9doi commented Jan 14, 2020

I've tested the first commit and I've observed that the image is stretched because the games ask for 480x272, but the webcam provides 640x480 (I think) which have a different aspect ratio.
This can be fixed by passing to sws_scale/sws_getContext a smaller source height (362 instead of 480)

@hrydgard
Copy link
Owner

If you pass a smaller source height you should also offset, to center it vertically, I guess. Though I'm not sure how much that matters for these games...

@hrydgard hrydgard merged commit 96e7281 into hrydgard:master Jan 15, 2020
@hrydgard
Copy link
Owner

Improving stuff like that can be done later, good to get the functionality in, so I'm merging.

@shenweip shenweip deleted the Capture_Win branch January 16, 2020 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants