Skip to content
Closed
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
75 changes: 75 additions & 0 deletions ios/.swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentConditionalCompilationBlocks" : true,
"indentSwitchCaseLabels" : false,
"indentation" : {
"spaces" : 2
},
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : false,
"lineBreakBeforeEachGenericRequirement" : false,
"lineBreakBetweenDeclarationAttributes" : false,
"lineLength" : 120,
"maximumBlankLines" : 1,
"multiElementCollectionTrailingCommas" : true,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow"
]
},
"prioritizeKeepingFunctionOutputTogether" : false,
"reflowMultilineStringLiterals" : "never",
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : true,
"AmbiguousTrailingClosureOverload" : true,
"AvoidRetroactiveConformances" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyLinesOpeningClosingBraces" : false,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoPlaygroundLiterals" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : false,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"TypeNamesShouldBeCapitalized" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : true,
"UseLetInEveryBoundCaseVariable" : true,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : true,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
},
"spacesAroundRangeFormationOperators" : false,
"spacesBeforeEndOfLineComments" : 2,
"tabWidth" : 4,
"version" : 1
}
1 change: 1 addition & 0 deletions ios/.swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.9
152 changes: 77 additions & 75 deletions ios/AudioUtils.swift
Original file line number Diff line number Diff line change
@@ -1,84 +1,86 @@
import AVFoundation

public class AudioUtils {
public static func audioSessionModeFromString(_ mode: String) -> AVAudioSession.Mode {
let retMode: AVAudioSession.Mode = switch mode {
case "default_":
.default
case "voicePrompt":
if #available(iOS 12.0, *) {
.voicePrompt
} else {
.default
}
case "videoRecording":
.videoRecording
case "videoChat":
.videoChat
case "voiceChat":
.voiceChat
case "gameChat":
.gameChat
case "measurement":
.measurement
case "moviePlayback":
.moviePlayback
case "spokenAudio":
.spokenAudio
default:
.default
public static func audioSessionModeFromString(_ mode: String) -> AVAudioSession.Mode {
let retMode: AVAudioSession.Mode =
switch mode {
case "default_":
.default
case "voicePrompt":
if #available(iOS 12.0, *) {
.voicePrompt
} else {
.default
}
return retMode
}
case "videoRecording":
.videoRecording
case "videoChat":
.videoChat
case "voiceChat":
.voiceChat
case "gameChat":
.gameChat
case "measurement":
.measurement
case "moviePlayback":
.moviePlayback
case "spokenAudio":
.spokenAudio
default:
.default
}
return retMode
}

public static func audioSessionCategoryFromString(_ category: String) -> AVAudioSession.Category {
let retCategory: AVAudioSession.Category = switch category {
case "ambient":
.ambient
case "soloAmbient":
.soloAmbient
case "playback":
.playback
case "record":
.record
case "playAndRecord":
.playAndRecord
case "multiRoute":
.multiRoute
default:
.soloAmbient
}
return retCategory
}
public static func audioSessionCategoryFromString(_ category: String) -> AVAudioSession.Category {
let retCategory: AVAudioSession.Category =
switch category {
case "ambient":
.ambient
case "soloAmbient":
.soloAmbient
case "playback":
.playback
case "record":
.record
case "playAndRecord":
.playAndRecord
case "multiRoute":
.multiRoute
default:
.soloAmbient
}
return retCategory
}

public static func audioSessionCategoryOptionsFromStrings(_ options: [String]) -> AVAudioSession.CategoryOptions {
var categoryOptions: AVAudioSession.CategoryOptions = []
for option in options {
switch option {
case "mixWithOthers":
categoryOptions.insert(.mixWithOthers)
case "duckOthers":
categoryOptions.insert(.duckOthers)
case "allowBluetooth":
categoryOptions.insert(.allowBluetooth)
case "allowBluetoothA2DP":
categoryOptions.insert(.allowBluetoothA2DP)
case "allowAirPlay":
categoryOptions.insert(.allowAirPlay)
case "defaultToSpeaker":
categoryOptions.insert(.defaultToSpeaker)
case "interruptSpokenAudioAndMixWithOthers":
if #available(iOS 13.0, *) {
categoryOptions.insert(.interruptSpokenAudioAndMixWithOthers)
}
case "overrideMutedMicrophoneInterruption":
if #available(iOS 14.5, *) {
categoryOptions.insert(.overrideMutedMicrophoneInterruption)
}
default:
break
}
public static func audioSessionCategoryOptionsFromStrings(_ options: [String]) -> AVAudioSession.CategoryOptions {
var categoryOptions: AVAudioSession.CategoryOptions = []
for option in options {
switch option {
case "mixWithOthers":
categoryOptions.insert(.mixWithOthers)
case "duckOthers":
categoryOptions.insert(.duckOthers)
case "allowBluetooth":
categoryOptions.insert(.allowBluetooth)
case "allowBluetoothA2DP":
categoryOptions.insert(.allowBluetoothA2DP)
case "allowAirPlay":
categoryOptions.insert(.allowAirPlay)
case "defaultToSpeaker":
categoryOptions.insert(.defaultToSpeaker)
case "interruptSpokenAudioAndMixWithOthers":
if #available(iOS 13.0, *) {
categoryOptions.insert(.interruptSpokenAudioAndMixWithOthers)
}
case "overrideMutedMicrophoneInterruption":
if #available(iOS 14.5, *) {
categoryOptions.insert(.overrideMutedMicrophoneInterruption)
}
return categoryOptions
default:
break
}
}
return categoryOptions
}
}
Loading
Loading