static void gst_festival_finalize (GObject * object);
-static void gst_festival_base_init (gpointer g_class);
-static void gst_festival_class_init (GstFestivalClass * klass);
-static void gst_festival_init (GstFestival * festival);
-
-static GstFlowReturn gst_festival_chain (GstPad * pad, GstBuffer * buf);
+static GstFlowReturn gst_festival_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buf);
static GstStateChangeReturn gst_festival_change_state (GstElement * element,
GstStateChange transition);
/* FILL ME */
};
-static GstElementClass *parent_class = NULL;
-
/*static guint gst_festival_signals[LAST_SIGNAL] = { 0 }; */
-GType
-gst_festival_get_type (void)
-{
- static GType festival_type = 0;
-
- if (!festival_type) {
- static const GTypeInfo festival_info = {
- sizeof (GstFestivalClass),
- gst_festival_base_init,
- NULL,
- (GClassInitFunc) gst_festival_class_init,
- NULL,
- NULL,
- sizeof (GstFestival),
- 0,
- (GInstanceInitFunc) gst_festival_init,
- };
-
- festival_type =
- g_type_register_static (GST_TYPE_ELEMENT, "GstFestival", &festival_info,
- 0);
- }
- return festival_type;
-}
+G_DEFINE_TYPE (GstFestival, gst_festival, GST_TYPE_ELEMENT)
-static void
-gst_festival_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- /* register pads */
- 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,
- "Festival Text-to-Speech synthesizer", "Filter/Effect/Audio",
- "Synthesizes plain text into audio",
- "Wim Taymans <wim.taymans@chello.be>");
-}
-
-static void
-gst_festival_class_init (GstFestivalClass * klass)
+ static void gst_festival_class_init (GstFestivalClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = G_OBJECT_CLASS (klass);
gstelement_class = GST_ELEMENT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_festival_finalize);
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_festival_change_state);
+
+ /* register pads */
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_template_factory));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_template_factory));
+
+ gst_element_class_set_details_simple (gstelement_class,
+ "Festival Text-to-Speech synthesizer", "Filter/Effect/Audio",
+ "Synthesizes plain text into audio",
+ "Wim Taymans <wim.taymans@chello.be>");
}
static void
g_free (festival->info);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gst_festival_parent_class)->finalize (object);
}
static gboolean
n += read (fd, ack + n, 3 - n);
ack[3] = '\0';
GST_DEBUG_OBJECT (festival, "got response %s", ack);
-
if (strcmp (ack, "WV\n") == 0) {
GstBuffer *buffer;
filesize);
/* push contents as a buffer */
- buffer = gst_buffer_new ();
- GST_BUFFER_SIZE (buffer) = (filesize);
- GST_BUFFER_DATA (buffer) = (guint8 *) data;
- GST_BUFFER_MALLOCDATA (buffer) = (guint8 *) data;
+ buffer = gst_buffer_new_wrapped (data, filesize);
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
-
gst_pad_push (festival->srcpad, buffer);
} else if (strcmp (ack, "LP\n") == 0) {
}
static GstFlowReturn
-gst_festival_chain (GstPad * pad, GstBuffer * buf)
+gst_festival_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstFestival *festival;
+ GstMapInfo info;
guint8 *p, *ep;
gint f;
FILE *fd;
- festival = GST_FESTIVAL (GST_PAD_PARENT (pad));
+ festival = GST_FESTIVAL (parent);
- GST_LOG_OBJECT (festival, "Got text buffer, %u bytes", GST_BUFFER_SIZE (buf));
+ GST_LOG_OBJECT (festival, "Got text buffer, %u bytes",
+ gst_buffer_get_size (buf));
f = dup (festival->info->server_fd);
if (f < 0)
}
fprintf (fd, "(tts_textall \"");
- p = GST_BUFFER_DATA (buf);
- ep = p + GST_BUFFER_SIZE (buf);
+ gst_buffer_map (buf, &info, GST_MAP_WRITE);
+ p = info.data;
+ ep = p + gst_buffer_get_size (buf);
for (; p < ep && (*p != '\0'); p++) {
if ((*p == '"') || (*p == '\\')) {
putc ('\\', fd);
}
}
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+ if (GST_ELEMENT_CLASS (gst_festival_parent_class)->change_state)
+ return GST_ELEMENT_CLASS (gst_festival_parent_class)->change_state (element,
+ transition);
return GST_STATE_CHANGE_SUCCESS;
}