Skip to content

Commit

Permalink
Fix for erronously always returning formats for first camera on syste…
Browse files Browse the repository at this point in the history
…ms with more than one camera.
  • Loading branch information
sskodje committed May 24, 2024
1 parent 614f0f0 commit a046fae
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ScreenRecorderLib/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,21 @@ List<VideoCaptureFormat^>^ ScreenRecorderLib::Recorder::GetSupportedVideoCapture
MeasureExecutionTime measure(L"GetSupportedVideoCaptureFormatsForDevice");
std::vector<IMFActivate*> captureDevices;
HRESULT hr = EnumVideoCaptureDevices(&captureDevices);
std::wstring devicePathWstring = msclr::interop::marshal_as<std::wstring>(DevicePath);


if (SUCCEEDED(hr))
{
ReleaseVectorOnExit release(captureDevices);
for (auto const& pDevice : captureDevices) {
// Get the device path
WCHAR* symbolicLink = NULL;
UINT32 cchSymbolicLink;
hr = pDevice->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, &symbolicLink, &cchSymbolicLink);
CoTaskMemFreeOnExit freeSymbolicLink(symbolicLink);
if (FAILED(hr) || symbolicLink == NULL || (!devicePathWstring.empty() && devicePathWstring != symbolicLink)) {
continue;
}

CComPtr<IMFMediaSource> pSource = nullptr;
CONTINUE_ON_BAD_HR(hr = pDevice->ActivateObject(__uuidof(IMFMediaSource), (void**)&pSource));
Expand Down

0 comments on commit a046fae

Please sign in to comment.