Skip to main content
Version: 0.0.x

Subscribe Audio - IoT SDK

The Audio subscribing feature allows IoT devices to receive and render audio streams from other participants in a meeting. This enables real-time playback of audio from remote peers in your VideoSDK-powered applications.

startSubscribeAudio()

The startSubscribeAudio() function initiates the process of subscribing to another participant’s audio stream. This allows your IoT device to receive and render audio from a specified peer in the active meeting.

This function requires two parameters:

  • subscriberId: Your unique subscriber ID. This can be set to NULL or an empty string, in which case the SDK will generate a random subscriber ID for you.
  • subscribeToId : It specifies the participant’s id that you want to subscribe to. If you want to subscribe to a specific participant, you must provide their participantId here. If you pass NULL, the SDK will automatically subscribe to the first participant who joined.
note
  • You must call the init() method before invoking startSubscribeAudio(). If not, the function will return an INIT_NOT_CALLED result code.

  • Only one subscribe task can run at a time. If another subscribe task is already active, calling this function again will result in a TASK_ALREADY_STARTED result code.

caution

The subscriberId and publisherId must be unique for each participant in the meeting. If a duplicate ID is detected, the SDK will return a DUPLICATE_ID result code. To resolve this please recheck your subscriberId and publisherId.

Example

#include "videosdk.h"
#include "esp_log.h"

void app_main() {
// Ensure init() is called before this
char *subscriberId = "your subscriberId"; // replace it with your subscriber Id
char *subscriberToId = "remoteParticipant123"; // ID of participant to subscribe

result_t subscribe_result = startSubscribeAudio(subscriberId, subscriberToId);
ESP_LOGI("Subscribe Result: %d", subscribe_result);
}

stopSubscribeAudio

  • The stopSubscribeAudio() function stops the active audio subscription.
  • When invoked, it halts all ongoing subscription processes, terminates the subscribe task, and removes the peer from the active meeting.

Example

#include "videosdk.h"
#include "esp_log.h"

void app_main() {
// Call the function to stop the active subscription task
result_t stop_subscribe_result = stopSubscribeAudio();
ESP_LOGI("Stop Subscribe Result: %d", stop_subscribe_result);
}

API Reference

The API references for all the methods utilized in this guide are provided below.

Got a Question? Ask us on discord