changeset 26391:b7b0513604e6

Make acceptance be per stream rather than per session.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 19 Mar 2009 22:08:21 +0000
parents f34fd86de085
children 17929a84c1fb
files libpurple/media.c
diffstat 1 files changed, 46 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Thu Mar 19 21:38:16 2009 +0000
+++ b/libpurple/media.c	Thu Mar 19 22:08:21 2009 +0000
@@ -57,7 +57,6 @@
 	PurpleMediaSessionType type;
 
 	gboolean codecs_ready;
-	gboolean accepted;
 
 	GstElement *sink;
 	gulong window_id;
@@ -75,6 +74,7 @@
 	GList *local_candidates;
 	GList *remote_candidates;
 
+	gboolean accepted;
 	gboolean candidates_prepared;
 
 	GList *active_local_candidates;
@@ -1236,7 +1236,7 @@
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
 
 	if ((session != NULL) && ((media->priv->initiator == FALSE &&
-			session->accepted == FALSE) ||
+			purple_media_accepted(media, session->id, NULL) == FALSE) ||
 			(purple_media_codecs_ready(media, session->id) == FALSE)))
 		return;
 
@@ -1249,7 +1249,8 @@
 		gboolean session_ready = TRUE;
 
 		if ((media->priv->initiator == FALSE &&
-				session_data->accepted == FALSE) ||
+				purple_media_accepted(media,
+				session->id, NULL) == FALSE) ||
 				(purple_media_codecs_ready(
 				media, session_data->id) == FALSE))
 			conf_ready = FALSE;
@@ -1449,16 +1450,6 @@
 
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
 
-	sessions = g_hash_table_get_values(media->priv->sessions);
-
-	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-		PurpleMediaSession *session = sessions->data;
-		session->accepted = TRUE;
-
-		if (media->priv->initiator == FALSE)
-			purple_media_emit_ready(media, session, NULL);
-	}
-
 	g_signal_emit(media, purple_media_signals[ACCEPTED],
 			0, NULL, NULL);
 	streams = media->priv->streams;
@@ -1468,7 +1459,18 @@
 		g_object_set(G_OBJECT(stream->stream), "direction",
 				purple_media_to_fs_stream_direction(
 				stream->session->type), NULL);
+		stream->accepted = TRUE;
 	}
+
+	sessions = g_hash_table_get_values(media->priv->sessions);
+
+	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
+		PurpleMediaSession *session = sessions->data;
+
+		if (media->priv->initiator == FALSE)
+			purple_media_emit_ready(media, session, NULL);
+	}
+
 }
 
 void
@@ -2321,16 +2323,40 @@
 purple_media_accepted(PurpleMedia *media, const gchar *sess_id,
 		const gchar *participant)
 {
-	PurpleMediaSession *session;
+	gboolean accepted = TRUE;
 
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 
-	session = purple_media_get_session(media, sess_id);
-
-	if (session == NULL)
-		return FALSE;
-
-	return session->accepted;
+	if (sess_id == NULL && participant == NULL) {
+		GList *streams = media->priv->streams;
+
+		for (; streams; streams = g_list_next(streams)) {
+			PurpleMediaStream *stream = streams->data;
+			if (stream->accepted == FALSE) {
+				accepted = FALSE;
+				break;
+			}
+		}
+	} else if (sess_id != NULL && participant == NULL) {
+		GList *streams = purple_media_get_streams(
+				media, sess_id, NULL);
+		for (; streams; streams =
+				g_list_delete_link(streams, streams)) {
+			PurpleMediaStream *stream = streams->data;
+			if (stream->accepted == FALSE) {
+				g_list_free(streams);
+				accepted = FALSE;
+				break;
+			}
+		}
+	} else if (sess_id != NULL && participant != NULL) {
+		PurpleMediaStream *stream = purple_media_get_stream(
+				media, sess_id, participant);
+		if (stream == NULL || stream->accepted == FALSE)
+			accepted = FALSE;
+	}
+
+	return accepted;
 }
 
 void purple_media_mute(PurpleMedia *media, gboolean active)