简体   繁体   中英

WebRTC not adding datachannel in SDP answer

I can successfully create a datachannel by calling peerConnection.createDataChannel("some/label") and then peerConnection.createOffer() , in which case the datachannel appears in the SDP offer (ie there is an m=application there).

But now I want the other peer to create the datachannel, and therefore have it appear in the SDP answer. Same thing: I call createDataChannel before peerConnection.createAnswer() . Except that this time, I don't see an m=application in the SDP answer.

Shouldn't it be possible to create a datachannel from the second peer, and shouldn't it appear in the SDP answer?

My code looks like this:

if (type === 'offer') {
    peerConnection.createDataChannel("some/channel");
    peerConnection.createAnswer().then(createdDescription).catch(errorHandler);
}

I tried with both Firefox and Google Chrome, and I have the same issue, ie I don't see an m=application in the SDP answer.

SDP follows an "offer-answer model" described in RFC 3264 . If the offer did not negotiate datachannel, the answer can not contain an additional m-line negotiating it. The answerer will, after sending their answer, have to send an additional offer with a datachannel m-line. The negotiationneeded event may fire to indicate this is required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM