Message ID | 20220110165524.72978-2-jacopo@jmondi.org |
---|---|
State | Accepted |
Delegated to: | Jacopo Mondi |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, On Tue, Jan 11, 2022 at 1:54 AM Jacopo Mondi <jacopo@jmondi.org> wrote: > > From: Hirokazu Honda <hiroh@chromium.org> > > Add to the CameraStream class a sourceStream field, which for streams > of type Mapped contains a reference to the stream which produces the > actual image data. > > The sourceStream of mapped streams will be used in later patches to make > sure for each Mapped stream at least one libcamera::Stream is queued to > the libcamera::Camera. > > Signed-off-by: Hirokazu Honda <hiroh@chromium.org> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> > --- > src/android/camera_device.cpp | 9 ++++++++- > src/android/camera_stream.cpp | 6 ++++-- > src/android/camera_stream.h | 6 +++++- > 3 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp > index 83825736ce31..005d95b51a0c 100644 > --- a/src/android/camera_device.cpp > +++ b/src/android/camera_device.cpp > @@ -681,10 +681,17 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) > for (const auto &streamConfig : streamConfigs) { > config->addConfiguration(streamConfig.config); > > + CameraStream *sourceStream = nullptr; > for (auto &stream : streamConfig.streams) { > + > streams_.emplace_back(this, config.get(), stream.type, > - stream.stream, config->size() - 1); > + stream.stream, sourceStream, > + config->size() - 1); > stream.stream->priv = static_cast<void *>(&streams_.back()); Although this is not critical problem, I would set to nullptr if the stream is not Mapped. Because sourceStream for Direct and Internal streams is not used. Regards, -Hiro > + > + /* Mapped streams are always associated with a Direct one. */ > + if (stream.type == CameraStream::Type::Direct) > + sourceStream = &streams_.back(); > } > } > > diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp > index c21574501916..032b0407bd32 100644 > --- a/src/android/camera_stream.cpp > +++ b/src/android/camera_stream.cpp > @@ -52,9 +52,11 @@ LOG_DECLARE_CATEGORY(HAL) > > CameraStream::CameraStream(CameraDevice *const cameraDevice, > CameraConfiguration *config, Type type, > - camera3_stream_t *camera3Stream, unsigned int index) > + camera3_stream_t *camera3Stream, > + CameraStream *const sourceStream, unsigned int index) > : cameraDevice_(cameraDevice), config_(config), type_(type), > - camera3Stream_(camera3Stream), index_(index) > + camera3Stream_(camera3Stream), sourceStream_(sourceStream), > + index_(index) > { > } > > diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h > index f9504462b253..4c5078b2c26d 100644 > --- a/src/android/camera_stream.h > +++ b/src/android/camera_stream.h > @@ -114,7 +114,9 @@ public: > }; > CameraStream(CameraDevice *const cameraDevice, > libcamera::CameraConfiguration *config, Type type, > - camera3_stream_t *camera3Stream, unsigned int index); > + camera3_stream_t *camera3Stream, > + CameraStream *const sourceStream, > + unsigned int index); > CameraStream(CameraStream &&other); > ~CameraStream(); > > @@ -122,6 +124,7 @@ public: > camera3_stream_t *camera3Stream() const { return camera3Stream_; } > const libcamera::StreamConfiguration &configuration() const; > libcamera::Stream *stream() const; > + CameraStream *sourceStream() const { return sourceStream_; } > > int configure(); > int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer); > @@ -167,6 +170,7 @@ private: > const libcamera::CameraConfiguration *config_; > const Type type_; > camera3_stream_t *camera3Stream_; > + CameraStream *const sourceStream_; > const unsigned int index_; > > std::unique_ptr<PlatformFrameBufferAllocator> allocator_; > -- > 2.34.1 >
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 83825736ce31..005d95b51a0c 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -681,10 +681,17 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) for (const auto &streamConfig : streamConfigs) { config->addConfiguration(streamConfig.config); + CameraStream *sourceStream = nullptr; for (auto &stream : streamConfig.streams) { + streams_.emplace_back(this, config.get(), stream.type, - stream.stream, config->size() - 1); + stream.stream, sourceStream, + config->size() - 1); stream.stream->priv = static_cast<void *>(&streams_.back()); + + /* Mapped streams are always associated with a Direct one. */ + if (stream.type == CameraStream::Type::Direct) + sourceStream = &streams_.back(); } } diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index c21574501916..032b0407bd32 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -52,9 +52,11 @@ LOG_DECLARE_CATEGORY(HAL) CameraStream::CameraStream(CameraDevice *const cameraDevice, CameraConfiguration *config, Type type, - camera3_stream_t *camera3Stream, unsigned int index) + camera3_stream_t *camera3Stream, + CameraStream *const sourceStream, unsigned int index) : cameraDevice_(cameraDevice), config_(config), type_(type), - camera3Stream_(camera3Stream), index_(index) + camera3Stream_(camera3Stream), sourceStream_(sourceStream), + index_(index) { } diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index f9504462b253..4c5078b2c26d 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -114,7 +114,9 @@ public: }; CameraStream(CameraDevice *const cameraDevice, libcamera::CameraConfiguration *config, Type type, - camera3_stream_t *camera3Stream, unsigned int index); + camera3_stream_t *camera3Stream, + CameraStream *const sourceStream, + unsigned int index); CameraStream(CameraStream &&other); ~CameraStream(); @@ -122,6 +124,7 @@ public: camera3_stream_t *camera3Stream() const { return camera3Stream_; } const libcamera::StreamConfiguration &configuration() const; libcamera::Stream *stream() const; + CameraStream *sourceStream() const { return sourceStream_; } int configure(); int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer); @@ -167,6 +170,7 @@ private: const libcamera::CameraConfiguration *config_; const Type type_; camera3_stream_t *camera3Stream_; + CameraStream *const sourceStream_; const unsigned int index_; std::unique_ptr<PlatformFrameBufferAllocator> allocator_;