diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index f2eb897a4d..1f09762623 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -77,7 +77,6 @@ body: - Shortcut Guide - System tray interaction - TextExtractor - - Video Conference Mute - Workspaces - Welcome / PowerToys Tour window validations: diff --git a/.github/ISSUE_TEMPLATE/translation_issue.yml b/.github/ISSUE_TEMPLATE/translation_issue.yml index 69787a3ed6..63efb7c928 100644 --- a/.github/ISSUE_TEMPLATE/translation_issue.yml +++ b/.github/ISSUE_TEMPLATE/translation_issue.yml @@ -51,7 +51,6 @@ body: - Shortcut Guide - System tray interaction - TextExtractor - - Video Conference Mute - Workspaces - Welcome / PowerToys Tour window validations: diff --git a/.github/actions/spell-check/allow/names.txt b/.github/actions/spell-check/allow/names.txt index fb7ff648b2..d82eb28c11 100644 --- a/.github/actions/spell-check/allow/names.txt +++ b/.github/actions/spell-check/allow/names.txt @@ -23,7 +23,6 @@ registrypreview rooler scoobe shortcutguide -videoconference # USERS diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index ba07b47d3a..f0d15e6ba2 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -1185,7 +1185,7 @@ psrm psrree pstatstg pstm -pstr +PStr pstream pstrm PSYSTEM @@ -1648,7 +1648,6 @@ vcamp vcdl vcgtq VCINSTALLDIR -vcm Vcpkg VCRT vcruntime @@ -1667,7 +1666,6 @@ vget vgetq vid VIDCAP -videoconferencevirtualdriver VIDEOINFOHEADER viewmodel vih diff --git a/.pipelines/ESRPSigning_core.json b/.pipelines/ESRPSigning_core.json index 1f84b4d415..76b55d0597 100644 --- a/.pipelines/ESRPSigning_core.json +++ b/.pipelines/ESRPSigning_core.json @@ -17,7 +17,6 @@ "PowerToys.FilePreviewCommon.dll", "PowerToys.Interop.dll", "Tools\\PowerToys.BugReportTool.exe", - "WebcamReportTool\\PowerToys.WebcamReportTool.exe", "StylesReportTool\\PowerToys.StylesReportTool.exe", "Telemetry.dll", "PowerToys.ManagedTelemetry.dll", @@ -212,11 +211,6 @@ "PowerToys.ShortcutGuide.exe", "PowerToys.ShortcutGuideModuleInterface.dll", - "PowerToys.VideoConferenceModule.dll", - "PowerToys.VideoConferenceProxyFilter_x86.dll", - "PowerToys.VideoConferenceProxyFilter_x64.dll", - "PowerToys.VideoConferenceProxyFilter_arm64.dll", - "WinUI3Apps\\PowerToys.Settings.dll", "WinUI3Apps\\PowerToys.Settings.exe" ], diff --git a/.pipelines/ESRPSigning_vcm.json b/.pipelines/ESRPSigning_vcm.json deleted file mode 100644 index e9f2309cc4..0000000000 --- a/.pipelines/ESRPSigning_vcm.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "Version": "1.0.0", - "UseMinimatch": false, - "SignBatches": [ - { - "MatchedPath": [ - "PowerToys.VideoConferenceProxyFilter_x86.dll" - ], - "SigningInfo": { - "Operations": [ - { - "KeyCode": "CP-230012", - "OperationSetCode": "SigntoolSign", - "Parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "ToolName": "sign", - "ToolVersion": "1.0" - }, - { - "KeyCode": "CP-230012", - "OperationSetCode": "SigntoolVerify", - "Parameters": [], - "ToolName": "sign", - "ToolVersion": "1.0" - } - ] - } - } - ] -} diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index 653e8cc9fd..5a3b787ede 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -172,7 +172,6 @@ jobs: - pwsh: |- & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\PowerToys.sln' & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\BugReportTool\BugReportTool.sln' - & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\WebcamReportTool\WebcamReportTool.sln' & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\tools\StylesReportTool\StylesReportTool.sln' & '.pipelines/verifyArm64Configuration.ps1' -solution '$(build.sourcesdirectory)\installer\PowerToysSetup.sln' displayName: Verify ARM64 configurations @@ -361,27 +360,6 @@ jobs: env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) - - task: VSBuild@1 - displayName: Build WebcamReportTool - inputs: - solution: '**/tools/WebcamReportTool/WebcamReportTool.sln' - vsVersion: 17.0 - msbuildArgs: >- - -restore -graph - /p:RestorePackagesConfig=true - /p:CIBuild=true - /bl:$(LogOutputDirectory)\build-webcam-report.binlog - ${{ parameters.additionalBuildOptions }} - $(MSBuildCacheParameters) - $(RestoreAdditionalProjectSourcesArg) - platform: $(BuildPlatform) - configuration: $(BuildConfiguration) - msbuildArchitecture: x64 - maximumCpuCount: true - ${{ if eq(parameters.enableMsBuildCaching, true) }}: - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - - task: VSBuild@1 displayName: Build StylesReportTool inputs: @@ -484,7 +462,7 @@ jobs: displayName: Sign Core PowerToys signingIdentity: ${{ parameters.signingIdentity }} inputs: - FolderPath: '$(BuildPlatform)/$(BuildConfiguration)' # Video conf uses x86 and x64. + FolderPath: '$(BuildPlatform)/$(BuildConfiguration)' signType: batchSigning batchSignPolicyFile: '$(build.sourcesdirectory)\.pipelines\ESRPSigning_core.json' ciPolicyFile: '$(build.sourcesdirectory)\.pipelines\CIPolicy.xml' @@ -499,16 +477,6 @@ jobs: batchSignPolicyFile: '$(build.sourcesdirectory)\.pipelines\ESRPSigning_DSC.json' ciPolicyFile: '$(build.sourcesdirectory)\.pipelines\CIPolicy.xml' - - template: steps-esrp-signing.yml - parameters: - displayName: Sign x86 DirectShow VCM - signingIdentity: ${{ parameters.signingIdentity }} - inputs: - FolderPath: 'x86/$(BuildConfiguration)' # Video conf uses x86 and x64. - signType: batchSigning - batchSignPolicyFile: '$(build.sourcesdirectory)\.pipelines\ESRPSigning_vcm.json' - ciPolicyFile: '$(build.sourcesdirectory)\.pipelines\CIPolicy.xml' - - template: steps-build-installer.yml parameters: codeSign: ${{ parameters.codeSign }} diff --git a/DATA_AND_PRIVACY.md b/DATA_AND_PRIVACY.md index 5570729c20..a8714fa903 100644 --- a/DATA_AND_PRIVACY.md +++ b/DATA_AND_PRIVACY.md @@ -941,26 +941,6 @@ _If you want to find diagnostic data events in the source code, these two links -### Video Conference Mute - - - - - - - - - - - - - - - - - -
Event NameDescription
Microsoft.PowerToys.VideoConference_CameraMutedTriggered when the camera is turned off by Video Conference Mute.
Microsoft.PowerToys.VideoConference_EnableVideoConferenceOccurs when Video Conference Mute is enabled.
Microsoft.PowerToys.VideoConference_MicrophoneMutedOccurs when the microphone is muted by Video Conference Mute.
- ### Workspaces diff --git a/PowerToys.sln b/PowerToys.sln index ca7fa06db7..f28a7c8013 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -349,17 +349,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerToys.Update", "src\Upd EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Run.Plugin.WindowsSettings", "src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.WindowsSettings\Microsoft.PowerToys.Run.Plugin.WindowsSettings.csproj", "{5043CECE-E6A7-4867-9CBE-02D27D83747A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceShared", "src\modules\videoconference\VideoConferenceShared\VideoConferenceShared.vcxproj", "{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceModule", "src\modules\videoconference\VideoConferenceModule\VideoConference.vcxproj", "{5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceProxyFilter", "src\modules\videoconference\VideoConferenceProxyFilter\VideoConferenceProxyFilter.vcxproj", "{AC2857B4-103D-4D6D-9740-926EBF785042}" - ProjectSection(ProjectDependencies) = postProject - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A} = {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VideoConference", "VideoConference", "{470FBAF9-E1F8-4F3E-8786-198A1C81C8A8}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PdfThumbnailProvider", "src\modules\previewpane\PdfThumbnailProvider\PdfThumbnailProvider.csproj", "{11491FD8-F921-48BF-880C-7FEA185B80A1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-PdfThumbnailProvider", "src\modules\previewpane\UnitTests-PdfThumbnailProvider\UnitTests-PdfThumbnailProvider.csproj", "{F40C3397-1834-4530-B2D9-8F8B8456BCDF}" @@ -1509,40 +1498,6 @@ Global {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.ActiveCfg = Release|x64 {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.Build.0 = Release|x64 {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x86.ActiveCfg = Release|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|ARM64.Build.0 = Debug|ARM64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|x64.ActiveCfg = Debug|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|x64.Build.0 = Debug|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|x86.ActiveCfg = Debug|Win32 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|x86.Build.0 = Debug|Win32 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|ARM64.ActiveCfg = Release|ARM64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|ARM64.Build.0 = Release|ARM64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.ActiveCfg = Release|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.Build.0 = Release|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x86.ActiveCfg = Release|Win32 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x86.Build.0 = Release|Win32 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Debug|ARM64.Build.0 = Debug|ARM64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Debug|x64.ActiveCfg = Debug|x64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Debug|x64.Build.0 = Debug|x64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Debug|x86.ActiveCfg = Debug|x64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Release|ARM64.ActiveCfg = Release|ARM64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Release|ARM64.Build.0 = Release|ARM64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Release|x64.ActiveCfg = Release|x64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Release|x64.Build.0 = Release|x64 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB}.Release|x86.ActiveCfg = Release|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|ARM64.Build.0 = Debug|ARM64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|x64.ActiveCfg = Debug|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|x64.Build.0 = Debug|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|x86.ActiveCfg = Debug|Win32 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|x86.Build.0 = Debug|Win32 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|ARM64.ActiveCfg = Release|ARM64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|ARM64.Build.0 = Release|ARM64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x64.ActiveCfg = Release|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x64.Build.0 = Release|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x86.ActiveCfg = Release|Win32 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x86.Build.0 = Release|Win32 {11491FD8-F921-48BF-880C-7FEA185B80A1}.Debug|ARM64.ActiveCfg = Debug|ARM64 {11491FD8-F921-48BF-880C-7FEA185B80A1}.Debug|ARM64.Build.0 = Debug|ARM64 {11491FD8-F921-48BF-880C-7FEA185B80A1}.Debug|x64.ActiveCfg = Debug|x64 @@ -2938,10 +2893,6 @@ Global {48804216-2A0E-4168-A6D8-9CD068D14227} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD} {FF1D7936-842A-4BBB-8BEA-E9FE796DE700} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD} {5043CECE-E6A7-4867-9CBE-02D27D83747A} = {4AFC9975-2456-4C70-94A4-84073C1CED93} - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A} = {470FBAF9-E1F8-4F3E-8786-198A1C81C8A8} - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB} = {470FBAF9-E1F8-4F3E-8786-198A1C81C8A8} - {AC2857B4-103D-4D6D-9740-926EBF785042} = {470FBAF9-E1F8-4F3E-8786-198A1C81C8A8} - {470FBAF9-E1F8-4F3E-8786-198A1C81C8A8} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} {11491FD8-F921-48BF-880C-7FEA185B80A1} = {2F305555-C296-497E-AC20-5FA1B237996A} {F40C3397-1834-4530-B2D9-8F8B8456BCDF} = {2F305555-C296-497E-AC20-5FA1B237996A} {A2D583F0-B70C-4462-B1F0-8E81AFB7BA85} = {4AFC9975-2456-4C70-94A4-84073C1CED93} diff --git a/README.md b/README.md index 6e68190911..6b2cc35f66 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline | [New+](https://aka.ms/PowerToysOverview_NewPlus) | [Peek](https://aka.ms/PowerToysOverview_Peek) | [Paste as Plain Text](https://aka.ms/PowerToysOverview_PastePlain) | | [PowerRename](https://aka.ms/PowerToysOverview_PowerRename) | [PowerToys Run](https://aka.ms/PowerToysOverview_PowerToysRun) | [Quick Accent](https://aka.ms/PowerToysOverview_QuickAccent) | | [Registry Preview](https://aka.ms/PowerToysOverview_RegistryPreview) | [Screen Ruler](https://aka.ms/PowerToysOverview_ScreenRuler) | [Shortcut Guide](https://aka.ms/PowerToysOverview_ShortcutGuide) | -| [Text Extractor](https://aka.ms/PowerToysOverview_TextExtractor) | [Video Conference Mute](https://aka.ms/PowerToysOverview_VideoConference) | [Workspaces](https://aka.ms/PowerToysOverview_Workspaces) | +| [Text Extractor](https://aka.ms/PowerToysOverview_TextExtractor) | [Workspaces](https://aka.ms/PowerToysOverview_Workspaces) | ## Installing and running Microsoft PowerToys @@ -226,6 +226,5 @@ The application logs basic diagnostic data (telemetry). For more information on [winget-link]: https://github.com/microsoft/winget-cli#installing-the-client [roadmap]: https://github.com/microsoft/PowerToys/wiki/Roadmap [privacy-link]: http://go.microsoft.com/fwlink/?LinkId=521839 -[vidConfOverview]: https://aka.ms/PowerToysOverview_VideoConference [loc-bug]: https://github.com/microsoft/PowerToys/issues/new?assignees=&labels=&template=translation_issue.md&title= [usingPowerToys-docs-link]: https://aka.ms/powertoys-docs diff --git a/doc/devdocs/akaLinks.md b/doc/devdocs/akaLinks.md index 6b0dcac1d8..eae60c1161 100644 --- a/doc/devdocs/akaLinks.md +++ b/doc/devdocs/akaLinks.md @@ -29,7 +29,6 @@ | PowerToysOverview_PowerRename | https://learn.microsoft.com/windows/powertoys/powerrename | | PowerToysOverview_PowerToysRun | https://learn.microsoft.com/windows/powertoys/run | | PowerToysOverview_ShortcutGuide | https://learn.microsoft.com/windows/powertoys/shortcut-guide | -| PowerToysOverview_VideoConference | https://learn.microsoft.com/windows/powertoys/video-conference-mute | | powerToysPowerLauncherImageSmall | https://github.com/microsoft/PowerToys/wiki/images/overview/PowerLauncher_small.png | | powerToysPowerLauncherSettingImage | https://raw.githubusercontent.com/microsoft/PowerToys/main/doc/images/overview/PowerLauncher_large.png | | powerToysPowerPreviewImageSmall | https://github.com/microsoft/PowerToys/wiki/images/overview/PowerPreview_small.png | @@ -42,6 +41,4 @@ | powerToysRequestFeature | https://github.com/microsoft/PowerToys/issues/new?assignees=&labels=&template=feature_request.md&title= | | powerToysShortcutGuideImageSmall | https://github.com/microsoft/PowerToys/wiki/images/overview/ShortcutGuide_small.png | | powerToysShortcutGuideSettingImage | https://raw.githubusercontent.com/microsoft/PowerToys/main/doc/images/overview/ShortcutGuide_large.png | -| powerToysVideoConferenceImageSmall | https://github.com/microsoft/PowerToys/wiki/images/overview/VideoConference_small.png | -| powerToysVideoConferenceSettingImage | https://github.com/microsoft/PowerToys/wiki/images/overview/VideoConference_large.png | | powertoyswiki | https://github.com/microsoft/PowerToys/wiki | diff --git a/doc/devdocs/readme.md b/doc/devdocs/readme.md index 558cb5aa49..50912c5b3f 100644 --- a/doc/devdocs/readme.md +++ b/doc/devdocs/readme.md @@ -73,7 +73,6 @@ The installer can only be compiled in `Release` mode; steps 1 and 2 must be perf 1. Compile `PowerToys.sln`. Instructions are listed above. 1. Compile `BugReportTool.sln` tool. Path from root: `tools\BugReportTool\BugReportTool.sln` (details listed below) -1. Compile `WebcamReportTool.sln` tool. Path from root: `tools\WebcamReportTool\WebcamReportTool.sln` (details listed below) 1. Compile `StylesReportTool.sln` tool. Path from root: `tools\StylesReportTool\StylesReportTool.sln` (details listed below) 1. Compile `PowerToysSetup.sln` Path from root: `installer\PowerToysSetup.sln` (details listed below) @@ -95,9 +94,6 @@ The installer can only be compiled in `Release` mode; steps 1 and 2 must be perf nuget restore .\tools\BugReportTool\BugReportTool.sln msbuild -p:Platform=x64 -p:Configuration=Release .\tools\BugReportTool\BugReportTool.sln -nuget restore .\tools\WebcamReportTool\WebcamReportTool.sln -msbuild -p:Platform=x64 -p:Configuration=Release .\tools\WebcamReportTool\WebcamReportTool.sln - nuget restore .\tools\StylesReportTool\StylesReportTool.sln msbuild -p:Platform=x64 -p:Configuration=Release .\tools\StylesReportTool\StylesReportTool.sln ``` @@ -109,9 +105,6 @@ If you prefer, you can alternatively build prerequisite projects for the install 1. Open `tools\BugReportTool\BugReportTool.sln` 1. In Visual Studio, in the `Solutions Configuration` drop-down menu select `Release` 1. From the `Build` menu, choose `Build Solution`. -1. Open `tools\WebcamReportTool\WebcamReportTool.sln` -1. In Visual Studio, in the `Solutions Configuration` drop-down menu select `Release` -1. From the `Build` menu, choose `Build Solution`. 1. Open `tools\StylesReportTool\StylesReportTool.sln` 1. In Visual Studio, in the `Solutions Configuration` drop-down menu select `Release` 1. From the `Build` menu, choose `Build Solution`. diff --git a/doc/devdocs/tools/build-tools.md b/doc/devdocs/tools/build-tools.md index dfa4e251b2..b8acaa3273 100644 --- a/doc/devdocs/tools/build-tools.md +++ b/doc/devdocs/tools/build-tools.md @@ -25,7 +25,3 @@ This script is used by the pipeline to move the .resw files to the correct locat ## [versionSetting.ps1](/tools/build/versionSetting.ps1) Sets `version.props` file with the version number. - -## [video_conference_make_cab.ps1](/tools/build/video_conference_make_cab.ps1) - -This script creates a cab file for the Video Conference Mute driver. diff --git a/doc/devdocs/tools/readme.md b/doc/devdocs/tools/readme.md index 1bf19d610b..a2640bda7a 100644 --- a/doc/devdocs/tools/readme.md +++ b/doc/devdocs/tools/readme.md @@ -18,4 +18,3 @@ Following tools are currently available: * [project template](/tools/project_template/README.md) - A Visual Studio project template for a new PowerToys project. * [StylesReportTool](styles-report-tool.md) - A tool to collect information about an open window. * [Verification scripts](verification-scripts.md) - A set of scripts that help verifying the PowerToys installation. -* [WebcamReportTool](webcam-report-tool.md) - A tool to collect information about the connected webcams. diff --git a/doc/devdocs/tools/webcam-report-tool.md b/doc/devdocs/tools/webcam-report-tool.md deleted file mode 100644 index efa6d47da3..0000000000 --- a/doc/devdocs/tools/webcam-report-tool.md +++ /dev/null @@ -1,6 +0,0 @@ -# [WebcamReportTool](/tools/WebcamReportTool/) - -This command line application generates a report about the connected webcams on the desktop called "WebcamReport.txt". The report contains the following information about every webcam: - -* Name -* Supported formats diff --git a/doc/images/overview/Original/VideoConference.png b/doc/images/overview/Original/VideoConference.png deleted file mode 100644 index 3a71531361..0000000000 Binary files a/doc/images/overview/Original/VideoConference.png and /dev/null differ diff --git a/doc/images/overview/VideoConference_large.png b/doc/images/overview/VideoConference_large.png deleted file mode 100644 index 028d98889c..0000000000 Binary files a/doc/images/overview/VideoConference_large.png and /dev/null differ diff --git a/doc/images/overview/VideoConference_small.png b/doc/images/overview/VideoConference_small.png deleted file mode 100644 index 8e2030e92d..0000000000 Binary files a/doc/images/overview/VideoConference_small.png and /dev/null differ diff --git a/installer/PowerToysSetup/Common.wxi b/installer/PowerToysSetup/Common.wxi index f036b3797b..21855a7936 100644 --- a/installer/PowerToysSetup/Common.wxi +++ b/installer/PowerToysSetup/Common.wxi @@ -8,7 +8,6 @@ - diff --git a/installer/PowerToysSetup/PowerToysInstaller.wixproj b/installer/PowerToysSetup/PowerToysInstaller.wixproj index 8771920c3c..7ce39b82cf 100644 --- a/installer/PowerToysSetup/PowerToysInstaller.wixproj +++ b/installer/PowerToysSetup/PowerToysInstaller.wixproj @@ -51,7 +51,6 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil call move /Y ..\..\..\Settings.wxs.bk ..\..\..\Settings.wxs call move /Y ..\..\..\ShortcutGuide.wxs.bk ..\..\..\ShortcutGuide.wxs call move /Y ..\..\..\Tools.wxs.bk ..\..\..\Tools.wxs - call move /Y ..\..\..\VideoConference.wxs.bk ..\..\..\VideoConference.wxs call move /Y ..\..\..\WinAppSDK.wxs.bk ..\..\..\WinAppSDK.wxs call move /Y ..\..\..\WinUI3Applications.wxs.bk ..\..\..\WinUI3Applications.wxs call move /Y ..\..\..\Workspaces.wxs.bk ..\..\..\Workspaces.wxs @@ -119,7 +118,6 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil - diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index 7a3a6ee697..33dc8d0e55 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -69,7 +69,6 @@ - @@ -196,6 +195,9 @@ NOT Installed + + NOT Installed + + + - - - - - - @@ -34,7 +28,6 @@ - diff --git a/installer/PowerToysSetup/VideoConference.wxs b/installer/PowerToysSetup/VideoConference.wxs deleted file mode 100644 index 04bdb1e506..0000000000 --- a/installer/PowerToysSetup/VideoConference.wxs +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - WINDOWSBUILDNUMBER >= 19041 - - - - - - - - - - - - - WINDOWSBUILDNUMBER >= 19041 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/installer/PowerToysSetupCustomActions/CustomAction.cpp b/installer/PowerToysSetupCustomActions/CustomAction.cpp index 8995d2f9b6..d757221acd 100644 --- a/installer/PowerToysSetupCustomActions/CustomAction.cpp +++ b/installer/PowerToysSetupCustomActions/CustomAction.cpp @@ -11,6 +11,7 @@ #include "../../src/common/updating/installer.h" #include "../../src/common/version/version.h" #include "../../src/common/Telemetry/EtwTrace/EtwTrace.h" +#include "../../src/common/utils/clean_video_conference.h" #include #include @@ -328,6 +329,19 @@ LExit: return WcaFinalize(er); } +// We've deprecated Video Conference Mute. This Custom Action cleans up any stray registry entry for the driver dll. +UINT __stdcall CleanVideoConferenceRegistryCA(MSIHANDLE hInstall) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + hr = WcaInitialize(hInstall, "CleanVideoConferenceRegistry"); + ExitOnFailure(hr, "Failed to initialize"); + clean_video_conference(); +LExit: + er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; + return WcaFinalize(er); +} + UINT __stdcall ApplyModulesRegistryChangeSetsCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; @@ -1026,164 +1040,6 @@ UINT __stdcall DetectPrevInstallPathCA(MSIHANDLE hInstall) return WcaFinalize(er); } -UINT __stdcall CertifyVirtualCameraDriverCA(MSIHANDLE hInstall) -{ -#ifdef CIBuild // On pipeline we are using microsoft certification - WcaInitialize(hInstall, "CertifyVirtualCameraDriverCA"); - return WcaFinalize(ERROR_SUCCESS); -#else - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - LPWSTR certificatePath = nullptr; - HCERTSTORE hCertStore = nullptr; - HANDLE hfile = nullptr; - DWORD size = INVALID_FILE_SIZE; - char* pFileContent = nullptr; - - hr = WcaInitialize(hInstall, "CertifyVirtualCameraDriverCA"); - ExitOnFailure(hr, "Failed to initialize", hr); - - hr = WcaGetProperty(L"CustomActionData", &certificatePath); - ExitOnFailure(hr, "Failed to get install property", hr); - - hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE, L"AuthRoot"); - if (!hCertStore) - { - hr = GetLastError(); - ExitOnFailure(hr, "Cannot put principal run level: %x", hr); - } - - hfile = CreateFile(certificatePath, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); - if (hfile == INVALID_HANDLE_VALUE) - { - hr = GetLastError(); - ExitOnFailure(hr, "Certificate file open failed", hr); - } - - size = GetFileSize(hfile, nullptr); - if (size == INVALID_FILE_SIZE) - { - hr = GetLastError(); - ExitOnFailure(hr, "Certificate file size not valid", hr); - } - - pFileContent = static_cast(malloc(size)); - - DWORD sizeread; - if (!ReadFile(hfile, pFileContent, size, &sizeread, nullptr)) - { - hr = GetLastError(); - ExitOnFailure(hr, "Certificate file read failed", hr); - } - - if (!CertAddEncodedCertificateToStore(hCertStore, - X509_ASN_ENCODING, - reinterpret_cast(pFileContent), - size, - CERT_STORE_ADD_ALWAYS, - nullptr)) - { - hr = GetLastError(); - ExitOnFailure(hr, "Adding certificate failed", hr); - } - - free(pFileContent); - -LExit: - ReleaseStr(certificatePath); - if (hCertStore) - { - CertCloseStore(hCertStore, 0); - } - if (hfile) - { - CloseHandle(hfile); - } - - if (!SUCCEEDED(hr)) - { - PMSIHANDLE hRecord = MsiCreateRecord(0); - MsiRecordSetString(hRecord, 0, TEXT("Failed to add certificate to store")); - MsiProcessMessage(hInstall, static_cast(INSTALLMESSAGE_WARNING + MB_OK), hRecord); - } - - er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; - return WcaFinalize(er); -#endif -} - -UINT __stdcall InstallVirtualCameraDriverCA(MSIHANDLE hInstall) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - LPWSTR driverPath = nullptr; - - hr = WcaInitialize(hInstall, "InstallVirtualCameraDriverCA"); - ExitOnFailure(hr, "Failed to initialize"); - - hr = WcaGetProperty(L"CustomActionData", &driverPath); - ExitOnFailure(hr, "Failed to get install property"); - - BOOL requiresReboot; - DiInstallDriverW(GetConsoleWindow(), driverPath, DIIRFLAG_FORCE_INF, &requiresReboot); - - hr = GetLastError(); - ExitOnFailure(hr, "Failed to install driver"); - -LExit: - - if (!SUCCEEDED(hr)) - { - PMSIHANDLE hRecord = MsiCreateRecord(0); - MsiRecordSetString(hRecord, 0, TEXT("Failed to install virtual camera driver")); - MsiProcessMessage(hInstall, static_cast(INSTALLMESSAGE_WARNING + MB_OK), hRecord); - } - - er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; - return WcaFinalize(er); -} - -UINT __stdcall UninstallVirtualCameraDriverCA(MSIHANDLE hInstall) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - LPWSTR driverPath = nullptr; - - hr = WcaInitialize(hInstall, "UninstallVirtualCameraDriverCA"); - ExitOnFailure(hr, "Failed to initialize"); - - hr = WcaGetProperty(L"CustomActionData", &driverPath); - ExitOnFailure(hr, "Failed to get uninstall property"); - - BOOL requiresReboot; - DiUninstallDriverW(GetConsoleWindow(), driverPath, 0, &requiresReboot); - - switch (GetLastError()) - { - case ERROR_ACCESS_DENIED: - case ERROR_FILE_NOT_FOUND: - case ERROR_INVALID_FLAGS: - case ERROR_IN_WOW64: - { - hr = GetLastError(); - ExitOnFailure(hr, "Failed to uninstall driver"); - break; - } - } - -LExit: - - if (!SUCCEEDED(hr)) - { - PMSIHANDLE hRecord = MsiCreateRecord(0); - MsiRecordSetString(hRecord, 0, TEXT("Failed to uninstall virtual camera driver")); - MsiProcessMessage(hInstall, static_cast(INSTALLMESSAGE_WARNING + MB_OK), hRecord); - } - - er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; - return WcaFinalize(er); -} - UINT __stdcall UnRegisterContextMenuPackagesCA(MSIHANDLE hInstall) { using namespace winrt::Windows::Foundation; diff --git a/installer/PowerToysSetupCustomActions/CustomAction.def b/installer/PowerToysSetupCustomActions/CustomAction.def index f685a0be1d..d9ed0d0f04 100644 --- a/installer/PowerToysSetupCustomActions/CustomAction.def +++ b/installer/PowerToysSetupCustomActions/CustomAction.def @@ -3,6 +3,7 @@ LIBRARY "PowerToysSetupCustomActions" EXPORTS LaunchPowerToysCA CheckGPOCA + CleanVideoConferenceRegistryCA ApplyModulesRegistryChangeSetsCA DetectPrevInstallPathCA RemoveScheduledTasksCA @@ -15,12 +16,9 @@ EXPORTS TelemetryLogRepairCancelCA TelemetryLogRepairFailCA TerminateProcessesCA - CertifyVirtualCameraDriverCA - InstallVirtualCameraDriverCA InstallEmbeddedMSIXCA InstallDSCModuleCA UnApplyModulesRegistryChangeSetsCA - UninstallVirtualCameraDriverCA UnRegisterContextMenuPackagesCA UninstallEmbeddedMSIXCA UninstallDSCModuleCA diff --git a/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj b/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj index dee9f63e2b..e2de4a4065 100644 --- a/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj +++ b/installer/PowerToysSetupCustomActions/PowerToysSetupCustomActions.vcxproj @@ -73,7 +73,6 @@ call cmd /C "copy ""$(ProjectDir)..\PowerToysSetup\Settings.wxs"" ""$(ProjectDir)..\PowerToysSetup\Settings.wxs.bk"""" call cmd /C "copy ""$(ProjectDir)..\PowerToysSetup\ShortcutGuide.wxs"" ""$(ProjectDir)..\PowerToysSetup\ShortcutGuide.wxs.bk"""" call cmd /C "copy ""$(ProjectDir)..\PowerToysSetup\Tools.wxs"" ""$(ProjectDir)..\PowerToysSetup\Tools.wxs.bk"""" - call cmd /C "copy ""$(ProjectDir)..\PowerToysSetup\VideoConference.wxs"" ""$(ProjectDir)..\PowerToysSetup\VideoConference.wxs.bk"""" call cmd /C "copy ""$(ProjectDir)..\PowerToysSetup\WinAppSDK.wxs"" ""$(ProjectDir)..\PowerToysSetup\WinAppSDK.wxs.bk"""" call cmd /C "copy ""$(ProjectDir)..\PowerToysSetup\WinUI3Applications.wxs"" ""$(ProjectDir)..\PowerToysSetup\WinUI3Applications.wxs.bk"""" call cmd /C "copy ""$(ProjectDir)..\PowerToysSetup\Workspaces.wxs"" ""$(ProjectDir)..\PowerToysSetup\Workspaces.wxs.bk"""" diff --git a/src/common/Common.UI/SettingsDeepLink.cs b/src/common/Common.UI/SettingsDeepLink.cs index 41bd2c012e..9a9d4c1070 100644 --- a/src/common/Common.UI/SettingsDeepLink.cs +++ b/src/common/Common.UI/SettingsDeepLink.cs @@ -22,7 +22,6 @@ namespace Common.UI PowerRename, FileExplorer, ShortcutGuide, - VideoConference, Hosts, MeasureTool, PowerOCR, @@ -60,8 +59,6 @@ namespace Common.UI return "FileExplorer"; case SettingsWindow.ShortcutGuide: return "ShortcutGuide"; - case SettingsWindow.VideoConference: - return "VideoConference"; case SettingsWindow.Hosts: return "Hosts"; case SettingsWindow.MeasureTool: diff --git a/src/common/GPOWrapper/GPOWrapper.cpp b/src/common/GPOWrapper/GPOWrapper.cpp index a9ecb43818..ae051648ab 100644 --- a/src/common/GPOWrapper/GPOWrapper.cpp +++ b/src/common/GPOWrapper/GPOWrapper.cpp @@ -128,10 +128,6 @@ namespace winrt::PowerToys::GPOWrapper::implementation { return static_cast(powertoys_gpo::getConfiguredAdvancedPasteEnabledValue()); } - GpoRuleConfigured GPOWrapper::GetConfiguredVideoConferenceMuteEnabledValue() - { - return static_cast(powertoys_gpo::getConfiguredVideoConferenceMuteEnabledValue()); - } GpoRuleConfigured GPOWrapper::GetConfiguredMouseWithoutBordersEnabledValue() { return static_cast(powertoys_gpo::getConfiguredMouseWithoutBordersEnabledValue()); diff --git a/src/common/GPOWrapper/GPOWrapper.h b/src/common/GPOWrapper/GPOWrapper.h index 34c1e3646b..0b9a15942d 100644 --- a/src/common/GPOWrapper/GPOWrapper.h +++ b/src/common/GPOWrapper/GPOWrapper.h @@ -39,7 +39,6 @@ namespace winrt::PowerToys::GPOWrapper::implementation static GpoRuleConfigured GetConfiguredShortcutGuideEnabledValue(); static GpoRuleConfigured GetConfiguredTextExtractorEnabledValue(); static GpoRuleConfigured GetConfiguredAdvancedPasteEnabledValue(); - static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue(); static GpoRuleConfigured GetConfiguredPeekEnabledValue(); static GpoRuleConfigured GetDisableNewUpdateToastValue(); static GpoRuleConfigured GetDisableAutomaticUpdateDownloadValue(); diff --git a/src/common/GPOWrapper/GPOWrapper.idl b/src/common/GPOWrapper/GPOWrapper.idl index af58834a0c..c404741e5d 100644 --- a/src/common/GPOWrapper/GPOWrapper.idl +++ b/src/common/GPOWrapper/GPOWrapper.idl @@ -43,7 +43,6 @@ namespace PowerToys static GpoRuleConfigured GetConfiguredShortcutGuideEnabledValue(); static GpoRuleConfigured GetConfiguredTextExtractorEnabledValue(); static GpoRuleConfigured GetConfiguredAdvancedPasteEnabledValue(); - static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue(); static GpoRuleConfigured GetConfiguredPeekEnabledValue(); static GpoRuleConfigured GetDisableNewUpdateToastValue(); static GpoRuleConfigured GetDisableAutomaticUpdateDownloadValue(); diff --git a/src/common/interop/CommonManaged.cpp b/src/common/interop/CommonManaged.cpp index 39ae2967b4..d59741fef6 100644 --- a/src/common/interop/CommonManaged.cpp +++ b/src/common/interop/CommonManaged.cpp @@ -2,8 +2,6 @@ #include "CommonManaged.h" #include "CommonManaged.g.cpp" #include -#include "../../modules/videoconference/VideoConferenceShared/MicrophoneDevice.h" -#include "../../modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.h" namespace winrt::PowerToys::Interop::implementation { @@ -11,29 +9,4 @@ namespace winrt::PowerToys::Interop::implementation { return hstring{ get_product_version() }; } - winrt::Windows::Foundation::Collections::IVector CommonManaged::GetAllActiveMicrophoneDeviceNames() - { - auto names = std::vector(); - for (const auto& device : MicrophoneDevice::getAllActive()) - { - names.push_back(device->name().data()); - } - return winrt::multi_threaded_vector(std::move(names)); - } - winrt::Windows::Foundation::Collections::IVector CommonManaged::GetAllVideoCaptureDeviceNames() - { - auto names = std::vector(); - VideoCaptureDeviceList vcdl; - vcdl.EnumerateDevices(); - - for (UINT32 i = 0; i < vcdl.Count(); ++i) - { - auto name = vcdl.GetDeviceName(i).data(); - if (name != L"PowerToys VideoConference Mute") - { - names.push_back(name); - } - } - return winrt::multi_threaded_vector(std::move(names)); - } } diff --git a/src/common/interop/CommonManaged.h b/src/common/interop/CommonManaged.h index 96d6f5d8a5..7196699ae9 100644 --- a/src/common/interop/CommonManaged.h +++ b/src/common/interop/CommonManaged.h @@ -8,8 +8,6 @@ namespace winrt::PowerToys::Interop::implementation CommonManaged() = default; static hstring GetProductVersion(); - static winrt::Windows::Foundation::Collections::IVector GetAllActiveMicrophoneDeviceNames(); - static winrt::Windows::Foundation::Collections::IVector GetAllVideoCaptureDeviceNames(); }; } namespace winrt::PowerToys::Interop::factory_implementation diff --git a/src/common/interop/CommonManaged.idl b/src/common/interop/CommonManaged.idl index 0a523e790a..38e9225bb5 100644 --- a/src/common/interop/CommonManaged.idl +++ b/src/common/interop/CommonManaged.idl @@ -4,8 +4,6 @@ namespace PowerToys { [default_interface] static runtimeclass CommonManaged { static String GetProductVersion(); - static Windows.Foundation.Collections.IVector GetAllActiveMicrophoneDeviceNames(); - static Windows.Foundation.Collections.IVector GetAllVideoCaptureDeviceNames(); } } } \ No newline at end of file diff --git a/src/common/interop/PowerToys.Interop.vcxproj b/src/common/interop/PowerToys.Interop.vcxproj index 88115f9eab..aadd8b2ebb 100644 --- a/src/common/interop/PowerToys.Interop.vcxproj +++ b/src/common/interop/PowerToys.Interop.vcxproj @@ -93,8 +93,6 @@ - - CommonManaged.idl @@ -123,8 +121,6 @@ - - CommonManaged.idl diff --git a/src/common/interop/PowerToys.Interop.vcxproj.filters b/src/common/interop/PowerToys.Interop.vcxproj.filters index 5df4afc368..6fa51a3275 100644 --- a/src/common/interop/PowerToys.Interop.vcxproj.filters +++ b/src/common/interop/PowerToys.Interop.vcxproj.filters @@ -21,12 +21,6 @@ Header Files - - Header Files - - - Header Files - Header Files @@ -65,12 +59,6 @@ Source Files - - Source Files - - - Source Files - Source Files diff --git a/src/common/utils/clean_video_conference.h b/src/common/utils/clean_video_conference.h new file mode 100644 index 0000000000..f90a3ad1ee --- /dev/null +++ b/src/common/utils/clean_video_conference.h @@ -0,0 +1,18 @@ +#pragma once + +// Video Conference Mute was a utility we deprecated. However, this required a manual user disable of the module to remove the camera registration, so we include the disable code here to be able to clean up. +void clean_video_conference() +{ + // 31AD75E9-8C3A-49C8-B9ED-5880D6B4A764 is the CLSID GUID for the 64 video conference mute driver. + // 31AD75E9-8C3A-49C8-B9ED-5880D6B4A732 is the CLSID GUID for the 32 video conference mute driver. + // 860BB310-5D01-11D0-BD3B-00A0C911CE86 is the CLSID GUID for CLSID_VideoInputDeviceCategory. + + // Unregister the 64 bit driver CLSID: + RegDeleteTreeW(HKEY_CLASSES_ROOT, L"CLSID\\{31AD75E9-8C3A-49C8-B9ED-5880D6B4A764}"); + // Unregister the 64 bit driver CLSID from Video Input Devices: + RegDeleteTreeW(HKEY_CLASSES_ROOT, L"CLSID\\{860BB310-5D01-11D0-BD3B-00A0C911CE86}\\Instance\\{31AD75E9-8C3A-49C8-B9ED-5880D6B4A764}"); + // Unregister the 32 bit driver CLSID: + RegDeleteTreeW(HKEY_LOCAL_MACHINE, L"Software\\WOW6432Node\\Classes\\CLSID\\{31AD75E9-8C3A-49C8-B9ED-5880D6B4A732}"); + // Unregister the 32 bit driver CLSID from Video Input Devices: + RegDeleteTreeW(HKEY_LOCAL_MACHINE, L"Software\\WOW6432Node\\Classes\\CLSID\\{860BB310-5D01-11D0-BD3B-00A0C911CE86}\\Instance\\{31AD75E9-8C3A-49C8-B9ED-5880D6B4A732}"); +} diff --git a/src/common/utils/gpo.h b/src/common/utils/gpo.h index 04e03b4767..2e3c681c91 100644 --- a/src/common/utils/gpo.h +++ b/src/common/utils/gpo.h @@ -53,7 +53,6 @@ namespace powertoys_gpo { const std::wstring POLICY_CONFIGURE_ENABLED_SHORTCUT_GUIDE = L"ConfigureEnabledUtilityShortcutGuide"; const std::wstring POLICY_CONFIGURE_ENABLED_TEXT_EXTRACTOR = L"ConfigureEnabledUtilityTextExtractor"; const std::wstring POLICY_CONFIGURE_ENABLED_ADVANCED_PASTE = L"ConfigureEnabledUtilityAdvancedPaste"; - const std::wstring POLICY_CONFIGURE_ENABLED_VIDEO_CONFERENCE_MUTE = L"ConfigureEnabledUtilityVideoConferenceMute"; const std::wstring POLICY_CONFIGURE_ENABLED_REGISTRY_PREVIEW = L"ConfigureEnabledUtilityRegistryPreview"; const std::wstring POLICY_CONFIGURE_ENABLED_MOUSE_WITHOUT_BORDERS = L"ConfigureEnabledUtilityMouseWithoutBorders"; const std::wstring POLICY_CONFIGURE_ENABLED_PEEK = L"ConfigureEnabledUtilityPeek"; @@ -414,11 +413,6 @@ namespace powertoys_gpo { return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_WORKSPACES); } - inline gpo_rule_configured_t getConfiguredVideoConferenceMuteEnabledValue() - { - return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_VIDEO_CONFERENCE_MUTE); - } - inline gpo_rule_configured_t getConfiguredMouseWithoutBordersEnabledValue() { return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_MOUSE_WITHOUT_BORDERS); diff --git a/src/common/version/version.vcxproj b/src/common/version/version.vcxproj index f6ad515137..b045d8f5a5 100644 --- a/src/common/version/version.vcxproj +++ b/src/common/version/version.vcxproj @@ -10,7 +10,7 @@ - + Debug diff --git a/src/dsc/Microsoft.PowerToys.Configure/examples/disableAllModules.dsc.yaml b/src/dsc/Microsoft.PowerToys.Configure/examples/disableAllModules.dsc.yaml index 5324df75ea..92986e8107 100644 --- a/src/dsc/Microsoft.PowerToys.Configure/examples/disableAllModules.dsc.yaml +++ b/src/dsc/Microsoft.PowerToys.Configure/examples/disableAllModules.dsc.yaml @@ -63,8 +63,6 @@ properties: Enabled: false ShortcutGuide: Enabled: false - VideoConference: - Enabled: false MeasureTool: Enabled: false Hosts: diff --git a/src/dsc/Microsoft.PowerToys.Configure/examples/enableAllModules.dsc.yaml b/src/dsc/Microsoft.PowerToys.Configure/examples/enableAllModules.dsc.yaml index 5fa895ddfd..5ff4dcfe71 100644 --- a/src/dsc/Microsoft.PowerToys.Configure/examples/enableAllModules.dsc.yaml +++ b/src/dsc/Microsoft.PowerToys.Configure/examples/enableAllModules.dsc.yaml @@ -63,8 +63,6 @@ properties: Enabled: true ShortcutGuide: Enabled: true - VideoConference: - Enabled: true MeasureTool: Enabled: true Hosts: diff --git a/src/gpo/assets/PowerToys.admx b/src/gpo/assets/PowerToys.admx index 799b1f20f3..c17e6712bf 100644 --- a/src/gpo/assets/PowerToys.admx +++ b/src/gpo/assets/PowerToys.admx @@ -1,11 +1,11 @@ - + - + @@ -23,6 +23,7 @@ + @@ -45,6 +46,9 @@ + + + @@ -441,8 +445,8 @@ - - + + diff --git a/src/gpo/assets/en-US/PowerToys.adml b/src/gpo/assets/en-US/PowerToys.adml index 7a8f037eee..adcc902811 100644 --- a/src/gpo/assets/en-US/PowerToys.adml +++ b/src/gpo/assets/en-US/PowerToys.adml @@ -1,7 +1,7 @@ - + PowerToys PowerToys @@ -13,6 +13,7 @@ Mouse Without Borders General settings New+ + Deprecated policies PowerToys version 0.64.0 or later PowerToys version 0.68.0 or later @@ -29,6 +30,7 @@ PowerToys version 0.84.0 or later PowerToys version 0.85.0 or later PowerToys version 0.86.0 or later + From PowerToys version 0.64.0 until PowerToys version 0.87.1 This policy configures the enabled state for all PowerToys utilities. diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Dark.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Dark.png deleted file mode 100644 index 08446a2078..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Dark.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Dark.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Dark.svg deleted file mode 100644 index 4860bbfd3a..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Dark.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera not in use - - - Microphone off - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Light.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Light.png deleted file mode 100644 index 285ea495b8..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Light.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Light.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Light.svg deleted file mode 100644 index a30e909ff1..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-NotInUse Light.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera not in use - - - Microphone off - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Dark.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Dark.png deleted file mode 100644 index 32d7559e73..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Dark.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Dark.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Dark.svg deleted file mode 100644 index c147f2278e..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Dark.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera off - - - Microphone off - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Light.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Light.png deleted file mode 100644 index 7f0477ff89..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Light.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Light.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Light.svg deleted file mode 100644 index 25eecdd72f..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-Off Light.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera off - - - Microphone off - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Dark.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Dark.png deleted file mode 100644 index ac33d985c8..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Dark.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Dark.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Dark.svg deleted file mode 100644 index ea31e3d78d..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Dark.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera on - - Microphone off - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Light.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Light.png deleted file mode 100644 index a43b3cf364..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Light.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Light.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Light.svg deleted file mode 100644 index e3c0352bcc..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/Off-On Light.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera on - - Microphone off - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Dark.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Dark.png deleted file mode 100644 index ff34ff3eb5..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Dark.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Dark.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Dark.svg deleted file mode 100644 index 268decd93b..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Dark.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera not in use - - Microphone on - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Light.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Light.png deleted file mode 100644 index b4e5edaea5..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Light.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Light.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Light.svg deleted file mode 100644 index d9d340c034..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-NotInUse Light.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera not in use - - Microphone on - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Dark.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Dark.png deleted file mode 100644 index 8492439759..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Dark.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Dark.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Dark.svg deleted file mode 100644 index 67080eabdd..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Dark.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera off - - Microphone on - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Light.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Light.png deleted file mode 100644 index b011e944bb..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Light.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Light.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Light.svg deleted file mode 100644 index f5661655bc..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-Off Light.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera off - - Microphone on - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Dark.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Dark.png deleted file mode 100644 index 6f1955d2d2..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Dark.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Dark.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Dark.svg deleted file mode 100644 index e539e785a6..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Dark.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera on - - Microphone on - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Light.png b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Light.png deleted file mode 100644 index b9fb04c6a6..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Light.png and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Light.svg b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Light.svg deleted file mode 100644 index ff4a5c2e31..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/On-On Light.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - Camera on - - Microphone on - - - diff --git a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/black.bmp b/src/modules/videoconference/VideoConferenceModule/Assets/VCM/black.bmp deleted file mode 100644 index 18d40779ce..0000000000 Binary files a/src/modules/videoconference/VideoConferenceModule/Assets/VCM/black.bmp and /dev/null differ diff --git a/src/modules/videoconference/VideoConferenceModule/AudioDeviceNotificationClient.cpp b/src/modules/videoconference/VideoConferenceModule/AudioDeviceNotificationClient.cpp deleted file mode 100644 index 1252907184..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/AudioDeviceNotificationClient.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "pch.h" - -#include "AudioDeviceNotificationClient.h" - -AudioDeviceNotificationClient::AudioDeviceNotificationClient() -{ - (void)CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&_deviceEnumerator)); - if (!_deviceEnumerator) - { - return; - } - - if (FAILED(_deviceEnumerator->RegisterEndpointNotificationCallback(this))) - { - _deviceEnumerator->Release(); - _deviceEnumerator = nullptr; - } -} - -AudioDeviceNotificationClient::~AudioDeviceNotificationClient() -{ - if (!_deviceEnumerator) - { - return; - } - - _deviceEnumerator->UnregisterEndpointNotificationCallback(this); - _deviceEnumerator->Release(); -} - -ULONG AudioDeviceNotificationClient::AddRef() -{ - return 1; -} - -ULONG AudioDeviceNotificationClient::Release() -{ - return 1; -} - -HRESULT AudioDeviceNotificationClient::QueryInterface(REFIID, void**) -{ - return S_OK; -} - -HRESULT AudioDeviceNotificationClient::OnPropertyValueChanged(LPCWSTR, const PROPERTYKEY) -{ - _deviceConfigurationChanged = true; - return S_OK; -} - -HRESULT AudioDeviceNotificationClient::OnDeviceAdded(LPCWSTR) -{ - _deviceConfigurationChanged = true; - return S_OK; -} - -HRESULT AudioDeviceNotificationClient::OnDeviceRemoved(LPCWSTR) -{ - _deviceConfigurationChanged = true; - return S_OK; -} - -HRESULT AudioDeviceNotificationClient::OnDeviceStateChanged(LPCWSTR, DWORD) -{ - _deviceConfigurationChanged = true; - return S_OK; -} - -HRESULT AudioDeviceNotificationClient::OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR) -{ - if (role == eConsole && (flow == eCapture || flow == eAll)) - { - _deviceConfigurationChanged = true; - } - - return S_OK; -} diff --git a/src/modules/videoconference/VideoConferenceModule/AudioDeviceNotificationClient.h b/src/modules/videoconference/VideoConferenceModule/AudioDeviceNotificationClient.h deleted file mode 100644 index 3fe3f5fd1d..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/AudioDeviceNotificationClient.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -struct AudioDeviceNotificationClient : IMMNotificationClient -{ - AudioDeviceNotificationClient(); - ~AudioDeviceNotificationClient(); - - bool PullPendingNotifications() - { - const bool result = _deviceConfigurationChanged; - _deviceConfigurationChanged = false; - return result; - } - -private: - ULONG AddRef() override; - ULONG Release() override; - HRESULT QueryInterface(REFIID, void**) override; - HRESULT OnPropertyValueChanged(LPCWSTR, const PROPERTYKEY) override; - HRESULT OnDeviceAdded(LPCWSTR) override; - HRESULT OnDeviceRemoved(LPCWSTR) override; - HRESULT OnDeviceStateChanged(LPCWSTR, DWORD) override; - HRESULT OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR) override; - - IMMDeviceEnumerator* _deviceEnumerator = nullptr; - - bool _deviceConfigurationChanged = false; -}; diff --git a/src/modules/videoconference/VideoConferenceModule/README.md b/src/modules/videoconference/VideoConferenceModule/README.md deleted file mode 100644 index d53920685a..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Video Conference Mute - -# Introduction -The Video Conference Mute module allows muting microphone and/or web camera video stream during video calls or other activity. - -# Usage -If you'd like to mute your web camera, please select "PowerToys VideoConference Mute" device in your web camera-using app, then restart it. - -During a video call, you can use default shortcuts to mute microphone, web camera or both. You'll see a toolbar indicating corresponding mute statuses. - -# Options -You can tweak the toolbar position on the screen as well as set web camera overlay image during muting. - -# Backlog diff --git a/src/modules/videoconference/VideoConferenceModule/Toolbar.cpp b/src/modules/videoconference/VideoConferenceModule/Toolbar.cpp deleted file mode 100644 index 0dabd58d9c..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Toolbar.cpp +++ /dev/null @@ -1,390 +0,0 @@ -#include "pch.h" -#include "Toolbar.h" - -#include - -#include -#include - -#include "Logging.h" -#include "VideoConferenceModule.h" - -Toolbar* toolbar = nullptr; - -const int REFRESH_RATE = 100; -const int OVERLAY_SHOW_TIME = 500; -const int BORDER_OFFSET = 12; -const int TOP_RIGHT_BORDER_OFFSET = 40; -std::wstring cached_position = L""; - -Toolbar::Toolbar() -{ - toolbar = this; - darkImages.camOnMicOn = Gdiplus::Image::FromFile(L"Assets/VCM/On-On Dark.png"); - darkImages.camOffMicOn = Gdiplus::Image::FromFile(L"Assets/VCM/On-Off Dark.png"); - darkImages.camOnMicOff = Gdiplus::Image::FromFile(L"Assets/VCM/Off-On Dark.png"); - darkImages.camOffMicOff = Gdiplus::Image::FromFile(L"Assets/VCM/Off-Off Dark.png"); - darkImages.camUnusedMicOn = Gdiplus::Image::FromFile(L"Assets/VCM/On-NotInUse Dark.png"); - darkImages.camUnusedMicOff = Gdiplus::Image::FromFile(L"Assets/VCM/Off-NotInUse Dark.png"); - - lightImages.camOnMicOn = Gdiplus::Image::FromFile(L"Assets/VCM/On-On Light.png"); - lightImages.camOffMicOn = Gdiplus::Image::FromFile(L"Assets/VCM/On-Off Light.png"); - lightImages.camOnMicOff = Gdiplus::Image::FromFile(L"Assets/VCM/Off-On Light.png"); - lightImages.camOffMicOff = Gdiplus::Image::FromFile(L"Assets/VCM/Off-Off Light.png"); - lightImages.camUnusedMicOn = Gdiplus::Image::FromFile(L"Assets/VCM/On-NotInUse Light.png"); - lightImages.camUnusedMicOff = Gdiplus::Image::FromFile(L"Assets/VCM/Off-NotInUse Light.png"); -} - -void Toolbar::scheduleModuleSettingsUpdate() -{ - moduleSettingsUpdateScheduled = true; -} - -void Toolbar::scheduleGeneralSettingsUpdate() -{ - generalSettingsUpdateScheduled = true; -} - -inline POINT calculateToolbarPositioning(Box const& screenSize, std::wstring& position, const int desiredWidth, const int desiredHeight) -{ - POINT p; - p.x = p.y = 0; - - if (position == L"Top left corner") - { - p.x = screenSize.left() + BORDER_OFFSET; - p.y = screenSize.top() + BORDER_OFFSET; - } - else if (position == L"Top center") - { - p.x = screenSize.middle().x - desiredWidth / 2; - p.y = screenSize.top() + BORDER_OFFSET; - } - else if (position == L"Bottom left corner") - { - p.x = screenSize.left() + BORDER_OFFSET; - p.y = screenSize.bottom() - desiredHeight - BORDER_OFFSET; - } - else if (position == L"Bottom center") - { - p.x = screenSize.middle().x - desiredWidth / 2; - p.y = screenSize.bottom() - desiredHeight - BORDER_OFFSET; - } - else if (position == L"Bottom right corner") - { - p.x = screenSize.right() - desiredWidth - BORDER_OFFSET; - p.y = screenSize.bottom() - desiredHeight - BORDER_OFFSET; - } - else //"Top right corner" or non-present - { - p.x = screenSize.right() - desiredWidth - BORDER_OFFSET; - p.y = screenSize.top() + TOP_RIGHT_BORDER_OFFSET; - } - return p; -} - -LRESULT Toolbar::WindowProcessMessages(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -{ - switch (msg) - { - case WM_DESTROY: - return 0; - case WM_LBUTTONDOWN: - { - int x = GET_X_LPARAM(lparam); - int y = GET_Y_LPARAM(lparam); - UINT dpi = DPIAware::DEFAULT_DPI; - DPIAware::GetScreenDPIForWindow(hwnd, dpi); - - if (x < 322 * static_cast(dpi) / static_cast(DPIAware::DEFAULT_DPI) / 2) - { - VideoConferenceModule::reverseMicrophoneMute(); - } - else - { - VideoConferenceModule::reverseVirtualCameraMuteState(); - } - - return DefWindowProcW(hwnd, msg, wparam, lparam); - } - case WM_DPICHANGED: - { - UINT dpi = LOWORD(wparam); - RECT* prcNewWindow = reinterpret_cast(lparam); - - POINT suggestedPosition; - suggestedPosition.x = prcNewWindow->left; - suggestedPosition.y = prcNewWindow->top; - - int desiredWidth = prcNewWindow->right - prcNewWindow->left; - int desiredHeight = prcNewWindow->bottom - prcNewWindow->top; - - HMONITOR hMonitor = MonitorFromPoint(suggestedPosition, MONITOR_DEFAULTTONEAREST); - - MonitorInfo info{ hMonitor }; - - suggestedPosition = calculateToolbarPositioning(info.GetScreenSize(false), cached_position, desiredWidth, desiredHeight); - - SetWindowPos(hwnd, - NULL, - suggestedPosition.x, - suggestedPosition.y, - desiredWidth, - desiredHeight, - SWP_NOZORDER | SWP_NOACTIVATE); - return DefWindowProcW(hwnd, msg, wparam, lparam); - } - case WM_CREATE: - case WM_PAINT: - { - PAINTSTRUCT ps; - HDC hdc; - UINT dpi = DPIAware::DEFAULT_DPI; - - DPIAware::GetScreenDPIForWindow(hwnd, dpi); - - hdc = BeginPaint(hwnd, &ps); - - Gdiplus::Graphics graphic(hdc); - - ToolbarImages* themeImages = &toolbar->darkImages; - - if (toolbar->theme == L"light" || (toolbar->theme == L"system" && !WindowsColors::is_dark_mode())) - { - themeImages = &toolbar->lightImages; - } - else - { - themeImages = &toolbar->darkImages; - } - Gdiplus::Image* toolbarImage = nullptr; - if (!toolbar->cameraInUse) - { - if (toolbar->microphoneMuted) - { - toolbarImage = themeImages->camUnusedMicOff; - } - else - { - toolbarImage = themeImages->camUnusedMicOn; - } - } - else if (toolbar->microphoneMuted) - { - if (toolbar->cameraMuted) - { - toolbarImage = themeImages->camOffMicOff; - } - else - { - toolbarImage = themeImages->camOnMicOff; - } - } - else - { - if (toolbar->cameraMuted) - { - toolbarImage = themeImages->camOffMicOn; - } - else - { - toolbarImage = themeImages->camOnMicOn; - } - } - // Images are scaled by 4 to support higher dpi values. - graphic.DrawImage(toolbarImage, 0, 0, toolbarImage->GetWidth() / 4 * dpi / DPIAware::DEFAULT_DPI, toolbarImage->GetHeight() / 4 * dpi / DPIAware::DEFAULT_DPI); - - EndPaint(hwnd, &ps); - break; - } - case WM_TIMER: - { - if (toolbar->audioConfChangesNotifier.PullPendingNotifications()) - { - instance->onMicrophoneConfigurationChanged(); - } - toolbar->microphoneMuted = instance->getMicrophoneMuteState(); - - if (toolbar->generalSettingsUpdateScheduled) - { - instance->onGeneralSettingsChanged(); - toolbar->generalSettingsUpdateScheduled = false; - } - if (toolbar->moduleSettingsUpdateScheduled) - { - instance->onModuleSettingsChanged(); - toolbar->moduleSettingsUpdateScheduled = false; - } - - toolbar->cameraInUse = VideoConferenceModule::getVirtualCameraInUse(); - - InvalidateRect(hwnd, NULL, NULL); - - using namespace std::chrono; - const auto nowMillis = duration_cast(system_clock::now().time_since_epoch()).count(); - const bool showOverlayTimeout = nowMillis - toolbar->lastTimeCamOrMicMuteStateChanged > OVERLAY_SHOW_TIME; - - static bool previousShow = false; - bool show = toolbar->ToolbarHide == L"Never"; - - const bool cameraJustStoppedInUse = toolbar->previouscameraInUse && !toolbar->cameraInUse; - bool shouldUnmuteAll = cameraJustStoppedInUse; - - if (toolbar->ToolbarHide == L"When both camera and microphone are muted") - { - // We shouldn't unmute devices, since we'd like to only show the toolbar only - // when something is unmuted -> the use case is to keep everything muted by default and track it - shouldUnmuteAll = false; - show = (!toolbar->cameraMuted && toolbar->cameraInUse) || !toolbar->microphoneMuted; - } - else if (toolbar->ToolbarHide == L"When both camera and microphone are unmuted") - show = (toolbar->cameraMuted && toolbar->cameraInUse) || toolbar->microphoneMuted; - - if (shouldUnmuteAll && !toolbar->moduleSettingsUpdateScheduled) - VideoConferenceModule::unmuteAll(); - - show = show || !showOverlayTimeout; - ShowWindow(hwnd, show ? SW_SHOW : SW_HIDE); - - if (previousShow != show) - { - previousShow = show; - LOG(show ? "Toolbar visibility changed to shown" : "Toolbar visibility changed to hidden"); - } - - KillTimer(hwnd, toolbar->nTimerId); - toolbar->previouscameraInUse = toolbar->cameraInUse; - break; - } - default: - return DefWindowProcW(hwnd, msg, wparam, lparam); - } - - toolbar->nTimerId = SetTimer(hwnd, 101, REFRESH_RATE, nullptr); - - return DefWindowProcW(hwnd, msg, wparam, lparam); -} - -void Toolbar::show(std::wstring position, std::wstring monitorString) -{ - cached_position = position; - for (auto& hwnd : hwnds) - { - PostMessageW(hwnd, WM_CLOSE, 0, 0); - } - hwnds.clear(); - - // Images are scaled by 4 to support higher dpi values. - int overlayWidth = darkImages.camOffMicOff->GetWidth() / 4; - int overlayHeight = darkImages.camOffMicOff->GetHeight() / 4; - - // Register the window class - LPCWSTR CLASS_NAME = L"MuteNotificationWindowClass"; - WNDCLASS wc{}; - wc.hInstance = GetModuleHandleW(nullptr); - wc.lpszClassName = CLASS_NAME; - wc.hCursor = LoadCursor(nullptr, IDC_ARROW); - wc.hbrBackground = reinterpret_cast(COLOR_WINDOW); - wc.lpfnWndProc = WindowProcessMessages; - RegisterClassW(&wc); - - // Create the window - DWORD dwExtStyle = 0; - DWORD dwStyle = WS_POPUPWINDOW; - - std::vector monitorInfos; - - if (monitorString == L"All monitors") - { - monitorInfos = MonitorInfo::GetMonitors(false); - } - else //"Main monitor" or non-present - { - monitorInfos.push_back(MonitorInfo::GetPrimaryMonitor()); - } - - for (auto& monitorInfo : monitorInfos) - { - const auto screenSize = monitorInfo.GetScreenSize(false); - UINT dpi = DPIAware::DEFAULT_DPI; - DPIAware::GetScreenDPIForMonitor(monitorInfo.GetHandle(), dpi); - - int scaledOverlayWidth = overlayWidth * dpi / DPIAware::DEFAULT_DPI; - int scaledOverlayHeight = overlayHeight * dpi / DPIAware::DEFAULT_DPI; - - POINT p = calculateToolbarPositioning(screenSize, position, scaledOverlayWidth, scaledOverlayHeight); - - HWND hwnd; - hwnd = CreateWindowExW( - WS_EX_TOOLWINDOW | WS_EX_LAYERED, - CLASS_NAME, - CLASS_NAME, - WS_POPUP, - static_cast(p.x), - static_cast(p.y), - scaledOverlayWidth, - scaledOverlayHeight, - nullptr, - nullptr, - GetModuleHandleW(nullptr), - nullptr); - - auto transparentColorKey = RGB(0, 0, 255); - HBRUSH brush = CreateSolidBrush(transparentColorKey); - SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, reinterpret_cast(brush)); - - SetLayeredWindowAttributes(hwnd, transparentColorKey, 0, LWA_COLORKEY); - - SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - - hwnds.push_back(hwnd); - } -} - -void Toolbar::hide() -{ - for (auto& hwnd : hwnds) - { - PostMessage(hwnd, WM_CLOSE, 0, 0); - } - hwnds.clear(); -} - -bool Toolbar::getCameraMute() -{ - return cameraMuted; -} - -void Toolbar::setCameraMute(bool mute) -{ - if (mute != cameraMuted) - { - lastTimeCamOrMicMuteStateChanged = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - } - cameraMuted = mute; -} - -bool Toolbar::getMicrophoneMute() -{ - return microphoneMuted; -} - -void Toolbar::setMicrophoneMute(bool mute) -{ - if (mute != microphoneMuted) - { - lastTimeCamOrMicMuteStateChanged = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - } - - microphoneMuted = mute; -} - -void Toolbar::setToolbarHide(std::wstring hide) -{ - ToolbarHide = hide; -} - -void Toolbar::setTheme(std::wstring theme) -{ - Toolbar::theme = theme; -} diff --git a/src/modules/videoconference/VideoConferenceModule/Toolbar.h b/src/modules/videoconference/VideoConferenceModule/Toolbar.h deleted file mode 100644 index 04b1c28a23..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/Toolbar.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#include -#include -#include - -#include - -#include "AudioDeviceNotificationClient.h" - -struct ToolbarImages -{ - Gdiplus::Image* camOnMicOn = nullptr; - Gdiplus::Image* camOffMicOn = nullptr; - Gdiplus::Image* camOnMicOff = nullptr; - Gdiplus::Image* camOffMicOff = nullptr; - Gdiplus::Image* camUnusedMicOn = nullptr; - Gdiplus::Image* camUnusedMicOff = nullptr; -}; - -class Toolbar -{ -public: - Toolbar(); - - void scheduleModuleSettingsUpdate(); - void scheduleGeneralSettingsUpdate(); - - void show(std::wstring position, std::wstring monitorString); - void hide(); - - bool getCameraMute(); - void setCameraMute(bool mute); - bool getMicrophoneMute(); - void setMicrophoneMute(bool mute); - - void setTheme(std::wstring theme); - void setToolbarHide(std::wstring hide); - -private: - static LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); - - // Window callback can't be non-static so this members can't as well - std::vector hwnds; - - ToolbarImages darkImages; - ToolbarImages lightImages; - AudioDeviceNotificationClient audioConfChangesNotifier; - - bool cameraMuted = false; - bool cameraInUse = false; - bool previouscameraInUse = false; - bool microphoneMuted = false; - - std::wstring theme = L"system"; - - std::wstring ToolbarHide = L"When both camera and microphone are unmuted"; - - uint64_t lastTimeCamOrMicMuteStateChanged{}; - - std::atomic_bool moduleSettingsUpdateScheduled = false; - std::atomic_bool generalSettingsUpdateScheduled = false; - UINT_PTR nTimerId{}; -}; diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConference.filters b/src/modules/videoconference/VideoConferenceModule/VideoConference.filters deleted file mode 100644 index e19316f1bd..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/VideoConference.filters +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - {2c7c97f7-0d87-4230-a4b2-baf2cfc35d58} - - - {aa4b6713-589d-42ef-804d-3a045833f83f} - - - - - - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConference.vcxproj b/src/modules/videoconference/VideoConferenceModule/VideoConference.vcxproj deleted file mode 100644 index e043322021..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/VideoConference.vcxproj +++ /dev/null @@ -1,189 +0,0 @@ - - - - - 15.0 - {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB} - Win32Proj - overlaywindow - VideoConferenceModule - ..\..\..\..\$(Platform)\$(Configuration)\ - PowerToys.VideoConferenceModule - - - - DynamicLibrary - true - v143 - Unicode - Spectre - - - DynamicLibrary - false - v143 - true - Unicode - Spectre - - - - - - - - - - - false - - - true - - - - Level3 - MaxSpeed - true - true - true - NDEBUG;OVERLAYWINDOW_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - MultiThreaded - ..\..\..\;..\..\;..\VideoConferenceShared\;%(AdditionalIncludeDirectories) - stdcpplatest - - - Windows - true - true - true - $(OutDir)$(TargetName)$(TargetExt) - shlwapi.lib;gdiplus.lib;dwmapi.lib;uxtheme.lib;shcore.lib;Wtsapi32.lib;%(AdditionalDependencies) - - - - - Level3 - Disabled - true - _DEBUG;OVERLAYWINDOW_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - MultiThreadedDebug - ..\..\..\common\inc;..\..\..\common\Telemetry;..\..\..\;..\..\;..\VideoConferenceShared\;%(AdditionalIncludeDirectories) - stdcpplatest - - - Windows - true - $(OutDir)$(TargetName)$(TargetExt) - shlwapi.lib;gdiplus.lib;dwmapi.lib;uxtheme.lib;shcore.lib;Wtsapi32.lib;dxguid.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - Create - - - - - - {459e0768-7ebd-4c41-bba1-6db3b3815e0a} - - - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - true - PreserveNewest - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - {caba8dfb-823b-4bf2-93ac-3f31984150d9} - - - {6955446d-23f7-4023-9bb3-8657f904af99} - - - {98537082-0fdb-40de-abd8-0dc5a4269bab} - - - - - - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConference.vcxproj.filters b/src/modules/videoconference/VideoConferenceModule/VideoConference.vcxproj.filters deleted file mode 100644 index fea3b28290..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/VideoConference.vcxproj.filters +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - {efd98846-4568-41d4-a425-451c246802cd} - - - {e79f8c1a-b78b-4ba5-b923-f7db79eba776} - - - - - - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - Assets\VCM - - - - - - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp deleted file mode 100644 index aab538e883..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp +++ /dev/null @@ -1,733 +0,0 @@ -#include "pch.h" - -#include "VideoConferenceModule.h" - -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include "logging.h" -#include "trace.h" - -extern "C" IMAGE_DOS_HEADER __ImageBase; - -VideoConferenceModule* instance = nullptr; - -VideoConferenceSettings VideoConferenceModule::settings; -Toolbar VideoConferenceModule::toolbar; -bool VideoConferenceModule::pushToTalkPressed = false; - -HHOOK VideoConferenceModule::hook_handle; - -IAudioEndpointVolume* endpointVolume = NULL; - -bool VideoConferenceModule::isKeyPressed(unsigned int keyCode) -{ - return (GetKeyState(keyCode) & 0x8000); -} - -namespace fs = std::filesystem; - -bool VideoConferenceModule::isHotkeyPressed(DWORD code, PowerToysSettings::HotkeyObject& hotkey) -{ - return code == hotkey.get_code() && - isKeyPressed(VK_SHIFT) == hotkey.shift_pressed() && - isKeyPressed(VK_CONTROL) == hotkey.ctrl_pressed() && - isKeyPressed(VK_LWIN) == hotkey.win_pressed() && - (isKeyPressed(VK_LMENU)) == hotkey.alt_pressed(); -} - -void VideoConferenceModule::reverseMicrophoneMute() -{ - // All controlled mic should same state with _microphoneTrackedInUI - // Avoid manually change in Control Panel make controlled mic has different state - bool muted = !getMicrophoneMuteState(); - for (auto& controlledMic : instance->_controlledMicrophones) - { - controlledMic->set_muted(muted); - } - if (muted) - { - Trace::MicrophoneMuted(); - } - instance->_mic_muted_state_during_disconnect = !instance->_mic_muted_state_during_disconnect; - - toolbar.setMicrophoneMute(muted); -} - -bool VideoConferenceModule::getMicrophoneMuteState() -{ - return instance->_microphoneTrackedInUI ? instance->_microphoneTrackedInUI->muted() : instance->_mic_muted_state_during_disconnect; -} - -void VideoConferenceModule::reverseVirtualCameraMuteState() -{ - bool muted = false; - if (!instance->_settingsUpdateChannel.has_value()) - { - return; - } - - instance->_settingsUpdateChannel->access([&muted](auto settingsMemory) { - auto settings = reinterpret_cast(settingsMemory._data); - settings->useOverlayImage = !settings->useOverlayImage; - muted = settings->useOverlayImage; - }); - - if (muted) - { - Trace::CameraMuted(); - } - toolbar.setCameraMute(muted); -} - -bool VideoConferenceModule::getVirtualCameraMuteState() -{ - bool disabled = false; - if (!instance->_settingsUpdateChannel.has_value()) - { - return disabled; - } - instance->_settingsUpdateChannel->access([&disabled](auto settingsMemory) { - auto settings = reinterpret_cast(settingsMemory._data); - disabled = settings->useOverlayImage; - }); - return disabled; -} - -bool VideoConferenceModule::getVirtualCameraInUse() -{ - if (!instance->_settingsUpdateChannel.has_value()) - { - return false; - } - bool inUse = false; - instance->_settingsUpdateChannel->access([&inUse](auto settingsMemory) { - auto settings = reinterpret_cast(settingsMemory._data); - inUse = settings->cameraInUse; - }); - return inUse; -} - -LRESULT CALLBACK VideoConferenceModule::LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) -{ - if (nCode == HC_ACTION) - { - KBDLLHOOKSTRUCT* kbd = reinterpret_cast(lParam); - switch (wParam) - { - case WM_KEYDOWN: - - if (isHotkeyPressed(kbd->vkCode, settings.cameraAndMicrophoneMuteHotkey)) - { - const bool cameraInUse = getVirtualCameraInUse(); - const bool microphoneIsMuted = getMicrophoneMuteState(); - const bool cameraIsMuted = cameraInUse && getVirtualCameraMuteState(); - if (cameraInUse) - { - // we're likely on a video call, so we must mute the unmuted cam/mic or reverse the mute state - // of everything, if cam and mic mute states are the same - if (microphoneIsMuted == cameraIsMuted) - { - reverseMicrophoneMute(); - reverseVirtualCameraMuteState(); - } - else if (cameraIsMuted) - { - reverseMicrophoneMute(); - } - else if (microphoneIsMuted) - { - reverseVirtualCameraMuteState(); - } - } - else - { - // if the camera is not in use, we just mute/unmute the mic - reverseMicrophoneMute(); - } - return 1; - } - else if (isHotkeyPressed(kbd->vkCode, settings.microphoneMuteHotkey)) - { - reverseMicrophoneMute(); - return 1; - } - else if (isHotkeyPressed(kbd->vkCode, settings.microphonePushToTalkHotkey)) - { - if (!pushToTalkPressed) - { - if (settings.pushToReverseEnabled || getMicrophoneMuteState()) - { - reverseMicrophoneMute(); - } - pushToTalkPressed = true; - } - return 1; - } - else if (isHotkeyPressed(kbd->vkCode, settings.cameraMuteHotkey)) - { - reverseVirtualCameraMuteState(); - return 1; - } - break; - case WM_KEYUP: - if (pushToTalkPressed && (kbd->vkCode == settings.microphonePushToTalkHotkey.get_code())) - { - reverseMicrophoneMute(); - pushToTalkPressed = false; - return 1; - } - } - } - - return CallNextHookEx(hook_handle, nCode, wParam, lParam); -} - -void VideoConferenceModule::onGeneralSettingsChanged() -{ - auto settings = PTSettingsHelper::load_general_settings(); - bool enabled = false; - try - { - if (json::has(settings, L"enabled")) - { - for (const auto& mod : settings.GetNamedObject(L"enabled")) - { - const auto value = mod.Value(); - if (value.ValueType() != json::JsonValueType::Boolean) - { - continue; - } - if (mod.Key() == get_key()) - { - enabled = value.GetBoolean(); - break; - } - } - } - } - catch (...) - { - LOG("Couldn't get enabled state"); - } - if (enabled) - { - enable(); - } - else - { - disable(); - } -} - -void VideoConferenceModule::onModuleSettingsChanged() -{ - try - { - PowerToysSettings::PowerToyValues values = PowerToysSettings::PowerToyValues::load_from_settings_file(get_key()); - //Trace::SettingsChanged(pressTime.value, overlayOpacity.value, theme.value); - - if (_enabled) - { - if (const auto val = values.get_json(L"mute_camera_and_microphone_hotkey")) - { - settings.cameraAndMicrophoneMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = values.get_json(L"mute_microphone_hotkey")) - { - settings.microphoneMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = values.get_json(L"push_to_talk_microphone_hotkey")) - { - settings.microphonePushToTalkHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = values.get_bool_value(L"push_to_reverse_enabled")) - { - settings.pushToReverseEnabled = *val; - } - if (const auto val = values.get_json(L"mute_camera_hotkey")) - { - settings.cameraMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = values.get_string_value(L"toolbar_position")) - { - settings.toolbarPositionString = val.value(); - } - if (const auto val = values.get_string_value(L"toolbar_monitor")) - { - settings.toolbarMonitorString = val.value(); - } - if (const auto val = values.get_string_value(L"selected_camera"); val && val != settings.selectedCamera) - { - settings.selectedCamera = val.value(); - sendSourceCameraNameUpdate(); - } - if (const auto val = values.get_string_value(L"camera_overlay_image_path"); val && val != settings.imageOverlayPath) - { - settings.imageOverlayPath = val.value(); - sendOverlayImageUpdate(); - } - if (const auto val = values.get_string_value(L"toolbar_hide")) - { - toolbar.setToolbarHide(val.value()); - } - if (const auto val = values.get_string_value(L"startup_action")) - { - settings.startupAction = val.value(); - } - - const auto selectedMic = values.get_string_value(L"selected_mic"); - if (selectedMic && selectedMic != settings.selectedMicrophone) - { - settings.selectedMicrophone = *selectedMic; - updateControlledMicrophones(settings.selectedMicrophone); - } - - toolbar.show(settings.toolbarPositionString, settings.toolbarMonitorString); - } - } - catch (...) - { - LOG("onModuleSettingsChanged encountered an exception"); - } -} - -void VideoConferenceModule::onMicrophoneConfigurationChanged() -{ - if (!_controllingAllMics) - { - // Don't care if we don't control all the mics - return; - } - - const bool mutedStateForNewMics = getMicrophoneMuteState(); - std::unordered_set currentlyTrackedMicsIds; - for (const auto& controlledMic : _controlledMicrophones) - { - currentlyTrackedMicsIds.emplace(controlledMic->id()); - } - - auto allMics = MicrophoneDevice::getAllActive(); - for (auto& newMic : allMics) - { - if (currentlyTrackedMicsIds.contains(newMic->id())) - { - continue; - } - - if (mutedStateForNewMics) - { - newMic->set_muted(true); - } - - _controlledMicrophones.emplace_back(std::move(newMic)); - } - // Restore invalidated pointer - _microphoneTrackedInUI = controlledDefaultMic(); - if (_microphoneTrackedInUI) - { - _microphoneTrackedInUI->set_mute_changed_callback([](const bool muted) { - toolbar.setMicrophoneMute(muted); - }); - } -} - -VideoConferenceModule::VideoConferenceModule() -{ - init_settings(); - _settingsUpdateChannel = - SerializedSharedMemory::create(CameraSettingsUpdateChannel::endpoint(), sizeof(CameraSettingsUpdateChannel), false); - if (_settingsUpdateChannel) - { - _settingsUpdateChannel->access([](auto memory) { - -// Suppress warning 26403 - Reset or explicitly delete an owner pointer 'variable' (r.3) -// the video conference class should be only instantiated once and it is using placement new -// the access to the data can be done through memory._data -#pragma warning(push) -#pragma warning(disable : 26403) - auto updatesChannel = new (memory._data) CameraSettingsUpdateChannel{}; -#pragma warning(pop) - }); - } - sendSourceCameraNameUpdate(); - sendOverlayImageUpdate(); -} - -inline VideoConferenceModule::~VideoConferenceModule() -{ - toolbar.hide(); -} - -const wchar_t* VideoConferenceModule::get_name() -{ - return L"Video Conference"; -} - -const wchar_t* VideoConferenceModule::get_key() -{ - return L"Video Conference"; -} - -// Return the configured status for the gpo policy for the module -powertoys_gpo::gpo_rule_configured_t VideoConferenceModule::gpo_policy_enabled_configuration() -{ - return powertoys_gpo::getConfiguredVideoConferenceMuteEnabledValue(); -} - -bool VideoConferenceModule::get_config(wchar_t* buffer, int* buffer_size) -{ - return true; -} - -void VideoConferenceModule::set_config(const wchar_t* config) -{ - try - { - PowerToysSettings::PowerToyValues values = PowerToysSettings::PowerToyValues::from_json_string(config, get_key()); - values.save_to_settings_file(); - } - catch (...) - { - LOG("VideoConferenceModule::set_config: exception during saving new settings values"); - } -} - -void VideoConferenceModule::init_settings() -{ - try - { - PowerToysSettings::PowerToyValues powerToysSettings = PowerToysSettings::PowerToyValues::load_from_settings_file(L"Video Conference"); - - if (const auto val = powerToysSettings.get_json(L"mute_camera_and_microphone_hotkey")) - { - settings.cameraAndMicrophoneMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = powerToysSettings.get_json(L"mute_microphone_hotkey")) - { - settings.microphoneMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = powerToysSettings.get_json(L"push_to_talk_microphone_hotkey")) - { - settings.microphonePushToTalkHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = powerToysSettings.get_bool_value(L"push_to_reverse_enabled")) - { - settings.pushToReverseEnabled = *val; - } - if (const auto val = powerToysSettings.get_json(L"mute_camera_hotkey")) - { - settings.cameraMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val); - } - if (const auto val = powerToysSettings.get_string_value(L"toolbar_position")) - { - settings.toolbarPositionString = val.value(); - } - if (const auto val = powerToysSettings.get_string_value(L"toolbar_monitor")) - { - settings.toolbarMonitorString = val.value(); - } - if (const auto val = powerToysSettings.get_string_value(L"selected_camera")) - { - settings.selectedCamera = val.value(); - } - if (const auto val = powerToysSettings.get_string_value(L"camera_overlay_image_path")) - { - settings.imageOverlayPath = val.value(); - } - if (const auto val = powerToysSettings.get_string_value(L"toolbar_hide")) - { - toolbar.setToolbarHide(val.value()); - } - if (const auto val = powerToysSettings.get_string_value(L"startup_action")) - { - settings.startupAction = val.value(); - } - if (const auto val = powerToysSettings.get_string_value(L"selected_mic"); val && *val != settings.selectedMicrophone) - { - settings.selectedMicrophone = *val; - updateControlledMicrophones(settings.selectedMicrophone); - } - } - catch (std::exception&) - { - // Error while loading from the settings file. Just let default values stay as they are. - } - - try - { - auto loaded = PTSettingsHelper::load_general_settings(); - std::wstring settings_theme{ static_cast(loaded.GetNamedString(L"theme", L"system")) }; - if (settings_theme != L"dark" && settings_theme != L"light") - { - settings_theme = L"system"; - } - toolbar.setTheme(settings_theme); - } - catch (...) - { - } -} - -void VideoConferenceModule::updateControlledMicrophones(const std::wstring_view new_mic) -{ - for (auto& controlledMic : _controlledMicrophones) - { - controlledMic->set_muted(false); - } - _controlledMicrophones.clear(); - _microphoneTrackedInUI = nullptr; - auto allMics = MicrophoneDevice::getAllActive(); - if (new_mic == L"[All]") - { - _controllingAllMics = true; - _controlledMicrophones = std::move(allMics); - _microphoneTrackedInUI = controlledDefaultMic(); - } - else - { - _controllingAllMics = false; - for (auto& controlledMic : allMics) - { - if (controlledMic->name() == new_mic) - { - _controlledMicrophones.emplace_back(std::move(controlledMic)); - _microphoneTrackedInUI = _controlledMicrophones[0].get(); - break; - } - } - } - - if (_microphoneTrackedInUI) - { - _microphoneTrackedInUI->set_mute_changed_callback([](const bool muted) { - toolbar.setMicrophoneMute(muted); - }); - toolbar.setMicrophoneMute(_microphoneTrackedInUI->muted()); - } - - if (settings.startupAction == L"Unmute") - { - for (auto& controlledMic : _controlledMicrophones) - { - controlledMic->set_muted(false); - } - } - else if (settings.startupAction == L"Mute") - { - for (auto& controlledMic : _controlledMicrophones) - { - controlledMic->set_muted(true); - } - } -} - -MicrophoneDevice* VideoConferenceModule::controlledDefaultMic() -{ - if (auto defaultMic = MicrophoneDevice::getDefault()) - { - for (auto& controlledMic : _controlledMicrophones) - { - if (controlledMic->id() == defaultMic->id()) - { - return controlledMic.get(); - } - } - } - - return nullptr; -} - -void toggleProxyCamRegistration(const bool enable) -{ - if (!is_process_elevated()) - { - return; - } - - auto vcmRoot = fs::path{ get_module_folderpath() }; -#if defined(_M_ARM64) - std::array proxyFilters = { vcmRoot / "PowerToys.VideoConferenceProxyFilter_ARM64.dll", vcmRoot / "PowerToys.VideoConferenceProxyFilter_x86.dll" }; -#else - std::array proxyFilters = { vcmRoot / "PowerToys.VideoConferenceProxyFilter_x64.dll", vcmRoot / "PowerToys.VideoConferenceProxyFilter_x86.dll" }; -#endif - for (const auto filter : proxyFilters) - { - std::wstring params{ L"/s " }; - if (!enable) - { - params += L"/u "; - } - params += '"'; - params += filter; - params += '"'; - SHELLEXECUTEINFOW sei{ sizeof(sei) }; - sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC }; - sei.lpFile = L"regsvr32"; - sei.lpParameters = params.c_str(); - sei.nShow = SW_SHOWNORMAL; - ShellExecuteExW(&sei); - } -} - -void VideoConferenceModule::enable() -{ - if (!_enabled) - { - _generalSettingsWatcher = std::make_unique( - PTSettingsHelper::get_powertoys_general_save_file_location(), [this] { - toolbar.scheduleGeneralSettingsUpdate(); - }); - _moduleSettingsWatcher = std::make_unique( - PTSettingsHelper::get_module_save_file_location(get_key()), [this] { - toolbar.scheduleModuleSettingsUpdate(); - }); - - toggleProxyCamRegistration(true); - toolbar.setMicrophoneMute(getMicrophoneMuteState()); - toolbar.setCameraMute(getVirtualCameraMuteState()); - - toolbar.show(settings.toolbarPositionString, settings.toolbarMonitorString); - - _enabled = true; - -#if defined(DISABLE_LOWLEVEL_HOOKS_WHEN_DEBUGGED) - if (IsDebuggerPresent()) - { - return; - } -#endif - hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), NULL); - } - Trace::EnableVideoConference(true); -} - -void VideoConferenceModule::unmuteAll() -{ - if (getVirtualCameraMuteState()) - { - reverseVirtualCameraMuteState(); - } - - if (getMicrophoneMuteState()) - { - reverseMicrophoneMute(); - } -} - -void VideoConferenceModule::muteAll() -{ - if (!getVirtualCameraMuteState()) - { - reverseVirtualCameraMuteState(); - } - - if (!getMicrophoneMuteState()) - { - reverseMicrophoneMute(); - } -} - -void VideoConferenceModule::disable() -{ - if (_enabled) - { - _generalSettingsWatcher.reset(); - _moduleSettingsWatcher.reset(); - toggleProxyCamRegistration(false); - if (hook_handle) - { - bool success = UnhookWindowsHookEx(hook_handle); - if (success) - { - hook_handle = nullptr; - } - } - - if (getVirtualCameraMuteState()) - { - reverseVirtualCameraMuteState(); - } - - toolbar.hide(); - - _enabled = false; - } - Trace::EnableVideoConference(false); -} - -bool VideoConferenceModule::is_enabled() -{ - return _enabled; -} - -void VideoConferenceModule::destroy() -{ - delete this; - instance = nullptr; -} - -bool VideoConferenceModule::is_enabled_by_default() const -{ - return false; -} - -void VideoConferenceModule::sendSourceCameraNameUpdate() -{ - if (!_settingsUpdateChannel.has_value() || settings.selectedCamera.empty()) - { - return; - } - _settingsUpdateChannel->access([](auto memory) { - auto updatesChannel = reinterpret_cast(memory._data); - updatesChannel->sourceCameraName.emplace(); - std::copy(begin(settings.selectedCamera), end(settings.selectedCamera), begin(*updatesChannel->sourceCameraName)); - if (settings.startupAction == L"Unmute") - { - updatesChannel->useOverlayImage = false; - } - else if (settings.startupAction == L"Mute") - { - updatesChannel->useOverlayImage = true; - } - }); -} - -void VideoConferenceModule::sendOverlayImageUpdate() -{ - if (!_settingsUpdateChannel.has_value()) - { - return; - } - _imageOverlayChannel.reset(); - - wchar_t powertoysDirectory[MAX_PATH + 1]; - - DWORD length = GetModuleFileNameW(nullptr, powertoysDirectory, MAX_PATH); - PathRemoveFileSpecW(powertoysDirectory); - - std::wstring blankImagePath(powertoysDirectory); - blankImagePath += L"\\Assets\\VCM\\black.bmp"; - - _imageOverlayChannel = SerializedSharedMemory::create_readonly(CameraOverlayImageChannel::endpoint(), - settings.imageOverlayPath != L"" ? settings.imageOverlayPath : blankImagePath); - - const auto imageSize = static_cast(_imageOverlayChannel->size()); - _settingsUpdateChannel->access([imageSize](auto memory) { - auto updatesChannel = reinterpret_cast(memory._data); - updatesChannel->overlayImageSize.emplace(imageSize); - updatesChannel->newOverlayImagePosted = true; - }); -} diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h deleted file mode 100644 index f3b835867a..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once - -#include - -#include -#include - -#include - -#include -#include - -#include "Toolbar.h" - -#include - -extern class VideoConferenceModule* instance; - -struct VideoConferenceSettings -{ - PowerToysSettings::HotkeyObject cameraAndMicrophoneMuteHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 81); - PowerToysSettings::HotkeyObject microphoneMuteHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 65); - PowerToysSettings::HotkeyObject microphonePushToTalkHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 73); - PowerToysSettings::HotkeyObject cameraMuteHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 79); - - std::wstring toolbarPositionString; - std::wstring toolbarMonitorString; - - std::wstring selectedCamera; - std::wstring imageOverlayPath; - std::wstring selectedMicrophone; - - std::wstring startupAction; - - bool pushToReverseEnabled = false; -}; - -class VideoConferenceModule : public PowertoyModuleIface -{ -public: - VideoConferenceModule(); - ~VideoConferenceModule(); - virtual const wchar_t* get_name() override; - - virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override; - - virtual bool get_config(wchar_t* buffer, int* buffer_size) override; - - virtual void set_config(const wchar_t* config) override; - - virtual void enable() override; - virtual void disable() override; - virtual bool is_enabled() override; - virtual void destroy() override; - virtual bool is_enabled_by_default() const override; - - virtual const wchar_t * get_key() override; - - void sendSourceCameraNameUpdate(); - void sendOverlayImageUpdate(); - - static void unmuteAll(); - static void muteAll(); - static void reverseMicrophoneMute(); - static bool getMicrophoneMuteState(); - static void reverseVirtualCameraMuteState(); - static bool getVirtualCameraMuteState(); - static bool getVirtualCameraInUse(); - - void onGeneralSettingsChanged(); - void onModuleSettingsChanged(); - void onMicrophoneConfigurationChanged(); - -private: - - void init_settings(); - void updateControlledMicrophones(const std::wstring_view new_mic); - MicrophoneDevice* controlledDefaultMic(); - - // all callback methods and used by callback have to be static - static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); - static bool isKeyPressed(unsigned int keyCode); - static bool isHotkeyPressed(DWORD code, PowerToysSettings::HotkeyObject& hotkey); - - static HHOOK hook_handle; - bool _enabled = false; - - bool _mic_muted_state_during_disconnect = false; - bool _controllingAllMics = false; - std::vector> _controlledMicrophones; - MicrophoneDevice* _microphoneTrackedInUI = nullptr; - - std::optional _imageOverlayChannel; - std::optional _settingsUpdateChannel; - - std::unique_ptr _generalSettingsWatcher; - std::unique_ptr _moduleSettingsWatcher; - - static VideoConferenceSettings settings; - static Toolbar toolbar; - static bool pushToTalkPressed; -}; diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.rc b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.rc deleted file mode 100644 index 5fa3c8b90d..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.rc +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include "resource.h" -#include "../../../common/version/version.h" - -#define APSTUDIO_READONLY_SYMBOLS -#include "winres.h" -#undef APSTUDIO_READONLY_SYMBOLS - -1 VERSIONINFO -FILEVERSION FILE_VERSION -PRODUCTVERSION PRODUCT_VERSION -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG -FILEFLAGS VS_FF_DEBUG -#else -FILEFLAGS 0x0L -#endif -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" // US English (0x0409), Unicode (0x04B0) charset - BEGIN - VALUE "CompanyName", COMPANY_NAME - VALUE "FileDescription", FILE_DESCRIPTION - VALUE "FileVersion", FILE_VERSION_STRING - VALUE "InternalName", INTERNAL_NAME - VALUE "LegalCopyright", COPYRIGHT_NOTE - VALUE "OriginalFilename", ORIGINAL_FILENAME - VALUE "ProductName", PRODUCT_NAME - VALUE "ProductVersion", PRODUCT_VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 // US English (0x0409), Unicode (1200) charset - END -END diff --git a/src/modules/videoconference/VideoConferenceModule/dllmain.cpp b/src/modules/videoconference/VideoConferenceModule/dllmain.cpp deleted file mode 100644 index c3d012cd6c..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/dllmain.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include "pch.h" -#include -#include "trace.h" -#include "VideoConferenceModule.h" - -BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - Trace::RegisterProvider(); - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - break; - case DLL_PROCESS_DETACH: - Trace::UnregisterProvider(); - break; - } - return TRUE; -} - -extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() -{ - if (!instance) - { - instance = new VideoConferenceModule(); - return instance; - } - else - { - return nullptr; - } -} diff --git a/src/modules/videoconference/VideoConferenceModule/framework.h b/src/modules/videoconference/VideoConferenceModule/framework.h deleted file mode 100644 index 54b83e94fd..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include diff --git a/src/modules/videoconference/VideoConferenceModule/packages.config b/src/modules/videoconference/VideoConferenceModule/packages.config deleted file mode 100644 index ff4b059648..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceModule/pch.cpp b/src/modules/videoconference/VideoConferenceModule/pch.cpp deleted file mode 100644 index 64b7eef6d6..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/src/modules/videoconference/VideoConferenceModule/pch.h b/src/modules/videoconference/VideoConferenceModule/pch.h deleted file mode 100644 index 7c614d9a5c..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/pch.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#define WIN32_LEAN_AND_MEAN -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include diff --git a/src/modules/videoconference/VideoConferenceModule/resource.h b/src/modules/videoconference/VideoConferenceModule/resource.h deleted file mode 100644 index 6073efd0c3..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/resource.h +++ /dev/null @@ -1,13 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by VideoConferenceModule.rc - -////////////////////////////// -// Non-localizable - -#define FILE_DESCRIPTION "PowerToys VideoConferenceMute Module" -#define INTERNAL_NAME "PowerToys.VideoConferenceModule" -#define ORIGINAL_FILENAME "PowerToys.VideoConferenceModule.dll" - -// Non-localizable -////////////////////////////// diff --git a/src/modules/videoconference/VideoConferenceModule/trace.cpp b/src/modules/videoconference/VideoConferenceModule/trace.cpp deleted file mode 100644 index 043c6b30e7..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/trace.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "pch.h" - -#include "trace.h" - -#include - -TRACELOGGING_DEFINE_PROVIDER( - g_hProvider, - "Microsoft.PowerToys", - // {38e8889b-9731-53f5-e901-e8a7c1753074} - (0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74), - TraceLoggingOptionProjectTelemetry()); - -// Log if the user has VCM enabled or disabled -void Trace::EnableVideoConference(const bool enabled) noexcept -{ - TraceLoggingWriteWrapper( - g_hProvider, - "VideoConference_EnableVideoConference", - ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), - TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE), - TraceLoggingBoolean(enabled, "Enabled")); -} - -void Trace::SettingsChanged(const struct VideoConferenceSettings& settings) noexcept -{ - bool CustomOverlayImage = (settings.imageOverlayPath.length() > 0); - - TraceLoggingWriteWrapper( - g_hProvider, - "VideoConference_SettingsChanged", - TraceLoggingWideString(settings.toolbarPositionString.c_str(), "ToolbarPosition"), - TraceLoggingWideString(settings.toolbarMonitorString.c_str(), "ToolbarMonitorSelection"), - TraceLoggingBool(CustomOverlayImage, "CustomImageOverlayUsed"), - ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), - TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), - TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); -} - -void Trace::MicrophoneMuted() noexcept -{ - TraceLoggingWriteWrapper( - g_hProvider, - "VideoConference_MicrophoneMuted", - TraceLoggingBoolean(true, "MicrophoneMuted"), - ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), - TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), - TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); -} - -void Trace::CameraMuted() noexcept -{ - TraceLoggingWriteWrapper( - g_hProvider, - "VideoConference_CameraMuted", - TraceLoggingBoolean(true, "CameraMuted"), - ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), - TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), - TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); -} diff --git a/src/modules/videoconference/VideoConferenceModule/trace.h b/src/modules/videoconference/VideoConferenceModule/trace.h deleted file mode 100644 index 0a9f193e69..0000000000 --- a/src/modules/videoconference/VideoConferenceModule/trace.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "VideoConferenceModule.h" - -#include - -class Trace : public telemetry::TraceBase -{ -public: - static void EnableVideoConference(const bool enabled) noexcept; - static void SettingsChanged(const struct VideoConferenceSettings &settings) noexcept; - static void MicrophoneMuted() noexcept; - static void CameraMuted() noexcept; -}; diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/DirectShowUtils.cpp b/src/modules/videoconference/VideoConferenceProxyFilter/DirectShowUtils.cpp deleted file mode 100644 index ef2d3f76ea..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/DirectShowUtils.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "DirectShowUtils.h" - -#include - -unique_media_type_ptr CopyMediaType(const AM_MEDIA_TYPE* source) -{ - unique_media_type_ptr target{ static_cast(CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))) }; - *target = *source; - if (source->cbFormat) - { - target->pbFormat = static_cast(CoTaskMemAlloc(source->cbFormat)); - std::copy(source->pbFormat, source->pbFormat + source->cbFormat, target->pbFormat); - } - - if (target->pUnk) - { - target->pUnk->AddRef(); - } - - return target; -} - -wil::com_ptr_nothrow GetPinAllocator(wil::com_ptr_nothrow& inputPin) -{ - if (!inputPin) - { - return nullptr; - } - wil::com_ptr_nothrow allocator; - if (auto memInput = inputPin.try_query(); memInput) - { - memInput->GetAllocator(&allocator); - return allocator; - } - - return nullptr; -} - -void MyFreeMediaType(AM_MEDIA_TYPE& mt) -{ - if (mt.cbFormat != 0) - { - CoTaskMemFree(mt.pbFormat); - mt.cbFormat = 0; - mt.pbFormat = nullptr; - } - - if (mt.pUnk != nullptr) - { - mt.pUnk->Release(); - mt.pUnk = nullptr; - } -} - -void MyDeleteMediaType(AM_MEDIA_TYPE* pmt) -{ - if (!pmt) - { - return; - } - - MyFreeMediaType(*pmt); - CoTaskMemFree(const_cast(pmt)); -} - -HRESULT MediaTypeEnumerator::Next(ULONG cObjects, AM_MEDIA_TYPE** outObjects, ULONG* pcFetched) -{ - if (!outObjects) - { - return E_POINTER; - } - - ULONG fetched = 0; - ULONG toFetch = cObjects; - while (toFetch-- && _pos < _objects.size()) - { - auto copy = CopyMediaType(_objects[_pos++].get()); - outObjects[fetched++] = copy.release(); - } - - if (pcFetched) - { - *pcFetched = fetched; - } - - return fetched == cObjects ? S_OK : S_FALSE; -} - -HRESULT MediaTypeEnumerator::Skip(ULONG cObjects) -{ - _pos += cObjects; - return _pos < _objects.size() ? S_OK : S_FALSE; -} - -HRESULT MediaTypeEnumerator::Reset() -{ - _pos = 0; - return S_OK; -} - -HRESULT MediaTypeEnumerator::Clone(IEnumMediaTypes** ppEnum) -{ - auto cloned = winrt::make_self(); - cloned->_objects.resize(_objects.size()); - for (size_t i = 0; i < _objects.size(); ++i) - { - cloned->_objects[i] = CopyMediaType(_objects[i].get()); - } - - cloned->_pos = _pos; - cloned.as().copy_to(ppEnum); - return S_OK; -} \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/DirectShowUtils.h b/src/modules/videoconference/VideoConferenceProxyFilter/DirectShowUtils.h deleted file mode 100644 index d8c35a54b6..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/DirectShowUtils.h +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once -#include - -#define WIN32_LEAN_AND_MEAN -#include -#include - -#include -#include - -#include - -#include "Logging.h" - -void MyDeleteMediaType(AM_MEDIA_TYPE* pmt); - -using unique_media_type_ptr = - wistd::unique_ptr>; - -unique_media_type_ptr CopyMediaType(const AM_MEDIA_TYPE* source); - -template -struct ObjectEnumerator : public winrt::implements, EnumeratorInterface> -{ - std::vector> _objects; - ULONG _pos = 0; - - HRESULT STDMETHODCALLTYPE Next(ULONG cObjects, ObjectInterface** outObjects, ULONG* pcFetched) override - { - if (!outObjects) - { - return E_POINTER; - } - - ULONG fetched = 0; - ULONG toFetch = cObjects; - while (toFetch-- && _pos < _objects.size()) - { - _objects[_pos++].copy_to(&outObjects[fetched++]); - } - - if (pcFetched) - { - *pcFetched = fetched; - } - - return fetched == cObjects ? S_OK : S_FALSE; - } - - HRESULT STDMETHODCALLTYPE Skip(ULONG cObjects) override - { - _pos += cObjects; - return _pos < _objects.size() ? S_OK : S_FALSE; - } - - HRESULT STDMETHODCALLTYPE Reset() override - { - _pos = 0; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE Clone(EnumeratorInterface** ppEnum) override - { - auto cloned = winrt::make_self(); - cloned->_objects = _objects; - cloned->_pos = _pos; - cloned.as().copy_to(ppEnum); - return S_OK; - } - - virtual ~ObjectEnumerator() = default; -}; - -struct MediaTypeEnumerator : public winrt::implements -{ - std::vector _objects; - ULONG _pos = 0; - - HRESULT STDMETHODCALLTYPE Next(ULONG cObjects, AM_MEDIA_TYPE** outObjects, ULONG* pcFetched) override; - HRESULT STDMETHODCALLTYPE Skip(ULONG cObjects) override; - HRESULT STDMETHODCALLTYPE Reset() override; - HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes** ppEnum) override; - - virtual ~MediaTypeEnumerator() = default; -}; - -wil::com_ptr_nothrow GetPinAllocator(wil::com_ptr_nothrow& inputPin); diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/ImageLoading.cpp b/src/modules/videoconference/VideoConferenceProxyFilter/ImageLoading.cpp deleted file mode 100644 index 4887801154..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/ImageLoading.cpp +++ /dev/null @@ -1,424 +0,0 @@ -#include - -#include -#include -#include - -#pragma warning(push) -#pragma warning(disable : 4005) -#include -#pragma warning(pop) - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include "Logging.h" - -IWICImagingFactory* _GetWIC() noexcept -{ - static IWICImagingFactory* s_Factory = nullptr; - - if (s_Factory) - { - return s_Factory; - } - - OK_OR_BAIL(CoCreateInstance( - CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, __uuidof(IWICImagingFactory), (LPVOID*)&s_Factory)); - - return s_Factory; -} - -bool ReencodeJPGImage(BYTE* imageBuf, const DWORD imageSize, DWORD& reencodedSize) -{ - auto pWIC = _GetWIC(); - wil::com_ptr_nothrow imageStream = SHCreateMemStream(imageBuf, imageSize); - if (!imageStream) - { - return false; - } - - // Decode jpg into bitmap - wil::com_ptr_nothrow bitmapDecoder; - OK_OR_BAIL(pWIC->CreateDecoderFromStream(imageStream.get(), nullptr, WICDecodeMetadataCacheOnLoad, &bitmapDecoder)); - wil::com_ptr_nothrow decodedFrame; - OK_OR_BAIL(bitmapDecoder->GetFrame(0, &decodedFrame)); - wil::com_ptr_nothrow bitmap; - bitmap.attach(decodedFrame.detach()); - UINT width = 0, height = 0; - OK_OR_BAIL(bitmap->GetSize(&width, &height)); - - // Initialize jpg encoder - wil::com_ptr_nothrow encoder; - OK_OR_BAIL(pWIC->CreateEncoder(GUID_ContainerFormatJpeg, nullptr, &encoder)); - - wil::com_ptr_nothrow outputStream; - OK_OR_BAIL(CreateStreamOnHGlobal(nullptr, true, &outputStream)); - OK_OR_BAIL(encoder->Initialize(outputStream.get(), WICBitmapEncoderNoCache)); - wil::com_ptr_nothrow encodedFrame; - wil::com_ptr_nothrow encoderOptions; - OK_OR_BAIL(encoder->CreateNewFrame(&encodedFrame, &encoderOptions)); - - ULONG nProperties = 0; - OK_OR_BAIL(encoderOptions->CountProperties(&nProperties)); - for (ULONG propIdx = 0; propIdx < nProperties; ++propIdx) - { - PROPBAG2 propBag{}; - ULONG _; - OK_OR_BAIL(encoderOptions->GetPropertyInfo(propIdx, 1, &propBag, &_)); - if (propBag.pstrName == std::wstring_view{ L"ImageQuality" }) - { - wil::unique_variant variant; - variant.vt = VT_R4; - variant.fltVal = 0.1f; - OK_OR_BAIL(encoderOptions->Write(1, &propBag, &variant)); - LOG("Successfully set jpg compression quality"); - // skip the rest of the properties - propIdx = nProperties; - } - CoTaskMemFree(propBag.pstrName); - } - - OK_OR_BAIL(encodedFrame->Initialize(encoderOptions.get())); - WICPixelFormatGUID intermediateFormat = GUID_WICPixelFormat24bppRGB; - - OK_OR_BAIL(encodedFrame->SetPixelFormat(&intermediateFormat)); - OK_OR_BAIL(encodedFrame->SetSize(width, height)); - - // Commit the image encoding - OK_OR_BAIL(encodedFrame->WriteSource(bitmap.get(), nullptr)); - OK_OR_BAIL(encodedFrame->Commit()); - OK_OR_BAIL(encoder->Commit()); - - STATSTG intermediateStreamStat{}; - OK_OR_BAIL(outputStream->Stat(&intermediateStreamStat, STATFLAG_NONAME)); - const ULONGLONG jpgStreamSize = intermediateStreamStat.cbSize.QuadPart; - HGLOBAL streamMemoryHandle{}; - OK_OR_BAIL(GetHGlobalFromStream(outputStream.get(), &streamMemoryHandle)); - - auto jpgStreamMemory = static_cast(GlobalLock(streamMemoryHandle)); - std::copy(jpgStreamMemory, jpgStreamMemory + jpgStreamSize, imageBuf); - auto unlockJpgStreamMemory = wil::scope_exit([jpgStreamMemory] { GlobalUnlock(jpgStreamMemory); }); - reencodedSize = static_cast(jpgStreamSize); - return true; -} - -wil::com_ptr_nothrow LoadAsRGB24BitmapWithSize(IWICImagingFactory* pWIC, - wil::com_ptr_nothrow image, - const UINT targetWidth, - const UINT targetHeight) -{ - wil::com_ptr_nothrow bitmap; - // Initialize image bitmap decoder from filename and get the image frame - wil::com_ptr_nothrow bitmapDecoder; - OK_OR_BAIL(pWIC->CreateDecoderFromStream(image.get(), nullptr, WICDecodeMetadataCacheOnLoad, &bitmapDecoder)); - - wil::com_ptr_nothrow decodedFrame; - OK_OR_BAIL(bitmapDecoder->GetFrame(0, &decodedFrame)); - - UINT imageWidth = 0, imageHeight = 0; - OK_OR_BAIL(decodedFrame->GetSize(&imageWidth, &imageHeight)); - - // Scale the image if required - if (targetWidth != imageWidth || targetHeight != imageHeight) - { - wil::com_ptr_nothrow scaler; - OK_OR_BAIL(pWIC->CreateBitmapScaler(&scaler)); - OK_OR_BAIL( - scaler->Initialize(decodedFrame.get(), targetWidth, targetHeight, WICBitmapInterpolationModeHighQualityCubic)); - bitmap.attach(scaler.detach()); - } - else - { - bitmap.attach(decodedFrame.detach()); - } - WICPixelFormatGUID pixelFormat{}; - OK_OR_BAIL(bitmap->GetPixelFormat(&pixelFormat)); - - const auto targetPixelFormat = GUID_WICPixelFormat24bppBGR; - if (pixelFormat != targetPixelFormat) - { - wil::com_ptr_nothrow convertedBitmap; - if (SUCCEEDED(WICConvertBitmapSource(targetPixelFormat, bitmap.get(), &convertedBitmap))) - { - return convertedBitmap; - } - } - - return bitmap; -} - -wil::com_ptr_nothrow EncodeBitmapToContainer(IWICImagingFactory* pWIC, - wil::com_ptr_nothrow bitmap, - const GUID& containerGUID, - const UINT width, - const UINT height, - const float quality) -{ - wil::com_ptr_nothrow encoder; - pWIC->CreateEncoder(containerGUID, nullptr, &encoder); - - if (!encoder) - { - return nullptr; - } - - // Prepare the encoder output memory stream and encoding params - wil::com_ptr_nothrow encodedBitmap; - OK_OR_BAIL(CreateStreamOnHGlobal(nullptr, true, &encodedBitmap)); - OK_OR_BAIL(encoder->Initialize(encodedBitmap.get(), WICBitmapEncoderNoCache)); - wil::com_ptr_nothrow encodedFrame; - - wil::com_ptr_nothrow encoderOptions; - OK_OR_BAIL(encoder->CreateNewFrame(&encodedFrame, &encoderOptions)); - - ULONG nProperties = 0; - OK_OR_BAIL(encoderOptions->CountProperties(&nProperties)); - for (ULONG propIdx = 0; propIdx < nProperties; ++propIdx) - { - PROPBAG2 propBag{}; - ULONG _; - OK_OR_BAIL(encoderOptions->GetPropertyInfo(propIdx, 1, &propBag, &_)); - if (propBag.pstrName == std::wstring_view{ L"ImageQuality" }) - { - wil::unique_variant variant; - variant.vt = VT_R4; - variant.fltVal = quality; - OK_OR_BAIL(encoderOptions->Write(1, &propBag, &variant)); - LOG("Successfully set jpg compression quality"); - // skip the rest of the properties - propIdx = nProperties; - } - CoTaskMemFree(propBag.pstrName); - } - - OK_OR_BAIL(encodedFrame->Initialize(encoderOptions.get())); - - WICPixelFormatGUID intermediateFormat = GUID_WICPixelFormat24bppRGB; - OK_OR_BAIL(encodedFrame->SetPixelFormat(&intermediateFormat)); - OK_OR_BAIL(encodedFrame->SetSize(width, height)); - - // Commit the image encoding - OK_OR_BAIL(encodedFrame->WriteSource(bitmap.get(), nullptr)); - OK_OR_BAIL(encodedFrame->Commit()); - OK_OR_BAIL(encoder->Commit()); - return encodedBitmap; -} - -IMFSample* ConvertIMFVideoSample(const MFT_REGISTER_TYPE_INFO& inputType, - IMFMediaType* outputMediaType, - const wil::com_ptr_nothrow& inputSample, - const UINT width, - const UINT height) -{ - IMFActivate** ppVDActivate = nullptr; - UINT32 count = 0; - - MFT_REGISTER_TYPE_INFO outputType = { MFMediaType_Video, {} }; - outputMediaType->GetGUID(MF_MT_SUBTYPE, &outputType.guidSubtype); - - const std::array transformerCategories = { - MFT_CATEGORY_VIDEO_PROCESSOR, MFT_CATEGORY_VIDEO_DECODER, MFT_CATEGORY_VIDEO_ENCODER - }; - - for (const auto& transformerCategory : transformerCategories) - { - OK_OR_BAIL(MFTEnumEx(transformerCategory, MFT_ENUM_FLAG_SYNCMFT, &inputType, &outputType, &ppVDActivate, &count)); - if (count != 0) - { - break; - } - } - - wil::com_ptr_nothrow videoTransformer; - - bool videoDecoderActivated = false; - for (UINT32 i = 0; i < count; ++i) - { - if (!videoDecoderActivated && !FAILED(ppVDActivate[i]->ActivateObject(IID_PPV_ARGS(&videoTransformer)))) - { - videoDecoderActivated = true; - } - ppVDActivate[i]->Release(); - } - - if (count) - { - CoTaskMemFree(ppVDActivate); - } - - if (!videoDecoderActivated) - { - LOG("No converter available for the selected format"); - return nullptr; - } - - auto shutdownVideoDecoder = wil::scope_exit([&videoTransformer] { MFShutdownObject(videoTransformer.get()); }); - // Set input/output types for the decoder - wil::com_ptr_nothrow intermediateFrameMediaType; - OK_OR_BAIL(MFCreateMediaType(&intermediateFrameMediaType)); - intermediateFrameMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); - intermediateFrameMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB24); - intermediateFrameMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive); - intermediateFrameMediaType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE); - OK_OR_BAIL(MFSetAttributeSize(intermediateFrameMediaType.get(), MF_MT_FRAME_SIZE, width, height)); - OK_OR_BAIL(MFSetAttributeRatio(intermediateFrameMediaType.get(), MF_MT_PIXEL_ASPECT_RATIO, width, height)); - OK_OR_BAIL(videoTransformer->SetInputType(0, intermediateFrameMediaType.get(), 0)); - OK_OR_BAIL(videoTransformer->SetOutputType(0, outputMediaType, 0)); - - // Process the input sample - OK_OR_BAIL(videoTransformer->ProcessInput(0, inputSample.get(), 0)); - - // Check whether we need to allocate output sample and buffer ourselves - MFT_OUTPUT_STREAM_INFO outputStreamInfo{}; - OK_OR_BAIL(videoTransformer->GetOutputStreamInfo(0, &outputStreamInfo)); - const bool onlyProvidesSamples = outputStreamInfo.dwFlags & MFT_OUTPUT_STREAM_PROVIDES_SAMPLES; - const bool canProvideSamples = outputStreamInfo.dwFlags & MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES; - const bool mustAllocateSample = - (!onlyProvidesSamples && !canProvideSamples) || - (!onlyProvidesSamples && (outputStreamInfo.dwFlags & MFT_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER)); - - MFT_OUTPUT_DATA_BUFFER outputSamples{}; - IMFSample* outputSample = nullptr; - - // If so, do the allocation - if (mustAllocateSample) - { - OK_OR_BAIL(MFCreateSample(&outputSample)); - OK_OR_BAIL(outputSample->SetSampleDuration(333333)); - OK_OR_BAIL(outputSample->SetSampleTime(1)); - OK_OR_BAIL(outputSample->SetUINT32(MF_MT_VIDEO_ROTATION, MFVideoRotationFormat::MFVideoRotationFormat_0)); - IMFMediaBuffer* outputMediaBuffer = nullptr; - OK_OR_BAIL( - MFCreateAlignedMemoryBuffer(outputStreamInfo.cbSize, outputStreamInfo.cbAlignment - 1, &outputMediaBuffer)); - OK_OR_BAIL(outputMediaBuffer->SetCurrentLength(outputStreamInfo.cbSize)); - OK_OR_BAIL(outputSample->AddBuffer(outputMediaBuffer)); - outputSamples.pSample = outputSample; - } - - // Finally, produce the output sample - DWORD processStatus = 0; - if (failed(videoTransformer->ProcessOutput(0, 1, &outputSamples, &processStatus))) - { - LOG("Failed to convert image frame"); - } - if (outputSamples.pEvents) - { - outputSamples.pEvents->Release(); - } - - return outputSamples.pSample; -} - -wil::com_ptr_nothrow LoadImageAsSample(wil::com_ptr_nothrow imageStream, - IMFMediaType* sampleMediaType, - const float quality) noexcept -{ - UINT targetWidth = 0; - UINT targetHeight = 0; - OK_OR_BAIL(MFGetAttributeSize(sampleMediaType, MF_MT_FRAME_SIZE, &targetWidth, &targetHeight)); - MFT_REGISTER_TYPE_INFO outputType = { MFMediaType_Video, {} }; - OK_OR_BAIL(sampleMediaType->GetGUID(MF_MT_SUBTYPE, &outputType.guidSubtype)); - - IWICImagingFactory* pWIC = _GetWIC(); - if (!pWIC) - { - LOG("Failed to create IWICImagingFactory"); - return nullptr; - } - - if (!imageStream) - { - return nullptr; - } - - const auto srcImageBitmap = LoadAsRGB24BitmapWithSize(pWIC, imageStream, targetWidth, targetHeight); - if (!srcImageBitmap) - { - return nullptr; - } - - // First, let's create a sample containing RGB24 bitmap - IMFSample* outputSample = nullptr; - OK_OR_BAIL(MFCreateSample(&outputSample)); - OK_OR_BAIL(outputSample->SetUINT32(MF_MT_VIDEO_ROTATION, MFVideoRotationFormat::MFVideoRotationFormat_0)); - OK_OR_BAIL(outputSample->SetSampleDuration(333333)); - OK_OR_BAIL(outputSample->SetSampleTime(1)); - IMFMediaBuffer* outputMediaBuffer = nullptr; - const DWORD nPixelBytes = targetWidth * targetHeight * 3; - OK_OR_BAIL(MFCreateAlignedMemoryBuffer(nPixelBytes, MF_64_BYTE_ALIGNMENT, &outputMediaBuffer)); - - const UINT stride = 3 * targetWidth; - - DWORD max_length = 0, current_length = 0; - BYTE* sampleBufferMemory = nullptr; - OK_OR_BAIL(outputMediaBuffer->Lock(&sampleBufferMemory, &max_length, ¤t_length)); - OK_OR_BAIL(srcImageBitmap->CopyPixels(nullptr, stride, nPixelBytes, sampleBufferMemory)); - OK_OR_BAIL(outputMediaBuffer->Unlock()); - - OK_OR_BAIL(outputMediaBuffer->SetCurrentLength(nPixelBytes)); - OK_OR_BAIL(outputSample->AddBuffer(outputMediaBuffer)); - - if (outputType.guidSubtype == MFVideoFormat_RGB24) - { - return outputSample; - } - - // Special case for mjpg, since we need to use jpg container for it instead of supplying raw pixels - if (outputType.guidSubtype == MFVideoFormat_MJPG) - { - // Use an intermediate jpg container sample which will be transcoded to the target format - wil::com_ptr_nothrow jpgStream = - EncodeBitmapToContainer(pWIC, srcImageBitmap, GUID_ContainerFormatJpeg, targetWidth, targetHeight, quality); - - // Obtain stream size and lock its memory pointer - STATSTG intermediateStreamStat{}; - OK_OR_BAIL(jpgStream->Stat(&intermediateStreamStat, STATFLAG_NONAME)); - const ULONGLONG jpgStreamSize = intermediateStreamStat.cbSize.QuadPart; - HGLOBAL streamMemoryHandle{}; - OK_OR_BAIL(GetHGlobalFromStream(jpgStream.get(), &streamMemoryHandle)); - - auto jpgStreamMemory = static_cast(GlobalLock(streamMemoryHandle)); - auto unlockJpgStreamMemory = wil::scope_exit([jpgStreamMemory] { GlobalUnlock(jpgStreamMemory); }); - - // Create a sample from the input image buffer - wil::com_ptr_nothrow jpgSample; - OK_OR_BAIL(MFCreateSample(&jpgSample)); - OK_OR_BAIL(jpgSample->SetUINT32(MF_MT_VIDEO_ROTATION, MFVideoRotationFormat::MFVideoRotationFormat_0)); - IMFMediaBuffer* inputMediaBuffer = nullptr; - OK_OR_BAIL(MFCreateAlignedMemoryBuffer(static_cast(jpgStreamSize), MF_64_BYTE_ALIGNMENT, &inputMediaBuffer)); - BYTE* inputBuf = nullptr; - OK_OR_BAIL(inputMediaBuffer->Lock(&inputBuf, &max_length, ¤t_length)); - if (max_length < jpgStreamSize) - { - return nullptr; - } - - std::copy(jpgStreamMemory, jpgStreamMemory + jpgStreamSize, inputBuf); - unlockJpgStreamMemory.reset(); - OK_OR_BAIL(inputMediaBuffer->Unlock()); - OK_OR_BAIL(inputMediaBuffer->SetCurrentLength(static_cast(jpgStreamSize))); - OK_OR_BAIL(jpgSample->AddBuffer(inputMediaBuffer)); - - return jpgSample; - } - - // Now we are ready to convert it to the requested media type - MFT_REGISTER_TYPE_INFO intermediateType = { MFMediaType_Video, MFVideoFormat_RGB24 }; - - // But if no conversion is needed, just return the input sample - - return ConvertIMFVideoSample(intermediateType, sampleMediaType, outputSample, targetWidth, targetHeight); -} \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/Resources.resx b/src/modules/videoconference/VideoConferenceProxyFilter/Resources.resx deleted file mode 100644 index 4770a524fe..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/Resources.resx +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - VideoCaptureProxyFilter - do not loc, product name - - diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.cpp b/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.cpp deleted file mode 100644 index 7b97891c5b..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.cpp +++ /dev/null @@ -1,636 +0,0 @@ -#include "Logging.h" -#include "VideoCaptureDevice.h" - -#include -#include - -struct VideoCaptureReceiverFilter : winrt::implements -{ - FILTER_STATE _state = State_Stopped; - IFilterGraph* _graph = nullptr; - wil::com_ptr_nothrow _videoReceiverPin; - - ULONG STDMETHODCALLTYPE GetMiscFlags() override { return AM_FILTER_MISC_FLAGS_IS_RENDERER; } - - HRESULT STDMETHODCALLTYPE GetClassID(CLSID*) override { return E_NOTIMPL; } - - HRESULT STDMETHODCALLTYPE Stop() override - { - _state = State_Stopped; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE Pause() override - { - _state = State_Paused; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME) override - { - _state = State_Running; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE GetState(DWORD, FILTER_STATE* outState) override - { - *outState = _state; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock** outRefClock) override - { - *outRefClock = nullptr; - return NOERROR; - } - - HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock*) override { return S_OK; } - - HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins** ppEnum) override - { - auto enumerator = winrt::make_self>(); - enumerator->_objects.emplace_back(_videoReceiverPin); - *ppEnum = enumerator.detach(); - - return S_OK; - } - - HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR, IPin**) override { return E_NOTIMPL; } - - HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR) override - { - _graph = pGraph; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO* pInfo) override - { - std::copy(std::begin(NAME), std::end(NAME), pInfo->achName); - if (_graph) - { - pInfo->pGraph = _graph; - _graph->AddRef(); - } - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR* pVendorInfo) override - { - auto info = static_cast(CoTaskMemAlloc(sizeof(VENDOR))); - std::copy(std::begin(VENDOR), std::end(VENDOR), info); - *pVendorInfo = info; - return S_OK; - } - - virtual ~VideoCaptureReceiverFilter() = default; - - constexpr static inline wchar_t NAME[] = L"PowerToysVCMCaptureFilter"; - constexpr static inline wchar_t VENDOR[] = L"Microsoft Corporation"; -}; - -struct VideoCaptureReceiverPin : winrt::implements -{ - VideoCaptureReceiverFilter* _owningFilter = nullptr; - unique_media_type_ptr _expectedMediaType; - wil::com_ptr_nothrow _captureInputPin; - unique_media_type_ptr _inputCaptureMediaType; - std::atomic_bool _flushing = false; - VideoCaptureDevice::callback_t _frameCallback; - - wil::com_ptr_nothrow _allocator; - - VideoCaptureReceiverPin(unique_media_type_ptr mediaType, VideoCaptureReceiverFilter* filter) : - _expectedMediaType{ std::move(mediaType) }, _owningFilter{ filter } - { - } - - HRESULT STDMETHODCALLTYPE Connect(IPin*, const AM_MEDIA_TYPE* pmt) override - { - if (_owningFilter->_state == State_Running) - { - return VFW_E_NOT_STOPPED; - } - - if (_captureInputPin) - { - return VFW_E_ALREADY_CONNECTED; - } - - if (!pmt || pmt->majortype == GUID_NULL) - { - return S_OK; - } - - if (pmt->majortype != _expectedMediaType->majortype || pmt->subtype != _expectedMediaType->subtype) - { - return S_FALSE; - } - - return S_OK; - } - - HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt) override - { - if (!pConnector || !pmt) - { - return E_POINTER; - } - - if (_captureInputPin) - { - return VFW_E_ALREADY_CONNECTED; - } - - if (_owningFilter->_state != State_Stopped) - { - return VFW_E_NOT_STOPPED; - } - - if (QueryAccept(pmt) != S_OK) - { - return VFW_E_TYPE_NOT_ACCEPTED; - } - - _captureInputPin = pConnector; - _inputCaptureMediaType = CopyMediaType(pmt); - - return S_OK; - } - - HRESULT STDMETHODCALLTYPE Disconnect() override - { - _allocator.reset(); - _captureInputPin.reset(); - _inputCaptureMediaType.reset(); - return S_OK; - } - - HRESULT STDMETHODCALLTYPE ConnectedTo(IPin** pPin) override - { - if (!_captureInputPin) - { - return VFW_E_NOT_CONNECTED; - } - - return _captureInputPin.try_copy_to(pPin) ? S_OK : E_FAIL; - } - - HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE* pmt) override - { - if (!pmt) - { - return E_POINTER; - } - - if (!_inputCaptureMediaType) - { - return VFW_E_NOT_CONNECTED; - } - - *pmt = *CopyMediaType(_inputCaptureMediaType.get()).release(); - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO* pInfo) override - { - if (!pInfo) - { - return E_POINTER; - } - - pInfo->pFilter = _owningFilter; - if (_owningFilter) - { - _owningFilter->AddRef(); - } - - pInfo->dir = PINDIR_INPUT; - std::copy(std::begin(NAME), std::end(NAME), pInfo->achName); - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION* pPinDir) override - { - if (!pPinDir) - { - return E_POINTER; - } - - *pPinDir = PINDIR_INPUT; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryId(LPWSTR* lpId) override - { - if (!lpId) - { - return E_POINTER; - } - - *lpId = static_cast(CoTaskMemAlloc(sizeof(NAME))); - - std::copy(std::begin(NAME), std::end(NAME), *lpId); - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE* pmt) override - { - if (!pmt) - { - return E_POINTER; - } - - if (pmt->majortype != _expectedMediaType->majortype || pmt->subtype != _expectedMediaType->subtype) - { - return S_FALSE; - } - - if (_captureInputPin) - { -// disable warning 26492 - Don't use const_cast to cast away const -// reset needs 'pmt' to be non-const, we can't easily change the query accept prototype -// because of the inheritance. -#pragma warning(suppress : 26492) - _inputCaptureMediaType.reset(const_cast(pmt)); - } - - return S_OK; - } - - HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes** ppEnum) override - { - if (!ppEnum) - { - return E_POINTER; - } - - auto enumerator = winrt::make_self(); - enumerator->_objects.emplace_back(CopyMediaType(_expectedMediaType.get())); - *ppEnum = enumerator.detach(); - - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin**, ULONG*) override { return E_NOTIMPL; } - - HRESULT STDMETHODCALLTYPE EndOfStream() override { return S_OK; } - - HRESULT STDMETHODCALLTYPE BeginFlush() override - { - _flushing = true; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE EndFlush() override - { - _flushing = false; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME, REFERENCE_TIME, double) override { return S_OK; } - - HRESULT STDMETHODCALLTYPE GetAllocator(IMemAllocator** allocator) override - { - VERBOSE_LOG; - if (!_allocator) - { - return VFW_E_NO_ALLOCATOR; - } - - return _allocator.try_copy_to(allocator) ? S_OK : E_FAIL; - } - - HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator* allocator, BOOL readOnly) override - { - VERBOSE_LOG; - LOG(readOnly ? "Allocator READONLY: true" : "Allocator READONLY: false"); - _allocator = allocator; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE GetAllocatorRequirements(ALLOCATOR_PROPERTIES*) override { return E_NOTIMPL; } - - HRESULT STDMETHODCALLTYPE Receive(IMediaSample* pSample) override - { - if (_flushing) - { - return S_FALSE; - } - - if (!pSample) - { - return E_POINTER; - } - - if (pSample && _frameCallback) - { - _frameCallback(pSample); - } - - return S_OK; - } - - HRESULT STDMETHODCALLTYPE ReceiveMultiple(IMediaSample** pSamples, long nSamples, long* nSamplesProcessed) override - { - if (!pSamples && nSamples) - { - return E_POINTER; - } - - if (_flushing) - { - return S_FALSE; - } - - for (long i = 0; i < nSamples; i++) - { - Receive(pSamples[i]); - } - - *nSamplesProcessed = nSamples; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE ReceiveCanBlock() override { return S_FALSE; } - - virtual ~VideoCaptureReceiverPin() = default; - - constexpr static inline wchar_t NAME[] = L"PowerToysVCMCapturePin"; -}; - -constexpr long MINIMAL_FPS_ALLOWED = 29; - -const char* GetMediaSubTypeString(const GUID& guid) -{ - if (guid == MEDIASUBTYPE_RGB24) - { - return "MEDIASUBTYPE_RGB24"; - } - - if (guid == MEDIASUBTYPE_YUY2) - { - return "MEDIASUBTYPE_YUY2"; - } - - if (guid == MEDIASUBTYPE_MJPG) - { - return "MEDIASUBTYPE_MJPG"; - } - - if (guid == MEDIASUBTYPE_NV12) - { - return "MEDIASUBTYPE_NV12"; - } - - return "MEDIASUBTYPE_UNKNOWN"; -} - -std::optional SelectBestMediaType(wil::com_ptr_nothrow& pin) -{ - VERBOSE_LOG; - wil::com_ptr_nothrow mediaTypeEnum; - if (pin->EnumMediaTypes(&mediaTypeEnum); !mediaTypeEnum) - { - return std::nullopt; - } - - ULONG _ = 0; - VideoStreamFormat bestFormat; - unique_media_type_ptr mt; - while (mediaTypeEnum->Next(1, wil::out_param(mt), &_) == S_OK) - { - if (mt->majortype != MEDIATYPE_Video) - { - continue; - } - - auto format = reinterpret_cast(mt->pbFormat); - if (!format || !format->AvgTimePerFrame) - { - LOG("VideoInfoHeader not found"); - continue; - } - - const auto formatAvgFPS = 10000000LL / format->AvgTimePerFrame; - if (format->AvgTimePerFrame > bestFormat.avgFrameTime || formatAvgFPS < MINIMAL_FPS_ALLOWED) - { - continue; - } - - if (format->bmiHeader.biWidth < bestFormat.width || format->bmiHeader.biHeight < bestFormat.height) - { - continue; - } - - if (mt->subtype != MEDIASUBTYPE_YUY2 && mt->subtype != MEDIASUBTYPE_MJPG && mt->subtype != MEDIASUBTYPE_RGB24) - { - OLECHAR* guidString; - StringFromCLSID(mt->subtype, &guidString); - LOG("Skipping mediatype due to unsupported subtype: "); - LOG(guidString); - ::CoTaskMemFree(guidString); - continue; - } - - bestFormat.avgFrameTime = format->AvgTimePerFrame; - bestFormat.width = format->bmiHeader.biWidth; - bestFormat.height = format->bmiHeader.biHeight; - bestFormat.mediaType = std::move(mt); - } - - if (!bestFormat.mediaType) - { - LOG(L"Couldn't select a suitable media format"); - return std::nullopt; - } - - char selectedFormat[512]{}; - sprintf_s(selectedFormat, "Selected media format: %s %ldx%ld %lld fps", GetMediaSubTypeString(bestFormat.mediaType->subtype), bestFormat.width, bestFormat.height, 10000000LL / bestFormat.avgFrameTime); - LOG(selectedFormat); - - return std::move(bestFormat); -} - -std::vector VideoCaptureDevice::ListAll() -{ - std::vector devices; - auto enumeratorFactory = wil::CoCreateInstanceNoThrow(CLSID_SystemDeviceEnum); - if (!enumeratorFactory) - { - LOG("Couldn't create devenum factory"); - return devices; - } - - wil::com_ptr_nothrow enumMoniker; - enumeratorFactory->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &enumMoniker, CDEF_DEVMON_PNP_DEVICE); - if (!enumMoniker) - { - LOG("Couldn't create class enumerator"); - return devices; - } - - ULONG _ = 0; - wil::com_ptr_nothrow moniker; - while (enumMoniker->Next(1, &moniker, &_) == S_OK) - { - LOG("Inspecting moniker"); - VideoCaptureDeviceInfo deviceInfo; - - wil::com_ptr_nothrow propertyData; - moniker->BindToStorage(nullptr, nullptr, IID_IPropertyBag, reinterpret_cast(&propertyData)); - if (!propertyData) - { - LOG("BindToStorage failed"); - continue; - } - - wil::unique_variant propVal; - propVal.vt = VT_BSTR; - - if (FAILED(propertyData->Read(L"FriendlyName", &propVal, nullptr))) - { - LOG("Couldn't obtain FriendlyName property"); - continue; - } - - deviceInfo.friendlyName = { propVal.bstrVal, SysStringLen(propVal.bstrVal) }; - LOG(deviceInfo.friendlyName); - - propVal.reset(); - propVal.vt = VT_BSTR; - - if (FAILED(propertyData->Read(L"DevicePath", &propVal, nullptr))) - { - LOG("Couldn't obtain DevicePath property"); - continue; - } - deviceInfo.devicePath = { propVal.bstrVal, SysStringLen(propVal.bstrVal) }; - - wil::com_ptr_nothrow filter; - moniker->BindToObject(nullptr, nullptr, IID_IBaseFilter, reinterpret_cast(&filter)); - if (!filter) - { - LOG("Couldn't BindToObject"); - continue; - } - - wil::com_ptr_nothrow pinsEnum; - if (FAILED(filter->EnumPins(&pinsEnum))) - { - LOG("BindToObject EnumPins"); - continue; - } - - wil::com_ptr_nothrow pin; - while (pinsEnum->Next(1, &pin, &_) == S_OK) - { - LOG("Inspecting pin"); - // Skip pins which do not belong to capture category - GUID category{}; - DWORD __; - if (auto props = pin.try_copy(); - !props || - FAILED(props->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, nullptr, 0, &category, sizeof(GUID), &__)) || - category != PIN_CATEGORY_CAPTURE) - { - continue; - } - - // Skip non-output pins - if (PIN_DIRECTION direction = {}; FAILED(pin->QueryDirection(&direction)) || direction != PINDIR_OUTPUT) - { - continue; - } - - LOG("Found a pin of suitable category and direction, selecting format"); - auto bestFormat = SelectBestMediaType(pin); - if (!bestFormat) - { - continue; - } - - deviceInfo.captureOutputPin = std::move(pin); - deviceInfo.bestFormat = std::move(bestFormat.value()); - deviceInfo.captureOutputFilter = std::move(filter); - devices.emplace_back(std::move(deviceInfo)); - } - } - - return devices; -} - -std::optional VideoCaptureDevice::Create(VideoCaptureDeviceInfo&& vdi, callback_t callback) -{ - VERBOSE_LOG; - VideoCaptureDevice result; - - result._graph = wil::CoCreateInstanceNoThrow(CLSID_FilterGraph); - result._builder = wil::CoCreateInstanceNoThrow(CLSID_CaptureGraphBuilder2); - if (!result._graph || !result._builder) - { - return std::nullopt; - } - - if (FAILED(result._builder->SetFiltergraph(result._graph.get()))) - { - return std::nullopt; - } - - result._control = result._graph.try_query(); - if (!result._control) - { - return std::nullopt; - } - - auto pinConfig = vdi.captureOutputPin.try_query(); - if (!pinConfig) - { - return std::nullopt; - } - - if (FAILED(pinConfig->SetFormat(vdi.bestFormat.mediaType.get()))) - { - return std::nullopt; - } - - auto captureInputFilter = winrt::make_self(); - auto receiverPin = winrt::make_self(std::move(vdi.bestFormat.mediaType), captureInputFilter.get()); - receiverPin->_frameCallback = std::move(callback); - captureInputFilter->_videoReceiverPin.attach(receiverPin.get()); - auto detachReceiverPin = wil::scope_exit([&receiverPin]() { receiverPin.detach(); }); - - if (FAILED(result._graph->AddFilter(captureInputFilter.get(), nullptr))) - { - return std::nullopt; - } - - if (FAILED(result._graph->AddFilter(vdi.captureOutputFilter.get(), nullptr))) - { - return std::nullopt; - } - - if (FAILED(result._graph->ConnectDirect(vdi.captureOutputPin.get(), captureInputFilter->_videoReceiverPin.get(), nullptr))) - { - return std::nullopt; - } - - result._allocator = receiverPin->_allocator; - return std::make_optional(std::move(result)); -} - -bool VideoCaptureDevice::StartCapture() -{ - VERBOSE_LOG; - return SUCCEEDED(_control->Run()); -} - -bool VideoCaptureDevice::StopCapture() -{ - VERBOSE_LOG; - return SUCCEEDED(_control->Stop()); -} - -VideoCaptureDevice::~VideoCaptureDevice() -{ - StopCapture(); -} diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.h b/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.h deleted file mode 100644 index 3af63691a6..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureDevice.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once -#include -#define WIN32_LEAN_AND_MEAN - -#include -#include - -#include - -#include -#include -#include -#include - -#include "DirectShowUtils.h" - -struct VideoStreamFormat -{ - long width = 0; - long height = 0; - REFERENCE_TIME avgFrameTime = std::numeric_limits::max(); - unique_media_type_ptr mediaType; - - VideoStreamFormat() = default; - - VideoStreamFormat(const VideoStreamFormat&) = delete; - VideoStreamFormat& operator=(const VideoStreamFormat&) = delete; - - VideoStreamFormat(VideoStreamFormat&&) = default; - VideoStreamFormat& operator=(VideoStreamFormat&&) = default; -}; - -struct VideoCaptureDeviceInfo -{ - std::wstring friendlyName; - std::wstring devicePath; - wil::com_ptr_nothrow captureOutputPin; - wil::com_ptr_nothrow captureOutputFilter; - VideoStreamFormat bestFormat; -}; - -class VideoCaptureDevice final -{ -public: - wil::com_ptr_nothrow _allocator; - - using callback_t = std::function; - - static std::vector ListAll(); - static std::optional Create(VideoCaptureDeviceInfo&& vdi, callback_t callback); - - bool StartCapture(); - bool StopCapture(); - - ~VideoCaptureDevice(); - -private: - wil::com_ptr_nothrow _graph; - wil::com_ptr_nothrow _builder; - wil::com_ptr_nothrow _control; - callback_t _callback; -}; diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureProxyFilter.cpp b/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureProxyFilter.cpp deleted file mode 100644 index 2a860a72fa..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureProxyFilter.cpp +++ /dev/null @@ -1,937 +0,0 @@ -#include "VideoCaptureProxyFilter.h" - -#include "VideoCaptureDevice.h" -#include -#include -#include -#include - -constexpr static inline wchar_t FILTER_NAME[] = L"PowerToysVCMProxyFilter"; -constexpr static inline wchar_t PIN_NAME[] = L"PowerToysVCMProxyPIN"; -constexpr static inline wchar_t VENDOR[] = L"Microsoft Corporation"; - -namespace -{ - constexpr float initialJpgQuality = 0.5f; - constexpr std::array overlayColor = { 0, 0, 0 }; - // clang-format off - unsigned char bmpPixelData[58] = { - 0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, - 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, overlayColor[0], overlayColor[1], overlayColor[2], 0x00 - }; - // clang-format on -} - -wil::com_ptr_nothrow VideoCaptureProxyPin::FindAllocator() -{ - auto allocator = GetPinAllocator(_connectedInputPin); - if (!allocator && _owningFilter->_captureDevice) - { - allocator = _owningFilter->_captureDevice->_allocator; - } - - return allocator; -} - -wil::com_ptr_nothrow LoadImageAsSample(wil::com_ptr_nothrow imageStream, - IMFMediaType* sampleMediaType, - const float quality) noexcept; -bool ReencodeJPGImage(BYTE* imageBuf, const DWORD imageSize, DWORD& reencodedSize); - -HRESULT VideoCaptureProxyPin::Connect(IPin* pReceivePin, const AM_MEDIA_TYPE*) -{ - if (!pReceivePin) - { - LOG("VideoCaptureProxyPin::Connect FAILED pReceivePin"); - return E_POINTER; - } - - if (_owningFilter->_state == State_Running) - { - LOG("VideoCaptureProxyPin::Connect FAILED _owningFilter->_state"); - return VFW_E_NOT_STOPPED; - } - - if (_connectedInputPin) - { - LOG("VideoCaptureProxyPin::Connect FAILED _connectedInputPin"); - return VFW_E_ALREADY_CONNECTED; - } - - if (FAILED(pReceivePin->ReceiveConnection(this, _mediaFormat.get()))) - { - LOG("VideoCaptureProxyPin::Connect FAILED pReceivePin->ReceiveConnection"); - return E_POINTER; - } - - _connectedInputPin = pReceivePin; - - auto memInput = _connectedInputPin.try_query(); - if (!memInput) - { - LOG("VideoCaptureProxyPin::Connect FAILED _connectedInputPin.try_query"); - return VFW_E_NO_TRANSPORT; - } - - auto allocator = FindAllocator(); - if (allocator == nullptr) - { - LOG("VideoCaptureProxyPin::Connect FAILED FindAllocator"); - return VFW_E_NO_TRANSPORT; - } - - if (FAILED(memInput->NotifyAllocator(allocator.get(), false))) - { - LOG("VideoCaptureProxyPin::Connect FAILED memInput->NotifyAllocator"); - return VFW_E_NO_TRANSPORT; - } - - return S_OK; -} - -HRESULT VideoCaptureProxyPin::ReceiveConnection(IPin*, const AM_MEDIA_TYPE*) -{ - return S_OK; -} - -HRESULT VideoCaptureProxyPin::Disconnect(void) -{ - if (!_connectedInputPin) - { - LOG("VideoCaptureProxyPin::Disconnect FAILED _connectedInputPin"); - return S_FALSE; - } - - _connectedInputPin.reset(); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::ConnectedTo(IPin** pPin) -{ - if (!_connectedInputPin) - { - *pPin = nullptr; - return VFW_E_NOT_CONNECTED; - } - - return _connectedInputPin.try_copy_to(pPin) ? S_OK : E_FAIL; -} - -HRESULT VideoCaptureProxyPin::ConnectionMediaType(AM_MEDIA_TYPE* pmt) -{ - if (!_connectedInputPin) - { - LOG("VideoCaptureProxyPin::ConnectionMediaType FAILED _connectedInputPin"); - return VFW_E_NOT_CONNECTED; - } - - *pmt = *CopyMediaType(_mediaFormat.get()).release(); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::QueryPinInfo(PIN_INFO* pInfo) -{ - if (!pInfo) - { - LOG("VideoCaptureProxyPin::QueryPinInfo FAILED pInfo"); - return E_POINTER; - } - - pInfo->pFilter = _owningFilter; - if (_owningFilter) - { - _owningFilter->AddRef(); - } - - if (_mediaFormat->majortype == MEDIATYPE_Video) - { - std::copy(std::begin(PIN_NAME), std::end(PIN_NAME), pInfo->achName); - } - - pInfo->dir = PINDIR_OUTPUT; - return S_OK; -} - -HRESULT VideoCaptureProxyPin::QueryDirection(PIN_DIRECTION* pPinDir) -{ - if (!pPinDir) - { - LOG("VideoCaptureProxyPin::QueryDirection FAILED pPinDir"); - return E_POINTER; - } - - *pPinDir = PINDIR_OUTPUT; - return S_OK; -} - -HRESULT VideoCaptureProxyPin::QueryId(LPWSTR* Id) -{ - if (!Id) - { - LOG("VideoCaptureProxyPin::QueryId FAILED Id"); - return E_POINTER; - } - - *Id = static_cast(CoTaskMemAlloc(sizeof(PIN_NAME))); - std::copy(std::begin(PIN_NAME), std::end(PIN_NAME), *Id); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::QueryAccept(const AM_MEDIA_TYPE*) -{ - return S_OK; -} - -HRESULT VideoCaptureProxyPin::EnumMediaTypes(IEnumMediaTypes** ppEnum) -{ - if (!ppEnum) - { - LOG("VideoCaptureProxyPin::EnumMediaTypes FAILED ppEnum"); - return E_POINTER; - } - - *ppEnum = nullptr; - - auto enumerator = winrt::make_self(); - enumerator->_objects.emplace_back(CopyMediaType(_mediaFormat.get())); - *ppEnum = enumerator.detach(); - - return S_OK; -} - -HRESULT VideoCaptureProxyPin::QueryInternalConnections(IPin** pins, ULONG*) -{ - if (pins) - { - *pins = nullptr; - } - return E_NOTIMPL; -} - -HRESULT VideoCaptureProxyPin::EndOfStream(void) -{ - return S_OK; -} - -HRESULT VideoCaptureProxyPin::BeginFlush(void) -{ - _flushing = true; - return S_OK; -} - -HRESULT VideoCaptureProxyPin::EndFlush(void) -{ - _flushing = false; - return S_OK; -} - -HRESULT VideoCaptureProxyPin::NewSegment(REFERENCE_TIME, REFERENCE_TIME, double) -{ - return S_OK; -} - -HRESULT VideoCaptureProxyPin::SetFormat(AM_MEDIA_TYPE* pmt) -{ - if (pmt == nullptr) - { - return S_OK; - } - - _mediaFormat = CopyMediaType(pmt); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::GetFormat(AM_MEDIA_TYPE** ppmt) -{ - if (!ppmt) - { - LOG("VideoCaptureProxyPin::GetFormat FAILED ppmt"); - return E_POINTER; - } - *ppmt = CopyMediaType(_mediaFormat.get()).release(); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::GetNumberOfCapabilities(int* piCount, int* piSize) -{ - if (!piCount || !piSize) - { - LOG("VideoCaptureProxyPin::GetNumberOfCapabilities FAILED piCount || piSize"); - return E_POINTER; - } - - *piCount = 1; - *piSize = sizeof(VIDEO_STREAM_CONFIG_CAPS); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::GetStreamCaps(int iIndex, AM_MEDIA_TYPE** ppmt, BYTE* pSCC) -{ - if (!ppmt || !pSCC) - { - LOG("VideoCaptureProxyPin::GetStreamCaps FAILED ppmt || pSCC"); - return E_POINTER; - } - - if (iIndex != 0) - { - LOG("VideoCaptureProxyPin::GetStreamCaps FAILED iIndex"); - return S_FALSE; - } - - VIDEOINFOHEADER* vih = reinterpret_cast(_mediaFormat->pbFormat); - - VIDEO_STREAM_CONFIG_CAPS caps{}; - caps.guid = FORMAT_VideoInfo; - caps.MinFrameInterval = vih->AvgTimePerFrame; - caps.MaxFrameInterval = vih->AvgTimePerFrame; - caps.MinOutputSize.cx = vih->bmiHeader.biWidth; - caps.MinOutputSize.cy = vih->bmiHeader.biHeight; - caps.MaxOutputSize = caps.MinOutputSize; - caps.InputSize = caps.MinOutputSize; - caps.MinCroppingSize = caps.MinOutputSize; - caps.MaxCroppingSize = caps.MinOutputSize; - caps.CropGranularityX = vih->bmiHeader.biWidth; - caps.CropGranularityY = vih->bmiHeader.biHeight; - caps.MinBitsPerSecond = vih->dwBitRate; - caps.MaxBitsPerSecond = caps.MinBitsPerSecond; - - *ppmt = CopyMediaType(_mediaFormat.get()).release(); - - const auto caps_begin = reinterpret_cast(&caps); - std::copy(caps_begin, caps_begin + sizeof(caps), pSCC); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::Set(REFGUID, DWORD, LPVOID, DWORD, LPVOID, DWORD) -{ - return E_NOTIMPL; -} - -HRESULT VideoCaptureProxyPin::Get( - REFGUID guidPropSet, - DWORD dwPropID, - LPVOID, - DWORD, - LPVOID pPropData, - DWORD cbPropData, - DWORD* pcbReturned) -{ - if (guidPropSet != AMPROPSETID_Pin) - { - LOG("VideoCaptureProxyPin::Get FAILED guidPropSet"); - return E_PROP_SET_UNSUPPORTED; - } - - if (dwPropID != AMPROPERTY_PIN_CATEGORY) - { - LOG("VideoCaptureProxyPin::Get FAILED dwPropID"); - return E_PROP_ID_UNSUPPORTED; - } - - if (!pPropData) - { - LOG("VideoCaptureProxyPin::Get FAILED pPropData || pcbReturned"); - return E_POINTER; - } - - if (pcbReturned) - { - *pcbReturned = sizeof(GUID); - } - - if (cbPropData < sizeof(GUID)) - { - LOG("VideoCaptureProxyPin::Get FAILED cbPropData"); - return E_UNEXPECTED; - } - - *static_cast(pPropData) = PIN_CATEGORY_CAPTURE; - - LOG("VideoCaptureProxyPin::Get SUCCESS"); - return S_OK; -} - -HRESULT VideoCaptureProxyPin::QuerySupported(REFGUID guidPropSet, DWORD dwPropID, DWORD* pTypeSupport) -{ - if (guidPropSet != AMPROPSETID_Pin) - { - LOG("VideoCaptureProxyPin::QuerySupported FAILED guidPropSet"); - return E_PROP_SET_UNSUPPORTED; - } - - if (dwPropID != AMPROPERTY_PIN_CATEGORY) - { - LOG("VideoCaptureProxyPin::QuerySupported FAILED dwPropID"); - return E_PROP_ID_UNSUPPORTED; - } - - if (pTypeSupport) - { - *pTypeSupport = KSPROPERTY_SUPPORT_GET; - } - - return S_OK; -} - -long GetImageSize(wil::com_ptr_nothrow& image) -{ - if (!image) - { - return 0; - } - - DWORD imageSize = 0; - wil::com_ptr_nothrow imageBuf; - - OK_OR_BAIL(image->GetBufferByIndex(0, &imageBuf)); - OK_OR_BAIL(imageBuf->GetCurrentLength(&imageSize)); - return imageSize; -} - -void ReencodeFrame(IMediaSample* frame) -{ - BYTE* frameData = nullptr; - frame->GetPointer(&frameData); - if (!frameData) - { - LOG("VideoCaptureProxyPin::ReencodeFrame FAILED frameData"); - return; - } - const DWORD frameSize = frame->GetSize(); - DWORD reencodedSize = 0; - if (!ReencodeJPGImage(frameData, frameSize, reencodedSize)) - { - LOG("VideoCaptureProxyPin::ReencodeJPGImage FAILED"); - return; - } - frame->SetActualDataLength(reencodedSize); -} - -bool OverwriteFrame(IMediaSample* frame, wil::com_ptr_nothrow& image) -{ - if (!image) - { - return false; - } - - BYTE* frameData = nullptr; - frame->GetPointer(&frameData); - if (!frameData) - { - LOG("VideoCaptureProxyPin::OverwriteFrame FAILED frameData"); - return false; - } - - wil::com_ptr_nothrow imageBuf; - const DWORD frameSize = frame->GetSize(); - - image->GetBufferByIndex(0, &imageBuf); - if (!imageBuf) - { - LOG("VideoCaptureProxyPin::OverwriteFrame FAILED imageBuf"); - return false; - } - - BYTE* imageData = nullptr; - DWORD _ = 0, imageSize = 0; - imageBuf->Lock(&imageData, &_, &imageSize); - if (!imageData) - { - LOG("VideoCaptureProxyPin::OverwriteFrame FAILED imageData"); - return false; - } - - if (imageSize > frameSize && failed(frame->SetActualDataLength(imageSize))) - { - char buf[512]{}; - sprintf_s(buf, "VideoCaptureProxyPin::OverwriteFrame FAILED overlay image size %lu is larger than frame size %lu", imageSize, frameSize); - LOG(buf); - imageBuf->Unlock(); - return false; - } - - std::copy(imageData, imageData + imageSize, frameData); - imageBuf->Unlock(); - frame->SetActualDataLength(imageSize); - - return true; -} - -//#define DEBUG_FRAME_DATA -//#define DEBUG_OVERWRITE_FRAME -//#define DEBUG_REENCODE_JPG_DATA - -#if defined(DEBUG_OVERWRITE_FRAME) -void DebugOverwriteFrame(IMediaSample* frame, std::string_view filepath) -{ - std::ifstream file{ filepath.data(), std::ios::binary }; - std::streampos fileSize = 0; - fileSize = file.tellg(); - file.seekg(0, std::ios::end); - fileSize = file.tellg() - fileSize; - - BYTE* frameData = nullptr; - if (!frame) - { - LOG("null frame provided"); - return; - } - frame->GetPointer(&frameData); - const DWORD frameSize = frame->GetSize(); - - if (fileSize > frameSize || !frameData) - { - LOG("frame can't be filled with data"); - return; - } - file.read((char*)frameData, fileSize); - frame->SetActualDataLength((long)fileSize); - LOG("DebugOverwriteFrame success"); -} - -#endif - -#if defined(DEBUG_FRAME_DATA) -#include - -namespace fs = std::filesystem; - -void DumpSample(IMediaSample* frame, const std::string_view filename) -{ - BYTE* data = nullptr; - frame->GetPointer(&data); - if (!data) - { - LOG("Couldn't get sample pointer"); - return; - } - const long nBytes = frame->GetActualDataLength(); - std::ofstream file{ fs::temp_directory_path() / filename, std::ios::binary }; - file.write((const char*)data, nBytes); -} -#endif - -VideoCaptureProxyFilter::VideoCaptureProxyFilter() : - _worker_thread{ - std::thread{ - [this]() { - using namespace std::chrono_literals; - const auto uninitializedSleepInterval = 15ms; - std::vector lowerJpgQualityModes = { 0.1f, 0.25f }; - while (!_shutdown_request) - { - std::unique_lock lock{ _worker_mutex }; - _worker_cv.wait(lock, [this] { return _pending_frame != nullptr || _shutdown_request; }); - - if (!_outPin || !_outPin->_connectedInputPin) - { - lock.unlock(); - std::this_thread::sleep_for(uninitializedSleepInterval); - continue; - } - - auto input = _outPin->_connectedInputPin.try_query(); - if (!input) - { - continue; - } - - IMediaSample* sample = _pending_frame; - if (!sample) - { - continue; - } -#if defined(DEBUG_FRAME_DATA) - static bool realFrameSaved = false; - if (!realFrameSaved) - { - DumpSample(sample, "PowerToysVCMRealFrame.binary"); - realFrameSaved = true; - } -#endif - auto newSettings = SyncCurrentSettings(); - if (newSettings.webcamDisabled) - { -#if !defined(DEBUG_OVERWRITE_FRAME) - bool overwritten = OverwriteFrame(_pending_frame, _overlayImage ? _overlayImage : _blankImage); - while (!overwritten && _overlayImage) - { - _overlayImage.reset(); - newSettings = SyncCurrentSettings(); - if (!lowerJpgQualityModes.empty() && newSettings.overlayImage) - { - const float quality = lowerJpgQualityModes.back(); - lowerJpgQualityModes.pop_back(); - char buf[512]{}; - sprintf_s(buf, "Reload overlay image with quality %f", quality); - LOG(buf); - _overlayImage = LoadImageAsSample(newSettings.overlayImage, _targetMediaType.get(), quality); - overwritten = OverwriteFrame(_pending_frame, _overlayImage); - } - else - { - LOG("Couldn't overwrite frame with image with all available quality modes."); - } - } -#if defined(DEBUG_FRAME_DATA) - static bool overlayFrameSaved = false; - if (!overlayFrameSaved && _overlayImage && overwritten) - { - DumpSample(sample, "PowerToysVCMOverlayImageFrame.binary"); - overlayFrameSaved = true; - } -#endif - if (!overwritten && !_overlayImage) - { - OverwriteFrame(_pending_frame, _blankImage); - } -#else - DebugOverwriteFrame(_pending_frame, "R:\\frame.data"); -#endif - } -#if defined(DEBUG_REENCODE_JPG_DATA) - else - { - GUID subtype{}; - _targetMediaType->GetGUID(MF_MT_SUBTYPE, &subtype); - if (subtype == MFVideoFormat_MJPG) - { - ReencodeFrame(_pending_frame); - } - } -#endif - - _pending_frame = nullptr; - input->Receive(sample); - sample->Release(); - } - } } - } -{ -} - -HRESULT VideoCaptureProxyFilter::Stop(void) -{ - if (_state != State_Stopped && _captureDevice) - { - _captureDevice->StopCapture(); - } - - _state = State_Stopped; - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::Pause(void) -{ - if (_state == State_Stopped) - { - std::unique_lock lock{ _worker_mutex }; - - if (!_outPin) - { - LOG("VideoCaptureProxyPin::Pause FAILED _outPin"); - return VFW_E_NO_TRANSPORT; - } - - auto allocator = _outPin->FindAllocator(); - if (!allocator) - { - LOG("VideoCaptureProxyPin::Pause FAILED allocator"); - return VFW_E_NO_TRANSPORT; - } - - allocator->Commit(); - } - - _state = State_Paused; - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::Run(REFERENCE_TIME) -{ - _state = State_Running; - if (_captureDevice) - { - _captureDevice->StartCapture(); - } - - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::GetState(DWORD, FILTER_STATE* State) -{ - *State = _state; - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::SetSyncSource(IReferenceClock* pClock) -{ - _clock = pClock; - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::GetSyncSource(IReferenceClock** pClock) -{ - if (!pClock) - { - return E_POINTER; - } - *pClock = nullptr; - return _clock.try_copy_to(pClock) ? S_OK : E_FAIL; -} - -GUID MapDShowSubtypeToMFT(const GUID& dshowSubtype) -{ - if (dshowSubtype == MEDIASUBTYPE_YUY2) - { - return MFVideoFormat_YUY2; - } - else if (dshowSubtype == MEDIASUBTYPE_MJPG) - { - return MFVideoFormat_MJPG; - } - else if (dshowSubtype == MEDIASUBTYPE_RGB24) - { - return MFVideoFormat_RGB24; - } - else - { - LOG("MapDShowSubtypeToMFT: Unsupported media type format provided!"); - return MFVideoFormat_MJPG; - } -} - -HRESULT VideoCaptureProxyFilter::EnumPins(IEnumPins** ppEnum) -{ - if (!ppEnum) - { - LOG("VideoCaptureProxyFilter::EnumPins null arg provided"); - return E_POINTER; - } - *ppEnum = nullptr; - auto enumerator = winrt::make_self>(); - auto detached_enumerator = enumerator.detach(); - *ppEnum = detached_enumerator; - - std::unique_lock lock{ _worker_mutex }; - - // We cannot initialize capture device and outpin during VideoCaptureProxyFilter ctor - // since that results in a deadlock -> initializing now. - if (!_outPin) - { - LOG("VideoCaptureProxyFilter::EnumPins started pin initialization"); - const auto newSettings = SyncCurrentSettings(); - std::vector webcams; - webcams = VideoCaptureDevice::ListAll(); - if (webcams.empty()) - { - LOG("VideoCaptureProxyFilter::EnumPins no physical webcams found"); - return E_FAIL; - } - - std::optional selectedCamIdx; - for (size_t i = 0; i < size(webcams); ++i) - { - if (newSettings.newCameraName == webcams[i].friendlyName) - { - selectedCamIdx = i; - LOG("VideoCaptureProxyFilter::EnumPins webcam selected using settings"); - break; - } - } - - if (!selectedCamIdx) - { - for (size_t i = 0; i < size(webcams); ++i) - { - if (newSettings.newCameraName != CAMERA_NAME) - { - LOG("VideoCaptureProxyFilter::EnumPins webcam selected using first fit"); - selectedCamIdx = i; - break; - } - } - } - - if (!selectedCamIdx) - { - LOG("VideoCaptureProxyFilter::EnumPins FAILED webcam couldn't be selected"); - return E_FAIL; - } - - auto& webcam = webcams[*selectedCamIdx]; - auto pin = winrt::make_self(); - pin->_mediaFormat = CopyMediaType(webcam.bestFormat.mediaType.get()); - pin->_owningFilter = this; - _outPin.attach(pin.detach()); - - auto frameCallback = [this](IMediaSample* sample) { - std::unique_lock lock{ _worker_mutex }; - sample->AddRef(); - _pending_frame = sample; - _worker_cv.notify_one(); - }; - - _targetMediaType.reset(); - MFCreateMediaType(&_targetMediaType); - _targetMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); - _targetMediaType->SetGUID(MF_MT_SUBTYPE, MapDShowSubtypeToMFT(webcam.bestFormat.mediaType->subtype)); - _targetMediaType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive); - _targetMediaType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE); - MFSetAttributeSize( - _targetMediaType.get(), MF_MT_FRAME_SIZE, webcam.bestFormat.width, webcam.bestFormat.height); - MFSetAttributeRatio(_targetMediaType.get(), MF_MT_PIXEL_ASPECT_RATIO, 1, 1); - - _captureDevice = VideoCaptureDevice::Create(std::move(webcam), std::move(frameCallback)); - if (_captureDevice) - { - if (!_blankImage) - { - wil::com_ptr_nothrow blackBMPImage = SHCreateMemStream(bmpPixelData, sizeof(bmpPixelData)); - _blankImage = LoadImageAsSample(blackBMPImage, _targetMediaType.get(), initialJpgQuality); - } - - _overlayImage = LoadImageAsSample(newSettings.overlayImage, _targetMediaType.get(), initialJpgQuality); - LOG("VideoCaptureProxyFilter::EnumPins capture device created successfully"); - } - else - { - LOG("VideoCaptureProxyFilter::EnumPins FAILED couldn't create capture device"); - } - } - - detached_enumerator->_objects.emplace_back(_outPin); - - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::FindPin(LPCWSTR, IPin** pin) -{ - if (pin) - { - *pin = nullptr; - } - return E_NOTIMPL; -} - -HRESULT VideoCaptureProxyFilter::QueryFilterInfo(FILTER_INFO* pInfo) -{ - if (!pInfo) - { - LOG("VideoCaptureProxyPin::QueryFilterInfo FAILED pInfo"); - return E_POINTER; - } - - VERBOSE_LOG; - std::copy(std::begin(FILTER_NAME), std::end(FILTER_NAME), pInfo->achName); - - pInfo->pGraph = _graph; - if (_graph) - { - _graph->AddRef(); - } - - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR) -{ - _graph = pGraph; - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::QueryVendorInfo(LPWSTR* pVendorInfo) -{ - auto info = static_cast(CoTaskMemAlloc(sizeof(VENDOR))); - std::copy(std::begin(VENDOR), std::end(VENDOR), info); - *pVendorInfo = info; - return S_OK; -} - -HRESULT VideoCaptureProxyFilter::GetClassID(CLSID*) -{ - return E_NOTIMPL; -} - -ULONG VideoCaptureProxyFilter::GetMiscFlags(void) -{ - return AM_FILTER_MISC_FLAGS_IS_SOURCE; -} - -VideoCaptureProxyFilter::~VideoCaptureProxyFilter() -{ - VERBOSE_LOG; - _shutdown_request = true; - - _worker_cv.notify_one(); - _worker_thread.join(); - if (_settingsUpdateChannel) - { - _settingsUpdateChannel->access([](auto settingsMemory) { - auto settings = reinterpret_cast(settingsMemory._data); - settings->cameraInUse = false; - }); - } -} - -VideoCaptureProxyFilter::SyncedSettings VideoCaptureProxyFilter::SyncCurrentSettings() -{ - SyncedSettings result; - if (!_settingsUpdateChannel.has_value()) - { - _settingsUpdateChannel = SerializedSharedMemory::open(CameraSettingsUpdateChannel::endpoint(), sizeof(CameraSettingsUpdateChannel), false); - } - - if (!_settingsUpdateChannel) - { - return result; - } - - _settingsUpdateChannel->access([this, &result](auto settingsMemory) { - auto settings = reinterpret_cast(settingsMemory._data); - bool cameraNameUpdated = false; - result.webcamDisabled = settings->useOverlayImage; - - settings->cameraInUse = true; - - if (settings->sourceCameraName.has_value()) - { - std::wstring_view newCameraNameView{ settings->sourceCameraName->data() }; - if (!_currentSourceCameraName.has_value() || *_currentSourceCameraName != newCameraNameView) - { - cameraNameUpdated = true; - result.newCameraName = newCameraNameView; - } - } - - if (!settings->overlayImageSize.has_value()) - { - return; - } - - if (settings->newOverlayImagePosted || !_overlayImage) - { - auto imageChannel = - SerializedSharedMemory::open(CameraOverlayImageChannel::endpoint(), *settings->overlayImageSize, true); - if (!imageChannel) - { - return; - } - - imageChannel->access([this, settings, &result](auto imageMemory) { - result.overlayImage = SHCreateMemStream(imageMemory._data, static_cast(imageMemory._size)); - if (!result.overlayImage) - { - return; - } - - settings->newOverlayImagePosted = false; - }); - } - }); - return result; -} diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureProxyFilter.h b/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureProxyFilter.h deleted file mode 100644 index 58f49f032a..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoCaptureProxyFilter.h +++ /dev/null @@ -1,120 +0,0 @@ -#pragma once - -#include - -#define WIN32_LEAN_AND_MEAN -#include -#include - -#include -#include -#include - -#include -#include - -#include "VideoCaptureDevice.h" - -#include -#include - -struct VideoCaptureProxyPin; -struct IMFSample; -struct IMFMediaType; - -inline const wchar_t CAMERA_NAME[] = L"PowerToys VideoConference Mute"; - -struct VideoCaptureProxyFilter : winrt::implements -{ - // BLOCK START: member accessed concurrently - wil::com_ptr_nothrow _outPin; - IMediaSample* _pending_frame = nullptr; - std::atomic_bool _shutdown_request = false; - std::optional _settingsUpdateChannel; - std::optional _currentSourceCameraName; - wil::com_ptr_nothrow _blankImage; - wil::com_ptr_nothrow _overlayImage; - wil::com_ptr_nothrow _targetMediaType; - // BLOCK END: member accessed concurrently - - std::mutex _worker_mutex; - std::condition_variable _worker_cv; - - FILTER_STATE _state = State_Stopped; - wil::com_ptr_nothrow _clock; - IFilterGraph* _graph = nullptr; - std::optional _captureDevice; - - std::thread _worker_thread; - - VideoCaptureProxyFilter(); - ~VideoCaptureProxyFilter(); - - struct SyncedSettings - { - bool webcamDisabled = false; - std::wstring newCameraName; - wil::com_ptr_nothrow overlayImage; - }; - - SyncedSettings SyncCurrentSettings(); - - HRESULT STDMETHODCALLTYPE Stop(void) override; - HRESULT STDMETHODCALLTYPE Pause(void) override; - HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart) override; - HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE* State) override; - HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock* pClock) override; - HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock** pClock) override; - HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins** ppEnum) override; - HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin** ppPin) override; - HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO* pInfo) override; - HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName) override; - HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR* pVendorInfo) override; - - HRESULT STDMETHODCALLTYPE GetClassID(CLSID* pClassID) override; - ULONG STDMETHODCALLTYPE GetMiscFlags(void) override; -}; -struct VideoCaptureProxyPin : winrt::implements -{ - VideoCaptureProxyFilter* _owningFilter = nullptr; - wil::com_ptr_nothrow _connectedInputPin; - unique_media_type_ptr _mediaFormat; - std::atomic_bool _flushing = false; - - HRESULT STDMETHODCALLTYPE Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt) override; - HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt) override; - HRESULT STDMETHODCALLTYPE Disconnect(void) override; - HRESULT STDMETHODCALLTYPE ConnectedTo(IPin** pPin) override; - HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE* pmt) override; - HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO* pInfo) override; - HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION* pPinDir) override; - HRESULT STDMETHODCALLTYPE QueryId(LPWSTR* Id) override; - HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE* pmt) override; - HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes** ppEnum) override; - HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin** apPin, ULONG* nPin) override; - HRESULT STDMETHODCALLTYPE EndOfStream(void) override; - HRESULT STDMETHODCALLTYPE BeginFlush(void) override; - HRESULT STDMETHODCALLTYPE EndFlush(void) override; - HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) override; - - HRESULT STDMETHODCALLTYPE SetFormat(AM_MEDIA_TYPE* pmt) override; - HRESULT STDMETHODCALLTYPE GetFormat(AM_MEDIA_TYPE** ppmt) override; - HRESULT STDMETHODCALLTYPE GetNumberOfCapabilities(int* piCount, int* piSize) override; - HRESULT STDMETHODCALLTYPE GetStreamCaps(int iIndex, AM_MEDIA_TYPE** ppmt, BYTE* pSCC) override; - HRESULT STDMETHODCALLTYPE Set(REFGUID guidPropSet, - DWORD dwPropID, - LPVOID pInstanceData, - DWORD cbInstanceData, - LPVOID pPropData, - DWORD cbPropData) override; - HRESULT STDMETHODCALLTYPE Get(REFGUID guidPropSet, - DWORD dwPropID, - LPVOID pInstanceData, - DWORD cbInstanceData, - LPVOID pPropData, - DWORD cbPropData, - DWORD* pcbReturned) override; - HRESULT STDMETHODCALLTYPE QuerySupported(REFGUID guidPropSet, DWORD dwPropID, DWORD* pTypeSupport) override; - - wil::com_ptr_nothrow FindAllocator(); -}; diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilter.rc b/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilter.rc deleted file mode 100644 index 1a2f62db5e..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilter.rc +++ /dev/null @@ -1,47 +0,0 @@ -#ifdef _WIN64 - #include "resource.h" -#else - #include "resource.x86.h" -#endif - -#include - -#include "../../../common/version/version.h" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -1 VERSIONINFO -FILEVERSION FILE_VERSION -PRODUCTVERSION PRODUCT_VERSION -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG -FILEFLAGS VS_FF_DEBUG -#else -FILEFLAGS 0x0L -#endif -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" // US English (0x0409), Unicode (0x04B0) charset - BEGIN - VALUE "CompanyName", COMPANY_NAME - VALUE "FileDescription", FILE_DESCRIPTION - VALUE "FileVersion", FILE_VERSION_STRING - VALUE "InternalName", INTERNAL_NAME - VALUE "LegalCopyright", COPYRIGHT_NOTE - VALUE "OriginalFilename", ORIGINAL_FILENAME - VALUE "ProductName", PRODUCT_NAME - VALUE "ProductVersion", PRODUCT_VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 // US English (0x0409), Unicode (1200) charset - END -END diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilter.vcxproj b/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilter.vcxproj deleted file mode 100644 index fd8525072f..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilter.vcxproj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Debug - ARM64 - - - Release - Win32 - - - Release - x64 - - - Release - ARM64 - - - - 16.0 - {AC2857B4-103D-4D6D-9740-926EBF785042} - Win32Proj - VideoConferenceProxyFilter - VideoConferenceProxyFilter - - - - DynamicLibrary - - - v143 - - - v143 - - - v143 - - - v143 - - - - $(SolutionDir)\src\;$(ProjectDir)..\..\..\ - Level4 - - - - - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - Console - true - - - true - - - - - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(SolutionDir)\src\; - - - Console - - - true - - - call "$(ProjectDir)build_vcm_x86.cmd" - - - - ..\..\..\..\$(Platform)\$(Configuration)\ - PowerToys.VideoConferenceProxyFilter_$(Platform) - - - ..\..\..\..\x86\$(Configuration)\ - PowerToys.VideoConferenceProxyFilter_x86 - - - - - - - - - - ..\VideoConferenceShared\;%(AdditionalIncludeDirectories) - _LIB;NOMINMAX;%(PreprocessorDefinitions) - NotUsing - MultiThreaded - MultiThreadedDebug - - - $(OutDir)VideoConferenceShared.lib;Windowscodecs.lib;Wtsapi32.lib;mfplat.lib;WindowsApp.lib;Mfsensorgroup.lib;Mf.lib;Shlwapi.lib;Strmiids.lib;%(AdditionalDependencies); - module.def - - - _WIN64;_UNICODE;UNICODE;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {459e0768-7ebd-4c41-bba1-6db3b3815e0a} - - - {cc6e41ac-8174-4e8a-8d22-85dd7f4851df} - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln b/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln deleted file mode 100644 index e4f5a92176..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/VideoConferenceProxyFilterx86.sln +++ /dev/null @@ -1,51 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30907.101 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceProxyFilter", "VideoConferenceProxyFilter.vcxproj", "{AC2857B4-103D-4D6D-9740-926EBF785042}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceShared", "..\VideoConferenceShared\VideoConferenceShared.vcxproj", "{459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Version", "..\..\..\common\version\version.vcxproj", "{CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|Win32.ActiveCfg = Debug|Win32 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|Win32.Build.0 = Debug|Win32 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|x64.ActiveCfg = Debug|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Debug|x64.Build.0 = Debug|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|Win32.ActiveCfg = Release|Win32 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|Win32.Build.0 = Release|Win32 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x64.ActiveCfg = Release|x64 - {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x64.Build.0 = Release|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|Win32.ActiveCfg = Debug|Win32 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|Win32.Build.0 = Debug|Win32 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|x64.ActiveCfg = Debug|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Debug|x64.Build.0 = Debug|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|Win32.ActiveCfg = Release|Win32 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|Win32.Build.0 = Release|Win32 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.ActiveCfg = Release|x64 - {459E0768-7EBD-4C41-BBA1-6DB3B3815E0A}.Release|x64.Build.0 = Release|x64 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|Win32.Build.0 = Debug|Win32 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|x64.ActiveCfg = Debug|x64 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Debug|x64.Build.0 = Debug|x64 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|Win32.ActiveCfg = Release|Win32 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|Win32.Build.0 = Release|Win32 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.ActiveCfg = Release|x64 - {CC6E41AC-8174-4E8A-8D22-85DD7F4851DF}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {0E41348C-22CB-45A4-8A16-8D7BEA070BB2} - EndGlobalSection -EndGlobal diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/build_vcm_x86.cmd b/src/modules/videoconference/VideoConferenceProxyFilter/build_vcm_x86.cmd deleted file mode 100644 index 9b85078623..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/build_vcm_x86.cmd +++ /dev/null @@ -1,3 +0,0 @@ -msbuild VideoConferenceProxyFilterx86.sln -p:Configuration="Release" -p:Platform="Win32" - -exit 0 \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/dllmain.cpp b/src/modules/videoconference/VideoConferenceProxyFilter/dllmain.cpp deleted file mode 100644 index 61133572c8..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/dllmain.cpp +++ /dev/null @@ -1,242 +0,0 @@ -#include "VideoCaptureProxyFilter.h" - -#include - -#include -#include - -namespace -{ -#if defined(_WIN64) - class __declspec(uuid("{31AD75E9-8C3A-49C8-B9ED-5880D6B4A764}")) GUID_DECL_POWERTOYS_VCM; -#elif defined(_WIN32) - class __declspec(uuid("{31AD75E9-8C3A-49C8-B9ED-5880D6B4A732}")) GUID_DECL_POWERTOYS_VCM; -#endif - const GUID CLSID_POWERTOYS_VCM = __uuidof(GUID_DECL_POWERTOYS_VCM); - - const REGPINTYPES MEDIA_TYPES = { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPG }; - - const wchar_t FILTER_NAME[] = L"Output"; - const REGFILTERPINS PINS_REGISTRATION = { - (wchar_t*)FILTER_NAME, - false, - true, - false, - false, - &CLSID_NULL, - nullptr, - 1, - &MEDIA_TYPES - }; - - HINSTANCE DLLInstance{}; -} - -struct __declspec(uuid("9DCAF869-9C13-4BDF-BD0D-3592C5579DD6")) VideoCaptureProxyFilterFactory : winrt::implements -{ - HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown*, REFIID riid, void** ppvObject) noexcept override - { - try - { - return winrt::make()->QueryInterface(riid, ppvObject); - } - catch (...) - { - return winrt::to_hresult(); - } - } - - HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock) noexcept override - { - if (fLock) - { - ++winrt::get_module_lock(); - } - else - { - --winrt::get_module_lock(); - } - - return S_OK; - } -}; - -HRESULT STDMETHODCALLTYPE DllCanUnloadNow() -{ - if (winrt::get_module_lock()) - { - return S_FALSE; - } - - winrt::clear_factory_cache(); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE DllGetClassObject(GUID const& clsid, GUID const& iid, void** result) -{ - if (!result) - { - return E_POINTER; - } - - if (iid != IID_IClassFactory && iid != IID_IUnknown) - { - return E_NOINTERFACE; - } - - if (clsid != CLSID_POWERTOYS_VCM) - { - return E_INVALIDARG; - } - - try - { - *result = nullptr; - - auto factory = winrt::make(); - factory->AddRef(); - *result = static_cast(factory.get()); - return S_OK; - } - catch (...) - { - return winrt::to_hresult(); - } -} - -std::wstring RegistryPath() -{ - std::wstring registryPath; - registryPath.resize(CHARS_IN_GUID, L'\0'); - - StringFromGUID2(CLSID_POWERTOYS_VCM, registryPath.data(), CHARS_IN_GUID); - registryPath.resize(registryPath.size() - 1); - registryPath = L"CLSID\\" + registryPath; - return registryPath; -} - -bool RegisterServer() -{ - std::wstring dllPath; - dllPath.resize(MAX_PATH, L'\0'); - if (auto length = GetModuleFileNameW(DLLInstance, dllPath.data(), MAX_PATH); length != 0) - { - dllPath.resize(length); - } - else - { - return false; - } - - wil::unique_hkey key; - wil::unique_hkey subkey; - const auto registryPath = RegistryPath(); - if (RegCreateKeyW(HKEY_CLASSES_ROOT, registryPath.c_str(), &key)) - { - return false; - } - - if (RegSetValueW(key.get(), nullptr, REG_SZ, CAMERA_NAME, sizeof(CAMERA_NAME))) - { - return false; - } - - if (RegCreateKeyW(key.get(), L"InprocServer32", &subkey)) - { - return false; - } - - if (RegSetValueW(subkey.get(), nullptr, REG_SZ, dllPath.c_str(), static_cast((dllPath.length() + 1) * sizeof(wchar_t)))) - { - return false; - } - const wchar_t THREADING_MODEL[] = L"Both"; - RegSetValueExW(subkey.get(), L"ThreadingModel", 0, REG_SZ, (const BYTE*)THREADING_MODEL, sizeof(THREADING_MODEL)); - - return true; -} - -bool UnregisterServer() -{ - const auto registryPath = RegistryPath(); - return !RegDeleteTreeW(HKEY_CLASSES_ROOT, registryPath.c_str()); -} - -bool RegisterFilter() -{ - auto filterMapper = wil::CoCreateInstanceNoThrow(CLSID_FilterMapper2); - if (!filterMapper) - { - return false; - } - - REGFILTER2 regFilter{ .dwVersion = 1, .dwMerit = MERIT_DO_NOT_USE, .cPins = 1, .rgPins = &PINS_REGISTRATION }; - - wil::com_ptr_nothrow moniker; - - return SUCCEEDED(filterMapper->RegisterFilter( - CLSID_POWERTOYS_VCM, CAMERA_NAME, &moniker, &CLSID_VideoInputDeviceCategory, nullptr, ®Filter)); -} - -bool UnregisterFilter() -{ - auto filterMapper = wil::CoCreateInstanceNoThrow(CLSID_FilterMapper2); - if (!filterMapper) - { - return false; - } - - return SUCCEEDED(filterMapper->UnregisterFilter(&CLSID_VideoInputDeviceCategory, nullptr, CLSID_POWERTOYS_VCM)); -} - -HRESULT STDMETHODCALLTYPE DllRegisterServer() -{ - if (!RegisterServer()) - { - UnregisterServer(); - return E_FAIL; - } - - auto COMContext = wil::CoInitializeEx(COINIT_APARTMENTTHREADED); - - if (!RegisterFilter()) - { - UnregisterFilter(); - UnregisterServer(); - return E_FAIL; - } - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE DllUnregisterServer() -{ - auto COMContext = wil::CoInitializeEx(COINIT_APARTMENTTHREADED); - - UnregisterFilter(); - UnregisterServer(); - - return S_OK; -} - -HRESULT STDMETHODCALLTYPE DllInstall(BOOL install, LPCWSTR) -{ - if (install) - { - return DllRegisterServer(); - } - else - { - return DllUnregisterServer(); - } -} - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { - DLLInstance = hinstDLL; - } - - return true; -} diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/module.def b/src/modules/videoconference/VideoConferenceProxyFilter/module.def deleted file mode 100644 index c4fcbcc661..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/module.def +++ /dev/null @@ -1,7 +0,0 @@ -EXPORTS - DllMain PRIVATE - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE - DllInstall PRIVATE diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/packages.config b/src/modules/videoconference/VideoConferenceProxyFilter/packages.config deleted file mode 100644 index 6199e2345c..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/resource.h b/src/modules/videoconference/VideoConferenceProxyFilter/resource.h deleted file mode 100644 index fbba969645..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/resource.h +++ /dev/null @@ -1,11 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by VideoConferenceProxyFilter.rc - -////////////////////////////// -// Non-localizable - -#define FILE_DESCRIPTION "PowerToys VideoConferenceProxyFilter" -#define INTERNAL_NAME "PowerToys.VideoConferenceProxyFilter" -#define ORIGINAL_FILENAME "PowerToys.VideoConferenceProxyFilter_x64.dll" - diff --git a/src/modules/videoconference/VideoConferenceProxyFilter/resource.x86.h b/src/modules/videoconference/VideoConferenceProxyFilter/resource.x86.h deleted file mode 100644 index fe511d0929..0000000000 --- a/src/modules/videoconference/VideoConferenceProxyFilter/resource.x86.h +++ /dev/null @@ -1,11 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by VideoConferenceProxyFilter.rc - -////////////////////////////// -// Non-localizable - -#define FILE_DESCRIPTION "PowerToys VideoConferenceProxyFilter" -#define INTERNAL_NAME "PowerToys.VideoConferenceProxyFilter" -#define ORIGINAL_FILENAME "PowerToys.VideoConferenceProxyFilter_x86.dll" - diff --git a/src/modules/videoconference/VideoConferenceShared/CameraStateUpdateChannels.cpp b/src/modules/videoconference/VideoConferenceShared/CameraStateUpdateChannels.cpp deleted file mode 100644 index 534428531b..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/CameraStateUpdateChannels.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "CameraStateUpdateChannels.h" - -#include "naming.h" - -std::wstring_view CameraOverlayImageChannel::endpoint() -{ - static const std::wstring endpoint = ObtainStableGlobalNameForKernelObject(L"PowerToysVideoConferenceCameraOverlayImageChannelSharedMemory", true); - return endpoint; -} - -std::wstring_view CameraSettingsUpdateChannel::endpoint() -{ - static const std::wstring endpoint = ObtainStableGlobalNameForKernelObject(L"PowerToysVideoConferenceSettingsChannelSharedMemory", true); - return endpoint; -} diff --git a/src/modules/videoconference/VideoConferenceShared/CameraStateUpdateChannels.h b/src/modules/videoconference/VideoConferenceShared/CameraStateUpdateChannels.h deleted file mode 100644 index 02ec542f7a..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/CameraStateUpdateChannels.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include -#include -#include - -struct alignas(16) CameraSettingsUpdateChannel -{ - bool useOverlayImage = false; - bool cameraInUse = false; - - std::optional overlayImageSize; - std::optional> sourceCameraName; - - bool newOverlayImagePosted = false; - - static std::wstring_view endpoint(); -}; - -namespace CameraOverlayImageChannel -{ - std::wstring_view endpoint(); -} diff --git a/src/modules/videoconference/VideoConferenceShared/DLLProviderHelpers.h b/src/modules/videoconference/VideoConferenceShared/DLLProviderHelpers.h deleted file mode 100644 index 73c29cf08b..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/DLLProviderHelpers.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN -#include - -#include -#include -#include - -#define DECLARE_DLL_FUNCTION(NAME) \ - std::function NAME = (std::add_pointer_t)GetProcAddress(_library_handle, #NAME); - -#define DECLARE_DLL_PROVIDER_BEGIN(DLL_NAME) \ - class DLL_NAME##APIProvider final \ - { \ - HMODULE _library_handle; \ - DLL_NAME##APIProvider(HMODULE h) : _library_handle{ h } {} \ - \ - public: \ - ~DLL_NAME##APIProvider() { FreeLibrary(_library_handle); } \ - static std::optional create() \ - { \ - HMODULE h = LoadLibraryA(#DLL_NAME ".dll"); \ - std::optional result; \ - if (!h) \ - return result; \ - result.emplace(DLL_NAME##APIProvider{ h }); \ - return result; \ - } - -#define DECLARE_DLL_PROVIDER_END \ - } \ - ; diff --git a/src/modules/videoconference/VideoConferenceShared/Logging.cpp b/src/modules/videoconference/VideoConferenceShared/Logging.cpp deleted file mode 100644 index faeab04bb5..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/Logging.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "Logging.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#pragma warning(disable : 4127) - -static std::mutex logMutex; -constexpr inline size_t maxLogSizeMegabytes = 10; -constexpr inline bool alwaysLogVerbose = true; - -void LogToFile(std::wstring what, const bool verbose) -{ - std::error_code _; - const auto tempPath = std::filesystem::temp_directory_path(_); - if (verbose) - { - const bool verboseIndicatorFilePresent = std::filesystem::exists(tempPath / L"PowerToysVideoConferenceVerbose.flag", _); - if (!alwaysLogVerbose && !verboseIndicatorFilePresent) - { - return; - } - } - time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - std::tm tm; - localtime_s(&tm, &now); - char prefix[64]; - const auto pid = GetCurrentProcessId(); - const auto iter = prefix + sprintf_s(prefix, "[%ld]", pid); - std::strftime(iter, sizeof(prefix) - (prefix - iter), "[%d.%m %H:%M:%S] ", &tm); - - std::lock_guard lock{ logMutex }; - std::wstring logFilePath = tempPath; -#if defined(_WIN64) - logFilePath += L"\\PowerToysVideoConference_x64.log"; -#elif defined(_WIN32) - logFilePath += L"\\PowerToysVideoConference_x86.log"; -#endif - size_t logSizeMBs = 0; - try - { - logSizeMBs = static_cast(std::filesystem::file_size(logFilePath) >> 20); - } - catch (...) - { - } - if (logSizeMBs > maxLogSizeMegabytes) - { - std::error_code __; - // Truncate the log file to zero - std::filesystem::resize_file(logFilePath, 0, __); - } - std::wofstream myfile; - myfile.open(logFilePath, std::fstream::app); - - static const auto newLaunch = [&] { - myfile << prefix << "\n\n<<>"; - return 0; - }(); - - myfile << prefix << what << "\n"; - myfile.close(); -} - -void LogToFile(std::string what, const bool verbose) -{ - std::wstring native{ begin(what), end(what) }; - LogToFile(std::move(native), verbose); -} - -std::string toMediaTypeString(GUID subtype) -{ - if (subtype == MFVideoFormat_YUY2) - return "MFVideoFormat_YUY2"; - else if (subtype == MFVideoFormat_RGB32) - return "MFVideoFormat_RGB32"; - else if (subtype == MFVideoFormat_RGB24) - return "MFVideoFormat_RGB24"; - else if (subtype == MFVideoFormat_ARGB32) - return "MFVideoFormat_ARGB32"; - else if (subtype == MFVideoFormat_RGB555) - return "MFVideoFormat_RGB555"; - else if (subtype == MFVideoFormat_RGB565) - return "MFVideoFormat_RGB565"; - else if (subtype == MFVideoFormat_RGB8) - return "MFVideoFormat_RGB8"; - else if (subtype == MFVideoFormat_L8) - return "MFVideoFormat_L8"; - else if (subtype == MFVideoFormat_L16) - return "MFVideoFormat_L16"; - else if (subtype == MFVideoFormat_D16) - return "MFVideoFormat_D16"; - else if (subtype == MFVideoFormat_AYUV) - return "MFVideoFormat_AYUV"; - else if (subtype == MFVideoFormat_YVYU) - return "MFVideoFormat_YVYU"; - else if (subtype == MFVideoFormat_YVU9) - return "MFVideoFormat_YVU9"; - else if (subtype == MFVideoFormat_UYVY) - return "MFVideoFormat_UYVY"; - else if (subtype == MFVideoFormat_NV11) - return "MFVideoFormat_NV11"; - else if (subtype == MFVideoFormat_NV12) - return "MFVideoFormat_NV12"; - else if (subtype == MFVideoFormat_YV12) - return "MFVideoFormat_YV12"; - else if (subtype == MFVideoFormat_I420) - return "MFVideoFormat_I420"; - else if (subtype == MFVideoFormat_IYUV) - return "MFVideoFormat_IYUV"; - else if (subtype == MFVideoFormat_Y210) - return "MFVideoFormat_Y210"; - else if (subtype == MFVideoFormat_Y216) - return "MFVideoFormat_Y216"; - else if (subtype == MFVideoFormat_Y410) - return "MFVideoFormat_Y410"; - else if (subtype == MFVideoFormat_Y416) - return "MFVideoFormat_Y416"; - else if (subtype == MFVideoFormat_Y41P) - return "MFVideoFormat_Y41P"; - else if (subtype == MFVideoFormat_Y41T) - return "MFVideoFormat_Y41T"; - else if (subtype == MFVideoFormat_Y42T) - return "MFVideoFormat_Y42T"; - else if (subtype == MFVideoFormat_P210) - return "MFVideoFormat_P210"; - else if (subtype == MFVideoFormat_P216) - return "MFVideoFormat_P216"; - else if (subtype == MFVideoFormat_P010) - return "MFVideoFormat_P010"; - else if (subtype == MFVideoFormat_P016) - return "MFVideoFormat_P016"; - else if (subtype == MFVideoFormat_v210) - return "MFVideoFormat_v210"; - else if (subtype == MFVideoFormat_v216) - return "MFVideoFormat_v216"; - else if (subtype == MFVideoFormat_v410) - return "MFVideoFormat_v410"; - else if (subtype == MFVideoFormat_MP43) - return "MFVideoFormat_MP43"; - else if (subtype == MFVideoFormat_MP4S) - return "MFVideoFormat_MP4S"; - else if (subtype == MFVideoFormat_M4S2) - return "MFVideoFormat_M4S2"; - else if (subtype == MFVideoFormat_MP4V) - return "MFVideoFormat_MP4V"; - else if (subtype == MFVideoFormat_WMV1) - return "MFVideoFormat_WMV1"; - else if (subtype == MFVideoFormat_WMV2) - return "MFVideoFormat_WMV2"; - else if (subtype == MFVideoFormat_WMV3) - return "MFVideoFormat_WMV3"; - else if (subtype == MFVideoFormat_WVC1) - return "MFVideoFormat_WVC1"; - else if (subtype == MFVideoFormat_MSS1) - return "MFVideoFormat_MSS1"; - else if (subtype == MFVideoFormat_MSS2) - return "MFVideoFormat_MSS2"; - else if (subtype == MFVideoFormat_MPG1) - return "MFVideoFormat_MPG1"; - else if (subtype == MFVideoFormat_DVSL) - return "MFVideoFormat_DVSL"; - else if (subtype == MFVideoFormat_DVSD) - return "MFVideoFormat_DVSD"; - else if (subtype == MFVideoFormat_DVHD) - return "MFVideoFormat_DVHD"; - else if (subtype == MFVideoFormat_DV25) - return "MFVideoFormat_DV25"; - else if (subtype == MFVideoFormat_DV50) - return "MFVideoFormat_DV50"; - else if (subtype == MFVideoFormat_DVH1) - return "MFVideoFormat_DVH1"; - else if (subtype == MFVideoFormat_DVC) - return "MFVideoFormat_DVC"; - else if (subtype == MFVideoFormat_H264) - return "MFVideoFormat_H264"; - else if (subtype == MFVideoFormat_H265) - return "MFVideoFormat_H265"; - else if (subtype == MFVideoFormat_MJPG) - return "MFVideoFormat_MJPG"; - else if (subtype == MFVideoFormat_420O) - return "MFVideoFormat_420O"; - else if (subtype == MFVideoFormat_HEVC) - return "MFVideoFormat_HEVC"; - else if (subtype == MFVideoFormat_HEVC_ES) - return "MFVideoFormat_HEVC_ES"; - else if (subtype == MFVideoFormat_VP80) - return "MFVideoFormat_VP80"; - else if (subtype == MFVideoFormat_VP90) - return "MFVideoFormat_VP90"; - else if (subtype == MFVideoFormat_ORAW) - return "MFVideoFormat_ORAW"; - else - return "Other VideoFormat"; -} \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceShared/Logging.h b/src/modules/videoconference/VideoConferenceShared/Logging.h deleted file mode 100644 index e585759229..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/Logging.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include -#include -#include - -#include -#include - -void LogToFile(std::string what, const bool verbose = false); -void LogToFile(std::wstring what, const bool verbose = false); -std::string toMediaTypeString(GUID subtype); - -#define RETURN_IF_FAILED_WITH_LOGGING(val) \ - hr = (val); \ - if (FAILED(hr)) \ - { \ - LogToFile(std::string(__FUNCTION__ "() ") + #val + ": " + std::system_category().message(hr)); \ - return hr; \ - } - -#define RETURN_NULLPTR_IF_FAILED_WITH_LOGGING(val) \ - hr = val; \ - if (FAILED(hr)) \ - { \ - LogToFile(std::string(__FUNCTION__ "() ") + #val + ": " + std::system_category().message(hr)); \ - return nullptr; \ - } - -#define VERBOSE_LOG \ - std::string functionNameTMPVAR = __FUNCTION__; \ - LogToFile(std::string(functionNameTMPVAR + " enter"), true); \ - auto verboseLogOnScopeEnd = wil::scope_exit([&] { \ - LogToFile(std::string(functionNameTMPVAR + " exit"), true); \ - }); - -#if defined(PowerToysInterop) -#undef LOG -#define LOG(...) -#else -#define LOG(str) LogToFile(str, false); -#endif - -constexpr inline bool failed(HRESULT hr) -{ - return hr != S_OK; -} - -constexpr inline bool failed(bool val) -{ - return val == false; -} - -template -inline bool failed(wil::com_ptr_nothrow& ptr) -{ - return ptr == nullptr; -} - -#define OK_OR_BAIL(expr) \ - if (failed(expr)) \ - return {}; diff --git a/src/modules/videoconference/VideoConferenceShared/MediaFoundationAPIProvider.h b/src/modules/videoconference/VideoConferenceShared/MediaFoundationAPIProvider.h deleted file mode 100644 index e3d6fcec09..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/MediaFoundationAPIProvider.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include -#include - -#include "DLLProviderHelpers.h" - -DECLARE_DLL_PROVIDER_BEGIN(mfplat) -DECLARE_DLL_FUNCTION(MFCreateAttributes) -DECLARE_DLL_PROVIDER_END - -DECLARE_DLL_PROVIDER_BEGIN(mf) -DECLARE_DLL_FUNCTION(MFEnumDeviceSources) -DECLARE_DLL_PROVIDER_END diff --git a/src/modules/videoconference/VideoConferenceShared/MicrophoneDevice.cpp b/src/modules/videoconference/VideoConferenceShared/MicrophoneDevice.cpp deleted file mode 100644 index f8e6f00a80..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/MicrophoneDevice.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "pch.h" -#include "MicrophoneDevice.h" - -#include "Logging.h" - -#include - -MicrophoneDevice::MicrophoneDevice(wil::com_ptr_nothrow device, wil::com_ptr_nothrow endpoint) : - _device{ std::move(device) }, - _endpoint{ std::move(endpoint) } -{ - if (!_device || !_endpoint) - { - throw std::logic_error("MicrophoneDevice was initialized with null objects"); - } - _device->GetId(&_id); - wil::com_ptr_nothrow props; - _device->OpenPropertyStore( - STGM_READ, &props); - if (props) - { - props->GetValue(PKEY_Device_FriendlyName, &_friendly_name); - } - else - { - LOG("MicrophoneDevice::MicrophoneDevice couldn't open property store"); - } -} - -MicrophoneDevice::~MicrophoneDevice() -{ - if (_notifier) - { - _endpoint->UnregisterControlChangeNotify(_notifier.get()); - } -} - -bool MicrophoneDevice::active() const noexcept -{ - DWORD state = 0; - _device->GetState(&state); - return state == DEVICE_STATE_ACTIVE; -} - -void MicrophoneDevice::set_muted(const bool muted) noexcept -{ - _endpoint->SetMute(muted, nullptr); -} - -bool MicrophoneDevice::muted() const noexcept -{ - BOOL muted = FALSE; - _endpoint->GetMute(&muted); - return muted; -} - -std::wstring_view MicrophoneDevice::id() const noexcept -{ - return _id ? _id.get() : FALLBACK_ID; -} - -std::wstring_view MicrophoneDevice::name() const noexcept -{ - return _friendly_name.pwszVal ? _friendly_name.pwszVal : FALLBACK_NAME; -} - -void MicrophoneDevice::set_mute_changed_callback(mute_changed_cb_t callback) noexcept -{ - if (_notifier) - { - _endpoint->UnregisterControlChangeNotify(_notifier.get()); - } - _mute_changed_callback = std::move(callback); - _notifier = winrt::make(this); - - _endpoint->RegisterControlChangeNotify(_notifier.get()); -} - -std::unique_ptr MicrophoneDevice::getDefault() -{ - auto deviceEnumerator = wil::CoCreateInstanceNoThrow(); - if (!deviceEnumerator) - { - LOG("MicrophoneDevice::getDefault MMDeviceEnumerator returned null"); - return nullptr; - } - wil::com_ptr_nothrow captureDevice; - deviceEnumerator->GetDefaultAudioEndpoint(eCapture, eCommunications, &captureDevice); - if (!captureDevice) - { - LOG("MicrophoneDevice::getDefault captureDevice is null"); - return nullptr; - } - wil::com_ptr_nothrow microphoneEndpoint; - captureDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, nullptr, reinterpret_cast(µphoneEndpoint)); - if (!microphoneEndpoint) - { - LOG("MicrophoneDevice::getDefault captureDevice is null"); - return nullptr; - } - return std::make_unique(std::move(captureDevice), std::move(microphoneEndpoint)); -} - -std::vector> MicrophoneDevice::getAllActive() -{ - std::vector> microphoneDevices; - auto deviceEnumerator = wil::CoCreateInstanceNoThrow(); - if (!deviceEnumerator) - { - LOG("MicrophoneDevice::getAllActive MMDeviceEnumerator returned null"); - return microphoneDevices; - } - - wil::com_ptr_nothrow captureDevices; - deviceEnumerator->EnumAudioEndpoints(eCapture, DEVICE_STATE_ACTIVE, &captureDevices); - if (!captureDevices) - { - LOG("MicrophoneDevice::getAllActive EnumAudioEndpoints returned null"); - return microphoneDevices; - } - UINT nDevices = 0; - captureDevices->GetCount(&nDevices); - microphoneDevices.reserve(nDevices); - for (UINT i = 0; i < nDevices; ++i) - { - wil::com_ptr_nothrow device; - captureDevices->Item(i, &device); - if (!device) - { - continue; - } - wil::com_ptr_nothrow microphoneEndpoint; - device->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, nullptr, reinterpret_cast(µphoneEndpoint)); - if (!microphoneEndpoint) - { - continue; - } - microphoneDevices.push_back(std::make_unique(std::move(device), std::move(microphoneEndpoint))); - } - return microphoneDevices; -} - -MicrophoneDevice::VolumeNotifier::VolumeNotifier(MicrophoneDevice* subscribedDevice) : - _subscribedDevice{ subscribedDevice } -{ -} - -HRESULT __stdcall MicrophoneDevice::VolumeNotifier::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA data) -{ - if (_subscribedDevice && _subscribedDevice->_mute_changed_callback) - _subscribedDevice->_mute_changed_callback(data->bMuted); - - return S_OK; -} diff --git a/src/modules/videoconference/VideoConferenceShared/MicrophoneDevice.h b/src/modules/videoconference/VideoConferenceShared/MicrophoneDevice.h deleted file mode 100644 index 6a40fb5d54..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/MicrophoneDevice.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once -#define NOMINMAX - -#include -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - -class MicrophoneDevice -{ -public: - using mute_changed_cb_t = std::function; - -private: - friend struct VolumeNotifier; - - struct VolumeNotifier : winrt::implements - { - MicrophoneDevice* _subscribedDevice = nullptr; - VolumeNotifier(MicrophoneDevice* subscribedDevice); - - virtual HRESULT __stdcall OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA data) override; - }; - - wil::unique_cotaskmem_string _id; - wil::unique_prop_variant _friendly_name; - mute_changed_cb_t _mute_changed_callback; - winrt::com_ptr _notifier; - wil::com_ptr_nothrow _endpoint; - wil::com_ptr_nothrow _device; - - constexpr static inline std::wstring_view FALLBACK_NAME = L"Unknown device"; - constexpr static inline std::wstring_view FALLBACK_ID = L"UNKNOWN_ID"; - -public: - MicrophoneDevice(MicrophoneDevice&&) noexcept = delete; - MicrophoneDevice(const MicrophoneDevice&) noexcept = delete; - MicrophoneDevice(wil::com_ptr_nothrow device, wil::com_ptr_nothrow endpoint); - ~MicrophoneDevice(); - - bool active() const noexcept; - void set_muted(const bool muted) noexcept; - bool muted() const noexcept; - - std::wstring_view id() const noexcept; - std::wstring_view name() const noexcept; - void set_mute_changed_callback(mute_changed_cb_t callback) noexcept; - - static std::unique_ptr getDefault(); - static std::vector> getAllActive(); -}; diff --git a/src/modules/videoconference/VideoConferenceShared/SerializedSharedMemory.cpp b/src/modules/videoconference/VideoConferenceShared/SerializedSharedMemory.cpp deleted file mode 100644 index a7620e7741..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/SerializedSharedMemory.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "SerializedSharedMemory.h" -#ifdef _M_ARM64 -#define _mm_pause() __yield(); -#endif -inline char* SerializedSharedMemory::lock_flag_addr() noexcept -{ - return reinterpret_cast(_memory._data + _memory._size); -} - -inline void SerializedSharedMemory::lock() noexcept -{ - if (_read_only) - { - return; - } - while (LOCKED == _InterlockedCompareExchange8(lock_flag_addr(), LOCKED, !LOCKED)) - { - while (*lock_flag_addr() == LOCKED) - { - _mm_pause(); - } - } -} - -inline void SerializedSharedMemory::unlock() noexcept -{ - if (_read_only) - { - return; - } - _InterlockedExchange8(lock_flag_addr(), !LOCKED); -} - -SerializedSharedMemory::SerializedSharedMemory(std::array handles, - memory_t memory, - const bool readonly) noexcept - : - _handles{ std::move(handles) }, _memory{ std::move(memory) }, _read_only(readonly) -{ -} - -SerializedSharedMemory::~SerializedSharedMemory() noexcept -{ - if (_memory._data) - { - UnmapViewOfFile(_memory._data); - } -} - -SerializedSharedMemory::SerializedSharedMemory(SerializedSharedMemory&& rhs) noexcept -{ - *this = std::move(rhs); -} - -SerializedSharedMemory& SerializedSharedMemory::operator=(SerializedSharedMemory&& rhs) noexcept -{ - _handles = {}; - _handles.swap(rhs._handles); - _memory = std::move(rhs._memory); - rhs._memory = {}; - _read_only = rhs._read_only; - rhs._read_only = true; - - return *this; -} - -std::optional SerializedSharedMemory::create(const std::wstring_view object_name, - const size_t size, - const bool read_only, - SECURITY_ATTRIBUTES* maybe_attributes) noexcept -{ - SECURITY_DESCRIPTOR sd; - SECURITY_ATTRIBUTES sa = { sizeof SECURITY_ATTRIBUTES }; - if (!maybe_attributes) - { - sa.lpSecurityDescriptor = &sd; - sa.bInheritHandle = false; - if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION) || - !SetSecurityDescriptorDacl(&sd, true, nullptr, false)) - { - return std::nullopt; - } - } - - // We need an extra byte for locking if it's not readonly - const ULARGE_INTEGER UISize{ .QuadPart = static_cast(size) + !read_only }; - - wil::unique_handle hMapFile{ CreateFileMappingW(INVALID_HANDLE_VALUE, - maybe_attributes ? maybe_attributes : &sa, - read_only ? PAGE_READONLY : PAGE_READWRITE, - UISize.HighPart, - UISize.LowPart, - object_name.data()) }; - if (!hMapFile) - { - return std::nullopt; - } - auto shmem = static_cast( - MapViewOfFile(hMapFile.get(), read_only ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, static_cast(UISize.QuadPart))); - if (!shmem) - { - return std::nullopt; - } - std::array handles = { std::move(hMapFile), {} }; - return SerializedSharedMemory{ std::move(handles), memory_t{ shmem, size }, read_only }; -} - -std::optional SerializedSharedMemory::open(const std::wstring_view object_name, - const size_t size, - const bool read_only) noexcept -{ - wil::unique_handle hMapFile{ OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, object_name.data()) }; - if (!hMapFile) - { - return std::nullopt; - } - - auto shmem = static_cast( - MapViewOfFile(hMapFile.get(), read_only ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, size + !read_only)); - - if (!shmem) - { - return std::nullopt; - } - std::array handles = { std::move(hMapFile), {} }; - return SerializedSharedMemory{ std::move(handles), memory_t{ shmem, size }, read_only }; -} - -std::optional SerializedSharedMemory::create_readonly( - const std::wstring_view object_name, - const std::wstring_view file_path, - SECURITY_ATTRIBUTES* maybe_attributes) noexcept -{ - SECURITY_DESCRIPTOR sd; - SECURITY_ATTRIBUTES sa = { sizeof SECURITY_ATTRIBUTES }; - if (!maybe_attributes) - { - sa.lpSecurityDescriptor = &sd; - sa.bInheritHandle = false; - if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION) || - !SetSecurityDescriptorDacl(&sd, true, nullptr, false)) - { - return std::nullopt; - } - } - wil::unique_handle hFile{ CreateFileW(file_path.data(), - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - maybe_attributes ? maybe_attributes : &sa, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr) }; - - if (!hFile) - { - return std::nullopt; - } - - LARGE_INTEGER fileSize; - if (!GetFileSizeEx(hFile.get(), &fileSize)) - { - return std::nullopt; - } - wil::unique_handle hMapFile{ CreateFileMappingW(hFile.get(), - maybe_attributes ? maybe_attributes : &sa, - PAGE_READONLY, - fileSize.HighPart, - fileSize.LowPart, - object_name.data()) }; - if (!hMapFile) - { - return std::nullopt; - } - - auto shmem = static_cast(MapViewOfFile(nullptr, FILE_MAP_READ, 0, 0, static_cast(fileSize.QuadPart))); - if (shmem) - { - return std::nullopt; - } - std::array handles = { std::move(hMapFile), std::move(hFile) }; - - return SerializedSharedMemory{ std::move(handles), memory_t{ shmem, static_cast(fileSize.QuadPart) }, true }; -} - -void SerializedSharedMemory::access(std::function access_routine) noexcept -{ - lock(); - access_routine(_memory); - unlock(); -} \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceShared/SerializedSharedMemory.h b/src/modules/videoconference/VideoConferenceShared/SerializedSharedMemory.h deleted file mode 100644 index 15f1052746..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/SerializedSharedMemory.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#include -#include -#include -#include -#include -#include - -// Wrapper class allowing sharing readonly/writable memory with a serialized access via atomic locking. -// Note that it doesn't protect against a 3rd party concurrently modifying physical file contents. -class SerializedSharedMemory -{ -public: - struct memory_t - { - uint8_t * _data = nullptr; - size_t _size = 0; - }; - - static std::optional create(const std::wstring_view object_name, - const size_t size, - const bool read_only, - SECURITY_ATTRIBUTES* maybe_attributes = nullptr) noexcept; - static std::optional create_readonly( - const std::wstring_view object_name, - const std::wstring_view file_path, - SECURITY_ATTRIBUTES* maybe_attributes = nullptr) noexcept; - static std::optional open(const std::wstring_view object_name, - const size_t size, - const bool read_only) noexcept; - - void access(std::function access_routine) noexcept; - inline size_t size() const noexcept { return _memory._size; } - - ~SerializedSharedMemory() noexcept; - SerializedSharedMemory(SerializedSharedMemory&&) noexcept; - SerializedSharedMemory& operator=(SerializedSharedMemory&&) noexcept; - -private: - std::array _handles; - memory_t _memory; - bool _read_only = true; - constexpr static inline int64_t LOCKED = 1; - - char* lock_flag_addr() noexcept; - void lock() noexcept; - void unlock() noexcept; - - SerializedSharedMemory(std::array handles, memory_t memory, const bool readonly) noexcept; -}; \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.cpp b/src/modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.cpp deleted file mode 100644 index ba710a0453..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "pch.h" -#include "VideoCaptureDeviceList.h" -#include "Logging.h" -#include "MediaFoundationAPIProvider.h" -#include -#include - -#include -#include - -void VideoCaptureDeviceList::Clear() -{ - for (UINT32 i = 0; i < m_numberDevices; i++) - { - CoTaskMemFree(m_deviceFriendlyNames[i]); - if (m_ppDevices[i]) - { - m_ppDevices[i]->Release(); - } - } - CoTaskMemFree(m_ppDevices); - m_ppDevices = nullptr; - if (m_deviceFriendlyNames) - { - delete[] m_deviceFriendlyNames; - } - - m_deviceFriendlyNames = nullptr; - m_numberDevices = 0; -} - -HRESULT VideoCaptureDeviceList::EnumerateDevices() -{ - HRESULT hr = S_OK; - wil::com_ptr pAttributes; - Clear(); - auto mfplatAPI = mfplatAPIProvider::create(); - auto mfAPI = mfAPIProvider::create(); - if (!mfplatAPI || !mfAPI) - { - return ERROR_FILE_NOT_FOUND; - } - - // Initialize an attribute store. We will use this to - // specify the enumeration parameters. - - hr = mfplatAPI->MFCreateAttributes(&pAttributes, 1); - - // Ask for source type = video capture devices - if (SUCCEEDED(hr)) - { - hr = pAttributes->SetGUID( - MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, - MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID); - } - else - { - LOG("VideoCaptureDeviceList::EnumerateDevices(): Couldn't MFCreateAttributes"); - } - // Enumerate devices. - if (SUCCEEDED(hr)) - { - hr = mfAPI->MFEnumDeviceSources(pAttributes.get(), &m_ppDevices, &m_numberDevices); - } - else - { - LOG("VideoCaptureDeviceList::EnumerateDevices(): Couldn't SetGUID"); - } - - if (FAILED(hr)) - { - LOG("VideoCaptureDeviceList::EnumerateDevices(): MFEnumDeviceSources failed"); - return hr; - } - - m_deviceFriendlyNames = new (std::nothrow) wchar_t*[m_numberDevices]; - for (UINT32 i = 0; i < m_numberDevices; i++) - { - UINT32 nameLength = 0; - m_ppDevices[i]->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &m_deviceFriendlyNames[i], &nameLength); - } - - return hr; -} - -HRESULT VideoCaptureDeviceList::GetDevice(UINT32 index, IMFActivate** ppActivate) -{ - if (index >= Count()) - { - return E_INVALIDARG; - } - - *ppActivate = m_ppDevices[index]; - (*ppActivate)->AddRef(); - - return S_OK; -} - -std::wstring_view VideoCaptureDeviceList::GetDeviceName(UINT32 index) -{ - if (index >= Count()) - { - return {}; - } - - return m_deviceFriendlyNames[index]; -} diff --git a/src/modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.h b/src/modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.h deleted file mode 100644 index eb0bf4afd4..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -#include -#include - -class VideoCaptureDeviceList -{ - UINT32 m_numberDevices; - // TODO: use wil - IMFActivate** m_ppDevices = nullptr; - wchar_t** m_deviceFriendlyNames = nullptr; - -public: - VideoCaptureDeviceList() : - m_ppDevices(NULL), m_numberDevices(0) - { - } - ~VideoCaptureDeviceList() - { - Clear(); - } - - UINT32 Count() const { return m_numberDevices; } - - void Clear(); - HRESULT EnumerateDevices(); - HRESULT GetDevice(UINT32 index, IMFActivate** ppActivate); - std::wstring_view GetDeviceName(UINT32 index); -}; diff --git a/src/modules/videoconference/VideoConferenceShared/VideoConferenceShared.vcxproj b/src/modules/videoconference/VideoConferenceShared/VideoConferenceShared.vcxproj deleted file mode 100644 index a888f90877..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/VideoConferenceShared.vcxproj +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - Debug - Win32 - - - Debug - x64 - - - Debug - ARM64 - - - Release - Win32 - - - Release - x64 - - - Release - ARM64 - - - - - mfplat.lib;Mfsensorgroup.lib;Mf.lib;Shlwapi.lib;Strmiids.lib;%(AdditionalDependencies); - - - - 16.0 - Win32Proj - {459e0768-7ebd-4c41-bba1-6db3b3815e0a} - VideoConferenceShared - - - - StaticLibrary - true - v143 - Unicode - - - - - - - - - - - - ..\..\..\..\$(Platform)\$(Configuration)\ - - - ..\..\..\..\x86\$(Configuration)\ - - - true - - - - NotUsing - - - - - Level4 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - $(SolutionDir)\src\; - - - Console - true - - - true - - - - - Level4 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreaded - true - $(SolutionDir)\src\;%(AdditionalIncludeDirectories) - ProgramDatabase - - - Console - true - true - true - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceShared/naming.cpp b/src/modules/videoconference/VideoConferenceShared/naming.cpp deleted file mode 100644 index b93088cd00..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/naming.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "naming.h" - -#include "username.h" - -std::wstring ObtainStableGlobalNameForKernelObject(const std::wstring_view name, const bool restricted) -{ - static const std::optional username = ObtainActiveUserName(); - std::wstring result = L"Global\\"; - if (restricted) - { - result += L"Restricted\\"; - } - if (username) - { - result += *username; - } - result += name; - return result; -} diff --git a/src/modules/videoconference/VideoConferenceShared/naming.h b/src/modules/videoconference/VideoConferenceShared/naming.h deleted file mode 100644 index 8d127b0623..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/naming.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include -#include - -std::wstring ObtainStableGlobalNameForKernelObject(const std::wstring_view name, const bool restricted); \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceShared/packages.config b/src/modules/videoconference/VideoConferenceShared/packages.config deleted file mode 100644 index ff4b059648..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/modules/videoconference/VideoConferenceShared/pch.h b/src/modules/videoconference/VideoConferenceShared/pch.h deleted file mode 100644 index 128bb3589f..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/pch.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -// Dummy file to allow compiling VideoCaptureDeviceList.h and MicrophoneDevice.h in this project, since it's also used in PowerToys.Interop.vcxproj, which has a pch. diff --git a/src/modules/videoconference/VideoConferenceShared/username.cpp b/src/modules/videoconference/VideoConferenceShared/username.cpp deleted file mode 100644 index d8b99e8dd5..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/username.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "username.h" - -#include -#include - -std::optional ObtainActiveUserName() -{ - const DWORD sessionId = WTSGetActiveConsoleSessionId(); - WCHAR* pUserName; - DWORD _ = 0; - - if (!WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, sessionId, WTSUserName, &pUserName, &_)) - { - return std::nullopt; - } - WTSGetActiveConsoleSessionId(); - std::wstring result{ pUserName }; - WTSFreeMemory(pUserName); - return result; -} diff --git a/src/modules/videoconference/VideoConferenceShared/username.h b/src/modules/videoconference/VideoConferenceShared/username.h deleted file mode 100644 index dcbefec38b..0000000000 --- a/src/modules/videoconference/VideoConferenceShared/username.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include -#include -#include - -std::optional ObtainActiveUserName(); - -std::wstring ObtainStableGlobalNameForKernelObject(const std::wstring_view name, const bool restricted); \ No newline at end of file diff --git a/src/modules/videoconference/make_cab.ddf b/src/modules/videoconference/make_cab.ddf deleted file mode 100644 index 0c75024114..0000000000 --- a/src/modules/videoconference/make_cab.ddf +++ /dev/null @@ -1,20 +0,0 @@ -; Disable default limits -.option EXPLICIT -.set CabinetFileCountThreshold=0 -.set FolderFileCountThreshold=0 -.set FolderSizeThreshold=0 -.set MaxCabinetSize=0 -.set MaxDiskFileCount=0 -.set MaxDiskSize=0 - -.set GenerateInf=ON -.set Compress=OFF -.set Cabinet=ON -.set CabinetNameTemplate=driver.cab -.set DestinationDir=cab_output -.set DiskDirectoryTemplate=driver - -VideoConferenceCustomMediaSource.dll -videoconferencevirtualdriver.cat -VideoConferenceVirtualDriver.dll -VideoConferenceVirtualDriver.inf \ No newline at end of file diff --git a/src/runner/main.cpp b/src/runner/main.cpp index ba893678c1..81a94c5e6c 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "UpdateUtils.h" #include "ActionRunnerUtils.h" @@ -132,6 +133,15 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow } }.detach(); chdir_current_executable(); + + // We deprecated a utility called Video Conference Mute, which registered itself as a video input device. + // When running elevated, we try to clean up the device registration from previous installations. + // This is done here too because a user-scope installer won't be able to remove the driver registration due to lack of permissions. + if (isProcessElevated) + { + clean_video_conference(); + } + // Load PowerToys DLLs std::vector knownModules = { @@ -164,12 +174,6 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow L"PowerToys.CmdNotFoundModuleInterface.dll", L"PowerToys.WorkspacesModuleInterface.dll", }; - const auto VCM_PATH = L"PowerToys.VideoConferenceModule.dll"; - if (const auto mf = LoadLibraryA("mf.dll")) - { - FreeLibrary(mf); - knownModules.emplace_back(VCM_PATH); - } for (auto moduleSubdir : knownModules) { diff --git a/src/runner/settings_window.cpp b/src/runner/settings_window.cpp index 4c2787194e..8a5c2fcf40 100644 --- a/src/runner/settings_window.cpp +++ b/src/runner/settings_window.cpp @@ -674,8 +674,6 @@ std::string ESettingsWindowNames_to_string(ESettingsWindowNames value) return "FileExplorer"; case ESettingsWindowNames::ShortcutGuide: return "ShortcutGuide"; - case ESettingsWindowNames::VideoConference: - return "VideoConference"; case ESettingsWindowNames::Hosts: return "Hosts"; case ESettingsWindowNames::MeasureTool: @@ -751,10 +749,6 @@ ESettingsWindowNames ESettingsWindowNames_from_string(std::string value) { return ESettingsWindowNames::ShortcutGuide; } - else if (value == "VideoConference") - { - return ESettingsWindowNames::VideoConference; - } else if (value == "Hosts") { return ESettingsWindowNames::Hosts; diff --git a/src/runner/settings_window.h b/src/runner/settings_window.h index 6fd5afca0f..4d2a4595ae 100644 --- a/src/runner/settings_window.h +++ b/src/runner/settings_window.h @@ -16,7 +16,6 @@ enum class ESettingsWindowNames PowerRename, FileExplorer, ShortcutGuide, - VideoConference, Hosts, MeasureTool, PowerOCR, diff --git a/src/settings-ui/Settings.UI.Library/EnabledModules.cs b/src/settings-ui/Settings.UI.Library/EnabledModules.cs index 604b4c46ab..e38db5eeb4 100644 --- a/src/settings-ui/Settings.UI.Library/EnabledModules.cs +++ b/src/settings-ui/Settings.UI.Library/EnabledModules.cs @@ -88,22 +88,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library } } - private bool videoConference; // defaulting to off https://github.com/microsoft/PowerToys/issues/14507 - - [JsonPropertyName("Video Conference")] - public bool VideoConference - { - get => this.videoConference; - set - { - if (this.videoConference != value) - { - LogTelemetryEvent(value); - this.videoConference = value; - } - } - } - private bool powerRename = true; public bool PowerRename diff --git a/src/settings-ui/Settings.UI.Library/SndVideoConferenceSettings.cs b/src/settings-ui/Settings.UI.Library/SndVideoConferenceSettings.cs deleted file mode 100644 index b16c79de79..0000000000 --- a/src/settings-ui/Settings.UI.Library/SndVideoConferenceSettings.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Microsoft.PowerToys.Settings.UI.Library -{ - public class SndVideoConferenceSettings - { - [JsonPropertyName("Video Conference")] - public VideoConferenceSettings VideoConference { get; set; } - - public SndVideoConferenceSettings(VideoConferenceSettings settings) - { - VideoConference = settings; - } - - public string ToJsonString() - { - return JsonSerializer.Serialize(this); - } - } -} diff --git a/src/settings-ui/Settings.UI.Library/VideoConferenceConfigProperties.cs b/src/settings-ui/Settings.UI.Library/VideoConferenceConfigProperties.cs deleted file mode 100644 index 9c7b33f804..0000000000 --- a/src/settings-ui/Settings.UI.Library/VideoConferenceConfigProperties.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text.Json; -using System.Text.Json.Serialization; - -using Settings.UI.Library.Attributes; - -namespace Microsoft.PowerToys.Settings.UI.Library -{ - public class VideoConferenceConfigProperties - { - [CmdConfigureIgnoreAttribute] - public HotkeySettings DefaultMuteCameraAndMicrophoneHotkey => new HotkeySettings() - { - Win = true, - Ctrl = false, - Alt = false, - Shift = true, - Key = "Q", - Code = 81, - }; - - [CmdConfigureIgnoreAttribute] - public HotkeySettings DefaultMuteMicrophoneHotkey => new HotkeySettings() - { - Win = true, - Ctrl = false, - Alt = false, - Shift = true, - Key = "A", - Code = 65, - }; - - [CmdConfigureIgnoreAttribute] - public HotkeySettings DefaultPushToTalkMicrophoneHotkey => new HotkeySettings() - { - Win = true, - Ctrl = false, - Alt = false, - Shift = true, - Key = "I", - Code = 73, - }; - - [CmdConfigureIgnoreAttribute] - public HotkeySettings DefaultMuteCameraHotkey => new HotkeySettings() - { - Win = true, - Ctrl = false, - Alt = false, - Shift = true, - Key = "O", - Code = 79, - }; - - public VideoConferenceConfigProperties() - { - MuteCameraAndMicrophoneHotkey = new KeyboardKeysProperty(DefaultMuteCameraAndMicrophoneHotkey); - MuteMicrophoneHotkey = new KeyboardKeysProperty(DefaultMuteMicrophoneHotkey); - PushToTalkMicrophoneHotkey = new KeyboardKeysProperty(DefaultPushToTalkMicrophoneHotkey); - MuteCameraHotkey = new KeyboardKeysProperty(DefaultMuteCameraHotkey); - - PushToReverseEnabled = new BoolProperty(false); - } - - [JsonPropertyName("mute_camera_and_microphone_hotkey")] - public KeyboardKeysProperty MuteCameraAndMicrophoneHotkey { get; set; } - - [JsonPropertyName("mute_microphone_hotkey")] - public KeyboardKeysProperty MuteMicrophoneHotkey { get; set; } - - [JsonPropertyName("push_to_talk_microphone_hotkey")] - public KeyboardKeysProperty PushToTalkMicrophoneHotkey { get; set; } - - [JsonPropertyName("push_to_reverse_enabled")] - public BoolProperty PushToReverseEnabled { get; set; } - - [JsonPropertyName("mute_camera_hotkey")] - public KeyboardKeysProperty MuteCameraHotkey { get; set; } - - [JsonPropertyName("selected_camera")] - public StringProperty SelectedCamera { get; set; } = string.Empty; - - [JsonPropertyName("selected_mic")] - public StringProperty SelectedMicrophone { get; set; } = string.Empty; - - [JsonPropertyName("toolbar_position")] - public StringProperty ToolbarPosition { get; set; } = "Top right corner"; - - [JsonPropertyName("toolbar_monitor")] - public StringProperty ToolbarMonitor { get; set; } = "Main monitor"; - - [JsonPropertyName("camera_overlay_image_path")] - public StringProperty CameraOverlayImagePath { get; set; } = string.Empty; - - [JsonPropertyName("theme")] - public StringProperty Theme { get; set; } - - [JsonPropertyName("toolbar_hide")] - public StringProperty ToolbarHide { get; set; } = "When both camera and microphone are unmuted"; - - [JsonPropertyName("startup_action")] - public StringProperty StartupAction { get; set; } = "Nothing"; - - // converts the current to a json string. - public string ToJsonString() - { - return JsonSerializer.Serialize(this); - } - } -} diff --git a/src/settings-ui/Settings.UI.Library/VideoConferenceSettings.cs b/src/settings-ui/Settings.UI.Library/VideoConferenceSettings.cs deleted file mode 100644 index c33bcdaaa6..0000000000 --- a/src/settings-ui/Settings.UI.Library/VideoConferenceSettings.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text.Json.Serialization; - -using Microsoft.PowerToys.Settings.UI.Library.Interfaces; - -namespace Microsoft.PowerToys.Settings.UI.Library -{ - public class VideoConferenceSettings : BasePTModuleSettings, ISettingsConfig - { - public const string ModuleName = "Video Conference"; - - public VideoConferenceSettings() - { - Version = "1"; - Name = ModuleName; - Properties = new VideoConferenceConfigProperties(); - } - - [JsonPropertyName("properties")] - public VideoConferenceConfigProperties Properties { get; set; } - - public string GetModuleName() - { - return Name; - } - - public bool UpgradeSettingsConfiguration() - { - return false; - } - } -} diff --git a/src/settings-ui/Settings.UI.Library/VideoConferenceSettingsIPCMessage.cs b/src/settings-ui/Settings.UI.Library/VideoConferenceSettingsIPCMessage.cs deleted file mode 100644 index 1fdc7f489e..0000000000 --- a/src/settings-ui/Settings.UI.Library/VideoConferenceSettingsIPCMessage.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Microsoft.PowerToys.Settings.UI.Library -{ - public class VideoConferenceSettingsIPCMessage - { - [JsonPropertyName("powertoys")] - public SndVideoConferenceSettings Powertoys { get; set; } - - public VideoConferenceSettingsIPCMessage() - { - } - - public VideoConferenceSettingsIPCMessage(SndVideoConferenceSettings settings) - { - this.Powertoys = settings; - } - - public string ToJsonString() - { - return JsonSerializer.Serialize(this); - } - } -} diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Icons/VideoConferenceMute.png b/src/settings-ui/Settings.UI/Assets/Settings/Icons/VideoConferenceMute.png deleted file mode 100644 index 22a39baf64..0000000000 Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Icons/VideoConferenceMute.png and /dev/null differ diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/VideoConferenceMute.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/VideoConferenceMute.png deleted file mode 100644 index 722ee5ca1d..0000000000 Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/VideoConferenceMute.png and /dev/null differ diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/VideoConference.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/VideoConference.png deleted file mode 100644 index 028d98889c..0000000000 Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/VideoConference.png and /dev/null differ diff --git a/src/settings-ui/Settings.UI/OOBE/Enums/PowerToysModules.cs b/src/settings-ui/Settings.UI/OOBE/Enums/PowerToysModules.cs index 14646c6647..98e5beb107 100644 --- a/src/settings-ui/Settings.UI/OOBE/Enums/PowerToysModules.cs +++ b/src/settings-ui/Settings.UI/OOBE/Enums/PowerToysModules.cs @@ -27,7 +27,6 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Enums QuickAccent, ShortcutGuide, TextExtractor, - VideoConference, MeasureTool, Hosts, Workspaces, diff --git a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs index 3b6b3a7681..24910afc6c 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs @@ -440,7 +440,6 @@ namespace Microsoft.PowerToys.Settings.UI case "FileExplorer": return typeof(PowerPreviewPage); case "ShortcutGuide": return typeof(ShortcutGuidePage); case "PowerOcr": return typeof(PowerOcrPage); - case "VideoConference": return typeof(VideoConferencePage); case "MeasureTool": return typeof(MeasureToolPage); case "Hosts": return typeof(HostsPage); case "RegistryPreview": return typeof(RegistryPreviewPage); diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml index b765b7d963..6c37ec15ea 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml @@ -157,10 +157,6 @@ x:Uid="Shell_TextExtractor" Icon="{ui:BitmapIcon Source=/Assets/Settings/Icons/TextExtractor.png}" Tag="TextExtractor" /> - - - - - - - - - - - - - - - - - -