Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win-dshow: Check for custom placeholder.png #4446

Closed
wants to merge 24 commits into from
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f71c890
awin-dshow: Check for custom placeholder.png file
pedanticdan Apr 11, 2021
b4192fa
awin-dshow: Check for custom placeholder.png file
pedanticdan Apr 11, 2021
44dd69f
win-dshow: Check for custom placeholder.png file
pedanticdan Apr 11, 2021
f143a83
win-dshow: Check for custom placeholder.png file
pedanticdan Apr 14, 2021
004eea5
win-dshow: Check for custom placeholder.png file
pedanticdan Apr 16, 2021
3cca37b
win-dshow: Check for custom placeholder.png file
pedanticdan Apr 18, 2021
63738cb
win-dshow: Check for custom placeholder.png file
pedanticdan Apr 24, 2021
4de4870
win-dshow: Check for custom placeholder.png file
pedanticdan Apr 27, 2021
db776e0
win-dshow: Check for custom placeholder.png file
pedanticdan May 3, 2021
c13d257
win-dshow: Check for custom placeholder.png file
pedanticdan May 11, 2021
a47e861
win-dshow: Check for custom placeholder.png file
pedanticdan May 16, 2021
0a39c77
win-dshow: Check for custom placeholder.png file
pedanticdan May 29, 2021
31ee6d3
win-dshow: Check for custom placeholder.png file
pedanticdan Jun 5, 2021
1c88bf8
win-dshow: Check for custom placeholder.png file
pedanticdan Jun 26, 2021
71b73fa
win-dshow: Check for custom placeholder.png file
pedanticdan Jul 30, 2021
2d0011e
win-dshow: Check for custom placeholder.png file
pedanticdan Aug 27, 2021
5c1a0ef
win-dshow: Check for custom placeholer.png file
pedanticdan Nov 2, 2021
c0299b4
win-dshow: Check for custom placeholer.png file
pedanticdan Jan 17, 2022
17b89fa
win-dshow: Check for custom placeholer.png file
pedanticdan Jan 22, 2022
1f44d48
Merge branch 'obsproject:master' into win-dshow2
pedanticdan Feb 6, 2022
36df764
Merge branch 'obsproject:master' into win-dshow2
pedanticdan Feb 8, 2022
c8a9041
Merge branch 'obsproject:master' into win-dshow2
pedanticdan Feb 11, 2022
b8467b2
Merge branch 'obsproject:master' into win-dshow2
pedanticdan Mar 12, 2022
a498950
Merge branch 'obsproject:master' into win-dshow2
pedanticdan Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 49 additions & 16 deletions plugins/win-dshow/virtualcam-module/placeholder.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <windows.h>
#include <shlobj_core.h>
#include <strsafe.h>
#include <gdiplus.h>
#include <stdint.h>
#include <vector>
#include <filesystem>

using namespace Gdiplus;

Expand Down Expand Up @@ -78,24 +80,10 @@ static void convert_placeholder(const uint8_t *rgb_in, int width, int height)
}
}

static bool load_placeholder_internal()
static bool load_placeholder_common(wchar_t *file)
{
Status s;

wchar_t file[MAX_PATH];
if (!GetModuleFileNameW(dll_inst, file, MAX_PATH)) {
return false;
}

wchar_t *slash = wcsrchr(file, '\\');
if (!slash) {
return false;
}

slash[1] = 0;

StringCbCat(file, sizeof(file), L"placeholder.png");

Bitmap bmp(file);
if (bmp.GetLastStatus() != Status::Ok) {
return false;
Expand All @@ -118,6 +106,49 @@ static bool load_placeholder_internal()
return true;
}

static bool load_placeholder_external()
{
wchar_t file[MAX_PATH] = {L""};
PWSTR pszPath = NULL;

HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL,
&pszPath);
if (hr != S_OK) {
CoTaskMemFree((wchar_t *)pszPath);
return false;
}

StringCbCat(file, sizeof(file), pszPath);
StringCbCat(file, sizeof(file),
L"\\obs-studio\\plugin_config\\win-dshow\\placeholder.png");
CoTaskMemFree(pszPath);

if (std::filesystem::exists(file)) {
return load_placeholder_common(file);
} else {
return false;
}
}

static bool load_placeholder_internal()
{
wchar_t file[MAX_PATH];
if (!GetModuleFileNameW(dll_inst, file, MAX_PATH)) {
return false;
}

wchar_t *slash = wcsrchr(file, '\\');
if (!slash) {
return false;
}

slash[1] = 0;

StringCbCat(file, sizeof(file), L"placeholder.png");

return load_placeholder_common(file);
}

bool initialize_placeholder()
{
if (initialized)
Expand All @@ -127,7 +158,9 @@ bool initialize_placeholder()
ULONG_PTR token;
GdiplusStartup(&token, &si, nullptr);

initialized = load_placeholder_internal();
initialized = load_placeholder_external();
if (!initialized)
initialized = load_placeholder_internal();

GdiplusShutdown(token);
return initialized;
Expand Down
Loading