Patch Detail
Show a patch.
GET /api/1.1/patches/875/?format=api
{ "id": 875, "url": "https://patchwork.libcamera.org/api/1.1/patches/875/?format=api", "web_url": "https://patchwork.libcamera.org/patch/875/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190403011221.12711-6-niklas.soderlund@ragnatech.se>", "date": "2019-04-03T01:12:21", "name": "[libcamera-devel,5/5] libcamera: camera: Add support for stream roles", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9e7b2dd9aa443150100c110cc84645f6487de16b", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/875/mbox/", "series": [ { "id": 232, "url": "https://patchwork.libcamera.org/api/1.1/series/232/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=232", "date": "2019-04-03T01:12:16", "name": "libcamera: camera: Add support for stream roles", "version": 1, "mbox": "https://patchwork.libcamera.org/series/232/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/875/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/875/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B6B7D611AA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 3 Apr 2019 03:12:30 +0200 (CEST)", "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 8b61c347-55ad-11e9-8144-0050569116f7;\n\tWed, 03 Apr 2019 03:12:26 +0200 (CEST)" ], "X-Halon-ID": "8b61c347-55ad-11e9-8144-0050569116f7", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 3 Apr 2019 03:12:21 +0200", "Message-Id": "<20190403011221.12711-6-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190403011221.12711-1-niklas.soderlund@ragnatech.se>", "References": "<20190403011221.12711-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 5/5] libcamera: camera: Add support for\n\tstream roles", "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": "Wed, 03 Apr 2019 01:12:31 -0000" }, "content": "Instead of requesting the default configuration for a set of streams\nwhere the application has to figure out which streams provided by the\ncamera is best suited for its intended usage, have the library figure\nthis out by using stream roles.\n\nThe application asks the library for a list of streams and a suggested\ndefault configuration for them by supplying a list of stream roles. Once\nthe list is retrieved the application can try and fine-tune the returned\nconfiguration and then try to apply it to the camera.\n\nCurrently no pipeline handler is prepared to handle stream roles but nor\ndid it make use of the list of Stream IDs which was the previous\ninterface. The main reason for this is that all cameras currently only\nprovide one stream each. This will still be the case but the API will be\nprepared to expand both pipeline handlers and applications to support\nstreams roles.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h | 3 ++-\n src/cam/main.cpp | 2 +-\n src/libcamera/camera.cpp | 30 ++++++++----------------\n src/libcamera/include/pipeline_handler.h | 2 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++--\n src/libcamera/pipeline/uvcvideo.cpp | 6 ++---\n src/libcamera/pipeline/vimc.cpp | 6 ++---\n src/libcamera/pipeline_handler.cpp | 8 +++----\n src/qcam/main_window.cpp | 5 ++--\n test/camera/capture.cpp | 5 ++--\n test/camera/configuration_default.cpp | 17 +++++---------\n test/camera/configuration_set.cpp | 3 +--\n test/camera/statemachine.cpp | 4 +---\n 13 files changed, 36 insertions(+), 59 deletions(-)", "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 77e4cd1ee14c2c61..cafc9673db457148 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -22,6 +22,7 @@ class PipelineHandler;\n class Request;\n class Stream;\n class StreamConfiguration;\n+class StreamRole;\n \n class Camera final\n {\n@@ -44,7 +45,7 @@ public:\n \n \tconst std::set<Stream *> &streams() const;\n \tstd::map<Stream *, StreamConfiguration>\n-\tstreamConfiguration(std::set<Stream *> &streams);\n+\tstreamConfiguration(const std::vector<StreamRole> &roles);\n \tint configureStreams(std::map<Stream *, StreamConfiguration> &config);\n \n \tint allocateBuffers();\ndiff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex b5895fae85699b26..030003f081bdddda 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -81,7 +81,7 @@ static int parseOptions(int argc, char *argv[])\n static int prepareCameraConfig(std::map<Stream *, StreamConfiguration> *config)\n {\n \tstd::set<Stream *> streams = camera->streams();\n-\t*config = camera->streamConfiguration(streams);\n+\t*config = camera->streamConfiguration({ Stream::VideoRecording() });\n \tStream *stream = config->begin()->first;\n \n \tif (options.isSet(OptFormat)) {\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 8ee9cc0866167ae1..1f613590b579360c 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -345,33 +345,23 @@ const std::set<Stream *> &Camera::streams() const\n }\n \n /**\n- * \\brief Retrieve a group of stream configurations\n- * \\param[in] streams A map of stream IDs and configurations to setup\n+ * \\brief Retrieve a group of stream configurations according to stream roles\n+ * \\param[in] roles A list of stream roles\n *\n- * Retrieve the camera's configuration for a specified group of streams. The\n- * caller can specifies which of the camera's streams to retrieve configuration\n- * from by populating \\a streams.\n+ * Retrieve configuration for a set of desired usages. The caller specifies a\n+ * list of stream roles and the camera returns a map of suitable streams and\n+ * their suggested default configurations.\n *\n- * The easiest way to populate the array of streams to fetch configuration from\n- * is to first retrieve the camera's full array of stream with streams() and\n- * then potentially trim it down to only contain the streams the caller\n- * are interested in.\n- *\n- * \\return A map of successfully retrieved stream IDs and configurations or an\n- * empty list on error.\n+ * \\return A map of streams to configurations if the requested roles can be\n+ * satisfied, or an empty map otherwise\n */\n std::map<Stream *, StreamConfiguration>\n-Camera::streamConfiguration(std::set<Stream *> &streams)\n+Camera::streamConfiguration(const std::vector<StreamRole> &roles)\n {\n-\tif (disconnected_ || !streams.size())\n+\tif (disconnected_ || !roles.size() || roles.size() > streams_.size())\n \t\treturn std::map<Stream *, StreamConfiguration>{};\n \n-\tfor (Stream *stream : streams) {\n-\t\tif (streams_.find(stream) == streams_.end())\n-\t\t\treturn std::map<Stream *, StreamConfiguration>{};\n-\t}\n-\n-\treturn pipe_->streamConfiguration(this, streams);\n+\treturn pipe_->streamConfiguration(this, roles);\n }\n \n /**\ndiff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex acb376e07030ae03..cfb0a1147e0764c8 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -53,7 +53,7 @@ public:\n \tvirtual bool match(DeviceEnumerator *enumerator) = 0;\n \n \tvirtual std::map<Stream *, StreamConfiguration>\n-\tstreamConfiguration(Camera *camera, std::set<Stream *> &streams) = 0;\n+\tstreamConfiguration(Camera *camera, const std::vector<StreamRole> &roles) = 0;\n \tvirtual int configureStreams(Camera *camera,\n \t\t\t\t std::map<Stream *, StreamConfiguration> &config) = 0;\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 55489c31df2d0382..a707aefbc0f9b956 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -32,7 +32,7 @@ public:\n \n \tstd::map<Stream *, StreamConfiguration>\n \tstreamConfiguration(Camera *camera,\n-\t\t\t std::set<Stream *> &streams) override;\n+\t\t\t const std::vector<StreamRole> &roles) override;\n \tint configureStreams(Camera *camera,\n \t\t\t std::map<Stream *, StreamConfiguration> &config) override;\n \n@@ -100,7 +100,7 @@ PipelineHandlerIPU3::~PipelineHandlerIPU3()\n \n std::map<Stream *, StreamConfiguration>\n PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n-\t\t\t\t\t std::set<Stream *> &streams)\n+\t\t\t\t\t const std::vector<StreamRole> &roles)\n {\n \tIPU3CameraData *data = cameraData(camera);\n \tstd::map<Stream *, StreamConfiguration> configs;\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex cc3e0cd9afab38b9..cf0581e5be3e0a91 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -28,7 +28,7 @@ public:\n \n \tstd::map<Stream *, StreamConfiguration>\n \tstreamConfiguration(Camera *camera,\n-\t\t\t std::set<Stream *> &streams) override;\n+\t\t\t const std::vector<StreamRole> &roles) override;\n \tint configureStreams(Camera *camera,\n \t\t\t std::map<Stream *, StreamConfiguration> &config) override;\n \n@@ -84,14 +84,12 @@ PipelineHandlerUVC::~PipelineHandlerUVC()\n \n std::map<Stream *, StreamConfiguration>\n PipelineHandlerUVC::streamConfiguration(Camera *camera,\n-\t\t\t\t\tstd::set<Stream *> &streams)\n+\t\t\t\t\tconst std::vector<StreamRole> &roles)\n {\n \tUVCCameraData *data = cameraData(camera);\n-\n \tstd::map<Stream *, StreamConfiguration> configs;\n \tStreamConfiguration config{};\n \n-\tLOG(UVC, Debug) << \"Retrieving default format\";\n \tconfig.width = 640;\n \tconfig.height = 480;\n \tconfig.pixelFormat = V4L2_PIX_FMT_YUYV;\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 2e8c26fb7c0b2708..721f2f3f4f39b689 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -28,7 +28,7 @@ public:\n \n \tstd::map<Stream *, StreamConfiguration>\n \tstreamConfiguration(Camera *camera,\n-\t\t\t std::set<Stream *> &streams) override;\n+\t\t\t const std::vector<StreamRole> &roles) override;\n \tint configureStreams(Camera *camera,\n \t\t\t std::map<Stream *, StreamConfiguration> &config) override;\n \n@@ -84,14 +84,12 @@ PipelineHandlerVimc::~PipelineHandlerVimc()\n \n std::map<Stream *, StreamConfiguration>\n PipelineHandlerVimc::streamConfiguration(Camera *camera,\n-\t\t\t\t\t std::set<Stream *> &streams)\n+\t\t\t\t\t const std::vector<StreamRole> &roles)\n {\n \tVimcCameraData *data = cameraData(camera);\n \tstd::map<Stream *, StreamConfiguration> configs;\n-\n \tStreamConfiguration config{};\n \n-\tLOG(VIMC, Debug) << \"Retrieving default format\";\n \tconfig.width = 640;\n \tconfig.height = 480;\n \tconfig.pixelFormat = V4L2_PIX_FMT_RGB24;\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 1a858f2638ceac5f..738f87b8a22fc151 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -152,12 +152,12 @@ PipelineHandler::~PipelineHandler()\n * \\fn PipelineHandler::streamConfiguration()\n * \\brief Retrieve a group of stream configurations for a specified camera\n * \\param[in] camera The camera to fetch default configuration from\n- * \\param[in] streams An array of streams to fetch information about\n+ * \\param[in] roles A list of stream roles\n *\n * Retrieve the species camera's default configuration for a specified group of\n- * streams. The caller shall populate the \\a streams array with the streams it\n- * wish to fetch the configuration from. The map of streams and configuration\n- * returned can then be examined by the caller to learn about the defualt\n+ * use-cases. The caller shall populate the \\a roles array with the use-cases it\n+ * wishes to fetch the configuration for. The map of streams and configuration\n+ * returned can then be examined by the caller to learn about the default\n * parameters for the specified streams.\n *\n * The intended companion to this is \\a configureStreams() which can be used to\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex fea701422015ce67..faa3bc5739dd8453 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -97,9 +97,8 @@ int MainWindow::startCapture()\n {\n \tint ret;\n \n-\tStream *stream = *camera_->streams().begin();\n-\tstd::set<Stream *> streams{ stream };\n-\tconfig_ = camera_->streamConfiguration(streams);\n+\tconfig_ = camera_->streamConfiguration({ Stream::VideoRecording() });\n+\tStream *stream = config_.begin()->first;\n \tret = camera_->configureStreams(config_);\n \tif (ret < 0) {\n \t\tstd::cout << \"Failed to configure camera\" << std::endl;\ndiff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\nindex f6932b7505571712..b8dbdb62f9a50a33 100644\n--- a/test/camera/capture.cpp\n+++ b/test/camera/capture.cpp\n@@ -42,10 +42,9 @@ protected:\n \n \tint run()\n \t{\n-\t\tStream *stream = *camera_->streams().begin();\n-\t\tstd::set<Stream *> streams = { stream };\n \t\tstd::map<Stream *, StreamConfiguration> conf =\n-\t\t\tcamera_->streamConfiguration(streams);\n+\t\t\tcamera_->streamConfiguration({ Stream::VideoRecording() });\n+\t\tStream *stream = conf.begin()->first;\n \t\tStreamConfiguration *sconf = &conf.begin()->second;\n \n \t\tif (!configurationValid(conf)) {\ndiff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp\nindex 856cd415f7a6aec1..2d7bfc2e227c689f 100644\n--- a/test/camera/configuration_default.cpp\n+++ b/test/camera/configuration_default.cpp\n@@ -20,14 +20,10 @@ protected:\n \t{\n \t\tstd::map<Stream *, StreamConfiguration> conf;\n \n-\t\t/*\n-\t\t * Test that asking for default configuration for a valid\n-\t\t * array of streams returns something valid.\n-\t\t */\n-\t\tstd::set<Stream *> streams = { *camera_->streams().begin() };\n-\t\tconf = camera_->streamConfiguration(streams);\n+\t\t/* Test asking for configuration for a video stream. */\n+\t\tconf = camera_->streamConfiguration({ Stream::VideoRecording() });\n \t\tif (conf.empty()) {\n-\t\t\tcout << \"Failed to retrieve configuration for valid streams\"\n+\t\t\tcout << \"Failed to retrieve configuration for video streams\"\n \t\t\t << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -39,12 +35,11 @@ protected:\n \n \t\t/*\n \t\t * Test that asking for configuration for an empty array of\n-\t\t * streams returns an empty list of configurations.\n+\t\t * stream roles returns an empty list of configurations.\n \t\t */\n-\t\tstd::set<Stream *> streams_empty = {};\n-\t\tconf = camera_->streamConfiguration(streams_empty);\n+\t\tconf = camera_->streamConfiguration({});\n \t\tif (!conf.empty()) {\n-\t\t\tcout << \"Failed to retrieve configuration for empty streams\"\n+\t\t\tcout << \"Failed to retrieve configuration for empty usage list\"\n \t\t\t << endl;\n \t\t\treturn TestFail;\n \t\t}\ndiff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp\nindex cac1da959f241bc5..1bc01e66625eedf0 100644\n--- a/test/camera/configuration_set.cpp\n+++ b/test/camera/configuration_set.cpp\n@@ -18,9 +18,8 @@ class ConfigurationSet : public CameraTest\n protected:\n \tint run()\n \t{\n-\t\tstd::set<Stream *> streams = { *camera_->streams().begin() };\n \t\tstd::map<Stream *, StreamConfiguration> conf =\n-\t\t\tcamera_->streamConfiguration(streams);\n+\t\t\tcamera_->streamConfiguration({ Stream::VideoRecording() });\n \t\tStreamConfiguration *sconf = &conf.begin()->second;\n \n \t\tif (!configurationValid(conf)) {\ndiff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\nindex f4395f2b1bfed698..ab3c6fb5bea38c36 100644\n--- a/test/camera/statemachine.cpp\n+++ b/test/camera/statemachine.cpp\n@@ -235,9 +235,7 @@ protected:\n \n \tint run()\n \t{\n-\t\tStream *stream = *camera_->streams().begin();\n-\t\tstd::set<Stream *> streams = { stream };\n-\t\tdefconf_ = camera_->streamConfiguration(streams);\n+\t\tdefconf_ = camera_->streamConfiguration({ Stream::VideoRecording() });\n \n \t\tif (testAvailable() != TestPass) {\n \t\t\tcout << \"State machine in Available state failed\" << endl;\n", "prefixes": [ "libcamera-devel", "5/5" ] }