diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml new file mode 100644 index 0000000..dabb7c5 --- /dev/null +++ b/.github/workflows/c-cpp.yml @@ -0,0 +1,27 @@ +name: C/C++ CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: windows-latest + + + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + install: mingw-w64-x86_64-gcc mingw-w64-x86_64-make make mingw-w64-x86_64-libjpeg-turbo + update: true + - name: create build dir + shell: msys2 {0} + run: mkdir -p build/gcc + - name: make + shell: msys2 {0} + run: cd src/apps/win/ && make diff --git a/src/apps/win/AccessRightsDialog.cpp b/src/apps/win/AccessRightsDialog.cpp index 00ec41f..4584b48 100644 --- a/src/apps/win/AccessRightsDialog.cpp +++ b/src/apps/win/AccessRightsDialog.cpp @@ -132,8 +132,10 @@ static void AddUserToListView( HWND hwndListView, const string& userName, UserGr lvI.iItem = ListView_GetItemCount( hwndListView ); ListView_InsertItem( hwndListView, &lvI ); + wchar_t adminText[] = L"Admin"; + wchar_t userText[] = L"User"; + lvI.pszText = (userGroup == UserGroup::Admin) ? adminText : userText; - lvI.pszText = ( userGroup == UserGroup::Admin ) ? L"Admin" : L"User"; lvI.mask = LVIF_TEXT; lvI.iSubItem = 1; @@ -171,7 +173,9 @@ static void UpdateUserInListView( HWND hwndListView, const string& userName, Use lvI.mask = LVIF_TEXT; lvI.iItem = i; lvI.iSubItem = 1; - lvI.pszText = ( userGroup == UserGroup::Admin ) ? L"Admin" : L"User"; + wchar_t adminText[] = L"Admin"; + wchar_t userText[] = L"User"; + lvI.pszText = (userGroup == UserGroup::Admin) ? adminText : userText; ListView_SetItem( hwndListView, &lvI ); diff --git a/src/apps/win/EditUserDialog.hpp b/src/apps/win/EditUserDialog.hpp index 87f09f0..df46591 100644 --- a/src/apps/win/EditUserDialog.hpp +++ b/src/apps/win/EditUserDialog.hpp @@ -23,6 +23,7 @@ #include #include +#include typedef struct { diff --git a/src/apps/win/cam2web.rc b/src/apps/win/cam2web.rc index badac12..2988e21 100644 Binary files a/src/apps/win/cam2web.rc and b/src/apps/win/cam2web.rc differ diff --git a/src/apps/win/makefile b/src/apps/win/makefile new file mode 100644 index 0000000..6e607c1 --- /dev/null +++ b/src/apps/win/makefile @@ -0,0 +1,71 @@ +# Compiler settings +CXX = g++ +CXXFLAGS = -Wall -g -DUNICODE -D_UNICODE -D_DEBUG -mssse3 -std=c++0x -fpermissive +INCLUDES = -I../../core/ -I../../core/cameras/DirectShow/ -I../../../externals/mongoose/ + +# Application name +APP = cam2web + +# Source files +CPP_SOURCES = $(wildcard *.cpp) $(wildcard ../../core/*.cpp) $(wildcard ../../core/cameras/DirectShow/*.cpp) +C_SOURCES = $(wildcard ../../../externals/mongoose/*.c) + +# Object files +CPP_OBJECTS = $(CPP_SOURCES:.cpp=.o) +C_OBJECTS = $(C_SOURCES:.c=.o) + +# Libraries to link against +LIBS = -lcomctl32 -lgdi32 -ljpeg -pthread -lIphlpapi -lole32 -lOleAut32 -lstrmiids -luuid -lrpcrt4 -lws2_32 -municode -Wl,-subsystem,windows + +# Output folder +OUT_FOLDER = ../../../build/gcc/ + +# Resource file +RES_FILE = cam2web.rc +RES_OBJECT = cam2web.res +# Default target +all: $(APP) + +# Rule to compile the resource file +$(RES_OBJECT): $(RES_FILE) + windres $(RES_FILE) -O coff -o $(RES_OBJECT) + +# Linking the application +$(APP): $(CPP_OBJECTS) $(C_OBJECTS) $(RES_OBJECT) + $(CXX) $(CXXFLAGS) $(INCLUDES) -o $(OUT_FOLDER)$(APP) $(CPP_OBJECTS) $(C_OBJECTS) $(LIBS) $(RES_OBJECT) + +# Compiling C++ source files into object files +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ + +# Compiling C source files into object files +%.o: %.c + $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ + +copyweb: + mkdir -p $(OUT_WEB) + cp ../../web/* $(OUT_WEB) + cp ../../../externals/jquery/*.js $(OUT_WEB) + cp ../../../externals/jquery/*.css $(OUT_WEB) + cp -r $(OUT_WEB) . + +generateweb: + mkdir -p $(OUT_INC) + cp ../../web/* $(OUT_INC) + cp ../../../externals/jquery/*.js $(OUT_INC) + cp ../../../externals/jquery/*.css $(OUT_INC) + $(WEB2H) -i $(OUT_INC)index.html -o $(OUT_INC)index.html.h + $(WEB2H) -i $(OUT_INC)styles.css -o $(OUT_INC)styles.css.h + $(WEB2H) -i $(OUT_INC)cam2web.png -o $(OUT_INC)cam2web.png.h + $(WEB2H) -i $(OUT_INC)cam2web_white.png -o $(OUT_INC)cam2web_white.png.h + $(WEB2H) -i $(OUT_INC)cameraproperties.html -o $(OUT_INC)cameraproperties.html.h + $(WEB2H) -i $(OUT_INC)camera.js -o $(OUT_INC)camera.js.h + $(WEB2H) -i $(OUT_INC)cameraproperties.js -o $(OUT_INC)cameraproperties.js.h + $(WEB2H) -i $(OUT_INC)jquery.js -o $(OUT_INC)jquery.js.h + $(WEB2H) -i $(OUT_INC)jquery.mobile.js -o $(OUT_INC)jquery.mobile.js.h + $(WEB2H) -i $(OUT_INC)jquery.mobile.css -o $(OUT_INC)jquery.mobile.css.h + rm $(OUT_INC)*.html + rm $(OUT_INC)*.css + rm $(OUT_INC)*.js +# Phony targets +.PHONY: all clean diff --git a/src/core/cameras/DirectShow/XLocalVideoDevice.cpp b/src/core/cameras/DirectShow/XLocalVideoDevice.cpp index 4e9b4f1..0b2f4d2 100644 --- a/src/core/cameras/DirectShow/XLocalVideoDevice.cpp +++ b/src/core/cameras/DirectShow/XLocalVideoDevice.cpp @@ -31,7 +31,6 @@ #include // Include qedit.h to get ISampleGrabberCB declaration #include - #include "XLocalVideoDevice.hpp" #include "XManualResetEvent.hpp" @@ -141,14 +140,14 @@ namespace Private XError SetVideoProperty( XVideoProperty property, int32_t value, bool automatic ); XError GetVideoProperty( XVideoProperty property, int32_t* value, bool* automatic ) const; - XError GetVideoPropertyRange( XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const; + XError GetVideoPropertyRange( XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported ) const; // Camera's control configuration bool IsCameraConfigSupported( ) const; XError SetCameraProperty( XCameraProperty property, int32_t value, bool automatic ); XError GetCameraProperty( XCameraProperty property, int32_t* value, bool* automatic ) const; - XError GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const; + XError GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported ) const; private: // Run video loop in a background thread @@ -619,9 +618,9 @@ XError XLocalVideoDevice::GetVideoProperty( XVideoProperty property, int32_t* va } // Get range of values supported by the specified video property -XError XLocalVideoDevice::GetVideoPropertyRange( XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const +XError XLocalVideoDevice::GetVideoPropertyRange( XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported ) const { - return mData->GetVideoPropertyRange( property, min, max, step, default, isAutomaticSupported ); + return mData->GetVideoPropertyRange( property, min, max, step, defaultValue, isAutomaticSupported ); } // Check if camera configuration is supported @@ -643,9 +642,9 @@ XError XLocalVideoDevice::GetCameraProperty( XCameraProperty property, int32_t* } // Get range of values supported by the specified camera property -XError XLocalVideoDevice::GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const +XError XLocalVideoDevice::GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported ) const { - return mData->GetCameraPropertyRange( property, min, max, step, default, isAutomaticSupported ); + return mData->GetCameraPropertyRange( property, min, max, step, defaultValue, isAutomaticSupported ); } namespace Private @@ -936,7 +935,7 @@ void XLocalVideoDeviceData::RunVideo( bool run ) // configure all video properties, which were set before device got running for ( auto property : VideoPropertiesToSet ) { - configOK &= SetVideoProperty( property.first, property.second.first, property.second.second ); + configOK &= static_cast(SetVideoProperty(property.first, property.second.first, property.second.second)); } VideoPropertiesToSet.clear( ); @@ -955,7 +954,7 @@ void XLocalVideoDeviceData::RunVideo( bool run ) // configure all camera properties, which were set before device got running for ( auto property : CameraPropertiesToSet ) { - configOK &= SetCameraProperty( property.first, property.second.first, property.second.second ); + configOK &= static_cast(SetCameraProperty( property.first, property.second.first, property.second.second )); } CameraPropertiesToSet.clear( ); @@ -1185,12 +1184,12 @@ XError XLocalVideoDeviceData::GetVideoProperty( XVideoProperty property, int32_t } // Get range of values supported by the specified video property -XError XLocalVideoDeviceData::GetVideoPropertyRange( XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const +XError XLocalVideoDeviceData::GetVideoPropertyRange( XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported ) const { lock_guard lock( RunningSync ); XError ret = XError::Success; - if ( ( min == nullptr ) || ( max == nullptr ) || ( step == nullptr ) || ( default == nullptr ) || ( isAutomaticSupported == nullptr ) ) + if ( ( min == nullptr ) || ( max == nullptr ) || ( step == nullptr ) || ( defaultValue == nullptr ) || ( isAutomaticSupported == nullptr ) ) { ret = XError::NullPointer; } @@ -1220,7 +1219,7 @@ XError XLocalVideoDeviceData::GetVideoPropertyRange( XVideoProperty property, in *min = propMin; *max = propMax; *step = propStep; - *default = propDef; + *defaultValue = propDef; *isAutomaticSupported = ( propFlags & VideoProcAmp_Flags_Auto ); } @@ -1333,12 +1332,12 @@ XError XLocalVideoDeviceData::GetCameraProperty( XCameraProperty property, int32 } // Get range of values supported by the specified camera property -XError XLocalVideoDeviceData::GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const +XError XLocalVideoDeviceData::GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported ) const { lock_guard lock( RunningSync ); XError ret = XError::Success; - if ( ( min == nullptr ) || ( max == nullptr ) || ( step == nullptr ) || ( default == nullptr ) || ( isAutomaticSupported == nullptr ) ) + if ( ( min == nullptr ) || ( max == nullptr ) || ( step == nullptr ) || ( defaultValue == nullptr ) || ( isAutomaticSupported == nullptr ) ) { ret = XError::NullPointer; } @@ -1368,7 +1367,7 @@ XError XLocalVideoDeviceData::GetCameraPropertyRange( XCameraProperty property, *min = propMin; *max = propMax; *step = propStep; - *default = propDef; + *defaultValue = propDef; *isAutomaticSupported = ( propFlags & CameraControl_Flags_Auto ); } diff --git a/src/core/cameras/DirectShow/XLocalVideoDevice.hpp b/src/core/cameras/DirectShow/XLocalVideoDevice.hpp index 7bdc176..caf43cc 100644 --- a/src/core/cameras/DirectShow/XLocalVideoDevice.hpp +++ b/src/core/cameras/DirectShow/XLocalVideoDevice.hpp @@ -129,7 +129,7 @@ class XLocalVideoDevice : public IVideoSource, private Uncopyable // Get current value if the specified video property. The device must be running. XError GetVideoProperty( XVideoProperty property, int32_t* value, bool* automatic = nullptr ) const; // Get range of values supported by the specified video property - XError GetVideoPropertyRange( XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const; + XError GetVideoPropertyRange(XVideoProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported) const; // Check if camera configuration is supported (device must be running) bool IsCameraConfigSupported( ) const; @@ -140,7 +140,7 @@ class XLocalVideoDevice : public IVideoSource, private Uncopyable // Get current value if the specified camera property. The device must be running. XError GetCameraProperty( XCameraProperty property, int32_t* value, bool* automatic = nullptr ) const; // Get range of values supported by the specified camera property - XError GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* default, bool* isAutomaticSupported ) const; + XError GetCameraPropertyRange( XCameraProperty property, int32_t* min, int32_t* max, int32_t* step, int32_t* defaultValue, bool* isAutomaticSupported ) const; private: Private::XLocalVideoDeviceData* mData; diff --git a/src/core/cameras/DirectShow/XLocalVideoDeviceConfig.cpp b/src/core/cameras/DirectShow/XLocalVideoDeviceConfig.cpp index 9c4452c..37a3a5f 100644 --- a/src/core/cameras/DirectShow/XLocalVideoDeviceConfig.cpp +++ b/src/core/cameras/DirectShow/XLocalVideoDeviceConfig.cpp @@ -208,23 +208,23 @@ XError XLocalVideoDevicePropsInfo::GetProperty( const std::string& propertyName, } else { - int32_t min = 0, max = 0, step = 0, default = 0; + int32_t min = 0, max = 0, step = 0, defaultValue = 0; bool isAutoSupported; - // get property features - min/max/default/etc + // get property features - min/max/defaultValue/etc if ( itSupportedProperty->second.PropertyKind == PROP_KIND_VIDEO ) { - ret = mCamera->GetVideoPropertyRange( static_cast( itSupportedProperty->second.Property ), &min, &max, &step, &default, &isAutoSupported ); + ret = mCamera->GetVideoPropertyRange( static_cast( itSupportedProperty->second.Property ), &min, &max, &step, &defaultValue, &isAutoSupported ); } else { if ( itSupportedProperty->second.ValueType == TYPE_INT ) { - ret = mCamera->GetCameraPropertyRange( static_cast< XCameraProperty >( itSupportedProperty->second.Property ), &min, &max, &step, &default, &isAutoSupported ); + ret = mCamera->GetCameraPropertyRange( static_cast< XCameraProperty >( itSupportedProperty->second.Property ), &min, &max, &step, &defaultValue, &isAutoSupported ); } else { - default = true; + defaultValue = true; } } @@ -233,12 +233,12 @@ XError XLocalVideoDevicePropsInfo::GetProperty( const std::string& propertyName, if ( itSupportedProperty->second.ValueType == TYPE_INT ) { sprintf( buffer, "{\"min\":%d,\"max\":%d,\"def\":%d,\"type\":\"int\",\"order\":%d,\"name\":\"%s\"}", - min, max, default, itSupportedProperty->second.Order, itSupportedProperty->second.Name ); + min, max, defaultValue, itSupportedProperty->second.Order, itSupportedProperty->second.Name ); } else { sprintf( buffer, "{\"def\":%d,\"type\":\"bool\",\"order\":%d,\"name\":\"%s\"}", - default, itSupportedProperty->second.Order, itSupportedProperty->second.Name ); + defaultValue, itSupportedProperty->second.Order, itSupportedProperty->second.Name ); } value = buffer;