From 2e7c80a4f9d4f50a82c674863ce159856c748873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Sun, 2 Aug 2020 23:57:17 +0200 Subject: libcamera: camera: Rename name() to id() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename Camera::name() to camera::id() to better describe what it represents, a unique and stable ID for the camera. While at it improve the documentation for the camera ID to describe it needs to be stable for a camera between resets of the system. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/qcam/dng_writer.cpp | 5 +++-- src/qcam/main_window.cpp | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/qcam') diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index 8fb9681c..b5b81f06 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -386,8 +386,9 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, TIFFTAG_DNGBACKWARDVERSION, version); TIFFSetField(tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); TIFFSetField(tif, TIFFTAG_MAKE, "libcamera"); - TIFFSetField(tif, TIFFTAG_MODEL, camera->name().c_str()); - TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, camera->name().c_str()); + /* \todo Report a real model string instead of id. */ + TIFFSetField(tif, TIFFTAG_MODEL, camera->id().c_str()); + TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, camera->id().c_str()); TIFFSetField(tif, TIFFTAG_SOFTWARE, "qcam"); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 13a4fefe..75035372 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -169,7 +169,7 @@ int MainWindow::createToolbars() this, &MainWindow::switchCamera); for (const std::shared_ptr &cam : cm_->cameras()) - cameraCombo_->addItem(QString::fromStdString(cam->name())); + cameraCombo_->addItem(QString::fromStdString(cam->id())); toolbar_->addWidget(cameraCombo_); @@ -241,11 +241,11 @@ void MainWindow::switchCamera(int index) const std::shared_ptr &cam = cameras[index]; if (cam->acquire()) { - qInfo() << "Failed to acquire camera" << cam->name().c_str(); + qInfo() << "Failed to acquire camera" << cam->id().c_str(); return; } - qInfo() << "Switching to camera" << cam->name().c_str(); + qInfo() << "Switching to camera" << cam->id().c_str(); /* * Stop the capture session, release the current camera, replace it with @@ -266,19 +266,19 @@ std::string MainWindow::chooseCamera() /* If only one camera is available, use it automatically. */ if (cm_->cameras().size() == 1) - return cm_->cameras()[0]->name(); + return cm_->cameras()[0]->id(); /* Present a dialog box to pick a camera. */ for (const std::shared_ptr &cam : cm_->cameras()) - cameras.append(QString::fromStdString(cam->name())); + cameras.append(QString::fromStdString(cam->id())); - QString name = QInputDialog::getItem(this, "Select Camera", - "Camera:", cameras, 0, - false, &result); + QString id = QInputDialog::getItem(this, "Select Camera", + "Camera:", cameras, 0, + false, &result); if (!result) return std::string(); - return name.toStdString(); + return id.toStdString(); } int MainWindow::openCamera() @@ -582,7 +582,7 @@ void MainWindow::processHotplug(HotplugEvent *e) HotplugEvent::PlugEvent event = e->hotplugEvent(); if (event == HotplugEvent::HotPlug) { - cameraCombo_->addItem(QString::fromStdString(camera->name())); + cameraCombo_->addItem(QString::fromStdString(camera->id())); } else if (event == HotplugEvent::HotUnplug) { /* Check if the currently-streaming camera is removed. */ if (camera == camera_.get()) { @@ -592,14 +592,14 @@ void MainWindow::processHotplug(HotplugEvent *e) cameraCombo_->setCurrentIndex(0); } - int camIndex = cameraCombo_->findText(QString::fromStdString(camera->name())); + int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id())); cameraCombo_->removeItem(camIndex); } } void MainWindow::addCamera(std::shared_ptr camera) { - qInfo() << "Adding new camera:" << camera->name().c_str(); + qInfo() << "Adding new camera:" << camera->id().c_str(); QCoreApplication::postEvent(this, new HotplugEvent(std::move(camera), HotplugEvent::HotPlug)); @@ -607,7 +607,7 @@ void MainWindow::addCamera(std::shared_ptr camera) void MainWindow::removeCamera(std::shared_ptr camera) { - qInfo() << "Removing camera:" << camera->name().c_str(); + qInfo() << "Removing camera:" << camera->id().c_str(); QCoreApplication::postEvent(this, new HotplugEvent(std::move(camera), HotplugEvent::HotUnplug)); -- cgit v1.2.1