Skip to content

Commit

Permalink
Refactor any to some.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Jun 2, 2024
1 parent d041959 commit 6914dbd
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
5 changes: 1 addition & 4 deletions Examples/iOS/IngestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ final class IngestViewController: UIViewController {
stream.bitrateStrategy = IOStreamVideoAdaptiveBitRateStrategy(mamimumVideoBitrate: VideoCodecSettings.default.bitRate)
videoBitrateSlider?.value = Float(VideoCodecSettings.default.bitRate) / 1000
audioBitrateSlider?.value = Float(AudioCodecSettings.default.bitRate) / 1000

NotificationCenter.default.addObserver(self, selector: #selector(on(_:)), name: UIDevice.orientationDidChangeNotification, object: nil)
}

override func viewWillAppear(_ animated: Bool) {
Expand All @@ -79,6 +77,7 @@ final class IngestViewController: UIViewController {
}
stream.addObserver(self, forKeyPath: "currentFPS", options: .new, context: nil)
(view as? (any IOStreamView))?.attachStream(stream)
NotificationCenter.default.addObserver(self, selector: #selector(on(_:)), name: UIDevice.orientationDidChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didInterruptionNotification(_:)), name: AVAudioSession.interruptionNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didRouteChangeNotification(_:)), name: AVAudioSession.routeChangeNotification, object: nil)
}
Expand All @@ -91,8 +90,6 @@ final class IngestViewController: UIViewController {
stream.attachAudio(nil)
stream.attachCamera(nil, track: 0)
stream.attachCamera(nil, track: 1)
// swiftlint:disable:next notification_center_detachment
NotificationCenter.default.removeObserver(self)
}

// swiftlint:disable:next block_based_kvo
Expand Down
8 changes: 4 additions & 4 deletions Sources/IO/IOAudioMixer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ enum IOAudioMixerError: Swift.Error {
}

protocol IOAudioMixerDelegate: AnyObject {
func audioMixer(_ audioMixer: any IOAudioMixerConvertible, track: UInt8, didInput buffer: AVAudioPCMBuffer, when: AVAudioTime)
func audioMixer(_ audioMixer: any IOAudioMixerConvertible, didOutput audioFormat: AVAudioFormat)
func audioMixer(_ audioMixer: any IOAudioMixerConvertible, didOutput audioBuffer: AVAudioPCMBuffer, when: AVAudioTime)
func audioMixer(_ audioMixer: any IOAudioMixerConvertible, errorOccurred error: IOAudioUnitError)
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, track: UInt8, didInput buffer: AVAudioPCMBuffer, when: AVAudioTime)
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, didOutput audioFormat: AVAudioFormat)
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, didOutput audioBuffer: AVAudioPCMBuffer, when: AVAudioTime)
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, errorOccurred error: IOAudioUnitError)
}

protocol IOAudioMixerConvertible: AnyObject {
Expand Down
8 changes: 4 additions & 4 deletions Sources/IO/IOAudioUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,19 @@ extension IOAudioUnit: Running {

extension IOAudioUnit: IOAudioMixerDelegate {
// MARK: IOAudioMixerDelegate
func audioMixer(_ audioMixer: any IOAudioMixerConvertible, track: UInt8, didInput buffer: AVAudioPCMBuffer, when: AVAudioTime) {
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, track: UInt8, didInput buffer: AVAudioPCMBuffer, when: AVAudioTime) {
mixer?.audioUnit(self, track: track, didInput: buffer, when: when)
}

func audioMixer(_ audioMixer: any IOAudioMixerConvertible, errorOccurred error: IOAudioUnitError) {
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, errorOccurred error: IOAudioUnitError) {
mixer?.audioUnit(self, errorOccurred: error)
}

func audioMixer(_ audioMixer: any IOAudioMixerConvertible, didOutput audioFormat: AVAudioFormat) {
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, didOutput audioFormat: AVAudioFormat) {
monitor.inputFormat = audioFormat
}

func audioMixer(_ audioMixer: any IOAudioMixerConvertible, didOutput audioBuffer: AVAudioPCMBuffer, when: AVAudioTime) {
func audioMixer(_ audioMixer: some IOAudioMixerConvertible, didOutput audioBuffer: AVAudioPCMBuffer, when: AVAudioTime) {
mixer?.audioUnit(self, didOutput: audioBuffer, when: when)
monitor.append(audioBuffer, when: when)
codec.append(audioBuffer, when: when)
Expand Down
2 changes: 1 addition & 1 deletion Sources/IO/MediaLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ final class MediaLink<T: MediaLinkDelegate> {

extension MediaLink: ChoreographerDelegate {
// MARK: ChoreographerDelegate
func choreographer(_ choreographer: any Choreographer, didFrame duration: Double) {
func choreographer(_ choreographer: some Choreographer, didFrame duration: Double) {
guard let bufferQueue else {
return
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/RTMP/RTMPConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public class RTMPConnection: EventDispatcher {

extension RTMPConnection: RTMPSocketDelegate {
// MARK: RTMPSocketDelegate
func socket(_ socket: any RTMPSocketCompatible, readyState: RTMPSocketReadyState) {
func socket(_ socket: some RTMPSocketCompatible, readyState: RTMPSocketReadyState) {
if logger.isEnabledFor(level: .debug) {
logger.debug(readyState)
}
Expand All @@ -520,7 +520,7 @@ extension RTMPConnection: RTMPSocketDelegate {
}
}

func socket(_ socket: any RTMPSocketCompatible, totalBytesIn: Int64) {
func socket(_ socket: some RTMPSocketCompatible, totalBytesIn: Int64) {
guard windowSizeS * (sequence + 1) <= totalBytesIn else {
return
}
Expand All @@ -532,7 +532,7 @@ extension RTMPConnection: RTMPSocketDelegate {
sequence += 1
}

func socket(_ socket: any RTMPSocketCompatible, data: Data) {
func socket(_ socket: some RTMPSocketCompatible, data: Data) {
guard let chunk = currentChunk ?? RTMPChunk(data, size: socket.chunkSizeC) else {
socket.inputBuffer.append(data)
return
Expand Down
6 changes: 3 additions & 3 deletions Sources/RTMP/RTMPSocketCompatible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension RTMPSocketCompatible {
// MARK: -
// swiftlint:disable:next class_delegate_protocol
protocol RTMPSocketDelegate: EventDispatcherConvertible {
func socket(_ socket: any RTMPSocketCompatible, data: Data)
func socket(_ socket: any RTMPSocketCompatible, readyState: RTMPSocketReadyState)
func socket(_ socket: any RTMPSocketCompatible, totalBytesIn: Int64)
func socket(_ socket: some RTMPSocketCompatible, data: Data)
func socket(_ socket: some RTMPSocketCompatible, readyState: RTMPSocketReadyState)
func socket(_ socket: some RTMPSocketCompatible, totalBytesIn: Int64)
}
2 changes: 1 addition & 1 deletion Sources/Screen/Choreographer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ typealias DisplayLink = CADisplayLink
#endif

protocol ChoreographerDelegate: AnyObject {
func choreographer(_ choreographer: any Choreographer, didFrame duration: Double)
func choreographer(_ choreographer: some Choreographer, didFrame duration: Double)
}

protocol Choreographer: Running {
Expand Down

0 comments on commit 6914dbd

Please sign in to comment.