-
-
Save zontan/b9832bea7b4d04473f37a635c668e9be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AgoraRtcKit | |
/** | |
A custom video source for the AgoraRtcEngine. This class conforms to the AgoraVideoSourceProtocol and is used to pass the AR pixel buffer as a video source of the Agora stream. | |
*/ | |
class CustomVideoSource: NSObject, AgoraVideoSourceProtocol { | |
var consumer: AgoraVideoFrameConsumer? | |
var rotation: AgoraVideoRotation = .rotation180 //Banuba frames are flipped compared to what Agora expects. | |
func shouldInitialize() -> Bool { return true } | |
func shouldStart() { } | |
func shouldStop() { } | |
func shouldDispose() { } | |
func bufferType() -> AgoraVideoBufferType { | |
return .pixelBuffer | |
} | |
func captureType() -> AgoraVideoCaptureType { | |
return .camera | |
} | |
func contentHint() -> AgoraVideoContentHint { | |
return .motion | |
} | |
func sendBuffer(_ buffer: CVPixelBuffer, timestamp: TimeInterval) { | |
let time = CMTime(seconds: timestamp, preferredTimescale: 1000) | |
consumer?.consumePixelBuffer(buffer, withTimestamp: time, rotation: rotation) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment