-
Notifications
You must be signed in to change notification settings - Fork 271
metaIPC2 on FreeRTOS: A Hands‐On Development Guide (BK7258 BK7259)
This guide details the integration and development workflow of metaIPC2 on the FreeRTOS system for Beken BK7258 and BK7259 chip platforms.
- Performance Measurement: On the BK7258 platform, the measured end-to-end latency for streaming H.264 video to a browser is consistently in the 100–150 ms range. With full optimization, the latency is expected to drop further to 60–120 ms.
- Hardware Differences: The BK7259 offers higher hardware specifications, and its expected performance will surpass that of the BK7258.
-
Codec Support:
- Video: H.264
- Audio: PCMA / PCMU
-
SDK Repository (choose the branch/version corresponding to your chip):
- BK7258 recommended version:
3.1.9 - BK7259 recommended version:
4.0
# Clone the SDK git clone https://gitlab.bekencorp.com/armino/bk_avdk_smp.git # or mirror git clone https://github.com/bekencorp/bk_avdk_smp.git
- BK7258 recommended version:
-
yangipc Solution:
git clone https://github.com/metartc/bk_solution_yangipc.git # or Gitee mirror git clone https://gitee.com/metartc/bk_solution_yangipc.git
Two server applications are required on the cloud side: mosquitto and coturn.
-
mosquitto:
https://mosquitto.org/download/ -
coturn:
https://github.com/coturn/coturn
Obtain the client source code:
git clone https://github.com/metartc/yangipcclient.git
# or Gitee mirror
git clone https://gitee.com/metartc/yangipcclient.gitFirst, apply the patches from the sdk_patch directory. Refer to the README.md inside the bk_solution_yangipc project for detailed instructions. Then compile:
# Create project directory and enter the SDK
mkdir -p ~/armino && cd ~/armino
cd bk_avdk_smp/bk_solution_yangipc/projects/yangipc
# Clean and build
make clean
make bk7258 # For BK7259, use the corresponding make targetThe compiled firmware can be flashed to the target chip.
cd coturn
./configure
make -j8
sudo cp ./examples/etc/turnserver.conf /usr/local/etc/
# Run in the background
turnserver -c /usr/local/etc/turnserver.conf -vCore Configuration /usr/local/etc/turnserver.conf:
# Listening ports (STUN/TURN)
listening-port=3478
# Encrypted TURNS port
tls-listening-port=5349
# Internal network interface IP
listening-ip=0.0.0.0
relay-ip=<server_internal_IP>
# Required for cloud servers – public IP
external-ip=<server_public_IP>
# Relay media port range
min-port=49152
max-port=65535
# Realm identifier (can be customized)
realm=metartc.cn
# Custom credentials
user=test:123456Replace <server_internal_IP> and <server_public_IP> with the actual addresses, and adjust the credentials if necessary.
Compile (with SSL, WebSocket, and systemd support):
cd mosquitto
make WITH_SSL=yes WITH_WEBSOCKETS=yes WITH_SYSTEMD=yesRun:
cd mosquitto/bin
./mosquitto -c mosquitto.confMake sure the mosquitto.conf file is properly configured to allow MQTT connections from the device and clients.
The client supports multiple platforms. Project directories and build methods:
-
Mobile:
- iOS: Xcode project
- Android: Android Studio project
- Cross-platform frameworks:
- Flutter (Android/iOS)
- React Native (Android/iOS)
- Uniapp (Android/iOS)
-
Desktop:
- Windows: Qt project
- macOS: Qt project
- Linux: Qt project
For detailed compilation and running instructions, refer to the corresponding official documentation or related guides on this site.
Implement the configuration initialization function yang_init_ipcConfig in ap_main.c:
void yang_init_ipcConfig(YangIpcConfig* config) {
// Audio direction: 0 one-way live streaming, 1 two-way intercom
config->audioDirection = 1;
// Video parameters
config->width = 640;
config->height = 480;
config->fps = 30;
// Device name (client must use the same name to communicate)
strcpy(config->deviceName, "test1001");
// Coturn configuration
config->icePort = 3478;
strcpy(config->iceServerIP, "192.168.0.104");
strcpy(config->iceUserName, "metartc");
strcpy(config->icePassword, "metartc");
// MQTT configuration
config->mqttPort = 1883;
strcpy(config->mqttServerIP, "192.168.0.104");
memset(config->mqttUserName, 0, sizeof(config->mqttUserName));
memset(config->mqttPassword, 0, sizeof(config->mqttPassword));
}Connect to Wi-Fi:
yangipc_wifi_sta_connect("ssid", "password"); // Connect to WiFi networkStart the yangipc service (via command line or system command):
ap_cmd yang_ipcNote: In a real deployment, replace IP addresses, ports, credentials, Wi-Fi credentials, and the device name with actual values.
Use the index_mqtt_hd.html page and set the key parameters:
- Around line 107, set the publish topic to match the device name:
var yang_pubTopic = "test1001"; // Must match the deviceName in yang_init_ipcConfig
- Also configure the MQTT server parameters and ICE server (coturn) parameters to match the device-side settings.
Open the page to establish a connection and receive the video stream.
The native client uses the YangIpcPlayer class for connection and playback.
class YangIpcPlayer;
// Initiate MQTT connection with the device name (must match device side)
startMqtt((char*)"test1001");
// Set ICE server (coturn)
void setIceServer(char* ip, int32_t port, char* username, char* password);
// Set MQTT server
void setMqttServer(bool isTls, char* ip, int32_t port, char* username, char* password);Call the above functions in order, ensuring that the ICE and MQTT parameters exactly match the device configuration. This enables cross-network audio/video communication.