Skip to content

Commit bd0dc54

Browse files
committed
ESP port: Use esp_websocket_client as an alternate implementation
- Added esp_websocket_client over libwebsockets for ESP-IDF - Using this as default for ESP port as it provides better flexibility for ESP-IDF
1 parent 5e20327 commit bd0dc54

File tree

11 files changed

+4335
-12
lines changed

11 files changed

+4335
-12
lines changed

esp_port/components/kvs_webrtc/CMakeLists.txt

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
set(KVS_WEBRTC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../")
22

3+
# Define source files
4+
set(KVS_SIGNALING_SOURCES
5+
"${KVS_WEBRTC_ROOT}/src/source/Signaling/ChannelInfo.c"
6+
"${KVS_WEBRTC_ROOT}/src/source/Signaling/FileCache.c"
7+
"${KVS_WEBRTC_ROOT}/src/source/Signaling/Client.c"
8+
"${KVS_WEBRTC_ROOT}/src/source/Signaling/StateMachine.c"
9+
)
10+
11+
# Conditionally add either ESP implementation or original implementation
12+
if(CONFIG_USE_ESP_WEBSOCKET_CLIENT)
13+
set(KVS_SIGNALING_SOURCES
14+
${KVS_SIGNALING_SOURCES}
15+
"${CMAKE_CURRENT_SOURCE_DIR}/esp_signaling/SignalingESP.c"
16+
"${CMAKE_CURRENT_SOURCE_DIR}/esp_signaling/LwsApiCallsESP.c"
17+
"${CMAKE_CURRENT_SOURCE_DIR}/src/DataBuffer.c"
18+
)
19+
message(STATUS "Using ESP WebSocket client for signaling")
20+
else()
21+
set(KVS_SIGNALING_SOURCES
22+
${KVS_SIGNALING_SOURCES}
23+
"${KVS_WEBRTC_ROOT}/src/source/Signaling/Signaling.c"
24+
"${KVS_WEBRTC_ROOT}/src/source/Signaling/LwsApiCalls.c"
25+
)
26+
message(STATUS "Using libwebsockets for signaling")
27+
endif()
28+
329
idf_component_register(
430
SRCS "${KVS_WEBRTC_ROOT}/src/source/Crypto/Crypto.c"
531
"${KVS_WEBRTC_ROOT}/src/source/Crypto/Dtls_mbedtls.c"
@@ -37,15 +63,10 @@ idf_component_register(
3763
"${KVS_WEBRTC_ROOT}/src/source/Sctp/Sctp.c"
3864
"${KVS_WEBRTC_ROOT}/src/source/Sdp/Deserialize.c"
3965
"${KVS_WEBRTC_ROOT}/src/source/Sdp/Serialize.c"
40-
"${KVS_WEBRTC_ROOT}/src/source/Signaling/ChannelInfo.c"
41-
"${KVS_WEBRTC_ROOT}/src/source/Signaling/Client.c"
42-
"${KVS_WEBRTC_ROOT}/src/source/Signaling/FileCache.c"
43-
"${KVS_WEBRTC_ROOT}/src/source/Signaling/LwsApiCalls.c"
44-
"${KVS_WEBRTC_ROOT}/src/source/Signaling/Signaling.c"
45-
"${KVS_WEBRTC_ROOT}/src/source/Signaling/StateMachine.c"
4666
"${KVS_WEBRTC_ROOT}/src/source/Srtp/SrtpSession.c"
4767
"${KVS_WEBRTC_ROOT}/src/source/Stun/Stun.c"
4868
"${KVS_WEBRTC_ROOT}/src/source/Threadpool/ThreadPoolContext.c"
69+
${KVS_SIGNALING_SOURCES}
4970

5071
INCLUDE_DIRS "${KVS_WEBRTC_ROOT}/src/include"
5172
"${KVS_WEBRTC_ROOT}/src/source/Crypto"
@@ -60,7 +81,7 @@ idf_component_register(
6081
"${KVS_WEBRTC_ROOT}/src/source/Sctp"
6182
"${KVS_WEBRTC_ROOT}/src/source/Stun"
6283
"${KVS_WEBRTC_ROOT}/src/source/Threadpool"
63-
# "${CMAKE_CURRENT_SOURCE_DIR}/include"
84+
"${CMAKE_CURRENT_SOURCE_DIR}/include"
6485

6586
PRIV_INCLUDE_DIRS "${KVS_WEBRTC_ROOT}/src/source"
6687

@@ -72,10 +93,15 @@ idf_component_register(
7293
"freertos"
7394
"esp_system"
7495
"heap"
75-
"driver" # libwebsockets.h has this include
76-
"spi_flash" # libwebsockets.h has this include
96+
"driver"
97+
"spi_flash"
98+
"esp_http_client"
7799
)
78100

101+
if(CONFIG_USE_ESP_WEBSOCKET_CLIENT)
102+
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DUSE_ESP_WEBSOCKET -DESP_PLATFORM)
103+
endif()
104+
79105
option(ENABLE_KVS_THREADPOOL "Enable support for KVS thread pool in signaling" ON)
80106
set(KVS_PLAT_ESP_FREERTOS ON CACHE BOOL "Build for ESP FreeRTOS")
81107
add_definitions(-DKVS_PLAT_ESP_FREERTOS)

esp_port/components/kvs_webrtc/Kconfig.projbuild

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
menu "KVS WebRTC Configuration"
2+
23
config ENABLE_DATA_CHANNEL
34
bool "Enable Data channel support using usrsctp"
45
default true
56
help
67
Enables WebRTC Data channel support
78

9+
config USE_ESP_WEBSOCKET_CLIENT
10+
bool "Use esp_websocket_client instead of libwebscoekts"
11+
default true
12+
help
13+
Kinesis Video Stream SDK uses libwebsockets for the signaling API requests.
14+
By using esp_websocket_client, you get better control over memory usage as the complete signaling part is re-implemented with ESP-IDF constraints in mind
15+
816
config PREFER_DYNAMIC_ALLOCS
917
bool "Prefer dynamic memory allocations"
1018
default false
@@ -25,4 +33,4 @@ menu "KVS WebRTC Configuration"
2533
range 1 10
2634
help
2735
Maximum number of concurrent WebRTC streams.
28-
endmenu
36+
endmenu

0 commit comments

Comments
 (0)