RTCEngine and SignalClient

This commit is contained in:
David Zhao
2021-07-20 15:38:30 -07:00
parent 941bbbdc32
commit b28466842f
8 changed files with 544 additions and 89 deletions
+26
View File
@@ -0,0 +1,26 @@
import 'package:flutter_webrtc/flutter_webrtc.dart';
/// a wrapper around PeerConnection
class PCTransport {
RTCPeerConnection pc;
List<RTCIceCandidate> pendingCandidates = [];
bool restartingIce = false;
PCTransport(this.pc);
Future<void> setRemoteDescription(RTCSessionDescription sd) async {
await pc.setRemoteDescription(sd);
Future.forEach<RTCIceCandidate>(pendingCandidates, (candidate) async {
await pc.addCandidate(candidate);
});
}
Future<void> addIceCandidate(RTCIceCandidate candidate) async {
var desc = await pc.getRemoteDescription();
if (desc != null && !restartingIce) {
return pc.addCandidate(candidate);
}
pendingCandidates.add(candidate);
}
}