[{"id":624,"web_url":"https://patchwork.libcamera.org/comment/624/","msgid":"<20190126100200.GF4596@pendragon.ideasonboard.com>","date":"2019-01-26T10:02:00","subject":"Re: [libcamera-devel] [PATCH v2 6/7] libcamera: camera: integrate\n\tstreams and configuration","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Fri, Jan 25, 2019 at 04:33:39PM +0100, Niklas Söderlund wrote:\n> Add retrieval and configuration of streams information and\n> configuration. The implementation in the Camera are minimalistic as the\n> heavily lifting are done by the pipeline handler implementations.\n\ns/heavily lifting are done/heavy lifting is done/\n\n> The single most important thing for the helpers in the Camera object is\n> to perform access control and making sure no request is forwarded to a\n> pipeline handler if the camera have been disconnected.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  include/libcamera/camera.h |  7 ++++++\n>  src/libcamera/camera.cpp   | 48 ++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 55 insertions(+)\n> \n> diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> index 7e358f8c0aa093cf..c6342ed81598921c 100644\n> --- a/include/libcamera/camera.h\n> +++ b/include/libcamera/camera.h\n> @@ -9,12 +9,15 @@\n>  \n>  #include <memory>\n>  #include <string>\n> +#include <vector>\n>  \n>  #include <libcamera/signal.h>\n>  \n>  namespace libcamera {\n>  \n>  class PipelineHandler;\n> +class Stream;\n> +class StreamConfiguration;\n>  \n>  class Camera final\n>  {\n> @@ -32,6 +35,10 @@ public:\n>  \tint acquire();\n>  \tvoid release();\n>  \n> +\tstd::vector<Stream> streams() const;\n\nDo you expect streams to be modified, or should this return a const\nvector ?\n\n> +\n> +\tint configure(std::vector<StreamConfiguration *> &config);\n> +\n\nWe may want some const here too, depending on your opinion of my review\nof the previous e-mails.\n\n>  private:\n>  \tCamera(PipelineHandler *pipe, const std::string &name);\n>  \t~Camera();\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index fd19e8cf6694cc1b..f90abfecd4e6bb48 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -6,6 +6,9 @@\n>   */\n>  \n>  #include <libcamera/camera.h>\n> +#include <libcamera/stream.h>\n> +\n> +#include \"pipeline_handler.h\"\n>  \n>  #include \"log.h\"\n>  #include \"pipeline_handler.h\"\n> @@ -160,4 +163,49 @@ void Camera::release()\n>  \tacquired_ = false;\n>  }\n>  \n> +/**\n> + * \\brief Retrieve the supported streams of the camera\n> + *\n> + * \\return An array of streams supported by the camera device\n> + */\n> +std::vector<Stream> Camera::streams() const\n> +{\n> +\tstd::vector<Stream> streams;\n> +\n> +\tif (pipe_)\n> +\t\tstreams = pipe_->streams(this);\n> +\n> +\treturn streams;\n> +}\n> +\n> +/**\n> + * \\brief Configure the camera device prior to capture\n\nMissing \\param.\n\n> + *\n> + * Prior to starting capture, the camera device must be configured to select a\n> + * set of streams.\n> + *\n> + * The requested configuration \\a config shall contain at least one stream and\n> + * may contain multiple streams. For each stream an associated StreamFormat\n> + * shall be supplied. Streams supported by the camera device not part of the\n> + * \\a config will be disabled.\n\nWe're missing a global explanation of how streams should be used.\nThere's information scattered in the related classes, but one or two\nparagraphs in the Camera class documentation is also needed in my\nopinion.\n\n> + *\n> + * Exclusive access to the camera device shall be ensured by a call to\n> + * Camera::acquire() before calling this function, otherwise an -EACCES error\n\nYou can just write acquire() when the function is part of the same\nclass.\n\n> + * will be returned.\n> + *\n> + * \\param[in] config Array of stream configurations to setup\n\nAh no, not missing :-) Please move it just after \\brief.\n\n> + *\n> + * \\return 0 on success or a negative error code on error.\n> + */\n> +int Camera::configure(std::vector<StreamConfiguration *> &config)\n> +{\n> +\tif (!pipe_)\n> +\t\treturn -ENODEV;\n\nThis can't happen. We however need to block this call if the camera has\nbeen disconnected.\n\n> +\tif (!acquired_)\n> +\t\treturn -EACCES;\n> +\n> +\treturn pipe_->configure(this, config);\n> +}\n> +\n>  } /* namespace libcamera */","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EEB1160C65\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 26 Jan 2019 11:02:24 +0100 (CET)","from pendragon.ideasonboard.com (unknown [62.119.166.9])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1C61F23A;\n\tSat, 26 Jan 2019 11:02:20 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548496944;\n\tbh=VmWpbdTz4ldANYztZdGO423x+w3qGdUF9cvnQgF17VY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mRm5SmTAQAUKrdaVbpblsh2colf1GtC2FukmooK87z/TAvWUE0AMqpGBDn/VITZfr\n\tCOTJMUTB8T0cCLVY6pucsfUZ04VO0iZdZQt4axv1g/MbJfjd6Tdf5sLOTOxxdtlyCe\n\tga4oPyPTJGpJ/n3unQQS2Cm6/tWmdBlgDgpSq5mY=","Date":"Sat, 26 Jan 2019 12:02:00 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190126100200.GF4596@pendragon.ideasonboard.com>","References":"<20190125153340.2744-1-niklas.soderlund@ragnatech.se>\n\t<20190125153340.2744-7-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190125153340.2744-7-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 6/7] libcamera: camera: integrate\n\tstreams and configuration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 26 Jan 2019 10:02:25 -0000"}}]