changeset 30442:603638fad2f1

Added ability to relay over TCP and TLS for TURN for media.
author Marcus Lundblad <ml@update.uu.se>
date Wed, 25 Aug 2010 19:11:38 +0000
parents d21c8058ead0
children f228c946a5bc
files ChangeLog libpurple/media/backend-fs2.c libpurple/network.c pidgin/gtkprefs.c
diffstat 4 files changed, 55 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Aug 11 03:53:02 2010 +0000
+++ b/ChangeLog	Wed Aug 25 19:11:38 2010 +0000
@@ -3,6 +3,10 @@
 version 2.7.4 (MM/DD/YYYY):
 	General:
 	* Fix search path for Tk when compiling on Debian Squeeze. (#12465)
+	
+	libpurple:
+	* Added ability to use TURN relaying via TCP and TLS (including preference
+	  settings for these).
 
 version 2.7.3 (08/10/2010):
 	General:
--- a/libpurple/media/backend-fs2.c	Wed Aug 11 03:53:02 2010 +0000
+++ b/libpurple/media/backend-fs2.c	Wed Aug 25 19:11:38 2010 +0000
@@ -1564,6 +1564,30 @@
 			(GSourceFunc)src_pad_added_cb_cb, stream);
 }
 
+static GValueArray *
+append_relay_info(GValueArray *relay_info, const gchar *ip, gint port,
+	const gchar *username, const gchar *password, const gchar *type)
+{
+	GValue value;
+	GstStructure *turn_setup = gst_structure_new("relay-info",
+				"ip", G_TYPE_STRING, ip, 
+				"port", G_TYPE_UINT, port,
+				"username", G_TYPE_STRING, username,
+				"password", G_TYPE_STRING, password,
+	            "relay-type", G_TYPE_STRING, type,
+				NULL);
+
+	if (turn_setup) {
+		memset(&value, 0, sizeof(GValue));
+		g_value_init(&value, GST_TYPE_STRUCTURE);
+		gst_value_set_structure(&value, turn_setup);
+		relay_info = g_value_array_append(relay_info, &value);
+		gst_structure_free(turn_setup);
+	}
+
+	return relay_info;
+}
+                        
 static gboolean
 create_stream(PurpleMediaBackendFs2 *self,
 		const gchar *sess_id, const gchar *who,
@@ -1605,31 +1629,32 @@
 
 	if (turn_ip && !strcmp("nice", transmitter)) {
 		GValueArray *relay_info = g_value_array_new(0);
-		GValue value;
-		gint turn_port = purple_prefs_get_int(
-				"/purple/network/turn_port");
+		gint port;
 		const gchar *username =	purple_prefs_get_string(
 				"/purple/network/turn_username");
 		const gchar *password = purple_prefs_get_string(
 				"/purple/network/turn_password");
-		GstStructure *turn_setup = gst_structure_new("relay-info",
-				"ip", G_TYPE_STRING, turn_ip, 
-				"port", G_TYPE_UINT, turn_port,
-				"username", G_TYPE_STRING, username,
-				"password", G_TYPE_STRING, password,
-				NULL);
 
-		if (!turn_setup) {
-			purple_debug_error("backend-fs2",
-					"Error creating relay info structure");
-			return FALSE;
+		/* UDP */
+		port = purple_prefs_get_int("/purple/network/turn_port");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "udp");
 		}
 
-		memset(&value, 0, sizeof(GValue));
-		g_value_init(&value, GST_TYPE_STRUCTURE);
-		gst_value_set_structure(&value, turn_setup);
-		relay_info = g_value_array_append(relay_info, &value);
-		gst_structure_free(turn_setup);
+		/* TCP */
+		port = purple_prefs_get_int("/purple/network/turn_port_tcp");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "tcp");
+		}
+
+		/* TLS */
+		port = purple_prefs_get_int("/purple/network/turn_port_tls");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "tls");
+		}
 
 		purple_debug_info("backend-fs2",
 			"Setting relay-info on new stream\n");
--- a/libpurple/network.c	Wed Aug 11 03:53:02 2010 +0000
+++ b/libpurple/network.c	Wed Aug 25 19:11:38 2010 +0000
@@ -1140,6 +1140,8 @@
 	purple_prefs_add_string("/purple/network/stun_server", "");
 	purple_prefs_add_string("/purple/network/turn_server", "");
 	purple_prefs_add_int   ("/purple/network/turn_port", 3478);
+	purple_prefs_add_int   ("/purple/network/turn_port_tcp", 3478);
+	purple_prefs_add_int   ("/purple/network/turn_port_tls", 443);
 	purple_prefs_add_string("/purple/network/turn_username", "");
 	purple_prefs_add_string("/purple/network/turn_password", "");
 	purple_prefs_add_bool  ("/purple/network/auto_ip", TRUE);
--- a/pidgin/gtkprefs.c	Wed Aug 11 03:53:02 2010 +0000
+++ b/pidgin/gtkprefs.c	Wed Aug 25 19:11:38 2010 +0000
@@ -1809,9 +1809,13 @@
 
 	hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_TURN server:"),
 			sg, entry, TRUE, NULL);
-
-	pidgin_prefs_labeled_spin_button(hbox, _("_Port:"),
+	
+	pidgin_prefs_labeled_spin_button(hbox, _("_UDP:"),
 		"/purple/network/turn_port", 0, 65535, NULL);
+	pidgin_prefs_labeled_spin_button(hbox, _("_TCP:"),
+		"/purple/network/turn_port_tcp", 0, 65535, NULL);
+	pidgin_prefs_labeled_spin_button(hbox, _("_TLS:"),
+		"/purple/network/turn_port_tls", 0, 65535, NULL);
 	hbox = pidgin_prefs_labeled_entry(vbox, _("Use_rname:"),
 		"/purple/network/turn_username", sg);
 	pidgin_prefs_labeled_password(hbox, _("Pass_word:"),