在 Android 上的 WebRTC 中,我正在创建一个响应报价的答案,并在其后面设置本地描述。
使用推荐的方法,本地描述的设置与答案相同,除了 ufrag 和 pwd 发生更改。这意味着远程对等方没有正确的凭据,通信无法继续。
使用“munged”方法并直接提供描述可以解决此问题,但显然非常不鼓励。
谁能给我解释一下这背后的逻辑吗?
@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
Log.d(TAG, "Local answer created:");
Log.d(TAG, sessionDescription.description);
// setLocalDescription with just an observer
// in this the description can change
peerConnection.setLocalDescription(this);
// setLocalDesciption with an observer and a SessionDescription (munged)
// this is HIGHLY DISCOURAGED
//peerConnection.setLocalDescription(this, sessionDescription);
Log.d(TAG, "Local description set");
signaling.onLocalAnswer(sessionDescription);
}
@Override
public void onSetSuccess() {
Log.d(TAG, "Set description was successful");
Log.d(TAG, "Local description currently:" +
peerConnection.getLocalDescription().description);
}
如果需要详细信息,我会将其放在下面的评论中。谢谢。
一个好处是它强制在 onSetSuccess 中发出答案信号,因此,如果由于某种原因无法设置本地描述,则远程对等点将不会有无效答案。
我目前无法找到确切的协议描述,无论它是说将描述设置为生成的答案还是将答案设置为生成的描述。