我正在尝试在 Chrome 上的 Android 和 Web 应用程序之间进行电话会议。当 Android 将优惠发送到 Web 应用程序时,我在 Chrome 控制台上收到以下错误:
无法构造“RTCSessionDescription”:参数 1(“descriptionInitDict”)不是对象。
这是屏幕截图:
在 Android 上,我有这样的代码:
PeerConnectionFactory.initializeAndroidGlobals(listener, true, true,
true, mEGLcontext);
Run Code Online (Sandbox Code Playgroud)
这就是我创建对等连接对象的方式:
this.pc = factory.createPeerConnection(RTCConfig.getIceServer(), RTCConfig.getMediaConstraints(), this);
Run Code Online (Sandbox Code Playgroud)
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;
}
Run Code Online (Sandbox Code Playgroud)
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;
}
Run Code Online (Sandbox Code Playgroud)
在 Web 应用程序上,我通过以下方式创建对等连接对象:
var pc = new RTCPeerConnection(
{'iceServers': [
createIceServer(isChrome
? 'stun:stun.l.google.com:19302'
: 'stun:23.21.150.121', null, null)
]},
{optional: [ {"DtlsSrtpKeyAgreement": true}]});
Run Code Online (Sandbox Code Playgroud)
这是 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);
});
Run Code Online (Sandbox Code Playgroud)
网络到网络之间的电话会议运行良好。当 Android 将优惠发送到 Web 应用程序时,它不起作用。此外,当 Web 将优惠发送到 android 时,不会调用 SdpObserver 的 onCreateSuccess(final SessionDescription sdp)。
我在互联网上找不到该错误的解决方案。我无法理解descriptionInitDict 的含义。
| 归档时间: |
|
| 查看次数: |
5584 次 |
| 最近记录: |