request method
Implementation
Future<void> request({
required String senderAddress,
required List<String> recipientAddresses,
required String chatId,
Object? details,
}) async {
print(
"senderAddress $senderAddress \n recipientAddresses $recipientAddresses \n chatId $chatId details $details");
for (final recipientAddress in recipientAddresses) {
try {
RTCPeerConnection peer = await createPeerConnection({
'iceServers':
// replace the below array with decrypted turn server API result
[
{
'urls': [
'stun:stun1.l.google.com:19302',
'stun:stun2.l.google.com:19302'
]
}
]
});
_rtcPeer[recipientAddress] = {
'peerConnection': peer,
'iceCandidates': []
};
// add local stream's tracks to RTC connection
// this.data.local.stream!.getTracks().forEach((track) {
// peer.addTrack(track, this.data.local.stream!);
// });
// listen for remotePeer mediaTrack event
peer.onTrack = (event) {
// save the incoming stream (event.streams[0]) in the state
};
// listen for local iceCandidate and add it to the list of IceCandidates
peer.onIceCandidate = (RTCIceCandidate candidate) =>
_rtcPeer[recipientAddress]?['iceCandidates'].add(candidate);
// create SDP Offer
RTCSessionDescription offer = await peer.createOffer();
// set SDP offer as localDescription for peerConnection
await peer.setLocalDescription(offer);
// send a notification containing SDP offer
// sendVideoCallNotification(
// {
// signer: ,
// chainId: ,
// pgpPrivateKey: ,
// }, {
// senderAddress,
// recipientAddress,
// status: VideoCallStatus.INITIALIZED,
// chatId,
// signalData: offer.toMap(),
// env: //,
// callType: //,
// callDetails: details,
// })
} catch (err) {
print('error in request $err');
}
}
}