6#include <private/qcameradevice_p.h>
7#include <private/qwindowsmfdefs_p.h>
8#include <private/qwindowsmultimediautils_p.h>
9#include <private/qcomptr_p.h>
10#include <private/qcomtaskresource_p.h>
15#include <mfreadwrite.h>
22 if (
message == WM_DEVICECHANGE) {
23 auto b = (PDEV_BROADCAST_HDR)lParam;
24 if (
b &&
b->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
27 if (wParam == DBT_DEVICEARRIVAL || wParam == DBT_DEVICEREMOVECOMPLETE) {
28 emit wmd->videoInputsChanged();
42 wx.cbSize =
sizeof(WNDCLASSEX);
44 wx.hInstance = GetModuleHandle(
nullptr);
47 if (!RegisterClassEx(&wx))
51 0, 0, 0, 0, 0, HWND_MESSAGE,
nullptr,
nullptr,
nullptr);
63 CoInitialize(
nullptr);
66 if (m_videoDeviceMsgWindow) {
67 SetWindowLongPtr(m_videoDeviceMsgWindow, GWLP_USERDATA, (LONG_PTR)
this);
69 DEV_BROADCAST_DEVICEINTERFACE di = {};
70 di.dbcc_size =
sizeof(di);
71 di.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
74 m_videoDeviceNotification =
75 RegisterDeviceNotification(m_videoDeviceMsgWindow, &di, DEVICE_NOTIFY_WINDOW_HANDLE);
76 if (!m_videoDeviceNotification) {
77 DestroyWindow(m_videoDeviceMsgWindow);
78 m_videoDeviceMsgWindow =
nullptr;
84 if (!m_videoDeviceNotification) {
85 qWarning() <<
"Video device change notification disabled";
91 if (m_videoDeviceNotification) {
92 UnregisterDeviceNotification(m_videoDeviceNotification);
95 if (m_videoDeviceMsgWindow) {
96 DestroyWindow(m_videoDeviceMsgWindow);
105 GUID subtype = GUID_NULL;
106 if (FAILED(mediaFormat->GetGUID(MF_MT_SUBTYPE, &subtype)))
115 if (FAILED(MFGetAttributeSize(mediaFormat, MF_MT_FRAME_SIZE, &
width, &
height)))
124 if (SUCCEEDED(MFGetAttributeRatio(mediaFormat, MF_MT_FRAME_RATE_RANGE_MIN, &
num, &den)))
125 minFr = float(
num) / float(den);
127 if (SUCCEEDED(MFGetAttributeRatio(mediaFormat, MF_MT_FRAME_RATE_RANGE_MAX, &
num, &den)))
128 maxFr = float(
num) / float(den);
148 auto info = std::make_unique<QCameraDevicePrivate>();
152 IMFMediaSource *
source = NULL;
157 ComPtr<IMFSourceReader> reader;
158 hr = MFCreateSourceReaderFromMediaSource(
source, NULL, reader.GetAddressOf());
164 for (DWORD
i = 0;; ++
i) {
166 ComPtr<IMFMediaType> mediaFormat;
167 hr = reader->GetNativeMediaType((DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM,
i,
168 mediaFormat.GetAddressOf());
174 videoFormats << *maybeCamera;
175 photoResolutions << maybeCamera->resolution();
179 info->videoFormats = videoFormats;
180 info->photoResolutions = photoResolutions;
181 return info.release()->create();
188 IMFActivate **devicesRaw =
nullptr;
189 HRESULT hr = MFEnumDeviceSources(attr, &devicesRaw, &
count);
193 for (UINT32
i = 0;
i <
count;
i++) {
198 cameras << *maybeCamera;
209 ComPtr<IMFAttributes> attr;
210 HRESULT hr = MFCreateAttributes(attr.GetAddressOf(), 2);
214 hr = attr->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
215 MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
219 hr = attr->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_CATEGORY,
IOBluetoothDevice * device
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
QByteArray toUtf8() const &
QList< QCameraDevice > videoDevices() const override
QWindowsVideoDevices(QPlatformMediaIntegration *integration)
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLint GLsizei GLsizei height
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * message
GLsizei GLsizei GLchar * source
const GUID QMM_KSCATEGORY_VIDEO_CAMERA
const GUID QMM_KSCATEGORY_SENSOR_CAMERA
static QString getString(IMFActivate *device, const IID &id)
QT_BEGIN_NAMESPACE LRESULT QT_WIN_CALLBACK deviceNotificationWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static const auto windowClassName
static std::optional< QCameraFormat > createCameraFormat(IMFMediaType *mediaFormat)
static std::optional< QCameraDevice > createCameraDevice(IMFActivate *device)
static HWND createMessageOnlyWindow()
static QList< QCameraDevice > readCameraDevices(IMFAttributes *attr)
QFileInfo info(fileName)
[8]