2001-12-23 17:27:58 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2001 Steve Baker <stevebaker_org@yahoo.co.uk>
|
|
|
|
*
|
|
|
|
* gstdparammanager.h: 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_DPMAN_H__
|
|
|
|
#define __GST_DPMAN_H__
|
|
|
|
|
|
|
|
#include <gst/gstobject.h>
|
|
|
|
#include <gst/control/dparamcommon.h>
|
|
|
|
#include <gst/control/dparam.h>
|
2002-04-14 10:08:21 +00:00
|
|
|
#include <gst/control/unitconvert.h>
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2002-10-30 09:17:34 +00:00
|
|
|
G_BEGIN_DECLS
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2001-12-23 17:27:58 +00:00
|
|
|
#define GST_TYPE_DPMAN (gst_dpman_get_type ())
|
|
|
|
#define GST_DPMAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPMAN,GstDParamManager))
|
|
|
|
#define GST_DPMAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPMAN,GstDParamManager))
|
|
|
|
#define GST_IS_DPMAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPMAN))
|
|
|
|
#define GST_IS_DPMAN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPMAN))
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2001-12-23 17:27:58 +00:00
|
|
|
#define GST_DPMAN_NAME(dpman) (GST_OBJECT_NAME(dpman))
|
|
|
|
#define GST_DPMAN_PARENT(dpman) (GST_OBJECT_PARENT(dpman))
|
|
|
|
#define GST_DPMAN_DPARAMS(dpman) ((dpman)->dparams)
|
|
|
|
#define GST_DPMAN_DPARAMS_LIST(dpman) ((dpman)->dparams_list)
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2001-12-23 17:27:58 +00:00
|
|
|
#define GST_DPMAN_MODE_NAME(dpman) ((dpman)->mode_name)
|
|
|
|
#define GST_DPMAN_MODE(dpman) ((dpman)->mode)
|
|
|
|
#define GST_DPMAN_RATE(dpman) ((dpman)->rate)
|
2002-05-29 18:51:27 +00:00
|
|
|
#define GST_DPMAN_FRAMES_TO_PROCESS(dpman) ((dpman)->frames_to_process)
|
|
|
|
#define GST_DPMAN_NEXT_UPDATE_FRAME(dpman) ((dpman)->next_update_frame)
|
2004-03-15 14:43:35 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2001-12-23 17:27:58 +00:00
|
|
|
GST_DPMAN_CALLBACK,
|
|
|
|
GST_DPMAN_DIRECT,
|
2004-04-28 23:26:06 +00:00
|
|
|
GST_DPMAN_ARRAY
|
2001-12-23 17:27:58 +00:00
|
|
|
} GstDPMUpdateMethod;
|
|
|
|
|
|
|
|
typedef struct _GstDParamManagerClass GstDParamManagerClass;
|
|
|
|
typedef struct _GstDPMMode GstDPMMode;
|
|
|
|
typedef struct _GstDParamWrapper GstDParamWrapper;
|
2002-05-29 18:51:27 +00:00
|
|
|
typedef struct _GstDParamAsyncToUpdate GstDParamAsyncToUpdate;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
typedef gboolean (*GstDPMModePreProcessFunction) (GstDParamManager *dpman, guint frames, gint64 timestamp);
|
|
|
|
typedef gboolean (*GstDPMModeProcessFunction) (GstDParamManager *dpman, guint frame_count);
|
|
|
|
typedef void (*GstDPMModeSetupFunction) (GstDParamManager *dpman);
|
|
|
|
typedef void (*GstDPMModeTeardownFunction) (GstDParamManager *dpman);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
typedef void (*GstDPMUpdateFunction) (const GValue *value, gpointer data);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstDParamManager {
|
|
|
|
GstObject object;
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
GHashTable *dparams;
|
|
|
|
GList *dparams_list;
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
/* mode state */
|
|
|
|
GstDPMMode* mode;
|
|
|
|
gchar *mode_name;
|
2004-07-02 13:24:33 +00:00
|
|
|
|
|
|
|
guint frames_to_process; /* number of frames in the current buffer */
|
|
|
|
guint next_update_frame; /* frame when the next update is required */
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
/* the following data is only used for async mode */
|
|
|
|
guint rate; /* the frame/sample rate - */
|
2004-07-02 13:24:33 +00:00
|
|
|
guint rate_ratio; /* used to convert between samples and time */
|
|
|
|
guint num_frames; /* number of frames in the current buffer */
|
2002-05-29 18:51:27 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
gint64 time_buffer_ends;
|
|
|
|
gint64 time_buffer_starts;
|
2001-12-23 17:27:58 +00:00
|
|
|
};
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstDParamManagerClass {
|
|
|
|
GstObjectClass parent_class;
|
|
|
|
GHashTable *modes;
|
|
|
|
/* signal callbacks */
|
2004-07-14 14:55:57 +00:00
|
|
|
void (*new_required_dparam) (GstDParamManager *dpman, const gchar* dparam_name);
|
2001-12-23 17:27:58 +00:00
|
|
|
};
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstDPMMode {
|
|
|
|
GstDPMModePreProcessFunction preprocessfunc;
|
|
|
|
GstDPMModeProcessFunction processfunc;
|
|
|
|
GstDPMModeSetupFunction setupfunc;
|
|
|
|
GstDPMModeTeardownFunction teardownfunc;
|
2001-12-23 17:27:58 +00:00
|
|
|
};
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstDParamWrapper {
|
|
|
|
GParamSpec* param_spec;
|
|
|
|
GValue *value;
|
|
|
|
GstDParam *dparam;
|
|
|
|
|
|
|
|
guint next_update_frame;
|
2004-07-02 13:24:33 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
GstDPMUpdateMethod update_method;
|
|
|
|
gpointer update_data;
|
|
|
|
GstDPMUpdateFunction update_func;
|
2004-07-02 13:24:33 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
gchar *unit_name;
|
|
|
|
GstDParamUpdateInfo update_info;
|
2002-05-29 18:51:27 +00:00
|
|
|
};
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstDParamAsyncToUpdate {
|
|
|
|
guint frame;
|
|
|
|
GValue *value;
|
|
|
|
GstDParamWrapper *dpwrap;
|
2001-12-23 17:27:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GST_DPMAN_PREPROCESSFUNC(dpman) (((dpman)->mode)->preprocessfunc)
|
|
|
|
#define GST_DPMAN_PROCESSFUNC(dpman) (((dpman)->mode)->processfunc)
|
|
|
|
#define GST_DPMAN_SETUPFUNC(dpman) (((dpman)->mode)->setupfunc)
|
|
|
|
#define GST_DPMAN_TEARDOWNFUNC(dpman) (((dpman)->mode)->teardownfunc)
|
|
|
|
|
|
|
|
#define GST_DPMAN_PREPROCESS(dpman, buffer_size, timestamp) \
|
2002-05-29 18:51:27 +00:00
|
|
|
(GST_DPMAN_PREPROCESSFUNC(dpman)(dpman, buffer_size, timestamp))
|
2001-12-23 17:27:58 +00:00
|
|
|
|
|
|
|
#define GST_DPMAN_PROCESS(dpman, frame_count) \
|
2002-05-29 18:51:27 +00:00
|
|
|
(frame_count < dpman->next_update_frame || \
|
2004-07-02 13:24:33 +00:00
|
|
|
(dpman->next_update_frame < dpman->num_frames \
|
|
|
|
&& (GST_DPMAN_PROCESSFUNC(dpman)(dpman, frame_count))))
|
2002-04-14 10:08:21 +00:00
|
|
|
|
2005-02-15 14:49:47 +00:00
|
|
|
/* FIXME: this should pass dpwrap->dparam as the first arg
|
|
|
|
* the first arg in callback is usually object that triggered the callback
|
|
|
|
*/
|
2002-05-29 18:51:27 +00:00
|
|
|
#define GST_DPMAN_CALLBACK_UPDATE(dpwrap, value) ((dpwrap->update_func)(value, dpwrap->update_data))
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
void _gst_dpman_initialize(void);
|
2001-12-23 17:27:58 +00:00
|
|
|
GType gst_dpman_get_type (void);
|
2004-03-15 14:43:35 +00:00
|
|
|
GstDParamManager* gst_dpman_new (gchar *name, GstElement *parent);
|
|
|
|
void gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent);
|
|
|
|
GstDParamManager* gst_dpman_get_manager (GstElement *parent);
|
|
|
|
|
|
|
|
gboolean gst_dpman_add_required_dparam_callback (GstDParamManager *dpman,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
gchar *unit_name,
|
|
|
|
GstDPMUpdateFunction update_func,
|
|
|
|
gpointer update_data);
|
|
|
|
gboolean gst_dpman_add_required_dparam_direct (GstDParamManager *dpman,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
gchar *unit_name,
|
|
|
|
gpointer update_data);
|
|
|
|
|
|
|
|
gboolean gst_dpman_add_required_dparam_array (GstDParamManager *dpman,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
gchar *unit_name,
|
|
|
|
gpointer update_data);
|
|
|
|
|
2004-07-14 14:55:57 +00:00
|
|
|
void gst_dpman_remove_required_dparam (GstDParamManager *dpman, const gchar *dparam_name);
|
|
|
|
gboolean gst_dpman_attach_dparam (GstDParamManager *dpman, const gchar *dparam_name, GstDParam *dparam);
|
|
|
|
void gst_dpman_detach_dparam (GstDParamManager *dpman, const gchar *dparam_name);
|
|
|
|
GstDParam* gst_dpman_get_dparam(GstDParamManager *dpman, const gchar *dparam_name);
|
|
|
|
GType gst_dpman_get_dparam_type (GstDParamManager *dpman, const gchar *dparam_name);
|
2004-03-15 14:43:35 +00:00
|
|
|
|
|
|
|
GParamSpec** gst_dpman_list_dparam_specs(GstDParamManager *dpman);
|
2004-07-14 14:55:57 +00:00
|
|
|
GParamSpec* gst_dpman_get_param_spec (GstDParamManager *dpman, const gchar *dparam_name);
|
|
|
|
void gst_dpman_dparam_spec_has_changed (GstDParamManager *dpman, const gchar *dparam_name);
|
2004-03-15 14:43:35 +00:00
|
|
|
|
|
|
|
void gst_dpman_set_rate(GstDParamManager *dpman, gint rate);
|
2004-07-14 14:55:57 +00:00
|
|
|
void gst_dpman_bypass_dparam(GstDParamManager *dpman, const gchar *dparam_name);
|
2004-03-15 14:43:35 +00:00
|
|
|
|
|
|
|
gboolean gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename);
|
|
|
|
void gst_dpman_register_mode (GstDParamManagerClass *klass,
|
|
|
|
gchar *modename,
|
|
|
|
GstDPMModePreProcessFunction preprocessfunc,
|
|
|
|
GstDPMModeProcessFunction processfunc,
|
|
|
|
GstDPMModeSetupFunction setupfunc,
|
|
|
|
GstDPMModeTeardownFunction teardownfunc);
|
2001-12-23 17:27:58 +00:00
|
|
|
|
2002-10-30 09:17:34 +00:00
|
|
|
G_END_DECLS
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2001-12-23 17:27:58 +00:00
|
|
|
#endif /* __GST_DPMAN_H__ */
|