*/
#include "gstcontrol.h"
+
+void
+gst_control_init (int *argc, char **argv[]) {
+ _gst_dpman_initialize ();
+}
#ifndef __GST_CONTROL_H__
#define __GST_CONTROL_H__
-#include <gst/gstobject.h>
-#include <gst/gstprops.h>
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <libs/control/gstdplinearinterp.h>
+void gst_control_init (int *argc, char **argv[]);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
static void gst_dparam_class_init (GstDParamClass *klass);
static void gst_dparam_init (GstDParam *dparam);
+static void gst_dparam_dispose (GObject *object);
static void gst_dparam_do_update_realtime (GstDParam *dparam, gint64 timestamp);
static GValue** gst_dparam_get_point_realtime (GstDParam *dparam, gint64 timestamp);
gobject_class = (GObjectClass*)klass;
dparam_class = (GstDParamClass*)klass;
gstobject_class = (GstObjectClass*) klass;
-
+
+ gobject_class->dispose = gst_dparam_dispose;
//gstobject_class->save_thyself = gst_dparam_save_thyself;
}
return dparam;
}
+static void
+gst_dparam_dispose (GObject *object)
+{
+ GstDParam *dparam = GST_DPARAM(object);
+ GValue **point = dparam->point;
+ guint i = 0;
+ gchar *dparam_name = g_strdup(GST_DPARAM_NAME(dparam));
+
+ g_print("disposing of %s\n", dparam_name);
+ if (GST_DPARAM_MANAGER(dparam)){
+ gst_dpman_detach_dparam(GST_DPARAM_MANAGER(dparam), dparam_name);
+ }
+ point = dparam->point;
+ while (point[i]){
+ g_value_unset(point[i]);
+ g_free(point[i]);
+ i++;
+ }
+ g_free(dparam_name);
+
+}
+
/**
* gst_dparam_attach
* @dparam: GstDParam instance
- * @parent: the GstDParamManager that this dparam belongs to
+ * @manager: the GstDParamManager that this dparam belongs to
*
*/
void
-gst_dparam_attach (GstDParam *dparam, GstObject *parent, GValue *value, GstDParamSpec *spec)
+gst_dparam_attach (GstDParam *dparam, GstDParamManager *manager, GValue *value, GstDParamSpec *spec)
{
g_return_if_fail (dparam != NULL);
g_return_if_fail (GST_IS_DPARAM (dparam));
- g_return_if_fail (GST_DPARAM_PARENT (dparam) == NULL);
- g_return_if_fail (parent != NULL);
- g_return_if_fail (G_IS_OBJECT (parent));
- g_return_if_fail (GST_IS_DPMAN (parent));
- g_return_if_fail ((gpointer)dparam != (gpointer)parent);
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GST_IS_DPMAN (manager));
g_return_if_fail (value != NULL);
g_return_if_fail (spec != NULL);
g_return_if_fail (GST_DPARAM_TYPE(dparam) == G_VALUE_TYPE(value));
GST_DPARAM_NAME(dparam) = spec->dparam_name;
GST_DPARAM_VALUE(dparam) = value;
GST_DPARAM_SPEC(dparam) = spec;
- gst_object_set_parent (GST_OBJECT (dparam), parent);
+ GST_DPARAM_MANAGER(dparam) = manager;
+}
+
+/**
+ * gst_dparam_detach
+ * @dparam: GstDParam instance
+ * @manager: the GstDParamManager that this dparam belongs to
+ *
+ */
+void
+gst_dparam_detach (GstDParam *dparam)
+{
+
+ g_return_if_fail (dparam != NULL);
+ g_return_if_fail (GST_IS_DPARAM (dparam));
+
+ GST_DPARAM_NAME(dparam) = NULL;
+ GST_DPARAM_VALUE(dparam) = NULL;
+ GST_DPARAM_SPEC(dparam) = NULL;
+ GST_DPARAM_MANAGER(dparam) = NULL;
}
/**
#include <gst/gstobject.h>
#include <gst/gstprops.h>
+#include <libs/control/gstdparamcommon.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-
#define GST_TYPE_DPARAM (gst_dparam_get_type ())
#define GST_DPARAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPARAM,GstDParam))
#define GST_DPARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPARAM,GstDParam))
#define GST_DPARAM_PARENT(dparam) (GST_OBJECT_PARENT(dparam))
#define GST_DPARAM_VALUE(dparam) ((dparam)->value)
#define GST_DPARAM_SPEC(dparam) ((dparam)->spec)
+#define GST_DPARAM_MANAGER(dparam) ((dparam)->manager)
#define GST_DPARAM_TYPE(dparam) ((dparam)->type)
#define GST_DPARAM_LOCK(dparam) (g_mutex_lock((dparam)->lock))
GST_DPARAM_FOUND_CLOSEST,
} GstDParamSearchResult;
-typedef struct _GstDParam GstDParam;
typedef struct _GstDParamClass GstDParamClass;
-typedef struct _GstDParamSpec GstDParamSpec;
typedef GValue** (*GstDParamInsertPointFunction) (GstDParam *dparam, guint64 timestamp);
typedef void (*GstDParamRemovePointFunction) (GstDParam *dparam, GValue** point);
GMutex *lock;
GValue *value;
+ GstDParamManager *manager;
GstDParamSpec *spec;
GValue **point;
GType type;
GType gst_dparam_get_type (void);
GstDParam* gst_dparam_new (GType type);
-void gst_dparam_attach (GstDParam *dparam, GstObject *parent, GValue *value, GstDParamSpec *spec);
+void gst_dparam_attach (GstDParam *dparam, GstDParamManager *manager, GValue *value, GstDParamSpec *spec);
+void gst_dparam_detach (GstDParam *dparam);
GValue** gst_dparam_new_value_array(GType type, ...);
void gst_dparam_set_value_from_string(GValue *value, const gchar *value_str);
--- /dev/null
+/* GStreamer
+ * Copyright (C) 2001 Steve Baker <stevebaker_org@yahoo.co.uk>
+ *
+ * gstdparamcommon.h: Dynamic Parameter common header
+ *
+ * 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.
+ */
+
+#ifndef __GST_DPCOMMON_H__
+#define __GST_DPCOMMON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _GstDParam GstDParam;
+typedef struct _GstDParamSpec GstDParamSpec;
+typedef struct _GstDParamManager GstDParamManager;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GST_DPCOMMON_H__ */
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, gchar *dparam_name, GType type, GstDPMUpdateMethod update_method);
static GstDParamWrapper* gst_dpman_get_wrapper(GstDParamManager *dpman, gchar *dparam_name);
static void gst_dpman_state_change (GstElement *element, gint state, GstDParamManager *dpman);
static guint gst_dpman_preprocess_noop(GstDParamManager *dpman, guint frames, gint64 timestamp);
static guint gst_dpman_process_noop(GstDParamManager *dpman, guint frame_count);
+void
+_gst_dpman_initialize()
+{
+ _element_registry = g_hash_table_new(NULL,NULL);
+}
+
GType
gst_dpman_get_type (void)
{
gstobject_class = (GstObjectClass*) klass;
gobject_class = (GObjectClass*) klass;
+ gobject_class->dispose = gst_dpman_dispose;
klass->modes = g_hash_table_new(g_str_hash,g_str_equal);
- _element_registry = g_hash_table_new(NULL,NULL);
gst_dpman_register_mode (klass, "synchronous",
gst_dpman_preprocess_synchronous, gst_dpman_process_noop, NULL, NULL);
return dpman;
}
+
+static void
+gst_dpman_dispose (GObject *object)
+{
+ GstDParamManager *dpman = GST_DPMAN(object);
+
+
+}
+
/**
* gst_dpman_add_required_dparam_callback:
* @dpman: GstDParamManager instance
g_return_val_if_fail(dpwrap->value != NULL, FALSE);
dpwrap->dparam = dparam;
- gst_dparam_attach(dparam, GST_OBJECT(dpman), dpwrap->value, dpwrap->spec);
+ gst_dparam_attach(dparam, dpman, dpwrap->value, dpwrap->spec);
return TRUE;
}
/**
- * gst_dpman_dettach_dparam:
+ * gst_dpman_detach_dparam:
* @dpman: GstDParamManager instance
* @dparam_name: the name of a parameter with a previously attached GstDParam
*
*/
void
-gst_dpman_dettach_dparam (GstDParamManager *dpman, gchar *dparam_name)
+gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name)
{
GstDParamWrapper* dpwrap;
g_return_if_fail(dpwrap);
- GST_DPARAM_VALUE(dpwrap->dparam) = NULL;
- GST_DPARAM_NAME(dpwrap->dparam) = NULL;
- gst_object_unparent (GST_OBJECT(dpwrap->dparam));
-
+ gst_dparam_detach(dpwrap->dparam);
dpwrap->dparam = NULL;
}
mode = g_hash_table_lookup(oclass->modes, modename);
g_return_val_if_fail (mode != NULL, FALSE);
+
+ if (GST_DPMAN_MODE(dpman) == mode) {
+ GST_DEBUG(GST_CAT_PARAMS, "mode %s already set\n", modename);
+ return TRUE;
+ }
+
GST_DEBUG(GST_CAT_PARAMS, "setting mode to %s\n", modename);
if (GST_DPMAN_MODE(dpman) && GST_DPMAN_TEARDOWNFUNC(dpman)){
GST_DPMAN_TEARDOWNFUNC(dpman)(dpman);
g_return_val_if_fail (GST_IS_ELEMENT (parent), NULL);
dpman = (GstDParamManager*)g_hash_table_lookup(_element_registry, parent);
- g_return_val_if_fail (dpman != NULL, NULL);
return dpman;
}
#include <gst/gstobject.h>
#include <gst/gstprops.h>
+#include <libs/control/gstdparamcommon.h>
#include <libs/control/gstdparam.h>
#ifdef __cplusplus
GST_DPMAN_ARRAY,
} GstDPMUpdateMethod;
-typedef struct _GstDParamManager GstDParamManager;
typedef struct _GstDParamManagerClass GstDParamManagerClass;
typedef struct _GstDPMMode GstDPMMode;
typedef struct _GstDParamWrapper GstDParamWrapper;
#define GST_DPMAN_DO_UPDATE(dpwrap) ((dpwrap->update_func)(dpwrap->value, dpwrap->update_data))
+void _gst_dpman_initialize();
GType gst_dpman_get_type (void);
GstDParamManager* gst_dpman_new (gchar *name, GstElement *parent);
void gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent);
gpointer update_data);
void gst_dpman_remove_required_dparam (GstDParamManager *dpman, gchar *dparam_name);
gboolean gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam *dparam);
-void gst_dpman_dettach_dparam (GstDParamManager *dpman, gchar *dparam_name);
+void gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name);
GstDParam* gst_dpman_get_dparam(GstDParamManager *dpman, gchar *name);
GType gst_dpman_get_dparam_type (GstDParamManager *dpman, gchar *name);