Skip to content

Commit

Permalink
Merge pull request #144 from Sean-Der/main
Browse files Browse the repository at this point in the history
Properly set ICE Role
  • Loading branch information
sepfy authored Sep 25, 2024
2 parents 1c149d2 + 988ca19 commit 6e22529
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ static void agent_create_binding_request(Agent* agent, StunMessage* msg) {
stun_msg_write_attr(msg, STUN_ATTR_TYPE_PRIORITY, 4, (char*)&agent->nominated_pair->priority);
if (agent->mode == AGENT_MODE_CONTROLLING) {
stun_msg_write_attr(msg, STUN_ATTR_TYPE_USE_CANDIDATE, 0, NULL);
stun_msg_write_attr(msg, STUN_ATTR_TYPE_ICE_CONTROLLING, 8, (char*)&tie_breaker);
} else {
stun_msg_write_attr(msg, STUN_ATTR_TYPE_ICE_CONTROLLED, 8, (char*)&tie_breaker);
}
stun_msg_write_attr(msg, STUN_ATTR_TYPE_ICE_CONTROLLED, 8, (char*)&tie_breaker);
stun_msg_finish(msg, STUN_CREDENTIAL_SHORT_TERM, agent->remote_upwd, strlen(agent->remote_upwd));
}

Expand Down
5 changes: 3 additions & 2 deletions src/peer_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ PeerConnection* peer_connection_create(PeerConfiguration* config) {

memcpy(&pc->config, config, sizeof(PeerConfiguration));

pc->agent.mode = AGENT_MODE_CONTROLLED;
agent_create(&pc->agent);

memset(&pc->sctp, 0, sizeof(pc->sctp));
Expand Down Expand Up @@ -270,6 +269,9 @@ static void peer_connection_state_new(PeerConnection* pc, DtlsSrtpRole role, int

if (isOfferer) {
agent_clear_candidates(&pc->agent);
pc->agent.mode = AGENT_MODE_CONTROLLING;
} else {
pc->agent.mode = AGENT_MODE_CONTROLLED;
}

agent_gather_candidate(&pc->agent, NULL, NULL, NULL); // host address
Expand Down Expand Up @@ -465,7 +467,6 @@ void peer_connection_set_remote_description(PeerConnection* pc, const char* sdp_
buf[line - start] = '\0';

if (strstr(buf, "a=setup:passive")) {
pc->agent.mode = AGENT_MODE_CONTROLLING;
role = DTLS_SRTP_ROLE_CLIENT;
}

Expand Down

0 comments on commit 6e22529

Please sign in to comment.