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 @@ -34,7 +34,7 @@ final class HybridCameraSession: HybridCameraSessionSpec {
}

// pragma MARK: Configuration
func configure(connections: [CameraSessionConnection], config: CameraSessionConfiguration?)
func configure(connections: [CameraSessionConnection], config: CameraSessionConfiguration)
-> Promise<[any HybridCameraControllerSpec]>
{
return Promise.parallel(Self.queue) {
Expand Down Expand Up @@ -90,19 +90,8 @@ final class HybridCameraSession: HybridCameraSessionSpec {
}
self.session.automaticallyConfiguresCaptureDeviceForWideColor = !hasCustomDynamicRangeConstraint

// Haptics and System Sounds Playback
if let allowHapticsAndSystemSoundsPlayback = config?.allowHapticsAndSystemSoundsPlayback {
let audioSession = AVAudioSession.sharedInstance()
if audioSession.allowHapticsAndSystemSoundsDuringRecording != allowHapticsAndSystemSoundsPlayback {
try audioSession.setAllowHapticsAndSystemSoundsDuringRecording(allowHapticsAndSystemSoundsPlayback)
}
}
// Background Audio Playback
if #available(iOS 18.0, *) {
if let allowBackgroundAudioPlayback = config?.allowBackgroundAudioPlayback {
self.session.configuresApplicationAudioSessionToMixWithOthers = allowBackgroundAudioPlayback
}
}
// Audio Session configuration
try self.configureAudioSession(config: config)

// Return CameraControllers per connection to adjust camera settings (focus, etc)
return try connections.map { connection in
Expand Down Expand Up @@ -207,6 +196,32 @@ final class HybridCameraSession: HybridCameraSessionSpec {
}
}
}

private func configureAudioSession(config: CameraSessionConfiguration) throws {
switch config.audioConfiguration {
case .first(let automaticConfig):
// Automatic
self.session.automaticallyConfiguresApplicationAudioSession = true
if #available(iOS 18.0, *) {
if self.session.configuresApplicationAudioSessionToMixWithOthers != automaticConfig.allowBackgroundAudioPlayback {
self.session.configuresApplicationAudioSessionToMixWithOthers = automaticConfig.allowBackgroundAudioPlayback
}
}
case .second(let manualConfig):
// Manual
self.session.automaticallyConfiguresApplicationAudioSession = false
let audioSession = AVAudioSession.sharedInstance()
let category: AVAudioSession.Category = manualConfig.allowBackgroundAudioPlayback ? .playAndRecord : .record
try audioSession.setCategory(category,
mode: .videoRecording,
options: [.allowAirPlay])
if audioSession.allowHapticsAndSystemSoundsDuringRecording != manualConfig.allowHapticsAndSystemSoundsPlayback {
try audioSession.setAllowHapticsAndSystemSoundsDuringRecording(manualConfig.allowHapticsAndSystemSoundsPlayback)
}
case .none:
// No config set
}
}

// pragma MARK: Start/Stop
func start() -> Promise<Void> {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading