Compare commits

..

2 Commits

Author SHA1 Message Date
weil bef8baba5f Fix screen change mechanism; create method for counting screens 2024-07-09 16:58:12 +02:00
weil 57505fd06d Recompile some libraries for compatibility 2024-07-09 16:07:09 +02:00
7 changed files with 59 additions and 8 deletions

BIN
3rdparty/opus/lib/opus.lib (Stored with Git LFS) vendored

Binary file not shown.

BIN
3rdparty/speex/lib/libspeex.lib (Stored with Git LFS) vendored

Binary file not shown.

BIN
3rdparty/speex/lib/libspeexdsp.lib (Stored with Git LFS) vendored

Binary file not shown.

View File

@ -51,6 +51,7 @@ void Obs::_bind_methods()
{
ClassDB::bind_method(D_METHOD("get_screen_frame"), &Obs::getEncodedScreenFrame);
ClassDB::bind_method(D_METHOD("render_frame"), &Obs::renderFrameToMesh);
ClassDB::bind_method(D_METHOD("get_screen_count"), &Obs::getScreenCount);
}
@ -176,4 +177,9 @@ void Obs::renderFrameToMesh(PackedByteArray frame, Ref<StandardMaterial3D> mat)
#endif
}
size_t Obs::getScreenCount() const
{
return microtaur::ScreenEnumerator().count();
}
}

View File

@ -31,6 +31,8 @@ public:
PackedByteArray getEncodedScreenFrame(size_t id);
void renderFrameToMesh(PackedByteArray frame, Ref<StandardMaterial3D> mat);
size_t getScreenCount() const;
private:
bool m_initialized{false};
bool m_decInitialized{false};

View File

@ -18,8 +18,18 @@
using namespace godot;
namespace microtaur
namespace microtaur {
namespace {
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
auto* count = reinterpret_cast<size_t*>(dwData);
(*count)++;
return TRUE;
}
}
class AcceleratedWindowCapturer
{
@ -64,7 +74,7 @@ public:
dxgiDevice->Release();
IDXGIOutput* dxgiOutput = nullptr;
hr = dxgiAdapter->EnumOutputs(1, &dxgiOutput); // TODO: screen choose
hr = dxgiAdapter->EnumOutputs(m_currentScreen, &dxgiOutput);
if (FAILED(hr)) {
reset();
return;
@ -377,6 +387,17 @@ public:
init();
}
void setCurrentScreen(size_t target)
{
m_currentScreen = target;
reset();
}
size_t getCurrentScreen() const
{
return m_currentScreen;
}
private:
Microsoft::WRL::ComPtr<ID3D11Device> m_device;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_context;
@ -390,6 +411,8 @@ private:
size_t m_width{};
size_t m_height{};
size_t m_currentScreen{};
};
@ -404,7 +427,21 @@ WindowCapturer::~WindowCapturer()
Frame WindowCapturer::capture(size_t id, size_t width, size_t height)
{
if (id != m_impl->getCurrentScreen()) {
m_impl->setCurrentScreen(id);
}
return m_impl->nextFrame(width, height);
}
size_t ScreenEnumerator::count()
{
size_t c = 0;
if (EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&c)) {
return c;
}
return -1;
}
}

View File

@ -27,4 +27,10 @@ private:
};
class ScreenEnumerator
{
public:
static size_t count();
};
}