agent: Prevent nice_agent_set_port_range() from being called after a gather
authorOlivier Crête <olivier.crete@collabora.com>
Fri, 28 Mar 2014 01:10:02 +0000 (21:10 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Sun, 30 Mar 2014 06:06:01 +0000 (02:06 -0400)
The port range is only used when gathering, print a critical if it is
called afterwards as it will have no effect.

agent/agent.c

index fe32b27..7673e0f 100644 (file)
@@ -2411,13 +2411,19 @@ NICEAPI_EXPORT void
 nice_agent_set_port_range (NiceAgent *agent, guint stream_id, guint component_id,
     guint min_port, guint max_port)
 {
+  Stream *stream;
   Component *component;
 
   agent_lock();
 
-  if (agent_find_component (agent, stream_id, component_id, NULL, &component)) {
-    component->min_port = min_port;
-    component->max_port = max_port;
+  if (agent_find_component (agent, stream_id, component_id, &stream,
+          &component)) {
+    if (stream->gathering_started) {
+      g_critical ("nice_agent_gather_candidates (stream_id=%u) already called for this stream", stream_id);
+    } else {
+      component->min_port = min_port;
+      component->max_port = max_port;
+    }
   }
 
   agent_unlock_and_emit (agent);