Message ID | 20210426105753.3498691-1-hiroh@chromium.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
With this implementation, stop() can be as follows. $ git diff diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 70174a2b..c5091e4f 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -773,19 +773,8 @@ void CameraDevice::stop() for (auto &[cookie, descriptor] : descriptors_) { LOG(HAL, Debug) << "request is canceled: " << cookie; - camera3_capture_result_t captureResult = {}; - captureResult.frame_number = descriptor.frameNumber_; - captureResult.num_output_buffers = descriptor.buffers_.size(); - for (camera3_stream_buffer_t &buffer : descriptor.buffers_) { - buffer.acquire_fence = -1; - buffer.release_fence = -1; - buffer.status = CAMERA3_BUFFER_STATUS_ERROR; - } - captureResult.output_buffers = descriptor.buffers_.data(); - - notifyError(descriptor.frameNumber_, - descriptor.buffers_[0].stream); - callbacks_->process_capture_result(callbacks_, &captureResult); + reportDescriptor(descriptor, + CAMERA3_BUFFER_STATUS_ERROR); } descriptors_.clear(); On Mon, Apr 26, 2021 at 7:57 PM Hirokazu Honda <hiroh@chromium.org> wrote: > > This factorizes a code of reporting a capture result including > notifying either shutter or error. It will be useful to report > capture results in other places than > CameraDevice::reqeustComplete(). > > Signed-off-by: Hirokazu Honda <hiroh@chromium.org> > --- > src/android/camera_device.cpp | 22 +++++++++++++++------- > src/android/camera_device.h | 4 ++++ > 2 files changed, 19 insertions(+), 7 deletions(-) > > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp > index fb89195e..70174a2b 100644 > --- a/src/android/camera_device.cpp > +++ b/src/android/camera_device.cpp > @@ -2132,7 +2132,20 @@ void CameraDevice::requestComplete(Request *request) > cameraStream->putBuffer(src); > } > > - /* Prepare to call back the Android camera stack. */ > + reportDescriptor(descriptor, status, timestamp, > + resultMetadata ? resultMetadata->get() : nullptr); > +} > + > +std::string CameraDevice::logPrefix() const > +{ > + return "'" + camera_->id() + "'"; > +} > + > +void CameraDevice::reportDescriptor(Camera3RequestDescriptor &descriptor, > + camera3_buffer_status status, > + uint64_t timestamp, > + camera_metadata_t *metadata) > +{ > camera3_capture_result_t captureResult = {}; > captureResult.frame_number = descriptor.frameNumber_; > captureResult.num_output_buffers = descriptor.buffers_.size(); > @@ -2147,7 +2160,7 @@ void CameraDevice::requestComplete(Request *request) > notifyShutter(descriptor.frameNumber_, timestamp); > > captureResult.partial_result = 1; > - captureResult.result = resultMetadata->get(); > + captureResult.result = metadata; > } > > if (status == CAMERA3_BUFFER_STATUS_ERROR || !captureResult.result) { > @@ -2164,11 +2177,6 @@ void CameraDevice::requestComplete(Request *request) > callbacks_->process_capture_result(callbacks_, &captureResult); > } > > -std::string CameraDevice::logPrefix() const > -{ > - return "'" + camera_->id() + "'"; > -} > - > void CameraDevice::notifyShutter(uint32_t frameNumber, uint64_t timestamp) > { > camera3_notify_msg_t notify = {}; > diff --git a/src/android/camera_device.h b/src/android/camera_device.h > index fa652c3c..a42b8dc0 100644 > --- a/src/android/camera_device.h > +++ b/src/android/camera_device.h > @@ -101,6 +101,10 @@ private: > > std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize(); > libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer); > + void reportDescriptor(Camera3RequestDescriptor &descriptor, > + camera3_buffer_status status, > + uint64_t timestamp = 0, > + camera_metadata_t *metadata = nullptr); > void notifyShutter(uint32_t frameNumber, uint64_t timestamp); > void notifyError(uint32_t frameNumber, camera3_stream_t *stream); > std::unique_ptr<CameraMetadata> requestTemplatePreview(); > -- > 2.31.1.498.g6c1eba8ee3d-goog >
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index fb89195e..70174a2b 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -2132,7 +2132,20 @@ void CameraDevice::requestComplete(Request *request) cameraStream->putBuffer(src); } - /* Prepare to call back the Android camera stack. */ + reportDescriptor(descriptor, status, timestamp, + resultMetadata ? resultMetadata->get() : nullptr); +} + +std::string CameraDevice::logPrefix() const +{ + return "'" + camera_->id() + "'"; +} + +void CameraDevice::reportDescriptor(Camera3RequestDescriptor &descriptor, + camera3_buffer_status status, + uint64_t timestamp, + camera_metadata_t *metadata) +{ camera3_capture_result_t captureResult = {}; captureResult.frame_number = descriptor.frameNumber_; captureResult.num_output_buffers = descriptor.buffers_.size(); @@ -2147,7 +2160,7 @@ void CameraDevice::requestComplete(Request *request) notifyShutter(descriptor.frameNumber_, timestamp); captureResult.partial_result = 1; - captureResult.result = resultMetadata->get(); + captureResult.result = metadata; } if (status == CAMERA3_BUFFER_STATUS_ERROR || !captureResult.result) { @@ -2164,11 +2177,6 @@ void CameraDevice::requestComplete(Request *request) callbacks_->process_capture_result(callbacks_, &captureResult); } -std::string CameraDevice::logPrefix() const -{ - return "'" + camera_->id() + "'"; -} - void CameraDevice::notifyShutter(uint32_t frameNumber, uint64_t timestamp) { camera3_notify_msg_t notify = {}; diff --git a/src/android/camera_device.h b/src/android/camera_device.h index fa652c3c..a42b8dc0 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -101,6 +101,10 @@ private: std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize(); libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer); + void reportDescriptor(Camera3RequestDescriptor &descriptor, + camera3_buffer_status status, + uint64_t timestamp = 0, + camera_metadata_t *metadata = nullptr); void notifyShutter(uint32_t frameNumber, uint64_t timestamp); void notifyError(uint32_t frameNumber, camera3_stream_t *stream); std::unique_ptr<CameraMetadata> requestTemplatePreview();
This factorizes a code of reporting a capture result including notifying either shutter or error. It will be useful to report capture results in other places than CameraDevice::reqeustComplete(). Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- src/android/camera_device.cpp | 22 +++++++++++++++------- src/android/camera_device.h | 4 ++++ 2 files changed, 19 insertions(+), 7 deletions(-)