Publish Audio - IoT SDK
The audio publishing feature lets an IoT device stream audio into a room for real-time, two-way communication with other participants.
startPublishAudio()
- The
startPublishAudio()function initiates publishing audio data from your IoT device into the active room session. - This function takes no parameters. The participant identity comes from the
participantIdyou set once ininit().
-
You must call the
init()method before invokingstartPublishAudio(). If not, the function will return anINIT_NOT_CALLEDresult code. -
Only one audio-publish stream can run at a time. If audio is already publishing, calling this function again returns a
TASK_ALREADY_STARTEDresult code. (Video publishing is independent and can run at the same time.) -
To stop only this stream without leaving, call
stopPublishAudio();startPublishAudio()resumes it.leave()tears down all publishing and subscribing when you exit the room.
The participantId must be unique for each participant in the room. If you leave it as NULL or an empty string in init(), the SDK generates a unique one for you.
Example
#include "videosdk.h"
#include "esp_log.h"
void app_main(){
result_t publish_result = startPublishAudio();
ESP_LOGI("IOT-SDK", "Publish Result: %d", publish_result);
}
stopPublishAudio()
- The
stopPublishAudio()function stops publishing audio without leaving the room. CallstartPublishAudio()to resume. It is safe to call when audio is not being published.
Example
#include "videosdk.h"
#include "esp_log.h"
void app_main(){
result_t stop_result = stopPublishAudio();
ESP_LOGI("IOT-SDK", "Stop Publish Result: %d", stop_result);
}
API Reference
The API references for all the methods utilized in this guide are provided below.
Got a Question? Ask us on discord

