Skip to content

Commit

Permalink
Merge pull request #51 from sandman42292/mingw_support
Browse files Browse the repository at this point in the history
MinGW support
  • Loading branch information
vonnieda authored Mar 17, 2022
2 parents 0aa77fb + 4e363a6 commit cd632a4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions win/platformcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include <vector>
#include <stdio.h>

#include <windows.h>
#include <mmsystem.h> // for MAKEFOURCC macro

#include "../common/logging.h"
#include "scopedcomptr.h"
#include "platformstream.h"
Expand Down Expand Up @@ -94,7 +97,7 @@ bool PlatformContext::enumerateDevices()

ScopedComPtr<ICreateDevEnum> 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!
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion win/platformdeviceinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define win_platformdeviceinfo_h

#include <windows.h>
#include <Dshow.h>
#include <dshow.h>
#include <string>

#include "../common/deviceinfo.h"
Expand Down
6 changes: 4 additions & 2 deletions win/platformstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "platformcontext.h"
#include "scopedcomptr.h"

#include <cmath>

extern HRESULT FindCaptureDevice(IBaseFilter** ppSrcFilter, const wchar_t* wDeviceName);
extern void _FreeMediaType(AM_MEDIA_TYPE& mt);

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions win/platformstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

#include <windows.h>
#include <dshow.h>
#include <Vidcap.h>
#include <Ksmedia.h>
#include <ks.h>
#include <ksmedia.h>

#include <stdint.h>
#include <vector>
Expand Down

0 comments on commit cd632a4

Please sign in to comment.