pidgin.vv: b85997cb: Move sink from PurpleMediaSession to Pur...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sat Dec 13 05:40:56 EST 2008


-----------------------------------------------------------------
Revision: b85997cb3793c7e2d7f301604f6a80b3ce00b3de
Ancestor: df21a0203c74d88008c39face4d2ddfc84a03dc8
Author: maiku at soc.pidgin.im
Date: 2008-12-13T09:11:08
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/b85997cb3793c7e2d7f301604f6a80b3ce00b3de

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

ChangeLog: 

Move sink from PurpleMediaSession to PurpleMediaStream.

-------------- next part --------------
============================================================
--- finch/gntmedia.c	7326d7dad2e32cb83cb1387b36ba7bcb7977720a
+++ finch/gntmedia.c	905f7de8b4e5f9df3124f2118bcc8879811fc799
@@ -178,21 +178,17 @@ finch_media_ready_cb(PurpleMedia *media,
 finch_media_ready_cb(PurpleMedia *media, FinchMedia *gntmedia)
 {
 	GstElement *sendbin, *sendlevel;
-	GstElement *recvbin, *recvlevel;
 
 	GList *sessions = purple_media_get_session_names(media);
 
 	purple_media_audio_init_src(&sendbin, &sendlevel);
-	purple_media_audio_init_recv(&recvbin, &recvlevel);
 
 	for (; sessions; sessions = sessions->next) {
 		purple_media_set_src(media, sessions->data, sendbin);
-		purple_media_set_sink(media, sessions->data, recvbin);
 	}
 	g_list_free(sessions);
 
 	g_object_set(gntmedia, "send-level", sendlevel,
-		     "recv-level", recvlevel,
 		     NULL);
 }
 
============================================================
--- libpurple/media.c	853a3546570fd420033a0adccda83e6429913487
+++ libpurple/media.c	196649e6ba58f5a7a4d4cb4db4e6a4a18ad2b25c
@@ -50,7 +50,6 @@ struct _PurpleMediaSession
 	gchar *id;
 	PurpleMedia *media;
 	GstElement *src;
-	GstElement *sink;
 	FsSession *session;
 
 	PurpleMediaSessionType type;
@@ -61,6 +60,7 @@ struct _PurpleMediaStream
 	PurpleMediaSession *session;
 	gchar *participant;
 	FsStream *stream;
+	GstElement *sink;
 
 	GList *local_candidates;
 
@@ -516,7 +516,7 @@ purple_media_add_participant(PurpleMedia
 	return participant;
 }
 
-static void
+static PurpleMediaStream *
 purple_media_insert_stream(PurpleMediaSession *session, const gchar *name, FsStream *stream)
 {
 	PurpleMediaStream *media_stream = g_new0(PurpleMediaStream, 1);
@@ -526,6 +526,8 @@ purple_media_insert_stream(PurpleMediaSe
 
 	session->media->priv->streams =
 			g_list_append(session->media->priv->streams, media_stream);
+
+	return media_stream;
 }
 
 static void
@@ -553,13 +555,19 @@ purple_media_get_elements(PurpleMedia *m
 
 		if (session->type & PURPLE_MEDIA_SEND_AUDIO && audio_src)
 			*audio_src = session->src;
-		if (session->type & PURPLE_MEDIA_RECV_AUDIO && audio_sink)
-			*audio_sink = session->sink;
 		if (session->type & PURPLE_MEDIA_SEND_VIDEO && video_src)
 			*video_src = session->src;
-		if (session->type & PURPLE_MEDIA_RECV_VIDEO && video_sink)
-			*video_sink = session->sink;
 	}
+
+	values = media->priv->streams;
+	for (; values; values = g_list_next(values)) {
+		PurpleMediaStream *stream = (PurpleMediaStream*)values->data;
+
+		if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO && audio_sink)
+			*audio_sink = stream->sink;
+		if (stream->session->type & PURPLE_MEDIA_RECV_VIDEO && video_sink)
+			*video_sink = stream->sink;
+	}
 }
 
 void 
@@ -583,14 +591,17 @@ void 
 }
 
 void 
-purple_media_set_sink(PurpleMedia *media, const gchar *sess_id, GstElement *sink)
+purple_media_set_sink(PurpleMedia *media, const gchar *sess_id,
+		const gchar *participant, GstElement *sink)
 {
-	PurpleMediaSession *session = purple_media_get_session(media, sess_id);
-	if (session->sink)
-		gst_object_unref(session->sink);
-	session->sink = sink;
+	PurpleMediaStream *stream =
+			purple_media_get_stream(media, sess_id, participant);
+
+	if (stream->sink)
+		gst_object_unref(stream->sink);
+	stream->sink = sink;
 	gst_bin_add(GST_BIN(purple_media_get_pipeline(media)),
-		    session->sink);
+		    stream->sink);
 }
 
 GstElement *
