Commit 3e9a5905 authored by Olivier Crête's avatar Olivier Crête

SPECIFIC: Allow creating a GIOStream with a non-reliable agent

Only usable with the patches from
https://bugzilla.gnome.org/show_bug.cgi?id=697907
parent 5fb09c81
......@@ -4788,15 +4788,14 @@ nice_agent_get_io_stream (NiceAgent *agent, guint stream_id,
g_return_val_if_fail (stream_id >= 1, NULL);
g_return_val_if_fail (component_id >= 1, NULL);
g_return_val_if_fail (agent->reliable, NULL);
agent_lock ();
if (!agent_find_component (agent, stream_id, component_id, NULL, &component))
goto done;
if (component->iostream == NULL)
component->iostream = nice_io_stream_new (agent, stream_id, component_id);
component->iostream = nice_io_stream_new (agent, stream_id, component_id,
agent->reliable);
iostream = g_object_ref (component->iostream);
......
......@@ -80,6 +80,8 @@ struct _NiceIOStreamPrivate
guint stream_id;
guint component_id;
gboolean is_datagram;
GInputStream *input_stream; /* owned */
GOutputStream *output_stream; /* owned */
};
......@@ -94,6 +96,7 @@ static GOutputStream *nice_io_stream_get_output_stream (GIOStream *stream);
static void streams_removed_cb (NiceAgent *agent, guint *stream_ids,
gpointer user_data);
static gboolean nice_io_stream_is_datagram (GIOStream *stream);
static void
nice_io_stream_class_init (NiceIOStreamClass *klass)
......@@ -109,6 +112,7 @@ nice_io_stream_class_init (NiceIOStreamClass *klass)
stream_class->get_input_stream = nice_io_stream_get_input_stream;
stream_class->get_output_stream = nice_io_stream_get_output_stream;
stream_class->is_datagram = nice_io_stream_is_datagram;
/*
* NiceIOStream:agent:
......@@ -277,17 +281,24 @@ nice_io_stream_set_property (GObject *object, guint prop_id,
* Since: 0.1.5
*/
GIOStream *
nice_io_stream_new (NiceAgent *agent, guint stream_id, guint component_id)
nice_io_stream_new (NiceAgent *agent, guint stream_id, guint component_id,
gboolean reliable)
{
GIOStream *stream;
g_return_val_if_fail (NICE_IS_AGENT (agent), NULL);
g_return_val_if_fail (stream_id > 0, NULL);
g_return_val_if_fail (component_id > 0, NULL);
return g_object_new (NICE_TYPE_IO_STREAM,
stream = g_object_new (NICE_TYPE_IO_STREAM,
"agent", agent,
"stream-id", stream_id,
"component-id", component_id,
NULL);
NICE_IO_STREAM (stream)->priv->is_datagram = !reliable;
return stream;
}
static GInputStream *
......@@ -348,3 +359,12 @@ streams_removed_cb (NiceAgent *agent, guint *stream_ids, gpointer user_data)
}
}
}
static gboolean
nice_io_stream_is_datagram (GIOStream *stream)
{
NiceIOStream *self = NICE_IO_STREAM (stream);
return self->priv->is_datagram;
}
......@@ -84,7 +84,7 @@ struct _NiceIOStream
};
GIOStream *nice_io_stream_new (NiceAgent *agent,
guint stream_id, guint component_id);
guint stream_id, guint component_id, gboolean reliable);
G_END_DECLS
......
......@@ -492,6 +492,14 @@ nice_output_stream_is_writable (GPollableOutputStream *stream)
goto done;
}
/* If it's a non-reliable agent, it never blocks, so one can
* always write
*/
if (!agent->reliable) {
retval = TRUE;
goto done;
}
/* Check whether any of the component’s FDs are pollable. */
for (i = component->socket_sources; i != NULL; i = i->next) {
SocketSource *socket_source = i->data;
......
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