Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension AVCaptureSession {

private func getDefaultMicrophone() throws -> AVCaptureDevice {
// TODO: Make microphone input selectable from JS
if #available(iOS 18.0, *) {
if #available(iOS 17.0, *) {
if let microphone = AVCaptureDevice.default(.microphone, for: .audio, position: .unspecified) {
return microphone
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ final class HybridCameraFrameOutput: HybridCameraFrameOutputSpec, NativeCameraOu
output.alwaysDiscardsLateVideoFrames = options.dropFramesWhileBusy
// JS configures the video resolution, we don't want to downscale here by default.
output.automaticallyConfiguresOutputBufferDimensions = false
if #available(iOS 26.0, *), output.isDeferredStartSupported {
// Deferred start allows the Session to delay this output's startup in favor
// of preview-related outputs to make preview appear faster.
output.isDeferredStartEnabled = options.allowDeferredStart
}
// TODO: Add a flag called `allowBufferResizing` and probably get rid of `enablePreviewSizedOutputBuffers`
// If `allowBufferResizing` is true, we can set `.videoSettings`/dimensions here to `options.targetResolution`
// and `targetResolution` to `.any` (to not participate in resolution negotiations).
// If `allowBufferResizing` is false, we don't set `.videoSettings` ("native" resolution), and reflect our
// target resolution via `targetResolution` to participate in resolution negotiations.
if #available(iOS 17.0, *), options.enablePreviewSizedOutputBuffers {
output.deliversPreviewSizedOutputBuffers = true
if #available(iOS 13.0, *) {
output.deliversPreviewSizedOutputBuffers = options.enablePreviewSizedOutputBuffers
}
if #available(iOS 26.0, *), output.isDeferredStartSupported {
// Deferred start allows the Session to delay this output's startup in favor
// of preview-related outputs to make preview appear faster.
output.isDeferredStartEnabled = options.allowDeferredStart
}
if #available(iOS 26.0, *) {
// We don't need HDR metadata, as that's only useful for encoders.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,6 @@ final class HybridCameraPhotoOutput: HybridCameraPhotoOutputSpec, NativeCameraOu
super.init()

output.maxPhotoQualityPrioritization = options.qualityPrioritization.toAVQualityPrioritization()

if options.containerFormat == .dng {
// If we capture RAW photos, try using Apple ProRAW. If not, Bayer14 RAW will be used.
output.isAppleProRAWEnabled = output.isAppleProRAWSupported
}

if #available(iOS 26, *),
output.isCameraSensorOrientationCompensationSupported
{
// Don't rotate Photo buffers - we handle orientation later on in file capture or toImage().
output.isCameraSensorOrientationCompensationEnabled = false
}

// Prepare the default Photo Settings to make the pipeline ready - some things (like flashMode)
// might change on a per-capture basis, but containerFormat and preview size is already known
// and can be prepared already.
try? prepareDefaultPhotoSettings()
}

func configure(config: CameraOutputConfiguration) {
Expand All @@ -82,6 +65,17 @@ final class HybridCameraPhotoOutput: HybridCameraPhotoOutputSpec, NativeCameraOu
try? connection.setOrientation(outputOrientation)
try? connection.setMirrorMode(config.mirrorMode)

let enableAppleProRAW = options.containerFormat == .dng && output.isAppleProRAWSupported
if output.isAppleProRAWEnabled != enableAppleProRAW {
// If we capture RAW photos, try using Apple ProRAW. If not, Bayer14 RAW will be used.
output.isAppleProRAWEnabled = enableAppleProRAW
}

if #available(iOS 26, *) {
// Don't rotate Photo buffers - we handle orientation later on in file capture or toImage().
output.isCameraSensorOrientationCompensationEnabled = false
}

if #available(iOS 16.0, *) {
// Configure PhotoOutput to the currently selected Format's max photo size
if let nativeDevice = connection.deviceInput {
Expand All @@ -93,10 +87,14 @@ final class HybridCameraPhotoOutput: HybridCameraPhotoOutputSpec, NativeCameraOu
{
// Target max photo dimensions have changed, re-configure
output.maxPhotoDimensions = nearestPhotoDimension
try? prepareDefaultPhotoSettings()
}
}
}

// Prepare the default Photo Settings to make the pipeline ready - some things (like flashMode)
// might change on a per-capture basis, but containerFormat and preview size is already known
// and can be prepared already.
try? prepareDefaultPhotoSettings()
}

private func prepareDefaultPhotoSettings() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public protocol NativeCameraOutput: AnyObject, ResolutionNegotiationParticipant
* change, in a `beginConfiguration()`/`commitConfiguration()`
* batch.
* The `NativeCameraOutput` is expected to apply all configs
* such as orientation or mirroring settings in here.
* such as orientation or mirroring settings in here, as well
* as any output properties that depend on session configuration,
* like `isResponsiveCaptureEnabled` which depends on
* the `isResponsiveCaptureSupported` property.
*/
func configure(config: CameraOutputConfiguration)
}
Loading