cpw.maiku.media_refactor: 7a6e1202: Move Farsight 2's local-candidates-prepa...

maiku at pidgin.im maiku at pidgin.im
Mon Oct 26 22:46:08 EDT 2009


-----------------------------------------------------------------
Revision: 7a6e120231085c2fe7aaea3cb60f9587618b138c
Ancestor: 6fbf0527701d00a524bd5c9073e98ed18161d5be
Author: maiku at pidgin.im
Date: 2009-10-26T18:02:06
Branch: im.pidgin.cpw.maiku.media_refactor
URL: http://d.pidgin.im/viewmtn/revision/info/7a6e120231085c2fe7aaea3cb60f9587618b138c

Modified files:
        libpurple/media/backend-fs2.c libpurple/media/media.c

ChangeLog: 

Move Farsight 2's local-candidates-prepared signal to the Fs2 media backend.

-------------- next part --------------
============================================================
--- libpurple/media/backend-fs2.c	799fb53dac7d35fc660412b8b8144a560ac5db8f
+++ libpurple/media/backend-fs2.c	a509a884a78b939763cd8413c1422e0c0643eeb3
@@ -558,16 +558,20 @@ _gst_handle_message_element(GstBus *bus,
 			"farsight-local-candidates-prepared")) {
 		const GValue *value;
 		FsStream *stream;
-#if 0
-		PurpleMediaSession *session;
-#endif
+		FsParticipant *participant;
+		PurpleMediaBackendFs2Session *session;
+		gchar *name;
 
 		value = gst_structure_get_value(msg->structure, "stream");
 		stream = g_value_get_object(value);
-#if 0
-		session = purple_media_session_from_fs_stream(media, stream);
-		_candidates_prepared_cb(stream, session);
-#endif
+		session = _get_session_from_fs_stream(self, stream);
+
+		g_object_get(stream, "participant", &participant, NULL);
+		g_object_get(participant, "cname", &name, NULL);
+		g_object_unref(participant);
+
+		g_signal_emit_by_name(self, "candidates-prepared",
+				session->id, name);
 	} else if (gst_structure_has_name(msg->structure,
 			"farsight-new-active-candidate-pair")) {
 		const GValue *value;
============================================================
--- libpurple/media/media.c	4e602cd9410f6a1839aefbce1357602a791064e9
+++ libpurple/media/media.c	dea81b92cb1c4d24f4e4f98a70d3744e47452c66
@@ -141,8 +141,8 @@ static void purple_media_new_local_candi
 static void purple_media_new_local_candidate_cb(PurpleMediaBackend *backend,
 		const gchar *sess_id, const gchar *participant,
 		PurpleMediaCandidate *candidate, PurpleMedia *media);
-static void purple_media_candidates_prepared_cb(FsStream *stream,
-		PurpleMediaSession *session);
+static void purple_media_candidates_prepared_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *name, PurpleMedia *media);
 static void purple_media_candidate_pair_established_cb(
 		PurpleMediaBackend *backend,
 		const gchar *sess_id, const gchar *name,
@@ -450,6 +450,11 @@ purple_media_set_property (GObject *obje
 					purple_media_candidate_pair_established_cb),
 					media);
 			g_signal_connect(media->priv->backend,
+					"candidates-prepared",
+					G_CALLBACK(
+					purple_media_candidates_prepared_cb),
+					media);
+			g_signal_connect(media->priv->backend,
 					"codecs-changed",
 					G_CALLBACK(
 					purple_media_codecs_changed_cb),
@@ -988,33 +993,6 @@ purple_media_get_src(PurpleMedia *media,
 #endif /* USE_GSTREAMER */
 
 #ifdef USE_VV
-static PurpleMediaSession *
-purple_media_session_from_fs_stream(PurpleMedia *media, FsStream *stream)
-{
-	FsSession *fssession;
-	GList *values;
-
-	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-	g_return_val_if_fail(FS_IS_STREAM(stream), NULL);
-
-	g_object_get(stream, "session", &fssession, NULL);
-
-	values = g_hash_table_get_values(media->priv->sessions);
-
-	for (; values; values = g_list_delete_link(values, values)) {
-		PurpleMediaSession *session = values->data;
-
-		if (session->session == fssession) {
-			g_list_free(values);
-			g_object_unref(fssession);
-			return session;
-		}
-	}
-
-	g_object_unref(fssession);
-	return NULL;
-}
-
 static gboolean
 media_bus_call(GstBus *bus, GstMessage *msg, PurpleMedia *media)
 {
@@ -1069,18 +1047,6 @@ media_bus_call(GstBus *bus, GstMessage *
 						0, session->id, participant, percent);
 				break;
 			}
-			if (!FS_IS_CONFERENCE(GST_MESSAGE_SRC(msg)) ||
-					!PURPLE_IS_MEDIA(media) ||
-					media->priv->conference !=
-					FS_CONFERENCE(GST_MESSAGE_SRC(msg)))
-				break;
-
-			if (gst_structure_has_name(msg->structure,
-					"farsight-local-candidates-prepared")) {
-				FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
-				PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
-				purple_media_candidates_prepared_cb(stream, session);
-			}
 			break;
 		}
 		default:
@@ -1272,27 +1238,18 @@ static void
 }
 
 static void
-purple_media_candidates_prepared_cb(FsStream *stream, PurpleMediaSession *session)
+purple_media_candidates_prepared_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *name, PurpleMedia *media)
 {
-	gchar *name;
-	FsParticipant *participant;
 	PurpleMediaStream *stream_data;
 
-	g_return_if_fail(FS_IS_STREAM(stream));
-	g_return_if_fail(session != NULL);
+	g_return_if_fail(PURPLE_IS_MEDIA(media));
 
-	g_object_get(stream, "participant", &participant, NULL);
-	g_object_get(participant, "cname", &name, NULL);
-	g_object_unref(participant);
-
-	stream_data = purple_media_get_stream(session->media, session->id, name);
+	stream_data = purple_media_get_stream(media, sess_id, name);
 	stream_data->candidates_prepared = TRUE;
 
-	g_signal_emit(session->media,
-			purple_media_signals[CANDIDATES_PREPARED],
-			0, session->id, name);
-
-	g_free(name);
+	g_signal_emit(media, purple_media_signals[CANDIDATES_PREPARED],
+			0, sess_id, name);
 }
 
 /* callback called when a pair of transport candidates (local and remote)


More information about the Commits mailing list