Merge branch 'master' into fix-uwp

This commit is contained in:
Paul-Louis Ageneau
2020-11-15 00:01:27 +01:00
62 changed files with 1838 additions and 949 deletions

View File

@ -156,11 +156,11 @@ void test_connectivity() {
cout << "Remote address 2: " << *addr << endl;
Candidate local, remote;
if(pc1->getSelectedCandidatePair(&local, &remote)) {
if (pc1->getSelectedCandidatePair(&local, &remote)) {
cout << "Local candidate 1: " << local << endl;
cout << "Remote candidate 1: " << remote << endl;
}
if(pc2->getSelectedCandidatePair(&local, &remote)) {
if (pc2->getSelectedCandidatePair(&local, &remote)) {
cout << "Local candidate 2: " << local << endl;
cout << "Remote candidate 2: " << remote << endl;
}
@ -208,6 +208,37 @@ void test_connectivity() {
attempts--)
this_thread::sleep_for(1s);
if (!asecond2 || !asecond2->isOpen() || !second1->isOpen())
throw runtime_error("Second DataChannel is not open");
// Try to open a negotiated channel
DataChannelInit init;
init.negotiated = true;
init.id = 42;
auto negotiated1 = pc1->createDataChannel("negotiated", init);
auto negotiated2 = pc2->createDataChannel("negoctated", init);
if (!negotiated1->isOpen() || !negotiated2->isOpen())
throw runtime_error("Negociated DataChannel is not open");
std::atomic<bool> received = false;
negotiated2->onMessage([&received](const variant<binary, string> &message) {
if (holds_alternative<string>(message)) {
cout << "Second Message 2: " << get<string>(message) << endl;
received = true;
}
});
negotiated1->send("Hello from negotiated channel");
// Wait a bit
attempts = 5;
while (!received && attempts--)
this_thread::sleep_for(1s);
if (!received)
throw runtime_error("Negociated DataChannel failed");
// Delay close of peer 2 to check closing works properly
pc1->close();
this_thread::sleep_for(1s);

View File

@ -133,7 +133,7 @@ void test_track() {
this_thread::sleep_for(1s);
if (!at2 || !at2->isOpen() || !t1->isOpen())
throw runtime_error("Renegociated track is not open");
throw runtime_error("Renegotiated track is not open");
// TODO: Test sending RTP packets in track

View File

@ -20,11 +20,11 @@
#if RTC_ENABLE_WEBSOCKET
#include <atomic>
#include <chrono>
#include <iostream>
#include <memory>
#include <thread>
#include <atomic>
using namespace rtc;
using namespace std;
@ -56,14 +56,14 @@ void test_websocket() {
ws->onMessage([&received, &myMessage](variant<binary, string> message) {
if (holds_alternative<string>(message)) {
string str = std::move(get<string>(message));
if((received = (str == myMessage)))
if ((received = (str == myMessage)))
cout << "WebSocket: Received expected message" << endl;
else
cout << "WebSocket: Received UNEXPECTED message" << endl;
}
});
ws->open("wss://echo.websocket.org/");
ws->open("wss://echo.websocket.org:443/");
int attempts = 10;
while ((!ws->isOpen() || !received) && attempts--)
@ -72,7 +72,7 @@ void test_websocket() {
if (!ws->isOpen())
throw runtime_error("WebSocket is not open");
if(!received)
if (!received)
throw runtime_error("Expected message not received");
ws->close();
@ -86,4 +86,3 @@ void test_websocket() {
}
#endif