From patchwork Tue Dec 5 13:33:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5b6Q56aP6ZqG?= <839789740@qq.com> X-Patchwork-Id: 44917 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9153:b0:181:818d:5e7f with SMTP id x19csp329875pzc; Tue, 5 Dec 2023 05:34:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFM+ymjVobBRKeZ86aWwvUzMh5HefojF9NxRYF67+YXwGx8m9E4v4Bt62a5fK3+GGk1LnEt X-Received: by 2002:a50:fc13:0:b0:54b:3f0c:7fe0 with SMTP id i19-20020a50fc13000000b0054b3f0c7fe0mr1610402edr.6.1701783247450; Tue, 05 Dec 2023 05:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701783247; cv=none; d=google.com; s=arc-20160816; b=tadHUpLJNpchm3vFSHQbx3Df3iljOxMI55zJUlZ7vWJMuCKsLGEIQpjyf67bKKT3P5 E9T+XBFohRWWbZKGjGZyyNBz/Xt0DQu9aM3YGEvHQG+L+kcDuRuU5qxF8HKL05sSmCHR h1YrZbbGshtNWwU5IoBBesEOQrbtzRKQ5z9bTR16sFaUpoMJ6oA3DNcwvu+W6AGNUcQI M3bndBlXaG0Hbn/X5a/43ui34K0T3H4QxrNrZFSs1Id/mFINhJ2U2OEvbQfTz94mBJZq nMtid6+2RLOSOkPL7td3ipRH1t2R0MNX1rv5aN2mV0QxLbN6WW1gXKemDR6CvzMbIesp CVDw== 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:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:date:to:message-id :delivered-to; bh=C1FmzXMeGozJ65ZBrKl80+OfLzSaO9J6oJctSPzzAl4=; fh=/QvfVIDcib8YPugs5q/sxqF0zCx8M9migilS77PcQx8=; b=jC9zkDLgUOr1TBqt9iSjeZ4c/yMRx2QZHA05OIPX6rQm5jH3SSmXeSgMCVxw1XUoYs XfemjRTRCfb7Bc3JVgnFeXakuxIBjHg69WZyZEhFvAodYFjnS+k/zUJEisWwGR8C7E7C 8nqPJCH8AOyWaFwzX+bs/3IGhR8rXJLNKZFYq2MSOjL6iAQz/sEnxgJ4EkZ6T8k8vzfH Fb39fRkLVHT7ZQVPYWNBds1dT1eQ7S2EdZiTXuLBflVdTPGG8nZLptgmVe0GbEIOiCgp /s5nLSWDO0pCTlOYLMQkF66pBpkNbo5THPZTBZ+RiGLLDG1gbY4fkhNfoJMNVfICGyCv iHRw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u22-20020a50a416000000b0054c9694d110si849677edb.199.2023.12.05.05.33.55; Tue, 05 Dec 2023 05:34:07 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2EF1768CEB9; Tue, 5 Dec 2023 15:33:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3FF268CD8E for ; Tue, 5 Dec 2023 15:33:43 +0200 (EET) Received: from localhost.localdomain ([14.145.2.241]) by newxmesmtplogicsvrszc5-0.qq.com (NewEsmtp) with SMTP id 86486499; Tue, 05 Dec 2023 21:33:36 +0800 X-QQ-mid: xmsmtpt1701783216tbijs89ye Message-ID: X-QQ-XMAILINFO: NiDupExshEc7ZDEE6BQioZIKCHciTX+aXGcBhw9XcnfmX2WHyAfTUMJMD+Gho4 bIZiw9y2G44jfkfbPJzR30I4kg5+QKHXlqjBF90/nMK5tJXDdLVwO7Dd7Pc96QseJ0R5KloCMYbL waOVHgangoAj4Fw01tAJGehAJ3c++6MRnDI3X1vdIMbNP/YEgDDFmD5Qd3SYHKOLuEIFEMrDhYad JgVJNpC0n6ziTAX/UOZu2xrgFsdr1VgQ0aWThhR8p/mnKutYd8gS+iyqJgPNBcAf0pOj1mnNSBRw Oi96KK4znwwls/l6QI+pkL1PbJ7JqXyGWufsD7hyKXy6kXT8GBvB0Tgoh2NUhgZrsvSHjEbATXcM +EqoCOcoPQWR3Wnheyac2QG7efVyzwmJK5Jcbg8lGfTfhfVWT9wWbGsiEOTu/dG1NiGzFCN9T8nZ GTI/zXb4QAE9fad02AX3nJ59znEFF2BOMJ6OGO4ANK5VZExeJW7DRR9Z8N3QVDiPHkkFxsfP/ZQV JK2St883SlpV2UHpF57YNtmaA6dncj2vRSMHpTDo26AmtXiewlvXcWSAkTxgW0OGiF17SULLEVbz 5a7jOQjFvafWX/ffYGvkXiss3T2bzkED9GBTWJ4/YKbn5VdhnRDWofUQ3wohKm6gLxua0jos4Hnr tNAZISniBccqVCoEoM2W31XzQelR0mYZvVsFjxfNC4NbSvq4n0pjHQ9/M12vCE5M2rOGBMNPaAHN CaOwoIVvm7z2HtycGrAJ33IqmKdtOGQKxS97nY3SRHkIi71UMTaP1/9Yq1dnBV55MQzUgG1ZU+8n 7qilktTU7hz4of/F397h8jpDXeuN7+AXUm6yyb8YwnHsfXFUHJk9p7z56NrVdcjHPy6115EjSgTa fKaJDJR0bTD11b2rgWXoDpZ1QQLIwk0apnBA/DbvFO2WRvbBPDJxdRctHqfwMQyKs3LeNDv//NhX YIDyNDaf2QaXGw1Nj5OVG/LWdvX9xpxpSmY6+7KDmL8OSmH4UL6g== X-QQ-XMRINFO: NI4Ajvh11aEj8Xl/2s1/T8w= To: ffmpeg-devel@ffmpeg.org Date: Tue, 5 Dec 2023 21:33:34 +0800 X-OQ-MSGID: <20231205133334.24093-1-839789740@qq.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace AVCaptureDevice with new api X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: xufuji456 via ffmpeg-devel From: =?utf-8?b?5b6Q56aP6ZqG?= <839789740@qq.com> Reply-To: FFmpeg development discussions and patches Cc: xufuji456 <839789740@qq.com> Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nVnK747ZLCeG Building with iOS platform, the compiler has a warning: "'devicesWithMediaType:' is deprecated: first deprecated in iOS 10.0 - Use AVCaptureDeviceDiscoverySession instead" Signed-off-by: xufuji456 <839789740@qq.com> --- libavdevice/avfoundation.m | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m index 36ad834753..1bc99d543a 100644 --- a/libavdevice/avfoundation.m +++ b/libavdevice/avfoundation.m @@ -761,6 +761,21 @@ static int get_audio_config(AVFormatContext *s) return 0; } +static NSArray* getDevicesWithMediaType(AVMediaType mediaType) { +#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000) || (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101500)) + if (@available(macOS 10.15, iOS 10.0, *)) { + AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession = + [AVCaptureDeviceDiscoverySession + discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera] + mediaType:mediaType + position:AVCaptureDevicePositionUnspecified]; + return [captureDeviceDiscoverySession devices]; + } +#endif + // fallback + return [AVCaptureDevice devicesWithMediaType:mediaType]; +} + static int avf_read_header(AVFormatContext *s) { int ret = 0; @@ -770,8 +785,8 @@ static int avf_read_header(AVFormatContext *s) AVCaptureDevice *video_device = nil; AVCaptureDevice *audio_device = nil; // Find capture device - NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; - NSArray *devices_muxed = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed]; + NSArray *devices = getDevicesWithMediaType(AVMediaTypeVideo); + NSArray *devices_muxed = getDevicesWithMediaType(AVMediaTypeMuxed); ctx->num_video_devices = [devices count] + [devices_muxed count]; @@ -806,7 +821,7 @@ static int avf_read_header(AVFormatContext *s) #endif av_log(ctx, AV_LOG_INFO, "AVFoundation audio devices:\n"); - devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio]; + devices = getDevicesWithMediaType(AVMediaTypeAudio); for (AVCaptureDevice *device in devices) { const char *name = [[device localizedName] UTF8String]; int index = [devices indexOfObject:device]; @@ -930,7 +945,7 @@ static int avf_read_header(AVFormatContext *s) // get audio device if (ctx->audio_device_index >= 0) { - NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio]; + NSArray *devices = getDevicesWithMediaType(AVMediaTypeAudio); if (ctx->audio_device_index >= [devices count]) { av_log(ctx, AV_LOG_ERROR, "Invalid audio device index\n"); @@ -943,7 +958,7 @@ static int avf_read_header(AVFormatContext *s) if (!strncmp(ctx->audio_filename, "default", 7)) { audio_device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio]; } else { - NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio]; + NSArray *devices = getDevicesWithMediaType(AVMediaTypeAudio); for (AVCaptureDevice *device in devices) { if (!strncmp(ctx->audio_filename, [[device localizedName] UTF8String], strlen(ctx->audio_filename))) {