From 8c9f090eada4ea1e94cf6cff9001da3a08dee202 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 17 Apr 2015 17:08:43 +0100 Subject: [PATCH] agent: Deprecate nice_agent_new_reliable() and NiceAgent:reliable Reliability of components should now be specified using nice_agent_add_stream_full(). nice_agent_new_reliable() has been deprecated but not removed. If called, it will cause future calls to nice_agent_add_stream() for that NiceAgent instance to create reliable streams; so API backwards compatibility is preserved. https://bugs.freedesktop.org/show_bug.cgi?id=90154 --- agent/agent-priv.h | 2 +- agent/agent.c | 11 ++++++----- agent/agent.h | 7 +++++-- tests/test-build-io-stream.c | 18 +++++++++--------- tests/test-io-stream-common.c | 16 ++++++++-------- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/agent/agent-priv.h b/agent/agent-priv.h index 5996d56..006fd3b 100644 --- a/agent/agent-priv.h +++ b/agent/agent-priv.h @@ -156,7 +156,7 @@ struct _NiceAgent GSource *upnp_timer_source; /* source of upnp timeout timer */ #endif gchar *software_attribute; /* SOFTWARE attribute */ - gboolean reliable; /* property: reliable */ + gboolean deprecated_reliable; /* property: reliable; deprecated */ gboolean keepalive_conncheck; /* property: keepalive_conncheck */ GQueue pending_signals; diff --git a/agent/agent.c b/agent/agent.c index 0e45723..a70b6f2 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -581,6 +581,8 @@ nice_agent_class_init (NiceAgentClass *klass) * ICE-TCP or PseudoTCP over ICE-UDP) * * Since: 0.0.11 + * Deprecated: 0.1.12.1: Specify which components should be reliable when + * calling nice_agent_add_stream_full(). */ g_object_class_install_property (gobject_class, PROP_RELIABLE, g_param_spec_boolean ( @@ -588,7 +590,7 @@ nice_agent_class_init (NiceAgentClass *klass) "reliable mode", "Whether the agent provides a reliable transport of messages", FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_DEPRECATED)); /** * NiceAgent:ice-udp: @@ -1029,7 +1031,6 @@ nice_agent_init (NiceAgent *agent) agent->software_attribute = NULL; agent->compatibility = NICE_COMPATIBILITY_RFC5245; - agent->reliable = FALSE; agent->use_ice_udp = TRUE; agent->use_ice_tcp = TRUE; @@ -1149,7 +1150,7 @@ nice_agent_get_property ( break; case PROP_RELIABLE: - g_value_set_boolean (value, agent->reliable); + g_value_set_boolean (value, agent->deprecated_reliable); break; case PROP_ICE_UDP: @@ -1161,7 +1162,7 @@ nice_agent_get_property ( break; case PROP_BYTESTREAM_TCP: - if (agent->reliable) { + if (agent->deprecated_reliable) { if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) g_value_set_boolean (value, TRUE); else @@ -1336,7 +1337,7 @@ nice_agent_set_property ( break; case PROP_RELIABLE: - agent->reliable = g_value_get_boolean (value); + agent->deprecated_reliable = g_value_get_boolean (value); break; /* Don't allow ice-udp and ice-tcp to be disabled at the same time */ diff --git a/agent/agent.h b/agent/agent.h index 6b256a1..cef4be0 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -53,7 +53,7 @@ * connectivity checks to create a stream of data between you and your peer. * * A #NiceAgent must always be used with a #GMainLoop running the #GMainContext - * passed into nice_agent_new() (or nice_agent_new_reliable()). Without the + * passed into nice_agent_new(). Without the * #GMainContext being iterated, the agent’s timers will not fire, etc. * * Streams and their components are referenced by integer IDs (with respect to a @@ -437,11 +437,14 @@ nice_agent_new (GMainContext *ctx, NiceCompatibility compat); * See also: #NiceAgent::reliable-transport-writable * * Since: 0.0.11 + * Deprecated: 0.1.12.1: Use nice_agent_new() instead, and specify which + * components should be reliable when calling nice_agent_add_stream_full(). * * Returns: The new agent GObject */ NiceAgent * -nice_agent_new_reliable (GMainContext *ctx, NiceCompatibility compat); +nice_agent_new_reliable (GMainContext *ctx, NiceCompatibility compat) + G_GNUC_DEPRECATED_FOR(nice_agent_new); /** * nice_agent_add_local_address: diff --git a/tests/test-build-io-stream.c b/tests/test-build-io-stream.c index 0c9c593..dbb5a32 100644 --- a/tests/test-build-io-stream.c +++ b/tests/test-build-io-stream.c @@ -48,7 +48,7 @@ test_invalid_stream (NiceAddress *addr) NiceAgent *agent; GIOStream *io_stream; - agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245); + agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); nice_agent_add_local_address (agent, addr); /* Try building an I/O stream for an invalid stream. All its operations should @@ -68,10 +68,10 @@ test_io_stream_properties (NiceAddress *addr) GInputStream *input_stream; GOutputStream *output_stream; - agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245); + agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); nice_agent_add_local_address (agent, addr); - stream_id = nice_agent_add_stream (agent, 1); + stream_id = nice_agent_add_stream_full (agent, 1, NICE_COMPONENT_RELIABLE); /* Try building an I/O stream around it. */ io_stream = nice_agent_get_io_stream (agent, stream_id, 1); @@ -124,11 +124,11 @@ test_pollable_properties (NiceAddress *addr) GError *error = NULL; GSource *stream_source; - agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245); + agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); nice_agent_add_local_address (agent, addr); /* Add a stream. */ - stream_id = nice_agent_add_stream (agent, 1); + stream_id = nice_agent_add_stream_full (agent, 1, NICE_COMPONENT_RELIABLE); /* Try building an I/O stream around it. */ io_stream = nice_agent_get_io_stream (agent, stream_id, 1); @@ -294,11 +294,11 @@ test_pollable_cancellation (NiceAddress *addr) GSource *stream_source; GCancellable *cancellable; - agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245); + agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); nice_agent_add_local_address (agent, addr); /* Add a stream. */ - stream_id = nice_agent_add_stream (agent, 1); + stream_id = nice_agent_add_stream_full (agent, 1, NICE_COMPONENT_RELIABLE); /* Try building an I/O stream around it. */ io_stream = nice_agent_get_io_stream (agent, stream_id, 1); @@ -372,11 +372,11 @@ test_zero_length_reads_writes (NiceAddress *addr) GError *error = NULL; guint8 buf[1]; /* should never be accessed */ - agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245); + agent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245); nice_agent_add_local_address (agent, addr); /* Add a stream. */ - stream_id = nice_agent_add_stream (agent, 1); + stream_id = nice_agent_add_stream_full (agent, 1, NICE_COMPONENT_RELIABLE); /* Try building an I/O stream around it. */ io_stream = nice_agent_get_io_stream (agent, stream_id, 1); diff --git a/tests/test-io-stream-common.c b/tests/test-io-stream-common.c index bd0f3b5..c113742 100644 --- a/tests/test-io-stream-common.c +++ b/tests/test-io-stream-common.c @@ -253,10 +253,7 @@ create_agent (gboolean controlling_mode, TestIOStreamThreadData *data, *main_loop = g_main_loop_new (*main_context, FALSE); /* Use Google compatibility to ignore credentials. */ - if (data->reliable) - agent = nice_agent_new_reliable (*main_context, NICE_COMPATIBILITY_GOOGLE); - else - agent = nice_agent_new (*main_context, NICE_COMPATIBILITY_GOOGLE); + agent = nice_agent_new (*main_context, NICE_COMPATIBILITY_GOOGLE); g_object_set (G_OBJECT (agent), "controlling-mode", controlling_mode, @@ -298,11 +295,12 @@ create_agent (gboolean controlling_mode, TestIOStreamThreadData *data, } static void -add_stream (NiceAgent *agent) +add_stream (NiceAgent *agent, NiceComponentFlags component_flags) { guint stream_id; - stream_id = nice_agent_add_stream (agent, 2); + stream_id = nice_agent_add_stream_full (agent, 2, + component_flags, component_flags); g_assert (stream_id > 0); g_object_set_data (G_OBJECT (agent), "stream-id", @@ -413,8 +411,10 @@ run_io_stream_test (guint deadlock_timeout, gboolean reliable, l_main_thread = spawn_thread ("libnice L main", main_thread_cb, &l_data); r_main_thread = spawn_thread ("libnice R main", main_thread_cb, &r_data); - add_stream (l_data.agent); - add_stream (r_data.agent); + add_stream (l_data.agent, + l_data.reliable ? NICE_COMPONENT_RELIABLE : NICE_COMPONENT_UNRELIABLE); + add_stream (r_data.agent, + r_data.reliable ? NICE_COMPONENT_RELIABLE : NICE_COMPONENT_UNRELIABLE); run_agent (&l_data, l_data.agent); run_agent (&r_data, r_data.agent); -- 2.1.0