Skip to content

Commit

Permalink
Add multi-monitor and P010 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Oct 29, 2024
1 parent 1785dd2 commit c55be9d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
3 changes: 3 additions & 0 deletions include/grabber/windows/DX/DxGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public slots:

private:

const QString MULTI_MONITOR = "MULTI-MONITOR";

void captureFrame(DisplayHandle& display);

QString GetSharedLut();
Expand All @@ -127,6 +129,7 @@ public slots:
QTimer* _retryTimer;
int _warningCounter;
bool _wideGamut;
bool _multiMonitor;

bool _dxRestartNow;
std::list<std::unique_ptr<DisplayHandle>> _handles;
Expand Down
9 changes: 9 additions & 0 deletions include/utils/PixelFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum class PixelFormat {
I420,
NV12,
MJPEG,
P010,
NO_CHANGE
};

Expand Down Expand Up @@ -42,6 +43,10 @@ inline PixelFormat parsePixelFormat(const QString& pixelFormat)
{
return PixelFormat::MJPEG;
}
else if (format.compare("p010") == 0)
{
return PixelFormat::P010;
}

return PixelFormat::NO_CHANGE;
}
Expand Down Expand Up @@ -73,6 +78,10 @@ inline QString pixelFormatToString(const PixelFormat& pixelFormat)
{
return "mjpeg";
}
else if (pixelFormat == PixelFormat::P010)
{
return "p010";
}

return "NO_CHANGE";
}
3 changes: 3 additions & 0 deletions sources/grabber/linux/v4l2/V4L2Grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ static const V4L2Grabber::HyperHdrFormat supportedFormats[] =
{ V4L2_PIX_FMT_YUV420, PixelFormat::I420 },
{ V4L2_PIX_FMT_NV12, PixelFormat::NV12 },
{ V4L2_PIX_FMT_MJPEG, PixelFormat::MJPEG }
#ifdef V4L2_PIX_FMT_P010
,{ V4L2_PIX_FMT_P010, PixelFormat::P010 }
#endif
};


Expand Down
17 changes: 14 additions & 3 deletions sources/grabber/windows/DX/DxGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ DxGrabber::DxGrabber(const QString& device, const QString& configurationPath)
, _retryTimer(new QTimer(this))
, _warningCounter(MAX_WARNINGS)
, _wideGamut(false)
, _multiMonitor(false)


, _dxRestartNow(false)
Expand Down Expand Up @@ -241,7 +242,8 @@ void DxGrabber::enumerateDevices(bool silent)
pAdapter->GetDesc1(&pDesc);

IDXGIOutput* pOutput;
for (UINT j = 0; pAdapter->EnumOutputs(j, &pOutput) != DXGI_ERROR_NOT_FOUND; j++)
UINT j = 0;
for (; pAdapter->EnumOutputs(j, &pOutput) != DXGI_ERROR_NOT_FOUND; j++)
{
DXGI_OUTPUT_DESC oDesc;
pOutput->GetDesc(&oDesc);
Expand All @@ -251,6 +253,12 @@ void DxGrabber::enumerateDevices(bool silent)

SafeRelease(&pOutput);
}

if (j > 1)
{
_deviceProperties.insert(MULTI_MONITOR + "|" + QString::fromWCharArray(pDesc.Description), properties);
}

SafeRelease(&pAdapter);
}
SafeRelease(&pFactory);
Expand Down Expand Up @@ -303,18 +311,21 @@ bool DxGrabber::initDirectX(QString selectedDeviceName)
{
DeviceProperties properties;
DXGI_ADAPTER_DESC1 pDesc;
QString multiName = MULTI_MONITOR + "|" + QString::fromWCharArray(pDesc.Description);

pAdapter->GetDesc1(&pDesc);

_multiMonitor = (selectedDeviceName == multiName);

IDXGIOutput* pOutput;
for (UINT j = 0; pAdapter->EnumOutputs(j, &pOutput) != DXGI_ERROR_NOT_FOUND && !exitNow; j++)
for (UINT j = 0; pAdapter->EnumOutputs(j, &pOutput) != DXGI_ERROR_NOT_FOUND && (!exitNow || _multiMonitor); j++)
{
DXGI_OUTPUT_DESC oDesc;
pOutput->GetDesc(&oDesc);

QString currentName = (QString::fromWCharArray(oDesc.DeviceName) + "|" + QString::fromWCharArray(pDesc.Description));

exitNow = (currentName == selectedDeviceName);
exitNow = (currentName == selectedDeviceName) || _multiMonitor;

if (exitNow)
{
Expand Down
2 changes: 1 addition & 1 deletion sources/grabber/windows/MF/MFGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const static VideoFormat fmt_array[] =
{ MFVideoFormat_Y42T, "Y42T", PixelFormat::NO_CHANGE },
{ MFVideoFormat_P210, "P210", PixelFormat::NO_CHANGE },
{ MFVideoFormat_P216, "P216", PixelFormat::NO_CHANGE },
{ MFVideoFormat_P010, "P010", PixelFormat::NO_CHANGE },
{ MFVideoFormat_P010, "P010", PixelFormat::P010 },
{ MFVideoFormat_P016, "P016", PixelFormat::NO_CHANGE },
{ MFVideoFormat_v210, "v210", PixelFormat::NO_CHANGE },
{ MFVideoFormat_v216, "v216", PixelFormat::NO_CHANGE },
Expand Down

0 comments on commit c55be9d

Please sign in to comment.