[{"id":12318,"web_url":"https://patchwork.libcamera.org/comment/12318/","msgid":"<20200905213013.GI6319@pendragon.ideasonboard.com>","date":"2020-09-05T21:30:13","subject":"Re: [libcamera-devel] [PATCH v2 06/12] libcamera:\n\tcamera_configuration: Return config index","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Wed, Sep 02, 2020 at 05:22:30PM +0200, Jacopo Mondi wrote:\n> When adding a new StreamConfiguration to a CameraConfiguration instance\n> it might be useful to know how what is the index of the newly added item\n> to be able to retrieve it later.\n> \n> Return the index of the newly inserted item, which corresponds to the\n> 0-indexed number of items in the CameraConfiguration::config_ vector,\n> from CameraConfiguration::addConfiguration().\n\nLooking at the rest of the series, this is only used in 07/12 to replace\na local counter. I'm not sure if it will also be useful for other users\nof the API, so I have no strong opinion. Please however note that you\ncould already use CameraConfiguration::size() to replace the counter,\nwithout this patch. I'll trust you to decide which course of action is\nbest (and the camera configuration API will be reworked, so this may not\nmatter that much).\n\nAcked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/camera.h | 2 +-\n>  src/libcamera/camera.cpp   | 5 ++++-\n>  2 files changed, 5 insertions(+), 2 deletions(-)\n> \n> diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> index 272c12c3c473..53c32afa23a5 100644\n> --- a/include/libcamera/camera.h\n> +++ b/include/libcamera/camera.h\n> @@ -39,7 +39,7 @@ public:\n>  \n>  \tvirtual ~CameraConfiguration();\n>  \n> -\tvoid addConfiguration(const StreamConfiguration &cfg);\n> +\tint addConfiguration(const StreamConfiguration &cfg);\n>  \tvirtual Status validate() = 0;\n>  \n>  \tStreamConfiguration &at(unsigned int index);\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 4a9c19c33cfb..9a8923620e24 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -104,10 +104,13 @@ CameraConfiguration::~CameraConfiguration()\n>  /**\n>   * \\brief Add a stream configuration to the camera configuration\n>   * \\param[in] cfg The stream configuration\n> + * \\return The index of the newly added stream configuration\n>   */\n> -void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg)\n> +int CameraConfiguration::addConfiguration(const StreamConfiguration &cfg)\n>  {\n>  \tconfig_.push_back(cfg);\n> +\n> +\treturn config_.size() - 1;\n>  }\n>  \n>  /**","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 283C9BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  5 Sep 2020 21:30:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A158B62B5B;\n\tSat,  5 Sep 2020 23:30:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E226262901\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  5 Sep 2020 23:30:37 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 63993335;\n\tSat,  5 Sep 2020 23:30:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Zm5gC/as\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1599341437;\n\tbh=d7j1v9fL6fftzpo2zlyGJexxZHCmC0nUeWOcmxDvYwU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Zm5gC/asfjXEaByKskihoA1pOyoMNJnWNlFv23ahrNUHYwE1Z9bpc75BrGZXJwkN7\n\tJd6c2JAhQpt7kYxTh1tI4OFlr6NtCUcz9TusQkLHBMB8VVzEnXjbGolIYj7tIvyJTz\n\t1jneGYnTotSufGv4rEcNNBL2Qdu+pJX5RT3bqzdg=","Date":"Sun, 6 Sep 2020 00:30:13 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200905213013.GI6319@pendragon.ideasonboard.com>","References":"<20200902152236.69770-1-jacopo@jmondi.org>\n\t<20200902152236.69770-7-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200902152236.69770-7-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 06/12] libcamera:\n\tcamera_configuration: Return config index","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"tfiga@google.com, libcamera-devel@lists.libcamera.org, hiroh@google.com","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12361,"web_url":"https://patchwork.libcamera.org/comment/12361/","msgid":"<CAO5uPHP9RGxUZaWU80aBXp+dWbNoUvZ+a15gsJ4DaVwd7wy+kA@mail.gmail.com>","date":"2020-09-08T04:05:27","subject":"Re: [libcamera-devel] [PATCH v2 06/12] libcamera:\n\tcamera_configuration: Return config index","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"The return value is useful if the index of added point is not always\nthe deterministic place, like std::map.\nHowever, like std::vector, the adding point is always the same, end of\nvector, per the implementation.\nIf it is guaranteed at the interface level, I think the return value\nis unnecessary.\n\nOn Sun, Sep 6, 2020 at 6:30 AM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Wed, Sep 02, 2020 at 05:22:30PM +0200, Jacopo Mondi wrote:\n> > When adding a new StreamConfiguration to a CameraConfiguration instance\n> > it might be useful to know how what is the index of the newly added item\n> > to be able to retrieve it later.\n> >\n> > Return the index of the newly inserted item, which corresponds to the\n> > 0-indexed number of items in the CameraConfiguration::config_ vector,\n> > from CameraConfiguration::addConfiguration().\n>\n> Looking at the rest of the series, this is only used in 07/12 to replace\n> a local counter. I'm not sure if it will also be useful for other users\n> of the API, so I have no strong opinion. Please however note that you\n> could already use CameraConfiguration::size() to replace the counter,\n> without this patch. I'll trust you to decide which course of action is\n> best (and the camera configuration API will be reworked, so this may not\n> matter that much).\n>\n> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  include/libcamera/camera.h | 2 +-\n> >  src/libcamera/camera.cpp   | 5 ++++-\n> >  2 files changed, 5 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> > index 272c12c3c473..53c32afa23a5 100644\n> > --- a/include/libcamera/camera.h\n> > +++ b/include/libcamera/camera.h\n> > @@ -39,7 +39,7 @@ public:\n> >\n> >       virtual ~CameraConfiguration();\n> >\n> > -     void addConfiguration(const StreamConfiguration &cfg);\n> > +     int addConfiguration(const StreamConfiguration &cfg);\n> >       virtual Status validate() = 0;\n> >\n> >       StreamConfiguration &at(unsigned int index);\n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index 4a9c19c33cfb..9a8923620e24 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -104,10 +104,13 @@ CameraConfiguration::~CameraConfiguration()\n> >  /**\n> >   * \\brief Add a stream configuration to the camera configuration\n> >   * \\param[in] cfg The stream configuration\n> > + * \\return The index of the newly added stream configuration\n> >   */\n> > -void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg)\n> > +int CameraConfiguration::addConfiguration(const StreamConfiguration &cfg)\n> >  {\n> >       config_.push_back(cfg);\n> > +\n> > +     return config_.size() - 1;\n> >  }\n> >\n> >  /**\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D248ABDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Sep 2020 04:05:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3EBC762BAA;\n\tTue,  8 Sep 2020 06:05:39 +0200 (CEST)","from mail-ed1-x544.google.com (mail-ed1-x544.google.com\n\t[IPv6:2a00:1450:4864:20::544])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D287603EE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Sep 2020 06:05:38 +0200 (CEST)","by mail-ed1-x544.google.com with SMTP id c8so14520446edv.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Sep 2020 21:05:38 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"LL4ybMl8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=5zUDqihP0AnaYRSC5QiMLPqye84wWtDMuXR+xgAh25s=;\n\tb=LL4ybMl8SBt732Slvwnq8ij2dFfoma5+bQOM007A4WDIBdoKtNyXXmShspClPtRpJ8\n\tcQvL8ecTiWOuLCnOii3YdOQ8VIcmWdb+0/rq69dTL6XfBtNst2Nho26pqMgs8aHsoZu4\n\tEQCE7LOycfwiU+vg4APe7mQhYf2ihZ4B9j06Q=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=5zUDqihP0AnaYRSC5QiMLPqye84wWtDMuXR+xgAh25s=;\n\tb=L7+8tZRgw9+yY6H+UFTvU44dr4ByWnlm4Nk9mzXTXHl7c2mYqrAU/VwFzOjQJQMun1\n\tpARnRFtoo3C/IZfGu6sLXBL0ibgH1gWTpUSsQjRXvjZa/AOrMa3SwpQzH/kojL2Y7y14\n\tq8CEm505iQk2ony+56YvPwroUxpRSDqtxIB5R/fT6m8qPN6t9KgyhmjP2D/nCvJwjU+t\n\tsonerbj+PIeOkzSqTSfMv9OJAHc+vfm4zuwcG/cx50UGgyI5C1Wu+sPWegmOvGqq1AAu\n\tE9fPZopjqXcLuXFDeFUdjNEnjgBtftlHIYV14Fp5VYjoMO/gLCD4oSq4ttu87HErpT4X\n\tEA8A==","X-Gm-Message-State":"AOAM530w+87GrP/kyYOPmvkcLgpFtuWWS3C6oeOa4RjS/r332S2q7zqm\n\ttOZ3wAXDdFv1k/IybBfNdmvIL1P350uT0mhLzogLeQ==","X-Google-Smtp-Source":"ABdhPJzxjf4o8ILZX6otxVhFBZd8+2axWcOXUIok1mV1F+GYnyCAtdgmHdGiQRzFe2otkcJBCv2Z7GSdJckdguT9cy8=","X-Received":"by 2002:a50:c3c4:: with SMTP id\n\ti4mr24940041edf.244.1599537937811; \n\tMon, 07 Sep 2020 21:05:37 -0700 (PDT)","MIME-Version":"1.0","References":"<20200902152236.69770-1-jacopo@jmondi.org>\n\t<20200902152236.69770-7-jacopo@jmondi.org>\n\t<20200905213013.GI6319@pendragon.ideasonboard.com>","In-Reply-To":"<20200905213013.GI6319@pendragon.ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Tue, 8 Sep 2020 13:05:27 +0900","Message-ID":"<CAO5uPHP9RGxUZaWU80aBXp+dWbNoUvZ+a15gsJ4DaVwd7wy+kA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 06/12] libcamera:\n\tcamera_configuration: Return config index","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"tfiga@google.com, libcamera-devel@lists.libcamera.org,\n\tHirokazu Honda <hiroh@google.com>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]