範囲
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 のドキュメントに苦労した後も、どこから始めて何をすべきかをまだ見つけることができません。
どんな種類のヘッズアップも大歓迎です!