diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index a982f40ca..72e58ddc3 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -5,10 +5,12 @@ on: [pull_request] jobs: build: - runs-on: macOS-12 + runs-on: macOS-13 steps: - uses: actions/checkout@v1 + - name: Select Xcode version + run: sudo xcode-select -s '/Applications/Xcode_15.0.app' - name: bundle install run: | bundle install diff --git a/Cartfile b/Cartfile index 16c91dba2..08cbae339 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "shogo4405/Logboard" ~> 2.3.1 +github "shogo4405/Logboard" ~> 2.4.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 26b13e704..3d53ef4de 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "shogo4405/Logboard" "2.3.1" +github "shogo4405/Logboard" "2.4.1" diff --git a/Examples/iOS/LiveViewController.swift b/Examples/iOS/LiveViewController.swift index e9d03afdb..b25ee3432 100644 --- a/Examples/iOS/LiveViewController.swift +++ b/Examples/iOS/LiveViewController.swift @@ -88,7 +88,7 @@ final class LiveViewController: UIViewController { logger.warn(error) } rtmpStream.addObserver(self, forKeyPath: "currentFPS", options: .new, context: nil) - (view as? NetStreamDrawable)?.attachStream(rtmpStream) + (view as? (any NetStreamDrawable))?.attachStream(rtmpStream) NotificationCenter.default.addObserver(self, selector: #selector(didInterruptionNotification(_:)), name: AVAudioSession.interruptionNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(didRouteChangeNotification(_:)), name: AVAudioSession.routeChangeNotification, object: nil) } diff --git a/Examples/iOS/Screencast/SampleHandler.swift b/Examples/iOS/Screencast/SampleHandler.swift index 57d337ca8..8d2a9d61b 100644 --- a/Examples/iOS/Screencast/SampleHandler.swift +++ b/Examples/iOS/Screencast/SampleHandler.swift @@ -43,7 +43,7 @@ open class SampleHandler: RPBroadcastSampleHandler { case .video: if let description = CMSampleBufferGetFormatDescription(sampleBuffer) { let dimensions = CMVideoFormatDescriptionGetDimensions(description) - rtmpStream.videoSettings.videoSize = .init(width: dimensions.width, height: dimensions.height) + rtmpStream.videoSettings.videoSize = .init(width: CGFloat(dimensions.width), height: CGFloat(dimensions.height)) rtmpStream.videoSettings.profileLevel = kVTProfileLevel_H264_Baseline_AutoLevel as String } rtmpStream.appendSampleBuffer(sampleBuffer) diff --git a/HaishinKit.podspec b/HaishinKit.podspec index 06573ff49..e598d2a8b 100644 --- a/HaishinKit.podspec +++ b/HaishinKit.podspec @@ -1,9 +1,9 @@ Pod::Spec.new do |s| s.name = "HaishinKit" - s.version = "1.5.8" + s.version = "1.6.0" s.summary = "Camera and Microphone streaming library via RTMP, HLS for iOS, macOS and tvOS." - s.swift_version = "5.7" + s.swift_version = "5.8" s.description = <<-DESC HaishinKit. Camera and Microphone streaming library via RTMP, HLS for iOS, macOS and tvOS. @@ -15,16 +15,16 @@ Pod::Spec.new do |s| s.authors = { "shogo4405" => "shogo4405@gmail.com" } s.source = { :git => "https://github.com/shogo4405/HaishinKit.swift.git", :tag => "#{s.version}" } - s.ios.deployment_target = "11.0" + s.ios.deployment_target = "12.0" s.ios.source_files = "Platforms/iOS/*.{h,swift}" s.osx.deployment_target = "10.13" s.osx.source_files = "Platforms/iOS/*.{h,swift}" - s.tvos.deployment_target = "11.0" + s.tvos.deployment_target = "12.0" s.tvos.source_files = "Platforms/iOS/*.{h,swift}" s.source_files = "Sources/**/*.swift" - s.dependency 'Logboard', '~> 2.3.1' + s.dependency 'Logboard', '~> 2.4.1' end diff --git a/HaishinKit.xcodeproj/project.pbxproj b/HaishinKit.xcodeproj/project.pbxproj index 98075e377..8956a9412 100644 --- a/HaishinKit.xcodeproj/project.pbxproj +++ b/HaishinKit.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 290686031DFDB7A7008EB7ED /* RTMPConnectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290686021DFDB7A6008EB7ED /* RTMPConnectionTests.swift */; }; 290EA8901DFB616000053022 /* Foundation+ExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290EA88E1DFB616000053022 /* Foundation+ExtensionTests.swift */; }; 290EA8911DFB616000053022 /* SwiftCore+ExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290EA88F1DFB616000053022 /* SwiftCore+ExtensionTests.swift */; }; - 290EA8931DFB617800053022 /* HTTPRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290EA8921DFB617800053022 /* HTTPRequestTests.swift */; }; 290EA8991DFB619600053022 /* PacketizedElementaryStreamTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290EA8951DFB619600053022 /* PacketizedElementaryStreamTests.swift */; }; 290EA89A1DFB619600053022 /* TSProgramTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290EA8961DFB619600053022 /* TSProgramTests.swift */; }; 290EA89B1DFB619600053022 /* TSPacketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290EA8971DFB619600053022 /* TSPacketTests.swift */; }; @@ -138,9 +137,10 @@ 2EC97B7227880FF400D8BE32 /* OnTapGestureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EC97B6E27880FF400D8BE32 /* OnTapGestureView.swift */; }; 2EC97B7327880FF400D8BE32 /* Views.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EC97B6F27880FF400D8BE32 /* Views.swift */; }; 2EC97B7427880FF400D8BE32 /* MTHKSwiftUiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EC97B7027880FF400D8BE32 /* MTHKSwiftUiView.swift */; }; - BC0BF4F22985FA9000D72CB4 /* HaishinKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2945CBBD1B4BE66000104112 /* HaishinKit.framework */; platformFilters = (ios, maccatalyst, ); }; + BC0394562AA8A384006EDE38 /* Logboard.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC34DFD125EBB12C005F975A /* Logboard.xcframework */; }; + BC03945F2AA8AFF5006EDE38 /* ExpressibleByIntegerLiteral+ExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC03945E2AA8AFF5006EDE38 /* ExpressibleByIntegerLiteral+ExtensionTests.swift */; }; + BC0BF4F22985FA9000D72CB4 /* HaishinKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2945CBBD1B4BE66000104112 /* HaishinKit.framework */; }; BC0BF4F529866FDE00D72CB4 /* IOMixerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC0BF4F429866FDE00D72CB4 /* IOMixerTests.swift */; }; - BC0BF4F72986CE8700D72CB4 /* VideoCodecTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC0BF4F62986CE8700D72CB4 /* VideoCodecTests.swift */; }; BC0D236D26331BAB001DDA0C /* DataBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC0D236C26331BAB001DDA0C /* DataBuffer.swift */; }; BC11023E2917C35B00D48035 /* CVPixelBufferPool+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC11023D2917C35B00D48035 /* CVPixelBufferPool+Extension.swift */; }; BC11024A2925147300D48035 /* IOCaptureUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC1102492925147300D48035 /* IOCaptureUnit.swift */; }; @@ -197,10 +197,8 @@ BC72EF2C25F24E480068F040 /* Logboard.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BC34DFD125EBB12C005F975A /* Logboard.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; BC72EF3225F24E500068F040 /* Logboard.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC34DFD125EBB12C005F975A /* Logboard.xcframework */; }; BC72EF3325F24E500068F040 /* Logboard.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BC34DFD125EBB12C005F975A /* Logboard.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - BC7C56892995082700C41A9B /* NetStreamTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56882995082700C41A9B /* NetStreamTests.swift */; }; BC7C56B7299E579F00C41A9B /* AudioCodecSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56B6299E579F00C41A9B /* AudioCodecSettings.swift */; }; BC7C56BB299E595000C41A9B /* VideoCodecSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56BA299E595000C41A9B /* VideoCodecSettings.swift */; }; - BC7C56BF299FC38D00C41A9B /* VideoSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56BE299FC38D00C41A9B /* VideoSize.swift */; }; BC7C56C329A1F28700C41A9B /* TSReaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56C229A1F28700C41A9B /* TSReaderTests.swift */; }; BC7C56C729A7701F00C41A9B /* ESSpecificDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56C629A7701F00C41A9B /* ESSpecificDataTests.swift */; }; BC7C56CD29A786AE00C41A9B /* ADTS.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC7C56CC29A786AE00C41A9B /* ADTS.swift */; }; @@ -416,7 +414,6 @@ 290686021DFDB7A6008EB7ED /* RTMPConnectionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RTMPConnectionTests.swift; sourceTree = ""; }; 290EA88E1DFB616000053022 /* Foundation+ExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Foundation+ExtensionTests.swift"; sourceTree = ""; }; 290EA88F1DFB616000053022 /* SwiftCore+ExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftCore+ExtensionTests.swift"; sourceTree = ""; }; - 290EA8921DFB617800053022 /* HTTPRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPRequestTests.swift; sourceTree = ""; }; 290EA8951DFB619600053022 /* PacketizedElementaryStreamTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PacketizedElementaryStreamTests.swift; sourceTree = ""; }; 290EA8961DFB619600053022 /* TSProgramTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TSProgramTests.swift; sourceTree = ""; }; 290EA8971DFB619600053022 /* TSPacketTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TSPacketTests.swift; sourceTree = ""; }; @@ -551,8 +548,8 @@ 2EC97B6E27880FF400D8BE32 /* OnTapGestureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnTapGestureView.swift; sourceTree = ""; }; 2EC97B6F27880FF400D8BE32 /* Views.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Views.swift; sourceTree = ""; }; 2EC97B7027880FF400D8BE32 /* MTHKSwiftUiView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTHKSwiftUiView.swift; sourceTree = ""; }; + BC03945E2AA8AFF5006EDE38 /* ExpressibleByIntegerLiteral+ExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ExpressibleByIntegerLiteral+ExtensionTests.swift"; sourceTree = ""; }; BC0BF4F429866FDE00D72CB4 /* IOMixerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOMixerTests.swift; sourceTree = ""; }; - BC0BF4F62986CE8700D72CB4 /* VideoCodecTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoCodecTests.swift; sourceTree = ""; }; BC0D236C26331BAB001DDA0C /* DataBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataBuffer.swift; sourceTree = ""; }; BC11023D2917C35B00D48035 /* CVPixelBufferPool+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CVPixelBufferPool+Extension.swift"; sourceTree = ""; }; BC1102492925147300D48035 /* IOCaptureUnit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOCaptureUnit.swift; sourceTree = ""; }; @@ -595,10 +592,8 @@ BC570B4728E9ACC10098A12C /* IOUnit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOUnit.swift; sourceTree = ""; }; BC6FC91D29609A6800A746EE /* ShapeFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShapeFactory.swift; sourceTree = ""; }; BC6FC9212961B3D800A746EE /* vImage_CGImageFormat+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "vImage_CGImageFormat+Extension.swift"; sourceTree = ""; }; - BC7C56882995082700C41A9B /* NetStreamTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetStreamTests.swift; sourceTree = ""; }; BC7C56B6299E579F00C41A9B /* AudioCodecSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioCodecSettings.swift; sourceTree = ""; }; BC7C56BA299E595000C41A9B /* VideoCodecSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoCodecSettings.swift; sourceTree = ""; }; - BC7C56BE299FC38D00C41A9B /* VideoSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoSize.swift; sourceTree = ""; }; BC7C56C229A1F28700C41A9B /* TSReaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSReaderTests.swift; sourceTree = ""; }; BC7C56C629A7701F00C41A9B /* ESSpecificDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ESSpecificDataTests.swift; sourceTree = ""; }; BC7C56CC29A786AE00C41A9B /* ADTS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADTS.swift; sourceTree = ""; }; @@ -647,7 +642,7 @@ BCD91C0C2A700FF50033F9E1 /* IOAudioMonitorRingBufferTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOAudioMonitorRingBufferTests.swift; sourceTree = ""; }; BCFB355324FA275600DC5108 /* PlaybackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackViewController.swift; sourceTree = ""; }; BCFB355924FA40DD00DC5108 /* PlaybackContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackContainerViewController.swift; sourceTree = ""; }; - BCFF640A29C0C44B004EFF2F /* SampleVideo_360x240_5mb_2ch.ts */ = {isa = PBXFileReference; lastKnownFileType = file; path = SampleVideo_360x240_5mb_2ch.ts; sourceTree = ""; }; + BCFF640A29C0C44B004EFF2F /* SampleVideo_360x240_5mb_2ch.ts */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.typescript; path = SampleVideo_360x240_5mb_2ch.ts; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -666,6 +661,7 @@ buildActionMask = 2147483647; files = ( BC0BF4F22985FA9000D72CB4 /* HaishinKit.framework in Frameworks */, + BC0394562AA8A384006EDE38 /* Logboard.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -753,7 +749,6 @@ BC4914B128DDFE31009E2DF6 /* VTSessionOptionKey.swift */, 29B876591CD70A7900FC07DA /* VideoCodec.swift */, BC7C56BA299E595000C41A9B /* VideoCodecSettings.swift */, - BC7C56BE299FC38D00C41A9B /* VideoSize.swift */, ); path = Codec; sourceTree = ""; @@ -844,14 +839,6 @@ path = Core; sourceTree = ""; }; - 291C2AD31CE9FF68006F042B /* HTTP */ = { - isa = PBXGroup; - children = ( - 290EA8921DFB617800053022 /* HTTPRequestTests.swift */, - ); - path = HTTP; - sourceTree = ""; - }; 2945CBB31B4BE66000104112 = { isa = PBXGroup; children = ( @@ -907,7 +894,6 @@ children = ( BCCBCE9F29ADF55A0095B51C /* AudioCodecBufferTests.swift */, 2950181F1FFA1BD700358E10 /* AudioCodecTests.swift */, - BC0BF4F62986CE8700D72CB4 /* VideoCodecTests.swift */, ); path = Codec; sourceTree = ""; @@ -1000,11 +986,10 @@ 291C2AD11CE9FF3E006F042B /* Asset */, 295018191FFA196800358E10 /* Codec */, 291C2AD21CE9FF48006F042B /* Core */, + BC03945D2AA8AFDD006EDE38 /* Extension */, BC1DC5022A02893600E928ED /* FLV */, - 291C2AD31CE9FF68006F042B /* HTTP */, 291C2ACF1CE9FF2B006F042B /* MPEG */, BC0BF4F329866FB700D72CB4 /* Media */, - BCA7C2502A91AA3800882D85 /* Net */, 291C2ACE1CE9FF25006F042B /* RTMP */, 291C2AD01CE9FF33006F042B /* Util */, 295018211FFA1C9D00358E10 /* CMAudioSampleBufferTestUtil.swift */, @@ -1173,6 +1158,14 @@ path = View; sourceTree = ""; }; + BC03945D2AA8AFDD006EDE38 /* Extension */ = { + isa = PBXGroup; + children = ( + BC03945E2AA8AFF5006EDE38 /* ExpressibleByIntegerLiteral+ExtensionTests.swift */, + ); + path = Extension; + sourceTree = ""; + }; BC0BF4F329866FB700D72CB4 /* Media */ = { isa = PBXGroup; children = ( @@ -1202,14 +1195,6 @@ path = Extension; sourceTree = ""; }; - BCA7C2502A91AA3800882D85 /* Net */ = { - isa = PBXGroup; - children = ( - BC7C56882995082700C41A9B /* NetStreamTests.swift */, - ); - path = Net; - sourceTree = ""; - }; BCCC45972AA289FA0016EFE8 /* SRTHaishinKit */ = { isa = PBXGroup; children = ( @@ -1787,7 +1772,6 @@ 29B876BE1CD70B3900FC07DA /* EventDispatcher.swift in Sources */, BC2828AF2AA322E400741013 /* AVFrameRateRange+Extension.swift in Sources */, 29B8769D1CD70B1100FC07DA /* NetService.swift in Sources */, - BC7C56BF299FC38D00C41A9B /* VideoSize.swift in Sources */, 29B8769E1CD70B1100FC07DA /* NetSocket.swift in Sources */, 2958911A1EEB8E3F00CE51E1 /* FLVAudioCodec.swift in Sources */, BC4914B628DEC2FE009E2DF6 /* VTSessionMode.swift in Sources */, @@ -1832,7 +1816,6 @@ 290EA8AC1DFB61E700053022 /* MD5Tests.swift in Sources */, 290EA8A01DFB61B100053022 /* AMFFoundationTests.swift in Sources */, BC8446092A30BFC800609FFD /* CMAudioSampleBufferFactoryTests.swift in Sources */, - BC7C56892995082700C41A9B /* NetStreamTests.swift in Sources */, 2917CB662104CA2800F6823A /* AudioSpecificConfigTests.swift in Sources */, 290EA8AB1DFB61E700053022 /* EventDispatcherTests.swift in Sources */, 290EA8901DFB616000053022 /* Foundation+ExtensionTests.swift in Sources */, @@ -1841,9 +1824,7 @@ BC0BF4F529866FDE00D72CB4 /* IOMixerTests.swift in Sources */, 290EA89A1DFB619600053022 /* TSProgramTests.swift in Sources */, BCCBCEA029ADF55A0095B51C /* AudioCodecBufferTests.swift in Sources */, - BC0BF4F72986CE8700D72CB4 /* VideoCodecTests.swift in Sources */, BC1DC5042A02894D00E928ED /* FLVVideoFourCCTests.swift in Sources */, - 290EA8931DFB617800053022 /* HTTPRequestTests.swift in Sources */, BC1DC5122A04E46E00E928ED /* HEVCDecoderConfigurationRecordTests.swift in Sources */, BCA7C24F2A91AA0500882D85 /* IORecorderTests.swift in Sources */, BCD91C0D2A700FF50033F9E1 /* IOAudioMonitorRingBufferTests.swift in Sources */, @@ -1852,6 +1833,7 @@ BCCBCE9B29A9D96A0095B51C /* NALUnitReaderTests.swift in Sources */, 290EA8A11DFB61B100053022 /* RTMPChunkTests.swift in Sources */, 290EA89F1DFB61B100053022 /* AMF0SerializerTests.swift in Sources */, + BC03945F2AA8AFF5006EDE38 /* ExpressibleByIntegerLiteral+ExtensionTests.swift in Sources */, 290EA8AA1DFB61E700053022 /* CRC32Tests.swift in Sources */, 035AFA042263868E009DD0BB /* RTMPStreamTests.swift in Sources */, 290686031DFDB7A7008EB7ED /* RTMPConnectionTests.swift in Sources */, @@ -1945,10 +1927,6 @@ }; BC0BF4F12985FA5800D72CB4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - platformFilters = ( - ios, - maccatalyst, - ); target = 2945CBBC1B4BE66000104112 /* HaishinKit */; targetProxy = BC0BF4F02985FA5800D72CB4 /* PBXContainerItemProxy */; }; @@ -2140,7 +2118,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -2148,7 +2126,7 @@ SUPPORTED_PLATFORMS = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; - TVOS_DEPLOYMENT_TARGET = 11.0; + TVOS_DEPLOYMENT_TARGET = 12.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -2196,7 +2174,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = ""; @@ -2204,7 +2182,7 @@ SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = "1,2"; - TVOS_DEPLOYMENT_TARGET = 11.0; + TVOS_DEPLOYMENT_TARGET = 12.0; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -2227,6 +2205,7 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Platforms/iOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2234,7 +2213,7 @@ ); MARKETING_VERSION = 1.5.8; ONLY_ACTIVE_ARCH = YES; - "OTHER_SWIFT_FLAGS[arch=*]" = ""; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit; PRODUCT_NAME = HaishinKit; PROVISIONING_PROFILE = ""; @@ -2246,6 +2225,7 @@ SWIFT_INCLUDE_PATHS = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Debug; }; @@ -2265,6 +2245,7 @@ FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Platforms/iOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2272,6 +2253,7 @@ ); MARKETING_VERSION = 1.5.8; ONLY_ACTIVE_ARCH = NO; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit; PRODUCT_NAME = HaishinKit; PROVISIONING_PROFILE = ""; @@ -2283,6 +2265,7 @@ SWIFT_INCLUDE_PATHS = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Release; }; @@ -2307,6 +2290,7 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2332,6 +2316,7 @@ SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2357,6 +2342,7 @@ "@executable_path/Frameworks", ); ONLY_ACTIVE_ARCH = YES; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.HaishinKit.Example-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2387,6 +2373,7 @@ "$(inherited)", "@executable_path/Frameworks", ); + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.HaishinKit.Example-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2414,6 +2401,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.13; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.HaishinKit.Example-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -2439,6 +2427,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.13; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.HaishinKit.Example-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -2466,6 +2455,7 @@ "$(inherited)", "@executable_path/Frameworks", ); + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.Example-tvOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; @@ -2495,6 +2485,7 @@ "$(inherited)", "@executable_path/Frameworks", ); + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.Example-tvOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; @@ -2531,7 +2522,7 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2023 Shogo Endo. All rights reserved."; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2542,6 +2533,7 @@ MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++20"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit.SRTHaishinKit; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2581,7 +2573,7 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2023 Shogo Endo. All rights reserved."; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2591,6 +2583,7 @@ MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++20"; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = com.haishinkit.HaishinKit.SRTHaishinKit; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2640,6 +2633,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.HaishinKit.Example-iOS-SwiftUI"; PRODUCT_NAME = "Example iOS+SwiftUI"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -2685,6 +2679,7 @@ ); MARKETING_VERSION = 1.0.0; MTL_FAST_MATH = YES; + OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny"; PRODUCT_BUNDLE_IDENTIFIER = "com.haishinkit.HaishinKit.Example-iOS-SwiftUI"; PRODUCT_NAME = "Example iOS+SwiftUI"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; diff --git a/Package.swift b/Package.swift index 377a72ec6..e113bf7bf 100644 --- a/Package.swift +++ b/Package.swift @@ -1,12 +1,12 @@ -// swift-tools-version:5.5 +// swift-tools-version:5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "HaishinKit", platforms: [ - .iOS(.v11), - .tvOS(.v11), + .iOS(.v12), + .tvOS(.v12), .macOS(.v10_13), .macCatalyst(.v14) ], @@ -15,7 +15,7 @@ let package = Package( .library(name: "SRTHaishinKit", targets: ["SRTHaishinKit"]) ], dependencies: [ - .package(url: "https://github.com/shogo4405/Logboard.git", "2.3.1"..<"2.4.0") + .package(url: "https://github.com/shogo4405/Logboard.git", "2.4.1"..<"2.5.0") ], targets: [ .binaryTarget( @@ -35,7 +35,7 @@ let package = Package( "MPEG", "Net", "RTMP", - "Util", + "Util" ]), .target(name: "SRTHaishinKit", dependencies: [ diff --git a/README.md b/README.md index bfc82ccf0..0612c148a 100644 --- a/README.md +++ b/README.md @@ -57,20 +57,13 @@ Project name |Notes |License - [x] _Tunneled (RTMPT over SSL/TLS) (Technical Preview)_ - [x] _RTMPT (Technical Preview)_ - [x] ReplayKit Live as a Broadcast Upload Extension -- [x] Supported codec - - Audio - - [x] AAC - - Video - - [x] H264/AVC - - ex: `stream.videoSettings.profileLevel = kVTProfileLevel_H264_Baseline_3_1 as String` - - [x] H265/HEVC ([Also server-side must support Enhanced RTMP.](https://github.com/veovera/enhanced-rtmp)) - - ex: `stream.videoSettings.profileLevel = kVTProfileLevel_HEVC_Main_AutoLevel as String` +- [x] Enhanced RTMP + +### HLS +- [x] HTTPService +- [x] HLS Publish ### SRT -It's a different framework. You can use it through SwiftPM. -```swift -import SRTHaishinKit -``` - [x] Publish and Recording (H264/AAC) - [x] Playback(beta) - [ ] mode @@ -78,11 +71,6 @@ import SRTHaishinKit - [x] listener - [ ] rendezvous - -### HLS -- [x] HTTPService -- [x] HLS Publish - ### Multi Camera Supports two camera video sources. A picture-in-picture display that shows the image of the secondary camera of the primary camera. Supports camera split display that displays horizontally and vertically. @@ -113,65 +101,51 @@ rtmpStream.attachAudio(AVCaptureDevice.default(for: .audio)) ### Others - [x] [Support multitasking camera access.](https://developer.apple.com/documentation/avfoundation/capture_setup/accessing_the_camera_while_multitasking) -- [x] _Support tvOS 11.0+ (Technical Preview)_ - - tvOS can't use camera and microphone devices. -- [x] Hardware acceleration for H264 video encoding, AAC audio encoding - [x] Support "Allow app extension API only" option -- [ ] ~~Support GPUImage framework (~> 0.5.12)~~ - - ~~https://github.com/shogo4405/GPUHaishinKit.swift/blob/master/README.md~~ -- [ ] ~~Objective-C Bridging~~ - -## 🌏 Requirements -|-|iOS|OSX|tvOS|Xcode|Swift| -|:----:|:----:|:----:|:----:|:----:|:----:| -|1.5.0+|11.0+|10.13+|10.2+|14.3+|5.7+| -|1.4.0+|11.0+|10.13+|10.2+|14.0+|5.7+| ## 🐾 Examples Examples project are available for iOS with UIKit, iOS with SwiftUI, macOS and tvOS. - [x] Camera and microphone publish. -- [x] RTMP Playback +- [x] RTMP Playback ```sh git clone https://github.com/shogo4405/HaishinKit.swift.git cd HaishinKit.swift -carthage bootstrap --use-xcframeworks +carthage bootstrap -platform iOS,macOS,tvOS --use-xcframeworks open HaishinKit.xcodeproj ``` -## ☕ Cocoa Keys +## 🌏 Requirements + +### Development +|Version|Xcode|Swift| +|:----:|:----:|:----:| +|1.6.0+|15.0+|5.8+| +|1.5.0+|14.0+|5.7+| + +### OS +|-|iOS|tvOS|macOS|visionOS|watchOS| +|:----|:----:|:----:|:----:|:----:|:----:| +|HaishinKit|12.0+|12.0+|10.13+|-|-| +|SRTHaishinKit|12.0+|-|-|-|-| + +### Cocoa Keys Please contains Info.plist. -iOS 10.0+ +**iOS 10.0+** * NSMicrophoneUsageDescription * NSCameraUsageDescription -macOS 10.14+ +**macOS 10.14+** * NSMicrophoneUsageDescription * NSCameraUsageDescription ## 🔧 Installation -### CocoaPods -```rb -source 'https://github.com/CocoaPods/Specs.git' -use_frameworks! - -def import_pods - pod 'HaishinKit', '~> 1.5.8 -end - -target 'Your Target' do - platform :ios, '11.0' - import_pods -end -``` -### Carthage -``` -github "shogo4405/HaishinKit.swift" ~> 1.5.8 -``` -### Swift Package Manager -``` -https://github.com/shogo4405/HaishinKit.swift -``` +HaishinKit has a multi-module configuration. If you want to use the SRT protocol, please use SRTHaishinKit. SRTHaishinKit supports SPM only. +| | HaishinKit | SRTHaishinKit | +| - | :- | :- | +| SPM | https://github.com/shogo4405/HaishinKit.swift | https://github.com/shogo4405/HaishinKit.swift | +| CocoaPods | source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

def import_pods
pod 'HaishinKit', '~> 1.6.0
end

target 'Your Target' do
platform :ios, '12.0'
import_pods
end
| Not supported. | +| Carthage | github "shogo4405/HaishinKit.swift" ~> 1.6.0 | Not supported. | ## 🔧 Prerequisites Make sure you setup and activate your AVAudioSession iOS. diff --git a/SRTHaishinKit/SRTStream.swift b/SRTHaishinKit/SRTStream.swift index 1a55554c6..5d80d5483 100644 --- a/SRTHaishinKit/SRTStream.swift +++ b/SRTHaishinKit/SRTStream.swift @@ -112,7 +112,7 @@ public class SRTStream: NetStream { writer.expectedMedias.remove(type) } - override public func attachCamera(_ camera: AVCaptureDevice?, onError: ((Error) -> Void)? = nil) { + override public func attachCamera(_ camera: AVCaptureDevice?, onError: ((any Error) -> Void)? = nil) { if camera == nil { writer.expectedMedias.remove(.video) } else { @@ -121,7 +121,7 @@ public class SRTStream: NetStream { super.attachCamera(camera, onError: onError) } - override public func attachAudio(_ audio: AVCaptureDevice?, automaticallyConfiguresApplicationAudioSession: Bool = true, onError: ((Error) -> Void)? = nil) { + override public func attachAudio(_ audio: AVCaptureDevice?, automaticallyConfiguresApplicationAudioSession: Bool = true, onError: ((any Error) -> Void)? = nil) { if audio == nil { writer.expectedMedias.remove(.audio) } else { diff --git a/Sources/Codec/VTSessionMode.swift b/Sources/Codec/VTSessionMode.swift index bd38525dc..fc5b0b5cf 100644 --- a/Sources/Codec/VTSessionMode.swift +++ b/Sources/Codec/VTSessionMode.swift @@ -11,8 +11,8 @@ enum VTSessionMode { var session: VTCompressionSession? var status = VTCompressionSessionCreate( allocator: kCFAllocatorDefault, - width: videoCodec.settings.videoSize.width, - height: videoCodec.settings.videoSize.height, + width: Int32(videoCodec.settings.videoSize.width), + height: Int32(videoCodec.settings.videoSize.height), codecType: videoCodec.settings.format.codecType, encoderSpecification: nil, imageBufferAttributes: videoCodec.attributes as CFDictionary?, diff --git a/Sources/Codec/VideoCodecSettings.swift b/Sources/Codec/VideoCodecSettings.swift index 38bf447a8..21489619d 100644 --- a/Sources/Codec/VideoCodecSettings.swift +++ b/Sources/Codec/VideoCodecSettings.swift @@ -74,7 +74,7 @@ public struct VideoCodecSettings: Codable { } /// Specifies the video size of encoding video. - public var videoSize: VideoSize + public var videoSize: CGSize /// Specifies the bitrate. public var bitRate: UInt32 /// Specifies the keyframeInterval. @@ -102,7 +102,7 @@ public struct VideoCodecSettings: Codable { /// Creates a new VideoCodecSettings instance. public init( - videoSize: VideoSize = .init(width: 854, height: 480), + videoSize: CGSize = .init(width: 854, height: 480), profileLevel: String = kVTProfileLevel_H264_Baseline_3_1 as String, bitRate: UInt32 = 640 * 1000, maxKeyFrameIntervalDuration: Int32 = 2, diff --git a/Sources/Codec/VideoSize.swift b/Sources/Codec/VideoSize.swift deleted file mode 100644 index 6288eab7d..000000000 --- a/Sources/Codec/VideoSize.swift +++ /dev/null @@ -1,20 +0,0 @@ -import Foundation - -/// The VideoSize class represents video width and height. -public struct VideoSize: Equatable, Codable { - /// The video width. - public let width: Int32 - /// The video height. - public let height: Int32 - - /// Creates a VideoSize object. - public init(width: Int32, height: Int32) { - self.width = width - self.height = height - } - - /// Swap width for height. - public func swap() -> VideoSize { - return VideoSize(width: height, height: width) - } -} diff --git a/Sources/Extension/ExpressibleByIntegerLiteral+Extension.swift b/Sources/Extension/ExpressibleByIntegerLiteral+Extension.swift index f28be0e61..18e73618b 100644 --- a/Sources/Extension/ExpressibleByIntegerLiteral+Extension.swift +++ b/Sources/Extension/ExpressibleByIntegerLiteral+Extension.swift @@ -2,8 +2,9 @@ import Foundation extension ExpressibleByIntegerLiteral { var data: Data { - var value: Self = self - return Data(bytes: &value, count: MemoryLayout.size) + return withUnsafePointer(to: self) { value in + return Data(bytes: UnsafeRawPointer(value), count: MemoryLayout.size) + } } init(data: Data) { diff --git a/Sources/HTTP/HTTPStream.swift b/Sources/HTTP/HTTPStream.swift index 14c41cafb..f774d5ec8 100644 --- a/Sources/HTTP/HTTPStream.swift +++ b/Sources/HTTP/HTTPStream.swift @@ -32,7 +32,7 @@ open class HTTPStream: NetStream { } #if os(iOS) || os(macOS) - override open func attachCamera(_ device: AVCaptureDevice?, onError: ((Error) -> Void)? = nil) { + override open func attachCamera(_ device: AVCaptureDevice?, onError: ((any Error) -> Void)? = nil) { if device == nil { tsWriter.expectedMedias.remove(.video) } else { @@ -41,7 +41,7 @@ open class HTTPStream: NetStream { super.attachCamera(device, onError: onError) } - override open func attachAudio(_ device: AVCaptureDevice?, automaticallyConfiguresApplicationAudioSession: Bool = true, onError: ((Error) -> Void)? = nil) { + override open func attachAudio(_ device: AVCaptureDevice?, automaticallyConfiguresApplicationAudioSession: Bool = true, onError: ((any Error) -> Void)? = nil) { if device == nil { tsWriter.expectedMedias.remove(.audio) } else { diff --git a/Sources/Media/IOMixer.swift b/Sources/Media/IOMixer.swift index bccd3185e..8834aa1c7 100644 --- a/Sources/Media/IOMixer.swift +++ b/Sources/Media/IOMixer.swift @@ -381,8 +381,8 @@ extension IOMixer: Running { let isMultiCamSupported = true #endif guard let device = error.device, let format = device.videoFormat( - width: sessionPreset.width ?? videoIO.codec.settings.videoSize.width, - height: sessionPreset.height ?? videoIO.codec.settings.videoSize.height, + width: sessionPreset.width ?? Int32(videoIO.codec.settings.videoSize.width), + height: sessionPreset.height ?? Int32(videoIO.codec.settings.videoSize.height), frameRate: videoIO.frameRate, isMultiCamSupported: isMultiCamSupported ), device.activeFormat != format else { diff --git a/Sources/Media/IORecorder.swift b/Sources/Media/IORecorder.swift index eb13f964e..0776e471a 100644 --- a/Sources/Media/IORecorder.swift +++ b/Sources/Media/IORecorder.swift @@ -17,13 +17,13 @@ public class IORecorder { /// The IORecorder error domain codes. public enum Error: Swift.Error { /// Failed to create the AVAssetWriter. - case failedToCreateAssetWriter(error: Swift.Error) + case failedToCreateAssetWriter(error: any Swift.Error) /// Failed to create the AVAssetWriterInput. case failedToCreateAssetWriterInput(error: NSException) /// Failed to append the PixelBuffer or SampleBuffer. - case failedToAppend(error: Swift.Error?) + case failedToAppend(error: (any Swift.Error)?) /// Failed to finish writing the AVAssetWriter. - case failedToFinishWriting(error: Swift.Error?) + case failedToFinishWriting(error: (any Swift.Error)?) } /// The default output settings for an IORecorder. diff --git a/Sources/Media/IOUIScreenCaptureUnit.swift b/Sources/Media/IOUIScreenCaptureUnit.swift index 74c42ec72..8204e302d 100644 --- a/Sources/Media/IOUIScreenCaptureUnit.swift +++ b/Sources/Media/IOUIScreenCaptureUnit.swift @@ -13,7 +13,7 @@ private extension CGRect { // MARK: - /// The IOUIScreenCaptureUnit class captures the UIView. public class IOUIScreenCaptureUnit: NSObject, IOScreenCaptureUnit { - static let defaultFrameInterval: Int = 2 + static let defaultPreferredFramesPerSecond: Int = 30 static let defaultAttributes: [NSString: NSObject] = [ kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32BGRA), kCVPixelBufferCGBitmapContextCompatibilityKey: true as NSObject @@ -24,7 +24,7 @@ public class IOUIScreenCaptureUnit: NSObject, IOScreenCaptureUnit { /// Specifies the boolean value that indicates whether the snapshot should be rendered after recent changes have been incorporated. public var afterScreenUpdates = false /// Specifies the number of shaphot that must pass before the display link notifies the target again. - public var frameInterval: Int = IOUIScreenCaptureUnit.defaultFrameInterval + public var preferredFramesPerSecond: Int = IOUIScreenCaptureUnit.defaultPreferredFramesPerSecond /// Specifies the CVPixelBufferPool's attrivutes. public var attributes: [NSString: NSObject] { var attributes: [NSString: NSObject] = IOUIScreenCaptureUnit.defaultAttributes @@ -153,7 +153,7 @@ extension IOUIScreenCaptureUnit: Running { self.pixelBufferPool = nil self.colorSpace = CGColorSpaceCreateDeviceRGB() self.displayLink = CADisplayLink(target: self, selector: #selector(onScreen)) - self.displayLink.frameInterval = self.frameInterval + self.displayLink.preferredFramesPerSecond = self.preferredFramesPerSecond self.displayLink.add(to: .main, forMode: .common) } } diff --git a/Sources/Net/NetStream.swift b/Sources/Net/NetStream.swift index 908565106..cd581644a 100644 --- a/Sources/Net/NetStream.swift +++ b/Sources/Net/NetStream.swift @@ -191,7 +191,7 @@ open class NetStream: NSObject { #if os(iOS) || os(macOS) /// Attaches the primary camera object. /// - Warning: This method can't use appendSampleBuffer at the same time. - open func attachCamera(_ device: AVCaptureDevice?, onError: ((_ error: Error) -> Void)? = nil) { + open func attachCamera(_ device: AVCaptureDevice?, onError: ((_ error: any Error) -> Void)? = nil) { lockQueue.async { do { try self.mixer.videoIO.attachCamera(device) @@ -204,7 +204,7 @@ open class NetStream: NSObject { /// Attaches the 2ndary camera object for picture in picture. /// - Warning: This method can't use appendSampleBuffer at the same time. @available(iOS 13.0, *) - open func attachMultiCamera(_ device: AVCaptureDevice?, onError: ((_ error: Error) -> Void)? = nil) { + open func attachMultiCamera(_ device: AVCaptureDevice?, onError: ((_ error: any Error) -> Void)? = nil) { lockQueue.async { do { try self.mixer.videoIO.attachMultiCamera(device) @@ -216,7 +216,7 @@ open class NetStream: NSObject { /// Attaches the audio capture object. /// - Warning: This method can't use appendSampleBuffer at the same time. - open func attachAudio(_ device: AVCaptureDevice?, automaticallyConfiguresApplicationAudioSession: Bool = false, onError: ((_ error: Error) -> Void)? = nil) { + open func attachAudio(_ device: AVCaptureDevice?, automaticallyConfiguresApplicationAudioSession: Bool = false, onError: ((_ error: any Error) -> Void)? = nil) { lockQueue.async { do { try self.mixer.audioIO.attachAudio(device, automaticallyConfiguresApplicationAudioSession: automaticallyConfiguresApplicationAudioSession) diff --git a/Sources/RTMP/RTMPStream.swift b/Sources/RTMP/RTMPStream.swift index 2711f977a..5a9720b31 100644 --- a/Sources/RTMP/RTMPStream.swift +++ b/Sources/RTMP/RTMPStream.swift @@ -411,7 +411,7 @@ open class RTMPStream: NetStream { } /// Creates flv metadata for a stream. - open func createMetaData() -> ASObject { + open func makeMetaData() -> ASObject { var metadata: [String: Any] = [:] #if os(iOS) || os(macOS) if mixer.videoIO.capture.device != nil { @@ -521,7 +521,7 @@ open class RTMPStream: NetStream { dataTimeStamps.removeAll() FCPublish() case .publishing: - send(handlerName: "@setDataFrame", arguments: "onMetaData", createMetaData()) + send(handlerName: "@setDataFrame", arguments: "onMetaData", makeMetaData()) mixer.startEncoding(muxer) default: break diff --git a/Sources/RTMP/RTMPTSocket.swift b/Sources/RTMP/RTMPTSocket.swift index 7eba4e2eb..bb2429242 100644 --- a/Sources/RTMP/RTMPTSocket.swift +++ b/Sources/RTMP/RTMPTSocket.swift @@ -119,14 +119,14 @@ final class RTMPTSocket: NSObject, RTMPSocketCompatible { doRequest("/close/\(connectionID)", Data(), didClose) } - private func listen(data: Data?, response: URLResponse?, error: Error?) { + private func listen(data: Data?, response: URLResponse?, error: (any Error)?) { lastResponse = Date() if logger.isEnabledFor(level: .trace) { logger.trace("\(String(describing: data)): \(String(describing: response)): \(String(describing: error))") } - if let error: Error = error { + if let error { logger.error("\(error)") if let lastRequestPathComponent: String = self.lastRequestPathComponent, @@ -193,8 +193,8 @@ final class RTMPTSocket: NSObject, RTMPSocketCompatible { } } - private func didIdent2(data: Data?, response: URLResponse?, error: Error?) { - if let error: Error = error { + private func didIdent2(data: Data?, response: URLResponse?, error: (any Error)?) { + if let error { logger.error("\(error)") } doRequest("/open/1", Data([0x00]), didOpen) @@ -203,8 +203,8 @@ final class RTMPTSocket: NSObject, RTMPSocketCompatible { } } - private func didOpen(data: Data?, response: URLResponse?, error: Error?) { - if let error: Error = error { + private func didOpen(data: Data?, response: URLResponse?, error: (any Error)?) { + if let error { logger.error("\(error)") } guard let data: Data = data else { @@ -217,8 +217,8 @@ final class RTMPTSocket: NSObject, RTMPSocketCompatible { } } - private func didIdle0(data: Data?, response: URLResponse?, error: Error?) { - if let error: Error = error { + private func didIdle0(data: Data?, response: URLResponse?, error: (any Error)?) { + if let error { logger.error("\(error)") } connected = true @@ -227,8 +227,8 @@ final class RTMPTSocket: NSObject, RTMPSocketCompatible { } } - private func didClose(data: Data?, response: URLResponse?, error: Error?) { - if let error: Error = error { + private func didClose(data: Data?, response: URLResponse?, error: (any Error)?) { + if let error { logger.error("\(error)") } connected = false @@ -246,7 +246,7 @@ final class RTMPTSocket: NSObject, RTMPSocketCompatible { } } - private func didIdle(data: Data?, response: URLResponse?, error: Error?) { + private func didIdle(data: Data?, response: URLResponse?, error: (any Error)?) { listen(data: data, response: response, error: error) } @@ -268,7 +268,7 @@ final class RTMPTSocket: NSObject, RTMPSocketCompatible { return data.count } - private func doRequest(_ pathComponent: String, _ data: Data, _ completionHandler: @escaping ((Data?, URLResponse?, Error?) -> Void)) { + private func doRequest(_ pathComponent: String, _ data: Data, _ completionHandler: @escaping ((Data?, URLResponse?, (any Error)?) -> Void)) { isRequesting = true lastRequestPathComponent = pathComponent lastRequestData = data diff --git a/Tests/Codec/VideoCodecTests.swift b/Tests/Codec/VideoCodecTests.swift deleted file mode 100644 index 29095b27f..000000000 --- a/Tests/Codec/VideoCodecTests.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation -import XCTest -import AVFoundation - -@testable import HaishinKit - -final class VideoCodecTests: XCTestCase { -} - diff --git a/Tests/Extension/ExpressibleByIntegerLiteral+ExtensionTests.swift b/Tests/Extension/ExpressibleByIntegerLiteral+ExtensionTests.swift new file mode 100644 index 000000000..4f4b43ba1 --- /dev/null +++ b/Tests/Extension/ExpressibleByIntegerLiteral+ExtensionTests.swift @@ -0,0 +1,30 @@ +import Foundation +import XCTest + +@testable import HaishinKit + +final class ExpressibleByIntegerLiteralTests: XCTestCase { + func testInt32() { + XCTAssertEqual(Int32.min.bigEndian.data, Data([128, 0, 0, 0])) + XCTAssertEqual(Int32(32).bigEndian.data, Data([0, 0, 0, 32])) + XCTAssertEqual(Int32.max.bigEndian.data, Data([127, 255, 255, 255])) + } + + func testUInt32() { + XCTAssertEqual(UInt32.min.bigEndian.data, Data([0, 0, 0, 0])) + XCTAssertEqual(UInt32(32).bigEndian.data, Data([0, 0, 0, 32])) + XCTAssertEqual(UInt32.max.bigEndian.data, Data([255, 255, 255, 255])) + } + + func testInt64() { + XCTAssertEqual(Int64.min.bigEndian.data, Data([128, 0, 0, 0, 0, 0, 0, 0])) + XCTAssertEqual(Int64(32).bigEndian.data, Data([0, 0, 0, 0, 0, 0, 0, 32])) + XCTAssertEqual(Int64.max.bigEndian.data, Data([127,255,255, 255, 255, 255, 255, 255])) + } + + func testUInt64() { + XCTAssertEqual(UInt64.min.bigEndian.data, Data([0, 0, 0, 0, 0, 0, 0, 0])) + XCTAssertEqual(UInt64(32).bigEndian.data, Data([0, 0, 0, 0, 0, 0, 0, 32])) + XCTAssertEqual(UInt64.max.bigEndian.data, Data([255, 255, 255, 255, 255, 255, 255, 255])) + } +} diff --git a/Tests/HTTP/HTTPRequestTests.swift b/Tests/HTTP/HTTPRequestTests.swift deleted file mode 100644 index 9a5917197..000000000 --- a/Tests/HTTP/HTTPRequestTests.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Foundation -import XCTest - -@testable import HaishinKit - -final class HTTPRequestTests: XCTestCase { - - static let data: [UInt8] = [71, 69, 84, 32, 47, 104, 111, 103, 101, 47, 116, 101, 115, 116, 46, 116, 115, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72, 111, 115, 116, 58, 32, 49, 57, 50, 46, 49, 54, 56, 46, 49, 55, 57, 46, 52, 58, 56, 48, 56, 48, 13, 10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 107, 101, 101, 112, 45, 97, 108, 105, 118, 101, 13, 10, 65, 99, 99, 101, 112, 116, 58, 32, 116, 101, 120, 116, 47, 104, 116, 109, 108, 44, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 120, 104, 116, 109, 108, 43, 120, 109, 108, 44, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 120, 109, 108, 59, 113, 61, 48, 46, 57, 44, 105, 109, 97, 103, 101, 47, 119, 101, 98, 112, 44, 42, 47, 42, 59, 113, 61, 48, 46, 56, 13, 10, 85, 112, 103, 114, 97, 100, 101, 45, 73, 110, 115, 101, 99, 117, 114, 101, 45, 82, 101, 113, 117, 101, 115, 116, 115, 58, 32, 49, 13, 10, 85, 115, 101, 114, 45, 65, 103, 101, 110, 116, 58, 32, 77, 111, 122, 105, 108, 108, 97, 47, 53, 46, 48, 32, 40, 77, 97, 99, 105, 110, 116, 111, 115, 104, 59, 32, 73, 110, 116, 101, 108, 32, 77, 97, 99, 32, 79, 83, 32, 88, 32, 49, 48, 95, 49, 49, 95, 52, 41, 32, 65, 112, 112, 108, 101, 87, 101, 98, 75, 105, 116, 47, 53, 51, 55, 46, 51, 54, 32, 40, 75, 72, 84, 77, 76, 44, 32, 108, 105, 107, 101, 32, 71, 101, 99, 107, 111, 41, 32, 67, 104, 114, 111, 109, 101, 47, 52, 57, 46, 48, 46, 50, 54, 50, 51, 46, 49, 49, 50, 32, 83, 97, 102, 97, 114, 105, 47, 53, 51, 55, 46, 51, 54, 32, 70, 105, 114, 101, 80, 72, 80, 47, 52, 67, 104, 114, 111, 109, 101, 13, 10, 65, 99, 99, 101, 112, 116, 45, 69, 110, 99, 111, 100, 105, 110, 103, 58, 32, 103, 122, 105, 112, 44, 32, 100, 101, 102, 108, 97, 116, 101, 44, 32, 115, 100, 99, 104, 13, 10, 65, 99, 99, 101, 112, 116, 45, 76, 97, 110, 103, 117, 97, 103, 101, 58, 32, 106, 97, 44, 101, 110, 45, 85, 83, 59, 113, 61, 48, 46, 56, 44, 101, 110, 59, 113, 61, 48, 46, 54, 13, 10, 88, 45, 70, 105, 114, 101, 80, 72, 80, 45, 86, 101, 114, 115, 105, 111, 110, 58, 32, 48, 46, 48, 46, 54, 13, 10, 88, 45, 87, 102, 45, 77, 97, 120, 45, 67, 111, 109, 98, 105, 110, 101, 100, 45, 83, 105, 122, 101, 58, 32, 50, 54, 49, 49, 50, 48, 13, 10, 13, 10] - - func testHTTPRequest() { - // var request: HTTPRequest = HTTPRequest(bytes: data) - // request.bytes = HTTPRequestTests.data - } -} diff --git a/Tests/Media/IOAudioMonitorRingBufferTests.swift b/Tests/Media/IOAudioMonitorRingBufferTests.swift index 869319b51..0fab920e3 100644 --- a/Tests/Media/IOAudioMonitorRingBufferTests.swift +++ b/Tests/Media/IOAudioMonitorRingBufferTests.swift @@ -43,7 +43,7 @@ final class IOAudioMonitorRingBufferTests: XCTestCase { readBuffer.frameLength = AVAudioFrameCount(numSamples) for _ in 0..<30 { buffer?.appendSampleBuffer(sinWave) - readBuffer.int16ChannelData?[0].assign(repeating: 0, count: numSamples) + readBuffer.int16ChannelData?[0].update(repeating: 0, count: numSamples) _ = buffer?.render(UInt32(numSamples), ioData: readBuffer.mutableAudioBufferList) XCTAssertEqual(sinWave.dataBuffer?.data?.bytes, Data(bytes: bufferList[0].mData!, count: numSamples * Int(channels) * 2).bytes) } diff --git a/Tests/Net/NetStreamTests.swift b/Tests/Net/NetStreamTests.swift deleted file mode 100644 index 8a947acc9..000000000 --- a/Tests/Net/NetStreamTests.swift +++ /dev/null @@ -1,7 +0,0 @@ -import Foundation -import XCTest - -@testable import HaishinKit - -final class NetStreamTests: XCTestCase { -}