Browse Source

Added signaling state to tests

Paul-Louis Ageneau 4 years ago
parent
commit
e91d721b20
2 changed files with 21 additions and 2 deletions
  1. 13 2
      test/capi_connectivity.cpp
  2. 8 0
      test/connectivity.cpp

+ 13 - 2
test/capi_connectivity.cpp

@@ -34,6 +34,7 @@ static void sleep(unsigned int secs) { Sleep(secs * 1000); }
 typedef struct {
 	rtcState state;
 	rtcGatheringState gatheringState;
+	rtcSignalingState signalingState;
 	int pc;
 	int dc;
 	bool connected;
@@ -68,6 +69,12 @@ static void gatheringStateCallback(int pc, rtcGatheringState state, void *ptr) {
 	printf("Gathering state %d: %d\n", peer == peer1 ? 1 : 2, (int)state);
 }
 
+static void signalingStateCallback(int pc, rtcSignalingState state, void *ptr) {
+	Peer *peer = (Peer *)ptr;
+	peer->signalingState = state;
+	printf("Signaling state %d: %d\n", peer == peer1 ? 1 : 2, (int)state);
+}
+
 static void openCallback(int id, void *ptr) {
 	Peer *peer = (Peer *)ptr;
 	peer->connected = true;
@@ -180,6 +187,12 @@ int test_capi_connectivity_main() {
 		goto error;
 	}
 
+	if (peer1->signalingState != RTC_SIGNALING_STABLE ||
+	    peer2->signalingState != RTC_SIGNALING_STABLE) {
+		fprintf(stderr, "Signaling state is not stable\n");
+		goto error;
+	}
+
 	if (!peer1->connected || !peer2->connected) {
 		fprintf(stderr, "DataChannel is not connected\n");
 		goto error;
@@ -236,7 +249,6 @@ int test_capi_connectivity_main() {
 	}
 	printf("Remote address 2: %s\n", buffer);
 
-
 	if (rtcGetSelectedCandidatePair(peer1->pc, buffer, BUFFER_SIZE, buffer2, BUFFER_SIZE) < 0) {
 		fprintf(stderr, "rtcGetSelectedCandidatePair failed\n");
 		goto error;
@@ -251,7 +263,6 @@ int test_capi_connectivity_main() {
 	printf("Local candidate 2:  %s\n", buffer);
 	printf("Remote candidate 2: %s\n", buffer2);
 
-
 	deletePeer(peer1);
 	sleep(1);
 	deletePeer(peer2);

+ 8 - 0
test/connectivity.cpp

@@ -69,6 +69,10 @@ void test_connectivity() {
 		cout << "Gathering state 1: " << state << endl;
 	});
 
+	pc1->onSignalingStateChange([](PeerConnection::SignalingState state) {
+		cout << "Signaling state 1: " << state << endl;
+	});
+
 	pc2->onLocalDescription([wpc1 = make_weak_ptr(pc1)](Description sdp) {
 		auto pc1 = wpc1.lock();
 		if (!pc1)
@@ -91,6 +95,10 @@ void test_connectivity() {
 		cout << "Gathering state 2: " << state << endl;
 	});
 
+	pc2->onSignalingStateChange([](PeerConnection::SignalingState state) {
+		cout << "Signaling state 2: " << state << endl;
+	});
+
 	shared_ptr<DataChannel> dc2;
 	pc2->onDataChannel([&dc2](shared_ptr<DataChannel> dc) {
 		cout << "DataChannel 2: Received with label \"" << dc->label() << "\"" << endl;