mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 15:48:03 +00:00
Renamed ENABLE_WEBSOCKET to RTC_ENABLE_WEBSOCKET
This commit is contained in:
@ -6,7 +6,7 @@ project (libdatachannel
|
|||||||
|
|
||||||
option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" OFF)
|
option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" OFF)
|
||||||
option(USE_JUICE "Use libjuice instead of libnice" OFF)
|
option(USE_JUICE "Use libjuice instead of libnice" OFF)
|
||||||
option(ENABLE_WEBSOCKET "Build WebSocket support" OFF)
|
option(RTC_ENABLE_WEBSOCKET "Build WebSocket support" ON)
|
||||||
|
|
||||||
if(USE_GNUTLS)
|
if(USE_GNUTLS)
|
||||||
option(USE_NETTLE "Use Nettle instead of OpenSSL in libjuice" ON)
|
option(USE_NETTLE "Use Nettle instead of OpenSSL in libjuice" ON)
|
||||||
@ -35,7 +35,9 @@ set(LIBDATACHANNEL_SOURCES
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/peerconnection.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/peerconnection.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/rtc.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/rtc.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/sctptransport.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/sctptransport.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(LIBDATACHANNEL_WEBSOCKET_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/base64.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/base64.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/tcptransport.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/tcptransport.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/tlstransport.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/tlstransport.cpp
|
||||||
@ -90,26 +92,42 @@ endif()
|
|||||||
add_library(Usrsctp::Usrsctp ALIAS usrsctp)
|
add_library(Usrsctp::Usrsctp ALIAS usrsctp)
|
||||||
add_library(Usrsctp::UsrsctpStatic ALIAS usrsctp-static)
|
add_library(Usrsctp::UsrsctpStatic ALIAS usrsctp-static)
|
||||||
|
|
||||||
add_library(datachannel SHARED ${LIBDATACHANNEL_SOURCES})
|
if (RTC_ENABLE_WEBSOCKET)
|
||||||
|
add_library(datachannel SHARED
|
||||||
|
${LIBDATACHANNEL_SOURCES}
|
||||||
|
${LIBDATACHANNEL_WEBSOCKET_SOURCES})
|
||||||
|
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL
|
||||||
|
${LIBDATACHANNEL_SOURCES}
|
||||||
|
${LIBDATACHANNEL_WEBSOCKET_SOURCES})
|
||||||
|
target_compile_definitions(datachannel PUBLIC RTC_ENABLE_WEBSOCKET=1)
|
||||||
|
target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_WEBSOCKET=1)
|
||||||
|
else()
|
||||||
|
add_library(datachannel SHARED
|
||||||
|
${LIBDATACHANNEL_SOURCES})
|
||||||
|
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL
|
||||||
|
${LIBDATACHANNEL_SOURCES})
|
||||||
|
target_compile_definitions(datachannel PUBLIC RTC_ENABLE_WEBSOCKET=0)
|
||||||
|
target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_WEBSOCKET=0)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(datachannel PROPERTIES
|
set_target_properties(datachannel PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
CXX_STANDARD 17)
|
CXX_STANDARD 17)
|
||||||
|
set_target_properties(datachannel-static PROPERTIES
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
CXX_STANDARD 17)
|
||||||
|
|
||||||
target_include_directories(datachannel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(datachannel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
|
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
|
||||||
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 Threads::Threads Usrsctp::UsrsctpStatic)
|
|
||||||
|
|
||||||
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL ${LIBDATACHANNEL_SOURCES})
|
|
||||||
set_target_properties(datachannel-static PROPERTIES
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
CXX_STANDARD 17)
|
|
||||||
|
|
||||||
target_include_directories(datachannel-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(datachannel-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
|
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
|
||||||
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
target_include_directories(datachannel-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/plog/include)
|
target_include_directories(datachannel-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/plog/include)
|
||||||
|
|
||||||
|
target_link_libraries(datachannel Threads::Threads Usrsctp::UsrsctpStatic)
|
||||||
target_link_libraries(datachannel-static Threads::Threads Usrsctp::UsrsctpStatic)
|
target_link_libraries(datachannel-static Threads::Threads Usrsctp::UsrsctpStatic)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -153,14 +171,6 @@ else()
|
|||||||
target_link_libraries(datachannel-static LibNice::LibNice)
|
target_link_libraries(datachannel-static LibNice::LibNice)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_WEBSOCKET)
|
|
||||||
target_compile_definitions(datachannel PRIVATE ENABLE_WEBSOCKET=1)
|
|
||||||
target_compile_definitions(datachannel-static PRIVATE ENABLE_WEBSOCKET=1)
|
|
||||||
else()
|
|
||||||
target_compile_definitions(datachannel PRIVATE ENABLE_WEBSOCKET=0)
|
|
||||||
target_compile_definitions(datachannel-static PRIVATE ENABLE_WEBSOCKET=0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(LibDataChannel::LibDataChannel ALIAS datachannel)
|
add_library(LibDataChannel::LibDataChannel ALIAS datachannel)
|
||||||
add_library(LibDataChannel::LibDataChannelStatic ALIAS datachannel-static)
|
add_library(LibDataChannel::LibDataChannelStatic ALIAS datachannel-static)
|
||||||
|
|
||||||
|
2
Jamfile
2
Jamfile
@ -10,7 +10,7 @@ lib libdatachannel
|
|||||||
<cxxstd>17
|
<cxxstd>17
|
||||||
<include>./include/rtc
|
<include>./include/rtc
|
||||||
<define>USE_JUICE=1
|
<define>USE_JUICE=1
|
||||||
<define>ENABLE_WEBSOCKET=0
|
<define>RTC_ENABLE_WEBSOCKET=0
|
||||||
<library>/libdatachannel//usrsctp
|
<library>/libdatachannel//usrsctp
|
||||||
<library>/libdatachannel//juice
|
<library>/libdatachannel//juice
|
||||||
<library>/libdatachannel//plog
|
<library>/libdatachannel//plog
|
||||||
|
8
Makefile
8
Makefile
@ -38,11 +38,11 @@ else
|
|||||||
LIBS+=glib-2.0 gobject-2.0 nice
|
LIBS+=glib-2.0 gobject-2.0 nice
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ENABLE_WEBSOCKET ?= 0
|
RTC_ENABLE_WEBSOCKET ?= 1
|
||||||
ifneq ($(ENABLE_WEBSOCKET), 0)
|
ifneq ($(RTC_ENABLE_WEBSOCKET), 0)
|
||||||
CPPFLAGS+=-DENABLE_WEBSOCKET=1
|
CPPFLAGS+=-DRTC_ENABLE_WEBSOCKET=1
|
||||||
else
|
else
|
||||||
CPPFLAGS+=-DENABLE_WEBSOCKET=0
|
CPPFLAGS+=-DRTC_ENABLE_WEBSOCKET=0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
#ifndef RTC_INCLUDE_H
|
#ifndef RTC_INCLUDE_H
|
||||||
#define RTC_INCLUDE_H
|
#define RTC_INCLUDE_H
|
||||||
|
|
||||||
|
#ifndef RTC_ENABLE_WEBSOCKET
|
||||||
|
#define RTC_ENABLE_WEBSOCKET 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _WIN32_WINNT
|
#ifndef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0602
|
#define _WIN32_WINNT 0x0602
|
||||||
|
@ -100,7 +100,7 @@ int rtcDeleteDataChannel(int dc);
|
|||||||
int rtcGetDataChannelLabel(int dc, char *buffer, int size);
|
int rtcGetDataChannelLabel(int dc, char *buffer, int size);
|
||||||
|
|
||||||
// WebSocket
|
// WebSocket
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
int rtcCreateWebSocket(const char *url); // returns ws id
|
int rtcCreateWebSocket(const char *url); // returns ws id
|
||||||
int rtcDeleteWebsocket(int ws);
|
int rtcDeleteWebsocket(int ws);
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef RTC_WEBSOCKET_H
|
#ifndef RTC_WEBSOCKET_H
|
||||||
#define RTC_WEBSOCKET_H
|
#define RTC_WEBSOCKET_H
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "include.hpp"
|
#include "include.hpp"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "base64.hpp"
|
#include "base64.hpp"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef RTC_BASE64_H
|
#ifndef RTC_BASE64_H
|
||||||
#define RTC_BASE64_H
|
#define RTC_BASE64_H
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "include.hpp"
|
#include "include.hpp"
|
||||||
|
|
||||||
|
10
src/rtc.cpp
10
src/rtc.cpp
@ -21,7 +21,7 @@
|
|||||||
#include "datachannel.hpp"
|
#include "datachannel.hpp"
|
||||||
#include "peerconnection.hpp"
|
#include "peerconnection.hpp"
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
#include "websocket.hpp"
|
#include "websocket.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ namespace {
|
|||||||
|
|
||||||
std::unordered_map<int, shared_ptr<PeerConnection>> peerConnectionMap;
|
std::unordered_map<int, shared_ptr<PeerConnection>> peerConnectionMap;
|
||||||
std::unordered_map<int, shared_ptr<DataChannel>> dataChannelMap;
|
std::unordered_map<int, shared_ptr<DataChannel>> dataChannelMap;
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
std::unordered_map<int, shared_ptr<WebSocket>> webSocketMap;
|
std::unordered_map<int, shared_ptr<WebSocket>> webSocketMap;
|
||||||
#endif
|
#endif
|
||||||
std::unordered_map<int, void *> userPointerMap;
|
std::unordered_map<int, void *> userPointerMap;
|
||||||
@ -111,7 +111,7 @@ bool eraseDataChannel(int dc) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
shared_ptr<WebSocket> getWebSocket(int id) {
|
shared_ptr<WebSocket> getWebSocket(int id) {
|
||||||
std::lock_guard lock(mutex);
|
std::lock_guard lock(mutex);
|
||||||
auto it = webSocketMap.find(id);
|
auto it = webSocketMap.find(id);
|
||||||
@ -138,7 +138,7 @@ shared_ptr<Channel> getChannel(int id) {
|
|||||||
std::lock_guard lock(mutex);
|
std::lock_guard lock(mutex);
|
||||||
if (auto it = dataChannelMap.find(id); it != dataChannelMap.end())
|
if (auto it = dataChannelMap.find(id); it != dataChannelMap.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
if (auto it = webSocketMap.find(id); it != webSocketMap.end())
|
if (auto it = webSocketMap.find(id); it != webSocketMap.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
#endif
|
#endif
|
||||||
@ -206,7 +206,7 @@ int rtcDeleteDataChannel(int dc) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
int rtcCreateWebSocket(const char *url) {
|
int rtcCreateWebSocket(const char *url) {
|
||||||
return emplaceWebSocket(std::make_shared<WebSocket>(url));
|
return emplaceWebSocket(std::make_shared<WebSocket>(url));
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "tcptransport.hpp"
|
#include "tcptransport.hpp"
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef RTC_TCP_TRANSPORT_H
|
#ifndef RTC_TCP_TRANSPORT_H
|
||||||
#define RTC_TCP_TRANSPORT_H
|
#define RTC_TCP_TRANSPORT_H
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "include.hpp"
|
#include "include.hpp"
|
||||||
#include "queue.hpp"
|
#include "queue.hpp"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "tlstransport.hpp"
|
#include "tlstransport.hpp"
|
||||||
#include "tcptransport.hpp"
|
#include "tcptransport.hpp"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef RTC_TLS_TRANSPORT_H
|
#ifndef RTC_TLS_TRANSPORT_H
|
||||||
#define RTC_TLS_TRANSPORT_H
|
#define RTC_TLS_TRANSPORT_H
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "include.hpp"
|
#include "include.hpp"
|
||||||
#include "queue.hpp"
|
#include "queue.hpp"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "include.hpp"
|
#include "include.hpp"
|
||||||
#include "websocket.hpp"
|
#include "websocket.hpp"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "wstransport.hpp"
|
#include "wstransport.hpp"
|
||||||
#include "tcptransport.hpp"
|
#include "tcptransport.hpp"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef RTC_WS_TRANSPORT_H
|
#ifndef RTC_WS_TRANSPORT_H
|
||||||
#define RTC_WS_TRANSPORT_H
|
#define RTC_WS_TRANSPORT_H
|
||||||
|
|
||||||
#if ENABLE_WEBSOCKET
|
#if RTC_ENABLE_WEBSOCKET
|
||||||
|
|
||||||
#include "include.hpp"
|
#include "include.hpp"
|
||||||
#include "transport.hpp"
|
#include "transport.hpp"
|
||||||
|
Reference in New Issue
Block a user