Skip to content

Commit 4de9b9e

Browse files
committed
1 parent a515712 commit 4de9b9e

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

tools/WebcamReportTool/DirectShowUtils.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "DirectShowUtils.h"
22

3-
void MyFreeMediaTypeHelper(AM_MEDIA_TYPE& mt)
3+
void FreeMediaTypeHelper(AM_MEDIA_TYPE& mt)
44
{
55
if (mt.cbFormat != 0)
66
{
@@ -15,12 +15,12 @@ void MyFreeMediaTypeHelper(AM_MEDIA_TYPE& mt)
1515
}
1616
}
1717

18-
void MyDeleteMediaTypeHelper(AM_MEDIA_TYPE* pmt)
18+
void DeleteMediaTypeHelper(AM_MEDIA_TYPE* pmt)
1919
{
2020
if (!pmt)
2121
{
2222
return;
2323
}
24-
MyFreeMediaTypeHelper(*pmt);
24+
FreeMediaTypeHelper(*pmt);
2525
CoTaskMemFree(const_cast<AM_MEDIA_TYPE*>(pmt));
2626
}

tools/WebcamReportTool/DirectShowUtils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ std::ofstream& log();
1616
#define TRACE log() << __FUNCTION__ << '\n';
1717
#define LOG(msg) log() << msg << '\n';
1818

19-
void MyDeleteMediaTypeHelper(AM_MEDIA_TYPE* pmt);
19+
void DeleteMediaTypeHelper(AM_MEDIA_TYPE* pmt);
2020

2121
using unique_media_type_ptr =
22-
wistd::unique_ptr<AM_MEDIA_TYPE, wil::function_deleter<decltype(&MyDeleteMediaTypeHelper), MyDeleteMediaTypeHelper>>;
22+
wistd::unique_ptr<AM_MEDIA_TYPE, wil::function_deleter<decltype(&DeleteMediaTypeHelper), DeleteMediaTypeHelper>>;

tools/WebcamReportTool/main.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ std::ofstream& log()
2020
return report;
2121
}
2222

23-
const char* GetMediaSubTypeString(const GUID& guid)
23+
std::string GetMediaSubTypeString(const GUID& guid)
2424
{
2525
if (guid == MEDIASUBTYPE_RGB24)
2626
{
@@ -56,7 +56,23 @@ const char* GetMediaSubTypeString(const GUID& guid)
5656
}
5757
else
5858
{
59-
return "MEDIASUBTYPE_UNKNOWN";
59+
OLECHAR* guidString = nullptr;
60+
StringFromCLSID(guid, &guidString);
61+
if (guidString)
62+
{
63+
std::wstring_view wideView{guidString};
64+
std::string result;
65+
for (const auto c :wideView)
66+
{
67+
result += static_cast<char>(c);
68+
}
69+
::CoTaskMemFree(guidString);
70+
return result;
71+
}
72+
else
73+
{
74+
return "MEDIASUBTYPE_UNKNOWN";
75+
}
6076
}
6177
}
6278

0 commit comments

Comments
 (0)