QuickBlox WebRTC iOS:无法正确连接
Posted
技术标签:
【中文标题】QuickBlox WebRTC iOS:无法正确连接【英文标题】:QuickBlox WebRTC iOS: can't connect properly 【发布时间】:2016-02-09 23:02:01 【问题描述】:我正在尝试使用 QuickBlox-WebRTC 创建一个带有视频聊天的 ios 应用程序。
我的控制器是QBRTCClientDelegate
,一切似乎都“运行良好”。命中以下调用(不按顺序):
didReceiveNewSession
initializedLocalMediaStream
receivedRemoteVideoTrack
acceptedByUser
但不幸的是,startedConnectingToUser
和 connectedToUser
永远不会发生。
在调用方,我在日志中看到以下内容:
2016-02-09 23:28:38:105 TestProject[1194:4052297] rtc::Did receive signal: accept from: 8760016
2016-02-09 23:28:38:158 TestProject[1194:4052328] rtc::Did receive signal: iceCandidates from: 8760016
2016-02-09 23:28:38:259 TestProject[1194:4052295] rtc::Did receive signal: iceCandidates from: 8760016
2016-02-09 23:28:38:262 TestProject[1194:4052295] rtc::Did receive signal: iceCandidates from: 8760016
2016-02-09 23:28:38:318 TestProject[1194:4052295] rtc::Did receive signal: iceCandidates from: 8760016
2016-02-09 23:28:38:412 TestProject[1194:4052327] rtc::Did receive signal: iceCandidates from: 8760016
2016-02-09 23:28:40:878 TestProject[1194:4052297] rtc::<Peer:0x155793250, UID:8760016, r:Offer> Send local offer sdp
2016-02-09 23:28:45:839 TestProject[1194:4052297] rtc::<Peer:0x155793250, UID:8760016, r:Offer> Send local offer sdp
2016-02-09 23:28:50:876 TestProject[1194:4052299] rtc::<Peer:0x155793250, UID:8760016, r:Offer> Send local offer sdp
2016-02-09 23:28:55:865 TestProject[1194:4052297] rtc::Close connection for user 8760016
2016-02-09 23:28:55:866 TestProject[1194:4052297] rtc::Invalidate timer:dialing timer, background task id 5 ...
2016-02-09 23:28:55:874 TestProject[1194:4052308] rtc::<Peer:0x155793250, UID:8760016, r:Offer> Renegotiation needed
2016-02-09 23:28:55:876 TestProject[1194:4052297] rtc::<Peer:0x155793250, UID:8760016, r:Offer> Remove local media stream: [com.quickblox.mediastream.device-iphone.6.plus_ios-9.2.1_userid-8762474]:A=1:V=1]
2016-02-09 23:28:55.897 TestProject[1194:4052297] dealloc QBRTCLocalAudioTrack
2016-02-09 23:28:55:896 TestProject[1194:4052297] rtc::<Peer:0x155793250, UID:8760016, r:Offer> Ice connection change:Closed
2016-02-09 23:28:55.897 TestProject[1194:4052297] dealloc QBRTCLocalVideoTrack
2016-02-09 23:28:55:898 TestProject[1194:4052307] rtc::Stop rtc video capturer
2016-02-09 23:28:55.902 TestProject[1194:4052297] Destroy local media stream
2016-02-09 23:28:55:902 TestProject[1194:4052297] rtc::<Peer:0x155793250, UID:8760016, r:Offer> Signaling state changed: Closed
2016-02-09 23:28:55:902 TestProject[1194:4052297] rtc::Destroy dialing timer
在被调用方,我看到以下内容:
2016-02-09 23:28:36:418 TestProject[97959:2233683] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Signaling state changed: Stable
2016-02-09 23:28:36:418 TestProject[97959:2233683] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Send queued ICE candidates, count: 0
2016-02-09 23:28:37:500 TestProject[97959:2233685] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> ICE gathering changed: Gathering
2016-02-09 23:28:37:500 TestProject[97959:2234170] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Set session description
2016-02-09 23:28:37:500 TestProject[97959:2234170] rtc::Send Answer: <Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer>
2016-02-09 23:28:37:500 TestProject[97959:2234170] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued ICE candidates, count: 0
2016-02-09 23:28:37:500 TestProject[97959:2234170] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Send queued ICE candidates, count: 1
2016-02-09 23:28:37:612 TestProject[97959:2234066] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued ICE candidates, count: 0
2016-02-09 23:28:37:613 TestProject[97959:2234066] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Send queued ICE candidates, count: 1
2016-02-09 23:28:37:706 TestProject[97959:2234170] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued ICE candidates, count: 0
2016-02-09 23:28:37:706 TestProject[97959:2234170] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Send queued ICE candidates, count: 1
2016-02-09 23:28:37:881 TestProject[97959:2234173] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued ICE candidates, count: 0
2016-02-09 23:28:37:881 TestProject[97959:2234173] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Send queued ICE candidates, count: 1
2016-02-09 23:28:38:131 TestProject[97959:2233685] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> ICE gathering changed: Complete
2016-02-09 23:28:38:132 TestProject[97959:2234172] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued ICE candidates, count: 0
2016-02-09 23:28:38:132 TestProject[97959:2234172] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Send queued ICE candidates, count: 1
2016-02-09 23:28:41:914 TestProject[97959:2234172] rtc::Did receive signal: call from: 8762474
2016-02-09 23:28:41:914 TestProject[97959:2234172] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued Remote SDP
2016-02-09 23:28:46:708 TestProject[97959:2234172] rtc::Did receive signal: call from: 8762474
2016-02-09 23:28:46:709 TestProject[97959:2234170] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued Remote SDP
2016-02-09 23:28:51:891 TestProject[97959:2234170] rtc::Did receive signal: call from: 8762474
2016-02-09 23:28:51:891 TestProject[97959:2233683] rtc::<Peer:0x7fbbe3b54cb0, UID:8762474, r:Answer> Queued Remote SDP
...它重复最后两行。
我在示例应用程序中检查了它是如何发生的,当以下情况发生时,我的应用程序似乎永远不会到达该部分:
2016-02-09 12:48:49:006 sample-videochat-webrtc[278:20551] rtc::Did receive signal: iceCandidates from: 2436266
2016-02-09 12:48:49:007 sample-videochat-webrtc[278:19893] rtc::<Peer:0x1477ec80, UID:2436266, r:Answer> Set remote ICE candidates, count: 20
2016-02-09 12:48:50:921 sample-videochat-webrtc[278:20551] rtc::<Peer:0x1477ec80, UID:2436266, r:Answer> Ice connection change:Connected
我在这里缺少什么?比较我的实现和示例的实现,我没有发现太大的区别。
【问题讨论】:
【参考方案1】:事实证明这是一个与语法相关的简单错误。创建会话时,我使用过:
QBRTCSession *newSession = [QBRTCClient.instance
createNewSessionWithOpponents:@[receipientStr]
withConferenceType:QBRTCConferenceTypeVideo];
但正确的语法是
QBRTCSession *newSession = [QBRTCClient.instance
createNewSessionWithOpponents:@[@(receipientStr.intValue)]
withConferenceType:QBRTCConferenceTypeVideo];
通过此修改,视频现在可以完全正常工作了。
【讨论】:
以上是关于QuickBlox WebRTC iOS:无法正确连接的主要内容,如果未能解决你的问题,请参考以下文章
Quickblox Flutter SDK 示例 WebRTC 未连接
Quickblox cordova 示例视频 webrtc 应用程序不在 Android 设备上显示摄像头流
Quickblox Javascript SDK + Angular + webRTC - Firefox 错误:SecurityError:操作不安全
id 为 X 的 QBWebRTC 目前很忙? QB.webrtc.onRemoteStreamListener 没有触发。 Quickblox Javascript SDK + 角度 + WebRT