WebRTC iOS本地视频轨道无法在RTCEAGLVideoView上呈现

时间:2018-11-06 09:37:01

标签: ios swift webrtc

我想在连接到房间之前在RTCEAGLView而不是RTCCameraPreviewView上渲染本地摄像机的视频轨迹。我在viewDidLoad中创建了一个本地视频轨道,如下所示:

    let dF = RTCDefaultVideoDecoderFactory.init()
    let eF = RTCDefaultVideoEncoderFactory.init()
    eF.preferredCodec = ARDSettingsModel.init().currentVideoCodecSettingFromStore()
    RTCPeerConnectionFactory.init()
    let factory = RTCPeerConnectionFactory.init(encoderFactory: eF, decoderFactory: dF)
    let videoSource = factory.videoSource()
    capturer = RTCCameraVideoCapturer.init(delegate: videoSource)
    capturerController = ARDCaptureController.init(capturer: capturer, settings: ARDSettingsModel.init())
    capturerController?.startCapture()
    let rtcTrack = factory.videoTrack(with: videoSource, trackId: "ARDAMSv0")
    let localView = RTCEAGLVideoView.init(frame: self.view.bounds)
    self.view.addSubview(localView)
    rtcTrack.add(localView)

RTCEAGLVideoView确实已添加为子视图,但是轨迹未在视图上呈现,有人知道为什么吗?

如果使用以下方法,我可以成功通过RTCCameraPreviewView获取预览视图:

    let localView2 = RTCCameraPreviewView.init(frame: self.view.bounds)
    localView2.captureSession = capturer?.captureSession
    self.view.addSubview(localView2)

0 个答案:

没有答案