soc.2008.vv: 9ce02fce: Added better Farsight error handling. Fi...
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Mon May 26 22:30:37 EDT 2008
-----------------------------------------------------------------
Revision: 9ce02fce3b1fc2c610860bcd00402f20985c562c
Ancestor: 7e0a41d4f9759d489cd9c87e558de2a0f8258cdc
Author: maiku at soc.pidgin.im
Date: 2008-05-27T02:24:03
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/9ce02fce3b1fc2c610860bcd00402f20985c562c
Modified files:
libpurple/media.c libpurple/media.h libpurple/mediamanager.c
libpurple/protocols/jabber/jabber.c pidgin/gtkconv.c
pidgin/gtkmedia.c
ChangeLog:
Added better Farsight error handling. Fixes several crash bugs related
to missing GStreamer/Farsight plugins.
-------------- next part --------------
============================================================
--- libpurple/media.c a333e384e574ae9af1133d63046441271a1bc826
+++ libpurple/media.c 38c5eecbf78b5fdc0cf4aa9d0b7285ce51b42384
@@ -710,7 +710,7 @@ purple_media_src_pad_added(FsStream *str
gst_element_set_state(pipeline, GST_STATE_PLAYING);
}
-static void
+static gboolean
purple_media_add_stream_internal(PurpleMedia *media, FsSession **session, GList **streams,
GstElement *src, const gchar *who, FsMediaType type,
FsStreamDirection type_direction, const gchar *transmitter)
@@ -724,7 +724,18 @@ purple_media_add_stream_internal(PurpleM
FsSession *s = NULL;
if (!*session) {
- *session = fs_conference_new_session(media->priv->conference, type, NULL);
+ GError *err = NULL;
+ *session = fs_conference_new_session(media->priv->conference, type, &err);
+
+ if (err != NULL) {
+ purple_debug_error("media", "Error creating session: %s\n", err->message);
+ g_error_free(err);
+ purple_conv_present_error(who,
+ purple_connection_get_account(purple_media_get_connection(media)),
+ _("Error creating session."));
+ return FALSE;
+ }
+
if (src) {
GstPad *sinkpad;
GstPad *srcpad;
@@ -782,9 +793,11 @@ purple_media_add_stream_internal(PurpleM
/* change direction */
g_object_set(stream, "direction", type_direction, NULL);
}
+
+ return TRUE;
}
-void
+gboolean
purple_media_add_stream(PurpleMedia *media, const gchar *who,
PurpleMediaStreamType type,
const gchar *transmitter)
@@ -801,11 +814,13 @@ purple_media_add_stream(PurpleMedia *med
else
type_direction = FS_DIRECTION_NONE;
- purple_media_add_stream_internal(media, &media->priv->audio_session,
- &media->priv->audio_streams,
- media->priv->audio_src, who,
- FS_MEDIA_TYPE_AUDIO, type_direction,
- transmitter);
+ if (!purple_media_add_stream_internal(media, &media->priv->audio_session,
+ &media->priv->audio_streams,
+ media->priv->audio_src, who,
+ FS_MEDIA_TYPE_AUDIO, type_direction,
+ transmitter)) {
+ return FALSE;
+ }
}
if (type & PURPLE_MEDIA_VIDEO) {
if (type & PURPLE_MEDIA_SEND_VIDEO && type & PURPLE_MEDIA_RECV_VIDEO)
@@ -817,12 +832,15 @@ purple_media_add_stream(PurpleMedia *med
else
type_direction = FS_DIRECTION_NONE;
- purple_media_add_stream_internal(media, &media->priv->video_session,
- &media->priv->video_streams,
- media->priv->video_src, who,
- FS_MEDIA_TYPE_VIDEO, type_direction,
- transmitter);
+ if (!purple_media_add_stream_internal(media, &media->priv->video_session,
+ &media->priv->video_streams,
+ media->priv->video_src, who,
+ FS_MEDIA_TYPE_VIDEO, type_direction,
+ transmitter)) {
+ return FALSE;
+ }
}
+ return TRUE;
}
void
============================================================
--- libpurple/media.h 1e2287929882130f00243b1cd5de5a01281970bc
+++ libpurple/media.h 726eeb086c3a1c4cab1ce6995ed670853a28ee58
@@ -113,7 +113,7 @@ void purple_media_audio_init_recv(GstEle
void purple_media_audio_init_recv(GstElement **recvbin, GstElement **recvlevel);
-void purple_media_add_stream(PurpleMedia *media, const gchar *who,
+gboolean purple_media_add_stream(PurpleMedia *media, const gchar *who,
PurpleMediaStreamType type, const gchar *transmitter);
void purple_media_remove_stream(PurpleMedia *media, const gchar *who, PurpleMediaStreamType type);
============================================================
--- libpurple/mediamanager.c c811c384fa5425282ccb9594681ccd765a8bfd14
+++ libpurple/mediamanager.c 1b5a10068805e11435b4db260a842f58ee6868db
@@ -133,13 +133,22 @@ purple_media_manager_create_media(Purple
const char *conference_type,
const char *remote_user)
{
+ PurpleMedia *media;
FsConference *conference = FS_CONFERENCE(gst_element_factory_make(conference_type, NULL));
+ GstStateChangeReturn ret = gst_element_set_state(GST_ELEMENT(conference), GST_STATE_READY);
- PurpleMedia *media = PURPLE_MEDIA(g_object_new(purple_media_get_type(),
- "screenname", remote_user,
- "connection", gc,
- "farsight-conference", conference,
- NULL));
+ if (ret == GST_STATE_CHANGE_FAILURE) {
+ purple_conv_present_error(remote_user,
+ purple_connection_get_account(gc),
+ _("Error creating conference."));
+ return NULL;
+ }
+
+ media = PURPLE_MEDIA(g_object_new(purple_media_get_type(),
+ "screenname", remote_user,
+ "connection", gc,
+ "farsight-conference", conference,
+ NULL));
manager->priv->medias = g_list_append(manager->priv->medias, media);
g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0, media);
return media;
============================================================
--- libpurple/protocols/jabber/jabber.c 3380601ebb97179653aed573f823dfc7ea6fc7c5
+++ libpurple/protocols/jabber/jabber.c dbbf7a06bbd51af83960d66e751974663635f14d
@@ -2484,15 +2484,25 @@ jabber_session_candidate_pair_establishe
}
}
-static void
+static gboolean
jabber_initiate_media_internal(JingleSession *session, const char *initiator, const char *remote_jid)
{
PurpleMedia *media = NULL;
media = purple_media_manager_create_media(purple_media_manager_get(),
session->js->gc, "fsrtpconference", remote_jid);
+
+ if (!media) {
+ purple_debug_error("jabber", "Couldn't create fsrtpconference\n");
+ return FALSE;
+ }
+
/* this will need to be changed to "nice" once the libnice transmitter is finished */
- purple_media_add_stream(media, remote_jid, PURPLE_MEDIA_AUDIO, "rawudp");
+ if (!purple_media_add_stream(media, remote_jid, PURPLE_MEDIA_AUDIO, "rawudp")) {
+ purple_debug_error("jabber", "Couldn't create audio stream\n");
+ purple_media_reject(media);
+ return FALSE;
+ }
jabber_jingle_session_set_remote_jid(session, remote_jid);
jabber_jingle_session_set_initiator(session, initiator);
@@ -2511,6 +2521,8 @@ jabber_initiate_media_internal(JingleSes
G_CALLBACK(jabber_session_candidate_pair_established), session);
purple_media_ready(media);
+
+ return TRUE;
}
static void
@@ -2581,7 +2593,12 @@ jabber_initiate_media(PurpleConnection *
/* set ourselves as initiator */
me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, js->user->resource);
- jabber_initiate_media_internal(session, me, jid);
+ if (!jabber_initiate_media_internal(session, me, jid)) {
+ g_free(jid);
+ g_free(me);
+ jabber_jingle_session_destroy(session);
+ return NULL;
+ }
g_free(jid);
g_free(me);
@@ -2717,6 +2734,11 @@ jabber_handle_session_terminate(JabberSt
const char *sid = xmlnode_get_attrib(jingle, "sid");
JingleSession *session = jabber_jingle_session_find_by_id(js, sid);
+ if(!session) {
+ purple_debug_error("jabber", "jabber_handle_session_terminate couldn't find session\n");
+ return;
+ }
+
xmlnode_set_attrib(result->node, "to",
jabber_jingle_session_get_remote_jid(session));
xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id"));
@@ -2831,7 +2853,12 @@ jabber_handle_session_initiate(JabberStr
return;
}
- jabber_initiate_media_internal(session, initiator, initiator);
+ if (!jabber_initiate_media_internal(session, initiator, initiator)) {
+ purple_debug_error("jabber", "Couldn't start media session with %s\n", initiator);
+ jabber_jingle_session_destroy(session);
+ /* we should create an error iq here */
+ return;
+ }
codecs = jabber_jingle_get_codecs(description);
============================================================
--- pidgin/gtkconv.c 0462cbd9a12e345e7a15cfca2208f897cdcc96d4
+++ pidgin/gtkconv.c cf564aa782cf053932ecade2b09d8716570e585d
@@ -7694,7 +7694,8 @@ menu_initiate_voice_call_cb(gpointer dat
purple_conversation_get_name(conv),
PURPLE_MEDIA_RECV_AUDIO & PURPLE_MEDIA_SEND_AUDIO);
- purple_media_wait(media);
+ if (media)
+ purple_media_wait(media);
}
static void
============================================================
--- pidgin/gtkmedia.c d39541eb18c2954feb5cc10709484a6e16893954
+++ pidgin/gtkmedia.c 1fb3568b8a5823b35dd25eb49f00bd46d4eeddfa
@@ -228,7 +228,9 @@ pidgin_media_disconnect_levels(PurpleMed
gulong handler_id = g_signal_handler_find(G_OBJECT(gst_pipeline_get_bus(GST_PIPELINE(element))),
G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0,
NULL, G_CALLBACK(level_message_cb), gtkmedia);
- g_signal_handler_disconnect(G_OBJECT(gst_pipeline_get_bus(GST_PIPELINE(element))), handler_id);
+ if (handler_id)
+ g_signal_handler_disconnect(G_OBJECT(gst_pipeline_get_bus(GST_PIPELINE(element))),
+ handler_id);
}
static void
More information about the Commits
mailing list