diff --git a/Cabbage/Sources/Core/Audio/AudioProcessingTapHolder.swift b/Cabbage/Sources/Core/Audio/AudioProcessingTapHolder.swift index ceec1d0..551506d 100644 --- a/Cabbage/Sources/Core/Audio/AudioProcessingTapHolder.swift +++ b/Cabbage/Sources/Core/Audio/AudioProcessingTapHolder.swift @@ -23,13 +23,13 @@ public class AudioProcessingTapHolder: NSObject, NSCopying { prepare: tapPrepare, unprepare: tapUnprepare, process: tapProcess) - var tap: Unmanaged? + // Use the expected type for the Create function: MTAudioProcessingTap? + var tap: MTAudioProcessingTap? let err = MTAudioProcessingTapCreate(kCFAllocatorDefault, &callbacks, kMTAudioProcessingTapCreationFlag_PostEffects, &tap) if err != noErr { Log.error("error: failed to create audioProcessingTap") } - self.tap = tap?.takeRetainedValue() - + self.tap = tap } // MARK: - Handler diff --git a/Cabbage/Sources/Core/CompositionGenerator.swift b/Cabbage/Sources/Core/CompositionGenerator.swift index c5dd944..439cb21 100644 --- a/Cabbage/Sources/Core/CompositionGenerator.swift +++ b/Cabbage/Sources/Core/CompositionGenerator.swift @@ -47,10 +47,10 @@ public class CompositionGenerator { return imageGenerator } - public func buildExportSession(presetName: String) -> AVAssetExportSession? { + public func buildExportSession(presetName: String, animationTool: AVVideoCompositionCoreAnimationTool? = nil) -> AVAssetExportSession? { let composition = buildComposition() let exportSession = AVAssetExportSession.init(asset: composition, presetName: presetName) - exportSession?.videoComposition = buildVideoComposition() + exportSession?.videoComposition = buildVideoComposition(animationTool: animationTool) exportSession?.audioMix = buildAudioMix() exportSession?.outputURL = { let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last! @@ -192,7 +192,7 @@ public class CompositionGenerator { return composition } - public func buildVideoComposition() -> AVVideoComposition? { + public func buildVideoComposition(animationTool: AVVideoCompositionCoreAnimationTool? = nil) -> AVVideoComposition? { if let videoComposition = self.videoComposition, !needRebuildVideoComposition { return videoComposition } @@ -242,6 +242,7 @@ public class CompositionGenerator { videoComposition.renderSize = self.timeline.renderSize videoComposition.instructions = instructions videoComposition.customVideoCompositorClass = VideoCompositor.self + videoComposition.animationTool = animationTool self.videoComposition = videoComposition self.needRebuildVideoComposition = false return videoComposition diff --git a/Cabbage/Sources/Track/Resource/Resource.swift b/Cabbage/Sources/Track/Resource/Resource.swift index 326c25f..c4f29c5 100644 --- a/Cabbage/Sources/Track/Resource/Resource.swift +++ b/Cabbage/Sources/Track/Resource/Resource.swift @@ -13,6 +13,12 @@ public struct ResourceTrackInfo { public var track: AVAssetTrack public var selectedTimeRange: CMTimeRange public var scaleToDuration: CMTime + + public init(track: AVAssetTrack, selectedTimeRange: CMTimeRange, scaleToDuration: CMTime) { + self.track = track + self.selectedTimeRange = selectedTimeRange + self.scaleToDuration = scaleToDuration + } } @@ -99,7 +105,7 @@ open class Resource: NSObject, NSCopying, ResourceTrackInfoProvider { // MARK: - ResourceTrackInfoProvider - public func trackInfo(for type: AVMediaType, at index: Int) -> ResourceTrackInfo { + open func trackInfo(for type: AVMediaType, at index: Int) -> ResourceTrackInfo { let track = tracks(for: type)[index] let emptyDuration = CMTime(value: 1, 30) let emptyTimeRange = CMTimeRangeMake(start: CMTime.zero, duration: emptyDuration) diff --git a/Package.swift b/Package.swift index 14d0e28..a351f51 100644 --- a/Package.swift +++ b/Package.swift @@ -4,12 +4,12 @@ import PackageDescription let package = Package( - name: "Cabbage", + name: "SCCabbage", products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( - name: "Cabbage", - targets: ["Cabbage"]), + name: "SCCabbage", + targets: ["SCCabbage"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -19,18 +19,8 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( - name: "Cabbage", - dependencies: [], - linkerSettings: [ - .linkedFramework( - "AVFoundation", - .when(platforms: [.iOS, .macOS]) - ), - .linkedFramework( - "Foundation", - .when(platforms: [.iOS, .macOS]) - ) - ] + name: "SCCabbage", + dependencies: [] ) ] ) diff --git a/README.md b/README.md index 239810b..8322d7f 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ use_frameworks! target 'MyApp' do # your other pod # ... - pod 'VFCabbage' + pod 'SCCabbage', :git => 'https://github.com/kre8tv/SCCabbage' end ``` @@ -167,7 +167,7 @@ You can - Or add Cabbage as a submodule. ``` -$ git submodule add https://github.com/VideoFlint/Cabbage.git +$ git submodule add https://github.com/kre8tv/SCCabbage ``` ## Requirements diff --git a/VFCabbage.podspec b/SCCabbage.podspec similarity index 88% rename from VFCabbage.podspec rename to SCCabbage.podspec index 20dad59..b591134 100644 --- a/VFCabbage.podspec +++ b/SCCabbage.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| - s.name = 'VFCabbage' - s.version = '0.5.1' + s.name = 'SCCabbage' + s.version = '0.5.2' s.summary = 'A high-level video composition framework build on top of AVFoundation. It\'s simple to use and easy to extend.' s.description = <<-DESC @@ -15,14 +15,14 @@ Pod::Spec.new do |s| s.license = { :type => "MIT", :file => "LICENSE" } - s.homepage = 'https://github.com/VideoFlint/Cabbage' + s.homepage = 'https://github.com/kre8tv/SCCabbage' s.author = { 'Vito' => 'vvitozhang@gmail.com' } s.platform = :ios, '9.0' s.swift_version = "4.2" - s.source = { :git => 'https://github.com/VideoFlint/Cabbage.git', :tag => s.version.to_s } + s.source = { :git => 'https://github.com/kre8tv/SCCabbage.git', :tag => s.version.to_s } s.source_files = ['Cabbage/Sources/core/**/*.swift', 'Cabbage/Sources/**/*.swift'] s.resource_bundles = { 'Cabbage' => 'Cabbage/Sources/Resource/*.mp4' } diff --git a/Sources/Cabbage/AVAssetReaderImageResource.swift b/Sources/SCCabbage/AVAssetReaderImageResource.swift similarity index 100% rename from Sources/Cabbage/AVAssetReaderImageResource.swift rename to Sources/SCCabbage/AVAssetReaderImageResource.swift diff --git a/Sources/Cabbage/AVAssetReverseImageResource.swift b/Sources/SCCabbage/AVAssetReverseImageResource.swift similarity index 100% rename from Sources/Cabbage/AVAssetReverseImageResource.swift rename to Sources/SCCabbage/AVAssetReverseImageResource.swift diff --git a/Sources/Cabbage/AVAssetTrackResource.swift b/Sources/SCCabbage/AVAssetTrackResource.swift similarity index 100% rename from Sources/Cabbage/AVAssetTrackResource.swift rename to Sources/SCCabbage/AVAssetTrackResource.swift diff --git a/Sources/Cabbage/AudioMixer.swift b/Sources/SCCabbage/AudioMixer.swift similarity index 100% rename from Sources/Cabbage/AudioMixer.swift rename to Sources/SCCabbage/AudioMixer.swift diff --git a/Sources/Cabbage/AudioProcessingChain.swift b/Sources/SCCabbage/AudioProcessingChain.swift similarity index 100% rename from Sources/Cabbage/AudioProcessingChain.swift rename to Sources/SCCabbage/AudioProcessingChain.swift diff --git a/Sources/Cabbage/AudioProcessingTapHolder.swift b/Sources/SCCabbage/AudioProcessingTapHolder.swift similarity index 100% rename from Sources/Cabbage/AudioProcessingTapHolder.swift rename to Sources/SCCabbage/AudioProcessingTapHolder.swift diff --git a/Sources/Cabbage/AudioTransition.swift b/Sources/SCCabbage/AudioTransition.swift similarity index 100% rename from Sources/Cabbage/AudioTransition.swift rename to Sources/SCCabbage/AudioTransition.swift diff --git a/Sources/Cabbage/CGMathFunctions.swift b/Sources/SCCabbage/CGMathFunctions.swift similarity index 100% rename from Sources/Cabbage/CGMathFunctions.swift rename to Sources/SCCabbage/CGMathFunctions.swift diff --git a/Sources/Cabbage/CMTimeExtensition.swift b/Sources/SCCabbage/CMTimeExtensition.swift similarity index 100% rename from Sources/Cabbage/CMTimeExtensition.swift rename to Sources/SCCabbage/CMTimeExtensition.swift diff --git a/Sources/Cabbage/CompositionGenerator.swift b/Sources/SCCabbage/CompositionGenerator.swift similarity index 100% rename from Sources/Cabbage/CompositionGenerator.swift rename to Sources/SCCabbage/CompositionGenerator.swift diff --git a/Sources/Cabbage/CompositionProvider.swift b/Sources/SCCabbage/CompositionProvider.swift similarity index 100% rename from Sources/Cabbage/CompositionProvider.swift rename to Sources/SCCabbage/CompositionProvider.swift diff --git a/Sources/Cabbage/CoreImageExtension.swift b/Sources/SCCabbage/CoreImageExtension.swift similarity index 100% rename from Sources/Cabbage/CoreImageExtension.swift rename to Sources/SCCabbage/CoreImageExtension.swift diff --git a/Sources/Cabbage/ImageCompositionGroupProvider.swift b/Sources/SCCabbage/ImageCompositionGroupProvider.swift similarity index 100% rename from Sources/Cabbage/ImageCompositionGroupProvider.swift rename to Sources/SCCabbage/ImageCompositionGroupProvider.swift diff --git a/Sources/Cabbage/ImageGeneratorExtension.swift b/Sources/SCCabbage/ImageGeneratorExtension.swift similarity index 100% rename from Sources/Cabbage/ImageGeneratorExtension.swift rename to Sources/SCCabbage/ImageGeneratorExtension.swift diff --git a/Sources/Cabbage/ImageOverlayItem.swift b/Sources/SCCabbage/ImageOverlayItem.swift similarity index 100% rename from Sources/Cabbage/ImageOverlayItem.swift rename to Sources/SCCabbage/ImageOverlayItem.swift diff --git a/Sources/Cabbage/ImageResource.swift b/Sources/SCCabbage/ImageResource.swift similarity index 100% rename from Sources/Cabbage/ImageResource.swift rename to Sources/SCCabbage/ImageResource.swift diff --git a/Sources/Cabbage/KeyframeVideoConfiguration.swift b/Sources/SCCabbage/KeyframeVideoConfiguration.swift similarity index 100% rename from Sources/Cabbage/KeyframeVideoConfiguration.swift rename to Sources/SCCabbage/KeyframeVideoConfiguration.swift diff --git a/Sources/Cabbage/Log.swift b/Sources/SCCabbage/Log.swift similarity index 100% rename from Sources/Cabbage/Log.swift rename to Sources/SCCabbage/Log.swift diff --git a/Sources/Cabbage/PHAssetImageResource.swift b/Sources/SCCabbage/PHAssetImageResource.swift similarity index 100% rename from Sources/Cabbage/PHAssetImageResource.swift rename to Sources/SCCabbage/PHAssetImageResource.swift diff --git a/Sources/Cabbage/PHAssetLivePhotoResource.swift b/Sources/SCCabbage/PHAssetLivePhotoResource.swift similarity index 100% rename from Sources/Cabbage/PHAssetLivePhotoResource.swift rename to Sources/SCCabbage/PHAssetLivePhotoResource.swift diff --git a/Sources/Cabbage/PHAssetTrackResource.swift b/Sources/SCCabbage/PHAssetTrackResource.swift similarity index 100% rename from Sources/Cabbage/PHAssetTrackResource.swift rename to Sources/SCCabbage/PHAssetTrackResource.swift diff --git a/Sources/Cabbage/Resource.swift b/Sources/SCCabbage/Resource.swift similarity index 100% rename from Sources/Cabbage/Resource.swift rename to Sources/SCCabbage/Resource.swift diff --git a/Sources/Cabbage/TimeRangeExtension.swift b/Sources/SCCabbage/TimeRangeExtension.swift similarity index 100% rename from Sources/Cabbage/TimeRangeExtension.swift rename to Sources/SCCabbage/TimeRangeExtension.swift diff --git a/Sources/Cabbage/Timeline.swift b/Sources/SCCabbage/Timeline.swift similarity index 100% rename from Sources/Cabbage/Timeline.swift rename to Sources/SCCabbage/Timeline.swift diff --git a/Sources/Cabbage/TimingFunctionFactory.swift b/Sources/SCCabbage/TimingFunctionFactory.swift similarity index 100% rename from Sources/Cabbage/TimingFunctionFactory.swift rename to Sources/SCCabbage/TimingFunctionFactory.swift diff --git a/Sources/Cabbage/TrackConfiguration.swift b/Sources/SCCabbage/TrackConfiguration.swift similarity index 100% rename from Sources/Cabbage/TrackConfiguration.swift rename to Sources/SCCabbage/TrackConfiguration.swift diff --git a/Sources/Cabbage/TrackItem.swift b/Sources/SCCabbage/TrackItem.swift similarity index 100% rename from Sources/Cabbage/TrackItem.swift rename to Sources/SCCabbage/TrackItem.swift diff --git a/Sources/Cabbage/VideoCompositionInstruction.swift b/Sources/SCCabbage/VideoCompositionInstruction.swift similarity index 100% rename from Sources/Cabbage/VideoCompositionInstruction.swift rename to Sources/SCCabbage/VideoCompositionInstruction.swift diff --git a/Sources/Cabbage/VideoCompositor.swift b/Sources/SCCabbage/VideoCompositor.swift similarity index 100% rename from Sources/Cabbage/VideoCompositor.swift rename to Sources/SCCabbage/VideoCompositor.swift diff --git a/Sources/Cabbage/VideoTransition.swift b/Sources/SCCabbage/VideoTransition.swift similarity index 100% rename from Sources/Cabbage/VideoTransition.swift rename to Sources/SCCabbage/VideoTransition.swift