diff --git a/ApiVideoLiveStream.podspec b/ApiVideoLiveStream.podspec index 76bd114..a50fdf8 100644 --- a/ApiVideoLiveStream.podspec +++ b/ApiVideoLiveStream.podspec @@ -24,6 +24,6 @@ Pod::Spec.new do |spec| spec.source_files = "Sources/**/*.{h,m,swift}" spec.exclude_files = "Sources/Exclude" - spec.dependency "HaishinKit", "1.7.2" + spec.dependency "HaishinKit", "1.7.3" end diff --git a/Examples/ExampleUIKit/ExampleUIKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Examples/ExampleUIKit/ExampleUIKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 29bf2a6..8d26adc 100644 --- a/Examples/ExampleUIKit/ExampleUIKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Examples/ExampleUIKit/ExampleUIKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/shogo4405/HaishinKit.swift", "state" : { - "revision" : "a7ae921e0cfce28057b610bd3374fd057c5c1b65", - "version" : "1.7.1" + "revision" : "0fdd6b0046964161e3a7d263685ac1737e57a341", + "version" : "1.7.3" } }, { diff --git a/Package.resolved b/Package.resolved index 1956df2..623a1a7 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/shogo4405/HaishinKit.swift", "state" : { - "revision" : "4d16635e4d5011c923fbf79cc2dcfdbc70821ab0", - "version" : "1.7.2" + "revision" : "0fdd6b0046964161e3a7d263685ac1737e57a341", + "version" : "1.7.3" } }, { diff --git a/Package.swift b/Package.swift index 44b0d90..e0feb9d 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), - .package(url: "https://github.com/shogo4405/HaishinKit.swift", from: "1.7.2") + .package(url: "https://github.com/shogo4405/HaishinKit.swift", from: "1.7.3") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/ApiVideoLiveStream/ApiVideoLiveStream.swift b/Sources/ApiVideoLiveStream/ApiVideoLiveStream.swift index d616e23..9ced1d2 100644 --- a/Sources/ApiVideoLiveStream/ApiVideoLiveStream.swift +++ b/Sources/ApiVideoLiveStream/ApiVideoLiveStream.swift @@ -246,7 +246,7 @@ public class ApiVideoLiveStream { /// - initialVideoConfig: The ApiVideoLiveStream's new VideoConfig /// - initialCamera: The ApiVideoLiveStream's initial camera device public convenience init( - preview: NetStreamDrawable, + preview: IOStreamDrawable, initialAudioConfig: AudioConfig? = AudioConfig(), initialVideoConfig: VideoConfig? = VideoConfig(), initialCamera: AVCaptureDevice? = AVCaptureDevice.default( @@ -281,37 +281,39 @@ public class ApiVideoLiveStream { private func attachCamera(_ camera: AVCaptureDevice?) { self.lastCamera = camera - let capture = self.rtmpStream.videoCapture(for: 0) - if let camera = camera { + self.rtmpStream.attachCamera(camera, channel: 0) { videoCaptureUnit, error in + if let error { + print("======== Camera error ==========") + print(error) + self.delegate?.videoError(error) + return + } + + if let camera { + videoCaptureUnit?.isVideoMirrored = camera.position == .front + } #if os(iOS) - // capture.preferredVideoStabilizationMode = AVCaptureVideoStabilizationMode + // videoCaptureUnit.preferredVideoStabilizationMode = AVCaptureVideoStabilizationMode // .auto // Add latency to video #endif - capture?.isVideoMirrored = camera.position == .front - } - - self.rtmpStream.attachCamera(camera) { error in - print("======== Camera error ==========") - print(error) - self.delegate?.videoError(error) - } - self.rtmpStream.lockQueue.async { - guard let device = capture?.device else { + guard let device = videoCaptureUnit?.device else { return } - do { - try device.lockForConfiguration() - if device.isExposureModeSupported(.continuousAutoExposure) { - device.exposureMode = .continuousAutoExposure + self.rtmpStream.lockQueue.async { + do { + try device.lockForConfiguration() + if device.isExposureModeSupported(.continuousAutoExposure) { + device.exposureMode = .continuousAutoExposure + } + if device.isFocusModeSupported(.continuousAutoFocus) { + device.focusMode = .continuousAutoFocus + } + device.unlockForConfiguration() + } catch { + print("Could not lock device for exposure and focus: \(error)") } - if device.isFocusModeSupported(.continuousAutoFocus) { - device.focusMode = .continuousAutoFocus - } - device.unlockForConfiguration() - } catch { - print("Could not lock device for exposure and focus: \(error)") } } } @@ -395,7 +397,7 @@ public class ApiVideoLiveStream { } public func stopPreview() { - self.rtmpStream.attachCamera(nil) + self.rtmpStream.attachCamera(nil, channel: 0) self.rtmpStream.attachAudio(nil) } @@ -423,7 +425,6 @@ public class ApiVideoLiveStream { if level == "error" { self.delegate?.connectionFailed(code) } - break } }