mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[Tools] Add DShow webcam report tool (#10502)
This commit is contained in:
parent
49fb838175
commit
ffda6a51bb
33
.github/actions/spell-check/expect.txt
vendored
33
.github/actions/spell-check/expect.txt
vendored
@ -49,6 +49,8 @@ amd
|
|||||||
Amicrosoft
|
Amicrosoft
|
||||||
AMirror
|
AMirror
|
||||||
AModifier
|
AModifier
|
||||||
|
AMPROPERTY
|
||||||
|
AMPROPSETID
|
||||||
anges
|
anges
|
||||||
ansicolor
|
ansicolor
|
||||||
antialiased
|
antialiased
|
||||||
@ -175,7 +177,6 @@ BRIGHTGREEN
|
|||||||
Browsable
|
Browsable
|
||||||
bsd
|
bsd
|
||||||
bstr
|
bstr
|
||||||
BText
|
|
||||||
bti
|
bti
|
||||||
Btn
|
Btn
|
||||||
BTNFACE
|
BTNFACE
|
||||||
@ -204,10 +205,12 @@ CDATA
|
|||||||
CDBECF
|
CDBECF
|
||||||
cdecl
|
cdecl
|
||||||
CDeclaration
|
CDeclaration
|
||||||
|
CDEF
|
||||||
cdpx
|
cdpx
|
||||||
cdpxwin
|
cdpxwin
|
||||||
CENTERALIGN
|
CENTERALIGN
|
||||||
cfg
|
cfg
|
||||||
|
cguid
|
||||||
charconv
|
charconv
|
||||||
charset
|
charset
|
||||||
chdir
|
chdir
|
||||||
@ -434,6 +437,8 @@ DEU
|
|||||||
Devagya
|
Devagya
|
||||||
devblogs
|
devblogs
|
||||||
devdocs
|
devdocs
|
||||||
|
devenum
|
||||||
|
DEVMON
|
||||||
df
|
df
|
||||||
DFactory
|
DFactory
|
||||||
Dialpad
|
Dialpad
|
||||||
@ -486,6 +491,7 @@ drivedetectionwarning
|
|||||||
DRM
|
DRM
|
||||||
dropdown
|
dropdown
|
||||||
dropref
|
dropref
|
||||||
|
dshow
|
||||||
dst
|
dst
|
||||||
DSVG
|
DSVG
|
||||||
DText
|
DText
|
||||||
@ -773,7 +779,6 @@ GNumber
|
|||||||
google
|
google
|
||||||
GPTR
|
GPTR
|
||||||
grayscale
|
grayscale
|
||||||
GText
|
|
||||||
gui
|
gui
|
||||||
guiddef
|
guiddef
|
||||||
GUITHREADINFO
|
GUITHREADINFO
|
||||||
@ -880,6 +885,7 @@ IAppx
|
|||||||
IAsync
|
IAsync
|
||||||
IAuto
|
IAuto
|
||||||
IBackground
|
IBackground
|
||||||
|
IBase
|
||||||
IBeam
|
IBeam
|
||||||
IBind
|
IBind
|
||||||
icase
|
icase
|
||||||
@ -898,6 +904,7 @@ Iconset
|
|||||||
IContext
|
IContext
|
||||||
ICONWARNING
|
ICONWARNING
|
||||||
ICore
|
ICore
|
||||||
|
ICreate
|
||||||
IData
|
IData
|
||||||
IDCANCEL
|
IDCANCEL
|
||||||
IDD
|
IDD
|
||||||
@ -945,6 +952,7 @@ IInput
|
|||||||
IInspectable
|
IInspectable
|
||||||
IItem
|
IItem
|
||||||
IJson
|
IJson
|
||||||
|
IKs
|
||||||
IList
|
IList
|
||||||
ILogon
|
ILogon
|
||||||
IMAGEHLP
|
IMAGEHLP
|
||||||
@ -955,6 +963,7 @@ IMarkdown
|
|||||||
ime
|
ime
|
||||||
imeutil
|
imeutil
|
||||||
img
|
img
|
||||||
|
IMoniker
|
||||||
IMonitor
|
IMonitor
|
||||||
IMouse
|
IMouse
|
||||||
impl
|
impl
|
||||||
@ -970,7 +979,7 @@ inheritdoc
|
|||||||
ini
|
ini
|
||||||
INITCOMMONCONTROLSEX
|
INITCOMMONCONTROLSEX
|
||||||
INITDIALOG
|
INITDIALOG
|
||||||
INITGUID
|
initguid
|
||||||
inl
|
inl
|
||||||
Inlines
|
Inlines
|
||||||
inorder
|
inorder
|
||||||
@ -992,7 +1001,6 @@ INSTALLLOCATION
|
|||||||
INSTALLLOGATTRIBUTES
|
INSTALLLOGATTRIBUTES
|
||||||
INSTALLLOGMODE
|
INSTALLLOGMODE
|
||||||
INSTALLMESSAGE
|
INSTALLMESSAGE
|
||||||
installpath
|
|
||||||
INSTALLPROPERTY
|
INSTALLPROPERTY
|
||||||
INSTALLSTARTMENUSHORTCUT
|
INSTALLSTARTMENUSHORTCUT
|
||||||
INSTALLSTATE
|
INSTALLSTATE
|
||||||
@ -1019,6 +1027,7 @@ ipc
|
|||||||
ipcmanager
|
ipcmanager
|
||||||
ipconfig
|
ipconfig
|
||||||
IPersist
|
IPersist
|
||||||
|
IPin
|
||||||
IPlugin
|
IPlugin
|
||||||
IPower
|
IPower
|
||||||
ipp
|
ipp
|
||||||
@ -1027,6 +1036,7 @@ ipreviewhandlertranslateaccelerator
|
|||||||
ipreviewhandlervisualssetfont
|
ipreviewhandlervisualssetfont
|
||||||
IPrincipal
|
IPrincipal
|
||||||
IProgram
|
IProgram
|
||||||
|
IProperty
|
||||||
IPublic
|
IPublic
|
||||||
IQuery
|
IQuery
|
||||||
IRead
|
IRead
|
||||||
@ -1241,6 +1251,7 @@ lzw
|
|||||||
mailto
|
mailto
|
||||||
MAINICON
|
MAINICON
|
||||||
Mainwindow
|
Mainwindow
|
||||||
|
majortype
|
||||||
makeappx
|
makeappx
|
||||||
MAKEINTRESOURCE
|
MAKEINTRESOURCE
|
||||||
MAKEINTRESOURCEW
|
MAKEINTRESOURCEW
|
||||||
@ -1267,6 +1278,8 @@ Mdb
|
|||||||
MDICHILD
|
MDICHILD
|
||||||
MDL
|
MDL
|
||||||
mdpreviewhandler
|
mdpreviewhandler
|
||||||
|
MEDIASUBTYPE
|
||||||
|
MEDIATYPE
|
||||||
Melman
|
Melman
|
||||||
memcpy
|
memcpy
|
||||||
memset
|
memset
|
||||||
@ -1293,6 +1306,7 @@ miniz
|
|||||||
MINMAXINFO
|
MINMAXINFO
|
||||||
Miracast
|
Miracast
|
||||||
mixin
|
mixin
|
||||||
|
MJPG
|
||||||
mkdir
|
mkdir
|
||||||
MLogo
|
MLogo
|
||||||
MMI
|
MMI
|
||||||
@ -1568,6 +1582,7 @@ phwnd
|
|||||||
pici
|
pici
|
||||||
pid
|
pid
|
||||||
pidl
|
pidl
|
||||||
|
PINDIR
|
||||||
pinfo
|
pinfo
|
||||||
pinvoke
|
pinvoke
|
||||||
Pipelinhttps
|
Pipelinhttps
|
||||||
@ -1781,13 +1796,12 @@ roslyn
|
|||||||
royvou
|
royvou
|
||||||
rpc
|
rpc
|
||||||
RRF
|
RRF
|
||||||
rshift
|
|
||||||
RSHIFT
|
RSHIFT
|
||||||
|
rshift
|
||||||
Rsp
|
Rsp
|
||||||
rst
|
rst
|
||||||
Rstrtmgr
|
Rstrtmgr
|
||||||
RTB
|
RTB
|
||||||
RText
|
|
||||||
rtf
|
rtf
|
||||||
Rtl
|
Rtl
|
||||||
RTLREADING
|
RTLREADING
|
||||||
@ -1999,6 +2013,7 @@ stringify
|
|||||||
STRINGIZE
|
STRINGIZE
|
||||||
stringtable
|
stringtable
|
||||||
stringval
|
stringval
|
||||||
|
Strmiids
|
||||||
strsafe
|
strsafe
|
||||||
strutil
|
strutil
|
||||||
sttngs
|
sttngs
|
||||||
@ -2244,6 +2259,7 @@ Versioning
|
|||||||
VFT
|
VFT
|
||||||
vh
|
vh
|
||||||
vid
|
vid
|
||||||
|
VIDEOINFOHEADER
|
||||||
viewbox
|
viewbox
|
||||||
viewmodel
|
viewmodel
|
||||||
virtualization
|
virtualization
|
||||||
@ -2293,7 +2309,7 @@ wdp
|
|||||||
wdupenv
|
wdupenv
|
||||||
weakme
|
weakme
|
||||||
webapp
|
webapp
|
||||||
Webcam
|
webcam
|
||||||
webclient
|
webclient
|
||||||
webkit
|
webkit
|
||||||
webp
|
webp
|
||||||
@ -2346,6 +2362,7 @@ winspool
|
|||||||
winstore
|
winstore
|
||||||
winui
|
winui
|
||||||
winxamlmanager
|
winxamlmanager
|
||||||
|
wistd
|
||||||
withinrafael
|
withinrafael
|
||||||
Withscript
|
Withscript
|
||||||
wix
|
wix
|
||||||
@ -2435,6 +2452,8 @@ YLogo
|
|||||||
yml
|
yml
|
||||||
YOffset
|
YOffset
|
||||||
YStr
|
YStr
|
||||||
|
YUY
|
||||||
|
YUYV
|
||||||
yy
|
yy
|
||||||
Zc
|
Zc
|
||||||
ZEROINIT
|
ZEROINIT
|
||||||
|
@ -7,4 +7,5 @@ set SolutionDir=%cd%
|
|||||||
popd
|
popd
|
||||||
SET IsPipeline=1
|
SET IsPipeline=1
|
||||||
call msbuild ../tools/BugReportTool/BugReportTool.sln /p:Configuration=Release /p:Platform=x64 /p:CIBuild=true || exit /b 1
|
call msbuild ../tools/BugReportTool/BugReportTool.sln /p:Configuration=Release /p:Platform=x64 /p:CIBuild=true || exit /b 1
|
||||||
|
call msbuild ../tools/WebcamReportTool/WebcamReportTool.sln /p:Configuration=Release /p:Platform=x64 /p:CIBuild=true || exit /b 1
|
||||||
|
|
||||||
|
@ -55,6 +55,25 @@ steps:
|
|||||||
msbuildArgs: ${{ parameters.additionalBuildArguments }}
|
msbuildArgs: ${{ parameters.additionalBuildArguments }}
|
||||||
maximumCpuCount: true
|
maximumCpuCount: true
|
||||||
|
|
||||||
|
- task: NuGetCommand@2
|
||||||
|
displayName: Restore NuGet packages for WebcamReportTool.sln
|
||||||
|
inputs:
|
||||||
|
command: restore
|
||||||
|
feedsToUse: config
|
||||||
|
configPath: NuGet.config
|
||||||
|
restoreSolution: tools\WebcamReportTool\WebcamReportTool.sln
|
||||||
|
restoreDirectory: '$(Build.SourcesDirectory)\tools\WebcamReportTool\packages'
|
||||||
|
|
||||||
|
- task: VSBuild@1
|
||||||
|
displayName: 'Build WebcamReportTool.sln'
|
||||||
|
inputs:
|
||||||
|
solution: '**\WebcamReportTool.sln'
|
||||||
|
vsVersion: 16.0
|
||||||
|
platform: '$(BuildPlatform)'
|
||||||
|
configuration: '$(BuildConfiguration)'
|
||||||
|
msbuildArgs: ${{ parameters.additionalBuildArguments }}
|
||||||
|
maximumCpuCount: true
|
||||||
|
|
||||||
- task: NuGetCommand@2
|
- task: NuGetCommand@2
|
||||||
displayName: Restore NuGet packages for PowerToysSetup.sln
|
displayName: Restore NuGet packages for PowerToysSetup.sln
|
||||||
inputs:
|
inputs:
|
||||||
|
@ -66,6 +66,7 @@ build:
|
|||||||
include:
|
include:
|
||||||
- 'action_runner.exe'
|
- 'action_runner.exe'
|
||||||
- 'BugReportTool\BugReportTool.exe'
|
- 'BugReportTool\BugReportTool.exe'
|
||||||
|
- 'WebcamReportTool\WebcamReportTool.exe'
|
||||||
- 'modules\ColorPicker\ColorPicker.dll'
|
- 'modules\ColorPicker\ColorPicker.dll'
|
||||||
- 'modules\ColorPicker\ColorPickerUI.dll'
|
- 'modules\ColorPicker\ColorPickerUI.dll'
|
||||||
- 'modules\ColorPicker\ColorPickerUI.exe'
|
- 'modules\ColorPicker\ColorPickerUI.exe'
|
||||||
@ -168,6 +169,7 @@ build:
|
|||||||
to: 'Build_Output'
|
to: 'Build_Output'
|
||||||
include:
|
include:
|
||||||
- 'BugReportTool\BugReportTool.exe'
|
- 'BugReportTool\BugReportTool.exe'
|
||||||
|
- 'WebcamReportTool\WebcamReportTool.exe'
|
||||||
signing_options:
|
signing_options:
|
||||||
sign_inline: true # This does signing a soon as this command completes
|
sign_inline: true # This does signing a soon as this command completes
|
||||||
- !!buildcommand
|
- !!buildcommand
|
||||||
|
26
tools/WebcamReportTool/DirectShowUtils.cpp
Normal file
26
tools/WebcamReportTool/DirectShowUtils.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "DirectShowUtils.h"
|
||||||
|
|
||||||
|
void FreeMediaTypeHelper(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 DeleteMediaTypeHelper(AM_MEDIA_TYPE* pmt)
|
||||||
|
{
|
||||||
|
if (!pmt)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FreeMediaTypeHelper(*pmt);
|
||||||
|
CoTaskMemFree(const_cast<AM_MEDIA_TYPE*>(pmt));
|
||||||
|
}
|
22
tools/WebcamReportTool/DirectShowUtils.h
Normal file
22
tools/WebcamReportTool/DirectShowUtils.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <initguid.h>
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <dshow.h>
|
||||||
|
|
||||||
|
#include <wil/com.h>
|
||||||
|
#include <winrt/Windows.Foundation.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
std::ofstream& log();
|
||||||
|
|
||||||
|
#define TRACE log() << __FUNCTION__ << '\n';
|
||||||
|
#define LOG(msg) log() << msg << '\n';
|
||||||
|
|
||||||
|
void DeleteMediaTypeHelper(AM_MEDIA_TYPE* pmt);
|
||||||
|
|
||||||
|
using unique_media_type_ptr =
|
||||||
|
wistd::unique_ptr<AM_MEDIA_TYPE, wil::function_deleter<decltype(&DeleteMediaTypeHelper), DeleteMediaTypeHelper>>;
|
25
tools/WebcamReportTool/WebcamReportTool.sln
Normal file
25
tools/WebcamReportTool/WebcamReportTool.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.31005.135
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebcamReportTool", "WebcamReportTool.vcxproj", "{FC9599B4-68CD-E14B-71D7-456FDD8D0845}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{FC9599B4-68CD-E14B-71D7-456FDD8D0845}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{FC9599B4-68CD-E14B-71D7-456FDD8D0845}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{FC9599B4-68CD-E14B-71D7-456FDD8D0845}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{FC9599B4-68CD-E14B-71D7-456FDD8D0845}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {536C9E03-09C5-4CAA-AA5E-D62D34A5C09A}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
69
tools/WebcamReportTool/WebcamReportTool.vcxproj
Normal file
69
tools/WebcamReportTool/WebcamReportTool.vcxproj
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{FC9599B4-68CD-E14B-71D7-456FDD8D0845}</ProjectGuid>
|
||||||
|
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
||||||
|
<RootNamespace>WebcamReportTool</RootNamespace>
|
||||||
|
<ProjectName>WebcamReportTool</ProjectName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<IntDir>$(SolutionDir)..\..\$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||||
|
<OutDir>$(SolutionDir)..\..\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<TargetName>WebcamReportTool</TargetName>
|
||||||
|
<TargetExt>.exe</TargetExt>
|
||||||
|
<IncludePath>include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>lib;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>WebcamReportTool</TargetName>
|
||||||
|
<TargetExt>.exe</TargetExt>
|
||||||
|
<IncludePath>include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>lib;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<AdditionalDependencies>Windowsapp.lib;Strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="DirectShowUtils.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="DirectShowUtils.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||||
|
<Import Project="packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>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}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||||
|
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||||
|
<Error Condition="!Exists('packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
219
tools/WebcamReportTool/main.cpp
Normal file
219
tools/WebcamReportTool/main.cpp
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
#include <initguid.h>
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <dshow.h>
|
||||||
|
#include <cguid.h>
|
||||||
|
|
||||||
|
#include <wil/com.h>
|
||||||
|
#include <wil/resource.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <Shlobj.h>
|
||||||
|
#include <Shlobj_core.h>
|
||||||
|
|
||||||
|
#include "DirectShowUtils.h"
|
||||||
|
|
||||||
|
std::ofstream& log()
|
||||||
|
{
|
||||||
|
static std::ofstream report = []{
|
||||||
|
char buffer[MAX_PATH]{};
|
||||||
|
if (SHGetSpecialFolderPathA(HWND_DESKTOP, buffer, CSIDL_DESKTOP, false))
|
||||||
|
{
|
||||||
|
std::string path = buffer;
|
||||||
|
path += "\\WebcamReport.txt";
|
||||||
|
return std::ofstream{ path };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return std::ofstream{ "WebcamReport.txt" };
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetMediaSubTypeString(const GUID& guid)
|
||||||
|
{
|
||||||
|
if (guid == MEDIASUBTYPE_RGB24)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_RGB24";
|
||||||
|
}
|
||||||
|
else if (guid == MEDIASUBTYPE_RGB32)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_RGB32";
|
||||||
|
}
|
||||||
|
else if (guid == MEDIASUBTYPE_YUY2)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_YUY2";
|
||||||
|
}
|
||||||
|
else if (guid == MEDIASUBTYPE_MJPG)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_MJPG";
|
||||||
|
}
|
||||||
|
else if (guid == MEDIASUBTYPE_NV12)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_NV12";
|
||||||
|
}
|
||||||
|
else if (guid == MEDIASUBTYPE_NV11)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_NV11";
|
||||||
|
}
|
||||||
|
else if (guid == MEDIASUBTYPE_YV12)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_YV12";
|
||||||
|
}
|
||||||
|
else if (guid == MEDIASUBTYPE_YUYV)
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_YUYV";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OLECHAR* guidString = nullptr;
|
||||||
|
StringFromCLSID(guid, &guidString);
|
||||||
|
if (guidString)
|
||||||
|
{
|
||||||
|
std::wstring_view wideView{guidString};
|
||||||
|
std::string result;
|
||||||
|
for (const auto c :wideView)
|
||||||
|
{
|
||||||
|
result += static_cast<char>(c);
|
||||||
|
}
|
||||||
|
::CoTaskMemFree(guidString);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "MEDIASUBTYPE_UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogMediaTypes(wil::com_ptr_nothrow<IPin>& pin)
|
||||||
|
{
|
||||||
|
wil::com_ptr_nothrow<IEnumMediaTypes> mediaTypeEnum;
|
||||||
|
if (pin->EnumMediaTypes(&mediaTypeEnum); !mediaTypeEnum)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ULONG _ = 0;
|
||||||
|
unique_media_type_ptr mt;
|
||||||
|
log() << "Supported formats:\n";
|
||||||
|
while (mediaTypeEnum->Next(1, wil::out_param(mt), &_) == S_OK)
|
||||||
|
{
|
||||||
|
if (mt->majortype != MEDIATYPE_Video)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto format = reinterpret_cast<VIDEOINFOHEADER*>(mt->pbFormat);
|
||||||
|
if (!format->AvgTimePerFrame)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto formatAvgFPS = 10000000LL / format->AvgTimePerFrame;
|
||||||
|
log() << GetMediaSubTypeString(mt->subtype) << '\t' << format->bmiHeader.biWidth << "x"
|
||||||
|
<< format->bmiHeader.biHeight << " - " << formatAvgFPS << "fps\n";
|
||||||
|
}
|
||||||
|
log() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReportAllWebcams()
|
||||||
|
{
|
||||||
|
auto enumeratorFactory = wil::CoCreateInstanceNoThrow<ICreateDevEnum>(CLSID_SystemDeviceEnum);
|
||||||
|
if (!enumeratorFactory)
|
||||||
|
{
|
||||||
|
LOG("Couldn't create devenum factory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wil::com_ptr_nothrow<IEnumMoniker> enumMoniker;
|
||||||
|
enumeratorFactory->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &enumMoniker, CDEF_DEVMON_PNP_DEVICE);
|
||||||
|
if (!enumMoniker)
|
||||||
|
{
|
||||||
|
LOG("Couldn't create class enumerator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG _ = 0;
|
||||||
|
wil::com_ptr_nothrow<IMoniker> moniker;
|
||||||
|
while (enumMoniker->Next(1, &moniker, &_) == S_OK)
|
||||||
|
{
|
||||||
|
wil::com_ptr_nothrow<IPropertyBag> propertyData;
|
||||||
|
moniker->BindToStorage(nullptr, nullptr, IID_IPropertyBag, reinterpret_cast<void**>(&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;
|
||||||
|
}
|
||||||
|
std::wstring wideFriendlyName = { propVal.bstrVal, SysStringLen(propVal.bstrVal) };
|
||||||
|
std::string friendlyName;
|
||||||
|
for (wchar_t c : wideFriendlyName)
|
||||||
|
{
|
||||||
|
friendlyName += (char)c;
|
||||||
|
}
|
||||||
|
log() << "Webcam " << friendlyName << '\n';
|
||||||
|
|
||||||
|
propVal.reset();
|
||||||
|
propVal.vt = VT_BSTR;
|
||||||
|
|
||||||
|
if (FAILED(propertyData->Read(L"DevicePath", &propVal, nullptr)))
|
||||||
|
{
|
||||||
|
LOG("Couldn't obtain DevicePath property");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wil::com_ptr_nothrow<IBaseFilter> filter;
|
||||||
|
moniker->BindToObject(nullptr, nullptr, IID_IBaseFilter, reinterpret_cast<void**>(&filter));
|
||||||
|
if (!filter)
|
||||||
|
{
|
||||||
|
LOG("Couldn't BindToObject");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
wil::com_ptr_nothrow<IEnumPins> pinsEnum;
|
||||||
|
if (FAILED(filter->EnumPins(&pinsEnum)))
|
||||||
|
{
|
||||||
|
LOG("BindToObject EnumPins");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wil::com_ptr_nothrow<IPin> pin;
|
||||||
|
|
||||||
|
while (pinsEnum->Next(1, &pin, &_) == S_OK)
|
||||||
|
{
|
||||||
|
// Skip pins which do not belong to capture category
|
||||||
|
GUID category{};
|
||||||
|
DWORD __;
|
||||||
|
if (auto props = pin.try_copy<IKsPropertySet>();
|
||||||
|
!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;
|
||||||
|
}
|
||||||
|
LogMediaTypes(pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
auto comCtx = wil::CoInitializeEx();
|
||||||
|
log() << "Report started\n";
|
||||||
|
ReportAllWebcams();
|
||||||
|
return 0;
|
||||||
|
}
|
5
tools/WebcamReportTool/packages.config
Normal file
5
tools/WebcamReportTool/packages.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.Windows.CppWinRT" version="2.0.200729.8" targetFramework="native" />
|
||||||
|
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.200902.2" targetFramework="native" />
|
||||||
|
</packages>
|
Loading…
Reference in New Issue
Block a user