[gst-cvs] CVS: gstreamer/plugins/a52dec gsta52dec.c,1.6,1.7 gsta52dec.h,1.1,1.2
David I. Lehn
dlehn at users.sourceforge.net
Mon Sep 17 22:56:02 PDT 2001
Update of /cvsroot/gstreamer/gstreamer/plugins/a52dec
In directory usw-pr-cvs1:/tmp/cvs-serv8859
Modified Files:
gsta52dec.c gsta52dec.h
Log Message:
- Add some property support.
- Add broken timestamp support to local bytestream code.
Index: gsta52dec.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/a52dec/gsta52dec.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gsta52dec.c 2001/09/18 04:36:22 1.6
+++ gsta52dec.c 2001/09/18 05:55:47 1.7
@@ -45,7 +45,7 @@
enum {
ARG_0,
- /* FILL ME */
+ ARG_DRC
};
//
@@ -86,9 +86,11 @@
)
);
-static void gst_a52dec_class_init (A52DecClass *klass);
-static void gst_a52dec_init (A52Dec *a52dec);
+static void gst_a52dec_class_init (GstA52DecClass *klass);
+static void gst_a52dec_init (GstA52Dec *a52dec);
static void gst_a52dec_loop (GstElement *element);
+static void gst_a52dec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void gst_a52dec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static GstElementClass *parent_class = NULL;
//static guint gst_a52dec_signals[LAST_SIGNAL] = { 0 };
@@ -100,30 +102,37 @@
if (!a52dec_type) {
static const GTypeInfo a52dec_info = {
- sizeof(A52DecClass), NULL, NULL, (GClassInitFunc)gst_a52dec_class_init,
+ sizeof(GstA52DecClass), NULL, NULL, (GClassInitFunc)gst_a52dec_class_init,
NULL,
NULL,
- sizeof(A52Dec),
+ sizeof(GstA52Dec),
0,
(GInstanceInitFunc)gst_a52dec_init,
};
- a52dec_type = g_type_register_static (GST_TYPE_ELEMENT, "A52Dec", &a52dec_info, 0);
+ a52dec_type = g_type_register_static (GST_TYPE_ELEMENT, "GstA52Dec", &a52dec_info, 0);
}
return a52dec_type;
}
static void
-gst_a52dec_class_init (A52DecClass *klass)
+gst_a52dec_class_init (GstA52DecClass *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_DRC,
+ g_param_spec_boolean("drc","Dynamic Range Compression","Use Dynamic Range Compression",FALSE,G_PARAM_READWRITE));
+
+ gobject_class->set_property = gst_a52dec_set_property;
+ gobject_class->get_property = gst_a52dec_get_property;
}
static void
-gst_a52dec_init (A52Dec *a52dec)
+gst_a52dec_init (GstA52Dec *a52dec)
{
/* create the sink and src pads */
a52dec->sinkpad = gst_pad_new_from_template (
@@ -281,7 +290,7 @@
return chans;
}
-static int gst_a52dec_push (GstPad *srcpad, int flags, sample_t *_samples)
+static int gst_a52dec_push (GstPad *srcpad, int flags, sample_t *_samples, gint64 timestamp)
{
GstBuffer *buf;
int chans;
@@ -306,6 +315,7 @@
buf = gst_buffer_new();
GST_BUFFER_SIZE(buf) = sizeof(int16_t) * 256 * chans;
GST_BUFFER_DATA(buf) = g_malloc(GST_BUFFER_SIZE(buf));
+ GST_BUFFER_TIMESTAMP(buf) = timestamp;
float_to_int (samples, (int16_t *)GST_BUFFER_DATA(buf), flags);
gst_pad_push(srcpad, buf);
@@ -321,6 +331,7 @@
uint8_t *data;
size_t size;
off_t index;
+ gint64 timestamp;
};
static GstByteStream *gst_bytestream_init(GstPad *pad) {
@@ -329,6 +340,7 @@
bs->data = NULL;
bs->size = 0;
bs->index = 0;
+ bs->timestamp = 0;
return bs;
};
@@ -338,6 +350,8 @@
while ((bs->index + len) > bs->size) {
buf = gst_pad_pull(bs->pad);
+ // FIXME this should be timestamp from start not end of stream
+ bs->timestamp = GST_BUFFER_TIMESTAMP(buf);
oldlen = bs->size - bs->index;
memmove(bs->data, bs->data + bs->index, oldlen);
bs->size = oldlen + GST_BUFFER_SIZE(buf);
@@ -347,6 +361,7 @@
fprintf(stderr, "realloc failed: d:%p s:%d\n", bs->data, bs->size);
}
memcpy(bs->data + oldlen, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
+ //gst_buffer_unref(buf);
}
g_assert ((bs->index + len) <= bs->size);
}
@@ -374,6 +389,10 @@
gst_bytestream_bytes_read(bs, len);
}
+static gint64 gst_bytestream_timestamp(GstByteStream *bs) {
+ return bs->timestamp;
+}
+
static void gst_bytestream_free(GstByteStream *bs) {
if (bs->data) {
free(bs->data);
@@ -404,11 +423,11 @@
static void
gst_a52dec_loop (GstElement *element)
{
- A52Dec *a52dec;
+ GstA52Dec *a52dec;
sample_t *samples;
guint8 *data;
int i, length, flags, sample_rate, bit_rate;
- int stream_channels, req_channels;
+ int stream_channels;
a52_state_t *state;
GstByteStream *bs;
@@ -479,12 +498,50 @@
fprintf(stderr, "a52dec a52_block error %d\n", i);
}
// push on
- gst_a52dec_push(a52dec->srcpad, a52dec->req_channels, samples);
+ gst_a52dec_push(a52dec->srcpad, a52dec->req_channels, samples, gst_bytestream_timestamp(bs));
}
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
gst_bytestream_free(bs);
g_free(state);
+}
+
+static void
+gst_a52dec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ GstA52Dec *src;
+
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_A52DEC (object));
+ src = GST_A52DEC (object);
+
+ switch (prop_id) {
+ case ARG_DRC:
+ src->dynamic_range_compression = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_a52dec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ GstA52Dec *src;
+
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_A52DEC (object));
+ src = GST_A52DEC (object);
+
+ switch (prop_id) {
+ case ARG_DRC:
+ g_value_set_int (value, src->dynamic_range_compression);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static gboolean
Index: gsta52dec.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/a52dec/gsta52dec.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gsta52dec.h 2001/09/06 20:12:17 1.1
+++ gsta52dec.h 2001/09/18 05:55:47 1.2
@@ -18,8 +18,8 @@
*/
-#ifndef __A52DEC_H__
-#define __A52DEC_H__
+#ifndef __GST_A52DEC_H__
+#define __GST_A52DEC_H__
#include <config.h>
@@ -33,18 +33,18 @@
#define GST_TYPE_A52DEC \
(gst_a52dec_get_type())
#define GST_A52DEC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_A52DEC,A52Dec))
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_A52DEC,GstA52Dec))
#define GST_A52DEC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_A52DEC,A52Dec))
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_A52DEC,GstA52Dec))
#define GST_IS_A52DEC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_A52DEC))
#define GST_IS_A52DEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_A52DEC))
-typedef struct _A52Dec A52Dec;
-typedef struct _A52DecClass A52DecClass;
+typedef struct _GstA52Dec GstA52Dec;
+typedef struct _GstA52DecClass GstA52DecClass;
-struct _A52Dec {
+struct _GstA52Dec {
GstElement element;
/* pads */
@@ -58,7 +58,7 @@
gboolean dynamic_range_compression;
};
-struct _A52DecClass {
+struct _GstA52DecClass {
GstElementClass parent_class;
};
@@ -67,4 +67,4 @@
#endif /* __cplusplus */
-#endif /* __A52DEC_H__ */
+#endif /* __GST_A52DEC_H__ */
More information about the Gstreamer-commits
mailing list