不支持的IOSurface格式:0x26424741在Scenekit中使用twilio视频

时间:2019-06-13 05:12:44

标签: swift twilio scenekit iosurface

我正在使用twilio发送视频,并在场景工具包中将该视频用作纹理。但是问题是它可以在iPhone X上正常工作,但是在iPhone XR和XS上却给出了此错误# this could be for line in input_file: for line in data.splitlines(): # check if it's a billing period line linematch = billing_period_re.search(line) if linematch: # check if there is a date range date_range = date_range_re.search(line, linematch.end()) if date_range: print(f"from: {date_range['from']} to: {date_range['to']}")

这就是我在做什么:

获取视频:

Unsupported IOSurface format: 0x26424741

委托:

func subscribed(to videoTrack: TVIRemoteVideoTrack, publication: TVIRemoteVideoTrackPublication, for participant: TVIRemoteParticipant) {
    print("Participant \(participant.identity) added a video track.")
    let remoteView = TVIVideoView.init(frame: UIWindow().frame,
                                       delegate:self)
    videoTrack.addRenderer(remoteView!)
    delegate.participantAdded(with: remoteView!)
}

并将视频添加到飞机上

func participantAdded(with videoView: UIView) {
    sceneView.addVideo(with: videoView)
}

1 个答案:

答案 0 :(得分:0)

问题实际上出在renderingType中的remoteView。对于较旧的设备,使用metal很好,但较新的设备则需要openGLES。我不知道为什么,但是可以解决。

I used this solution to find out the device type.

下一步,我确定要使用哪个renderingType

var renderingType: VideoView.RenderingType {
    get{
        let device = UIDevice()
        switch device.type{
        case .iPhoneXS:
            return .openGLES
        case .iPhoneXR:
            return .openGLES
        case .iPhoneXSMax:
            return .openGLES
        default:
            return .metal
        }
    }
}

并用它来初始化remoteView

func didSubscribeToVideoTrack(videoTrack: RemoteVideoTrack, publication: RemoteVideoTrackPublication, participant: RemoteParticipant) {
    print("Participant \(participant.identity) added a video track.")
    let remoteView = VideoView.init(frame: UIWindow().frame,
                                    delegate:self,
                                    renderingType: renderingType)
    videoTrack.addRenderer(remoteView!)
    delegate.participantAddedVideo(for: participant.identity, with: remoteView!)
}