@@ -600,9 +611,9 @@ GstElement *
 }
 
 GstElement *
-purple_media_get_sink(PurpleMedia *media, const gchar *sess_id)
+purple_media_get_sink(PurpleMedia *media, const gchar *sess_id, const gchar *participant)
 {
-	return purple_media_get_session(media, sess_id)->sink;
+	return purple_media_get_stream(media, sess_id, participant)->sink;
 }
 
 static PurpleMediaSession *
@@ -1067,19 +1078,21 @@ static void
 }
 
 static void
-purple_media_src_pad_added_cb(FsStream *stream, GstPad *srcpad,
-			      FsCodec *codec, PurpleMediaSession *session)
+purple_media_src_pad_added_cb(FsStream *fsstream, GstPad *srcpad,
+			      FsCodec *codec, PurpleMediaStream *stream)
 {
 	PurpleMediaSessionType type = purple_media_from_fs(codec->media_type, FS_DIRECTION_RECV);
 	GstPad *sinkpad = NULL;
-	session->sink = purple_media_manager_get_element(purple_media_manager_get(), type);
 
-	gst_bin_add(GST_BIN(purple_media_get_pipeline(session->media)),
-		    session->sink);
-	sinkpad = gst_element_get_static_pad(session->sink, "ghostsink");
+	stream->sink = purple_media_manager_get_element(
+			purple_media_manager_get(), type);
+
+	gst_bin_add(GST_BIN(purple_media_get_pipeline(stream->session->media)),
+		    stream->sink);
+	sinkpad = gst_element_get_static_pad(stream->sink, "ghostsink");
 	purple_debug_info("media", "connecting new src pad: %s\n", 
 			  gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK ? "success" : "failure");
-	gst_element_set_state(session->sink, GST_STATE_PLAYING);
+	gst_element_set_state(stream->sink, GST_STATE_PLAYING);
 }
 
 static gchar *
@@ -1224,11 +1237,11 @@ purple_media_add_stream_internal(PurpleM
 			return FALSE;
 		}
 
-		purple_media_insert_stream(session, who, fsstream);
+		stream = purple_media_insert_stream(session, who, fsstream);
 
 		/* callback for source pad added (new stream source ready) */
 		g_signal_connect(G_OBJECT(fsstream),
-				 "src-pad-added", G_CALLBACK(purple_media_src_pad_added_cb), session);
+				 "src-pad-added", G_CALLBACK(purple_media_src_pad_added_cb), stream);
 
 	} else if (*direction != type_direction) {	
 		/* change direction */
@@ -1432,7 +1445,7 @@ void purple_media_set_output_volume(Purp
 
 		if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO) {
 			GstElement *volume = gst_bin_get_by_name(
-					GST_BIN(stream->session->sink),
+					GST_BIN(stream->sink),
 					"purpleaudiooutputvolume");
 			g_object_set(volume, "volume", level, NULL);
 		}
============================================================
--- libpurple/media.h	d23cbaa40ac76a574c44cc91a77e4cd9e048714e
+++ libpurple/media.h	35a0c2b462896adccc77fe8646336ea33b6f4b7b
@@ -173,13 +173,15 @@ void purple_media_set_src(PurpleMedia *m
 void purple_media_set_src(PurpleMedia *media, const gchar *sess_id, GstElement *src);
 
 /**
- * Sets the sink on a session.
+ * Sets the sink on a stream.
  *
  * @param media The media object the session is in.
- * @param sess_id The session id of the session to set the sink on.
+ * @param sess_id The session id the stream belongs to.
+ * @param sess_id The participant the stream is associated with.
  * @param sink The source to set the session sink to.
  */
-void purple_media_set_sink(PurpleMedia *media, const gchar *sess_id, GstElement *sink);
+void purple_media_set_sink(PurpleMedia *media, const gchar *sess_id,
+		const gchar *participant, GstElement *sink);
 
 /**
  * Gets the source from a session
@@ -192,14 +194,15 @@ GstElement *purple_media_get_src(PurpleM
 GstElement *purple_media_get_src(PurpleMedia *media, const gchar *sess_id);
 
 /**
- * Gets the sink from a session
+ * Gets the sink from a stream
  *
  * @param media The media object the session is in.
- * @param sess_id The session id of the session to get the source from.
+ * @param sess_id The session id the stream belongs to.
+ * @param participant The participant the stream is associated with.
  *
  * @return The sink retrieved.
  */
-GstElement *purple_media_get_sink(PurpleMedia *media, const gchar *sess_id);
+GstElement *purple_media_get_sink(PurpleMedia *media, const gchar *sess_id, const gchar *participant);
 
 /**
  * Gets the pipeline from the media session.


More information about the Commits mailing list