Commit 51492d41 authored by Olivier Crete's avatar Olivier Crete

Save gio callback function in the Component

darcs-hash:20080426001405-3e2dc-620a44caf56023c4fe32e438ba0d6ee540ec0a79.gz
parent b8eac481
...@@ -108,9 +108,7 @@ static guint signals[N_SIGNALS]; ...@@ -108,9 +108,7 @@ static guint signals[N_SIGNALS];
static gboolean priv_attach_stream_component (NiceAgent *agent, static gboolean priv_attach_stream_component (NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component, Component *component,
GMainContext *ctx, GMainContext *ctx);
NiceAgentRecvFunc func,
gpointer data );
static void priv_detach_stream_component (Stream *stream, Component *component); static void priv_detach_stream_component (Stream *stream, Component *component);
Stream *agent_find_stream (NiceAgent *agent, guint stream_id) Stream *agent_find_stream (NiceAgent *agent, guint stream_id)
...@@ -1700,8 +1698,6 @@ struct _IOCtx ...@@ -1700,8 +1698,6 @@ struct _IOCtx
Stream *stream; Stream *stream;
Component *component; Component *component;
NiceUDPSocket *socket; NiceUDPSocket *socket;
NiceAgentRecvFunc recv_func;
gpointer recv_data;
}; };
...@@ -1710,9 +1706,7 @@ io_ctx_new ( ...@@ -1710,9 +1706,7 @@ io_ctx_new (
NiceAgent *agent, NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component, Component *component,
NiceUDPSocket *socket, NiceUDPSocket *socket)
NiceAgentRecvFunc func,
gpointer data)
{ {
IOCtx *ctx; IOCtx *ctx;
...@@ -1722,8 +1716,6 @@ io_ctx_new ( ...@@ -1722,8 +1716,6 @@ io_ctx_new (
ctx->stream = stream; ctx->stream = stream;
ctx->component = component; ctx->component = component;
ctx->socket = socket; ctx->socket = socket;
ctx->recv_func = func;
ctx->recv_data = data;
} }
return ctx; return ctx;
} }
...@@ -1759,9 +1751,9 @@ nice_agent_g_source_cb ( ...@@ -1759,9 +1751,9 @@ nice_agent_g_source_cb (
len = _nice_agent_recv (agent, stream, component, ctx->socket, len = _nice_agent_recv (agent, stream, component, ctx->socket,
MAX_BUFFER_SIZE, buf); MAX_BUFFER_SIZE, buf);
if (len > 0) if (len > 0 && component->g_source_io_cb)
ctx->recv_func (agent, stream->id, component->id, component->g_source_io_cb (agent, stream->id, component->id,
len, buf, ctx->recv_data); len, buf, component->data);
g_mutex_unlock (agent->mutex); g_mutex_unlock (agent->mutex);
return TRUE; return TRUE;
...@@ -1775,9 +1767,7 @@ nice_agent_g_source_cb ( ...@@ -1775,9 +1767,7 @@ nice_agent_g_source_cb (
static gboolean priv_attach_stream_component (NiceAgent *agent, static gboolean priv_attach_stream_component (NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component, Component *component,
GMainContext *context, GMainContext *context)
NiceAgentRecvFunc func,
gpointer data)
{ {
GSList *i; GSList *i;
...@@ -1792,7 +1782,7 @@ static gboolean priv_attach_stream_component (NiceAgent *agent, ...@@ -1792,7 +1782,7 @@ static gboolean priv_attach_stream_component (NiceAgent *agent,
/* note: without G_IO_ERR the glib mainloop goes into /* note: without G_IO_ERR the glib mainloop goes into
* busyloop if errors are encountered */ * busyloop if errors are encountered */
source = g_io_create_watch (io, G_IO_IN | G_IO_ERR); source = g_io_create_watch (io, G_IO_IN | G_IO_ERR);
ctx = io_ctx_new (agent, stream, component, udp_socket, func, data); ctx = io_ctx_new (agent, stream, component, udp_socket);
g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb, g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb,
ctx, (GDestroyNotify) io_ctx_free); ctx, (GDestroyNotify) io_ctx_free);
g_debug ("Attach source %p (stream %u).", source, stream->id); g_debug ("Attach source %p (stream %u).", source, stream->id);
...@@ -1849,10 +1839,18 @@ nice_agent_attach_recv ( ...@@ -1849,10 +1839,18 @@ nice_agent_attach_recv (
goto done; goto done;
} }
priv_detach_stream_component (stream, component); if (component->g_source_io_cb && func == NULL)
priv_detach_stream_component (stream, component);
ret = TRUE; ret = TRUE;
component->g_source_io_cb = NULL;
if (func != NULL) if (func != NULL)
ret = priv_attach_stream_component (agent, stream, component, ctx, func, data); ret = priv_attach_stream_component (agent, stream, component, ctx);
if (ret)
component->g_source_io_cb = func;
component->data = data;
done: done:
g_mutex_unlock (agent->mutex); g_mutex_unlock (agent->mutex);
......
...@@ -87,6 +87,8 @@ struct _Component ...@@ -87,6 +87,8 @@ struct _Component
gboolean media_after_tick; /**< true if media received since last gboolean media_after_tick; /**< true if media received since last
keepalive tick */ keepalive tick */
NiceCandidate *restart_candidate; /**< for storing active remote candidate during a restart */ NiceCandidate *restart_candidate; /**< for storing active remote candidate during a restart */
NiceAgentRecvFunc g_source_io_cb; /**< function called on io cb */
gpointer data; /**< data passed to the io function */
}; };
Component * Component *
......
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