Show a patch.

GET /api/patches/386/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 386,
    "url": "https://patchwork.libcamera.org/api/patches/386/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/386/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20190125153340.2744-8-niklas.soderlund@ragnatech.se>",
    "date": "2019-01-25T15:33:40",
    "name": "[libcamera-devel,v2,7/7] cam: add option to statically configure a pipeline",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4915a73c3f005f2450b8c3fb18bb311b6bd20316",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": {
        "id": 16,
        "url": "https://patchwork.libcamera.org/api/users/16/?format=api",
        "username": "neg",
        "first_name": "Niklas",
        "last_name": "Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "mbox": "https://patchwork.libcamera.org/patch/386/mbox/",
    "series": [
        {
            "id": 132,
            "url": "https://patchwork.libcamera.org/api/series/132/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=132",
            "date": "2019-01-25T15:33:33",
            "name": "libcamera: add basic support for Streams and format configuration",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/132/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/386/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/386/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 218CF60C9D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jan 2019 16:33:55 +0100 (CET)",
            "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 9ee6f09a-20b6-11e9-874f-005056917f90;\n\tFri, 25 Jan 2019 16:33:53 +0100 (CET)"
        ],
        "X-Halon-ID": "9ee6f09a-20b6-11e9-874f-005056917f90",
        "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": "Fri, 25 Jan 2019 16:33:40 +0100",
        "Message-Id": "<20190125153340.2744-8-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190125153340.2744-1-niklas.soderlund@ragnatech.se>",
        "References": "<20190125153340.2744-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 7/7] cam: add option to statically\n\tconfigure a pipeline",
        "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": "Fri, 25 Jan 2019 15:33:56 -0000"
    },
    "content": "Add a option to statically configure the first stream of a camera to a\nfixed resolution. This should obviously be improved in the future but\nfor now serves as a good exercise for the Camera API towards an\napplication.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/cam/main.cpp | 62 ++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 50 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex cb98d302dcf30331..b8c05d9079be3cb3 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -20,7 +20,8 @@ using namespace libcamera;\n OptionsParser::Options options;\n \n enum {\n-\tOptCamera = 'c',\n+\tOptCamera = 'C',\n+\tOptFormat = 'f',\n \tOptHelp = 'h',\n \tOptList = 'l',\n };\n@@ -40,6 +41,7 @@ static int parseOptions(int argc, char *argv[])\n \tparser.addOption(OptCamera, \"Specify which camera to operate on\",\n \t\t\t \"camera\", OptionsParser::ArgumentRequired,\n \t\t\t \"camera\");\n+\tparser.addOption(OptFormat, \"Configure the first stream to 640x480\", \"format\");\n \tparser.addOption(OptHelp, \"Display this help message\", \"help\");\n \tparser.addOption(OptList, \"List all cameras\", \"list\");\n \n@@ -64,6 +66,8 @@ int main(int argc, char **argv)\n \t\treturn EXIT_FAILURE;\n \n \tCameraManager *cm = CameraManager::instance();\n+\tstd::shared_ptr<Camera> camera;\n+\tstd::vector<Stream> streams;\n \n \tret = cm->start();\n \tif (ret) {\n@@ -72,31 +76,65 @@ int main(int argc, char **argv)\n \t\treturn EXIT_FAILURE;\n \t}\n \n+\tloop = new EventLoop(cm->eventDispatcher());\n+\n+\tstruct sigaction sa = {};\n+\tsa.sa_handler = &signalHandler;\n+\tsigaction(SIGINT, &sa, nullptr);\n+\n \tif (options.isSet(OptList)) {\n \t\tstd::cout << \"Available cameras:\" << std::endl;\n-\t\tfor (const std::shared_ptr<Camera> &camera : cm->cameras())\n-\t\t\tstd::cout << \"- \" << camera->name() << std::endl;\n+\t\tfor (const std::shared_ptr<Camera> &cam : cm->cameras())\n+\t\t\tstd::cout << \"- \" << cam->name() << std::endl;\n \t}\n \n \tif (options.isSet(OptCamera)) {\n-\t\tstd::shared_ptr<Camera> cam = cm->get(options[OptCamera]);\n-\n-\t\tif (cam) {\n-\t\t\tstd::cout << \"Using camera \" << cam->name() << std::endl;\n-\t\t} else {\n+\t\tcamera = cm->get(options[OptCamera]);\n+\t\tif (!camera) {\n \t\t\tstd::cout << \"Camera \" << options[OptCamera]\n \t\t\t\t  << \" not found\" << std::endl;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tstreams = camera->streams();\n+\t\tif (streams.size() != 1) {\n+\t\t\tstd::cout << \"Camera have \" << streams.size() <<\n+\t\t\t\t\" streams, I only know how to work with 1\" << std::endl;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif (camera->acquire()) {\n+\t\t\tstd::cout << \"Failed to acquire camera\" << std::endl;\n+\t\t\tgoto out;\n \t\t}\n+\n+\t\tstd::cout << \"Using camera \" << camera->name() << std::endl;\n \t}\n \n-\tloop = new EventLoop(cm->eventDispatcher());\n+\tif (options.isSet(OptFormat)) {\n+\t\tif (!camera) {\n+\t\t\tstd::cout << \"Can't configure stream, no camera selected\" << std::endl;\n+\t\t\tgoto out_camera;\n+\t\t}\n \n-\tstruct sigaction sa = {};\n-\tsa.sa_handler = &signalHandler;\n-\tsigaction(SIGINT, &sa, nullptr);\n+\t\tStreamConfiguration config = StreamConfiguration(streams.front());\n+\t\tconfig.setDimension(640, 480);\n+\n+\t\tstd::vector<StreamConfiguration *> configs;\n+\t\tconfigs.push_back(&config);\n+\n+\t\tif (camera->configure(configs))\n+\t\t\tstd::cout << \"Failed to configure camera\" << std::endl;\n+\t}\n \n \tret = loop->exec();\n \n+out_camera:\n+\tif (camera) {\n+\t\tcamera->release();\n+\t\tcamera.reset();\n+\t}\n+out:\n \tdelete loop;\n \n \tcm->stop();\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "7/7"
    ]
}