Skip to content

Commit

Permalink
return video audio data and pts
Browse files Browse the repository at this point in the history
  • Loading branch information
huiping192 committed May 12, 2024
1 parent 616b1f2 commit 9ad6dbb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Sources/HPRTMP/RTMPPlayerSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public protocol RTMPPlayerSessionDelegate: Actor {
func sessionStatusChange(_ session: RTMPPlayerSession, status: RTMPPlayerSession.Status)
func sessionError(_ session: RTMPPlayerSession, error: RTMPError)

func sessionVideo(_ session: RTMPPlayerSession, data: Data, timestamp: Int64)
func sessionAudio(_ session: RTMPPlayerSession, data: Data, timestamp: Int64)
}

public actor RTMPPlayerSession {
Expand Down Expand Up @@ -57,18 +59,15 @@ public actor RTMPPlayerSession {
private var socket: RTMPSocket!

private let transactionIdGenerator = TransactionIdGenerator()

private var configure: PublishConfigure?


private var connectId: Int = 0

private let logger = Logger(subsystem: "HPRTMP", category: "Player")


public init() {}

public func publish(url: String, configure: PublishConfigure) async {
self.configure = configure
public func play(url: String) async {
if socket != nil {
await socket.invalidate()
}
Expand Down Expand Up @@ -103,10 +102,14 @@ extension RTMPPlayerSession: RTMPSocketDelegate {
}

func socketStreamOutputAudio(_ socket: RTMPSocket, data: Data, timeStamp: Int64) {

Task {
await delegate?.sessionAudio(self, data: data, timestamp: timeStamp)
}
}
func socketStreamOutputVideo(_ socket: RTMPSocket, data: Data, timeStamp: Int64) {

Task {
await delegate?.sessionVideo(self, data: data, timestamp: timeStamp)
}
}
func socketStreamRecord(_ socket: RTMPSocket) {}

Expand Down

0 comments on commit 9ad6dbb

Please sign in to comment.