android: camera_device: Set Encoder at construction
Make the CameraStream encoder a private unique pointer and require its initialization at construction time. This ties the encoder lifetime to the CameraStream it has been created with, allowing to remove the CameraStream destructor. This change dis-allow creating a CameraStream and set the Encoder later, which shall not happen now that we create CameraStream once we have all the required information in place. No functional changes intended but this change aims to make the code more robust enforcing a stricter CameraStream interface. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -29,16 +29,15 @@ class CameraMetadata;
|
||||
|
||||
struct CameraStream {
|
||||
public:
|
||||
CameraStream(libcamera::PixelFormat, libcamera::Size, unsigned int i);
|
||||
~CameraStream();
|
||||
CameraStream(libcamera::PixelFormat, libcamera::Size, unsigned int i,
|
||||
Encoder *e = nullptr);
|
||||
|
||||
unsigned int index() const { return index_; }
|
||||
Encoder *encoder() const { return encoder_.get(); }
|
||||
|
||||
libcamera::PixelFormat format;
|
||||
libcamera::Size size;
|
||||
|
||||
Encoder *jpeg;
|
||||
|
||||
private:
|
||||
/*
|
||||
* The index of the libcamera StreamConfiguration as added during
|
||||
@@ -46,6 +45,7 @@ private:
|
||||
* one or more streams to the Android framework.
|
||||
*/
|
||||
unsigned int index_;
|
||||
std::unique_ptr<Encoder> encoder_;
|
||||
};
|
||||
|
||||
class CameraDevice : protected libcamera::Loggable
|
||||
|
||||
Reference in New Issue
Block a user