Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] OF nightly minimum system requirement >13? (ofAVFoundationGrabber.mm:44:17: error: use of undeclared identifier 'AVCaptureDeviceTypeExternal'l) #8230

Open
gllmAR opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@gllmAR
Copy link
Contributor

gllmAR commented Dec 10, 2024

On a fresh download of OF of_v0.12.0_osx_release.zip

I can cd in any example and make without problem

On the nightly and via git clone, making a example return this error

../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm:44:17: error: use of undeclared identifier 'AVCaptureDeviceTypeExternal'
                AVCaptureDeviceTypeExternal
                ^
../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm:273:17: error: use of undeclared identifier 'AVCaptureDeviceTypeExternal'
                AVCaptureDeviceTypeExternal

tracing back the type lead to Apple

https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct/external

AVFoundation/AVCaptureDevice/AVCaptureDevice.DeviceType/external

which specify these requierements

iOS 17.0+/iPadOS 17.0+/Mac Catalyst 17.0+/macOS 14.0+/tvOS 17.0+/visionOS 2.1+

seem's like the following pre compile filter may not work as expected in file
openFrameworks/video/ofAVFoundationGrabber.mm

	if (@available(macOS 10.15, *)) {
        if (@available(macOS 14.0, *)) {

Any way to compile on macOS 13?

full compile log ->

videoPlayerExample % make
Compiling OF library for Release
💾 CXX = c++
💾 CC = cc
💾 CXX = c++
💾 CC = cc
Compiling ../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm
Compiling ../../../libs/openFrameworks/video/ofAVFoundationVideoPlayer.m
c++ -O3 -mtune=native -DNDEBUG -stdlib=libc++ -Wall -Werror=return-type -fexceptions -fpascal-strings -mmacosx-version-min=10.15 -std=c17 -fobjc-arc -DUSE_FMOD=0 -D__MACOSX_CORE__ -I../../../libs/FreeImage/include -I../../../libs/brotli/include -I../../../libs/brotli/include/brotli -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/curl/include -I../../../libs/curl/include/curl -I../../../libs/fmt/include -I../../../libs/fmt/include/fmt -I../../../libs/fmt/include/include -I../../../libs/fmt/include/include/fmt -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype -I../../../libs/freetype/include/freetype/config -I../../../libs/freetype/include/freetype/internal -I../../../libs/freetype/include/freetype/internal/services -I../../../libs/glew/include -I../../../libs/glew/include/GL -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/glm/include -I../../../libs/glm/include/glm -I../../../libs/glm/include/glm/ext -I../../../libs/glm/include/glm/simd -I../../../libs/glm/include/glm/detail -I../../../libs/glm/include/glm/gtc -I../../../libs/glm/include/glm/gtx -I../../../libs/json/include -I../../../libs/json/include/nlohmann -I../../../libs/libpng/include -I../../../libs/libpng/include/libpng16 -I../../../libs/libpng/include/include -I../../../libs/libpng/include/include/libpng16 -I../../../libs/openssl/include -I../../../libs/openssl/include/openssl -I../../../libs/pixman/include -I../../../libs/pugixml/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/uriparser/include -I../../../libs/uriparser/include/uriparser -I../../../libs/utf8/include -I../../../libs/utf8/include/utf8 -I../../../libs/zlib/include -I../../../libs/openFrameworks -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/sound -mmacosx-version-min=10.15 -x objective-c++ -std=c++2b -MMD -MP -MF ../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofAVFoundationGrabber.d -MT../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofAVFoundationGrabber.o -o ../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofAVFoundationGrabber.o -c ../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm
cc -O3 -mtune=native -DNDEBUG -stdlib=libc++ -Wall -Werror=return-type -fexceptions -fpascal-strings -mmacosx-version-min=10.15 -std=c17 -fobjc-arc -DUSE_FMOD=0 -D__MACOSX_CORE__ -I../../../libs/FreeImage/include -I../../../libs/brotli/include -I../../../libs/brotli/include/brotli -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/curl/include -I../../../libs/curl/include/curl -I../../../libs/fmt/include -I../../../libs/fmt/include/fmt -I../../../libs/fmt/include/include -I../../../libs/fmt/include/include/fmt -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype -I../../../libs/freetype/include/freetype/config -I../../../libs/freetype/include/freetype/internal -I../../../libs/freetype/include/freetype/internal/services -I../../../libs/glew/include -I../../../libs/glew/include/GL -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/glm/include -I../../../libs/glm/include/glm -I../../../libs/glm/include/glm/ext -I../../../libs/glm/include/glm/simd -I../../../libs/glm/include/glm/detail -I../../../libs/glm/include/glm/gtc -I../../../libs/glm/include/glm/gtx -I../../../libs/json/include -I../../../libs/json/include/nlohmann -I../../../libs/libpng/include -I../../../libs/libpng/include/libpng16 -I../../../libs/libpng/include/include -I../../../libs/libpng/include/include/libpng16 -I../../../libs/openssl/include -I../../../libs/openssl/include/openssl -I../../../libs/pixman/include -I../../../libs/pugixml/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/uriparser/include -I../../../libs/uriparser/include/uriparser -I../../../libs/utf8/include -I../../../libs/utf8/include/utf8 -I../../../libs/zlib/include -I../../../libs/openFrameworks -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/sound -mmacosx-version-min=10.15 -x objective-c++ -std=c++2b -MMD -MP -MF ../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofAVFoundationVideoPlayer.d -MT../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofAVFoundationVideoPlayer.o -o ../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofAVFoundationVideoPlayer.o -c ../../../libs/openFrameworks/video/ofAVFoundationVideoPlayer.m
In file included from ../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm:5:
In file included from ../../../libs/openFrameworks/video/ofAVFoundationGrabber.h:7:
../../../libs/openFrameworks/utils/ofConstants.h:117:11: warning: 'TARGET_OS_VISION' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
    #elif TARGET_OS_VISION
          ^
../../../libs/openFrameworks/video/ofAVFoundationVideoPlayer.m:631:16: warning: unused variable 'currentSampleRate' [-Wunused-variable]
        double currentSampleRate = preferredHardwareSampleRate;
               ^
1 warning generated.
Compiling ../../../libs/openFrameworks/types/ofRectangle.cpp
c++ -O3 -mtune=native -DNDEBUG -stdlib=libc++ -Wall -Werror=return-type -fexceptions -fpascal-strings -mmacosx-version-min=10.15 -std=c17 -fobjc-arc -DUSE_FMOD=0 -D__MACOSX_CORE__ -I../../../libs/FreeImage/include -I../../../libs/brotli/include -I../../../libs/brotli/include/brotli -I../../../libs/cairo/include -I../../../libs/cairo/include/cairo -I../../../libs/curl/include -I../../../libs/curl/include/curl -I../../../libs/fmt/include -I../../../libs/fmt/include/fmt -I../../../libs/fmt/include/include -I../../../libs/fmt/include/include/fmt -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype -I../../../libs/freetype/include/freetype/config -I../../../libs/freetype/include/freetype/internal -I../../../libs/freetype/include/freetype/internal/services -I../../../libs/glew/include -I../../../libs/glew/include/GL -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/glm/include -I../../../libs/glm/include/glm -I../../../libs/glm/include/glm/ext -I../../../libs/glm/include/glm/simd -I../../../libs/glm/include/glm/detail -I../../../libs/glm/include/glm/gtc -I../../../libs/glm/include/glm/gtx -I../../../libs/json/include -I../../../libs/json/include/nlohmann -I../../../libs/libpng/include -I../../../libs/libpng/include/libpng16 -I../../../libs/libpng/include/include -I../../../libs/libpng/include/include/libpng16 -I../../../libs/openssl/include -I../../../libs/openssl/include/openssl -I../../../libs/pixman/include -I../../../libs/pugixml/include -I../../../libs/rtAudio/include -I../../../libs/tess2/include -I../../../libs/uriparser/include -I../../../libs/uriparser/include/uriparser -I../../../libs/utf8/include -I../../../libs/utf8/include/utf8 -I../../../libs/zlib/include -I../../../libs/openFrameworks -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/video -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/sound -mmacosx-version-min=10.15 -x objective-c++ -std=c++2b -MMD -MP -MF ../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/types/ofRectangle.d -MT../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/types/ofRectangle.o -o ../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/types/ofRectangle.o -c ../../../libs/openFrameworks/types/ofRectangle.cpp
../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm:44:17: error: use of undeclared identifier 'AVCaptureDeviceTypeExternal'
                AVCaptureDeviceTypeExternal
                ^
../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm:273:17: error: use of undeclared identifier 'AVCaptureDeviceTypeExternal'
                AVCaptureDeviceTypeExternal
                ^
In file included from ../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm:5:
In file included from ../../../libs/openFrameworks/video/ofAVFoundationGrabber.h:13:
In file included from ../../../libs/openFrameworks/graphics/ofPixels.h:4:
../../../libs/openFrameworks/utils/ofLog.h:18:45: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
        size_t n = std::snprintf(buf, sizeof(buf), format, std::forward<Args>(args)...);
                                                   ^~~~~~
../../../libs/openFrameworks/utils/ofLog.h:464:19: note: in instantiation of function template specialization 'ofVAArgsToString<>' requested here
                        : ofLog(level, ofVAArgsToString(format, args...)){}
                                       ^
../../../libs/openFrameworks/video/ofAVFoundationGrabber.mm:424:2: note: in instantiation of function template specialization 'ofLog::ofLog<>' requested here
        ofLog(OF_LOG_VERBOSE, "ofAVFoundationGrabber destructor");
        ^
../../../libs/openFrameworks/utils/ofLog.h:18:45: note: treat the string as an argument to avoid this
        size_t n = std::snprintf(buf, sizeof(buf), format, std::forward<Args>(args)...);
                                                   ^
                                                   "%s", 
../../../libs/openFrameworks/utils/ofLog.h:30:56: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
        std::snprintf(const_cast<char *>(s.data()), s.size(), format, std::forward<Args>(args)...);
                                                              ^~~~~~
../../../libs/openFrameworks/utils/ofLog.h:30:56: note: treat the string as an argument to avoid this
        std::snprintf(const_cast<char *>(s.data()), s.size(), format, std::forward<Args>(args)...);
                                                              ^
                                                              "%s", 
3 warnings and 2 errors generated.
make[2]: *** [../../../libs/openFrameworksCompiled/lib/osx/obj/Release/libs/openFrameworks/video/ofAVFoundationGrabber.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from ../../../libs/openFrameworks/types/ofRectangle.cpp:2:
In file included from ../../../libs/openFrameworks/utils/ofLog.h:4:
In file included from ../../../libs/openFrameworks/utils/ofFileUtils.h:4:
../../../libs/openFrameworks/utils/ofConstants.h:117:11: warning: 'TARGET_OS_VISION' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
    #elif TARGET_OS_VISION
          ^
1 warning generated.
make[1]: *** [Release] Error 2
make: *** [Release] Error 2
### macOS System Information ###
macOS Version: 13.4.1
Build Version: 22F770820d
Mac Model: MacBookAir10,1
Processor: Apple M1
Number of Cores: 8
Memory: 8 GB
Disk Space: 460Gi total, 10Gi free
Graphics Card: Apple M1
@gllmAR
Copy link
Contributor Author

gllmAR commented Dec 10, 2024

doing something like the following solve my compile problem but feel wrong

[openFrameworks/video/ofAVFoundationGrabber.mm](https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/video/ofAVFoundationGrabber.mm)
- (BOOL)initCapture:(int)framerate capWidth:(int)w capHeight:(int)h{
	NSArray * devices;
	if (@available(macOS 10.15, *)) {
		if (@available(macOS 14.0, *)) {
			#ifdef AVCaptureDeviceTypeExternal
				AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
					discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeExternal]
					mediaType:AVMediaTypeVideo
					position:AVCaptureDevicePositionUnspecified];
			#else
				AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
					discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
					mediaType:AVMediaTypeVideo
					position:AVCaptureDevicePositionUnspecified];
			#endif
			devices = [session devices];
		} else {
            AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
                discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
                mediaType:AVMediaTypeVideo
                position:AVCaptureDevicePositionUnspecified];
            devices = [session devices];
        }
	} else {
        AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
            discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
            mediaType:AVMediaTypeVideo
            position:AVCaptureDevicePositionUnspecified];
        devices = [session devices];

	}
	

and

-(std::vector <std::string>)listDevices{
    std::vector <std::string> deviceNames;
	NSArray * devices;
	if (@available(macOS 10.15, *)) {
		if (@available(macOS 14.0, *)) {
				#ifdef AVCaptureDeviceTypeExternal
					AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
						discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeExternal]
						mediaType:AVMediaTypeVideo
						position:AVCaptureDevicePositionUnspecified];
				#else
					AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
						discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
						mediaType:AVMediaTypeVideo
						position:AVCaptureDevicePositionUnspecified];
				#endif
				devices = [session devices];
			} else {
					AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[
						AVCaptureDeviceTypeBuiltInWideAngleCamera
					] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
					devices = [session devices];
				}
			} else {
				AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
					discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
					mediaType:AVMediaTypeVideo
					position:AVCaptureDevicePositionUnspecified];
				devices = [session devices];
			}

	int i=0;
	for (AVCaptureDevice * captureDevice in devices){
        deviceNames.push_back([captureDevice.localizedName UTF8String]);
		 ofLogNotice() << "Device: " << i << ": " << deviceNames.back();
		i++;
    }
    return deviceNames;
}

@danoli3 danoli3 self-assigned this Dec 11, 2024
@danoli3 danoli3 added the macOS label Dec 11, 2024
@danoli3 danoli3 added this to the 0.12.1 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants