summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/transport/third_party
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/webrtc/transport/third_party')
-rw-r--r--dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.c38
-rw-r--r--dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.h21
-rw-r--r--dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_handler.h6
-rw-r--r--dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.c38
-rw-r--r--dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.h1
-rw-r--r--dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_peer_ctx.c6
6 files changed, 93 insertions, 17 deletions
diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.c b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.c
index 0d498845a4..b428264e5a 100644
--- a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.c
+++ b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.c
@@ -325,8 +325,9 @@ int nr_ice_fetch_turn_servers(int ct, nr_ice_turn_server **out)
#endif /* USE_TURN */
#define MAXADDRS 100 /* Ridiculously high */
-int nr_ice_ctx_create(char *label, UINT4 flags, nr_ice_ctx **ctxp)
- {
+ int nr_ice_ctx_create(char* label, UINT4 flags,
+ nr_ice_gather_handler* gather_handler,
+ nr_ice_ctx** ctxp) {
nr_ice_ctx *ctx=0;
int r,_status;
@@ -341,6 +342,8 @@ int nr_ice_ctx_create(char *label, UINT4 flags, nr_ice_ctx **ctxp)
if(!(ctx->label=r_strdup(label)))
ABORT(R_NO_MEMORY);
+ ctx->gather_handler = gather_handler;
+
/* Get the STUN servers */
if(r=NR_reg_get_child_count(NR_ICE_REG_STUN_SRV_PRFX,
(unsigned int *)&ctx->stun_server_ct_cfg)||ctx->stun_server_ct_cfg==0) {
@@ -442,7 +445,7 @@ int nr_ice_ctx_create(char *label, UINT4 flags, nr_ice_ctx **ctxp)
int i;
nr_ice_stun_id *id1,*id2;
- ctx->done_cb = 0;
+ ctx->gather_done_cb = 0;
ctx->trickle_cb = 0;
STAILQ_FOREACH_SAFE(s1, &ctx->streams, entry, s2){
@@ -452,6 +455,8 @@ int nr_ice_ctx_create(char *label, UINT4 flags, nr_ice_ctx **ctxp)
RFREE(ctx->label);
+ ctx->gather_handler = 0;
+
RFREE(ctx->stun_servers_cfg);
RFREE(ctx->local_addrs);
@@ -539,20 +544,26 @@ void nr_ice_gather_finished_cb(NR_SOCKET s, int h, void *cb_arg)
}
}
- if (nr_ice_media_stream_is_done_gathering(stream) &&
- ctx->trickle_cb) {
- ctx->trickle_cb(ctx->trickle_cb_arg, ctx, stream, component_id, NULL);
+ if (nr_ice_media_stream_is_done_gathering(stream)) {
+ if (ctx->gather_handler && ctx->gather_handler->vtbl->stream_gathered) {
+ ctx->gather_handler->vtbl->stream_gathered(ctx->gather_handler->obj,
+ stream);
+ }
+ if (ctx->trickle_cb) {
+ ctx->trickle_cb(ctx->trickle_cb_arg, ctx, stream, component_id, NULL);
+ }
}
if(ctx->uninitialized_candidates==0){
+ assert(nr_ice_media_stream_is_done_gathering(stream));
r_log(LOG_ICE, LOG_INFO, "ICE(%s): All candidates initialized",
ctx->label);
- if (ctx->done_cb) {
- ctx->done_cb(0,0,ctx->cb_arg);
- }
- else {
+ if (ctx->gather_done_cb) {
+ ctx->gather_done_cb(0, 0, ctx->cb_arg);
+ } else {
r_log(LOG_ICE, LOG_INFO,
- "ICE(%s): No done_cb. We were probably destroyed.", ctx->label);
+ "ICE(%s): No gather_done_cb. We were probably destroyed.",
+ ctx->label);
}
}
else {
@@ -850,8 +861,7 @@ int nr_ice_set_target_for_default_local_address_lookup(nr_ice_ctx *ctx, const ch
return(_status);
}
-int nr_ice_gather(nr_ice_ctx *ctx, NR_async_cb done_cb, void *cb_arg)
- {
+ int nr_ice_gather(nr_ice_ctx* ctx, NR_async_cb gather_done_cb, void* cb_arg) {
int r,_status;
nr_ice_media_stream *stream;
nr_local_addr stun_addrs[MAXADDRS];
@@ -872,7 +882,7 @@ int nr_ice_gather(nr_ice_ctx *ctx, NR_async_cb done_cb, void *cb_arg)
}
r_log(LOG_ICE,LOG_DEBUG,"ICE(%s): Initializing candidates",ctx->label);
- ctx->done_cb=done_cb;
+ ctx->gather_done_cb = gather_done_cb;
ctx->cb_arg=cb_arg;
/* Initialize all the media stream/component pairs */
diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.h b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.h
index 8b3081f567..4039c741ec 100644
--- a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.h
+++ b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_ctx.h
@@ -97,9 +97,23 @@ typedef struct nr_ice_stats_ {
UINT2 turn_438s;
} nr_ice_stats;
+typedef struct nr_ice_gather_handler_vtbl_ {
+ /* This media stream is gathering */
+ int (*stream_gathering)(void* obj, nr_ice_media_stream* stream);
+
+ /* This media stream has finished gathering */
+ int (*stream_gathered)(void* obj, nr_ice_media_stream* stream);
+} nr_ice_gather_handler_vtbl;
+
+typedef struct nr_ice_gather_handler_ {
+ void* obj;
+ nr_ice_gather_handler_vtbl* vtbl;
+} nr_ice_gather_handler;
+
struct nr_ice_ctx_ {
UINT4 flags;
char *label;
+ nr_ice_gather_handler* gather_handler;
UINT4 Ta;
@@ -129,7 +143,7 @@ struct nr_ice_ctx_ {
nr_ice_peer_ctx_head peers;
nr_ice_stun_id_head ids;
- NR_async_cb done_cb;
+ NR_async_cb gather_done_cb;
void *cb_arg;
nr_ice_trickle_candidate_cb trickle_cb;
@@ -141,7 +155,8 @@ struct nr_ice_ctx_ {
nr_transport_addr *target_for_default_local_address_lookup;
};
-int nr_ice_ctx_create(char *label, UINT4 flags, nr_ice_ctx **ctxp);
+int nr_ice_ctx_create(char* label, UINT4 flags,
+ nr_ice_gather_handler* gather_handler, nr_ice_ctx** ctxp);
int nr_ice_ctx_create_with_credentials(char *label, UINT4 flags, char* ufrag, char* pwd, nr_ice_ctx **ctxp);
#define NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION (1)
#define NR_ICE_CTX_FLAGS_LITE (1<<1)
@@ -156,7 +171,7 @@ void nr_ice_ctx_remove_flags(nr_ice_ctx *ctx, UINT4 flags);
void nr_ice_ctx_destroy(nr_ice_ctx** ctxp);
int nr_ice_set_local_addresses(nr_ice_ctx *ctx, nr_local_addr* stun_addrs, int stun_addr_ct);
int nr_ice_set_target_for_default_local_address_lookup(nr_ice_ctx *ctx, const char *target_ip, UINT2 target_port);
-int nr_ice_gather(nr_ice_ctx *ctx, NR_async_cb done_cb, void *cb_arg);
+int nr_ice_gather(nr_ice_ctx* ctx, NR_async_cb gather_done_cb, void* cb_arg);
int nr_ice_add_candidate(nr_ice_ctx *ctx, nr_ice_candidate *cand);
void nr_ice_gather_finished_cb(NR_SOCKET s, int h, void *cb_arg);
int nr_ice_add_media_stream(nr_ice_ctx *ctx,const char *label,const char *ufrag,const char *pwd,int components, nr_ice_media_stream **streamp);
diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_handler.h b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_handler.h
index 5a0690adad..ab3e41ef2d 100644
--- a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_handler.h
+++ b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_handler.h
@@ -56,9 +56,15 @@ int component_id, nr_ice_cand_pair **potentials,int potential_ct);
*/
int (*stream_ready)(void *obj, nr_ice_media_stream *stream);
+ /* This media stream is checking */
+ int (*stream_checking)(void* obj, nr_ice_media_stream* stream);
+
/* This media stream has failed */
int (*stream_failed)(void *obj, nr_ice_media_stream *stream);
+ /* This media stream has disconnected */
+ int (*stream_disconnected)(void* obj, nr_ice_media_stream* stream);
+
/* ICE is connected for this peer ctx */
int (*ice_connected)(void *obj, nr_ice_peer_ctx *pctx);
diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.c b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.c
index 62bfbad629..90e278bedb 100644
--- a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.c
+++ b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.c
@@ -80,6 +80,7 @@ int nr_ice_media_stream_create(nr_ice_ctx *ctx,const char *label,const char *ufr
stream->component_ct=components;
stream->ice_state = NR_ICE_MEDIA_STREAM_UNPAIRED;
stream->obsolete = 0;
+ stream->actually_started_checking = 0;
stream->r2l_user = 0;
stream->l2r_user = 0;
stream->flags = ctx->flags;
@@ -177,8 +178,20 @@ int nr_ice_media_stream_initialize(nr_ice_ctx *ctx, nr_ice_media_stream *stream)
comp=STAILQ_NEXT(comp,entry);
}
+ if (!nr_ice_media_stream_is_done_gathering(stream) && ctx->gather_handler &&
+ ctx->gather_handler->vtbl->stream_gathering) {
+ ctx->gather_handler->vtbl->stream_gathering(ctx->gather_handler->obj,
+ stream);
+ }
+
_status=0;
abort:
+ if (_status) {
+ if (ctx->gather_handler && ctx->gather_handler->vtbl->stream_gathered) {
+ ctx->gather_handler->vtbl->stream_gathered(ctx->gather_handler->obj,
+ stream);
+ }
+ }
return(_status);
}
@@ -413,6 +426,19 @@ static void nr_ice_media_stream_check_timer_cb(NR_SOCKET s, int h, void *cb_arg)
if(pair){
nr_ice_candidate_pair_start(pair->pctx,pair); /* Ignore failures */
+
+ /* stream->ice_state goes to checking when we decide that it is ok to
+ * start checking, which can happen before we get remote candidates. We
+ * want to fire this event when we _actually_ start sending checks. */
+ if (!stream->actually_started_checking) {
+ stream->actually_started_checking = 1;
+ if (stream->pctx->handler &&
+ stream->pctx->handler->vtbl->stream_checking) {
+ stream->pctx->handler->vtbl->stream_checking(
+ stream->pctx->handler->obj, stream->local_stream);
+ }
+ }
+
NR_ASYNC_TIMER_SET(timer_val,nr_ice_media_stream_check_timer_cb,cb_arg,&stream->timer);
}
else {
@@ -729,9 +755,21 @@ void nr_ice_media_stream_set_disconnected(nr_ice_media_stream *stream, int disco
if (disconnected == NR_ICE_MEDIA_STREAM_DISCONNECTED) {
if (!stream->local_stream->obsolete) {
+ if (stream->pctx->handler &&
+ stream->pctx->handler->vtbl->stream_disconnected) {
+ stream->pctx->handler->vtbl->stream_disconnected(
+ stream->pctx->handler->obj, stream->local_stream);
+ }
nr_ice_peer_ctx_disconnected(stream->pctx);
}
} else {
+ if (!stream->local_stream->obsolete) {
+ if (stream->pctx->handler &&
+ stream->pctx->handler->vtbl->stream_ready) {
+ stream->pctx->handler->vtbl->stream_ready(stream->pctx->handler->obj,
+ stream->local_stream);
+ }
+ }
nr_ice_peer_ctx_check_if_connected(stream->pctx);
}
}
diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.h b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.h
index 99f906c100..3da20e3b5e 100644
--- a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.h
+++ b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_media_stream.h
@@ -72,6 +72,7 @@ struct nr_ice_media_stream_ {
* processing. If this stream is connected already, traffic can continue to
* flow for a limited time while the new stream gets ready. */
int obsolete;
+ int actually_started_checking;
#define NR_ICE_MEDIA_STREAM_UNPAIRED 1
#define NR_ICE_MEDIA_STREAM_CHECKS_FROZEN 2
diff --git a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_peer_ctx.c b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_peer_ctx.c
index 0bf97eb984..bfa1fcf44b 100644
--- a/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_peer_ctx.c
+++ b/dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_peer_ctx.c
@@ -671,6 +671,12 @@ void nr_ice_peer_ctx_refresh_consent_all_streams(nr_ice_peer_ctx *pctx)
void nr_ice_peer_ctx_disconnected(nr_ice_peer_ctx *pctx)
{
+ if (pctx->connected_cb_timer) {
+ /* Whoops, never mind */
+ NR_async_timer_cancel(pctx->connected_cb_timer);
+ pctx->connected_cb_timer = 0;
+ }
+
if (pctx->reported_connected &&
pctx->handler &&
pctx->handler->vtbl->ice_disconnected) {