# HG changeset patch # User olivier.crete@collabora.com # Date 1333595920 0 # Node ID fd1b4bbefc6b8513cd86fd64bdb7076cba5980de # Parent 60bd913072f7e07fa04a998b003635a5f2c1cb2e 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. committer: Richard Laager diff -r 60bd913072f7 -r fd1b4bbefc6b configure.ac --- a/configure.ac Wed Apr 04 22:54:48 2012 +0000 +++ b/configure.ac Thu Apr 05 03:18:40 2012 +0000 @@ -786,20 +786,26 @@ 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 @@ [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 diff -r 60bd913072f7 -r fd1b4bbefc6b libpurple/Makefile.am --- a/libpurple/Makefile.am Wed Apr 04 22:54:48 2012 +0000 +++ b/libpurple/Makefile.am Thu Apr 05 03:18:40 2012 +0000 @@ -306,7 +306,7 @@ $(LIBXML_LIBS) \ $(NETWORKMANAGER_LIBS) \ $(INTLLIBS) \ - $(FARSIGHT_LIBS) \ + $(FARSTREAM_LIBS) \ $(GSTREAMER_LIBS) \ $(GSTINTERFACES_LIBS) \ $(IDN_LIBS) \ @@ -322,7 +322,7 @@ $(DEBUG_CFLAGS) \ $(DBUS_CFLAGS) \ $(LIBXML_CFLAGS) \ - $(FARSIGHT_CFLAGS) \ + $(FARSTREAM_CFLAGS) \ $(GSTREAMER_CFLAGS) \ $(GSTINTERFACES_CFLAGS) \ $(IDN_CFLAGS) \ diff -r 60bd913072f7 -r fd1b4bbefc6b libpurple/media/backend-fs2.c --- a/libpurple/media/backend-fs2.c Wed Apr 04 22:54:48 2012 +0000 +++ b/libpurple/media/backend-fs2.c Thu Apr 05 03:18:40 2012 +0000 @@ -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 #include +#else +#include +#include +#include +#endif /** @copydoc _PurpleMediaBackendFs2Class */ typedef struct _PurpleMediaBackendFs2Class PurpleMediaBackendFs2Class; @@ -112,6 +118,10 @@ gchar *participant; FsStream *stream; +#ifndef HAVE_FARSIGHT + gboolean supports_add; +#endif + GstElement *src; GstElement *tee; GstElement *volume; @@ -147,6 +157,10 @@ FsConference *conference; gchar *conference_type; +#ifndef HAVE_FARSIGHT + FsElementAddedNotifier *notifier; +#endif + GHashTable *sessions; GHashTable *participants; @@ -212,6 +226,13 @@ 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 @@ 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 @@ " 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 @@ * 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ _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 @@ "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 @@ 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 @@ 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 @@ 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; } diff -r 60bd913072f7 -r fd1b4bbefc6b libpurple/mediamanager.c --- a/libpurple/mediamanager.c Wed Apr 04 22:54:48 2012 +0000 +++ b/libpurple/mediamanager.c Thu Apr 05 03:18:40 2012 +0000 @@ -39,7 +39,11 @@ #ifdef USE_VV #include +#ifdef HAVE_FARSIGHT #include +#else +#include +#endif #include /** @copydoc _PurpleMediaManagerPrivate */