[libcamera-devel] [PATCH 12/30] cam: Rename Capture to CameraSession
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Jul 7 04:19:23 CEST 2021
Rename the Capture class to CameraSession, to prepare for multi-camera
support that will gather more camera-related operations than capture in
that class.
While at it, remove an unneeded blank line.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/cam/{capture.cpp => camera_session.cpp} | 21 ++++++++++-----------
src/cam/{capture.h => camera_session.h} | 16 ++++++++--------
src/cam/main.cpp | 6 +++---
src/cam/meson.build | 2 +-
4 files changed, 22 insertions(+), 23 deletions(-)
rename src/cam/{capture.cpp => camera_session.cpp} (90%)
rename src/cam/{capture.h => camera_session.h} (77%)
diff --git a/src/cam/capture.cpp b/src/cam/camera_session.cpp
similarity index 90%
rename from src/cam/capture.cpp
rename to src/cam/camera_session.cpp
index 3c3e3a53adf7..439dcdb29ad7 100644
--- a/src/cam/capture.cpp
+++ b/src/cam/camera_session.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * capture.cpp - Cam capture
+ * camera_session.cpp - Camera capture session
*/
#include <iomanip>
@@ -12,20 +12,20 @@
#include <libcamera/control_ids.h>
-#include "capture.h"
+#include "camera_session.h"
#include "main.h"
using namespace libcamera;
-Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,
- EventLoop *loop)
+CameraSession::CameraSession(std::shared_ptr<Camera> camera,
+ CameraConfiguration *config, EventLoop *loop)
: camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop),
queueCount_(0), captureCount_(0), captureLimit_(0),
printMetadata_(false)
{
}
-int Capture::run(const OptionsParser::Options &options)
+int CameraSession::run(const OptionsParser::Options &options)
{
int ret;
@@ -51,7 +51,7 @@ int Capture::run(const OptionsParser::Options &options)
streamName_[cfg.stream()] = "stream" + std::to_string(index);
}
- camera_->requestCompleted.connect(this, &Capture::requestComplete);
+ camera_->requestCompleted.connect(this, &CameraSession::requestComplete);
if (options.isSet(OptFile)) {
if (!options[OptFile].toString().empty())
@@ -60,7 +60,6 @@ int Capture::run(const OptionsParser::Options &options)
writer_ = new BufferWriter();
}
-
FrameBufferAllocator *allocator = new FrameBufferAllocator(camera_);
ret = capture(allocator);
@@ -77,7 +76,7 @@ int Capture::run(const OptionsParser::Options &options)
return ret;
}
-int Capture::capture(FrameBufferAllocator *allocator)
+int CameraSession::capture(FrameBufferAllocator *allocator)
{
int ret;
@@ -157,7 +156,7 @@ int Capture::capture(FrameBufferAllocator *allocator)
return ret;
}
-int Capture::queueRequest(Request *request)
+int CameraSession::queueRequest(Request *request)
{
if (captureLimit_ && queueCount_ >= captureLimit_)
return 0;
@@ -167,7 +166,7 @@ int Capture::queueRequest(Request *request)
return camera_->queueRequest(request);
}
-void Capture::requestComplete(Request *request)
+void CameraSession::requestComplete(Request *request)
{
if (request->status() == Request::RequestCancelled)
return;
@@ -179,7 +178,7 @@ void Capture::requestComplete(Request *request)
loop_->callLater([=]() { processRequest(request); });
}
-void Capture::processRequest(Request *request)
+void CameraSession::processRequest(Request *request)
{
const Request::BufferMap &buffers = request->buffers();
diff --git a/src/cam/capture.h b/src/cam/camera_session.h
similarity index 77%
rename from src/cam/capture.h
rename to src/cam/camera_session.h
index de478c98e9c1..ef8a11c3bfb4 100644
--- a/src/cam/capture.h
+++ b/src/cam/camera_session.h
@@ -2,10 +2,10 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * capture.h - Cam capture
+ * camera_session.h - Camera capture session
*/
-#ifndef __CAM_CAPTURE_H__
-#define __CAM_CAPTURE_H__
+#ifndef __CAM_CAMERA_SESSION_H__
+#define __CAM_CAMERA_SESSION_H__
#include <memory>
#include <stdint.h>
@@ -21,12 +21,12 @@
#include "event_loop.h"
#include "options.h"
-class Capture
+class CameraSession
{
public:
- Capture(std::shared_ptr<libcamera::Camera> camera,
- libcamera::CameraConfiguration *config,
- EventLoop *loop);
+ CameraSession(std::shared_ptr<libcamera::Camera> camera,
+ libcamera::CameraConfiguration *config,
+ EventLoop *loop);
int run(const OptionsParser::Options &options);
private:
@@ -52,4 +52,4 @@ private:
std::vector<std::unique_ptr<libcamera::Request>> requests_;
};
-#endif /* __CAM_CAPTURE_H__ */
+#endif /* __CAM_CAMERA_SESSION_H__ */
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 70e9f62c7cb0..f71b65a20fe2 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -13,7 +13,7 @@
#include <libcamera/libcamera.h>
#include <libcamera/property_ids.h>
-#include "capture.h"
+#include "camera_session.h"
#include "event_loop.h"
#include "main.h"
#include "options.h"
@@ -363,8 +363,8 @@ int CamApp::run()
}
if (options_.isSet(OptCapture)) {
- Capture capture(camera_, config_.get(), &loop_);
- return capture.run(options_);
+ CameraSession session(camera_, config_.get(), &loop_);
+ return session.run(options_);
}
if (options_.isSet(OptMonitor)) {
diff --git a/src/cam/meson.build b/src/cam/meson.build
index 6234ed0a059a..1e90ee521f74 100644
--- a/src/cam/meson.build
+++ b/src/cam/meson.build
@@ -11,7 +11,7 @@ cam_enabled = true
cam_sources = files([
'buffer_writer.cpp',
- 'capture.cpp',
+ 'camera_session.cpp',
'event_loop.cpp',
'main.cpp',
'options.cpp',
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list