void CameraModeControl::setDevice(const QString &device) { if(device != m_device) { m_device = device; if(m_camera) { QMediaObject *mediaObject = m_camera ? qobject_cast<QMediaObject *>(m_camera->property("mediaObject").value<QObject*>()) : nullptr; if(mediaObject) { QVideoDeviceSelectorControl *videoDevice = mediaObject->service()->requestControl<QVideoDeviceSelectorControl*>(); if(videoDevice) { const int value = ("primary" == device) ? 0 : 1; if(videoDevice->selectedDevice() != value) { videoDevice->setSelectedDevice(value); } } } } emit deviceChanged(m_device); } }
void ChilitagsDetection::setSource(QObject *source) { QVariant mediaObjectProperty = source->property("mediaObject"); QMediaObject *mediaObject = qvariant_cast<QMediaObject *>(mediaObjectProperty); QMediaService *mediaService = mediaObject->service(); QVideoRendererControl *rendererControl = mediaService->requestControl<QVideoRendererControl *>(); rendererControl->setSurface(&m_surface); m_source = source; }