From f306b737c69a1c6539f4e1fd8776369befa93273 Mon Sep 17 00:00:00 2001 From: shogo4405 Date: Tue, 11 Jun 2024 21:36:25 +0900 Subject: [PATCH] Suppress Warnigns. --- SRTHaishinKit/SRTSocket.swift | 3 +-- SRTHaishinKit/SRTSocketOption.swift | 10 ++++------ Sources/IO/IOStreamRecorder.swift | 12 ++++-------- Sources/RTMP/RTMPStream.swift | 2 +- Sources/Util/DeviceUtil.swift | 3 ++- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/SRTHaishinKit/SRTSocket.swift b/SRTHaishinKit/SRTSocket.swift index e658d343b..eb482cfae 100644 --- a/SRTHaishinKit/SRTSocket.swift +++ b/SRTHaishinKit/SRTSocket.swift @@ -3,7 +3,6 @@ import HaishinKit import libsrt import Logboard -private let kSRTSocket_defaultOptions: [SRTSocketOption: Any] = [:] private let kSRTSOcket_payloadSize: Int = 1316 protocol SRTSocketDelegate: AnyObject { @@ -71,7 +70,7 @@ final class SRTSocket { } } - func open(_ addr: sockaddr_in, mode: SRTMode, options: [SRTSocketOption: Any] = kSRTSocket_defaultOptions) throws { + func open(_ addr: sockaddr_in, mode: SRTMode, options: [SRTSocketOption: Any] = [:]) throws { guard socket == SRT_INVALID_SOCK else { return } diff --git a/SRTHaishinKit/SRTSocketOption.swift b/SRTHaishinKit/SRTSocketOption.swift index 44a4c1235..5c3538106 100644 --- a/SRTHaishinKit/SRTSocketOption.swift +++ b/SRTHaishinKit/SRTSocketOption.swift @@ -1,11 +1,6 @@ import Foundation import libsrt -private let enummapTranstype: [String: Any] = [ - "live": SRTT_LIVE, - "file": SRTT_FILE -] - public enum SRTSocketOption: String, Sendable { static func from(uri: URL?) -> [SRTSocketOption: Any] { guard let uri = uri else { @@ -360,7 +355,10 @@ public enum SRTSocketOption: String, Sendable { var valmap: [String: Any]? { switch self { case .transtype: - return enummapTranstype + return [ + "live": SRTT_LIVE, + "file": SRTT_FILE + ] default: return nil } diff --git a/Sources/IO/IOStreamRecorder.swift b/Sources/IO/IOStreamRecorder.swift index 171f30330..e4c395dc7 100644 --- a/Sources/IO/IOStreamRecorder.swift +++ b/Sources/IO/IOStreamRecorder.swift @@ -25,9 +25,10 @@ public final class IOStreamRecorder { /// Failed to finish writing the AVAssetWriter. case failedToFinishWriting(error: (any Swift.Error)?) } - - /// The default output settings for a recording. - public static let defaultSettings: [AVMediaType: [String: Any]] = [ + /// Specifies the delegate. + public weak var delegate: (any IOStreamRecorderDelegate)? + /// Specifies the recorder settings. + public var settings: [AVMediaType: [String: Any]] = [ .audio: [ AVFormatIDKey: Int(kAudioFormatMPEG4AAC), AVSampleRateKey: 0, @@ -39,11 +40,6 @@ public final class IOStreamRecorder { AVVideoWidthKey: 0 ] ] - - /// Specifies the delegate. - public weak var delegate: (any IOStreamRecorderDelegate)? - /// Specifies the recorder settings. - public var settings: [AVMediaType: [String: Any]] = IOStreamRecorder.defaultSettings /// Specifies the file name. nil will generate a unique file name. public var fileName: String? /// The running indicies whether recording or not. diff --git a/Sources/RTMP/RTMPStream.swift b/Sources/RTMP/RTMPStream.swift index d282aa693..56320f13d 100644 --- a/Sources/RTMP/RTMPStream.swift +++ b/Sources/RTMP/RTMPStream.swift @@ -138,7 +138,7 @@ open class RTMPStream: IOStream { } /// The type of publish options. - public enum HowToPublish: String { + public enum HowToPublish: String, Sendable { /// Publish with server-side recording. case record /// Publish with server-side recording which is to append file if exists. diff --git a/Sources/Util/DeviceUtil.swift b/Sources/Util/DeviceUtil.swift index 49493b196..c0530049d 100644 --- a/Sources/Util/DeviceUtil.swift +++ b/Sources/Util/DeviceUtil.swift @@ -5,8 +5,9 @@ import UIKit /// The namespace of DeviceUtil. public enum DeviceUtil { /// Looks up the AVCaptureVideoOrientation by a Notification. + @MainActor public static func videoOrientation(by notification: Notification) -> AVCaptureVideoOrientation? { - guard let device: UIDevice = notification.object as? UIDevice else { + guard let device = notification.object as? UIDevice else { return nil } return videoOrientation(by: device.orientation)