/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2019-2021, Google Inc. * * camera_request.cpp - libcamera Android Camera Request Descriptor */ #include "camera_request.h" #include #include "camera_buffer.h" using namespace libcamera; /* * \class Camera3RequestDescriptor * * A utility class that groups information about a capture request to be later * reused at request complete time to notify the framework. * ******************************************************************************* * Lifetime of a Camera3RequestDescriptor tracking a capture request placed by * Android Framework ******************************************************************************* * * * Android Framework * │ * │ ┌──────────────────────────────────┐ * │ │camera3_capture_request_t │ * │ │ │ * │ │Requested output streams │ * │ │ stream1 stream2 stream3 ... │ * │ └──────────────────────────────────┘ * ▼ * ┌─────────────────────────────────────────────────────────────┐ * │ libcamera HAL │ * ├─────────────────────────────────────────────────────────────┤ * │ CameraDevice │ * │ │ * │ processCaptureRequest(camera3_capture_request_t request) │ * │ │ * │ - Create Camera3RequestDescriptor tracking this request │ * │ - Streams requiring post-processing are stored in the │ * │ pendingStreamsToProcess map │ * │ - Add this Camera3RequestDescriptor to descriptors' queue │ * │ CameraDevice::descriptors_ │ * │ │ ┌─────────────────────────┐ * │ - Queue the capture request to libcamera core ────────────┤►│libcamera core │ * │ │ ├─────────────────────────┤ * │ │ │- Capture from Camera │ * │ │ │ │ * │ │ │- Emit │ * │ │ │ Camera::requestComplete│ * │ requestCompleted(Request *request) ◄───────────────────────┼─┼──── │ * │ │ │ │ * │ - Check request completion status │ └─────────────────────────┘ * │ │ * │ - if (pendingStreamsToProcess > 0) │ * │ Queue all entries from pendingStreamsToProcess │ * │ else │ │ * │ completeDescriptor() │ └──────────────────────┐ * │ │ │ * │ ┌──────────────────────────┴───┬──────────────────┐ │ * │ │ │ │ │ * │ ┌──────────▼────────────┐ ┌───────────▼─────────┐ ▼ │ * │ │CameraStream1 │ │CameraStream2 │ .... │ * │ ├┬───┬───┬──────────────┤ ├┬───┬───┬────────────┤ │ * │ ││ │ │ │ ││ │ │ │ │ * │ │▼───▼───▼──────────────┤ │▼───▼───▼────────────┤ │ * │ │PostProcessorWorker │ │PostProcessorWorker │ │ * │ │ │ │ │ │ * │ │ +------------------+ │ │ +------------------+│ │ * │ │ | PostProcessor | │ │ | PostProcessor |│ │ * │ │ | process() | │ │ | process() |│ │ * │ │ | | │ │ | |│ │ * │ │ | Emit | │ │ | Emit |│ │ * │ │ | processComplete | │ │ | processComplete |│ │ * │ │ | | │ │ | |│ │ * │ │ +--------------│---+ │ │ +--------------│---+│ │ * │ │ │ │ │ │ │ │ * │ │ │ │ │ │ │ │ * │ └────────────────┼──────┘ └────────────────┼────┘ │ * │ │ │ │ * │ │ │ │ * │ │ │ │ * │ ▼ ▼ │ * │ +---------------------------------------+ +--------------+ │ * │ | CameraDevice | | | │ * │ | | | | │ * │ | streamProcessingComplete() | | | │ * │ | | | | │ * │ | - Check and set buffer status | | .... | │ * │ | - Remove post+processing entry | | | */ /** * \brief Construct a PubKey from key data * \param[in] key Key data encoded in DER format */ PubKey::PubKey([[maybe_unused]] Span<const uint8_t> key) : valid_(false) { #if HAVE_GNUTLS int ret = gnutls_pubkey_init(&pubkey_); if (ret < 0) return; const gnutls_datum_t gnuTlsKey{ const_cast<unsigned char *>(key.data()), static_cast<unsigned int>(key.size()) }; ret = gnutls_pubkey_import(pubkey_, &gnuTlsKey, GNUTLS_X509_FMT_DER); if (ret < 0) return; valid_ = true; #endif } PubKey::~PubKey() { #if HAVE_GNUTLS gnutls_pubkey_deinit(pubkey_); #endif } /** * \fn bool PubKey::isValid() const * \brief Check is the public key is valid * \return True if the public key is valid, false otherwise */ /** * \brief Verify signature on data * \param[in] data The signed data * \param[in] sig The signature * * Verify that the signature \a sig matches the signed \a data for the public * key. The signture algorithm is hardcoded to RSA-SHA256. * * \return True if the signature is valid, false otherwise */ bool PubKey::verify([[maybe_unused]] Span<const uint8_t> data, [[maybe_unused]] Span<