From 2e675ded31728b664e2463b6f1926c177dee2e91 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Mon, 7 Jun 2010 07:46:09 -0700 Subject: [PATCH] Implement TP_IFACE_CHANNEL_INTERFACE_DTMF, so Empathy dialpad can be used when calling Asterisk with Jingle, https://bugs.freedesktop.org/show_bug.cgi?id=28413 --- src/media-channel.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++- src/media-stream.c | 18 ++++++++++++++ src/media-stream.h | 3 ++ 3 files changed, 86 insertions(+), 1 deletions(-) diff --git a/src/media-channel.c b/src/media-channel.c index 261386c..0698420 100644 --- a/src/media-channel.c +++ b/src/media-channel.c @@ -54,15 +54,19 @@ #define MAX_STREAMS 99 static void channel_iface_init (gpointer, gpointer); +static void dtmf_iface_init (gpointer, gpointer); static void media_signalling_iface_init (gpointer, gpointer); static void streamed_media_iface_init (gpointer, gpointer); static void session_handler_iface_init (gpointer, gpointer); G_DEFINE_TYPE_WITH_CODE (GabbleMediaChannel, gabble_media_channel, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL, channel_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL, + channel_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_CALL_STATE, gabble_media_channel_call_state_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_DTMF, + dtmf_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_GROUP, tp_group_mixin_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_HOLD, @@ -82,6 +86,7 @@ G_DEFINE_TYPE_WITH_CODE (GabbleMediaChannel, gabble_media_channel, static const gchar *gabble_media_channel_interfaces[] = { TP_IFACE_CHANNEL_INTERFACE_CALL_STATE, + TP_IFACE_CHANNEL_INTERFACE_DTMF, TP_IFACE_CHANNEL_INTERFACE_GROUP, TP_IFACE_CHANNEL_INTERFACE_HOLD, TP_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING, @@ -2793,6 +2798,53 @@ gabble_media_channel_error (TpSvcMediaSessionHandler *iface, tp_svc_media_session_handler_return_from_error (context); } +static void +gabble_media_channel_start_tone (TpSvcChannelInterfaceDTMF *iface, + guint stream_id, + guchar event, + DBusGMethodInvocation *context) +{ + GabbleMediaChannel *self = GABBLE_MEDIA_CHANNEL (iface); + GabbleMediaStream *stream; + GError *error = NULL; + + stream = _find_stream_by_id (self, stream_id, &error); + + if (stream == NULL) + { + dbus_g_method_return_error (context, error); + g_error_free (error); + return; + } + + gabble_media_stream_start_telephony_event (stream, event); + + tp_svc_channel_interface_dtmf_return_from_start_tone (context); +} + +static void +gabble_media_channel_stop_tone (TpSvcChannelInterfaceDTMF *iface, + guint stream_id, + DBusGMethodInvocation *context) +{ + GabbleMediaChannel *self = GABBLE_MEDIA_CHANNEL (iface); + GabbleMediaStream *stream; + GError *error = NULL; + + stream = _find_stream_by_id (self, stream_id, &error); + + if (stream == NULL) + { + dbus_g_method_return_error (context, error); + g_error_free (error); + return; + } + + gabble_media_stream_stop_telephony_event (stream); + + tp_svc_channel_interface_dtmf_return_from_stop_tone (context); +} + static void channel_iface_init (gpointer g_iface, gpointer iface_data) @@ -2809,6 +2861,18 @@ channel_iface_init (gpointer g_iface, gpointer iface_data) } static void +dtmf_iface_init (gpointer g_iface, gpointer iface_data) +{ + TpSvcChannelInterfaceDTMFClass *klass = (TpSvcChannelInterfaceDTMFClass *)g_iface; + +#define IMPLEMENT(x) tp_svc_channel_interface_dtmf_implement_##x (\ + klass, gabble_media_channel_##x) + IMPLEMENT(start_tone); + IMPLEMENT(stop_tone); +#undef IMPLEMENT +} + +static void streamed_media_iface_init (gpointer g_iface, gpointer iface_data) { TpSvcChannelTypeStreamedMediaClass *klass = diff --git a/src/media-stream.c b/src/media-stream.c index 45cf605..8dfb295 100644 --- a/src/media-stream.c +++ b/src/media-stream.c @@ -1847,3 +1847,21 @@ gabble_media_stream_get_content (GabbleMediaStream *self) */ return GABBLE_JINGLE_MEDIA_RTP (self->priv->content); } + +void +gabble_media_stream_start_telephony_event (GabbleMediaStream *self, guchar event) +{ + DEBUG ("called"); + + tp_svc_media_stream_handler_emit_start_telephony_event ( + (TpSvcMediaStreamHandler *)self, event); +} + +void +gabble_media_stream_stop_telephony_event (GabbleMediaStream *self) +{ + DEBUG ("called"); + + tp_svc_media_stream_handler_emit_stop_telephony_event ( + (TpSvcMediaStreamHandler *)self); +} diff --git a/src/media-stream.h b/src/media-stream.h index a43b575..bef983b 100644 --- a/src/media-stream.h +++ b/src/media-stream.h @@ -105,6 +105,9 @@ TpMediaStreamType gabble_media_stream_get_media_type (GabbleMediaStream *self); GabbleJingleMediaRtp *gabble_media_stream_get_content (GabbleMediaStream *self); +void gabble_media_stream_start_telephony_event (GabbleMediaStream *self, guchar event); +void gabble_media_stream_stop_telephony_event (GabbleMediaStream *self); + G_END_DECLS #endif /* #ifndef __GABBLE_MEDIA_STREAM_H__*/ -- 1.7.1