2001-12-23 17:27:58 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2001 Steve Baker <stevebaker_org@yahoo.co.uk>
|
|
|
|
*
|
|
|
|
* gstdparammanager.c: Dynamic Parameter group functionality
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2002-05-02 13:39:39 +00:00
|
|
|
#include "dparammanager.h"
|
2001-12-23 17:27:58 +00:00
|
|
|
#include <gst/gstelement.h>
|
2004-02-03 03:31:26 +00:00
|
|
|
#include <gst/gstmarshal.h>
|
2001-12-23 17:27:58 +00:00
|
|
|
#include <gst/gstinfo.h>
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (_gst_control_debug);
|
2004-07-02 13:24:33 +00:00
|
|
|
#define GST_CAT_DEFAULT _gst_control_debug
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2002-08-11 12:18:03 +00:00
|
|
|
static GHashTable *_element_registry = NULL;
|
2002-04-14 10:08:21 +00:00
|
|
|
static gboolean _gst_dpman_init_done = FALSE;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-04-02 09:03:21 +00:00
|
|
|
NEW_REQUIRED_DPARAM,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_dpman_class_init (GstDParamManagerClass * klass);
|
|
|
|
static void gst_dpman_init (GstDParamManager * dpman);
|
|
|
|
static void gst_dpman_dispose (GObject * object);
|
|
|
|
static GstDParamWrapper *gst_dpman_new_wrapper (GstDParamManager * dpman,
|
|
|
|
GParamSpec * param_spec, gchar * unit_name,
|
|
|
|
GstDPMUpdateMethod update_method);
|
|
|
|
static GstDParamWrapper *gst_dpman_get_wrapper (GstDParamManager * dpman,
|
2004-07-14 14:55:57 +00:00
|
|
|
const gchar * dparam_name);
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_dpman_state_change (GstElement * element, gint old_state,
|
|
|
|
gint new_state, GstDParamManager * dpman);
|
|
|
|
static gboolean gst_dpman_preprocess_synchronous (GstDParamManager * dpman,
|
|
|
|
guint frames, gint64 timestamp);
|
|
|
|
static gboolean gst_dpman_preprocess_asynchronous (GstDParamManager * dpman,
|
|
|
|
guint frames, gint64 timestamp);
|
|
|
|
static gboolean gst_dpman_process_asynchronous (GstDParamManager * dpman,
|
|
|
|
guint frame_count);
|
|
|
|
static gboolean gst_dpman_preprocess_noop (GstDParamManager * dpman,
|
|
|
|
guint frames, gint64 timestamp);
|
|
|
|
static gboolean gst_dpman_process_noop (GstDParamManager * dpman,
|
|
|
|
guint frame_count);
|
|
|
|
static void gst_dpman_setup_synchronous (GstDParamManager * dpman);
|
|
|
|
static void gst_dpman_setup_asynchronous (GstDParamManager * dpman);
|
|
|
|
static void gst_dpman_setup_disabled (GstDParamManager * dpman);
|
|
|
|
static void gst_dpman_teardown_synchronous (GstDParamManager * dpman);
|
|
|
|
static void gst_dpman_teardown_asynchronous (GstDParamManager * dpman);
|
|
|
|
static void gst_dpman_teardown_disabled (GstDParamManager * dpman);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
|
|
|
static GObjectClass *parent_class;
|
2002-04-02 09:03:21 +00:00
|
|
|
static guint gst_dpman_signals[LAST_SIGNAL] = { 0 };
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
_gst_dpman_initialize ()
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
if (_gst_dpman_init_done)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_gst_dpman_init_done = TRUE;
|
|
|
|
_element_registry = g_hash_table_new (NULL, NULL);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
gst_dpman_get_type (void)
|
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
static GType dpman_type = 0;
|
|
|
|
|
|
|
|
if (!dpman_type) {
|
|
|
|
static const GTypeInfo dpman_info = {
|
|
|
|
sizeof (GstDParamManagerClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_dpman_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstDParamManager),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_dpman_init,
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpman_type =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_register_static (GST_TYPE_OBJECT, "GstDParamManager",
|
|
|
|
&dpman_info, 0);
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
return dpman_type;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_class_init (GstDParamManagerClass * klass)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstObjectClass *gstobject_class;
|
|
|
|
GObjectClass *gobject_class;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gstobject_class = (GstObjectClass *) klass;
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gobject_class->dispose = gst_dpman_dispose;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
klass->modes = g_hash_table_new (g_str_hash, g_str_equal);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_register_mode (klass, "synchronous",
|
|
|
|
gst_dpman_preprocess_synchronous, gst_dpman_process_noop,
|
|
|
|
gst_dpman_setup_synchronous, gst_dpman_teardown_synchronous);
|
|
|
|
gst_dpman_register_mode (klass, "asynchronous",
|
|
|
|
gst_dpman_preprocess_asynchronous, gst_dpman_process_asynchronous,
|
|
|
|
gst_dpman_setup_asynchronous, gst_dpman_teardown_asynchronous);
|
|
|
|
gst_dpman_register_mode (klass, "disabled",
|
|
|
|
gst_dpman_preprocess_noop, gst_dpman_process_noop,
|
|
|
|
gst_dpman_setup_disabled, gst_dpman_teardown_disabled);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2002-04-02 09:03:21 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_signals[NEW_REQUIRED_DPARAM] =
|
|
|
|
g_signal_new ("new-required-dparam", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDParamManagerClass,
|
2004-03-15 19:27:17 +00:00
|
|
|
new_required_dparam), NULL, NULL, gst_marshal_VOID__STRING,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_STRING);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_init (GstDParamManager * dpman)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DPMAN_DPARAMS (dpman) = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
GST_DPMAN_DPARAMS_LIST (dpman) = NULL;
|
|
|
|
GST_DPMAN_PARENT (dpman) = NULL;
|
|
|
|
GST_DPMAN_MODE_NAME (dpman) = NULL;
|
|
|
|
GST_DPMAN_MODE (dpman) = NULL;
|
|
|
|
GST_DPMAN_RATE (dpman) = 0;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_new:
|
2004-07-02 13:24:33 +00:00
|
|
|
* @name: name of the new #GstDParamManager instance to create
|
|
|
|
* @parent: #GstElement which creates this instance
|
2001-12-23 17:27:58 +00:00
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Creates a new instance of a dynamic parameter manager.
|
|
|
|
*
|
2004-07-02 13:24:33 +00:00
|
|
|
* Returns: a new instance of #GstDParamManager.
|
2001-12-23 17:27:58 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamManager *
|
|
|
|
gst_dpman_new (gchar * name, GstElement * parent)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamManager *dpman;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpman = g_object_new (gst_dpman_get_type (), NULL);
|
|
|
|
gst_object_set_name (GST_OBJECT (dpman), name);
|
|
|
|
gst_dpman_set_parent (dpman, parent);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_set_mode (dpman, "disabled");
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return dpman;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_dispose (GObject * object)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
|
|
|
/* GstDParamManager *dpman = GST_DPMAN(object); */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_add_required_dparam_callback:
|
|
|
|
* @dpman: GstDParamManager instance
|
2004-07-14 14:55:57 +00:00
|
|
|
* @param_spec: the spacification of the new dparam
|
|
|
|
* @unit_name: the unit name of the dparam
|
2001-12-23 17:27:58 +00:00
|
|
|
* @update_func: callback to update the element with the new value
|
|
|
|
* @update_data: will be included in the call to update_func
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Add a mandatory dynamic parameter to the manager, where the value can be
|
|
|
|
* updated by calling the supplied callback function.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: true if it was successfully added
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
gboolean
|
|
|
|
gst_dpman_add_required_dparam_callback (GstDParamManager * dpman,
|
|
|
|
GParamSpec * param_spec,
|
|
|
|
gchar * unit_name, GstDPMUpdateFunction update_func, gpointer update_data)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpman != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
|
|
|
|
g_return_val_if_fail (update_func != NULL, FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap =
|
|
|
|
gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_CALLBACK);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpwrap != NULL, FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("adding required callback dparam '%s'",
|
|
|
|
g_param_spec_get_name (param_spec));
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap->update_func = update_func;
|
|
|
|
dpwrap->update_data = update_data;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0,
|
|
|
|
g_param_spec_get_name (param_spec));
|
|
|
|
|
|
|
|
return TRUE;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_add_required_dparam_direct:
|
|
|
|
* @dpman: GstDParamManager instance
|
2004-07-14 14:55:57 +00:00
|
|
|
* @param_spec: the spacification of the new dparam
|
|
|
|
* @unit_name: the unit name of the dparam
|
2001-12-23 17:27:58 +00:00
|
|
|
* @update_data: pointer to the member to be updated
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Add a mandatory dynamic parameter to the manager, where the value can be
|
|
|
|
* updated by directly storing it into the provided memory location.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: true if it was successfully added
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
gboolean
|
|
|
|
gst_dpman_add_required_dparam_direct (GstDParamManager * dpman,
|
|
|
|
GParamSpec * param_spec, gchar * unit_name, gpointer update_data)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpman != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
|
|
|
|
g_return_val_if_fail (update_data != NULL, FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap =
|
|
|
|
gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_DIRECT);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpwrap != NULL, FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("adding required direct dparam '%s'",
|
|
|
|
g_param_spec_get_name (param_spec));
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap->update_data = update_data;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0,
|
|
|
|
g_param_spec_get_name (param_spec));
|
2002-04-02 09:03:21 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return TRUE;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_add_required_dparam_array:
|
|
|
|
* @dpman: GstDParamManager instance
|
2004-07-14 14:55:57 +00:00
|
|
|
* @param_spec: the spacification of the new dparam
|
|
|
|
* @unit_name: the unit name of the dparam
|
2001-12-23 17:27:58 +00:00
|
|
|
* @update_data: pointer to where the array will be stored
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Add a mandatory dynamic parameter to the manager, where the values can be
|
|
|
|
* updated by storing them into the provided memory location.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: true if it was successfully added
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
gboolean
|
|
|
|
gst_dpman_add_required_dparam_array (GstDParamManager * dpman,
|
|
|
|
GParamSpec * param_spec, gchar * unit_name, gpointer update_data)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpman != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
|
|
|
|
g_return_val_if_fail (update_data != NULL, FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap =
|
|
|
|
gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_ARRAY);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpwrap != NULL, FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("adding required array dparam '%s'",
|
|
|
|
g_param_spec_get_name (param_spec));
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap->update_data = update_data;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0,
|
|
|
|
g_param_spec_get_name (param_spec));
|
2002-04-02 09:03:21 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return TRUE;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_remove_required_dparam:
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @dparam_name: the name of an existing parameter
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Removes the named dynamic parameter from the manager.
|
2001-12-23 17:27:58 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_remove_required_dparam (GstDParamManager * dpman,
|
|
|
|
const gchar * dparam_name)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (dpman != NULL);
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
|
|
|
g_return_if_fail (dparam_name != NULL);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (dpwrap != NULL);
|
|
|
|
g_return_if_fail (dpwrap->dparam == NULL);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("removing required dparam: %s", dparam_name);
|
|
|
|
|
|
|
|
g_hash_table_remove (GST_DPMAN_DPARAMS (dpman), dparam_name);
|
|
|
|
GST_DPMAN_DPARAMS_LIST (dpman) =
|
|
|
|
g_list_remove (GST_DPMAN_DPARAMS_LIST (dpman), dpwrap);
|
|
|
|
|
|
|
|
g_free (dpwrap->value);
|
|
|
|
g_free (dpwrap);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_attach_dparam:
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @dparam_name: a name previously added with gst_dpman_add_required_dparam
|
|
|
|
* @dparam: GstDParam instance to attach
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Adding a parameter controller to a dynamic parameter. Whenever the controller
|
|
|
|
* changes, the dynamic parameter of the GstElement will follow.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: true if it was successfully attached
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
gboolean
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_attach_dparam (GstDParamManager * dpman, const gchar * dparam_name,
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParam * dparam)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpman != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
|
|
|
|
g_return_val_if_fail (dparam_name != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (dparam != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_DPARAM (dparam), FALSE);
|
|
|
|
g_return_val_if_fail (dparam != NULL, FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpwrap != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (dpwrap->value != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (G_PARAM_SPEC_VALUE_TYPE (dpwrap->param_spec) ==
|
|
|
|
GST_DPARAM_TYPE (dparam), FALSE);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpwrap->dparam = dparam;
|
|
|
|
gst_dparam_attach (dparam, dpman, dpwrap->param_spec, dpwrap->unit_name);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return TRUE;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_detach_dparam:
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @dparam_name: the name of a parameter with a previously attached GstDParam
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Removing a parameter controller from a dynamic parameter.
|
2001-12-23 17:27:58 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_detach_dparam (GstDParamManager * dpman, const gchar * dparam_name)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
|
|
|
|
g_return_if_fail (dpman != NULL);
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
|
|
|
g_return_if_fail (dparam_name != NULL);
|
|
|
|
|
|
|
|
dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
|
|
|
|
g_return_if_fail (dpwrap);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dparam_detach (dpwrap->dparam);
|
|
|
|
dpwrap->dparam = NULL;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_get_dparam:
|
|
|
|
* @dpman: GstDParamManager instance
|
2004-07-14 14:55:57 +00:00
|
|
|
* @dparam_name: the name of an existing dparam instance
|
2001-12-23 17:27:58 +00:00
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Fetches a dparam object that is registered by manager under the given name.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: the dparam with the given name - or NULL otherwise
|
|
|
|
*/
|
|
|
|
GstDParam *
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_get_dparam (GstDParamManager * dpman, const gchar * dparam_name)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpman != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
|
2004-07-14 14:55:57 +00:00
|
|
|
g_return_val_if_fail (dparam_name != NULL, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-07-14 14:55:57 +00:00
|
|
|
dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpwrap != NULL, NULL);
|
|
|
|
|
|
|
|
return dpwrap->dparam;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_get_dparam_type:
|
|
|
|
* @dpman: GstDParamManager instance
|
2004-07-14 14:55:57 +00:00
|
|
|
* @dparam_name: the name of dparam
|
2001-12-23 17:27:58 +00:00
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Fetches the type of the supplied dynamic parameter.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: the type that this dparam requires/uses
|
|
|
|
*/
|
|
|
|
GType
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_get_dparam_type (GstDParamManager * dpman, const gchar * dparam_name)
|
2004-03-13 15:27:01 +00:00
|
|
|
{
|
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
|
|
|
|
g_return_val_if_fail (dpman != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), 0);
|
2004-07-14 14:55:57 +00:00
|
|
|
g_return_val_if_fail (dparam_name != NULL, 0);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-07-14 14:55:57 +00:00
|
|
|
dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpwrap != NULL, 0);
|
|
|
|
|
|
|
|
return G_VALUE_TYPE (dpwrap->value);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
2004-07-14 14:55:57 +00:00
|
|
|
/**
|
|
|
|
* gst_dpman_list_dparam_specs:
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Fetches the list of parameter specifications, that this manager maintains.
|
|
|
|
*
|
|
|
|
* Returns: the the parameter specifications as a NULL terminated array
|
2004-07-14 14:55:57 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GParamSpec **
|
|
|
|
gst_dpman_list_dparam_specs (GstDParamManager * dpman)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
GList *dwraps;
|
|
|
|
GParamSpec **param_specs;
|
|
|
|
guint x = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (dpman != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
|
|
|
|
|
|
|
|
dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
param_specs = g_new0 (GParamSpec *, g_list_length (dwraps) + 1);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (dwraps) {
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
|
|
|
param_specs[x++] = dpwrap->param_spec;
|
|
|
|
dwraps = g_list_next (dwraps);
|
|
|
|
}
|
|
|
|
return param_specs;
|
|
|
|
}
|
|
|
|
|
2004-07-14 14:55:57 +00:00
|
|
|
/**
|
|
|
|
* gst_dpman_get_param_spec:
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @dparam_name: the name of dparam
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Fetches a single parameter specification by its dparam name.
|
|
|
|
*
|
2004-07-14 14:55:57 +00:00
|
|
|
* Returns: the the parameter specifications for a given name
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GParamSpec *
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_get_param_spec (GstDParamManager * dpman, const gchar * dparam_name)
|
2004-03-13 15:27:01 +00:00
|
|
|
{
|
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
|
|
|
|
g_return_val_if_fail (dpman != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
|
|
|
|
g_return_val_if_fail (dparam_name != NULL, NULL);
|
|
|
|
|
|
|
|
dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
|
|
|
|
return dpwrap->param_spec;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
2004-07-14 14:55:57 +00:00
|
|
|
/**
|
|
|
|
* gst_dpman_set_rate:
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @rate: the new the frame/sample rate
|
2004-07-15 12:51:59 +00:00
|
|
|
*
|
|
|
|
* Sets the frame or sampling rate used by the machine.
|
|
|
|
*
|
2004-07-14 14:55:57 +00:00
|
|
|
*/
|
2002-05-29 18:51:27 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_set_rate (GstDParamManager * dpman, gint rate)
|
2002-05-29 18:51:27 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
|
|
|
GST_DPMAN_RATE (dpman) = rate;
|
2002-05-29 18:51:27 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 17:27:58 +00:00
|
|
|
/**
|
|
|
|
* gst_dpman_register_mode
|
|
|
|
* @klass: GstDParamManagerClass class instance
|
|
|
|
* @modename: the unique name of the new mode
|
|
|
|
* @preprocessfunc: the function which will be called before each buffer is processed
|
|
|
|
* @processfunc: the function which may be called throughout the processing of a buffer
|
|
|
|
* @setupfunc: the function which initialises the mode when activated
|
|
|
|
* @teardownfunc: the function which frees any resources the mode uses
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Registers a run-mode for the dparam manager. Each such mode has a defined
|
|
|
|
* run-time behaviour - that is, they differ in the way dynamic parameter
|
|
|
|
* changes are pushed into the underlying GstElements.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_register_mode (GstDParamManagerClass * klass,
|
|
|
|
gchar * modename,
|
|
|
|
GstDPMModePreProcessFunction preprocessfunc,
|
|
|
|
GstDPMModeProcessFunction processfunc,
|
|
|
|
GstDPMModeSetupFunction setupfunc, GstDPMModeTeardownFunction teardownfunc)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDPMMode *mode;
|
|
|
|
|
|
|
|
g_return_if_fail (klass != NULL);
|
|
|
|
g_return_if_fail (modename != NULL);
|
|
|
|
g_return_if_fail (GST_IS_DPMAN_CLASS (klass));
|
|
|
|
|
|
|
|
mode = g_new0 (GstDPMMode, 1);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
mode->preprocessfunc = preprocessfunc;
|
|
|
|
mode->processfunc = processfunc;
|
|
|
|
mode->setupfunc = setupfunc;
|
|
|
|
mode->teardownfunc = teardownfunc;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_hash_table_insert (klass->modes, modename, mode);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_set_mode
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @modename: the name of the mode to use
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Activate one of the registered modes.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: TRUE if the mode was set, FALSE otherwise
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_set_mode (GstDParamManager * dpman, gchar * modename)
|
|
|
|
{
|
|
|
|
GstDPMMode *mode = NULL;
|
|
|
|
GstDParamManagerClass *oclass;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (dpman != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
|
|
|
|
g_return_val_if_fail (modename != NULL, FALSE);
|
|
|
|
|
|
|
|
oclass = (GstDParamManagerClass *) (G_OBJECT_GET_CLASS (dpman));
|
|
|
|
|
|
|
|
mode = g_hash_table_lookup (oclass->modes, modename);
|
|
|
|
g_return_val_if_fail (mode != NULL, FALSE);
|
|
|
|
|
|
|
|
if (GST_DPMAN_MODE (dpman) == mode) {
|
|
|
|
GST_DEBUG ("mode %s already set", modename);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG ("setting mode to %s", modename);
|
|
|
|
if (GST_DPMAN_MODE (dpman) && GST_DPMAN_TEARDOWNFUNC (dpman)) {
|
|
|
|
GST_DPMAN_TEARDOWNFUNC (dpman) (dpman);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DPMAN_MODE (dpman) = mode;
|
|
|
|
|
|
|
|
if (GST_DPMAN_SETUPFUNC (dpman)) {
|
|
|
|
GST_DPMAN_SETUPFUNC (dpman) (dpman);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_set_parent
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @parent: the element that this GstDParamManager belongs to
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Set a GstElement that parameters this manager should handle.
|
2001-12-23 17:27:58 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_set_parent (GstDParamManager * dpman, GstElement * parent)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (dpman != NULL);
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
|
|
|
g_return_if_fail (parent != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (parent));
|
|
|
|
|
|
|
|
g_hash_table_insert (_element_registry, parent, dpman);
|
|
|
|
gst_object_set_parent (GST_OBJECT (dpman), GST_OBJECT (parent));
|
|
|
|
g_signal_connect (G_OBJECT (parent), "state_change",
|
|
|
|
G_CALLBACK (gst_dpman_state_change), dpman);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dpman_get_manager
|
|
|
|
* @parent: the element that the desired GstDParamManager belongs to
|
|
|
|
*
|
2004-07-15 12:51:59 +00:00
|
|
|
* Fetch the GstElement that parameters are handled by this manager.
|
|
|
|
*
|
2001-12-23 17:27:58 +00:00
|
|
|
* Returns: the GstDParamManager which belongs to this element or NULL
|
|
|
|
* if it doesn't exist
|
|
|
|
*/
|
|
|
|
GstDParamManager *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_get_manager (GstElement * parent)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstDParamManager *dpman;
|
|
|
|
|
|
|
|
g_return_val_if_fail (parent != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (parent), NULL);
|
|
|
|
|
|
|
|
dpman = (GstDParamManager *) g_hash_table_lookup (_element_registry, parent);
|
|
|
|
return dpman;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
2002-04-02 09:03:21 +00:00
|
|
|
/**
|
|
|
|
* gst_dpman_bypass_dparam:
|
|
|
|
* @dpman: GstDParamManager instance
|
|
|
|
* @dparam_name: the name of dparam
|
|
|
|
*
|
|
|
|
* If a dparam is attached to this dparam_name, it will be detached
|
|
|
|
* and a warning will be issued. This should be called in the _set_property
|
|
|
|
* function of an element if the value it changes is also changed by a dparam.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_bypass_dparam (GstDParamManager * dpman, const gchar * dparam_name)
|
2004-03-13 15:27:01 +00:00
|
|
|
{
|
|
|
|
GstDParamWrapper *dpwrap;
|
2002-04-02 09:03:21 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (dpman != NULL);
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
|
|
|
g_return_if_fail (dparam_name != NULL);
|
|
|
|
|
|
|
|
dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
|
|
|
|
g_return_if_fail (dpwrap != NULL);
|
|
|
|
|
|
|
|
if (dpwrap->dparam != NULL) {
|
|
|
|
g_warning ("Bypassing attached dparam '%s'. It will be detached",
|
2004-03-15 19:27:17 +00:00
|
|
|
dparam_name);
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_dpman_detach_dparam (dpman, dparam_name);
|
|
|
|
}
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
2004-07-15 12:51:59 +00:00
|
|
|
// internal methods
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static GstDParamWrapper *
|
2004-07-14 14:55:57 +00:00
|
|
|
gst_dpman_get_wrapper (GstDParamManager * dpman, const gchar * dparam_name)
|
2004-03-13 15:27:01 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (dpman != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
|
|
|
|
g_return_val_if_fail (dparam_name != NULL, NULL);
|
|
|
|
|
|
|
|
return g_hash_table_lookup (GST_DPMAN_DPARAMS (dpman), dparam_name);
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static GstDParamWrapper *
|
|
|
|
gst_dpman_new_wrapper (GstDParamManager * dpman,
|
|
|
|
GParamSpec * param_spec,
|
|
|
|
gchar * unit_name, GstDPMUpdateMethod update_method)
|
|
|
|
{
|
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
gchar *dparam_name;
|
|
|
|
|
|
|
|
g_return_val_if_fail (dpman != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
|
|
|
|
g_return_val_if_fail (param_spec != NULL, NULL);
|
|
|
|
g_return_val_if_fail (gst_unitconv_unit_exists (unit_name), NULL);
|
|
|
|
|
|
|
|
dparam_name = g_strdup (g_param_spec_get_name (param_spec));
|
|
|
|
g_return_val_if_fail (gst_dpman_get_wrapper (dpman, dparam_name) == NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dpwrap = g_new0 (GstDParamWrapper, 1);
|
|
|
|
dpwrap->update_method = update_method;
|
|
|
|
dpwrap->value = g_new0 (GValue, 1);
|
|
|
|
g_value_init (dpwrap->value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
|
|
|
|
dpwrap->param_spec = param_spec;
|
|
|
|
dpwrap->unit_name = unit_name;
|
|
|
|
|
|
|
|
g_hash_table_insert (GST_DPMAN_DPARAMS (dpman), dparam_name, dpwrap);
|
|
|
|
GST_DPMAN_DPARAMS_LIST (dpman) =
|
|
|
|
g_list_append (GST_DPMAN_DPARAMS_LIST (dpman), dpwrap);
|
|
|
|
|
|
|
|
return dpwrap;
|
|
|
|
}
|
2002-05-05 15:39:37 +00:00
|
|
|
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_dpman_state_change (GstElement * element, gint old_state, gint new_state,
|
|
|
|
GstDParamManager * dpman)
|
|
|
|
{
|
|
|
|
GList *dwraps;
|
|
|
|
GstDParam *dparam;
|
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
|
|
|
|
g_return_if_fail (dpman != NULL);
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
|
|
|
|
|
|
|
if (new_state == GST_STATE_PLAYING) {
|
|
|
|
GST_DEBUG ("initialising params");
|
|
|
|
|
|
|
|
|
|
|
|
/* force all params to be updated */
|
|
|
|
dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
|
|
|
|
while (dwraps) {
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
|
|
|
dparam = dpwrap->dparam;
|
|
|
|
|
|
|
|
if (dparam) {
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
|
|
|
|
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = 0LL;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
/* some dparams treat the first update after the pipeline starts differently */
|
|
|
|
dpwrap->update_info = GST_DPARAM_UPDATE_FIRST;
|
|
|
|
dwraps = g_list_next (dwraps);
|
|
|
|
}
|
|
|
|
}
|
2002-05-29 18:51:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static inline void
|
|
|
|
gst_dpman_inline_direct_update (GValue * value, gpointer data)
|
2002-05-29 18:51:27 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
switch (G_VALUE_TYPE (value)) {
|
|
|
|
case G_TYPE_INT:
|
|
|
|
*(gint *) data = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case G_TYPE_INT64:
|
|
|
|
*(gint64 *) data = g_value_get_int64 (value);
|
|
|
|
break;
|
|
|
|
case G_TYPE_FLOAT:
|
|
|
|
*(gfloat *) data = g_value_get_float (value);
|
|
|
|
break;
|
|
|
|
case G_TYPE_DOUBLE:
|
|
|
|
*(double *) data = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-05-29 18:51:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static gboolean
|
|
|
|
gst_dpman_preprocess_synchronous (GstDParamManager * dpman, guint frames,
|
|
|
|
gint64 timestamp)
|
2002-05-29 18:51:27 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *dwraps;
|
|
|
|
GstDParamWrapper *dpwrap;
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
/* this basically means don't call GST_DPMAN_PREPROCESS at all */
|
|
|
|
dpman->next_update_frame = frames;
|
|
|
|
dpman->frames_to_process = frames;
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
/* now check whether any dparams are ready for an update */
|
|
|
|
dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
|
|
|
|
while (dwraps) {
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (dpwrap->dparam &&
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) &&
|
|
|
|
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam) <= timestamp) {
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
switch (dpwrap->update_method) {
|
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
/* direct method - set the value directly in the struct of the element */
|
|
|
|
case GST_DPMAN_DIRECT:
|
|
|
|
GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value,
|
|
|
|
dpwrap->update_info);
|
|
|
|
GST_DEBUG ("doing direct update");
|
|
|
|
|
|
|
|
gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* callback method - call the element's callback so it can do what it likes */
|
|
|
|
case GST_DPMAN_CALLBACK:
|
|
|
|
GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value,
|
|
|
|
dpwrap->update_info);
|
|
|
|
GST_DEBUG ("doing callback update");
|
|
|
|
|
|
|
|
GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GST_DPMAN_ARRAY:
|
|
|
|
/* FIXME do array method checking here */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) {
|
2004-03-15 19:27:17 +00:00
|
|
|
/* it is not the first update anymore */
|
|
|
|
dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dwraps = g_list_next (dwraps);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static gint
|
|
|
|
gst_dpman_dpwrap_compare (const GstDParamWrapper * a,
|
|
|
|
const GstDParamWrapper * b)
|
2002-05-29 18:51:27 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
if (a->next_update_frame > b->next_update_frame)
|
|
|
|
return 1;
|
|
|
|
return (a->next_update_frame < b->next_update_frame) ? -1 : 0;
|
|
|
|
}
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static gboolean
|
|
|
|
gst_dpman_preprocess_asynchronous (GstDParamManager * dpman, guint frames,
|
|
|
|
gint64 timestamp)
|
|
|
|
{
|
|
|
|
GList *dwraps;
|
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
gint64 current_time;
|
|
|
|
gboolean updates_pending;
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
|
2002-05-29 18:51:27 +00:00
|
|
|
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (GST_DPMAN_RATE (dpman) == 0) {
|
|
|
|
g_warning ("The element hasn't given GstDParamManager a frame rate");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
dpman->rate_ratio = (guint) (1000000000LL / (gint64) GST_DPMAN_RATE (dpman));
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dpman->time_buffer_starts = timestamp;
|
|
|
|
dpman->time_buffer_ends =
|
|
|
|
timestamp + ((gint64) frames * (gint64) dpman->rate_ratio);
|
|
|
|
dpman->num_frames = frames;
|
|
|
|
|
|
|
|
updates_pending = FALSE;
|
|
|
|
|
|
|
|
/* now check whether any dparams are ready for an update */
|
|
|
|
dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
|
|
|
|
while (dwraps) {
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
|
|
|
|
|
|
|
dpwrap->next_update_frame = frames;
|
|
|
|
|
|
|
|
if (dpwrap->dparam && GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) {
|
|
|
|
|
|
|
|
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
|
|
|
|
if (current_time > dpman->time_buffer_ends) {
|
2004-03-15 19:27:17 +00:00
|
|
|
/* not due for an update in this buffer */
|
|
|
|
dwraps = g_list_next (dwraps);
|
|
|
|
continue;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
if (current_time < timestamp) {
|
2004-03-15 19:27:17 +00:00
|
|
|
current_time = timestamp;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (current_time == timestamp) {
|
2004-03-15 19:27:17 +00:00
|
|
|
/* we are overdue for an update. lets do it now */
|
|
|
|
|
|
|
|
GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value,
|
|
|
|
dpwrap->update_info);
|
|
|
|
|
|
|
|
if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) {
|
|
|
|
/* it is not the first update anymore */
|
|
|
|
dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (dpwrap->update_method) {
|
|
|
|
|
|
|
|
/* direct method - set the value directly in the struct of the element */
|
|
|
|
case GST_DPMAN_DIRECT:
|
|
|
|
GST_DEBUG ("doing direct update");
|
|
|
|
gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* callback method - call the element's callback so it can do what it likes */
|
|
|
|
case GST_DPMAN_CALLBACK:
|
|
|
|
GST_DEBUG ("doing callback update");
|
|
|
|
GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
|
|
|
|
|
|
|
|
if (!GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) ||
|
|
|
|
current_time > dpman->time_buffer_ends) {
|
|
|
|
/* not due for an update in this buffer */
|
|
|
|
dwraps = g_list_next (dwraps);
|
|
|
|
continue;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dpwrap->next_update_frame =
|
2004-03-15 19:27:17 +00:00
|
|
|
(guint) (current_time - timestamp) / dpman->rate_ratio;
|
2004-03-13 15:27:01 +00:00
|
|
|
updates_pending = TRUE;
|
|
|
|
|
|
|
|
GST_DEBUG ("timestamp start: %"
|
2004-03-15 19:27:17 +00:00
|
|
|
G_GINT64_FORMAT " end: %"
|
|
|
|
G_GINT64_FORMAT " current: %"
|
|
|
|
G_GINT64_FORMAT, timestamp, dpman->time_buffer_ends, current_time);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
dwraps = g_list_next (dwraps);
|
|
|
|
}
|
|
|
|
if (updates_pending) {
|
|
|
|
GST_DPMAN_DPARAMS_LIST (dpman) =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman),
|
|
|
|
(GCompareFunc) gst_dpman_dpwrap_compare);
|
2004-03-13 15:27:01 +00:00
|
|
|
dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
|
|
|
|
|
|
|
dpman->next_update_frame = dpwrap->next_update_frame;
|
|
|
|
dpman->frames_to_process = dpman->next_update_frame;
|
|
|
|
|
|
|
|
GST_DEBUG ("next update frame %u, frames to process %u",
|
2004-03-15 19:27:17 +00:00
|
|
|
dpman->next_update_frame, dpman->frames_to_process);
|
2004-03-13 15:27:01 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dpman->next_update_frame = frames;
|
|
|
|
dpman->frames_to_process = frames;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static gboolean
|
|
|
|
gst_dpman_process_asynchronous (GstDParamManager * dpman, guint frame_count)
|
|
|
|
{
|
|
|
|
GstDParamWrapper *dpwrap;
|
|
|
|
GList *dwraps;
|
|
|
|
gint64 current_time;
|
|
|
|
gboolean needs_resort = FALSE;
|
|
|
|
|
|
|
|
dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
|
|
|
|
|
|
|
GST_DEBUG ("in gst_dpman_process_asynchronous");
|
|
|
|
|
|
|
|
if (frame_count >= dpman->num_frames) {
|
|
|
|
g_warning ("there is no more buffer to process");
|
|
|
|
dpman->next_update_frame = dpman->num_frames;
|
|
|
|
dpman->frames_to_process = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame_count != dpwrap->next_update_frame) {
|
|
|
|
g_warning ("frame count %u does not match update frame %u",
|
2004-03-15 19:27:17 +00:00
|
|
|
frame_count, dpwrap->next_update_frame);
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (dpwrap) {
|
|
|
|
|
|
|
|
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
|
|
|
|
GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value,
|
2004-03-15 19:27:17 +00:00
|
|
|
dpwrap->update_info);
|
2004-03-13 15:27:01 +00:00
|
|
|
switch (dpwrap->update_method) {
|
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
/* direct method - set the value directly in the struct of the element */
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_DPMAN_DIRECT:
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_DEBUG ("doing direct update");
|
|
|
|
gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
|
|
|
|
break;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
/* callback method - call the element's callback so it can do what it likes */
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_DPMAN_CALLBACK:
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_DEBUG ("doing callback update");
|
|
|
|
GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
|
|
|
|
break;
|
2004-03-13 15:27:01 +00:00
|
|
|
default:
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dpwrap->next_update_frame = dpman->num_frames;
|
|
|
|
needs_resort = TRUE;
|
|
|
|
|
|
|
|
if (GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) {
|
|
|
|
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
|
|
|
|
if (current_time <= dpman->time_buffer_ends) {
|
2004-03-15 19:27:17 +00:00
|
|
|
dpwrap->next_update_frame =
|
|
|
|
(guint) (current_time -
|
|
|
|
dpman->time_buffer_starts) / dpman->rate_ratio;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((dwraps = g_list_next (dwraps))) {
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
|
|
|
if (frame_count == dpwrap->next_update_frame) {
|
2004-03-15 19:27:17 +00:00
|
|
|
continue;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dpwrap = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needs_resort && g_list_length (GST_DPMAN_DPARAMS_LIST (dpman)) > 1) {
|
|
|
|
GST_DPMAN_DPARAMS_LIST (dpman) =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman),
|
|
|
|
(GCompareFunc) gst_dpman_dpwrap_compare);
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
|
|
|
|
dpwrap = (GstDParamWrapper *) dwraps->data;
|
|
|
|
|
|
|
|
if (dpwrap->next_update_frame == dpman->num_frames) {
|
|
|
|
dpman->next_update_frame = dpman->num_frames;
|
|
|
|
dpman->frames_to_process = dpman->num_frames - frame_count;
|
|
|
|
GST_DEBUG ("no more updates, frames to process %u",
|
2004-03-15 19:27:17 +00:00
|
|
|
dpman->frames_to_process);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else {
|
|
|
|
dpman->next_update_frame = dpwrap->next_update_frame;
|
|
|
|
dpman->frames_to_process = dpman->next_update_frame - frame_count;
|
|
|
|
GST_DEBUG ("next update frame %u, frames to process %u",
|
2004-03-15 19:27:17 +00:00
|
|
|
dpman->next_update_frame, dpman->frames_to_process);
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2002-05-29 18:51:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static gboolean
|
|
|
|
gst_dpman_preprocess_noop (GstDParamManager * dpman, guint frames,
|
|
|
|
gint64 timestamp)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
dpman->next_update_frame = frames;
|
|
|
|
dpman->frames_to_process = frames;
|
|
|
|
return FALSE;
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static gboolean
|
|
|
|
gst_dpman_process_noop (GstDParamManager * dpman, guint frame_count)
|
2001-12-23 17:27:58 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning
|
|
|
|
("gst_dpman_process_noop should never be called - something might be wrong with your processing loop");
|
|
|
|
return FALSE;
|
2002-05-29 18:51:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_dpman_setup_synchronous (GstDParamManager * dpman)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
2002-05-29 18:51:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_dpman_setup_asynchronous (GstDParamManager * dpman)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
2002-05-29 18:51:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_dpman_setup_disabled (GstDParamManager * dpman)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
2002-05-29 18:51:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_dpman_teardown_synchronous (GstDParamManager * dpman)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
2002-05-29 18:51:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_dpman_teardown_asynchronous (GstDParamManager * dpman)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
|
|
|
|
2002-05-29 18:51:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void
|
|
|
|
gst_dpman_teardown_disabled (GstDParamManager * dpman)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DPMAN (dpman));
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2001-12-23 17:27:58 +00:00
|
|
|
}
|