iOS WebRTC本地媒体NSInvalidArgumentException [RTCI420Frame nativeHandle]

时间:2017-07-09 09:31:56

标签: ios swift webrtc apprtc

我正在尝试在iOS webRTC应用中创建本地媒体流。见下面的代码

let localStream = pcFactory.mediaStream(withLabel: "ARDAMS")!

let audio = pcFactory.audioTrack(withID: "ARDAMSa0")
localStream.addAudioTrack(audio!)

var device: AVCaptureDevice?
for captureDevice in AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo){
    if let captureDevice = captureDevice as? AVCaptureDevice{
        if captureDevice.position == AVCaptureDevicePosition.front{
            device = captureDevice
        }
    }
}

if let device = device{
    let capture = RTCVideoCapturer(deviceName: device.localizedName)
    let videoSource = pcFactory.videoSource(with: capture, constraints: nil)
    localVideoTrack = pcFactory.videoTrack(withID: "ARDAMSv0", source: videoSource)
    localStream.addVideoTrack(localVideoTrack)
}


self.peerConnection?.add(localStream)

localVideoTrack?.add(localVideoView)

一切正常,但是当我将localVideoView添加到localVideoTrack后,我收到了错误消息:

-[RTCI420Frame nativeHandle]: unrecognized selector sent to instance 0x170010620

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RTCI420Frame nativeHandle]: unrecognized selector sent to instance 0x170010620'

所有代码都在主线程上运行,并且应用程序具有相应的权限和plist键。当我使用调试器逐行遍历代码时,一切似乎都正常运行。这段代码取自Obj-C AppRTC演示,刚刚转换为swift。我似乎无法找到崩溃的快速项目和正在运行的AppRTC项目之间的区别。知道我做错了什么吗?我在64位设备上测试。谢谢!

0 个答案:

没有答案