cam: Rename Capture to CameraSession
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@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
180e95f06a
commit
94d828d880
4 changed files with 22 additions and 23 deletions
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2019, Google Inc.
|
* Copyright (C) 2019, Google Inc.
|
||||||
*
|
*
|
||||||
* capture.cpp - Cam capture
|
* camera_session.cpp - Camera capture session
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
@ -12,20 +12,20 @@
|
||||||
|
|
||||||
#include <libcamera/control_ids.h>
|
#include <libcamera/control_ids.h>
|
||||||
|
|
||||||
#include "capture.h"
|
#include "camera_session.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,
|
CameraSession::CameraSession(std::shared_ptr<Camera> camera,
|
||||||
EventLoop *loop)
|
CameraConfiguration *config, EventLoop *loop)
|
||||||
: camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop),
|
: camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop),
|
||||||
queueCount_(0), captureCount_(0), captureLimit_(0),
|
queueCount_(0), captureCount_(0), captureLimit_(0),
|
||||||
printMetadata_(false)
|
printMetadata_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int Capture::run(const OptionsParser::Options &options)
|
int CameraSession::run(const OptionsParser::Options &options)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ int Capture::run(const OptionsParser::Options &options)
|
||||||
streamName_[cfg.stream()] = "stream" + std::to_string(index);
|
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.isSet(OptFile)) {
|
||||||
if (!options[OptFile].toString().empty())
|
if (!options[OptFile].toString().empty())
|
||||||
|
@ -60,7 +60,6 @@ int Capture::run(const OptionsParser::Options &options)
|
||||||
writer_ = new BufferWriter();
|
writer_ = new BufferWriter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FrameBufferAllocator *allocator = new FrameBufferAllocator(camera_);
|
FrameBufferAllocator *allocator = new FrameBufferAllocator(camera_);
|
||||||
|
|
||||||
ret = capture(allocator);
|
ret = capture(allocator);
|
||||||
|
@ -77,7 +76,7 @@ int Capture::run(const OptionsParser::Options &options)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Capture::capture(FrameBufferAllocator *allocator)
|
int CameraSession::capture(FrameBufferAllocator *allocator)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ int Capture::capture(FrameBufferAllocator *allocator)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Capture::queueRequest(Request *request)
|
int CameraSession::queueRequest(Request *request)
|
||||||
{
|
{
|
||||||
if (captureLimit_ && queueCount_ >= captureLimit_)
|
if (captureLimit_ && queueCount_ >= captureLimit_)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -167,7 +166,7 @@ int Capture::queueRequest(Request *request)
|
||||||
return camera_->queueRequest(request);
|
return camera_->queueRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Capture::requestComplete(Request *request)
|
void CameraSession::requestComplete(Request *request)
|
||||||
{
|
{
|
||||||
if (request->status() == Request::RequestCancelled)
|
if (request->status() == Request::RequestCancelled)
|
||||||
return;
|
return;
|
||||||
|
@ -179,7 +178,7 @@ void Capture::requestComplete(Request *request)
|
||||||
loop_->callLater([=]() { processRequest(request); });
|
loop_->callLater([=]() { processRequest(request); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Capture::processRequest(Request *request)
|
void CameraSession::processRequest(Request *request)
|
||||||
{
|
{
|
||||||
const Request::BufferMap &buffers = request->buffers();
|
const Request::BufferMap &buffers = request->buffers();
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2019, Google Inc.
|
* Copyright (C) 2019, Google Inc.
|
||||||
*
|
*
|
||||||
* capture.h - Cam capture
|
* camera_session.h - Camera capture session
|
||||||
*/
|
*/
|
||||||
#ifndef __CAM_CAPTURE_H__
|
#ifndef __CAM_CAMERA_SESSION_H__
|
||||||
#define __CAM_CAPTURE_H__
|
#define __CAM_CAMERA_SESSION_H__
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -21,10 +21,10 @@
|
||||||
#include "event_loop.h"
|
#include "event_loop.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
class Capture
|
class CameraSession
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Capture(std::shared_ptr<libcamera::Camera> camera,
|
CameraSession(std::shared_ptr<libcamera::Camera> camera,
|
||||||
libcamera::CameraConfiguration *config,
|
libcamera::CameraConfiguration *config,
|
||||||
EventLoop *loop);
|
EventLoop *loop);
|
||||||
|
|
||||||
|
@ -52,4 +52,4 @@ private:
|
||||||
std::vector<std::unique_ptr<libcamera::Request>> requests_;
|
std::vector<std::unique_ptr<libcamera::Request>> requests_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __CAM_CAPTURE_H__ */
|
#endif /* __CAM_CAMERA_SESSION_H__ */
|
|
@ -13,7 +13,7 @@
|
||||||
#include <libcamera/libcamera.h>
|
#include <libcamera/libcamera.h>
|
||||||
#include <libcamera/property_ids.h>
|
#include <libcamera/property_ids.h>
|
||||||
|
|
||||||
#include "capture.h"
|
#include "camera_session.h"
|
||||||
#include "event_loop.h"
|
#include "event_loop.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
@ -363,8 +363,8 @@ int CamApp::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptCapture)) {
|
if (options_.isSet(OptCapture)) {
|
||||||
Capture capture(camera_, config_.get(), &loop_);
|
CameraSession session(camera_, config_.get(), &loop_);
|
||||||
return capture.run(options_);
|
return session.run(options_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptMonitor)) {
|
if (options_.isSet(OptMonitor)) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ cam_enabled = true
|
||||||
|
|
||||||
cam_sources = files([
|
cam_sources = files([
|
||||||
'buffer_writer.cpp',
|
'buffer_writer.cpp',
|
||||||
'capture.cpp',
|
'camera_session.cpp',
|
||||||
'event_loop.cpp',
|
'event_loop.cpp',
|
||||||
'main.cpp',
|
'main.cpp',
|
||||||
'options.cpp',
|
'options.cpp',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue