diff --git a/modules/juce_audio_devices/native/juce_Audio_ios.cpp b/modules/juce_audio_devices/native/juce_Audio_ios.cpp index 8ec93c13c8..64dc6ccfb4 100644 --- a/modules/juce_audio_devices/native/juce_Audio_ios.cpp +++ b/modules/juce_audio_devices/native/juce_Audio_ios.cpp @@ -298,10 +298,8 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater { options |= AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetooth - | AVAudioSessionCategoryOptionAllowAirPlay; - - if (@available (iOS 10.0, *)) - options |= AVAudioSessionCategoryOptionAllowBluetoothA2DP; + | AVAudioSessionCategoryOptionAllowAirPlay + | AVAudioSessionCategoryOptionAllowBluetoothA2DP; } JUCE_NSERROR_CHECK ([[AVAudioSession sharedInstance] setCategory: category @@ -739,18 +737,9 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater &dataSize); if (err == noErr) { - if (@available (iOS 10.0, *)) - { - [[UIApplication sharedApplication] openURL: (NSURL*) hostUrl - options: @{} - completionHandler: nil]; - - return; - } - - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - [[UIApplication sharedApplication] openURL: (NSURL*) hostUrl]; - JUCE_END_IGNORE_WARNINGS_GCC_LIKE + [[UIApplication sharedApplication] openURL: (NSURL*) hostUrl + options: @{} + completionHandler: nil]; } } diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm index 5b2c68448c..f314187dc3 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm @@ -633,7 +633,7 @@ public: { const auto value = (newValue != nullptr ? *newValue : juceParam->getValue()) * getMaximumParameterValue (*juceParam); - if (@available (macOS 10.12, iOS 10.0, *)) + if (@available (macOS 10.12, *)) { [param setValue: value originator: editorObserverToken.get() diff --git a/modules/juce_core/native/juce_Files_mac.mm b/modules/juce_core/native/juce_Files_mac.mm index 96fa367635..85843d70c5 100644 --- a/modules/juce_core/native/juce_Files_mac.mm +++ b/modules/juce_core/native/juce_Files_mac.mm @@ -395,18 +395,11 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, [[maybe_unused : [NSURL URLWithString: fileNameAsNS]; #if JUCE_IOS - if (@available (iOS 10.0, *)) - { - [[UIApplication sharedApplication] openURL: filenameAsURL - options: @{} - completionHandler: nil]; + [[UIApplication sharedApplication] openURL: filenameAsURL + options: @{} + completionHandler: nil]; - return true; - } - - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - return [[UIApplication sharedApplication] openURL: filenameAsURL]; - JUCE_END_IGNORE_WARNINGS_GCC_LIKE + return true; #else NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; diff --git a/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm b/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm index 44c89dd5b0..f30b6ff3d3 100644 --- a/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm +++ b/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm @@ -1159,12 +1159,7 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet* presses, UIPr if (auto* target = [self getTextInputTarget]) { if (action == @selector (paste:)) - { - if (@available (iOS 10, *)) - return [[UIPasteboard generalPasteboard] hasStrings]; - - return [[UIPasteboard generalPasteboard] string] != nil; - } + return [[UIPasteboard generalPasteboard] hasStrings]; } return [super canPerformAction: action withSender: sender]; diff --git a/modules/juce_gui_extra/native/juce_PushNotifications_ios.cpp b/modules/juce_gui_extra/native/juce_PushNotifications_ios.cpp index 35dbdad9ba..89975d3a3d 100644 --- a/modules/juce_gui_extra/native/juce_PushNotifications_ios.cpp +++ b/modules/juce_gui_extra/native/juce_PushNotifications_ios.cpp @@ -43,77 +43,34 @@ struct PushNotificationsDelegateDetails static void* actionToNSAction (const Action& a) { - if (@available (iOS 10, *)) + if (a.style == Action::text) { - if (a.style == Action::text) - { - return [UNTextInputNotificationAction actionWithIdentifier: juceStringToNS (a.identifier) - title: juceStringToNS (a.title) - options: NSUInteger (a.destructive << 1 | (! a.triggerInBackground) << 2) - textInputButtonTitle: juceStringToNS (a.textInputButtonText) - textInputPlaceholder: juceStringToNS (a.textInputPlaceholder)]; - } - - return [UNNotificationAction actionWithIdentifier: juceStringToNS (a.identifier) - title: juceStringToNS (a.title) - options: NSUInteger (a.destructive << 1 | (! a.triggerInBackground) << 2)]; + return [UNTextInputNotificationAction actionWithIdentifier: juceStringToNS (a.identifier) + title: juceStringToNS (a.title) + options: NSUInteger (a.destructive << 1 | (! a.triggerInBackground) << 2) + textInputButtonTitle: juceStringToNS (a.textInputButtonText) + textInputPlaceholder: juceStringToNS (a.textInputPlaceholder)]; } - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - auto action = [[UIMutableUserNotificationAction alloc] init]; - - action.identifier = juceStringToNS (a.identifier); - action.title = juceStringToNS (a.title); - action.behavior = a.style == Action::text ? UIUserNotificationActionBehaviorTextInput - : UIUserNotificationActionBehaviorDefault; - action.parameters = varToNSDictionary (a.parameters); - action.activationMode = a.triggerInBackground ? UIUserNotificationActivationModeBackground - : UIUserNotificationActivationModeForeground; - action.destructive = (bool) a.destructive; - - [action autorelease]; - - return action; - JUCE_END_IGNORE_WARNINGS_GCC_LIKE + return [UNNotificationAction actionWithIdentifier: juceStringToNS (a.identifier) + title: juceStringToNS (a.title) + options: NSUInteger (a.destructive << 1 | (! a.triggerInBackground) << 2)]; } static void* categoryToNSCategory (const Category& c) { - if (@available (iOS 10, *)) - { - auto actions = [NSMutableArray arrayWithCapacity: (NSUInteger) c.actions.size()]; - - for (const auto& a : c.actions) - { - auto* action = (UNNotificationAction*) actionToNSAction (a); - [actions addObject: action]; - } - - return [UNNotificationCategory categoryWithIdentifier: juceStringToNS (c.identifier) - actions: actions - intentIdentifiers: @[] - options: c.sendDismissAction ? UNNotificationCategoryOptionCustomDismissAction : 0]; - } - - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - auto category = [[UIMutableUserNotificationCategory alloc] init]; - category.identifier = juceStringToNS (c.identifier); - auto actions = [NSMutableArray arrayWithCapacity: (NSUInteger) c.actions.size()]; for (const auto& a : c.actions) { - auto* action = (UIUserNotificationAction*) actionToNSAction (a); + auto* action = (UNNotificationAction*) actionToNSAction (a); [actions addObject: action]; } - [category setActions: actions forContext: UIUserNotificationActionContextDefault]; - [category setActions: actions forContext: UIUserNotificationActionContextMinimal]; - - [category autorelease]; - - return category; - JUCE_END_IGNORE_WARNINGS_GCC_LIKE + return [UNNotificationCategory categoryWithIdentifier: juceStringToNS (c.identifier) + actions: actions + intentIdentifiers: @[] + options: c.sendDismissAction ? UNNotificationCategoryOptionCustomDismissAction : 0]; } //============================================================================== @@ -418,10 +375,7 @@ private: //============================================================================== bool PushNotifications::Notification::isValid() const noexcept { - if (@available (iOS 10, *)) - return title.isNotEmpty() && body.isNotEmpty() && identifier.isNotEmpty() && category.isNotEmpty(); - - return title.isNotEmpty() && body.isNotEmpty() && category.isNotEmpty(); + return title.isNotEmpty() && body.isNotEmpty() && identifier.isNotEmpty() && category.isNotEmpty(); } //============================================================================== @@ -446,170 +400,87 @@ struct PushNotifications::Pimpl auto categories = [NSMutableSet setWithCapacity: (NSUInteger) settings.categories.size()]; - if (@available (iOS 10, *)) + for (const auto& c : settings.categories) { - for (const auto& c : settings.categories) - { - auto* category = (UNNotificationCategory*) PushNotificationsDelegateDetails::categoryToNSCategory (c); - [categories addObject: category]; - } - - UNAuthorizationOptions authOptions = NSUInteger ((bool)settings.allowBadge << 0 - | (bool)settings.allowSound << 1 - | (bool)settings.allowAlert << 2); - - [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories: categories]; - [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions: authOptions - completionHandler: ^(BOOL /*granted*/, NSError* /*error*/) - { - requestSettingsUsed(); - }]; + auto* category = (UNNotificationCategory*) PushNotificationsDelegateDetails::categoryToNSCategory (c); + [categories addObject: category]; } - else - { - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - for (const auto& c : settings.categories) - { - auto* category = (UIUserNotificationCategory*) PushNotificationsDelegateDetails::categoryToNSCategory (c); - [categories addObject: category]; - } + UNAuthorizationOptions authOptions = NSUInteger ((bool)settings.allowBadge << 0 + | (bool)settings.allowSound << 1 + | (bool)settings.allowAlert << 2); - UIUserNotificationType type = NSUInteger ((bool)settings.allowBadge << 0 - | (bool)settings.allowSound << 1 - | (bool)settings.allowAlert << 2); - - UIUserNotificationSettings* s = [UIUserNotificationSettings settingsForTypes: type categories: categories]; - [[UIApplication sharedApplication] registerUserNotificationSettings: s]; - - JUCE_END_IGNORE_WARNINGS_GCC_LIKE - } + [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories: categories]; + [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions: authOptions + completionHandler: ^(BOOL /*granted*/, NSError* /*error*/) + { + requestSettingsUsed(); + }]; [[UIApplication sharedApplication] registerForRemoteNotifications]; } void requestSettingsUsed() { - if (@available (iOS 10, *)) - { - [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler: - ^(UNNotificationSettings* s) - { - [[UNUserNotificationCenter currentNotificationCenter] getNotificationCategoriesWithCompletionHandler: - ^(NSSet* categories) - { - settings.allowBadge = s.badgeSetting == UNNotificationSettingEnabled; - settings.allowSound = s.soundSetting == UNNotificationSettingEnabled; - settings.allowAlert = s.alertSetting == UNNotificationSettingEnabled; + [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler: + ^(UNNotificationSettings* s) + { + [[UNUserNotificationCenter currentNotificationCenter] getNotificationCategoriesWithCompletionHandler: + ^(NSSet* categories) + { + settings.allowBadge = s.badgeSetting == UNNotificationSettingEnabled; + settings.allowSound = s.soundSetting == UNNotificationSettingEnabled; + settings.allowAlert = s.alertSetting == UNNotificationSettingEnabled; - for (UNNotificationCategory* c in categories) - settings.categories.add (PushNotificationsDelegateDetails::unNotificationCategoryToCategory (c)); + for (UNNotificationCategory* c in categories) + settings.categories.add (PushNotificationsDelegateDetails::unNotificationCategoryToCategory (c)); - owner.listeners.call ([&] (Listener& l) { l.notificationSettingsReceived (settings); }); - } - ]; - - }]; - } - else - { - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - - UIUserNotificationSettings* s = [UIApplication sharedApplication].currentUserNotificationSettings; - - settings.allowBadge = s.types & UIUserNotificationTypeBadge; - settings.allowSound = s.types & UIUserNotificationTypeSound; - settings.allowAlert = s.types & UIUserNotificationTypeAlert; - - for (UIUserNotificationCategory *c in s.categories) - settings.categories.add (PushNotificationsDelegateDetails::uiUserNotificationCategoryToCategory (c)); - - owner.listeners.call ([&] (Listener& l) { l.notificationSettingsReceived (settings); }); - - JUCE_END_IGNORE_WARNINGS_GCC_LIKE - } + owner.listeners.call ([&] (Listener& l) { l.notificationSettingsReceived (settings); }); + } + ]; + }]; } bool areNotificationsEnabled() const { return true; } void sendLocalNotification (const Notification& n) { - if (@available (iOS 10, *)) - { - UNNotificationRequest* request = PushNotificationsDelegateDetails::juceNotificationToUNNotificationRequest (n); + UNNotificationRequest* request = PushNotificationsDelegateDetails::juceNotificationToUNNotificationRequest (n); - [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest: request - withCompletionHandler: ^(NSError* error) - { - jassert (error == nil); + [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest: request + withCompletionHandler: ^(NSError* error) + { + jassert (error == nil); - if (error != nil) - NSLog (nsStringLiteral ("addNotificationRequest error: %@"), error); - }]; - } - else - { - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - - auto* notification = PushNotificationsDelegateDetails::juceNotificationToUILocalNotification (n); - - [[UIApplication sharedApplication] scheduleLocalNotification: notification]; - [notification release]; - - JUCE_END_IGNORE_WARNINGS_GCC_LIKE - } + if (error != nil) + NSLog (nsStringLiteral ("addNotificationRequest error: %@"), error); + }]; } void getDeliveredNotifications() const { - if (@available (iOS 10, *)) - { - [[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler: - ^(NSArray* notifications) - { - Array notifs; + [[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler: + ^(NSArray* notifications) + { + Array notifs; - for (UNNotification* n in notifications) - notifs.add (PushNotificationsDelegateDetails::unNotificationToJuceNotification (n)); + for (UNNotification* n in notifications) + notifs.add (PushNotificationsDelegateDetails::unNotificationToJuceNotification (n)); - owner.listeners.call ([&] (Listener& l) { l.deliveredNotificationsListReceived (notifs); }); - }]; - } - else - { - // Not supported on this platform - jassertfalse; - owner.listeners.call ([] (Listener& l) { l.deliveredNotificationsListReceived ({}); }); - } + owner.listeners.call ([&] (Listener& l) { l.deliveredNotificationsListReceived (notifs); }); + }]; } void removeAllDeliveredNotifications() { - if (@available (iOS 10, *)) - { - [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications]; - } - else - { - // Not supported on this platform - jassertfalse; - } + [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications]; } void removeDeliveredNotification ([[maybe_unused]] const String& identifier) { - if (@available (iOS 10, *)) - { + NSArray* identifiers = [NSArray arrayWithObject: juceStringToNS (identifier)]; - NSArray* identifiers = [NSArray arrayWithObject: juceStringToNS (identifier)]; - - [[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers: identifiers]; - } - else - { - // Not supported on this platform - jassertfalse; - } + [[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers: identifiers]; } void setupChannels ([[maybe_unused]] const Array& groups, [[maybe_unused]] const Array& channels) @@ -618,64 +489,27 @@ struct PushNotifications::Pimpl void getPendingLocalNotifications() const { - if (@available (iOS 10, *)) - { - [[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler: - ^(NSArray* requests) - { - Array notifs; + [[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler: + ^(NSArray* requests) + { + Array notifs; - for (UNNotificationRequest* r : requests) - notifs.add (PushNotificationsDelegateDetails::unNotificationRequestToJuceNotification (r)); + for (UNNotificationRequest* r : requests) + notifs.add (PushNotificationsDelegateDetails::unNotificationRequestToJuceNotification (r)); - owner.listeners.call ([&] (Listener& l) { l.pendingLocalNotificationsListReceived (notifs); }); - } - ]; - } - else - { - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - - Array notifs; - - for (UILocalNotification* n in [UIApplication sharedApplication].scheduledLocalNotifications) - notifs.add (PushNotificationsDelegateDetails::uiLocalNotificationToJuceNotification (n)); - - owner.listeners.call ([&] (Listener& l) { l.pendingLocalNotificationsListReceived (notifs); }); - - JUCE_END_IGNORE_WARNINGS_GCC_LIKE - } + owner.listeners.call ([&] (Listener& l) { l.pendingLocalNotificationsListReceived (notifs); }); + }]; } void removePendingLocalNotification (const String& identifier) { - if (@available (iOS 10, *)) - { - NSArray* identifiers = [NSArray arrayWithObject: juceStringToNS (identifier)]; - - [[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers: identifiers]; - } - else - { - // Not supported on this platform - jassertfalse; - } + NSArray* identifiers = [NSArray arrayWithObject: juceStringToNS (identifier)]; + [[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers: identifiers]; } void removeAllPendingLocalNotifications() { - if (@available (iOS 10, *)) - { - [[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests]; - } - else - { - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") - - [[UIApplication sharedApplication] cancelAllLocalNotifications]; - - JUCE_END_IGNORE_WARNINGS_GCC_LIKE - } + [[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests]; } String getDeviceToken() diff --git a/modules/juce_video/native/juce_CameraDevice_ios.h b/modules/juce_video/native/juce_CameraDevice_ios.h index ba6f8bba21..f815011ecc 100644 --- a/modules/juce_video/native/juce_CameraDevice_ios.h +++ b/modules/juce_video/native/juce_CameraDevice_ios.h @@ -147,27 +147,21 @@ struct CameraDevice::Pimpl private: static NSArray* getDevices() { - if (@available (iOS 10.0, *)) - { - std::unique_ptr, NSObjectDeleter> deviceTypes ([[NSMutableArray alloc] initWithCapacity: 2]); + std::unique_ptr, NSObjectDeleter> deviceTypes ([[NSMutableArray alloc] initWithCapacity: 2]); - [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInWideAngleCamera]; - [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInTelephotoCamera]; + [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInWideAngleCamera]; + [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInTelephotoCamera]; - if (@available (iOS 10.2, *)) - [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInDualCamera]; + [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInDualCamera]; - if (@available (iOS 11.1, *)) - [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInTrueDepthCamera]; + if (@available (iOS 11.1, *)) + [deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInTrueDepthCamera]; - auto discoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes: deviceTypes.get() - mediaType: AVMediaTypeVideo - position: AVCaptureDevicePositionUnspecified]; + auto discoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes: deviceTypes.get() + mediaType: AVMediaTypeVideo + position: AVCaptureDevicePositionUnspecified]; - return [discoverySession devices]; - } - - return [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo]; + return [discoverySession devices]; } //============================================================================== @@ -211,11 +205,8 @@ private: JUCE_CAMERA_LOG ("Supports custom exposure: " + String ((int)[device isExposureModeSupported: AVCaptureExposureModeCustom])); JUCE_CAMERA_LOG ("Supports point of interest exposure: " + String ((int)device.exposurePointOfInterestSupported)); - if (@available (iOS 10.0, *)) - { - JUCE_CAMERA_LOG ("Device type: " + nsStringToJuce (device.deviceType)); - JUCE_CAMERA_LOG ("Locking focus with custom lens position supported: " + String ((int)device.lockingFocusWithCustomLensPositionSupported)); - } + JUCE_CAMERA_LOG ("Device type: " + nsStringToJuce (device.deviceType)); + JUCE_CAMERA_LOG ("Locking focus with custom lens position supported: " + String ((int)device.lockingFocusWithCustomLensPositionSupported)); if (@available (iOS 11.0, *)) { @@ -238,23 +229,20 @@ private: { JUCE_CAMERA_LOG ("Media type: " + nsStringToJuce (format.mediaType)); - if (@available (iOS 10.0, *)) + String colourSpaces; + + for (NSNumber* number in format.supportedColorSpaces) { - String colourSpaces; - - for (NSNumber* number in format.supportedColorSpaces) + switch ([number intValue]) { - switch ([number intValue]) - { - case AVCaptureColorSpace_sRGB: colourSpaces << "sRGB "; break; - case AVCaptureColorSpace_P3_D65: colourSpaces << "P3_D65 "; break; - default: break; - } + case AVCaptureColorSpace_sRGB: colourSpaces << "sRGB "; break; + case AVCaptureColorSpace_P3_D65: colourSpaces << "P3_D65 "; break; + default: break; } - - JUCE_CAMERA_LOG ("Supported colour spaces: " + colourSpaces); } + JUCE_CAMERA_LOG ("Supported colour spaces: " + colourSpaces); + JUCE_CAMERA_LOG ("Video field of view: " + String (format.videoFieldOfView)); JUCE_CAMERA_LOG ("Video max zoom factor: " + String (format.videoMaxZoomFactor)); JUCE_CAMERA_LOG ("Video zoom factor upscale threshold: " + String (format.videoZoomFactorUpscaleThreshold)); @@ -582,12 +570,9 @@ private: captureOutput (createCaptureOutput()), photoOutputDelegate (nullptr) { - if (@available (iOS 10.0, *)) - { - static PhotoOutputDelegateClass cls; - photoOutputDelegate.reset ([cls.createInstance() init]); - PhotoOutputDelegateClass::setOwner (photoOutputDelegate.get(), this); - } + static PhotoOutputDelegateClass cls; + photoOutputDelegate.reset ([cls.createInstance() init]); + PhotoOutputDelegateClass::setOwner (photoOutputDelegate.get(), this); captureSession.addOutputIfPossible (captureOutput); } @@ -607,19 +592,16 @@ private: if (auto* connection = findVideoConnection (captureOutput)) { - if (@available (iOS 10.0, *)) + if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]]) { - if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]]) - { - auto* photoOutput = (AVCapturePhotoOutput*) captureOutput; - auto outputConnection = [photoOutput connectionWithMediaType: AVMediaTypeVideo]; - outputConnection.videoOrientation = orientationToUse; + auto* photoOutput = (AVCapturePhotoOutput*) captureOutput; + auto outputConnection = [photoOutput connectionWithMediaType: AVMediaTypeVideo]; + outputConnection.videoOrientation = orientationToUse; - [photoOutput capturePhotoWithSettings: [AVCapturePhotoSettings photoSettings] - delegate: id (photoOutputDelegate.get())]; + [photoOutput capturePhotoWithSettings: [AVCapturePhotoSettings photoSettings] + delegate: id (photoOutputDelegate.get())]; - return; - } + return; } auto* stillImageOutput = (AVCaptureStillImageOutput*) captureOutput; @@ -657,66 +639,60 @@ private: private: static AVCaptureOutput* createCaptureOutput() { - if (@available (iOS 10.0, *)) - return [AVCapturePhotoOutput new]; - - return [AVCaptureStillImageOutput new]; + return [AVCapturePhotoOutput new]; } static void printImageOutputDebugInfo (AVCaptureOutput* captureOutput) { - if (@available (iOS 10.0, *)) + if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]]) { - if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]]) + auto* photoOutput = (AVCapturePhotoOutput*) captureOutput; + + String typesString; + + for (id type in photoOutput.availablePhotoCodecTypes) + typesString << nsStringToJuce (type) << " "; + + JUCE_CAMERA_LOG ("Available image codec types: " + typesString); + + JUCE_CAMERA_LOG ("Still image stabilization supported: " + String ((int) photoOutput.stillImageStabilizationSupported)); + JUCE_CAMERA_LOG ("Dual camera fusion supported: " + String ((int) photoOutput.dualCameraFusionSupported)); + JUCE_CAMERA_LOG ("Supports flash: " + String ((int) [photoOutput.supportedFlashModes containsObject: @(AVCaptureFlashModeOn)])); + JUCE_CAMERA_LOG ("Supports auto flash: " + String ((int) [photoOutput.supportedFlashModes containsObject: @(AVCaptureFlashModeAuto)])); + JUCE_CAMERA_LOG ("Max bracketed photo count: " + String (photoOutput.maxBracketedCapturePhotoCount)); + JUCE_CAMERA_LOG ("Lens stabilization during bracketed capture supported: " + String ((int) photoOutput.lensStabilizationDuringBracketedCaptureSupported)); + JUCE_CAMERA_LOG ("Live photo capture supported: " + String ((int) photoOutput.livePhotoCaptureSupported)); + + + if (@available (iOS 11.0, *)) { - auto* photoOutput = (AVCapturePhotoOutput*) captureOutput; + typesString.clear(); - String typesString; - - for (id type in photoOutput.availablePhotoCodecTypes) + for (AVFileType type in photoOutput.availablePhotoFileTypes) typesString << nsStringToJuce (type) << " "; - JUCE_CAMERA_LOG ("Available image codec types: " + typesString); + JUCE_CAMERA_LOG ("Available photo file types: " + typesString); - JUCE_CAMERA_LOG ("Still image stabilization supported: " + String ((int) photoOutput.stillImageStabilizationSupported)); - JUCE_CAMERA_LOG ("Dual camera fusion supported: " + String ((int) photoOutput.dualCameraFusionSupported)); - JUCE_CAMERA_LOG ("Supports flash: " + String ((int) [photoOutput.supportedFlashModes containsObject: @(AVCaptureFlashModeOn)])); - JUCE_CAMERA_LOG ("Supports auto flash: " + String ((int) [photoOutput.supportedFlashModes containsObject: @(AVCaptureFlashModeAuto)])); - JUCE_CAMERA_LOG ("Max bracketed photo count: " + String (photoOutput.maxBracketedCapturePhotoCount)); - JUCE_CAMERA_LOG ("Lens stabilization during bracketed capture supported: " + String ((int) photoOutput.lensStabilizationDuringBracketedCaptureSupported)); - JUCE_CAMERA_LOG ("Live photo capture supported: " + String ((int) photoOutput.livePhotoCaptureSupported)); + typesString.clear(); + for (AVFileType type in photoOutput.availableRawPhotoFileTypes) + typesString << nsStringToJuce (type) << " "; - if (@available (iOS 11.0, *)) - { - typesString.clear(); + JUCE_CAMERA_LOG ("Available RAW photo file types: " + typesString); - for (AVFileType type in photoOutput.availablePhotoFileTypes) - typesString << nsStringToJuce (type) << " "; + typesString.clear(); - JUCE_CAMERA_LOG ("Available photo file types: " + typesString); + for (AVFileType type in photoOutput.availableLivePhotoVideoCodecTypes) + typesString << nsStringToJuce (type) << " "; - typesString.clear(); + JUCE_CAMERA_LOG ("Available live photo video codec types: " + typesString); - for (AVFileType type in photoOutput.availableRawPhotoFileTypes) - typesString << nsStringToJuce (type) << " "; - - JUCE_CAMERA_LOG ("Available RAW photo file types: " + typesString); - - typesString.clear(); - - for (AVFileType type in photoOutput.availableLivePhotoVideoCodecTypes) - typesString << nsStringToJuce (type) << " "; - - JUCE_CAMERA_LOG ("Available live photo video codec types: " + typesString); - - JUCE_CAMERA_LOG ("Dual camera dual photo delivery supported: " + String ((int) photoOutput.dualCameraDualPhotoDeliverySupported)); - JUCE_CAMERA_LOG ("Camera calibration data delivery supported: " + String ((int) photoOutput.cameraCalibrationDataDeliverySupported)); - JUCE_CAMERA_LOG ("Depth data delivery supported: " + String ((int) photoOutput.depthDataDeliverySupported)); - } - - return; + JUCE_CAMERA_LOG ("Dual camera dual photo delivery supported: " + String ((int) photoOutput.dualCameraDualPhotoDeliverySupported)); + JUCE_CAMERA_LOG ("Camera calibration data delivery supported: " + String ((int) photoOutput.cameraCalibrationDataDeliverySupported)); + JUCE_CAMERA_LOG ("Depth data delivery supported: " + String ((int) photoOutput.depthDataDeliverySupported)); } + + return; } auto* stillImageOutput = (AVCaptureStillImageOutput*) captureOutput; @@ -745,7 +721,7 @@ private: } //============================================================================== - class API_AVAILABLE (ios (10.0)) PhotoOutputDelegateClass : public ObjCClass + class PhotoOutputDelegateClass : public ObjCClass { public: PhotoOutputDelegateClass() : ObjCClass ("PhotoOutputDelegateClass_") @@ -996,8 +972,7 @@ private: void startRecording (const File& file, AVCaptureVideoOrientation orientationToUse) { - if (@available (iOS 10.0, *)) - printVideoOutputDebugInfo (movieFileOutput); + printVideoOutputDebugInfo (movieFileOutput); auto url = [NSURL fileURLWithPath: juceStringToNS (file.getFullPathName()) isDirectory: NO];