Skip to content

Commit 910729b

Browse files
shienapenninghlhd
andcommitted
Add CameraFeed support for iOS
Co-authored-by: Leo de Penning <[email protected]>
1 parent 21fbf03 commit 910729b

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

doc/classes/CameraFeed.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<description>
77
A camera feed gives you access to a single physical camera attached to your device. When enabled, Godot will start capturing frames from the camera which can then be used. See also [CameraServer].
88
[b]Note:[/b] Many cameras will return YCbCr images which are split into two textures and need to be combined in a shader. Godot does this automatically for you if you set the environment to show the camera image in the background.
9-
[b]Note:[/b] This class is currently only implemented on Linux, Android, macOS, and iOS. On other platforms no [CameraFeed]s will be available. To get a [CameraFeed] on iOS, the camera plugin from [url=https://github.com/godotengine/godot-ios-plugins]godot-ios-plugins[/url] is required.
9+
[b]Note:[/b] This class is currently only implemented on Linux, Android, macOS, and iOS. On other platforms no [CameraFeed]s will be available.
1010
</description>
1111
<tutorials>
1212
</tutorials>

doc/classes/CameraServer.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<description>
77
The [CameraServer] keeps track of different cameras accessible in Godot. These are external cameras such as webcams or the cameras on your phone.
88
It is notably used to provide AR modules with a video feed from the camera.
9-
[b]Note:[/b] This class is currently only implemented on Linux, Android, macOS, and iOS. On other platforms no [CameraFeed]s will be available. To get a [CameraFeed] on iOS, the camera plugin from [url=https://github.com/godotengine/godot-ios-plugins]godot-ios-plugins[/url] is required.
9+
[b]Note:[/b] This class is currently only implemented on Linux, Android, macOS, and iOS. On other platforms no [CameraFeed]s will be available.
1010
</description>
1111
<tutorials>
1212
</tutorials>

modules/camera/SCsub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Import("env_modules")
66

77
env_camera = env_modules.Clone()
88

9-
if env["platform"] in ["windows", "macos", "linuxbsd", "android"]:
9+
if env["platform"] in ["windows", "macos", "linuxbsd", "android", "ios"]:
1010
env_camera.add_source_files(env.modules_sources, "register_types.cpp")
1111

1212
if env["platform"] == "windows":
1313
env_camera.add_source_files(env.modules_sources, "camera_win.cpp")
1414

15-
elif env["platform"] == "macos":
15+
elif env["platform"] in ["macos", "ios"]:
1616
env_camera.add_source_files(env.modules_sources, "camera_macos.mm")
1717

1818
elif env["platform"] == "android":

modules/camera/camera_macos.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,14 @@ - (void)dealloc {
314314
if (@available(macOS 10.15, *)) {
315315
#endif
316316
AVCaptureDeviceDiscoverySession *session;
317-
if (@available(macOS 14.0, *)) {
317+
if (@available(macOS 14.0, iOS 17.0, *)) {
318318
session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeExternal, AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeContinuityCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
319319
} else {
320-
session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeExternalUnknown, AVCaptureDeviceTypeBuiltInWideAngleCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
320+
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
321+
session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeBuiltInWideAngleCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
322+
#else
323+
session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeExternalUnknown, AVCaptureDeviceTypeBuiltInWideAngleCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
324+
#endif
321325
}
322326
devices = session.devices;
323327
#if defined(__x86_64__)

modules/camera/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def can_build(env, platform):
33

44
if sys.platform.startswith("freebsd"):
55
return False
6-
return platform == "macos" or platform == "windows" or platform == "linuxbsd" or platform == "android"
6+
return platform in ["macos", "windows", "linuxbsd", "android", "ios"]
77

88

99
def configure(env):

modules/camera/register_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#if defined(WINDOWS_ENABLED)
3737
#include "camera_win.h"
3838
#endif
39-
#if defined(MACOS_ENABLED)
39+
#if defined(MACOS_ENABLED) || defined(IOS_ENABLED)
4040
#include "camera_macos.h"
4141
#endif
4242
#if defined(ANDROID_ENABLED)
@@ -54,7 +54,7 @@ void initialize_camera_module(ModuleInitializationLevel p_level) {
5454
#if defined(WINDOWS_ENABLED)
5555
CameraServer::make_default<CameraWindows>();
5656
#endif
57-
#if defined(MACOS_ENABLED)
57+
#if defined(MACOS_ENABLED) || defined(IOS_ENABLED)
5858
CameraServer::make_default<CameraMacOS>();
5959
#endif
6060
#if defined(ANDROID_ENABLED)

0 commit comments

Comments
 (0)