diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2011-11-08 18:53:22 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2011-11-28 16:08:13 +0100 |
commit | 4eb7319798bbae58c2f3f4880c446c8f5183fbcb (patch) | |
tree | ffd24427092a8242c00ebbf405ed3b48b08ee1c3 | |
parent | a4d0638f123d2752e56174632f89bd1a62087665 (diff) |
Add methods to report sending and receiving failures
-rw-r--r-- | doc/lib/Makefile.am | 2 | ||||
-rw-r--r-- | doc/lib/telepathy-farstream-sections.txt | 4 | ||||
-rw-r--r-- | python/pytpfarstream.defs | 42 | ||||
-rw-r--r-- | telepathy-farstream/call-content.c | 50 | ||||
-rw-r--r-- | telepathy-farstream/call-stream.c | 36 | ||||
-rw-r--r-- | telepathy-farstream/call-stream.h | 7 | ||||
-rw-r--r-- | telepathy-farstream/channel.c | 6 | ||||
-rw-r--r-- | telepathy-farstream/content-priv.h | 6 | ||||
-rw-r--r-- | telepathy-farstream/content.c | 138 | ||||
-rw-r--r-- | telepathy-farstream/content.h | 15 |
10 files changed, 298 insertions, 8 deletions
diff --git a/doc/lib/Makefile.am b/doc/lib/Makefile.am index 59bfce7..e93fb74 100644 --- a/doc/lib/Makefile.am +++ b/doc/lib/Makefile.am @@ -46,7 +46,7 @@ CFILE_GLOB=$(top_srcdir)/telepathy-farstream/channel.c $(top_srcdir)/telepathy-f # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h IGNORE_HFILES=channel-priv.h content-priv.h session-priv.h stream-priv.h \ stream.h call-channel.h call-content.h call-stream.h tf-signals-marshal.h \ - media-signalling-channel.h media-signalling-content.h + media-signalling-channel.h media-signalling-content.h utils.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png diff --git a/doc/lib/telepathy-farstream-sections.txt b/doc/lib/telepathy-farstream-sections.txt index c668a19..41903c4 100644 --- a/doc/lib/telepathy-farstream-sections.txt +++ b/doc/lib/telepathy-farstream-sections.txt @@ -11,6 +11,10 @@ TfContentClass tf_content_iterate_src_pads tf_content_error tf_content_error_literal +tf_content_receiving_failed +tf_content_receiving_failed_literal +tf_content_sending_failed +tf_content_sending_failed_literal <SUBSECTION Private> TfContentPrivate <SUBSECTION Standard> diff --git a/python/pytpfarstream.defs b/python/pytpfarstream.defs index ea61165..fa2e554 100644 --- a/python/pytpfarstream.defs +++ b/python/pytpfarstream.defs @@ -83,6 +83,48 @@ (varargs #t) ) +(define-method sending_failed_literal + (of-object "TfContent") + (c-name "tf_content_sending_failed_literal") + (return-type "none") + (parameters + '("const-gchar*" "message") + ) +) + +(define-method sending_failed + (of-object "TfContent") + (c-name "tf_content_sending_failed") + (return-type "none") + (parameters + '("const-gchar*" "message_format") + ) + (varargs #t) +) + +(define-method receiving_failed_literal + (of-object "TfContent") + (c-name "tf_content_receiving_failed_literal") + (return-type "none") + (parameters + '("guint*" "handles") + '("guint" "handle_count") + '("const-gchar*" "message") + ) +) + +(define-method receiving_failed + (of-object "TfContent") + (c-name "tf_content_receiving_failed") + (return-type "none") + (parameters + '("guint*" "handles") + '("guint" "handle_count") + '("const-gchar*" "message_format") + ) + (varargs #t) +) + (define-method iterate_src_pads (of-object "TfContent") (c-name "tf_content_iterate_src_pads") diff --git a/telepathy-farstream/call-content.c b/telepathy-farstream/call-content.c index 519bfc2..ea8c60c 100644 --- a/telepathy-farstream/call-content.c +++ b/telepathy-farstream/call-content.c @@ -193,9 +193,13 @@ static void tf_call_content_error_literal (TfCallContent *self, const gchar *detailed_reason, const gchar *message); -static void -tf_call_content_error_impl (TfContent *content, +static void tf_call_content_error_impl (TfContent *content, const gchar *message); +static void tf_call_content_sending_failed (TfContent *content, + const gchar *message); +static void tf_call_content_receiving_failed (TfContent *content, + guint *handles, guint handle_count, + const gchar *message); static void tf_call_content_class_init (TfCallContentClass *klass) @@ -206,6 +210,8 @@ tf_call_content_class_init (TfCallContentClass *klass) content_class->iterate_src_pads = tf_call_content_iterate_src_pads; content_class->content_error = tf_call_content_error_impl; + content_class->sending_failed = tf_call_content_sending_failed; + content_class->receiving_failed = tf_call_content_receiving_failed; object_class->dispose = tf_call_content_dispose; object_class->finalize = tf_call_content_finalize; @@ -2304,3 +2310,43 @@ tf_call_content_iterate_src_pads (TfContent *content, guint *handles, return (GstIterator *) iter; } + +static void +tf_call_content_sending_failed (TfContent *content, + const gchar *message) +{ + TfCallContent *self = TF_CALL_CONTENT (content); + GHashTableIter iter; + gpointer key, value; + + if (!self->streams) + { + g_warning ("Too early, ignoring sending error"); + return; + } + + g_hash_table_iter_init (&iter, self->streams); + while (g_hash_table_iter_next (&iter, &key, &value)) + tf_call_stream_sending_failed (value, message); +} + + +static void +tf_call_content_receiving_failed (TfContent *content, + guint *handles, guint handle_count, + const gchar *message) +{ + TfCallContent *self = TF_CALL_CONTENT (content); + GHashTableIter iter; + gpointer key, value; + + if (!self->streams) + { + g_warning ("Too early, ignoring sending error"); + return; + } + + g_hash_table_iter_init (&iter, self->streams); + while (g_hash_table_iter_next (&iter, &key, &value)) + tf_call_stream_receiving_failed (value, handles, handle_count, message); +} diff --git a/telepathy-farstream/call-stream.c b/telepathy-farstream/call-stream.c index 27a6eb2..184dcbf 100644 --- a/telepathy-farstream/call-stream.c +++ b/telepathy-farstream/call-stream.c @@ -1496,3 +1496,39 @@ tf_call_stream_fail (TfCallStream *self, tf_call_stream_fail_literal (self, reason, detailed_reason, message); g_free (message); } + +void +tf_call_stream_sending_failed (TfCallStream *self, const gchar *message) +{ + g_warning ("Reporting sending failure: %s", message); + + tp_cli_call_stream_interface_media_call_report_sending_failure ( + self->proxy, -1, TP_CALL_STATE_CHANGE_REASON_INTERNAL_ERROR, + TP_ERROR_STR_MEDIA_STREAMING_ERROR, + message, NULL, NULL, NULL, NULL); +} + + +void +tf_call_stream_receiving_failed (TfCallStream *self, + guint *handles, guint handle_count, + const gchar *message) +{ + if (handle_count && handle_count > 0) + { + guint i; + + for (i = 0; i < handle_count; i++) + if (handles[i] == self->contact_handle) + goto ok; + return; + } + ok: + + g_warning ("Reporting receiving failure: %s", message); + + tp_cli_call_stream_interface_media_call_report_receiving_failure ( + self->proxy, -1, TP_CALL_STATE_CHANGE_REASON_INTERNAL_ERROR, + TP_ERROR_STR_MEDIA_STREAMING_ERROR, + message, NULL, NULL, NULL, NULL); +} diff --git a/telepathy-farstream/call-stream.h b/telepathy-farstream/call-stream.h index dcbedb8..3f5c4b8 100644 --- a/telepathy-farstream/call-stream.h +++ b/telepathy-farstream/call-stream.h @@ -120,6 +120,13 @@ TfCallStream *tf_call_stream_new ( gboolean tf_call_stream_bus_message (TfCallStream *stream, GstMessage *message); +void tf_call_stream_sending_failed (TfCallStream *stream, const gchar *message); + +void tf_call_stream_receiving_failed (TfCallStream *stream, + guint *handles, guint handle_count, + const gchar *message); + + G_END_DECLS #endif /* __TF_CALL_STREAM_H__ */ diff --git a/telepathy-farstream/channel.c b/telepathy-farstream/channel.c index d1349d5..f810135 100644 --- a/telepathy-farstream/channel.c +++ b/telepathy-farstream/channel.c @@ -606,6 +606,9 @@ tf_channel_new_async (TpChannel *channel_proxy, GAsyncReadyCallback callback, gpointer user_data) { + g_return_if_fail (channel_proxy != NULL); + g_return_if_fail (callback != NULL); + return g_async_initable_new_async (TF_TYPE_CHANNEL, 0, NULL, callback, user_data, "channel", channel_proxy, @@ -627,6 +630,9 @@ gboolean tf_channel_bus_message (TfChannel *channel, GstMessage *message) { + g_return_val_if_fail (channel != NULL, FALSE); + g_return_val_if_fail (message != NULL, FALSE); + if (channel->priv->media_signalling_channel) return tf_media_signalling_channel_bus_message ( channel->priv->media_signalling_channel, message); diff --git a/telepathy-farstream/content-priv.h b/telepathy-farstream/content-priv.h index 167ef56..7c1f598 100644 --- a/telepathy-farstream/content-priv.h +++ b/telepathy-farstream/content-priv.h @@ -21,6 +21,12 @@ struct _TfContentClass{ void (*content_error) (TfContent *content, const gchar *message); + void (*sending_failed) (TfContent *content, + const gchar *message); + void (*receiving_failed) (TfContent *content, + guint *handles, guint handle_count, + const gchar *message); + GstIterator * (*iterate_src_pads) (TfContent *content, guint *handle, guint handle_count); }; diff --git a/telepathy-farstream/content.c b/telepathy-farstream/content.c index d86c6c3..dfced48 100644 --- a/telepathy-farstream/content.c +++ b/telepathy-farstream/content.c @@ -15,10 +15,10 @@ * Objects of this class allow the user to handle the media side of a Telepathy * channel handled by #TfChannel. * - * This object is created by the #TfChannel and the user is notified of its - * creation by the #TfChannel::content-added signal. In the callback for this - * signal, the user should call tf_content_set_codec_preferences() and connect - * to the #TfContent::src-pad-added signal. + * This object is created by the #TfChannel and the user is notified + * of its creation by the #TfChannel::content-added signal. In the + * callback for this signal, the user should connect to the + * #TfContent::src-pad-added signal. * */ @@ -315,6 +315,9 @@ tf_content_error_literal (TfContent *content, { TfContentClass *klass = TF_CONTENT_GET_CLASS (content); + g_return_if_fail (content != NULL); + g_return_if_fail (message != NULL); + if (klass->content_error) klass->content_error (content, message); else @@ -339,6 +342,9 @@ tf_content_error (TfContent *content, gchar *message; va_list valist; + g_return_if_fail (content != NULL); + g_return_if_fail (message_format != NULL); + va_start (valist, message_format); message = g_strdup_vprintf (message_format, valist); va_end (valist); @@ -365,6 +371,8 @@ tf_content_iterate_src_pads (TfContent *content, guint *handles, { TfContentClass *klass = TF_CONTENT_GET_CLASS (content); + g_return_val_if_fail (content != NULL, NULL); + if (klass->iterate_src_pads) return klass->iterate_src_pads (content, handles, handle_count); else @@ -414,3 +422,125 @@ _tf_content_stop_receiving (TfContent *self, guint *handles, g_signal_emit (self, signals[SIGNAL_STOP_SENDING], 0, handles, handle_count); } + + +/** + * tf_content_sending_failed_literal: + * @content: a #TfContent + * @message_format: Message with printf style formatting + * @...: Parameters to insert into the @message_format string + * + * Informs the Connection Manager that sending has failed for this + * content. This is a transient error and it may or not not end the Content + * and the call. + */ + +void +tf_content_sending_failed_literal (TfContent *content, + const gchar *message) +{ + TfContentClass *klass = TF_CONTENT_GET_CLASS (content); + + g_return_if_fail (content != NULL); + g_return_if_fail (message != NULL); + + if (klass->content_error) + klass->sending_failed (content, message); + else + GST_WARNING ("sending_failed not defined in class, ignoring error: %s", + message); +} + +/** + * tf_content_sending_failed: + * @content: a #TfContent + * @message: The error message + * + * Informs the Connection Manager that sending has failed for this + * content. This is a transient error and it may or not not end the Content + * and the call. + */ + +void +tf_content_sending_failed (TfContent *content, + const gchar *message_format, ...) +{ + gchar *message; + va_list valist; + + g_return_if_fail (content != NULL); + g_return_if_fail (message_format != NULL); + + va_start (valist, message_format); + message = g_strdup_vprintf (message_format, valist); + va_end (valist); + + tf_content_sending_failed_literal (content, message); + g_free (message); +} + +/** + * tf_content_receiving_failed_literal: + * @content: a #TfContent + * @handles: an array of #guint representing Telepathy handles, may be %NULL + * @handle_count: the numner of handles in @handles + * @message: The error message + * + * Informs the Connection Manager that receiving has failed for this + * content. This is a transient error and it may or not not end the Content + * and the call. + * + * If handles are not specific, it assumes that it is valid for all handles. + */ + +void +tf_content_receiving_failed_literal (TfContent *content, + guint *handles, guint handle_count, + const gchar *message) +{ + TfContentClass *klass = TF_CONTENT_GET_CLASS (content); + + g_return_if_fail (content != NULL); + g_return_if_fail (message != NULL); + + if (klass->content_error) + klass->receiving_failed (content, handles, handle_count, message); + else + GST_WARNING ("receiving_failed not defined in class, ignoring error: %s", + message); +} + + +/** + * tf_content_receiving_failed: + * @content: a #TfContent + * @handles: an array of #guint representing Telepathy handles, may be %NULL + * @handle_count: the numner of handles in @handles + * @message_format: Message with printf style formatting + * @...: Parameters to insert into the @message_format string + * + * Informs the Connection Manager that receiving has failed for this + * content. This is a transient error and it may or not not end the Content + * and the call. + * + * If handles are not specific, it assumes that it is valid for all handles. + */ + +void +tf_content_receiving_failed (TfContent *content, + guint *handles, guint handle_count, + const gchar *message_format, ...) +{ + gchar *message; + va_list valist; + + g_return_if_fail (content != NULL); + g_return_if_fail (message_format != NULL); + + va_start (valist, message_format); + message = g_strdup_vprintf (message_format, valist); + va_end (valist); + + tf_content_receiving_failed_literal (content, handles, handle_count, message); + g_free (message); +} diff --git a/telepathy-farstream/content.h b/telepathy-farstream/content.h index aabfdff..eea2455 100644 --- a/telepathy-farstream/content.h +++ b/telepathy-farstream/content.h @@ -49,10 +49,23 @@ GType tf_content_get_type (void); void tf_content_error_literal (TfContent *content, const gchar *message); - void tf_content_error (TfContent *content, const gchar *message_format, ...) G_GNUC_PRINTF (2, 3); + +void tf_content_sending_failed_literal (TfContent *content, + const gchar *message); +void tf_content_sending_failed (TfContent *content, + const gchar *message_format, ...) G_GNUC_PRINTF (2, 3); + +void tf_content_receiving_failed_literal (TfContent *content, + guint *handles, guint handle_count, + const gchar *message); +void tf_content_receiving_failed (TfContent *content, + guint *handles, guint handle_count, + const gchar *message_format, ...) G_GNUC_PRINTF (4, 5); + + GstIterator *tf_content_iterate_src_pads (TfContent *content, guint *handles, guint handle_count); |