小编Raj*_*har的帖子

使用WebRTC iOS Swift在视频通话期间在iPhoneX上纠正远程视频大小

我正在使用webRTC进行视频通话。一切运行顺利,但我正在为iPhoneX,XSMax上的远程视频的纵横比而苦苦挣扎。我看到很多视频放大。您能帮我解决如何在有陷波功能的设备上管理远程视频吗?下面是我处理远程大小的代码。

func videoView(_ videoView: RTCEAGLVideoView, didChangeVideoSize size: CGSize) {
    print(size)

    let defaultAspectRatio: CGSize = CGSize(width: 4, height: 3)
    let aspectRatio: CGSize = size.equalTo(CGSize.zero) ? defaultAspectRatio : size
    let videoRect: CGRect = self.view.bounds
    let maxFloat = CGFloat.maximum(self.view.frame.width, self.view.frame.height)
    let newAspectRatio = aspectRatio.width / aspectRatio.height
    var frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
    if (aspectRatio.width < aspectRatio.height) {
        frame.size.width = maxFloat;
        frame.size.height = frame.size.width / newAspectRatio;
    } else {
        frame.size.height = maxFloat;
        frame.size.width = frame.size.height * newAspectRatio;
    }
    frame.origin.x …
Run Code Online (Sandbox Code Playgroud)

video-streaming ios webrtc swift webrtc-ios

5
推荐指数
2
解决办法
270
查看次数

标签 统计

ios ×1

swift ×1

video-streaming ×1

webrtc ×1

webrtc-ios ×1