From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 808464843D for ; Mon, 4 Dec 2023 13:55:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B92BC68CAB3; Mon, 4 Dec 2023 15:55:30 +0200 (EET) Received: from shout01.mail.de (shout01.mail.de [62.201.172.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78AB268BB77 for ; Mon, 4 Dec 2023 15:55:24 +0200 (EET) Received: from postfix01.mail.de (postfix01.bt.mail.de [10.0.121.125]) by shout01.mail.de (Postfix) with ESMTP id DBBA2240BA5 for ; Mon, 4 Dec 2023 14:55:23 +0100 (CET) Received: from smtp01.mail.de (smtp04.bt.mail.de [10.0.121.214]) by postfix01.mail.de (Postfix) with ESMTP id C3780801B2 for ; Mon, 4 Dec 2023 14:55:23 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id 9B1CC240A73 for ; Mon, 4 Dec 2023 14:55:23 +0100 (CET) Message-ID: <1179d31f-dcea-4a2d-b14a-59849e975d91@mail.de> Date: Mon, 4 Dec 2023 14:55:23 +0100 MIME-Version: 1.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: In-Reply-To: X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 2140 X-purgate-ID: 154282::1701698123-02C7B8B7-F3E1F4F5/0/0 Subject: Re: [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: , From: Thilo Borgmann via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Thilo Borgmann Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Am 04.12.23 um 13:47 schrieb xufuji456 via ffmpeg-devel: > 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 | 81 +++++++++++++++++++++++++++++++++++--- > 1 file changed, 76 insertions(+), 5 deletions(-) > > diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m > index 36ad834753..668c726eb7 100644 > --- a/libavdevice/avfoundation.m > +++ b/libavdevice/avfoundation.m > @@ -770,8 +770,38 @@ 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 = nil; > + NSArray *devices_muxed = nil; > + > + if (TARGET_OS_IPHONE) { > + if (@available(iOS 10.0, *)) { The preprocessor directives should be more reliable especially on older machines. See other parts of the code which are handled that way and adopt for your case. > + AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession = > + [AVCaptureDeviceDiscoverySession > + discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera] > + mediaType:AVMediaTypeVideo > + position:AVCaptureDevicePositionUnspecified]; > + devices = [captureDeviceDiscoverySession devices]; > + } else { > + devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; > + } > + } else { > + devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; > + } Here and in other chunks you can join the if() conditions into one and avoid the duplication of the old code. -Thilo _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".