diff --git a/Sources/RTMP/RTMPMessage.swift b/Sources/RTMP/RTMPMessage.swift index f1a1067a5..16d33f20b 100644 --- a/Sources/RTMP/RTMPMessage.swift +++ b/Sources/RTMP/RTMPMessage.swift @@ -427,6 +427,15 @@ final class RTMPDataMessage: RTMPMessage { return } stream.info.byteCount.mutate { $0 += Int64(payload.count) } + switch handlerName { + case "onMetaData": + stream.metadata = arguments[0] as? [String: Any?] ?? [:] + case "|RtmpSampleAccess": + stream.audioSampleAccess = arguments[0] as? Bool ?? true + stream.videoSampleAccess = arguments[1] as? Bool ?? true + default: + break + } } } diff --git a/Sources/RTMP/RTMPStream.swift b/Sources/RTMP/RTMPStream.swift index a7feb331b..26e5089c8 100644 --- a/Sources/RTMP/RTMPStream.swift +++ b/Sources/RTMP/RTMPStream.swift @@ -155,10 +155,16 @@ open class RTMPStream: NetStream { } static let defaultID: UInt32 = 0 - /// The NetStreamInfo object whose properties contain data. + /// The RTMPStream metadata. + public internal(set) var metadata: [String: Any?] = [:] + /// The RTMPStreamInfo object whose properties contain data. public internal(set) var info = RTMPStreamInfo() /// The object encoding (AMF). Framework supports AMF0 only. public private(set) var objectEncoding: RTMPObjectEncoding = RTMPConnection.defaultObjectEncoding + /// The boolean value that indicates audio samples allow access or not. + public internal(set) var audioSampleAccess = true + /// The boolean value that indicates video samples allow access or not. + public internal(set) var videoSampleAccess = true /// Incoming audio plays on the stream or not. public var receiveAudio = true { didSet { @@ -428,6 +434,9 @@ open class RTMPStream: NetStream { case .open: currentFPS = 0 frameCount = 0 + audioSampleAccess = true + videoSampleAccess = true + metadata.removeAll() info.clear() delegate?.streamDidOpen(self) for message in messages { @@ -457,7 +466,9 @@ open class RTMPStream: NetStream { dataTimeStamps.removeAll() FCPublish() case .publishing: - send(handlerName: "@setDataFrame", arguments: "onMetaData", makeMetaData()) + let metadata = makeMetaData() + send(handlerName: "@setDataFrame", arguments: "onMetaData", metadata) + self.metadata = metadata default: break }