@@ -46,10 +46,22 @@ void test_turn_connectivity() {
46
46
pc1.onGatheringStateChange ([&pc1, &pc2](PeerConnection::GatheringState state) {
47
47
cout << " Gathering state 1: " << state << endl;
48
48
if (state == PeerConnection::GatheringState::Complete) {
49
- auto sdp = pc1.localDescription ().value ();
49
+ pc2.setRemoteGatherDone ();
50
+ }
51
+ });
52
+
53
+ pc1.onLocalDescription ([&pc2](Description sdp) {
50
54
cout << " Description 1: " << sdp << endl;
51
55
pc2.setRemoteDescription (string (sdp));
56
+ });
57
+
58
+ pc1.onLocalCandidate ([&pc2](Candidate candidate) {
59
+ if (candidate.type () == rtc::Candidate::Type::Host) {
60
+ cout << " Candidate 1 ignored: " << candidate << endl;
61
+ return ;
52
62
}
63
+ cout << " Candidate 1: " << candidate << endl;
64
+ pc2.addRemoteCandidate (string (candidate));
53
65
});
54
66
55
67
pc1.onSignalingStateChange ([](PeerConnection::SignalingState state) {
@@ -62,10 +74,10 @@ void test_turn_connectivity() {
62
74
});
63
75
64
76
pc2.onLocalCandidate ([&pc1](Candidate candidate) {
65
- // Filter server reflexive candidates
66
- if (candidate. type () != rtc::Candidate::Type::ServerReflexive)
77
+ if (candidate. type () == rtc::Candidate::Type::Host) {
78
+ cout << " Candidate 2 ignored: " << candidate << endl;
67
79
return ;
68
-
80
+ }
69
81
cout << " Candidate 2: " << candidate << endl;
70
82
pc1.addRemoteCandidate (string (candidate));
71
83
});
@@ -75,8 +87,11 @@ void test_turn_connectivity() {
75
87
pc2.onIceStateChange (
76
88
[](PeerConnection::IceState state) { cout << " ICE state 2: " << state << endl; });
77
89
78
- pc2.onGatheringStateChange ([](PeerConnection::GatheringState state) {
90
+ pc2.onGatheringStateChange ([&pc1 ](PeerConnection::GatheringState state) {
79
91
cout << " Gathering state 2: " << state << endl;
92
+ if (state == PeerConnection::GatheringState::Complete) {
93
+ pc1.setRemoteGatherDone ();
94
+ }
80
95
});
81
96
82
97
pc2.onSignalingStateChange ([](PeerConnection::SignalingState state) {
0 commit comments