changeset 31640:5b51e5fb8d76

MXit VV WIP.
author andrew.victor@mxit.com
date Sun, 15 May 2011 20:43:28 +0000
parents 5643110e51db
children a47a82a009bf
files libpurple/protocols/mxit/voicevideo.c
diffstat 1 files changed, 89 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/mxit/voicevideo.c	Sun May 15 20:37:43 2011 +0000
+++ b/libpurple/protocols/mxit/voicevideo.c	Sun May 15 20:43:28 2011 +0000
@@ -109,6 +109,59 @@
 }
 
 
+static void mxit_candidates_prepared_cb(PurpleMedia* media, gchar* sessionid, gchar* who, void* session)
+{
+	purple_debug_info(MXIT_PLUGIN_ID, "mxit_candidates_prepared_cb: buddy '%s', session '%s'\n", who, sessionid);
+
+	if (purple_media_is_initiator(media, sessionid, who)) {
+		// TODO: Send INVITE via SIP.
+	}
+	else {
+		// TODO: ??
+	}
+}
+
+static void mxit_stream_info_cb(PurpleMedia* media, PurpleMediaInfoType type, char* sessionid, gchar* who, gboolean local, void* session)
+{
+	purple_debug_info(MXIT_PLUGIN_ID, "mxit_stream_info_cb: buddy '%s', session '%s', info %d \n", who, sessionid, type);
+
+	switch (type) {
+		case PURPLE_MEDIA_INFO_HANGUP:
+			break;
+		case PURPLE_MEDIA_INFO_ACCEPT:
+			break;
+		case PURPLE_MEDIA_INFO_REJECT:
+			break;
+		case PURPLE_MEDIA_INFO_MUTE:
+			break;
+		case PURPLE_MEDIA_INFO_UNMUTE:
+			break;
+		case PURPLE_MEDIA_INFO_PAUSE:
+			break;
+		case PURPLE_MEDIA_INFO_UNPAUSE:
+			break;
+		case PURPLE_MEDIA_INFO_HOLD:
+			break;
+		case PURPLE_MEDIA_INFO_UNHOLD:
+			break;
+	}
+}
+
+static void mxit_state_changed_cb(PurpleMedia* media, PurpleMediaState state, gchar* sessionid, char* who, void* session)
+{
+	purple_debug_info(MXIT_PLUGIN_ID, "mxit_state_changed_cb: buddy '%s', session '%s', state %d\n", who, sessionid, state);
+
+	switch (state) {
+		case PURPLE_MEDIA_STATE_NEW:
+			break;
+		case PURPLE_MEDIA_STATE_CONNECTED:
+			break;
+		case PURPLE_MEDIA_STATE_END:
+			break;
+	}
+}
+
+
 /*------------------------------------------------------------------------
  * Initiate a voice/video session with a contact.
  *
@@ -119,9 +172,44 @@
  */
 gboolean mxit_media_initiate(PurpleAccount *account, const char *who, PurpleMediaSessionType type)
 {
+	gchar* transmitter = "rawudp";
+	PurpleMedia* media = NULL;
+
 	purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_initiate: buddy '%s'\n", who);
 
-	return FALSE;
+	media = purple_media_manager_create_media(
+		purple_media_manager_get(),
+		account,
+		"fsrtpconference",
+		who,
+		TRUE
+	);
+
+	if (!media) {
+		purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_initiate: could not create media session\n");
+		return FALSE;
+	}
+
+	/* attach callbacks */
+	g_signal_connect(G_OBJECT(media), "candidates-prepared", G_CALLBACK(mxit_candidates_prepared_cb), NULL);
+	g_signal_connect(G_OBJECT(media), "stream-info", G_CALLBACK(mxit_stream_info_cb), NULL);
+	g_signal_connect(G_OBJECT(media), "state-changed", G_CALLBACK(mxit_state_changed_cb), NULL);
+
+	/* initiate audio session */
+	if ((type & PURPLE_MEDIA_AUDIO) && 
+			(!purple_media_add_stream(media, "audio", who, PURPLE_MEDIA_AUDIO, TRUE, transmitter, 0, NULL))) {
+		purple_media_end(media, NULL, NULL);
+		return FALSE;
+	}
+
+	/* initiate video session */
+	if ((type & PURPLE_MEDIA_VIDEO) &&
+			(!purple_media_add_stream(media, "video", who, PURPLE_MEDIA_VIDEO, TRUE, transmitter, 0, NULL))) {
+		purple_media_end(media, NULL, NULL);
+		return FALSE;
+	}
+
+	return TRUE;
 }
 
 #else