* [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace deprecated AVCaptureDevice
@ 2023-12-06 12:03 xufuji456 via ffmpeg-devel
2023-12-06 17:39 ` Thilo Borgmann via ffmpeg-devel
0 siblings, 1 reply; 5+ messages in thread
From: xufuji456 via ffmpeg-devel @ 2023-12-06 12:03 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: xufuji456
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 | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 36ad834753..5ebfe89dca 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -761,6 +761,19 @@ 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))
+ AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession =
+ [AVCaptureDeviceDiscoverySession
+ discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
+ mediaType:mediaType
+ position:AVCaptureDevicePositionUnspecified];
+ return [captureDeviceDiscoverySession devices];
+#else
+ return [AVCaptureDevice devicesWithMediaType:mediaType];
+#endif
+}
+
static int avf_read_header(AVFormatContext *s)
{
int ret = 0;
@@ -770,8 +783,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 +819,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 +943,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 +956,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))) {
--
2.32.0 (Apple Git-132)
_______________________________________________
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace deprecated AVCaptureDevice
2023-12-06 12:03 [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace deprecated AVCaptureDevice xufuji456 via ffmpeg-devel
@ 2023-12-06 17:39 ` Thilo Borgmann via ffmpeg-devel
0 siblings, 0 replies; 5+ messages in thread
From: Thilo Borgmann via ffmpeg-devel @ 2023-12-06 17:39 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Thilo Borgmann
Am 06.12.23 um 13:03 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 | 23 ++++++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index 36ad834753..5ebfe89dca 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -761,6 +761,19 @@ 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))
> + AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession =
> + [AVCaptureDeviceDiscoverySession
> + discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
deviceTypes should be an array of all possible types or we risk loosing currently detected hardware.
Otherwise, LGTM.
-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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace deprecated AVCaptureDevice
@ 2023-12-09 12:09 xufuji456 via ffmpeg-devel
2023-12-11 9:32 ` Thilo Borgmann via ffmpeg-devel
0 siblings, 1 reply; 5+ messages in thread
From: xufuji456 via ffmpeg-devel @ 2023-12-09 12:09 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: xufuji456
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 | 65 +++++++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 5 deletions(-)
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 36ad834753..aa892fae60 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -761,6 +761,61 @@ 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))
+ NSMutableArray *deviceTypes = nil;
+ if (mediaType == AVMediaTypeVideo) {
+ deviceTypes = [NSMutableArray arrayWithArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]];
+ #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000)
+ [deviceTypes addObject: AVCaptureDeviceTypeBuiltInDualCamera];
+ [deviceTypes addObject: AVCaptureDeviceTypeBuiltInTelephotoCamera];
+ #endif
+ #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110100)
+ [deviceTypes addObject: AVCaptureDeviceTypeBuiltInTrueDepthCamera];
+ #endif
+ #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000)
+ [deviceTypes addObject: AVCaptureDeviceTypeBuiltInTripleCamera];
+ [deviceTypes addObject: AVCaptureDeviceTypeBuiltInDualWideCamera];
+ [deviceTypes addObject: AVCaptureDeviceTypeBuiltInUltraWideCamera];
+ #endif
+ #if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000)
+ [deviceTypes addObject: AVCaptureDeviceTypeDeskViewCamera];
+ #endif
+ #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 150400)
+ [deviceTypes addObject: AVCaptureDeviceTypeBuiltInLiDARDepthCamera];
+ #endif
+ #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 || (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140000))
+ [deviceTypes addObject: AVCaptureDeviceTypeContinuityCamera];
+ #endif
+ } else if (mediaType == AVMediaTypeAudio) {
+ #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 || (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140000))
+ deviceTypes = [NSMutableArray arrayWithArray:@[AVCaptureDeviceTypeMicrophone]];
+ #else
+ deviceTypes = [NSMutableArray arrayWithArray:@[AVCaptureDeviceTypeBuiltInMicrophone]];
+ #endif
+ } else if (mediaType == AVMediaTypeMuxed) {
+ #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 || (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140000))
+ deviceTypes = [NSMutableArray arrayWithArray:@[AVCaptureDeviceTypeExternal]];
+ #elseif (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED < 140000)
+ deviceTypes = [NSMutableArray arrayWithArray:@[AVCaptureDeviceTypeExternalUnknown]];
+ #else
+ return nil;
+ #endif
+ } else {
+ return nil;
+ }
+
+ AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession =
+ [AVCaptureDeviceDiscoverySession
+ discoverySessionWithDeviceTypes:deviceTypes
+ mediaType:mediaType
+ position:AVCaptureDevicePositionUnspecified];
+ return [captureDeviceDiscoverySession devices];
+#else
+ return [AVCaptureDevice devicesWithMediaType:mediaType];
+#endif
+}
+
static int avf_read_header(AVFormatContext *s)
{
int ret = 0;
@@ -770,8 +825,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 +861,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 +985,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 +998,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))) {
--
2.32.0 (Apple Git-132)
_______________________________________________
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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace deprecated AVCaptureDevice
2023-12-09 12:09 xufuji456 via ffmpeg-devel
@ 2023-12-11 9:32 ` Thilo Borgmann via ffmpeg-devel
2023-12-11 14:54 ` Thilo Borgmann via ffmpeg-devel
0 siblings, 1 reply; 5+ messages in thread
From: Thilo Borgmann via ffmpeg-devel @ 2023-12-11 9:32 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Thilo Borgmann
Am 09.12.23 um 13:09 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 | 65 +++++++++++++++++++++++++++++++++++---
> 1 file changed, 60 insertions(+), 5 deletions(-)
LGTM.
Will apply shortly if there are no more comments.
-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".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace deprecated AVCaptureDevice
2023-12-11 9:32 ` Thilo Borgmann via ffmpeg-devel
@ 2023-12-11 14:54 ` Thilo Borgmann via ffmpeg-devel
0 siblings, 0 replies; 5+ messages in thread
From: Thilo Borgmann via ffmpeg-devel @ 2023-12-11 14:54 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Thilo Borgmann
Am 11.12.23 um 10:32 schrieb Thilo Borgmann via ffmpeg-devel:
> Am 09.12.23 um 13:09 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 | 65 +++++++++++++++++++++++++++++++++++---
>> 1 file changed, 60 insertions(+), 5 deletions(-)
>
> LGTM.
>
> Will apply shortly if there are no more comments.
Pushed.
-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".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-11 14:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-06 12:03 [FFmpeg-devel] [PATCH] avdevice/avfoundation: replace deprecated AVCaptureDevice xufuji456 via ffmpeg-devel
2023-12-06 17:39 ` Thilo Borgmann via ffmpeg-devel
2023-12-09 12:09 xufuji456 via ffmpeg-devel
2023-12-11 9:32 ` Thilo Borgmann via ffmpeg-devel
2023-12-11 14:54 ` Thilo Borgmann via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git