|
@@ -22,6 +22,10 @@
|
|
#include <iostream>
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <memory>
|
|
|
|
|
|
|
|
+#ifdef _WIN32
|
|
|
|
+#include <winsock2.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
using namespace rtc;
|
|
using namespace rtc;
|
|
using namespace std;
|
|
using namespace std;
|
|
|
|
|
|
@@ -41,9 +45,26 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
auto pc = std::make_shared<PeerConnection>(config);
|
|
auto pc = std::make_shared<PeerConnection>(config);
|
|
|
|
|
|
|
|
+#ifdef _WIN32
|
|
|
|
+ WSADATA wsaData;
|
|
|
|
+ int iResult;
|
|
|
|
+
|
|
|
|
+ // Initialize Winsock
|
|
|
|
+ iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
|
|
|
+ if (iResult != 0) {
|
|
|
|
+ std::string err("WSAStartup failed. Error:");
|
|
|
|
+ err.append(WSAGetLastError() + "");
|
|
|
|
+ std::cout << err;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
pc->onLocalDescription([](const Description &sdp) {
|
|
pc->onLocalDescription([](const Description &sdp) {
|
|
std::string s(sdp);
|
|
std::string s(sdp);
|
|
std::replace(s.begin(), s.end(), '\n', static_cast<char>(94));
|
|
std::replace(s.begin(), s.end(), '\n', static_cast<char>(94));
|
|
|
|
+#ifdef _WIN32
|
|
|
|
+ std::replace(s.begin(), s.end(), '\r', static_cast<char>(95));
|
|
|
|
+#endif
|
|
cout << "Local Description (Paste this to other peer):" << endl << s << endl << endl;
|
|
cout << "Local Description (Paste this to other peer):" << endl << s << endl << endl;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -102,6 +123,9 @@ int main(int argc, char **argv) {
|
|
getline(cin, sdp);
|
|
getline(cin, sdp);
|
|
|
|
|
|
std::replace(sdp.begin(), sdp.end(), static_cast<char>(94), '\n');
|
|
std::replace(sdp.begin(), sdp.end(), static_cast<char>(94), '\n');
|
|
|
|
+#ifdef _WIN32
|
|
|
|
+ std::replace(sdp.begin(), sdp.end(), static_cast<char>(95), '\r');
|
|
|
|
+#endif
|
|
descPtr = std::make_unique<Description>(sdp, Description::Type::Offer,
|
|
descPtr = std::make_unique<Description>(sdp, Description::Type::Offer,
|
|
Description::Role::Passive);
|
|
Description::Role::Passive);
|
|
pc->setRemoteDescription(*descPtr);
|
|
pc->setRemoteDescription(*descPtr);
|
|
@@ -141,4 +165,8 @@ int main(int argc, char **argv) {
|
|
dc->close();
|
|
dc->close();
|
|
if (pc)
|
|
if (pc)
|
|
pc->close();
|
|
pc->close();
|
|
|
|
+
|
|
|
|
+#ifdef _WIN32
|
|
|
|
+ WSACleanup();
|
|
|
|
+#endif
|
|
}
|
|
}
|