summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-10-03 11:36:41 +0200
committerJacopo Mondi <jacopo@jmondi.org>2020-10-07 16:07:44 +0200
commit216030aa9d0953cff552d5892d32e5cd73864202 (patch)
tree6374d754012666ecfab24cc8fe84f894d29aaebc /src/android
parent9e95d5e4531039f8e21c65ea88be9ad6aaa1ced0 (diff)
android: camera_stream: Retrieve Stream and Configuration
It's a common pattern to access the libcamera::Stream and libcamera::StreamConfiguration using the CameraStream instance's index. Add two methods to the CameraStream to shorten access to the two fields. This allows removing the index() method from the class interface. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/camera_device.cpp11
-rw-r--r--src/android/camera_stream.cpp10
-rw-r--r--src/android/camera_stream.h4
3 files changed, 16 insertions, 9 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 914e66b8..47c42319 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1292,7 +1292,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
camera3_stream_t *stream = stream_list->streams[i];
CameraStream *cameraStream = static_cast<CameraStream *>(stream->priv);
- StreamConfiguration &cfg = config_->at(cameraStream->index());
+ const StreamConfiguration &cfg = cameraStream->configuration();
int ret = cameraStream->configure(cfg);
if (ret)
@@ -1413,10 +1413,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
}
descriptor->frameBuffers.emplace_back(buffer);
- StreamConfiguration *streamConfiguration = &config_->at(cameraStream->index());
- Stream *stream = streamConfiguration->stream();
-
- request->addBuffer(stream, buffer);
+ request->addBuffer(cameraStream->stream(), buffer);
}
int ret = camera_->queueRequest(request);
@@ -1462,9 +1459,7 @@ void CameraDevice::requestComplete(Request *request)
if (cameraStream->camera3Stream().format != HAL_PIXEL_FORMAT_BLOB)
continue;
- StreamConfiguration *streamConfiguration = &config_->at(cameraStream->index());
- Stream *stream = streamConfiguration->stream();
- FrameBuffer *buffer = request->findBuffer(stream);
+ FrameBuffer *buffer = request->findBuffer(cameraStream->stream());
if (!buffer) {
LOG(HAL, Error) << "Failed to find a source stream buffer";
continue;
diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
index e86a7ba6..9c7819ef 100644
--- a/src/android/camera_stream.cpp
+++ b/src/android/camera_stream.cpp
@@ -33,6 +33,16 @@ CameraStream::CameraStream(CameraDevice *cameraDevice,
encoder_ = std::make_unique<EncoderLibJpeg>();
}
+const StreamConfiguration &CameraStream::configuration() const
+{
+ return config_->at(index_);
+}
+
+Stream *CameraStream::stream() const
+{
+ return configuration().stream();
+}
+
int CameraStream::configure(const libcamera::StreamConfiguration &cfg)
{
if (encoder_)
diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
index d95c2a38..d8d9d8c4 100644
--- a/src/android/camera_stream.h
+++ b/src/android/camera_stream.h
@@ -115,7 +115,9 @@ public:
const libcamera::PixelFormat &format() const { return format_; }
const libcamera::Size &size() const { return size_; }
Type type() const { return type_; }
- unsigned int index() const { return index_; }
+
+ const libcamera::StreamConfiguration &configuration() const;
+ libcamera::Stream *stream() const;
int configure(const libcamera::StreamConfiguration &cfg);
int process(const libcamera::FrameBuffer &source,