コード例 #1
0
ファイル: component.c プロジェクト: ThoughtWorks-SZ/libnice
/* Reattaches socket handles of @component to the main context.
 *
 * Must *not* take the agent lock, since it’s called from within
 * nice_component_set_io_context(), which holds the Component’s I/O lock. */
static void
nice_component_reattach_all_sockets (NiceComponent *component)
{
  GSList *i;

  for (i = component->socket_sources; i != NULL; i = i->next) {
    SocketSource *socket_source = i->data;
    nice_debug ("Reattach source %p.", socket_source->source);
    socket_source_detach (socket_source);
    socket_source_attach (socket_source, component->ctx);
  }
}
コード例 #2
0
ファイル: component.c プロジェクト: kakaroto/libnice
/* This takes ownership of the socket.
 * It creates and attaches a source to the component’s context. */
void
component_attach_socket (Component *component, NiceSocket *nicesock)
{
  GSList *l;
  SocketSource *socket_source;

  g_assert (component != NULL);
  g_assert (nicesock != NULL);

  g_assert (component->ctx != NULL);

  if (nicesock->fileno == NULL)
    return;

  /* Find an existing SocketSource in the component which contains @socket, or
   * create a new one.
   *
   * Whenever a source is added or remove to socket_sources, socket_sources_age
   * must be incremented.
   */
  l = g_slist_find_custom (component->socket_sources, nicesock,
          _find_socket_source);
  if (l != NULL) {
    socket_source = l->data;
  } else {
    socket_source = g_slice_new0 (SocketSource);
    socket_source->socket = nicesock;
    socket_source->component = component;
    component->socket_sources =
        g_slist_prepend (component->socket_sources, socket_source);
    component->socket_sources_age++;
  }

  /* Create and attach a source */
  nice_debug ("Component %p (agent %p): Attach source (stream %u).",
      component, component->agent, component->stream->id);
  socket_source_attach (socket_source, component->ctx);
}