diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index 7335d9f..0000000 --- a/Package.resolved +++ /dev/null @@ -1,25 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "YbridOgg", - "repositoryURL": "https://github.com/ybrid/ogg-swift.git", - "state": { - "branch": null, - "revision": "bed9003d0d014f6237aed3de3a3cf5693ce91e18", - "version": "0.8.0" - } - }, - { - "package": "YbridOpus", - "repositoryURL": "https://github.com/ybrid/opus-swift.git", - "state": { - "branch": null, - "revision": "92e76803ce7efc8e8903433cfd5f7f68938534ba", - "version": "0.8.0" - } - } - ] - }, - "version": 1 -} diff --git a/Package.swift b/Package.swift index 304ce64..d4fa109 100644 --- a/Package.swift +++ b/Package.swift @@ -12,14 +12,16 @@ let package = Package( dependencies: [ .package( name: "YbridOpus", - url: "https://github.com/ybrid/opus-swift.git", - from: "0.8.0"), + url: "https://github.com/vector-im/opus-swift", + from: "0.8.4"), .package( name: "YbridOgg", - url: "https://github.com/ybrid/ogg-swift.git", - from: "0.8.0") + url: "https://github.com/vector-im/ogg-swift.git", + from: "0.8.3") ], targets: [ + // To debug with a local framework +// .binaryTarget(name: "YbridOpus", path: "YbridOpus.xcframework"), .target(name: "Copustools", path: "Sources/SupportingFiles/Dependencies/Copustools"), .target(name: "SwiftOGG", dependencies: ["YbridOpus", "YbridOgg", "Copustools"], path: "Sources/SwiftOGG"), .testTarget(name: "EncoderDecoderTests", dependencies: ["SwiftOGG"], resources: [.process("Resources")]), diff --git a/README.md b/README.md index 65da4ea..8eef638 100644 --- a/README.md +++ b/README.md @@ -20,5 +20,5 @@ Apple's recording and playback APIs from `AVFoundation` can then be used quite s # Licence Portions of the swift-ogg library contain code derived from [watson-developer-cloud/swift-sdk](https://github.com/watson-developer-cloud/swift-sdk) under the Apache License 2.0 -This project makes use of [opus-swift](https://github.com/ybrid/opus-swift) and [ogg-swift](https://github.com/ybrid/ogg-swift) which package the source code of libopus and libogg as platform independend XCFrameworks. +This project makes use of [opus-swift](https://github.com/vector-im/opus-swift) and [ogg-swift](https://github.com/vector-im/ogg-swift.git) which package the source code of libopus and libogg as platform independent XCFrameworks. These two projects are under the MIT licence while the underlying libopus and libogg library source themselves are included under the BSD Licence described [here](https://opus-codec.org/license/) diff --git a/Sample.xcworkspace/contents.xcworkspacedata b/Sample.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..eaf4d19 --- /dev/null +++ b/Sample.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Sample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Sample.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/Sample.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/Sample.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/Sample.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Sample.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..23dbfd8 --- /dev/null +++ b/Sample.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,25 @@ +{ + "object": { + "pins": [ + { + "package": "YbridOgg", + "repositoryURL": "https://github.com/vector-im/ogg-swift.git", + "state": { + "branch": null, + "revision": "9d82ed838404f10b607a1a1689f404563e9115c3", + "version": "0.8.3" + } + }, + { + "package": "YbridOpus", + "repositoryURL": "https://github.com/vector-im/opus-swift", + "state": { + "branch": null, + "revision": "11f1887767cbc87c4b64b789ee830b779cc744cb", + "version": "0.8.4" + } + } + ] + }, + "version": 1 +} diff --git a/Sample/Sample.xcodeproj/project.pbxproj b/Sample/Sample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..1084da1 --- /dev/null +++ b/Sample/Sample.xcodeproj/project.pbxproj @@ -0,0 +1,372 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + 662D638928801045008825E9 /* SampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 662D636128801042008825E9 /* SampleApp.swift */; }; + 662D638B28801045008825E9 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 662D636228801042008825E9 /* ContentView.swift */; }; + 662D638D28801045008825E9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 662D636328801044008825E9 /* Assets.xcassets */; }; + 662D639E28801092008825E9 /* VoiceRecordingWeb.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 662D639D28801091008825E9 /* VoiceRecordingWeb.m4a */; }; + 66D38E6D2880484900B422AC /* SwiftOGG in Frameworks */ = {isa = PBXBuildFile; productRef = 66D38E6C2880484900B422AC /* SwiftOGG */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 662D636128801042008825E9 /* SampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleApp.swift; sourceTree = ""; }; + 662D636228801042008825E9 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 662D636328801044008825E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 662D636828801044008825E9 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 662D637028801044008825E9 /* macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = macOS.entitlements; sourceTree = ""; }; + 662D639D28801091008825E9 /* VoiceRecordingWeb.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; name = VoiceRecordingWeb.m4a; path = ../Tests/EncoderDecoderTests/Resources/VoiceRecordingWeb.m4a; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 662D636528801044008825E9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 66D38E6D2880484900B422AC /* SwiftOGG in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 662D635B28801042008825E9 = { + isa = PBXGroup; + children = ( + 66D38E65288011FA00B422AC /* Packages */, + 662D639D28801091008825E9 /* VoiceRecordingWeb.m4a */, + 662D636028801042008825E9 /* Shared */, + 662D636F28801044008825E9 /* macOS */, + 662D636928801044008825E9 /* Products */, + 66D38E63288011DA00B422AC /* Frameworks */, + ); + sourceTree = ""; + }; + 662D636028801042008825E9 /* Shared */ = { + isa = PBXGroup; + children = ( + 662D636128801042008825E9 /* SampleApp.swift */, + 662D636228801042008825E9 /* ContentView.swift */, + 662D636328801044008825E9 /* Assets.xcassets */, + ); + path = Shared; + sourceTree = ""; + }; + 662D636928801044008825E9 /* Products */ = { + isa = PBXGroup; + children = ( + 662D636828801044008825E9 /* Sample.app */, + ); + name = Products; + sourceTree = ""; + }; + 662D636F28801044008825E9 /* macOS */ = { + isa = PBXGroup; + children = ( + 662D637028801044008825E9 /* macOS.entitlements */, + ); + path = macOS; + sourceTree = ""; + }; + 66D38E63288011DA00B422AC /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; + 66D38E65288011FA00B422AC /* Packages */ = { + isa = PBXGroup; + children = ( + ); + name = Packages; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 662D636728801044008825E9 /* Sample (iOS) */ = { + isa = PBXNativeTarget; + buildConfigurationList = 662D639128801045008825E9 /* Build configuration list for PBXNativeTarget "Sample (iOS)" */; + buildPhases = ( + 662D636428801044008825E9 /* Sources */, + 662D636528801044008825E9 /* Frameworks */, + 662D636628801044008825E9 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Sample (iOS)"; + packageProductDependencies = ( + 66D38E6C2880484900B422AC /* SwiftOGG */, + ); + productName = "Sample (iOS)"; + productReference = 662D636828801044008825E9 /* Sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 662D635C28801042008825E9 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1340; + LastUpgradeCheck = 1340; + TargetAttributes = { + 662D636728801044008825E9 = { + CreatedOnToolsVersion = 13.4.1; + }; + }; + }; + buildConfigurationList = 662D635F28801042008825E9 /* Build configuration list for PBXProject "Sample" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 662D635B28801042008825E9; + productRefGroup = 662D636928801044008825E9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 662D636728801044008825E9 /* Sample (iOS) */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 662D636628801044008825E9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 662D639E28801092008825E9 /* VoiceRecordingWeb.m4a in Resources */, + 662D638D28801045008825E9 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 662D636428801044008825E9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 662D638B28801045008825E9 /* ContentView.swift in Sources */, + 662D638928801045008825E9 /* SampleApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 662D638F28801045008825E9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 662D639028801045008825E9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 662D639228801045008825E9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 7J4U792NQT; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.5; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = vector.im.Sample; + PRODUCT_NAME = Sample; + SDKROOT = iphoneos; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 662D639328801045008825E9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 7J4U792NQT; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.5; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = vector.im.Sample; + PRODUCT_NAME = Sample; + SDKROOT = iphoneos; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 662D635F28801042008825E9 /* Build configuration list for PBXProject "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 662D638F28801045008825E9 /* Debug */, + 662D639028801045008825E9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 662D639128801045008825E9 /* Build configuration list for PBXNativeTarget "Sample (iOS)" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 662D639228801045008825E9 /* Debug */, + 662D639328801045008825E9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 66D38E6C2880484900B422AC /* SwiftOGG */ = { + isa = XCSwiftPackageProductDependency; + productName = SwiftOGG; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 662D635C28801042008825E9 /* Project object */; +} diff --git a/Sample/Shared/Assets.xcassets/AccentColor.colorset/Contents.json b/Sample/Shared/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Sample/Shared/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sample/Shared/Assets.xcassets/AppIcon.appiconset/Contents.json b/Sample/Shared/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..c136eaf --- /dev/null +++ b/Sample/Shared/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,148 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sample/Shared/Assets.xcassets/Contents.json b/Sample/Shared/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sample/Shared/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sample/Shared/ContentView.swift b/Sample/Shared/ContentView.swift new file mode 100644 index 0000000..c470569 --- /dev/null +++ b/Sample/Shared/ContentView.swift @@ -0,0 +1,62 @@ +// +// Copyright 2022 Vector Creations Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import SwiftUI +import SwiftOGG +import AVFoundation + +struct ContentView: View { + var body: some View { + Button("Convert!") { + testConversionRoundTrip() + } + .padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} + +func testConversionRoundTrip() { + let src = Bundle.main.url(forResource: "VoiceRecordingWeb", withExtension: "m4a")! + let originalDuration = getM4aDuration(src: src) + let dest = URL(fileURLWithPath: NSTemporaryDirectory() + "VoiceRecordingWebOut.ogg") + let dest2 = URL(fileURLWithPath: NSTemporaryDirectory() + "VoiceRecordingWebOut.m4a") + + do { + try OGGConverter.convertM4aFileToOpusOGG(src: src, dest: dest) + } catch { + print(false, "Failed to convert from m4a to ogg with error \(error)") + } + + do { + try OGGConverter.convertOpusOGGToM4aFile(src: dest, dest: dest2) + } catch { + print(false, "Failed to convert from ogg to m4a with error \(error)") + } + let roundTripDuration = getM4aDuration(src: dest2) + print("roundTripDuration", originalDuration, roundTripDuration) + +} + +private func getM4aDuration(src: URL) -> Int { + let audioAsset = AVURLAsset(url: src, options: nil) + let duration = audioAsset.duration + return Int(CMTimeGetSeconds(duration)) +} diff --git a/Sample/Shared/SampleApp.swift b/Sample/Shared/SampleApp.swift new file mode 100644 index 0000000..9187545 --- /dev/null +++ b/Sample/Shared/SampleApp.swift @@ -0,0 +1,26 @@ +// +// Copyright 2022 Vector Creations Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import SwiftUI + +@main +struct SampleApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/Sample/macOS/macOS.entitlements b/Sample/macOS/macOS.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/Sample/macOS/macOS.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/Sources/SwiftOgg/OGGDecoder.swift b/Sources/SwiftOgg/OGGDecoder.swift index 77a1529..e4f8f2b 100644 --- a/Sources/SwiftOgg/OGGDecoder.swift +++ b/Sources/SwiftOgg/OGGDecoder.swift @@ -64,7 +64,12 @@ class OGGDecoder { // initialize ogg sync state ogg_sync_init(&syncState) var processedByteCount = 0 - + + // deallocate pcmDataBuffer when the function ends, regardless if the function ended normally or with an error. + defer { + pcmDataBuffer.deallocate() + } + while processedByteCount < audioData.count { // determine the size of the buffer to ask for var bufferSize: Int @@ -173,10 +178,6 @@ class OGGDecoder { let capacity = MemoryLayout.stride * Int(MAX_FRAME_SIZE) * Int(numChannels) pcmDataBuffer = UnsafeMutablePointer.allocate(capacity: capacity) - // deallocate pcmDataBuffer when the function ends, regardless if the function ended normally or with an error. - defer { - pcmDataBuffer.deallocate() - } } else if packetCount == 1 { hasTagsPacket = true