From 24134d0ad5cd9b547ffc396d05fbff167a0c1d88 Mon Sep 17 00:00:00 2001 From: sandman42292 Date: Sun, 21 Nov 2021 23:44:11 +0900 Subject: [PATCH 1/3] fix for mingw compiler --- CMakeLists.txt | 11 +++++++---- win/platformdeviceinfo.h | 2 +- win/platformstream.cpp | 6 ++++-- win/platformstream.h | 3 +-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a1d4ae..771a60b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,10 +70,12 @@ set_target_properties(openpnp-capture PROPERTIES SOVERSION ${OPENPNP_CAPTURE_LIB_SOVERSION}) IF (WIN32) - # build with static runtime rather than DLL based so that we - # don't have to distribute it - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") + if(MSVC) + # build with static runtime rather than DLL based so that we + # don't have to distribute it + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") + endif() # set the platform identification string add_definitions(-D__PLATFORM__="Win ${COMPILERBITS}") @@ -84,6 +86,7 @@ IF (WIN32) # add files for WIN32 target_sources(openpnp-capture PRIVATE win/platformcontext.cpp win/platformstream.cpp) + target_link_libraries(openpnp-capture strmiids) # add windows-specific test application add_subdirectory(win/tests) diff --git a/win/platformdeviceinfo.h b/win/platformdeviceinfo.h index 2b75ef3..25dbffe 100644 --- a/win/platformdeviceinfo.h +++ b/win/platformdeviceinfo.h @@ -27,7 +27,7 @@ #define win_platformdeviceinfo_h #include -#include +#include #include #include "../common/deviceinfo.h" diff --git a/win/platformstream.cpp b/win/platformstream.cpp index 2ae0f33..8b69b98 100644 --- a/win/platformstream.cpp +++ b/win/platformstream.cpp @@ -31,6 +31,8 @@ #include "platformcontext.h" #include "scopedcomptr.h" +#include + extern HRESULT FindCaptureDevice(IBaseFilter** ppSrcFilter, const wchar_t* wDeviceName); extern void _FreeMediaType(AM_MEDIA_TYPE& mt); @@ -544,8 +546,8 @@ void PlatformStream::dumpCameraProperties() if (m_camControl->GetRange(CameraControl_Exposure, &mmin, &mmax, &delta, &defaultValue, &flags) == S_OK) { - LOG(LOG_INFO, "Exposure min : %2.3f seconds (%d integer)\n", pow(2.0f, (float)mmin), mmin); - LOG(LOG_INFO, "Exposure max : %2.3f seconds (%d integer)\n", pow(2.0f, (float)mmax), mmax); + LOG(LOG_INFO, "Exposure min : %2.3f seconds (%d integer)\n", std::pow(2.0f, (float)mmin), mmin); + LOG(LOG_INFO, "Exposure max : %2.3f seconds (%d integer)\n", std::pow(2.0f, (float)mmax), mmax); LOG(LOG_INFO, "Exposure step : %d (integer)\n", delta); LOG(LOG_INFO, "Exposure default : %2.3f seconds\n", pow(2.0f, (float)defaultValue)); LOG(LOG_INFO, "Flags : %08X\n", flags); diff --git a/win/platformstream.h b/win/platformstream.h index 8be74fe..cb3fc68 100644 --- a/win/platformstream.h +++ b/win/platformstream.h @@ -31,8 +31,7 @@ #include #include -#include -#include +#include #include #include From 56b93370690b95f1e3515e1eb3ad3aea84132c85 Mon Sep 17 00:00:00 2001 From: sandman42292 Date: Sun, 21 Nov 2021 23:54:12 +0900 Subject: [PATCH 2/3] add ks.h include --- win/platformstream.h | 1 + 1 file changed, 1 insertion(+) diff --git a/win/platformstream.h b/win/platformstream.h index cb3fc68..56b9c83 100644 --- a/win/platformstream.h +++ b/win/platformstream.h @@ -31,6 +31,7 @@ #include #include +#include #include #include From 4e363a63de741584a0f6cc7cf09675b5b6a566e0 Mon Sep 17 00:00:00 2001 From: sandman42292 Date: Mon, 22 Nov 2021 22:17:02 +0900 Subject: [PATCH 3/3] remove warnings --- win/platformcontext.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/win/platformcontext.cpp b/win/platformcontext.cpp index c37e7d2..8b2f52b 100644 --- a/win/platformcontext.cpp +++ b/win/platformcontext.cpp @@ -32,6 +32,9 @@ #include #include +#include +#include // for MAKEFOURCC macro + #include "../common/logging.h" #include "scopedcomptr.h" #include "platformstream.h" @@ -94,7 +97,7 @@ bool PlatformContext::enumerateDevices() ScopedComPtr devEnum(dev_enum); - hr = devEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&enum_moniker,NULL); + hr = devEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&enum_moniker, 0); if (hr == S_FALSE) { // no devices found! @@ -371,11 +374,11 @@ bool PlatformContext::enumerateFrameInfo(IMoniker *moniker, platformDeviceInfo * newFrameInfo.bpp = pVih->bmiHeader.biBitCount; if (pVih->bmiHeader.biCompression == BI_RGB) { - newFrameInfo.fourcc = 'RGB '; + newFrameInfo.fourcc = MAKEFOURCC('R', 'G', 'B', ' '); } else if (pVih->bmiHeader.biCompression == BI_BITFIELDS) { - newFrameInfo.fourcc = ' '; + newFrameInfo.fourcc = MAKEFOURCC(' ', ' ', ' ', ' '); } else {