I'm testing WebRTC procedure step by step for my sake.
I wrote some testing site for server-less WebRTC.
http://webrtcdevelop.appspot.com/
In fact, STUN server by google is used, but no signalling server deployed.
Session Description Protocol (SDP) is exchanged manually by hand that is CopyPaste between browser windows.
So far, here is the result I've got with the code:
'use strict';
var peerCon;
var ch;
$(document)
.ready(function()
{
init();
$('#remotebtn2')
.attr("disabled", "");
$('#localbtn')
.click(function()
{
offerCreate();
$('#localbtn')
.attr("disabled", "");
$('#remotebtn')
.attr("disabled", "");
$('#remotebtn2')
.removeAttr("disabled");
});
$('#remotebtn')
.click(function()
{
answerCreate(
new RTCSessionDescription(JSON.parse($('#remote')
.val())));
$('#localbtn')
.attr("disabled", "");
$('#remotebtn')
.attr("disabled", "");
$('#remotebtn')
.attr("disabled", "");
});
$('#remotebtn2')
.click(function()
{
answerGet(
new RTCSessionDescription(JSON.parse($('#remote')
.val())));
$('#remotebtn2')
.attr("disabled", "");
});
});
var init = function()
{
//offer------
peerCon =
new RTCPeerConnection(
{
"iceServers": [
{
"url": "stun:stun.l.google.com:19302"
}]
},
{
"optional": [
{
"RtpDataChannels": true
}]
});
peerCon.onicecandidate = function(e)
{
console.log(e);
};
ch = peerCon.createDataChannel(
'ch1',
{
reliable: false
});
ch.onopen = function()
{
alert('ch.onopen');
ch.send("hello chat!");
};
ch.onmessage = function(e)
{
alert(e.data);
};
};
var offerCreate = function()
{
peerCon
.createOffer(function(description)
{
peerCon
.setLocalDescription(description, function()
{
console.log(JSON.stringify(description));
$('#local')
.text(JSON.stringify(description));
}, error);
}, error);
};
var answerCreate = function(descreption)
{
peerCon
.setRemoteDescription(descreption, function()
{
peerCon
.createAnswer(
function(description)
{
peerCon
.setLocalDescription(description, function()
{
console.log(JSON.stringify(description));
$('#local')
.text(JSON.stringify(description));
}, error);
}, error);
}, error);
};
var answerGet = function(description)
{
peerCon.setRemoteDescription(description, function()
{ //
console.log(JSON.stringify(description));
alert('local-remote-setDescriptions complete!');
}, error);
};
var error = function(e)
{
console.log(e);
};
Firefox(26.0):
RtpDataChannels
onopen
event is fired successfully, butsend
fails.Chrome(31.0):
RtpDataChannels
onopen
event is not fired.
So, my question is,
I want to know why Chrome fails on RtpDataChannels
onopen
event, and how to fix.
Probably more importantly, I want to understand how to manage ICE .onicecandidate
event.
The Offer Local Description fed-back from STUN server is, for instance. as follows:
{"sdp":"v=0\r\no=- 7430372191078664219 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio data\r\na=msid-semantic: WMS\r\nm=audio 1 RTP/SAVPF 111 103 104 0 8 106 105 13 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:1 IN IP4 0.0.0.0\r\na=ice-ufrag:Gj7WBxZNS7HswoxM\r\na=ice-pwd:FsXen3Tz2sXdXV31splr7WKg\r\na=ice-options:google-ice\r\na=fingerprint:sha-256 EF:67:28:00:41:B6:08:A3:C5:27:BF:38:84:83:CF:8D:DC:CC:95:A9:6C:DB:77:44:DA:B2:D1:05:39:73:99:D1\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=recvonly\r\na=rtcp-mux\r\na=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:ZTGRIJAdH3o1Y1T/6gF3YUtCF5CTdsaEkjWCtWJ+\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 minptime=10\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:126 telephone-event/8000\r\na=maxptime:60\r\nm=application 1 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\na=rtcp:1 IN IP4 0.0.0.0\r\na=ice-ufrag:Gj7WBxZNS7HswoxM\r\na=ice-pwd:FsXen3Tz2sXdXV31splr7WKg\r\na=ice-options:google-ice\r\na=fingerprint:sha-256 EF:67:28:00:41:B6:08:A3:C5:27:BF:38:84:83:CF:8D:DC:CC:95:A9:6C:DB:77:44:DA:B2:D1:05:39:73:99:D1\r\na=setup:actpass\r\na=mid:data\r\na=sendrecv\r\nb=AS:30\r\na=rtcp-mux\r\na=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:ZTGRIJAdH3o1Y1T/6gF3YUtCF5CTdsaEkjWCtWJ+\r\na=rtpmap:101 google-data/90000\r\na=ssrc:3757983348 cname:ojw6/osqSDh7tsMo\r\na=ssrc:3757983348 msid:ch1 ch1\r\na=ssrc:3757983348 mslabel:ch1\r\na=ssrc:3757983348 label:ch1\r\n","type":"offer"}
The only IP I could see is 127.0.0.1
that is the localhost
, but I suppose some global address should be included in SDP info because without it, we can connect only locally.
So, I guess I need to marge the various ICE candidates onicecaditate event with SDP, but I'm not sure how, and I think this issue is related to the failure of the test.
Any suggestion and recommendation to read is appreciated.
EDIT: Ok, probably, this is the same topic I'm following right now:
necessary to send ice candidates across, or do they come packaged in offer/answer data? https://groups.google.com/forum/#!topic/discuss-webrtc/UOnopWJ1l44