IoT SDK Methods
create_meeting()
The create_meeting
function creates a new meeting using the provided token and returns a create_meeting_result_t
structure.This structure contains two fields: code
and roomId
.
- If the operation succeeds,
code
is set to0
androomId
holds the newly generated meeting ID. - In case of an error,
code
will be non-zero androomId
will beNULL
.
Parameters
- token
- type:
String
REQUIRED
- type:
Returns
create_meeting_result_t
containingcode
androomId
Example
create_meeting_result_t result = create_meeting("Your - generated - token");
if (result.room_id)
{
ESP_LOGI(TAG, "Created meeting roomId = %s", result.room_id);
free(result.room_id);
}
else
{
ESP_LOGE(TAG, "Failed to create meeting");
}
init()
The init function initializes a meeting using the provided configuration in init_config_t
. A return value of RESULT_OK
signifies success, while any other value indicates an error.
Parameters
init_config_t init_cfg = {
.meetingID = "Your meeting id",
.token = "your authentication token",
.displayName = "ESP32-Device",
.audioCodec = AUDIO_CODEC_OPUS,
};
Returns
result_t
enum.
Example
result_t init_result = init(&init_cfg);
startPublishAudio()
The startPublishAudio
function captures audio from the IoT device and publishes it into the active meeting session. A return value of RESULT_OK
means the audio stream has started successfully, while any non-zero
result code indicates an error and the audio will not be published.
Parameters
- publisherId
- type:
String
REQUIRED
- type:
Returns
result_t
enum.
Example
result_t publish_result = startPublishAudio("your publisherId");
startSubscribeAudio()
The startSubscribeAudio
function subscribes to an audio stream from the meeting and plays it through the IoT device.
The function returns a result_t
code, where RESULT_OK
indicates successful subscription and playback, while any non-zero value signals an error.
Parameters
-
subscriberId
- type:
String
REQUIRED
- It represents your subscriber identity and can be
NULL
or an empty string (in which case the SDK generates one automatically).
- type:
-
subscribeToId
- type:
String
REQUIRED
- It specifies the participant’s id you want to subscribe to. If you want to subscribe to a specific participant, you must provide their
participantId
here. If you passNULL
, the SDK will automatically subscribe to the first participant who joined.
- type:
Returns
result_t
enum.
Example
result_t subscribe_result = startSubscribeAudio(subscriberId, NULL);
stopPublishAudio()
The stopPublishAudio
function stops the ongoing audio publishing task from the IoT device and removes the associated peer from the meeting. Returns a result_t
code, where RESULT_OK
indicates success and a non-zero value indicates failure.
Parameters
- void
Returns
result_t
enum.
Example
result_t stop_publish_result = stopPublishAudio();
stopSubscribeAudio()
The stopSubscribeAudio
function stops the ongoing audio consuming task from the IoT device and removes the associated peer from the meeting. Returns a result_t
code, where RESULT_OK
indicates success and a non-zero value indicates failure.
Parameters
- void
Returns
result_t
enum.
Example
result_t stop_subscribe_result = stopSubscribeAudio();
leave()
The leave
method removes the peer from the active meeting session and stops all ongoing tasks, including publishing
and subscribing
, if they are running.
Parameters
- void
Returns
result_t
enum.
Example
result_t leave_result = leave();
Got a Question? Ask us on discord