Skip to content

Commit 5b818b1

Browse files
committed
add user_ptr in callback.
1 parent 50fa27a commit 5b818b1

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

include/juice/juice.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ typedef struct juice_stun_binding {
7373
uint16_t port;
7474
} juice_stun_binding_t;
7575

76-
typedef void (*juice_cb_stun_binding_t)(const juice_stun_binding_t *info);
76+
typedef void (*juice_cb_stun_binding_t)(const juice_stun_binding_t *info, void *user_ptr);
7777

7878
typedef struct juice_turn_server {
7979
const char *host;
@@ -129,7 +129,7 @@ JUICE_EXPORT int juice_get_selected_addresses(juice_agent_t *agent, char *local,
129129
char *remote, size_t remote_size);
130130
JUICE_EXPORT int juice_set_local_ice_attributes(juice_agent_t *agent, const char *ufrag, const char *pwd);
131131
JUICE_EXPORT const char *juice_state_to_string(juice_state_t state);
132-
JUICE_EXPORT int juice_bind_stun(const char *bind_address, int local_port, juice_cb_stun_binding_t cb);
132+
JUICE_EXPORT int juice_bind_stun(const char *bind_address, int local_port, juice_cb_stun_binding_t cb, void *user_ptr);
133133
JUICE_EXPORT int juice_unbind_stun();
134134

135135
// ICE server

src/conn.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ int juice_unbind_stun() {
262262
mutex_lock(&registry->mutex);
263263

264264
registry->cb_stun_binding = NULL;
265+
registry->stun_binding_user_ptr = NULL;
265266
conn_mux_interrupt_registry(registry);
266267

267268
release_registry(entry);
@@ -271,7 +272,7 @@ int juice_unbind_stun() {
271272
return 0;
272273
}
273274

274-
int juice_bind_stun(const char *bind_address, int local_port, juice_cb_stun_binding_t cb)
275+
int juice_bind_stun(const char *bind_address, int local_port, juice_cb_stun_binding_t cb, void *user_ptr)
275276
{
276277
conn_mode_entry_t *entry = &mode_entries[JUICE_CONCURRENCY_MODE_MUX];
277278

@@ -293,6 +294,7 @@ int juice_bind_stun(const char *bind_address, int local_port, juice_cb_stun_bind
293294
return -2;
294295

295296
registry->cb_stun_binding = cb;
297+
registry->stun_binding_user_ptr = user_ptr;
296298
mutex_unlock(&registry->mutex);
297299

298300
return 0;

src/conn.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef struct conn_registry {
3131
int agents_size;
3232
int agents_count;
3333
juice_cb_stun_binding_t cb_stun_binding;
34+
void *stun_binding_user_ptr;
3435
} conn_registry_t;
3536

3637
int conn_create(juice_agent_t *agent, udp_socket_config_t *config);

src/conn_mux.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static juice_agent_t *lookup_agent(conn_registry_t *registry, char *buf, size_t
319319
binding_info.address = host;
320320
binding_info.port = addr_get_port((struct sockaddr *)src);
321321

322-
registry->cb_stun_binding(&binding_info);
322+
registry->cb_stun_binding(&binding_info, registry->stun_binding_user_ptr);
323323

324324
return NULL;
325325
}

0 commit comments

Comments
 (0)