mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
level: port to 0.11
* use G_DEFINE_TYPE * adjust to new GstBuffer
This commit is contained in:
parent
d9ba4b7616
commit
696ffc85d7
1 changed files with 19 additions and 21 deletions
|
@ -159,8 +159,8 @@ enum
|
||||||
PROP_PEAK_FALLOFF
|
PROP_PEAK_FALLOFF
|
||||||
};
|
};
|
||||||
|
|
||||||
GST_BOILERPLATE (GstLevel, gst_level, GstBaseTransform,
|
#define gst_level_parent_class parent_class
|
||||||
GST_TYPE_BASE_TRANSFORM);
|
G_DEFINE_TYPE (GstLevel, gst_level, GST_TYPE_BASE_TRANSFORM);
|
||||||
|
|
||||||
static void gst_level_set_property (GObject * object, guint prop_id,
|
static void gst_level_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -175,25 +175,11 @@ static GstFlowReturn gst_level_transform_ip (GstBaseTransform * trans,
|
||||||
GstBuffer * in);
|
GstBuffer * in);
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_level_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = g_class;
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_template_factory));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_template_factory));
|
|
||||||
gst_element_class_set_details_simple (element_class, "Level",
|
|
||||||
"Filter/Analyzer/Audio",
|
|
||||||
"RMS/Peak/Decaying Peak Level messager for audio/raw",
|
|
||||||
"Thomas Vander Stichele <thomas at apestaart dot org>");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_level_class_init (GstLevelClass * klass)
|
gst_level_class_init (GstLevelClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
|
GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
|
||||||
|
|
||||||
gobject_class->set_property = gst_level_set_property;
|
gobject_class->set_property = gst_level_set_property;
|
||||||
|
@ -221,6 +207,15 @@ gst_level_class_init (GstLevelClass * klass)
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (level_debug, "level", 0, "Level calculation");
|
GST_DEBUG_CATEGORY_INIT (level_debug, "level", 0, "Level calculation");
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&sink_template_factory));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&src_template_factory));
|
||||||
|
gst_element_class_set_details_simple (element_class, "Level",
|
||||||
|
"Filter/Analyzer/Audio",
|
||||||
|
"RMS/Peak/Decaying Peak Level messager for audio/raw",
|
||||||
|
"Thomas Vander Stichele <thomas at apestaart dot org>");
|
||||||
|
|
||||||
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_level_set_caps);
|
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_level_set_caps);
|
||||||
trans_class->start = GST_DEBUG_FUNCPTR (gst_level_start);
|
trans_class->start = GST_DEBUG_FUNCPTR (gst_level_start);
|
||||||
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_level_transform_ip);
|
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_level_transform_ip);
|
||||||
|
@ -228,7 +223,7 @@ gst_level_class_init (GstLevelClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_level_init (GstLevel * filter, GstLevelClass * g_class)
|
gst_level_init (GstLevel * filter)
|
||||||
{
|
{
|
||||||
filter->CS = NULL;
|
filter->CS = NULL;
|
||||||
filter->peak = NULL;
|
filter->peak = NULL;
|
||||||
|
@ -569,7 +564,8 @@ static GstFlowReturn
|
||||||
gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
{
|
{
|
||||||
GstLevel *filter;
|
GstLevel *filter;
|
||||||
guint8 *in_data;
|
guint8 *in_data, *data;
|
||||||
|
gsize in_size;
|
||||||
gdouble CS;
|
gdouble CS;
|
||||||
guint i;
|
guint i;
|
||||||
guint num_frames = 0;
|
guint num_frames = 0;
|
||||||
|
@ -579,8 +575,8 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
|
|
||||||
filter = GST_LEVEL (trans);
|
filter = GST_LEVEL (trans);
|
||||||
|
|
||||||
in_data = GST_BUFFER_DATA (in);
|
in_data = data = gst_buffer_map (in, &in_size, NULL, GST_MAP_READ);
|
||||||
num_int_samples = GST_BUFFER_SIZE (in) / (filter->width / 8);
|
num_int_samples = in_size / (filter->width / 8);
|
||||||
|
|
||||||
GST_LOG_OBJECT (filter, "analyzing %u sample frames at ts %" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (filter, "analyzing %u sample frames at ts %" GST_TIME_FORMAT,
|
||||||
num_int_samples, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (in)));
|
num_int_samples, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (in)));
|
||||||
|
@ -709,6 +705,8 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
filter->num_frames = 0;
|
filter->num_frames = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_buffer_unmap (in, data, in_size);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue