summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEitan Isaacson <eitan@monotonous.org>2010-12-03 21:00:07 (GMT)
committerEitan Isaacson <eitan@monotonous.org>2010-12-10 21:11:39 (GMT)
commitaf2a564d51ab652fa2ca67e06aa2cf1a541c0061 (patch)
treef1479432aa665fde615b366b56abe20c80785901
parent0f626a551e31b50a513fe74ec8c01931e50328a7 (diff)
downloadtelepathy-gabble-af2a564d51ab652fa2ca67e06aa2cf1a541c0061.tar.gz
telepathy-gabble-af2a564d51ab652fa2ca67e06aa2cf1a541c0061.tar.xz
Added content-rejected callback in media channel.
-rw-r--r--src/media-channel.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/media-channel.c b/src/media-channel.c
index b5cb5d8..f0fd4e0 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -223,6 +223,9 @@ static void create_stream_from_content (GabbleMediaChannel *chan,
static gboolean contact_is_media_capable (GabbleMediaChannel *chan, TpHandle peer,
gboolean *wait, GError **error);
static void stream_creation_data_cancel (gpointer p, gpointer unused);
+static void session_content_rejected_cb (GabbleJingleSession *session,
+ GabbleJingleContent *c, JingleReason reason, const gchar *message,
+ gpointer user_data);
static void
create_initial_streams (GabbleMediaChannel *chan)
@@ -289,6 +292,9 @@ _latch_to_session (GabbleMediaChannel *chan)
g_signal_connect (priv->session, "terminated",
(GCallback) session_terminated_cb, chan);
+ g_signal_connect (priv->session, "content-rejected",
+ (GCallback) session_content_rejected_cb, chan);
+
gabble_media_channel_hold_latch_to_session (chan);
g_assert (priv->streams->len == 0);
@@ -1284,6 +1290,30 @@ _find_stream_by_id (GabbleMediaChannel *chan,
return NULL;
}
+static GabbleMediaStream *
+_find_stream_by_content (GabbleMediaChannel *chan,
+ GabbleJingleContent *content)
+{
+ GabbleMediaChannelPrivate *priv;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (chan));
+
+ priv = chan->priv;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+ GabbleJingleContent *c = GABBLE_JINGLE_CONTENT (
+ gabble_media_stream_get_content (stream));
+
+ if (content == c)
+ return stream;
+ }
+
+ return NULL;
+}
+
/**
* gabble_media_channel_remove_streams
*
@@ -2764,6 +2794,43 @@ create_stream_from_content (GabbleMediaChannel *self,
}
static void
+session_content_rejected_cb (GabbleJingleSession *session,
+ GabbleJingleContent *c, JingleReason reason, const gchar *message,
+ gpointer user_data)
+{
+ GabbleMediaChannel *chan = GABBLE_MEDIA_CHANNEL (user_data);
+ GabbleMediaStream *stream = _find_stream_by_content (chan, c);
+ guint id = 0;
+
+ DEBUG (" ");
+
+ g_return_if_fail (stream != NULL);
+
+ g_object_get (stream,
+ "id", &id,
+ NULL);
+
+ switch (reason) {
+ case JINGLE_REASON_CONNECTIVITY_ERROR:
+ tp_svc_channel_type_streamed_media_emit_stream_error (chan, id,
+ TP_MEDIA_STREAM_ERROR_NETWORK_ERROR, message);
+ break;
+ case JINGLE_REASON_MEDIA_ERROR:
+ tp_svc_channel_type_streamed_media_emit_stream_error (chan, id,
+ TP_MEDIA_STREAM_ERROR_MEDIA_ERROR, message);
+ break;
+ case JINGLE_REASON_FAILED_APPLICATION:
+ tp_svc_channel_type_streamed_media_emit_stream_error (chan, id,
+ TP_MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED, message);
+ break;
+ default:
+ tp_svc_channel_type_streamed_media_emit_stream_error (chan, id,
+ TP_MEDIA_STREAM_ERROR_UNKNOWN, message);
+ break;
+ }
+}
+
+static void
session_new_content_cb (GabbleJingleSession *session,
GabbleJingleContent *c, gpointer user_data)
{