mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
all info to describe a dparam is now in the GstDParamSpec struct. The resemblance to LADSPA descriptors is intentional
Original commit message from CVS: all info to describe a dparam is now in the GstDParamSpec struct. The resemblance to LADSPA descriptors is intentional
This commit is contained in:
parent
1477b02850
commit
5be7eb77cf
6 changed files with 111 additions and 38 deletions
|
@ -152,6 +152,7 @@ gst_sinesrc_init (GstSineSrc *src)
|
|||
{
|
||||
GstElement *element = GST_ELEMENT(src);
|
||||
GstDParamManager *dpman;
|
||||
GstDParamSpec *spec;
|
||||
|
||||
src->srcpad = gst_pad_new_from_template (
|
||||
GST_PADTEMPLATE_GET (sinesrc_src_factory), "src");
|
||||
|
@ -173,10 +174,22 @@ gst_sinesrc_init (GstSineSrc *src)
|
|||
src->seq = 0;
|
||||
|
||||
dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src));
|
||||
gst_dpman_add_required_dparam_callback (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src);
|
||||
gst_dpman_add_required_dparam_callback (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src);
|
||||
|
||||
src->volume = 1.0;
|
||||
spec = gst_dpman_get_dparam_spec (dpman, "freq");
|
||||
g_value_set_float(spec->min_val, 10.0);
|
||||
g_value_set_float(spec->max_val, 10000.0);
|
||||
g_value_set_float(spec->default_val, 350.0);
|
||||
spec->unit_name = "frequency";
|
||||
spec->is_log = TRUE;
|
||||
|
||||
gst_dpman_add_required_dparam_callback (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src);
|
||||
spec = gst_dpman_get_dparam_spec (dpman, "volume");
|
||||
g_value_set_float(spec->min_val, 0.0);
|
||||
g_value_set_float(spec->max_val, 2.0);
|
||||
g_value_set_float(spec->default_val, 0.8);
|
||||
spec->unit_name = "scalar";
|
||||
|
||||
src->volume = 0.0;
|
||||
|
||||
gst_dpman_set_rate_change_pad(dpman, src->srcpad);
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "gstdparammanager.h"
|
||||
|
||||
static void gst_dparam_class_init (GstDParamClass *klass);
|
||||
static void gst_dparam_base_class_init (GstDParamClass *klass);
|
||||
static void gst_dparam_init (GstDParam *dparam);
|
||||
|
||||
static void gst_dparam_do_update_realtime (GstDParam *dparam, gint64 timestamp);
|
||||
|
@ -38,7 +37,7 @@ gst_dparam_get_type(void) {
|
|||
if (!dparam_type) {
|
||||
static const GTypeInfo dparam_info = {
|
||||
sizeof(GstDParamClass),
|
||||
(GBaseInitFunc)gst_dparam_base_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_dparam_class_init,
|
||||
NULL,
|
||||
|
@ -52,15 +51,6 @@ gst_dparam_get_type(void) {
|
|||
return dparam_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dparam_base_class_init (GstDParamClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
|
||||
gobject_class = (GObjectClass*) klass;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dparam_class_init (GstDParamClass *klass)
|
||||
{
|
||||
|
@ -116,7 +106,7 @@ gst_dparam_new (GType type)
|
|||
*
|
||||
*/
|
||||
void
|
||||
gst_dparam_attach (GstDParam *dparam, GstObject *parent, gchar *dparam_name, GValue *value)
|
||||
gst_dparam_attach (GstDParam *dparam, GstObject *parent, GValue *value, GstDParamSpec *spec)
|
||||
{
|
||||
|
||||
g_return_if_fail (dparam != NULL);
|
||||
|
@ -126,12 +116,13 @@ gst_dparam_attach (GstDParam *dparam, GstObject *parent, gchar *dparam_name, GVa
|
|||
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 (dparam_name != NULL);
|
||||
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) = dparam_name;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -151,7 +142,7 @@ gst_dparam_new_value_array(GType type, ...)
|
|||
GValue **point;
|
||||
GValue *value;
|
||||
guint x;
|
||||
gint values_length = 0;
|
||||
guint values_length = 0;
|
||||
va_list var_args;
|
||||
GType each_type;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ extern "C" {
|
|||
#define GST_DPARAM_NAME(dparam) (GST_OBJECT_NAME(dparam))
|
||||
#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_TYPE(dparam) ((dparam)->type)
|
||||
|
||||
#define GST_DPARAM_LOCK(dparam) (g_mutex_lock((dparam)->lock))
|
||||
|
@ -78,7 +79,7 @@ typedef enum {
|
|||
|
||||
typedef struct _GstDParam GstDParam;
|
||||
typedef struct _GstDParamClass GstDParamClass;
|
||||
typedef struct _GstDParamModel GstDParamModel;
|
||||
typedef struct _GstDParamSpec GstDParamSpec;
|
||||
|
||||
typedef GValue** (*GstDParamInsertPointFunction) (GstDParam *dparam, guint64 timestamp);
|
||||
typedef void (*GstDParamRemovePointFunction) (GstDParam *dparam, GValue** point);
|
||||
|
@ -100,6 +101,7 @@ struct _GstDParam {
|
|||
|
||||
GMutex *lock;
|
||||
GValue *value;
|
||||
GstDParamSpec *spec;
|
||||
GValue **point;
|
||||
GType type;
|
||||
gint64 last_update_timestamp;
|
||||
|
@ -114,9 +116,19 @@ struct _GstDParamClass {
|
|||
/* signal callbacks */
|
||||
};
|
||||
|
||||
struct _GstDParamSpec {
|
||||
gchar *dparam_name;
|
||||
gchar *unit_name;
|
||||
GValue *min_val;
|
||||
GValue *max_val;
|
||||
GValue *default_val;
|
||||
gboolean is_log;
|
||||
gboolean is_rate;
|
||||
};
|
||||
|
||||
GType gst_dparam_get_type (void);
|
||||
GstDParam* gst_dparam_new (GType type);
|
||||
void gst_dparam_attach (GstDParam *dparam, GstObject *parent, gchar *dparam_name, GValue *value);
|
||||
void gst_dparam_attach (GstDParam *dparam, GstObject *parent, GValue *value, GstDParamSpec *spec);
|
||||
GValue** gst_dparam_new_value_array(GType type, ...);
|
||||
void gst_dparam_set_value_from_string(GValue *value, const gchar *value_str);
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <gst/gstelement.h>
|
||||
|
||||
|
||||
static void gst_dpman_base_class_init (GstDParamManagerClass *klass);
|
||||
static void gst_dpman_class_init (GstDParamManagerClass *klass);
|
||||
static void gst_dpman_init (GstDParamManager *dpman);
|
||||
static GstDParamWrapper* gst_dpman_new_wrapper(GstDParamManager *dpman, gchar *dparam_name, GType type, GstDPMUpdateMethod update_method);
|
||||
|
@ -44,7 +43,7 @@ gst_dpman_get_type (void)
|
|||
if (!dpman_type) {
|
||||
static const GTypeInfo dpman_info = {
|
||||
sizeof(GstDParamManagerClass),
|
||||
(GBaseInitFunc)gst_dpman_base_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_dpman_class_init,
|
||||
NULL,
|
||||
|
@ -58,15 +57,6 @@ gst_dpman_get_type (void)
|
|||
return dpman_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dpman_base_class_init (GstDParamManagerClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
|
||||
gobject_class = (GObjectClass*) klass;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dpman_class_init (GstDParamManagerClass *klass)
|
||||
{
|
||||
|
@ -277,7 +267,7 @@ gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam
|
|||
g_return_val_if_fail(dpwrap->value != NULL, FALSE);
|
||||
|
||||
dpwrap->dparam = dparam;
|
||||
gst_dparam_attach(dparam, GST_OBJECT(dpman), dparam_name, dpwrap->value);
|
||||
gst_dparam_attach(dparam, GST_OBJECT(dpman), dpwrap->value, dpwrap->spec);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -353,6 +343,48 @@ gst_dpman_get_dparam_type (GstDParamManager *dpman, gchar *name)
|
|||
return G_VALUE_TYPE(dpwrap->value);
|
||||
}
|
||||
|
||||
GstDParamSpec**
|
||||
gst_dpman_list_dparam_specs(GstDParamManager *dpman)
|
||||
{
|
||||
GstDParamWrapper* dpwrap;
|
||||
GSList *dpwraps;
|
||||
GstDParamSpec** dparam_specs;
|
||||
guint x = 0;
|
||||
|
||||
g_return_val_if_fail (dpman != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
|
||||
|
||||
dpwraps = GST_DPMAN_DPARAMS_LIST(dpman);
|
||||
|
||||
dparam_specs = g_new0(GstDParamSpec*, g_slist_length(dpwraps) + 1);
|
||||
|
||||
while (dpwraps){
|
||||
dpwrap = (GstDParamWrapper*)dpwraps->data;
|
||||
dparam_specs[x++] = dpwrap->spec;
|
||||
dpwraps = g_slist_next(dpwraps);
|
||||
}
|
||||
return dparam_specs;
|
||||
}
|
||||
|
||||
GstDParamSpec*
|
||||
gst_dpman_get_dparam_spec (GstDParamManager *dpman, gchar *dparam_name)
|
||||
{
|
||||
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->spec;
|
||||
}
|
||||
|
||||
void
|
||||
gst_dpman_dparam_spec_has_changed (GstDParamManager *dpman, gchar *dparam_name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_dpman_register_mode
|
||||
* @klass: GstDParamManagerClass class instance
|
||||
|
@ -482,10 +514,18 @@ gst_dpman_new_wrapper(GstDParamManager *dpman, gchar *dparam_name, GType type, G
|
|||
g_return_val_if_fail(gst_dpman_get_wrapper(dpman, dparam_name) == NULL, NULL);
|
||||
|
||||
dpwrap = g_new0(GstDParamWrapper,1);
|
||||
dpwrap->dparam_name = dparam_name;
|
||||
dpwrap->update_method = update_method;
|
||||
dpwrap->value = g_new0(GValue,1);
|
||||
g_value_init(dpwrap->value, type);
|
||||
|
||||
dpwrap->spec = g_new0(GstDParamSpec,1);
|
||||
dpwrap->spec->dparam_name = dparam_name;
|
||||
dpwrap->spec->min_val = g_new0(GValue,1);
|
||||
dpwrap->spec->max_val = g_new0(GValue,1);
|
||||
dpwrap->spec->default_val = g_new0(GValue,1);
|
||||
g_value_init(dpwrap->spec->min_val, type);
|
||||
g_value_init(dpwrap->spec->max_val, type);
|
||||
g_value_init(dpwrap->spec->default_val, type);
|
||||
|
||||
g_hash_table_insert(GST_DPMAN_DPARAMS(dpman), dparam_name, dpwrap);
|
||||
GST_DPMAN_DPARAMS_LIST(dpman) = g_slist_append(GST_DPMAN_DPARAMS_LIST(dpman), dpwrap);
|
||||
|
@ -538,7 +578,7 @@ gst_dpman_preprocess_synchronous(GstDParamManager *dpman, guint frames, gint64 t
|
|||
GSList *dwraps;
|
||||
GstDParam *dparam;
|
||||
GstDParamWrapper *dpwrap;
|
||||
int x;
|
||||
guint x;
|
||||
|
||||
g_return_val_if_fail (dpman != NULL, frames);
|
||||
g_return_val_if_fail (GST_IS_DPMAN (dpman), frames);
|
||||
|
|
|
@ -92,7 +92,7 @@ struct _GstDPMMode {
|
|||
};
|
||||
|
||||
struct _GstDParamWrapper {
|
||||
gchar *dparam_name;
|
||||
GstDParamSpec* spec;
|
||||
GValue *value;
|
||||
GstDParam *dparam;
|
||||
GstDPMUpdateMethod update_method;
|
||||
|
@ -140,6 +140,10 @@ void gst_dpman_dettach_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);
|
||||
|
||||
GstDParamSpec** gst_dpman_list_dparam_specs(GstDParamManager *dpman);
|
||||
GstDParamSpec* gst_dpman_get_dparam_spec (GstDParamManager *dpman, gchar *dparam_name);
|
||||
void gst_dpman_dparam_spec_has_changed (GstDParamManager *dpman, gchar *dparam_name);
|
||||
|
||||
void gst_dpman_set_rate_change_pad(GstDParamManager *dpman, GstPad *pad);
|
||||
|
||||
gboolean gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename);
|
||||
|
|
|
@ -152,6 +152,7 @@ gst_sinesrc_init (GstSineSrc *src)
|
|||
{
|
||||
GstElement *element = GST_ELEMENT(src);
|
||||
GstDParamManager *dpman;
|
||||
GstDParamSpec *spec;
|
||||
|
||||
src->srcpad = gst_pad_new_from_template (
|
||||
GST_PADTEMPLATE_GET (sinesrc_src_factory), "src");
|
||||
|
@ -173,10 +174,22 @@ gst_sinesrc_init (GstSineSrc *src)
|
|||
src->seq = 0;
|
||||
|
||||
dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src));
|
||||
gst_dpman_add_required_dparam_callback (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src);
|
||||
gst_dpman_add_required_dparam_callback (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src);
|
||||
|
||||
src->volume = 1.0;
|
||||
spec = gst_dpman_get_dparam_spec (dpman, "freq");
|
||||
g_value_set_float(spec->min_val, 10.0);
|
||||
g_value_set_float(spec->max_val, 10000.0);
|
||||
g_value_set_float(spec->default_val, 350.0);
|
||||
spec->unit_name = "frequency";
|
||||
spec->is_log = TRUE;
|
||||
|
||||
gst_dpman_add_required_dparam_callback (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src);
|
||||
spec = gst_dpman_get_dparam_spec (dpman, "volume");
|
||||
g_value_set_float(spec->min_val, 0.0);
|
||||
g_value_set_float(spec->max_val, 2.0);
|
||||
g_value_set_float(spec->default_val, 0.8);
|
||||
spec->unit_name = "scalar";
|
||||
|
||||
src->volume = 0.0;
|
||||
|
||||
gst_dpman_set_rate_change_pad(dpman, src->srcpad);
|
||||
|
||||
|
|
Loading…
Reference in a new issue