Skip to content

Commit 038ab2c

Browse files
committed
WebRTC bridge component
- This component is specifically designed to exchange messages between signaling and streaming planes of the WebRTC - For example, if we want to implement only the streaming part of the webrtc and get signaling messages relayed to it, another device can implement signaling and relay those messages to streaming plane
1 parent e52c8fa commit 038ab2c

File tree

6 files changed

+476
-0
lines changed

6 files changed

+476
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set(srcs "src/webrtc_bridge.c")
2+
3+
set(requires mqtt esp_webrtc_utils)
4+
5+
idf_component_register(SRCS "${srcs}"
6+
REQUIRES ${requires}
7+
INCLUDE_DIRS "include")
8+
9+
if (ENABLE_SIGNALLING_ONLY)
10+
add_definitions(-DENABLE_SIGNALLING_ONLY)
11+
elseif (ENABLE_STREAMING_ONLY)
12+
add_definitions(-DENABLE_STREAMING_ONLY)
13+
endif ()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
menu "WebRTC Bridge Config"
2+
choice WEBRTC_BRIDGE_TYPE
3+
bool "Bridge to use between streaming and signalling device"
4+
default ESP_WEBRTC_BRIDGE_MQTT
5+
default ESP_WEBRTC_BRIDGE_HOSTED if IDF_TARGET_ESP32P4
6+
default ESP_WEBRTC_BRIDGE_HOSTED if IDF_TARGET_ESP32C6
7+
help
8+
Bus interface to be used for communication with the host
9+
10+
config ESP_WEBRTC_BRIDGE_HOSTED
11+
bool "Use hosted bridge"
12+
help
13+
Relay messages using existing esp_hosted communication line
14+
Direct dependancy on `ESP_HOSTED_ENABLED`
15+
16+
config ESP_WEBRTC_BRIDGE_MQTT
17+
bool "Use MQTT bridge"
18+
help
19+
Relay messages using by subscribing and publishing to MQTT broker
20+
endchoice
21+
endmenu
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# WebRTC Bridge
2+
- The communication bridge between Signalling and Streaming part of the WebRTC.
3+
- When running with [split mode](../../README.md#split_mode), we need a bridge between Signalling device and the Streaming device running respective parts of the WebRTC.
4+
- By default, i.e., the bridge used is esp_hosted. It is also possible to use MQTT as the bridge.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
description: webrtc_bridge
2+
version: "0.0.1"
3+
4+
dependencies:
5+
esp_webrtc_utils:
6+
path: ../esp_webrtc_utils
7+
version: "*"
8+
# espressif/esp_hosted:
9+
# override_path: ../esp_hosted
10+
# version: "*"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
/**
14+
* @brief Function pointer type for WebRTC bridge message callback
15+
*
16+
* @param data Pointer to the received message data
17+
* @param len Length of the received message data
18+
*/
19+
typedef void (*webrtc_bridge_msg_cb_t) (const void *data, int len);
20+
21+
/**
22+
* @brief Start the webrtc bridge
23+
*/
24+
void webrtc_bridge_start(void);
25+
26+
/**
27+
* @brief Send message via webrtc bridge
28+
*
29+
* @param data pointer to the data to send
30+
* @param len length of the data to send
31+
*
32+
* @note the data is freed by the webrtc bridge, hence do not free it in the caller
33+
*/
34+
void webrtc_bridge_send_message(const char *data, int len);
35+
36+
/**
37+
* @brief Register a message handler for the webrtc bridge
38+
*
39+
* @param handler function pointer to the message handler
40+
*/
41+
void webrtc_bridge_register_handler(webrtc_bridge_msg_cb_t handler);
42+
43+
#ifdef __cplusplus
44+
}
45+
#endif

0 commit comments

Comments
 (0)