function createRTCPeerConnection() {
console.log("*Creating RTCPeerConnection*");
$peerConnection = new RTCPeerConnection();
$peerConnection.ondatachannel = (event) => {
$dataChannel = event.channel;
$dataChannel.onopen = dataChannelOpen;
$dataChannel.onmessage = dataChannelMessage;
$dataChannel.onerror = dataChannelError;
$dataChannel.onclose = dataChannelClose;
};
$peerConnection.ontrack = (event) => {
if ($videoStream.srcObject !== event.streams[0]) {
$videoStream.srcObject = event.streams[0];
}
};
$peerConnection.onicecandidate = (event) => {
if (event.candidate == null) {
console.log("*All ICE candidates gathered*");
return;
}
var ice = {'ice': event.candidate};
fetch('/api/rice', {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(ice)
});
console.log("*ICE candidate sent*");
};
}
Now follow an example of the offer sent by the C application:
v=0
o=- 5683312150702073703 0 IN IP4 0.0.0.0
s=-
t=0 0
a=ice-options:trickle
a=group:BUNDLE video0 application1
m=video 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=setup:actpass
a=ice-ufrag:Ztbgaa1pyn+z3kU/5BgkEYmGoVIGsSK6
a=ice-pwd:YXZ3YmHyBVwIGvjurVvig+LLHlUSgW00
a=rtcp-mux
a=rtcp-rsize
a=sendonly
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 nack pli
a=ssrc:3525767168 msid:user1680094828@host-731c8bb3 webrtctransceiver0
a=ssrc:3525767168 cname:user1680094828@host-731c8bb3
a=mid:video0
a=fingerprint:sha-256 6C:09:C8:5B:13:53:90:D1:E8:28:19:E5:69:8A:3F:57:D0:04:26:D1:44:32:4B:B7:C6:A0:74:58:99:AC:A6:36
m=application 0 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=setup:actpass
a=ice-ufrag:Ztbgaa1pyn+z3kU/5BgkEYmGoVIGsSK6
a=ice-pwd:YXZ3YmHyBVwIGvjurVvig+LLHlUSgW00
a=bundle-only
a=mid:application1
a=sctp-port:5000
a=fingerprint:sha-256 6C:09:C8:5B:13:53:90:D1:E8:28:19:E5:69:8A:3F:57:D0:04:26:D1:44:32:4B:B7:C6:A0:74:58:99:AC:A6:36
And the answer sent by the browser, which does state 'recvonly'
v=0
o=- 393586954441480955 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video0 application1
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:FnE2
a=ice-pwd:JGXFZkcwnQ6gODUrTwkU5xAb
a=ice-options:trickle
a=fingerprint:sha-256 BC:37:31:59:7D:8F:AE:96:B6:41:00:2B:96:A3:47:9B:2F:1E:20:73:53:A6:62:11:DE:0A:7D:D1:9A:4E:7F:49
a=setup:active
a=mid:video0
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 nack pli
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:FnE2
a=ice-pwd:JGXFZkcwnQ6gODUrTwkU5xAb
a=ice-options:trickle
a=fingerprint:sha-256 BC:37:31:59:7D:8F:AE:96:B6:41:00:2B:96:A3:47:9B:2F:1E:20:73:53:A6:62:11:DE:0A:7D:D1:9A:4E:7F:49
a=setup:active
a=mid:application1
a=sctp-port:5000
Thanks!