Skip to content

Commit

Permalink
Corrected the implementation of the readyState.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Dec 7, 2023
1 parent 1660479 commit 2965f9b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions SRTHaishinKit/SRTStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ public final class SRTStream: NetStream {
private var action: (() -> Void)?
private var keyValueObservations: [NSKeyValueObservation] = []
private weak var connection: SRTConnection?

private lazy var writer: TSWriter = {
private lazy var writer = {
var writer = TSWriter()
writer.delegate = self
return writer
}()

private lazy var reader: TSReader = {
private lazy var reader = {
var reader = TSReader()
reader.delegate = self
return reader
Expand Down Expand Up @@ -97,9 +95,11 @@ public final class SRTStream: NetStream {
}

override public func readyStateDidChange(to readyState: NetStream.ReadyState) {
super.readyStateDidChange(to: readyState)
switch readyState {
case .play:
connection?.socket?.doInput()
self.readyState = .playing
case .publish:
writer.expectedMedias.removeAll()
if videoInputFormat != nil {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Net/NetStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ open class NetStream: NSObject {
guard readyState != newValue else {
return
}
readyStateWillChange(to: readyState)
readyStateWillChange(to: newValue)
}
didSet {
guard readyState != oldValue else {
Expand Down Expand Up @@ -427,11 +427,11 @@ open class NetStream: NSObject {
/// A handler that receives stream readyState will update.
/// - Warning: Please do not call this method yourself.
open func readyStateWillChange(to readyState: ReadyState) {
switch readyState {
case .publishing:
mixer.stopRunning()
switch self.readyState {
case .playing:
mixer.stopRunning()
case .publishing:
mixer.stopRunning()
default:
break
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/RTMP/RTMPStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ open class RTMPStream: NetStream {
}

override public func readyStateWillChange(to readyState: NetStream.ReadyState) {
switch readyState {
switch self.readyState {
case .publishing:
FCUnpublish()
default:
Expand Down

0 comments on commit 2965f9b

Please sign in to comment.