Skip to content

Commit

Permalink
Merge pull request #134 from Sean-Der/fix_trickle
Browse files Browse the repository at this point in the history
Don't clear candidates on set_remote_description
  • Loading branch information
sepfy authored Sep 21, 2024
2 parents e4cb297 + e021276 commit d3c80cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ void agent_gather_candidate(Agent* agent, const char* urls, const char* username
}

void agent_get_local_description(Agent* agent, char* description, int length) {
int ncandidates = 0;

memset(description, 0, length);
memset(agent->local_ufrag, 0, sizeof(agent->local_ufrag));
memset(agent->local_upwd, 0, sizeof(agent->local_upwd));
Expand All @@ -287,7 +285,6 @@ void agent_get_local_description(Agent* agent, char* description, int length) {
utils_random_string(agent->local_upwd, 24);

snprintf(description, length, "a=ice-ufrag:%s\r\na=ice-pwd:%s\r\n", agent->local_ufrag, agent->local_upwd);
ncandidates = agent->local_candidates_count;

for (int i = 0; i < agent->local_candidates_count; i++) {
ice_candidate_to_description(&agent->local_candidates[i], description + strlen(description), length - strlen(description));
Expand Down
10 changes: 6 additions & 4 deletions src/peer_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static char* peer_connection_dtls_role_setup_value(DtlsSrtpRole d) {
return d == DTLS_SRTP_ROLE_SERVER ? "a=setup:passive" : "a=setup:active";
}

static void peer_connection_state_new(PeerConnection* pc, DtlsSrtpRole role) {
static void peer_connection_state_new(PeerConnection* pc, DtlsSrtpRole role, int isOfferer) {
char* description = (char*)pc->temp_buf;

memset(pc->temp_buf, 0, sizeof(pc->temp_buf));
Expand All @@ -268,7 +268,9 @@ static void peer_connection_state_new(PeerConnection* pc, DtlsSrtpRole role) {

pc->sctp.connected = 0;

agent_clear_candidates(&pc->agent);
if (isOfferer) {
agent_clear_candidates(&pc->agent);
}

agent_gather_candidate(&pc->agent, NULL, NULL, NULL); // host address
for (int i = 0; i < sizeof(pc->config.ice_servers) / sizeof(pc->config.ice_servers[0]); ++i) {
Expand Down Expand Up @@ -346,7 +348,7 @@ int peer_connection_loop(PeerConnection* pc) {
case PEER_CONNECTION_NEW:

if (!pc->b_local_description_created) {
peer_connection_state_new(pc, DTLS_SRTP_ROLE_SERVER);
peer_connection_state_new(pc, DTLS_SRTP_ROLE_SERVER, 1);
}
break;

Expand Down Expand Up @@ -484,7 +486,7 @@ void peer_connection_set_remote_description(PeerConnection* pc, const char* sdp_
}

if (!pc->b_local_description_created) {
peer_connection_state_new(pc, role);
peer_connection_state_new(pc, role, 0);
}

agent_set_remote_description(&pc->agent, (char*)sdp_text);
Expand Down

0 comments on commit d3c80cf

Please sign in to comment.