Skip to content

Commit

Permalink
feat: Add support for Openterface Mini-KVM camera plug and play
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinzjpeng committed May 27, 2024
1 parent 099571e commit ded928e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,17 @@ void Camera::init()

// Camera devices:
updateCameras();

setCamera(QMediaDevices::defaultVideoInput());
}

void Camera::setCamera(const QCameraDevice &cameraDevice)
{
if(cameraDevice.description().contains("Openterface") == false){
qCDebug(log_ui_mainwindow) << "The camera is not an Openterface Mini-KVM, skip it.";
return;
}
qCDebug(log_ui_mainwindow) << "Set Camera, device name: " << cameraDevice.description();
m_camera.reset(new QCamera(cameraDevice));
m_captureSession.setCamera(m_camera.data());

Expand Down Expand Up @@ -428,8 +434,11 @@ void Camera::displayCameraError()

stackedLayout->setCurrentIndex(0);

disconnect(m_camera.data());

m_audioInput->disconnect();
m_captureSession.disconnect();

}
}

Expand Down Expand Up @@ -483,6 +492,12 @@ void Camera::updateCameras()

stackedLayout->setCurrentIndex(1);

//If the default camera is not an Openterface camera, set the camera to the first Openterface camera
//if (QMediaDevices::defaultVideoInput().description().contains("Openterface") == false) {
//update the default camera to the first Openterface camera
setCamera(camera);
//}

break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Camera</string>
<string>Openterface Mini-KVM</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="cursor">
Expand Down

0 comments on commit ded928e

Please sign in to comment.