From 5d3f8654ce20439f763fe391fdf42c67c3fd0e46 Mon Sep 17 00:00:00 2001 From: shogo4405 Date: Sat, 22 Jun 2024 16:13:57 +0900 Subject: [PATCH] Rename Preference.default --- Examples/iOS/IngestViewController.swift | 2 +- Examples/iOS/NetStreamSwitcher.swift | 8 ++++---- Examples/iOS/PlaybackViewController.swift | 2 +- Examples/iOS/Preference.swift | 2 +- Examples/iOS/PreferenceViewController.swift | 8 ++++---- Examples/iOS/Screencast/SampleHandler.swift | 6 +++--- Examples/iOSSwiftUI/Model/ViewModel.swift | 10 +++++----- Examples/macOS/CameraIngestViewController.swift | 4 ++-- Examples/macOS/PlaybackViewController.swift | 2 +- Examples/macOS/PreferenceViewController.swift | 8 ++++---- Examples/macOS/SCStreamPublishViewController.swift | 4 ++-- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Examples/iOS/IngestViewController.swift b/Examples/iOS/IngestViewController.swift index 98fc68885..3b9fa36d9 100644 --- a/Examples/iOS/IngestViewController.swift +++ b/Examples/iOS/IngestViewController.swift @@ -36,7 +36,7 @@ final class IngestViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - netStreamSwitcher.uri = Preference.defaultInstance.uri ?? "" + netStreamSwitcher.uri = Preference.default.uri ?? "" stream.screen.size = .init(width: 720, height: 1280) stream.screen.backgroundColor = UIColor.white.cgColor diff --git a/Examples/iOS/NetStreamSwitcher.swift b/Examples/iOS/NetStreamSwitcher.swift index d1f50244a..5b8a11ce5 100644 --- a/Examples/iOS/NetStreamSwitcher.swift +++ b/Examples/iOS/NetStreamSwitcher.swift @@ -62,7 +62,7 @@ final class NetStreamSwitcher { switch method { case .ingest: // Performing operations for FMLE compatibility purposes. - (stream as? RTMPStream)?.fcPublishName = Preference.defaultInstance.streamName + (stream as? RTMPStream)?.fcPublishName = Preference.default.streamName case .playback: break } @@ -120,9 +120,9 @@ final class NetStreamSwitcher { retryCount = 0 switch method { case .playback: - (stream as? RTMPStream)?.play(Preference.defaultInstance.streamName!) + (stream as? RTMPStream)?.play(Preference.default.streamName!) case .ingest: - (stream as? RTMPStream)?.publish(Preference.defaultInstance.streamName!) + (stream as? RTMPStream)?.publish(Preference.default.streamName!) } case RTMPConnection.Code.connectFailed.rawValue, RTMPConnection.Code.connectClosed.rawValue: guard retryCount <= NetStreamSwitcher.maxRetryCount else { @@ -139,7 +139,7 @@ final class NetStreamSwitcher { @objc private func rtmpErrorHandler(_ notification: Notification) { logger.error(notification) - (connection as? RTMPConnection)?.connect(Preference.defaultInstance.uri!) + (connection as? RTMPConnection)?.connect(Preference.default.uri!) } } diff --git a/Examples/iOS/PlaybackViewController.swift b/Examples/iOS/PlaybackViewController.swift index b49005525..221532767 100644 --- a/Examples/iOS/PlaybackViewController.swift +++ b/Examples/iOS/PlaybackViewController.swift @@ -15,7 +15,7 @@ final class PlaybackViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { logger.info("viewWillAppear") super.viewWillAppear(animated) - netStreamSwitcher.uri = Preference.defaultInstance.uri ?? "" + netStreamSwitcher.uri = Preference.default.uri ?? "" (view as? (any IOStreamView))?.attachStream(stream) if #available(iOS 15.0, *), let layer = view.layer as? AVSampleBufferDisplayLayer, pictureInPictureController == nil { pictureInPictureController = AVPictureInPictureController(contentSource: .init(sampleBufferDisplayLayer: layer, playbackDelegate: self)) diff --git a/Examples/iOS/Preference.swift b/Examples/iOS/Preference.swift index 792697361..79070e450 100644 --- a/Examples/iOS/Preference.swift +++ b/Examples/iOS/Preference.swift @@ -1,5 +1,5 @@ struct Preference { - static var defaultInstance = Preference() + static var `default` = Preference() var uri: String? = "rtmp://192.168.1.6/live" var streamName: String? = "live" diff --git a/Examples/iOS/PreferenceViewController.swift b/Examples/iOS/PreferenceViewController.swift index 36c5a0d59..6bd386eea 100644 --- a/Examples/iOS/PreferenceViewController.swift +++ b/Examples/iOS/PreferenceViewController.swift @@ -6,8 +6,8 @@ final class PreferenceViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - urlField?.text = Preference.defaultInstance.uri - streamNameField?.text = Preference.defaultInstance.streamName + urlField?.text = Preference.default.uri + streamNameField?.text = Preference.default.streamName } @IBAction func on(open: UIButton) { @@ -20,10 +20,10 @@ final class PreferenceViewController: UIViewController { extension PreferenceViewController: UITextFieldDelegate { func textFieldShouldReturn(_ textField: UITextField) -> Bool { if urlField == textField { - Preference.defaultInstance.uri = textField.text + Preference.default.uri = textField.text } if streamNameField == textField { - Preference.defaultInstance.streamName = textField.text + Preference.default.streamName = textField.text } textField.resignFirstResponder() return true diff --git a/Examples/iOS/Screencast/SampleHandler.swift b/Examples/iOS/Screencast/SampleHandler.swift index 371cdb511..cbceeafbd 100644 --- a/Examples/iOS/Screencast/SampleHandler.swift +++ b/Examples/iOS/Screencast/SampleHandler.swift @@ -47,7 +47,7 @@ open class SampleHandler: RPBroadcastSampleHandler { LBLogger.with(HaishinKitIdentifier).level = .info // rtmpStream.audioMixerSettings = .init(sampleRate: 0, channels: 2) rtmpStream.audioMixerSettings.tracks[1] = .default - rtmpConnection.connect(Preference.defaultInstance.uri!, arguments: nil) + rtmpConnection.connect(Preference.default.uri!, arguments: nil) // The volume of the audioApp can be obtained even when muted. A hack to synchronize with the volume. DispatchQueue.main.async { let volumeView = MPVolumeView(frame: CGRect.zero) @@ -97,7 +97,7 @@ open class SampleHandler: RPBroadcastSampleHandler { @objc private func rtmpErrorHandler(_ notification: Notification) { logger.info(notification) - rtmpConnection.connect(Preference.defaultInstance.uri!) + rtmpConnection.connect(Preference.default.uri!) } @objc @@ -111,7 +111,7 @@ open class SampleHandler: RPBroadcastSampleHandler { } switch code { case RTMPConnection.Code.connectSuccess.rawValue: - rtmpStream.publish(Preference.defaultInstance.streamName!) + rtmpStream.publish(Preference.default.streamName!) default: break } diff --git a/Examples/iOSSwiftUI/Model/ViewModel.swift b/Examples/iOSSwiftUI/Model/ViewModel.swift index 7cfe55977..61d5e13df 100644 --- a/Examples/iOSSwiftUI/Model/ViewModel.swift +++ b/Examples/iOSSwiftUI/Model/ViewModel.swift @@ -133,11 +133,11 @@ final class ViewModel: ObservableObject { func startPublish() { UIApplication.shared.isIdleTimerDisabled = true - logger.info(Preference.defaultInstance.uri!) + logger.info(Preference.default.uri!) rtmpConnection.addEventListener(.rtmpStatus, selector: #selector(rtmpStatusHandler), observer: self) rtmpConnection.addEventListener(.ioError, selector: #selector(rtmpErrorHandler), observer: self) - rtmpConnection.connect(Preference.defaultInstance.uri!) + rtmpConnection.connect(Preference.default.uri!) } func stopPublish() { @@ -211,14 +211,14 @@ final class ViewModel: ObservableObject { switch code { case RTMPConnection.Code.connectSuccess.rawValue: retryCount = 0 - rtmpStream.publish(Preference.defaultInstance.streamName!) + rtmpStream.publish(Preference.default.streamName!) // sharedObject!.connect(rtmpConnection) case RTMPConnection.Code.connectFailed.rawValue, RTMPConnection.Code.connectClosed.rawValue: guard retryCount <= maxRetryCount else { return } Thread.sleep(forTimeInterval: pow(2.0, Double(retryCount))) - rtmpConnection.connect(Preference.defaultInstance.uri!) + rtmpConnection.connect(Preference.default.uri!) retryCount += 1 default: break @@ -228,7 +228,7 @@ final class ViewModel: ObservableObject { @objc private func rtmpErrorHandler(_ notification: Notification) { logger.error(notification) - rtmpConnection.connect(Preference.defaultInstance.uri!) + rtmpConnection.connect(Preference.default.uri!) } } diff --git a/Examples/macOS/CameraIngestViewController.swift b/Examples/macOS/CameraIngestViewController.swift index 4ed1f5165..634ab7de2 100644 --- a/Examples/macOS/CameraIngestViewController.swift +++ b/Examples/macOS/CameraIngestViewController.swift @@ -25,10 +25,10 @@ final class CameraIngestViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() - urlField.stringValue = Preference.defaultInstance.uri ?? "" + urlField.stringValue = Preference.default.uri ?? "" audioPopUpButton?.present(mediaType: .audio) cameraPopUpButton?.present(mediaType: .video) - netStreamSwitcher.uri = Preference.defaultInstance.uri ?? "" + netStreamSwitcher.uri = Preference.default.uri ?? "" lfView?.attachStream(stream) } diff --git a/Examples/macOS/PlaybackViewController.swift b/Examples/macOS/PlaybackViewController.swift index 2dff3a928..4173b687c 100644 --- a/Examples/macOS/PlaybackViewController.swift +++ b/Examples/macOS/PlaybackViewController.swift @@ -11,7 +11,7 @@ final class PlaybackViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() - netStreamSwitcher.uri = Preference.defaultInstance.uri! + netStreamSwitcher.uri = Preference.default.uri! lfView.attachStream(stream) } diff --git a/Examples/macOS/PreferenceViewController.swift b/Examples/macOS/PreferenceViewController.swift index ea4a94773..5871fd87b 100644 --- a/Examples/macOS/PreferenceViewController.swift +++ b/Examples/macOS/PreferenceViewController.swift @@ -7,8 +7,8 @@ final class PreferenceViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() - urlField.stringValue = Preference.defaultInstance.uri ?? "" - streamNameField.stringValue = Preference.defaultInstance.streamName ?? "" + urlField.stringValue = Preference.default.uri ?? "" + streamNameField.stringValue = Preference.default.streamName ?? "" } } @@ -18,10 +18,10 @@ extension PreferenceViewController: NSTextFieldDelegate { return } if textFile == urlField { - Preference.defaultInstance.uri = textFile.stringValue + Preference.default.uri = textFile.stringValue } if textFile == streamNameField { - Preference.defaultInstance.streamName = textFile.stringValue + Preference.default.streamName = textFile.stringValue } } } diff --git a/Examples/macOS/SCStreamPublishViewController.swift b/Examples/macOS/SCStreamPublishViewController.swift index 4cefb2c9c..e898b6a96 100644 --- a/Examples/macOS/SCStreamPublishViewController.swift +++ b/Examples/macOS/SCStreamPublishViewController.swift @@ -37,8 +37,8 @@ class SCStreamPublishViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() - urlField.stringValue = Preference.defaultInstance.uri ?? "" - netStreamSwitcher.uri = Preference.defaultInstance.uri ?? "" + urlField.stringValue = Preference.default.uri ?? "" + netStreamSwitcher.uri = Preference.default.uri ?? "" mthkView?.attachStream(stream) if #available(macOS 12.3, *) { Task {