Renamed ENABLE_WEBSOCKET to RTC_ENABLE_WEBSOCKET

This commit is contained in:
Paul-Louis Ageneau
2020-03-18 18:55:58 +01:00
parent 500e31befa
commit 1a701c33b3
16 changed files with 51 additions and 37 deletions

View File

@ -6,7 +6,7 @@ project (libdatachannel
option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" 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)
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/rtc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/sctptransport.cpp
)
set(LIBDATACHANNEL_WEBSOCKET_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/base64.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/tcptransport.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/tlstransport.cpp
@ -90,26 +92,42 @@ endif()
add_library(Usrsctp::Usrsctp ALIAS usrsctp)
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
VERSION ${PROJECT_VERSION}
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 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
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 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
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_link_libraries(datachannel Threads::Threads Usrsctp::UsrsctpStatic)
target_link_libraries(datachannel-static Threads::Threads Usrsctp::UsrsctpStatic)
if(WIN32)
@ -153,14 +171,6 @@ else()
target_link_libraries(datachannel-static LibNice::LibNice)
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::LibDataChannelStatic ALIAS datachannel-static)

View File

@ -10,7 +10,7 @@ lib libdatachannel
<cxxstd>17
<include>./include/rtc
<define>USE_JUICE=1
<define>ENABLE_WEBSOCKET=0
<define>RTC_ENABLE_WEBSOCKET=0
<library>/libdatachannel//usrsctp
<library>/libdatachannel//juice
<library>/libdatachannel//plog

View File

@ -38,11 +38,11 @@ else
LIBS+=glib-2.0 gobject-2.0 nice
endif
ENABLE_WEBSOCKET ?= 0
ifneq ($(ENABLE_WEBSOCKET), 0)
CPPFLAGS+=-DENABLE_WEBSOCKET=1
RTC_ENABLE_WEBSOCKET ?= 1
ifneq ($(RTC_ENABLE_WEBSOCKET), 0)
CPPFLAGS+=-DRTC_ENABLE_WEBSOCKET=1
else
CPPFLAGS+=-DENABLE_WEBSOCKET=0
CPPFLAGS+=-DRTC_ENABLE_WEBSOCKET=0
endif

View File

@ -19,6 +19,10 @@
#ifndef RTC_INCLUDE_H
#define RTC_INCLUDE_H
#ifndef RTC_ENABLE_WEBSOCKET
#define RTC_ENABLE_WEBSOCKET 1
#endif
#ifdef _WIN32
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0602

View File

@ -100,7 +100,7 @@ int rtcDeleteDataChannel(int dc);
int rtcGetDataChannelLabel(int dc, char *buffer, int size);
// WebSocket
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
int rtcCreateWebSocket(const char *url); // returns ws id
int rtcDeleteWebsocket(int ws);
#endif

View File

@ -19,7 +19,7 @@
#ifndef RTC_WEBSOCKET_H
#define RTC_WEBSOCKET_H
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "channel.hpp"
#include "include.hpp"

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "base64.hpp"

View File

@ -19,7 +19,7 @@
#ifndef RTC_BASE64_H
#define RTC_BASE64_H
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "include.hpp"

View File

@ -21,7 +21,7 @@
#include "datachannel.hpp"
#include "peerconnection.hpp"
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "websocket.hpp"
#endif
@ -48,7 +48,7 @@ namespace {
std::unordered_map<int, shared_ptr<PeerConnection>> peerConnectionMap;
std::unordered_map<int, shared_ptr<DataChannel>> dataChannelMap;
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
std::unordered_map<int, shared_ptr<WebSocket>> webSocketMap;
#endif
std::unordered_map<int, void *> userPointerMap;
@ -111,7 +111,7 @@ bool eraseDataChannel(int dc) {
return true;
}
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
shared_ptr<WebSocket> getWebSocket(int id) {
std::lock_guard lock(mutex);
auto it = webSocketMap.find(id);
@ -138,7 +138,7 @@ shared_ptr<Channel> getChannel(int id) {
std::lock_guard lock(mutex);
if (auto it = dataChannelMap.find(id); it != dataChannelMap.end())
return it->second;
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
if (auto it = webSocketMap.find(id); it != webSocketMap.end())
return it->second;
#endif
@ -206,7 +206,7 @@ int rtcDeleteDataChannel(int dc) {
return 0;
}
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
int rtcCreateWebSocket(const char *url) {
return emplaceWebSocket(std::make_shared<WebSocket>(url));
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "tcptransport.hpp"

View File

@ -19,7 +19,7 @@
#ifndef RTC_TCP_TRANSPORT_H
#define RTC_TCP_TRANSPORT_H
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "include.hpp"
#include "queue.hpp"

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "tlstransport.hpp"
#include "tcptransport.hpp"

View File

@ -19,7 +19,7 @@
#ifndef RTC_TLS_TRANSPORT_H
#define RTC_TLS_TRANSPORT_H
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "include.hpp"
#include "queue.hpp"

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "include.hpp"
#include "websocket.hpp"

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "wstransport.hpp"
#include "tcptransport.hpp"

View File

@ -19,7 +19,7 @@
#ifndef RTC_WS_TRANSPORT_H
#define RTC_WS_TRANSPORT_H
#if ENABLE_WEBSOCKET
#if RTC_ENABLE_WEBSOCKET
#include "include.hpp"
#include "transport.hpp"