pidgin.2.x.y: 68e940c0: Port to Farstream

rlaager at pidgin.im rlaager at pidgin.im
Fri Apr 6 00:43:51 EDT 2012


----------------------------------------------------------------------
Revision: 68e940c00e0139f6c56254e6c46fbad903fac17e
Parent:   1f57443e276782649f964e5c3c2e9213317bf368
Author:   olivier.crete at collabora.com
Date:     04/04/12 23:18:40
Branch:   im.pidgin.pidgin.2.x.y
URL: http://d.pidgin.im/viewmtn/revision/info/68e940c00e0139f6c56254e6c46fbad903fac17e

Changelog: 

Port to Farstream

Farstream is the new name of Farsight.

The changes to support Farstream are from ocrete.  rlaager modified the
patch to retain the Farsight code using #ifdef HAVE_FARSIGHT.

Changes against parent 1f57443e276782649f964e5c3c2e9213317bf368

  patched  configure.ac
  patched  libpurple/Makefile.am
  patched  libpurple/media/backend-fs2.c
  patched  libpurple/mediamanager.c

-------------- next part --------------
============================================================
--- configure.ac	b5155d791d3bfc938939d529453e5b327c518dea
+++ configure.ac	2a9cd757a9f1a8ab095ffe87be3c2d71cb193632
@@ -786,20 +786,26 @@ dnl ####################################
 fi
 
 dnl #######################################################################
-dnl # Check for Farsight
+dnl # Check for Farstream
 dnl #######################################################################
-AC_ARG_ENABLE(farsight,
-	[AC_HELP_STRING([--disable-farsight], [compile without farsight support])],
-	enable_farsight="$enableval", enable_farsight="yes")
-if test "x$enable_farsight" != "xno"; then
-	PKG_CHECK_MODULES(FARSIGHT, [farsight2-0.10 >= 0.0.9], [
-		AC_DEFINE(USE_FARSIGHT, 1, [Use Farsight for voice and video])
-		AC_SUBST(FARSIGHT_CFLAGS)
-		AC_SUBST(FARSIGHT_LIBS)
-	], [
-		enable_farsight="no"
-	])
-fi
+AC_ARG_ENABLE(farstream,
+	[AC_HELP_STRING([--disable-farstream], [compile without farstream support])],
+	enable_farstream="$enableval", enable_farstream="yes")
+if test "x$enable_farstream" != "xno"; then
+	PKG_CHECK_MODULES(FARSTREAM, [farstream-0.1], [
+		AC_SUBST(FARSTREAM_CFLAGS)
+		AC_SUBST(FARSTREAM_LIBS)
+ 	], [
+		# Try farsight.
+		PKG_CHECK_MODULES(FARSTREAM, [farsight2-0.10 >= 0.0.9], [
+		        AC_DEFINE(HAVE_FARSIGHT, 1, [Use Farsight instead of Farstream])
+			AC_SUBST(FARSTREAM_CFLAGS)
+			AC_SUBST(FARSTREAM_LIBS)
+		], [
+		        enable_farstream="no"
+		])
+ 	])
+ fi
 
 dnl #######################################################################
 dnl # Check for Voice and Video support
@@ -808,20 +814,20 @@ if test "x$enable_vv" != "xno"; then
 	[AC_HELP_STRING([--disable-vv], [compile without voice and video support])],
 	enable_vv="$enableval", enable_vv="yes")
 if test "x$enable_vv" != "xno"; then
-	if test "x$enable_gstreamer" != "xno" -a "x$enable_gstinterfaces" != "xno" -a "x$enable_farsight" != "xno"; then
+	if test "x$enable_gstreamer" != "xno" -a "x$enable_gstinterfaces" != "xno" -a "x$enable_farstream" != "xno"; then
 		AC_DEFINE(USE_VV, 1, [Use voice and video])
 	else
 		enable_vv="no"
 		if test "x$force_deps" = "xyes"; then
 			AC_MSG_ERROR([
 Dependencies for voice/video were not met.
-Install the necessary gstreamer and farsight packages first.
+Install the necessary gstreamer and farstream packages first.
 Or use --disable-vv if you do not need voice/video support.
 			])
 		fi
 	fi
 fi
