From b25ff16fb06615172bb7379fcb8087c358aa1984 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Mon, 27 Dec 2010 01:16:05 +0100 Subject: [PATCH] media: capture pipeline with SIGUSR1 Save graph to GST_DEBUG_DUMP_DOT_DIR when program receives SIGUSR1, so the media pipeline can be inspected at any time. --- src/purple/purple-media.c | 15 ++++++++++----- src/purple/purple-plugin.c | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/purple/purple-media.c b/src/purple/purple-media.c index 03e248ec..57e2b27e 100644 --- a/src/purple/purple-media.c +++ b/src/purple/purple-media.c @@ -102,17 +102,22 @@ on_state_changed_cb(SIPE_UNUSED_PARAMETER PurpleMedia *media, call->media_connected_cb(call); } -static void -capture_pipeline(PurpleMedia *media, gchar *label) { - PurpleMediaManager *manager = purple_media_get_manager(media); +/* Used externally in purple-plugin.c. This declaration stops the compiler + * complaining about missing prototype. */ +void capture_pipeline(gchar *label); + +void +capture_pipeline(gchar *label) { + PurpleMediaManager *manager = purple_media_manager_get(); GstElement *pipeline = purple_media_manager_get_pipeline(manager); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, label); } static void -on_error_cb(PurpleMedia *media, gchar *message, struct stream_info_context *ctx) +on_error_cb(SIPE_UNUSED_PARAMETER PurpleMedia *media, gchar *message, + struct stream_info_context *ctx) { - capture_pipeline(media, "ERROR"); + capture_pipeline("ERROR"); if (ctx->call->error_cb) ctx->call->error_cb(ctx->call, ctx->backend_media, message); diff --git a/src/purple/purple-plugin.c b/src/purple/purple-plugin.c index 31f31aee..d797ea7f 100644 --- a/src/purple/purple-plugin.c +++ b/src/purple/purple-plugin.c @@ -397,6 +397,15 @@ sipe_purple_get_account_text_table(SIPE_UNUSED_PARAMETER PurpleAccount *account) #if PURPLE_VERSION_CHECK(2,6,0) #ifdef HAVE_VV + +extern void capture_pipeline(gchar *label); + +static void +sipe_purple_sigusr1_handler(SIPE_UNUSED_PARAMETER int signum) +{ + capture_pipeline("PURPLE_SIPE_PIPELINE"); +} + static gboolean sipe_purple_initiate_media(PurpleAccount *account, const char *who, SIPE_UNUSED_PARAMETER PurpleMediaSessionType type) { @@ -511,11 +520,23 @@ static PurplePluginProtocolInfo sipe_prpl_info = /* PurplePluginInfo function calls & data structure */ static gboolean sipe_purple_plugin_load(SIPE_UNUSED_PARAMETER PurplePlugin *plugin) { +#ifdef HAVE_VV + struct sigaction action; + memset(&action, 0, sizeof (action)); + action.sa_handler = sipe_purple_sigusr1_handler; + sigaction(SIGUSR1, &action, NULL); +#endif return TRUE; } static gboolean sipe_purple_plugin_unload(SIPE_UNUSED_PARAMETER PurplePlugin *plugin) { +#ifdef HAVE_VV + struct sigaction action; + memset(&action, 0, sizeof (action)); + action.sa_handler = SIG_DFL; + sigaction(SIGUSR1, &action, NULL); +#endif return TRUE; } -- 2.11.4.GIT