【发布时间】:2015-10-18 02:16:17
【问题描述】:
我正在尝试在 Chrome 上的 Android 和 Web 应用程序之间进行电话会议。当 Android 将报价发送到 Web 应用程序时,我在 chrome 控制台上收到以下错误:
未能构造“RTCSessionDescription”:参数 1(“descriptionInitDict”)不是对象。
截图如下:
在 Android 上,我有这样的代码:
PeerConnectionFactory.initializeAndroidGlobals(listener, true, true,
true, mEGLcontext);
这就是我创建 Peer Connection 对象的方式:
this.pc = factory.createPeerConnection(RTCConfig.getIceServer(), RTCConfig.getMediaConstraints(), this);
RTCConfig.getMediaConstraints() 函数定义如下:
public static MediaConstraints getMediaConstraints(){
// Initialize PeerConnection
MediaConstraints pcMediaConstraints = new MediaConstraints();
pcMediaConstraints.optional.add(new MediaConstraints.KeyValuePair(
"DtlsSrtpKeyAgreement", "true"));
pcMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
"OfferToReceiveAudio", "true"));
pcMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
"OfferToReceiveVideo", "true"));
return pcMediaConstraints;
}
而 RTCConfig.getICEServer() 函数定义为:
public static LinkedList<PeerConnection.IceServer> getIceServer(){
// Initialize ICE server list
LinkedList<PeerConnection.IceServer> iceServers = new LinkedList<PeerConnection.IceServer>();
iceServers.add(new PeerConnection.IceServer("stun:stun.l.google.com:19302"));
return iceServers;
}
在 Web 应用程序上,我以这种方式创建对等连接对象:
var pc = new RTCPeerConnection(
{'iceServers': [
createIceServer(isChrome
? 'stun:stun.l.google.com:19302'
: 'stun:23.21.150.121', null, null)
]},
{optional: [ {"DtlsSrtpKeyAgreement": true}]});
这是 Web 应用程序处理报价的方式:
pc.setRemoteDescription(new RTCSessionDescription(data.sdp), function () {
$log.debug('Setting remote description by offer');
pc.createAnswer(function (sdp) {
pc.setLocalDescription(sdp);
socket.emit('msg', { by: currentId, to: data.by, sdp: sdp, type: 'answer' });
}, function (e) {
$log.error(e);
});
}, function (e) {
$log.error(e);
});
网络到网络之间的电话会议运行良好。当 android 将报价发送到 Web 应用程序时,它不起作用。此外,当 Web 将 offer 发送到 android 时,不会调用 SdpObserver 的 onCreateSuccess(final SessionDescription sdp)。
我在 Internet 上找不到此错误的解决方案。我不明白 descriptionInitDict 是什么意思。
【问题讨论】: