Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion components/livekit/core/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static engine_err_t subscribe_tracks(engine_t *eng, livekit_pb_track_info_t *tra
return ENGINE_ERR_INVALID_ARG;
}
if (eng->session.sub_audio_track_sid[0] != '\0') {
return ENGINE_ERR_NONE;
return ENGINE_ERR_MAX_SUB;
}
for (int i = 0; i < count; i++) {
livekit_pb_track_info_t *track = &tracks[i];
Expand Down Expand Up @@ -689,6 +689,16 @@ static bool handle_join(engine_t *eng, const livekit_pb_join_response_t *join)
ESP_LOGE(TAG, "Failed to establish peer connections");
return false;
}

// 6. Subscribe to remote tracks that have already been published.
for (pb_size_t i = 0; i < join->other_participants_count; i++) {
engine_err_t ret = subscribe_tracks(
eng,
join->other_participants[i].tracks,
join->other_participants[i].tracks_count
);
if (ret == ENGINE_ERR_MAX_SUB) break;
}
return true;
}

Expand Down
1 change: 1 addition & 0 deletions components/livekit/core/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef enum {
ENGINE_ERR_RTC = -4,
ENGINE_ERR_MEDIA = -5,
ENGINE_ERR_OTHER = -6,
ENGINE_ERR_MAX_SUB = -7, // No more subscriptions allowed.
// TODO: Add more error cases as needed
} engine_err_t;

Expand Down