mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-24 07:59:23 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
24e9e06c5a | |||
443a19d8e7 | |||
83de743924 | |||
1dc1de4b86 | |||
8ca7722d48 | |||
3079072e63 | |||
982d1c10e1 | |||
50b22bbf3c | |||
93e153398f |
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (libdatachannel
|
project (libdatachannel
|
||||||
DESCRIPTION "WebRTC DataChannels Library"
|
DESCRIPTION "WebRTC DataChannels Library"
|
||||||
VERSION 0.4.2
|
VERSION 0.4.4
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" OFF)
|
option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" OFF)
|
||||||
@ -16,6 +16,12 @@ endif()
|
|||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if (MSYS OR MINGW)
|
||||||
|
add_definitions(-DSCTP_STDINT_INCLUDE=<stdint.h>)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(LIBDATACHANNEL_SOURCES
|
set(LIBDATACHANNEL_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/candidate.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/candidate.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/certificate.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/certificate.cpp
|
||||||
@ -59,9 +65,15 @@ target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inclu
|
|||||||
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
target_include_directories(datachannel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/plog/include)
|
target_include_directories(datachannel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/plog/include)
|
||||||
target_link_libraries(datachannel
|
target_link_libraries(datachannel
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
Usrsctp::UsrsctpStatic
|
Usrsctp::UsrsctpStatic
|
||||||
|
)
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(datachannel
|
||||||
|
"wsock32" #winsock2
|
||||||
|
"ws2_32" #winsock2
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL ${LIBDATACHANNEL_SOURCES})
|
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL ${LIBDATACHANNEL_SOURCES})
|
||||||
set_target_properties(datachannel-static PROPERTIES
|
set_target_properties(datachannel-static PROPERTIES
|
||||||
@ -76,6 +88,12 @@ target_link_libraries(datachannel-static
|
|||||||
Threads::Threads
|
Threads::Threads
|
||||||
Usrsctp::UsrsctpStatic
|
Usrsctp::UsrsctpStatic
|
||||||
)
|
)
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(datachannel-static
|
||||||
|
"wsock32" #winsock2
|
||||||
|
"ws2_32" #winsock2
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (USE_GNUTLS)
|
if (USE_GNUTLS)
|
||||||
find_package(GnuTLS REQUIRED)
|
find_package(GnuTLS REQUIRED)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# libdatachannel - C/C++ WebRTC DataChannels
|
# libdatachannel - C/C++ WebRTC DataChannels
|
||||||
|
|
||||||
libdatachannel is a standalone implementation of WebRTC DataChannels in C++17 with C bindings. It enables direct connectivity between native applications and web browsers without the pain of importing the entire WebRTC stack. Its API is modelled as a simplified version of the JavaScript WebRTC API, in order to ease the design of cross-environment applications.
|
libdatachannel is a standalone implementation of WebRTC DataChannels in C++17 with C bindings for POSIX platforms and Microsoft Windows. It enables direct connectivity between native applications and web browsers without the pain of importing the entire WebRTC stack. Its API is modelled as a simplified version of the JavaScript WebRTC API, in order to ease the design of cross-environment applications.
|
||||||
|
|
||||||
This projet is originally inspired by [librtcdcpp](https://github.com/chadnickbok/librtcdcpp), however it is a complete rewrite from scratch, because the messy architecture of librtcdcpp made solving its implementation issues difficult.
|
This projet is originally inspired by [librtcdcpp](https://github.com/chadnickbok/librtcdcpp), however it is a complete rewrite from scratch, because the messy architecture of librtcdcpp made solving its implementation issues difficult.
|
||||||
|
|
||||||
|
2
deps/libjuice
vendored
2
deps/libjuice
vendored
Submodule deps/libjuice updated: 65f492dbff...6ac73257b6
@ -19,6 +19,12 @@
|
|||||||
#ifndef RTC_INCLUDE_H
|
#ifndef RTC_INCLUDE_H
|
||||||
#define RTC_INCLUDE_H
|
#define RTC_INCLUDE_H
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifndef _WIN32_WINNT
|
||||||
|
#define _WIN32_WINNT 0x0602
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -22,8 +22,14 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#elif __linux__
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
using std::array;
|
using std::array;
|
||||||
|
@ -19,9 +19,14 @@
|
|||||||
#include "icetransport.hpp"
|
#include "icetransport.hpp"
|
||||||
#include "configuration.hpp"
|
#include "configuration.hpp"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#elif __linux__
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
@ -29,7 +29,12 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#elif __linux__
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "usrsctp.h"
|
#include "usrsctp.h"
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace rtc;
|
using namespace rtc;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -43,6 +47,20 @@ int main(int argc, char **argv) {
|
|||||||
auto pc1 = std::make_shared<PeerConnection>(config);
|
auto pc1 = std::make_shared<PeerConnection>(config);
|
||||||
auto pc2 = std::make_shared<PeerConnection>(config);
|
auto pc2 = 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
|
||||||
|
|
||||||
pc1->onLocalDescription([wpc2 = make_weak_ptr(pc2)](const Description &sdp) {
|
pc1->onLocalDescription([wpc2 = make_weak_ptr(pc2)](const Description &sdp) {
|
||||||
auto pc2 = wpc2.lock();
|
auto pc2 = wpc2.lock();
|
||||||
if (!pc2)
|
if (!pc2)
|
||||||
@ -127,9 +145,15 @@ int main(int argc, char **argv) {
|
|||||||
pc2->close();
|
pc2->close();
|
||||||
|
|
||||||
cout << "Success" << endl;
|
cout << "Success" << endl;
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
cout << "Failure" << endl;
|
cout << "Failure" << endl;
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,24 @@ 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));
|
||||||
|
std::replace(s.begin(), s.end(), '\r', static_cast<char>(95));
|
||||||
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 +121,7 @@ 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');
|
||||||
|
std::replace(sdp.begin(), sdp.end(), static_cast<char>(95), '\r');
|
||||||
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 +161,8 @@ int main(int argc, char **argv) {
|
|||||||
dc->close();
|
dc->close();
|
||||||
if (pc)
|
if (pc)
|
||||||
pc->close();
|
pc->close();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -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,24 @@ 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));
|
||||||
|
std::replace(s.begin(), s.end(), '\r', static_cast<char>(95));
|
||||||
cout << "Local Description (Paste this to other peer):" << endl << s << endl << endl;
|
cout << "Local Description (Paste this to other peer):" << endl << s << endl << endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -100,6 +119,7 @@ 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');
|
||||||
|
std::replace(sdp.begin(), sdp.end(), static_cast<char>(95), '\r');
|
||||||
descPtr = std::make_unique<Description>(sdp);
|
descPtr = std::make_unique<Description>(sdp);
|
||||||
pc->setRemoteDescription(*descPtr);
|
pc->setRemoteDescription(*descPtr);
|
||||||
break;
|
break;
|
||||||
@ -138,4 +158,8 @@ int main(int argc, char **argv) {
|
|||||||
dc->close();
|
dc->close();
|
||||||
if (pc)
|
if (pc)
|
||||||
pc->close();
|
pc->close();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user