mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-20 13:28:21 +00:00
talk about a painful merge
Original commit message from CVS: talk about a painful merge
This commit is contained in:
parent
f44e8e3a50
commit
21dd80fa24
|
@ -48,10 +48,6 @@ enum {
|
||||||
enum {
|
enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_NUM_PADS,
|
ARG_NUM_PADS,
|
||||||
ARG_FORMAT,
|
|
||||||
ARG_RATE,
|
|
||||||
ARG_WIDTH,
|
|
||||||
ARG_CHANNELS
|
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,81 +55,33 @@ GST_PAD_TEMPLATE_FACTORY (gst_adder_src_template_factory,
|
||||||
"src",
|
"src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_CAPS_NEW (
|
gst_caps_new ("int_src", "audio/raw",
|
||||||
"int_src",
|
GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
|
||||||
"audio/raw",
|
gst_caps_new ("float_src", "audio/raw",
|
||||||
"format", GST_PROPS_STRING ("int"),
|
GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS)
|
||||||
"law", GST_PROPS_INT (0),
|
|
||||||
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
|
|
||||||
"signed", GST_PROPS_BOOLEAN (TRUE),
|
|
||||||
"width", GST_PROPS_LIST (GST_PROPS_INT (8),
|
|
||||||
GST_PROPS_INT (16)),
|
|
||||||
"depth", GST_PROPS_LIST (GST_PROPS_INT (8),
|
|
||||||
GST_PROPS_INT (16)),
|
|
||||||
"rate", GST_PROPS_INT_RANGE (GST_AUDIO_MIN_RATE,
|
|
||||||
GST_AUDIO_MAX_RATE),
|
|
||||||
"channels", GST_PROPS_INT_RANGE (1, 2)
|
|
||||||
),
|
|
||||||
GST_CAPS_NEW (
|
|
||||||
"float_src",
|
|
||||||
"audio/raw",
|
|
||||||
"format", GST_PROPS_STRING ("float"),
|
|
||||||
"layout", GST_PROPS_STRING ("gfloat"),
|
|
||||||
"intercept", GST_PROPS_FLOAT (0.0),
|
|
||||||
"slope", GST_PROPS_FLOAT (1.0),
|
|
||||||
"rate", GST_PROPS_INT_RANGE (GST_AUDIO_MIN_RATE,
|
|
||||||
GST_AUDIO_MAX_RATE),
|
|
||||||
"channels", GST_PROPS_INT_RANGE (1, 2)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
GST_PAD_TEMPLATE_FACTORY (gst_adder_sink_template_factory,
|
GST_PAD_TEMPLATE_FACTORY (gst_adder_sink_template_factory,
|
||||||
"sink%d",
|
"sink%d",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_REQUEST,
|
GST_PAD_REQUEST,
|
||||||
GST_CAPS_NEW (
|
gst_caps_new ("int_sink", "audio/raw",
|
||||||
"int_sink",
|
GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
|
||||||
"audio/raw",
|
gst_caps_new ("float_sink", "audio/raw",
|
||||||
"format", GST_PROPS_STRING ("int"),
|
GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS)
|
||||||
"law", GST_PROPS_INT (0),
|
|
||||||
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
|
|
||||||
"signed", GST_PROPS_BOOLEAN (TRUE),
|
|
||||||
"width", GST_PROPS_LIST (GST_PROPS_INT (8),
|
|
||||||
GST_PROPS_INT (16)),
|
|
||||||
"depth", GST_PROPS_LIST (GST_PROPS_INT (8),
|
|
||||||
GST_PROPS_INT (16)),
|
|
||||||
"rate", GST_PROPS_INT_RANGE (GST_AUDIO_MIN_RATE,
|
|
||||||
GST_AUDIO_MAX_RATE),
|
|
||||||
"channels", GST_PROPS_INT_RANGE (1, 2)
|
|
||||||
),
|
|
||||||
GST_CAPS_NEW (
|
|
||||||
"float_sink",
|
|
||||||
"audio/raw",
|
|
||||||
"format", GST_PROPS_STRING ("float"),
|
|
||||||
"layout", GST_PROPS_STRING ("gfloat"),
|
|
||||||
"intercept", GST_PROPS_FLOAT (0.0),
|
|
||||||
"slope", GST_PROPS_FLOAT (1.0),
|
|
||||||
"rate", GST_PROPS_INT_RANGE (GST_AUDIO_MIN_RATE,
|
|
||||||
GST_AUDIO_MAX_RATE),
|
|
||||||
"channels", GST_PROPS_INT_RANGE (1, 2)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static void gst_adder_class_init (GstAdderClass *klass);
|
static void gst_adder_class_init (GstAdderClass *klass);
|
||||||
static void gst_adder_init (GstAdder *adder);
|
static void gst_adder_init (GstAdder *adder);
|
||||||
|
|
||||||
static void gst_adder_get_property (GObject *object, guint prop_id,
|
static void gst_adder_get_property (GObject *object, guint prop_id,
|
||||||
GValue *value, GParamSpec *pspec);
|
GValue *value, GParamSpec *pspec);
|
||||||
static void gst_adder_set_property (GObject *object, guint prop_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec);
|
|
||||||
|
|
||||||
static GstPad* gst_adder_request_new_pad (GstElement *element,
|
static GstPad* gst_adder_request_new_pad (GstElement *element, GstPadTemplate *temp,
|
||||||
GstPadTemplate *temp,
|
const gchar *unused);
|
||||||
const gchar *unused);
|
|
||||||
|
|
||||||
/* we do need a loop function */
|
/* we do need a loop function */
|
||||||
static void gst_adder_loop (GstElement *element);
|
static void gst_adder_loop (GstElement *element);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
/* static guint gst_adder_signals[LAST_SIGNAL] = { 0 }; */
|
/* static guint gst_adder_signals[LAST_SIGNAL] = { 0 }; */
|
||||||
|
@ -146,8 +94,7 @@ gst_adder_get_type (void) {
|
||||||
static const GTypeInfo adder_info = {
|
static const GTypeInfo adder_info = {
|
||||||
sizeof (GstAdderClass), NULL, NULL,
|
sizeof (GstAdderClass), NULL, NULL,
|
||||||
(GClassInitFunc) gst_adder_class_init, NULL, NULL,
|
(GClassInitFunc) gst_adder_class_init, NULL, NULL,
|
||||||
sizeof (GstAdder),
|
sizeof (GstAdder), 0,
|
||||||
0,
|
|
||||||
(GInstanceInitFunc) gst_adder_init,
|
(GInstanceInitFunc) gst_adder_init,
|
||||||
};
|
};
|
||||||
adder_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAdder",
|
adder_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAdder",
|
||||||
|
@ -165,7 +112,8 @@ gst_adder_parse_caps (GstAdder *adder, GstCaps *caps)
|
||||||
gst_caps_get_string (caps, "format", &format);
|
gst_caps_get_string (caps, "format", &format);
|
||||||
|
|
||||||
if (adder->format == GST_ADDER_FORMAT_UNSET) {
|
if (adder->format == GST_ADDER_FORMAT_UNSET) {
|
||||||
/* the caps haven't been set yet at all, so we need to go ahead and set all
|
/* the caps haven't been set yet at all,
|
||||||
|
* so we need to go ahead and set all
|
||||||
the relevant values. */
|
the relevant values. */
|
||||||
if (strcmp (format, "int") == 0) {
|
if (strcmp (format, "int") == 0) {
|
||||||
GST_DEBUG (GST_CAT_PLUGIN_INFO, "parse_caps sets adder to format int");
|
GST_DEBUG (GST_CAT_PLUGIN_INFO, "parse_caps sets adder to format int");
|
||||||
|
@ -200,32 +148,31 @@ gst_adder_parse_caps (GstAdder *adder, GstCaps *caps)
|
||||||
|
|
||||||
/* provide an error message if we can't connect */
|
/* provide an error message if we can't connect */
|
||||||
if (adder->format != GST_ADDER_FORMAT_INT) {
|
if (adder->format != GST_ADDER_FORMAT_INT) {
|
||||||
gst_element_error (el,
|
gst_element_error (el, "can't connect a non-int pad to an int adder");
|
||||||
"can't connect a non-int pad to an int adder");
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
if (adder->channels != channels) {
|
if (adder->channels != channels) {
|
||||||
gst_element_error (el,
|
gst_element_error (el,
|
||||||
"can't connect %d-channel pad with %d-channel adder",
|
"can't connect %d-channel pad with %d-channel adder",
|
||||||
channels, adder->channels);
|
channels, adder->channels);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (adder->rate != rate) {
|
if (adder->rate != rate) {
|
||||||
gst_element_error (el, "can't connect %d Hz pad with %d Hz adder",
|
gst_element_error (el, "can't connect %d Hz pad with %d Hz adder",
|
||||||
rate, adder->rate);
|
rate, adder->rate);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (adder->width != width) {
|
if (adder->width != width) {
|
||||||
gst_element_error (el, "can't connect %d-bit pad with %d-bit adder",
|
gst_element_error (el, "can't connect %d-bit pad with %d-bit adder",
|
||||||
width, adder->width);
|
width, adder->width);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (adder->is_signed != is_signed) {
|
if (adder->is_signed != is_signed) {
|
||||||
gst_element_error (el,
|
gst_element_error (el,
|
||||||
"can't connect %ssigned pad with %ssigned adder",
|
"can't connect %ssigned pad with %ssigned adder",
|
||||||
adder->is_signed ? "" : "un",
|
adder->is_signed ? "" : "un",
|
||||||
is_signed ? "" : "un");
|
is_signed ? "" : "un");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (strcmp (format, "float") == 0) {
|
} else if (strcmp (format, "float") == 0) {
|
||||||
gint channels, rate;
|
gint channels, rate;
|
||||||
|
@ -234,25 +181,24 @@ gst_adder_parse_caps (GstAdder *adder, GstCaps *caps)
|
||||||
gst_caps_get_int (caps, "rate", &rate);
|
gst_caps_get_int (caps, "rate", &rate);
|
||||||
|
|
||||||
if (adder->format != GST_ADDER_FORMAT_FLOAT) {
|
if (adder->format != GST_ADDER_FORMAT_FLOAT) {
|
||||||
gst_element_error (el,
|
gst_element_error (el,
|
||||||
"can't connect a non-float pad to a float adder");
|
"can't connect a non-float pad to a float adder");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (adder->channels != channels) {
|
if (adder->channels != channels) {
|
||||||
gst_element_error (el,
|
gst_element_error (el,
|
||||||
"can't connect %d-channel pad with %d-channel adder",
|
"can't connect %d-channel pad with %d-channel adder",
|
||||||
channels, adder->channels);
|
channels, adder->channels);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (adder->rate != rate) {
|
if (adder->rate != rate) {
|
||||||
gst_element_error (el, "can't connect %d Hz pad with %d Hz adder",
|
gst_element_error (el, "can't connect %d Hz pad with %d Hz adder",
|
||||||
rate, adder->rate);
|
rate, adder->rate);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
/* whoa, we don't know what's trying to connect with us ! barf ! */
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/* whoa, we don't know what's trying to connect with us ! barf ! */
|
|
||||||
gst_element_error (el, "can't connect unknown type of pad to adder");
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -277,9 +223,9 @@ gst_adder_connect (GstPad *pad, GstCaps *caps)
|
||||||
return GST_PAD_CONNECT_REFUSED;
|
return GST_PAD_CONNECT_REFUSED;
|
||||||
|
|
||||||
if (pad == adder->srcpad || gst_pad_try_set_caps (adder->srcpad, caps) > 0) {
|
if (pad == adder->srcpad || gst_pad_try_set_caps (adder->srcpad, caps) > 0) {
|
||||||
sinkpads = gst_element_get_pad_list ((GstElement*) adder);
|
sinkpads = gst_element_get_pad_list ((GstElement *) adder);
|
||||||
while (sinkpads) {
|
while (sinkpads) {
|
||||||
p = (GstPad*) sinkpads->data;
|
p = (GstPad *) sinkpads->data;
|
||||||
if (p != pad && p != adder->srcpad) {
|
if (p != pad && p != adder->srcpad) {
|
||||||
if (gst_pad_try_set_caps (p, caps) <= 0) {
|
if (gst_pad_try_set_caps (p, caps) <= 0) {
|
||||||
GST_DEBUG (GST_CAT_PLUGIN_INFO,
|
GST_DEBUG (GST_CAT_PLUGIN_INFO,
|
||||||
|
@ -299,10 +245,11 @@ gst_adder_connect (GstPad *pad, GstCaps *caps)
|
||||||
restart:
|
restart:
|
||||||
channels = adder->input_channels;
|
channels = adder->input_channels;
|
||||||
while (channels) {
|
while (channels) {
|
||||||
GstAdderInputChannel *channel = (GstAdderInputChannel*) channels->data;
|
GstAdderInputChannel *channel;
|
||||||
|
channel = (GstAdderInputChannel*) channels->data;
|
||||||
if (channel->sinkpad == GST_PAD_CAST (remove->data)) {
|
if (channel->sinkpad == GST_PAD_CAST (remove->data)) {
|
||||||
gst_bytestream_destroy (channel->bytestream);
|
gst_bytestream_destroy (channel->bytestream);
|
||||||
adder->input_channels = g_slist_remove_link (adder->input_channels,
|
adder->input_channels = g_slist_remove_link (adder->input_channels,
|
||||||
channels);
|
channels);
|
||||||
adder->numsinkpads--;
|
adder->numsinkpads--;
|
||||||
goto restart;
|
goto restart;
|
||||||
|
@ -326,32 +273,16 @@ gst_adder_class_init (GstAdderClass *klass)
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
GstElementClass *gstelement_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass*) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
gstelement_class = (GstElementClass*) klass;
|
gstelement_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
|
||||||
g_param_spec_int ("num_pads", "number of pads", "Number Of Pads",
|
g_param_spec_int ("num_pads","number of pads","Number Of Pads",
|
||||||
0, G_MAXINT, 0, G_PARAM_READABLE));
|
0, G_MAXINT, 0, G_PARAM_READABLE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FORMAT,
|
|
||||||
g_param_spec_string ("format", "data format", "Format of Data (int/float)",
|
|
||||||
"int", G_PARAM_READWRITE));
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RATE,
|
|
||||||
g_param_spec_int ("rate", "Rate", "Sample Rate (Hz)",
|
|
||||||
GST_AUDIO_MIN_RATE, GST_AUDIO_MAX_RATE,
|
|
||||||
GST_AUDIO_DEF_RATE, G_PARAM_READWRITE));
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH,
|
|
||||||
g_param_spec_int ("width", "Bit Width", "Bit Width",
|
|
||||||
8, 16,
|
|
||||||
16, G_PARAM_READWRITE));
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHANNELS,
|
|
||||||
g_param_spec_int ("channels", "Channels", "Number of channels",
|
|
||||||
1, G_MAXINT,
|
|
||||||
2, G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_adder_get_property);
|
gobject_class->get_property = gst_adder_get_property;
|
||||||
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_adder_set_property);
|
|
||||||
|
|
||||||
gstelement_class->request_new_pad = gst_adder_request_new_pad;
|
gstelement_class->request_new_pad = gst_adder_request_new_pad;
|
||||||
}
|
}
|
||||||
|
@ -367,12 +298,6 @@ gst_adder_init (GstAdder *adder)
|
||||||
|
|
||||||
adder->format = GST_ADDER_FORMAT_UNSET;
|
adder->format = GST_ADDER_FORMAT_UNSET;
|
||||||
|
|
||||||
/* defaults */
|
|
||||||
adder->rate = GST_AUDIO_DEF_RATE;
|
|
||||||
adder->channels = 1;
|
|
||||||
adder->width = 16;
|
|
||||||
adder->depth = 16;
|
|
||||||
|
|
||||||
/* keep track of the sinkpads requested */
|
/* keep track of the sinkpads requested */
|
||||||
|
|
||||||
adder->numsinkpads = 0;
|
adder->numsinkpads = 0;
|
||||||
|
@ -398,7 +323,7 @@ gst_adder_request_new_pad (GstElement *element, GstPadTemplate *templ,
|
||||||
|
|
||||||
input = (GstAdderInputChannel *) g_malloc (sizeof (GstAdderInputChannel));
|
input = (GstAdderInputChannel *) g_malloc (sizeof (GstAdderInputChannel));
|
||||||
if (input == NULL) {
|
if (input == NULL) {
|
||||||
g_warning ("gstadder: could not allocate memory for adder input channel !\n");
|
g_warning ("gstadder: could not allocate adder input channel !\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,8 +347,7 @@ gst_adder_request_new_pad (GstElement *element, GstPadTemplate *templ,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_adder_get_property (GObject *object, guint prop_id,
|
gst_adder_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||||
GValue *value, GParamSpec *pspec)
|
|
||||||
{
|
{
|
||||||
GstAdder *adder;
|
GstAdder *adder;
|
||||||
|
|
||||||
|
@ -436,88 +360,12 @@ gst_adder_get_property (GObject *object, guint prop_id,
|
||||||
case ARG_NUM_PADS:
|
case ARG_NUM_PADS:
|
||||||
g_value_set_int (value, adder->numsinkpads);
|
g_value_set_int (value, adder->numsinkpads);
|
||||||
break;
|
break;
|
||||||
case ARG_FORMAT:
|
|
||||||
/* FIXME: check if this causes memleaks */
|
|
||||||
if (adder->format == GST_ADDER_FORMAT_INT)
|
|
||||||
g_value_set_string (value, g_strdup ("int"));
|
|
||||||
else if (adder->format == GST_ADDER_FORMAT_FLOAT)
|
|
||||||
g_value_set_string (value, g_strdup ("float"));
|
|
||||||
else
|
|
||||||
g_value_set_string (value, g_strdup ("unknown"));
|
|
||||||
break;
|
|
||||||
case ARG_RATE:
|
|
||||||
g_value_set_int (value, adder->rate);
|
|
||||||
break;
|
|
||||||
case ARG_WIDTH:
|
|
||||||
g_value_set_int (value, adder->depth);
|
|
||||||
break;
|
|
||||||
case ARG_CHANNELS:
|
|
||||||
g_value_set_int (value, adder->channels);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_adder_set_property (GObject *object, guint prop_id,
|
|
||||||
const GValue *value, GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GstAdder *adder;
|
|
||||||
GstElementState state;
|
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_ADDER (object));
|
|
||||||
|
|
||||||
adder = GST_ADDER (object);
|
|
||||||
state = gst_element_get_state (GST_ELEMENT (adder));
|
|
||||||
|
|
||||||
/* none of these properties can be set when not in NULL */
|
|
||||||
if (state != GST_STATE_NULL)
|
|
||||||
{
|
|
||||||
gst_element_error (GST_ELEMENT (adder),
|
|
||||||
"trying to set properties on adder when not in NULL.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (prop_id) {
|
|
||||||
case ARG_NUM_PADS:
|
|
||||||
g_warning ("Trying to change read-only parameter num_pads\n");
|
|
||||||
break;
|
|
||||||
case ARG_FORMAT:
|
|
||||||
if (strcmp (g_value_get_string (value), "int") == 0)
|
|
||||||
{
|
|
||||||
GST_DEBUG (GST_CAT_PLUGIN_INFO, "adder: setting format to int\n");
|
|
||||||
adder->format = GST_ADDER_FORMAT_INT;
|
|
||||||
}
|
|
||||||
else if (strcmp (g_value_get_string (value), "float") == 0)
|
|
||||||
{
|
|
||||||
GST_DEBUG (GST_CAT_PLUGIN_INFO, "adder: setting format to float\n");
|
|
||||||
adder->format = GST_ADDER_FORMAT_FLOAT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_warning ("adder: unknown format %s specified\n",
|
|
||||||
g_value_get_string (value));
|
|
||||||
adder->format = GST_ADDER_FORMAT_UNSET;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ARG_RATE:
|
|
||||||
adder->rate = g_value_get_int (value);
|
|
||||||
break;
|
|
||||||
case ARG_WIDTH:
|
|
||||||
adder->width = g_value_get_int (value);
|
|
||||||
adder->depth = g_value_get_int (value);
|
|
||||||
break;
|
|
||||||
case ARG_CHANNELS:
|
|
||||||
adder->channels = g_value_get_int (value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* use this loop */
|
/* use this loop */
|
||||||
static void
|
static void
|
||||||
gst_adder_loop (GstElement *element)
|
gst_adder_loop (GstElement *element)
|
||||||
|
@ -540,7 +388,6 @@ gst_adder_loop (GstElement *element)
|
||||||
GSList *inputs;
|
GSList *inputs;
|
||||||
GstAdderInputChannel *input;
|
GstAdderInputChannel *input;
|
||||||
|
|
||||||
gint8 *zero_out;
|
|
||||||
guint8 *raw_in;
|
guint8 *raw_in;
|
||||||
guint32 waiting;
|
guint32 waiting;
|
||||||
guint32 got_bytes;
|
guint32 got_bytes;
|
||||||
|
@ -563,12 +410,11 @@ gst_adder_loop (GstElement *element)
|
||||||
buf_out = gst_buffer_new_from_pool (adder->bufpool, 0, 0);
|
buf_out = gst_buffer_new_from_pool (adder->bufpool, 0, 0);
|
||||||
|
|
||||||
if (buf_out == NULL)
|
if (buf_out == NULL)
|
||||||
GST_ERROR (GST_ELEMENT (adder), "could not get new output buffer !");
|
gst_element_error (GST_ELEMENT (adder),
|
||||||
|
"could not get new output buffer !\n");
|
||||||
|
|
||||||
/* initialize the output data to 0 */
|
/* initialize the output data to 0 */
|
||||||
zero_out = (gint8 *) GST_BUFFER_DATA (buf_out);
|
memset (GST_BUFFER_DATA (buf_out), 0, GST_BUFFER_SIZE (buf_out));
|
||||||
for (i = 0; i < GST_BUFFER_SIZE (buf_out); i++)
|
|
||||||
zero_out[i] = 0;
|
|
||||||
|
|
||||||
/* get data from all of the sinks */
|
/* get data from all of the sinks */
|
||||||
inputs = adder->input_channels;
|
inputs = adder->input_channels;
|
||||||
|
@ -588,14 +434,14 @@ gst_adder_loop (GstElement *element)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get data from the bytestream of each input channel.
|
/* Get data from the bytestream of each input channel.
|
||||||
* We need to check for events before passing on the data to
|
* We need to check for events before passing on the data
|
||||||
* the output buffer. */
|
* to the output buffer. */
|
||||||
got_bytes = gst_bytestream_peek_bytes (input->bytestream, &raw_in,
|
got_bytes = gst_bytestream_peek_bytes (input->bytestream, &raw_in,
|
||||||
GST_BUFFER_SIZE (buf_out));
|
GST_BUFFER_SIZE (buf_out));
|
||||||
|
|
||||||
/* FIXME we should do something with the data
|
/* FIXME we should do something with the data if
|
||||||
* if got_bytes is more than zero */
|
* got_bytes is more than zero */
|
||||||
if (got_bytes < GST_BUFFER_SIZE (buf_out)) {
|
if (got_bytes < GST_BUFFER_SIZE(buf_out)) {
|
||||||
/* we need to check for an event. */
|
/* we need to check for an event. */
|
||||||
gst_bytestream_get_status (input->bytestream, &waiting, &event);
|
gst_bytestream_get_status (input->bytestream, &waiting, &event);
|
||||||
|
|
||||||
|
@ -662,6 +508,29 @@ gst_adder_loop (GstElement *element)
|
||||||
inputs = g_slist_next (inputs);
|
inputs = g_slist_next (inputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adder->format == GST_ADDER_FORMAT_UNSET) {
|
||||||
|
GstCaps *caps =
|
||||||
|
gst_caps_new ("default_adder_caps",
|
||||||
|
"audio/raw",
|
||||||
|
gst_props_new ("format", GST_PROPS_STRING ("int"),
|
||||||
|
"width", GST_PROPS_INT (16),
|
||||||
|
"depth", GST_PROPS_INT (16),
|
||||||
|
"rate", GST_PROPS_INT (44100),
|
||||||
|
"channels", GST_PROPS_INT (2),
|
||||||
|
"law", GST_PROPS_INT (0),
|
||||||
|
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
|
||||||
|
"signed", GST_PROPS_BOOLEAN (TRUE),
|
||||||
|
NULL));
|
||||||
|
|
||||||
|
if (gst_pad_try_set_caps (adder->srcpad, caps) < 0) {
|
||||||
|
gst_element_error (GST_ELEMENT (adder),
|
||||||
|
"Couldn't set the default caps, "
|
||||||
|
"use connect_filtered instead");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gst_adder_parse_caps (adder, caps);
|
||||||
|
}
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (buf_out) = timestamp;
|
GST_BUFFER_TIMESTAMP (buf_out) = timestamp;
|
||||||
if (adder->format == GST_ADDER_FORMAT_FLOAT)
|
if (adder->format == GST_ADDER_FORMAT_FLOAT)
|
||||||
offset += GST_BUFFER_SIZE (buf_out) / sizeof (gfloat) / adder->channels;
|
offset += GST_BUFFER_SIZE (buf_out) / sizeof (gfloat) / adder->channels;
|
||||||
|
@ -684,15 +553,16 @@ plugin_init (GModule *module, GstPlugin *plugin)
|
||||||
{
|
{
|
||||||
GstElementFactory *factory;
|
GstElementFactory *factory;
|
||||||
|
|
||||||
factory = gst_element_factory_new("adder",GST_TYPE_ADDER,
|
factory = gst_element_factory_new ("adder", GST_TYPE_ADDER, &adder_details);
|
||||||
&adder_details);
|
g_return_val_if_fail (factory != NULL, FALSE);
|
||||||
g_return_val_if_fail(factory != NULL, FALSE);
|
|
||||||
|
|
||||||
if (! gst_library_load ("gstbytestream"))
|
if (! gst_library_load ("gstbytestream"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (gst_adder_src_template_factory));
|
gst_element_factory_add_pad_template (factory,
|
||||||
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (gst_adder_sink_template_factory));
|
GST_PAD_TEMPLATE_GET (gst_adder_src_template_factory));
|
||||||
|
gst_element_factory_add_pad_template (factory,
|
||||||
|
GST_PAD_TEMPLATE_GET (gst_adder_sink_template_factory));
|
||||||
|
|
||||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue