Refactor nice_agent_set_stream_tos to use agent_find_stream internal API
authorYouness Alaoui <youness.alaoui@collabora.co.uk>
Tue, 5 Feb 2013 03:00:02 +0000 (22:00 -0500)
committerYouness Alaoui <youness.alaoui@collabora.co.uk>
Tue, 5 Feb 2013 03:00:16 +0000 (22:00 -0500)
agent/agent.c

index d848275..df7f4be 100644 (file)
@@ -2958,25 +2958,27 @@ NICEAPI_EXPORT void
 nice_agent_set_stream_tos (NiceAgent *agent,
   guint stream_id, gint tos)
 {
-  GSList *i, *j, *k;
+  GSList *i, *j;
+  Stream *stream;
 
   agent_lock();
 
-  for (i = agent->streams; i; i = i->next) {
-    Stream *stream = i->data;
-    if (stream->id == stream_id) {
-      stream->tos = tos;
-      for (j = stream->components; j; j = j->next) {
-        Component *component = j->data;
-
-        for (k = component->local_candidates; k; k = k->next) {
-          NiceCandidate *local_candidate = k->data;
-          _priv_set_socket_tos (agent, local_candidate->sockptr, tos);
-        }
-      }
+  stream = agent_find_stream (agent, stream_id);
+  if (stream == NULL)
+    goto done;
+
+  stream->tos = tos;
+  for (i = stream->components; i; i = i->next) {
+    Component *component = i->data;
+
+    for (j = component->local_candidates; j; j = j->next) {
+      NiceCandidate *local_candidate = j->data;
+
+      _priv_set_socket_tos (agent, local_candidate->sockptr, tos);
     }
   }
 
+ done:
   agent_unlock();
 }