In my webrtc-applications (peers in javascript, Windows, Firefox, my signalling server in C++):
peer1 starts the connection (sends offer) add tracks to the connection, peer2 gets offer and sends answer, adds own track.
All works good if user grants both peers all right to media (camera, mic) - getUserMedia
resolved OK.
I'd like to create a "limited" connection: peer1 will not have rights for camera and mic, perr2 will have.
The problem is: peer1 can not call addTrack(), because it has not rights and tracks to send. So, negotiationneeded
is not fired for it.
The question is: how can peer1 can force negotiationneeded
event to start a connection process - send your offer etc ?
RtcPeerConnection set up by the following function (peerConnection
field is of the RTCPeerConnection type):
function InitWebRTC(userRecord) {
const config = {iceServers: []};
try {
userRecord.webRtc.peerConnection = new RTCPeerConnection(config);
}
catch (err) {
userRecord.webRtc.peerConnection = null;
}
if (userRecord.webRtc.peerConnection !== null) {
if (settings.createDataChannel) {
userRecord.webRtc.peerConnection.addEventListener("datachannel", rtc_OnRemoteDataChannel);
}
userRecord.webRtc.peerConnection.addEventListener("icecandidate", rtc_OnIceCandidate);
userRecord.webRtc.peerConnection.addEventListener("negotiationneeded", rtc_OnNegotiationNeeded);
userRecord.webRtc.peerConnection.addEventListener("connectionstatechange", rtc_OnConnectionStateChange);
userRecord.webRtc.peerConnection.addEventListener("iceconnectionstatechange", rtc_OnIceConnectionStateChange);
userRecord.webRtc.peerConnection.addEventListener("icegatheringstatechange", rtc_OnIceGatheringStateChange);
let sigState = userRecord.webRtc.peerConnection.signalingState;
//userRecord.webRtc.peerConnection.addEventListener('track', rtc_OnTrack);
userRecord.webRtc.peerConnection.ontrack = rtc_OnTrack;
userRecord.webRtc.peerConnection.onremovetrack = rtc_OnRemoveTrack;
}
}
if you want to rely on the negotiationneeded
event you can add a transceiver instead of a track using addTransceiver('video')
and sets its direction
to recvonly
.