[Nice] [nice/master] Separate stream creating from candidate gathering
Olivier Crete
olivier.crete at collabora.co.uk
Wed Nov 5 14:01:06 PST 2008
darcs-hash:20080425220943-3e2dc-6de15f6302cd5e71f34c22f9fcb75f2971f32363.gz
---
agent/agent.c | 55 +++++++++++++++++++++++++++++++++++++----------------
agent/agent.h | 5 ++++
gst/gstnicesrc.c | 1 +
nice/libnice.sym | 1 +
4 files changed, 45 insertions(+), 17 deletions(-)
diff --git a/agent/agent.c b/agent/agent.c
index 237c8d3..5d5afc3 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -683,8 +683,7 @@ nice_agent_add_stream (
guint n_components)
{
Stream *stream;
- GSList *i, *modified_list = NULL;
- guint n;
+ GSList *modified_list = NULL;
guint ret = 0;
g_mutex_lock (agent->mutex);
@@ -699,7 +698,7 @@ nice_agent_add_stream (
if (modified_list) {
stream->id = agent->next_stream_id++;
g_debug ("allocating stream id %u (%p)", stream->id, stream);
-
+
stream_initialize_credentials (stream, agent->rng);
agent->streams = modified_list;
@@ -708,8 +707,33 @@ nice_agent_add_stream (
stream_free (stream);
}
- /* note: error in allocating objects */
- if (!modified_list) {
+ ret = stream->id;
+
+ done:
+ g_mutex_unlock (agent->mutex);
+ return ret;
+}
+
+
+/**
+ * nice_agent_gather_candidates:
+ *
+ * start the candidate gathering process
+ */
+
+NICEAPI_EXPORT void
+nice_agent_gather_candidates (
+ NiceAgent *agent,
+ guint stream_id)
+{
+ guint n;
+ GSList *i;
+ Stream *stream;
+
+ g_mutex_lock (agent->mutex);
+
+ stream = agent_find_stream (agent, stream_id);
+ if (stream == NULL) {
goto done;
}
@@ -722,22 +746,22 @@ nice_agent_add_stream (
NiceAddress *addr = i->data;
NiceCandidate *host_candidate;
- for (n = 0; n < n_components; n++) {
+ for (n = 0; n < stream->n_components; n++) {
host_candidate = discovery_add_local_host_candidate (agent, stream->id,
n + 1, addr);
-
+
if (!host_candidate) {
- stream->id = 0;
+ g_error ("No host candidate??");
break;
}
if (agent->full_mode &&
agent->stun_server_ip) {
- gboolean res =
- priv_add_srv_rfx_candidate_discovery (agent,
- host_candidate,
- agent->stun_server_ip,
+ gboolean res =
+ priv_add_srv_rfx_candidate_discovery (agent,
+ host_candidate,
+ agent->stun_server_ip,
agent->stun_server_port,
stream,
n + 1 /* component-id */,
@@ -745,8 +769,7 @@ nice_agent_add_stream (
if (res != TRUE) {
/* note: memory allocation failure, return error */
- stream->id = 0;
- break;
+ g_error ("Memory allocation failure?");
}
}
}
@@ -761,11 +784,9 @@ nice_agent_add_stream (
discovery_schedule (agent);
}
- ret = stream->id;
-
done:
+
g_mutex_unlock (agent->mutex);
- return ret;
}
static void priv_remove_keepalive_timer (NiceAgent *agent)
diff --git a/agent/agent.h b/agent/agent.h
index 3c29373..8b160df 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -150,6 +150,11 @@ nice_agent_remove_stream (
NiceAgent *agent,
guint stream_id);
+void
+nice_agent_gather_candidates (
+ NiceAgent *agent,
+ guint stream_id);
+
gboolean
nice_agent_set_remote_credentials (
NiceAgent *agent,
diff --git a/gst/gstnicesrc.c b/gst/gstnicesrc.c
index 27bf965..a6b64af 100644
--- a/gst/gstnicesrc.c
+++ b/gst/gstnicesrc.c
@@ -284,6 +284,7 @@ gst_nice_src_create (
*buffer = nicesrc->outbuf;
return nicesrc->flow_ret;
} else {
+ GST_LOG_OBJECT (nicesrc, "Got interrupting, returning wrong-state");
return GST_FLOW_WRONG_STATE;
}
diff --git a/nice/libnice.sym b/nice/libnice.sym
index 1c201de..bd46ce0 100644
--- a/nice/libnice.sym
+++ b/nice/libnice.sym
@@ -14,6 +14,7 @@ nice_address_to_string
nice_agent_add_local_address
nice_agent_add_remote_candidate
nice_agent_add_stream
+nice_agent_gather_candidates
nice_agent_attach_recv
nice_agent_get_local_candidates
nice_agent_get_local_credentials
--
1.5.6.5
More information about the Nice
mailing list