-AM_CONDITIONAL(USE_VV, test "x$enable_gstreamer" != "xno" -a "x$enable_gstinterfaces" != "xno" -a "x$enable_farsight" != "xno")
+AM_CONDITIONAL(USE_VV, test "x$enable_gstreamer" != "xno" -a "x$enable_gstinterfaces" != "xno" -a "x$enable_farstream" != "xno")
 
 dnl #######################################################################
 dnl # Check for Internationalized Domain Name support
============================================================
--- libpurple/Makefile.am	98a11dd7e6b174ca919fa4734c900904af94e91b
+++ libpurple/Makefile.am	3d58790ace97b844146ebf7492a0ed705c209788
@@ -306,7 +306,7 @@ libpurple_la_LIBADD = \
 	$(LIBXML_LIBS) \
 	$(NETWORKMANAGER_LIBS) \
 	$(INTLLIBS) \
-	$(FARSIGHT_LIBS) \
+	$(FARSTREAM_LIBS) \
 	$(GSTREAMER_LIBS) \
 	$(GSTINTERFACES_LIBS) \
 	$(IDN_LIBS) \
@@ -322,7 +322,7 @@ AM_CPPFLAGS = \
 	$(DEBUG_CFLAGS) \
 	$(DBUS_CFLAGS) \
 	$(LIBXML_CFLAGS) \
-	$(FARSIGHT_CFLAGS) \
+	$(FARSTREAM_CFLAGS) \
 	$(GSTREAMER_CFLAGS) \
 	$(GSTINTERFACES_CFLAGS) \
 	$(IDN_CFLAGS) \
============================================================
--- libpurple/mediamanager.c	1e55c322fe59eb10d19628c4c44757ea404ba23b
+++ libpurple/mediamanager.c	0a57c7b39ee3f9a34bbb11a5722ecc7e3c70dbdd
@@ -39,7 +39,11 @@
 #ifdef USE_VV
 #include <media/backend-fs2.h>
 
+#ifdef HAVE_FARSIGHT
 #include <gst/farsight/fs-element-added-notifier.h>
+#else
+#include <farstream/fs-element-added-notifier.h>
+#endif
 #include <gst/interfaces/xoverlay.h>
 
 /** @copydoc _PurpleMediaManagerPrivate */
============================================================
--- libpurple/media/backend-fs2.c	7880795b2acf380bec5f8ef6227196cf64951896
+++ libpurple/media/backend-fs2.c	40cd232d21c4a803fd38727fb2bdf7420433418f
@@ -1,5 +1,5 @@
 /**
- * @file backend-fs2.c Farsight 2 backend for media API
+ * @file backend-fs2.c Farstream backend for media API
  * @ingroup core
  */
 
@@ -34,8 +34,14 @@
 #include "network.h"
 #include "media-gst.h"
 
+#ifdef HAVE_FARSIGHT
 #include <gst/farsight/fs-conference-iface.h>
 #include <gst/farsight/fs-element-added-notifier.h>
+#else
+#include <farstream/fs-conference.h>
+#include <farstream/fs-element-added-notifier.h>
+#include <farstream/fs-utils.h>
+#endif
 
 /** @copydoc _PurpleMediaBackendFs2Class */
 typedef struct _PurpleMediaBackendFs2Class PurpleMediaBackendFs2Class;
@@ -112,6 +118,10 @@ struct _PurpleMediaBackendFs2Stream
 	gchar *participant;
 	FsStream *stream;
 
+#ifndef HAVE_FARSIGHT
+	gboolean supports_add;
+#endif
+
 	GstElement *src;
 	GstElement *tee;
 	GstElement *volume;
@@ -147,6 +157,10 @@ struct _PurpleMediaBackendFs2Private
 	FsConference *conference;
 	gchar *conference_type;
 
+#ifndef HAVE_FARSIGHT
+	FsElementAddedNotifier *notifier;
+#endif
+
 	GHashTable *sessions;
 	GHashTable *participants;
 
