[libcamera-devel,2/3] libcamera: camera_manager: Improve class documentation

Message ID 20190112144619.5816-3-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Pipeline handler refactoring and documentation improvements
Related show

Commit Message

Laurent Pinchart Jan. 12, 2019, 2:46 p.m. UTC
Move documentation from the \file directive to the CameraManager class,
as it documents the class, not the file. Improve the documentation to
provide a brief overview of how the camera manager operates, and fix a
few typos and inconsistencies.

The documentation mentions hotplug even though it isn't implement yet,
as this is a planned feature. More improvements are needed for the
documentation of the CameraManager member functions, and will be added
as part of the API improvements in the near future.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/camera_manager.cpp | 56 +++++++++++++++++++-------------
 1 file changed, 34 insertions(+), 22 deletions(-)

Comments

Jacopo Mondi Jan. 14, 2019, 9:38 a.m. UTC | #1
Hi Laurent,

On Sat, Jan 12, 2019 at 04:46:18PM +0200, Laurent Pinchart wrote:
> Move documentation from the \file directive to the CameraManager class,
> as it documents the class, not the file. Improve the documentation to
> provide a brief overview of how the camera manager operates, and fix a
> few typos and inconsistencies.
>
> The documentation mentions hotplug even though it isn't implement yet,
> as this is a planned feature. More improvements are needed for the
> documentation of the CameraManager member functions, and will be added
> as part of the API improvements in the near future.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/camera_manager.cpp | 56 +++++++++++++++++++-------------
>  1 file changed, 34 insertions(+), 22 deletions(-)
>
> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> index e4072529fdc4..d91ca72a3802 100644
> --- a/src/libcamera/camera_manager.cpp
> +++ b/src/libcamera/camera_manager.cpp
> @@ -15,30 +15,42 @@
>
>  /**
>   * \file camera_manager.h
> - * \brief Manage all cameras handled by libcamera
> - *
> - * The responsibility of the camera manager is to control the lifetime
> - * management of objects provided by libcamera.
> - *
> - * When a user wish to interact with libcamera it creates and starts a
> - * CameraManager object. Once confirmed the camera manager is running
> - * the application can list all cameras detected by the library, get
> - * one or more of the cameras and interact with them.
> - *
> - * When the user is done with the camera it should be returned to the
> - * camera manager. Once all cameras are returned to the camera manager
> - * the user is free to stop the manager.
> - *
> - * \todo Add ability to add and remove media devices based on
> - *       hot-(un)plug events coming from the device enumerator.
> - *
> - * \todo Add interface to register a notification callback to the user
> - *       to be able to inform it new cameras have been hot-plugged or
> - *       cameras have been removed due to hot-unplug.
> + * \brief The camera manager
>   */
>
>  namespace libcamera {
>
> +/**
> + * \class CameraManager
> + * \brief Provide access and manage all cameras in the system
> + *
> + * The camera manager is the entry point to libcamera. Ii enumerates devices,
s/Ii/It
> + * associates them with pipeline managers, and provides access to the cameras
> + * in the system to applications. The manager owns all Camera objects and
> + * handles hot-plugging and hot-unplugging to manage the lifetime of cameras.
> + *
> + * To interact with libcamera, an application retrieves the camera manager
> + * instance with CameraManager::instance(). The manager is initially stopped,
> + * and shall be configured before being started. In particular a custom event
> + * dispatcher shall be installed if needed with
> + * CameraManager::setEventDispatcher().
> + *
> + * Once the camera manager is configured, it shall be started with start().
> + * This will enumerate all the cameras present in the system, which can then be
> + * listed with list() and retrieved with get().
> + *
> + * Cameras are reference-counted, and shall be returned to the camera manager
> + * with Camera::put() after being used. Once all cameras have been returned to
> + * the manager, it can be stopped with stop().
> + *
> + * \todo Add ability to add and remove media devices based on hot-(un)plug
> + * events coming from the device enumerator.
> + *
> + * \todo Add interface to register a notification callback to the user to be
> + * able to inform it new cameras have been hot-plugged or cameras have been
> + * removed due to hot-unplug.
> + */
> +
>  CameraManager::CameraManager()
>  	: enumerator_(nullptr), dispatcher_(nullptr)
>  {
> @@ -57,7 +69,7 @@ CameraManager::~CameraManager()
>   * interact with cameras in the system until either the camera manager
>   * is stopped or the camera is unplugged from the system.
>   *
> - * \return true on successful start false otherwise
> + * \return 0 on successful start, or a negative error code otherwise

Ah, that was my comment on v1, please ignore it :)

>   */
>  int CameraManager::start()
>  {
> @@ -100,7 +112,7 @@ int CameraManager::start()
>  /**
>   * \brief Stop the camera manager
>   *
> - * Before stopping the camera manger the caller is responsible for making
> + * Before stopping the camera manager the caller is responsible for making
>   * sure all cameras provided by the manager are returned to the manager.
>   *
>   * After the manager has been stopped no resource provided by the camera

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index e4072529fdc4..d91ca72a3802 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -15,30 +15,42 @@ 
 
 /**
  * \file camera_manager.h
- * \brief Manage all cameras handled by libcamera
- *
- * The responsibility of the camera manager is to control the lifetime
- * management of objects provided by libcamera.
- *
- * When a user wish to interact with libcamera it creates and starts a
- * CameraManager object. Once confirmed the camera manager is running
- * the application can list all cameras detected by the library, get
- * one or more of the cameras and interact with them.
- *
- * When the user is done with the camera it should be returned to the
- * camera manager. Once all cameras are returned to the camera manager
- * the user is free to stop the manager.
- *
- * \todo Add ability to add and remove media devices based on
- *       hot-(un)plug events coming from the device enumerator.
- *
- * \todo Add interface to register a notification callback to the user
- *       to be able to inform it new cameras have been hot-plugged or
- *       cameras have been removed due to hot-unplug.
+ * \brief The camera manager
  */
 
 namespace libcamera {
 
+/**
+ * \class CameraManager
+ * \brief Provide access and manage all cameras in the system
+ *
+ * The camera manager is the entry point to libcamera. Ii enumerates devices,
+ * associates them with pipeline managers, and provides access to the cameras
+ * in the system to applications. The manager owns all Camera objects and
+ * handles hot-plugging and hot-unplugging to manage the lifetime of cameras.
+ *
+ * To interact with libcamera, an application retrieves the camera manager
+ * instance with CameraManager::instance(). The manager is initially stopped,
+ * and shall be configured before being started. In particular a custom event
+ * dispatcher shall be installed if needed with
+ * CameraManager::setEventDispatcher().
+ *
+ * Once the camera manager is configured, it shall be started with start().
+ * This will enumerate all the cameras present in the system, which can then be
+ * listed with list() and retrieved with get().
+ *
+ * Cameras are reference-counted, and shall be returned to the camera manager
+ * with Camera::put() after being used. Once all cameras have been returned to
+ * the manager, it can be stopped with stop().
+ *
+ * \todo Add ability to add and remove media devices based on hot-(un)plug
+ * events coming from the device enumerator.
+ *
+ * \todo Add interface to register a notification callback to the user to be
+ * able to inform it new cameras have been hot-plugged or cameras have been
+ * removed due to hot-unplug.
+ */
+
 CameraManager::CameraManager()
 	: enumerator_(nullptr), dispatcher_(nullptr)
 {
@@ -57,7 +69,7 @@  CameraManager::~CameraManager()
  * interact with cameras in the system until either the camera manager
  * is stopped or the camera is unplugged from the system.
  *
- * \return true on successful start false otherwise
+ * \return 0 on successful start, or a negative error code otherwise
  */
 int CameraManager::start()
 {
@@ -100,7 +112,7 @@  int CameraManager::start()
 /**
  * \brief Stop the camera manager
  *
- * Before stopping the camera manger the caller is responsible for making
+ * Before stopping the camera manager the caller is responsible for making
  * sure all cameras provided by the manager are returned to the manager.
  *
  * After the manager has been stopped no resource provided by the camera