cpw.malu.xmpp.google_relay: 654214ec: Can now generate a relayed candidate for...
malu at pidgin.im
malu at pidgin.im
Thu Sep 24 16:26:02 EDT 2009
-----------------------------------------------------------------
Revision: 654214ec033cd83759eb1fae4d04309951c33982
Ancestor: 868ed0d8209f9950843fa95b7646c8f300df1042
Author: malu at pidgin.im
Date: 2009-09-24T20:22:24
Branch: im.pidgin.cpw.malu.xmpp.google_relay
URL: http://d.pidgin.im/viewmtn/revision/info/654214ec033cd83759eb1fae4d04309951c33982
Modified files:
libpurple/protocols/jabber/Makefile.am
libpurple/protocols/jabber/google.c
libpurple/protocols/jabber/jingle/jingle.c
libpurple/protocols/jabber/jingle/jingle.h
libpurple/protocols/jabber/jingle/rtp.c
ChangeLog:
Can now generate a relayed candidate for the initiator
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/Makefile.am 94e91143750f6fa784291b1a93b1370ed949b7db
+++ libpurple/protocols/jabber/Makefile.am 41177d46d228a6bbfa355b922aea2ecbb4738d99
@@ -88,7 +88,10 @@ libjabber_la_SOURCES = $(JABBERSOURCES)
st =
pkg_LTLIBRARIES = libjabber.la libxmpp.la
libjabber_la_SOURCES = $(JABBERSOURCES)
-libjabber_la_LIBADD = $(GLIB_LIBS) $(SASL_LIBS) $(LIBXML_LIBS) $(IDN_LIBS)
+libjabber_la_LIBADD = $(GLIB_LIBS) $(SASL_LIBS) $(LIBXML_LIBS) $(IDN_LIBS)\
+ $(FARSIGHT_LIBS) \
+ $(GSTREAMER_LIBS) \
+ $(GSTINTERFACES_LIBS)
libxmpp_la_SOURCES = libxmpp.c
libxmpp_la_LIBADD = libjabber.la
@@ -101,4 +104,7 @@ AM_CPPFLAGS = \
$(DEBUG_CFLAGS) \
$(GLIB_CFLAGS) \
$(IDN_CFLAGS) \
- $(LIBXML_CFLAGS)
+ $(LIBXML_CFLAGS) \
+ $(FARSIGHT_CFLAGS) \
+ $(GSTREAMER_CFLAGS) \
+ $(GSTINTERFACES_CFLAGS)
============================================================
--- libpurple/protocols/jabber/google.c 36a7688310ba40e6a36734e1946d4b61b7d21b9b
+++ libpurple/protocols/jabber/google.c 67a7c6a6238a6b1550b5ac17a9f6cd82996c5e0d
@@ -323,10 +323,14 @@ static GParameter *
}
static GParameter *
-jabber_google_session_get_params(JabberStream *js, guint *num)
+jabber_google_session_get_params(JabberStream *js, const gchar *relay_ip,
+ guint16 relay_udp, guint16 relay_tcp, guint16 relay_ssltcp,
+ const gchar *relay_username, const gchar *relay_password, guint *num)
{
guint num_params;
- GParameter *params = jingle_get_params(js, &num_params);
+ GParameter *params =
+ jingle_get_params(js, relay_ip, relay_udp, relay_tcp, relay_ssltcp,
+ relay_username, relay_password, &num_params);
GParameter *new_params = g_new0(GParameter, num_params + 1);
memcpy(new_params, params, sizeof(GParameter) * num_params);
@@ -342,6 +346,41 @@ static void
}
static void
+jabber_google_relay_parse_response(const gchar *response, gchar **ip,
+ guint *udp, guint *tcp, guint *ssltcp, gchar **username, gchar **password)
+{
+ gchar **lines = g_strsplit(response, "\n", -1);
+ int i = 0;
+
+ for (; lines[i] ; i++) {
+ gchar *line = lines[i];
+ gchar **parts = g_strsplit(line, "=", 2);
+
+ purple_debug_info("jabber", "parsing line %s in Google relay response\n",
+ line);
+
+ if (parts[0] && parts[1]) {
+ if (purple_strequal(parts[0], "relay.ip")) {
+ *ip = g_strdup(parts[1]);
+ } else if (purple_strequal(parts[0], "relay.udp_port")) {
+ *udp = atoi(parts[1]);
+ } else if (purple_strequal(parts[0], "relay.tcp_port")) {
+ *tcp = atoi(parts[1]);
+ } else if (purple_strequal(parts[0], "relay.ssltcp_port")) {
+ *ssltcp = atoi(parts[1]);
+ } else if (purple_strequal(parts[0], "username")) {
+ *username = g_strdup(parts[1]);
+ } else if (purple_strequal(parts[0], "password")) {
+ *password = g_strdup(parts[1]);
+ }
+ }
+ g_strfreev(parts);
+ }
+
+ g_strfreev(lines);
+}
+
+static void
jabber_google_relay_response_cb(PurpleUtilFetchUrlData *url_data,
gpointer user_data, const gchar *url_text, gsize len,
const gchar *error_message)
@@ -350,6 +389,12 @@ jabber_google_relay_response_cb(PurpleUt
GParameter *params;
guint num_params;
JabberStream *js = session->js;
+ gchar *relay_ip = NULL;
+ guint relay_udp = 0;
+ guint relay_tcp = 0;
+ guint relay_ssltcp = 0;
+ gchar *relay_username = NULL;
+ gchar *relay_password = NULL;
js->google_relay_request = NULL;
@@ -358,8 +403,8 @@ jabber_google_relay_response_cb(PurpleUt
if (url_text && len > 0) {
purple_debug_info("jabber", "got Google relay request response:\n%s\n",
url_text);
- } else {
-
+ jabber_google_relay_parse_response(url_text, &relay_ip, &relay_udp,
+ &relay_tcp, &relay_ssltcp, &relay_username, &relay_password);
}
session->media = purple_media_manager_create_media(
@@ -379,8 +424,14 @@ jabber_google_relay_response_cb(PurpleUt
g_signal_connect(G_OBJECT(session->media), "stream-info",
G_CALLBACK(google_session_stream_info_cb), session);
- params = jabber_google_session_get_params(js, &num_params);
+ params =
+ jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp,
+ relay_ssltcp, relay_username, relay_password, &num_params);
+ g_free(relay_ip);
+ g_free(relay_username);
+ g_free(relay_password);
+
if (purple_media_add_stream(session->media, "google-voice",
session->remote_jid, PURPLE_MEDIA_AUDIO,
TRUE, "nice", num_params, params) == FALSE ||
@@ -507,7 +558,9 @@ google_session_handle_initiate(JabberStr
g_signal_connect(G_OBJECT(session->media), "stream-info",
G_CALLBACK(google_session_stream_info_cb), session);
- params = jabber_google_session_get_params(js, &num_params);
+ /* TODO: setup relay stuff... */
+ params = jabber_google_session_get_params(js, NULL, 0, 0, 0, NULL, NULL,
+ &num_params);
if (purple_media_add_stream(session->media, "google-voice",
session->remote_jid, PURPLE_MEDIA_AUDIO, FALSE,
============================================================
--- libpurple/protocols/jabber/jingle/jingle.c 397971687e5784f99459ff5b340dead50b110e83
+++ libpurple/protocols/jabber/jingle/jingle.c 31b899147df244cd678b295555882cabef1b22e9
@@ -35,6 +35,11 @@
#include "rawudp.h"
#include "rtp.h"
+#ifdef USE_VV
+#include <gst/farsight/fs-conference-iface.h>
+#include <gst/farsight/fs-element-added-notifier.h>
+#endif
+
GType
jingle_get_type(const gchar *type)
{
@@ -430,32 +435,103 @@ jingle_terminate_sessions(JabberStream *
jingle_terminate_sessions_gh, NULL);
}
+#ifdef USE_VV
GParameter *
-jingle_get_params(JabberStream *js, guint *num)
+jingle_get_params(JabberStream *js, const gchar *relay_ip, guint relay_udp,
+ guint relay_tcp, guint relay_ssltcp, const gchar *relay_username,
+ const gchar *relay_password, guint *num)
{
/* don't set a STUN server if one is set globally in prefs, in that case
this will be handled in media.c */
gboolean has_account_stun = js->stun_ip && !purple_network_get_stun_ip();
- guint num_params = has_account_stun ? 2 : 0;
+ guint num_params = has_account_stun ?
+ (relay_ip ? 3 : 2) : (relay_ip ? 1 : 0);
GParameter *params = NULL;
-
+ int next_index = 0;
+
if (num_params > 0) {
params = g_new0(GParameter, num_params);
- purple_debug_info("jabber",
- "setting param stun-ip for stream using Google auto-config: %s\n",
- js->stun_ip);
- params[0].name = "stun-ip";
- g_value_init(¶ms[0].value, G_TYPE_STRING);
- g_value_set_string(¶ms[0].value, js->stun_ip);
- purple_debug_info("jabber",
- "setting param stun-port for stream using Google auto-config: %d\n",
- js->stun_port);
- params[1].name = "stun-port";
- g_value_init(¶ms[1].value, G_TYPE_UINT);
- g_value_set_uint(¶ms[1].value, js->stun_port);
+ if (has_account_stun) {
+ purple_debug_info("jabber",
+ "setting param stun-ip for stream using Google auto-config: %s\n",
+ js->stun_ip);
+ params[next_index].name = "stun-ip";
+ g_value_init(¶ms[next_index].value, G_TYPE_STRING);
+ g_value_set_string(¶ms[next_index].value, js->stun_ip);
+ purple_debug_info("jabber",
+ "setting param stun-port for stream using Google auto-config: %d\n",
+ js->stun_port);
+ next_index++;
+ params[next_index].name = "stun-port";
+ g_value_init(¶ms[next_index].value, G_TYPE_UINT);
+ g_value_set_uint(¶ms[next_index].value, js->stun_port);
+ next_index++;
+ }
+
+ if (relay_ip) {
+ GValueArray *relay_info = g_value_array_new(0);
+ GValue udp_value;
+ GValue tcp_value;
+ GValue ssltcp_value;
+
+ if (relay_udp) {
+ GstStructure *turn_setup = gst_structure_new("relay-info",
+ "ip", G_TYPE_STRING, relay_ip,
+ "port", G_TYPE_UINT, relay_udp,
+ "username", G_TYPE_STRING, relay_username,
+ "password", G_TYPE_STRING, relay_password,
+ "relay-type", G_TYPE_STRING, "udp",
+ NULL);
+ if (turn_setup) {
+ memset(&udp_value, 0, sizeof(GValue));
+ g_value_init(&udp_value, GST_TYPE_STRUCTURE);
+ gst_value_set_structure(&udp_value, turn_setup);
+ relay_info = g_value_array_append(relay_info, &udp_value);
+ gst_structure_free(turn_setup);
+ }
+ }
+ if (relay_tcp) {
+ GstStructure *turn_setup = gst_structure_new("relay-info",
+ "ip", G_TYPE_STRING, relay_ip,
+ "port", G_TYPE_UINT, relay_tcp,
+ "username", G_TYPE_STRING, relay_username,
+ "password", G_TYPE_STRING, relay_password,
+ "relay-type", G_TYPE_STRING, "tcp",
+ NULL);
+ if (turn_setup) {
+ memset(&tcp_value, 0, sizeof(GValue));
+ g_value_init(&tcp_value, GST_TYPE_STRUCTURE);
+ gst_value_set_structure(&tcp_value, turn_setup);
+ relay_info = g_value_array_append(relay_info, &tcp_value);
+ gst_structure_free(turn_setup);
+ }
+ }
+ if (relay_ssltcp) {
+ GstStructure *turn_setup = gst_structure_new("relay-info",
+ "ip", G_TYPE_STRING, relay_ip,
+ "port", G_TYPE_UINT, relay_ssltcp,
+ "username", G_TYPE_STRING, relay_username,
+ "password", G_TYPE_STRING, relay_password,
+ "relay-type", G_TYPE_STRING, "tls",
+ NULL);
+ if (turn_setup) {
+ memset(&ssltcp_value, 0, sizeof(GValue));
+ g_value_init(&ssltcp_value, GST_TYPE_STRUCTURE);
+ gst_value_set_structure(&ssltcp_value, turn_setup);
+ relay_info = g_value_array_append(relay_info, &ssltcp_value);
+ gst_structure_free(turn_setup);
+ }
+ }
+ params[next_index].name = "relay-info";
+ g_value_init(¶ms[next_index].value, G_TYPE_VALUE_ARRAY);
+ g_value_set_boxed(¶ms[next_index].value, relay_info);
+ g_value_array_free(relay_info);
+ }
}
*num = num_params;
return params;
}
+#endif
+
============================================================
--- libpurple/protocols/jabber/jingle/jingle.h edc4c414043d627a1980e2058b0c31b552a7c71c
+++ libpurple/protocols/jabber/jingle/jingle.h fc736d6579adae2285d74cdece32d9b48edd0d82
@@ -78,9 +78,13 @@ void jingle_terminate_sessions(JabberStr
void jingle_terminate_sessions(JabberStream *js);
+#ifdef USE_VV
/* create a GParam array given autoconfigured STUN (and later perhaps TURN).
if google_talk is TRUE, set compatability mode to GOOGLE_TALK */
-GParameter *jingle_get_params(JabberStream *js, guint *num_params);
+GParameter *jingle_get_params(JabberStream *js, const gchar *relay_ip,
+ guint relay_udp, guint relay_tcp, guint relay_ssltcp,
+ const gchar *relay_username, const gchar *relay_password, guint *num_params);
+#endif
#ifdef __cplusplus
}
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c 49fe4058345a502d41b67c6f51fce3786d05354e
+++ libpurple/protocols/jabber/jingle/rtp.c 4494c933355ff50242b96e694b5d5d10ebb318d9
@@ -602,7 +602,8 @@ jingle_rtp_init_media(JingleContent *con
: PURPLE_MEDIA_RECV_VIDEO;
params =
- jingle_get_params(jingle_session_get_js(session), &num_params);
+ jingle_get_params(jingle_session_get_js(session), NULL, 0, 0, 0,
+ NULL, NULL, &num_params);
creator = jingle_content_get_creator(content);
if (!strcmp(creator, "initiator"))
More information about the Commits
mailing list