范围
我正在使用 RTCCameraPreviewView 显示本地摄像机流
let videoSource = self.pcFactory.avFoundationVideoSource(with: nil)
let videoTrack = self.pcFactory.videoTrack(with: sVideoSource, trackId: "video0")
//setting the capture session to my RTCCameraPreviewView:
(self.previewView as! RTCCameraPreviewView).captureSession = (videoTrack.source as! RTCAVFoundationVideoSource).captureSession
stream = self.pcFactory.mediaStream(withStreamId: "unique_label")
audioTrack = self.pcFactory.audioTrack(withTrackId: "audio0")
stream.addAudioTrack(audioTrack)
var device: AVCaptureDevice?
for captureDevice in AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) {
if (captureDevice as AnyObject).position == AVCaptureDevicePosition.front {
device = captureDevice as? AVCaptureDevice
break
}
}
if device != nil && videoTrack != nil {
stream.addVideoTrack(videoTrack)
}
configuration = RTCConfiguration()
configuration.iceServers = iceServers
peerConnection = self.pcFactory.peerConnection(with: configuration, constraints: RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: ["DtlsSrtpKeyAgreement": "true"]), delegate: self)
peerConnection.add(stream)
事情按预期工作正常。
问题
现在我想从相机中获取帧并对其进行预处理以添加一些过滤器(棕褐色、黑白等),然后将帧中继到 WebRTC。在通过 webrtc 文档苦苦挣扎之后,我仍然无法找到从哪里开始以及该做什么。
任何形式的抬头都将受到高度赞赏!