Skip to content

Commit

Permalink
minor changes. update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
MetaDevo committed Sep 6, 2023
1 parent 2ca61b1 commit ecec65a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# wasm-video-recorder
A Qt WebAssembly camera viewer / recorder.

This can be built for desktop but the point is to test out pure Qt camera abilities in a WebAssembly target.
As of Qt 6.5.2, this doesn't get a non-null QCameraFormat, even though the permissions mechanism seems to work. It also can't access the camera device descriptions.

The wasm demo resides here: https://metadevo.github.io/wasm-video-recorder/
28 changes: 14 additions & 14 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ MainWindow::MainWindow(QWidget *parent)
ui->setupUi(this);

#ifdef USE_PERMISSIONS
QCameraPermission camPermission;
switch (qApp->checkPermission(camPermission)) {
//QCameraPermission camPermission;
switch (qApp->checkPermission(QCameraPermission{})) {
case Qt::PermissionStatus::Undetermined:
qDebug() << "Undetermined";
qApp->requestPermission(camPermission, this, &MainWindow::permissionsChanged);
qApp->requestPermission(QCameraPermission{}, this, &MainWindow::permissionsChanged);
break;
case Qt::PermissionStatus::Denied:
qDebug() << "Denied";
Expand Down Expand Up @@ -71,32 +71,31 @@ void MainWindow::permissionsChanged(const QPermission& permission)
void MainWindow::updateCameraList()
{
m_availableCams = QMediaDevices::videoInputs();
m_availableMics = QMediaDevices::audioInputs();
//m_availableMics = QMediaDevices::audioInputs();
qDebug() << Q_FUNC_INFO << "Num cams: " << m_availableCams.size();
qDebug() << Q_FUNC_INFO << "Num mics: " << m_availableMics.size();
//qDebug() << Q_FUNC_INFO << "Num mics: " << m_availableMics.size();

ui->camListWidget->clear();
int i = 0;
for (const QCameraDevice& cameraDevice : m_availableCams) {
qDebug() << "Cam " << ++i << cameraDevice.description();
QString desc = cameraDevice.description();
if (desc.isEmpty()) {
qDebug() << "ID: " << cameraDevice.id();
desc = "camera " + QString::number(i);
if (cameraDevice.isNull()) {
qDebug() << desc << "is null.";
}
}
ui->camListWidget->addItem(desc);

// if (cameraDevice == QMediaDevices::defaultVideoInput()) {
// qDebug() << "Loading " << desc;
// loadCamera(cameraDevice);
// }
}
}

void MainWindow::loadCamera(const QCameraDevice& device)
{
m_camera.reset(new QCamera(device));
m_captureSession.setCamera(m_camera.data());
m_captureSession.setVideoOutput(m_videoItem);
//m_captureSession.setCamera(m_camera.data());
//m_captureSession.setVideoOutput(m_videoItem);

qDebug() << Q_FUNC_INFO << "Initial format:";
printCameraFormat(m_camera->cameraFormat());
Expand All @@ -118,16 +117,17 @@ void MainWindow::loadCamera(const QCameraDevice& device)
bestFormat = fmt;
}
}

m_camera->setCameraFormat(bestFormat);
//m_mediaRecorder->setVideoFrameRate(bestFormat.maxFrameRate());
}
else
{
qDebug() << Q_FUNC_INFO << "No formats available.";
}
}


//m_mediaRecorder->setVideoFrameRate(bestFormat.maxFrameRate());

qDebug() << Q_FUNC_INFO << "Final format:";
printCameraFormat(m_camera->cameraFormat());

Expand Down
2 changes: 1 addition & 1 deletion mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ private slots:
QList<QCameraDevice> m_availableCams;
QList<QAudioDevice> m_availableMics;
QScopedPointer<QCamera> m_camera;
QMediaCaptureSession m_captureSession;
//QMediaCaptureSession m_captureSession;
};
#endif // MAINWINDOW_H

0 comments on commit ecec65a

Please sign in to comment.