├── .gitignore ├── AudioUnit通话 ├── RecordAndPlay.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── RecordAndPlay │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── SKYAudioUnitManager.h │ ├── SKYAudioUnitManager.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── RecordAndPlayTests │ ├── Info.plist │ └── RecordAndPlayTests.m └── RecordAndPlayUITests │ ├── Info.plist │ └── RecordAndPlayUITests.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 77130A8F1FC7BFF100CD3B36 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 77130A8E1FC7BFF100CD3B36 /* AppDelegate.m */; }; 11 | 77130A921FC7BFF100CD3B36 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77130A911FC7BFF100CD3B36 /* ViewController.m */; }; 12 | 77130A951FC7BFF100CD3B36 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77130A931FC7BFF100CD3B36 /* Main.storyboard */; }; 13 | 77130A971FC7BFF100CD3B36 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77130A961FC7BFF100CD3B36 /* Assets.xcassets */; }; 14 | 77130A9A1FC7BFF100CD3B36 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77130A981FC7BFF100CD3B36 /* LaunchScreen.storyboard */; }; 15 | 77130A9D1FC7BFF100CD3B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 77130A9C1FC7BFF100CD3B36 /* main.m */; }; 16 | 77130AA71FC7BFF100CD3B36 /* RecordAndPlayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 77130AA61FC7BFF100CD3B36 /* RecordAndPlayTests.m */; }; 17 | 77130AB21FC7BFF100CD3B36 /* RecordAndPlayUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 77130AB11FC7BFF100CD3B36 /* RecordAndPlayUITests.m */; }; 18 | 77130AC11FC7C85300CD3B36 /* SKYAudioUnitManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 77130AC01FC7C85300CD3B36 /* SKYAudioUnitManager.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 77130AA31FC7BFF100CD3B36 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 77130A821FC7BFF100CD3B36 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 77130A891FC7BFF100CD3B36; 27 | remoteInfo = RecordAndPlay; 28 | }; 29 | 77130AAE1FC7BFF100CD3B36 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 77130A821FC7BFF100CD3B36 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 77130A891FC7BFF100CD3B36; 34 | remoteInfo = RecordAndPlay; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 77130A8A1FC7BFF100CD3B36 /* RecordAndPlay.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RecordAndPlay.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 77130A8D1FC7BFF100CD3B36 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 41 | 77130A8E1FC7BFF100CD3B36 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 42 | 77130A901FC7BFF100CD3B36 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 43 | 77130A911FC7BFF100CD3B36 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 44 | 77130A941FC7BFF100CD3B36 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 77130A961FC7BFF100CD3B36 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 77130A991FC7BFF100CD3B36 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | 77130A9B1FC7BFF100CD3B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 77130A9C1FC7BFF100CD3B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 49 | 77130AA21FC7BFF100CD3B36 /* RecordAndPlayTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RecordAndPlayTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 77130AA61FC7BFF100CD3B36 /* RecordAndPlayTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RecordAndPlayTests.m; sourceTree = ""; }; 51 | 77130AA81FC7BFF100CD3B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 77130AAD1FC7BFF100CD3B36 /* RecordAndPlayUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RecordAndPlayUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 77130AB11FC7BFF100CD3B36 /* RecordAndPlayUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RecordAndPlayUITests.m; sourceTree = ""; }; 54 | 77130AB31FC7BFF100CD3B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 77130ABF1FC7C85300CD3B36 /* SKYAudioUnitManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SKYAudioUnitManager.h; sourceTree = ""; }; 56 | 77130AC01FC7C85300CD3B36 /* SKYAudioUnitManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SKYAudioUnitManager.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 77130A871FC7BFF100CD3B36 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 77130A9F1FC7BFF100CD3B36 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 77130AAA1FC7BFF100CD3B36 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 77130A811FC7BFF100CD3B36 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 77130A8C1FC7BFF100CD3B36 /* RecordAndPlay */, 88 | 77130AA51FC7BFF100CD3B36 /* RecordAndPlayTests */, 89 | 77130AB01FC7BFF100CD3B36 /* RecordAndPlayUITests */, 90 | 77130A8B1FC7BFF100CD3B36 /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 77130A8B1FC7BFF100CD3B36 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 77130A8A1FC7BFF100CD3B36 /* RecordAndPlay.app */, 98 | 77130AA21FC7BFF100CD3B36 /* RecordAndPlayTests.xctest */, 99 | 77130AAD1FC7BFF100CD3B36 /* RecordAndPlayUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 77130A8C1FC7BFF100CD3B36 /* RecordAndPlay */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 77130A8D1FC7BFF100CD3B36 /* AppDelegate.h */, 108 | 77130A8E1FC7BFF100CD3B36 /* AppDelegate.m */, 109 | 77130A901FC7BFF100CD3B36 /* ViewController.h */, 110 | 77130A911FC7BFF100CD3B36 /* ViewController.m */, 111 | 77130ABF1FC7C85300CD3B36 /* SKYAudioUnitManager.h */, 112 | 77130AC01FC7C85300CD3B36 /* SKYAudioUnitManager.m */, 113 | 77130A931FC7BFF100CD3B36 /* Main.storyboard */, 114 | 77130A961FC7BFF100CD3B36 /* Assets.xcassets */, 115 | 77130A981FC7BFF100CD3B36 /* LaunchScreen.storyboard */, 116 | 77130A9B1FC7BFF100CD3B36 /* Info.plist */, 117 | 77130A9C1FC7BFF100CD3B36 /* main.m */, 118 | ); 119 | path = RecordAndPlay; 120 | sourceTree = ""; 121 | }; 122 | 77130AA51FC7BFF100CD3B36 /* RecordAndPlayTests */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 77130AA61FC7BFF100CD3B36 /* RecordAndPlayTests.m */, 126 | 77130AA81FC7BFF100CD3B36 /* Info.plist */, 127 | ); 128 | path = RecordAndPlayTests; 129 | sourceTree = ""; 130 | }; 131 | 77130AB01FC7BFF100CD3B36 /* RecordAndPlayUITests */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 77130AB11FC7BFF100CD3B36 /* RecordAndPlayUITests.m */, 135 | 77130AB31FC7BFF100CD3B36 /* Info.plist */, 136 | ); 137 | path = RecordAndPlayUITests; 138 | sourceTree = ""; 139 | }; 140 | /* End PBXGroup section */ 141 | 142 | /* Begin PBXNativeTarget section */ 143 | 77130A891FC7BFF100CD3B36 /* RecordAndPlay */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = 77130AB61FC7BFF100CD3B36 /* Build configuration list for PBXNativeTarget "RecordAndPlay" */; 146 | buildPhases = ( 147 | 77130A861FC7BFF100CD3B36 /* Sources */, 148 | 77130A871FC7BFF100CD3B36 /* Frameworks */, 149 | 77130A881FC7BFF100CD3B36 /* Resources */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = RecordAndPlay; 156 | productName = RecordAndPlay; 157 | productReference = 77130A8A1FC7BFF100CD3B36 /* RecordAndPlay.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | 77130AA11FC7BFF100CD3B36 /* RecordAndPlayTests */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = 77130AB91FC7BFF100CD3B36 /* Build configuration list for PBXNativeTarget "RecordAndPlayTests" */; 163 | buildPhases = ( 164 | 77130A9E1FC7BFF100CD3B36 /* Sources */, 165 | 77130A9F1FC7BFF100CD3B36 /* Frameworks */, 166 | 77130AA01FC7BFF100CD3B36 /* Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | 77130AA41FC7BFF100CD3B36 /* PBXTargetDependency */, 172 | ); 173 | name = RecordAndPlayTests; 174 | productName = RecordAndPlayTests; 175 | productReference = 77130AA21FC7BFF100CD3B36 /* RecordAndPlayTests.xctest */; 176 | productType = "com.apple.product-type.bundle.unit-test"; 177 | }; 178 | 77130AAC1FC7BFF100CD3B36 /* RecordAndPlayUITests */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = 77130ABC1FC7BFF100CD3B36 /* Build configuration list for PBXNativeTarget "RecordAndPlayUITests" */; 181 | buildPhases = ( 182 | 77130AA91FC7BFF100CD3B36 /* Sources */, 183 | 77130AAA1FC7BFF100CD3B36 /* Frameworks */, 184 | 77130AAB1FC7BFF100CD3B36 /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | 77130AAF1FC7BFF100CD3B36 /* PBXTargetDependency */, 190 | ); 191 | name = RecordAndPlayUITests; 192 | productName = RecordAndPlayUITests; 193 | productReference = 77130AAD1FC7BFF100CD3B36 /* RecordAndPlayUITests.xctest */; 194 | productType = "com.apple.product-type.bundle.ui-testing"; 195 | }; 196 | /* End PBXNativeTarget section */ 197 | 198 | /* Begin PBXProject section */ 199 | 77130A821FC7BFF100CD3B36 /* Project object */ = { 200 | isa = PBXProject; 201 | attributes = { 202 | LastUpgradeCheck = 0910; 203 | ORGANIZATIONNAME = Topsky; 204 | TargetAttributes = { 205 | 77130A891FC7BFF100CD3B36 = { 206 | CreatedOnToolsVersion = 9.1; 207 | ProvisioningStyle = Automatic; 208 | SystemCapabilities = { 209 | com.apple.BackgroundModes = { 210 | enabled = 1; 211 | }; 212 | }; 213 | }; 214 | 77130AA11FC7BFF100CD3B36 = { 215 | CreatedOnToolsVersion = 9.1; 216 | ProvisioningStyle = Automatic; 217 | TestTargetID = 77130A891FC7BFF100CD3B36; 218 | }; 219 | 77130AAC1FC7BFF100CD3B36 = { 220 | CreatedOnToolsVersion = 9.1; 221 | ProvisioningStyle = Automatic; 222 | TestTargetID = 77130A891FC7BFF100CD3B36; 223 | }; 224 | }; 225 | }; 226 | buildConfigurationList = 77130A851FC7BFF100CD3B36 /* Build configuration list for PBXProject "RecordAndPlay" */; 227 | compatibilityVersion = "Xcode 8.0"; 228 | developmentRegion = en; 229 | hasScannedForEncodings = 0; 230 | knownRegions = ( 231 | en, 232 | Base, 233 | ); 234 | mainGroup = 77130A811FC7BFF100CD3B36; 235 | productRefGroup = 77130A8B1FC7BFF100CD3B36 /* Products */; 236 | projectDirPath = ""; 237 | projectRoot = ""; 238 | targets = ( 239 | 77130A891FC7BFF100CD3B36 /* RecordAndPlay */, 240 | 77130AA11FC7BFF100CD3B36 /* RecordAndPlayTests */, 241 | 77130AAC1FC7BFF100CD3B36 /* RecordAndPlayUITests */, 242 | ); 243 | }; 244 | /* End PBXProject section */ 245 | 246 | /* Begin PBXResourcesBuildPhase section */ 247 | 77130A881FC7BFF100CD3B36 /* Resources */ = { 248 | isa = PBXResourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | 77130A9A1FC7BFF100CD3B36 /* LaunchScreen.storyboard in Resources */, 252 | 77130A971FC7BFF100CD3B36 /* Assets.xcassets in Resources */, 253 | 77130A951FC7BFF100CD3B36 /* Main.storyboard in Resources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | 77130AA01FC7BFF100CD3B36 /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | runOnlyForDeploymentPostprocessing = 0; 263 | }; 264 | 77130AAB1FC7BFF100CD3B36 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | /* End PBXResourcesBuildPhase section */ 272 | 273 | /* Begin PBXSourcesBuildPhase section */ 274 | 77130A861FC7BFF100CD3B36 /* Sources */ = { 275 | isa = PBXSourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | 77130AC11FC7C85300CD3B36 /* SKYAudioUnitManager.m in Sources */, 279 | 77130A921FC7BFF100CD3B36 /* ViewController.m in Sources */, 280 | 77130A9D1FC7BFF100CD3B36 /* main.m in Sources */, 281 | 77130A8F1FC7BFF100CD3B36 /* AppDelegate.m in Sources */, 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | 77130A9E1FC7BFF100CD3B36 /* Sources */ = { 286 | isa = PBXSourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | 77130AA71FC7BFF100CD3B36 /* RecordAndPlayTests.m in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | 77130AA91FC7BFF100CD3B36 /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 77130AB21FC7BFF100CD3B36 /* RecordAndPlayUITests.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXTargetDependency section */ 304 | 77130AA41FC7BFF100CD3B36 /* PBXTargetDependency */ = { 305 | isa = PBXTargetDependency; 306 | target = 77130A891FC7BFF100CD3B36 /* RecordAndPlay */; 307 | targetProxy = 77130AA31FC7BFF100CD3B36 /* PBXContainerItemProxy */; 308 | }; 309 | 77130AAF1FC7BFF100CD3B36 /* PBXTargetDependency */ = { 310 | isa = PBXTargetDependency; 311 | target = 77130A891FC7BFF100CD3B36 /* RecordAndPlay */; 312 | targetProxy = 77130AAE1FC7BFF100CD3B36 /* PBXContainerItemProxy */; 313 | }; 314 | /* End PBXTargetDependency section */ 315 | 316 | /* Begin PBXVariantGroup section */ 317 | 77130A931FC7BFF100CD3B36 /* Main.storyboard */ = { 318 | isa = PBXVariantGroup; 319 | children = ( 320 | 77130A941FC7BFF100CD3B36 /* Base */, 321 | ); 322 | name = Main.storyboard; 323 | sourceTree = ""; 324 | }; 325 | 77130A981FC7BFF100CD3B36 /* LaunchScreen.storyboard */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | 77130A991FC7BFF100CD3B36 /* Base */, 329 | ); 330 | name = LaunchScreen.storyboard; 331 | sourceTree = ""; 332 | }; 333 | /* End PBXVariantGroup section */ 334 | 335 | /* Begin XCBuildConfiguration section */ 336 | 77130AB41FC7BFF100CD3B36 /* Debug */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ALWAYS_SEARCH_USER_PATHS = NO; 340 | CLANG_ANALYZER_NONNULL = YES; 341 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 342 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 343 | CLANG_CXX_LIBRARY = "libc++"; 344 | CLANG_ENABLE_MODULES = YES; 345 | CLANG_ENABLE_OBJC_ARC = YES; 346 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 347 | CLANG_WARN_BOOL_CONVERSION = YES; 348 | CLANG_WARN_COMMA = YES; 349 | CLANG_WARN_CONSTANT_CONVERSION = YES; 350 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 351 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 352 | CLANG_WARN_EMPTY_BODY = YES; 353 | CLANG_WARN_ENUM_CONVERSION = YES; 354 | CLANG_WARN_INFINITE_RECURSION = YES; 355 | CLANG_WARN_INT_CONVERSION = YES; 356 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 357 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 358 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 359 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 360 | CLANG_WARN_STRICT_PROTOTYPES = YES; 361 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 362 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | CODE_SIGN_IDENTITY = "iPhone Developer"; 366 | COPY_PHASE_STRIP = NO; 367 | DEBUG_INFORMATION_FORMAT = dwarf; 368 | ENABLE_STRICT_OBJC_MSGSEND = YES; 369 | ENABLE_TESTABILITY = YES; 370 | GCC_C_LANGUAGE_STANDARD = gnu11; 371 | GCC_DYNAMIC_NO_PIC = NO; 372 | GCC_NO_COMMON_BLOCKS = YES; 373 | GCC_OPTIMIZATION_LEVEL = 0; 374 | GCC_PREPROCESSOR_DEFINITIONS = ( 375 | "DEBUG=1", 376 | "$(inherited)", 377 | ); 378 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 379 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 380 | GCC_WARN_UNDECLARED_SELECTOR = YES; 381 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 382 | GCC_WARN_UNUSED_FUNCTION = YES; 383 | GCC_WARN_UNUSED_VARIABLE = YES; 384 | IPHONEOS_DEPLOYMENT_TARGET = 11.1; 385 | MTL_ENABLE_DEBUG_INFO = YES; 386 | ONLY_ACTIVE_ARCH = YES; 387 | SDKROOT = iphoneos; 388 | }; 389 | name = Debug; 390 | }; 391 | 77130AB51FC7BFF100CD3B36 /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ALWAYS_SEARCH_USER_PATHS = NO; 395 | CLANG_ANALYZER_NONNULL = YES; 396 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 397 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 398 | CLANG_CXX_LIBRARY = "libc++"; 399 | CLANG_ENABLE_MODULES = YES; 400 | CLANG_ENABLE_OBJC_ARC = YES; 401 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 402 | CLANG_WARN_BOOL_CONVERSION = YES; 403 | CLANG_WARN_COMMA = YES; 404 | CLANG_WARN_CONSTANT_CONVERSION = YES; 405 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 406 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 407 | CLANG_WARN_EMPTY_BODY = YES; 408 | CLANG_WARN_ENUM_CONVERSION = YES; 409 | CLANG_WARN_INFINITE_RECURSION = YES; 410 | CLANG_WARN_INT_CONVERSION = YES; 411 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 412 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 413 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 414 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 415 | CLANG_WARN_STRICT_PROTOTYPES = YES; 416 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 417 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 418 | CLANG_WARN_UNREACHABLE_CODE = YES; 419 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 420 | CODE_SIGN_IDENTITY = "iPhone Developer"; 421 | COPY_PHASE_STRIP = NO; 422 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 423 | ENABLE_NS_ASSERTIONS = NO; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | GCC_C_LANGUAGE_STANDARD = gnu11; 426 | GCC_NO_COMMON_BLOCKS = YES; 427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 429 | GCC_WARN_UNDECLARED_SELECTOR = YES; 430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 431 | GCC_WARN_UNUSED_FUNCTION = YES; 432 | GCC_WARN_UNUSED_VARIABLE = YES; 433 | IPHONEOS_DEPLOYMENT_TARGET = 11.1; 434 | MTL_ENABLE_DEBUG_INFO = NO; 435 | SDKROOT = iphoneos; 436 | VALIDATE_PRODUCT = YES; 437 | }; 438 | name = Release; 439 | }; 440 | 77130AB71FC7BFF100CD3B36 /* Debug */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | CODE_SIGN_STYLE = Automatic; 445 | DEVELOPMENT_TEAM = C5BS2BPRLK; 446 | INFOPLIST_FILE = RecordAndPlay/Info.plist; 447 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 448 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 449 | PRODUCT_BUNDLE_IDENTIFIER = com.kunulo.RecordAndPlay; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | TARGETED_DEVICE_FAMILY = "1,2"; 452 | }; 453 | name = Debug; 454 | }; 455 | 77130AB81FC7BFF100CD3B36 /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | buildSettings = { 458 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 459 | CODE_SIGN_STYLE = Automatic; 460 | DEVELOPMENT_TEAM = C5BS2BPRLK; 461 | INFOPLIST_FILE = RecordAndPlay/Info.plist; 462 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 464 | PRODUCT_BUNDLE_IDENTIFIER = com.kunulo.RecordAndPlay; 465 | PRODUCT_NAME = "$(TARGET_NAME)"; 466 | TARGETED_DEVICE_FAMILY = "1,2"; 467 | }; 468 | name = Release; 469 | }; 470 | 77130ABA1FC7BFF100CD3B36 /* Debug */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | BUNDLE_LOADER = "$(TEST_HOST)"; 474 | CODE_SIGN_STYLE = Automatic; 475 | DEVELOPMENT_TEAM = C5BS2BPRLK; 476 | INFOPLIST_FILE = RecordAndPlayTests/Info.plist; 477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 478 | PRODUCT_BUNDLE_IDENTIFIER = com.kunulo.RecordAndPlayTests; 479 | PRODUCT_NAME = "$(TARGET_NAME)"; 480 | TARGETED_DEVICE_FAMILY = "1,2"; 481 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RecordAndPlay.app/RecordAndPlay"; 482 | }; 483 | name = Debug; 484 | }; 485 | 77130ABB1FC7BFF100CD3B36 /* Release */ = { 486 | isa = XCBuildConfiguration; 487 | buildSettings = { 488 | BUNDLE_LOADER = "$(TEST_HOST)"; 489 | CODE_SIGN_STYLE = Automatic; 490 | DEVELOPMENT_TEAM = C5BS2BPRLK; 491 | INFOPLIST_FILE = RecordAndPlayTests/Info.plist; 492 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 493 | PRODUCT_BUNDLE_IDENTIFIER = com.kunulo.RecordAndPlayTests; 494 | PRODUCT_NAME = "$(TARGET_NAME)"; 495 | TARGETED_DEVICE_FAMILY = "1,2"; 496 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RecordAndPlay.app/RecordAndPlay"; 497 | }; 498 | name = Release; 499 | }; 500 | 77130ABD1FC7BFF100CD3B36 /* Debug */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | CODE_SIGN_STYLE = Automatic; 504 | DEVELOPMENT_TEAM = C5BS2BPRLK; 505 | INFOPLIST_FILE = RecordAndPlayUITests/Info.plist; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 507 | PRODUCT_BUNDLE_IDENTIFIER = com.kunulo.RecordAndPlayUITests; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | TARGETED_DEVICE_FAMILY = "1,2"; 510 | TEST_TARGET_NAME = RecordAndPlay; 511 | }; 512 | name = Debug; 513 | }; 514 | 77130ABE1FC7BFF100CD3B36 /* Release */ = { 515 | isa = XCBuildConfiguration; 516 | buildSettings = { 517 | CODE_SIGN_STYLE = Automatic; 518 | DEVELOPMENT_TEAM = C5BS2BPRLK; 519 | INFOPLIST_FILE = RecordAndPlayUITests/Info.plist; 520 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 521 | PRODUCT_BUNDLE_IDENTIFIER = com.kunulo.RecordAndPlayUITests; 522 | PRODUCT_NAME = "$(TARGET_NAME)"; 523 | TARGETED_DEVICE_FAMILY = "1,2"; 524 | TEST_TARGET_NAME = RecordAndPlay; 525 | }; 526 | name = Release; 527 | }; 528 | /* End XCBuildConfiguration section */ 529 | 530 | /* Begin XCConfigurationList section */ 531 | 77130A851FC7BFF100CD3B36 /* Build configuration list for PBXProject "RecordAndPlay" */ = { 532 | isa = XCConfigurationList; 533 | buildConfigurations = ( 534 | 77130AB41FC7BFF100CD3B36 /* Debug */, 535 | 77130AB51FC7BFF100CD3B36 /* Release */, 536 | ); 537 | defaultConfigurationIsVisible = 0; 538 | defaultConfigurationName = Release; 539 | }; 540 | 77130AB61FC7BFF100CD3B36 /* Build configuration list for PBXNativeTarget "RecordAndPlay" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | 77130AB71FC7BFF100CD3B36 /* Debug */, 544 | 77130AB81FC7BFF100CD3B36 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | defaultConfigurationName = Release; 548 | }; 549 | 77130AB91FC7BFF100CD3B36 /* Build configuration list for PBXNativeTarget "RecordAndPlayTests" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | 77130ABA1FC7BFF100CD3B36 /* Debug */, 553 | 77130ABB1FC7BFF100CD3B36 /* Release */, 554 | ); 555 | defaultConfigurationIsVisible = 0; 556 | defaultConfigurationName = Release; 557 | }; 558 | 77130ABC1FC7BFF100CD3B36 /* Build configuration list for PBXNativeTarget "RecordAndPlayUITests" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | 77130ABD1FC7BFF100CD3B36 /* Debug */, 562 | 77130ABE1FC7BFF100CD3B36 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | /* End XCConfigurationList section */ 568 | }; 569 | rootObject = 77130A821FC7BFF100CD3B36 /* Project object */; 570 | } 571 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // RecordAndPlay 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // RecordAndPlay 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 36 | 51 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSMicrophoneUsageDescription 24 | 25 | UIBackgroundModes 26 | 27 | audio 28 | 29 | UIFileSharingEnabled 30 | 31 | UILaunchStoryboardName 32 | LaunchScreen 33 | UIMainStoryboardFile 34 | Main 35 | UIRequiredDeviceCapabilities 36 | 37 | armv7 38 | 39 | UISupportedInterfaceOrientations 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationLandscapeLeft 43 | UIInterfaceOrientationLandscapeRight 44 | 45 | UISupportedInterfaceOrientations~ipad 46 | 47 | UIInterfaceOrientationPortrait 48 | UIInterfaceOrientationPortraitUpsideDown 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/SKYAudioUnitManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKYAudioUnitManager.h 3 | // RecordAndPlay 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SKYAudioUnitManager : NSObject 12 | 13 | + (instancetype)sharedInstance; 14 | - (void)startRecord; //开始录音 15 | - (void)stopRecord; //结束录音 16 | - (void)startPlay; //开始放音 17 | - (void)stopPlay; //结束放音 18 | 19 | - (void)startRecordAndPlay; //开始通话 20 | - (void)stopRecordAndPlay; //结束通话 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/SKYAudioUnitManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKYAudioUnitManager.m 3 | // RecordAndPlay 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import "SKYAudioUnitManager.h" 10 | #import 11 | 12 | #define INPUT_BUS 1 13 | #define OUTPUT_BUS 0 14 | #define kSampleRate 44100 //采样率 15 | 16 | static AudioBufferList recordBufferList; 17 | static AudioUnit _recordAudioUnit; 18 | 19 | //static NSMutableData *recordPcmData; 20 | static NSMutableData *receivePcmData; 21 | 22 | @interface SKYAudioUnitManager () 23 | 24 | @property (assign, nonatomic) BOOL isUnitWorking; 25 | @property (assign, nonatomic) BOOL isRecording; //录音开关状态 26 | @property (assign, nonatomic) BOOL isPlaying; //放音开关状态 27 | 28 | @end 29 | 30 | @implementation SKYAudioUnitManager 31 | 32 | static SKYAudioUnitManager *sharedInstace = nil; 33 | + (instancetype)sharedInstance { 34 | static dispatch_once_t onceToken; 35 | dispatch_once(&onceToken, ^{ 36 | sharedInstace = [[SKYAudioUnitManager alloc] init]; 37 | [sharedInstace initRemoteIO]; 38 | }); 39 | return sharedInstace; 40 | } 41 | 42 | - (void)initRemoteIO { 43 | AudioUnitInitialize(_recordAudioUnit); 44 | [self initBuffer]; 45 | [self initAudioComponent]; 46 | [self initFormat]; 47 | [self initAudioProperty]; 48 | [self initRecordeCallback]; 49 | [self initPlayCallback]; 50 | } 51 | 52 | - (void)initBuffer { 53 | UInt32 flag = 0; 54 | AudioUnitSetProperty(_recordAudioUnit, 55 | kAudioUnitProperty_ShouldAllocateBuffer, 56 | kAudioUnitScope_Output, 57 | INPUT_BUS, 58 | &flag, 59 | sizeof(flag)); 60 | } 61 | 62 | - (void)initAudioComponent { 63 | AudioComponentDescription audioDesc; 64 | audioDesc.componentType = kAudioUnitType_Output; 65 | //audioDesc.componentSubType = kAudioUnitSubType_RemoteIO; 66 | audioDesc.componentSubType = kAudioUnitSubType_VoiceProcessingIO; 67 | audioDesc.componentManufacturer = kAudioUnitManufacturer_Apple; 68 | audioDesc.componentFlags = 0; 69 | audioDesc.componentFlagsMask = 0; 70 | 71 | AudioComponent inputComponent = AudioComponentFindNext(NULL, &audioDesc); 72 | AudioComponentInstanceNew(inputComponent, &_recordAudioUnit); 73 | } 74 | 75 | - (void)initFormat { 76 | AudioStreamBasicDescription audioFormat; 77 | audioFormat.mSampleRate = kSampleRate; 78 | audioFormat.mFormatID = kAudioFormatLinearPCM; 79 | audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; 80 | audioFormat.mFramesPerPacket = 1; 81 | audioFormat.mChannelsPerFrame = 1; 82 | audioFormat.mBitsPerChannel = 16; 83 | audioFormat.mBytesPerPacket = 2; 84 | audioFormat.mBytesPerFrame = 2; 85 | 86 | AudioUnitSetProperty(_recordAudioUnit, 87 | kAudioUnitProperty_StreamFormat, 88 | kAudioUnitScope_Input, 89 | OUTPUT_BUS, 90 | &audioFormat, 91 | sizeof(audioFormat)); 92 | AudioUnitSetProperty(_recordAudioUnit, 93 | kAudioUnitProperty_StreamFormat, 94 | kAudioUnitScope_Output, 95 | INPUT_BUS, 96 | &audioFormat, 97 | sizeof(audioFormat)); 98 | } 99 | 100 | - (void)initAudioProperty { 101 | UInt32 flag = 1; 102 | AudioUnitSetProperty(_recordAudioUnit, 103 | kAudioOutputUnitProperty_EnableIO, 104 | kAudioUnitScope_Input, 105 | INPUT_BUS, 106 | &flag, 107 | sizeof(flag)); 108 | AudioUnitSetProperty(_recordAudioUnit, 109 | kAudioOutputUnitProperty_EnableIO, 110 | kAudioUnitScope_Output, 111 | OUTPUT_BUS, 112 | &flag, 113 | sizeof(flag)); 114 | } 115 | 116 | - (void)initRecordeCallback { 117 | AURenderCallbackStruct recordCallback; 118 | recordCallback.inputProc = RecordCallback; 119 | recordCallback.inputProcRefCon = (__bridge void *)self; 120 | AudioUnitSetProperty(_recordAudioUnit, 121 | kAudioOutputUnitProperty_SetInputCallback, 122 | kAudioUnitScope_Global, 123 | INPUT_BUS, 124 | &recordCallback, 125 | sizeof(recordCallback)); 126 | } 127 | 128 | - (void)initPlayCallback { 129 | AURenderCallbackStruct playCallback; 130 | playCallback.inputProc = PlayCallback; 131 | playCallback.inputProcRefCon = (__bridge void *)self; 132 | AudioUnitSetProperty(_recordAudioUnit, 133 | kAudioUnitProperty_SetRenderCallback, 134 | kAudioUnitScope_Global, 135 | OUTPUT_BUS, 136 | &playCallback, 137 | sizeof(playCallback)); 138 | } 139 | 140 | #pragma mark - callback function 141 | 142 | static OSStatus RecordCallback(void *inRefCon, 143 | AudioUnitRenderActionFlags *ioActionFlags, 144 | const AudioTimeStamp *inTimeStamp, 145 | UInt32 inBusNumber, 146 | UInt32 inNumberFrames, 147 | AudioBufferList *ioData) 148 | { 149 | UInt16 numSamples=inNumberFrames*1; 150 | UInt16 samples[numSamples]; 151 | memset (&samples, 0, sizeof (samples)); 152 | recordBufferList.mNumberBuffers = 1; 153 | recordBufferList.mBuffers[0].mData = samples; 154 | recordBufferList.mBuffers[0].mNumberChannels = 1; 155 | recordBufferList.mBuffers[0].mDataByteSize = numSamples*sizeof(UInt16); 156 | 157 | AudioUnitRender(_recordAudioUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, &recordBufferList); 158 | if (sharedInstace.isRecording) { 159 | NSData *pcmData = [NSData dataWithBytes:recordBufferList.mBuffers[0].mData length:recordBufferList.mBuffers[0].mDataByteSize]; 160 | NSLog(@"recordPcmData.length=====================>%ld",(unsigned long)pcmData.length); 161 | if (pcmData && pcmData.length > 0) { 162 | if (sharedInstace.isPlaying) { 163 | [receivePcmData appendData:pcmData]; 164 | } 165 | } 166 | } 167 | return noErr; 168 | } 169 | 170 | static OSStatus PlayCallback(void *inRefCon, 171 | AudioUnitRenderActionFlags *ioActionFlags, 172 | const AudioTimeStamp *inTimeStamp, 173 | UInt32 inBusNumber, 174 | UInt32 inNumberFrames, 175 | AudioBufferList *ioData) { 176 | UInt32 buffLen = ioData->mBuffers[0].mDataByteSize; 177 | NSLog(@"PlayCallback.length----------------->%d,%ld",buffLen,(unsigned long)receivePcmData.length); 178 | if (receivePcmData.length >= buffLen) { 179 | NSData *data = [receivePcmData subdataWithRange:NSMakeRange(0, buffLen)]; 180 | AudioBuffer inBuffer = ioData->mBuffers[0]; 181 | memcpy(inBuffer.mData, data.bytes, data.length); 182 | inBuffer.mDataByteSize = (UInt32)data.length; 183 | [receivePcmData replaceBytesInRange:NSMakeRange(0, buffLen) withBytes:NULL length:0]; 184 | }else { 185 | NSLog(@"=====================静音:%ld",(unsigned long)receivePcmData.length); 186 | 187 | for (UInt32 i=0; i < ioData->mNumberBuffers; i++) 188 | { 189 | memset(ioData->mBuffers[i].mData, 0, ioData->mBuffers[i].mDataByteSize); 190 | } 191 | } 192 | return noErr; 193 | } 194 | 195 | - (void)initAudioSession { 196 | NSError *error; 197 | [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&error]; 198 | //VoiceProcessingIO有一个属性可用来打开(0)/关闭(1)回声消除功能 199 | UInt32 echoCancellation=0; 200 | AudioUnitSetProperty(_recordAudioUnit, 201 | kAUVoiceIOProperty_BypassVoiceProcessing, 202 | kAudioUnitScope_Global, 203 | 0, 204 | &echoCancellation, 205 | sizeof(echoCancellation)); 206 | 207 | AudioOutputUnitStart(_recordAudioUnit); 208 | self.isUnitWorking = YES; 209 | } 210 | 211 | #pragma mark - public methods 212 | 213 | - (void)startRecord { 214 | NSLog(@"开始录音"); 215 | self.isRecording = YES; 216 | 217 | } 218 | 219 | - (void)stopRecord { 220 | NSLog(@"暂停录音"); 221 | self.isRecording = NO; 222 | } 223 | 224 | - (void)startPlay { 225 | NSLog(@"开始放音"); 226 | self.isPlaying = YES; 227 | } 228 | 229 | - (void)stopPlay { 230 | NSLog(@"暂停放音"); 231 | self.isPlaying = NO; 232 | } 233 | 234 | - (void)startRecordAndPlay { 235 | if (self.isUnitWorking) { 236 | NSLog(@"通话中..."); 237 | return; 238 | } 239 | NSLog(@"开始通话"); 240 | if (receivePcmData) { 241 | receivePcmData = nil; 242 | } 243 | receivePcmData = [NSMutableData data]; 244 | [self startRecord]; 245 | [self startPlay]; 246 | [self initAudioSession]; 247 | } 248 | 249 | - (void)stopRecordAndPlay { 250 | NSLog(@"结束通话"); 251 | AudioOutputUnitStop(_recordAudioUnit); 252 | self.isUnitWorking = NO; 253 | [self stopRecord]; 254 | [self stopPlay]; 255 | } 256 | 257 | - (void)audio_release { 258 | AudioUnitUninitialize(_recordAudioUnit); 259 | } 260 | 261 | //保存录音文件 262 | - (void)saveAudioData:(NSData *)data name:(NSString *)name clearBefore:(BOOL)clear{ 263 | NSString *path=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]stringByAppendingPathComponent:name]; 264 | if (clear == YES) { 265 | if ( YES == [[NSFileManager defaultManager] fileExistsAtPath:path] ){ 266 | [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; 267 | } 268 | }else { 269 | if (NO == [[NSFileManager defaultManager] fileExistsAtPath:path]) { 270 | [[NSFileManager defaultManager] createFileAtPath:path contents:data attributes:nil]; 271 | }else { 272 | NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:path]; 273 | [fileHandle seekToEndOfFile]; //将节点跳到文件的末尾 274 | [fileHandle writeData:data]; //追加写入数据 275 | [fileHandle closeFile]; 276 | } 277 | } 278 | } 279 | 280 | @end 281 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // RecordAndPlay 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // RecordAndPlay 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SKYAudioUnitManager.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (weak, nonatomic) IBOutlet UIButton *callBtn; 15 | @property (weak, nonatomic) IBOutlet UIButton *recordBtn; 16 | @property (weak, nonatomic) IBOutlet UIButton *playBtn; 17 | @property (assign, nonatomic) BOOL isRecording; 18 | @property (assign, nonatomic) BOOL isPlaying; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | _callBtn.layer.cornerRadius = 5; 27 | _recordBtn.layer.cornerRadius = 5; 28 | _playBtn.layer.cornerRadius = 5; 29 | _recordBtn.hidden = YES; 30 | _playBtn.hidden = YES; 31 | } 32 | - (IBAction)clickCallBtn:(UIButton *)sender { 33 | if (sender.tag == 100) { 34 | sender.tag = 101; 35 | [[SKYAudioUnitManager sharedInstance] startRecordAndPlay]; 36 | [sender setTitle:@"结束通话" forState:UIControlStateNormal]; 37 | _recordBtn.hidden = NO; 38 | _playBtn.hidden = NO; 39 | }else { 40 | sender.tag = 100; 41 | [[SKYAudioUnitManager sharedInstance] stopRecordAndPlay]; 42 | [sender setTitle:@"开始通话" forState:UIControlStateNormal]; 43 | _recordBtn.hidden = YES; 44 | _playBtn.hidden = YES; 45 | } 46 | 47 | } 48 | 49 | - (IBAction)clickRecordBtn:(UIButton *)sender { 50 | if (sender.tag == 100) { 51 | sender.tag = 101; 52 | [[SKYAudioUnitManager sharedInstance] stopRecord]; 53 | [sender setTitle:@"开始录音" forState:UIControlStateNormal]; 54 | }else { 55 | sender.tag = 100; 56 | [[SKYAudioUnitManager sharedInstance] startRecord]; 57 | [sender setTitle:@"暂停录音" forState:UIControlStateNormal]; 58 | } 59 | } 60 | 61 | - (IBAction)clickPlayBtn:(UIButton *)sender { 62 | if (sender.tag == 100) { 63 | sender.tag = 101; 64 | [[SKYAudioUnitManager sharedInstance] stopPlay]; 65 | [sender setTitle:@"开始放音" forState:UIControlStateNormal]; 66 | }else { 67 | sender.tag = 100; 68 | [[SKYAudioUnitManager sharedInstance] startPlay]; 69 | [sender setTitle:@"暂停放音" forState:UIControlStateNormal]; 70 | } 71 | } 72 | 73 | - (void)didReceiveMemoryWarning { 74 | [super didReceiveMemoryWarning]; 75 | // Dispose of any resources that can be recreated. 76 | } 77 | 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlay/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RecordAndPlay 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlayTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlayTests/RecordAndPlayTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RecordAndPlayTests.m 3 | // RecordAndPlayTests 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RecordAndPlayTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation RecordAndPlayTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlayUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /AudioUnit通话/RecordAndPlayUITests/RecordAndPlayUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RecordAndPlayUITests.m 3 | // RecordAndPlayUITests 4 | // 5 | // Created by Topsky on 2017/11/24. 6 | // Copyright © 2017年 Topsky. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RecordAndPlayUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation RecordAndPlayUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AudioUnit 2 | 利用AudioUnit实现语音通话,里面包含了回声消除 3 | --------------------------------------------------------------------------------