pidgin.vv: 0172cf13: Add state-changed signal to PurpleMedia.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Mon Jan 5 01:40:33 EST 2009


-----------------------------------------------------------------
Revision: 0172cf13d2ad06b098c9807836797ae0087ac913
Ancestor: 68eefccdd54cbc4a678a47e24ef2f1dab773ad3a
Author: maiku at soc.pidgin.im
Date: 2009-01-05T06:34:30
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/0172cf13d2ad06b098c9807836797ae0087ac913

Modified files:
        libpurple/marshallers.list libpurple/media.c
        libpurple/media.h libpurple/protocols/jabber/jingle/rtp.c

ChangeLog: 

Add state-changed signal to PurpleMedia.

-------------- next part --------------
============================================================
--- libpurple/marshallers.list	a3edfa9599fa64795d23bb60ce1213aceb87170d
+++ libpurple/marshallers.list	4e7fb780529f606c1837dfcff8de04aab53426d2
@@ -2,3 +2,4 @@ VOID:STRING,STRING
 VOID:POINTER,POINTER,OBJECT
 BOOLEAN:OBJECT,POINTER,STRING
 VOID:STRING,STRING
+VOID:ENUM,STRING,STRING
============================================================
--- libpurple/media.c	1c67538c21cfb1012a7c6e2635193dbbde1fa04c
+++ libpurple/media.c	be398504a06b5ae13418958f49d5513d0361f071
@@ -122,6 +122,7 @@ enum {
 	CANDIDATE_PAIR,
 	CODECS_READY,
 	READY_NEW,
+	STATE_CHANGED,
 	LAST_SIGNAL
 };
 static guint purple_media_signals[LAST_SIGNAL] = {0};
@@ -155,6 +156,22 @@ purple_media_get_type()
 	return type;
 }
 
+GType
+purple_media_state_changed_get_type()
+{
+	static GType type = 0;
+	if (type == 0) {
+		static const GEnumValue values[] = {
+			{ PURPLE_MEDIA_STATE_CHANGED_NEW, "PURPLE_MEDIA_STATE_CHANGED_NEW", "new" },
+			{ PURPLE_MEDIA_STATE_CHANGED_CONNECTED, "PURPLE_MEDIA_STATE_CHANGED_CONNECTED", "connected" },
+			{ PURPLE_MEDIA_STATE_CHANGED_END, "PURPLE_MEDIA_STATE_CHANGED_END", "end" },
+			{ 0, NULL, NULL }
+		};
+		type = g_enum_register_static("PurpleMediaStateChangedType", values);
+	}
+	return type;
+}
+
 static void
 purple_media_class_init (PurpleMediaClass *klass)
 {
@@ -236,6 +253,11 @@ purple_media_class_init (PurpleMediaClas
 					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
 					 purple_smarshal_VOID__STRING_STRING,
 					 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
+	purple_media_signals[STATE_CHANGED] = g_signal_new("state-changed", G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+					 purple_smarshal_VOID__ENUM_STRING_STRING,
+					 G_TYPE_NONE, 3, PURPLE_MEDIA_TYPE_STATE_CHANGED,
+					 G_TYPE_STRING, G_TYPE_STRING);
 	g_type_class_add_private(klass, sizeof(PurpleMediaPrivate));
 }
 
@@ -845,12 +867,18 @@ purple_media_hangup(PurpleMedia *media)
 void
 purple_media_hangup(PurpleMedia *media)
 {
+	g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+			0, PURPLE_MEDIA_STATE_CHANGED_END,
+			NULL, NULL);
 	g_signal_emit(media, purple_media_signals[HANGUP], 0);
 }
 
 void
 purple_media_reject(PurpleMedia *media)
 {
+	g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+			0, PURPLE_MEDIA_STATE_CHANGED_END,
+			NULL, NULL);
 	g_signal_emit(media, purple_media_signals[REJECT], 0);
 }
 
@@ -863,6 +891,9 @@ purple_media_got_hangup(PurpleMedia *med
 void
 purple_media_got_hangup(PurpleMedia *media)
 {
+	g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+			0, PURPLE_MEDIA_STATE_CHANGED_END,
+			NULL, NULL);
 	g_signal_emit(media, purple_media_signals[GOT_HANGUP], 0);
 }
 
@@ -1172,6 +1203,10 @@ purple_media_src_pad_added_cb(FsStream *
 	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(stream->sink, GST_STATE_PLAYING);
+
+	g_signal_emit(stream->session->media, purple_media_signals[STATE_CHANGED],
+				0, PURPLE_MEDIA_STATE_CHANGED_CONNECTED,
+				stream->session->id, stream->participant);
 }
 
 static gchar *
@@ -1259,12 +1294,19 @@ purple_media_add_stream_internal(PurpleM
 		session->type = purple_media_from_fs(type, type_direction);
 
 		purple_media_add_session(media, session);
+		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+				0, PURPLE_MEDIA_STATE_CHANGED_NEW,
+				session->id, NULL);
 	}
 
 	if (!(participant = purple_media_add_participant(media, who))) {
 		purple_media_remove_session(media, session);
 		g_free(session);
 		return FALSE;
+	} else {
+		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+				0, PURPLE_MEDIA_STATE_CHANGED_NEW,
+				NULL, who);
 	}
 
 	stream = purple_media_get_stream(media, sess_id, who);
@@ -1310,6 +1352,9 @@ purple_media_add_stream_internal(PurpleM
 		g_signal_connect(G_OBJECT(fsstream),
 				 "src-pad-added", G_CALLBACK(purple_media_src_pad_added_cb), stream);
 
+		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+				0, PURPLE_MEDIA_STATE_CHANGED_NEW,
+				session->id, who);
 	} else if (*direction != type_direction) {	
 		/* change direction */
 		g_object_set(stream->stream, "direction", type_direction, NULL);
@@ -1350,7 +1395,7 @@ purple_media_remove_stream(PurpleMedia *
 void
 purple_media_remove_stream(PurpleMedia *media, const gchar *sess_id, const gchar *who)
 {
-	
+	/* Add state-changed end emits in here when this is implemented */
 }
 
 PurpleMediaSessionType
============================================================
--- libpurple/media.h	fe482bfe9372a3eba8a6092cae59b509a39bf6d7
+++ libpurple/media.h	62d7facd51a58b5137aae84030a3fd03f0198368
@@ -45,6 +45,8 @@ G_BEGIN_DECLS
 #define PURPLE_IS_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA))
 #define PURPLE_MEDIA_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA, PurpleMediaClass))
 
+#define PURPLE_MEDIA_TYPE_STATE_CHANGED	(purple_media_state_changed_get_type())
+
 /** @copydoc _PurpleMedia */
 typedef struct _PurpleMedia PurpleMedia;
 /** @copydoc _PurpleMediaClass */
@@ -69,6 +71,13 @@ typedef enum {
 	PURPLE_MEDIA_VIDEO = PURPLE_MEDIA_RECV_VIDEO | PURPLE_MEDIA_SEND_VIDEO
 } PurpleMediaSessionType;
 
+/** Media state-changed types */
+typedef enum {
+	PURPLE_MEDIA_STATE_CHANGED_NEW = 0,
+	PURPLE_MEDIA_STATE_CHANGED_CONNECTED,
+	PURPLE_MEDIA_STATE_CHANGED_END,
+} PurpleMediaStateChangedType;
+
 #ifdef USE_VV
 
 /** The media class */
@@ -95,6 +104,13 @@ GType purple_media_get_type(void);
  */
 GType purple_media_get_type(void);
 
+/**
+ * Gets the type of the state-changed enum
+ *
+ * @return The state-changed enum's GType
+ */
+GType purple_media_state_changed_get_type(void);
+
 /**************************************************************************/
 /** @name Media Utility Functions                                         */
 /**************************************************************************/
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	4ceb35b7c5b2c7d0d590527ec3531e17fbebda34
+++ libpurple/protocols/jabber/jingle/rtp.c	04309b54c16143dfdcf4a1c9e6bfc9c647eecec8
@@ -329,6 +329,13 @@ jingle_rtp_ready_cb(PurpleMedia *media, 
 	}
 }
 
+static void
+jingle_rtp_state_changed_cb(PurpleMedia *media, PurpleMediaStateChangedType type,
+		gchar *sid, gchar *name, JingleSession *session)
+{
+	purple_debug_info("jingle-rtp", "state-changed: type %d id: %s name: %s\n", type, sid, name);
+}
+
 static PurpleMedia *
 jingle_rtp_create_media(JingleContent *content)
 {
@@ -368,6 +375,8 @@ jingle_rtp_create_media(JingleContent *c
 				 G_CALLBACK(jingle_rtp_candidate_pair_established_cb), session);
 	g_signal_connect(G_OBJECT(media), "ready-new",
 				 G_CALLBACK(jingle_rtp_ready_cb), session);
+	g_signal_connect(G_OBJECT(media), "state-changed",
+				 G_CALLBACK(jingle_rtp_state_changed_cb), session);
 
 	g_object_unref(session);
 	return media;


More information about the Commits mailing list