Sinch不支持swift中的视频通话

时间:2018-05-07 06:10:19

标签: ios swift video sinch

这是我的代码。我将这个代码从目标c转换为快速的sinch测试。给Objective-C部分提供帮助可能很有趣,但它不支持视频通话。当我接受通话音频工作正常。但是视频没有发送到其他设备。如果任何人有swift的示例代码,请帮助我,然后发送或尝试使用此代码修复它..谢谢

// MARK: - Load
override func viewDidLoad() {
    super.viewDidLoad()

    if call?.direction == SINCallDirection.incoming {
        self.callStateLabel.text = ""
        self.showButtons(EButtonsBar.kButtonsAnswerDecline)
        //audioController().startPlayingSoundFile(path(forSound: "incoming.wav"), loop: true)
    } else {
        self.callStateLabel.text = "calling..."
        self.showButtons(EButtonsBar.kButtonsHangup)
    }
    if  (call?.details.isVideoOffered)! {
        localVideoView.addSubview(videoController().localView())
        localVideoFullscreenGestureRecognizer.require(toFail: switchCameraGestureRecognizer)
        videoController().localView().addGestureRecognizer(localVideoFullscreenGestureRecognizer)
        videoController().remoteView().addGestureRecognizer(remoteVideoFullscreenGestureRecognizer)
    }
}

@IBAction func accept(sender: AnyObject) {
    call?.answer()

}

@IBAction func decline(sender: AnyObject) {
    call?.hangup()
    dismiss(animated: true, completion: nil)
}


@IBAction func hangup(sender: AnyObject) {
    call?.hangup()
    dismiss(animated: true, completion: nil)
}

func audioController() -> SINAudioController{
    return Global.client.audioController()

}

func videoController() -> SINVideoController {
    return Global.client.videoController()
}

1 个答案:

答案 0 :(得分:0)

在视图控制器中添加2个视图。一个用于本地视频视图,另一个用于远程视频视频。设置出口以查看控制器。我有一个有效的音频调用示例,我只是将这些内容添加到我的呼叫视图控制器。

func videoController() -> SINVideoController {
    return appDeletgate.client.videoController()
}

在viewdidload中检查是否通过电话提供视频。

if call.details.isVideoOffered {

    localVideoView.addSubview(videoController().localView())
    //localVideoFullscreenGestureRecognizer.require(toFail: switchCameraGestureRecognizer)
    //videoController().localView().addGestureRecognizer(localVideoFullscreenGestureRecognizer)
    //videoController().remoteView().addGestureRecognizer(remoteVideoFullscreenGestureRecognizer)
}

添加此方法以在视图中添加远程视频。

func callDidAddVideoTrack(_ call: SINCall?) {
    remoteVideoView.addSubview(videoController().remoteView())
}

还要确保将这2个密钥添加到info.plist

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) need to access your camera for video call.</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) uses the Microphone for calling</string>

这就是我最后的称呼方式。

let call: SINCall? = self.callClient().callUserVideo(withId: recipientName) //self.callClient().callUser(withId: recipientName)
let callVC  = mainStoryBoard.instantiateViewController(withIdentifier: "CallVC") as! CallVC
callVC.call = call
self.navigationController?.pushViewController(callVC, animated: true)