diff --git a/docs/content/docs/constraints.mdx b/docs/content/docs/constraints.mdx index 50d22a4cea..edf23bd08e 100644 --- a/docs/content/docs/constraints.mdx +++ b/docs/content/docs/constraints.mdx @@ -361,6 +361,20 @@ const constraints = [ ] satisfies Constraint[] ``` +#### High-speed and slow-motion + +On Android, you can request a high-speed capture session with a [`{ videoRecordingMode: ... }`](/api/react-native-vision-camera/interfaces/VideoRecordingModeConstraint) constraint. +Use `'high-speed'` to save a high frame-rate file directly, or `'slow-motion'` to save the recording with a slow-motion playback effect. + +If you do not also provide an explicit [`{ fps: ... }`](/api/react-native-vision-camera/interfaces/FPSConstraint) constraint, VisionCamera automatically picks the lowest supported high-speed FPS for the negotiated session. + +```ts +const constraints = [ + { videoRecordingMode: 'slow-motion' }, + { fps: 240 }, +] satisfies Constraint[] +``` + #### Binned preference Binned formats combine multiple neighboring sensor pixels into one larger effective pixel. diff --git a/docs/content/docs/fps.mdx b/docs/content/docs/fps.mdx index 2077d6d642..f037816101 100644 --- a/docs/content/docs/fps.mdx +++ b/docs/content/docs/fps.mdx @@ -78,3 +78,18 @@ await session.start() ``` + +### High-speed and Slow-motion + +On Android, you can turn a Video recording into a negotiated high-speed capture session by combining your Video output with a [`{ videoRecordingMode: ... }`](/api/react-native-vision-camera/interfaces/VideoRecordingModeConstraint) constraint: + +```ts +const constraints = [ + { videoRecordingMode: 'slow-motion' }, + { fps: 240 }, +] +``` + +- Use `'high-speed'` to save the file at the negotiated high FPS. +- Use `'slow-motion'` to record at a high FPS and save the file for slow-motion playback. +- If you omit the [`{ fps: ... }`](/api/react-native-vision-camera/interfaces/FPSConstraint) constraint, VisionCamera automatically picks the lowest supported high-speed FPS for that session. diff --git a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/HybridCameraSessionConfig.kt b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/HybridCameraSessionConfig.kt index 05233485c4..a574067c49 100644 --- a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/HybridCameraSessionConfig.kt +++ b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/HybridCameraSessionConfig.kt @@ -7,6 +7,7 @@ import com.margelo.nitro.camera.HybridCameraSessionConfigSpec import com.margelo.nitro.camera.PixelFormat import com.margelo.nitro.camera.TargetDynamicRange import com.margelo.nitro.camera.TargetStabilizationMode +import com.margelo.nitro.camera.VideoRecordingMode import com.margelo.nitro.camera.public.NativeCameraOutput import com.margelo.nitro.camera.public.NativeCameraSessionConfig @@ -31,6 +32,9 @@ class HybridCameraSessionConfig( override val isPhotoHDREnabled: Boolean get() = resolvedConfig.photoHDR ?: false + override val selectedVideoRecordingMode: VideoRecordingMode? + get() = resolvedConfig.videoRecordingMode + override val nativePixelFormat: PixelFormat // TODO: Do we always stream in PRIVATE? get() = PixelFormat.PRIVATE @@ -52,6 +56,7 @@ class HybridCameraSessionConfig( "selectedPreviewStabilizationMode: $selectedPreviewStabilizationMode", "selectedVideoDynamicRange: $selectedVideoDynamicRange", "isPhotoHDREnabled: $isPhotoHDREnabled", + "selectedVideoRecordingMode: $selectedVideoRecordingMode", ) return "CameraSessionConfig(${components.joinToString(", ")})" } diff --git a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/outputs/HybridVideoOutput.kt b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/outputs/HybridVideoOutput.kt index a1294ea44c..28c5a19fad 100644 --- a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/outputs/HybridVideoOutput.kt +++ b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/hybrids/outputs/HybridVideoOutput.kt @@ -2,8 +2,6 @@ package com.margelo.nitro.camera.hybrids.outputs import android.annotation.SuppressLint import android.content.Context -import android.util.Log -import androidx.camera.core.DynamicRange import androidx.camera.video.FileOutputOptions import androidx.camera.video.Recorder import androidx.camera.video.VideoCapture @@ -14,7 +12,6 @@ import com.margelo.nitro.camera.HybridRecorderSpec import com.margelo.nitro.camera.MediaType import com.margelo.nitro.camera.MirrorMode import com.margelo.nitro.camera.RecorderSettings -import com.margelo.nitro.camera.Size import com.margelo.nitro.camera.TargetStabilizationMode import com.margelo.nitro.camera.VideoCodec import com.margelo.nitro.camera.VideoOutputOptions @@ -100,8 +97,10 @@ class HybridVideoOutput( VideoCapture .Builder(videoOutput) .apply { - // isMirrored={...} - setMirrorMode(mirrorMode.toMirrorMode()) + if (config.videoRecordingMode == null) { + // High-speed sessions cannot set mirror mode on VideoCapture. + setMirrorMode(mirrorMode.toMirrorMode()) + } // orientation from previous value setTargetRotation(outputOrientation.surfaceRotation) diff --git a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/public/NativeCameraOutput.kt b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/public/NativeCameraOutput.kt index d2d5e0b10c..1ccd3a2d74 100644 --- a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/public/NativeCameraOutput.kt +++ b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/public/NativeCameraOutput.kt @@ -5,6 +5,7 @@ import androidx.camera.core.UseCase import com.margelo.nitro.camera.MirrorMode import com.margelo.nitro.camera.TargetDynamicRange import com.margelo.nitro.camera.TargetStabilizationMode +import com.margelo.nitro.camera.VideoRecordingMode interface NativeCameraOutput { /** @@ -17,6 +18,7 @@ interface NativeCameraOutput { val videoStabilizationMode: TargetStabilizationMode?, val videoDynamicRange: TargetDynamicRange?, val photoHDR: Boolean?, + val videoRecordingMode: VideoRecordingMode?, ) /** diff --git a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/session/ConstraintResolver.kt b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/session/ConstraintResolver.kt index 2431cd83bd..47930431ff 100644 --- a/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/session/ConstraintResolver.kt +++ b/packages/react-native-vision-camera/android/src/main/java/com/margelo/nitro/camera/session/ConstraintResolver.kt @@ -6,7 +6,9 @@ import androidx.camera.core.CameraInfo import androidx.camera.core.ImageCapture import androidx.camera.core.Preview import androidx.camera.core.SessionConfig +import androidx.camera.video.HighSpeedVideoSessionConfig import androidx.camera.video.Recorder +import androidx.camera.video.VideoCapture import com.margelo.nitro.camera.CameraOutputConfiguration import com.margelo.nitro.camera.Constraint import com.margelo.nitro.camera.FPSConstraint @@ -17,6 +19,8 @@ import com.margelo.nitro.camera.TargetDynamicRange import com.margelo.nitro.camera.TargetDynamicRangeBitDepth import com.margelo.nitro.camera.TargetStabilizationMode import com.margelo.nitro.camera.VideoDynamicRangeConstraint +import com.margelo.nitro.camera.VideoRecordingMode +import com.margelo.nitro.camera.VideoRecordingModeConstraint import com.margelo.nitro.camera.VideoStabilizationModeConstraint import com.margelo.nitro.camera.extensions.converters.toDynamicRange import com.margelo.nitro.camera.public.NativeCameraOutput @@ -67,23 +71,19 @@ object ConstraintResolver { return@map output.createUseCase(outputConfiguration.mirrorMode, config) } val sessionConfig = - SessionConfig - .Builder(preparedUseCases.map { it.useCase }) - .build() + buildSessionConfig(cameraInfo, preparedUseCases, config) - if (cameraInfo.isSessionConfigSupported(sessionConfig) || activeConstraints.isEmpty()) { + if (sessionConfig != null && (cameraInfo.isSessionConfigSupported(sessionConfig) || activeConstraints.isEmpty())) { // Pass 2: Resolve FPS against the validated use-case combination. - val resolvedFPSRange = fpsConstraint?.resolveFPSRange(cameraInfo, sessionConfig) + val resolvedFPSRange = + resolveFPSRange( + cameraInfo = cameraInfo, + sessionConfig = sessionConfig, + targetFps = fpsConstraint?.fps?.toInt(), + shouldAutoSelectLowest = config.videoRecordingMode != null, + ) val finalConfig = config.copy(fpsRange = resolvedFPSRange) - val finalSessionConfig = - if (resolvedFPSRange != null) { - SessionConfig - .Builder(preparedUseCases.map { it.useCase }) - .apply { setFrameRateRange(resolvedFPSRange) } - .build() - } else { - sessionConfig - } + val finalSessionConfig = buildSessionConfig(cameraInfo, preparedUseCases, finalConfig) ?: sessionConfig Log.i(TAG, "Resolved constraints to: $finalConfig") return CameraSessionConfig(finalSessionConfig, preparedUseCases, finalConfig) } @@ -109,13 +109,20 @@ object ConstraintResolver { * Picks the supported range whose upper bound is closest to the target FPS. * On ties, prefers tighter ranges (higher lower bound). */ - private fun FPSConstraint.resolveFPSRange( + private fun resolveFPSRange( cameraInfo: CameraInfo, sessionConfig: SessionConfig, + targetFps: Int?, + shouldAutoSelectLowest: Boolean, ): Range? { - val targetFps = fps.toInt() val supportedRanges = cameraInfo.getSupportedFrameRateRanges(sessionConfig) if (supportedRanges.isEmpty()) return null + if (targetFps == null) { + if (!shouldAutoSelectLowest) return null + return supportedRanges.minWith( + compareBy> { it.upper }.thenBy { it.lower }, + ) + } return supportedRanges.minWith( compareBy> { @@ -127,6 +134,49 @@ object ConstraintResolver { }, ) } + + private fun buildSessionConfig( + cameraInfo: CameraInfo, + preparedUseCases: List, + config: NativeCameraOutput.Config, + ): SessionConfig? { + return when (config.videoRecordingMode) { + null -> { + SessionConfig + .Builder(preparedUseCases.map { it.useCase }) + .apply { + config.fpsRange?.let { setFrameRateRange(it) } + }.build() + } + else -> buildHighSpeedSessionConfig(cameraInfo, preparedUseCases, config) + } + } + + private fun buildHighSpeedSessionConfig( + cameraInfo: CameraInfo, + preparedUseCases: List, + config: NativeCameraOutput.Config, + ): SessionConfig? { + if (Recorder.getHighSpeedVideoCapabilities(cameraInfo) == null) return null + + val previewUseCases = preparedUseCases.mapNotNull { it.useCase as? Preview } + val videoCaptureUseCases = preparedUseCases.mapNotNull { it.useCase as? VideoCapture<*> } + val containsUnsupportedUseCases = + preparedUseCases.any { preparedUseCase -> + preparedUseCase.useCase !is Preview && preparedUseCase.useCase !is VideoCapture<*> + } + if (containsUnsupportedUseCases || videoCaptureUseCases.size != 1 || previewUseCases.size > 1) { + return null + } + + return HighSpeedVideoSessionConfig + .Builder(videoCaptureUseCases.single()) + .apply { + previewUseCases.singleOrNull()?.let { setPreview(it) } + setSlowMotionEnabled(config.videoRecordingMode == VideoRecordingMode.SLOW_MOTION) + config.fpsRange?.let { setFrameRateRange(it) } + }.build() + } } // MARK: - Config Resolution @@ -138,7 +188,7 @@ object ConstraintResolver { * constraint are `null`, meaning "platform decides". * * FPS is not resolved here — it requires a validated [SessionConfig] - * and is resolved separately in [FPSConstraint.resolveFPSRange]. + * and is resolved separately in [ConstraintResolver.resolveConstraints]. */ internal fun List.toConfig(): NativeCameraOutput.Config { return NativeCameraOutput.Config( @@ -147,6 +197,7 @@ internal fun List.toConfig(): NativeCameraOutput.Config { videoStabilizationMode = firstNotNullOfOrNull { it.asType() }?.videoStabilizationMode, videoDynamicRange = firstNotNullOfOrNull { it.asType() }?.videoDynamicRange, photoHDR = firstNotNullOfOrNull { it.asType() }?.photoHDR, + videoRecordingMode = firstNotNullOfOrNull { it.asType() }?.videoRecordingMode, ) } @@ -161,7 +212,9 @@ internal fun List.toConfig(): NativeCameraOutput.Config { * When in doubt, returns `true` — a constraint that wrongly returns `false` * is silently dropped with no chance of recovery. */ -private fun Constraint.isSupportedIndividually(cameraInfo: CameraInfo): Boolean { +private fun Constraint.isSupportedIndividually( + cameraInfo: CameraInfo, +): Boolean { return this.match( { true }, // FPS: resolved separately after features { videoStabilizationMode -> @@ -195,6 +248,7 @@ private fun Constraint.isSupportedIndividually(cameraInfo: CameraInfo): Boolean }, { true }, // PixelFormat: let downgrade loop handle it { true }, // Binning: not configurable in CameraX + { Recorder.getHighSpeedVideoCapabilities(cameraInfo) != null }, ) } @@ -261,5 +315,6 @@ private fun Constraint.getNextBestOption(): Constraint? { { null }, // PhotoHDR: on or off, no middle ground { null }, // PixelFormat: no fallback { null }, // Binning: not configurable + { null }, // VideoRecordingMode: falls back to regular recording ) } diff --git a/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/ConstraintResolver.swift b/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/ConstraintResolver.swift index 92f2bec4e3..93de619f1d 100644 --- a/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/ConstraintResolver.swift +++ b/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/ConstraintResolver.swift @@ -126,7 +126,8 @@ enum ConstraintResolver { selectedFPS: fps, selectedVideoStabilizationMode: videoStabilizationMode, selectedPreviewStabilizationMode: previewStabilizationMode, - selectedVideoDynamicRange: videoDynamicRange) + selectedVideoDynamicRange: videoDynamicRange, + selectedVideoRecordingMode: nil) return FormatEvaluation( format: format, @@ -238,6 +239,9 @@ extension Constraint { case .eigth(let binned): let r = binned.resolve(for: format) return ConstraintEvaluation(penalty: r.penalty, resolved: .formatOnly) + case .ninth( /* videoRecordingMode */ _): + // High-speed session orchestration is currently Android-only. + return ConstraintEvaluation(penalty: .noPenalty, resolved: .formatOnly) } } } diff --git a/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/EnabledConstraints.swift b/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/EnabledConstraints.swift index 7643dd1e00..bb2d2cca9e 100644 --- a/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/EnabledConstraints.swift +++ b/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/EnabledConstraints.swift @@ -13,4 +13,5 @@ public struct EnabledConstraints { let selectedVideoStabilizationMode: TargetStabilizationMode? let selectedPreviewStabilizationMode: TargetStabilizationMode? let selectedVideoDynamicRange: TargetDynamicRange? + let selectedVideoRecordingMode: VideoRecordingMode? } diff --git a/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/HybridCameraSessionConfig.swift b/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/HybridCameraSessionConfig.swift index 0ae6b5c551..213f88a4ec 100644 --- a/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/HybridCameraSessionConfig.swift +++ b/packages/react-native-vision-camera/ios/Hybrid Objects/Constraints/HybridCameraSessionConfig.swift @@ -38,6 +38,10 @@ final class HybridCameraSessionConfig: HybridCameraSessionConfigSpec, NativeCame return negotiatedFormat.format.isHighestPhotoQualitySupported } + var selectedVideoRecordingMode: VideoRecordingMode? { + return enabledConstraints.selectedVideoRecordingMode + } + var nativePixelFormat: PixelFormat { let format = negotiatedFormat.format return PixelFormat(mediaSubType: format.formatDescription.mediaSubType) @@ -60,6 +64,7 @@ final class HybridCameraSessionConfig: HybridCameraSessionConfigSpec, NativeCame "selectedPreviewStabilizationMode: \(String(describing: selectedPreviewStabilizationMode))", "selectedVideoDynamicRange: \(String(describing: selectedVideoDynamicRange))", "isPhotoHDREnabled: \(isPhotoHDREnabled)", + "selectedVideoRecordingMode: \(String(describing: selectedVideoRecordingMode))", ] return "CameraSessionConfig(\(components.joined(separator: ", ")))" } diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JCameraSessionConnection.hpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JCameraSessionConnection.hpp index 6b8d0710b3..163f364f40 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JCameraSessionConnection.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JCameraSessionConnection.hpp @@ -36,6 +36,8 @@ #include "JTargetDynamicRangeBitDepth.hpp" #include "JTargetStabilizationMode.hpp" #include "JVideoDynamicRangeConstraint.hpp" +#include "JVideoRecordingMode.hpp" +#include "JVideoRecordingModeConstraint.hpp" #include "JVideoStabilizationModeConstraint.hpp" #include "MirrorMode.hpp" #include "PhotoHDRConstraint.hpp" @@ -49,6 +51,8 @@ #include "TargetDynamicRangeBitDepth.hpp" #include "TargetStabilizationMode.hpp" #include "VideoDynamicRangeConstraint.hpp" +#include "VideoRecordingMode.hpp" +#include "VideoRecordingModeConstraint.hpp" #include "VideoStabilizationModeConstraint.hpp" #include #include @@ -102,7 +106,7 @@ namespace margelo::nitro::camera { }(), [&]() { size_t __size = constraints->size(); - std::vector> __vector; + std::vector> __vector; __vector.reserve(__size); for (size_t __i = 0; __i < __size; __i++) { auto __element = constraints->getElement(__i); diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.cpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.cpp index b700e04b47..4610d371c8 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.cpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.cpp @@ -9,9 +9,9 @@ namespace margelo::nitro::camera { /** - * Converts JConstraint to std::variant + * Converts JConstraint to std::variant */ - std::variant JConstraint::toCpp() const { + std::variant JConstraint::toCpp() const { if (isInstanceOf(JConstraint_impl::First::javaClassStatic())) { // It's a `FPSConstraint` auto jniValue = static_cast(this)->getValue(); @@ -44,6 +44,10 @@ namespace margelo::nitro::camera { // It's a `BinnedConstraint` auto jniValue = static_cast(this)->getValue(); return jniValue->toCpp(); + } else if (isInstanceOf(JConstraint_impl::Ninth::javaClassStatic())) { + // It's a `VideoRecordingModeConstraint` + auto jniValue = static_cast(this)->getValue(); + return jniValue->toCpp(); } throw std::invalid_argument("Variant is unknown Kotlin instance!"); } diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.hpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.hpp index a70b90ad27..2f2d47044d 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JConstraint.hpp @@ -18,6 +18,7 @@ #include "PhotoHDRConstraint.hpp" #include "PixelFormatConstraint.hpp" #include "BinnedConstraint.hpp" +#include "VideoRecordingModeConstraint.hpp" #include #include "JFPSConstraint.hpp" #include "JVideoStabilizationModeConstraint.hpp" @@ -42,6 +43,9 @@ #include "PixelFormat.hpp" #include "JPixelFormat.hpp" #include "JBinnedConstraint.hpp" +#include "JVideoRecordingModeConstraint.hpp" +#include "VideoRecordingMode.hpp" +#include "JVideoRecordingMode.hpp" namespace margelo::nitro::camera { @@ -86,8 +90,12 @@ namespace margelo::nitro::camera { static const auto method = javaClassStatic()->getStaticMethod)>("create"); return method(javaClassStatic(), value); } + static jni::local_ref create_8(jni::alias_ref value) { + static const auto method = javaClassStatic()->getStaticMethod)>("create"); + return method(javaClassStatic(), value); + } - static jni::local_ref fromCpp(const std::variant& variant) { + static jni::local_ref fromCpp(const std::variant& variant) { switch (variant.index()) { case 0: return create_0(JFPSConstraint::fromCpp(std::get<0>(variant))); case 1: return create_1(JVideoStabilizationModeConstraint::fromCpp(std::get<1>(variant))); @@ -97,11 +105,12 @@ namespace margelo::nitro::camera { case 5: return create_5(JPhotoHDRConstraint::fromCpp(std::get<5>(variant))); case 6: return create_6(JPixelFormatConstraint::fromCpp(std::get<6>(variant))); case 7: return create_7(JBinnedConstraint::fromCpp(std::get<7>(variant))); + case 8: return create_8(JVideoRecordingModeConstraint::fromCpp(std::get<8>(variant))); default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")"); } } - [[nodiscard]] std::variant toCpp() const; + [[nodiscard]] std::variant toCpp() const; }; namespace JConstraint_impl { @@ -184,5 +193,15 @@ namespace margelo::nitro::camera { return getFieldValue(field); } }; + + class Ninth final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/Constraint$Ninth;"; + + [[nodiscard]] jni::local_ref getValue() const { + static const auto field = javaClassStatic()->getField("value"); + return getFieldValue(field); + } + }; } // namespace JConstraint_impl } // namespace margelo::nitro::camera diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.cpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.cpp index a2f2fa2be6..2dde384ec3 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.cpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.cpp @@ -63,6 +63,8 @@ namespace margelo::nitro::camera { struct PhotoHDRConstraint; } namespace margelo::nitro::camera { struct PixelFormatConstraint; } // Forward declaration of `BinnedConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct BinnedConstraint; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } // Forward declaration of `TargetStabilizationMode` to properly resolve imports. namespace margelo::nitro::camera { enum class TargetStabilizationMode; } // Forward declaration of `TargetDynamicRange` to properly resolve imports. @@ -75,6 +77,8 @@ namespace margelo::nitro::camera { enum class TargetColorSpace; } namespace margelo::nitro::camera { enum class TargetColorRange; } // Forward declaration of `PixelFormat` to properly resolve imports. namespace margelo::nitro::camera { enum class PixelFormat; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `PhotoOutputOptions` to properly resolve imports. namespace margelo::nitro::camera { struct PhotoOutputOptions; } // Forward declaration of `Size` to properly resolve imports. @@ -150,6 +154,7 @@ namespace margelo::nitro::camera { enum class OrientationSource; } #include "PhotoHDRConstraint.hpp" #include "PixelFormatConstraint.hpp" #include "BinnedConstraint.hpp" +#include "VideoRecordingModeConstraint.hpp" #include #include "JConstraint.hpp" #include "JFPSConstraint.hpp" @@ -172,6 +177,9 @@ namespace margelo::nitro::camera { enum class OrientationSource; } #include "PixelFormat.hpp" #include "JPixelFormat.hpp" #include "JBinnedConstraint.hpp" +#include "JVideoRecordingModeConstraint.hpp" +#include "VideoRecordingMode.hpp" +#include "JVideoRecordingMode.hpp" #include #include "PhotoOutputOptions.hpp" #include "JPhotoOutputOptions.hpp" @@ -291,7 +299,7 @@ namespace margelo::nitro::camera { return __promise; }(); } - std::shared_ptr>> JHybridCameraFactorySpec::resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) { + std::shared_ptr>> JHybridCameraFactorySpec::resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) { static const auto method = _javaPart->javaClassStatic()->getMethod(jni::alias_ref /* device */, jni::alias_ref> /* outputConfigurations */, jni::alias_ref> /* constraints */, jni::alias_ref /* requiresMultiCam */)>("resolveConstraints"); auto __result = method(_javaPart, std::dynamic_pointer_cast(device)->getJavaPart(), [&]() { size_t __size = outputConfigurations.size(); diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.hpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.hpp index 69e1c1698f..5cb0d1bc05 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraFactorySpec.hpp @@ -59,7 +59,7 @@ namespace margelo::nitro::camera { std::shared_ptr> requestCameraPermission() override; std::shared_ptr> requestMicrophonePermission() override; std::shared_ptr>> createCameraSession(bool enableMultiCam) override; - std::shared_ptr>> resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) override; + std::shared_ptr>> resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) override; std::shared_ptr>> createDeviceFactory() override; std::shared_ptr createPhotoOutput(const PhotoOutputOptions& options) override; std::shared_ptr createVideoOutput(const VideoOutputOptions& options) override; diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.cpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.cpp index 3cce4730fa..20a5eecb83 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.cpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.cpp @@ -17,6 +17,8 @@ namespace margelo::nitro::camera { enum class TargetDynamicRangeBitDepth; } namespace margelo::nitro::camera { enum class TargetColorSpace; } // Forward declaration of `TargetColorRange` to properly resolve imports. namespace margelo::nitro::camera { enum class TargetColorRange; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `PixelFormat` to properly resolve imports. namespace margelo::nitro::camera { enum class PixelFormat; } // Forward declaration of `AutoFocusSystem` to properly resolve imports. @@ -33,6 +35,8 @@ namespace margelo::nitro::camera { enum class AutoFocusSystem; } #include "JTargetColorSpace.hpp" #include "TargetColorRange.hpp" #include "JTargetColorRange.hpp" +#include "VideoRecordingMode.hpp" +#include "JVideoRecordingMode.hpp" #include "PixelFormat.hpp" #include "JPixelFormat.hpp" #include "AutoFocusSystem.hpp" @@ -93,6 +97,11 @@ namespace margelo::nitro::camera { auto __result = method(_javaPart); return static_cast(__result); } + std::optional JHybridCameraSessionConfigSpec::getSelectedVideoRecordingMode() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getSelectedVideoRecordingMode"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt; + } PixelFormat JHybridCameraSessionConfigSpec::getNativePixelFormat() { static const auto method = _javaPart->javaClassStatic()->getMethod()>("getNativePixelFormat"); auto __result = method(_javaPart); diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.hpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.hpp index 00a1faa79c..a166f4dd14 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionConfigSpec.hpp @@ -55,6 +55,7 @@ namespace margelo::nitro::camera { std::optional getSelectedPreviewStabilizationMode() override; std::optional getSelectedVideoDynamicRange() override; bool getIsPhotoHDREnabled() override; + std::optional getSelectedVideoRecordingMode() override; PixelFormat getNativePixelFormat() override; AutoFocusSystem getAutoFocusSystem() override; bool getIsBinned() override; diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionSpec.cpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionSpec.cpp index 7f939efcc0..7ba24cc4fd 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionSpec.cpp +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JHybridCameraSessionSpec.cpp @@ -37,6 +37,8 @@ namespace margelo::nitro::camera { struct PhotoHDRConstraint; } namespace margelo::nitro::camera { struct PixelFormatConstraint; } // Forward declaration of `BinnedConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct BinnedConstraint; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } // Forward declaration of `TargetStabilizationMode` to properly resolve imports. namespace margelo::nitro::camera { enum class TargetStabilizationMode; } // Forward declaration of `TargetDynamicRange` to properly resolve imports. @@ -49,6 +51,8 @@ namespace margelo::nitro::camera { enum class TargetColorSpace; } namespace margelo::nitro::camera { enum class TargetColorRange; } // Forward declaration of `PixelFormat` to properly resolve imports. namespace margelo::nitro::camera { enum class PixelFormat; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `HybridCameraSessionConfigSpec` to properly resolve imports. namespace margelo::nitro::camera { class HybridCameraSessionConfigSpec; } // Forward declaration of `CameraSessionConfiguration` to properly resolve imports. @@ -86,6 +90,7 @@ namespace margelo::nitro::camera { enum class InterruptionReason; } #include "PhotoHDRConstraint.hpp" #include "PixelFormatConstraint.hpp" #include "BinnedConstraint.hpp" +#include "VideoRecordingModeConstraint.hpp" #include #include "JConstraint.hpp" #include "JFPSConstraint.hpp" @@ -108,6 +113,9 @@ namespace margelo::nitro::camera { enum class InterruptionReason; } #include "PixelFormat.hpp" #include "JPixelFormat.hpp" #include "JBinnedConstraint.hpp" +#include "JVideoRecordingModeConstraint.hpp" +#include "VideoRecordingMode.hpp" +#include "JVideoRecordingMode.hpp" #include #include "HybridCameraSessionConfigSpec.hpp" #include "JFunc_void_std__shared_ptr_HybridCameraSessionConfigSpec_.hpp" diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JVideoRecordingMode.hpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JVideoRecordingMode.hpp new file mode 100644 index 0000000000..509891e9f2 --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JVideoRecordingMode.hpp @@ -0,0 +1,58 @@ +/// +/// JVideoRecordingMode.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "VideoRecordingMode.hpp" + +namespace margelo::nitro::camera { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ enum "VideoRecordingMode" and the the Kotlin enum "VideoRecordingMode". + */ + struct JVideoRecordingMode final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/VideoRecordingMode;"; + + public: + /** + * Convert this Java/Kotlin-based enum to the C++ enum VideoRecordingMode. + */ + [[maybe_unused]] + [[nodiscard]] + VideoRecordingMode toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldOrdinal = clazz->getField("value"); + int ordinal = this->getFieldValue(fieldOrdinal); + return static_cast(ordinal); + } + + public: + /** + * Create a Java/Kotlin-based enum with the given C++ enum's value. + */ + [[maybe_unused]] + static jni::alias_ref fromCpp(VideoRecordingMode value) { + static const auto clazz = javaClassStatic(); + switch (value) { + case VideoRecordingMode::HIGH_SPEED: + static const auto fieldHIGH_SPEED = clazz->getStaticField("HIGH_SPEED"); + return clazz->getStaticFieldValue(fieldHIGH_SPEED); + case VideoRecordingMode::SLOW_MOTION: + static const auto fieldSLOW_MOTION = clazz->getStaticField("SLOW_MOTION"); + return clazz->getStaticFieldValue(fieldSLOW_MOTION); + default: + std::string stringValue = std::to_string(static_cast(value)); + throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); + } + } + }; + +} // namespace margelo::nitro::camera diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/c++/JVideoRecordingModeConstraint.hpp b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JVideoRecordingModeConstraint.hpp new file mode 100644 index 0000000000..276a623dda --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/android/c++/JVideoRecordingModeConstraint.hpp @@ -0,0 +1,58 @@ +/// +/// JVideoRecordingModeConstraint.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "VideoRecordingModeConstraint.hpp" + +#include "JVideoRecordingMode.hpp" +#include "VideoRecordingMode.hpp" + +namespace margelo::nitro::camera { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "VideoRecordingModeConstraint" and the the Kotlin data class "VideoRecordingModeConstraint". + */ + struct JVideoRecordingModeConstraint final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/VideoRecordingModeConstraint;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct VideoRecordingModeConstraint by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + VideoRecordingModeConstraint toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldVideoRecordingMode = clazz->getField("videoRecordingMode"); + jni::local_ref videoRecordingMode = this->getFieldValue(fieldVideoRecordingMode); + return VideoRecordingModeConstraint( + videoRecordingMode->toCpp() + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const VideoRecordingModeConstraint& value) { + using JSignature = JVideoRecordingModeConstraint(jni::alias_ref); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + JVideoRecordingMode::fromCpp(value.videoRecordingMode) + ); + } + }; + +} // namespace margelo::nitro::camera diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/Constraint.kt b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/Constraint.kt index afaf45600d..395152f236 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/Constraint.kt +++ b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/Constraint.kt @@ -11,7 +11,7 @@ import com.facebook.proguard.annotations.DoNotStrip /** - * Represents the TypeScript variant "FPSConstraint | VideoStabilizationModeConstraint | PreviewStabilizationModeConstraint | ResolutionBiasConstraint | VideoDynamicRangeConstraint | PhotoHDRConstraint | PixelFormatConstraint | BinnedConstraint". + * Represents the TypeScript variant "FPSConstraint | VideoStabilizationModeConstraint | PreviewStabilizationModeConstraint | ResolutionBiasConstraint | VideoDynamicRangeConstraint | PhotoHDRConstraint | PixelFormatConstraint | BinnedConstraint | VideoRecordingModeConstraint". */ @Suppress("ClassName") @DoNotStrip @@ -32,6 +32,8 @@ sealed class Constraint { data class Seventh(@DoNotStrip val value: PixelFormatConstraint): Constraint() @DoNotStrip data class Eigth(@DoNotStrip val value: BinnedConstraint): Constraint() + @DoNotStrip + data class Ninth(@DoNotStrip val value: VideoRecordingModeConstraint): Constraint() inline fun asType(): T? { return when (this) { @@ -43,12 +45,13 @@ sealed class Constraint { is Sixth -> (value) as? T is Seventh -> (value) as? T is Eigth -> (value) as? T + is Ninth -> (value) as? T } } inline fun isType(): Boolean { return asType() != null } - inline fun match(first: (FPSConstraint) -> R, second: (VideoStabilizationModeConstraint) -> R, third: (PreviewStabilizationModeConstraint) -> R, fourth: (ResolutionBiasConstraint) -> R, fifth: (VideoDynamicRangeConstraint) -> R, sixth: (PhotoHDRConstraint) -> R, seventh: (PixelFormatConstraint) -> R, eigth: (BinnedConstraint) -> R): R { + inline fun match(first: (FPSConstraint) -> R, second: (VideoStabilizationModeConstraint) -> R, third: (PreviewStabilizationModeConstraint) -> R, fourth: (ResolutionBiasConstraint) -> R, fifth: (VideoDynamicRangeConstraint) -> R, sixth: (PhotoHDRConstraint) -> R, seventh: (PixelFormatConstraint) -> R, eigth: (BinnedConstraint) -> R, ninth: (VideoRecordingModeConstraint) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) @@ -58,6 +61,7 @@ sealed class Constraint { is Sixth -> sixth(value) is Seventh -> seventh(value) is Eigth -> eigth(value) + is Ninth -> ninth(value) } } @@ -77,6 +81,8 @@ sealed class Constraint { get() = this is Seventh val isEigth: Boolean get() = this is Eigth + val isNinth: Boolean + get() = this is Ninth fun asFirstOrNull(): FPSConstraint? { val value = (this as? First)?.value ?: return null @@ -110,6 +116,10 @@ sealed class Constraint { val value = (this as? Eigth)?.value ?: return null return value } + fun asNinthOrNull(): VideoRecordingModeConstraint? { + val value = (this as? Ninth)?.value ?: return null + return value + } companion object { @JvmStatic @@ -136,5 +146,8 @@ sealed class Constraint { @JvmStatic @DoNotStrip fun create(value: BinnedConstraint): Constraint = Eigth(value) + @JvmStatic + @DoNotStrip + fun create(value: VideoRecordingModeConstraint): Constraint = Ninth(value) } } diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/HybridCameraSessionConfigSpec.kt b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/HybridCameraSessionConfigSpec.kt index 4d2fabc7fe..2ae7d35e88 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/HybridCameraSessionConfigSpec.kt +++ b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/HybridCameraSessionConfigSpec.kt @@ -45,6 +45,10 @@ abstract class HybridCameraSessionConfigSpec: HybridObject() { @get:Keep abstract val isPhotoHDREnabled: Boolean + @get:DoNotStrip + @get:Keep + abstract val selectedVideoRecordingMode: VideoRecordingMode? + @get:DoNotStrip @get:Keep abstract val nativePixelFormat: PixelFormat diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/VideoRecordingMode.kt b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/VideoRecordingMode.kt new file mode 100644 index 0000000000..1bf77a7aff --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/VideoRecordingMode.kt @@ -0,0 +1,23 @@ +/// +/// VideoRecordingMode.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.camera + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +/** + * Represents the JavaScript enum/union "VideoRecordingMode". + */ +@DoNotStrip +@Keep +enum class VideoRecordingMode(@DoNotStrip @Keep val value: Int) { + HIGH_SPEED(0), + SLOW_MOTION(1); + + companion object +} diff --git a/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/VideoRecordingModeConstraint.kt b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/VideoRecordingModeConstraint.kt new file mode 100644 index 0000000000..5e0706fb43 --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/VideoRecordingModeConstraint.kt @@ -0,0 +1,38 @@ +/// +/// VideoRecordingModeConstraint.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.camera + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + + +/** + * Represents the JavaScript object/struct "VideoRecordingModeConstraint". + */ +@DoNotStrip +@Keep +data class VideoRecordingModeConstraint( + @DoNotStrip + @Keep + val videoRecordingMode: VideoRecordingMode +) { + /* primary constructor */ + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(videoRecordingMode: VideoRecordingMode): VideoRecordingModeConstraint { + return VideoRecordingModeConstraint(videoRecordingMode) + } + } +} diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Bridge.hpp b/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Bridge.hpp index 68a5cdec22..d0d887b3fa 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Bridge.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Bridge.hpp @@ -164,6 +164,10 @@ namespace margelo::nitro::camera { enum class TargetStabilizationMode; } namespace margelo::nitro::camera { enum class VideoCodec; } // Forward declaration of `VideoDynamicRangeConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct VideoDynamicRangeConstraint; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `VideoStabilizationModeConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct VideoStabilizationModeConstraint; } // Forward declaration of `WhiteBalanceGains` to properly resolve imports. @@ -322,6 +326,8 @@ namespace VisionCamera { class HybridZoomGestureControllerSpec_cxx; } #include "TargetStabilizationMode.hpp" #include "VideoCodec.hpp" #include "VideoDynamicRangeConstraint.hpp" +#include "VideoRecordingMode.hpp" +#include "VideoRecordingModeConstraint.hpp" #include "VideoStabilizationModeConstraint.hpp" #include "WhiteBalanceGains.hpp" #include @@ -734,16 +740,16 @@ namespace margelo::nitro::camera::bridge::swift { return vector; } - // pragma MARK: std::variant + // pragma MARK: std::variant /** - * Wrapper struct for `std::variant`. + * Wrapper struct for `std::variant`. * std::variant cannot be used in Swift because of a Swift bug. * Not even specializing it works. So we create a wrapper struct. */ - struct std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ final { - std::variant variant; - std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(std::variant variant): variant(variant) { } - operator std::variant() const noexcept { + struct std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ final { + std::variant variant; + std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(std::variant variant): variant(variant) { } + operator std::variant() const noexcept { return variant; } inline size_t index() const noexcept { @@ -773,39 +779,45 @@ namespace margelo::nitro::camera::bridge::swift { inline BinnedConstraint get_7() const noexcept { return std::get<7>(variant); } + inline VideoRecordingModeConstraint get_8() const noexcept { + return std::get<8>(variant); + } }; - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const FPSConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const FPSConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); + } + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const VideoStabilizationModeConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const VideoStabilizationModeConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const PreviewStabilizationModeConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const PreviewStabilizationModeConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const ResolutionBiasConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const ResolutionBiasConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const VideoDynamicRangeConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const VideoDynamicRangeConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const PhotoHDRConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const PhotoHDRConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const PixelFormatConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const PixelFormatConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const BinnedConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(const BinnedConstraint& value) noexcept { - return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(value); + inline std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(const VideoRecordingModeConstraint& value) noexcept { + return std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(value); } - // pragma MARK: std::vector> + // pragma MARK: std::vector> /** - * Specialized version of `std::vector>`. + * Specialized version of `std::vector>`. */ - using std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__ = std::vector>; - inline std::vector> create_std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__(size_t size) noexcept { - std::vector> vector; + using std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint__ = std::vector>; + inline std::vector> create_std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint__(size_t size) noexcept { + std::vector> vector; vector.reserve(size); return vector; } @@ -2683,6 +2695,21 @@ namespace margelo::nitro::camera::bridge::swift { return optional.value(); } + // pragma MARK: std::optional + /** + * Specialized version of `std::optional`. + */ + using std__optional_VideoRecordingMode_ = std::optional; + inline std::optional create_std__optional_VideoRecordingMode_(const VideoRecordingMode& value) noexcept { + return std::optional(value); + } + inline bool has_value_std__optional_VideoRecordingMode_(const std::optional& optional) noexcept { + return optional.has_value(); + } + inline VideoRecordingMode get_std__optional_VideoRecordingMode_(const std::optional& optional) noexcept { + return optional.value(); + } + // pragma MARK: std::shared_ptr /** * Specialized version of `std::shared_ptr`. diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Umbrella.hpp b/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Umbrella.hpp index 36bf60e83d..38383fe810 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Umbrella.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/VisionCamera-Swift-Cxx-Umbrella.hpp @@ -218,6 +218,10 @@ namespace margelo::nitro::camera { struct VideoDynamicRangeConstraint; } namespace margelo::nitro::camera { struct VideoOutputOptions; } // Forward declaration of `VideoOutputSettings` to properly resolve imports. namespace margelo::nitro::camera { struct VideoOutputSettings; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `VideoStabilizationModeConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct VideoStabilizationModeConstraint; } // Forward declaration of `WhiteBalanceGains` to properly resolve imports. @@ -332,6 +336,8 @@ namespace margelo::nitro::camera { struct WhiteBalanceTemperatureAndTint; } #include "VideoDynamicRangeConstraint.hpp" #include "VideoOutputOptions.hpp" #include "VideoOutputSettings.hpp" +#include "VideoRecordingMode.hpp" +#include "VideoRecordingModeConstraint.hpp" #include "VideoStabilizationModeConstraint.hpp" #include "WhiteBalanceGains.hpp" #include "WhiteBalanceMode.hpp" diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraFactorySpecSwift.hpp b/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraFactorySpecSwift.hpp index 26507b64d0..3724f5abaf 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraFactorySpecSwift.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraFactorySpecSwift.hpp @@ -42,6 +42,8 @@ namespace margelo::nitro::camera { struct PhotoHDRConstraint; } namespace margelo::nitro::camera { struct PixelFormatConstraint; } // Forward declaration of `BinnedConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct BinnedConstraint; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } // Forward declaration of `TargetStabilizationMode` to properly resolve imports. namespace margelo::nitro::camera { enum class TargetStabilizationMode; } // Forward declaration of `TargetDynamicRange` to properly resolve imports. @@ -54,6 +56,8 @@ namespace margelo::nitro::camera { enum class TargetColorSpace; } namespace margelo::nitro::camera { enum class TargetColorRange; } // Forward declaration of `PixelFormat` to properly resolve imports. namespace margelo::nitro::camera { enum class PixelFormat; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `HybridCameraDeviceFactorySpec` to properly resolve imports. namespace margelo::nitro::camera { class HybridCameraDeviceFactorySpec; } // Forward declaration of `HybridCameraPhotoOutputSpec` to properly resolve imports. @@ -121,6 +125,7 @@ namespace margelo::nitro::camera { class HybridMeteringPointSpec; } #include "PhotoHDRConstraint.hpp" #include "PixelFormatConstraint.hpp" #include "BinnedConstraint.hpp" +#include "VideoRecordingModeConstraint.hpp" #include #include "TargetStabilizationMode.hpp" #include "TargetDynamicRange.hpp" @@ -128,6 +133,7 @@ namespace margelo::nitro::camera { class HybridMeteringPointSpec; } #include "TargetColorSpace.hpp" #include "TargetColorRange.hpp" #include "PixelFormat.hpp" +#include "VideoRecordingMode.hpp" #include #include "HybridCameraDeviceFactorySpec.hpp" #include "HybridCameraPhotoOutputSpec.hpp" @@ -238,7 +244,7 @@ namespace margelo::nitro::camera { auto __value = std::move(__result.value()); return __value; } - inline std::shared_ptr>> resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) override { + inline std::shared_ptr>> resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) override { auto __result = _swiftPart.resolveConstraints(device, outputConfigurations, constraints, requiresMultiCam); if (__result.hasError()) [[unlikely]] { std::rethrow_exception(__result.error()); diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionConfigSpecSwift.hpp b/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionConfigSpecSwift.hpp index 9a674964c6..ee20b8e059 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionConfigSpecSwift.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionConfigSpecSwift.hpp @@ -22,6 +22,8 @@ namespace margelo::nitro::camera { enum class TargetDynamicRangeBitDepth; } namespace margelo::nitro::camera { enum class TargetColorSpace; } // Forward declaration of `TargetColorRange` to properly resolve imports. namespace margelo::nitro::camera { enum class TargetColorRange; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `PixelFormat` to properly resolve imports. namespace margelo::nitro::camera { enum class PixelFormat; } // Forward declaration of `AutoFocusSystem` to properly resolve imports. @@ -33,6 +35,7 @@ namespace margelo::nitro::camera { enum class AutoFocusSystem; } #include "TargetDynamicRangeBitDepth.hpp" #include "TargetColorSpace.hpp" #include "TargetColorRange.hpp" +#include "VideoRecordingMode.hpp" #include "PixelFormat.hpp" #include "AutoFocusSystem.hpp" @@ -101,6 +104,10 @@ namespace margelo::nitro::camera { inline bool getIsPhotoHDREnabled() noexcept override { return _swiftPart.isPhotoHDREnabled(); } + inline std::optional getSelectedVideoRecordingMode() noexcept override { + auto __result = _swiftPart.getSelectedVideoRecordingMode(); + return __result; + } inline PixelFormat getNativePixelFormat() noexcept override { auto __result = _swiftPart.getNativePixelFormat(); return static_cast(__result); diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionSpecSwift.hpp b/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionSpecSwift.hpp index 9204993f94..d6c28e6eaa 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionSpecSwift.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/c++/HybridCameraSessionSpecSwift.hpp @@ -40,6 +40,8 @@ namespace margelo::nitro::camera { struct PhotoHDRConstraint; } namespace margelo::nitro::camera { struct PixelFormatConstraint; } // Forward declaration of `BinnedConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct BinnedConstraint; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } // Forward declaration of `TargetStabilizationMode` to properly resolve imports. namespace margelo::nitro::camera { enum class TargetStabilizationMode; } // Forward declaration of `TargetDynamicRange` to properly resolve imports. @@ -52,6 +54,8 @@ namespace margelo::nitro::camera { enum class TargetColorSpace; } namespace margelo::nitro::camera { enum class TargetColorRange; } // Forward declaration of `PixelFormat` to properly resolve imports. namespace margelo::nitro::camera { enum class PixelFormat; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `HybridCameraSessionConfigSpec` to properly resolve imports. namespace margelo::nitro::camera { class HybridCameraSessionConfigSpec; } // Forward declaration of `CameraSessionConfiguration` to properly resolve imports. @@ -78,6 +82,7 @@ namespace margelo::nitro::camera { enum class InterruptionReason; } #include "PhotoHDRConstraint.hpp" #include "PixelFormatConstraint.hpp" #include "BinnedConstraint.hpp" +#include "VideoRecordingModeConstraint.hpp" #include #include "TargetStabilizationMode.hpp" #include "TargetDynamicRange.hpp" @@ -85,6 +90,7 @@ namespace margelo::nitro::camera { enum class InterruptionReason; } #include "TargetColorSpace.hpp" #include "TargetColorRange.hpp" #include "PixelFormat.hpp" +#include "VideoRecordingMode.hpp" #include #include "HybridCameraSessionConfigSpec.hpp" #include diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/CameraSessionConnection.swift b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/CameraSessionConnection.swift index 696b201b89..a55f1f39ed 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/CameraSessionConnection.swift +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/CameraSessionConnection.swift @@ -28,27 +28,29 @@ public extension CameraSessionConnection { __vector.push_back(__item) } return __vector - }(), { () -> bridge.std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__ in - var __vector = bridge.create_std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__(constraints.count) + }(), { () -> bridge.std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint__ in + var __vector = bridge.create_std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint__(constraints.count) for __item in constraints { - __vector.push_back({ () -> bridge.std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_ in + __vector.push_back({ () -> bridge.std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_ in switch __item { case .first(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) case .second(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) case .third(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) case .fourth(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) case .fifth(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) case .sixth(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) case .seventh(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) case .eigth(let __value): - return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__value) + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) + case .ninth(let __value): + return bridge.create_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__value) } }().variant) } @@ -94,7 +96,7 @@ public extension CameraSessionConnection { @inline(__always) var constraints: [Constraint] { return self.__constraints.map({ __item in { () -> Constraint in - let __variant = bridge.std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__item) + let __variant = bridge.std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__item) switch __variant.index() { case 0: let __actual = __variant.get_0() @@ -120,6 +122,9 @@ public extension CameraSessionConnection { case 7: let __actual = __variant.get_7() return .eigth(__actual) + case 8: + let __actual = __variant.get_8() + return .ninth(__actual) default: fatalError("Variant can never have index \(__variant.index())!") } diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/Constraint.swift b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/Constraint.swift index 8ecb394eed..5a7994349f 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/Constraint.swift +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/Constraint.swift @@ -9,7 +9,7 @@ /** * An Swift enum with associated values representing a Variant/Union type. - * JS type: `struct | struct | struct | struct | struct | struct | struct | struct` + * JS type: `struct | struct | struct | struct | struct | struct | struct | struct | struct` */ @frozen public indirect enum Constraint { @@ -21,6 +21,7 @@ public indirect enum Constraint { case sixth(PhotoHDRConstraint) case seventh(PixelFormatConstraint) case eigth(BinnedConstraint) + case ninth(VideoRecordingModeConstraint) } public extension Constraint { @@ -34,6 +35,7 @@ public extension Constraint { case .sixth(let value): return value as? T case .seventh(let value): return value as? T case .eigth(let value): return value as? T + case .ninth(let value): return value as? T } } func isType(_ type: T.Type = T.self) -> Bool { diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraFactorySpec_cxx.swift b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraFactorySpec_cxx.swift index 31b70e3b98..a94e00e935 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraFactorySpec_cxx.swift +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraFactorySpec_cxx.swift @@ -204,14 +204,14 @@ open class HybridCameraFactorySpec_cxx { } @inline(__always) - public final func resolveConstraints(device: bridge.std__shared_ptr_HybridCameraDeviceSpec_, outputConfigurations: bridge.std__vector_CameraOutputConfiguration_, constraints: bridge.std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__, requiresMultiCam: bridge.std__optional_bool_) -> bridge.Result_std__shared_ptr_Promise_std__shared_ptr_HybridCameraSessionConfigSpec____ { + public final func resolveConstraints(device: bridge.std__shared_ptr_HybridCameraDeviceSpec_, outputConfigurations: bridge.std__vector_CameraOutputConfiguration_, constraints: bridge.std__vector_std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint__, requiresMultiCam: bridge.std__optional_bool_) -> bridge.Result_std__shared_ptr_Promise_std__shared_ptr_HybridCameraSessionConfigSpec____ { do { let __result = try self.__implementation.resolveConstraints(device: { () -> any HybridCameraDeviceSpec in let __unsafePointer = bridge.get_std__shared_ptr_HybridCameraDeviceSpec_(device) let __instance = HybridCameraDeviceSpec_cxx.fromUnsafe(__unsafePointer) return __instance.getHybridCameraDeviceSpec() }(), outputConfigurations: outputConfigurations.map({ __item in __item }), constraints: constraints.map({ __item in { () -> Constraint in - let __variant = bridge.std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint_(__item) + let __variant = bridge.std__variant_FPSConstraint__VideoStabilizationModeConstraint__PreviewStabilizationModeConstraint__ResolutionBiasConstraint__VideoDynamicRangeConstraint__PhotoHDRConstraint__PixelFormatConstraint__BinnedConstraint__VideoRecordingModeConstraint_(__item) switch __variant.index() { case 0: let __actual = __variant.get_0() @@ -237,6 +237,9 @@ open class HybridCameraFactorySpec_cxx { case 7: let __actual = __variant.get_7() return .eigth(__actual) + case 8: + let __actual = __variant.get_8() + return .ninth(__actual) default: fatalError("Variant can never have index \(__variant.index())!") } diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec.swift b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec.swift index 209ccf4746..1f08756430 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec.swift +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec.swift @@ -15,6 +15,7 @@ public protocol HybridCameraSessionConfigSpec_protocol: HybridObject { var selectedPreviewStabilizationMode: TargetStabilizationMode? { get } var selectedVideoDynamicRange: TargetDynamicRange? { get } var isPhotoHDREnabled: Bool { get } + var selectedVideoRecordingMode: VideoRecordingMode? { get } var nativePixelFormat: PixelFormat { get } var autoFocusSystem: AutoFocusSystem { get } var isBinned: Bool { get } diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec_cxx.swift b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec_cxx.swift index 222294d496..3979abd34f 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec_cxx.swift +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/HybridCameraSessionConfigSpec_cxx.swift @@ -180,6 +180,19 @@ open class HybridCameraSessionConfigSpec_cxx { } } + public final var selectedVideoRecordingMode: bridge.std__optional_VideoRecordingMode_ { + @inline(__always) + get { + return { () -> bridge.std__optional_VideoRecordingMode_ in + if let __unwrappedValue = self.__implementation.selectedVideoRecordingMode { + return bridge.create_std__optional_VideoRecordingMode_(__unwrappedValue) + } else { + return .init() + } + }() + } + } + public final var nativePixelFormat: Int32 { @inline(__always) get { diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/VideoRecordingMode.swift b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/VideoRecordingMode.swift new file mode 100644 index 0000000000..d4c21d2e88 --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/VideoRecordingMode.swift @@ -0,0 +1,40 @@ +/// +/// VideoRecordingMode.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +/** + * Represents the JS union `VideoRecordingMode`, backed by a C++ enum. + */ +public typealias VideoRecordingMode = margelo.nitro.camera.VideoRecordingMode + +public extension VideoRecordingMode { + /** + * Get a VideoRecordingMode for the given String value, or + * return `nil` if the given value was invalid/unknown. + */ + init?(fromString string: String) { + switch string { + case "high-speed": + self = .highSpeed + case "slow-motion": + self = .slowMotion + default: + return nil + } + } + + /** + * Get the String value this VideoRecordingMode represents. + */ + var stringValue: String { + switch self { + case .highSpeed: + return "high-speed" + case .slowMotion: + return "slow-motion" + } + } +} diff --git a/packages/react-native-vision-camera/nitrogen/generated/ios/swift/VideoRecordingModeConstraint.swift b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/VideoRecordingModeConstraint.swift new file mode 100644 index 0000000000..a79cf6dc1b --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/ios/swift/VideoRecordingModeConstraint.swift @@ -0,0 +1,29 @@ +/// +/// VideoRecordingModeConstraint.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Represents an instance of `VideoRecordingModeConstraint`, backed by a C++ struct. + */ +public typealias VideoRecordingModeConstraint = margelo.nitro.camera.VideoRecordingModeConstraint + +public extension VideoRecordingModeConstraint { + private typealias bridge = margelo.nitro.camera.bridge.swift + + /** + * Create a new instance of `VideoRecordingModeConstraint`. + */ + init(videoRecordingMode: VideoRecordingMode) { + self.init(videoRecordingMode) + } + + @inline(__always) + var videoRecordingMode: VideoRecordingMode { + return self.__videoRecordingMode + } +} diff --git a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/CameraSessionConnection.hpp b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/CameraSessionConnection.hpp index 82389224a1..67df7e64d2 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/CameraSessionConnection.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/CameraSessionConnection.hpp @@ -48,6 +48,8 @@ namespace margelo::nitro::camera { struct PhotoHDRConstraint; } namespace margelo::nitro::camera { struct PixelFormatConstraint; } // Forward declaration of `BinnedConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct BinnedConstraint; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } // Forward declaration of `HybridCameraSessionConfigSpec` to properly resolve imports. namespace margelo::nitro::camera { class HybridCameraSessionConfigSpec; } @@ -63,6 +65,7 @@ namespace margelo::nitro::camera { class HybridCameraSessionConfigSpec; } #include "PhotoHDRConstraint.hpp" #include "PixelFormatConstraint.hpp" #include "BinnedConstraint.hpp" +#include "VideoRecordingModeConstraint.hpp" #include #include #include "HybridCameraSessionConfigSpec.hpp" @@ -77,14 +80,14 @@ namespace margelo::nitro::camera { public: std::shared_ptr input SWIFT_PRIVATE; std::vector outputs SWIFT_PRIVATE; - std::vector> constraints SWIFT_PRIVATE; + std::vector> constraints SWIFT_PRIVATE; std::optional initialZoom SWIFT_PRIVATE; std::optional initialExposureBias SWIFT_PRIVATE; std::optional& /* config */)>> onSessionConfigSelected SWIFT_PRIVATE; public: CameraSessionConnection() = default; - explicit CameraSessionConnection(std::shared_ptr input, std::vector outputs, std::vector> constraints, std::optional initialZoom, std::optional initialExposureBias, std::optional& /* config */)>> onSessionConfigSelected): input(input), outputs(outputs), constraints(constraints), initialZoom(initialZoom), initialExposureBias(initialExposureBias), onSessionConfigSelected(onSessionConfigSelected) {} + explicit CameraSessionConnection(std::shared_ptr input, std::vector outputs, std::vector> constraints, std::optional initialZoom, std::optional initialExposureBias, std::optional& /* config */)>> onSessionConfigSelected): input(input), outputs(outputs), constraints(constraints), initialZoom(initialZoom), initialExposureBias(initialExposureBias), onSessionConfigSelected(onSessionConfigSelected) {} public: // CameraSessionConnection is not equatable because these properties are not equatable: onSessionConfigSelected @@ -102,7 +105,7 @@ namespace margelo::nitro { return margelo::nitro::camera::CameraSessionConnection( JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "input"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputs"))), - JSIConverter>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "constraints"))), + JSIConverter>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "constraints"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "initialZoom"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "initialExposureBias"))), JSIConverter&)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onSessionConfigSelected"))) @@ -112,7 +115,7 @@ namespace margelo::nitro { jsi::Object obj(runtime); obj.setProperty(runtime, PropNameIDCache::get(runtime, "input"), JSIConverter>::toJSI(runtime, arg.input)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "outputs"), JSIConverter>::toJSI(runtime, arg.outputs)); - obj.setProperty(runtime, PropNameIDCache::get(runtime, "constraints"), JSIConverter>>::toJSI(runtime, arg.constraints)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "constraints"), JSIConverter>>::toJSI(runtime, arg.constraints)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "initialZoom"), JSIConverter>::toJSI(runtime, arg.initialZoom)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "initialExposureBias"), JSIConverter>::toJSI(runtime, arg.initialExposureBias)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "onSessionConfigSelected"), JSIConverter&)>>>::toJSI(runtime, arg.onSessionConfigSelected)); @@ -128,7 +131,7 @@ namespace margelo::nitro { } if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "input")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputs")))) return false; - if (!JSIConverter>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "constraints")))) return false; + if (!JSIConverter>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "constraints")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "initialZoom")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "initialExposureBias")))) return false; if (!JSIConverter&)>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onSessionConfigSelected")))) return false; diff --git a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraFactorySpec.hpp b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraFactorySpec.hpp index 537af34d71..b4f422b2f4 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraFactorySpec.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraFactorySpec.hpp @@ -39,6 +39,8 @@ namespace margelo::nitro::camera { struct PhotoHDRConstraint; } namespace margelo::nitro::camera { struct PixelFormatConstraint; } // Forward declaration of `BinnedConstraint` to properly resolve imports. namespace margelo::nitro::camera { struct BinnedConstraint; } +// Forward declaration of `VideoRecordingModeConstraint` to properly resolve imports. +namespace margelo::nitro::camera { struct VideoRecordingModeConstraint; } // Forward declaration of `HybridCameraDeviceFactorySpec` to properly resolve imports. namespace margelo::nitro::camera { class HybridCameraDeviceFactorySpec; } // Forward declaration of `HybridCameraPhotoOutputSpec` to properly resolve imports. @@ -96,6 +98,7 @@ namespace margelo::nitro::camera { class HybridMeteringPointSpec; } #include "PhotoHDRConstraint.hpp" #include "PixelFormatConstraint.hpp" #include "BinnedConstraint.hpp" +#include "VideoRecordingModeConstraint.hpp" #include #include #include "HybridCameraDeviceFactorySpec.hpp" @@ -155,7 +158,7 @@ namespace margelo::nitro::camera { virtual std::shared_ptr> requestCameraPermission() = 0; virtual std::shared_ptr> requestMicrophonePermission() = 0; virtual std::shared_ptr>> createCameraSession(bool enableMultiCam) = 0; - virtual std::shared_ptr>> resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) = 0; + virtual std::shared_ptr>> resolveConstraints(const std::shared_ptr& device, const std::vector& outputConfigurations, const std::vector>& constraints, std::optional requiresMultiCam) = 0; virtual std::shared_ptr>> createDeviceFactory() = 0; virtual std::shared_ptr createPhotoOutput(const PhotoOutputOptions& options) = 0; virtual std::shared_ptr createVideoOutput(const VideoOutputOptions& options) = 0; diff --git a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.cpp b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.cpp index 2627bc9db6..eb0964a230 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.cpp +++ b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.cpp @@ -19,6 +19,7 @@ namespace margelo::nitro::camera { prototype.registerHybridGetter("selectedPreviewStabilizationMode", &HybridCameraSessionConfigSpec::getSelectedPreviewStabilizationMode); prototype.registerHybridGetter("selectedVideoDynamicRange", &HybridCameraSessionConfigSpec::getSelectedVideoDynamicRange); prototype.registerHybridGetter("isPhotoHDREnabled", &HybridCameraSessionConfigSpec::getIsPhotoHDREnabled); + prototype.registerHybridGetter("selectedVideoRecordingMode", &HybridCameraSessionConfigSpec::getSelectedVideoRecordingMode); prototype.registerHybridGetter("nativePixelFormat", &HybridCameraSessionConfigSpec::getNativePixelFormat); prototype.registerHybridGetter("autoFocusSystem", &HybridCameraSessionConfigSpec::getAutoFocusSystem); prototype.registerHybridGetter("isBinned", &HybridCameraSessionConfigSpec::getIsBinned); diff --git a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.hpp b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.hpp index c1ec3a54fd..5b6edfb84e 100644 --- a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.hpp +++ b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/HybridCameraSessionConfigSpec.hpp @@ -17,6 +17,8 @@ namespace margelo::nitro::camera { enum class TargetStabilizationMode; } // Forward declaration of `TargetDynamicRange` to properly resolve imports. namespace margelo::nitro::camera { struct TargetDynamicRange; } +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } // Forward declaration of `PixelFormat` to properly resolve imports. namespace margelo::nitro::camera { enum class PixelFormat; } // Forward declaration of `AutoFocusSystem` to properly resolve imports. @@ -25,6 +27,7 @@ namespace margelo::nitro::camera { enum class AutoFocusSystem; } #include #include "TargetStabilizationMode.hpp" #include "TargetDynamicRange.hpp" +#include "VideoRecordingMode.hpp" #include "PixelFormat.hpp" #include "AutoFocusSystem.hpp" @@ -60,6 +63,7 @@ namespace margelo::nitro::camera { virtual std::optional getSelectedPreviewStabilizationMode() = 0; virtual std::optional getSelectedVideoDynamicRange() = 0; virtual bool getIsPhotoHDREnabled() = 0; + virtual std::optional getSelectedVideoRecordingMode() = 0; virtual PixelFormat getNativePixelFormat() = 0; virtual AutoFocusSystem getAutoFocusSystem() = 0; virtual bool getIsBinned() = 0; diff --git a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/VideoRecordingMode.hpp b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/VideoRecordingMode.hpp new file mode 100644 index 0000000000..1d4b01366a --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/VideoRecordingMode.hpp @@ -0,0 +1,76 @@ +/// +/// VideoRecordingMode.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +namespace margelo::nitro::camera { + + /** + * An enum which can be represented as a JavaScript union (VideoRecordingMode). + */ + enum class VideoRecordingMode { + HIGH_SPEED SWIFT_NAME(highSpeed) = 0, + SLOW_MOTION SWIFT_NAME(slowMotion) = 1, + } CLOSED_ENUM; + +} // namespace margelo::nitro::camera + +namespace margelo::nitro { + + // C++ VideoRecordingMode <> JS VideoRecordingMode (union) + template <> + struct JSIConverter final { + static inline margelo::nitro::camera::VideoRecordingMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + std::string unionValue = JSIConverter::fromJSI(runtime, arg); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("high-speed"): return margelo::nitro::camera::VideoRecordingMode::HIGH_SPEED; + case hashString("slow-motion"): return margelo::nitro::camera::VideoRecordingMode::SLOW_MOTION; + default: [[unlikely]] + throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum VideoRecordingMode - invalid value!"); + } + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::camera::VideoRecordingMode arg) { + switch (arg) { + case margelo::nitro::camera::VideoRecordingMode::HIGH_SPEED: return JSIConverter::toJSI(runtime, "high-speed"); + case margelo::nitro::camera::VideoRecordingMode::SLOW_MOTION: return JSIConverter::toJSI(runtime, "slow-motion"); + default: [[unlikely]] + throw std::invalid_argument("Cannot convert VideoRecordingMode to JS - invalid value: " + + std::to_string(static_cast(arg)) + "!"); + } + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isString()) { + return false; + } + std::string unionValue = JSIConverter::fromJSI(runtime, value); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("high-speed"): + case hashString("slow-motion"): + return true; + default: + return false; + } + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-vision-camera/nitrogen/generated/shared/c++/VideoRecordingModeConstraint.hpp b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/VideoRecordingModeConstraint.hpp new file mode 100644 index 0000000000..1bde8c0799 --- /dev/null +++ b/packages/react-native-vision-camera/nitrogen/generated/shared/c++/VideoRecordingModeConstraint.hpp @@ -0,0 +1,84 @@ +/// +/// VideoRecordingModeConstraint.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `VideoRecordingMode` to properly resolve imports. +namespace margelo::nitro::camera { enum class VideoRecordingMode; } + +#include "VideoRecordingMode.hpp" + +namespace margelo::nitro::camera { + + /** + * A struct which can be represented as a JavaScript object (VideoRecordingModeConstraint). + */ + struct VideoRecordingModeConstraint final { + public: + VideoRecordingMode videoRecordingMode SWIFT_PRIVATE; + + public: + VideoRecordingModeConstraint() = default; + explicit VideoRecordingModeConstraint(VideoRecordingMode videoRecordingMode): videoRecordingMode(videoRecordingMode) {} + + public: + friend bool operator==(const VideoRecordingModeConstraint& lhs, const VideoRecordingModeConstraint& rhs) = default; + }; + +} // namespace margelo::nitro::camera + +namespace margelo::nitro { + + // C++ VideoRecordingModeConstraint <> JS VideoRecordingModeConstraint (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::camera::VideoRecordingModeConstraint fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::camera::VideoRecordingModeConstraint( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "videoRecordingMode"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::VideoRecordingModeConstraint& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "videoRecordingMode"), JSIConverter::toJSI(runtime, arg.videoRecordingMode)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "videoRecordingMode")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/packages/react-native-vision-camera/src/index.ts b/packages/react-native-vision-camera/src/index.ts index e6e1f4a11f..edf8e78415 100644 --- a/packages/react-native-vision-camera/src/index.ts +++ b/packages/react-native-vision-camera/src/index.ts @@ -47,6 +47,7 @@ export * from './specs/common-types/Size' export * from './specs/common-types/StabilizationMode' export * from './specs/common-types/TorchMode' export * from './specs/common-types/VideoCodec' +export * from './specs/common-types/VideoRecordingMode' export * from './specs/common-types/VideoPixelFormat' export * from './specs/common-types/WhiteBalanceGains' export * from './specs/common-types/WhiteBalanceMode' diff --git a/packages/react-native-vision-camera/src/specs/common-types/Constraint.ts b/packages/react-native-vision-camera/src/specs/common-types/Constraint.ts index f3e81a9511..c8d899941e 100644 --- a/packages/react-native-vision-camera/src/specs/common-types/Constraint.ts +++ b/packages/react-native-vision-camera/src/specs/common-types/Constraint.ts @@ -10,6 +10,7 @@ import type { CameraSessionConnection } from '../session/CameraSessionConnection import type { TargetDynamicRange } from './DynamicRange' import type { PixelFormat } from './PixelFormat' import type { TargetStabilizationMode } from './StabilizationMode' +import type { VideoRecordingMode } from './VideoRecordingMode' /** * A constraint to set a given FPS `number` for any Video, @@ -154,6 +155,31 @@ export interface PixelFormatConstraint { export interface BinnedConstraint { binned: boolean } +/** + * A constraint to request high-speed capture on Android. + * + * @discussion + * This is useful for both smooth high frame-rate playback and + * slow-motion recording. If no explicit {@linkcode FPSConstraint} + * is present, VisionCamera automatically picks the lowest supported + * high-speed frame-rate to maximize compatibility. + * + * @example + * Record high frame-rate video: + * ```ts + * { videoRecordingMode: 'high-speed' } + * ``` + * @example + * Record slow-motion video: + * ```ts + * { videoRecordingMode: 'slow-motion' } + * ``` + * + * @platform Android + */ +export interface VideoRecordingModeConstraint { + videoRecordingMode: VideoRecordingMode +} /** * Constraints are session configuration options that are negotiated by @@ -204,3 +230,4 @@ export type Constraint = | PhotoHDRConstraint | PixelFormatConstraint | BinnedConstraint + | VideoRecordingModeConstraint diff --git a/packages/react-native-vision-camera/src/specs/common-types/VideoRecordingMode.ts b/packages/react-native-vision-camera/src/specs/common-types/VideoRecordingMode.ts new file mode 100644 index 0000000000..8b90a067d3 --- /dev/null +++ b/packages/react-native-vision-camera/src/specs/common-types/VideoRecordingMode.ts @@ -0,0 +1,9 @@ +/** + * Specifies how a video recording should be encoded when using a high-speed capture session. + * + * - `'high-speed'`: Records and saves the video at the negotiated high frame-rate (for example 120 FPS). + * - `'slow-motion'`: Records at a negotiated high frame-rate, then saves the file at a standard playback frame-rate to create a slow-motion effect. + * + * @platform Android + */ +export type VideoRecordingMode = 'high-speed' | 'slow-motion' diff --git a/packages/react-native-vision-camera/src/specs/outputs/CameraVideoOutput.nitro.ts b/packages/react-native-vision-camera/src/specs/outputs/CameraVideoOutput.nitro.ts index fd6df808e8..d42e8d890c 100644 --- a/packages/react-native-vision-camera/src/specs/outputs/CameraVideoOutput.nitro.ts +++ b/packages/react-native-vision-camera/src/specs/outputs/CameraVideoOutput.nitro.ts @@ -134,6 +134,11 @@ export interface RecorderSettings { * A Video output allows recording videos (possibly with audio) * to a file. * + * @discussion + * To record high-speed or slow-motion video on Android, combine this + * output with a {@linkcode Constraint} such as + * `{ videoRecordingMode: 'slow-motion' }`. + * * @see {@linkcode VideoOutputOptions} * @see {@linkcode Recorder} * @see {@linkcode useVideoOutput | useVideoOutput(...)} diff --git a/packages/react-native-vision-camera/src/specs/session/CameraSessionConfig.nitro.ts b/packages/react-native-vision-camera/src/specs/session/CameraSessionConfig.nitro.ts index 13b6cc10bd..d2bd686b68 100644 --- a/packages/react-native-vision-camera/src/specs/session/CameraSessionConfig.nitro.ts +++ b/packages/react-native-vision-camera/src/specs/session/CameraSessionConfig.nitro.ts @@ -6,6 +6,7 @@ import type { } from '../common-types/DynamicRange' import type { PixelFormat } from '../common-types/PixelFormat' import type { TargetStabilizationMode } from '../common-types/StabilizationMode' +import type { VideoRecordingMode } from '../common-types/VideoRecordingMode' import type { CameraDevice } from '../inputs/CameraDevice.nitro' import type { Frame } from '../instances/Frame.nitro' import type { CameraFrameOutput } from '../outputs/CameraFrameOutput.nitro' @@ -56,6 +57,14 @@ export interface CameraSessionConfig */ readonly isPhotoHDREnabled: boolean + /** + * Gets the currently selected high-speed recording mode for Video streams, + * or `undefined` if the session is not using a high-speed capture session. + * + * @platform Android + */ + readonly selectedVideoRecordingMode?: VideoRecordingMode + /** * Gets the {@linkcode PixelFormat} this config is natively * streaming in. diff --git a/packages/react-native-vision-camera/src/specs/session/CameraSessionConnection.ts b/packages/react-native-vision-camera/src/specs/session/CameraSessionConnection.ts index 27c028123e..4244a55c4b 100644 --- a/packages/react-native-vision-camera/src/specs/session/CameraSessionConnection.ts +++ b/packages/react-native-vision-camera/src/specs/session/CameraSessionConnection.ts @@ -53,7 +53,9 @@ export interface CameraSessionConnection { * The given {@linkcode config} can be used to provide visual feedback in * Camera apps where buttons have to be greyed out when they are not supported, * e.g. when passing a HDR {@linkcode Constraint} but the session didn't end up - * selecting a {@linkcode CameraSessionConfig.selectedVideoDynamicRange}. + * selecting a {@linkcode CameraSessionConfig.selectedVideoDynamicRange}, or + * when requesting slow-motion but the session didn't end up selecting a + * {@linkcode CameraSessionConfig.selectedVideoRecordingMode}. */ onSessionConfigSelected?: (config: CameraSessionConfig) => void }