changeset 29581:f351e87b7af0

Add codecs_ready to the media backend interface.
author maiku@pidgin.im
date Tue, 27 Oct 2009 19:06:29 +0000
parents 7e9d8840e97f
children 209fa20fc39f
files libpurple/media/backend-fs2.c libpurple/media/backend-iface.c libpurple/media/backend-iface.h libpurple/media/media.c
diffstat 4 files changed, 64 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media/backend-fs2.c	Tue Oct 27 18:42:01 2009 +0000
+++ b/libpurple/media/backend-fs2.c	Tue Oct 27 19:06:29 2009 +0000
@@ -70,6 +70,8 @@
 		PurpleMediaBackend *self,
 		const gchar *sess_id, const gchar *participant,
 		GList *remote_candidates);
+static gboolean purple_media_backend_fs2_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id);
 static GList *purple_media_backend_fs2_get_codecs(PurpleMediaBackend *self,
 		const gchar *sess_id);
 static GList *purple_media_backend_fs2_get_local_candidates(
@@ -366,6 +368,7 @@
 	iface->add_stream = purple_media_backend_fs2_add_stream;
 	iface->add_remote_candidates =
 			purple_media_backend_fs2_add_remote_candidates;
+	iface->codecs_ready = purple_media_backend_fs2_codecs_ready;
 	iface->get_codecs = purple_media_backend_fs2_get_codecs;
 	iface->get_local_candidates =
 			purple_media_backend_fs2_get_local_candidates;
@@ -1500,6 +1503,53 @@
 	}
 }
 
+static gboolean
+purple_media_backend_fs2_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id)
+{
+	PurpleMediaBackendFs2Private *priv;
+	gboolean ret;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), FALSE);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	if (sess_id != NULL) {
+		PurpleMediaBackendFs2Session *session = _get_session(
+				PURPLE_MEDIA_BACKEND_FS2(self), sess_id);
+
+		if (session == NULL)
+			return FALSE;
+
+		if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
+				PURPLE_MEDIA_SEND_VIDEO))
+			g_object_get(session->session,
+					"codecs-ready", &ret, NULL);
+		else
+			ret = TRUE;
+	} else {
+		GList *values = g_hash_table_get_values(priv->sessions);
+
+		for (; values; values = g_list_delete_link(values, values)) {
+			PurpleMediaBackendFs2Session *session = values->data;
+			if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
+					PURPLE_MEDIA_SEND_VIDEO))
+				g_object_get(session->session,
+						"codecs-ready", &ret, NULL);
+			else
+				ret = TRUE;
+
+			if (ret == FALSE)
+				break;
+		}
+
+		if (values != NULL)
+			g_list_free(values);
+	}
+
+	return ret;
+}
+
 static GList *
 purple_media_backend_fs2_get_codecs(PurpleMediaBackend *self,
 		const gchar *sess_id)
--- a/libpurple/media/backend-iface.c	Tue Oct 27 18:42:01 2009 +0000
+++ b/libpurple/media/backend-iface.c	Tue Oct 27 19:06:29 2009 +0000
@@ -146,6 +146,14 @@
 			sess_id, participant, remote_candidates);
 }
 
+gboolean
+purple_media_backend_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->codecs_ready(self,
+			sess_id);
+}
 
 GList *
 purple_media_backend_get_codecs(PurpleMediaBackend *self,
--- a/libpurple/media/backend-iface.h	Tue Oct 27 18:42:01 2009 +0000
+++ b/libpurple/media/backend-iface.h	Tue Oct 27 19:06:29 2009 +0000
@@ -54,6 +54,8 @@
 	void (*add_remote_candidates) (PurpleMediaBackend *self,
 		const gchar *sess_id, const gchar *participant,
 		GList *remote_candidates);
+	gboolean (*codecs_ready) (PurpleMediaBackend *self,
+		const gchar *sess_id);
 	GList *(*get_codecs) (PurpleMediaBackend *self,
 		const gchar *sess_id);
 	GList *(*get_local_candidates) (PurpleMediaBackend *self,
@@ -75,6 +77,8 @@
 void purple_media_backend_add_remote_candidates(PurpleMediaBackend *self,
 		const gchar *sess_id, const gchar *participant,
 		GList *remote_candidates);
+gboolean purple_media_backend_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id);
 GList *purple_media_backend_get_codecs(PurpleMediaBackend *self,
 		const gchar *sess_id);
 GList *purple_media_backend_get_local_candidates(PurpleMediaBackend *self,
--- a/libpurple/media/media.c	Tue Oct 27 18:42:01 2009 +0000
+++ b/libpurple/media/media.c	Tue Oct 27 19:06:29 2009 +0000
@@ -1425,40 +1425,10 @@
 purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id)
 {
 #ifdef USE_VV
-	gboolean ret;
-
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 
-	if (sess_id != NULL) {
-		PurpleMediaSession *session;
-		session = purple_media_get_session(media, sess_id);
-
-		if (session == NULL)
-			return FALSE;
-		if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
-				PURPLE_MEDIA_SEND_VIDEO))
-			g_object_get(session->session,
-					"codecs-ready", &ret, NULL);
-		else
-			ret = TRUE;
-	} else {
-		GList *values = g_hash_table_get_values(media->priv->sessions);
-		for (; values; values = g_list_delete_link(values, values)) {
-			PurpleMediaSession *session = values->data;
-			if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
-					PURPLE_MEDIA_SEND_VIDEO))
-				g_object_get(session->session,
-						"codecs-ready", &ret, NULL);
-			else
-				ret = TRUE;
-
-			if (ret == FALSE)
-				break;
-		}
-		if (values != NULL)
-			g_list_free(values);
-	}
-	return ret;
+	return purple_media_backend_codecs_ready(
+			media->priv->backend, sess_id);
 #else
 	return FALSE;
 #endif