Skip to content

metaIPC2 on FreeRTOS: A Hands‐On Development Guide (BK7258 BK7259)

yangrtc edited this page Jun 30, 2026 · 1 revision

metaIPC2 on FreeRTOS: A Hands-On Development Guide (BK7258/BK7259)

1. Overview

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

2. Environment Setup and Code Acquisition

2.1 Code Acquisition

2.1.1 Device Side

  • 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
  • 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

2.1.2 Cloud Side

Two server applications are required on the cloud side: mosquitto and coturn.

2.1.3 Client Side

Obtain the client source code:

git clone https://github.com/metartc/yangipcclient.git
# or Gitee mirror
git clone https://gitee.com/metartc/yangipcclient.git

2.2 Compilation

2.2.1 Device Side

First, 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 target

The compiled firmware can be flashed to the target chip.

2.2.2 Cloud Side

2.2.2.1 coturn
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 -v

Core 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:123456

Replace <server_internal_IP> and <server_public_IP> with the actual addresses, and adjust the credentials if necessary.

2.2.2.2 mosquitto

Compile (with SSL, WebSocket, and systemd support):

cd mosquitto
make WITH_SSL=yes WITH_WEBSOCKETS=yes WITH_SYSTEMD=yes

Run:

cd mosquitto/bin
./mosquitto -c mosquitto.conf

Make sure the mosquitto.conf file is properly configured to allow MQTT connections from the device and clients.

2.2.3 Client Side

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.

3. Parameter Configuration

3.1 Device Side

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 network

Start the yangipc service (via command line or system command):

ap_cmd yang_ipc

Note: In a real deployment, replace IP addresses, ports, credentials, Wi-Fi credentials, and the device name with actual values.

3.2 Client Side

3.2.1 Browser

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.

3.2.2 Native Client

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.

Clone this wiki locally