From: Darren S. <ds...@us...> - 2004-12-22 02:30:50
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23366/src Modified Files: gtkvideo.c gtkvideo.h main.c utils.c Log Message: Generic post-plugin support for both audio and video (back-end code). This is probably broken, though it works with no plugins :-) Index: gtkvideo.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/gtkvideo.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- gtkvideo.c 22 Dec 2004 02:23:59 -0000 1.29 +++ gtkvideo.c 22 Dec 2004 02:30:38 -0000 1.30 @@ -139,6 +139,10 @@ /* tvtime */ xine_post_t *tvtime_plugin; gboolean deinterlace; + + /* other post-plugins (lists of xine_post_t) */ + GList *post_video, *post_audio; + gboolean post_video_enable, post_audio_enable; }; static int gtv_table_signals[LAST_SIGNAL] = { 0 }; @@ -733,22 +737,6 @@ return TRUE; } -static void gtv_wire_plugins (gtk_video_private_t *priv) -{ - xine_post_wire_video_port (xine_get_video_source (priv->stream), - priv->video_port); - - if (priv->deinterlace) - { - const char *const *out = xine_post_list_outputs (priv->tvtime_plugin); - const char *const *in = xine_post_list_inputs (priv->tvtime_plugin); - xine_post_wire_video_port (xine_post_output (priv->tvtime_plugin, *out), - priv->video_port); - xine_post_wire (xine_get_video_source (priv->stream), - xine_post_input (priv->tvtime_plugin, *in)); - } -} - #define MWM_HINTS_DECORATIONS (1L << 1) #define PROP_MWM_HINTS_ELEMENTS 5 typedef struct { @@ -928,8 +916,6 @@ priv->tvtime_plugin = xine_post_init (priv->xine, "tvtime", 0, NULL, &priv->video_port); - if (priv->tvtime_plugin) - gtv_wire_plugins (priv); /* * create mouse cursors @@ -1036,6 +1022,7 @@ priv->vis_plugin_id = NULL; priv->vis_plugin = NULL; priv->tvtime_plugin = NULL; + priv->post_audio = priv->post_video = NULL; if (video_driver_id) priv->video_driver_id = strdup (video_driver_id); @@ -1148,11 +1135,7 @@ pthread_mutex_lock (&priv->map_lock); XUnlockDisplay (priv->display); while (!priv->mapped) - { - puts ("waiting..."); pthread_cond_wait (&priv->map_cond, &priv->map_lock); - } - puts ("mapped"); pthread_mutex_unlock (&priv->map_lock); sched_yield (); @@ -1237,6 +1220,9 @@ return gtv->priv->auto_resize; } + +/* Plugins: audio visualisation */ + static void gtv_hide_vis (gtk_video_private_t *priv, xine_audio_port_t *audio_port) { @@ -1315,7 +1301,221 @@ return gtv_show_vis (priv, audio_port); } -/* FIXME: implement window for this (elsewhere) */ + +/* Plugins: shared post-plugin code */ + +static GList *gtv_create_plugins (gtk_video_private_t *priv, + const char *plugins, int type) +{ + GList *list = NULL; + + --plugins; + while (*++plugins) + { + char *next = strchr (plugins, ';') ? : (char *)plugins + strlen (plugins); + char *args = strchr (plugins, ':'); + char *name; + xine_post_t *plugin; + + if (!args || args > next) + args = next; + name = g_strndup (plugins, args - plugins); + plugin = xine_post_init (priv->xine, name, 0, NULL, NULL); + if (plugin) + { + if (plugin->type == type) + { + list = g_list_append (list, plugin); + args = g_strndup (args + 1, next - args - 1); + post_parse_set_parameters (plugin, args); + free (args); + } + else + { + fprintf (stderr, "gtkvideo: post-plugin '%s': wrong type\n", name); + xine_post_dispose (priv->xine, plugin); + } + } + else + fprintf (stderr, "gtkvideo: unknown post-plugin '%s'\n", name); + free (name); + plugins = next; + } + + return list; +} + + +/* Plugins: video post-plugins */ + +static void gtv_wire_plugins_video (gtk_video_private_t *priv) +{ + /* note: assumes default wiring */ + GList *list = priv->post_video_enable ? g_list_copy (priv->post_video) : NULL; + GList *item, *next = NULL; + + if (priv->tvtime_plugin) + list = g_list_prepend (list, priv->tvtime_plugin); + + item = g_list_last (list); + while (item) + { + const char *const *outs = xine_post_list_outputs (item->data); + xine_post_out_t *out = xine_post_output (item->data, *outs); + if (next) + xine_post_wire (out, xine_post_input (next->data, "video")); + else + xine_post_wire_video_port (out, priv->video_port); + next = item; + item = g_list_previous (item); + } + + if (next) + xine_post_wire (xine_get_video_source (priv->stream), + xine_post_input (next->data, "video")); + + g_list_free (list); +} + +static void gtv_unwire_plugins_video (gtk_video_private_t *priv) +{ + GList *item; + xine_post_wire_video_port (xine_get_video_source (priv->stream), + priv->video_port); + item = g_list_last (priv->post_video); + while (item) + { + const char *const *out = xine_post_list_outputs (item->data); + xine_post_wire (xine_post_output (item->data, *out), NULL); + item = g_list_previous (item); + } +} + +static void gtv_dispose_plugins_video (gtk_video_private_t *priv) +{ + gtv_unwire_plugins_video (priv); + g_list_foreach (priv->post_video, (GFunc) xine_post_dispose, NULL); + g_list_free (priv->post_video); + priv->post_video = NULL; +} + +void gtk_video_set_post_plugins_video (GtkVideo *gtv, const char *params) +{ + gtk_video_private_t *priv; + + g_return_if_fail (gtv != NULL); + g_return_if_fail (GTK_IS_VIDEO (gtv)); + priv = gtv->priv; + g_return_if_fail (priv->stream != NULL); + + gtv_dispose_plugins_video (priv); + priv->post_video = gtv_create_plugins (priv, params, + XINE_POST_TYPE_VIDEO_FILTER); + gtv_wire_plugins_video (priv); +} + +void gtk_video_set_use_post_plugins_video (GtkVideo *gtv, gboolean on) +{ + gtk_video_private_t *priv; + + g_return_if_fail (gtv != NULL); + g_return_if_fail (GTK_IS_VIDEO (gtv)); + priv = gtv->priv; + g_return_if_fail (priv->stream != NULL); + + gtv_unwire_plugins_video (priv); + priv->post_video_enable = on; + gtv_wire_plugins_video (priv); +} + + +/* Plugins: audio post-plugins */ + +static void gtv_wire_plugins_audio (gtk_video_private_t *priv, + xine_audio_port_t *audio_port) +{ + /* note: assumes default wiring */ + GList *item, *next = NULL; + + if (!priv->post_audio_enable) + return; + + item = g_list_last (priv->post_audio); + while (item) + { + const char *const *outs = xine_post_list_outputs (item->data); + xine_post_out_t *out = xine_post_output (item->data, *outs); + if (next) + xine_post_wire (out, xine_post_input (next->data, "audio")); + else + xine_post_wire_audio_port (out, audio_port); + next = item; + item = g_list_previous (item); + } + + if (next) + xine_post_wire (xine_get_audio_source (priv->stream), + xine_post_input (next->data, "audio")); +} + +static void gtv_unwire_plugins_audio (gtk_video_private_t *priv, + xine_audio_port_t *audio_port) +{ + GList *item; + xine_post_wire_audio_port (xine_get_video_source (priv->stream), + audio_port); + item = g_list_last (priv->post_audio); + while (item) + { + const char *const *out = xine_post_list_outputs (item->data); + xine_post_wire (xine_post_output (item->data, *out), NULL); + item = g_list_previous (item); + } +} + +static void gtv_dispose_plugins_audio (gtk_video_private_t *priv, + xine_audio_port_t *audio_port) +{ + gtv_unwire_plugins_audio (priv, audio_port); + g_list_foreach (priv->post_audio, (GFunc) xine_post_dispose, NULL); + g_list_free (priv->post_audio); + priv->post_audio = NULL; +} + +void gtk_video_set_post_plugins_audio (GtkVideo *gtv, const char *params, + xine_audio_port_t *audio_port) +{ + gtk_video_private_t *priv; + + g_return_if_fail (gtv != NULL); + g_return_if_fail (GTK_IS_VIDEO (gtv)); + priv = gtv->priv; + g_return_if_fail (priv->stream != NULL); + + gtv_dispose_plugins_audio (priv, audio_port); + priv->post_audio = gtv_create_plugins (priv, params, + XINE_POST_TYPE_AUDIO_FILTER); + gtv_wire_plugins_audio (priv, audio_port); +} + +void gtk_video_set_use_post_plugins_audio (GtkVideo *gtv, gboolean on, + xine_audio_port_t *audio_port) +{ + gtk_video_private_t *priv; + + g_return_if_fail (gtv != NULL); + g_return_if_fail (GTK_IS_VIDEO (gtv)); + priv = gtv->priv; + g_return_if_fail (priv->stream != NULL); + + gtv_unwire_plugins_audio (priv, audio_port); + priv->post_audio_enable = on; + gtv_wire_plugins_audio (priv, audio_port); +} + + +/* Plugins: deinterlace post-plugin */ + void gtk_video_set_tvtime (GtkVideo *gtv, const char *params) { gtk_video_private_t *priv; @@ -1348,8 +1548,11 @@ g_return_if_fail (priv->stream != NULL); priv->deinterlace = set; - if (priv->tvtime_plugin) - gtv_wire_plugins (priv); + if (!priv->tvtime_plugin) + { + gtv_unwire_plugins_video (priv); + gtv_wire_plugins_video (priv); + } else xine_set_param (priv->stream, XINE_PARAM_VO_DEINTERLACE, set); } Index: gtkvideo.h =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/gtkvideo.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- gtkvideo.h 20 Dec 2004 22:22:25 -0000 1.6 +++ gtkvideo.h 22 Dec 2004 02:30:38 -0000 1.7 @@ -89,6 +89,13 @@ gboolean gtk_video_show_vis (GtkVideo *, xine_audio_port_t **); void gtk_video_hide_vis (GtkVideo *, xine_audio_port_t *); + void gtk_video_set_post_plugins_video (GtkVideo *, const char *); + void gtk_video_set_post_plugins_audio (GtkVideo *, const char *, + xine_audio_port_t *); + void gtk_video_set_use_post_plugins_video (GtkVideo *, gboolean); + void gtk_video_set_use_post_plugins_audio (GtkVideo *, gboolean, + xine_audio_port_t *); + void gtk_video_set_tvtime (GtkVideo *, const char *); void gtk_video_set_deinterlace (GtkVideo *, gboolean); gboolean gtk_video_get_deinterlace (GtkVideo *); Index: main.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/main.c,v retrieving revision 1.105 retrieving revision 1.106 diff -u -r1.105 -r1.106 --- main.c 20 Dec 2004 22:22:25 -0000 1.105 +++ main.c 22 Dec 2004 02:30:38 -0000 1.106 @@ -184,12 +184,26 @@ static gboolean post_init_configure (void) { xine_cfg_entry_t entry; + GtkVideo *v = GTK_VIDEO(gtv); if (xine_config_lookup_entry (xine, "gui.deinterlace_plugin", &entry)) - gtk_video_set_tvtime (gtv, entry.str_value); + gtk_video_set_tvtime (v, entry.str_value); if (xine_config_lookup_entry (xine, "gui.deinterlace_by_default", &entry)) - gtk_video_set_deinterlace (gtv, entry.num_value); + gtk_video_set_deinterlace (v, entry.num_value); + + if (xine_config_lookup_entry (xine, "gui.post_plugins.video", &entry)) + gtk_video_set_post_plugins_video (v, entry.str_value); + + if (xine_config_lookup_entry (xine, "gui.post_plugins.audio", &entry)) + gtk_video_set_post_plugins_audio (v, entry.str_value, audio_port); + + if (xine_config_lookup_entry (xine, "gui.post_plugins.video_enable", &entry)) + gtk_video_set_use_post_plugins_video (v, entry.num_value); + + if (xine_config_lookup_entry (xine, "gui.post_plugins.audio", &entry)) + gtk_video_set_use_post_plugins_audio (v, entry.num_value, audio_port); + return FALSE; } Index: utils.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/utils.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- utils.c 20 Dec 2004 22:22:26 -0000 1.41 +++ utils.c 22 Dec 2004 02:30:38 -0000 1.42 @@ -742,11 +742,36 @@ static void post_deinterlace_plugin_cb (void *data, xine_cfg_entry_t *cfg) { - /* FIXME */ if (gtv) gtk_video_set_tvtime (GTK_VIDEO(gtv), cfg->str_value); } +static void post_plugins_video_cb (void *data, xine_cfg_entry_t *cfg) +{ + if (gtv) + gtk_video_set_post_plugins_video (GTK_VIDEO(gtv), cfg->str_value); +} + +static void post_plugins_audio_cb (void *data, xine_cfg_entry_t *cfg) +{ + if (gtv) + gtk_video_set_post_plugins_audio (GTK_VIDEO(gtv), cfg->str_value, + audio_port); +} + +static void post_plugins_video_use_cb (void *data, xine_cfg_entry_t *cfg) +{ + if (gtv) + gtk_video_set_use_post_plugins_video (GTK_VIDEO(gtv), cfg->num_value); +} + +static void post_plugins_audio_use_cb (void *data, xine_cfg_entry_t *cfg) +{ + if (gtv) + gtk_video_set_use_post_plugins_audio (GTK_VIDEO(gtv), cfg->num_value, + audio_port); +} + void ui_preferences_register (xine_t *this) { static char *experience_labels[] = { @@ -778,12 +803,6 @@ } /* Register some front-end widget options */ - xine_config_register_bool - (this, "gui.deinterlace_by_default", 0, - _("enable deinterlacing by default"), - _("Deinterlace plugin will be enabled on startup. Progressive streams are automatically detected with no performance penalty."), - 0, NULL, NULL); - xine_config_register_string (this, "gui.deinterlace_plugin", "tvtime:method=LinearBlend,cheap_mode=1,pulldown=none,use_progressive_frame_flag=1", @@ -791,6 +810,28 @@ _("Currently, only tvtime is supported."), 30, post_deinterlace_plugin_cb, CONFIG_DATA_NONE); + xine_config_register_string + (this, "gui.post_plugins.video", "", + _("Video post-processing plugins' names and parameters."), + _("Format: plugin:arg=value,arg=value,...;plugin:..."), + 30, post_plugins_video_cb, CONFIG_DATA_NONE); + + xine_config_register_bool + (this, "gui.post_plugins.video_enable", 0, + _("Enable video post-processing."), NULL, + 30, post_plugins_video_use_cb, NULL); + + xine_config_register_string + (this, "gui.post_plugins.audio", "", + _("Audio post-processing plugins' names and parameters."), + _("Format: plugin:arg=value,arg=value,...;plugin:..."), + 30, post_plugins_audio_cb, CONFIG_DATA_NONE); + + xine_config_register_bool + (this, "gui.post_plugins.audio_enable", 0, + _("Enable audio post-processing."), NULL, + 30, post_plugins_audio_use_cb, NULL); + xine_config_register_enum (this, "gui.fullscreen_toolbar", 1, tbar_pos_labels, _("default position & visibility of the full-screen toolbar"), |