From patchwork Thu Oct 15 21:30:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Forest Crossman X-Patchwork-Id: 22983 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:3414:0:0:0:0:0 with SMTP id b20csp784452yba; Thu, 15 Oct 2020 14:39:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR2XX/lD7BW03MttqyfIT79zIstGovoMPytFoyZRU//xYHD8nXvEDVtLG2ZEdqhZ59gwLC X-Received: by 2002:a05:6000:1084:: with SMTP id y4mr294354wrw.138.1602797945048; Thu, 15 Oct 2020 14:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602797945; cv=none; d=google.com; s=arc-20160816; b=RhogIgUjwvwfq/ZaX1JKqyDOSQpGDkOEXRISZQX3gEPLTUcyQokfKDuumirMB2dYIQ /6gCLIHqXXC1yr3wHr/uahO73DL1O/MW5IJMaXG3dqu/M2T5/d1oaOhqS1UbDE5yOBZ8 aMwPo0YQjqmR/f9BDFDDsuaqydqWN9WAEBpHjLVlRsDSIdLsgPfEocYfEL9Ywe368sPq 8ldAUOj08VM6RRCz4AYr9NoZI9jd+0uE7zyphdeClifrqY9TS5fTIGOC9ABSiWBnA95Y glN9Gsm4L29w64DSgO0yI50x5op+ZBfq1jFhH8P7A24aDIxV3B1K0Wa0LD/uW2NH6iS6 cLOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=rC763xqZW4bpcRn0vejaYohr6ybSN0YomH4pcI8B63Q=; b=RZXZ6Hs/91p5vl1pK/l5v4SKKe1vZG4NvfUbySctzyeMp90WFTNF5u0DP406EZydxz nln/+gx/ECnAWj98Jxm1JE+yfmG202206yKpu1TA27VC1uuGiN+IptUIA8ing8pHAL+W ECXMb2TTVvZSjz5zHyDe0061J2613a/6FaAOvEm5Iw9IVUPyAla5mS3XMmWbtZDl/FgO 0RI7bdVCM1Zt1DxOF3scTrfHFIEJ/SGqYEzwvDHZnHroDbw8Wj+5VWCLTKHPrXI2Dr6q X4wiVfKRlVQPqu0YDNgZz7pEM4GLMzNBaQU5yZcXhyMUcM57lN0bhscOvyCxTKoI1wsz 66wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Rtkq4n7s; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 72si296816wrc.120.2020.10.15.14.39.04; Thu, 15 Oct 2020 14:39:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Rtkq4n7s; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B426F68B972; Fri, 16 Oct 2020 00:39:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb1-f196.google.com (mail-yb1-f196.google.com [209.85.219.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81D3D68B944 for ; Fri, 16 Oct 2020 00:38:52 +0300 (EEST) Received: by mail-yb1-f196.google.com with SMTP id l15so223388ybp.2 for ; Thu, 15 Oct 2020 14:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QbdLXWyoMNkpb2Dh5vTCa3okl/FVn85g3qf1B0lW7Nk=; b=Rtkq4n7sAP7JXdBoh0goyxs90OzXoZkMgO3bEJJ3Uv5xbaHTbNTdzwo1EkrIuT09O+ r9wtEwBEJHKfTCO5tRGRU1mz8ZUlMExWooTZ1yjCKueHRTcPqU/DGQxp2EGxGcDTlNH/ wIcmtXa0rd1arqXp2vyS1+z5TIitpYiJbM8wNqMdBMIPQQP575QmzwumvmXaUA3ZS5zU HOyyC2sxQGT792SapIY/USZDStUulwqLRnvWBx6vaiIhllgLvk6HzEOQ3GloI8o2KM37 I4F+5aB2GjxT1UmvEvLckT9RbBoXgXPUNjA7TnO5e0QpZW6HN3DBWeaKhO4ByKDK1dC5 b2Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QbdLXWyoMNkpb2Dh5vTCa3okl/FVn85g3qf1B0lW7Nk=; b=ej7syPblM1Fh8HylqB36GoT7A1nUkn7mwy/YT6M3dEea9Vnaxa+8d7OMeXz1ieqflr 1qvOxjovbvVSGqu0hWT+flYyskt0bufdQfky0GG/kmZyH5SkwUue14p9Gf7M70AZjMPG gszShGeZVp30Izni5yYpvSp0uD/DJm2ePncZpjr+Z2NxTWwunpxb0/D16U3rtnoAcdl4 gR4U6FQs24dBeqIJuQqeIk0wzbKz0BDcO3o6z8l12OoIc6oSa0VL+ht2QlSh+lmEtUry ah2FYmH4PLHjuPPyKetie2OEcc7wJKQ7jChB2OFI1O8dF/6LSZl0sICfYgi2grP0iGVU xgrA== X-Gm-Message-State: AOAM5333PqzodQyJD1u9W1NdAlmUx9cl7GTva2ZO7wcgG2y15cBai4lB LQccq53bVXuqKdnSYvxTixC4IgwrYsk= X-Received: by 2002:a9d:d23:: with SMTP id 32mr392942oti.34.1602797455536; Thu, 15 Oct 2020 14:30:55 -0700 (PDT) Received: from localhost.localdomain ([170.130.31.90]) by smtp.gmail.com with ESMTPSA id 15sm233248ooy.36.2020.10.15.14.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 14:30:54 -0700 (PDT) From: Forest Crossman To: ffmpeg-devel@ffmpeg.org Date: Thu, 15 Oct 2020 16:30:37 -0500 Message-Id: <20201015213039.1019624-4-cyrozap@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201015213039.1019624-1-cyrozap@gmail.com> References: <20191020095533.15016-1-cyrozap@gmail.com> <20201015213039.1019624-1-cyrozap@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/5] libdc1394: Enable specifying a camera by GUID[:unit] X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Forest Crossman Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: cbM497dZunkV Content-Length: 6197 This enables a user to select a specific unit of a specific camera, instead of always selecting the first unit of the first camera that's found. Signed-off-by: Forest Crossman --- doc/indevs.texi | 3 ++ libavdevice/libdc1394.c | 70 ++++++++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 3d554bc8d8..46203833e9 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -1096,6 +1096,9 @@ IIDC1394 input device, based on libdc1394 and libraw1394. Requires the configure option @code{--enable-libdc1394}. +Specify the FireWire device GUID to be used as the input file, or "auto" +to choose the first device detected. + @subsection Options @table @option diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index 7be1d7b8dd..90252f7c4a 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -171,6 +171,8 @@ static int dc1394_read_header(AVFormatContext *c) dc1394_data* dc1394 = c->priv_data; dc1394camera_list_t *list; int res, i; + uint64_t guid; + uint16_t unit; const struct dc1394_frame_format *fmt = NULL; const struct dc1394_frame_rate *fps = NULL; const struct dc1394_frame_format *tmp_fmt; @@ -186,33 +188,57 @@ static int dc1394_read_header(AVFormatContext *c) /* Now let us prep the hardware. */ dc1394->d = dc1394_new(); - if (dc1394_camera_enumerate(dc1394->d, &list) != DC1394_SUCCESS || !list) { - av_log(c, AV_LOG_ERROR, "Unable to look for an IIDC camera.\n"); - goto out; - } - if (list->num == 0) { - av_log(c, AV_LOG_ERROR, "No cameras found.\n"); - dc1394_camera_free_list(list); - goto out; - } + /* Parse URL */ + if (sscanf(c->url, "0x%"SCNx64":%"SCNu16, &guid, &unit) == 2) { + /* If both the GUID and unit are set, open the device based on + * those values exactly. */ + dc1394->camera = dc1394_camera_new_unit(dc1394->d, guid, unit); + if (!dc1394->camera) { + av_log(c, AV_LOG_ERROR, "Unable to open camera 0x%016"PRIx64":%"PRIu16"\n", + guid, unit); + goto out; + } + } else if (sscanf(c->url, "0x%"SCNx64, &guid) == 1) { + /* If the GUID is set, but not the unit, grab the device using + * the first unit found. */ + dc1394->camera = dc1394_camera_new(dc1394->d, guid); + if (!dc1394->camera) { + av_log(c, AV_LOG_ERROR, "Unable to open camera 0x%016"PRIx64"\n", + guid); + goto out; + } + } else { + /* If no GUID is set, or is set to "auto", use the first camera + * found. */ + if (dc1394_camera_enumerate(dc1394->d, &list) != DC1394_SUCCESS || !list) { + av_log(c, AV_LOG_ERROR, "Unable to look for an IIDC camera.\n"); + goto out; + } - /* FIXME: To select a specific camera I need to search in list its guid */ - dc1394->camera = dc1394_camera_new (dc1394->d, list->ids[0].guid); + if (list->num == 0) { + av_log(c, AV_LOG_ERROR, "No cameras found.\n"); + dc1394_camera_free_list(list); + goto out; + } - if (!dc1394->camera) { - av_log(c, AV_LOG_ERROR, "Unable to open camera with guid 0x%"PRIx64"\n", - list->ids[0].guid); - dc1394_camera_free_list(list); - goto out; - } + if (list->num > 1) { + av_log(c, AV_LOG_INFO, "Multiple cameras detected, using the first camera found.\n"); + } - if (list->num > 1) { - av_log(c, AV_LOG_INFO, "Working with the first camera found\n"); - } + guid = list->ids[0].guid; + unit = list->ids[0].unit; + dc1394->camera = dc1394_camera_new_unit(dc1394->d, guid, unit); - /* Freeing list of cameras */ - dc1394_camera_free_list (list); + /* Freeing list of cameras */ + dc1394_camera_free_list (list); + + if (!dc1394->camera) { + av_log(c, AV_LOG_ERROR, "Unable to open camera 0x%016"PRIx64":%"PRIu16"\n", + guid, unit); + goto out; + } + } /* Select MAX Speed possible from the cam */ if (dc1394->camera->bmode_capable>0) {