|
@@ -20,6 +20,8 @@
|
|
|
#include <iostream>
|
|
|
#include <thread>
|
|
|
|
|
|
+#include <rtc/rtc.hpp>
|
|
|
+
|
|
|
using namespace std;
|
|
|
using namespace chrono_literals;
|
|
|
|
|
@@ -45,6 +47,7 @@ void test_benchmark() {
|
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
+ // C++ API tests
|
|
|
try {
|
|
|
cout << endl << "*** Running WebRTC connectivity test..." << endl;
|
|
|
test_connectivity();
|
|
@@ -53,7 +56,6 @@ int main(int argc, char **argv) {
|
|
|
cerr << "WebRTC connectivity test failed: " << e.what() << endl;
|
|
|
return -1;
|
|
|
}
|
|
|
- this_thread::sleep_for(1s);
|
|
|
try {
|
|
|
cout << endl << "*** Running WebRTC TURN connectivity test..." << endl;
|
|
|
test_turn_connectivity();
|
|
@@ -62,17 +64,7 @@ int main(int argc, char **argv) {
|
|
|
cerr << "WebRTC TURN connectivity test failed: " << e.what() << endl;
|
|
|
return -1;
|
|
|
}
|
|
|
- this_thread::sleep_for(1s);
|
|
|
- try {
|
|
|
- cout << endl << "*** Running WebRTC C API connectivity test..." << endl;
|
|
|
- test_capi_connectivity();
|
|
|
- cout << "*** Finished WebRTC C API connectivity test" << endl;
|
|
|
- } catch (const exception &e) {
|
|
|
- cerr << "WebRTC C API connectivity test failed: " << e.what() << endl;
|
|
|
- return -1;
|
|
|
- }
|
|
|
#if RTC_ENABLE_MEDIA
|
|
|
- this_thread::sleep_for(1s);
|
|
|
try {
|
|
|
cout << endl << "*** Running WebRTC Track test..." << endl;
|
|
|
test_track();
|
|
@@ -81,19 +73,10 @@ int main(int argc, char **argv) {
|
|
|
cerr << "WebRTC Track test failed: " << e.what() << endl;
|
|
|
return -1;
|
|
|
}
|
|
|
- try {
|
|
|
- cout << endl << "*** Running WebRTC C API track test..." << endl;
|
|
|
- test_capi_track();
|
|
|
- cout << "*** Finished WebRTC C API track test" << endl;
|
|
|
- } catch (const exception &e) {
|
|
|
- cerr << "WebRTC C API track test failed: " << e.what() << endl;
|
|
|
- return -1;
|
|
|
- }
|
|
|
#endif
|
|
|
#if RTC_ENABLE_WEBSOCKET
|
|
|
// TODO: Temporarily disabled as the echo service is unreliable
|
|
|
/*
|
|
|
- this_thread::sleep_for(1s);
|
|
|
try {
|
|
|
cout << endl << "*** Running WebSocket test..." << endl;
|
|
|
test_websocket();
|
|
@@ -111,6 +94,38 @@ int main(int argc, char **argv) {
|
|
|
cerr << "WebSocketServer test failed: " << e.what() << endl;
|
|
|
return -1;
|
|
|
}
|
|
|
+#endif
|
|
|
+ try {
|
|
|
+ // Every created object must have been destroyed, otherwise the wait will block
|
|
|
+ cout << endl << "*** Running cleanup..." << endl;
|
|
|
+ if(rtc::Cleanup().wait_for(10s) == future_status::timeout)
|
|
|
+ throw std::runtime_error("Timeout");
|
|
|
+ cout << "*** Finished cleanup..." << endl;
|
|
|
+ } catch (const exception &e) {
|
|
|
+ cerr << "Cleanup failed: " << e.what() << endl;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // C API tests
|
|
|
+ try {
|
|
|
+ cout << endl << "*** Running WebRTC C API connectivity test..." << endl;
|
|
|
+ test_capi_connectivity();
|
|
|
+ cout << "*** Finished WebRTC C API connectivity test" << endl;
|
|
|
+ } catch (const exception &e) {
|
|
|
+ cerr << "WebRTC C API connectivity test failed: " << e.what() << endl;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+#if RTC_ENABLE_MEDIA
|
|
|
+ try {
|
|
|
+ cout << endl << "*** Running WebRTC C API track test..." << endl;
|
|
|
+ test_capi_track();
|
|
|
+ cout << "*** Finished WebRTC C API track test" << endl;
|
|
|
+ } catch (const exception &e) {
|
|
|
+ cerr << "WebRTC C API track test failed: " << e.what() << endl;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+#if RTC_ENABLE_WEBSOCKET
|
|
|
try {
|
|
|
cout << endl << "*** Running WebSocketServer C API test..." << endl;
|
|
|
test_capi_websocketserver();
|
|
@@ -120,8 +135,16 @@ int main(int argc, char **argv) {
|
|
|
return -1;
|
|
|
}
|
|
|
#endif
|
|
|
+ try {
|
|
|
+ cout << endl << "*** Running C API cleanup..." << endl;
|
|
|
+ rtcCleanup();
|
|
|
+ cout << "*** Finished C API cleanup..." << endl;
|
|
|
+ } catch (const exception &e) {
|
|
|
+ cerr << "C API cleanup failed: " << e.what() << endl;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
/*
|
|
|
- this_thread::sleep_for(1s);
|
|
|
+ // Benchmark
|
|
|
try {
|
|
|
cout << endl << "*** Running WebRTC benchmark..." << endl;
|
|
|
test_benchmark();
|
|
@@ -132,6 +155,5 @@ int main(int argc, char **argv) {
|
|
|
return -1;
|
|
|
}
|
|
|
*/
|
|
|
- std::this_thread::sleep_for(1s);
|
|
|
return 0;
|
|
|
}
|