mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-03 09:12:19 +00:00
just some code cleanup
Original commit message from CVS: just some code cleanup
This commit is contained in:
parent
d95362aab5
commit
69edaac422
2 changed files with 67 additions and 106 deletions
|
@ -19,12 +19,14 @@
|
|||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <gst/gst.h>
|
||||
#include <math.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
#include "gstspeed.h"
|
||||
|
||||
/* buffer size to make if no bufferpool is available, must be divisible by
|
||||
|
@ -53,7 +55,6 @@ enum {
|
|||
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_SILENT,
|
||||
ARG_SPEED
|
||||
};
|
||||
|
||||
|
@ -66,7 +67,7 @@ speed_sink_factory (void)
|
|||
template = gst_pad_template_new
|
||||
("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
|
||||
gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int",
|
||||
GST_AUDIO_INT_MONO_PAD_TEMPLATE_PROPS),
|
||||
GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_PROPS),
|
||||
gst_caps_new ("sink_float", "audio/x-raw-float",
|
||||
GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)),
|
||||
NULL);
|
||||
|
@ -85,7 +86,7 @@ speed_src_factory (void)
|
|||
gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float",
|
||||
GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS),
|
||||
gst_caps_new ("src_int", "audio/x-raw-int",
|
||||
GST_AUDIO_INT_MONO_PAD_TEMPLATE_PROPS)),
|
||||
GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_PROPS)),
|
||||
NULL);
|
||||
|
||||
return template;
|
||||
|
@ -115,7 +116,7 @@ static GstElementClass *parent_class = NULL;
|
|||
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
static GstPadLinkReturn
|
||||
speed_connect (GstPad *pad, GstCaps *caps)
|
||||
speed_link (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
GstSpeed *filter;
|
||||
GstPad *otherpad;
|
||||
|
@ -126,8 +127,7 @@ speed_connect (GstPad *pad, GstCaps *caps)
|
|||
otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad);
|
||||
|
||||
if (GST_CAPS_IS_FIXED (caps)) {
|
||||
if (!speed_parse_caps (filter, caps))
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED;
|
||||
|
||||
return gst_pad_try_set_caps(otherpad, caps);
|
||||
}
|
||||
|
@ -140,35 +140,23 @@ speed_parse_caps (GstSpeed *filter, GstCaps *caps)
|
|||
{
|
||||
const gchar *mimetype;
|
||||
|
||||
g_return_val_if_fail(filter!=NULL,-1);
|
||||
g_return_val_if_fail(caps!=NULL,-1);
|
||||
|
||||
mimetype = gst_caps_get_mime (caps);
|
||||
g_return_val_if_fail(filter != NULL, FALSE);
|
||||
g_return_val_if_fail(caps != NULL, FALSE);
|
||||
|
||||
gst_caps_get_int (caps, "rate", &filter->rate);
|
||||
gst_caps_get_int (caps, "channels", &filter->channels);
|
||||
gst_caps_get_int (caps, "width", &filter->width);
|
||||
gst_caps_get_int (caps, "endianness", &filter->endianness);
|
||||
gst_caps_get_int (caps, "buffer-frames", &filter->buffer_frames);
|
||||
|
||||
if (strcmp(mimetype, "audio/x-raw-int")==0) {
|
||||
mimetype = gst_caps_get_mime (caps);
|
||||
|
||||
if (! strncmp(mimetype, "audio/x-raw-int", 15)) {
|
||||
filter->format = GST_SPEED_FORMAT_INT;
|
||||
gst_caps_get_int (caps, "depth", &filter->depth);
|
||||
gst_caps_get_boolean (caps, "signed", &filter->is_signed);
|
||||
|
||||
if (!filter->silent) {
|
||||
g_print ("Speed : channels %d, rate %d\n",
|
||||
filter->channels, filter->rate);
|
||||
g_print ("Speed : format int, bit width %d, endianness %d, signed %s\n",
|
||||
filter->width, filter->endianness, filter->is_signed ? "yes" : "no");
|
||||
}
|
||||
} else if (strcmp(mimetype, "audio/x-raw-float")==0) {
|
||||
gst_caps_get_int (caps, "depth", &filter->depth);
|
||||
gst_caps_get_boolean (caps, "signed", &filter->is_signed);
|
||||
} else if (! strncmp(mimetype, "audio/x-raw-float", 17)) {
|
||||
filter->format = GST_SPEED_FORMAT_FLOAT;
|
||||
|
||||
if (!filter->silent) {
|
||||
g_print ("Speed : channels %d, rate %d\n",
|
||||
filter->channels, filter->rate);
|
||||
g_print ("Speed : format float, width %d\n", filter->width);
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -199,43 +187,33 @@ gst_speed_get_type(void) {
|
|||
static void
|
||||
speed_class_init (GstSpeedClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstelement_class = (GstElementClass*)klass;
|
||||
|
||||
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SILENT,
|
||||
g_param_spec_boolean("silent","silent","silent",
|
||||
TRUE,G_PARAM_READWRITE)); /* CHECKME */
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SPEED,
|
||||
g_param_spec_float("speed","speed","speed",
|
||||
0.1,40.0,1.0,G_PARAM_READWRITE));
|
||||
GObjectClass *gobject_class = (GObjectClass*)klass;
|
||||
|
||||
gobject_class->set_property = speed_set_property;
|
||||
gobject_class->get_property = speed_get_property;
|
||||
|
||||
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SPEED,
|
||||
g_param_spec_float("speed","speed","speed",
|
||||
0.1,40.0,1.0,G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
}
|
||||
|
||||
static void
|
||||
speed_init (GstSpeed *filter)
|
||||
{
|
||||
filter->sinkpad = gst_pad_new_from_template(speed_sink_factory (),"sink");
|
||||
gst_pad_set_link_function(filter->sinkpad,speed_connect);
|
||||
gst_pad_set_bufferpool_function (filter->sinkpad, speed_sink_get_bufferpool);
|
||||
filter->srcpad = gst_pad_new_from_template(speed_src_factory (),"src");
|
||||
gst_pad_set_link_function(filter->srcpad,speed_connect);
|
||||
|
||||
filter->sinkpad = gst_pad_new_from_template(speed_sink_factory (), "sink");
|
||||
gst_pad_set_link_function(filter->sinkpad, speed_link);
|
||||
gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
|
||||
gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);
|
||||
gst_element_set_loop_function(GST_ELEMENT(filter),speed_loop);
|
||||
filter->silent = FALSE;
|
||||
filter->speed = 1.0;
|
||||
gst_pad_set_bufferpool_function (filter->sinkpad, speed_sink_get_bufferpool);
|
||||
|
||||
filter->sinkpool = gst_buffer_pool_get_default(SPEED_BUFSIZE,
|
||||
SPEED_NUMBUF);
|
||||
filter->srcpad = gst_pad_new_from_template(speed_src_factory (), "src");
|
||||
gst_pad_set_link_function(filter->srcpad, speed_link);
|
||||
gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);
|
||||
|
||||
gst_element_set_loop_function(GST_ELEMENT(filter),speed_loop);
|
||||
|
||||
filter->sinkpool = gst_buffer_pool_get_default(SPEED_BUFSIZE, SPEED_NUMBUF);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -296,9 +274,6 @@ speed_set_property (GObject *object, guint prop_id, const GValue *value, GParamS
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case ARG_SILENT:
|
||||
filter->silent = g_value_get_boolean (value);
|
||||
break;
|
||||
case ARG_SPEED:
|
||||
filter->speed = g_value_get_float (value);
|
||||
break;
|
||||
|
@ -317,9 +292,6 @@ speed_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *p
|
|||
filter = GST_SPEED(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_SILENT:
|
||||
g_value_set_boolean (value, filter->silent);
|
||||
break;
|
||||
case ARG_SPEED:
|
||||
g_value_set_float (value, filter->speed);
|
||||
break;
|
||||
|
@ -334,8 +306,7 @@ plugin_init (GModule *module, GstPlugin *plugin)
|
|||
{
|
||||
GstElementFactory *factory;
|
||||
|
||||
factory = gst_element_factory_new("speed",GST_TYPE_SPEED,
|
||||
&speed_details);
|
||||
factory = gst_element_factory_new("speed", GST_TYPE_SPEED, &speed_details);
|
||||
g_return_val_if_fail(factory != NULL, FALSE);
|
||||
|
||||
gst_element_factory_add_pad_template (factory, speed_src_factory ());
|
||||
|
|
|
@ -22,23 +22,20 @@
|
|||
#ifndef __GST_SPEED_H__
|
||||
#define __GST_SPEED_H__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include <gst/gst.h>
|
||||
/* #include <gst/meta/audioraw.h> */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_SPEED \
|
||||
(gst_speed_get_type())
|
||||
#define GST_SPEED(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPEED,GstSpeed))
|
||||
#define GST_SPEED_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstSpeed))
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPEED,GstSpeed))
|
||||
#define GST_IS_SPEED(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPEED))
|
||||
#define GST_IS_SPEED_CLASS(obj) \
|
||||
|
@ -59,23 +56,19 @@ struct _GstSpeed {
|
|||
GstPad *sinkpad, *srcpad;
|
||||
GstBufferPool *sinkpool, *srcpool;
|
||||
|
||||
gboolean silent;
|
||||
gfloat speed;
|
||||
|
||||
/* the next are valid for both int and float */
|
||||
/* valid for both int and float */
|
||||
GstSpeedFormat format;
|
||||
guint rate;
|
||||
guint channels;
|
||||
guint width;
|
||||
guint endianness;
|
||||
guint buffer_frames;
|
||||
|
||||
/* the next are valid only for format==GST_SPEED_FORMAT_INT */
|
||||
/* valid only for format==GST_SPEED_FORMAT_INT */
|
||||
guint depth;
|
||||
gboolean is_signed;
|
||||
|
||||
/* the next three are valid only for format==GST_SPEED_FORMAT_FLOAT */
|
||||
gfloat slope;
|
||||
gfloat intercept;
|
||||
};
|
||||
|
||||
struct _GstSpeedClass {
|
||||
|
@ -84,9 +77,6 @@ struct _GstSpeedClass {
|
|||
|
||||
GType gst_speed_get_type(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_SPEED_H__ */
|
||||
|
|
Loading…
Reference in a new issue