Commit d850f924 authored by Olivier Crete's avatar Olivier Crete

Separate stream creating from candidate gathering

darcs-hash:20080425220943-3e2dc-6de15f6302cd5e71f34c22f9fcb75f2971f32363.gz
parent 4c5fabc4
...@@ -683,8 +683,7 @@ nice_agent_add_stream ( ...@@ -683,8 +683,7 @@ nice_agent_add_stream (
guint n_components) guint n_components)
{ {
Stream *stream; Stream *stream;
GSList *i, *modified_list = NULL; GSList *modified_list = NULL;
guint n;
guint ret = 0; guint ret = 0;
g_mutex_lock (agent->mutex); g_mutex_lock (agent->mutex);
...@@ -699,7 +698,7 @@ nice_agent_add_stream ( ...@@ -699,7 +698,7 @@ nice_agent_add_stream (
if (modified_list) { if (modified_list) {
stream->id = agent->next_stream_id++; stream->id = agent->next_stream_id++;
g_debug ("allocating stream id %u (%p)", stream->id, stream); g_debug ("allocating stream id %u (%p)", stream->id, stream);
stream_initialize_credentials (stream, agent->rng); stream_initialize_credentials (stream, agent->rng);
agent->streams = modified_list; agent->streams = modified_list;
...@@ -708,8 +707,33 @@ nice_agent_add_stream ( ...@@ -708,8 +707,33 @@ nice_agent_add_stream (
stream_free (stream); stream_free (stream);
} }
/* note: error in allocating objects */ ret = stream->id;
if (!modified_list) {
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; goto done;
} }
...@@ -722,22 +746,22 @@ nice_agent_add_stream ( ...@@ -722,22 +746,22 @@ nice_agent_add_stream (
NiceAddress *addr = i->data; NiceAddress *addr = i->data;
NiceCandidate *host_candidate; 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, host_candidate = discovery_add_local_host_candidate (agent, stream->id,
n + 1, addr); n + 1, addr);
if (!host_candidate) { if (!host_candidate) {
stream->id = 0; g_error ("No host candidate??");
break; break;
} }
if (agent->full_mode && if (agent->full_mode &&
agent->stun_server_ip) { agent->stun_server_ip) {
gboolean res = gboolean res =
priv_add_srv_rfx_candidate_discovery (agent, priv_add_srv_rfx_candidate_discovery (agent,
host_candidate, host_candidate,
agent->stun_server_ip, agent->stun_server_ip,
agent->stun_server_port, agent->stun_server_port,
stream, stream,
n + 1 /* component-id */, n + 1 /* component-id */,
...@@ -745,8 +769,7 @@ nice_agent_add_stream ( ...@@ -745,8 +769,7 @@ nice_agent_add_stream (
if (res != TRUE) { if (res != TRUE) {
/* note: memory allocation failure, return error */ /* note: memory allocation failure, return error */
stream->id = 0; g_error ("Memory allocation failure?");
break;
} }
} }
} }
...@@ -761,11 +784,9 @@ nice_agent_add_stream ( ...@@ -761,11 +784,9 @@ nice_agent_add_stream (
discovery_schedule (agent); discovery_schedule (agent);
} }
ret = stream->id;
done: done:
g_mutex_unlock (agent->mutex); g_mutex_unlock (agent->mutex);
return ret;
} }
static void priv_remove_keepalive_timer (NiceAgent *agent) static void priv_remove_keepalive_timer (NiceAgent *agent)
......
...@@ -150,6 +150,11 @@ nice_agent_remove_stream ( ...@@ -150,6 +150,11 @@ nice_agent_remove_stream (
NiceAgent *agent, NiceAgent *agent,
guint stream_id); guint stream_id);
void
nice_agent_gather_candidates (
NiceAgent *agent,
guint stream_id);
gboolean gboolean
nice_agent_set_remote_credentials ( nice_agent_set_remote_credentials (
NiceAgent *agent, NiceAgent *agent,
......
...@@ -284,6 +284,7 @@ gst_nice_src_create ( ...@@ -284,6 +284,7 @@ gst_nice_src_create (
*buffer = nicesrc->outbuf; *buffer = nicesrc->outbuf;
return nicesrc->flow_ret; return nicesrc->flow_ret;
} else { } else {
GST_LOG_OBJECT (nicesrc, "Got interrupting, returning wrong-state");
return GST_FLOW_WRONG_STATE; return GST_FLOW_WRONG_STATE;
} }
......
...@@ -14,6 +14,7 @@ nice_address_to_string ...@@ -14,6 +14,7 @@ nice_address_to_string
nice_agent_add_local_address nice_agent_add_local_address
nice_agent_add_remote_candidate nice_agent_add_remote_candidate
nice_agent_add_stream nice_agent_add_stream
nice_agent_gather_candidates
nice_agent_attach_recv nice_agent_attach_recv
nice_agent_get_local_candidates nice_agent_get_local_candidates
nice_agent_get_local_credentials nice_agent_get_local_credentials
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment