diff --git a/HaishinKit.xcodeproj/project.pbxproj b/HaishinKit.xcodeproj/project.pbxproj index 5abd51e11..5772decae 100644 --- a/HaishinKit.xcodeproj/project.pbxproj +++ b/HaishinKit.xcodeproj/project.pbxproj @@ -206,8 +206,8 @@ BC7C56CD29A786AE00C41A9B /* ADTS.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56CC29A786AE00C41A9B /* ADTS.swift */; }; BC7C56D129A78D4F00C41A9B /* ADTSHeaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56D029A78D4F00C41A9B /* ADTSHeaderTests.swift */; }; BC83A4732403D83B006BDE06 /* VTCompressionSession+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC83A4722403D83B006BDE06 /* VTCompressionSession+Extension.swift */; }; - BC8446052A30BE1600609FFD /* CMAudioSampleBufferUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC8446042A30BE1600609FFD /* CMAudioSampleBufferUtil.swift */; }; - BC8446092A30BFC800609FFD /* CMAudioSampleBufferUtilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC8446082A30BFC800609FFD /* CMAudioSampleBufferUtilTests.swift */; }; + BC8446052A30BE1600609FFD /* CMAudioSampleBufferFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC8446042A30BE1600609FFD /* CMAudioSampleBufferFactory.swift */; }; + BC8446092A30BFC800609FFD /* CMAudioSampleBufferFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC8446082A30BFC800609FFD /* CMAudioSampleBufferFactoryTests.swift */; }; BC8A29902AA63D9E00F6D27F /* HaishinKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2945CBBD1B4BE66000104112 /* HaishinKit.framework */; }; BC8A29912AA63D9E00F6D27F /* HaishinKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 2945CBBD1B4BE66000104112 /* HaishinKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; BC8A29942AA63DA300F6D27F /* HaishinKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2945CBBD1B4BE66000104112 /* HaishinKit.framework */; }; @@ -604,8 +604,8 @@ BC7C56CC29A786AE00C41A9B /* ADTS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADTS.swift; sourceTree = ""; }; BC7C56D029A78D4F00C41A9B /* ADTSHeaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADTSHeaderTests.swift; sourceTree = ""; }; BC83A4722403D83B006BDE06 /* VTCompressionSession+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VTCompressionSession+Extension.swift"; sourceTree = ""; }; - BC8446042A30BE1600609FFD /* CMAudioSampleBufferUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMAudioSampleBufferUtil.swift; sourceTree = ""; }; - BC8446082A30BFC800609FFD /* CMAudioSampleBufferUtilTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMAudioSampleBufferUtilTests.swift; sourceTree = ""; }; + BC8446042A30BE1600609FFD /* CMAudioSampleBufferFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMAudioSampleBufferFactory.swift; sourceTree = ""; }; + BC8446082A30BFC800609FFD /* CMAudioSampleBufferFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMAudioSampleBufferFactoryTests.swift; sourceTree = ""; }; BC959EEE296EE4190067BA97 /* ImageTransform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageTransform.swift; sourceTree = ""; }; BC959F0D29705B1B0067BA97 /* SCStreamPublishViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCStreamPublishViewController.swift; sourceTree = ""; }; BC959F1129717EDB0067BA97 /* PreferenceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceViewController.swift; sourceTree = ""; }; @@ -764,7 +764,7 @@ 298BCF321DD4C44A007FF86A /* AnyUtil.swift */, 29DC17B221D0CC0600E26CED /* Atomic.swift */, 29B876B81CD70B3900FC07DA /* ByteArray.swift */, - BC8446042A30BE1600609FFD /* CMAudioSampleBufferUtil.swift */, + BC8446042A30BE1600609FFD /* CMAudioSampleBufferFactory.swift */, 29B876631CD70AB300FC07DA /* Constants.swift */, BC0D236C26331BAB001DDA0C /* DataBuffer.swift */, 29B876671CD70AB300FC07DA /* DataConvertible.swift */, @@ -811,7 +811,7 @@ isa = PBXGroup; children = ( 290EA8A41DFB61E700053022 /* ByteArrayTests.swift */, - BC8446082A30BFC800609FFD /* CMAudioSampleBufferUtilTests.swift */, + BC8446082A30BFC800609FFD /* CMAudioSampleBufferFactoryTests.swift */, 290EA8A51DFB61E700053022 /* CRC32Tests.swift */, BCC9E9082636FF7400948774 /* DataBufferTests.swift */, 290EA8A61DFB61E700053022 /* EventDispatcherTests.swift */, @@ -1732,7 +1732,7 @@ BC44A1A923D31E92002D4297 /* AudioCodecRingBuffer.swift in Sources */, BC20DF38250377A3007BC608 /* IOUIScreenCaptureUnit.swift in Sources */, 29B876AF1CD70B2800FC07DA /* RTMPChunk.swift in Sources */, - BC8446052A30BE1600609FFD /* CMAudioSampleBufferUtil.swift in Sources */, + BC8446052A30BE1600609FFD /* CMAudioSampleBufferFactory.swift in Sources */, 29B876841CD70AE800FC07DA /* AVCDecoderConfigurationRecord.swift in Sources */, 296242621D8DB86500C451A3 /* TSWriter.swift in Sources */, BC9CFA9323BDE8B700917EEF /* NetStreamDrawable.swift in Sources */, @@ -1843,7 +1843,7 @@ 295018201FFA1BD700358E10 /* AudioCodecTests.swift in Sources */, 290EA8AC1DFB61E700053022 /* MD5Tests.swift in Sources */, 290EA8A01DFB61B100053022 /* AMFFoundationTests.swift in Sources */, - BC8446092A30BFC800609FFD /* CMAudioSampleBufferUtilTests.swift in Sources */, + BC8446092A30BFC800609FFD /* CMAudioSampleBufferFactoryTests.swift in Sources */, BC7C56892995082700C41A9B /* NetStreamTests.swift in Sources */, 2917CB662104CA2800F6823A /* AudioSpecificConfigTests.swift in Sources */, 290EA8AB1DFB61E700053022 /* EventDispatcherTests.swift in Sources */, diff --git a/Sources/Media/IOAudioUnit.swift b/Sources/Media/IOAudioUnit.swift index 07e4b5523..f00a0657b 100644 --- a/Sources/Media/IOAudioUnit.swift +++ b/Sources/Media/IOAudioUnit.swift @@ -78,7 +78,7 @@ final class IOAudioUnit: NSObject, IOUnit { var gapPresentationTimeStamp = presentationTimeStamp for i in 0 ... numSampleBuffers { let numSamples = numSampleBuffers == i ? numGapSamples % sampleBuffer.numSamples : sampleBuffer.numSamples - guard let gapSampleBuffer = CMAudioSampleBufferUtil.makeSampleBuffer(sampleBuffer, numSamples: numSamples, presentationTimeStamp: gapPresentationTimeStamp) else { + guard let gapSampleBuffer = CMAudioSampleBufferFactory.makeSampleBuffer(sampleBuffer, numSamples: numSamples, presentationTimeStamp: gapPresentationTimeStamp) else { continue } mixer?.recorder.appendSampleBuffer(gapSampleBuffer) diff --git a/Sources/Util/CMAudioSampleBufferUtil.swift b/Sources/Util/CMAudioSampleBufferFactory.swift similarity index 98% rename from Sources/Util/CMAudioSampleBufferUtil.swift rename to Sources/Util/CMAudioSampleBufferFactory.swift index e9876a881..7eeb48c0e 100644 --- a/Sources/Util/CMAudioSampleBufferUtil.swift +++ b/Sources/Util/CMAudioSampleBufferFactory.swift @@ -1,7 +1,7 @@ import CoreMedia import Foundation -enum CMAudioSampleBufferUtil { +enum CMAudioSampleBufferFactory { static func makeSampleBuffer(_ buffer: CMSampleBuffer, numSamples: Int, presentationTimeStamp: CMTime) -> CMSampleBuffer? { guard 0 < numSamples, let formatDescription = buffer.formatDescription, let streamBasicDescription = formatDescription.streamBasicDescription else { return nil diff --git a/Tests/Util/CMAudioSampleBufferUtilTests.swift b/Tests/Util/CMAudioSampleBufferFactoryTests.swift similarity index 87% rename from Tests/Util/CMAudioSampleBufferUtilTests.swift rename to Tests/Util/CMAudioSampleBufferFactoryTests.swift index 3821dd949..7da194773 100644 --- a/Tests/Util/CMAudioSampleBufferUtilTests.swift +++ b/Tests/Util/CMAudioSampleBufferFactoryTests.swift @@ -4,7 +4,7 @@ import CoreMedia @testable import HaishinKit -final class CMAudioSampleBufferUtilTests: XCTestCase { +final class CMAudioSampleBufferFactoryTests: XCTestCase { func test48000_2chTest() { let streamBasicDescription = AudioStreamBasicDescription( mSampleRate: 48000.0, @@ -18,7 +18,7 @@ final class CMAudioSampleBufferUtilTests: XCTestCase { mReserved: 0 ) if let buffer = makeSampleBuffer(streamBasicDescription) { - XCTAssertNotNil(CMAudioSampleBufferUtil.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) + XCTAssertNotNil(CMAudioSampleBufferFactory.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) } else { XCTFail() } @@ -37,7 +37,7 @@ final class CMAudioSampleBufferUtilTests: XCTestCase { mReserved: 0 ) if let buffer = makeSampleBuffer(streamBasicDescription) { - XCTAssertNotNil(CMAudioSampleBufferUtil.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) + XCTAssertNotNil(CMAudioSampleBufferFactory.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) } else { XCTFail() } @@ -56,7 +56,7 @@ final class CMAudioSampleBufferUtilTests: XCTestCase { mReserved: 0 ) if let buffer = makeSampleBuffer(streamBasicDescription) { - XCTAssertNotNil(CMAudioSampleBufferUtil.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) + XCTAssertNotNil(CMAudioSampleBufferFactory.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) } else { XCTFail() } @@ -75,7 +75,7 @@ final class CMAudioSampleBufferUtilTests: XCTestCase { mReserved: 0 ) if let buffer = makeSampleBuffer(streamBasicDescription) { - XCTAssertNotNil(CMAudioSampleBufferUtil.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) + XCTAssertNotNil(CMAudioSampleBufferFactory.makeSampleBuffer(buffer, numSamples: 1024, presentationTimeStamp: .zero)) } else { XCTFail() }