pidgin.vv: 9b9ba130: Added PurpleMediaStream to wrap FsStream...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sun Nov 16 01:00:59 EST 2008


-----------------------------------------------------------------
Revision: 9b9ba130757dcdc481a8a80c74480f356d3ba398
Ancestor: b0fb48968be0b7920578304ff5b1c43be26c9b17
Author: maiku at soc.pidgin.im
Date: 2008-11-16T04:23:36
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/9b9ba130757dcdc481a8a80c74480f356d3ba398

Modified files:
        libpurple/media.c libpurple/media.h

ChangeLog: 

Added PurpleMediaStream to wrap FsStream.

-------------- next part --------------
============================================================
--- libpurple/media.c	5f80c23145ceafaab4c05c9a06350ff1a615b884
+++ libpurple/media.c	f5d34ce824b30a03ef988eddaa6cfe26e5aa0b44
@@ -40,6 +40,11 @@
 #include <gst/interfaces/propertyprobe.h>
 #include <gst/farsight/fs-conference-iface.h>
 
+/** @copydoc _PurpleMediaSession */
+typedef struct _PurpleMediaSession PurpleMediaSession;
+/** @copydoc _PurpleMediaStream */
+typedef struct _PurpleMediaStream PurpleMediaStream;
+
 struct _PurpleMediaSession
 {
 	gchar *id;
@@ -47,8 +52,7 @@ struct _PurpleMediaSession
 	GstElement *src;
 	GstElement *sink;
 	FsSession *session;
-	/* FsStream table. Mapped by participant's name */
-	GHashTable *streams;
+
 	PurpleMediaSessionType type;
 	/* GList of FsCandidates table. Mapped by participant's name */
 	GHashTable *local_candidates;
@@ -61,6 +65,20 @@ struct _PurpleMediaSession
 	FsCandidate *remote_candidate;
 };
 
+struct _PurpleMediaStream
+{
+	PurpleMediaSession *session;
+	gchar *participant;
+	FsStream *stream;
+
+	GList *local_candidates;
+
+	gboolean candidates_prepared;
+
+	FsCandidate *local_candidate;
+	FsCandidate *remote_candidate;
+};
+
 struct _PurpleMediaPrivate
 {
 	FsConference *conference;
@@ -71,7 +89,10 @@ struct _PurpleMediaPrivate
 	GHashTable *sessions;	/* PurpleMediaSession table */
 	GHashTable *participants; /* FsParticipant table */
 
+	GList *streams;		/* PurpleMediaStream table */
+
 	GstElement *pipeline;
+	
 };
 
 #define PURPLE_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA, PurpleMediaPrivate))
@@ -233,6 +254,44 @@ static void
 }
 
 static void
+purple_media_stream_free(PurpleMediaStream *stream)
+{
+	g_free(stream->participant);
+	g_object_unref(stream->stream);
+
+	if (stream->local_candidates)
+		fs_candidate_list_destroy(stream->local_candidates);
+
+	if (stream->local_candidate)
+		fs_candidate_destroy(stream->local_candidate);
+	if (stream->remote_candidate)
+		fs_candidate_destroy(stream->remote_candidate);
+
+	g_free(stream);
+}
+
+static void
+purple_media_session_free(PurpleMediaSession *session)
+{
+	g_free(session->id);
+
+	if (session->local_candidates) {
+		GList *candidates = g_hash_table_get_values(session->local_candidates);
+		for (; candidates; candidates =
+				g_list_delete_link(candidates, candidates))
+			fs_candidate_list_destroy(candidates->data);
+		g_hash_table_destroy(session->local_candidates);
+	}
+
+	if (session->local_candidate)
+		fs_candidate_destroy(session->local_candidate);
+	if (session->remote_candidate)
+		fs_candidate_destroy(session->remote_candidate);
+
+	g_free(session);
+}
+
+static void
 purple_media_finalize (GObject *media)
 {
 	PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
@@ -246,34 +305,14 @@ purple_media_finalize (GObject *media)
 	if (priv->sessions) {
 		GList *sessions = g_hash_table_get_values(priv->sessions);
 		for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-			PurpleMediaSession *session = sessions->data;
-			g_free(session->id);
-
-			if (session->streams) {
-				GList *streams = g_hash_table_get_values(session->streams);
-				for (; streams; streams = g_list_delete_link(streams, streams))
-					g_object_unref(streams->data);
-				g_hash_table_destroy(session->streams);
-			}
-
-			if (session->local_candidates) {
-				GList *candidates = g_hash_table_get_values(session->local_candidates);
-				for (; candidates; candidates =
-						g_list_delete_link(candidates, candidates))
-					fs_candidate_list_destroy(candidates->data);
-				g_hash_table_destroy(session->local_candidates);
-			}
-
-			if (session->local_candidate)
-				fs_candidate_destroy(session->local_candidate);
-			if (session->remote_candidate)
-				fs_candidate_destroy(session->remote_candidate);
-
-			g_free(session);
+			purple_media_session_free(sessions->data);
 		}
 		g_hash_table_destroy(priv->sessions);
 	}
 
+	for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams))
+		purple_media_stream_free(priv->streams->data);
+
 	if (priv->participants) {
 		GList *participants = g_hash_table_get_values(priv->participants);
 		for (; participants; participants = g_list_delete_link(participants, participants))
@@ -423,8 +462,16 @@ purple_media_session_get_stream(PurpleMe
 static FsStream*
 purple_media_session_get_stream(PurpleMediaSession *session, const gchar *name)
 {
-	return (FsStream*) (session->streams) ?
-			g_hash_table_lookup(session->streams, name) : NULL;
+	GList *streams = session->media->priv->streams;
+
+	for (; streams; streams = g_list_next(streams)) {
+		PurpleMediaStream *stream = streams->data;
+		if (session == stream->session &&
+				!strcmp(stream->participant, name))
+			return stream->stream;
+	}
+
+	return NULL;
 }
 
 static GList*
@@ -483,13 +530,13 @@ purple_media_insert_stream(PurpleMediaSe
 static void
 purple_media_insert_stream(PurpleMediaSession *session, const gchar *name, FsStream *stream)
 {
-	if (!session->streams) {
-		purple_debug_info("media", "Creating hash table for streams\n");
-		session->streams = g_hash_table_new_full(g_str_hash,
-				g_str_equal, g_free, NULL);
-	}
+	PurpleMediaStream *media_stream = g_new0(PurpleMediaStream, 1);
+	media_stream->stream = stream;
+	media_stream->participant = g_strdup(name);
+	media_stream->session = session;
 
-	g_hash_table_insert(session->streams, g_strdup(name), stream);
+	session->media->priv->streams =
+			g_list_append(session->media->priv->streams, media_stream);
 }
 
 static void
============================================================
--- libpurple/media.h	b154067811eda005edd16e70fa4d817577163d4c
+++ libpurple/media.h	89d5851603ab4310df24b766affde0545c7d0209
@@ -51,8 +51,6 @@ typedef struct _PurpleMediaPrivate Purpl
 typedef struct _PurpleMediaClass PurpleMediaClass;
 /** @copydoc _PurpleMediaPrivate */
 typedef struct _PurpleMediaPrivate PurpleMediaPrivate;
-/** @copydoc _PurpleMediaSession */
-typedef struct _PurpleMediaSession PurpleMediaSession;
 
 #else
 


More information about the Commits mailing list