Android 无法构造';RTCSessionDescription';:参数1(';descriptionInitDict';)不是对象
我正在尝试在Android和Chrome上的Web应用程序之间进行电话会议。当Android向web应用程序发送报价时,我在chrome控制台上收到以下错误: 构造“RTCSessionDescription”失败:参数1(“descriptionInitDict”)不是对象 以下是截图: 在Android上,我有如下代码:Android 无法构造';RTCSessionDescription';:参数1(';descriptionInitDict';)不是对象,android,webrtc,Android,Webrtc,我正在尝试在Android和Chrome上的Web应用程序之间进行电话会议。当Android向web应用程序发送报价时,我在chrome控制台上收到以下错误: 构造“RTCSessionDescription”失败:参数1(“descriptionInitDict”)不是对象 以下是截图: 在Android上,我有如下代码: PeerConnectionFactory.initializeAndroidGlobals(listener, true, true, true, mEGLco
PeerConnectionFactory.initializeAndroidGlobals(listener, true, true,
true, mEGLcontext);
以下是创建对等连接对象的方式:
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应用程序处理此服务的方式:
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);
});
web到web之间的电话会议工作正常。当android向web应用程序发送报价时,它不起作用。此外,当Web向android发送报价时,不会调用SdpObserver的onCreateSuccess(最终会话描述sdp)
我在网上找不到这个错误的解决办法。我不明白descriptionInitDict是什么意思。浏览器端的data.sdp是什么类型?如果它是一个字符串,我想它是基于你给它的名字,这就是问题所在。您应该传递具有两个属性的对象:
type
和sdp
。查看官方规格谢谢您的回答。现在正在显示出一些进展。Web现在能够为android创建答案。Android无法创建答案或生成候选答案。问题是sdp对象在信令服务器中被转换为字符串。我只是把它改成了对象类型&错误已经过去了。一旦越过障碍。
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);
});