@@ -212,6 +226,13 @@ purple_media_backend_fs2_dispose(GObject
 
 	purple_debug_info("backend-fs2", "purple_media_backend_fs2_dispose\n");
 
+#ifndef HAVE_FARSIGHT
+	if (priv->notifier) {
+		g_object_unref(priv->notifier);
+		priv->notifier = NULL;
+	}
+#endif
+
 	if (priv->confbin) {
 		GstElement *pipeline;
 
@@ -846,7 +867,11 @@ gst_handle_message_element(GstBus *bus, 
 			priv->conference != FS_CONFERENCE(src))
 		return;
 
+#ifdef HAVE_FARSIGHT
 	if (gst_structure_has_name(msg->structure, "farsight-error")) {
+#else
+	if (gst_structure_has_name(msg->structure, "farstream-error")) {
+#endif
 		FsError error_no;
 		gst_structure_get_enum(msg->structure, "error-no",
 				FS_TYPE_ERROR, (gint*)&error_no);
@@ -859,6 +884,7 @@ gst_handle_message_element(GstBus *bus, 
 						" packages."));
 				purple_media_end(priv->media, NULL, NULL);
 				break;
+#ifdef HAVE_FARSIGHT
 			case FS_ERROR_NO_CODECS_LEFT:
 				purple_media_error(priv->media, _("No codecs"
 						" left. Your codec"
@@ -874,9 +900,14 @@ gst_handle_message_element(GstBus *bus, 
 				 * It is also deprecated.
 				 */
 				break;
+#endif
 			default:
 				purple_debug_error("backend-fs2",
+#ifdef HAVE_FARSIGHT
 						"farsight-error: %i: %s\n",
+#else
+						"farstream-error: %i: %s\n",
+#endif
 						error_no,
 						gst_structure_get_string(
 						msg->structure, "error-msg"));
@@ -884,12 +915,21 @@ gst_handle_message_element(GstBus *bus, 
 		}
 
 		if (FS_ERROR_IS_FATAL(error_no)) {
+#ifdef HAVE_FARSIGHT
 			purple_media_error(priv->media, _("A non-recoverable "
 					"Farsight2 error has occurred."));
+#else
+			purple_media_error(priv->media, _("A non-recoverable "
+					"Farstream error has occurred."));
+#endif
 			purple_media_end(priv->media, NULL, NULL);
 		}
 	} else if (gst_structure_has_name(msg->structure,
+#ifdef HAVE_FARSIGHT
 			"farsight-new-local-candidate")) {
+#else
+			"farstream-new-local-candidate")) {
+#endif
 		const GValue *value;
 		FsStream *stream;
 		FsCandidate *local_candidate;
@@ -924,7 +964,11 @@ gst_handle_message_element(GstBus *bus, 
 				session->id, name, candidate);
 		g_object_unref(candidate);
 	} else if (gst_structure_has_name(msg->structure,
+#ifdef HAVE_FARSIGHT
 			"farsight-local-candidates-prepared")) {
+#else
+			"farstream-local-candidates-prepared")) {
+#endif
 		const GValue *value;
 		FsStream *stream;
 		FsParticipant *participant;
@@ -942,7 +986,11 @@ gst_handle_message_element(GstBus *bus, 
 		g_signal_emit_by_name(self, "candidates-prepared",
 				session->id, name);
 	} else if (gst_structure_has_name(msg->structure,
+#ifdef HAVE_FARSIGHT
 			"farsight-new-active-candidate-pair")) {
+#else
+			"farstream-new-active-candidate-pair")) {
+#endif
 		const GValue *value;
 		FsStream *stream;
 		FsCandidate *local_candidate;
@@ -976,7 +1024,11 @@ gst_handle_message_element(GstBus *bus, 
 		g_object_unref(lcandidate);
 		g_object_unref(rcandidate);
 	} else if (gst_structure_has_name(msg->structure,
+#ifdef HAVE_FARSIGHT
 			"farsight-recv-codecs-changed")) {
+#else
+			"farstream-recv-codecs-changed")) {
+#endif
 		const GValue *value;
 		GList *codecs;
 		FsCodec *codec;
@@ -986,10 +1038,18 @@ gst_handle_message_element(GstBus *bus, 
 		codec = codecs->data;
 
 		purple_debug_info("backend-fs2",
+#ifdef HAVE_FARSIGHT
 				"farsight-recv-codecs-changed: %s\n",
+#else
+				"farstream-recv-codecs-changed: %s\n",
+#endif
 				codec->encoding_name);
 	} else if (gst_structure_has_name(msg->structure,
+#ifdef HAVE_FARSIGHT
 			"farsight-component-state-changed")) {
+#else
+			"farstream-component-state-changed")) {
+#endif
 		const GValue *value;
 		FsStreamState fsstate;
 		guint component;
@@ -1025,11 +1085,19 @@ gst_handle_message_element(GstBus *bus, 
 		}
 
 		purple_debug_info("backend-fs2",
+#ifdef HAVE_FARSIGHT
 				"farsight-component-state-changed: "
+#else
+				"farstream-component-state-changed: "
+#endif
 				"component: %u state: %s\n",
 				component, state);
 	} else if (gst_structure_has_name(msg->structure,
+#ifdef HAVE_FARSIGHT
 			"farsight-send-codec-changed")) {
+#else
+			"farstream-send-codec-changed")) {
+#endif
 		const GValue *value;
 		FsCodec *codec;
 		gchar *codec_str;
@@ -1039,12 +1107,20 @@ gst_handle_message_element(GstBus *bus, 
 		codec_str = fs_codec_to_string(codec);
 
 		purple_debug_info("backend-fs2",
+#ifdef HAVE_FARSIGHT
 				"farsight-send-codec-changed: codec: %s\n",
+#else
+				"farstream-send-codec-changed: codec: %s\n",
+#endif
 				codec_str);
 
 		g_free(codec_str);
 	} else if (gst_structure_has_name(msg->structure,
+#ifdef HAVE_FARSIGHT
 			"farsight-codecs-changed")) {
+#else
+			"farstream-codecs-changed")) {
+#endif
 		const GValue *value;
 		FsSession *fssession;
 		GList *sessions;
@@ -1220,8 +1296,17 @@ stream_info_cb(PurpleMedia *media, Purpl
 				purple_media_is_initiator(media, sid, name))
 			return;
 
+#ifdef HAVE_FARSIGHT
 		fs_stream_set_remote_candidates(stream->stream,
 				stream->remote_candidates, &err);
+#else
+		if (stream->supports_add)
+			fs_stream_add_remote_candidates(stream->stream,
+					stream->remote_candidates, &err);
+		else
+			fs_stream_force_remote_candidates(stream->stream,
+					stream->remote_candidates, &err);
+#endif
 
 		if (err == NULL)
 			return;
@@ -1301,6 +1386,9 @@ init_conference(PurpleMediaBackendFs2 *s
 	GstElement *pipeline;
 	GstBus *bus;
 	gchar *name;
+#ifndef HAVE_FARSIGHT
+	GKeyFile *default_props;
+#endif
 
 	priv->conference = FS_CONFERENCE(
 			gst_element_factory_make(priv->conference_type, NULL));
@@ -1343,6 +1431,16 @@ init_conference(PurpleMediaBackendFs2 *s
 		return FALSE;
 	}
 
+#ifndef HAVE_FARSIGHT
+	default_props = fs_utils_get_default_element_properties(GST_ELEMENT(priv->conference));
+	if (default_props != NULL) {
+		priv->notifier = fs_element_added_notifier_new();
+		fs_element_added_notifier_add(priv->notifier,
+				GST_BIN(priv->confbin));
+		fs_element_added_notifier_set_properties_from_keyfile(priv->notifier, default_props);
+	}
+#endif
+
 	g_signal_connect(G_OBJECT(bus), "message",
 			G_CALLBACK(gst_bus_cb), self);
 	gst_object_unref(bus);
@@ -1559,7 +1657,11 @@ create_session(PurpleMediaBackendFs2 *se
 	 * receiving the src-pad-added signal.
 	 * Only works for non-multicast FsRtpSessions.
 	 */
+#ifdef HAVE_FARSIGHT
 	if (is_nice || !strcmp(transmitter, "rawudp"))
+#else
+	if (!!strcmp(transmitter, "multicast"))
+#endif
 		g_object_set(G_OBJECT(session->session),
 				"no-rtcp-timeout", 0, NULL);
 
@@ -1612,7 +1714,11 @@ create_participant(PurpleMediaBackendFs2
 	GError *err = NULL;
 
 	participant = fs_conference_new_participant(
+#ifdef HAVE_FARSIGHT
 			priv->conference, name, &err);
+#else
+			priv->conference, &err);
+#endif
 
 	if (err) {
 		purple_debug_error("backend-fs2",
@@ -1622,6 +1728,13 @@ create_participant(PurpleMediaBackendFs2
 		return FALSE;
 	}
 
+#ifndef HAVE_FARSIGHT
+	if (g_object_class_find_property(G_OBJECT_GET_CLASS(participant),
+			"cname")) {
+		g_object_set(participant, "cname", name, NULL);
+	}
+#endif
+
 	if (!priv->participants) {
 		purple_debug_info("backend-fs2",
 				"Creating hash table for participants\n");
@@ -1795,6 +1908,25 @@ create_stream(PurpleMediaBackendFs2 *sel
 		return FALSE;
 	}
 
+#ifndef HAVE_FARSIGHT
+	fsstream = fs_session_new_stream(session->session, participant,
+			initiator == TRUE ? type_direction :
+			(type_direction & FS_DIRECTION_RECV), &err);
+
+	if (fsstream == NULL) {
+		if (err) {
+			purple_debug_error("backend-fs2",
+					"Error creating stream: %s\n",
+					err && err->message ?
+					err->message : "NULL");
+			g_error_free(err);
+		} else
+			purple_debug_error("backend-fs2",
+					"Error creating stream\n");
+		return FALSE;
+	}
+#endif
+
 	for (i = 0 ; i < num_params ; i++) {
 		if (purple_strequal(params[i].name, "relay-info")) {
 			got_turn_from_prpl = TRUE;
@@ -1857,6 +1989,7 @@ create_stream(PurpleMediaBackendFs2 *sel
 		_num_params++;
 	}
 
+#ifdef HAVE_FARSIGHT
 	fsstream = fs_session_new_stream(session->session, participant,
 			initiator == TRUE ? type_direction :
 			(type_direction & FS_DIRECTION_RECV), transmitter,
@@ -1875,11 +2008,26 @@ create_stream(PurpleMediaBackendFs2 *sel
 					"Error creating stream\n");
 		return FALSE;
 	}
+#else
+	if (!fs_stream_set_transmitter(fsstream, transmitter,
+			_params, _num_params, &err)) {
+		purple_debug_error("backend-fs2",
+				"Could not set transmitter %s: %s.\n",
+				transmitter, err->message);
+		g_clear_error(&err);
+		g_free(_params);
+		return FALSE;
+	}
+	g_free(_params);
+#endif
 
 	stream = g_new0(PurpleMediaBackendFs2Stream, 1);
 	stream->participant = g_strdup(who);
 	stream->session = session;
 	stream->stream = fsstream;
+#ifndef HAVE_FARSTREAM
+	stream->supports_add = !strcmp(transmitter, "nice");
+#endif
 
 	priv->streams =	g_list_append(priv->streams, stream);
 
@@ -1992,8 +2140,17 @@ purple_media_backend_fs2_add_remote_cand
 	if (purple_media_is_initiator(priv->media, sess_id, participant) ||
 			purple_media_accepted(
 			priv->media, sess_id, participant)) {
+#ifdef HAVE_FARSIGHT
 		fs_stream_set_remote_candidates(stream->stream,
 				stream->remote_candidates, &err);
+#else
+		if (stream->supports_add)
+			fs_stream_add_remote_candidates(stream->stream,
+					stream->remote_candidates, &err);
+		else
+			fs_stream_force_remote_candidates(stream->stream,
+					stream->remote_candidates, &err);
+#endif
 
 		if (err) {
 			purple_debug_error("backend-fs2", "Error adding remote"
@@ -2023,8 +2180,19 @@ purple_media_backend_fs2_codecs_ready(Pu
 
 		if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
 				PURPLE_MEDIA_SEND_VIDEO)) {
+#ifdef HAVE_FARSIGHT
 			g_object_get(session->session,
-					"codecs-ready", &ret, NULL);
+					"codecs-ready", &ret, NULL);	
+#else
+			GList *codecs = NULL;
+
+			g_object_get(session->session,
+					"codecs", &codecs, NULL);
+			if (codecs) {
+				fs_codec_list_destroy (codecs);
+				ret = TRUE;
+			}
+#endif
 		} else
 			ret = TRUE;
 	} else {
@@ -2032,12 +2200,27 @@ purple_media_backend_fs2_codecs_ready(Pu
 
 		for (; values; values = g_list_delete_link(values, values)) {
 			PurpleMediaBackendFs2Session *session = values->data;
+
 			if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
 					PURPLE_MEDIA_SEND_VIDEO)) {
+#ifdef HAVE_FARSIGHT
 				g_object_get(session->session,
 						"codecs-ready", &ret, NULL);
 				if (ret == FALSE)
 					break;
+#else
+				GList *codecs = NULL;
+
+				g_object_get(session->session,
+						"codecs", &codecs, NULL);
+				if (codecs) {
+					fs_codec_list_destroy (codecs);
+					ret = TRUE;
+				} else {
+					ret = FALSE;
+					break;
+				}
+#endif
 			} else
 				ret = TRUE;
 		}


More information about the Commits mailing list