gst-indent

Original commit message from CVS:
gst-indent
This commit is contained in:
Thomas Vander Stichele 2004-03-14 22:34:30 +00:00
parent 55594847ba
commit 908defa2c4
120 changed files with 11300 additions and 11450 deletions

View file

@ -1,3 +1,7 @@
2004-03-14 Thomas Vander Stichele <thomas at apestaart dot org>
* *.c, *.h: run gst-indent
2004-03-14 Benjamin Otte <otte@gnome.org>
* gst/modplug/gstmodplug.cc:

View file

@ -6,7 +6,7 @@
* connection would use the I420 format (assuming Xv is enabled) */
static void
new_pad_func (GstElement *element, GstPad *newpad, gpointer data)
new_pad_func (GstElement * element, GstPad * newpad, gpointer data)
{
GstElement *pipeline = (GstElement *) data;
GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue");
@ -19,7 +19,7 @@ new_pad_func (GstElement *element, GstPad *newpad, gpointer data)
}
gint
main (gint argc, gchar *argv[])
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *filesrc;
@ -44,7 +44,8 @@ main (gint argc, gchar *argv[])
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
demux = gst_element_factory_make ("mpegdemux", "demux");
g_return_val_if_fail (demux, -1);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func),
pipeline);
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
@ -58,7 +59,7 @@ main (gint argc, gchar *argv[])
gst_bin_add (GST_BIN (pipeline), filesrc);
gst_bin_add (GST_BIN (pipeline), demux);
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), mpeg2dec);
gst_bin_add (GST_BIN (thread), colorspace);
@ -70,11 +71,9 @@ main (gint argc, gchar *argv[])
gst_element_link (mpeg2dec, "src", colorspace, "sink");
/* force RGB data passing between colorspace and xvideosink */
res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink",
GST_CAPS_NEW (
"filtercaps",
"video/raw",
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
));
GST_CAPS_NEW ("filtercaps",
"video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
));
if (!res) {
g_print ("could not connect colorspace and xvideosink\n");
return -1;
@ -83,7 +82,7 @@ main (gint argc, gchar *argv[])
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL);
return 0;

View file

@ -18,13 +18,13 @@ struct _filter_ui
GtkWidget *window; /* top-level interface window */
GtkWidget *buttons; /* all of the control buttons */
GtkWidget *parse, *play, *stop; /* control buttons */
GtkWidget *parse, *play, *stop; /* control buttons */
GtkWidget *feedback; /* here's where we'll tell you stuff */
GtkTextBuffer *fb_buffer; /* feedback buffer */
GtkWidget *selection; /* the place to input element stuff */
GtkWidget *input, *filter, *output; /* the selection widgets */
GtkWidget *input, *filter, *output; /* the selection widgets */
GtkWidget *control; /* the dynamically generated control UI */
};
@ -33,13 +33,13 @@ typedef struct _filter_ui _filter_ui_t;
/* back-end data */
struct _filter_data
{
_filter_ui_t *ui; /* the UI data */
_filter_ui_t *ui; /* the UI data */
gchar *input_pipe, *output_pipe, *filter_element;
gchar *pipe_string;
GList *filter_choices;
gboolean playing;
GstElement *input, *output; /* these are in and out bins */
GstElement *input, *output; /* these are in and out bins */
GstElement *pipeline;
GstElement *filter;
};
@ -47,17 +47,18 @@ struct _filter_data
typedef struct _filter_data _filter_data_t;
/* internal prototypes when they can't be avoided */
void cb_remove_and_destroy (GtkWidget *widget, gpointer user_data);
//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data);
void cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam);
void cb_remove_and_destroy (GtkWidget * widget, gpointer user_data);
//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data);
void cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam);
/* GStreamer helper functions go here */
/* go through a bin, finding the one pad that is unconnected in the given
* direction, and return a ghost pad */
GstPad *
gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction,
gchar *name)
gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction,
gchar * name)
{
GstPad *pad = NULL;
GList *elements = NULL;
@ -67,39 +68,36 @@ gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction,
g_print ("DEBUG: find_unconnected start\n");
elements = (GList *) gst_bin_get_list (bin);
/* traverse all elements looking for unconnected pads */
while (elements && pad == NULL)
{
while (elements && pad == NULL) {
element = GST_ELEMENT (elements->data);
g_print ("DEBUG: looking in element %s\n", gst_element_get_name (element));
pads = gst_element_get_pad_list (element);
while (pads)
{
while (pads) {
/* check if the direction matches */
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction)
{
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL)
{
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) {
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) {
/* found it ! */
g_print ("DEBUG: found an unconnected pad !\n");
pad = GST_PAD (pads->data);
}
}
if (pad) break; /* found one already */
if (pad)
break; /* found one already */
pads = g_list_next (pads);
}
elements = g_list_next (elements);
}
g_print ("DEBUG: find_unconnected stop\n");
if (pad == NULL) /* we didn't find it at all */
if (pad == NULL) /* we didn't find it at all */
return NULL;
pad = gst_ghost_pad_new (name, pad);
return pad;
}
void
ui_feedback_add_text (_filter_ui_t *ui, const gchar *text)
ui_feedback_add_text (_filter_ui_t * ui, const gchar * text)
{
GtkTextIter iter;
@ -108,7 +106,7 @@ ui_feedback_add_text (_filter_ui_t *ui, const gchar *text)
}
void
ui_feedback_add (_filter_ui_t *ui, const gchar *format, ...)
ui_feedback_add (_filter_ui_t * ui, const gchar * format, ...)
{
va_list args;
gchar *buffer = NULL;
@ -121,7 +119,7 @@ ui_feedback_add (_filter_ui_t *ui, const gchar *format, ...)
}
void
ui_feedback_clear (_filter_ui_t *ui)
ui_feedback_clear (_filter_ui_t * ui)
{
gtk_text_buffer_set_text (ui->fb_buffer, "", 0);
}
@ -129,7 +127,7 @@ ui_feedback_clear (_filter_ui_t *ui)
/* create the control widget using the element's dynparams
* control is a vbox which we need to empty first */
void
ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui)
ui_control_create (GstElement * element, GtkWidget * control, _filter_ui_t * ui)
{
GtkWidget *hbox = NULL;
GtkWidget *widget = NULL;
@ -137,70 +135,63 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui)
GstDParam *dparam = NULL;
GParamSpec **specs = NULL;
int i = 0;
g_assert (GTK_IS_VBOX (control));
/* empty control vbox */
g_print ("DEBUG: emptying control widget\n");
gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy,
(gpointer) control);
gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy,
(gpointer) control);
g_print ("DEBUG: adding label to control widget\n");
widget = gtk_label_new ("Dynamic Parameters");
gtk_container_add (GTK_CONTAINER (control), widget);
gtk_widget_show (widget);
if ((dpman = gst_dpman_get_manager (element)))
{
if ((dpman = gst_dpman_get_manager (element))) {
ui_feedback_add (ui, "Found Dynamic Parameters on filter element.\n");
specs = gst_dpman_list_dparam_specs (dpman);
for (i = 0; specs[i] != NULL; ++i)
{
for (i = 0; specs[i] != NULL; ++i) {
hbox = gtk_hbox_new (FALSE, 0);
widget = gtk_label_new (g_param_spec_get_name (specs[i]));
gtk_container_add (GTK_CONTAINER (hbox), widget);
gtk_widget_show (widget);
switch (G_PARAM_SPEC_VALUE_TYPE (specs[i]))
{
case G_TYPE_INT64:
switch (G_PARAM_SPEC_VALUE_TYPE (specs[i])) {
case G_TYPE_INT64:
widget = gtk_hscale_new_with_range (
(gdouble) (((GParamSpecInt64*)specs[i])->minimum),
(gdouble) (((GParamSpecInt64*)specs[i])->maximum),
1.0);
(gdouble) (((GParamSpecInt64 *) specs[i])->minimum),
(gdouble) (((GParamSpecInt64 *) specs[i])->maximum), 1.0);
gtk_range_set_value (GTK_RANGE (widget),
(gdouble) ((GParamSpecInt64*)specs[i])->default_value);
break;
(gdouble) ((GParamSpecInt64 *) specs[i])->default_value);
break;
case G_TYPE_INT:
widget = gtk_hscale_new_with_range (
(gdouble) (((GParamSpecInt*)specs[i])->minimum),
(gdouble) (((GParamSpecInt*)specs[i])->maximum),
1.0);
(gdouble) (((GParamSpecInt *) specs[i])->minimum),
(gdouble) (((GParamSpecInt *) specs[i])->maximum), 1.0);
gtk_range_set_value (GTK_RANGE (widget),
(gdouble) ((GParamSpecInt*)specs[i])->default_value);
break;
case G_TYPE_FLOAT:
(gdouble) ((GParamSpecInt *) specs[i])->default_value);
break;
case G_TYPE_FLOAT:
widget = gtk_hscale_new_with_range (
(gdouble) (((GParamSpecFloat*)specs[i])->minimum),
(gdouble) (((GParamSpecFloat*)specs[i])->maximum),
0.00001);
(gdouble) (((GParamSpecFloat *) specs[i])->minimum),
(gdouble) (((GParamSpecFloat *) specs[i])->maximum), 0.00001);
gtk_range_set_value (GTK_RANGE (widget),
(gdouble) ((GParamSpecFloat*)specs[i])->default_value);
(gdouble) ((GParamSpecFloat *) specs[i])->default_value);
break;
}
/* create the dparam object */
dparam = gst_dpsmooth_new (G_PARAM_SPEC_VALUE_TYPE (specs[i]));
g_object_set (G_OBJECT (dparam), "update_period", 2000000LL, NULL);
g_assert (gst_dpman_attach_dparam (dpman,
(gchar *) g_param_spec_get_name (specs[i]),
dparam));
gst_dpman_set_mode(dpman, "asynchronous");
g_assert (gst_dpman_attach_dparam (dpman,
(gchar *) g_param_spec_get_name (specs[i]), dparam));
gst_dpman_set_mode (dpman, "asynchronous");
g_signal_connect (widget, "value-changed",
G_CALLBACK (cb_dynparm_value_changed), dparam);
G_CALLBACK (cb_dynparm_value_changed), dparam);
cb_dynparm_value_changed (GTK_RANGE (widget), dparam);
gtk_container_add (GTK_CONTAINER (hbox), widget);
gtk_widget_show (widget);
gtk_widget_show (widget);
}
gtk_container_add (GTK_CONTAINER (control), hbox);
gtk_widget_show (hbox);
@ -209,7 +200,7 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui)
/* all the pretty callbacks gather here please */
void
cb_remove_and_destroy (GtkWidget *widget, gpointer user_data)
cb_remove_and_destroy (GtkWidget * widget, gpointer user_data)
{
GtkContainer *container = GTK_CONTAINER (user_data);
@ -220,55 +211,51 @@ cb_remove_and_destroy (GtkWidget *widget, gpointer user_data)
/* when the scale associated with a dparam changes, respond */
void
cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam)
cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam)
{
/*
GstDParam *dparam = GST_DPARAM (user_data);
GtkHScale *adj = GTK_HSCALE (widget);
*/
GstDParam *dparam = GST_DPARAM (user_data);
GtkHScale *adj = GTK_HSCALE (widget);
*/
gdouble value = 0.0;
g_assert (GST_IS_DPARAM (dparam));
g_assert (GTK_IS_RANGE (range));
value = gtk_range_get_value (range);
g_print ("DEBUG: setting value to %f\n", value);
g_print ("DEBUG: setting value to %f\n", value);
switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam)))
{
switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam))) {
case G_TYPE_INT64:
g_object_set (G_OBJECT (dparam), "value_int64",
(gint64) value, NULL);
g_object_set (G_OBJECT (dparam), "value_int64", (gint64) value, NULL);
break;
case G_TYPE_INT:
g_object_set (G_OBJECT (dparam), "value_int",
(gint) value, NULL);
g_object_set (G_OBJECT (dparam), "value_int", (gint) value, NULL);
break;
case G_TYPE_FLOAT:
g_object_set (G_OBJECT (dparam), "value_float",
(gfloat) value, NULL);
g_object_set (G_OBJECT (dparam), "value_float", (gfloat) value, NULL);
break;
}
}
void
cb_entry_activate (GtkEntry *entry, gpointer user_data)
cb_entry_activate (GtkEntry * entry, gpointer user_data)
{
g_print ("DEBUG: oi ! you activated an entry !\n");
g_print ("DEBUG: pipeline: %s\n", gtk_entry_get_text (entry));
}
void
cb_play_clicked (GtkButton *button, gpointer *user_data)
cb_play_clicked (GtkButton * button, gpointer * user_data)
{
_filter_data_t *fd = (_filter_data_t *) user_data;
g_return_if_fail (GST_IS_PIPELINE (fd->pipeline));
if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING)
{
if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING) {
ui_feedback_add (fd->ui, "Pipeline is already playing !\n");
return;
}
@ -276,12 +263,11 @@ cb_play_clicked (GtkButton *button, gpointer *user_data)
}
void
cb_stop_clicked (GtkButton *button, gpointer *user_data)
cb_stop_clicked (GtkButton * button, gpointer * user_data)
{
_filter_data_t *fd = (_filter_data_t *) user_data;
if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING)
{
if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING) {
ui_feedback_add (fd->ui, "Pipeline is not playing !\n");
return;
}
@ -289,67 +275,72 @@ cb_stop_clicked (GtkButton *button, gpointer *user_data)
}
void
cb_parse_clicked (GtkButton *button, gpointer *user_data)
cb_parse_clicked (GtkButton * button, gpointer * user_data)
{
_filter_data_t *fd = (_filter_data_t *) user_data;
GtkCombo *filter = GTK_COMBO (fd->ui->filter);
GError *error = NULL;
GstPad *src_pad, *sink_pad;
g_print ("DEBUG: you pressed parse.\n");
ui_feedback_clear (fd->ui);
ui_feedback_add (fd->ui, "Parsing pipeline ...\n");
if (fd->input_pipe) g_free (fd->input_pipe);
if (fd->output_pipe) g_free (fd->output_pipe);
if (fd->filter_element) g_free (fd->filter_element);
if (fd->input_pipe)
g_free (fd->input_pipe);
if (fd->output_pipe)
g_free (fd->output_pipe);
if (fd->filter_element)
g_free (fd->filter_element);
fd->input_pipe = g_strdup_printf ("bin.( %s )",
gtk_entry_get_text (GTK_ENTRY (fd->ui->input)));
gtk_entry_get_text (GTK_ENTRY (fd->ui->input)));
fd->output_pipe = g_strdup_printf ("bin.( %s )",
gtk_entry_get_text (GTK_ENTRY (fd->ui->output)));
gtk_entry_get_text (GTK_ENTRY (fd->ui->output)));
/* gtkcombo.h says I can access the entry field directly */
fd->filter_element = g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry)));
g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe, (int)strlen (fd->input_pipe));
g_print ("Filter element :\t%s (%d)\n", fd->filter_element, (int)strlen (fd->filter_element));
g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe, (int)strlen (fd->output_pipe));
fd->filter_element =
g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry)));
g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe,
(int) strlen (fd->input_pipe));
g_print ("Filter element :\t%s (%d)\n", fd->filter_element,
(int) strlen (fd->filter_element));
g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe,
(int) strlen (fd->output_pipe));
/* try to create in and out bins */
if (strlen (fd->input_pipe) == 0)
{
if (strlen (fd->input_pipe) == 0) {
ui_feedback_add (fd->ui, "Error : try setting an input pipe.\n");
return;
}
if (fd->input) gst_object_unref (GST_OBJECT (fd->input));
if (fd->input)
gst_object_unref (GST_OBJECT (fd->input));
fd->input = GST_ELEMENT (gst_parse_launch (fd->input_pipe, &error));
if (error)
{
ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n",
error->message);
if (error) {
ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n",
error->message);
g_error_free (error);
return;
}
if (strlen (fd->output_pipe) == 0)
{
if (strlen (fd->output_pipe) == 0) {
ui_feedback_add (fd->ui, "Error : try setting an output pipe.\n");
return;
}
if (fd->output) gst_object_unref (GST_OBJECT (fd->output));
if (fd->output)
gst_object_unref (GST_OBJECT (fd->output));
fd->output = GST_ELEMENT (gst_parse_launch (fd->output_pipe, &error));
if (error)
{
ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n",
error->message);
if (error) {
ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n",
error->message);
g_error_free (error);
return;
}
/* try to create filter */
if (fd->filter) gst_object_unref (GST_OBJECT (fd->filter));
if (fd->filter)
gst_object_unref (GST_OBJECT (fd->filter));
fd->filter = gst_element_factory_make (fd->filter_element, "filter");
if (fd->filter == NULL)
{
if (fd->filter == NULL) {
ui_feedback_add (fd->ui, "Error : could not create element %s\n",
fd->filter_element);
fd->filter_element);
return;
}
@ -360,35 +351,33 @@ cb_parse_clicked (GtkButton *button, gpointer *user_data)
fd->pipeline = gst_thread_new ("toplevel");
/* add the players to it */
gst_bin_add_many (GST_BIN (fd->pipeline),
fd->input, fd->filter,
fd->output, NULL);
gst_bin_add_many (GST_BIN (fd->pipeline),
fd->input, fd->filter, fd->output, NULL);
/* connect filter to input and output bin */
src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC,
"source");
if (src_pad == NULL)
{
ui_feedback_add (fd->ui,
"Error : could not find an unconnected source pad !\n");
src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC,
"source");
if (src_pad == NULL) {
ui_feedback_add (fd->ui,
"Error : could not find an unconnected source pad !\n");
return;
}
sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK,
"sink");
if (sink_pad == NULL)
{
ui_feedback_add (fd->ui,
"Error : could not find an unconnected sink pad !\n");
sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK,
"sink");
if (sink_pad == NULL) {
ui_feedback_add (fd->ui,
"Error : could not find an unconnected sink pad !\n");
return;
}
gst_element_add_pad (fd->input, src_pad);
gst_element_add_pad (fd->output, sink_pad);
gst_element_link_many (fd->input, fd->filter, fd->output, NULL);
if (fd->pipe_string) g_free (fd->pipe_string);
if (fd->pipe_string)
g_free (fd->pipe_string);
fd->pipe_string = g_strdup_printf ("%s ! %s ! %s", fd->input_pipe,
fd->filter_element, fd->output_pipe);
fd->filter_element, fd->output_pipe);
g_print ("Pipeline : %s\n", fd->pipe_string);
ui_feedback_add (fd->ui, "Complete parsed pipeline: %s\n", fd->pipe_string);
@ -404,12 +393,12 @@ get_filter_choices (void)
choices = g_list_append (choices, "volume");
choices = g_list_append (choices, "ladspa_lpf");
choices = g_list_append (choices, "ladspa_hpf");
return choices;
}
void
init_data (_filter_data_t *fd)
init_data (_filter_data_t * fd)
{
fd->input_pipe = NULL;
fd->output_pipe = NULL;
@ -426,11 +415,11 @@ init_data (_filter_data_t *fd)
}
void
create_ui (_filter_ui_t *fui, _filter_data_t *fd)
create_ui (_filter_ui_t * fui, _filter_data_t * fd)
{
GtkWidget *widget; /* temporary widget */
GtkWidget *vbox; /* temporary vbox */
g_print ("DEBUG: creating top-level window\n");
fui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
widget = gtk_vbox_new (FALSE, 0);
@ -452,22 +441,22 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd)
fui->parse = gtk_button_new_with_label ("Parse");
gtk_container_add (GTK_CONTAINER (fui->buttons), fui->parse);
g_signal_connect (G_OBJECT (fui->parse), "clicked",
G_CALLBACK (cb_parse_clicked), fd);
G_CALLBACK (cb_parse_clicked), fd);
fui->play = gtk_button_new_with_label ("Play");
gtk_container_add (GTK_CONTAINER (fui->buttons), fui->play);
g_signal_connect (G_OBJECT (fui->play), "clicked",
G_CALLBACK (cb_play_clicked), fd);
G_CALLBACK (cb_play_clicked), fd);
fui->stop = gtk_button_new_with_label ("Stop");
gtk_container_add (GTK_CONTAINER (fui->buttons), fui->stop);
g_signal_connect (G_OBJECT (fui->stop), "clicked",
G_CALLBACK (cb_stop_clicked), fd);
G_CALLBACK (cb_stop_clicked), fd);
/* feedback widget */
fui->fb_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (fui->feedback));
gtk_text_buffer_set_text (fui->fb_buffer,
"Hello, and welcome to the GStreamer filter demo app !\n"\
gtk_text_buffer_set_text (fui->fb_buffer,
"Hello, and welcome to the GStreamer filter demo app !\n"
"I'll be your feedback window for today.\n", -1);
/* selection widget */
vbox = gtk_vbox_new (FALSE, 0);
widget = gtk_label_new ("Input Pipe");
@ -476,8 +465,8 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd)
gtk_entry_set_text (GTK_ENTRY (fui->input), "sinesrc");
gtk_container_add (GTK_CONTAINER (vbox), fui->input);
gtk_container_add (GTK_CONTAINER (fui->selection), vbox);
g_signal_connect (G_OBJECT (fui->input), "activate",
G_CALLBACK (cb_entry_activate), NULL);
g_signal_connect (G_OBJECT (fui->input), "activate",
G_CALLBACK (cb_entry_activate), NULL);
vbox = gtk_vbox_new (FALSE, 0);
widget = gtk_label_new ("Filter");
@ -491,18 +480,18 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd)
widget = gtk_label_new ("Output Pipe");
gtk_container_add (GTK_CONTAINER (vbox), widget);
fui->output = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */
gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */
gtk_container_add (GTK_CONTAINER (vbox), fui->output);
gtk_container_add (GTK_CONTAINER (fui->selection), vbox);
g_signal_connect (G_OBJECT (fui->output), "activate",
G_CALLBACK (cb_entry_activate), NULL);
g_signal_connect (G_OBJECT (fui->output), "activate",
G_CALLBACK (cb_entry_activate), NULL);
/* control widget is dynamically generated */
/*
g_print ("DEBUG: labeling control area.\n");
widget = gtk_label_new ("This is the big control area.");
gtk_container_add (GTK_CONTAINER (fui->control), widget);
*/
g_print ("DEBUG: labeling control area.\n");
widget = gtk_label_new ("This is the big control area.");
gtk_container_add (GTK_CONTAINER (fui->control), widget);
*/
}
@ -511,8 +500,8 @@ main (int argc, char *argv[])
{
_filter_data_t filter_data;
_filter_ui_t filter_ui;
gtk_init (&argc, &argv);
gst_init (&argc, &argv);
gst_control_init (&argc, &argv);
@ -524,7 +513,6 @@ main (int argc, char *argv[])
gtk_widget_show_all (filter_ui.window);
gtk_main ();
return 0;
}

View file

@ -16,14 +16,14 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/play/play.h>
static GMainLoop *loop = NULL;
static gint64 length = 0;
static void
print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{
gint i, count;
@ -31,14 +31,14 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
for (i = 0; i < count; i++) {
gchar *str;
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
str = g_strdup_value_contents (
gst_tag_list_get_value_index (list, tag, i));
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {
g_print ("%15s: %s\n", gst_tag_get_nick (tag), str);
} else {
@ -50,46 +50,46 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
}
static void
got_found_tag (GstPlay *play,GstElement *source, GstTagList *tag_list)
got_found_tag (GstPlay * play, GstElement * source, GstTagList * tag_list)
{
gst_tag_list_foreach (tag_list, print_tag, NULL);
}
static void
got_time_tick (GstPlay *play, gint64 time_nanos)
got_time_tick (GstPlay * play, gint64 time_nanos)
{
g_print ("time tick %f\n", time_nanos / (float) GST_SECOND);
}
static void
got_stream_length (GstPlay *play, gint64 length_nanos)
got_stream_length (GstPlay * play, gint64 length_nanos)
{
g_print ("got length %llu\n", length_nanos);
length = length_nanos;
}
static void
got_video_size (GstPlay *play, gint width, gint height)
got_video_size (GstPlay * play, gint width, gint height)
{
g_print ("got video size %d, %d\n", width, height);
}
static void
got_eos (GstPlay *play)
got_eos (GstPlay * play)
{
g_print ("End Of Stream\n");
g_main_loop_quit (loop);
}
static gboolean
seek_timer (GstPlay *play)
seek_timer (GstPlay * play)
{
gst_play_seek_to_time (play, length / 2);
return FALSE;
}
static gboolean
idle_iterate (GstPlay *play)
idle_iterate (GstPlay * play)
{
gst_bin_iterate (GST_BIN (play));
return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING);
@ -114,8 +114,7 @@ main (int argc, char *argv[])
/* Creating the GstPlay object */
play = gst_play_new (&error);
if (error)
{
if (error) {
g_print ("Error: could not create play object:\n%s\n", error->message);
g_error_free (error);
return 1;
@ -140,17 +139,16 @@ main (int argc, char *argv[])
/* gst_xml_write_file (GST_ELEMENT (play), stdout); */
g_signal_connect (G_OBJECT (play), "time_tick",
G_CALLBACK (got_time_tick), NULL);
G_CALLBACK (got_time_tick), NULL);
g_signal_connect (G_OBJECT (play), "stream_length",
G_CALLBACK (got_stream_length), NULL);
G_CALLBACK (got_stream_length), NULL);
g_signal_connect (G_OBJECT (play), "have_video_size",
G_CALLBACK (got_video_size), NULL);
G_CALLBACK (got_video_size), NULL);
g_signal_connect (G_OBJECT (play), "found_tag",
G_CALLBACK (got_found_tag), NULL);
G_CALLBACK (got_found_tag), NULL);
g_signal_connect (G_OBJECT (play), "error",
G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (G_OBJECT (play), "eos",
G_CALLBACK (got_eos), NULL);
G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL);
/* Change state to PLAYING */
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
@ -163,9 +161,9 @@ main (int argc, char *argv[])
g_print ("setting pipeline to ready\n");
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
/* unref
gst_object_unref (GST_OBJECT (play)); */
gst_object_unref (GST_OBJECT (play)); */
exit (0);
}

View file

@ -24,26 +24,26 @@ static gboolean verbose = FALSE;
static gboolean quiet = FALSE;
static void
entry_added (GstIndex *index, GstIndexEntry *entry)
entry_added (GstIndex * index, GstIndexEntry * entry)
{
switch (entry->type) {
case GST_INDEX_ENTRY_ID:
g_print ("id %d describes writer %s\n", entry->id,
GST_INDEX_ID_DESCRIPTION (entry));
g_print ("id %d describes writer %s\n", entry->id,
GST_INDEX_ID_DESCRIPTION (entry));
break;
case GST_INDEX_ENTRY_FORMAT:
g_print ("%d: registered format %d for %s\n", entry->id,
GST_INDEX_FORMAT_FORMAT (entry),
GST_INDEX_FORMAT_KEY (entry));
g_print ("%d: registered format %d for %s\n", entry->id,
GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_KEY (entry));
break;
case GST_INDEX_ENTRY_ASSOCIATION:
{
gint i;
g_print ("%p, %d: %08x ", entry, entry->id, GST_INDEX_ASSOC_FLAGS (entry));
g_print ("%p, %d: %08x ", entry, entry->id,
GST_INDEX_ASSOC_FLAGS (entry));
for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i),
GST_INDEX_ASSOC_VALUE (entry, i));
g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i),
GST_INDEX_ASSOC_VALUE (entry, i));
}
g_print ("\n");
break;
@ -55,15 +55,15 @@ entry_added (GstIndex *index, GstIndexEntry *entry)
typedef struct
{
const gchar *padname;
GstPad *target;
GstElement *bin;
GstElement *pipeline;
GstIndex *index;
const gchar *padname;
GstPad *target;
GstElement *bin;
GstElement *pipeline;
GstIndex *index;
} dyn_link;
static void
dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{
dyn_link *link = (dyn_link *) data;
@ -77,27 +77,25 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
}
static void
setup_dynamic_linking (GstElement *pipeline,
GstElement *element,
const gchar *padname,
GstPad *target,
GstElement *bin,
GstIndex *index)
setup_dynamic_linking (GstElement * pipeline,
GstElement * element,
const gchar * padname, GstPad * target, GstElement * bin, GstIndex * index)
{
dyn_link *link;
link = g_new0 (dyn_link, 1);
link->padname = g_strdup (padname);
link->target = target;
link->bin = bin;
link->pipeline = pipeline;
link->index = index;
link->padname = g_strdup (padname);
link->target = target;
link->bin = bin;
link->pipeline = pipeline;
link->index = index;
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link);
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
link);
}
static GstElement*
make_mpeg_systems_pipeline (const gchar *path, GstIndex *index)
static GstElement *
make_mpeg_systems_pipeline (const gchar * path, GstIndex * index)
{
GstElement *pipeline;
GstElement *src, *demux;
@ -117,12 +115,12 @@ make_mpeg_systems_pipeline (const gchar *path, GstIndex *index)
}
gst_element_link_pads (src, "src", demux, "sink");
return pipeline;
}
static GstElement*
make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
static GstElement *
make_mpeg_decoder_pipeline (const gchar * path, GstIndex * index)
{
GstElement *pipeline;
GstElement *src, *demux;
@ -145,29 +143,27 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
video_decoder = gst_element_factory_make ("mpeg2dec", "video_decoder");
gst_bin_add (GST_BIN (video_bin), video_decoder);
setup_dynamic_linking (pipeline, demux, "video_00",
gst_element_get_pad (video_decoder, "sink"),
video_bin, index);
setup_dynamic_linking (pipeline, demux, "video_00",
gst_element_get_pad (video_decoder, "sink"), video_bin, index);
audio_bin = gst_bin_new ("audio_bin");
audio_decoder = gst_element_factory_make ("mad", "audio_decoder");
setup_dynamic_linking (pipeline, demux, "audio_00",
gst_element_get_pad (audio_decoder, "sink"),
audio_bin, index);
setup_dynamic_linking (pipeline, demux, "audio_00",
gst_element_get_pad (audio_decoder, "sink"), audio_bin, index);
gst_bin_add (GST_BIN (audio_bin), audio_decoder);
if (index) {
gst_element_set_index (pipeline, index);
}
return pipeline;
}
static void
print_progress (GstPad *pad)
print_progress (GstPad * pad)
{
gint i = 0;
gchar status[53];
@ -181,14 +177,14 @@ print_progress (GstPad *pad)
format = GST_FORMAT_PERCENT;
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
if (res) {
percent = value / (2 * GST_FORMAT_PERCENT_SCALE);
percent = value / (2 * GST_FORMAT_PERCENT_SCALE);
}
for (i = 0; i < percent; i++) {
status[i+1] = '=';
status[i + 1] = '=';
}
for (i = percent; i < 50; i++) {
status[i+1] = ' ';
status[i + 1] = ' ';
}
status[51] = '|';
status[52] = 0;
@ -196,8 +192,8 @@ print_progress (GstPad *pad)
g_print ("%s\r", status);
}
gint
main (gint argc, gchar *argv[])
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *src;
@ -208,27 +204,28 @@ main (gint argc, gchar *argv[])
gboolean res;
GstElement *sink;
struct poptOption options[] = {
{ "verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0,
"Print index entries", NULL},
{ "quiet", 'q', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &quiet, 0,
"don't print progress bar", NULL},
POPT_TABLEEND
};
{"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0,
"Print index entries", NULL},
{"quiet", 'q', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &quiet, 0,
"don't print progress bar", NULL},
POPT_TABLEEND
};
if (!gst_init_check_with_popt_table (&argc, &argv, options) || argc < 3) {
g_print ("usage: %s [-v] <type> <filename> \n"
" type can be: 0 mpeg_systems\n"
" 1 mpeg_decoder\n"
" -v : report added index entries\n"
" -q : don't print progress\n" , argv[0]);
g_print ("usage: %s [-v] <type> <filename> \n"
" type can be: 0 mpeg_systems\n"
" 1 mpeg_decoder\n"
" -v : report added index entries\n"
" -q : don't print progress\n", argv[0]);
return -1;
}
/* create index that elements can fill */
index = gst_index_factory_make ("memindex");
if (index) {
if (verbose)
g_signal_connect (G_OBJECT (index), "entry_added", G_CALLBACK (entry_added), NULL);
if (verbose)
g_signal_connect (G_OBJECT (index), "entry_added",
G_CALLBACK (entry_added), NULL);
g_object_set (G_OBJECT (index), "resolver", 1, NULL);
}
@ -247,10 +244,10 @@ main (gint argc, gchar *argv[])
}
/* setup some default info/error handlers */
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (G_OBJECT (pipeline), "error",
G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (G_OBJECT (pipeline), "error",
G_CALLBACK (gst_element_default_error), NULL);
/* get a pad to perform progress reporting on */
src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
@ -259,7 +256,7 @@ main (gint argc, gchar *argv[])
/* prepare for iteration */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("indexing %s...\n", argv [2]);
g_print ("indexing %s...\n", argv[2]);
/* run through the complete stream to let it generate an index */
while (gst_bin_iterate (GST_BIN (pipeline))) {
if (!quiet && (count % 1000 == 0)) {
@ -285,24 +282,23 @@ main (gint argc, gchar *argv[])
gint total_tm;
gst_index_get_writer_id (index, GST_OBJECT (src), &id);
entry = gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_BEFORE, 0,
GST_FORMAT_TIME, G_MAXINT64);
GST_FORMAT_TIME, G_MAXINT64);
g_assert (entry);
gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &result);
total_tm = result * 60 / GST_SECOND;
g_print ("total time = %.2fs\n", total_tm / 60.0);
}
pad = gst_element_get_pad (src, "src");
sink = gst_element_factory_make ("fakesink", "sink");
gst_element_link_pads (src, "src", sink, "sink");
gst_bin_add (GST_BIN (pipeline), sink);
g_print ("seeking %s...\n", argv [2]);
g_print ("seeking %s...\n", argv[2]);
event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res) {
@ -322,4 +318,3 @@ main (gint argc, gchar *argv[])
return 1;
}

View file

@ -3,7 +3,7 @@
#include <string.h>
static void
get_position_info (GstElement *cdparanoia)
get_position_info (GstElement * cdparanoia)
{
GstFormat track_format;
const GstFormat *formats;
@ -24,14 +24,13 @@ get_position_info (GstElement *cdparanoia)
definition = gst_format_get_details (*formats);
format = *formats;
res = gst_pad_query (pad, GST_QUERY_POSITION,
&format, &position);
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &position);
if (format == GST_FORMAT_TIME) {
position /= GST_SECOND;
g_print ("%s: %lld:%02lld", definition->nick, position/60, position%60);
}
else {
g_print ("%s: %lld:%02lld", definition->nick, position / 60,
position % 60);
} else {
g_print ("%s: %lld", definition->nick, position);
}
@ -44,7 +43,7 @@ get_position_info (GstElement *cdparanoia)
}
static void
get_track_info (GstElement *cdparanoia)
get_track_info (GstElement * cdparanoia)
{
GstFormat track_format;
gint64 total_tracks = 0, total_time = 0;
@ -52,7 +51,7 @@ get_track_info (GstElement *cdparanoia)
const GstFormat *formats;
gint i;
gint64 time_count = 0;
track_format = gst_format_get_by_nick ("track");
g_assert (track_format != 0);
@ -66,26 +65,24 @@ get_track_info (GstElement *cdparanoia)
gint64 total;
GstFormat format;
gboolean res;
definition = gst_format_get_details (*formats);
format = *formats;
res = gst_pad_query (pad, GST_QUERY_TOTAL,
&format, &total);
res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &total);
if (res) {
if (format == GST_FORMAT_TIME) {
total /= GST_SECOND;
g_print ("%s total: %lld:%02lld\n", definition->nick, total/60, total%60);
}
else
g_print ("%s total: %lld\n", definition->nick, total);
g_print ("%s total: %lld:%02lld\n", definition->nick, total / 60,
total % 60);
} else
g_print ("%s total: %lld\n", definition->nick, total);
if (format == track_format)
total_tracks = total;
else if (format == GST_FORMAT_TIME)
total_time = total;
}
else
} else
g_print ("failed to get %s total\n", definition->nick);
formats++;
@ -102,11 +99,9 @@ get_track_info (GstElement *cdparanoia)
GstFormat format;
format = GST_FORMAT_TIME;
res = gst_pad_convert (pad, track_format, i,
&format, &time);
res = gst_pad_convert (pad, track_format, i, &format, &time);
time /= GST_SECOND;
}
else {
} else {
time = total_time;
res = TRUE;
}
@ -117,14 +112,12 @@ get_track_info (GstElement *cdparanoia)
if (i > 0) {
gint64 length = time - time_count;
g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n",
i-1,
time_count / 60, time_count % 60,
time / 60, time % 60,
length / 60, length % 60);
g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n",
i - 1,
time_count / 60, time_count % 60,
time / 60, time % 60, length / 60, length % 60);
}
}
else {
} else {
g_print ("could not get time for track %d\n", i);
}
@ -161,7 +154,7 @@ main (int argc, char **argv)
gst_element_link_pads (cdparanoia, "src", osssink, "sink");
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
G_CALLBACK (gst_element_default_deep_notify), NULL);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
@ -177,9 +170,7 @@ main (int argc, char **argv)
g_print ("playing from track 3\n");
/* seek to track3 */
event = gst_event_new_seek (track_format |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
3);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 3);
res = gst_pad_send_event (pad, event);
if (!res)
@ -198,9 +189,8 @@ main (int argc, char **argv)
g_print ("\nplaying from second 25 to second 29\n");
/* seek to some seconds */
event = gst_event_new_segment_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
25 * GST_SECOND, 29 * GST_SECOND);
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, 25 * GST_SECOND, 29 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res)
g_warning ("seek failed");

View file

@ -15,11 +15,11 @@ static guint update_id;
#define UPDATE_INTERVAL 500
static GstElement*
make_cdaudio_pipeline (void)
static GstElement *
make_cdaudio_pipeline (void)
{
GstElement *cdaudio;
cdaudio = gst_element_factory_make ("cdaudio", "cdaudio");
g_assert (cdaudio != NULL);
@ -28,9 +28,8 @@ make_cdaudio_pipeline (void)
return cdaudio;
}
static gchar*
format_value (GtkScale *scale,
gdouble value)
static gchar *
format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
@ -41,9 +40,7 @@ format_value (GtkScale *scale,
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
seconds/60,
seconds%60,
subseconds%100);
seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
@ -52,13 +49,12 @@ typedef struct
const GstFormat format;
} seek_format;
static seek_format seek_formats[] =
{
{ "tim", GST_FORMAT_TIME },
{ "byt", GST_FORMAT_BYTES },
{ "buf", GST_FORMAT_BUFFERS },
{ "def", GST_FORMAT_DEFAULT },
{ NULL, 0 },
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
{"byt", GST_FORMAT_BYTES},
{"buf", GST_FORMAT_BUFFERS},
{"def", GST_FORMAT_DEFAULT},
{NULL, 0},
};
@ -80,10 +76,9 @@ query_durations ()
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -110,10 +105,9 @@ query_positions ()
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -123,7 +117,7 @@ query_positions ()
}
static gboolean
update_scale (gpointer data)
update_scale (gpointer data)
{
GstClock *clock;
guint64 position = 0;
@ -134,6 +128,7 @@ update_scale (gpointer data)
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
if (clock)
@ -141,7 +136,8 @@ update_scale (gpointer data)
if (stats) {
if (clock)
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
}
@ -167,7 +163,7 @@ iterate (gpointer data)
}
static gboolean
start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
@ -176,7 +172,7 @@ start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
}
static gboolean
stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
@ -188,8 +184,7 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
@ -199,7 +194,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
@ -211,7 +207,8 @@ play_cb (GtkButton * button, gpointer data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -236,22 +233,23 @@ stop_cb (GtkButton * button, gpointer data)
int
main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button,
*hscale;
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
{"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
POPT_TABLEEND
};
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
POPT_TABLEEND
};
gst_init_with_popt_table (&argc, &argv, options);
gtk_init (&argc, &argv);
pipeline = make_cdaudio_pipeline ();
g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (pipeline, "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
NULL);
/* initialize gui elements ... */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -261,17 +259,18 @@ main (int argc, char **argv)
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
gtk_signal_connect(GTK_OBJECT(hscale),
"button_press_event", G_CALLBACK (start_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
"button_release_event", G_CALLBACK (stop_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
"format_value", G_CALLBACK (format_value), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"button_press_event", G_CALLBACK (start_seek), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"button_release_event", G_CALLBACK (stop_seek), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"format_value", G_CALLBACK (format_value), pipeline);
/* do the packing stuff ... */
gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
@ -283,9 +282,12 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */

View file

@ -25,26 +25,25 @@ static guint update_id;
typedef struct
{
const gchar *padname;
GstPad *target;
GstElement *bin;
const gchar *padname;
GstPad *target;
GstElement *bin;
} dyn_link;
static GstElement *
gst_element_factory_make_or_warn (gchar *type, gchar *name)
gst_element_factory_make_or_warn (gchar * type, gchar * name)
{
GstElement *element = gst_element_factory_make (type, name);
if (!element) {
g_warning ("Failed to create element %s of type %s",
name, type);
g_warning ("Failed to create element %s of type %s", name, type);
}
return element;
}
static void
dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{
dyn_link *connect = (dyn_link *) data;
@ -60,25 +59,27 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
}
static void
setup_dynamic_link (GstElement *element, const gchar *padname, GstPad *target, GstElement *bin)
setup_dynamic_link (GstElement * element, const gchar * padname,
GstPad * target, GstElement * bin)
{
dyn_link *connect;
connect = g_new0 (dyn_link, 1);
connect->padname = g_strdup (padname);
connect->target = target;
connect->bin = bin;
connect->padname = g_strdup (padname);
connect->target = target;
connect->bin = bin;
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), connect);
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
connect);
}
static GstElement*
make_mod_pipeline (const gchar *location)
static GstElement *
make_mod_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -103,13 +104,13 @@ make_mod_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_dv_pipeline (const gchar *location)
static GstElement *
make_dv_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink, *videosink;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -140,13 +141,13 @@ make_dv_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_wav_pipeline (const gchar *location)
static GstElement *
make_wav_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -171,13 +172,13 @@ make_wav_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_flac_pipeline (const gchar *location)
static GstElement *
make_flac_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -202,13 +203,13 @@ make_flac_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_sid_pipeline (const gchar *location)
static GstElement *
make_sid_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -233,13 +234,13 @@ make_sid_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_parse_pipeline (const gchar *location)
static GstElement *
make_parse_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *parser, *fakesink;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -265,13 +266,13 @@ make_parse_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_vorbis_pipeline (const gchar *location)
static GstElement *
make_vorbis_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -296,13 +297,13 @@ make_vorbis_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_mp3_pipeline (const gchar *location)
static GstElement *
make_mp3_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *osssink, *queue, *audio_thread;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -335,14 +336,15 @@ make_mp3_pipeline (const gchar *location)
return pipeline;
}
static GstElement*
make_avi_pipeline (const gchar *location)
static GstElement *
make_avi_pipeline (const gchar * location)
{
GstElement *pipeline, *audio_bin, *video_bin;
GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink;
GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue = NULL, *video_thread = NULL;
GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue =
NULL, *video_thread = NULL;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -369,12 +371,14 @@ make_avi_pipeline (const gchar *location)
gst_bin_add (GST_BIN (audio_thread), audiosink);
gst_element_set_state (audio_bin, GST_STATE_PAUSED);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
//v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec");
@ -395,25 +399,27 @@ make_avi_pipeline (const gchar *location)
gst_element_set_state (video_bin, GST_STATE_PAUSED);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
"sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
static GstElement*
make_mpeg_pipeline (const gchar *location)
static GstElement *
make_mpeg_pipeline (const gchar * location)
{
GstElement *pipeline, *audio_bin, *video_bin;
GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
GstElement *audiosink, *videosink;
GstElement *a_queue, *audio_thread, *v_queue, *video_thread;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -441,12 +447,14 @@ make_mpeg_pipeline (const gchar *location)
gst_bin_add (GST_BIN (audio_thread), a_queue);
gst_bin_add (GST_BIN (audio_thread), audiosink);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
@ -456,30 +464,32 @@ make_mpeg_pipeline (const gchar *location)
v_filter = gst_element_factory_make_or_warn ("colorspace", "v_filter");
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
gst_element_link_many (v_decoder, v_queue, v_filter, NULL);
gst_element_link (v_filter, videosink);
gst_bin_add_many (GST_BIN (video_bin), v_decoder, video_thread, NULL);
gst_bin_add_many (GST_BIN (video_thread), v_queue, v_filter, videosink, NULL);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
"sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
static GstElement*
make_mpegnt_pipeline (const gchar *location)
static GstElement *
make_mpegnt_pipeline (const gchar * location)
{
GstElement *pipeline, *audio_bin, *video_bin;
GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
GstElement *audiosink, *videosink;
GstElement *a_queue, *audio_thread;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
@ -508,40 +518,43 @@ make_mpegnt_pipeline (const gchar *location)
gst_bin_add (GST_BIN (audio_thread), a_queue);
gst_bin_add (GST_BIN (audio_thread), audiosink);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
v_filter = gst_element_factory_make_or_warn ("colorspace", "v_filter");
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
gst_element_link_many (v_decoder, v_filter, videosink, NULL);
gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
"sink"), video_bin);
seekable = gst_element_get_pad (v_decoder, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
static GstElement*
make_playerbin_pipeline (const gchar *location)
static GstElement *
make_playerbin_pipeline (const gchar * location)
{
return NULL;
}
static gchar*
format_value (GtkScale *scale,
gdouble value)
static gchar *
format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
@ -552,9 +565,7 @@ format_value (GtkScale *scale,
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
seconds/60,
seconds%60,
subseconds%100);
seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
@ -563,13 +574,12 @@ typedef struct
const GstFormat format;
} seek_format;
static seek_format seek_formats[] =
{
{ "tim", GST_FORMAT_TIME },
{ "byt", GST_FORMAT_BYTES },
{ "buf", GST_FORMAT_BUFFERS },
{ "def", GST_FORMAT_DEFAULT },
{ NULL, 0 },
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
{"byt", GST_FORMAT_BYTES},
{"buf", GST_FORMAT_BUFFERS},
{"def", GST_FORMAT_DEFAULT},
{NULL, 0},
};
G_GNUC_UNUSED static void
@ -588,13 +598,10 @@ query_rates (void)
format = seek_formats[i].format;
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND,
&format, &value))
{
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -623,15 +630,14 @@ query_durations ()
format = seek_formats[i].format;
res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
walk = g_list_next (walk);
}
}
@ -654,10 +660,9 @@ query_positions ()
format = seek_formats[i].format;
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -668,7 +673,7 @@ query_positions ()
}
static gboolean
update_scale (gpointer data)
update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
@ -679,12 +684,14 @@ update_scale (gpointer data)
if (seekable_pads) {
GstPad *pad = GST_PAD (seekable_pads->data);
gst_pad_query (pad, GST_QUERY_TOTAL, &format, &duration);
}
position = gst_clock_get_time (clock);
if (stats) {
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
@ -711,7 +718,7 @@ iterate (gpointer data)
}
static gboolean
start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
@ -720,21 +727,23 @@ start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
}
static gboolean
stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
GstEvent *s_event;
#ifdef PAD_SEEK
GList *walk = seekable_pads;
while (walk) {
GstPad *seekable = GST_PAD (walk->data);
g_print ("seek to %lld on pad %s:%s\n", real, GST_DEBUG_PAD_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
g_print ("seek to %lld on pad %s:%s\n", real,
GST_DEBUG_PAD_NAME (seekable));
s_event =
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
res = gst_pad_send_event (seekable, s_event);
@ -746,10 +755,11 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
while (walk) {
GstElement *seekable = GST_ELEMENT (walk->data);
g_print ("seek to %lld on element %s\n", real, gst_element_get_name (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
g_print ("seek to %lld on element %s\n", real,
gst_element_get_name (seekable));
s_event =
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
@ -759,7 +769,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
@ -770,7 +781,8 @@ play_cb (GtkButton * button, gpointer data)
if (gst_element_get_state (pipeline) != GST_STATE_PLAYING) {
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -795,23 +807,23 @@ stop_cb (GtkButton * button, gpointer data)
typedef struct
{
gchar *name;
GstElement* (*func) (const gchar *location);
GstElement *(*func) (const gchar * location);
} Pipeline;
static Pipeline pipelines[] = {
{ "mp3", make_mp3_pipeline },
{ "avi", make_avi_pipeline },
{ "mpeg1", make_mpeg_pipeline },
{ "mpegparse", make_parse_pipeline },
{ "vorbis", make_vorbis_pipeline },
{ "sid", make_sid_pipeline },
{ "flac", make_flac_pipeline },
{ "wav", make_wav_pipeline },
{ "mod", make_mod_pipeline },
{ "dv", make_dv_pipeline },
{ "mpeg1nothreads", make_mpegnt_pipeline },
{ "playerbin", make_playerbin_pipeline },
{ NULL, NULL},
{"mp3", make_mp3_pipeline},
{"avi", make_avi_pipeline},
{"mpeg1", make_mpeg_pipeline},
{"mpegparse", make_parse_pipeline},
{"vorbis", make_vorbis_pipeline},
{"sid", make_sid_pipeline},
{"flac", make_flac_pipeline},
{"wav", make_wav_pipeline},
{"mod", make_mod_pipeline},
{"dv", make_dv_pipeline},
{"mpeg1nothreads", make_mpegnt_pipeline},
{"playerbin", make_playerbin_pipeline},
{NULL, NULL},
};
#define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
@ -832,16 +844,15 @@ print_usage (int argc, char **argv)
int
main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button,
*hscale;
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
{ "stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
"Show pad stats", NULL },
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show pad stats", NULL},
POPT_TABLEEND
};
gint type;
gst_init_with_popt_table (&argc, &argv, options);
gtk_init (&argc, &argv);
@ -868,17 +879,18 @@ main (int argc, char **argv)
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
gtk_signal_connect(GTK_OBJECT(hscale),
"button_press_event", G_CALLBACK (start_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
"button_release_event", G_CALLBACK (stop_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
"format_value", G_CALLBACK (format_value), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"button_press_event", G_CALLBACK (start_seek), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"button_release_event", G_CALLBACK (stop_seek), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"format_value", G_CALLBACK (format_value), pipeline);
/* do the packing stuff ... */
gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
@ -890,16 +902,21 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */
gtk_widget_show_all (window);
g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (pipeline, "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
NULL);
gtk_main ();

View file

@ -19,19 +19,19 @@ static guint update_id;
#define UPDATE_INTERVAL 500
static GstElement*
make_spider_pipeline (const gchar *location, gboolean thread)
static GstElement *
make_spider_pipeline (const gchar * location, gboolean thread)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread, *a_queue, *v_queue;
GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread,
*a_queue, *v_queue;
if (thread) {
pipeline = gst_thread_new ("app");
}
else {
} else {
pipeline = gst_pipeline_new ("app");
}
src = gst_element_factory_make (SOURCE, "src");
decoder = gst_element_factory_make ("spider", "decoder");
@ -64,15 +64,16 @@ make_spider_pipeline (const gchar *location, gboolean thread)
seekable_elements = g_list_prepend (seekable_elements, videosink);
seekable_elements = g_list_prepend (seekable_elements, audiosink);
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink"));
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink"));
rate_pads =
g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink"));
return pipeline;
}
static gchar*
format_value (GtkScale *scale,
gdouble value)
static gchar *
format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
@ -83,9 +84,7 @@ format_value (GtkScale *scale,
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
seconds/60,
seconds%60,
subseconds%100);
seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
@ -94,13 +93,12 @@ typedef struct
const GstFormat format;
} seek_format;
static seek_format seek_formats[] =
{
{ "tim", GST_FORMAT_TIME },
{ "byt", GST_FORMAT_BYTES },
{ "buf", GST_FORMAT_BUFFERS },
{ "def", GST_FORMAT_DEFAULT },
{ NULL, 0 },
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
{"byt", GST_FORMAT_BYTES},
{"buf", GST_FORMAT_BUFFERS},
{"def", GST_FORMAT_DEFAULT},
{NULL, 0},
};
G_GNUC_UNUSED static void
@ -119,13 +117,10 @@ query_rates (void)
format = seek_formats[i].format;
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND,
&format, &value))
{
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -154,10 +149,9 @@ query_durations ()
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -184,10 +178,9 @@ query_positions ()
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
if (res) {
g_print ("%s %13lld | ", seek_formats[i].name, value);
}
else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -197,7 +190,7 @@ query_positions ()
}
static gboolean
update_scale (gpointer data)
update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
@ -208,12 +201,14 @@ update_scale (gpointer data)
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
position = gst_clock_get_time (clock);
if (stats) {
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
@ -239,7 +234,7 @@ iterate (gpointer data)
}
static gboolean
start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
@ -248,7 +243,7 @@ start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
}
static gboolean
stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
@ -260,8 +255,7 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
@ -271,7 +265,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
@ -283,7 +278,8 @@ play_cb (GtkButton * button, gpointer data)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -308,17 +304,16 @@ stop_cb (GtkButton * button, gpointer data)
int
main (int argc, char **argv)
{
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button,
*hscale;
GtkWidget *window, *hbox, *vbox,
*play_button, *pause_button, *stop_button, *hscale;
gboolean threaded = FALSE;
struct poptOption options[] = {
{"threaded", 't', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &threaded, 0,
"Run the pipeline in a toplevel thread", NULL},
{"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
POPT_TABLEEND
};
{"threaded", 't', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &threaded, 0,
"Run the pipeline in a toplevel thread", NULL},
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
POPT_TABLEEND
};
gst_init_with_popt_table (&argc, &argv, options);
gtk_init (&argc, &argv);
@ -338,17 +333,18 @@ main (int argc, char **argv)
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
gtk_signal_connect(GTK_OBJECT(hscale),
"button_press_event", G_CALLBACK (start_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
"button_release_event", G_CALLBACK (stop_seek), pipeline);
gtk_signal_connect(GTK_OBJECT(hscale),
"format_value", G_CALLBACK (format_value), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"button_press_event", G_CALLBACK (start_seek), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"button_release_event", G_CALLBACK (stop_seek), pipeline);
gtk_signal_connect (GTK_OBJECT (hscale),
"format_value", G_CALLBACK (format_value), pipeline);
/* do the packing stuff ... */
gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
@ -360,9 +356,12 @@ main (int argc, char **argv)
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
pipeline);
g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
pipeline);
g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */

View file

@ -4,34 +4,37 @@
static gboolean ready = FALSE;
struct probe_context {
struct probe_context
{
GstElement *pipeline;
GstElement *element;
GstPad *pad;
GstFormat ls_format;
GstPad *pad;
GstFormat ls_format;
gint total_ls;
gint total_ls;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
};
static void
print_caps (GstCaps *caps)
print_caps (GstCaps * caps)
{
char *s;
s = gst_caps_to_string (caps);
g_print(" %s\n", s);
g_print (" %s\n", s);
g_free (s);
}
static void
print_format (GstCaps *caps)
print_format (GstCaps * caps)
{
char *s;
s = gst_caps_to_string (caps);
g_print(" format: %s\n", s);
g_print (" format: %s\n", s);
g_free (s);
}
@ -61,35 +64,31 @@ print_lbs_info (struct probe_context *context, gint stream)
definition = gst_format_get_details (format);
/* get start and end position of this stream */
res = gst_pad_convert (context->pad,
context->ls_format, stream,
&format, &value_start);
res = gst_pad_convert (context->pad,
context->ls_format, stream, &format, &value_start);
res &= gst_pad_convert (context->pad,
context->ls_format, stream + 1,
&format, &value_end);
context->ls_format, stream + 1, &format, &value_end);
if (res) {
/* substract to get the length */
value_end -= value_start;
if (format == GST_FORMAT_TIME) {
value_end /= (GST_SECOND/100);
g_print (" %s: %lld:%02lld.%02lld\n", definition->nick,
value_end/6000, (value_end/100)%60, (value_end%100));
value_end /= (GST_SECOND / 100);
g_print (" %s: %lld:%02lld.%02lld\n", definition->nick,
value_end / 6000, (value_end / 100) % 60, (value_end % 100));
} else {
g_print (" %s: %lld\n", definition->nick, value_end);
}
else {
g_print (" %s: %lld\n", definition->nick, value_end);
}
}
else
} else
g_print (" could not get logical stream %s\n", definition->nick);
}
}
static void
deep_notify (GObject *object, GstObject *origin,
GParamSpec *pspec, gpointer data)
deep_notify (GObject * object, GstObject * origin,
GParamSpec * pspec, gpointer data)
{
struct probe_context *context = (struct probe_context *) data;
GValue value = { 0, };
@ -99,8 +98,7 @@ deep_notify (GObject *object, GstObject *origin,
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
context->metadata = g_value_peek_pointer (&value);
}
else if (!strcmp (pspec->name, "streaminfo")) {
} else if (!strcmp (pspec->name, "streaminfo")) {
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
@ -127,9 +125,7 @@ collect_logical_stream_properties (struct probe_context *context, gint stream)
/* seek to stream */
event = gst_event_new_seek (context->ls_format |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
stream);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, stream);
res = gst_pad_send_event (context->pad, event);
if (!res) {
g_warning ("seek to logical track failed");
@ -141,7 +137,8 @@ collect_logical_stream_properties (struct probe_context *context, gint stream)
ready = FALSE;
while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) {
count++;
if (count > 10) break;
if (count > 10)
break;
}
print_caps (context->metadata);
@ -177,21 +174,19 @@ collect_stream_properties (struct probe_context *context)
format = *formats;
formats++;
res = gst_pad_query (context->pad, GST_QUERY_TOTAL,
&format, &value);
res = gst_pad_query (context->pad, GST_QUERY_TOTAL, &format, &value);
definition = gst_format_get_details (format);
if (res) {
if (format == GST_FORMAT_TIME) {
value /= (GST_SECOND/100);
g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick,
value/6000, (value/100)%60, (value%100));
}
else {
if (format == context->ls_format)
context->total_ls = value;
g_print (" total %s: %lld\n", definition->nick, value);
value /= (GST_SECOND / 100);
g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick,
value / 6000, (value / 100) % 60, (value % 100));
} else {
if (format == context->ls_format)
context->total_ls = value;
g_print (" total %s: %lld\n", definition->nick, value);
}
}
}
@ -248,7 +243,7 @@ main (int argc, char **argv)
context->ls_format = logical_stream_format;
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (deep_notify), context);
G_CALLBACK (deep_notify), context);
gst_element_set_state (pipeline, GST_STATE_PLAYING);

View file

@ -24,8 +24,8 @@
* compression status of mpeg audio to ogg vorbis transcoding.
*/
gint
main (gint argc, gchar *argv[])
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GError *error = NULL;
@ -34,21 +34,22 @@ main (gint argc, gchar *argv[])
GstPad *dec_sink, *enc_src;
gst_init (&argc, &argv);
if (argc < 3) {
g_print ("usage: %s <inputfile> <outputfile>\n", argv[0]);
return -1;
}
description = g_strdup_printf ("filesrc location=\"%s\" ! mad name=decoder ! "
"vorbisenc name=encoder ! filesink location=\"%s\"", argv[1], argv[2]);
"vorbisenc name=encoder ! filesink location=\"%s\"", argv[1], argv[2]);
pipeline = GST_ELEMENT (gst_parse_launch (description, &error));
if (!pipeline) {
if (error)
g_print ("ERROR: pipeline could not be constructed: %s\n", error->message);
g_print ("ERROR: pipeline could not be constructed: %s\n",
error->message);
else
g_print ("ERROR: pipeline could not be constructed\n");
g_print ("ERROR: pipeline could not be constructed\n");
return -1;
}
@ -57,7 +58,7 @@ main (gint argc, gchar *argv[])
dec_sink = gst_element_get_pad (decoder, "sink");
enc_src = gst_element_get_pad (encoder, "src");
if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
g_print ("pipeline doesn't want to play\n");
return -1;
@ -71,33 +72,29 @@ main (gint argc, gchar *argv[])
format = GST_FORMAT_TIME;
/* get the position */
gst_pad_query (enc_src, GST_QUERY_POSITION,
&format, &position);
gst_pad_query (enc_src, GST_QUERY_POSITION, &format, &position);
/* get the total duration */
gst_pad_query (enc_src, GST_QUERY_TOTAL,
&format, &duration);
gst_pad_query (enc_src, GST_QUERY_TOTAL, &format, &duration);
format = GST_FORMAT_BYTES;
/* see how many bytes are genereated per 8 seconds (== bitrate) */
gst_pad_convert (enc_src, GST_FORMAT_TIME, 8 * GST_SECOND,
&format, &bitrate_enc);
&format, &bitrate_enc);
gst_pad_convert (dec_sink, GST_FORMAT_TIME, 8 * GST_SECOND,
&format, &bitrate_dec);
&format, &bitrate_dec);
g_print ("[%2dm %.2ds] of [%2dm %.2ds], "
"src avg bitrate: %lld, dest avg birate: %lld, ratio [%02.2f] \r",
(gint)(position / (GST_SECOND * 60)),
(gint)(position / (GST_SECOND)) % 60,
(gint)(duration / (GST_SECOND * 60)),
(gint)(duration / (GST_SECOND)) % 60,
bitrate_dec,
bitrate_enc,
(gfloat)bitrate_dec/bitrate_enc);
"src avg bitrate: %lld, dest avg birate: %lld, ratio [%02.2f] \r",
(gint) (position / (GST_SECOND * 60)),
(gint) (position / (GST_SECOND)) % 60,
(gint) (duration / (GST_SECOND * 60)),
(gint) (duration / (GST_SECOND)) % 60,
bitrate_dec, bitrate_enc, (gfloat) bitrate_dec / bitrate_enc);
}
g_print ("\n");
return 0;
}

View file

@ -16,7 +16,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -28,38 +28,36 @@ static GMainLoop *loop = NULL;
static void
got_eos (GstElement *pipeline)
got_eos (GstElement * pipeline)
{
g_main_loop_quit (loop);
}
static gboolean
idle_iterate (GstElement *pipeline)
idle_iterate (GstElement * pipeline)
{
gst_bin_iterate (GST_BIN (pipeline));
return (GST_STATE (GST_ELEMENT (pipeline)) == GST_STATE_PLAYING);
}
static gboolean
switch_timer (GstElement *video_switch)
switch_timer (GstElement * video_switch)
{
gint nb_sources, active_source;
g_object_get (G_OBJECT (video_switch), "nb_sources", &nb_sources, NULL);
g_object_get (G_OBJECT (video_switch), "active_source",
&active_source, NULL);
active_source ++;
g_object_get (G_OBJECT (video_switch), "active_source", &active_source, NULL);
active_source++;
if (active_source > nb_sources - 1)
active_source = 0;
g_object_set (G_OBJECT (video_switch), "active_source",
active_source, NULL);
g_object_set (G_OBJECT (video_switch), "active_source", active_source, NULL);
g_message ("current number of sources : %d, active source %d",
nb_sources, active_source);
nb_sources, active_source);
return (GST_STATE (GST_ELEMENT (video_switch)) == GST_STATE_PLAYING);
}
@ -72,7 +70,7 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
pipeline = gst_pipeline_new ("pipeline");
src1 = gst_element_factory_make ("videotestsrc", "src1");
g_object_set (G_OBJECT (src1), "pattern", 0, NULL);
@ -80,26 +78,25 @@ main (int argc, char *argv[])
g_object_set (G_OBJECT (src2), "pattern", 1, NULL);
video_switch = gst_element_factory_make ("switch", "video_switch");
video_sink = gst_element_factory_make ("ximagesink", "video_sink");
gst_bin_add_many (GST_BIN (pipeline), src1, src2, video_switch,
video_sink, NULL);
video_sink, NULL);
gst_element_link (src1, video_switch);
gst_element_link (src2, video_switch);
gst_element_link (video_switch, video_sink);
g_signal_connect (G_OBJECT (pipeline), "eos",
G_CALLBACK (got_eos), NULL);
g_signal_connect (G_OBJECT (pipeline), "eos", G_CALLBACK (got_eos), NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
g_idle_add ((GSourceFunc) idle_iterate, pipeline);
g_timeout_add (2000, (GSourceFunc) switch_timer, video_switch);
g_main_loop_run (loop);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
/* unref */
gst_object_unref (GST_OBJECT (pipeline));

View file

@ -57,43 +57,37 @@ enum
* "audio/a52" and "audio/ac3" are the same format. The name
* "ac3" is now deprecated and should not be used in new code.
*/
static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-ac3")
);
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-ac3")
);
static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 4000, 48000 ], "
"channels = (int) [ 1, 6 ]"
)
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 4000, 48000 ], " "channels = (int) [ 1, 6 ]")
);
static void gst_a52dec_base_init (gpointer g_class);
static void gst_a52dec_class_init (GstA52DecClass * klass);
static void gst_a52dec_init (GstA52Dec * a52dec);
static void gst_a52dec_base_init (gpointer g_class);
static void gst_a52dec_class_init (GstA52DecClass * klass);
static void gst_a52dec_init (GstA52Dec * a52dec);
static void gst_a52dec_loop (GstElement * element);
static GstElementStateReturn
gst_a52dec_change_state (GstElement * element);
static void gst_a52dec_loop (GstElement * element);
static GstElementStateReturn gst_a52dec_change_state (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 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 }; */
GType
@ -103,8 +97,8 @@ gst_a52dec_get_type (void)
if (!a52dec_type) {
static const GTypeInfo a52dec_info = {
sizeof (GstA52DecClass),
gst_a52dec_base_init,
sizeof (GstA52DecClass),
gst_a52dec_base_init,
NULL, (GClassInitFunc) gst_a52dec_class_init,
NULL,
NULL,
@ -113,7 +107,8 @@ gst_a52dec_get_type (void)
(GInstanceInitFunc) gst_a52dec_init,
};
a52dec_type = g_type_register_static (GST_TYPE_ELEMENT, "GstA52Dec", &a52dec_info, 0);
a52dec_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstA52Dec", &a52dec_info, 0);
}
return a52dec_type;
}
@ -141,9 +136,8 @@ gst_a52dec_class_init (GstA52DecClass * 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));
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;
@ -155,13 +149,15 @@ static void
gst_a52dec_init (GstA52Dec * a52dec)
{
/* create the sink and src pads */
a52dec->sinkpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (a52dec), "sink"), "sink");
a52dec->sinkpad =
gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
(a52dec), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->sinkpad);
gst_element_set_loop_function ((GstElement *) a52dec, gst_a52dec_loop);
a52dec->srcpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (a52dec), "src"), "src");
a52dec->srcpad =
gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
(a52dec), "src"), "src");
gst_pad_use_explicit_caps (a52dec->srcpad);
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->srcpad);
@ -190,87 +186,87 @@ float_to_int (float *_f, int16_t * s16, int flags)
switch (flags) {
case A52_MONO:
for (i = 0; i < 256; i++) {
s16[5 * i] = s16[5 * i + 1] = s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i]);
s16[5 * i] = s16[5 * i + 1] = s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i]);
}
break;
case A52_CHANNEL:
case A52_STEREO:
case A52_DOLBY:
for (i = 0; i < 256; i++) {
s16[2 * i] = convert (f[i]);
s16[2 * i + 1] = convert (f[i + 256]);
s16[2 * i] = convert (f[i]);
s16[2 * i + 1] = convert (f[i + 256]);
}
break;
case A52_3F:
for (i = 0; i < 256; i++) {
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i + 256]);
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i + 256]);
}
break;
case A52_2F2R:
for (i = 0; i < 256; i++) {
s16[4 * i] = convert (f[i]);
s16[4 * i + 1] = convert (f[i + 256]);
s16[4 * i + 2] = convert (f[i + 512]);
s16[4 * i + 3] = convert (f[i + 768]);
s16[4 * i] = convert (f[i]);
s16[4 * i + 1] = convert (f[i + 256]);
s16[4 * i + 2] = convert (f[i + 512]);
s16[4 * i + 3] = convert (f[i + 768]);
}
break;
case A52_3F2R:
for (i = 0; i < 256; i++) {
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = convert (f[i + 768]);
s16[5 * i + 3] = convert (f[i + 1024]);
s16[5 * i + 4] = convert (f[i + 256]);
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = convert (f[i + 768]);
s16[5 * i + 3] = convert (f[i + 1024]);
s16[5 * i + 4] = convert (f[i + 256]);
}
break;
case A52_MONO | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = s16[6 * i + 1] = s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 256]);
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = s16[6 * i + 1] = s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 256]);
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_CHANNEL | A52_LFE:
case A52_STEREO | A52_LFE:
case A52_DOLBY | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = s16[6 * i + 3] = s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = s16[6 * i + 3] = s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_3F | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_2F2R | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = convert (f[i + 768]);
s16[6 * i + 3] = convert (f[i + 1024]);
s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = convert (f[i + 768]);
s16[6 * i + 3] = convert (f[i + 1024]);
s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_3F2R | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = convert (f[i + 1024]);
s16[6 * i + 3] = convert (f[i + 1280]);
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = convert (f[i + 1024]);
s16[6 * i + 3] = convert (f[i + 1280]);
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
}
break;
}
@ -310,7 +306,8 @@ gst_a52dec_channels (int flags)
}
static int
gst_a52dec_push (GstPad * srcpad, int flags, sample_t * _samples, gint64 timestamp)
gst_a52dec_push (GstPad * srcpad, int flags, sample_t * _samples,
gint64 timestamp)
{
GstBuffer *buf;
int chans;
@ -348,21 +345,19 @@ gst_a52dec_push (GstPad * srcpad, int flags, sample_t * _samples, gint64 timesta
static void
gst_a52dec_reneg (GstPad * pad, int channels, int rate)
{
GST_INFO ( "a52dec: reneg channels:%d rate:%d\n", channels, rate);
GST_INFO ("a52dec: reneg channels:%d rate:%d\n", channels, rate);
gst_pad_set_explicit_caps (pad,
gst_pad_set_explicit_caps (pad,
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, rate,
NULL));
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL));
}
static void
gst_a52dec_handle_event (GstA52Dec *a52dec)
gst_a52dec_handle_event (GstA52Dec * a52dec)
{
guint32 remaining;
GstEvent *event;
@ -385,27 +380,26 @@ gst_a52dec_handle_event (GstA52Dec *a52dec)
#if 0
static void
gst_a52dec_update_streaminfo (GstA52Dec *a52dec)
gst_a52dec_update_streaminfo (GstA52Dec * a52dec)
{
GstProps *props;
GstPropsEntry *entry;
props = gst_props_empty_new ();
entry = gst_props_entry_new ("bitrate", GST_PROPS_INT (a52dec->bit_rate));
gst_props_add_entry (props, (GstPropsEntry *) entry);
gst_caps_unref (a52dec->streaminfo);
a52dec->streaminfo = gst_caps_new ("a52dec_streaminfo",
"application/x-gst-streaminfo",
props);
"application/x-gst-streaminfo", props);
g_object_notify (G_OBJECT (a52dec), "streaminfo");
}
#endif
static void
gst_a52dec_loop (GstElement *element)
gst_a52dec_loop (GstElement * element)
{
GstA52Dec *a52dec;
guint8 *data;
@ -429,8 +423,7 @@ gst_a52dec_loop (GstElement *element)
if (length == 0) {
/* slide window to next 7 bytesa */
gst_bytestream_flush_fast (a52dec->bs, 1);
}
else
} else
break;
/* FIXME this can potentially be an infinite loop, we might
@ -460,8 +453,7 @@ gst_a52dec_loop (GstElement *element)
timestamp = gst_bytestream_get_timestamp (a52dec->bs);
if (timestamp == a52dec->last_ts) {
timestamp = a52dec->current_ts;
}
else {
} else {
a52dec->last_ts = timestamp;
}
@ -483,9 +475,9 @@ gst_a52dec_loop (GstElement *element)
if (need_reneg == TRUE) {
GST_DEBUG ("a52dec reneg: sample_rate:%d stream_chans:%d using_chans:%d\n",
a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
gst_a52dec_reneg (a52dec->srcpad,
gst_a52dec_channels (a52dec->using_channels), a52dec->sample_rate);
gst_a52dec_channels (a52dec->using_channels), a52dec->sample_rate);
}
if (a52dec->dynamic_range_compression == FALSE) {
@ -498,10 +490,10 @@ gst_a52dec_loop (GstElement *element)
continue;
}
/* push on */
if (gst_a52dec_push (a52dec->srcpad, a52dec->using_channels, a52dec->samples, timestamp)) {
if (gst_a52dec_push (a52dec->srcpad, a52dec->using_channels,
a52dec->samples, timestamp)) {
g_warning ("a52dec push error\n");
}
else {
} else {
timestamp += sizeof (int16_t) * 256 * GST_SECOND / a52dec->sample_rate;
}
}
@ -558,7 +550,8 @@ gst_a52dec_change_state (GstElement * element)
}
static void
gst_a52dec_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
gst_a52dec_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
GstA52Dec *src;
@ -577,7 +570,8 @@ gst_a52dec_set_property (GObject * object, guint prop_id, const GValue * value,
}
static void
gst_a52dec_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
gst_a52dec_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstA52Dec *src;
@ -602,20 +596,15 @@ plugin_init (GstPlugin * plugin)
if (!gst_library_load ("gstbytestream"))
return FALSE;
if (!gst_element_register (plugin, "a52dec", GST_RANK_PRIMARY, GST_TYPE_A52DEC))
if (!gst_element_register (plugin, "a52dec", GST_RANK_PRIMARY,
GST_TYPE_A52DEC))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"a52dec",
"Decodes ATSC A/52 encoded audio streams",
plugin_init,
VERSION,
"GPL",
GST_PACKAGE,
GST_ORIGIN
);
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"a52dec",
"Decodes ATSC A/52 encoded audio streams",
plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN);

View file

@ -25,7 +25,6 @@
#include <gst/bytestream/bytestream.h>
G_BEGIN_DECLS
#define GST_TYPE_A52DEC \
(gst_a52dec_get_type())
#define GST_A52DEC(obj) \
@ -36,38 +35,37 @@ G_BEGIN_DECLS
(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 _GstA52Dec GstA52Dec;
typedef struct _GstA52DecClass GstA52DecClass;
struct _GstA52Dec {
GstElement element;
struct _GstA52Dec
{
GstElement element;
/* pads */
GstPad *sinkpad,
*srcpad;
int bit_rate;
int sample_rate;
int stream_channels;
int request_channels;
int using_channels;
GstPad *sinkpad, *srcpad;
int bit_rate;
int sample_rate;
int stream_channels;
int request_channels;
int using_channels;
sample_t level;
sample_t bias;
gboolean dynamic_range_compression;
sample_t *samples;
a52_state_t *state;
sample_t level;
sample_t bias;
gboolean dynamic_range_compression;
sample_t *samples;
a52_state_t *state;
GstByteStream *bs;
GstClockTime last_ts;
GstClockTime current_ts;
GstClockTime last_ts;
GstClockTime current_ts;
};
struct _GstA52DecClass {
struct _GstA52DecClass
{
GstElementClass parent_class;
};
G_END_DECLS
#endif /* __GST_A52DEC_H__ */

File diff suppressed because it is too large Load diff

View file

@ -4,144 +4,155 @@
GstPipeline *pipeline;
GstElement *v_queue, *a_queue, *v_thread, *a_thread;
GtkWidget *appwindow;
GtkWidget *gtk_socket;
GtkWidget *gtk_socket;
void eof(GstElement *src) {
g_print("have eos, quitting\n");
exit(0);
void
eof (GstElement * src)
{
g_print ("have eos, quitting\n");
exit (0);
}
gboolean idle_func(gpointer data) {
gst_bin_iterate(GST_BIN(data));
gboolean
idle_func (gpointer data)
{
gst_bin_iterate (GST_BIN (data));
return TRUE;
}
void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
void
mpeg2parse_newpad (GstElement * parser, GstPad * pad, GstElement * pipeline)
{
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
g_print ("***** a new pad %s was created\n", gst_pad_get_name (pad));
if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
gst_pad_link(pad, gst_element_get_pad(v_queue,"sink"));
gst_bin_add(GST_BIN(pipeline),v_thread);
gst_element_set_state(v_thread,GST_STATE_PLAYING);
} else if (strcmp(gst_pad_get_name(pad), "private_stream_1.0") == 0) {
gst_pad_link(pad, gst_element_get_pad(a_queue,"sink"));
gst_bin_add(GST_BIN(pipeline),a_thread);
gst_element_set_state(a_thread,GST_STATE_PLAYING);
if (strncmp (gst_pad_get_name (pad), "video_", 6) == 0) {
gst_pad_link (pad, gst_element_get_pad (v_queue, "sink"));
gst_bin_add (GST_BIN (pipeline), v_thread);
gst_element_set_state (v_thread, GST_STATE_PLAYING);
} else if (strcmp (gst_pad_get_name (pad), "private_stream_1.0") == 0) {
gst_pad_link (pad, gst_element_get_pad (a_queue, "sink"));
gst_bin_add (GST_BIN (pipeline), a_thread);
gst_element_set_state (a_thread, GST_STATE_PLAYING);
}
}
void mpeg2parse_have_size(GstElement *videosink,gint width,gint height) {
gtk_widget_set_usize(gtk_socket,width,height);
gtk_widget_show_all(appwindow);
void
mpeg2parse_have_size (GstElement * videosink, gint width, gint height)
{
gtk_widget_set_usize (gtk_socket, width, height);
gtk_widget_show_all (appwindow);
}
int main(int argc,char *argv[]) {
int
main (int argc, char *argv[])
{
GstElement *src, *parse;
GstElement *v_decode, *show, *color;
GstElement *a_decode, *osssink;
if (argc < 5) {
g_print("usage: %s dvdlocation title chapter angle\n", argv[0]);
exit(1);
g_print ("usage: %s dvdlocation title chapter angle\n", argv[0]);
exit (1);
}
gst_init(&argc,&argv);
gnome_init("MPEG2 Video player","0.0.1",argc,argv);
gst_init (&argc, &argv);
gnome_init ("MPEG2 Video player", "0.0.1", argc, argv);
/* ***** construct the main pipeline ***** */
pipeline = GST_PIPELINE(gst_pipeline_new("pipeline"));
g_return_val_if_fail(pipeline != NULL, -1);
pipeline = GST_PIPELINE (gst_pipeline_new ("pipeline"));
g_return_val_if_fail (pipeline != NULL, -1);
src = gst_element_factory_make("dvdreadsrc","src");
g_return_val_if_fail(src != NULL, -1);
gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
gtk_object_set(GTK_OBJECT(src),"title",atoi(argv[2]),NULL);
gtk_object_set(GTK_OBJECT(src),"chapter",atoi(argv[3]),NULL);
gtk_object_set(GTK_OBJECT(src),"angle",atoi(argv[4]),NULL);
src = gst_element_factory_make ("dvdreadsrc", "src");
g_return_val_if_fail (src != NULL, -1);
gtk_object_set (GTK_OBJECT (src), "location", argv[1], NULL);
gtk_object_set (GTK_OBJECT (src), "title", atoi (argv[2]), NULL);
gtk_object_set (GTK_OBJECT (src), "chapter", atoi (argv[3]), NULL);
gtk_object_set (GTK_OBJECT (src), "angle", atoi (argv[4]), NULL);
parse = gst_element_factory_make("mpeg2parse","parse");
parse = gst_element_factory_make ("mpeg2parse", "parse");
/*parse = gst_element_factory_make("mpeg1parse","parse"); */
g_return_val_if_fail(parse != NULL, -1);
g_return_val_if_fail (parse != NULL, -1);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (parse));
gst_element_link(src,"src",parse,"sink");
gst_element_link (src, "src", parse, "sink");
/* ***** pre-construct the video thread ***** */
v_thread = GST_ELEMENT(gst_thread_new("v_thread"));
g_return_val_if_fail(v_thread != NULL, -1);
v_thread = GST_ELEMENT (gst_thread_new ("v_thread"));
g_return_val_if_fail (v_thread != NULL, -1);
v_queue = gst_element_factory_make("queue","v_queue");
g_return_val_if_fail(v_queue != NULL, -1);
v_queue = gst_element_factory_make ("queue", "v_queue");
g_return_val_if_fail (v_queue != NULL, -1);
v_decode = gst_element_factory_make("mpeg2dec","decode_video");
g_return_val_if_fail(v_decode != NULL, -1);
v_decode = gst_element_factory_make ("mpeg2dec", "decode_video");
g_return_val_if_fail (v_decode != NULL, -1);
color = gst_element_factory_make("colorspace","color");
g_return_val_if_fail(color != NULL, -1);
color = gst_element_factory_make ("colorspace", "color");
g_return_val_if_fail (color != NULL, -1);
show = gst_element_factory_make("xvideosink","show");
g_return_val_if_fail(show != NULL, -1);
show = gst_element_factory_make ("xvideosink", "show");
g_return_val_if_fail (show != NULL, -1);
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(v_queue));
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(v_decode));
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(color));
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(show));
gst_bin_add (GST_BIN (v_thread), GST_ELEMENT (v_queue));
gst_bin_add (GST_BIN (v_thread), GST_ELEMENT (v_decode));
gst_bin_add (GST_BIN (v_thread), GST_ELEMENT (color));
gst_bin_add (GST_BIN (v_thread), GST_ELEMENT (show));
gst_element_link(v_queue,"src",v_decode,"sink");
gst_element_link(v_decode,"src",color,"sink");
gst_element_link(color,"src",show,"sink");
gst_element_link (v_queue, "src", v_decode, "sink");
gst_element_link (v_decode, "src", color, "sink");
gst_element_link (color, "src", show, "sink");
/* ***** pre-construct the audio thread ***** */
a_thread = GST_ELEMENT(gst_thread_new("a_thread"));
g_return_val_if_fail(a_thread != NULL, -1);
a_thread = GST_ELEMENT (gst_thread_new ("a_thread"));
g_return_val_if_fail (a_thread != NULL, -1);
a_queue = gst_element_factory_make("queue","a_queue");
g_return_val_if_fail(a_queue != NULL, -1);
a_decode = gst_element_factory_make("a52dec","decode_audio");
g_return_val_if_fail(a_decode != NULL, -1);
a_queue = gst_element_factory_make ("queue", "a_queue");
g_return_val_if_fail (a_queue != NULL, -1);
osssink = gst_element_factory_make("osssink","osssink");
g_return_val_if_fail(osssink != NULL, -1);
a_decode = gst_element_factory_make ("a52dec", "decode_audio");
g_return_val_if_fail (a_decode != NULL, -1);
gst_bin_add(GST_BIN(a_thread),GST_ELEMENT(a_queue));
gst_bin_add(GST_BIN(a_thread),GST_ELEMENT(a_decode));
gst_bin_add(GST_BIN(a_thread),GST_ELEMENT(osssink));
osssink = gst_element_factory_make ("osssink", "osssink");
g_return_val_if_fail (osssink != NULL, -1);
gst_element_link(a_queue,"src",a_decode,"sink");
gst_element_link(a_decode,"src",osssink,"sink");
gst_bin_add (GST_BIN (a_thread), GST_ELEMENT (a_queue));
gst_bin_add (GST_BIN (a_thread), GST_ELEMENT (a_decode));
gst_bin_add (GST_BIN (a_thread), GST_ELEMENT (osssink));
gst_element_link (a_queue, "src", a_decode, "sink");
gst_element_link (a_decode, "src", osssink, "sink");
/* ***** construct the GUI ***** */
appwindow = gnome_app_new("DVD Player","DVD Player");
appwindow = gnome_app_new ("DVD Player", "DVD Player");
gtk_socket = gtk_socket_new ();
gtk_widget_show (gtk_socket);
gnome_app_set_contents(GNOME_APP(appwindow),
GTK_WIDGET(gtk_socket));
gnome_app_set_contents (GNOME_APP (appwindow), GTK_WIDGET (gtk_socket));
gtk_widget_realize (gtk_socket);
gtk_socket_steal (GTK_SOCKET (gtk_socket),
gst_util_get_int_arg (GTK_OBJECT(show), "xid"));
gtk_socket_steal (GTK_SOCKET (gtk_socket),
gst_util_get_int_arg (GTK_OBJECT (show), "xid"));
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",mpeg2parse_newpad, pipeline);
gtk_signal_connect(GTK_OBJECT(src),"eos",GTK_SIGNAL_FUNC(eof),NULL);
gtk_signal_connect(GTK_OBJECT(show),"have_size",mpeg2parse_have_size, pipeline);
gtk_signal_connect (GTK_OBJECT (parse), "new_pad", mpeg2parse_newpad,
pipeline);
gtk_signal_connect (GTK_OBJECT (src), "eos", GTK_SIGNAL_FUNC (eof), NULL);
gtk_signal_connect (GTK_OBJECT (show), "have_size", mpeg2parse_have_size,
pipeline);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
g_print ("setting to PLAYING state\n");
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
gtk_idle_add(idle_func,pipeline);
gtk_idle_add (idle_func, pipeline);
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
gdk_threads_enter ();
gtk_main ();
gdk_threads_leave ();
return 0;
}

View file

@ -62,7 +62,8 @@
#include <dvdread/nav_read.h>
#include <dvdread/nav_print.h>
struct _DVDReadSrcPrivate {
struct _DVDReadSrcPrivate
{
GstElement element;
/* pads */
GstPad *srcpad;
@ -94,12 +95,14 @@ GstElementDetails dvdreadsrc_details = {
/* DVDReadSrc signals and args */
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
ARG_LOCATION,
ARG_TITLE,
@ -107,41 +110,47 @@ enum {
ARG_ANGLE
};
static void dvdreadsrc_base_init (gpointer g_class);
static void dvdreadsrc_class_init (DVDReadSrcClass *klass);
static void dvdreadsrc_init (DVDReadSrc *dvdreadsrc);
static void dvdreadsrc_base_init (gpointer g_class);
static void dvdreadsrc_class_init (DVDReadSrcClass * klass);
static void dvdreadsrc_init (DVDReadSrc * dvdreadsrc);
static void dvdreadsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void dvdreadsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void dvdreadsrc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void dvdreadsrc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
/*static GstData * dvdreadsrc_get (GstPad *pad); */
static void dvdreadsrc_loop (GstElement *element);
static void dvdreadsrc_loop (GstElement * element);
/*static GstBuffer * dvdreadsrc_get_region (GstPad *pad,gulong offset,gulong size); */
static GstElementStateReturn dvdreadsrc_change_state (GstElement *element);
static GstElementStateReturn dvdreadsrc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
/*static guint dvdreadsrc_signals[LAST_SIGNAL] = { 0 }; */
GType
dvdreadsrc_get_type (void)
dvdreadsrc_get_type (void)
{
static GType dvdreadsrc_type = 0;
if (!dvdreadsrc_type) {
static const GTypeInfo dvdreadsrc_info = {
sizeof(DVDReadSrcClass),
sizeof (DVDReadSrcClass),
dvdreadsrc_base_init,
NULL,
(GClassInitFunc)dvdreadsrc_class_init,
(GClassInitFunc) dvdreadsrc_class_init,
NULL,
NULL,
sizeof(DVDReadSrc),
sizeof (DVDReadSrc),
0,
(GInstanceInitFunc)dvdreadsrc_init,
(GInstanceInitFunc) dvdreadsrc_init,
};
dvdreadsrc_type = g_type_register_static (GST_TYPE_ELEMENT, "DVDReadSrc", &dvdreadsrc_info, 0);
dvdreadsrc_type =
g_type_register_static (GST_TYPE_ELEMENT, "DVDReadSrc",
&dvdreadsrc_info, 0);
}
return dvdreadsrc_type;
}
@ -155,44 +164,45 @@ dvdreadsrc_base_init (gpointer g_class)
}
static void
dvdreadsrc_class_init (DVDReadSrcClass *klass)
dvdreadsrc_class_init (DVDReadSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
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_LOCATION,
g_param_spec_string("location","location","location",
NULL, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TITLE,
g_param_spec_int("title","title","title",
0,G_MAXINT,0,G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CHAPTER,
g_param_spec_int("chapter","chapter","chapter",
0,G_MAXINT,0,G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ANGLE,
g_param_spec_int("angle","angle","angle",
0,G_MAXINT,0,G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
g_param_spec_string ("location", "location", "location",
NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TITLE,
g_param_spec_int ("title", "title", "title",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHAPTER,
g_param_spec_int ("chapter", "chapter", "chapter",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ANGLE,
g_param_spec_int ("angle", "angle", "angle",
0, G_MAXINT, 0, G_PARAM_READWRITE));
gobject_class->set_property = GST_DEBUG_FUNCPTR(dvdreadsrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR(dvdreadsrc_get_property);
gobject_class->set_property = GST_DEBUG_FUNCPTR (dvdreadsrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (dvdreadsrc_get_property);
gstelement_class->change_state = dvdreadsrc_change_state;
}
static void
dvdreadsrc_init (DVDReadSrc *dvdreadsrc)
static void
dvdreadsrc_init (DVDReadSrc * dvdreadsrc)
{
dvdreadsrc->priv = g_new(DVDReadSrcPrivate, 1);
dvdreadsrc->priv = g_new (DVDReadSrcPrivate, 1);
dvdreadsrc->priv->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (dvdreadsrc), dvdreadsrc->priv->srcpad);
gst_element_set_loop_function (GST_ELEMENT(dvdreadsrc), GST_DEBUG_FUNCPTR(dvdreadsrc_loop));
gst_element_set_loop_function (GST_ELEMENT (dvdreadsrc),
GST_DEBUG_FUNCPTR (dvdreadsrc_loop));
dvdreadsrc->priv->location = g_strdup("/dev/dvd");
dvdreadsrc->priv->location = g_strdup ("/dev/dvd");
dvdreadsrc->priv->new_seek = FALSE;
dvdreadsrc->priv->title = 1;
dvdreadsrc->priv->chapter = 1;
@ -202,23 +212,24 @@ dvdreadsrc_init (DVDReadSrc *dvdreadsrc)
/* FIXME: this code is not being used */
#ifdef PLEASEFIXTHISCODE
static void
dvdreadsrc_destroy (DVDReadSrc *dvdreadsrc)
dvdreadsrc_destroy (DVDReadSrc * dvdreadsrc)
{
/* FIXME */
g_print("FIXME\n");
g_free(dvdreadsrc->priv);
g_print ("FIXME\n");
g_free (dvdreadsrc->priv);
}
#endif
static void
dvdreadsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
static void
dvdreadsrc_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
DVDReadSrc *src;
DVDReadSrcPrivate *priv;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DVDREADSRC (object));
src = DVDREADSRC (object);
priv = src->priv;
@ -228,13 +239,13 @@ dvdreadsrc_set_property (GObject *object, guint prop_id, const GValue *value, GP
/*g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */
if (priv->location)
g_free (priv->location);
g_free (priv->location);
/* clear the filename if we get a NULL (is that possible?) */
if (g_value_get_string (value) == NULL)
priv->location = g_strdup("/dev/dvd");
priv->location = g_strdup ("/dev/dvd");
/* otherwise set the new filename */
else
priv->location = g_strdup (g_value_get_string (value));
priv->location = g_strdup (g_value_get_string (value));
break;
case ARG_TITLE:
priv->title = g_value_get_int (value) - 1;
@ -254,15 +265,16 @@ dvdreadsrc_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
static void
dvdreadsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
static void
dvdreadsrc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
DVDReadSrc *src;
DVDReadSrcPrivate *priv;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DVDREADSRC (object));
src = DVDREADSRC (object);
priv = src->priv;
@ -291,23 +303,23 @@ dvdreadsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
* need to make this stronger.
*/
static int
is_nav_pack( unsigned char *buffer )
is_nav_pack (unsigned char *buffer)
{
return ( buffer[ 41 ] == 0xbf && buffer[ 1027 ] == 0xbf );
return (buffer[41] == 0xbf && buffer[1027] == 0xbf);
}
static int
_open(DVDReadSrcPrivate *priv, const gchar *location)
_open (DVDReadSrcPrivate * priv, const gchar * location)
{
g_return_val_if_fail(priv != NULL, -1);
g_return_val_if_fail(location != NULL, -1);
g_return_val_if_fail (priv != NULL, -1);
g_return_val_if_fail (location != NULL, -1);
/**
* Open the disc.
*/
priv->dvd = DVDOpen( location );
if( !priv->dvd ) {
fprintf( stderr, "Couldn't open DVD: %s\n", location );
priv->dvd = DVDOpen (location);
if (!priv->dvd) {
fprintf (stderr, "Couldn't open DVD: %s\n", location);
return -1;
}
@ -316,10 +328,10 @@ _open(DVDReadSrcPrivate *priv, const gchar *location)
* Load the video manager to find out the information about the titles on
* this disc.
*/
priv->vmg_file = ifoOpen( priv->dvd, 0 );
if( !priv->vmg_file ) {
fprintf( stderr, "Can't open VMG info.\n" );
DVDClose( priv->dvd );
priv->vmg_file = ifoOpen (priv->dvd, 0);
if (!priv->vmg_file) {
fprintf (stderr, "Can't open VMG info.\n");
DVDClose (priv->dvd);
return -1;
}
priv->tt_srpt = priv->vmg_file->tt_srpt;
@ -328,102 +340,104 @@ _open(DVDReadSrcPrivate *priv, const gchar *location)
}
static int
_close(DVDReadSrcPrivate *priv)
_close (DVDReadSrcPrivate * priv)
{
ifoClose( priv->vts_file );
ifoClose( priv->vmg_file );
DVDCloseFile( priv->dvd_title );
DVDClose( priv->dvd );
return 0;
ifoClose (priv->vts_file);
ifoClose (priv->vmg_file);
DVDCloseFile (priv->dvd_title);
DVDClose (priv->dvd);
return 0;
}
static int
_seek(DVDReadSrcPrivate *priv, int title, int chapter, int angle)
_seek (DVDReadSrcPrivate * priv, int title, int chapter, int angle)
{
/**
* Make sure our title number is valid.
*/
fprintf( stderr, "There are %d titles on this DVD.\n",
priv->tt_srpt->nr_of_srpts );
if( title < 0 || title >= priv->tt_srpt->nr_of_srpts ) {
fprintf( stderr, "Invalid title %d.\n", title + 1 );
ifoClose( priv->vmg_file );
DVDClose( priv->dvd );
return -1;
}
fprintf (stderr, "There are %d titles on this DVD.\n",
priv->tt_srpt->nr_of_srpts);
if (title < 0 || title >= priv->tt_srpt->nr_of_srpts) {
fprintf (stderr, "Invalid title %d.\n", title + 1);
ifoClose (priv->vmg_file);
DVDClose (priv->dvd);
return -1;
}
/**
* Make sure the chapter number is valid for this title.
*/
fprintf( stderr, "There are %d chapters in this title.\n",
priv->tt_srpt->title[ title ].nr_of_ptts );
fprintf (stderr, "There are %d chapters in this title.\n",
priv->tt_srpt->title[title].nr_of_ptts);
if( chapter < 0 || chapter >= priv->tt_srpt->title[ title ].nr_of_ptts ) {
fprintf( stderr, "Invalid chapter %d\n", chapter + 1 );
ifoClose( priv->vmg_file );
DVDClose( priv->dvd );
return -1;
}
if (chapter < 0 || chapter >= priv->tt_srpt->title[title].nr_of_ptts) {
fprintf (stderr, "Invalid chapter %d\n", chapter + 1);
ifoClose (priv->vmg_file);
DVDClose (priv->dvd);
return -1;
}
/**
* Make sure the angle number is valid for this title.
*/
fprintf( stderr, "There are %d angles in this title.\n",
priv->tt_srpt->title[ title ].nr_of_angles );
if( angle < 0 || angle >= priv->tt_srpt->title[ title ].nr_of_angles ) {
fprintf( stderr, "Invalid angle %d\n", angle + 1 );
ifoClose( priv->vmg_file );
DVDClose( priv->dvd );
return -1;
}
fprintf (stderr, "There are %d angles in this title.\n",
priv->tt_srpt->title[title].nr_of_angles);
if (angle < 0 || angle >= priv->tt_srpt->title[title].nr_of_angles) {
fprintf (stderr, "Invalid angle %d\n", angle + 1);
ifoClose (priv->vmg_file);
DVDClose (priv->dvd);
return -1;
}
/**
* Load the VTS information for the title set our title is in.
*/
priv->vts_file = ifoOpen( priv->dvd, priv->tt_srpt->title[ title ].title_set_nr );
if( !priv->vts_file ) {
fprintf( stderr, "Can't open the title %d info file.\n",
priv->tt_srpt->title[ title ].title_set_nr );
ifoClose( priv->vmg_file );
DVDClose( priv->dvd );
return -1;
}
priv->vts_file =
ifoOpen (priv->dvd, priv->tt_srpt->title[title].title_set_nr);
if (!priv->vts_file) {
fprintf (stderr, "Can't open the title %d info file.\n",
priv->tt_srpt->title[title].title_set_nr);
ifoClose (priv->vmg_file);
DVDClose (priv->dvd);
return -1;
}
/**
* Determine which program chain we want to watch. This is based on the
* chapter number.
*/
priv->ttn = priv->tt_srpt->title[ title ].vts_ttn;
priv->vts_ptt_srpt = priv->vts_file->vts_ptt_srpt;
priv->pgc_id = priv->vts_ptt_srpt->title[ priv->ttn - 1 ].ptt[ chapter ].pgcn;
priv->pgn = priv->vts_ptt_srpt->title[ priv->ttn - 1 ].ptt[ chapter ].pgn;
priv->cur_pgc = priv->vts_file->vts_pgcit->pgci_srp[ priv->pgc_id - 1 ].pgc;
priv->start_cell = priv->cur_pgc->program_map[ priv->pgn - 1 ] - 1;
priv->ttn = priv->tt_srpt->title[title].vts_ttn;
priv->vts_ptt_srpt = priv->vts_file->vts_ptt_srpt;
priv->pgc_id = priv->vts_ptt_srpt->title[priv->ttn - 1].ptt[chapter].pgcn;
priv->pgn = priv->vts_ptt_srpt->title[priv->ttn - 1].ptt[chapter].pgn;
priv->cur_pgc = priv->vts_file->vts_pgcit->pgci_srp[priv->pgc_id - 1].pgc;
priv->start_cell = priv->cur_pgc->program_map[priv->pgn - 1] - 1;
/**
* We've got enough info, time to open the title set data.
*/
priv->dvd_title = DVDOpenFile( priv->dvd, priv->tt_srpt->title[ title ].title_set_nr,
DVD_READ_TITLE_VOBS );
if( !priv->dvd_title ) {
fprintf( stderr, "Can't open title VOBS (VTS_%02d_1.VOB).\n",
priv->tt_srpt->title[ title ].title_set_nr );
ifoClose( priv->vts_file );
ifoClose( priv->vmg_file );
DVDClose( priv->dvd );
return -1;
}
priv->dvd_title =
DVDOpenFile (priv->dvd, priv->tt_srpt->title[title].title_set_nr,
DVD_READ_TITLE_VOBS);
if (!priv->dvd_title) {
fprintf (stderr, "Can't open title VOBS (VTS_%02d_1.VOB).\n",
priv->tt_srpt->title[title].title_set_nr);
ifoClose (priv->vts_file);
ifoClose (priv->vmg_file);
DVDClose (priv->dvd);
return -1;
}
return 0;
return 0;
}
static void
dvdreadsrc_loop (GstElement *element)
dvdreadsrc_loop (GstElement * element)
{
DVDReadSrc *dvdreadsrc;
DVDReadSrcPrivate *priv;
@ -439,82 +453,85 @@ dvdreadsrc_loop (GstElement *element)
* Playback by cell in this pgc, starting at the cell for our chapter.
*/
priv->next_cell = priv->start_cell;
for( priv->cur_cell = priv->start_cell; priv->next_cell < priv->cur_pgc->nr_of_cells; ) {
for (priv->cur_cell = priv->start_cell;
priv->next_cell < priv->cur_pgc->nr_of_cells;) {
priv->cur_cell = priv->next_cell;
priv->cur_cell = priv->next_cell;
/* Check if we're entering an angle block. */
if( priv->cur_pgc->cell_playback[ priv->cur_cell ].block_type
== BLOCK_TYPE_ANGLE_BLOCK ) {
int i;
/* Check if we're entering an angle block. */
if (priv->cur_pgc->cell_playback[priv->cur_cell].block_type
== BLOCK_TYPE_ANGLE_BLOCK) {
int i;
priv->cur_cell += priv->angle;
for( i = 0;; ++i ) {
if( priv->cur_pgc->cell_playback[ priv->cur_cell + i ].block_mode
== BLOCK_MODE_LAST_CELL ) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
}
} else {
priv->next_cell = priv->cur_cell + 1;
priv->cur_cell += priv->angle;
for (i = 0;; ++i) {
if (priv->cur_pgc->cell_playback[priv->cur_cell + i].block_mode
== BLOCK_MODE_LAST_CELL) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
}
} else {
priv->next_cell = priv->cur_cell + 1;
}
/**
* We loop until we're out of this cell.
*/
for( priv->cur_pack = priv->cur_pgc->cell_playback[ priv->cur_cell ].first_sector;
priv->cur_pack < priv->cur_pgc->cell_playback[ priv->cur_cell ].last_sector; ) {
for (priv->cur_pack =
priv->cur_pgc->cell_playback[priv->cur_cell].first_sector;
priv->cur_pack <
priv->cur_pgc->cell_playback[priv->cur_cell].last_sector;) {
dsi_t dsi_pack;
unsigned int next_vobu, next_ilvu_start, cur_output_size;
GstBuffer *buf;
unsigned char *data;
int len;
dsi_t dsi_pack;
unsigned int next_vobu, next_ilvu_start, cur_output_size;
GstBuffer *buf;
unsigned char *data;
int len;
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
buf = gst_buffer_new ();
g_return_if_fail (buf);
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
buf = gst_buffer_new ();
g_return_if_fail (buf);
/* allocate the space for the buffer data */
data = g_malloc (1024 * DVD_VIDEO_LB_LEN);
GST_BUFFER_DATA (buf) = data;
/* allocate the space for the buffer data */
data = g_malloc (1024 * DVD_VIDEO_LB_LEN);
GST_BUFFER_DATA (buf) = data;
g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
/**
/**
* Read NAV packet.
*/
len = DVDReadBlocks( priv->dvd_title, priv->cur_pack, 1, data );
if( len == 0 ) {
fprintf( stderr, "Read failed for block %d\n", priv->cur_pack );
_close(priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
}
assert( is_nav_pack( data ) );
len = DVDReadBlocks (priv->dvd_title, priv->cur_pack, 1, data);
if (len == 0) {
fprintf (stderr, "Read failed for block %d\n", priv->cur_pack);
_close (priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
}
assert (is_nav_pack (data));
/**
/**
* Parse the contained dsi packet.
*/
navRead_DSI( &dsi_pack, &(data[ DSI_START_BYTE ]) );
assert( priv->cur_pack == dsi_pack.dsi_gi.nv_pck_lbn );
/*navPrint_DSI(&dsi_pack); */
navRead_DSI (&dsi_pack, &(data[DSI_START_BYTE]));
assert (priv->cur_pack == dsi_pack.dsi_gi.nv_pck_lbn);
/*navPrint_DSI(&dsi_pack); */
/**
/**
* Determine where we go next. These values are the ones we mostly
* care about.
*/
next_ilvu_start = priv->cur_pack
+ dsi_pack.sml_agli.data[ priv->angle ].address;
cur_output_size = dsi_pack.dsi_gi.vobu_ea;
next_ilvu_start = priv->cur_pack
+ dsi_pack.sml_agli.data[priv->angle].address;
cur_output_size = dsi_pack.dsi_gi.vobu_ea;
/**
/**
* If we're not at the end of this cell, we can determine the next
* VOBU to display using the VOBU_SRI information section of the
* DSI. Using this value correctly follows the current angle,
@ -524,117 +541,117 @@ dvdreadsrc_loop (GstElement *element)
* Otherwise, we set our next address past the end of this cell to
* force the code above to go to the next cell in the program.
*/
if( dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) {
next_vobu = priv->cur_pack
+ ( dsi_pack.vobu_sri.next_vobu & 0x7fffffff );
} else {
next_vobu = priv->cur_pack + cur_output_size + 1;
}
if (dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL) {
next_vobu = priv->cur_pack + (dsi_pack.vobu_sri.next_vobu & 0x7fffffff);
} else {
next_vobu = priv->cur_pack + cur_output_size + 1;
}
assert( cur_output_size < 1024 );
priv->cur_pack++;
assert (cur_output_size < 1024);
priv->cur_pack++;
/**
/**
* Read in and output cursize packs.
*/
len = DVDReadBlocks( priv->dvd_title, priv->cur_pack,
cur_output_size, data );
if( len != cur_output_size ) {
fprintf( stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack );
_close(priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
}
GST_BUFFER_SIZE(buf) = cur_output_size * DVD_VIDEO_LB_LEN;
gst_pad_push(priv->srcpad, GST_DATA (buf));
priv->cur_pack = next_vobu;
len = DVDReadBlocks (priv->dvd_title, priv->cur_pack,
cur_output_size, data);
if (len != cur_output_size) {
fprintf (stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack);
_close (priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
}
GST_BUFFER_SIZE (buf) = cur_output_size * DVD_VIDEO_LB_LEN;
gst_pad_push (priv->srcpad, GST_DATA (buf));
priv->cur_pack = next_vobu;
}
}
}
#if 0
static int
_read(DVDReadSrcPrivate *priv, int angle, int new_seek, GstBuffer *buf)
_read (DVDReadSrcPrivate * priv, int angle, int new_seek, GstBuffer * buf)
{
unsigned char *data;
unsigned char *data;
data = GST_BUFFER_DATA(buf);
data = GST_BUFFER_DATA (buf);
/**
* Playback by cell in this pgc, starting at the cell for our chapter.
*/
if (new_seek) {
priv->next_cell = priv->start_cell;
priv->cur_cell = priv->start_cell;
if (new_seek) {
priv->next_cell = priv->start_cell;
priv->cur_cell = priv->start_cell;
}
if (priv->next_cell < priv->cur_pgc->nr_of_cells) {
priv->cur_cell = priv->next_cell;
/* Check if we're entering an angle block. */
if (priv->cur_pgc->cell_playback[priv->cur_cell].block_type
== BLOCK_TYPE_ANGLE_BLOCK) {
int i;
priv->cur_cell += angle;
for (i = 0;; ++i) {
if (priv->cur_pgc->cell_playback[priv->cur_cell + i].block_mode
== BLOCK_MODE_LAST_CELL) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
}
} else {
priv->next_cell = priv->cur_cell + 1;
}
if (priv->next_cell < priv->cur_pgc->nr_of_cells) {
priv->cur_cell = priv->next_cell;
/* Check if we're entering an angle block. */
if( priv->cur_pgc->cell_playback[ priv->cur_cell ].block_type
== BLOCK_TYPE_ANGLE_BLOCK ) {
int i;
priv->cur_cell += angle;
for( i = 0;; ++i ) {
if( priv->cur_pgc->cell_playback[ priv->cur_cell + i ].block_mode
== BLOCK_MODE_LAST_CELL ) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
}
} else {
priv->next_cell = priv->cur_cell + 1;
}
/**
/**
* We loop until we're out of this cell.
*/
if (priv->new_cell) {
priv->cur_pack = priv->cur_pgc->cell_playback[ priv->cur_cell ].first_sector;
priv->new_cell = FALSE;
}
if (priv->new_cell) {
priv->cur_pack =
priv->cur_pgc->cell_playback[priv->cur_cell].first_sector;
priv->new_cell = FALSE;
}
if (priv->cur_pack < priv->cur_pgc->cell_playback[ priv->cur_cell ].last_sector; ) {
if (priv->cur_pack <
priv->cur_pgc->cell_playback[priv->cur_cell].last_sector;) {
dsi_t dsi_pack;
unsigned int next_vobu, next_ilvu_start, cur_output_size;
int len;
dsi_t dsi_pack;
unsigned int next_vobu, next_ilvu_start, cur_output_size;
int len;
/**
/**
* Read NAV packet.
*/
len = DVDReadBlocks( priv->title, priv->cur_pack, 1, data );
if( len == 0 ) {
fprintf( stderr, "Read failed for block %d\n", priv->cur_pack );
_close(priv);
return -1;
}
assert( is_nav_pack( data ) );
len = DVDReadBlocks (priv->title, priv->cur_pack, 1, data);
if (len == 0) {
fprintf (stderr, "Read failed for block %d\n", priv->cur_pack);
_close (priv);
return -1;
}
assert (is_nav_pack (data));
/**
/**
* Parse the contained dsi packet.
*/
navRead_DSI( &dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t) );
assert( priv->cur_pack == dsi_pack.dsi_gi.nv_pck_lbn );
navRead_DSI (&dsi_pack, &(data[DSI_START_BYTE]), sizeof (dsi_t));
assert (priv->cur_pack == dsi_pack.dsi_gi.nv_pck_lbn);
/**
/**
* Determine where we go next. These values are the ones we mostly
* care about.
*/
next_ilvu_start = priv->cur_pack
+ dsi_pack.sml_agli.data[ angle ].address;
cur_output_size = dsi_pack.dsi_gi.vobu_ea;
next_ilvu_start = priv->cur_pack + dsi_pack.sml_agli.data[angle].address;
cur_output_size = dsi_pack.dsi_gi.vobu_ea;
/**
/**
* If we're not at the end of this cell, we can determine the next
* VOBU to display using the VOBU_SRI information section of the
* DSI. Using this value correctly follows the current angle,
@ -644,40 +661,38 @@ _read(DVDReadSrcPrivate *priv, int angle, int new_seek, GstBuffer *buf)
* Otherwise, we set our next address past the end of this cell to
* force the code above to go to the next cell in the program.
*/
if( dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) {
next_vobu = priv->cur_pack
+ ( dsi_pack.vobu_sri.next_vobu & 0x7fffffff );
} else {
next_vobu = priv->cur_pack + cur_output_size + 1;
}
if (dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL) {
next_vobu = priv->cur_pack + (dsi_pack.vobu_sri.next_vobu & 0x7fffffff);
} else {
next_vobu = priv->cur_pack + cur_output_size + 1;
}
assert( cur_output_size < 1024 );
priv->cur_pack++;
assert (cur_output_size < 1024);
priv->cur_pack++;
/**
/**
* Read in and output cursize packs.
*/
len = DVDReadBlocks( priv->title, priv->cur_pack,
cur_output_size, data );
if( len != cur_output_size ) {
fprintf( stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack );
_close(priv);
return -1;
}
len = DVDReadBlocks (priv->title, priv->cur_pack, cur_output_size, data);
if (len != cur_output_size) {
fprintf (stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack);
_close (priv);
return -1;
}
GST_BUFFER_SIZE(buf) = cur_output_size * DVD_VIDEO_LB_LEN;
priv->cur_pack = next_vobu;
}
} else {
return -1;
GST_BUFFER_SIZE (buf) = cur_output_size * DVD_VIDEO_LB_LEN;
priv->cur_pack = next_vobu;
}
} else {
return -1;
}
return 0;
return 0;
}
static GstData *
dvdreadsrc_get (GstPad *pad)
dvdreadsrc_get (GstPad * pad)
{
DVDReadSrc *dvdreadsrc;
DVDReadSrcPrivate *priv;
@ -688,7 +703,7 @@ dvdreadsrc_get (GstPad *pad)
dvdreadsrc = DVDREADSRC (gst_pad_get_parent (pad));
priv = dvdreadsrc->priv;
g_return_val_if_fail (GST_FLAG_IS_SET (dvdreadsrc, DVDREADSRC_OPEN),NULL);
g_return_val_if_fail (GST_FLAG_IS_SET (dvdreadsrc, DVDREADSRC_OPEN), NULL);
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
@ -700,7 +715,7 @@ dvdreadsrc_get (GstPad *pad)
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
if (priv->new_seek) {
_seek(priv, priv->titleid, priv->chapid, priv->angle);
_seek (priv, priv->titleid, priv->chapid, priv->angle);
}
/* read it in from the file */
@ -718,39 +733,36 @@ dvdreadsrc_get (GstPad *pad)
#endif
/* open the file, necessary to go to RUNNING state */
static gboolean
dvdreadsrc_open_file (DVDReadSrc *src)
static gboolean
dvdreadsrc_open_file (DVDReadSrc * src)
{
g_return_val_if_fail (src != NULL, FALSE);
g_return_val_if_fail (GST_IS_DVDREADSRC(src), FALSE);
g_return_val_if_fail (GST_IS_DVDREADSRC (src), FALSE);
g_return_val_if_fail (!GST_FLAG_IS_SET (src, DVDREADSRC_OPEN), FALSE);
if (_open(src->priv, src->priv->location))
if (_open (src->priv, src->priv->location))
return FALSE;
if (_seek(src->priv,
src->priv->title,
src->priv->chapter,
src->priv->angle))
if (_seek (src->priv, src->priv->title, src->priv->chapter, src->priv->angle))
return FALSE;
GST_FLAG_SET (src, DVDREADSRC_OPEN);
return TRUE;
}
/* close the file */
static void
dvdreadsrc_close_file (DVDReadSrc *src)
static void
dvdreadsrc_close_file (DVDReadSrc * src)
{
g_return_if_fail (GST_FLAG_IS_SET (src, DVDREADSRC_OPEN));
_close(src->priv);
_close (src->priv);
GST_FLAG_UNSET (src, DVDREADSRC_OPEN);
}
static GstElementStateReturn
dvdreadsrc_change_state (GstElement *element)
dvdreadsrc_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_DVDREADSRC (element), GST_STATE_FAILURE);
@ -760,11 +772,11 @@ dvdreadsrc_change_state (GstElement *element)
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
if (GST_FLAG_IS_SET (element, DVDREADSRC_OPEN))
dvdreadsrc_close_file (DVDREADSRC (element));
/* otherwise (READY or higher) we need to open the file */
/* otherwise (READY or higher) we need to open the file */
} else {
if (!GST_FLAG_IS_SET (element, DVDREADSRC_OPEN)) {
if (!dvdreadsrc_open_file (DVDREADSRC (element)))
return GST_STATE_FAILURE;
return GST_STATE_FAILURE;
}
}
@ -776,22 +788,17 @@ dvdreadsrc_change_state (GstElement *element)
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "dvdreadsrc", GST_RANK_NONE, GST_TYPE_DVDREADSRC))
if (!gst_element_register (plugin, "dvdreadsrc", GST_RANK_NONE,
GST_TYPE_DVDREADSRC))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"dvdreadsrc",
"Access a DVD with dvdread",
plugin_init,
VERSION,
"GPL",
GST_PACKAGE,
GST_ORIGIN)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"dvdreadsrc",
"Access a DVD with dvdread",
plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -25,9 +25,7 @@
#include <gst/gst.h>
G_BEGIN_DECLS
GstElementDetails dvdreadsrc_details;
G_BEGIN_DECLS GstElementDetails dvdreadsrc_details;
#define GST_TYPE_DVDREADSRC \
@ -42,27 +40,29 @@ GstElementDetails dvdreadsrc_details;
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVDREADSRC))
/* NOTE: per-element flags start with 16 for now */
typedef enum {
DVDREADSRC_OPEN = GST_ELEMENT_FLAG_LAST,
typedef enum
{
DVDREADSRC_OPEN = GST_ELEMENT_FLAG_LAST,
DVDREADSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
DVDREADSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} DVDReadSrcFlags;
typedef struct _DVDReadSrc DVDReadSrc;
typedef struct _DVDReadSrcPrivate DVDReadSrcPrivate;
typedef struct _DVDReadSrcClass DVDReadSrcClass;
struct _DVDReadSrc {
struct _DVDReadSrc
{
GstElement element;
DVDReadSrcPrivate *priv;
};
struct _DVDReadSrcClass {
struct _DVDReadSrcClass
{
GstElementClass parent_class;
};
GType dvdreadsrc_get_type(void);
GType dvdreadsrc_get_type (void);
G_END_DECLS
#endif /* __DVDREADSRC_H__ */

View file

@ -24,8 +24,7 @@
#include "gstlame.h"
/* elementfactory information */
static GstElementDetails gst_lame_details =
{
static GstElementDetails gst_lame_details = {
"L.A.M.E. mp3 encoder",
"Codec/Audio/Encoder",
"High-quality free MP3 encoder",
@ -33,34 +32,28 @@ static GstElementDetails gst_lame_details =
};
static GstStaticPadTemplate gst_lame_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]"
)
);
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]")
);
static GstStaticPadTemplate gst_lame_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) 3, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]"
)
);
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) 3, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]")
);
/********** Define useful types for non-programmatic interfaces **********/
#define GST_TYPE_LAME_MODE (gst_lame_mode_get_type())
@ -69,12 +62,12 @@ gst_lame_mode_get_type (void)
{
static GType lame_mode_type = 0;
static GEnumValue lame_modes[] = {
{ 0, "0", "Stereo" },
{ 1, "1", "Joint-Stereo" },
{ 2, "2", "Dual channel" },
{ 3, "3", "Mono" },
{ 4, "4", "Auto" },
{ 0, NULL, NULL },
{0, "0", "Stereo"},
{1, "1", "Joint-Stereo"},
{2, "2", "Dual channel"},
{3, "3", "Mono"},
{4, "4", "Auto"},
{0, NULL, NULL},
};
if (!lame_mode_type) {
lame_mode_type = g_enum_register_static ("GstLameMode", lame_modes);
@ -88,17 +81,17 @@ gst_lame_quality_get_type (void)
{
static GType lame_quality_type = 0;
static GEnumValue lame_quality[] = {
{ 0, "0", "0 - Best" },
{ 1, "1", "1" },
{ 2, "2", "2" },
{ 3, "3", "3" },
{ 4, "4", "4" },
{ 5, "5", "5 - Default" },
{ 6, "6", "6" },
{ 7, "7", "7" },
{ 8, "8", "8" },
{ 9, "9", "9 - Worst" },
{ 0, NULL, NULL },
{0, "0", "0 - Best"},
{1, "1", "1"},
{2, "2", "2"},
{3, "3", "3"},
{4, "4", "4"},
{5, "5", "5 - Default"},
{6, "6", "6"},
{7, "7", "7"},
{8, "8", "8"},
{9, "9", "9 - Worst"},
{0, NULL, NULL},
};
if (!lame_quality_type) {
lame_quality_type = g_enum_register_static ("GstLameQuality", lame_quality);
@ -112,10 +105,10 @@ gst_lame_padding_get_type (void)
{
static GType lame_padding_type = 0;
static GEnumValue lame_padding[] = {
{ 0, "0", "No Padding" },
{ 1, "1", "Always Pad" },
{ 2, "2", "Adjust Padding" },
{ 0, NULL, NULL },
{0, "0", "No Padding"},
{1, "1", "Always Pad"},
{2, "2", "Adjust Padding"},
{0, NULL, NULL},
};
if (!lame_padding_type) {
lame_padding_type = g_enum_register_static ("GstLamePadding", lame_padding);
@ -125,12 +118,14 @@ gst_lame_padding_get_type (void)
/********** Standard stuff for signals and arguments **********/
/* GstLame signals and args */
enum {
enum
{
/* FILL_ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
ARG_BITRATE,
ARG_COMPRESSION_RATIO,
@ -164,19 +159,20 @@ enum {
ARG_EMPHASIS,
};
static void gst_lame_base_init (gpointer g_class);
static void gst_lame_class_init (GstLameClass *klass);
static void gst_lame_init (GstLame *gst_lame);
static void gst_lame_base_init (gpointer g_class);
static void gst_lame_class_init (GstLameClass * klass);
static void gst_lame_init (GstLame * gst_lame);
static void gst_lame_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void gst_lame_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static void gst_lame_chain (GstPad *pad, GstData *_data);
static gboolean gst_lame_setup (GstLame *lame);
static GstElementStateReturn gst_lame_change_state (GstElement *element);
static void gst_lame_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_lame_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_lame_chain (GstPad * pad, GstData * _data);
static gboolean gst_lame_setup (GstLame * lame);
static GstElementStateReturn gst_lame_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
/* static guint gst_lame_signals[LAST_SIGNAL] = { 0 }; */
GType
@ -186,13 +182,13 @@ gst_lame_get_type (void)
if (!gst_lame_type) {
static const GTypeInfo gst_lame_info = {
sizeof (GstLameClass),
sizeof (GstLameClass),
gst_lame_base_init,
NULL,
(GClassInitFunc) gst_lame_class_init,
NULL,
NULL,
sizeof(GstLame),
sizeof (GstLame),
0,
(GInstanceInitFunc) gst_lame_init,
};
@ -203,8 +199,10 @@ gst_lame_get_type (void)
NULL
};
gst_lame_type = g_type_register_static (GST_TYPE_ELEMENT, "GstLame", &gst_lame_info, 0);
g_type_add_interface_static (gst_lame_type, GST_TYPE_TAG_SETTER, &tag_setter_info);
gst_lame_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstLame", &gst_lame_info, 0);
g_type_add_interface_static (gst_lame_type, GST_TYPE_TAG_SETTER,
&tag_setter_info);
}
return gst_lame_type;
@ -215,123 +213,124 @@ gst_lame_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_lame_src_template));
gst_element_class_add_pad_template (element_class,
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_lame_sink_template));
gst_element_class_set_details (element_class, &gst_lame_details);
}
static void
gst_lame_class_init (GstLameClass *klass)
gst_lame_class_init (GstLameClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
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_BITRATE,
g_param_spec_int("bitrate", "Bitrate (kb/s)", "Bitrate in kbit/sec",
8, 320, 128, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMPRESSION_RATIO,
g_param_spec_float ("compression_ratio", "Compression Ratio",
"choose bitrate to achive selected compression ratio",
1.0, 200.0, 11.0, G_PARAM_READWRITE));
g_param_spec_int ("bitrate", "Bitrate (kb/s)", "Bitrate in kbit/sec",
8, 320, 128, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_COMPRESSION_RATIO, g_param_spec_float ("compression_ratio",
"Compression Ratio",
"choose bitrate to achive selected compression ratio", 1.0, 200.0,
11.0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
g_param_spec_enum ("quality", "Quality", "Encoding Quality",
GST_TYPE_LAME_QUALITY, 5, G_PARAM_READWRITE));
g_param_spec_enum ("quality", "Quality", "Encoding Quality",
GST_TYPE_LAME_QUALITY, 5, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
g_param_spec_enum ("mode", "Mode", "Encoding mode",
GST_TYPE_LAME_MODE, 0, G_PARAM_READWRITE));
g_param_spec_enum ("mode", "Mode", "Encoding mode", GST_TYPE_LAME_MODE, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FORCE_MS,
g_param_spec_boolean ("force_ms","Force ms","Force ms_stereo on all frames",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("force_ms", "Force ms",
"Force ms_stereo on all frames", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FREE_FORMAT,
g_param_spec_boolean ("free_format","Free format","Produce a free format bitstream",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("free_format", "Free format",
"Produce a free format bitstream", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COPYRIGHT,
g_param_spec_boolean ("copyright","Copyright","Mark as copyright",
TRUE, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ORIGINAL,
g_param_spec_boolean("original", "Original", "Mark as non-original",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("copyright", "Copyright", "Mark as copyright", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ORIGINAL,
g_param_spec_boolean ("original", "Original", "Mark as non-original",
TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_PROTECTION,
g_param_spec_boolean ("error_protection","Error protection",
"Adds 16 bit checksum to every frame",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("error_protection", "Error protection",
"Adds 16 bit checksum to every frame", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PADDING_TYPE,
g_param_spec_enum ("padding_type", "Padding type", "Padding type",
GST_TYPE_LAME_PADDING, 0, G_PARAM_READWRITE));
g_param_spec_enum ("padding_type", "Padding type", "Padding type",
GST_TYPE_LAME_PADDING, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EXTENSION,
g_param_spec_boolean ("extension", "Extension", "Extension",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("extension", "Extension", "Extension", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STRICT_ISO,
g_param_spec_boolean ("strict_iso", "Strict ISO",
"Comply as much as possible to ISO MPEG spec",
TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DISABLE_RESERVOIR,
g_param_spec_boolean ("disable_reservoir", "Disable reservoir", "Disable the bit reservoir",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("strict_iso", "Strict ISO",
"Comply as much as possible to ISO MPEG spec", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_DISABLE_RESERVOIR, g_param_spec_boolean ("disable_reservoir",
"Disable reservoir", "Disable the bit reservoir", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR,
g_param_spec_boolean ("vbr", "VBR", "Use variable bitrate",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("vbr", "VBR", "Use variable bitrate", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MEAN_BITRATE,
g_param_spec_int ("vbr_mean_bitrate", "VBR mean bitrate", "Specify mean bitrate",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_param_spec_int ("vbr_mean_bitrate", "VBR mean bitrate",
"Specify mean bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MIN_BITRATE,
g_param_spec_int ("vbr_min_bitrate", "VBR min bitrate", "Specify min bitrate",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VBR_MAX_BITRATE,
g_param_spec_int ("vbr_max_bitrate", "VBR max bitrate", "Specify max bitrate",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VBR_HARD_MIN,
g_param_spec_int ("vbr_hard_min", "VBR hard min", "Specify hard min bitrate",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_param_spec_int ("vbr_min_bitrate", "VBR min bitrate",
"Specify min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MAX_BITRATE,
g_param_spec_int ("vbr_max_bitrate", "VBR max bitrate",
"Specify max bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_HARD_MIN,
g_param_spec_int ("vbr_hard_min", "VBR hard min",
"Specify hard min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOWPASS_FREQ,
g_param_spec_int ("lowpass_freq", "Lowpass freq",
"frequency(kHz), lowpass filter cutoff above freq",
0, 50000, 0, G_PARAM_READWRITE));
g_param_spec_int ("lowpass_freq", "Lowpass freq",
"frequency(kHz), lowpass filter cutoff above freq", 0, 50000, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOWPASS_WIDTH,
g_param_spec_int ("lowpass_width", "Lowpass width",
"frequency(kHz) - default 15% of lowpass freq",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_param_spec_int ("lowpass_width", "Lowpass width",
"frequency(kHz) - default 15% of lowpass freq", 0, G_MAXINT, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HIGHPASS_FREQ,
g_param_spec_int ("highpass_freq", "Highpass freq",
"frequency(kHz), highpass filter cutoff below freq",
0, 50000, 0, G_PARAM_READWRITE));
g_param_spec_int ("highpass_freq", "Highpass freq",
"frequency(kHz), highpass filter cutoff below freq", 0, 50000, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HIGHPASS_WIDTH,
g_param_spec_int ("highpass_width", "Highpass width",
"frequency(kHz) - default 15% of highpass freq",
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_param_spec_int ("highpass_width", "Highpass width",
"frequency(kHz) - default 15% of highpass freq", 0, G_MAXINT, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_ONLY,
g_param_spec_boolean ("ath_only", "ATH only",
"Ignore GPSYCHO completely, use ATH only",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("ath_only", "ATH only",
"Ignore GPSYCHO completely, use ATH only", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_SHORT,
g_param_spec_boolean ("ath_short", "ATH short",
"Ignore GPSYCHO for short blocks, use ATH only",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("ath_short", "ATH short",
"Ignore GPSYCHO for short blocks, use ATH only", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NO_ATH,
g_param_spec_boolean ("no_ath", "No ath", "turns ATH down to a flat noise floor",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("no_ath", "No ath",
"turns ATH down to a flat noise floor", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_LOWER,
g_param_spec_int ("ath_lower", "ATH lower", "lowers ATH by x dB",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
g_param_spec_int ("ath_lower", "ATH lower", "lowers ATH by x dB",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CWLIMIT,
g_param_spec_int ("cwlimit", "Cwlimit", "Compute tonality up to freq (in kHz) default 8.8717",
0, 50000, 0, G_PARAM_READWRITE));
g_param_spec_int ("cwlimit", "Cwlimit",
"Compute tonality up to freq (in kHz) default 8.8717", 0, 50000, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ALLOW_DIFF_SHORT,
g_param_spec_boolean ("allow_diff_short", "Allow diff short", "Allow diff short",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("allow_diff_short", "Allow diff short",
"Allow diff short", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NO_SHORT_BLOCKS,
g_param_spec_boolean ("no_short_blocks", "No short blocks", "Do not use short blocks",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("no_short_blocks", "No short blocks",
"Do not use short blocks", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EMPHASIS,
g_param_spec_boolean ("emphasis", "Emphasis", "Emphasis",
TRUE, G_PARAM_READWRITE));
g_param_spec_boolean ("emphasis", "Emphasis", "Emphasis", TRUE,
G_PARAM_READWRITE));
gobject_class->set_property = gst_lame_set_property;
gobject_class->get_property = gst_lame_get_property;
@ -340,7 +339,7 @@ gst_lame_class_init (GstLameClass *klass)
}
static GstPadLinkReturn
gst_lame_sink_link (GstPad *pad, const GstCaps *caps)
gst_lame_sink_link (GstPad * pad, const GstCaps * caps)
{
GstLame *lame;
gint out_samplerate;
@ -355,37 +354,36 @@ gst_lame_sink_link (GstPad *pad, const GstCaps *caps)
if (!gst_lame_setup (lame)) {
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
("could not initialize encoder (wrong parameters?)"));
("could not initialize encoder (wrong parameters?)"));
return GST_PAD_LINK_REFUSED;
}
out_samplerate = lame_get_out_samplerate (lame->lgf);
othercaps =
gst_caps_new_simple (
"audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, 3,
"channels", G_TYPE_INT, lame->num_channels,
"rate", G_TYPE_INT, out_samplerate,
NULL
);
othercaps =
gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, 3,
"channels", G_TYPE_INT, lame->num_channels,
"rate", G_TYPE_INT, out_samplerate, NULL);
return gst_pad_try_set_caps (lame->srcpad, othercaps);
}
static void
gst_lame_init (GstLame *lame)
gst_lame_init (GstLame * lame)
{
GST_DEBUG_OBJECT (lame, "starting initialization");
lame->sinkpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_lame_sink_template), "sink");
lame->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_lame_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (lame), lame->sinkpad);
gst_pad_set_chain_function (lame->sinkpad, gst_lame_chain);
gst_pad_set_link_function (lame->sinkpad, gst_lame_sink_link);
lame->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_lame_src_template), "src");
lame->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_lame_src_template), "src");
gst_element_add_pad (GST_ELEMENT (lame), lame->srcpad);
GST_FLAG_SET (lame, GST_ELEMENT_EVENT_AWARE);
@ -431,12 +429,12 @@ gst_lame_init (GstLame *lame)
lame->tags = gst_tag_list_new ();
id3tag_init (lame->lgf);
GST_DEBUG_OBJECT (lame, "done initializing");
}
typedef struct _GstLameTagMatch GstLameTagMatch;
typedef void (*GstLameTagFunc)(lame_global_flags* gfp, const char *value);
typedef void (*GstLameTagFunc) (lame_global_flags * gfp, const char *value);
struct _GstLameTagMatch
{
@ -444,21 +442,19 @@ struct _GstLameTagMatch
GstLameTagFunc tag_func;
};
static GstLameTagMatch tag_matches[] =
{
{GST_TAG_TITLE, id3tag_set_title},
{GST_TAG_DATE, id3tag_set_year},
{GST_TAG_TRACK_NUMBER, id3tag_set_track},
{GST_TAG_COMMENT, id3tag_set_comment},
{GST_TAG_ARTIST, id3tag_set_artist},
{GST_TAG_ALBUM, id3tag_set_album},
{GST_TAG_GENRE, (GstLameTagFunc)id3tag_set_genre},
{NULL, NULL}
};
static GstLameTagMatch tag_matches[] = {
{GST_TAG_TITLE, id3tag_set_title},
{GST_TAG_DATE, id3tag_set_year},
{GST_TAG_TRACK_NUMBER, id3tag_set_track},
{GST_TAG_COMMENT, id3tag_set_comment},
{GST_TAG_ARTIST, id3tag_set_artist},
{GST_TAG_ALBUM, id3tag_set_album},
{GST_TAG_GENRE, (GstLameTagFunc) id3tag_set_genre},
{NULL, NULL}
};
static void
add_one_tag (const GstTagList *list, const gchar *tag,
gpointer user_data)
static void
add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
GstLame *lame;
gchar *value;
@ -473,31 +469,32 @@ add_one_tag (const GstTagList *list, const gchar *tag,
}
i++;
}
if (tag_matches[i].tag_func == NULL) {
g_print ("Couldn't find matching gstreamer tag for %s\n", tag);
return;
}
switch (gst_tag_get_type (tag)) {
case G_TYPE_UINT: {
guint ivalue;
if (!gst_tag_list_get_uint (list, tag, &ivalue)) {
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
case G_TYPE_UINT:{
guint ivalue;
if (!gst_tag_list_get_uint (list, tag, &ivalue)) {
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
}
value = g_strdup_printf ("%u", ivalue);
break;
}
value = g_strdup_printf ("%u", ivalue);
break;
}
case G_TYPE_STRING:
if (!gst_tag_list_get_string (list, tag, &value)) {
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
};
break;
default:
GST_DEBUG ("Couldn't write tag %s", tag);
break;
case G_TYPE_STRING:
if (!gst_tag_list_get_string (list, tag, &value)) {
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
};
break;
default:
GST_DEBUG ("Couldn't write tag %s", tag);
break;
}
tag_matches[i].tag_func (lame->lgf, value);
@ -508,7 +505,7 @@ add_one_tag (const GstTagList *list, const gchar *tag,
}
static void
gst_lame_set_metadata (GstLame *lame)
gst_lame_set_metadata (GstLame * lame)
{
const GstTagList *user_tags;
GstTagList *copy;
@ -518,9 +515,9 @@ gst_lame_set_metadata (GstLame *lame)
if ((lame->tags == NULL) && (user_tags == NULL)) {
return;
}
copy = gst_tag_list_merge (user_tags, lame->tags,
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (lame)));
gst_tag_list_foreach ((GstTagList*)copy, add_one_tag, lame);
copy = gst_tag_list_merge (user_tags, lame->tags,
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (lame)));
gst_tag_list_foreach ((GstTagList *) copy, add_one_tag, lame);
gst_tag_list_free (copy);
}
@ -528,7 +525,8 @@ gst_lame_set_metadata (GstLame *lame)
static void
gst_lame_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_lame_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
GstLame *lame;
@ -635,7 +633,8 @@ gst_lame_set_property (GObject *object, guint prop_id, const GValue *value, GPar
}
static void
gst_lame_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_lame_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstLame *lame;
@ -742,7 +741,7 @@ gst_lame_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec
}
static void
gst_lame_chain (GstPad *pad, GstData *_data)
gst_lame_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstLame *lame;
@ -760,71 +759,67 @@ gst_lame_chain (GstPad *pad, GstData *_data)
case GST_EVENT_EOS:
eos = TRUE;
case GST_EVENT_FLUSH:
mp3_buffer_size = 7200;
mp3_data = g_malloc (mp3_buffer_size);
mp3_buffer_size = 7200;
mp3_data = g_malloc (mp3_buffer_size);
mp3_size = lame_encode_flush (lame->lgf, mp3_data, mp3_buffer_size);
mp3_size = lame_encode_flush (lame->lgf, mp3_data, mp3_buffer_size);
gst_event_unref (GST_EVENT (buf));
break;
break;
case GST_EVENT_TAG:
if (lame->tags) {
gst_tag_list_insert (lame->tags, gst_event_tag_get_list (GST_EVENT (buf)),
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (lame)));
gst_tag_list_insert (lame->tags,
gst_event_tag_get_list (GST_EVENT (buf)),
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (lame)));
} else {
g_assert_not_reached ();
}
// gst_pad_event_default (pad, GST_EVENT (buf));
}
// gst_pad_event_default (pad, GST_EVENT (buf));
break;
default:
gst_pad_event_default (pad, GST_EVENT (buf));
break;
}
}
else {
} else {
gint64 duration;
if (!lame->initialized) {
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
("encoder not initialized (input is not audio?)"));
("encoder not initialized (input is not audio?)"));
return;
}
/* allocate space for output */
mp3_buffer_size = ((GST_BUFFER_SIZE(buf) / (2+lame->num_channels)) * 1.25) + 7200;
mp3_buffer_size =
((GST_BUFFER_SIZE (buf) / (2 + lame->num_channels)) * 1.25) + 7200;
mp3_data = g_malloc (mp3_buffer_size);
if (lame->num_channels == 2) {
mp3_size = lame_encode_buffer_interleaved (lame->lgf,
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 4,
mp3_data, mp3_buffer_size);
}
else {
mp3_size = lame_encode_buffer (lame->lgf,
(short int *) (GST_BUFFER_DATA (buf)),
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 2,
mp3_data, mp3_buffer_size);
mp3_size = lame_encode_buffer_interleaved (lame->lgf,
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 4, mp3_data, mp3_buffer_size);
} else {
mp3_size = lame_encode_buffer (lame->lgf,
(short int *) (GST_BUFFER_DATA (buf)),
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 2, mp3_data, mp3_buffer_size);
}
GST_DEBUG (
"encoded %d bytes of audio to %d bytes of mp3",
GST_BUFFER_SIZE (buf), mp3_size);
GST_DEBUG ("encoded %d bytes of audio to %d bytes of mp3",
GST_BUFFER_SIZE (buf), mp3_size);
duration = (GST_SECOND * GST_BUFFER_SIZE (buf) /
(2 * lame->samplerate * lame->num_channels));
(2 * lame->samplerate * lame->num_channels));
if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE &&
GST_BUFFER_DURATION (buf) != duration)
GST_DEBUG (
"mad: incoming buffer had incorrect duration %lld, "
"outgoing buffer will have correct duration %lld",
GST_BUFFER_DURATION (buf), duration);
GST_DEBUG ("mad: incoming buffer had incorrect duration %lld, "
"outgoing buffer will have correct duration %lld",
GST_BUFFER_DURATION (buf), duration);
if (lame->last_ts == GST_CLOCK_TIME_NONE) {
lame->last_ts = GST_BUFFER_TIMESTAMP (buf);
lame->last_offs = GST_BUFFER_OFFSET (buf);
lame->last_ts = GST_BUFFER_TIMESTAMP (buf);
lame->last_offs = GST_BUFFER_OFFSET (buf);
lame->last_duration = duration;
} else {
lame->last_duration += duration;
@ -832,20 +827,19 @@ gst_lame_chain (GstPad *pad, GstData *_data)
gst_buffer_unref (buf);
}
if (mp3_size > 0) {
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = mp3_data;
GST_BUFFER_SIZE (outbuf) = mp3_size;
GST_BUFFER_DATA (outbuf) = mp3_data;
GST_BUFFER_SIZE (outbuf) = mp3_size;
GST_BUFFER_TIMESTAMP (outbuf) = lame->last_ts;
GST_BUFFER_OFFSET (outbuf) = lame->last_offs;
GST_BUFFER_DURATION (outbuf) = lame->last_duration;
GST_BUFFER_OFFSET (outbuf) = lame->last_offs;
GST_BUFFER_DURATION (outbuf) = lame->last_duration;
gst_pad_push (lame->srcpad,GST_DATA (outbuf));
gst_pad_push (lame->srcpad, GST_DATA (outbuf));
lame->last_ts = GST_CLOCK_TIME_NONE;
}
else {
} else {
g_free (mp3_data);
}
@ -857,7 +851,7 @@ gst_lame_chain (GstPad *pad, GstData *_data)
/* transition to the READY state by configuring the gst_lame encoder */
static gboolean
gst_lame_setup (GstLame *lame)
gst_lame_setup (GstLame * lame)
{
GST_DEBUG_OBJECT (lame, "starting setup");
@ -871,7 +865,7 @@ gst_lame_setup (GstLame *lame)
lame_set_in_samplerate (lame->lgf, lame->samplerate);
/* force mono encoding if we only have one channel */
if (lame->num_channels == 1)
if (lame->num_channels == 1)
lame->mode = 3;
lame_set_brate (lame->lgf, lame->bitrate);
@ -910,13 +904,11 @@ gst_lame_setup (GstLame *lame)
/* initialize the lame encoder */
if (lame_init_params (lame->lgf) < 0) {
lame->initialized = FALSE;
}
else {
} else {
lame->initialized = TRUE;
/* FIXME: it would be nice to print out the mode here */
GST_INFO (
"lame encoder initialized (%d kbit/s, %d Hz, %d channels)",
lame->bitrate, lame->samplerate, lame->num_channels);
GST_INFO ("lame encoder initialized (%d kbit/s, %d Hz, %d channels)",
lame->bitrate, lame->samplerate, lame->num_channels);
}
GST_DEBUG_OBJECT (lame, "done with setup");
@ -925,10 +917,10 @@ gst_lame_setup (GstLame *lame)
}
static GstElementStateReturn
gst_lame_change_state (GstElement *element)
gst_lame_change_state (GstElement * element)
{
GstLame *lame;
g_return_val_if_fail (GST_IS_LAME (element), GST_STATE_FAILURE);
lame = GST_LAME (element);
@ -941,7 +933,7 @@ gst_lame_change_state (GstElement *element)
break;
case GST_STATE_READY_TO_NULL:
if (lame->initialized) {
lame_close (lame->lgf);
lame_close (lame->lgf);
lame->initialized = FALSE;
}
break;
@ -957,21 +949,16 @@ gst_lame_change_state (GstElement *element)
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "lame", GST_RANK_NONE, GST_TYPE_LAME))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"lame",
"Encode MP3's with LAME",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"lame",
"Encode MP3's with LAME",
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -25,8 +25,9 @@
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern "C"
{
#endif /* __cplusplus */
#include <lame/lame.h>
@ -41,73 +42,76 @@ extern "C" {
#define GST_IS_LAME_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_LAME))
typedef enum {
GST_LAME_OPEN = GST_ELEMENT_FLAG_LAST,
typedef enum
{
GST_LAME_OPEN = GST_ELEMENT_FLAG_LAST,
GST_LAME_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
} GstLameFlags;
GST_LAME_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstLameFlags;
typedef struct _GstLame GstLame;
typedef struct _GstLameClass GstLameClass;
typedef struct _GstLame GstLame;
typedef struct _GstLameClass GstLameClass;
struct _GstLame {
GstElement element;
/* pads */
GstPad *srcpad, *sinkpad;
struct _GstLame
{
GstElement element;
/* pads */
GstPad *srcpad, *sinkpad;
gint samplerate;
gint num_channels;
gboolean initialized;
gint samplerate;
gint num_channels;
gboolean initialized;
gint bitrate;
gfloat compression_ratio;
gint quality;
gint mode;
gboolean force_ms;
gboolean free_format;
gboolean copyright;
gboolean original;
gboolean error_protection;
gint padding_type;
gboolean extension;
gboolean strict_iso;
gboolean disable_reservoir;
gboolean vbr;
gint vbr_mean_bitrate;
gint vbr_min_bitrate;
gint vbr_max_bitrate;
gint vbr_hard_min;
gint lowpass_freq;
gint lowpass_width;
gint highpass_freq;
gint highpass_width;
gboolean ath_only;
gboolean ath_short;
gboolean no_ath;
gint ath_type;
gint ath_lower;
gint cwlimit;
gboolean allow_diff_short;
gboolean no_short_blocks;
gboolean emphasis;
gint bitrate;
gfloat compression_ratio;
gint quality;
gint mode;
gboolean force_ms;
gboolean free_format;
gboolean copyright;
gboolean original;
gboolean error_protection;
gint padding_type;
gboolean extension;
gboolean strict_iso;
gboolean disable_reservoir;
gboolean vbr;
gint vbr_mean_bitrate;
gint vbr_min_bitrate;
gint vbr_max_bitrate;
gint vbr_hard_min;
gint lowpass_freq;
gint lowpass_width;
gint highpass_freq;
gint highpass_width;
gboolean ath_only;
gboolean ath_short;
gboolean no_ath;
gint ath_type;
gint ath_lower;
gint cwlimit;
gboolean allow_diff_short;
gboolean no_short_blocks;
gboolean emphasis;
lame_global_flags *lgf;
lame_global_flags *lgf;
GstTagList *tags;
GstTagList *tags;
/* time tracker */
guint64 last_ts, last_offs, last_duration;
};
/* time tracker */
guint64 last_ts, last_offs, last_duration;
};
struct _GstLameClass {
GstElementClass parent_class;
};
struct _GstLameClass
{
GstElementClass parent_class;
};
GType gst_lame_get_type(void);
GType gst_lame_get_type (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* __GST_LAME_H__ */
#endif /* __GST_LAME_H__ */

View file

@ -12,12 +12,12 @@
*/
static void
error_callback (GObject *object, GstObject *orig, gchar *error)
error_callback (GObject * object, GstObject * orig, gchar * error)
{
g_print ("ERROR: %s: %s\n", GST_OBJECT_NAME (orig), error);
g_print ("ERROR: %s: %s\n", GST_OBJECT_NAME (orig), error);
}
int
int
main (int argc, char *argv[])
{
GstElement *pipeline;
@ -29,13 +29,20 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
/* create elements */
if (!(pipeline = gst_element_factory_make ("pipeline", "pipeline"))) return 1;
if (!(src = gst_element_factory_make ("fakesrc", "source"))) return 1;
if (!(tee = gst_element_factory_make ("tee", "tee"))) return 1;
if (!(encoder1 = gst_element_factory_make ("lame", "lame1"))) return 1;
if (!(encoder2 = gst_element_factory_make ("lame", "lame2"))) return 1;
if (!(sink1 = gst_element_factory_make ("fakesink", "sink1"))) return 1;
if (!(sink2 = gst_element_factory_make ("fakesink", "sink2"))) return 1;
if (!(pipeline = gst_element_factory_make ("pipeline", "pipeline")))
return 1;
if (!(src = gst_element_factory_make ("fakesrc", "source")))
return 1;
if (!(tee = gst_element_factory_make ("tee", "tee")))
return 1;
if (!(encoder1 = gst_element_factory_make ("lame", "lame1")))
return 1;
if (!(encoder2 = gst_element_factory_make ("lame", "lame2")))
return 1;
if (!(sink1 = gst_element_factory_make ("fakesink", "sink1")))
return 1;
if (!(sink2 = gst_element_factory_make ("fakesink", "sink2")))
return 1;
pipeline = gst_pipeline_new ("pipeline");
g_signal_connect (pipeline, "error", G_CALLBACK (error_callback), NULL);
@ -45,34 +52,31 @@ main (int argc, char *argv[])
gst_bin_add (GST_BIN (pipeline), src);
gst_bin_add (GST_BIN (pipeline), tee);
gst_pad_link (gst_element_get_pad (src, "src"),
gst_element_get_pad (tee, "sink"));
gst_element_get_pad (tee, "sink"));
/* set up fakesrc */
g_object_set (G_OBJECT (src), "filltype", 3, NULL);
g_object_set (G_OBJECT (src), "sizetype", 3, NULL);
/* set caps on fakesrc */
caps = GST_CAPS_NEW (
"input audio",
caps = GST_CAPS_NEW ("input audio",
"audio/raw",
"format", GST_PROPS_STRING ("int"),
"rate", GST_PROPS_INT (44100),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"law", GST_PROPS_INT (0),
"signed", GST_PROPS_BOOLEAN (TRUE),
"channels", GST_PROPS_INT (1)
"signed", GST_PROPS_BOOLEAN (TRUE), "channels", GST_PROPS_INT (1)
);
g_object_set (G_OBJECT (src), "sizetype", 3,
"filltype", 3, NULL);
g_object_set (G_OBJECT (src), "sizetype", 3, "filltype", 3, NULL);
gst_element_set_state (pipeline, GST_STATE_READY);
g_print ("Setting caps on fakesrc's src pad\n");
if (gst_pad_try_set_caps (gst_element_get_pad (src, "src"), caps) <= 0)
g_print ("Could not set caps !\n");
g_print ("Could not set caps !\n");
/* request first pad from tee and connect */
g_print ("attaching first output pipe to tee\n");
teepad1 = gst_element_request_pad_by_name (tee, "src%d");
@ -81,8 +85,8 @@ main (int argc, char *argv[])
gst_bin_add (GST_BIN (pipeline), sink1);
gst_pad_link (teepad1, gst_element_get_pad (encoder1, "sink"));
gst_pad_link (gst_element_get_pad (encoder1, "src"),
gst_element_get_pad (sink1, "sink"));
gst_element_get_pad (sink1, "sink"));
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* iterate */
g_print ("iterate\n");
@ -97,7 +101,7 @@ main (int argc, char *argv[])
gst_bin_add (GST_BIN (pipeline), sink2);
gst_pad_link (teepad2, gst_element_get_pad (encoder2, "sink"));
gst_pad_link (gst_element_get_pad (encoder2, "src"),
gst_element_get_pad (sink2, "sink"));
gst_element_get_pad (sink2, "sink"));
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("iterate\n");

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -26,17 +26,13 @@
#include <mad.h>
#include <id3tag.h>
G_BEGIN_DECLS
G_BEGIN_DECLS GType gst_mad_get_type (void);
GType gst_id3_parse_get_type (void);
GType gst_id3_tag_get_type (void);
GType gst_mad_get_type (void);
GType gst_id3_parse_get_type (void);
GType gst_id3_tag_get_type (void);
GstTagList *gst_mad_id3_to_tag_list (const struct id3_tag *tag);
struct id3_tag *gst_mad_tag_list_to_id3_tag (GstTagList * list);
GstTagList* gst_mad_id3_to_tag_list (const struct id3_tag * tag);
struct id3_tag * gst_mad_tag_list_to_id3_tag (GstTagList * list);
G_END_DECLS
#endif /* __GST_MAD_H__ */

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,6 @@
#include <mpeg2.h>
G_BEGIN_DECLS
#define GST_TYPE_MPEG2DEC \
(gst_mpeg2dec_get_type())
#define GST_MPEG2DEC(obj) \
@ -37,10 +36,8 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MPEG2DEC))
#define GST_IS_MPEG2DEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MPEG2DEC))
#define MPEGTIME_TO_GSTTIME(time) (((time) * (GST_MSECOND/10)) / 9LL)
#define GSTTIME_TO_MPEGTIME(time) (((time) * 9LL) / (GST_MSECOND/10))
typedef struct _GstMpeg2dec GstMpeg2dec;
typedef struct _GstMpeg2decClass GstMpeg2decClass;
@ -51,54 +48,53 @@ typedef enum
MPEG2DEC_FORMAT_YV12,
} Mpeg2decFormat;
typedef enum
typedef enum
{
MPEG2DEC_DISC_NONE = 0,
MPEG2DEC_DISC_NONE = 0,
MPEG2DEC_DISC_NEW_PICTURE,
MPEG2DEC_DISC_NEW_KEYFRAME,
} DiscontState;
struct _GstMpeg2dec {
GstElement element;
struct _GstMpeg2dec
{
GstElement element;
/* pads */
GstPad *sinkpad,
*srcpad,
*userdatapad;
GstPad *sinkpad, *srcpad, *userdatapad;
mpeg2dec_t *decoder;
gboolean closed;
gboolean have_fbuf;
mpeg2dec_t *decoder;
gboolean closed;
gboolean have_fbuf;
/* the timestamp of the next frame */
DiscontState discont_state;
gint64 next_time;
gint64 segment_start;
gint64 segment_end;
DiscontState discont_state;
gint64 next_time;
gint64 segment_start;
gint64 segment_end;
/* video state */
Mpeg2decFormat format;
gint width;
gint height;
gint pixel_width;
gint pixel_height;
gint frame_rate_code;
gint64 total_frames;
gint64 frame_period;
gboolean need_sequence;
gint width;
gint height;
gint pixel_width;
gint pixel_height;
gint frame_rate_code;
gint64 total_frames;
gint64 frame_period;
gboolean need_sequence;
GstEvent *pending_event;
GstEvent *pending_event;
GstIndex *index;
gint index_id;
GstIndex *index;
gint index_id;
};
struct _GstMpeg2decClass {
struct _GstMpeg2decClass
{
GstElementClass parent_class;
};
GType gst_mpeg2dec_get_type(void);
GType gst_mpeg2dec_get_type (void);
G_END_DECLS
#endif /* __GST_MPEG2DEC_H__ */

View file

@ -11,14 +11,15 @@
#include "gstmpeg2dec.h"
void new_frame (char *buf, void *data, uint64_t timestamp)
void
new_frame (char *buf, void *data, uint64_t timestamp)
{
g_print(".");
g_print (".");
}
int
main (int argc, char *argv[])
int
main (int argc, char *argv[])
{
int fd, count = 20000;
mpeg2dec_t *decoder;
@ -30,7 +31,7 @@ main (int argc, char *argv[])
mpeg2_init (decoder, new_frame, NULL);
while (read (fd, buffer, 2048) && count--) {
mpeg2_decode_data(decoder, buffer, buffer + 2048);
mpeg2_decode_data (decoder, buffer, buffer + 2048);
}
g_print("\n");
g_print ("\n");
}

View file

@ -28,7 +28,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_SIDDEC \
(gst_siddec_get_type())
#define GST_SIDDEC(obj) \
@ -39,38 +38,37 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SIDDEC))
#define GST_IS_SIDDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SIDDEC))
typedef struct _GstSidDec GstSidDec;
typedef struct _GstSidDecClass GstSidDecClass;
struct _GstSidDec {
GstElement element;
struct _GstSidDec
{
GstElement element;
/* pads */
GstPad *sinkpad,
*srcpad;
GstPad *sinkpad, *srcpad;
gint state;
guchar *tune_buffer;
gint tune_len;
gint tune_number;
guint64 total_bytes;
gint state;
guchar *tune_buffer;
gint tune_len;
gint tune_number;
guint64 total_bytes;
emuEngine *engine;
sidTune *tune;
emuConfig *config;
emuEngine *engine;
sidTune *tune;
emuConfig *config;
gulong blocksize;
gulong blocksize;
GstCaps *metadata;
GstCaps *metadata;
};
struct _GstSidDecClass {
struct _GstSidDecClass
{
GstElementClass parent_class;
};
GType gst_siddec_get_type (void);
G_END_DECLS
G_END_DECLS
#endif /* __GST_SIDDEC_H__ */

View file

@ -26,7 +26,7 @@
#include <gst/gststructure.h>
int
gst_audio_frame_byte_size (GstPad* pad)
gst_audio_frame_byte_size (GstPad * pad)
{
/* calculate byte size of an audio frame
* this should be moved closer to the gstreamer core
@ -45,20 +45,20 @@ gst_audio_frame_byte_size (GstPad* pad)
if (caps == NULL) {
/* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
}
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
return (width / 8) * channels;
return (width / 8) * channels;
}
long
gst_audio_frame_length (GstPad* pad, GstBuffer* buf)
gst_audio_frame_length (GstPad * pad, GstBuffer * buf)
/* calculate length of buffer in frames
* this should be moved closer to the gstreamer core
* and be implemented for every mime type IMO
@ -72,13 +72,13 @@ gst_audio_frame_length (GstPad* pad, GstBuffer* buf)
/* error */
return 0;
/* FIXME: this function assumes the buffer size to be a whole multiple
* of the frame byte size
* of the frame byte size
*/
return GST_BUFFER_SIZE (buf) / frame_byte_size;
}
long
gst_audio_frame_rate (GstPad *pad)
gst_audio_frame_rate (GstPad * pad)
/*
* calculate frame rate (based on caps of pad)
* returns 0 if failed, rate if success
@ -93,19 +93,18 @@ gst_audio_frame_rate (GstPad *pad)
if (caps == NULL) {
/* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
}
else {
} else {
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "rate", &rate);
gst_structure_get_int (structure, "rate", &rate);
return rate;
}
}
double
gst_audio_length (GstPad* pad, GstBuffer* buf)
double
gst_audio_length (GstPad * pad, GstBuffer * buf)
{
/* calculate length in seconds
* of audio buffer buf
@ -125,20 +124,17 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
g_assert (GST_IS_BUFFER (buf));
/* get caps of pad */
caps = GST_PAD_CAPS (pad);
if (caps == NULL)
{
if (caps == NULL) {
/* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
length = 0.0;
}
else
{
} else {
structure = gst_caps_get_structure (caps, 0);
bytes = GST_BUFFER_SIZE (buf);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
gst_structure_get_int (structure, "rate", &rate);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
gst_structure_get_int (structure, "rate", &rate);
g_assert (bytes != 0);
g_assert (width != 0);
@ -150,8 +146,8 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
return length;
}
long
gst_audio_highest_sample_value (GstPad* pad)
long
gst_audio_highest_sample_value (GstPad * pad)
/* calculate highest possible sample value
* based on capabilities of pad
*/
@ -160,25 +156,25 @@ gst_audio_highest_sample_value (GstPad* pad)
gint width = 0;
const GstCaps *caps = NULL;
GstStructure *structure;
caps = GST_PAD_CAPS (pad);
if (caps == NULL)
{
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
if (caps == NULL) {
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
}
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_boolean (structure, "signed", &is_signed);
if (is_signed) --width;
gst_structure_get_int (structure, "width", &width);
gst_structure_get_boolean (structure, "signed", &is_signed);
if (is_signed)
--width;
/* example : 16 bit, signed : samples between -32768 and 32767 */
return ((long) (1 << width));
}
gboolean
gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf)
gboolean
gst_audio_is_buffer_framed (GstPad * pad, GstBuffer * buf)
/* check if the buffer size is a whole multiple of the frame size */
{
if (GST_BUFFER_SIZE (buf) % gst_audio_frame_byte_size (pad) == 0)
@ -199,8 +195,8 @@ gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf)
* number of list values, and each of the values, terminating with NULL
*/
static void
_gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
GType type, int number, ...)
_gst_audio_structure_set_list (GstStructure * structure,
const gchar * fieldname, GType type, int number, ...)
{
va_list varargs;
GValue value = { 0 };
@ -214,27 +210,27 @@ _gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
va_start (varargs, number);
for (j = 0; j < number; ++j)
{
for (j = 0; j < number; ++j) {
int i;
gboolean b;
GValue list_value = { 0 };
switch (type)
{
switch (type) {
case G_TYPE_INT:
i = va_arg (varargs, int);
g_value_init (&list_value, G_TYPE_INT);
g_value_set_int (&list_value, i);
break;
i = va_arg (varargs, int);
g_value_init (&list_value, G_TYPE_INT);
g_value_set_int (&list_value, i);
break;
case G_TYPE_BOOLEAN:
b = va_arg (varargs, gboolean);
g_value_init (&list_value, G_TYPE_BOOLEAN);
g_value_set_boolean (&list_value, b);
break;
default:
g_warning ("_gst_audio_structure_set_list: LIST of given type not implemented.");
b = va_arg (varargs, gboolean);
g_value_init (&list_value, G_TYPE_BOOLEAN);
g_value_set_boolean (&list_value, b);
break;
default:
g_warning
("_gst_audio_structure_set_list: LIST of given type not implemented.");
}
g_array_append_val (array, list_value);
@ -244,38 +240,38 @@ _gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
}
void
gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag)
gst_audio_structure_set_int (GstStructure * structure, GstAudioFieldFlag flag)
{
if (flag & GST_AUDIO_FIELD_RATE)
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL);
if (flag & GST_AUDIO_FIELD_CHANNELS)
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL);
if (flag & GST_AUDIO_FIELD_ENDIANNESS)
_gst_audio_structure_set_list (structure, "endianness", G_TYPE_INT, 2, G_LITTLE_ENDIAN, G_BIG_ENDIAN, NULL);
_gst_audio_structure_set_list (structure, "endianness", G_TYPE_INT, 2,
G_LITTLE_ENDIAN, G_BIG_ENDIAN, NULL);
if (flag & GST_AUDIO_FIELD_WIDTH)
_gst_audio_structure_set_list (structure, "width", G_TYPE_INT, 3, 8, 16, 32, NULL);
_gst_audio_structure_set_list (structure, "width", G_TYPE_INT, 3, 8, 16, 32,
NULL);
if (flag & GST_AUDIO_FIELD_DEPTH)
gst_structure_set (structure, "depth", GST_TYPE_INT_RANGE, 1, 32, NULL);
if (flag & GST_AUDIO_FIELD_SIGNED)
_gst_audio_structure_set_list (structure, "signed", G_TYPE_BOOLEAN, 2, TRUE, FALSE, NULL);
_gst_audio_structure_set_list (structure, "signed", G_TYPE_BOOLEAN, 2, TRUE,
FALSE, NULL);
if (flag & GST_AUDIO_FIELD_BUFFER_FRAMES)
gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1,
G_MAXINT, NULL);
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudio",
"Support services for audio plugins",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
);
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudio",
"Support services for audio plugins",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);

View file

@ -26,7 +26,6 @@
#define __GST_AUDIO_AUDIO_H__
G_BEGIN_DECLS
/* For people that are looking at this source: the purpose of these defines is
* to make GstCaps a bit easier, in that you don't have to know all of the
* properties that need to be defined. you can just use these macros. currently
@ -50,9 +49,7 @@ G_BEGIN_DECLS
*
* Andy Wingo, 18 August 2001
* Thomas, 6 September 2002 */
#define GST_AUDIO_DEF_RATE 44100
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
@ -60,9 +57,7 @@ G_BEGIN_DECLS
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) { 8, 16, 32 }, " \
"depth = (int) [ 1, 32 ], " \
"signed = (boolean) { true, false }"
"signed = (boolean) { true, false }"
/* "standard" int audio is native order, 16 bit stereo. */
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
@ -71,8 +66,7 @@ G_BEGIN_DECLS
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (boolean) true"
"signed = (boolean) true"
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
"rate = (int) [ 1, MAX ], " \
@ -80,7 +74,6 @@ G_BEGIN_DECLS
"endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \
"width = (int) { 32, 64 }, " \
"buffer-frames = (int) [ 1, MAX]"
/* "standard" float audio is native order, 32 bit mono. */
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
@ -88,43 +81,42 @@ G_BEGIN_DECLS
"channels = (int) 1, " \
"endianness = (int) BYTE_ORDER, " \
"buffer-frames = (int) [ 1, MAX]"
/*
* this library defines and implements some helper functions for audio
* handling
*/
/* get byte size of audio frame (based on caps of pad */
int gst_audio_frame_byte_size (GstPad* pad);
int gst_audio_frame_byte_size (GstPad * pad);
/* get length in frames of buffer */
long gst_audio_frame_length (GstPad* pad, GstBuffer* buf);
long gst_audio_frame_length (GstPad * pad, GstBuffer * buf);
/* get frame rate based on caps */
long gst_audio_frame_rate (GstPad *pad);
long gst_audio_frame_rate (GstPad * pad);
/* calculate length in seconds of audio buffer buf based on caps of pad */
double gst_audio_length (GstPad* pad, GstBuffer* buf);
double gst_audio_length (GstPad * pad, GstBuffer * buf);
/* calculate highest possible sample value based on capabilities of pad */
long gst_audio_highest_sample_value (GstPad* pad);
long gst_audio_highest_sample_value (GstPad * pad);
/* check if the buffer size is a whole multiple of the frame size */
gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf);
gboolean gst_audio_is_buffer_framed (GstPad * pad, GstBuffer * buf);
/* functions useful for _getcaps functions */
typedef enum {
GST_AUDIO_FIELD_RATE = (1 << 0),
GST_AUDIO_FIELD_CHANNELS = (1 << 1),
GST_AUDIO_FIELD_ENDIANNESS = (1 << 2),
GST_AUDIO_FIELD_WIDTH = (1 << 3),
GST_AUDIO_FIELD_DEPTH = (1 << 4),
GST_AUDIO_FIELD_SIGNED = (1 << 5),
typedef enum
{
GST_AUDIO_FIELD_RATE = (1 << 0),
GST_AUDIO_FIELD_CHANNELS = (1 << 1),
GST_AUDIO_FIELD_ENDIANNESS = (1 << 2),
GST_AUDIO_FIELD_WIDTH = (1 << 3),
GST_AUDIO_FIELD_DEPTH = (1 << 4),
GST_AUDIO_FIELD_SIGNED = (1 << 5),
GST_AUDIO_FIELD_BUFFER_FRAMES = (1 << 6)
} GstAudioFieldFlag;
void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag);
void gst_audio_structure_set_int (GstStructure * structure,
GstAudioFieldFlag flag);
G_END_DECLS
#endif /* __GST_AUDIO_AUDIO_H__ */

View file

@ -26,23 +26,24 @@
#include "audioclock.h"
static void gst_audio_clock_class_init (GstAudioClockClass *klass);
static void gst_audio_clock_init (GstAudioClock *clock);
static void gst_audio_clock_class_init (GstAudioClockClass * klass);
static void gst_audio_clock_init (GstAudioClock * clock);
static GstClockTime gst_audio_clock_get_internal_time (GstClock *clock);
static GstClockReturn gst_audio_clock_id_wait_async (GstClock *clock,
GstClockEntry *entry);
static void gst_audio_clock_id_unschedule (GstClock *clock,
GstClockEntry *entry);
static GstClockTime gst_audio_clock_get_internal_time (GstClock * clock);
static GstClockReturn gst_audio_clock_id_wait_async (GstClock * clock,
GstClockEntry * entry);
static void gst_audio_clock_id_unschedule (GstClock * clock,
GstClockEntry * entry);
static GstSystemClockClass *parent_class = NULL;
/* static guint gst_audio_clock_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_audio_clock_get_type (void)
{
{
static GType clock_type = 0;
if (!clock_type) {
static const GTypeInfo clock_info = {
sizeof (GstAudioClockClass),
@ -57,32 +58,32 @@ gst_audio_clock_get_type (void)
NULL
};
clock_type = g_type_register_static (GST_TYPE_SYSTEM_CLOCK, "GstAudioClock",
&clock_info, 0);
&clock_info, 0);
}
return clock_type;
}
static void
gst_audio_clock_class_init (GstAudioClockClass *klass)
gst_audio_clock_class_init (GstAudioClockClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstClockClass *gstclock_class;
gobject_class = (GObjectClass*) klass;
gstobject_class = (GstObjectClass*) klass;
gstclock_class = (GstClockClass*) klass;
gobject_class = (GObjectClass *) klass;
gstobject_class = (GstObjectClass *) klass;
gstclock_class = (GstClockClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_SYSTEM_CLOCK);
gstclock_class->get_internal_time = gst_audio_clock_get_internal_time;
gstclock_class->wait_async = gst_audio_clock_id_wait_async;
gstclock_class->unschedule = gst_audio_clock_id_unschedule;
gstclock_class->get_internal_time = gst_audio_clock_get_internal_time;
gstclock_class->wait_async = gst_audio_clock_id_wait_async;
gstclock_class->unschedule = gst_audio_clock_id_unschedule;
}
static void
gst_audio_clock_init (GstAudioClock *clock)
gst_audio_clock_init (GstAudioClock * clock)
{
gst_object_set_name (GST_OBJECT (clock), "GstAudioClock");
@ -90,20 +91,22 @@ gst_audio_clock_init (GstAudioClock *clock)
clock->prev2 = 0;
}
GstClock*
gst_audio_clock_new (gchar *name, GstAudioClockGetTimeFunc func, gpointer user_data)
GstClock *
gst_audio_clock_new (gchar * name, GstAudioClockGetTimeFunc func,
gpointer user_data)
{
GstAudioClock *aclock = GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, NULL));
GstAudioClock *aclock =
GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, NULL));
aclock->func = func;
aclock->user_data = user_data;
aclock->adjust = 0;
return (GstClock*)aclock;
return (GstClock *) aclock;
}
void
gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active)
gst_audio_clock_set_active (GstAudioClock * aclock, gboolean active)
{
GstClockTime time;
GstClock *clock;
@ -117,8 +120,9 @@ gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active)
aclock->adjust = time - aclock->func (clock, aclock->user_data);
} else {
GTimeVal timeval;
g_get_current_time (&timeval);
aclock->adjust = GST_TIMEVAL_TO_TIME (timeval) - time;
}
@ -126,22 +130,22 @@ gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active)
}
static GstClockTime
gst_audio_clock_get_internal_time (GstClock *clock)
gst_audio_clock_get_internal_time (GstClock * clock)
{
GstAudioClock *aclock = GST_AUDIO_CLOCK (clock);
if (aclock->active) {
return aclock->func (clock, aclock->user_data) + aclock->adjust;
} else {
GTimeVal timeval;
g_get_current_time (&timeval);
return GST_TIMEVAL_TO_TIME (timeval);
}
}
void
gst_audio_clock_update_time (GstAudioClock *aclock, GstClockTime time)
gst_audio_clock_update_time (GstAudioClock * aclock, GstClockTime time)
{
/* I don't know of a purpose in updating these; perhaps they can be removed */
aclock->prev2 = aclock->prev1;
@ -150,43 +154,41 @@ gst_audio_clock_update_time (GstAudioClock *aclock, GstClockTime time)
/* FIXME: the wait_async subsystem should be made threadsafe, but I don't want
* to lock and unlock a mutex on every iteration... */
while (aclock->async_entries) {
GstClockEntry *entry = (GstClockEntry*)aclock->async_entries->data;
GstClockEntry *entry = (GstClockEntry *) aclock->async_entries->data;
if (entry->time > time)
break;
entry->func ((GstClock*)aclock, time, entry, entry->user_data);
entry->func ((GstClock *) aclock, time, entry, entry->user_data);
aclock->async_entries = g_slist_delete_link (aclock->async_entries,
aclock->async_entries);
aclock->async_entries);
/* do I need to free the entry? */
}
}
static gint
compare_clock_entries (GstClockEntry *entry1, GstClockEntry *entry2)
compare_clock_entries (GstClockEntry * entry1, GstClockEntry * entry2)
{
return entry1->time - entry2->time;
}
static GstClockReturn
gst_audio_clock_id_wait_async (GstClock *clock, GstClockEntry *entry)
gst_audio_clock_id_wait_async (GstClock * clock, GstClockEntry * entry)
{
GstAudioClock *aclock = (GstAudioClock*)clock;
GstAudioClock *aclock = (GstAudioClock *) clock;
aclock->async_entries = g_slist_insert_sorted (aclock->async_entries,
entry,
(GCompareFunc)compare_clock_entries);
entry, (GCompareFunc) compare_clock_entries);
/* is this the proper return val? */
return GST_CLOCK_EARLY;
}
static void
gst_audio_clock_id_unschedule (GstClock *clock, GstClockEntry *entry)
gst_audio_clock_id_unschedule (GstClock * clock, GstClockEntry * entry)
{
GstAudioClock *aclock = (GstAudioClock*)clock;
aclock->async_entries = g_slist_remove (aclock->async_entries,
entry);
GstAudioClock *aclock = (GstAudioClock *) clock;
aclock->async_entries = g_slist_remove (aclock->async_entries, entry);
}

View file

@ -27,7 +27,6 @@
#include <gst/gstsystemclock.h>
G_BEGIN_DECLS
#define GST_TYPE_AUDIO_CLOCK \
(gst_audio_clock_get_type())
#define GST_AUDIO_CLOCK(obj) \
@ -38,14 +37,15 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_CLOCK))
#define GST_IS_AUDIO_CLOCK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_CLOCK))
typedef struct _GstAudioClock GstAudioClock;
typedef struct _GstAudioClockClass GstAudioClockClass;
typedef GstClockTime (*GstAudioClockGetTimeFunc) (GstClock *clock, gpointer user_data);
typedef GstClockTime (*GstAudioClockGetTimeFunc) (GstClock * clock,
gpointer user_data);
struct _GstAudioClock {
struct _GstAudioClock
{
GstSystemClock clock;
GstClockTime prev1, prev2;
@ -63,19 +63,19 @@ struct _GstAudioClock {
gpointer _gst_reserved[GST_PADDING];
};
struct _GstAudioClockClass {
struct _GstAudioClockClass
{
GstSystemClockClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
GType gst_audio_clock_get_type (void);
GstClock* gst_audio_clock_new (gchar *name, GstAudioClockGetTimeFunc func,
gpointer user_data);
void gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active);
GType gst_audio_clock_get_type (void);
GstClock *gst_audio_clock_new (gchar * name, GstAudioClockGetTimeFunc func,
gpointer user_data);
void gst_audio_clock_set_active (GstAudioClock * aclock, gboolean active);
void gst_audio_clock_update_time (GstAudioClock *aclock, GstClockTime time);
void gst_audio_clock_update_time (GstAudioClock * aclock, GstClockTime time);
G_END_DECLS
#endif /* __GST_AUDIO_CLOCK_H__ */

View file

@ -29,26 +29,30 @@
/* GstAudiofilter signals and args */
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
ARG_METHOD,
/* FILL ME */
};
static void gst_audiofilter_base_init (gpointer g_class);
static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data);
static void gst_audiofilter_init (GTypeInstance *instance, gpointer g_class);
static void gst_audiofilter_base_init (gpointer g_class);
static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data);
static void gst_audiofilter_init (GTypeInstance * instance, gpointer g_class);
static void gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_audiofilter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_audiofilter_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_audiofilter_chain (GstPad *pad, GstData *_data);
GstCaps * gst_audiofilter_class_get_capslist(GstAudiofilterClass *klass);
static void gst_audiofilter_chain (GstPad * pad, GstData * _data);
GstCaps *gst_audiofilter_class_get_capslist (GstAudiofilterClass * klass);
static GstElementClass *parent_class = NULL;
@ -59,23 +63,24 @@ gst_audiofilter_get_type (void)
if (!audiofilter_type) {
static const GTypeInfo audiofilter_info = {
sizeof(GstAudiofilterClass),
sizeof (GstAudiofilterClass),
gst_audiofilter_base_init,
NULL,
gst_audiofilter_class_init,
NULL,
NULL,
sizeof(GstAudiofilter),
sizeof (GstAudiofilter),
0,
gst_audiofilter_init,
};
audiofilter_type = g_type_register_static(GST_TYPE_ELEMENT,
audiofilter_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstAudiofilter", &audiofilter_info, G_TYPE_FLAG_ABSTRACT);
}
return audiofilter_type;
}
static void gst_audiofilter_base_init (gpointer g_class)
static void
gst_audiofilter_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_details = {
"Audio filter base class",
@ -89,24 +94,25 @@ static void gst_audiofilter_base_init (gpointer g_class)
gst_element_class_set_details (element_class, &audiofilter_details);
}
static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data)
static void
gst_audiofilter_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstAudiofilterClass *klass;
klass = (GstAudiofilterClass *)g_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
klass = (GstAudiofilterClass *) g_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_audiofilter_set_property;
gobject_class->get_property = gst_audiofilter_get_property;
}
static GstPadLinkReturn
gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
gst_audiofilter_link (GstPad * pad, const GstCaps * caps)
{
GstAudiofilter *audiofilter;
GstPadLinkReturn ret;
@ -114,11 +120,10 @@ gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
GstStructure *structure;
GstAudiofilterClass *audiofilter_class;
GST_DEBUG("gst_audiofilter_link");
GST_DEBUG ("gst_audiofilter_link");
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
audiofilter_class = GST_AUDIOFILTER_CLASS (
G_OBJECT_GET_CLASS (audiofilter));
audiofilter_class = GST_AUDIOFILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
if (pad == audiofilter->srcpad) {
link_ret = gst_pad_try_set_caps (audiofilter->sinkpad, caps);
@ -135,53 +140,55 @@ gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0) {
ret = gst_structure_get_int (structure, "depth", &audiofilter->depth);
ret &= gst_structure_get_int (structure, "width", &audiofilter->width);
ret &= gst_structure_get_int (structure, "channels", &audiofilter->channels);
ret &=
gst_structure_get_int (structure, "channels", &audiofilter->channels);
} else if (strcmp (gst_structure_get_name (structure), "audio/x-raw-float")
== 0) {
} else {
g_assert_not_reached();
g_assert_not_reached ();
}
ret &= gst_structure_get_int (structure, "rate", &audiofilter->rate);
audiofilter->bytes_per_sample = (audiofilter->width/8) *
audiofilter->channels;
audiofilter->bytes_per_sample = (audiofilter->width / 8) *
audiofilter->channels;
if (audiofilter_class->setup) (audiofilter_class->setup) (audiofilter);
if (audiofilter_class->setup)
(audiofilter_class->setup) (audiofilter);
return GST_PAD_LINK_OK;
}
static void
gst_audiofilter_init (GTypeInstance *instance, gpointer g_class)
gst_audiofilter_init (GTypeInstance * instance, gpointer g_class)
{
GstAudiofilter *audiofilter = GST_AUDIOFILTER (instance);
GstPadTemplate *pad_template;
GST_DEBUG("gst_audiofilter_init");
GST_DEBUG ("gst_audiofilter_init");
pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
"sink");
g_return_if_fail(pad_template != NULL);
audiofilter->sinkpad = gst_pad_new_from_template(pad_template, "sink");
gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->sinkpad);
gst_pad_set_chain_function(audiofilter->sinkpad,gst_audiofilter_chain);
gst_pad_set_link_function(audiofilter->sinkpad,gst_audiofilter_link);
gst_pad_set_getcaps_function(audiofilter->sinkpad,gst_pad_proxy_getcaps);
pad_template =
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "sink");
g_return_if_fail (pad_template != NULL);
audiofilter->sinkpad = gst_pad_new_from_template (pad_template, "sink");
gst_element_add_pad (GST_ELEMENT (audiofilter), audiofilter->sinkpad);
gst_pad_set_chain_function (audiofilter->sinkpad, gst_audiofilter_chain);
gst_pad_set_link_function (audiofilter->sinkpad, gst_audiofilter_link);
gst_pad_set_getcaps_function (audiofilter->sinkpad, gst_pad_proxy_getcaps);
pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
"src");
g_return_if_fail(pad_template != NULL);
audiofilter->srcpad = gst_pad_new_from_template(pad_template, "src");
gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->srcpad);
gst_pad_set_link_function(audiofilter->srcpad,gst_audiofilter_link);
gst_pad_set_getcaps_function(audiofilter->srcpad,gst_pad_proxy_getcaps);
pad_template =
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
g_return_if_fail (pad_template != NULL);
audiofilter->srcpad = gst_pad_new_from_template (pad_template, "src");
gst_element_add_pad (GST_ELEMENT (audiofilter), audiofilter->srcpad);
gst_pad_set_link_function (audiofilter->srcpad, gst_audiofilter_link);
gst_pad_set_getcaps_function (audiofilter->srcpad, gst_pad_proxy_getcaps);
audiofilter->inited = FALSE;
}
static void
gst_audiofilter_chain (GstPad *pad, GstData *data)
gst_audiofilter_chain (GstPad * pad, GstData * data)
{
GstBuffer *inbuf = GST_BUFFER (data);
GstAudiofilter *audiofilter;
@ -196,60 +203,60 @@ gst_audiofilter_chain (GstPad *pad, GstData *data)
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
//g_return_if_fail (audiofilter->inited);
audiofilter_class = GST_AUDIOFILTER_CLASS (
G_OBJECT_GET_CLASS (audiofilter));
audiofilter_class = GST_AUDIOFILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
GST_DEBUG ("gst_audiofilter_chain: got buffer of %d bytes in '%s'",
GST_BUFFER_SIZE(inbuf), GST_OBJECT_NAME (audiofilter));
if(audiofilter->passthru){
gst_pad_push(audiofilter->srcpad, data);
GST_BUFFER_SIZE (inbuf), GST_OBJECT_NAME (audiofilter));
if (audiofilter->passthru) {
gst_pad_push (audiofilter->srcpad, data);
return;
}
audiofilter->size = GST_BUFFER_SIZE (inbuf);
audiofilter->n_samples = audiofilter->size / audiofilter->bytes_per_sample;
if (gst_data_is_writable(data)) {
if (gst_data_is_writable (data)) {
if (audiofilter_class->filter_inplace) {
(audiofilter_class->filter_inplace) (audiofilter, inbuf);
outbuf = inbuf;
} else {
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf));
GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf);
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf);
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (inbuf));
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
(audiofilter_class->filter) (audiofilter, outbuf, inbuf);
gst_buffer_unref(inbuf);
gst_buffer_unref (inbuf);
}
} else {
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf));
GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf);
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf);
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (inbuf));
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
if (audiofilter_class->filter) {
(audiofilter_class->filter) (audiofilter, outbuf, inbuf);
} else {
memcpy(GST_BUFFER_DATA(outbuf), GST_BUFFER_DATA(inbuf),
GST_BUFFER_SIZE(inbuf));
memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
GST_BUFFER_SIZE (inbuf));
(audiofilter_class->filter_inplace) (audiofilter, outbuf);
}
gst_buffer_unref(inbuf);
gst_buffer_unref (inbuf);
}
gst_pad_push(audiofilter->srcpad, GST_DATA (outbuf));
gst_pad_push (audiofilter->srcpad, GST_DATA (outbuf));
}
static void
gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_audiofilter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAudiofilter *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER(object));
src = GST_AUDIOFILTER(object);
g_return_if_fail (GST_IS_AUDIOFILTER (object));
src = GST_AUDIOFILTER (object);
GST_DEBUG("gst_audiofilter_set_property");
GST_DEBUG ("gst_audiofilter_set_property");
switch (prop_id) {
default:
break;
@ -257,13 +264,14 @@ gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *valu
}
static void
gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_audiofilter_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstAudiofilter *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER(object));
src = GST_AUDIOFILTER(object);
g_return_if_fail (GST_IS_AUDIOFILTER (object));
src = GST_AUDIOFILTER (object);
switch (prop_id) {
default:
@ -272,37 +280,31 @@ gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GPa
}
}
void gst_audiofilter_class_add_pad_templates (
GstAudiofilterClass *audiofilter_class, const GstCaps *caps)
void
gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *
audiofilter_class, const GstCaps * caps)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (audiofilter_class);
audiofilter_class->caps = gst_caps_copy(caps);
audiofilter_class->caps = gst_caps_copy (caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gst_caps_copy(caps)));
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gst_caps_copy (caps)));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
gst_caps_copy(caps)));
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
gst_caps_copy (caps)));
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter",
"Audio filter parent class",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter",
"Audio filter parent class",
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -25,17 +25,15 @@
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstAudiofilter GstAudiofilter;
G_BEGIN_DECLS typedef struct _GstAudiofilter GstAudiofilter;
typedef struct _GstAudiofilterClass GstAudiofilterClass;
typedef void (*GstAudiofilterFilterFunc)(GstAudiofilter *filter,
GstBuffer *outbuf, GstBuffer *inbuf);
typedef void (*GstAudiofilterInplaceFilterFunc)(GstAudiofilter *filter,
GstBuffer *buffer);
typedef void (*GstAudiofilterFilterFunc) (GstAudiofilter * filter,
GstBuffer * outbuf, GstBuffer * inbuf);
typedef void (*GstAudiofilterInplaceFilterFunc) (GstAudiofilter * filter,
GstBuffer * buffer);
typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter *filter);
typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter * filter);
#define GST_TYPE_AUDIOFILTER \
@ -49,10 +47,11 @@ typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter *filter);
#define GST_IS_AUDIOFILTER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER))
struct _GstAudiofilter {
struct _GstAudiofilter
{
GstElement element;
GstPad *sinkpad,*srcpad;
GstPad *sinkpad, *srcpad;
/* audio state */
gboolean inited;
@ -68,7 +67,8 @@ struct _GstAudiofilter {
int bytes_per_sample;
};
struct _GstAudiofilterClass {
struct _GstAudiofilterClass
{
GstElementClass parent_class;
GstCaps *caps;
@ -77,11 +77,10 @@ struct _GstAudiofilterClass {
GstAudiofilterFilterFunc filter;
};
GType gst_audiofilter_get_type(void);
GType gst_audiofilter_get_type (void);
void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *audiofilterclass, const GstCaps *caps);
void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *
audiofilterclass, const GstCaps * caps);
G_END_DECLS
#endif /* __GST_AUDIOFILTER_H__ */

View file

@ -48,37 +48,47 @@ typedef struct _GstAudiofilterTemplateClass GstAudiofilterTemplateClass;
#define GST_IS_AUDIOFILTER_TEMPLATE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER_TEMPLATE))
struct _GstAudiofilterTemplate {
struct _GstAudiofilterTemplate
{
GstAudiofilter audiofilter;
};
struct _GstAudiofilterTemplateClass {
struct _GstAudiofilterTemplateClass
{
GstAudiofilterClass parent_class;
};
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
/* FILL ME */
};
static void gst_audiofilter_template_base_init (gpointer g_class);
static void gst_audiofilter_template_class_init (gpointer g_class, gpointer class_data);
static void gst_audiofilter_template_init (GTypeInstance *instance, gpointer g_class);
static void gst_audiofilter_template_base_init (gpointer g_class);
static void gst_audiofilter_template_class_init (gpointer g_class,
gpointer class_data);
static void gst_audiofilter_template_init (GTypeInstance * instance,
gpointer g_class);
static void gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_audiofilter_template_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_audiofilter_template_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_audiofilter_template_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_audiofilter_template_setup (GstAudiofilter *audiofilter);
static void gst_audiofilter_template_filter (GstAudiofilter *audiofilter, GstBuffer *outbuf, GstBuffer *inbuf);
static void gst_audiofilter_template_filter_inplace (GstAudiofilter *audiofilter, GstBuffer *buf);
static void gst_audiofilter_template_setup (GstAudiofilter * audiofilter);
static void gst_audiofilter_template_filter (GstAudiofilter * audiofilter,
GstBuffer * outbuf, GstBuffer * inbuf);
static void gst_audiofilter_template_filter_inplace (GstAudiofilter *
audiofilter, GstBuffer * buf);
GType
gst_audiofilter_template_get_type (void)
@ -87,23 +97,24 @@ gst_audiofilter_template_get_type (void)
if (!audiofilter_template_type) {
static const GTypeInfo audiofilter_template_info = {
sizeof(GstAudiofilterTemplateClass),
sizeof (GstAudiofilterTemplateClass),
gst_audiofilter_template_base_init,
NULL,
gst_audiofilter_template_class_init,
NULL,
gst_audiofilter_template_init,
sizeof(GstAudiofilterTemplate),
sizeof (GstAudiofilterTemplate),
0,
NULL,
};
audiofilter_template_type = g_type_register_static(GST_TYPE_AUDIOFILTER,
audiofilter_template_type = g_type_register_static (GST_TYPE_AUDIOFILTER,
"GstAudiofilterTemplate", &audiofilter_template_info, 0);
}
return audiofilter_template_type;
}
static void gst_audiofilter_template_base_init (gpointer g_class)
static void
gst_audiofilter_template_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_template_details = {
"Audio filter template",
@ -128,16 +139,16 @@ gst_audiofilter_template_class_init (gpointer g_class, gpointer class_data)
GstAudiofilterTemplateClass *klass;
GstAudiofilterClass *audiofilter_class;
klass = (GstAudiofilterTemplateClass *)g_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
audiofilter_class = (GstAudiofilterClass *)g_class;
klass = (GstAudiofilterTemplateClass *) g_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
audiofilter_class = (GstAudiofilterClass *) g_class;
#if 0
g_object_class_install_property(gobject_class, ARG_METHOD,
g_param_spec_enum("method","method","method",
GST_TYPE_AUDIOTEMPLATE_METHOD, GST_AUDIOTEMPLATE_METHOD_1,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_METHOD,
g_param_spec_enum ("method", "method", "method",
GST_TYPE_AUDIOTEMPLATE_METHOD, GST_AUDIOTEMPLATE_METHOD_1,
G_PARAM_READWRITE));
#endif
gobject_class->set_property = gst_audiofilter_template_set_property;
@ -146,11 +157,11 @@ gst_audiofilter_template_class_init (gpointer g_class, gpointer class_data)
audiofilter_class->setup = gst_audiofilter_template_setup;
audiofilter_class->filter = gst_audiofilter_template_filter;
audiofilter_class->filter_inplace = gst_audiofilter_template_filter_inplace;
audiofilter_class->filter = NULL;
audiofilter_class->filter = NULL;
}
static void
gst_audiofilter_template_init (GTypeInstance *instance, gpointer g_class)
gst_audiofilter_template_init (GTypeInstance * instance, gpointer g_class)
{
//GstAudiofilterTemplate *audiofilter_template = GST_AUDIOFILTER_TEMPLATE (instance);
//GstAudiofilter *audiofilter = GST_AUDIOFILTER (instance);
@ -162,15 +173,16 @@ gst_audiofilter_template_init (GTypeInstance *instance, gpointer g_class)
}
static void
gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_audiofilter_template_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAudiofilterTemplate *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER_TEMPLATE(object));
src = GST_AUDIOFILTER_TEMPLATE(object);
g_return_if_fail (GST_IS_AUDIOFILTER_TEMPLATE (object));
src = GST_AUDIOFILTER_TEMPLATE (object);
GST_DEBUG("gst_audiofilter_template_set_property");
GST_DEBUG ("gst_audiofilter_template_set_property");
switch (prop_id) {
default:
break;
@ -178,13 +190,14 @@ gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GVa
}
static void
gst_audiofilter_template_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_audiofilter_template_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstAudiofilterTemplate *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER_TEMPLATE(object));
src = GST_AUDIOFILTER_TEMPLATE(object);
g_return_if_fail (GST_IS_AUDIOFILTER_TEMPLATE (object));
src = GST_AUDIOFILTER_TEMPLATE (object);
switch (prop_id) {
default:
@ -194,7 +207,7 @@ gst_audiofilter_template_get_property (GObject *object, guint prop_id, GValue *v
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstaudiofilter"))
return FALSE;
@ -203,20 +216,13 @@ plugin_init (GstPlugin *plugin)
GST_TYPE_AUDIOFILTER_TEMPLATE);
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter_template",
"Audio filter template",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter_template",
"Audio filter template",
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
static void
gst_audiofilter_template_setup (GstAudiofilter *audiofilter)
static void gst_audiofilter_template_setup (GstAudiofilter * audiofilter)
{
GstAudiofilterTemplate *audiofilter_template;
@ -234,8 +240,8 @@ gst_audiofilter_template_setup (GstAudiofilter *audiofilter)
* with a minimum of memory copies. */
static void
gst_audiofilter_template_filter (GstAudiofilter *audiofilter,
GstBuffer *outbuf, GstBuffer *inbuf)
gst_audiofilter_template_filter (GstAudiofilter * audiofilter,
GstBuffer * outbuf, GstBuffer * inbuf)
{
GstAudiofilterTemplate *audiofilter_template;
@ -245,13 +251,12 @@ gst_audiofilter_template_filter (GstAudiofilter *audiofilter,
/* do something interesting here. This simply copies the source
* to the destination. */
memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
audiofilter->size);
memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf), audiofilter->size);
}
static void
gst_audiofilter_template_filter_inplace (GstAudiofilter *audiofilter,
GstBuffer *buf)
gst_audiofilter_template_filter_inplace (GstAudiofilter * audiofilter,
GstBuffer * buf)
{
GstAudiofilterTemplate *audiofilter_template;
@ -262,4 +267,3 @@ gst_audiofilter_template_filter_inplace (GstAudiofilter *audiofilter,
* to the destination. */
}

View file

@ -27,12 +27,13 @@
#include "colorbalance.h"
#include "colorbalance-marshal.h"
enum {
enum
{
VALUE_CHANGED,
LAST_SIGNAL
};
static void gst_color_balance_class_init (GstColorBalanceClass *klass);
static void gst_color_balance_class_init (GstColorBalanceClass * klass);
static guint gst_color_balance_signals[LAST_SIGNAL] = { 0 };
@ -55,35 +56,33 @@ gst_color_balance_get_type (void)
};
gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
"GstColorBalance",
&gst_color_balance_info, 0);
"GstColorBalance", &gst_color_balance_info, 0);
g_type_interface_add_prerequisite (gst_color_balance_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_color_balance_type;
}
static void
gst_color_balance_class_init (GstColorBalanceClass *klass)
gst_color_balance_class_init (GstColorBalanceClass * klass)
{
static gboolean initialized = FALSE;
if (!initialized) {
gst_color_balance_signals[VALUE_CHANGED] =
g_signal_new ("value-changed",
GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
NULL, NULL,
gst_color_balance_marshal_VOID__OBJECT_INT,
G_TYPE_NONE, 2,
GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
g_signal_new ("value-changed",
GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
NULL, NULL,
gst_color_balance_marshal_VOID__OBJECT_INT,
G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
initialized = TRUE;
}
klass->balance_type = GST_COLOR_BALANCE_SOFTWARE;
/* default virtual functions */
klass->list_channels = NULL;
klass->set_value = NULL;
@ -91,7 +90,7 @@ gst_color_balance_class_init (GstColorBalanceClass *klass)
}
const GList *
gst_color_balance_list_channels (GstColorBalance *balance)
gst_color_balance_list_channels (GstColorBalance * balance)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
@ -103,9 +102,8 @@ gst_color_balance_list_channels (GstColorBalance *balance)
}
void
gst_color_balance_set_value (GstColorBalance *balance,
GstColorBalanceChannel *channel,
gint value)
gst_color_balance_set_value (GstColorBalance * balance,
GstColorBalanceChannel * channel, gint value)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
@ -115,8 +113,8 @@ gst_color_balance_set_value (GstColorBalance *balance,
}
gint
gst_color_balance_get_value (GstColorBalance *balance,
GstColorBalanceChannel *channel)
gst_color_balance_get_value (GstColorBalance * balance,
GstColorBalanceChannel * channel)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
@ -128,13 +126,11 @@ gst_color_balance_get_value (GstColorBalance *balance,
}
void
gst_color_balance_value_changed (GstColorBalance *balance,
GstColorBalanceChannel *channel,
gint value)
gst_color_balance_value_changed (GstColorBalance * balance,
GstColorBalanceChannel * channel, gint value)
{
g_signal_emit (G_OBJECT (balance),
gst_color_balance_signals[VALUE_CHANGED],
0, channel, value);
gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);
}

View file

@ -27,7 +27,6 @@
#include <gst/colorbalance/colorbalance-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_COLOR_BALANCE \
(gst_color_balance_get_type ())
#define GST_COLOR_BALANCE(obj) \
@ -42,55 +41,48 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE))
#define GST_COLOR_BALANCE_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_COLOR_BALANCE, GstColorBalanceClass))
#define GST_COLOR_BALANCE_TYPE(klass) (klass->balance_type)
typedef struct _GstColorBalance GstColorBalance;
typedef enum
{
GST_COLOR_BALANCE_HARDWARE,
GST_COLOR_BALANCE_SOFTWARE
} GstColorBalanceType;
typedef struct _GstColorBalanceClass {
typedef struct _GstColorBalanceClass
{
GTypeInterface klass;
GstColorBalanceType balance_type;
/* virtual functions */
const GList * (* list_channels) (GstColorBalance *balance);
void (* set_value) (GstColorBalance *balance,
GstColorBalanceChannel *channel,
gint value);
gint (* get_value) (GstColorBalance *balance,
GstColorBalanceChannel *channel);
/* virtual functions */
const GList *(*list_channels) (GstColorBalance * balance);
void (*set_value) (GstColorBalance * balance,
GstColorBalanceChannel * channel, gint value);
gint (*get_value) (GstColorBalance * balance,
GstColorBalanceChannel * channel);
/* signals */
void (* value_changed) (GstColorBalance *balance,
GstColorBalanceChannel *channel,
gint value);
void (*value_changed) (GstColorBalance * balance,
GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceClass;
GType gst_color_balance_get_type (void);
GType gst_color_balance_get_type (void);
/* virtual class function wrappers */
const GList *
gst_color_balance_list_channels (GstColorBalance *balance);
void gst_color_balance_set_value (GstColorBalance *balance,
GstColorBalanceChannel *channel,
gint value);
gint gst_color_balance_get_value (GstColorBalance *balance,
GstColorBalanceChannel *channel);
const GList *gst_color_balance_list_channels (GstColorBalance * balance);
void gst_color_balance_set_value (GstColorBalance * balance,
GstColorBalanceChannel * channel, gint value);
gint gst_color_balance_get_value (GstColorBalance * balance,
GstColorBalanceChannel * channel);
/* trigger signal */
void gst_color_balance_value_changed (GstColorBalance *balance,
GstColorBalanceChannel *channel,
gint value);
void gst_color_balance_value_changed (GstColorBalance * balance,
GstColorBalanceChannel * channel, gint value);
G_END_DECLS
#endif /* __GST_COLOR_BALANCE_H__ */

View file

@ -25,15 +25,17 @@
#include "colorbalancechannel.h"
enum {
enum
{
/* FILL ME */
SIGNAL_VALUE_CHANGED,
LAST_SIGNAL
};
static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass);
static void gst_color_balance_channel_init (GstColorBalanceChannel *balance);
static void gst_color_balance_channel_dispose (GObject *object);
static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *
klass);
static void gst_color_balance_channel_init (GstColorBalanceChannel * balance);
static void gst_color_balance_channel_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
@ -59,46 +61,44 @@ gst_color_balance_channel_get_type (void)
gst_color_balance_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstColorBalanceChannel",
&color_balance_channel_info, 0);
"GstColorBalanceChannel", &color_balance_channel_info, 0);
}
return gst_color_balance_channel_type;
}
static void
gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass)
gst_color_balance_channel_class_init (GstColorBalanceChannelClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
signals[SIGNAL_VALUE_CHANGED] =
g_signal_new ("value-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstColorBalanceChannelClass,
value_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
g_signal_new ("value-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstColorBalanceChannelClass,
value_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_color_balance_channel_dispose;
}
static void
gst_color_balance_channel_init (GstColorBalanceChannel *channel)
gst_color_balance_channel_init (GstColorBalanceChannel * channel)
{
channel->label = NULL;
channel->min_value = channel->max_value = 0;
}
static void
gst_color_balance_channel_dispose (GObject *object)
gst_color_balance_channel_dispose (GObject * object)
{
GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (object);
if (channel->label)
g_free (channel->label);
channel->label = NULL;
if (parent_class->dispose)

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_COLOR_BALANCE_CHANNEL \
(gst_color_balance_channel_get_type ())
#define GST_COLOR_BALANCE_CHANNEL(obj) \
@ -38,27 +37,25 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_COLOR_BALANCE_CHANNEL))
#define GST_IS_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE_CHANNEL))
typedef struct _GstColorBalanceChannel {
typedef struct _GstColorBalanceChannel
{
GObject parent;
gchar *label;
gint min_value,
max_value;
gchar *label;
gint min_value, max_value;
} GstColorBalanceChannel;
typedef struct _GstColorBalanceChannelClass {
typedef struct _GstColorBalanceChannelClass
{
GObjectClass parent;
/* signals */
void (* value_changed) (GstColorBalanceChannel *channel,
gint value);
void (*value_changed) (GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceChannelClass;
GType gst_color_balance_channel_get_type (void);
GType gst_color_balance_channel_get_type (void);
G_END_DECLS
#endif /* __GST_COLOR_BALANCE_CHANNEL_H__ */

View file

@ -29,53 +29,46 @@
#include <glib/gtypes.h>
G_BEGIN_DECLS
#if (HAVE_LRINT && HAVE_LRINTF)
/* These defines enable functionality introduced with the 1999 ISO C
** standard. They must be defined before the inclusion of math.h to
** engage them. If optimisation is enabled, these functions will be
** inlined. With optimisation switched off, you have to link in the
** maths library using -lm.
*/
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
#include <math.h>
#define gst_cast_float(x) ((gint)lrintf(x))
#define gst_cast_double(x) ((gint)lrint(x))
/* These defines enable functionality introduced with the 1999 ISO C
** standard. They must be defined before the inclusion of math.h to
** engage them. If optimisation is enabled, these functions will be
** inlined. With optimisation switched off, you have to link in the
** maths library using -lm.
*/
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
#include <math.h>
#define gst_cast_float(x) ((gint)lrintf(x))
#define gst_cast_double(x) ((gint)lrint(x))
#else
/* use a standard c cast, but do rounding correctly */
#define gst_cast_float(x) ((gint)floor((x)+0.5))
#define gst_cast_double(x) ((gint)floor((x)+0.5))
/* use a standard c cast, but do rounding correctly */
#define gst_cast_float(x) ((gint)floor((x)+0.5))
#define gst_cast_double(x) ((gint)floor((x)+0.5))
#endif
inline static gfloat
GFLOAT_SWAP_LE_BE(gfloat in)
GFLOAT_SWAP_LE_BE (gfloat in)
{
gint32 swap;
gfloat out;
memcpy(&swap, &in, 4);
memcpy (&swap, &in, 4);
swap = GUINT32_SWAP_LE_BE_CONSTANT (swap);
memcpy(&out, &swap, 4);
memcpy (&out, &swap, 4);
return out;
}
inline static gdouble
GDOUBLE_SWAP_LE_BE(gdouble in)
GDOUBLE_SWAP_LE_BE (gdouble in)
{
gint64 swap;
gdouble out;
memcpy(&swap, &in, 8);
memcpy (&swap, &in, 8);
swap = GUINT64_SWAP_LE_BE_CONSTANT (swap);
memcpy(&out, &swap, 8);
memcpy (&out, &swap, 8);
return out;
}
@ -101,6 +94,4 @@ GDOUBLE_SWAP_LE_BE(gdouble in)
#define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))
G_END_DECLS
#endif /* __FLOATCAST_H__ */

View file

@ -31,7 +31,7 @@
#error "GST_GCONF_DIR is not defined !"
#endif
static GConfClient *_gst_gconf_client = NULL; /* GConf connection */
static GConfClient *_gst_gconf_client = NULL; /* GConf connection */
/* internal functions */
@ -48,7 +48,7 @@ gst_gconf_get_client (void)
/* go through a bin, finding the one pad that is unconnected in the given
* * direction, and return that pad */
static GstPad *
gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction)
gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction)
{
GstPad *pad = NULL;
GList *elements = NULL;
@ -57,22 +57,19 @@ gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction)
elements = (GList *) gst_bin_get_list (bin);
/* traverse all elements looking for unconnected pads */
while (elements && pad == NULL)
{
while (elements && pad == NULL) {
element = GST_ELEMENT (elements->data);
pads = gst_element_get_pad_list (element);
while (pads)
{
while (pads) {
/* check if the direction matches */
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction)
{
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL)
{
/* found it ! */
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) {
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) {
/* found it ! */
pad = GST_PAD (pads->data);
}
}
if (pad) break; /* found one already */
if (pad)
break; /* found one already */
pads = g_list_next (pads);
}
elements = g_list_next (elements);
@ -91,7 +88,7 @@ gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction)
* Returns: a #gchar string containing @key's value.
*/
gchar *
gst_gconf_get_string (const gchar *key)
gst_gconf_get_string (const gchar * key)
{
GError *error = NULL;
gchar *value = NULL;
@ -101,8 +98,7 @@ gst_gconf_get_string (const gchar *key)
value = gconf_client_get_string (gst_gconf_get_client (), full_key, &error);
g_free (full_key);
if (error)
{
if (error) {
g_print ("gst_gconf_get_string: error: %s\n", error->message);
g_error_free (error);
}
@ -118,14 +114,13 @@ gst_gconf_get_string (const gchar *key)
* Set GConf key @key to string value @value.
*/
void
gst_gconf_set_string (const gchar *key, const gchar *value)
gst_gconf_set_string (const gchar * key, const gchar * value)
{
GError *error = NULL;
gchar *full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key);
gconf_client_set_string (gst_gconf_get_client (), full_key, value, &error);
if (error)
{
if (error) {
g_print ("gst_gconf_set_string: error: %s\n", error->message);
g_error_free (error);
}
@ -141,7 +136,7 @@ gst_gconf_set_string (const gchar *key, const gchar *value)
* Returns: a #GstElement containing the rendered bin.
*/
GstElement *
gst_gconf_render_bin_from_description (const gchar *description)
gst_gconf_render_bin_from_description (const gchar * description)
{
GstElement *bin = NULL;
GstPad *pad = NULL;
@ -152,19 +147,18 @@ gst_gconf_render_bin_from_description (const gchar *description)
desc = g_strdup_printf ("bin.( %s )", description);
bin = GST_ELEMENT (gst_parse_launch (desc, &error));
g_free (desc);
if (error)
{
if (error) {
g_print ("DEBUG: gstgconf: error parsing pipeline %s\n%s\n",
description, error->message);
description, error->message);
g_error_free (error);
return NULL;
}
/* find pads and ghost them if necessary */
if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SRC))){
if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SRC))) {
gst_element_add_ghost_pad (bin, pad, "src");
}
if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SINK))){
if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SINK))) {
gst_element_add_ghost_pad (bin, pad, "sink");
}
return bin;
@ -179,11 +173,11 @@ gst_gconf_render_bin_from_description (const gchar *description)
* Returns: a #GstElement containing the rendered bin.
*/
GstElement *
gst_gconf_render_bin_from_key (const gchar *key)
gst_gconf_render_bin_from_key (const gchar * key)
{
GstElement *bin = NULL;
gchar *value;
value = gst_gconf_get_string (key);
if (value)
bin = gst_gconf_render_bin_from_description (value);
@ -203,10 +197,10 @@ GstElement *
gst_gconf_get_default_audio_sink (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/audiosink");
if (!ret) {
ret = gst_element_factory_make ("osssink", NULL);
if (!ret)
g_warning ("No GConf default audio sink key and osssink doesn't work");
else
@ -229,10 +223,10 @@ GstElement *
gst_gconf_get_default_video_sink (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/videosink");
if (!ret) {
ret = gst_element_factory_make ("ximagesink", NULL);
if (!ret)
g_warning ("No GConf default video sink key and ximagesink doesn't work");
else
@ -255,10 +249,10 @@ GstElement *
gst_gconf_get_default_audio_src (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/audiosrc");
if (!ret) {
ret = gst_element_factory_make ("osssrc", NULL);
if (!ret)
g_warning ("No GConf default audio src key and osssrc doesn't work");
else
@ -282,10 +276,10 @@ GstElement *
gst_gconf_get_default_video_src (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/videosrc");
if (!ret) {
ret = gst_element_factory_make ("videotestsrc", NULL);
if (!ret)
g_warning ("No GConf default video src key and videotestrc doesn't work");
else
@ -308,16 +302,16 @@ GstElement *
gst_gconf_get_default_visualization_element (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/visualization");
if (!ret) {
ret = gst_element_factory_make ("goom", NULL);
if (!ret)
g_warning ("No GConf default visualization plugin key and goom doesn't work");
g_warning
("No GConf default visualization plugin key and goom doesn't work");
else
g_print ("GConf visualization plugin not found, using goom\n");
}
return ret;
}

View file

@ -27,17 +27,16 @@
#include <gst/gst.h>
#include <gconf/gconf-client.h>
gchar * gst_gconf_get_string (const gchar *key);
void gst_gconf_set_string (const gchar *key,
const gchar *value);
gchar *gst_gconf_get_string (const gchar * key);
void gst_gconf_set_string (const gchar * key, const gchar * value);
GstElement * gst_gconf_render_bin_from_key (const gchar *key);
GstElement * gst_gconf_render_bin_from_description (const gchar *description);
GstElement *gst_gconf_render_bin_from_key (const gchar * key);
GstElement *gst_gconf_render_bin_from_description (const gchar * description);
GstElement * gst_gconf_get_default_video_sink (void);
GstElement * gst_gconf_get_default_audio_sink (void);
GstElement * gst_gconf_get_default_video_src (void);
GstElement * gst_gconf_get_default_audio_src (void);
GstElement * gst_gconf_get_default_visualization_element (void);
GstElement *gst_gconf_get_default_video_sink (void);
GstElement *gst_gconf_get_default_audio_sink (void);
GstElement *gst_gconf_get_default_video_src (void);
GstElement *gst_gconf_get_default_audio_src (void);
GstElement *gst_gconf_get_default_visualization_element (void);
#endif /* GST_GCONF_H */

View file

@ -22,13 +22,13 @@
int
main (int argc, char *argv[])
{
printf ("Default video sink : %s\n",
gst_gconf_get_string ("default/videosink"));
printf ("Default audio sink : %s\n",
gst_gconf_get_string ("default/audiosink"));
printf ("Default video src : %s\n",
gst_gconf_get_string ("default/videosrc"));
printf ("Default audio src : %s\n",
gst_gconf_get_string ("default/audiosrc"));
printf ("Default video sink : %s\n",
gst_gconf_get_string ("default/videosink"));
printf ("Default audio sink : %s\n",
gst_gconf_get_string ("default/audiosink"));
printf ("Default video src : %s\n",
gst_gconf_get_string ("default/videosrc"));
printf ("Default audio src : %s\n",
gst_gconf_get_string ("default/audiosrc"));
return 0;
}

View file

@ -22,8 +22,8 @@
#ifndef __GST_I18N_PLUGIN_H__
#define __GST_I18N_PLUGIN_H__
#include <locale.h> /* some people need it and some people don't */
#include "gettext.h" /* included with gettext distribution and copied */
#include <locale.h> /* some people need it and some people don't */
#include "gettext.h" /* included with gettext distribution and copied */
#ifndef GETTEXT_PACKAGE
#error You must define GETTEXT_PACKAGE before including this header.

View file

@ -16,7 +16,7 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
typedef long INT32; /* must be at least 32 bits */
extern void gst_idct_int_idct();
extern void gst_idct_int_idct ();
extern void gst_idct_init_fast_int_idct (void);
extern void gst_idct_fast_int_idct (short *block);
@ -27,6 +27,5 @@ extern void gst_idct_mmx32_idct (short *block);
extern void gst_idct_sse_idct (short *block);
#endif /* HAVE_LIBMMX */
extern void gst_idct_init_float_idct(void);
extern void gst_idct_init_float_idct (void);
extern void gst_idct_float_idct (short *block);

View file

@ -45,17 +45,17 @@
/* this code assumes >> to be a two's-complement arithmetic */
/* right shift: (-2)>>1 == -1 , (-3)>>1 == -2 */
#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */
#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */
#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */
#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */
#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */
#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */
#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */
#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */
#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
#include "dct.h"
/* private data */
static short iclip[1024]; /* clipping table */
static short iclip[1024]; /* clipping table */
static short *iclp;
/* private prototypes */
@ -72,57 +72,58 @@ static void idctcol (short *blk);
* c[1..7] = 128*sqrt(2)
*/
static void idctrow(blk)
short *blk;
static void
idctrow (blk)
short *blk;
{
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
/* shortcut */
if (!((x1 = blk[4]<<11) | (x2 = blk[6]) | (x3 = blk[2]) |
(x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3])))
{
blk[0]=blk[1]=blk[2]=blk[3]=blk[4]=blk[5]=blk[6]=blk[7]=blk[0]<<3;
if (!((x1 = blk[4] << 11) | (x2 = blk[6]) | (x3 = blk[2]) |
(x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3]))) {
blk[0] = blk[1] = blk[2] = blk[3] = blk[4] = blk[5] = blk[6] = blk[7] =
blk[0] << 3;
return;
}
x0 = (blk[0]<<11) + 128; /* for proper rounding in the fourth stage */
x0 = (blk[0] << 11) + 128; /* for proper rounding in the fourth stage */
/* first stage */
x8 = W7*(x4+x5);
x4 = x8 + (W1-W7)*x4;
x5 = x8 - (W1+W7)*x5;
x8 = W3*(x6+x7);
x6 = x8 - (W3-W5)*x6;
x7 = x8 - (W3+W5)*x7;
x8 = W7 * (x4 + x5);
x4 = x8 + (W1 - W7) * x4;
x5 = x8 - (W1 + W7) * x5;
x8 = W3 * (x6 + x7);
x6 = x8 - (W3 - W5) * x6;
x7 = x8 - (W3 + W5) * x7;
/* second stage */
x8 = x0 + x1;
x0 -= x1;
x1 = W6*(x3+x2);
x2 = x1 - (W2+W6)*x2;
x3 = x1 + (W2-W6)*x3;
x1 = W6 * (x3 + x2);
x2 = x1 - (W2 + W6) * x2;
x3 = x1 + (W2 - W6) * x3;
x1 = x4 + x6;
x4 -= x6;
x6 = x5 + x7;
x5 -= x7;
/* third stage */
x7 = x8 + x3;
x8 -= x3;
x3 = x0 + x2;
x0 -= x2;
x2 = (181*(x4+x5)+128)>>8;
x4 = (181*(x4-x5)+128)>>8;
x2 = (181 * (x4 + x5) + 128) >> 8;
x4 = (181 * (x4 - x5) + 128) >> 8;
/* fourth stage */
blk[0] = (x7+x1)>>8;
blk[1] = (x3+x2)>>8;
blk[2] = (x0+x4)>>8;
blk[3] = (x8+x6)>>8;
blk[4] = (x8-x6)>>8;
blk[5] = (x0-x4)>>8;
blk[6] = (x3-x2)>>8;
blk[7] = (x7-x1)>>8;
blk[0] = (x7 + x1) >> 8;
blk[1] = (x3 + x2) >> 8;
blk[2] = (x0 + x4) >> 8;
blk[3] = (x8 + x6) >> 8;
blk[4] = (x8 - x6) >> 8;
blk[5] = (x0 - x4) >> 8;
blk[6] = (x3 - x2) >> 8;
blk[7] = (x7 - x1) >> 8;
}
/* column (vertical) IDCT
@ -134,78 +135,81 @@ short *blk;
* where: c[0] = 1/1024
* c[1..7] = (1/1024)*sqrt(2)
*/
static void idctcol(blk)
short *blk;
static void
idctcol (blk)
short *blk;
{
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
/* shortcut */
if (!((x1 = (blk[8*4]<<8)) | (x2 = blk[8*6]) | (x3 = blk[8*2]) |
(x4 = blk[8*1]) | (x5 = blk[8*7]) | (x6 = blk[8*5]) | (x7 = blk[8*3])))
{
blk[8*0]=blk[8*1]=blk[8*2]=blk[8*3]=blk[8*4]=blk[8*5]=blk[8*6]=blk[8*7]=
iclp[(blk[8*0]+32)>>6];
if (!((x1 = (blk[8 * 4] << 8)) | (x2 = blk[8 * 6]) | (x3 = blk[8 * 2]) |
(x4 = blk[8 * 1]) | (x5 = blk[8 * 7]) | (x6 = blk[8 * 5]) | (x7 =
blk[8 * 3]))) {
blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = blk[8 * 3] = blk[8 * 4] =
blk[8 * 5] = blk[8 * 6] = blk[8 * 7] = iclp[(blk[8 * 0] + 32) >> 6];
return;
}
x0 = (blk[8*0]<<8) + 8192;
x0 = (blk[8 * 0] << 8) + 8192;
/* first stage */
x8 = W7*(x4+x5) + 4;
x4 = (x8+(W1-W7)*x4)>>3;
x5 = (x8-(W1+W7)*x5)>>3;
x8 = W3*(x6+x7) + 4;
x6 = (x8-(W3-W5)*x6)>>3;
x7 = (x8-(W3+W5)*x7)>>3;
x8 = W7 * (x4 + x5) + 4;
x4 = (x8 + (W1 - W7) * x4) >> 3;
x5 = (x8 - (W1 + W7) * x5) >> 3;
x8 = W3 * (x6 + x7) + 4;
x6 = (x8 - (W3 - W5) * x6) >> 3;
x7 = (x8 - (W3 + W5) * x7) >> 3;
/* second stage */
x8 = x0 + x1;
x0 -= x1;
x1 = W6*(x3+x2) + 4;
x2 = (x1-(W2+W6)*x2)>>3;
x3 = (x1+(W2-W6)*x3)>>3;
x1 = W6 * (x3 + x2) + 4;
x2 = (x1 - (W2 + W6) * x2) >> 3;
x3 = (x1 + (W2 - W6) * x3) >> 3;
x1 = x4 + x6;
x4 -= x6;
x6 = x5 + x7;
x5 -= x7;
/* third stage */
x7 = x8 + x3;
x8 -= x3;
x3 = x0 + x2;
x0 -= x2;
x2 = (181*(x4+x5)+128)>>8;
x4 = (181*(x4-x5)+128)>>8;
x2 = (181 * (x4 + x5) + 128) >> 8;
x4 = (181 * (x4 - x5) + 128) >> 8;
/* fourth stage */
blk[8*0] = iclp[(x7+x1)>>14];
blk[8*1] = iclp[(x3+x2)>>14];
blk[8*2] = iclp[(x0+x4)>>14];
blk[8*3] = iclp[(x8+x6)>>14];
blk[8*4] = iclp[(x8-x6)>>14];
blk[8*5] = iclp[(x0-x4)>>14];
blk[8*6] = iclp[(x3-x2)>>14];
blk[8*7] = iclp[(x7-x1)>>14];
blk[8 * 0] = iclp[(x7 + x1) >> 14];
blk[8 * 1] = iclp[(x3 + x2) >> 14];
blk[8 * 2] = iclp[(x0 + x4) >> 14];
blk[8 * 3] = iclp[(x8 + x6) >> 14];
blk[8 * 4] = iclp[(x8 - x6) >> 14];
blk[8 * 5] = iclp[(x0 - x4) >> 14];
blk[8 * 6] = iclp[(x3 - x2) >> 14];
blk[8 * 7] = iclp[(x7 - x1) >> 14];
}
/* two dimensional inverse discrete cosine transform */
void gst_idct_fast_int_idct(block)
short *block;
void
gst_idct_fast_int_idct (block)
short *block;
{
int i;
for (i=0; i<8; i++)
idctrow(block+8*i);
for (i = 0; i < 8; i++)
idctrow (block + 8 * i);
for (i=0; i<8; i++)
idctcol(block+i);
for (i = 0; i < 8; i++)
idctcol (block + i);
}
void gst_idct_init_fast_int_idct()
void
gst_idct_init_fast_int_idct ()
{
int i;
iclp = iclip+512;
for (i= -512; i<512; i++)
iclp[i] = (i<-256) ? -256 : ((i>255) ? 255 : i);
iclp = iclip + 512;
for (i = -512; i < 512; i++)
iclp[i] = (i < -256) ? -256 : ((i > 255) ? 255 : i);
}

View file

@ -56,51 +56,51 @@ static double gst_idct_float_c[8][8];
/* initialize DCT coefficient matrix */
void gst_idct_init_float_idct()
void
gst_idct_init_float_idct ()
{
int freq, time;
double scale;
for (freq=0; freq < 8; freq++)
{
scale = (freq == 0) ? sqrt(0.125) : 0.5;
for (time=0; time<8; time++)
gst_idct_float_c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5));
for (freq = 0; freq < 8; freq++) {
scale = (freq == 0) ? sqrt (0.125) : 0.5;
for (time = 0; time < 8; time++)
gst_idct_float_c[freq][time] =
scale * cos ((PI / 8.0) * freq * (time + 0.5));
}
}
/* perform IDCT matrix multiply for 8x8 coefficient block */
void gst_idct_float_idct(block)
short *block;
void
gst_idct_float_idct (block)
short *block;
{
int i, j, k, v;
double partial_product;
double tmp[64];
for (i=0; i<8; i++)
for (j=0; j<8; j++)
{
for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++) {
partial_product = 0.0;
for (k=0; k<8; k++)
partial_product+= gst_idct_float_c[k][j]*block[8*i+k];
for (k = 0; k < 8; k++)
partial_product += gst_idct_float_c[k][j] * block[8 * i + k];
tmp[8*i+j] = partial_product;
tmp[8 * i + j] = partial_product;
}
/* Transpose operation is integrated into address mapping by switching
loop order of i and j */
for (j=0; j<8; j++)
for (i=0; i<8; i++)
{
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++) {
partial_product = 0.0;
for (k=0; k<8; k++)
partial_product+= gst_idct_float_c[k][i]*tmp[8*k+j];
for (k = 0; k < 8; k++)
partial_product += gst_idct_float_c[k][i] * tmp[8 * k + j];
v = (int) floor(partial_product+0.5);
block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v);
v = (int) floor (partial_product + 0.5);
block[8 * i + j] = (v < -256) ? -256 : ((v > 255) ? 255 : v);
}
}

View file

@ -25,24 +25,25 @@
#include <gst/idct/idct.h>
#include "dct.h"
static void gst_idct_int_sparse_idct(short *data);
static void gst_idct_int_sparse_idct (short *data);
GstIDCT *gst_idct_new(GstIDCTMethod method)
GstIDCT *
gst_idct_new (GstIDCTMethod method)
{
GstIDCT *new = g_malloc(sizeof(GstIDCT));
GstIDCT *new = g_malloc (sizeof (GstIDCT));
new->need_transpose = FALSE;
if (method == GST_IDCT_DEFAULT) {
#ifdef HAVE_LIBMMX
if (gst_cpu_get_flags() & GST_CPU_FLAG_MMX) {
if (gst_cpu_get_flags () & GST_CPU_FLAG_MMX) {
method = GST_IDCT_MMX;
}
/* disabled for now
if (gst_cpu_get_flags() & GST_CPU_FLAG_SSE) {
method = GST_IDCT_SSE;
}
*/
if (gst_cpu_get_flags() & GST_CPU_FLAG_SSE) {
method = GST_IDCT_SSE;
}
*/
else
#endif /* HAVE_LIBMMX */
{
@ -53,49 +54,50 @@ GstIDCT *gst_idct_new(GstIDCTMethod method)
new->convert_sparse = gst_idct_int_sparse_idct;
switch (method) {
case GST_IDCT_FAST_INT:
GST_INFO ( "using fast_int_idct");
gst_idct_init_fast_int_idct();
new->convert = gst_idct_fast_int_idct;
break;
case GST_IDCT_INT:
GST_INFO ( "using int_idct");
new->convert = gst_idct_int_idct;
break;
case GST_IDCT_FLOAT:
GST_INFO ( "using float_idct");
gst_idct_init_float_idct();
new->convert = gst_idct_float_idct;
break;
case GST_IDCT_FAST_INT:
GST_INFO ("using fast_int_idct");
gst_idct_init_fast_int_idct ();
new->convert = gst_idct_fast_int_idct;
break;
case GST_IDCT_INT:
GST_INFO ("using int_idct");
new->convert = gst_idct_int_idct;
break;
case GST_IDCT_FLOAT:
GST_INFO ("using float_idct");
gst_idct_init_float_idct ();
new->convert = gst_idct_float_idct;
break;
#ifdef HAVE_LIBMMX
case GST_IDCT_MMX:
GST_INFO ( "using MMX_idct");
new->convert = gst_idct_mmx_idct;
new->need_transpose = TRUE;
break;
case GST_IDCT_MMX32:
GST_INFO ( "using MMX32_idct");
new->convert = gst_idct_mmx32_idct;
new->need_transpose = TRUE;
break;
case GST_IDCT_SSE:
GST_INFO ( "using SSE_idct");
new->convert = gst_idct_sse_idct;
new->need_transpose = TRUE;
break;
case GST_IDCT_MMX:
GST_INFO ("using MMX_idct");
new->convert = gst_idct_mmx_idct;
new->need_transpose = TRUE;
break;
case GST_IDCT_MMX32:
GST_INFO ("using MMX32_idct");
new->convert = gst_idct_mmx32_idct;
new->need_transpose = TRUE;
break;
case GST_IDCT_SSE:
GST_INFO ("using SSE_idct");
new->convert = gst_idct_sse_idct;
new->need_transpose = TRUE;
break;
#endif /* HAVE_LIBMMX */
default:
GST_INFO ( "method not supported");
g_free(new);
return NULL;
default:
GST_INFO ("method not supported");
g_free (new);
return NULL;
}
return new;
}
static void gst_idct_int_sparse_idct(short *data)
static void
gst_idct_int_sparse_idct (short *data)
{
short val;
gint32 v, *dp = (guint32 *)data;
gint32 v, *dp = (guint32 *) data;
v = *data;
@ -104,43 +106,61 @@ static void gst_idct_int_sparse_idct(short *data)
val += (8 >> 1);
val /= 8;
val = -val;
}
else {
} else {
val = (v + (8 >> 1)) / 8;
}
v = (( val & 0xffff) | (val << 16));
v = ((val & 0xffff) | (val << 16));
dp[0] = v; dp[1] = v; dp[2] = v; dp[3] = v;
dp[4] = v; dp[5] = v; dp[6] = v; dp[7] = v;
dp[8] = v; dp[9] = v; dp[10] = v; dp[11] = v;
dp[12] = v; dp[13] = v; dp[14] = v; dp[15] = v;
dp[16] = v; dp[17] = v; dp[18] = v; dp[19] = v;
dp[20] = v; dp[21] = v; dp[22] = v; dp[23] = v;
dp[24] = v; dp[25] = v; dp[26] = v; dp[27] = v;
dp[28] = v; dp[29] = v; dp[30] = v; dp[31] = v;
dp[0] = v;
dp[1] = v;
dp[2] = v;
dp[3] = v;
dp[4] = v;
dp[5] = v;
dp[6] = v;
dp[7] = v;
dp[8] = v;
dp[9] = v;
dp[10] = v;
dp[11] = v;
dp[12] = v;
dp[13] = v;
dp[14] = v;
dp[15] = v;
dp[16] = v;
dp[17] = v;
dp[18] = v;
dp[19] = v;
dp[20] = v;
dp[21] = v;
dp[22] = v;
dp[23] = v;
dp[24] = v;
dp[25] = v;
dp[26] = v;
dp[27] = v;
dp[28] = v;
dp[29] = v;
dp[30] = v;
dp[31] = v;
}
void gst_idct_destroy(GstIDCT *idct)
void
gst_idct_destroy (GstIDCT * idct)
{
g_return_if_fail(idct != NULL);
g_return_if_fail (idct != NULL);
g_free(idct);
g_free (idct);
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstidct",
"Accelerated IDCT routines",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstidct",
"Accelerated IDCT routines",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)

View file

@ -23,22 +23,24 @@
#include <glib.h>
typedef enum {
GST_IDCT_DEFAULT,
GST_IDCT_INT,
GST_IDCT_FAST_INT,
GST_IDCT_FLOAT,
GST_IDCT_MMX,
typedef enum
{
GST_IDCT_DEFAULT,
GST_IDCT_INT,
GST_IDCT_FAST_INT,
GST_IDCT_FLOAT,
GST_IDCT_MMX,
GST_IDCT_MMX32,
GST_IDCT_SSE,
} GstIDCTMethod;
typedef struct _GstIDCT GstIDCT;
typedef void (*GstIDCTFunction) (gshort *block);
typedef void (*GstIDCTFunction) (gshort * block);
#define GST_IDCT_TRANSPOSE(idct) ((idct)->need_transpose)
struct _GstIDCT {
struct _GstIDCT
{
/* private */
GstIDCTFunction convert;
GstIDCTFunction convert_sparse;
@ -46,9 +48,10 @@ struct _GstIDCT {
};
GstIDCT *gst_idct_new(GstIDCTMethod method);
GstIDCT *gst_idct_new (GstIDCTMethod method);
#define gst_idct_convert(idct, blocks) (idct)->convert((blocks))
#define gst_idct_convert_sparse(idct, blocks) (idct)->convert_sparse((blocks))
void gst_idct_destroy(GstIDCT *idct);
void gst_idct_destroy (GstIDCT * idct);
#endif /* __GST_IDCT_H__ */

View file

@ -27,9 +27,9 @@
void usage (char *msg);
long ieeerand (long L, long H);
void dct_init(void);
void ref_fdct(DCTELEM block[8][8]);
void ref_idct(DCTELEM block[8][8]);
void dct_init (void);
void ref_fdct (DCTELEM block[8][8]);
void ref_idct (DCTELEM block[8][8]);
/* error stat accumulators -- assume initialized to 0 */
@ -38,47 +38,49 @@ long sumsqerrs[DCTSIZE2];
int maxerr[DCTSIZE2];
char * meets (double val, double limit)
char *
meets (double val, double limit)
{
return ((fabs(val) <= limit) ? "meets" : "FAILS");
return ((fabs (val) <= limit) ? "meets" : "FAILS");
}
int
main(int argc, char **argv)
main (int argc, char **argv)
{
long minpix, maxpix, sign;
long curiter, niters;
int i, j;
double max, total;
int method;
DCTELEM block[DCTSIZE2]; /* random source data */
DCTELEM refcoefs[DCTSIZE2]; /* coefs from reference FDCT */
DCTELEM refout[DCTSIZE2]; /* output from reference IDCT */
DCTELEM testout[DCTSIZE2]; /* output from test IDCT */
GstIDCT *idct;
guint64 tscstart, tscmin = ~0, tscmax = 0;
guint64 tscstop;
DCTELEM block[DCTSIZE2]; /* random source data */
DCTELEM refcoefs[DCTSIZE2]; /* coefs from reference FDCT */
DCTELEM refout[DCTSIZE2]; /* output from reference IDCT */
DCTELEM testout[DCTSIZE2]; /* output from test IDCT */
GstIDCT *idct;
guint64 tscstart, tscmin = ~0, tscmax = 0;
guint64 tscstop;
/* Argument parsing --- not very bulletproof at all */
if (argc != 6) usage(NULL);
if (argc != 6)
usage (NULL);
method = atoi(argv[1]);
minpix = atoi(argv[2]);
maxpix = atoi(argv[3]);
sign = atoi(argv[4]);
niters = atol(argv[5]);
method = atoi (argv[1]);
minpix = atoi (argv[2]);
maxpix = atoi (argv[3]);
sign = atoi (argv[4]);
niters = atol (argv[5]);
gst_library_load("gstidct");
gst_library_load ("gstidct");
idct = gst_idct_new(method);
idct = gst_idct_new (method);
if (idct == 0) {
printf("method not available\n\n\n");
printf ("method not available\n\n\n");
return 0;
}
dct_init();
dct_init ();
/* Loop once per generated random-data block */
@ -86,164 +88,186 @@ main(int argc, char **argv)
/* generate a pseudo-random block of data */
for (i = 0; i < DCTSIZE2; i++)
block[i] = (DCTELEM) (ieeerand(-minpix,maxpix) * sign);
block[i] = (DCTELEM) (ieeerand (-minpix, maxpix) * sign);
/* perform reference FDCT */
memcpy(refcoefs, block, sizeof(DCTELEM)*DCTSIZE2);
ref_fdct((DCTELEM **) &refcoefs);
memcpy (refcoefs, block, sizeof (DCTELEM) * DCTSIZE2);
ref_fdct ((DCTELEM **) & refcoefs);
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (refcoefs[i] < -2048) refcoefs[i] = -2048;
else if (refcoefs[i] > 2047) refcoefs[i] = 2047;
if (refcoefs[i] < -2048)
refcoefs[i] = -2048;
else if (refcoefs[i] > 2047)
refcoefs[i] = 2047;
}
/* perform reference IDCT */
memcpy(refout, refcoefs, sizeof(DCTELEM)*DCTSIZE2);
ref_idct(refout);
memcpy (refout, refcoefs, sizeof (DCTELEM) * DCTSIZE2);
ref_idct (refout);
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (refout[i] < -256) refout[i] = -256;
else if (refout[i] > 255) refout[i] = 255;
if (refout[i] < -256)
refout[i] = -256;
else if (refout[i] > 255)
refout[i] = 255;
}
/* perform test IDCT */
if (GST_IDCT_TRANSPOSE(idct)) {
if (GST_IDCT_TRANSPOSE (idct)) {
for (j = 0; j < DCTSIZE; j++) {
for (i = 0; i < DCTSIZE; i++) {
testout[i*DCTSIZE+j] = refcoefs[j*DCTSIZE+i];
}
}
}
else {
memcpy(testout, refcoefs, sizeof(DCTELEM)*DCTSIZE2);
}
for (i = 0; i < DCTSIZE; i++) {
testout[i * DCTSIZE + j] = refcoefs[j * DCTSIZE + i];
}
}
} else {
memcpy (testout, refcoefs, sizeof (DCTELEM) * DCTSIZE2);
}
gst_trace_read_tsc(&tscstart);
gst_idct_convert(idct, testout);
gst_trace_read_tsc(&tscstop);
/*printf("time %llu, %llu %lld\n", tscstart, tscstop, tscstop-tscstart); */
if (tscstop - tscstart < tscmin) tscmin = tscstop-tscstart;
if (tscstop - tscstart > tscmax) tscmax = tscstop-tscstart;
gst_trace_read_tsc (&tscstart);
gst_idct_convert (idct, testout);
gst_trace_read_tsc (&tscstop);
/*printf("time %llu, %llu %lld\n", tscstart, tscstop, tscstop-tscstart); */
if (tscstop - tscstart < tscmin)
tscmin = tscstop - tscstart;
if (tscstop - tscstart > tscmax)
tscmax = tscstop - tscstart;
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (testout[i] < -256) testout[i] = -256;
else if (testout[i] > 255) testout[i] = 255;
if (testout[i] < -256)
testout[i] = -256;
else if (testout[i] > 255)
testout[i] = 255;
}
/* accumulate error stats */
for (i = 0; i < DCTSIZE2; i++) {
register int err = testout[i] - refout[i];
sumerrs[i] += err;
sumsqerrs[i] += err * err;
if (err < 0) err = -err;
if (maxerr[i] < err) maxerr[i] = err;
if (err < 0)
err = -err;
if (maxerr[i] < err)
maxerr[i] = err;
}
if (curiter % 100 == 99) {
fprintf(stderr, ".");
fflush(stderr);
fprintf (stderr, ".");
fflush (stderr);
}
}
fprintf(stderr, "\n");
fprintf (stderr, "\n");
/* print results */
printf("IEEE test conditions: -L = %ld, +H = %ld, sign = %ld, #iters = %ld\n",
minpix, maxpix, sign, niters);
printf
("IEEE test conditions: -L = %ld, +H = %ld, sign = %ld, #iters = %ld\n",
minpix, maxpix, sign, niters);
printf("Speed, min time %lld, max %lld\n", tscmin, tscmax);
printf ("Speed, min time %lld, max %lld\n", tscmin, tscmax);
printf("Peak absolute values of errors:\n");
printf ("Peak absolute values of errors:\n");
for (i = 0, j = 0; i < DCTSIZE2; i++) {
if (j < maxerr[i]) j = maxerr[i];
printf("%4d", maxerr[i]);
if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
if (j < maxerr[i])
j = maxerr[i];
printf ("%4d", maxerr[i]);
if ((i % DCTSIZE) == DCTSIZE - 1)
printf ("\n");
}
printf("Worst peak error = %d (%s spec limit 1)\n\n", j,
meets((double) j, 1.0));
printf ("Worst peak error = %d (%s spec limit 1)\n\n", j,
meets ((double) j, 1.0));
printf("Mean square errors:\n");
printf ("Mean square errors:\n");
max = total = 0.0;
for (i = 0; i < DCTSIZE2; i++) {
double err = (double) sumsqerrs[i] / ((double) niters);
double err = (double) sumsqerrs[i] / ((double) niters);
total += (double) sumsqerrs[i];
if (max < err) max = err;
printf(" %8.4f", err);
if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
if (max < err)
max = err;
printf (" %8.4f", err);
if ((i % DCTSIZE) == DCTSIZE - 1)
printf ("\n");
}
printf("Worst pmse = %.6f (%s spec limit 0.06)\n", max, meets(max, 0.06));
total /= (double) (64*niters);
printf("Overall mse = %.6f (%s spec limit 0.02)\n\n", total,
meets(total, 0.02));
printf ("Worst pmse = %.6f (%s spec limit 0.06)\n", max, meets (max, 0.06));
total /= (double) (64 * niters);
printf ("Overall mse = %.6f (%s spec limit 0.02)\n\n", total,
meets (total, 0.02));
printf("Mean errors:\n");
printf ("Mean errors:\n");
max = total = 0.0;
for (i = 0; i < DCTSIZE2; i++) {
double err = (double) sumerrs[i] / ((double) niters);
double err = (double) sumerrs[i] / ((double) niters);
total += (double) sumerrs[i];
printf(" %8.4f", err);
if (err < 0.0) err = -err;
if (max < err) max = err;
if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
printf (" %8.4f", err);
if (err < 0.0)
err = -err;
if (max < err)
max = err;
if ((i % DCTSIZE) == DCTSIZE - 1)
printf ("\n");
}
printf("Worst mean error = %.6f (%s spec limit 0.015)\n", max,
meets(max, 0.015));
total /= (double) (64*niters);
printf("Overall mean error = %.6f (%s spec limit 0.0015)\n\n", total,
meets(total, 0.0015));
printf ("Worst mean error = %.6f (%s spec limit 0.015)\n", max,
meets (max, 0.015));
total /= (double) (64 * niters);
printf ("Overall mean error = %.6f (%s spec limit 0.0015)\n\n", total,
meets (total, 0.0015));
/* test for 0 input giving 0 output */
memset(testout, 0, sizeof(DCTELEM)*DCTSIZE2);
gst_idct_convert(idct, testout);
for (i = 0, j=0; i < DCTSIZE2; i++) {
memset (testout, 0, sizeof (DCTELEM) * DCTSIZE2);
gst_idct_convert (idct, testout);
for (i = 0, j = 0; i < DCTSIZE2; i++) {
if (testout[i]) {
printf("Position %d of IDCT(0) = %d (FAILS)\n", i, testout[i]);
printf ("Position %d of IDCT(0) = %d (FAILS)\n", i, testout[i]);
j++;
}
}
printf("%d elements of IDCT(0) were not zero\n\n\n", j);
printf ("%d elements of IDCT(0) were not zero\n\n\n", j);
exit(0);
exit (0);
return 0;
}
void usage (char *msg)
void
usage (char *msg)
{
if (msg != NULL)
fprintf(stderr, "\nerror: %s\n", msg);
fprintf (stderr, "\nerror: %s\n", msg);
fprintf(stderr, "\n");
fprintf(stderr, "usage: ieeetest minpix maxpix sign niters\n");
fprintf(stderr, "\n");
fprintf(stderr, " test = 1 - 5\n");
fprintf(stderr, " minpix = -L value per IEEE spec\n");
fprintf(stderr, " maxpix = H value per IEEE spec\n");
fprintf(stderr, " sign = +1 for normal, -1 to run negated test\n");
fprintf(stderr, " niters = # iterations (10000 for full test)\n");
fprintf(stderr, "\n");
fprintf (stderr, "\n");
fprintf (stderr, "usage: ieeetest minpix maxpix sign niters\n");
fprintf (stderr, "\n");
fprintf (stderr, " test = 1 - 5\n");
fprintf (stderr, " minpix = -L value per IEEE spec\n");
fprintf (stderr, " maxpix = H value per IEEE spec\n");
fprintf (stderr, " sign = +1 for normal, -1 to run negated test\n");
fprintf (stderr, " niters = # iterations (10000 for full test)\n");
fprintf (stderr, "\n");
exit(1);
exit (1);
}
/* Pseudo-random generator specified by IEEE 1180 */
long ieeerand (long L, long H)
long
ieeerand (long L, long H)
{
static long randx = 1;
static double z = (double) 0x7fffffff;
long i,j;
long i, j;
double x;
randx = (randx * 1103515245) + 12345;
i = randx & 0x7ffffffe;
x = ((double) i) / z;
x *= (L+H+1);
x *= (L + H + 1);
j = x;
return j-L;
return j - L;
}
@ -256,33 +280,35 @@ double coslu[8][8];
/* Routine to initialise the cosine lookup table */
void dct_init(void)
void
dct_init (void)
{
int a,b;
int a, b;
double tmp;
for(a=0;a<8;a++)
for(b=0;b<8;b++) {
tmp = cos((double)((a+a+1)*b) * (3.14159265358979323846 / 16.0));
if(b==0)
tmp /= sqrt(2.0);
for (a = 0; a < 8; a++)
for (b = 0; b < 8; b++) {
tmp = cos ((double) ((a + a + 1) * b) * (3.14159265358979323846 / 16.0));
if (b == 0)
tmp /= sqrt (2.0);
coslu[a][b] = tmp * 0.5;
}
}
void ref_fdct (DCTELEM block[8][8])
void
ref_fdct (DCTELEM block[8][8])
{
int x,y,u,v;
int x, y, u, v;
double tmp, tmp2;
double res[8][8];
for (v=0; v<8; v++) {
for (u=0; u<8; u++) {
for (v = 0; v < 8; v++) {
for (u = 0; u < 8; u++) {
tmp = 0.0;
for (y=0; y<8; y++) {
for (y = 0; y < 8; y++) {
tmp2 = 0.0;
for (x=0; x<8; x++) {
for (x = 0; x < 8; x++) {
tmp2 += (double) block[y][x] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
@ -291,11 +317,11 @@ void ref_fdct (DCTELEM block[8][8])
}
}
for (v=0; v<8; v++) {
for (u=0; u<8; u++) {
for (v = 0; v < 8; v++) {
for (u = 0; u < 8; u++) {
tmp = res[v][u];
if (tmp < 0.0) {
x = - ((int) (0.5 - tmp));
x = -((int) (0.5 - tmp));
} else {
x = (int) (tmp + 0.5);
}
@ -305,18 +331,19 @@ void ref_fdct (DCTELEM block[8][8])
}
void ref_idct (DCTELEM block[8][8])
void
ref_idct (DCTELEM block[8][8])
{
int x,y,u,v;
int x, y, u, v;
double tmp, tmp2;
double res[8][8];
for (y=0; y<8; y++) {
for (x=0; x<8; x++) {
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
tmp = 0.0;
for (v=0; v<8; v++) {
for (v = 0; v < 8; v++) {
tmp2 = 0.0;
for (u=0; u<8; u++) {
for (u = 0; u < 8; u++) {
tmp2 += (double) block[v][u] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
@ -325,11 +352,11 @@ void ref_idct (DCTELEM block[8][8])
}
}
for (v=0; v<8; v++) {
for (u=0; u<8; u++) {
for (v = 0; v < 8; v++) {
for (u = 0; u < 8; u++) {
tmp = res[v][u];
if (tmp < 0.0) {
x = - ((int) (0.5 - tmp));
x = -((int) (0.5 - tmp));
} else {
x = (int) (tmp + 0.5);
}

View file

@ -51,10 +51,8 @@
*/
#if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
Sorry, this code only copes with 8 x8 DCTs. /* deliberate syntax err */
#endif
/*
* A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT
* on each column. Direct algorithms are also available, but they are
@ -90,7 +88,6 @@
* have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
* shows that the values given below are the most effective.
*/
#ifdef EIGHT_BIT_SAMPLES
#define CONST_BITS 13
#define PASS1_BITS 2
@ -98,22 +95,16 @@
#define CONST_BITS 13
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
#define ONE ((INT32) 1)
#define CONST_SCALE (ONE << CONST_BITS)
/* Convert a positive real constant to an integer scaled by CONST_SCALE. */
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
* causing a lot of useless floating-point operations at run time.
* To get around this we use the following pre-calculated constants.
* If you change CONST_BITS you may want to add appropriate values.
* (With a reasonable C compiler, you can just rely on the FIX() macro...)
*/
#if CONST_BITS == 13
#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */
#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */
@ -141,15 +132,11 @@
#define FIX_2_562915447 FIX(2.562915447)
#define FIX_3_072711026 FIX(3.072711026)
#endif
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
@ -160,7 +147,6 @@
* combination of casts.
* NB: for 12-bit samples, a full 32-bit multiplication will be needed.
*/
#ifdef EIGHT_BIT_SAMPLES
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT16) (const)))
@ -169,17 +155,13 @@
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT32) (const)))
#endif
#endif
#ifndef MULTIPLY /* default definition */
#define MULTIPLY(var,const) ((var) * (const))
#endif
/*
* Perform the inverse DCT on one block of coefficients.
*/
void
void
gst_idct_int_idct (DCTBLOCK data)
{
INT32 tmp0, tmp1, tmp2, tmp3;
@ -187,14 +169,13 @@ gst_idct_int_idct (DCTBLOCK data)
INT32 z1, z2, z3, z4, z5;
register DCTELEM *dataptr;
int rowctr;
SHIFT_TEMPS
/* Pass 1: process rows. */
/* Note results are scaled up by sqrt(8) compared to a true IDCT; */
/* furthermore, we scale the results by 2**PASS1_BITS. */
dataptr = data;
for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
/* Pass 1: process rows. */
/* Note results are scaled up by sqrt(8) compared to a true IDCT; */
/* furthermore, we scale the results by 2**PASS1_BITS. */
dataptr = data;
for (rowctr = DCTSIZE - 1; rowctr >= 0; rowctr--) {
/* Due to quantization, we will usually find that many of the input
* coefficients are zero, especially the AC terms. We can exploit this
* by short-circuiting the IDCT calculation for any row in which all
@ -205,10 +186,10 @@ gst_idct_int_idct (DCTBLOCK data)
*/
if ((dataptr[1] | dataptr[2] | dataptr[3] | dataptr[4] |
dataptr[5] | dataptr[6] | dataptr[7]) == 0) {
dataptr[5] | dataptr[6] | dataptr[7]) == 0) {
/* AC terms all zero */
DCTELEM dcval = (DCTELEM) (dataptr[0] << PASS1_BITS);
dataptr[0] = dcval;
dataptr[1] = dcval;
dataptr[2] = dcval;
@ -217,7 +198,7 @@ gst_idct_int_idct (DCTBLOCK data)
dataptr[5] = dcval;
dataptr[6] = dcval;
dataptr[7] = dcval;
dataptr += DCTSIZE; /* advance pointer to next row */
continue;
}
@ -228,9 +209,9 @@ gst_idct_int_idct (DCTBLOCK data)
z2 = (INT32) dataptr[2];
z3 = (INT32) dataptr[6];
z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);
tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
z1 = MULTIPLY (z2 + z3, FIX_0_541196100);
tmp2 = z1 + MULTIPLY (z3, -FIX_1_847759065);
tmp3 = z1 + MULTIPLY (z2, FIX_0_765366865);
tmp0 = ((INT32) dataptr[0] + (INT32) dataptr[4]) << CONST_BITS;
tmp1 = ((INT32) dataptr[0] - (INT32) dataptr[4]) << CONST_BITS;
@ -239,7 +220,7 @@ gst_idct_int_idct (DCTBLOCK data)
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
/* Odd part per figure 8; the matrix is unitary and hence its
* transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
*/
@ -253,20 +234,20 @@ gst_idct_int_idct (DCTBLOCK data)
z2 = tmp1 + tmp2;
z3 = tmp0 + tmp2;
z4 = tmp1 + tmp3;
z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
z5 = MULTIPLY (z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
tmp0 = MULTIPLY (tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
tmp1 = MULTIPLY (tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
tmp2 = MULTIPLY (tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
tmp3 = MULTIPLY (tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = MULTIPLY (z1, -FIX_0_899976223); /* sqrt(2) * (c7-c3) */
z2 = MULTIPLY (z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
z3 = MULTIPLY (z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
z4 = MULTIPLY (z4, -FIX_0_390180644); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
tmp0 += z1 + z3;
tmp1 += z2 + z4;
tmp2 += z2 + z3;
@ -274,14 +255,14 @@ gst_idct_int_idct (DCTBLOCK data)
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
dataptr[0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
dataptr[7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
dataptr[6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
dataptr[2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
dataptr[5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
dataptr[0] = (DCTELEM) DESCALE (tmp10 + tmp3, CONST_BITS - PASS1_BITS);
dataptr[7] = (DCTELEM) DESCALE (tmp10 - tmp3, CONST_BITS - PASS1_BITS);
dataptr[1] = (DCTELEM) DESCALE (tmp11 + tmp2, CONST_BITS - PASS1_BITS);
dataptr[6] = (DCTELEM) DESCALE (tmp11 - tmp2, CONST_BITS - PASS1_BITS);
dataptr[2] = (DCTELEM) DESCALE (tmp12 + tmp1, CONST_BITS - PASS1_BITS);
dataptr[5] = (DCTELEM) DESCALE (tmp12 - tmp1, CONST_BITS - PASS1_BITS);
dataptr[3] = (DCTELEM) DESCALE (tmp13 + tmp0, CONST_BITS - PASS1_BITS);
dataptr[4] = (DCTELEM) DESCALE (tmp13 - tmp0, CONST_BITS - PASS1_BITS);
dataptr += DCTSIZE; /* advance pointer to next row */
}
@ -291,7 +272,7 @@ gst_idct_int_idct (DCTBLOCK data)
/* and also undo the PASS1_BITS scaling. */
dataptr = data;
for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
for (rowctr = DCTSIZE - 1; rowctr >= 0; rowctr--) {
/* Columns of zeroes can be exploited in the same way as we did with rows.
* However, the row calculation has created many nonzero AC terms, so the
* simplification applies less often (typically 5% to 10% of the time).
@ -301,21 +282,21 @@ gst_idct_int_idct (DCTBLOCK data)
*/
#ifndef NO_ZERO_COLUMN_TEST
if ((dataptr[DCTSIZE*1] | dataptr[DCTSIZE*2] | dataptr[DCTSIZE*3] |
dataptr[DCTSIZE*4] | dataptr[DCTSIZE*5] | dataptr[DCTSIZE*6] |
dataptr[DCTSIZE*7]) == 0) {
if ((dataptr[DCTSIZE * 1] | dataptr[DCTSIZE * 2] | dataptr[DCTSIZE * 3] |
dataptr[DCTSIZE * 4] | dataptr[DCTSIZE * 5] | dataptr[DCTSIZE * 6] |
dataptr[DCTSIZE * 7]) == 0) {
/* AC terms all zero */
DCTELEM dcval = (DCTELEM) DESCALE((INT32) dataptr[0], PASS1_BITS+3);
dataptr[DCTSIZE*0] = dcval;
dataptr[DCTSIZE*1] = dcval;
dataptr[DCTSIZE*2] = dcval;
dataptr[DCTSIZE*3] = dcval;
dataptr[DCTSIZE*4] = dcval;
dataptr[DCTSIZE*5] = dcval;
dataptr[DCTSIZE*6] = dcval;
dataptr[DCTSIZE*7] = dcval;
DCTELEM dcval = (DCTELEM) DESCALE ((INT32) dataptr[0], PASS1_BITS + 3);
dataptr[DCTSIZE * 0] = dcval;
dataptr[DCTSIZE * 1] = dcval;
dataptr[DCTSIZE * 2] = dcval;
dataptr[DCTSIZE * 3] = dcval;
dataptr[DCTSIZE * 4] = dcval;
dataptr[DCTSIZE * 5] = dcval;
dataptr[DCTSIZE * 6] = dcval;
dataptr[DCTSIZE * 7] = dcval;
dataptr++; /* advance pointer to next column */
continue;
}
@ -324,48 +305,52 @@ gst_idct_int_idct (DCTBLOCK data)
/* Even part: reverse the even part of the forward DCT. */
/* The rotator is sqrt(2)*c(-6). */
z2 = (INT32) dataptr[DCTSIZE*2];
z3 = (INT32) dataptr[DCTSIZE*6];
z2 = (INT32) dataptr[DCTSIZE * 2];
z3 = (INT32) dataptr[DCTSIZE * 6];
z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);
tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
z1 = MULTIPLY (z2 + z3, FIX_0_541196100);
tmp2 = z1 + MULTIPLY (z3, -FIX_1_847759065);
tmp3 = z1 + MULTIPLY (z2, FIX_0_765366865);
tmp0 = ((INT32) dataptr[DCTSIZE*0] + (INT32) dataptr[DCTSIZE*4]) << CONST_BITS;
tmp1 = ((INT32) dataptr[DCTSIZE*0] - (INT32) dataptr[DCTSIZE*4]) << CONST_BITS;
tmp0 =
((INT32) dataptr[DCTSIZE * 0] +
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
tmp1 =
((INT32) dataptr[DCTSIZE * 0] -
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
/* Odd part per figure 8; the matrix is unitary and hence its
* transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
*/
tmp0 = (INT32) dataptr[DCTSIZE*7];
tmp1 = (INT32) dataptr[DCTSIZE*5];
tmp2 = (INT32) dataptr[DCTSIZE*3];
tmp3 = (INT32) dataptr[DCTSIZE*1];
tmp0 = (INT32) dataptr[DCTSIZE * 7];
tmp1 = (INT32) dataptr[DCTSIZE * 5];
tmp2 = (INT32) dataptr[DCTSIZE * 3];
tmp3 = (INT32) dataptr[DCTSIZE * 1];
z1 = tmp0 + tmp3;
z2 = tmp1 + tmp2;
z3 = tmp0 + tmp2;
z4 = tmp1 + tmp3;
z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
z5 = MULTIPLY (z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
tmp0 = MULTIPLY (tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
tmp1 = MULTIPLY (tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
tmp2 = MULTIPLY (tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
tmp3 = MULTIPLY (tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
z1 = MULTIPLY (z1, -FIX_0_899976223); /* sqrt(2) * (c7-c3) */
z2 = MULTIPLY (z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
z3 = MULTIPLY (z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
z4 = MULTIPLY (z4, -FIX_0_390180644); /* sqrt(2) * (c5-c3) */
z3 += z5;
z4 += z5;
tmp0 += z1 + z3;
tmp1 += z2 + z4;
tmp2 += z2 + z3;
@ -373,23 +358,23 @@ gst_idct_int_idct (DCTBLOCK data)
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0,
CONST_BITS+PASS1_BITS+3);
dataptr[DCTSIZE * 0] = (DCTELEM) DESCALE (tmp10 + tmp3,
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 7] = (DCTELEM) DESCALE (tmp10 - tmp3,
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 1] = (DCTELEM) DESCALE (tmp11 + tmp2,
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 6] = (DCTELEM) DESCALE (tmp11 - tmp2,
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 2] = (DCTELEM) DESCALE (tmp12 + tmp1,
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 5] = (DCTELEM) DESCALE (tmp12 - tmp1,
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 3] = (DCTELEM) DESCALE (tmp13 + tmp0,
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 4] = (DCTELEM) DESCALE (tmp13 - tmp0,
CONST_BITS + PASS1_BITS + 3);
dataptr++; /* advance pointer to next column */
}
}

File diff suppressed because it is too large Load diff

View file

@ -49,9 +49,10 @@ gmi_stream_new (void)
}
void
gmi_stream_free (GstMediaInfoStream *stream)
gmi_stream_free (GstMediaInfoStream * stream)
{
if (stream->mime) g_free (stream->mime);
if (stream->mime)
g_free (stream->mime);
/* FIXME: free tracks */
g_free (stream);
}
@ -78,7 +79,8 @@ gmi_track_new (void)
/* callbacks */
static void
have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstMediaInfoPriv *priv)
have_type_callback (GstElement * typefind, guint probability, GstCaps * type,
GstMediaInfoPriv * priv)
{
GstStructure *str;
const gchar *mime;
@ -90,8 +92,7 @@ have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstM
/* FIXME: this code doesn't yet work, test it later */
#ifdef DONTWORK
if (strcmp (mime, "application/x-id3") == 0)
{
if (strcmp (mime, "application/x-id3") == 0) {
/* dig a little deeper */
GST_DEBUG ("dealing with id3, digging deeper");
gst_element_set_state (priv->pipeline, GST_STATE_READY);
@ -102,70 +103,72 @@ have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstM
if (priv->decontainer == NULL)
/* FIXME: signal error */
g_warning ("Couldn't create id3tag");
if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind, NULL));
g_warning ("Couldn't link in id3tag");
if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind,
NULL));
g_warning ("Couldn't link in id3tag");
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
== GST_STATE_FAILURE)
g_warning ("Couldn't set to playing");
}
#endif
}
void
deep_notify_callback (GObject *object, GstObject *origin,
GParamSpec *pspec, GstMediaInfoPriv *priv)
deep_notify_callback (GObject * object, GstObject * origin,
GParamSpec * pspec, GstMediaInfoPriv * priv)
{
GValue value = { 0, };
/* we only care about pad notifies */
if (!GST_IS_PAD (origin)) return;
if (!GST_IS_PAD (origin))
return;
/*
GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
gst_object_get_name (origin));
*/
else if (strcmp (pspec->name, "caps") == 0)
{
GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
gst_object_get_name (origin));
*/
else if (strcmp (pspec->name, "caps") == 0) {
/* check if we're getting it from fakesink */
if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink)
{
if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink) {
GST_DEBUG ("have caps on fakesink pad !");
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
priv->format = g_value_peek_pointer (&value);
GST_DEBUG ("caps: %" GST_PTR_FORMAT, priv->format);
}
else GST_DEBUG ("ignoring caps on object %s:%s",
gst_object_get_name (gst_object_get_parent (origin)),
gst_object_get_name (origin));
}
else if (strcmp (pspec->name, "offset") == 0)
{
} else
GST_DEBUG ("ignoring caps on object %s:%s",
gst_object_get_name (gst_object_get_parent (origin)),
gst_object_get_name (origin));
} else if (strcmp (pspec->name, "offset") == 0) {
/* we REALLY ignore offsets, we hate them */
}
//else GST_DEBUG ("ignoring notify of %s", pspec->name);
//else GST_DEBUG ("ignoring notify of %s", pspec->name);
}
typedef struct {
typedef struct
{
guint meta;
guint encoded;
} TagFlagScore;
static void
tag_flag_score (const GstTagList *list, const gchar *tag, gpointer user_data)
tag_flag_score (const GstTagList * list, const gchar * tag, gpointer user_data)
{
TagFlagScore *score = (TagFlagScore *) user_data;
GstTagFlag flag;
flag = gst_tag_get_flag (tag);
if (flag == GST_TAG_FLAG_META) score->meta++;
if (flag == GST_TAG_FLAG_ENCODED) score->encoded++;
if (flag == GST_TAG_FLAG_META)
score->meta++;
if (flag == GST_TAG_FLAG_ENCODED)
score->encoded++;
}
void
found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv)
found_tag_callback (GObject * pipeline, GstElement * source, GstTagList * tags,
GstMediaInfoPriv * priv)
{
TagFlagScore score;
@ -179,20 +182,18 @@ found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, Gst
gst_tag_list_foreach (tags, tag_flag_score, &score);
if (score.meta > score.encoded)
{
if (score.meta > score.encoded) {
GST_DEBUG ("found tags from decoder, adding them as metadata");
priv->metadata = gst_tag_list_copy (tags);
}
else
{
} else {
GST_DEBUG ("found tags, adding them as streaminfo");
priv->streaminfo = gst_tag_list_copy (tags);
}
}
void
error_callback (GObject *element, GstElement *source, GError *error, gchar *debug, GstMediaInfoPriv *priv)
error_callback (GObject * element, GstElement * source, GError * error,
gchar * debug, GstMediaInfoPriv * priv)
{
g_print ("ERROR: %s\n", error->message);
g_error_free (error);
@ -202,7 +203,7 @@ error_callback (GObject *element, GstElement *source, GError *error, gchar *debu
/* General GError creation */
static void
gst_media_info_error_create (GError **error, const gchar *message)
gst_media_info_error_create (GError ** error, const gchar * message)
{
/* check if caller wanted an error reported */
if (error == NULL)
@ -214,15 +215,14 @@ gst_media_info_error_create (GError **error, const gchar *message)
/* GError creation when element is missing */
static void
gst_media_info_error_element (const gchar *element, GError **error)
gst_media_info_error_element (const gchar * element, GError ** error)
{
gchar *message;
message = g_strdup_printf ("The %s element could not be found. "
"This element is essential for reading. "
"Please install the right plug-in and verify "
"that it works by running 'gst-inspect %s'",
element, element);
"This element is essential for reading. "
"Please install the right plug-in and verify "
"that it works by running 'gst-inspect %s'", element, element);
gst_media_info_error_create (error, message);
g_free (message);
return;
@ -230,7 +230,7 @@ gst_media_info_error_element (const gchar *element, GError **error)
/* initialise priv; done the first time */
gboolean
gmip_init (GstMediaInfoPriv *priv, GError **error)
gmip_init (GstMediaInfoPriv * priv, GError ** error)
{
#define GST_MEDIA_INFO_MAKE_OR_ERROR(el, factory, name, error) \
G_STMT_START { \
@ -257,7 +257,7 @@ G_STMT_START { \
/* called at the beginning of each use cycle */
/* reset info to a state where it can be used to query for media info */
void
gmip_reset (GstMediaInfoPriv *priv)
gmip_reset (GstMediaInfoPriv * priv)
{
#define STRING_RESET(string) \
@ -266,8 +266,8 @@ G_STMT_START { \
string = NULL; \
} G_STMT_END
STRING_RESET(priv->pipeline_desc);
STRING_RESET(priv->location);
STRING_RESET (priv->pipeline_desc);
STRING_RESET (priv->location);
#undef STRING_RESET
#define CAPS_RESET(target) \
@ -275,8 +275,8 @@ G_STMT_START { \
if (target) gst_caps_free (target); \
target = NULL; \
} G_STMT_END
CAPS_RESET(priv->type);
CAPS_RESET(priv->format);
CAPS_RESET (priv->type);
CAPS_RESET (priv->format);
#undef CAPS_RESET
#define TAGS_RESET(target) \
@ -285,12 +285,11 @@ G_STMT_START { \
gst_tag_list_free (target); \
target = NULL; \
} G_STMT_END
TAGS_RESET(priv->metadata);
TAGS_RESET(priv->streaminfo);
TAGS_RESET (priv->metadata);
TAGS_RESET (priv->streaminfo);
#undef TAGS_RESET
if (priv->stream)
{
if (priv->stream) {
gmi_stream_free (priv->stream);
priv->stream = NULL;
}
@ -302,7 +301,7 @@ G_STMT_START { \
/* seek to a track and reset metadata and streaminfo structs */
gboolean
gmi_seek_to_track (GstMediaInfo *info, long track)
gmi_seek_to_track (GstMediaInfo * info, long track)
{
GstEvent *event;
GstFormat track_format = 0;
@ -311,32 +310,28 @@ gmi_seek_to_track (GstMediaInfo *info, long track)
/* FIXME: consider more nicks as "track" */
track_format = gst_format_get_by_nick ("logical_stream");
if (track_format == 0) return FALSE;
if (track_format == 0)
return FALSE;
GST_DEBUG ("Track format: %d", track_format);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
== GST_STATE_FAILURE)
g_warning ("Couldn't set to play");
g_assert (GST_IS_PAD (info->priv->decoder_pad));
event = gst_event_new_seek (track_format |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
track);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, track);
res = gst_pad_send_event (info->priv->decoder_pad, event);
if (!res)
{
if (!res) {
g_warning ("seek to logical track on pad %s:%s failed",
GST_DEBUG_PAD_NAME(info->priv->decoder_pad));
GST_DEBUG_PAD_NAME (info->priv->decoder_pad));
return FALSE;
}
/* clear structs because of the seek */
if (priv->metadata)
{
if (priv->metadata) {
gst_tag_list_free (priv->metadata);
priv->metadata = NULL;
}
if (priv->streaminfo)
{
if (priv->streaminfo) {
gst_tag_list_free (priv->streaminfo);
priv->streaminfo = NULL;
}
@ -345,7 +340,7 @@ gmi_seek_to_track (GstMediaInfo *info, long track)
/* set the mime type on the media info getter */
gboolean
gmi_set_mime (GstMediaInfo *info, const char *mime)
gmi_set_mime (GstMediaInfo * info, const char *mime)
{
gchar *desc = NULL;
GError *error = NULL;
@ -354,31 +349,45 @@ gmi_set_mime (GstMediaInfo *info, const char *mime)
/* FIXME: please figure out proper mp3 mimetypes */
if ((strcmp (mime, "application/x-ogg") == 0) ||
(strcmp (mime, "application/ogg") == 0))
desc = g_strdup_printf ("%s name=source ! oggdemux ! vorbisdec name=decoder ! fakesink name=sink", priv->source_name);
else if ((strcmp (mime, "audio/mpeg") == 0) ||
(strcmp (mime, "audio/x-mp3") == 0) ||
(strcmp (mime, "audio/mp3") == 0) ||
(strcmp (mime, "application/x-id3") == 0) ||
(strcmp (mime, "audio/x-id3") == 0))
desc = g_strdup_printf ("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else if ((strcmp (mime, "application/x-flac") == 0) ||
(strcmp (mime, "audio/x-flac") == 0))
desc = g_strdup_printf ("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else if ((strcmp (mime, "audio/wav") == 0) ||
(strcmp (mime, "audio/x-wav") == 0))
desc = g_strdup_printf ("%s ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else if (strcmp (mime, "audio/x-mod") == 0 ||
strcmp (mime, "audio/x-s3m") == 0 ||
strcmp (mime, "audio/x-xm") == 0 ||
strcmp (mime, "audio/x-it") == 0)
desc = g_strdup_printf ("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
else return FALSE;
desc =
g_strdup_printf
("%s name=source ! oggdemux ! vorbisdec name=decoder ! fakesink name=sink",
priv->source_name);
else if ((strcmp (mime, "audio/mpeg") == 0)
|| (strcmp (mime, "audio/x-mp3") == 0)
|| (strcmp (mime, "audio/mp3") == 0)
|| (strcmp (mime, "application/x-id3") == 0)
|| (strcmp (mime, "audio/x-id3") == 0))
desc =
g_strdup_printf
("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else if ((strcmp (mime, "application/x-flac") == 0)
|| (strcmp (mime, "audio/x-flac") == 0))
desc =
g_strdup_printf
("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else if ((strcmp (mime, "audio/wav") == 0)
|| (strcmp (mime, "audio/x-wav") == 0))
desc =
g_strdup_printf
("%s ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else if (strcmp (mime, "audio/x-mod") == 0
|| strcmp (mime, "audio/x-s3m") == 0 || strcmp (mime, "audio/x-xm") == 0
|| strcmp (mime, "audio/x-it") == 0)
desc =
g_strdup_printf
("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else
return FALSE;
GST_DEBUG ("using description %s", desc);
priv->pipeline_desc = desc;
priv->pipeline = gst_parse_launch (desc, &error);
if (error)
{
if (error) {
g_warning ("Error parsing pipeline description: %s\n", error->message);
g_error_free (error);
return FALSE;
@ -398,25 +407,27 @@ gmi_set_mime (GstMediaInfo *info, const char *mime)
/* get the "decoder" source pad */
priv->decoder_pad = gst_element_get_pad (priv->decoder, "src");
g_assert (GST_IS_PAD (priv->decoder_pad));
GST_DEBUG ("decoder pad: %s:%s", gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->decoder_pad))), gst_pad_get_name (priv->decoder_pad));
GST_DEBUG ("decoder pad: %s:%s",
gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->
decoder_pad))), gst_pad_get_name (priv->decoder_pad));
/* attach notify handler */
g_signal_connect (G_OBJECT (info->priv->pipeline), "deep_notify",
G_CALLBACK (deep_notify_callback), info->priv);
g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag", G_CALLBACK (found_tag_callback), info->priv);
G_CALLBACK (deep_notify_callback), info->priv);
g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag",
G_CALLBACK (found_tag_callback), info->priv);
g_signal_connect (G_OBJECT (info->priv->pipeline), "error",
G_CALLBACK (error_callback), info->priv);
G_CALLBACK (error_callback), info->priv);
return TRUE;
}
/* clear the decoding pipeline */
void
gmi_clear_decoder (GstMediaInfo *info)
gmi_clear_decoder (GstMediaInfo * info)
{
if (info->priv->pipeline)
{
GST_DEBUG("Unreffing pipeline");
if (info->priv->pipeline) {
GST_DEBUG ("Unreffing pipeline");
gst_object_unref (GST_OBJECT (info->priv->pipeline));
}
info->priv->pipeline = NULL;
@ -430,7 +441,7 @@ gmi_clear_decoder (GstMediaInfo *info)
/* prepare for typefind, move from NULL to TYPEFIND */
gboolean
gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error)
gmip_find_type_pre (GstMediaInfoPriv * priv, GError ** error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@ -440,23 +451,21 @@ gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error)
* just use it through this function only */
priv->pipeline = gst_pipeline_new ("pipeline-typefind");
if (!GST_IS_PIPELINE (priv->pipeline))
{
if (!GST_IS_PIPELINE (priv->pipeline)) {
gst_media_info_error_create (error, "Internal GStreamer error.");
return FALSE;
}
gst_bin_add (GST_BIN (priv->pipeline), priv->typefind);
GST_MEDIA_INFO_MAKE_OR_ERROR (priv->source, priv->source_name, "source",
error);
error);
g_object_set (G_OBJECT (priv->source), "location", priv->location, NULL);
gst_bin_add (GST_BIN (priv->pipeline), priv->source);
if (!gst_element_link (priv->source, priv->typefind))
g_warning ("Couldn't connect source and typefind\n");
g_signal_connect (G_OBJECT (priv->typefind), "have-type",
G_CALLBACK (have_type_callback), priv);
G_CALLBACK (have_type_callback), priv);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -467,24 +476,20 @@ gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error)
/* finish off typefind */
gboolean
gmip_find_type_post (GstMediaInfoPriv *priv)
gmip_find_type_post (GstMediaInfoPriv * priv)
{
/*clear up typefind */
gst_element_set_state (priv->pipeline, GST_STATE_READY);
if (priv->decontainer)
{
if (priv->decontainer) {
gst_element_unlink (priv->source, priv->decontainer);
gst_element_unlink (priv->decontainer, priv->typefind);
gst_bin_remove (GST_BIN (priv->pipeline), priv->decontainer);
}
else
{
} else {
gst_element_unlink (priv->source, priv->typefind);
}
gst_bin_remove (GST_BIN (priv->pipeline), priv->typefind);
if (priv->type == NULL)
{
if (priv->type == NULL) {
g_warning ("iteration ended, type not found !\n");
return FALSE;
}
@ -495,25 +500,23 @@ gmip_find_type_post (GstMediaInfoPriv *priv)
/* complete version */
gboolean
gmip_find_type (GstMediaInfoPriv *priv, GError ** error)
gmip_find_type (GstMediaInfoPriv * priv, GError ** error)
{
if (!gmip_find_type_pre (priv, error))
return FALSE;
GST_DEBUG ("gmip_find_type: iterating");
while ((priv->type == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG("+");
GMI_DEBUG("\n");
while ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
return gmip_find_type_post (priv);
}
/* FIXME: why not have these functions work on priv types ? */
gboolean
gmip_find_stream_pre (GstMediaInfoPriv *priv)
gmip_find_stream_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -522,7 +525,7 @@ gmip_find_stream_pre (GstMediaInfoPriv *priv)
}
gboolean
gmip_find_stream_post (GstMediaInfoPriv *priv)
gmip_find_stream_post (GstMediaInfoPriv * priv)
{
GstMediaInfoStream *stream = priv->stream;
const GstFormat *formats;
@ -541,8 +544,7 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
/* get supported formats on decoder pad */
formats = gst_pad_get_formats (priv->decoder_pad);
while (*formats)
{
while (*formats) {
const GstFormatDefinition *definition;
format = *formats;
@ -551,16 +553,13 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
definition = gst_format_get_details (*formats);
GST_DEBUG ("trying to figure out length for format %s", definition->nick);
res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL,
&format, &value);
res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL, &format, &value);
if (res)
{
switch (format)
{
case GST_FORMAT_TIME:
stream->length_time = value;
GST_DEBUG (" total %s: %lld", definition->nick, value);
if (res) {
switch (format) {
case GST_FORMAT_TIME:
stream->length_time = value;
GST_DEBUG (" total %s: %lld", definition->nick, value);
break;
case GST_FORMAT_DEFAULT:
case GST_FORMAT_BYTES:
@ -568,35 +567,33 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
default:
/* separation is necessary because track_format doesn't resolve to
* int */
if (format == track_format)
{
if (format == track_format) {
stream->length_tracks = value;
GST_DEBUG (" total %s: %lld", definition->nick, value);
}
else
GST_DEBUG (" total %s: %lld", definition->nick, value);
} else
GST_DEBUG ("unhandled format %s", definition->nick);
}
}
else
} else
GST_DEBUG ("query didn't return result for %s", definition->nick);
formats++;
}
if (stream->length_tracks == 0) stream->length_tracks = 1;
if (stream->length_tracks == 0)
stream->length_tracks = 1;
/* now get number of bytes from the sink pad to get the bitrate */
format = GST_FORMAT_BYTES;
g_assert (GST_IS_PAD (priv->source_pad));
res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL,
&format, &value);
if (!res) g_warning ("Failed to query on sink pad !");
res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL, &format, &value);
if (!res)
g_warning ("Failed to query on sink pad !");
bytes = value;
GST_DEBUG ("bitrate calc: bytes gotten: %ld", bytes);
if (bytes)
{
if (bytes) {
double seconds = (double) stream->length_time / GST_SECOND;
double bits = bytes * 8;
stream->bitrate = (long) (bits / seconds);
}
GST_DEBUG ("moving to STATE_METADATA\n");
@ -607,7 +604,7 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
/* get properties of complete physical stream
* and return them in pre-alloced stream struct in priv->stream */
gboolean
gmip_find_stream (GstMediaInfoPriv *priv)
gmip_find_stream (GstMediaInfoPriv * priv)
{
GST_DEBUG ("mip_find_stream start");
@ -615,16 +612,13 @@ gmip_find_stream (GstMediaInfoPriv *priv)
/* iterate until caps are found */
/* FIXME: this should be done through the plugin sending some signal
* that it is ready for queries */
while (gst_bin_iterate (GST_BIN (priv->pipeline)) &&
priv->format == NULL)
;
while (gst_bin_iterate (GST_BIN (priv->pipeline)) && priv->format == NULL);
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
== GST_STATE_FAILURE)
== GST_STATE_FAILURE)
g_warning ("Couldn't set to paused");
if (priv->format == NULL)
{
GMI_DEBUG("gmip_find_stream: couldn't get caps !");
if (priv->format == NULL) {
GMI_DEBUG ("gmip_find_stream: couldn't get caps !");
return FALSE;
}
return gmip_find_stream_post (priv);
@ -632,14 +626,13 @@ gmip_find_stream (GstMediaInfoPriv *priv)
/* find metadata encoded in media and store in priv->metadata */
gboolean
gmip_find_track_metadata_pre (GstMediaInfoPriv *priv)
gmip_find_track_metadata_pre (GstMediaInfoPriv * priv)
{
/* FIXME: this is a hack to set max allowed iterations for metadata
* querying - we should make gst smarter by itself instead */
priv->metadata_iters = 0;
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -647,10 +640,10 @@ gmip_find_track_metadata_pre (GstMediaInfoPriv *priv)
}
gboolean
gmip_find_track_metadata_post (GstMediaInfoPriv *priv)
gmip_find_track_metadata_post (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
== GST_STATE_FAILURE)
== GST_STATE_FAILURE)
return FALSE;
priv->current_track->metadata = priv->metadata;
priv->metadata = NULL;
@ -658,14 +651,13 @@ gmip_find_track_metadata_post (GstMediaInfoPriv *priv)
}
gboolean
gmip_find_track_metadata (GstMediaInfoPriv *priv)
gmip_find_track_metadata (GstMediaInfoPriv * priv)
{
gmip_find_track_metadata_pre (priv);
GST_DEBUG ("gmip_find_metadata: iterating");
while ((priv->metadata == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG("+");
GMI_DEBUG("\n");
while ((priv->metadata == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_metadata_post (priv);
return TRUE;
@ -674,11 +666,10 @@ gmip_find_track_metadata (GstMediaInfoPriv *priv)
/* find streaminfo found by decoder and store in priv->streaminfo */
/* FIXME: this is an exact copy, so reuse this function instead */
gboolean
gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv)
gmip_find_track_streaminfo_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -686,7 +677,7 @@ gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv)
}
gboolean
gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv)
{
GstFormat format, track_format;
@ -694,33 +685,26 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
/* now add total length to this, and maybe even bitrate ? FIXME */
track_format = gst_format_get_by_nick ("logical_stream");
if (track_format == 0)
{
if (track_format == 0) {
g_print ("FIXME: implement getting length of whole track\n");
}
else
{
} else {
/* which one are we at ? */
long track_num;
gint64 value_start, value_end;
gboolean res;
res = gst_pad_query (priv->decoder_pad, GST_QUERY_POSITION,
&track_format, &value_start);
if (res)
{
&track_format, &value_start);
if (res) {
format = GST_FORMAT_TIME;
track_num = value_start;
GST_DEBUG ("we are currently at %ld", track_num);
res = gst_pad_convert (priv->decoder_pad,
track_format, track_num,
&format, &value_start);
res = gst_pad_convert (priv->decoder_pad,
track_format, track_num, &format, &value_start);
res &= gst_pad_convert (priv->decoder_pad,
track_format, track_num + 1,
&format, &value_end);
if (res)
{
/* substract to get the length */
track_format, track_num + 1, &format, &value_end);
if (res) {
/* substract to get the length */
GST_DEBUG ("start %lld, end %lld", value_start, value_end);
value_end -= value_start;
/* FIXME: check units; this is in seconds */
@ -737,14 +721,14 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
}
gboolean
gmip_find_track_streaminfo (GstMediaInfoPriv *priv)
gmip_find_track_streaminfo (GstMediaInfoPriv * priv)
{
gmip_find_track_streaminfo_pre (priv);
GST_DEBUG ("DEBUG: gmip_find_streaminfo: iterating");
while ((priv->streaminfo == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG("+");
GMI_DEBUG("\n");
gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_streaminfo_post (priv);
return TRUE;
@ -752,11 +736,10 @@ gmip_find_track_streaminfo (GstMediaInfoPriv *priv)
/* find format found by decoder and store in priv->format */
gboolean
gmip_find_track_format_pre (GstMediaInfoPriv *priv)
gmip_find_track_format_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
{
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
@ -764,10 +747,10 @@ gmip_find_track_format_pre (GstMediaInfoPriv *priv)
}
gboolean
gmip_find_track_format_post (GstMediaInfoPriv *priv)
gmip_find_track_format_post (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
== GST_STATE_FAILURE)
== GST_STATE_FAILURE)
return FALSE;
priv->current_track->format = priv->format;
priv->format = NULL;
@ -775,17 +758,14 @@ gmip_find_track_format_post (GstMediaInfoPriv *priv)
}
gboolean
gmip_find_track_format (GstMediaInfoPriv *priv)
gmip_find_track_format (GstMediaInfoPriv * priv)
{
gmip_find_track_format_pre (priv);
GST_DEBUG ("DEBUG: gmip_find_format: iterating");
while ((priv->format == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG("+");
GMI_DEBUG("\n");
while ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_format_post (priv);
return TRUE;
}

View file

@ -72,69 +72,65 @@ struct GstMediaInfoPriv
gint metadata_iters;
GstTagList *streaminfo;
GstElement *pipeline; /* will be != NULL during collection */
gchar *pipeline_desc; /* will be != NULL during collection */
GstElement *fakesink; /* so we can get caps from the
decoder sink pad */
gchar *source_name; /* type of element used as source */
GstElement *pipeline; /* will be != NULL during collection */
gchar *pipeline_desc; /* will be != NULL during collection */
GstElement *fakesink; /* so we can get caps from the
decoder sink pad */
gchar *source_name; /* type of element used as source */
GstElement *source;
GstPad *source_pad; /* pad for querying encoded caps */
GstPad *source_pad; /* pad for querying encoded caps */
GstElement *decoder;
GstPad *decoder_pad; /* pad for querying decoded caps */
GstElement *decontainer; /* element to typefind in containers */
GstPad *decoder_pad; /* pad for querying decoded caps */
GstElement *decontainer; /* element to typefind in containers */
GstMediaInfoState state; /* current state of state machine */
gchar *location; /* location set on the info object */
guint16 flags; /* flags supplied for detection */
GstMediaInfoTrack *current_track; /* track pointer under inspection */
glong current_track_num; /* current track under inspection */
GstMediaInfoState state; /* current state of state machine */
gchar *location; /* location set on the info object */
guint16 flags; /* flags supplied for detection */
GstMediaInfoTrack *current_track; /* track pointer under inspection */
glong current_track_num; /* current track under inspection */
GstMediaInfoStream *stream; /* total stream properties */
char *cache; /* location of cache */
GstMediaInfoStream *stream; /* total stream properties */
char *cache; /* location of cache */
GError *error; /* error for creation problems */
GError *error; /* error for creation problems */
};
/* declarations */
GstMediaInfoStream *
gmi_stream_new (void);
void gmi_stream_free (GstMediaInfoStream *stream);
GstMediaInfoStream *gmi_stream_new (void);
void gmi_stream_free (GstMediaInfoStream * stream);
GstMediaInfoTrack *
gmi_track_new (void);
GstMediaInfoTrack *gmi_track_new (void);
void gmip_reset (GstMediaInfoPriv *priv);
gboolean gmip_init (GstMediaInfoPriv *priv, GError **error);
void gmip_reset (GstMediaInfoPriv * priv);
gboolean gmip_init (GstMediaInfoPriv * priv, GError ** error);
void gmi_clear_decoder (GstMediaInfo *info);
void gmi_clear_decoder (GstMediaInfo * info);
gboolean gmi_seek_to_track (GstMediaInfo *info,
long track);
gboolean gmi_seek_to_track (GstMediaInfo * info, long track);
gboolean gmi_set_mime (GstMediaInfo *info,
const char *mime);
gboolean gmi_set_mime (GstMediaInfo * info, const char *mime);
void deep_notify_callback (GObject *object,
GstObject *origin,
GParamSpec *pspec,
GstMediaInfoPriv *priv);
void found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv);
void error_callback (GObject *element, GstElement *source, GError *error, gchar *debug, GstMediaInfoPriv *priv);
void deep_notify_callback (GObject * object,
GstObject * origin, GParamSpec * pspec, GstMediaInfoPriv * priv);
void found_tag_callback (GObject * pipeline, GstElement * source,
GstTagList * tags, GstMediaInfoPriv * priv);
void error_callback (GObject * element, GstElement * source, GError * error,
gchar * debug, GstMediaInfoPriv * priv);
gboolean gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error);
gboolean gmip_find_type_post (GstMediaInfoPriv *priv);
gboolean gmip_find_type (GstMediaInfoPriv *priv, GError **error);
gboolean gmip_find_stream_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_stream_post (GstMediaInfoPriv *priv);
gboolean gmip_find_stream (GstMediaInfoPriv *priv);
gboolean gmip_find_track_metadata_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_track_metadata_post (GstMediaInfoPriv *priv);
gboolean gmip_find_track_metadata (GstMediaInfoPriv *priv);
gboolean gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv);
gboolean gmip_find_track_streaminfo (GstMediaInfoPriv *priv);
gboolean gmip_find_track_format_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_track_format_post (GstMediaInfoPriv *priv);
gboolean gmip_find_track_format (GstMediaInfoPriv *priv);
gboolean gmip_find_type_pre (GstMediaInfoPriv * priv, GError ** error);
gboolean gmip_find_type_post (GstMediaInfoPriv * priv);
gboolean gmip_find_type (GstMediaInfoPriv * priv, GError ** error);
gboolean gmip_find_stream_pre (GstMediaInfoPriv * priv);
gboolean gmip_find_stream_post (GstMediaInfoPriv * priv);
gboolean gmip_find_stream (GstMediaInfoPriv * priv);
gboolean gmip_find_track_metadata_pre (GstMediaInfoPriv * priv);
gboolean gmip_find_track_metadata_post (GstMediaInfoPriv * priv);
gboolean gmip_find_track_metadata (GstMediaInfoPriv * priv);
gboolean gmip_find_track_streaminfo_pre (GstMediaInfoPriv * priv);
gboolean gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv);
gboolean gmip_find_track_streaminfo (GstMediaInfoPriv * priv);
gboolean gmip_find_track_format_pre (GstMediaInfoPriv * priv);
gboolean gmip_find_track_format_post (GstMediaInfoPriv * priv);
gboolean gmip_find_track_format (GstMediaInfoPriv * priv);
#endif /* __GST_MEDIA_INFO_PRIV_H__ */

View file

@ -5,7 +5,7 @@
#include "media-info.h"
static void
print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{
gint i, count;
@ -17,8 +17,8 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
str = g_strdup_value_contents (
gst_tag_list_get_value_index (list, tag, i));
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {
@ -32,7 +32,7 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
}
static void
info_print (GstMediaInfoStream *stream)
info_print (GstMediaInfoStream * stream)
{
int i;
GList *p;
@ -40,17 +40,15 @@ info_print (GstMediaInfoStream *stream)
g_print ("- mime type: %s\n", stream->mime);
g_print ("- length: %.3f seconds\n",
(gdouble) stream->length_time / GST_SECOND);
(gdouble) stream->length_time / GST_SECOND);
g_print ("- bitrate: %.3f kbps\n", stream->bitrate / 1000.0);
g_print ("- number of tracks: %ld\n", stream->length_tracks);
p = stream->tracks;
if (p == NULL)
{
if (p == NULL) {
g_print ("- no track information, probably an error\n");
return;
}
for (i = 0; i < stream->length_tracks; ++i)
{
for (i = 0; i < stream->length_tracks; ++i) {
g_print ("- track %d\n", i);
track = (GstMediaInfoTrack *) p->data;
g_print (" - metadata:\n");
@ -80,16 +78,14 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
info = gst_media_info_new (&error);
if (error != NULL)
{
if (error != NULL) {
g_print ("Error creating media-info object: %s\n", error->message);
g_error_free (error);
return -1;
}
g_assert (G_IS_OBJECT (info));
if (!gst_media_info_set_source (info, "gnomevfssrc", &error))
{
if (!gst_media_info_set_source (info, "gnomevfssrc", &error)) {
g_print ("Could not set gnomevfssrc as a source\n");
g_print ("reason: %s\n", error->message);
g_error_free (error);
@ -97,19 +93,18 @@ main (int argc, char *argv[])
}
g_print ("stream: %p, &stream: %p\n", stream, &stream);
for (i = 1; i < argc; ++i)
{
for (i = 1; i < argc; ++i) {
/*
stream = gst_media_info_read (info, argv[i], GST_MEDIA_INFO_ALL);
*/
stream = gst_media_info_read (info, argv[i], GST_MEDIA_INFO_ALL);
*/
gst_media_info_read_with_idler (info, argv[i], GST_MEDIA_INFO_ALL, &error);
while (gst_media_info_read_idler (info, &stream, &error) && stream == NULL)
/* keep idling */ g_print ("+");
/* keep idling */
g_print ("+");
g_print ("\nFILE: %s\n", argv[i]);
g_print ("stream: %p, &stream: %p\n", stream, &stream);
if (error)
{
if (error) {
g_print ("Error reading media info: %s\n", error->message);
g_error_free (error);
}

View file

@ -26,12 +26,11 @@
#include "media-info.h"
#include "media-info-priv.h"
static void gst_media_info_class_init (GstMediaInfoClass *klass);
static void gst_media_info_instance_init (GstMediaInfo *info);
static void gst_media_info_class_init (GstMediaInfoClass * klass);
static void gst_media_info_instance_init (GstMediaInfo * info);
static void gst_media_info_get_property (GObject *object, guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gst_media_info_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean _media_info_inited = FALSE;
@ -64,6 +63,7 @@ GQuark
gst_media_info_error_quark (void)
{
static GQuark quark = 0;
if (quark == 0)
quark = g_quark_from_static_string ("gst-media-info-error-quark");
return quark;
@ -86,11 +86,12 @@ GST_DEBUG_CATEGORY (gst_media_info_debug);
void
gst_media_info_init (void)
{
if (_media_info_inited) return;
if (_media_info_inited)
return;
/* register our debugging category */
GST_DEBUG_CATEGORY_INIT (gst_media_info_debug, "GST_MEDIA_INFO", 0,
"GStreamer media-info library");
"GStreamer media-info library");
GST_DEBUG ("Initialized media-info library");
_media_info_inited = TRUE;
}
@ -99,8 +100,8 @@ GType
gst_media_info_get_type (void)
{
static GType gst_media_info_type = 0;
if (!gst_media_info_type)
{
if (!gst_media_info_type) {
static const GTypeInfo gst_media_info_info = {
sizeof (GstMediaInfoClass),
(GBaseInitFunc) NULL,
@ -113,14 +114,13 @@ gst_media_info_get_type (void)
NULL
};
gst_media_info_type = g_type_register_static (G_TYPE_OBJECT,
"GstMediaInfo",
&gst_media_info_info, 0);
"GstMediaInfo", &gst_media_info_info, 0);
}
return gst_media_info_type;
}
static void
gst_media_info_class_init (GstMediaInfoClass *klass)
gst_media_info_class_init (GstMediaInfoClass * klass)
{
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
@ -129,36 +129,36 @@ gst_media_info_class_init (GstMediaInfoClass *klass)
/*
object_class->finalize = gst_media_info_finalize;
object_class->dispose = gst_media_info_dispose;
*/
object_class->finalize = gst_media_info_finalize;
object_class->dispose = gst_media_info_dispose;
*/
/*
g_object_class->set_property = gst_media_info_set_property;
*/
g_object_class->set_property = gst_media_info_set_property;
*/
g_object_class->get_property = gst_media_info_get_property;
klass->media_info_signal = NULL;
gst_media_info_signals [MEDIA_INFO_SIGNAL] =
g_signal_new ("media-info",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMediaInfoClass, media_info_signal),
NULL, NULL,
gst_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gst_media_info_signals[MEDIA_INFO_SIGNAL] =
g_signal_new ("media-info",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMediaInfoClass, media_info_signal),
NULL, NULL, gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
gst_media_info_instance_init (GstMediaInfo *info)
gst_media_info_instance_init (GstMediaInfo * info)
{
GError **error;
info->priv = g_new0 (GstMediaInfoPriv, 1);
error = &info->priv->error;
if (!_media_info_inited) { gst_media_info_init (); }
if (!_media_info_inited) {
gst_media_info_init ();
}
gmip_init (info->priv, error);
gmip_reset (info->priv);
@ -166,13 +166,12 @@ gst_media_info_instance_init (GstMediaInfo *info)
/* get/set */
static void
gst_media_info_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
gst_media_info_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstMediaInfo *info = GST_MEDIA_INFO (object);
switch (prop_id)
{
switch (prop_id) {
case PROP_SOURCE:
g_value_set_string (value, info->priv->source_name);
break;
@ -183,21 +182,17 @@ gst_media_info_get_property (GObject *object, guint prop_id,
}
GstMediaInfo *
gst_media_info_new (GError **error)
gst_media_info_new (GError ** error)
{
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
if (info->priv->error)
{
if (error)
{
if (info->priv->error) {
if (error) {
*error = info->priv->error;
info->priv->error = NULL;
}
else
{
} else {
g_warning ("Error creating GstMediaInfo object.\n%s",
info->priv->error->message);
info->priv->error->message);
g_error_free (info->priv->error);
}
}
@ -208,7 +203,8 @@ gst_media_info_new (GError **error)
* public methods
*/
gboolean
gst_media_info_set_source (GstMediaInfo *info, const char *source, GError **error)
gst_media_info_set_source (GstMediaInfo * info, const char *source,
GError ** error)
{
info->priv->source_name = g_strdup (source);
return TRUE;
@ -221,12 +217,12 @@ gst_media_info_set_source (GstMediaInfo *info, const char *source, GError **erro
* previous one is done ?
*/
void
gst_media_info_read_with_idler (GstMediaInfo *info, const char *location,
guint16 flags, GError **error)
gst_media_info_read_with_idler (GstMediaInfo * info, const char *location,
guint16 flags, GError ** error)
{
GstMediaInfoPriv *priv = info->priv;
gmip_reset (info->priv); /* reset all structs */
gmip_reset (info->priv); /* reset all structs */
priv->location = g_strdup (location);
priv->flags = flags;
}
@ -236,12 +232,14 @@ gst_media_info_read_with_idler (GstMediaInfo *info, const char *location,
* returns: TRUE if it was able to idle, FALSE if there was an error
*/
gboolean
gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GError **error)
gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
GError ** error)
{
GstMediaInfoPriv *priv;
/* if it's NULL then we're sure something went wrong higher up) */
if (info == NULL) return FALSE;
if (info == NULL)
return FALSE;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
priv = info->priv;
@ -249,15 +247,13 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
g_assert (streamp != NULL);
g_assert (priv);
switch (priv->state)
{
switch (priv->state) {
case GST_MEDIA_INFO_STATE_NULL:
/* make sure we have a source */
if (!priv->source_name)
{
*error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
"No source set on media info.");
return FALSE;
if (!priv->source_name) {
*error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
"No source set on media info.");
return FALSE;
}
/* need to find type */
@ -269,29 +265,27 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
gchar *mime;
GST_LOG ("STATE_TYPEFIND");
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
{
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GST_DEBUG ("iterating while in STATE_TYPEFIND");
GMI_DEBUG("?");
return TRUE;
GMI_DEBUG ("?");
return TRUE;
}
if (priv->type == NULL)
{
g_warning ("Couldn't find type\n");
if (priv->type == NULL) {
g_warning ("Couldn't find type\n");
return FALSE;
}
/* do the state transition */
GST_DEBUG ("doing find_type_post");
gmip_find_type_post (priv);
GST_DEBUG ("finding out mime type");
mime = g_strdup (gst_structure_get_name (
gst_caps_get_structure(priv->type, 0)));
mime =
g_strdup (gst_structure_get_name (gst_caps_get_structure (priv->type,
0)));
GST_DEBUG ("found out mime type: %s", mime);
if (!gmi_set_mime (info, mime))
{
/* FIXME: pop up error */
GST_DEBUG ("no decoder pipeline found for mime %s", mime);
return FALSE;
if (!gmi_set_mime (info, mime)) {
/* FIXME: pop up error */
GST_DEBUG ("no decoder pipeline found for mime %s", mime);
return FALSE;
}
priv->stream = gmi_stream_new ();
GST_DEBUG ("new stream: %p", priv->stream);
@ -303,14 +297,12 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
case GST_MEDIA_INFO_STATE_STREAM:
{
GST_LOG ("STATE_STREAM");
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
{
GMI_DEBUG("?");
return TRUE;
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GMI_DEBUG ("?");
return TRUE;
}
if (priv->format == NULL)
{
g_warning ("Couldn't find format\n");
if (priv->format == NULL) {
g_warning ("Couldn't find format\n");
return FALSE;
}
/* do state transition; stream -> first track metadata */
@ -320,26 +312,25 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
gmip_find_track_metadata_pre (priv);
return TRUE;
}
/* these ones are repeated per track */
/* these ones are repeated per track */
case GST_MEDIA_INFO_STATE_METADATA:
{
if ((priv->metadata == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)) &&
priv->metadata_iters < MAX_METADATA_ITERS)
{
GMI_DEBUG("?");
priv->metadata_iters < MAX_METADATA_ITERS) {
GMI_DEBUG ("?");
priv->metadata_iters++;
return TRUE;
return TRUE;
}
if (priv->metadata_iters == MAX_METADATA_ITERS)
g_print ("iterated a few times, didn't find metadata\n");
if (priv->metadata == NULL)
{
g_print ("iterated a few times, didn't find metadata\n");
if (priv->metadata == NULL) {
/* this is not a permanent failure */
GST_DEBUG ("Couldn't find metadata");
GST_DEBUG ("Couldn't find metadata");
}
GST_DEBUG ("found metadata of track %ld", priv->current_track_num);
if (!gmip_find_track_metadata_post (priv)) return FALSE;
if (!gmip_find_track_metadata_post (priv))
return FALSE;
GST_DEBUG ("METADATA: going to STREAMINFO\n");
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
return gmip_find_track_streaminfo_pre (priv);
@ -347,53 +338,47 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
case GST_MEDIA_INFO_STATE_STREAMINFO:
{
if ((priv->streaminfo == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
{
GMI_DEBUG("?");
return TRUE;
gst_bin_iterate (GST_BIN (priv->pipeline))) {
GMI_DEBUG ("?");
return TRUE;
}
if (priv->streaminfo == NULL)
{
if (priv->streaminfo == NULL) {
/* this is not a permanent failure */
GST_DEBUG ("Couldn't find streaminfo");
}
else
GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
if (!gmip_find_track_streaminfo_post (priv)) return FALSE;
GST_DEBUG ("Couldn't find streaminfo");
} else
GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
if (!gmip_find_track_streaminfo_post (priv))
return FALSE;
priv->state = GST_MEDIA_INFO_STATE_FORMAT;
return gmip_find_track_format_pre (priv);
}
case GST_MEDIA_INFO_STATE_FORMAT:
{
if ((priv->format == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)))
{
GMI_DEBUG("?");
return TRUE;
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GMI_DEBUG ("?");
return TRUE;
}
if (priv->format == NULL)
{
g_warning ("Couldn't find format\n");
if (priv->format == NULL) {
g_warning ("Couldn't find format\n");
return FALSE;
}
GST_DEBUG ("found format of track %ld", priv->current_track_num);
if (!gmip_find_track_format_post (priv)) return FALSE;
if (!gmip_find_track_format_post (priv))
return FALSE;
/* save the track info */
priv->stream->tracks = g_list_append (priv->stream->tracks,
priv->current_track);
priv->current_track);
/* these alloc'd data types have been handed off */
priv->current_track = NULL;
priv->location = NULL;
/* now see if we need to seek to a next track or not */
priv->current_track_num++;
if (priv->current_track_num < priv->stream->length_tracks)
{
gmi_seek_to_track (info, priv->current_track_num);
priv->current_track = gmi_track_new ();
if (!gmip_find_track_metadata_pre (priv))
{
if (priv->current_track_num < priv->stream->length_tracks) {
gmi_seek_to_track (info, priv->current_track_num);
priv->current_track = gmi_track_new ();
if (!gmip_find_track_metadata_pre (priv)) {
g_free (priv->current_track);
return FALSE;
return FALSE;
}
priv->state = GST_MEDIA_INFO_STATE_METADATA;
return TRUE;
@ -407,24 +392,26 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
}
case GST_MEDIA_INFO_STATE_DONE:
return TRUE;
default:
default:
g_warning ("don't know what to do\n");
return FALSE;
}
}
}
/* main function
* read all possible info from the file pointed to by location
* use flags to limit the type of information searched for */
GstMediaInfoStream *
gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags, GError **error)
gst_media_info_read (GstMediaInfo * info, const char *location, guint16 flags,
GError ** error)
{
GstMediaInfoStream *stream = NULL;
gst_media_info_read_with_idler (info, location, flags, error);
if (*error) return FALSE;
if (*error)
return FALSE;
while (gst_media_info_read_idler (info, &stream, error) && stream == NULL)
/* keep looping */;
/* keep looping */ ;
if (*error)
return NULL;

View file

@ -23,11 +23,9 @@
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct GstMediaInfoPriv GstMediaInfoPriv;
typedef struct _GstMediaInfo GstMediaInfo;
typedef struct _GstMediaInfoClass GstMediaInfoClass;
G_BEGIN_DECLS typedef struct GstMediaInfoPriv GstMediaInfoPriv;
typedef struct _GstMediaInfo GstMediaInfo;
typedef struct _GstMediaInfoClass GstMediaInfoClass;
struct _GstMediaInfo
{
@ -43,8 +41,9 @@ struct _GstMediaInfoClass
GObjectClass parent_class;
/* signals */
void (*media_info_signal) (GstMediaInfo *gst_media_info);
void (*error_signal) (GstMediaInfo *gst_media_info, GError *error, const gchar *debug);
void (*media_info_signal) (GstMediaInfo * gst_media_info);
void (*error_signal) (GstMediaInfo * gst_media_info, GError * error,
const gchar * debug);
gpointer _gst_reserved[GST_PADDING];
};
@ -100,34 +99,25 @@ typedef struct
#define GST_MEDIA_INFO_FORMAT 1 << 5
#define GST_MEDIA_INFO_ALL ((1 << 6) - 1)
GQuark gst_media_info_error_quark (void);
GQuark gst_media_info_error_quark (void);
void gst_media_info_init (void);
GType gst_media_info_get_type (void);
void gst_media_info_init (void);
GType gst_media_info_get_type (void);
GstMediaInfo * gst_media_info_new (GError **error);
GstMediaInfo *gst_media_info_new (GError ** error);
gboolean gst_media_info_set_source (GstMediaInfo * info,
const char *source, GError ** error);
void gst_media_info_read_with_idler (GstMediaInfo * media_info,
const char *location, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
gboolean gst_media_info_read_idler (GstMediaInfo * media_info,
GstMediaInfoStream ** streamp, GError ** error);
GstMediaInfoStream *gst_media_info_read (GstMediaInfo * media_info,
const char *location, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
gboolean gst_media_info_read_many (GstMediaInfo * media_info,
GList * locations, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
GstCaps *gst_media_info_get_next (GstMediaInfo * media_info, GError ** error);
gboolean gst_media_info_set_source (GstMediaInfo *info,
const char *source,
GError **error);
void gst_media_info_read_with_idler (GstMediaInfo *media_info,
const char *location,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
gboolean gst_media_info_read_idler (GstMediaInfo *media_info,
GstMediaInfoStream **streamp,
GError **error);
GstMediaInfoStream *
gst_media_info_read (GstMediaInfo *media_info,
const char *location,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
gboolean gst_media_info_read_many (GstMediaInfo *media_info,
GList *locations,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
GstCaps * gst_media_info_get_next (GstMediaInfo *media_info,
GError **error);
/*
* FIXME: reset ?
gboolean gst_media_info_write (GstMediaInfo *media_info,
@ -136,5 +126,4 @@ gboolean gst_media_info_write (GstMediaInfo *media_info,
*/
G_END_DECLS
#endif /* __GST_MEDIA_INFO_H__ */

View file

@ -26,14 +26,15 @@
#include "mixer.h"
#include "mixer-marshal.h"
enum {
enum
{
MUTE_TOGGLED,
RECORD_TOGGLED,
VOLUME_CHANGED,
LAST_SIGNAL
};
static void gst_mixer_class_init (GstMixerClass *klass);
static void gst_mixer_class_init (GstMixerClass * klass);
static guint gst_mixer_signals[LAST_SIGNAL] = { 0 };
@ -56,48 +57,47 @@ gst_mixer_get_type (void)
};
gst_mixer_type = g_type_register_static (G_TYPE_INTERFACE,
"GstMixer",
&gst_mixer_info, 0);
"GstMixer", &gst_mixer_info, 0);
g_type_interface_add_prerequisite (gst_mixer_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_mixer_type;
}
static void
gst_mixer_class_init (GstMixerClass *klass)
gst_mixer_class_init (GstMixerClass * klass)
{
static gboolean initialized = FALSE;
if (!initialized) {
gst_mixer_signals[RECORD_TOGGLED] =
g_signal_new ("record-toggled",
GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerClass, record_toggled),
NULL, NULL,
gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
g_signal_new ("record-toggled",
GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerClass, record_toggled),
NULL, NULL,
gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
gst_mixer_signals[MUTE_TOGGLED] =
g_signal_new ("mute-toggled",
GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerClass, mute_toggled),
NULL, NULL,
gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
g_signal_new ("mute-toggled",
GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerClass, mute_toggled),
NULL, NULL,
gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
gst_mixer_signals[VOLUME_CHANGED] =
g_signal_new ("volume-changed",
GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerClass, volume_changed),
NULL, NULL,
gst_mixer_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
GST_TYPE_MIXER_TRACK, G_TYPE_POINTER);
g_signal_new ("volume-changed",
GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerClass, volume_changed),
NULL, NULL,
gst_mixer_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
GST_TYPE_MIXER_TRACK, G_TYPE_POINTER);
initialized = TRUE;
}
klass->mixer_type = GST_MIXER_SOFTWARE;
/* default virtual functions */
klass->list_tracks = NULL;
klass->set_volume = NULL;
@ -119,7 +119,7 @@ gst_mixer_class_init (GstMixerClass *klass)
*/
const GList *
gst_mixer_list_tracks (GstMixer *mixer)
gst_mixer_list_tracks (GstMixer * mixer)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -146,9 +146,7 @@ gst_mixer_list_tracks (GstMixer *mixer)
*/
void
gst_mixer_set_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes)
gst_mixer_set_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -169,9 +167,7 @@ gst_mixer_set_volume (GstMixer *mixer,
*/
void
gst_mixer_get_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes)
gst_mixer_get_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -198,9 +194,7 @@ gst_mixer_get_volume (GstMixer *mixer,
*/
void
gst_mixer_set_mute (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute)
gst_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -223,9 +217,7 @@ gst_mixer_set_mute (GstMixer *mixer,
*/
void
gst_mixer_set_record (GstMixer *mixer,
GstMixerTrack *track,
gboolean record)
gst_mixer_set_record (GstMixer * mixer, GstMixerTrack * track, gboolean record)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
@ -235,43 +227,30 @@ gst_mixer_set_record (GstMixer *mixer,
}
void
gst_mixer_mute_toggled (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute)
gst_mixer_mute_toggled (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[MUTE_TOGGLED], 0,
track, mute);
gst_mixer_signals[MUTE_TOGGLED], 0, track, mute);
g_signal_emit_by_name (G_OBJECT (track),
"mute_toggled",
mute);
g_signal_emit_by_name (G_OBJECT (track), "mute_toggled", mute);
}
void
gst_mixer_record_toggled (GstMixer *mixer,
GstMixerTrack *track,
gboolean record)
gst_mixer_record_toggled (GstMixer * mixer,
GstMixerTrack * track, gboolean record)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[RECORD_TOGGLED], 0,
track, record);
gst_mixer_signals[RECORD_TOGGLED], 0, track, record);
g_signal_emit_by_name (G_OBJECT (track),
"record_toggled",
record);
g_signal_emit_by_name (G_OBJECT (track), "record_toggled", record);
}
void
gst_mixer_volume_changed (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes)
gst_mixer_volume_changed (GstMixer * mixer,
GstMixerTrack * track, gint * volumes)
{
g_signal_emit (G_OBJECT (mixer),
gst_mixer_signals[VOLUME_CHANGED], 0,
track, volumes);
gst_mixer_signals[VOLUME_CHANGED], 0, track, volumes);
g_signal_emit_by_name (G_OBJECT (track),
"volume_changed",
volumes);
g_signal_emit_by_name (G_OBJECT (track), "volume_changed", volumes);
}

View file

@ -27,7 +27,6 @@
#include <gst/mixer/mixer-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_MIXER \
(gst_mixer_get_type ())
#define GST_MIXER(obj) \
@ -40,9 +39,7 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER))
#define GST_MIXER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerClass))
#define GST_MIXER_TYPE(klass) (klass->mixer_type)
typedef struct _GstMixer GstMixer;
typedef enum
@ -51,70 +48,52 @@ typedef enum
GST_MIXER_SOFTWARE
} GstMixerType;
typedef struct _GstMixerClass {
typedef struct _GstMixerClass
{
GTypeInterface klass;
GstMixerType mixer_type;
/* virtual functions */
const GList * (* list_tracks) (GstMixer *mixer);
const GList *(*list_tracks) (GstMixer * mixer);
void (* set_volume) (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void (* get_volume) (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void (*set_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
void (*get_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
void (* set_mute) (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute);
void (* set_record) (GstMixer *mixer,
GstMixerTrack *track,
gboolean record);
void (*set_mute) (GstMixer * mixer, GstMixerTrack * track, gboolean mute);
void (*set_record) (GstMixer * mixer, GstMixerTrack * track, gboolean record);
/* signals */
void (* mute_toggled) (GstMixer *mixer,
GstMixerTrack *channel,
gboolean mute);
void (* record_toggled) (GstMixer *mixer,
GstMixerTrack *channel,
gboolean record);
void (* volume_changed) (GstMixer *mixer,
GstMixerTrack *channel,
gint *volumes);
void (*mute_toggled) (GstMixer * mixer,
GstMixerTrack * channel, gboolean mute);
void (*record_toggled) (GstMixer * mixer,
GstMixerTrack * channel, gboolean record);
void (*volume_changed) (GstMixer * mixer,
GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerClass;
GType gst_mixer_get_type (void);
GType gst_mixer_get_type (void);
/* virtual class function wrappers */
const GList * gst_mixer_list_tracks (GstMixer *mixer);
void gst_mixer_set_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void gst_mixer_get_volume (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void gst_mixer_set_mute (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute);
void gst_mixer_set_record (GstMixer *mixer,
GstMixerTrack *track,
gboolean record);
const GList *gst_mixer_list_tracks (GstMixer * mixer);
void gst_mixer_set_volume (GstMixer * mixer,
GstMixerTrack * track, gint * volumes);
void gst_mixer_get_volume (GstMixer * mixer,
GstMixerTrack * track, gint * volumes);
void gst_mixer_set_mute (GstMixer * mixer,
GstMixerTrack * track, gboolean mute);
void gst_mixer_set_record (GstMixer * mixer,
GstMixerTrack * track, gboolean record);
/* trigger signals */
void gst_mixer_mute_toggled (GstMixer *mixer,
GstMixerTrack *track,
gboolean mute);
void gst_mixer_record_toggled (GstMixer *mixer,
GstMixerTrack *track,
gboolean record);
void gst_mixer_volume_changed (GstMixer *mixer,
GstMixerTrack *track,
gint *volumes);
void gst_mixer_mute_toggled (GstMixer * mixer,
GstMixerTrack * track, gboolean mute);
void gst_mixer_record_toggled (GstMixer * mixer,
GstMixerTrack * track, gboolean record);
void gst_mixer_volume_changed (GstMixer * mixer,
GstMixerTrack * track, gint * volumes);
G_END_DECLS
#endif /* __GST_MIXER_H__ */

View file

@ -25,7 +25,8 @@
#include "mixertrack.h"
enum {
enum
{
/* FILL ME */
SIGNAL_VOLUME_CHANGED,
SIGNAL_RECORD_TOGGLED,
@ -33,9 +34,9 @@ enum {
LAST_SIGNAL
};
static void gst_mixer_track_class_init (GstMixerTrackClass *klass);
static void gst_mixer_track_init (GstMixerTrack *mixer);
static void gst_mixer_track_dispose (GObject *object);
static void gst_mixer_track_class_init (GstMixerTrackClass * klass);
static void gst_mixer_track_init (GstMixerTrack * mixer);
static void gst_mixer_track_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
@ -61,47 +62,46 @@ gst_mixer_track_get_type (void)
gst_mixer_track_type =
g_type_register_static (G_TYPE_OBJECT,
"GstMixerTrack",
&mixer_track_info, 0);
"GstMixerTrack", &mixer_track_info, 0);
}
return gst_mixer_track_type;
}
static void
gst_mixer_track_class_init (GstMixerTrackClass *klass)
gst_mixer_track_class_init (GstMixerTrackClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
signals[SIGNAL_RECORD_TOGGLED] =
g_signal_new ("record_toggled", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerTrackClass,
record_toggled),
NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
g_signal_new ("record_toggled", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerTrackClass,
record_toggled),
NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
signals[SIGNAL_MUTE_TOGGLED] =
g_signal_new ("mute_toggled", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerTrackClass,
mute_toggled),
NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
g_signal_new ("mute_toggled", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerTrackClass,
mute_toggled),
NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
signals[SIGNAL_VOLUME_CHANGED] =
g_signal_new ("volume_changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerTrackClass,
volume_changed),
NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
g_signal_new ("volume_changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerTrackClass,
volume_changed),
NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
object_klass->dispose = gst_mixer_track_dispose;
}
static void
gst_mixer_track_init (GstMixerTrack *channel)
gst_mixer_track_init (GstMixerTrack * channel)
{
channel->label = NULL;
channel->min_volume = channel->max_volume = 0;
@ -110,7 +110,7 @@ gst_mixer_track_init (GstMixerTrack *channel)
}
static void
gst_mixer_track_dispose (GObject *object)
gst_mixer_track_dispose (GObject * object)
{
GstMixerTrack *channel = GST_MIXER_TRACK (object);

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_MIXER_TRACK \
(gst_mixer_track_get_type ())
#define GST_MIXER_TRACK(obj) \
@ -38,7 +37,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MIXER_TRACK))
#define GST_IS_MIXER_TRACK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER_TRACK))
/*
* Naming:
*
@ -54,45 +52,41 @@ G_BEGIN_DECLS
* mixer, which means that setting this track will change
* the hearable volume on any output.
*/
typedef enum {
GST_MIXER_TRACK_INPUT = (1<<0),
GST_MIXER_TRACK_OUTPUT = (1<<1),
GST_MIXER_TRACK_MUTE = (1<<2),
GST_MIXER_TRACK_RECORD = (1<<3),
GST_MIXER_TRACK_MASTER = (1<<4),
GST_MIXER_TRACK_SOFTWARE = (1<<5)
typedef enum
{
GST_MIXER_TRACK_INPUT = (1 << 0),
GST_MIXER_TRACK_OUTPUT = (1 << 1),
GST_MIXER_TRACK_MUTE = (1 << 2),
GST_MIXER_TRACK_RECORD = (1 << 3),
GST_MIXER_TRACK_MASTER = (1 << 4),
GST_MIXER_TRACK_SOFTWARE = (1 << 5)
} GstMixerTrackFlags;
#define GST_MIXER_TRACK_HAS_FLAG(channel, flag) \
((channel)->flags & flag)
typedef struct _GstMixerTrack {
GObject parent;
typedef struct _GstMixerTrack
{
GObject parent;
gchar *label;
gchar *label;
GstMixerTrackFlags flags;
gint num_channels,
min_volume,
max_volume;
gint num_channels, min_volume, max_volume;
} GstMixerTrack;
typedef struct _GstMixerTrackClass {
typedef struct _GstMixerTrackClass
{
GObjectClass parent;
/* signals */
void (* mute_toggled) (GstMixerTrack *channel,
gboolean mute);
void (* record_toggled) (GstMixerTrack *channel,
gboolean record);
void (* volume_changed) (GstMixerTrack *channel,
gint *volumes);
void (*mute_toggled) (GstMixerTrack * channel, gboolean mute);
void (*record_toggled) (GstMixerTrack * channel, gboolean record);
void (*volume_changed) (GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerTrackClass;
GType gst_mixer_track_get_type (void);
GType gst_mixer_track_get_type (void);
G_END_DECLS
#endif /* __GST_MIXER_TRACK_H__ */

View file

@ -25,7 +25,7 @@
#include <gst/navigation/navigation.h>
static void gst_navigation_class_init (GstNavigationInterface *iface);
static void gst_navigation_class_init (GstNavigationInterface * iface);
GType
gst_navigation_get_type (void)
@ -46,22 +46,21 @@ gst_navigation_get_type (void)
};
gst_navigation_type = g_type_register_static (G_TYPE_INTERFACE,
"GstNavigation",
&gst_navigation_info, 0);
"GstNavigation", &gst_navigation_info, 0);
}
return gst_navigation_type;
}
static void
gst_navigation_class_init (GstNavigationInterface *iface)
gst_navigation_class_init (GstNavigationInterface * iface)
{
/* default virtual functions */
iface->send_event = NULL;
}
void
gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
gst_navigation_send_event (GstNavigation * navigation, GstStructure * structure)
{
GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation);
@ -71,25 +70,20 @@ gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
}
void
gst_navigation_send_key_event (GstNavigation *navigation, const char *event,
const char *key)
gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
const char *key)
{
gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
"event", G_TYPE_STRING, event,
"key", G_TYPE_STRING, key, NULL));
gst_navigation_send_event (navigation,
gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
event, "key", G_TYPE_STRING, key, NULL));
}
void
gst_navigation_send_mouse_event (GstNavigation *navigation, const char *event,
int button, double x, double y)
gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
int button, double x, double y)
{
gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
"event", G_TYPE_STRING, event,
"button", G_TYPE_INT, button,
"pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", G_TYPE_DOUBLE, y, NULL));
gst_navigation_send_event (navigation,
gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
event, "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", G_TYPE_DOUBLE, y, NULL));
}

View file

@ -26,7 +26,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_NAVIGATION \
(gst_navigation_get_type ())
#define GST_NAVIGATION(obj) \
@ -35,28 +34,28 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NAVIGATION))
#define GST_NAVIGATION_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_NAVIGATION, GstNavigationInterface))
typedef struct _GstNavigation GstNavigation;
typedef struct _GstNavigationInterface {
typedef struct _GstNavigationInterface
{
GTypeInterface g_iface;
/* virtual functions */
void (*send_event) (GstNavigation *navigation, GstStructure *structure);
void (*send_event) (GstNavigation * navigation, GstStructure * structure);
gpointer _gst_reserved[GST_PADDING];
} GstNavigationInterface;
GType gst_navigation_get_type (void);
GType gst_navigation_get_type (void);
/* virtual class function wrappers */
void gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure);
void gst_navigation_send_event (GstNavigation * navigation,
GstStructure * structure);
void gst_navigation_send_key_event (GstNavigation *navigation,
const char *event, const char *key);
void gst_navigation_send_mouse_event (GstNavigation *navigation,
const char *event, int button, double x, double y);
void gst_navigation_send_key_event (GstNavigation * navigation,
const char *event, const char *key);
void gst_navigation_send_mouse_event (GstNavigation * navigation,
const char *event, int button, double x, double y);
G_END_DECLS
#endif /* __GST_NAVIGATION_H__ */

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_PLAY_H__
#define __GST_PLAY_H__
@ -46,51 +46,43 @@ typedef enum
typedef struct _GstPlay GstPlay;
typedef struct _GstPlayClass GstPlayClass;
typedef struct _GstPlayPrivate GstPlayPrivate;
struct _GstPlay
{
GstPipeline pipeline;
GstPlayPrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstPlayClass
{
GstPipelineClass parent_class;
void (*time_tick) (GstPlay *play, gint64 time_nanos);
void (*stream_length) (GstPlay *play, gint64 length_nanos);
void (*have_video_size) (GstPlay *play, gint width, gint height);
void (*time_tick) (GstPlay * play, gint64 time_nanos);
void (*stream_length) (GstPlay * play, gint64 length_nanos);
void (*have_video_size) (GstPlay * play, gint width, gint height);
gpointer _gst_reserved[GST_PADDING];
};
GType gst_play_get_type (void);
GstPlay * gst_play_new (GError **error);
GType gst_play_get_type (void);
GstPlay *gst_play_new (GError ** error);
gboolean gst_play_set_data_src (GstPlay *play,
GstElement *data_src);
gboolean gst_play_set_video_sink (GstPlay *play,
GstElement *video_sink);
gboolean gst_play_set_audio_sink (GstPlay *play,
GstElement *audio_sink);
gboolean gst_play_set_data_src (GstPlay * play, GstElement * data_src);
gboolean gst_play_set_video_sink (GstPlay * play, GstElement * video_sink);
gboolean gst_play_set_audio_sink (GstPlay * play, GstElement * audio_sink);
gboolean gst_play_set_visualization (GstPlay *play,
GstElement *element);
gboolean gst_play_connect_visualization (GstPlay *play,
gboolean connect);
gboolean gst_play_set_visualization (GstPlay * play, GstElement * element);
gboolean gst_play_connect_visualization (GstPlay * play, gboolean connect);
gboolean gst_play_set_location (GstPlay *play,
const char *location);
char * gst_play_get_location (GstPlay *play);
gboolean gst_play_set_location (GstPlay * play, const char *location);
char *gst_play_get_location (GstPlay * play);
gboolean gst_play_seek_to_time (GstPlay *play,
gint64 time_nanos);
gboolean gst_play_seek_to_time (GstPlay * play, gint64 time_nanos);
GstElement * gst_play_get_sink_element (GstPlay *play,
GstElement *element,
GstPlaySinkType sink_type);
GstElement *gst_play_get_sink_element (GstPlay * play,
GstElement * element, GstPlaySinkType sink_type);
#endif /* __GST_PLAY_H__ */

View file

@ -27,12 +27,13 @@
#include "propertyprobe.h"
enum {
enum
{
SIGNAL_PROBE_NEEDED,
LAST_SIGNAL
};
static void gst_property_probe_iface_init (GstPropertyProbeInterface *iface);
static void gst_property_probe_iface_init (GstPropertyProbeInterface * iface);
static guint gst_property_probe_signals[LAST_SIGNAL] = { 0 };
@ -56,30 +57,29 @@ gst_property_probe_get_type (void)
gst_property_probe_type =
g_type_register_static (G_TYPE_INTERFACE,
"GstPropertyProbe",
&gst_property_probe_info, 0);
"GstPropertyProbe", &gst_property_probe_info, 0);
}
return gst_property_probe_type;
}
static void
gst_property_probe_iface_init (GstPropertyProbeInterface *iface)
gst_property_probe_iface_init (GstPropertyProbeInterface * iface)
{
static gboolean initialized = FALSE;
if (!initialized) {
gst_property_probe_signals[SIGNAL_PROBE_NEEDED] =
g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstPropertyProbeInterface, probe_needed),
NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstPropertyProbeInterface,
probe_needed), NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
initialized = TRUE;
}
/* default virtual functions */
iface->get_properties = NULL;
iface->get_values = NULL;
iface->get_values = NULL;
}
/**
@ -93,23 +93,22 @@ gst_property_probe_iface_init (GstPropertyProbeInterface *iface)
*/
const GList *
gst_property_probe_get_properties (GstPropertyProbe *probe)
gst_property_probe_get_properties (GstPropertyProbe * probe)
{
GstPropertyProbeInterface *iface;
g_return_val_if_fail (probe != NULL, NULL);
iface = GST_PROPERTY_PROBE_GET_IFACE (probe);
if (iface->get_properties)
return iface->get_properties (probe);
return NULL;
}
const GParamSpec *
gst_property_probe_get_property (GstPropertyProbe *probe,
const gchar *name)
gst_property_probe_get_property (GstPropertyProbe * probe, const gchar * name)
{
const GList *pspecs = gst_property_probe_get_properties (probe);
@ -129,8 +128,8 @@ gst_property_probe_get_property (GstPropertyProbe *probe,
}
void
gst_property_probe_probe_property (GstPropertyProbe *probe,
const GParamSpec *pspec)
gst_property_probe_probe_property (GstPropertyProbe * probe,
const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
@ -156,8 +155,8 @@ gst_property_probe_probe_property (GstPropertyProbe *probe,
*/
void
gst_property_probe_probe_property_name (GstPropertyProbe *probe,
const gchar *name)
gst_property_probe_probe_property_name (GstPropertyProbe * probe,
const gchar * name)
{
const GParamSpec *pspec;
@ -188,8 +187,8 @@ gst_property_probe_probe_property_name (GstPropertyProbe *probe,
*/
gboolean
gst_property_probe_needs_probe (GstPropertyProbe *probe,
const GParamSpec *pspec)
gst_property_probe_needs_probe (GstPropertyProbe * probe,
const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
@ -215,8 +214,8 @@ gst_property_probe_needs_probe (GstPropertyProbe *probe,
*/
gboolean
gst_property_probe_needs_probe_name (GstPropertyProbe *probe,
const gchar *name)
gst_property_probe_needs_probe_name (GstPropertyProbe * probe,
const gchar * name)
{
const GParamSpec *pspec;
@ -242,10 +241,10 @@ gst_property_probe_needs_probe_name (GstPropertyProbe *probe,
*
* Returns: A list of valid values for the given property.
*/
GValueArray *
gst_property_probe_get_values (GstPropertyProbe *probe,
const GParamSpec *pspec)
gst_property_probe_get_values (GstPropertyProbe * probe,
const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
@ -271,8 +270,8 @@ gst_property_probe_get_values (GstPropertyProbe *probe,
*/
GValueArray *
gst_property_probe_get_values_name (GstPropertyProbe *probe,
const gchar *name)
gst_property_probe_get_values_name (GstPropertyProbe * probe,
const gchar * name)
{
const GParamSpec *pspec;
@ -301,8 +300,8 @@ gst_property_probe_get_values_name (GstPropertyProbe *probe,
*/
GValueArray *
gst_property_probe_probe_and_get_values (GstPropertyProbe *probe,
const GParamSpec *pspec)
gst_property_probe_probe_and_get_values (GstPropertyProbe * probe,
const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
@ -328,8 +327,8 @@ gst_property_probe_probe_and_get_values (GstPropertyProbe *probe,
*/
GValueArray *
gst_property_probe_probe_and_get_values_name (GstPropertyProbe *probe,
const gchar *name)
gst_property_probe_probe_and_get_values_name (GstPropertyProbe * probe,
const gchar * name)
{
const GParamSpec *pspec;

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_PROPERTY_PROBE \
(gst_property_probe_get_type ())
#define GST_PROPERTY_PROBE(obj) \
@ -34,64 +33,59 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PROPERTY_PROBE))
#define GST_PROPERTY_PROBE_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_PROPERTY_PROBE, GstPropertyProbeInterface))
typedef struct _GstPropertyProbe GstPropertyProbe; /* dummy typedef */
typedef struct _GstPropertyProbe GstPropertyProbe; /* dummy typedef */
typedef struct _GstPropertyProbeInterface {
typedef struct _GstPropertyProbeInterface
{
GTypeInterface klass;
/* signals */
void (*probe_needed) (GstPropertyProbe *probe,
const GParamSpec *pspec);
void (*probe_needed) (GstPropertyProbe * probe, const GParamSpec * pspec);
/* virtual functions */
const GList * (*get_properties) (GstPropertyProbe *probe);
gboolean (*needs_probe) (GstPropertyProbe *probe,
guint prop_id,
const GParamSpec *pspec);
void (*probe_property) (GstPropertyProbe *probe,
guint prop_id,
const GParamSpec *pspec);
GValueArray * (*get_values) (GstPropertyProbe *probe,
guint prop_id,
const GParamSpec *pspec);
const GList *(*get_properties) (GstPropertyProbe * probe);
gboolean (*needs_probe) (GstPropertyProbe * probe,
guint prop_id, const GParamSpec * pspec);
void (*probe_property) (GstPropertyProbe * probe,
guint prop_id, const GParamSpec * pspec);
GValueArray *(*get_values) (GstPropertyProbe * probe,
guint prop_id, const GParamSpec * pspec);
gpointer _gst_reserved[GST_PADDING];
} GstPropertyProbeInterface;
GType gst_property_probe_get_type (void);
GType gst_property_probe_get_type (void);
/* virtual class function wrappers */
/* returns list of GParamSpecs */
const GList * gst_property_probe_get_properties (GstPropertyProbe *probe);
const GParamSpec *gst_property_probe_get_property (GstPropertyProbe *probe,
const gchar *name);
const GList *gst_property_probe_get_properties (GstPropertyProbe * probe);
const GParamSpec *gst_property_probe_get_property (GstPropertyProbe * probe,
const gchar * name);
/* probe one property */
void gst_property_probe_probe_property (GstPropertyProbe *probe,
const GParamSpec *pspec);
void gst_property_probe_probe_property_name (GstPropertyProbe *probe,
const gchar *name);
void gst_property_probe_probe_property (GstPropertyProbe * probe,
const GParamSpec * pspec);
void gst_property_probe_probe_property_name (GstPropertyProbe * probe,
const gchar * name);
/* do we need a probe? */
gboolean gst_property_probe_needs_probe (GstPropertyProbe *probe,
const GParamSpec *pspec);
gboolean gst_property_probe_needs_probe_name (GstPropertyProbe *probe,
const gchar *name);
gboolean gst_property_probe_needs_probe (GstPropertyProbe * probe,
const GParamSpec * pspec);
gboolean gst_property_probe_needs_probe_name (GstPropertyProbe * probe,
const gchar * name);
/* returns list of GValues */
GValueArray * gst_property_probe_get_values (GstPropertyProbe *probe,
const GParamSpec *pspec);
GValueArray * gst_property_probe_get_values_name (GstPropertyProbe *probe,
const gchar *name);
GValueArray *gst_property_probe_get_values (GstPropertyProbe * probe,
const GParamSpec * pspec);
GValueArray *gst_property_probe_get_values_name (GstPropertyProbe * probe,
const gchar * name);
/* sugar */
GValueArray * gst_property_probe_probe_and_get_values (GstPropertyProbe *probe,
const GParamSpec *pspec);
GValueArray * gst_property_probe_probe_and_get_values_name (GstPropertyProbe *probe,
const gchar *name);
GValueArray *gst_property_probe_probe_and_get_values (GstPropertyProbe * probe,
const GParamSpec * pspec);
GValueArray *gst_property_probe_probe_and_get_values_name (GstPropertyProbe *
probe, const gchar * name);
G_END_DECLS
#endif /* __GST_PROPERTY_PROBE_H__ */

View file

@ -29,40 +29,46 @@
/*#include <ml.h> */
#include "private.h"
void conv_double_float_ref(double *dest, float *src, int n)
void
conv_double_float_ref (double *dest, float *src, int n)
{
int i;
for(i=0;i<n;i++){
dest[i]=src[i];
}
int i;
for (i = 0; i < n; i++) {
dest[i] = src[i];
}
}
void conv_float_double_ref(float *dest, double *src, int n)
void
conv_float_double_ref (float *dest, double *src, int n)
{
int i;
for(i=0;i<n;i++){
dest[i]=src[i];
}
int i;
for (i = 0; i < n; i++) {
dest[i] = src[i];
}
}
void conv_double_float_dstr(double *dest, float *src, int n, int dstr)
void
conv_double_float_dstr (double *dest, float *src, int n, int dstr)
{
int i;
void *d = dest;
for(i=0;i<n;i++){
(*(double *)d)=*src++;
d += dstr;
}
int i;
void *d = dest;
for (i = 0; i < n; i++) {
(*(double *) d) = *src++;
d += dstr;
}
}
void conv_float_double_sstr(float *dest, double *src, int n, int sstr)
void
conv_float_double_sstr (float *dest, double *src, int n, int sstr)
{
int i;
void *s = src;
int i;
void *s = src;
for(i=0;i<n;i++){
*dest++ = *(double *)s;
s += sstr;
}
for (i = 0; i < n; i++) {
*dest++ = *(double *) s;
s += sstr;
}
}

View file

@ -39,92 +39,98 @@
static float ints_high[256];
static float ints_low[256];
void conv_double_short_table(double *dest, short *src, int n)
void
conv_double_short_table (double *dest, short *src, int n)
{
static int init = 0;
int i;
unsigned int idx;
if(!init){
for(i=0;i<256;i++){
ints_high[i]=256.0*((i<128)?i:i-256);
ints_low[i]=i;
}
init = 1;
}
static int init = 0;
int i;
unsigned int idx;
if(n&1){
idx = (unsigned short)*src++;
*dest++ = ints_high[(idx>>8)] + ints_low[(idx&0xff)];
n-=1;
}
for(i=0;i<n;i+=2){
idx = (unsigned short)*src++;
*dest++ = ints_high[(idx>>8)] + ints_low[(idx&0xff)];
idx = (unsigned short)*src++;
*dest++ = ints_high[(idx>>8)] + ints_low[(idx&0xff)];
}
if (!init) {
for (i = 0; i < 256; i++) {
ints_high[i] = 256.0 * ((i < 128) ? i : i - 256);
ints_low[i] = i;
}
init = 1;
}
if (n & 1) {
idx = (unsigned short) *src++;
*dest++ = ints_high[(idx >> 8)] + ints_low[(idx & 0xff)];
n -= 1;
}
for (i = 0; i < n; i += 2) {
idx = (unsigned short) *src++;
*dest++ = ints_high[(idx >> 8)] + ints_low[(idx & 0xff)];
idx = (unsigned short) *src++;
*dest++ = ints_high[(idx >> 8)] + ints_low[(idx & 0xff)];
}
}
#endif
#ifdef short_to_double_unroll
void conv_double_short_unroll(double *dest, short *src, int n)
void
conv_double_short_unroll (double *dest, short *src, int n)
{
if(n&1){
*dest++ = *src++;
n--;
}
if(n&2){
*dest++ = *src++;
*dest++ = *src++;
n-=2;
}
while(n>0){
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
n-=4;
}
if (n & 1) {
*dest++ = *src++;
n--;
}
if (n & 2) {
*dest++ = *src++;
*dest++ = *src++;
n -= 2;
}
while (n > 0) {
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
n -= 4;
}
}
#endif
void conv_double_short_ref(double *dest, short *src, int n)
void
conv_double_short_ref (double *dest, short *src, int n)
{
int i;
for(i=0;i<n;i++){
dest[i]=src[i];
}
int i;
for (i = 0; i < n; i++) {
dest[i] = src[i];
}
}
#ifdef HAVE_CPU_PPC
#if 0
static union { int i[4]; float f[4]; } av_tmp __attribute__ ((__aligned__ (16)));
void conv_double_short_altivec(double *dest, short *src, int n)
static union
{
int i;
int i[4];
float f[4];
} av_tmp __attribute__ ((__aligned__ (16)));
for(i=0;i<n;i+=4){
av_tmp.i[0] = src[0];
av_tmp.i[1] = src[1];
av_tmp.i[2] = src[2];
av_tmp.i[3] = src[3];
void
conv_double_short_altivec (double *dest, short *src, int n)
{
int i;
asm(
" lvx 0,0,%0\n"
" vcfsx 1,0,0\n"
" stvx 1,0,%0\n"
: : "r" (&av_tmp)
);
for (i = 0; i < n; i += 4) {
av_tmp.i[0] = src[0];
av_tmp.i[1] = src[1];
av_tmp.i[2] = src[2];
av_tmp.i[3] = src[3];
dest[0]=av_tmp.f[0];
dest[1]=av_tmp.f[1];
dest[2]=av_tmp.f[2];
dest[3]=av_tmp.f[3];
src += 4;
dest += 4;
}
asm (" lvx 0,0,%0\n" " vcfsx 1,0,0\n" " stvx 1,0,%0\n": :"r" (&av_tmp)
);
dest[0] = av_tmp.f[0];
dest[1] = av_tmp.f[1];
dest[2] = av_tmp.f[2];
dest[3] = av_tmp.f[3];
src += 4;
dest += 4;
}
}
#endif
#endif
@ -133,73 +139,78 @@ void conv_double_short_altivec(double *dest, short *src, int n)
/* double to short */
void conv_short_double_ref(short *dest, double *src, int n)
void
conv_short_double_ref (short *dest, double *src, int n)
{
int i;
double x;
int i;
double x;
for(i=0;i<n;i++){
x = *src++;
if(x<-32768.0)x=-32768.0;
if(x>32767.0)x=32767.0;
*dest++ = rint(x);
}
for (i = 0; i < n; i++) {
x = *src++;
if (x < -32768.0)
x = -32768.0;
if (x > 32767.0)
x = 32767.0;
*dest++ = rint (x);
}
}
/* #ifdef HAVE_CPU_PPC */
#if 0
void conv_short_double_ppcasm(short *dest, double *src, int n)
void
conv_short_double_ppcasm (short *dest, double *src, int n)
{
int tmp[2];
double min = -32768.0;
double max = 32767.0;
double ftmp0, ftmp1;
int tmp[2];
double min = -32768.0;
double max = 32767.0;
double ftmp0, ftmp1;
asm __volatile__(
"\taddic. %3,%3,-8\n"
"\taddic. %6,%6,-2\n"
"loop:\n"
"\tlfdu %0,8(%3)\n"
"\tfsub %1,%0,%4\n"
"\tfsel %0,%1,%0,%4\n"
"\tfsub %1,%0,%5\n"
"\tfsel %0,%1,%5,%0\n"
"\tfctiw %1,%0\n"
"\taddic. 5,5,-1\n"
"\tstfd %1,0(%2)\n"
"\tlhz 9,6(%2)\n"
"\tsthu 9,2(%6)\n"
"\tbne loop\n"
: "=&f" (ftmp0), "=&f" (ftmp1)
: "b" (tmp), "r" (src), "f" (min), "f" (max), "r" (dest)
: "r9", "r5" );
asm __volatile__ ("\taddic. %3,%3,-8\n"
"\taddic. %6,%6,-2\n"
"loop:\n"
"\tlfdu %0,8(%3)\n"
"\tfsub %1,%0,%4\n"
"\tfsel %0,%1,%0,%4\n"
"\tfsub %1,%0,%5\n"
"\tfsel %0,%1,%5,%0\n"
"\tfctiw %1,%0\n"
"\taddic. 5,5,-1\n"
"\tstfd %1,0(%2)\n"
"\tlhz 9,6(%2)\n"
"\tsthu 9,2(%6)\n" "\tbne loop\n":"=&f" (ftmp0), "=&f" (ftmp1)
:"b" (tmp), "r" (src), "f" (min), "f" (max), "r" (dest)
:"r9", "r5");
}
#endif
void conv_double_short_dstr(double *dest, short *src, int n, int dstr)
void
conv_double_short_dstr (double *dest, short *src, int n, int dstr)
{
int i;
void *d = dest;
for(i=0;i<n;i++){
(*(double *)d)=*src++;
d += dstr;
}
int i;
void *d = dest;
for (i = 0; i < n; i++) {
(*(double *) d) = *src++;
d += dstr;
}
}
void conv_short_double_sstr(short *dest, double *src, int n, int sstr)
void
conv_short_double_sstr (short *dest, double *src, int n, int sstr)
{
int i;
double x;
void *s = src;
int i;
double x;
void *s = src;
for(i=0;i<n;i++){
x = *(double *)s;
if(x<-32768.0)x=-32768.0;
if(x>32767.0)x=32767.0;
*dest++ = rint(x);
s += sstr;
}
for (i = 0; i < n; i++) {
x = *(double *) s;
if (x < -32768.0)
x = -32768.0;
if (x > 32767.0)
x = 32767.0;
*dest++ = rint (x);
s += sstr;
}
}

View file

@ -30,285 +30,293 @@
double functable_sinc(void *p,double x)
double
functable_sinc (void *p, double x)
{
if(x==0)return 1;
return sin(x)/x;
if (x == 0)
return 1;
return sin (x) / x;
}
double functable_dsinc(void *p,double x)
double
functable_dsinc (void *p, double x)
{
if(x==0)return 0;
return cos(x)/x - sin(x)/(x*x);
if (x == 0)
return 0;
return cos (x) / x - sin (x) / (x * x);
}
double functable_window_boxcar(void *p,double x)
double
functable_window_boxcar (void *p, double x)
{
if(x<-1 || x>1)return 0;
return 1;
if (x < -1 || x > 1)
return 0;
return 1;
}
double functable_window_dboxcar(void *p,double x)
double
functable_window_dboxcar (void *p, double x)
{
return 0;
return 0;
}
double functable_window_std(void *p,double x)
double
functable_window_std (void *p, double x)
{
if(x<-1 || x>1)return 0;
return (1-x*x)*(1-x*x);
if (x < -1 || x > 1)
return 0;
return (1 - x * x) * (1 - x * x);
}
double functable_window_dstd(void *p,double x)
double
functable_window_dstd (void *p, double x)
{
if(x<-1 || x>1)return 0;
return -4*x*(1-x*x);
if (x < -1 || x > 1)
return 0;
return -4 * x * (1 - x * x);
}
void functable_init(functable_t *t)
void
functable_init (functable_t * t)
{
int i;
double x;
int i;
double x;
t->fx = malloc(sizeof(double)*(t->len+1));
t->fdx = malloc(sizeof(double)*(t->len+1));
t->fx = malloc (sizeof (double) * (t->len + 1));
t->fdx = malloc (sizeof (double) * (t->len + 1));
t->invoffset = 1.0 / t->offset;
t->invoffset = 1.0 / t->offset;
for(i=0;i<t->len+1;i++){
x = t->start + t->offset * i;
x *= t->scale;
for (i = 0; i < t->len + 1; i++) {
x = t->start + t->offset * i;
x *= t->scale;
t->fx[i] = t->func_x(t->priv,x);
t->fdx[i] = t->scale * t->func_dx(t->priv,x);
}
if(t->func2_x){
double f1x,f1dx;
double f2x,f2dx;
t->fx[i] = t->func_x (t->priv, x);
t->fdx[i] = t->scale * t->func_dx (t->priv, x);
}
if (t->func2_x) {
double f1x, f1dx;
double f2x, f2dx;
for(i=0;i<t->len+1;i++){
x = t->start + t->offset * i;
x *= t->scale2;
for (i = 0; i < t->len + 1; i++) {
x = t->start + t->offset * i;
x *= t->scale2;
f2x = t->func2_x(t->priv,x);
f2dx = t->scale2 * t->func2_dx(t->priv,x);
f2x = t->func2_x (t->priv, x);
f2dx = t->scale2 * t->func2_dx (t->priv, x);
f1x = t->fx[i];
f1dx = t->fdx[i];
f1x = t->fx[i];
f1dx = t->fdx[i];
t->fx[i] = f1x * f2x;
t->fdx[i] = f1x * f2dx + f1dx * f2x;
}
}
t->fx[i] = f1x * f2x;
t->fdx[i] = f1x * f2dx + f1dx * f2x;
}
}
}
double functable_eval(functable_t *t,double x)
double
functable_eval (functable_t * t, double x)
{
int i;
double f0, f1, w0, w1;
double x2, x3;
double w;
int i;
double f0, f1, w0, w1;
double x2, x3;
double w;
if(x<t->start || x>(t->start+(t->len+1)*t->offset)){
printf("x out of range %g\n",x);
}
x -= t->start;
x /= t->offset;
i = floor(x);
x -= i;
if (x < t->start || x > (t->start + (t->len + 1) * t->offset)) {
printf ("x out of range %g\n", x);
}
x -= t->start;
x /= t->offset;
i = floor (x);
x -= i;
x2 = x * x;
x3 = x2 * x;
x2 = x * x;
x3 = x2 * x;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
/*printf("i=%d x=%g f0=%g f1=%g w0=%g w1=%g\n",i,x,f0,f1,w0,w1); */
/*printf("i=%d x=%g f0=%g f1=%g w0=%g w1=%g\n",i,x,f0,f1,w0,w1); */
w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
t->fdx[i] * w0 + t->fdx[i + 1] * w1;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
/*w = t->fx[i] * (1-x) + t->fx[i+1] * x; */
/*w = t->fx[i] * (1-x) + t->fx[i+1] * x; */
return w;
return w;
}
double functable_fir(functable_t *t, double x, int n, double *data, int len)
double
functable_fir (functable_t * t, double x, int n, double *data, int len)
{
int i,j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum;
int i, j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum;
x -= t->start;
x /= t->offset;
i = floor(x);
x -= i;
x -= t->start;
x /= t->offset;
i = floor (x);
x -= i;
x2 = x * x;
x3 = x2 * x;
x2 = x * x;
x3 = x2 * x;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
sum = 0;
for(j=0;j<len;j++){
w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum += data[j*2] * w;
i += n;
}
sum = 0;
for (j = 0; j < len; j++) {
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum += data[j * 2] * w;
i += n;
}
return sum;
return sum;
}
void functable_fir2(functable_t *t, double *r0, double *r1, double x,
int n, double *data, int len)
void
functable_fir2 (functable_t * t, double *r0, double *r1, double x,
int n, double *data, int len)
{
int i,j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum0, sum1;
double floor_x;
int i, j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum0, sum1;
double floor_x;
x -= t->start;
x *= t->invoffset;
floor_x = floor(x);
i = floor_x;
x -= floor_x;
x -= t->start;
x *= t->invoffset;
floor_x = floor (x);
i = floor_x;
x -= floor_x;
x2 = x * x;
x3 = x2 * x;
x2 = x * x;
x3 = x2 * x;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
sum0 = 0;
sum1 = 0;
for(j=0;j<len;j++){
w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j*2] * w;
sum1 += data[j*2+1] * w;
i += n;
sum0 = 0;
sum1 = 0;
for (j = 0; j < len; j++) {
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j * 2] * w;
sum1 += data[j * 2 + 1] * w;
i += n;
#define unroll2
#define unroll3
#define unroll4
#ifdef unroll2
j++;
j++;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j*2] * w;
sum1 += data[j*2+1] * w;
i += n;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j * 2] * w;
sum1 += data[j * 2 + 1] * w;
i += n;
#endif
#ifdef unroll3
j++;
j++;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j*2] * w;
sum1 += data[j*2+1] * w;
i += n;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j * 2] * w;
sum1 += data[j * 2 + 1] * w;
i += n;
#endif
#ifdef unroll4
j++;
j++;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j*2] * w;
sum1 += data[j*2+1] * w;
i += n;
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
sum0 += data[j * 2] * w;
sum1 += data[j * 2 + 1] * w;
i += n;
#endif
}
}
*r0 = sum0;
*r1 = sum1;
*r0 = sum0;
*r1 = sum1;
}
#ifdef unused
void functable_fir2_altivec(functable_t *t, float *r0, float *r1,
double x, int n, float *data, int len)
void
functable_fir2_altivec (functable_t * t, float *r0, float *r1,
double x, int n, float *data, int len)
{
int i,j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum0, sum1;
double floor_x;
int i, j;
double f0, f1, w0, w1;
double x2, x3;
double w;
double sum0, sum1;
double floor_x;
x -= t->start;
x *= t->invoffset;
floor_x = floor(x);
i = floor_x;
x -= floor_x;
x -= t->start;
x *= t->invoffset;
floor_x = floor (x);
i = floor_x;
x -= floor_x;
x2 = x * x;
x3 = x2 * x;
x2 = x * x;
x3 = x2 * x;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
f1 = 3 * x2 - 2 * x3;
f0 = 1 - f1;
w0 = (x - 2 * x2 + x3) * t->offset;
w1 = (-x2 + x3) * t->offset;
sum0 = 0;
sum1 = 0;
for(j=0;j<len;j++){
/* t->fx, t->fdx needs to be multiplexed by n */
/* we need 5 consecutive floats, which fit into 2 vecs */
/* load v0, t->fx[i] */
/* load v1, t->fx[i+n] */
/* v2 = v0 (not correct) */
/* v3 = (v0>>32) || (v1<<3*32) (not correct) */
/* */
/* load v4, t->dfx[i] */
/* load v5, t->dfx[i+n] */
/* v6 = v4 (not correct) */
/* v7 = (v4>>32) || (v5<<3*32) (not correct) */
/* */
/* v8 = splat(f0) */
/* v9 = splat(f1) */
/* v10 = splat(w0) */
/* v11 = splat(w1) */
/* */
/* v12 = v2 * v8 */
/* v12 += v3 * v9 */
/* v12 += v6 * v10 */
/* v12 += v7 * v11 */
w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
t->fdx[i] * w0 + t->fdx[i + 1] * w1;
/* v13 = data[j*2] */
/* v14 = data[j*2+4] */
/* v15 = deinterlace_high(v13,v14) */
/* v16 = deinterlace_low(v13,v14) */
/* (sum0) v17 += multsum(v13,v15) */
/* (sum1) v18 += multsum(v14,v16) */
sum0 += data[j*2] * w;
sum1 += data[j*2+1] * w;
i += n;
sum0 = 0;
sum1 = 0;
for (j = 0; j < len; j++) {
/* t->fx, t->fdx needs to be multiplexed by n */
/* we need 5 consecutive floats, which fit into 2 vecs */
/* load v0, t->fx[i] */
/* load v1, t->fx[i+n] */
/* v2 = v0 (not correct) */
/* v3 = (v0>>32) || (v1<<3*32) (not correct) */
/* */
/* load v4, t->dfx[i] */
/* load v5, t->dfx[i+n] */
/* v6 = v4 (not correct) */
/* v7 = (v4>>32) || (v5<<3*32) (not correct) */
/* */
/* v8 = splat(f0) */
/* v9 = splat(f1) */
/* v10 = splat(w0) */
/* v11 = splat(w1) */
/* */
/* v12 = v2 * v8 */
/* v12 += v3 * v9 */
/* v12 += v6 * v10 */
/* v12 += v7 * v11 */
}
w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
*r0 = sum0;
*r1 = sum1;
/* v13 = data[j*2] */
/* v14 = data[j*2+4] */
/* v15 = deinterlace_high(v13,v14) */
/* v16 = deinterlace_low(v13,v14) */
/* (sum0) v17 += multsum(v13,v15) */
/* (sum1) v18 += multsum(v14,v16) */
sum0 += data[j * 2] * w;
sum1 += data[j * 2 + 1] * w;
i += n;
}
*r0 = sum0;
*r1 = sum1;
}
#endif

View file

@ -23,68 +23,71 @@
#include "resample.h"
void gst_resample_nearest_s16(gst_resample_t *r);
void gst_resample_bilinear_s16(gst_resample_t *r);
void gst_resample_sinc_s16(gst_resample_t *r);
void gst_resample_sinc_slow_s16(gst_resample_t *r);
void gst_resample_sinc_ft_s16(gst_resample_t * r);
void gst_resample_nearest_s16 (gst_resample_t * r);
void gst_resample_bilinear_s16 (gst_resample_t * r);
void gst_resample_sinc_s16 (gst_resample_t * r);
void gst_resample_sinc_slow_s16 (gst_resample_t * r);
void gst_resample_sinc_ft_s16 (gst_resample_t * r);
void gst_resample_nearest_float(gst_resample_t *r);
void gst_resample_bilinear_float(gst_resample_t *r);
void gst_resample_sinc_float(gst_resample_t *r);
void gst_resample_sinc_slow_float(gst_resample_t *r);
void gst_resample_sinc_ft_float(gst_resample_t * r);
void gst_resample_nearest_float (gst_resample_t * r);
void gst_resample_bilinear_float (gst_resample_t * r);
void gst_resample_sinc_float (gst_resample_t * r);
void gst_resample_sinc_slow_float (gst_resample_t * r);
void gst_resample_sinc_ft_float (gst_resample_t * r);
typedef struct functable_s functable_t;
struct functable_s {
double start;
double offset;
int len;
struct functable_s
{
double start;
double offset;
int len;
double invoffset;
double invoffset;
double scale;
double scale2;
double scale;
double scale2;
double (*func_x)(void *,double x);
double (*func_dx)(void *,double x);
double (*func_x) (void *, double x);
double (*func_dx) (void *, double x);
double (*func2_x)(void *,double x);
double (*func2_dx)(void *,double x);
double (*func2_x) (void *, double x);
double (*func2_dx) (void *, double x);
double *fx;
double *fdx;
double *fx;
double *fdx;
void *priv;
void *priv;
};
void functable_init(functable_t *t);
double functable_eval(functable_t *t,double x);
void functable_init (functable_t * t);
double functable_eval (functable_t * t, double x);
double functable_fir(functable_t *t,double x0,int n,double *data,int len);
void functable_fir2(functable_t *t,double *r0, double *r1, double x0,
int n,double *data,int len);
double functable_fir (functable_t * t, double x0, int n, double *data, int len);
void functable_fir2 (functable_t * t, double *r0, double *r1, double x0,
int n, double *data, int len);
double functable_sinc(void *p, double x);
double functable_dsinc(void *p, double x);
double functable_window_std(void *p, double x);
double functable_window_dstd(void *p, double x);
double functable_window_boxcar(void *p, double x);
double functable_window_dboxcar(void *p, double x);
double functable_sinc (void *p, double x);
double functable_dsinc (void *p, double x);
double functable_window_std (void *p, double x);
double functable_window_dstd (void *p, double x);
double functable_window_boxcar (void *p, double x);
double functable_window_dboxcar (void *p, double x);
/* math lib stuff */
void conv_double_short_table(double *dest, short *src, int n);
void conv_double_short_unroll(double *dest, short *src, int n);
void conv_double_short_ref(double *dest, short *src, int n);
void conv_double_short_table (double *dest, short *src, int n);
void conv_double_short_unroll (double *dest, short *src, int n);
void conv_double_short_ref (double *dest, short *src, int n);
#ifdef HAVE_CPU_PPC
void conv_double_short_altivec(double *dest, short *src, int n);
void conv_double_short_altivec (double *dest, short *src, int n);
#endif
void conv_short_double_ref(short *dest, double *src, int n);
void conv_short_double_ref (short *dest, double *src, int n);
#ifdef HAVE_CPU_PPC
void conv_short_double_ppcasm(short *dest, double *src, int n);
void conv_short_double_ppcasm (short *dest, double *src, int n);
#endif
#ifdef HAVE_CPU_PPC
@ -98,12 +101,12 @@ void conv_short_double_ppcasm(short *dest, double *src, int n);
#define conv_double_float conv_double_float_ref
#define conv_float_double conv_float_double_ref
void conv_double_short_dstr(double *dest, short *src, int n, int dstr);
void conv_short_double_sstr(short *dest, double *src, int n, int dstr);
void conv_double_short_dstr (double *dest, short *src, int n, int dstr);
void conv_short_double_sstr (short *dest, double *src, int n, int dstr);
void conv_double_float_ref(double *dest, float *src, int n);
void conv_float_double_ref(float *dest, double *src, int n);
void conv_double_float_dstr(double *dest, float *src, int n, int dstr);
void conv_float_double_sstr(float *dest, double *src, int n, int sstr);
void conv_double_float_ref (double *dest, float *src, int n);
void conv_float_double_ref (float *dest, double *src, int n);
void conv_double_float_dstr (double *dest, float *src, int n, int dstr);
void conv_float_double_sstr (float *dest, double *src, int n, int sstr);
#endif /* __PRIVATE_H__ */

File diff suppressed because it is too large Load diff

View file

@ -21,76 +21,78 @@
#ifndef __GST_RESAMPLE_H__
#define __GST_RESAMPLE_H__
typedef enum {
GST_RESAMPLE_NEAREST = 0,
GST_RESAMPLE_BILINEAR,
GST_RESAMPLE_SINC_SLOW,
GST_RESAMPLE_SINC,
typedef enum
{
GST_RESAMPLE_NEAREST = 0,
GST_RESAMPLE_BILINEAR,
GST_RESAMPLE_SINC_SLOW,
GST_RESAMPLE_SINC,
} gst_resample_method;
typedef enum {
GST_RESAMPLE_S16 = 0,
GST_RESAMPLE_FLOAT
typedef enum
{
GST_RESAMPLE_S16 = 0,
GST_RESAMPLE_FLOAT
} gst_resample_format;
typedef struct gst_resample_s gst_resample_t;
struct gst_resample_s {
/* parameters */
struct gst_resample_s
{
/* parameters */
gst_resample_method method;
int channels;
int verbose;
gst_resample_format format;
gst_resample_method method;
int channels;
int verbose;
gst_resample_format format;
int filter_length;
int filter_length;
double i_rate;
double o_rate;
double i_rate;
double o_rate;
void *priv;
void *priv;
void *(*get_buffer)(void *priv, unsigned int size);
void *(*get_buffer) (void *priv, unsigned int size);
/* internal parameters */
/* internal parameters */
double halftaps;
double halftaps;
/* filter state */
/* filter state */
void *buffer;
int buffer_len;
void *buffer;
int buffer_len;
double i_start;
double o_start;
double i_start;
double o_start;
double i_start_buf;
double i_end_buf;
double i_start_buf;
double i_end_buf;
double i_inc;
double o_inc;
double i_inc;
double o_inc;
double i_end;
double o_end;
double i_end;
double o_end;
int i_samples;
int o_samples;
int i_samples;
int o_samples;
void *i_buf, *o_buf;
void *i_buf, *o_buf;
double acc[10];
double acc[10];
/* methods */
void (*scale)(gst_resample_t *r);
/* methods */
void (*scale) (gst_resample_t * r);
double ack;
double ack;
};
void gst_resample_init(gst_resample_t *r);
void gst_resample_init (gst_resample_t * r);
void gst_resample_reinit(gst_resample_t *r);
void gst_resample_reinit (gst_resample_t * r);
void gst_resample_scale(gst_resample_t *r, void *i_buf, unsigned int size);
void gst_resample_scale (gst_resample_t * r, void *i_buf, unsigned int size);
#endif /* __GST_RESAMPLE_H__ */

View file

@ -16,337 +16,360 @@
/*#define test_func(x) sin(2*M_PI*(x)*(x)*1000) */
#define test_func(x) sin(2*M_PI*(x)*(x)*12000)
short i_buf[I_RATE*2*2];
short o_buf[O_RATE*2*2];
short i_buf[I_RATE * 2 * 2];
short o_buf[O_RATE * 2 * 2];
static int i_offset;
static int o_offset;
FILE *out;
void test_res1(void);
void test_res2(void);
void test_res3(void);
void test_res4(void);
void test_res5(void);
void test_res6(void);
void test_res7(void);
void test_res1 (void);
void test_res2 (void);
void test_res3 (void);
void test_res4 (void);
void test_res5 (void);
void test_res6 (void);
void test_res7 (void);
int main(int argc,char *argv[])
int
main (int argc, char *argv[])
{
out = fopen("out","w");
out = fopen ("out", "w");
test_res7();
test_res7 ();
return 0;
return 0;
}
void *get_buffer(void *priv, unsigned int size)
void *
get_buffer (void *priv, unsigned int size)
{
void *ret;
ret = ((void *)o_buf) + o_offset;
o_offset += size;
return ret;
void *ret;
ret = ((void *) o_buf) + o_offset;
o_offset += size;
return ret;
}
struct timeval start_time;
void start_timer(void)
void
start_timer (void)
{
gettimeofday(&start_time,NULL);
/*printf("start %ld.%06ld\n",start_time.tv_sec,start_time.tv_usec); */
gettimeofday (&start_time, NULL);
/*printf("start %ld.%06ld\n",start_time.tv_sec,start_time.tv_usec); */
}
void end_timer(void)
void
end_timer (void)
{
struct timeval end_time;
double diff;
struct timeval end_time;
double diff;
gettimeofday(&end_time,NULL);
/*printf("end %ld.%06ld\n",end_time.tv_sec,end_time.tv_usec); */
diff = (end_time.tv_sec - start_time.tv_sec) +
1e-6*(end_time.tv_usec - start_time.tv_usec);
gettimeofday (&end_time, NULL);
/*printf("end %ld.%06ld\n",end_time.tv_sec,end_time.tv_usec); */
diff = (end_time.tv_sec - start_time.tv_sec) +
1e-6 * (end_time.tv_usec - start_time.tv_usec);
printf("time %g\n",diff);
printf ("time %g\n", diff);
}
void test_res1(void)
void
test_res1 (void)
{
resample_t *r;
int i;
double sum10k,sum22k;
double f;
int n10k,n22k;
double x;
resample_t *r;
int i;
double sum10k, sum22k;
double f;
int n10k, n22k;
double x;
for(i=0;i<I_RATE;i++){
i_buf[i*2+0] = rint(AMP * test_func((double)i/I_RATE));
/*i_buf[i*2+1] = rint(AMP * test_func((double)i/I_RATE)); */
i_buf[i*2+1] = (i<1000)?AMP:0;
}
for (i = 0; i < I_RATE; i++) {
i_buf[i * 2 + 0] = rint (AMP * test_func ((double) i / I_RATE));
/*i_buf[i*2+1] = rint(AMP * test_func((double)i/I_RATE)); */
i_buf[i * 2 + 1] = (i < 1000) ? AMP : 0;
}
r = malloc(sizeof(resample_t));
memset(r,0,sizeof(resample_t));
r = malloc (sizeof (resample_t));
memset (r, 0, sizeof (resample_t));
r->i_rate = I_RATE;
r->o_rate = O_RATE;
/*r->method = RESAMPLE_SINC_SLOW; */
r->method = RESAMPLE_SINC;
r->channels = 2;
/*r->verbose = 1; */
r->filter_length = 64;
r->get_buffer = get_buffer;
r->i_rate = I_RATE;
r->o_rate = O_RATE;
/*r->method = RESAMPLE_SINC_SLOW; */
r->method = RESAMPLE_SINC;
r->channels = 2;
/*r->verbose = 1; */
r->filter_length = 64;
r->get_buffer = get_buffer;
resample_init(r);
resample_init (r);
start_timer();
start_timer ();
#define blocked
#ifdef blocked
for(i=0;i+256<I_RATE;i+=256){
resample_scale(r,i_buf+i*2,256*2*2);
}
if(I_RATE-i){
resample_scale(r,i_buf+i*2,(I_RATE-i)*2*2);
}
for (i = 0; i + 256 < I_RATE; i += 256) {
resample_scale (r, i_buf + i * 2, 256 * 2 * 2);
}
if (I_RATE - i) {
resample_scale (r, i_buf + i * 2, (I_RATE - i) * 2 * 2);
}
#else
resample_scale(r,i_buf,I_RATE*2*2);
resample_scale (r, i_buf, I_RATE * 2 * 2);
#endif
end_timer();
end_timer ();
for(i=0;i<O_RATE;i++){
f = AMP*test_func((double)i/O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
fprintf(out,"%d %d %d %g %g\n",i,
o_buf[2*i+0],o_buf[2*i+1],
f,o_buf[2*i+0]-f);
}
for (i = 0; i < O_RATE; i++) {
f = AMP * test_func ((double) i / O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
fprintf (out, "%d %d %d %g %g\n", i,
o_buf[2 * i + 0], o_buf[2 * i + 1], f, o_buf[2 * i + 0] - f);
}
sum10k=0;
sum22k=0;
n10k=0;
n22k=0;
for(i=0;i<O_RATE;i++){
f = AMP*test_func((double)i/O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
x = o_buf[2*i+0]-f;
if(((0.5*i)/O_RATE*I_RATE)<10000){
sum10k += x*x;
n10k++;
}
if(((0.5*i)/O_RATE*I_RATE)<22050){
sum22k += x*x;
n22k++;
}
}
printf("average error 10k=%g 22k=%g\n",
sqrt(sum10k/n10k),
sqrt(sum22k/n22k));
sum10k = 0;
sum22k = 0;
n10k = 0;
n22k = 0;
for (i = 0; i < O_RATE; i++) {
f = AMP * test_func ((double) i / O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
x = o_buf[2 * i + 0] - f;
if (((0.5 * i) / O_RATE * I_RATE) < 10000) {
sum10k += x * x;
n10k++;
}
if (((0.5 * i) / O_RATE * I_RATE) < 22050) {
sum22k += x * x;
n22k++;
}
}
printf ("average error 10k=%g 22k=%g\n",
sqrt (sum10k / n10k), sqrt (sum22k / n22k));
}
void test_res2(void)
void
test_res2 (void)
{
functable_t *t;
int i;
double x;
double f1,f2;
functable_t *t;
int i;
double x;
double f1, f2;
t = malloc(sizeof(*t));
memset(t,0,sizeof(*t));
t = malloc (sizeof (*t));
memset (t, 0, sizeof (*t));
t->start = -50.0;
t->offset = 1;
t->len = 100;
t->start = -50.0;
t->offset = 1;
t->len = 100;
t->func_x = functable_sinc;
t->func_dx = functable_dsinc;
t->func_x = functable_sinc;
t->func_dx = functable_dsinc;
functable_init(t);
functable_init (t);
for(i=0;i<1000;i++){
x = -50.0 + 0.1 * i;
f1 = functable_sinc(NULL,x);
f2 = functable_eval(t,x);
fprintf(out,"%d %g %g %g\n",i,f1,f2,f1-f2);
}
for (i = 0; i < 1000; i++) {
x = -50.0 + 0.1 * i;
f1 = functable_sinc (NULL, x);
f2 = functable_eval (t, x);
fprintf (out, "%d %g %g %g\n", i, f1, f2, f1 - f2);
}
}
void test_res3(void)
void
test_res3 (void)
{
functable_t *t;
int i;
double x;
double f1,f2;
int n = 1;
functable_t *t;
int i;
double x;
double f1, f2;
int n = 1;
t = malloc(sizeof(*t));
memset(t,0,sizeof(*t));
t = malloc (sizeof (*t));
memset (t, 0, sizeof (*t));
t->start = -50.0;
t->offset = 1.0 / n;
t->len = 100 * n;
t->start = -50.0;
t->offset = 1.0 / n;
t->len = 100 * n;
t->func_x = functable_sinc;
t->func_dx = functable_dsinc;
t->func_x = functable_sinc;
t->func_dx = functable_dsinc;
t->func2_x = functable_window_std;
t->func2_dx = functable_window_dstd;
t->func2_x = functable_window_std;
t->func2_dx = functable_window_dstd;
t->scale = 1.0;
t->scale2 = 1.0 / (M_PI * 16);
t->scale = 1.0;
t->scale2 = 1.0 / (M_PI * 16);
functable_init(t);
functable_init (t);
for(i=0;i<1000 * n;i++){
x = -50.0 + 0.1/n * i;
f1 = functable_sinc(NULL,t->scale * x) *
functable_window_std(NULL,t->scale2 * x);
f2 = functable_eval(t,x);
fprintf(out,"%d %g %g %g\n",i,f1,f2,f2-f1);
}
for (i = 0; i < 1000 * n; i++) {
x = -50.0 + 0.1 / n * i;
f1 = functable_sinc (NULL, t->scale * x) *
functable_window_std (NULL, t->scale2 * x);
f2 = functable_eval (t, x);
fprintf (out, "%d %g %g %g\n", i, f1, f2, f2 - f1);
}
}
double sinc_poly(double x)
double
sinc_poly (double x)
{
#define INV3FAC 1.66666666666666666e-1
#define INV5FAC 8.33333333333333333e-3
#define INV7FAC 1.984126984e-4
#define INV9FAC 2.755731922e-6
#define INV11FAC 2.505210839e-8
double x2 = x * x;
double x2 = x * x;
return 1
- x2 * INV3FAC
+ x2 * x2 * INV5FAC
- x2 * x2 * x2 * INV7FAC;
/*+ x2 * x2 * x2 * x2 * INV9FAC */
return 1 - x2 * INV3FAC + x2 * x2 * INV5FAC - x2 * x2 * x2 * INV7FAC;
/*+ x2 * x2 * x2 * x2 * INV9FAC */
/*- x2 * x2 * x2 * x2 * x2 * INV11FAC; */
}
void test_res4(void)
void
test_res4 (void)
{
int i;
double x,f1,f2;
int i;
double x, f1, f2;
for(i=1;i<100;i++){
x = 0.01 * i;
f1 = 1 - sin(x)/x;
f2 = 1 - sinc_poly(x);
fprintf(out,"%g %.20g %.20g %.20g\n",x,f1,f2,f2-f1);
}
for (i = 1; i < 100; i++) {
x = 0.01 * i;
f1 = 1 - sin (x) / x;
f2 = 1 - sinc_poly (x);
fprintf (out, "%g %.20g %.20g %.20g\n", x, f1, f2, f2 - f1);
}
}
void test_res5(void)
void
test_res5 (void)
{
int i;
double sum;
int i;
double sum;
start_timer();
sum = 0;
for(i=0;i<I_RATE;i++){
sum += i_buf[i*2];
}
end_timer();
i_buf[0] = sum;
start_timer ();
sum = 0;
for (i = 0; i < I_RATE; i++) {
sum += i_buf[i * 2];
}
end_timer ();
i_buf[0] = sum;
}
void short_to_double(double *d,short *x) { *d = *x; }
void short_to_float(float *f,short *x) { *f = *x; }
void float_to_double(double *f,float *x) { *f = *x; }
void double_to_short(short *f,double *x) { *f = *x; }
void
short_to_double (double *d, short *x)
{
*d = *x;
}
void
short_to_float (float *f, short *x)
{
*f = *x;
}
void
float_to_double (double *f, float *x)
{
*f = *x;
}
void
double_to_short (short *f, double *x)
{
*f = *x;
}
double res6_tmp[1000];
void test_res6(void)
void
test_res6 (void)
{
int i;
int i;
for(i=0;i<I_RATE;i++){
i_buf[i] = rint(AMP * test_func((double)i/I_RATE));
}
for (i = 0; i < I_RATE; i++) {
i_buf[i] = rint (AMP * test_func ((double) i / I_RATE));
}
conv_double_short_ref(res6_tmp,i_buf,1000);
for(i=0;i<1000;i++){
res6_tmp[i] *= 3.0;
}
conv_short_double_ppcasm(o_buf,res6_tmp,1000);
conv_double_short_ref (res6_tmp, i_buf, 1000);
for (i = 0; i < 1000; i++) {
res6_tmp[i] *= 3.0;
}
conv_short_double_ppcasm (o_buf, res6_tmp, 1000);
for(i=0;i<1000;i++){
fprintf(out,"%d %d %g %d\n",i,i_buf[i],res6_tmp[i],o_buf[i]);
}
for (i = 0; i < 1000; i++) {
fprintf (out, "%d %d %g %d\n", i, i_buf[i], res6_tmp[i], o_buf[i]);
}
}
void test_res7(void)
void
test_res7 (void)
{
resample_t *r;
int i;
double sum10k,sum22k;
double f;
int n10k,n22k;
double x;
resample_t *r;
int i;
double sum10k, sum22k;
double f;
int n10k, n22k;
double x;
for(i=0;i<I_RATE;i++){
i_buf[i] = rint(AMP * test_func((double)i/I_RATE));
}
for (i = 0; i < I_RATE; i++) {
i_buf[i] = rint (AMP * test_func ((double) i / I_RATE));
}
r = malloc(sizeof(resample_t));
memset(r,0,sizeof(resample_t));
r = malloc (sizeof (resample_t));
memset (r, 0, sizeof (resample_t));
r->i_rate = I_RATE;
r->o_rate = O_RATE;
/*r->method = RESAMPLE_SINC_SLOW; */
r->method = RESAMPLE_SINC;
r->channels = 1;
/*r->verbose = 1; */
r->filter_length = 64;
r->get_buffer = get_buffer;
r->i_rate = I_RATE;
r->o_rate = O_RATE;
/*r->method = RESAMPLE_SINC_SLOW; */
r->method = RESAMPLE_SINC;
r->channels = 1;
/*r->verbose = 1; */
r->filter_length = 64;
r->get_buffer = get_buffer;
resample_init(r);
resample_init (r);
start_timer();
start_timer ();
#define blocked
#ifdef blocked
for(i=0;i+256<I_RATE;i+=256){
resample_scale(r,i_buf+i,256*2);
}
if(I_RATE-i){
resample_scale(r,i_buf+i,(I_RATE-i)*2);
}
for (i = 0; i + 256 < I_RATE; i += 256) {
resample_scale (r, i_buf + i, 256 * 2);
}
if (I_RATE - i) {
resample_scale (r, i_buf + i, (I_RATE - i) * 2);
}
#else
resample_scale(r,i_buf,I_RATE*2);
resample_scale (r, i_buf, I_RATE * 2);
#endif
end_timer();
end_timer ();
for(i=0;i<O_RATE;i++){
f = AMP*test_func((double)i/O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
fprintf(out,"%d %d %d %g %g\n",i,
o_buf[i],0,
f,o_buf[i]-f);
}
for (i = 0; i < O_RATE; i++) {
f = AMP * test_func ((double) i / O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
fprintf (out, "%d %d %d %g %g\n", i, o_buf[i], 0, f, o_buf[i] - f);
}
sum10k=0;
sum22k=0;
n10k=0;
n22k=0;
for(i=0;i<O_RATE;i++){
f = AMP*test_func((double)i/O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
x = o_buf[i]-f;
if(((0.5*i)/O_RATE*I_RATE)<10000){
sum10k += x*x;
n10k++;
}
if(((0.5*i)/O_RATE*I_RATE)<22050){
sum22k += x*x;
n22k++;
}
}
printf("average error 10k=%g 22k=%g\n",
sqrt(sum10k/n10k),
sqrt(sum22k/n22k));
sum10k = 0;
sum22k = 0;
n10k = 0;
n22k = 0;
for (i = 0; i < O_RATE; i++) {
f = AMP * test_func ((double) i / O_RATE);
/*f = rint(AMP*test_func((double)i/O_RATE)); */
x = o_buf[i] - f;
if (((0.5 * i) / O_RATE * I_RATE) < 10000) {
sum10k += x * x;
n10k++;
}
if (((0.5 * i) / O_RATE * I_RATE) < 22050) {
sum22k += x * x;
n22k++;
}
}
printf ("average error 10k=%g 22k=%g\n",
sqrt (sum10k / n10k), sqrt (sum22k / n22k));
}

View file

@ -66,29 +66,29 @@
#define GST_RIFF_FCCH_MSVC GST_MAKE_FOURCC ('M','S','V','C')
/* INFO types - see http://www.saettler.com/RIFFMCI/riffmci.html */
#define GST_RIFF_INFO_IARL GST_MAKE_FOURCC ('I','A','R','L') /* location */
#define GST_RIFF_INFO_IART GST_MAKE_FOURCC ('I','A','R','T') /* artist */
#define GST_RIFF_INFO_ICMS GST_MAKE_FOURCC ('I','C','M','S') /* commissioned */
#define GST_RIFF_INFO_ICMT GST_MAKE_FOURCC ('I','C','M','T') /* comment */
#define GST_RIFF_INFO_ICOP GST_MAKE_FOURCC ('I','C','O','P') /* copyright */
#define GST_RIFF_INFO_ICRD GST_MAKE_FOURCC ('I','C','R','D') /* creation date */
#define GST_RIFF_INFO_ICRP GST_MAKE_FOURCC ('I','C','R','P') /* cropped */
#define GST_RIFF_INFO_IDIM GST_MAKE_FOURCC ('I','D','I','M') /* dimensions */
#define GST_RIFF_INFO_IDPI GST_MAKE_FOURCC ('I','D','P','I') /* dots-per-inch */
#define GST_RIFF_INFO_IENG GST_MAKE_FOURCC ('I','E','N','G') /* engineer(s) */
#define GST_RIFF_INFO_IGNR GST_MAKE_FOURCC ('I','G','N','R') /* genre */
#define GST_RIFF_INFO_IKEY GST_MAKE_FOURCC ('I','K','E','Y') /* keywords */
#define GST_RIFF_INFO_ILGT GST_MAKE_FOURCC ('I','L','G','T') /* lightness */
#define GST_RIFF_INFO_IMED GST_MAKE_FOURCC ('I','M','E','D') /* medium */
#define GST_RIFF_INFO_INAM GST_MAKE_FOURCC ('I','N','A','M') /* name */
#define GST_RIFF_INFO_IPLT GST_MAKE_FOURCC ('I','P','L','T') /* palette setting */
#define GST_RIFF_INFO_IPRD GST_MAKE_FOURCC ('I','P','R','D') /* product */
#define GST_RIFF_INFO_ISBJ GST_MAKE_FOURCC ('I','S','B','J') /* subject */
#define GST_RIFF_INFO_ISFT GST_MAKE_FOURCC ('I','S','F','T') /* software */
#define GST_RIFF_INFO_ISHP GST_MAKE_FOURCC ('I','S','H','P') /* sharpness */
#define GST_RIFF_INFO_ISRC GST_MAKE_FOURCC ('I','S','R','C') /* source */
#define GST_RIFF_INFO_ISRF GST_MAKE_FOURCC ('I','S','R','F') /* source form */
#define GST_RIFF_INFO_ITCH GST_MAKE_FOURCC ('I','T','C','H') /* technician(s) */
#define GST_RIFF_INFO_IARL GST_MAKE_FOURCC ('I','A','R','L') /* location */
#define GST_RIFF_INFO_IART GST_MAKE_FOURCC ('I','A','R','T') /* artist */
#define GST_RIFF_INFO_ICMS GST_MAKE_FOURCC ('I','C','M','S') /* commissioned */
#define GST_RIFF_INFO_ICMT GST_MAKE_FOURCC ('I','C','M','T') /* comment */
#define GST_RIFF_INFO_ICOP GST_MAKE_FOURCC ('I','C','O','P') /* copyright */
#define GST_RIFF_INFO_ICRD GST_MAKE_FOURCC ('I','C','R','D') /* creation date */
#define GST_RIFF_INFO_ICRP GST_MAKE_FOURCC ('I','C','R','P') /* cropped */
#define GST_RIFF_INFO_IDIM GST_MAKE_FOURCC ('I','D','I','M') /* dimensions */
#define GST_RIFF_INFO_IDPI GST_MAKE_FOURCC ('I','D','P','I') /* dots-per-inch */
#define GST_RIFF_INFO_IENG GST_MAKE_FOURCC ('I','E','N','G') /* engineer(s) */
#define GST_RIFF_INFO_IGNR GST_MAKE_FOURCC ('I','G','N','R') /* genre */
#define GST_RIFF_INFO_IKEY GST_MAKE_FOURCC ('I','K','E','Y') /* keywords */
#define GST_RIFF_INFO_ILGT GST_MAKE_FOURCC ('I','L','G','T') /* lightness */
#define GST_RIFF_INFO_IMED GST_MAKE_FOURCC ('I','M','E','D') /* medium */
#define GST_RIFF_INFO_INAM GST_MAKE_FOURCC ('I','N','A','M') /* name */
#define GST_RIFF_INFO_IPLT GST_MAKE_FOURCC ('I','P','L','T') /* palette setting */
#define GST_RIFF_INFO_IPRD GST_MAKE_FOURCC ('I','P','R','D') /* product */
#define GST_RIFF_INFO_ISBJ GST_MAKE_FOURCC ('I','S','B','J') /* subject */
#define GST_RIFF_INFO_ISFT GST_MAKE_FOURCC ('I','S','F','T') /* software */
#define GST_RIFF_INFO_ISHP GST_MAKE_FOURCC ('I','S','H','P') /* sharpness */
#define GST_RIFF_INFO_ISRC GST_MAKE_FOURCC ('I','S','R','C') /* source */
#define GST_RIFF_INFO_ISRF GST_MAKE_FOURCC ('I','S','R','F') /* source form */
#define GST_RIFF_INFO_ITCH GST_MAKE_FOURCC ('I','T','C','H') /* technician(s) */
/*********Chunk Names***************/
#define GST_RIFF_FF00 GST_MAKE_FOURCC (0xFF,0xFF,0x00,0x00)
@ -167,7 +167,7 @@
#define GST_RIFF_v422 GST_MAKE_FOURCC ('v', '4', '2', '2')
#define GST_RIFF_V422 GST_MAKE_FOURCC ('V', '4', '2', '2')
#define GST_RIFF_mvi1 GST_MAKE_FOURCC ('m', 'v', 'i', '1')
#define GST_RIFF_MPIX GST_MAKE_FOURCC (0x04,0x00, 'i', '1') /* MotionPixels munged their id */
#define GST_RIFF_MPIX GST_MAKE_FOURCC (0x04,0x00, 'i', '1') /* MotionPixels munged their id */
#define GST_RIFF_AURA GST_MAKE_FOURCC ('A', 'U', 'R', 'A')
#define GST_RIFF_DMB1 GST_MAKE_FOURCC ('D', 'M', 'B', '1')
#define GST_RIFF_dmb1 GST_MAKE_FOURCC ('d', 'm', 'b', '1')
@ -203,7 +203,7 @@
#define GST_RIFF_rpza GST_MAKE_FOURCC ('r', 'p', 'z', 'a')
/* And this here's the mistakes that need to be supported */
#define GST_RIFF_azpr GST_MAKE_FOURCC ('a', 'z', 'p', 'r') /* recognize Apple's rpza mangled? */
#define GST_RIFF_azpr GST_MAKE_FOURCC ('a', 'z', 'p', 'r') /* recognize Apple's rpza mangled? */
/*********** FND in MJPG **********/
#define GST_RIFF_ISFT GST_MAKE_FOURCC ('I', 'S', 'F', 'T')
@ -216,26 +216,28 @@
#define GST_RIFF_rec GST_MAKE_FOURCC ('r', 'e', 'c', ' ')
/* common data structures */
typedef struct _gst_riff_strh {
guint32 type; /* stream type */
guint32 fcc_handler; /* fcc_handler */
typedef struct _gst_riff_strh
{
guint32 type; /* stream type */
guint32 fcc_handler; /* fcc_handler */
guint32 flags;
/* flags values */
#define GST_RIFF_STRH_DISABLED 0x000000001
#define GST_RIFF_STRH_VIDEOPALCHANGES 0x000010000
guint32 priority;
guint32 init_frames; /* initial frames (???) */
guint32 init_frames; /* initial frames (???) */
guint32 scale;
guint32 rate;
guint32 start;
guint32 length;
guint32 bufsize; /* suggested buffer size */
guint32 bufsize; /* suggested buffer size */
guint32 quality;
guint32 samplesize;
/* XXX 16 bytes ? */
} gst_riff_strh;
typedef struct _gst_riff_strf_vids { /* == BitMapInfoHeader */
typedef struct _gst_riff_strf_vids
{ /* == BitMapInfoHeader */
guint32 size;
guint32 width;
guint32 height;
@ -245,13 +247,14 @@ typedef struct _gst_riff_strf_vids { /* == BitMapInfoHeader */
guint32 image_size;
guint32 xpels_meter;
guint32 ypels_meter;
guint32 num_colors; /* used colors */
guint32 imp_colors; /* important colors */
guint32 num_colors; /* used colors */
guint32 imp_colors; /* important colors */
/* may be more for some codecs */
} gst_riff_strf_vids;
typedef struct _gst_riff_strf_auds { /* == WaveHeader (?) */
typedef struct _gst_riff_strf_auds
{ /* == WaveHeader (?) */
guint16 format;
/**** from public Microsoft RIFF docs ******/
#define GST_RIFF_WAVE_FORMAT_UNKNOWN (0x0000)
@ -290,7 +293,8 @@ typedef struct _gst_riff_strf_auds { /* == WaveHeader (?) */
guint16 size;
} gst_riff_strf_auds;
typedef struct _gst_riff_strf_iavs {
typedef struct _gst_riff_strf_iavs
{
guint32 DVAAuxSrc;
guint32 DVAAuxCtl;
guint32 DVAAuxSrc1;
@ -301,7 +305,8 @@ typedef struct _gst_riff_strf_iavs {
guint32 DVReserved2;
} gst_riff_strf_iavs;
typedef struct _gst_riff_index_entry {
typedef struct _gst_riff_index_entry
{
guint32 id;
guint32 flags;
#define GST_RIFF_IF_LIST (0x00000001L)
@ -312,7 +317,8 @@ typedef struct _gst_riff_index_entry {
guint32 size;
} gst_riff_index_entry;
typedef struct _gst_riff_dmlh {
typedef struct _gst_riff_dmlh
{
guint32 totalframes;
} gst_riff_dmlh;

View file

@ -27,198 +27,183 @@
#include "riff-media.h"
GstCaps *
gst_riff_create_video_caps (guint32 codec_fcc,
gst_riff_strh *strh,
gst_riff_strf_vids *strf,
char **codec_name)
gst_riff_create_video_caps (guint32 codec_fcc,
gst_riff_strh * strh, gst_riff_strf_vids * strf, char **codec_name)
{
GstCaps *caps = NULL;
switch (codec_fcc) {
case GST_MAKE_FOURCC('I','4','2','0'):
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
caps = gst_caps_new_simple ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, codec_fcc,
NULL);
"format", GST_TYPE_FOURCC, codec_fcc, NULL);
if (codec_name)
*codec_name = g_strdup ("Raw, uncompressed I420");
*codec_name = g_strdup ("Raw, uncompressed I420");
break;
case GST_MAKE_FOURCC('Y','U','Y','2'):
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
caps = gst_caps_new_simple ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, codec_fcc,
NULL);
"format", GST_TYPE_FOURCC, codec_fcc, NULL);
if (codec_name)
*codec_name = g_strdup ("Raw, uncompressed YUV 4:2:2");
*codec_name = g_strdup ("Raw, uncompressed YUV 4:2:2");
break;
case GST_MAKE_FOURCC('M','J','P','G'): /* YUY2 MJPEG */
case GST_MAKE_FOURCC ('M', 'J', 'P', 'G'): /* YUY2 MJPEG */
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
if (codec_name)
*codec_name = g_strdup ("Motion JPEG");
*codec_name = g_strdup ("Motion JPEG");
break;
case GST_MAKE_FOURCC('J','P','E','G'): /* generic (mostly RGB) MJPEG */
case GST_MAKE_FOURCC ('J', 'P', 'E', 'G'): /* generic (mostly RGB) MJPEG */
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
if (codec_name)
*codec_name = g_strdup ("JPEG Still Image");
*codec_name = g_strdup ("JPEG Still Image");
break;
case GST_MAKE_FOURCC('P','I','X','L'): /* Miro/Pinnacle fourccs */
case GST_MAKE_FOURCC('V','I','X','L'): /* Miro/Pinnacle fourccs */
case GST_MAKE_FOURCC ('P', 'I', 'X', 'L'): /* Miro/Pinnacle fourccs */
case GST_MAKE_FOURCC ('V', 'I', 'X', 'L'): /* Miro/Pinnacle fourccs */
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
if (codec_name)
*codec_name = g_strdup ("Miro/Pinnacle Video XL");
*codec_name = g_strdup ("Miro/Pinnacle Video XL");
break;
case GST_MAKE_FOURCC('H','F','Y','U'):
caps = gst_caps_new_simple ( "video/x-huffyuv", NULL);
case GST_MAKE_FOURCC ('H', 'F', 'Y', 'U'):
caps = gst_caps_new_simple ("video/x-huffyuv", NULL);
if (codec_name)
*codec_name = g_strdup ("Huffman Lossless Codec");
*codec_name = g_strdup ("Huffman Lossless Codec");
break;
case GST_MAKE_FOURCC('M','P','E','G'):
case GST_MAKE_FOURCC('M','P','G','I'):
case GST_MAKE_FOURCC ('M', 'P', 'E', 'G'):
case GST_MAKE_FOURCC ('M', 'P', 'G', 'I'):
caps = gst_caps_new_simple ("video/mpeg",
"systemstream", G_TYPE_BOOLEAN, FALSE,
"mpegversion", G_TYPE_BOOLEAN, 1,
NULL);
"systemstream", G_TYPE_BOOLEAN, FALSE,
"mpegversion", G_TYPE_BOOLEAN, 1, NULL);
if (codec_name)
*codec_name = g_strdup ("MPEG video");
*codec_name = g_strdup ("MPEG video");
break;
case GST_MAKE_FOURCC('H','2','6','3'):
case GST_MAKE_FOURCC ('H', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
*codec_name = g_strdup ("ITU H.26n");
*codec_name = g_strdup ("ITU H.26n");
break;
case GST_MAKE_FOURCC('i','2','6','3'):
case GST_MAKE_FOURCC ('i', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
*codec_name = g_strdup ("ITU H.263");
*codec_name = g_strdup ("ITU H.263");
break;
case GST_MAKE_FOURCC('L','2','6','3'):
case GST_MAKE_FOURCC ('L', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
*codec_name = g_strdup ("Lead H.263");
*codec_name = g_strdup ("Lead H.263");
break;
case GST_MAKE_FOURCC('M','2','6','3'):
case GST_MAKE_FOURCC ('M', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
*codec_name = g_strdup ("Microsoft H.263");
*codec_name = g_strdup ("Microsoft H.263");
break;
case GST_MAKE_FOURCC('V','D','O','W'):
case GST_MAKE_FOURCC ('V', 'D', 'O', 'W'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
*codec_name = g_strdup ("VDOLive");
*codec_name = g_strdup ("VDOLive");
break;
case GST_MAKE_FOURCC('V','I','V','O'):
case GST_MAKE_FOURCC ('V', 'I', 'V', 'O'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
*codec_name = g_strdup ("Vivo H.263");
*codec_name = g_strdup ("Vivo H.263");
break;
case GST_MAKE_FOURCC('x','2','6','3'):
case GST_MAKE_FOURCC ('x', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
*codec_name = g_strdup ("Xirlink H.263");
*codec_name = g_strdup ("Xirlink H.263");
break;
case GST_MAKE_FOURCC('D','I','V','3'):
case GST_MAKE_FOURCC ('D', 'I', 'V', '3'):
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 3,
NULL);
"divxversion", G_TYPE_INT, 3, NULL);
if (codec_name)
*codec_name = g_strdup ("DivX MPEG-4 Version 3");
*codec_name = g_strdup ("DivX MPEG-4 Version 3");
break;
case GST_MAKE_FOURCC('D','I','V','4'):
case GST_MAKE_FOURCC ('D', 'I', 'V', '4'):
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 4,
NULL);
"divxversion", G_TYPE_INT, 4, NULL);
if (codec_name)
*codec_name = g_strdup ("DivX MPEG-4 Version 4");
*codec_name = g_strdup ("DivX MPEG-4 Version 4");
break;
case GST_MAKE_FOURCC('d','i','v','x'):
case GST_MAKE_FOURCC('D','I','V','X'):
case GST_MAKE_FOURCC('D','X','5','0'):
case GST_MAKE_FOURCC('D','I','V','5'):
case GST_MAKE_FOURCC ('d', 'i', 'v', 'x'):
case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
case GST_MAKE_FOURCC ('D', 'X', '5', '0'):
case GST_MAKE_FOURCC ('D', 'I', 'V', '5'):
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 5,
NULL);
"divxversion", G_TYPE_INT, 5, NULL);
if (codec_name)
*codec_name = g_strdup ("DivX MPEG-4 Version 5");
*codec_name = g_strdup ("DivX MPEG-4 Version 5");
break;
case GST_MAKE_FOURCC('X','V','I','D'):
case GST_MAKE_FOURCC('x','v','i','d'):
case GST_MAKE_FOURCC ('X', 'V', 'I', 'D'):
case GST_MAKE_FOURCC ('x', 'v', 'i', 'd'):
caps = gst_caps_new_simple ("video/x-xvid", NULL);
if (codec_name)
*codec_name = g_strdup ("XVID MPEG-4");
*codec_name = g_strdup ("XVID MPEG-4");
break;
case GST_MAKE_FOURCC('M','P','G','4'):
case GST_MAKE_FOURCC ('M', 'P', 'G', '4'):
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 41,
NULL);
"msmpegversion", G_TYPE_INT, 41, NULL);
if (codec_name)
*codec_name = g_strdup ("Microsoft MPEG-4 4.1");
*codec_name = g_strdup ("Microsoft MPEG-4 4.1");
break;
case GST_MAKE_FOURCC('M','P','4','2'):
case GST_MAKE_FOURCC ('M', 'P', '4', '2'):
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 42,
NULL);
"msmpegversion", G_TYPE_INT, 42, NULL);
if (codec_name)
*codec_name = g_strdup ("Microsoft MPEG-4 4.2");
*codec_name = g_strdup ("Microsoft MPEG-4 4.2");
break;
case GST_MAKE_FOURCC('M','P','4','3'):
case GST_MAKE_FOURCC ('M', 'P', '4', '3'):
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 43,
NULL);
"msmpegversion", G_TYPE_INT, 43, NULL);
if (codec_name)
*codec_name = g_strdup ("Microsoft MPEG-4 4.3");
*codec_name = g_strdup ("Microsoft MPEG-4 4.3");
break;
case GST_MAKE_FOURCC('3','I','V','1'):
case GST_MAKE_FOURCC('3','I','V','2'):
caps = gst_caps_new_simple ( "video/x-3ivx", NULL);
case GST_MAKE_FOURCC ('3', 'I', 'V', '1'):
case GST_MAKE_FOURCC ('3', 'I', 'V', '2'):
caps = gst_caps_new_simple ("video/x-3ivx", NULL);
if (codec_name)
*codec_name = g_strdup ("3ivx");
*codec_name = g_strdup ("3ivx");
break;
case GST_MAKE_FOURCC('D','V','S','D'):
case GST_MAKE_FOURCC('d','v','s','d'):
case GST_MAKE_FOURCC ('D', 'V', 'S', 'D'):
case GST_MAKE_FOURCC ('d', 'v', 's', 'd'):
caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, FALSE,
NULL);
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
if (codec_name)
*codec_name = g_strdup ("Generic DV");
*codec_name = g_strdup ("Generic DV");
break;
case GST_MAKE_FOURCC('W','M','V','1'):
case GST_MAKE_FOURCC ('W', 'M', 'V', '1'):
caps = gst_caps_new_simple ("video/x-wmv",
"wmvversion", G_TYPE_INT, 1,
NULL);
"wmvversion", G_TYPE_INT, 1, NULL);
if (codec_name)
*codec_name = g_strdup ("Windows Media Video 7");
*codec_name = g_strdup ("Windows Media Video 7");
break;
case GST_MAKE_FOURCC('W','M','V','2'):
case GST_MAKE_FOURCC ('W', 'M', 'V', '2'):
caps = gst_caps_new_simple ("video/x-wmv",
"wmvversion", G_TYPE_INT, 2,
NULL);
"wmvversion", G_TYPE_INT, 2, NULL);
if (codec_name)
*codec_name = g_strdup ("Windows Media Video 8");
*codec_name = g_strdup ("Windows Media Video 8");
break;
case GST_MAKE_FOURCC('W','M','V','3'):
case GST_MAKE_FOURCC ('W', 'M', 'V', '3'):
caps = gst_caps_new_simple ("video/x-wmv",
"wmvversion", G_TYPE_INT, 3,
NULL);
"wmvversion", G_TYPE_INT, 3, NULL);
if (codec_name)
*codec_name = g_strdup ("Windows Media Video 9");
*codec_name = g_strdup ("Windows Media Video 9");
break;
default:
GST_WARNING ("Unkown video fourcc " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (codec_fcc));
GST_FOURCC_ARGS (codec_fcc));
return NULL;
}
@ -228,153 +213,136 @@ gst_riff_create_video_caps (guint32 codec_fcc,
gst_caps_set_simple (caps, "framerate", G_TYPE_DOUBLE, fps, NULL);
} else {
gst_caps_set_simple (caps,
"framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE,
NULL);
"framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE, NULL);
}
if (strf != NULL) {
gst_caps_set_simple (caps,
"width", G_TYPE_INT, strf->width,
"height", G_TYPE_INT, strf->height,
NULL);
"width", G_TYPE_INT, strf->width,
"height", G_TYPE_INT, strf->height, NULL);
} else {
gst_caps_set_simple (caps,
"width", GST_TYPE_INT_RANGE, 16, 4096,
"height", GST_TYPE_INT_RANGE, 16, 4096,
NULL);
"width", GST_TYPE_INT_RANGE, 16, 4096,
"height", GST_TYPE_INT_RANGE, 16, 4096, NULL);
}
return caps;
}
GstCaps *
gst_riff_create_audio_caps (guint16 codec_id,
gst_riff_strh *strh,
gst_riff_strf_auds *strf,
char **codec_name)
gst_riff_create_audio_caps (guint16 codec_id,
gst_riff_strh * strh, gst_riff_strf_auds * strf, char **codec_name)
{
GstCaps *caps = NULL;
switch (codec_id) {
case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
caps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, 3,
NULL);
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
if (codec_name)
*codec_name = g_strdup ("MPEG 1 layer 3");
*codec_name = g_strdup ("MPEG 1 layer 3");
break;
case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */
case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */
caps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, 2,
NULL);
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
if (codec_name)
*codec_name = g_strdup ("MPEG 1 layer 2");
*codec_name = g_strdup ("MPEG 1 layer 2");
break;
case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */
case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */
if (strf != NULL) {
gint ba = GUINT16_FROM_LE (strf->blockalign);
gint ch = GUINT16_FROM_LE (strf->channels);
gint ws = GUINT16_FROM_LE (strf->size);
gint ba = GUINT16_FROM_LE (strf->blockalign);
gint ch = GUINT16_FROM_LE (strf->channels);
gint ws = GUINT16_FROM_LE (strf->size);
caps = gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"width", G_TYPE_INT, (int)(ba * 8 / ch),
"depth", G_TYPE_INT, ws,
"signed", G_TYPE_BOOLEAN, ws != 8,
NULL);
caps = gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"width", G_TYPE_INT, (int) (ba * 8 / ch),
"depth", G_TYPE_INT, ws, "signed", G_TYPE_BOOLEAN, ws != 8, NULL);
} else {
caps = gst_caps_from_string ("audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"height = (int) { 8, 16 }");
caps = gst_caps_from_string ("audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, " "height = (int) { 8, 16 }");
}
if (codec_name)
*codec_name = g_strdup ("PCM WAV");
*codec_name = g_strdup ("PCM WAV");
break;
case GST_RIFF_WAVE_FORMAT_MULAW:
if (strf != NULL && strf->size != 8) {
GST_WARNING ("invalid depth (%d) of mulaw audio, overwriting.",
strf->size);
GST_WARNING ("invalid depth (%d) of mulaw audio, overwriting.",
strf->size);
}
caps = gst_caps_new_simple ("audio/x-mulaw", NULL);
if (codec_name)
*codec_name = g_strdup ("Mulaw");
*codec_name = g_strdup ("Mulaw");
break;
case GST_RIFF_WAVE_FORMAT_ALAW:
if (strf != NULL && strf->size != 8) {
GST_WARNING ("invalid depth (%d) of alaw audio, overwriting.",
strf->size);
GST_WARNING ("invalid depth (%d) of alaw audio, overwriting.",
strf->size);
}
caps = gst_caps_new_simple ("audio/x-alaw", NULL);
if (codec_name)
*codec_name = g_strdup ("Alaw");
*codec_name = g_strdup ("Alaw");
break;
case GST_RIFF_WAVE_FORMAT_VORBIS1: /* ogg/vorbis mode 1 */
case GST_RIFF_WAVE_FORMAT_VORBIS2: /* ogg/vorbis mode 2 */
case GST_RIFF_WAVE_FORMAT_VORBIS3: /* ogg/vorbis mode 3 */
case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* ogg/vorbis mode 1+ */
case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* ogg/vorbis mode 2+ */
case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* ogg/vorbis mode 3+ */
case GST_RIFF_WAVE_FORMAT_VORBIS1: /* ogg/vorbis mode 1 */
case GST_RIFF_WAVE_FORMAT_VORBIS2: /* ogg/vorbis mode 2 */
case GST_RIFF_WAVE_FORMAT_VORBIS3: /* ogg/vorbis mode 3 */
case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* ogg/vorbis mode 1+ */
case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* ogg/vorbis mode 2+ */
case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* ogg/vorbis mode 3+ */
caps = gst_caps_new_simple ("audio/x-vorbis", NULL);
if (codec_name)
*codec_name = g_strdup ("Vorbis");
*codec_name = g_strdup ("Vorbis");
break;
case GST_RIFF_WAVE_FORMAT_A52:
caps = gst_caps_new_simple ("audio/x-ac3", NULL);
if (codec_name)
*codec_name = g_strdup ("AC3");
*codec_name = g_strdup ("AC3");
break;
default:
GST_WARNING ("Unkown audio tag 0x%04x",
codec_id);
GST_WARNING ("Unkown audio tag 0x%04x", codec_id);
break;
}
if (strf != NULL) {
gst_caps_set_simple (caps,
"rate", G_TYPE_INT, strf->rate,
"channels", G_TYPE_INT, strf->channels,
NULL);
"rate", G_TYPE_INT, strf->rate,
"channels", G_TYPE_INT, strf->channels, NULL);
} else {
gst_caps_set_simple (caps,
"rate", GST_TYPE_INT_RANGE, 8000, 96000,
"channels", GST_TYPE_INT_RANGE, 1, 2,
NULL);
"rate", GST_TYPE_INT_RANGE, 8000, 96000,
"channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
}
return caps;
}
GstCaps *
gst_riff_create_iavs_caps (guint32 codec_fcc,
gst_riff_strh *strh,
gst_riff_strf_iavs *strf,
char **codec_name)
gst_riff_create_iavs_caps (guint32 codec_fcc,
gst_riff_strh * strh, gst_riff_strf_iavs * strf, char **codec_name)
{
GstCaps *caps = NULL;
switch (codec_fcc) {
/* is this correct? */
case GST_MAKE_FOURCC ('D','V','S','D'):
case GST_MAKE_FOURCC ('d','v','s','d'):
caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
/* is this correct? */
case GST_MAKE_FOURCC ('D', 'V', 'S', 'D'):
case GST_MAKE_FOURCC ('d', 'v', 's', 'd'):
caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
if (codec_name)
*codec_name = g_strdup ("Generic DV");
*codec_name = g_strdup ("Generic DV");
default:
GST_WARNING ("Unkown IAVS fourcc " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (codec_fcc));
GST_FOURCC_ARGS (codec_fcc));
return NULL;
}
@ -389,22 +357,22 @@ GstCaps *
gst_riff_create_video_template_caps (void)
{
guint32 tags[] = {
GST_MAKE_FOURCC ('I','4','2','0'),
GST_MAKE_FOURCC ('Y','U','Y','2'),
GST_MAKE_FOURCC ('M','J','P','G'),
GST_MAKE_FOURCC ('D','V','S','D'),
GST_MAKE_FOURCC ('W','M','V','1'),
GST_MAKE_FOURCC ('W','M','V','2'),
GST_MAKE_FOURCC ('M','P','G','4'),
GST_MAKE_FOURCC ('M','P','4','2'),
GST_MAKE_FOURCC ('M','P','4','3'),
GST_MAKE_FOURCC ('H','F','Y','U'),
GST_MAKE_FOURCC ('D','I','V','3'),
GST_MAKE_FOURCC ('M','P','E','G'),
GST_MAKE_FOURCC ('H','2','6','3'),
GST_MAKE_FOURCC ('D','I','V','X'),
GST_MAKE_FOURCC ('X','V','I','D'),
GST_MAKE_FOURCC ('3','I','V','1'),
GST_MAKE_FOURCC ('I', '4', '2', '0'),
GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
GST_MAKE_FOURCC ('M', 'J', 'P', 'G'),
GST_MAKE_FOURCC ('D', 'V', 'S', 'D'),
GST_MAKE_FOURCC ('W', 'M', 'V', '1'),
GST_MAKE_FOURCC ('W', 'M', 'V', '2'),
GST_MAKE_FOURCC ('M', 'P', 'G', '4'),
GST_MAKE_FOURCC ('M', 'P', '4', '2'),
GST_MAKE_FOURCC ('M', 'P', '4', '3'),
GST_MAKE_FOURCC ('H', 'F', 'Y', 'U'),
GST_MAKE_FOURCC ('D', 'I', 'V', '3'),
GST_MAKE_FOURCC ('M', 'P', 'E', 'G'),
GST_MAKE_FOURCC ('H', '2', '6', '3'),
GST_MAKE_FOURCC ('D', 'I', 'V', 'X'),
GST_MAKE_FOURCC ('X', 'V', 'I', 'D'),
GST_MAKE_FOURCC ('3', 'I', 'V', '1'),
/* FILL ME */
0
};
@ -452,7 +420,7 @@ GstCaps *
gst_riff_create_iavs_template_caps (void)
{
guint32 tags[] = {
GST_MAKE_FOURCC ('D','V','S','D'),
GST_MAKE_FOURCC ('D', 'V', 'S', 'D'),
/* FILL ME */
0
};

View file

@ -27,23 +27,15 @@
#include "riff-ids.h"
G_BEGIN_DECLS
/*
* Create one caps. strh/strf can be NULL (for non-fixed caps).
*/
GstCaps *gst_riff_create_video_caps (guint32 codec_fcc,
gst_riff_strh *strh,
gst_riff_strf_vids *strf,
char **codec_name);
GstCaps *gst_riff_create_audio_caps (guint16 codec_id,
gst_riff_strh *strh,
gst_riff_strf_auds *strf,
char **codec_name);
GstCaps *gst_riff_create_iavs_caps (guint32 codec_fcc,
gst_riff_strh *strh,
gst_riff_strf_iavs *strf,
char **codec_name);
GstCaps * gst_riff_create_video_caps (guint32 codec_fcc,
gst_riff_strh * strh, gst_riff_strf_vids * strf, char **codec_name);
GstCaps *gst_riff_create_audio_caps (guint16 codec_id,
gst_riff_strh * strh, gst_riff_strf_auds * strf, char **codec_name);
GstCaps *gst_riff_create_iavs_caps (guint32 codec_fcc,
gst_riff_strh * strh, gst_riff_strf_iavs * strf, char **codec_name);
/*
* Create template caps (includes all known types).
@ -51,8 +43,7 @@ GstCaps *gst_riff_create_iavs_caps (guint32 codec_fcc,
GstCaps *gst_riff_create_video_template_caps (void);
GstCaps *gst_riff_create_audio_template_caps (void);
GstCaps *gst_riff_create_iavs_template_caps (void);
GstCaps *gst_riff_create_iavs_template_caps (void);
G_END_DECLS
#endif /* __GST_RIFF_READ_H__ */

View file

@ -28,28 +28,28 @@
#include "riff-ids.h"
#include "riff-read.h"
enum {
enum
{
ARG_0,
ARG_METADATA
/* FILL ME */
/* FILL ME */
};
static void gst_riff_read_class_init (GstRiffReadClass *klass);
static void gst_riff_read_init (GstRiffRead *riff);
static void gst_riff_read_class_init (GstRiffReadClass * klass);
static void gst_riff_read_init (GstRiffRead * riff);
static GstElementStateReturn
gst_riff_read_change_state (GstElement *element);
static GstElementStateReturn gst_riff_read_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
GType
gst_riff_read_get_type (void)
gst_riff_read_get_type (void)
{
static GType gst_riff_read_type = 0;
if (!gst_riff_read_type) {
static const GTypeInfo gst_riff_read_info = {
sizeof (GstRiffReadClass),
sizeof (GstRiffReadClass),
NULL,
NULL,
(GClassInitFunc) gst_riff_read_class_init,
@ -62,24 +62,24 @@ gst_riff_read_get_type (void)
gst_riff_read_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstRiffRead",
&gst_riff_read_info, 0);
&gst_riff_read_info, 0);
}
return gst_riff_read_type;
}
static void
gst_riff_read_class_init (GstRiffReadClass *klass)
gst_riff_read_class_init (GstRiffReadClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gstelement_class->change_state = gst_riff_read_change_state;
}
static void
gst_riff_read_init (GstRiffRead *riff)
gst_riff_read_init (GstRiffRead * riff)
{
riff->sinkpad = NULL;
riff->bs = NULL;
@ -87,23 +87,23 @@ gst_riff_read_init (GstRiffRead *riff)
}
static GstElementStateReturn
gst_riff_read_change_state (GstElement *element)
gst_riff_read_change_state (GstElement * element)
{
GstRiffRead *riff = GST_RIFF_READ (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
if (!riff->sinkpad)
return GST_STATE_FAILURE;
return GST_STATE_FAILURE;
riff->bs = gst_bytestream_new (riff->sinkpad);
break;
case GST_STATE_PAUSED_TO_READY:
gst_bytestream_destroy (riff->bs);
while (riff->level) {
GstRiffLevel *level = riff->level->data;
GstRiffLevel *level = riff->level->data;
riff->level = g_list_remove (riff->level, level);
g_free (level);
riff->level = g_list_remove (riff->level, level);
g_free (level);
}
break;
default:
@ -124,7 +124,7 @@ gst_riff_read_change_state (GstElement *element)
*/
static guint
gst_riff_read_element_level_up (GstRiffRead *riff)
gst_riff_read_element_level_up (GstRiffRead * riff)
{
guint num = 0;
guint64 pos = gst_bytestream_tell (riff->bs);
@ -150,10 +150,8 @@ gst_riff_read_element_level_up (GstRiffRead *riff)
*/
static gboolean
gst_riff_peek_head (GstRiffRead *riff,
guint32 *tag,
guint32 *length,
guint *level_up)
gst_riff_peek_head (GstRiffRead * riff,
guint32 * tag, guint32 * length, guint * level_up)
{
guint8 *data;
@ -167,7 +165,7 @@ gst_riff_peek_head (GstRiffRead *riff,
if (GST_IS_EVENT (event)) {
gst_pad_event_default (riff->sinkpad, event);
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)
return FALSE;
return FALSE;
} else {
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
return FALSE;
@ -192,8 +190,7 @@ gst_riff_peek_head (GstRiffRead *riff,
*/
static GstBuffer *
gst_riff_read_element_data (GstRiffRead *riff,
guint length)
gst_riff_read_element_data (GstRiffRead * riff, guint length)
{
GstBuffer *buf = NULL;
@ -218,8 +215,7 @@ gst_riff_read_element_data (GstRiffRead *riff,
*/
GstEvent *
gst_riff_read_seek (GstRiffRead *riff,
guint64 offset)
gst_riff_read_seek (GstRiffRead * riff, guint64 offset)
{
guint64 length = gst_bytestream_length (riff->bs);
guint32 remaining;
@ -261,7 +257,7 @@ gst_riff_read_seek (GstRiffRead *riff,
} else if (GST_EVENT_TYPE (event) != GST_EVENT_DISCONTINUOUS) {
gst_pad_event_default (riff->sinkpad, event);
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)
return NULL;
return NULL;
event = NULL;
}
}
@ -274,8 +270,7 @@ gst_riff_read_seek (GstRiffRead *riff,
*/
guint32
gst_riff_peek_tag (GstRiffRead *riff,
guint *level_up)
gst_riff_peek_tag (GstRiffRead * riff, guint * level_up)
{
guint32 tag;
@ -290,7 +285,7 @@ gst_riff_peek_tag (GstRiffRead *riff,
*/
guint32
gst_riff_peek_list (GstRiffRead *riff)
gst_riff_peek_list (GstRiffRead * riff)
{
guint32 lst;
guint8 *data;
@ -315,7 +310,7 @@ gst_riff_peek_list (GstRiffRead *riff)
*/
gboolean
gst_riff_read_skip (GstRiffRead *riff)
gst_riff_read_skip (GstRiffRead * riff)
{
guint32 tag, length;
GstEvent *event;
@ -346,7 +341,7 @@ gst_riff_read_skip (GstRiffRead *riff)
/* no */
if (!(event = gst_riff_read_seek (riff,
gst_bytestream_tell (riff->bs) + length)))
gst_bytestream_tell (riff->bs) + length)))
return FALSE;
gst_event_unref (event);
@ -359,9 +354,7 @@ gst_riff_read_skip (GstRiffRead *riff)
*/
gboolean
gst_riff_read_data (GstRiffRead *riff,
guint32 *tag,
GstBuffer **buf)
gst_riff_read_data (GstRiffRead * riff, guint32 * tag, GstBuffer ** buf)
{
guint32 length;
@ -377,9 +370,7 @@ gst_riff_read_data (GstRiffRead *riff,
*/
gboolean
gst_riff_read_ascii (GstRiffRead *riff,
guint32 *tag,
gchar **str)
gst_riff_read_ascii (GstRiffRead * riff, guint32 * tag, gchar ** str)
{
GstBuffer *buf;
@ -400,8 +391,7 @@ gst_riff_read_ascii (GstRiffRead *riff,
*/
gboolean
gst_riff_read_strh (GstRiffRead *riff,
gst_riff_strh **header)
gst_riff_read_strh (GstRiffRead * riff, gst_riff_strh ** header)
{
guint32 tag;
GstBuffer *buf;
@ -417,28 +407,27 @@ gst_riff_read_strh (GstRiffRead *riff,
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strh)) {
g_warning ("Too small strh (%d available, %d needed)",
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strh));
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strh));
gst_buffer_unref (buf);
return FALSE;
}
strh = g_memdup (GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
strh = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
gst_buffer_unref (buf);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
strh->type = GUINT32_FROM_LE (strh->type);
strh->type = GUINT32_FROM_LE (strh->type);
strh->fcc_handler = GUINT32_FROM_LE (strh->fcc_handler);
strh->flags = GUINT32_FROM_LE (strh->flags);
strh->priority = GUINT32_FROM_LE (strh->priority);
strh->flags = GUINT32_FROM_LE (strh->flags);
strh->priority = GUINT32_FROM_LE (strh->priority);
strh->init_frames = GUINT32_FROM_LE (strh->init_frames);
strh->scale = GUINT32_FROM_LE (strh->scale);
strh->rate = GUINT32_FROM_LE (strh->rate);
strh->start = GUINT32_FROM_LE (strh->start);
strh->length = GUINT32_FROM_LE (strh->length);
strh->bufsize = GUINT32_FROM_LE (strh->bufsize);
strh->quality = GUINT32_FROM_LE (strh->quality);
strh->samplesize = GUINT32_FROM_LE (strh->samplesize);
strh->scale = GUINT32_FROM_LE (strh->scale);
strh->rate = GUINT32_FROM_LE (strh->rate);
strh->start = GUINT32_FROM_LE (strh->start);
strh->length = GUINT32_FROM_LE (strh->length);
strh->bufsize = GUINT32_FROM_LE (strh->bufsize);
strh->quality = GUINT32_FROM_LE (strh->quality);
strh->samplesize = GUINT32_FROM_LE (strh->samplesize);
#endif
/* avoid divisions by zero */
@ -449,20 +438,19 @@ gst_riff_read_strh (GstRiffRead *riff,
/* debug */
GST_INFO ("strh tag found");
GST_INFO (" type " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (strh->type));
GST_INFO (" type " GST_FOURCC_FORMAT, GST_FOURCC_ARGS (strh->type));
GST_INFO (" fcc_handler " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (strh->fcc_handler));
GST_FOURCC_ARGS (strh->fcc_handler));
GST_INFO (" flags 0x%08x", strh->flags);
GST_INFO (" priority %d", strh->priority);
GST_INFO (" init_frames %d", strh->init_frames);
GST_INFO (" scale %d", strh->scale);
GST_INFO (" rate %d", strh->rate);
GST_INFO (" start %d", strh->start);
GST_INFO (" length %d", strh->length);
GST_INFO (" bufsize %d", strh->bufsize);
GST_INFO (" quality %d", strh->quality);
GST_INFO (" samplesize %d", strh->samplesize);
GST_INFO (" priority %d", strh->priority);
GST_INFO (" init_frames %d", strh->init_frames);
GST_INFO (" scale %d", strh->scale);
GST_INFO (" rate %d", strh->rate);
GST_INFO (" start %d", strh->start);
GST_INFO (" length %d", strh->length);
GST_INFO (" bufsize %d", strh->bufsize);
GST_INFO (" quality %d", strh->quality);
GST_INFO (" samplesize %d", strh->samplesize);
*header = strh;
@ -470,8 +458,7 @@ gst_riff_read_strh (GstRiffRead *riff,
}
gboolean
gst_riff_read_strf_vids (GstRiffRead *riff,
gst_riff_strf_vids **header)
gst_riff_read_strf_vids (GstRiffRead * riff, gst_riff_strf_vids ** header)
{
guint32 tag;
GstBuffer *buf;
@ -487,32 +474,31 @@ gst_riff_read_strf_vids (GstRiffRead *riff,
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_vids)) {
g_warning ("Too small strf_vids (%d available, %d needed)",
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_vids));
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_vids));
gst_buffer_unref (buf);
return FALSE;
}
strf = g_memdup (GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
strf->size = GUINT32_FROM_LE (strf->size);
strf->width = GUINT32_FROM_LE (strf->width);
strf->height = GUINT32_FROM_LE (strf->height);
strf->planes = GUINT16_FROM_LE (strf->planes);
strf->bit_cnt = GUINT16_FROM_LE (strf->bit_cnt);
strf->size = GUINT32_FROM_LE (strf->size);
strf->width = GUINT32_FROM_LE (strf->width);
strf->height = GUINT32_FROM_LE (strf->height);
strf->planes = GUINT16_FROM_LE (strf->planes);
strf->bit_cnt = GUINT16_FROM_LE (strf->bit_cnt);
strf->compression = GUINT32_FROM_LE (strf->compression);
strf->image_size = GUINT32_FROM_LE (strf->image_size);
strf->image_size = GUINT32_FROM_LE (strf->image_size);
strf->xpels_meter = GUINT32_FROM_LE (strf->xpels_meter);
strf->ypels_meter = GUINT32_FROM_LE (strf->ypels_meter);
strf->num_colors = GUINT32_FROM_LE (strf->num_colors);
strf->imp_colors = GUINT32_FROM_LE (strf->imp_colors);
strf->num_colors = GUINT32_FROM_LE (strf->num_colors);
strf->imp_colors = GUINT32_FROM_LE (strf->imp_colors);
#endif
/* size checking */
if (strf->size > GST_BUFFER_SIZE (buf)) {
g_warning ("strf_vids header gave %d bytes data, only %d available",
strf->size, GST_BUFFER_SIZE (buf));
strf->size, GST_BUFFER_SIZE (buf));
strf->size = GST_BUFFER_SIZE (buf);
}
@ -524,7 +510,7 @@ gst_riff_read_strf_vids (GstRiffRead *riff,
GST_INFO (" planes %d", strf->planes);
GST_INFO (" bit_cnt %d", strf->bit_cnt);
GST_INFO (" compression " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (strf->compression));
GST_FOURCC_ARGS (strf->compression));
GST_INFO (" image_size %d", strf->image_size);
GST_INFO (" xpels_meter %d", strf->xpels_meter);
GST_INFO (" ypels_meter %d", strf->ypels_meter);
@ -539,8 +525,7 @@ gst_riff_read_strf_vids (GstRiffRead *riff,
}
gboolean
gst_riff_read_strf_auds (GstRiffRead *riff,
gst_riff_strf_auds **header)
gst_riff_read_strf_auds (GstRiffRead * riff, gst_riff_strf_auds ** header)
{
guint32 tag;
GstBuffer *buf;
@ -556,21 +541,20 @@ gst_riff_read_strf_auds (GstRiffRead *riff,
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_auds)) {
g_warning ("Too small strf_auds (%d available, %d needed)",
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_auds));
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_auds));
gst_buffer_unref (buf);
return FALSE;
}
strf = g_memdup (GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
strf->format = GUINT16_FROM_LE (strf->format);
strf->channels = GUINT16_FROM_LE (strf->channels);
strf->rate = GUINT32_FROM_LE (strf->rate);
strf->av_bps = GUINT32_FROM_LE (strf->av_bps);
strf->format = GUINT16_FROM_LE (strf->format);
strf->channels = GUINT16_FROM_LE (strf->channels);
strf->rate = GUINT32_FROM_LE (strf->rate);
strf->av_bps = GUINT32_FROM_LE (strf->av_bps);
strf->blockalign = GUINT16_FROM_LE (strf->blockalign);
strf->size = GUINT16_FROM_LE (strf->size);
strf->size = GUINT16_FROM_LE (strf->size);
#endif
/* debug */
@ -580,7 +564,7 @@ gst_riff_read_strf_auds (GstRiffRead *riff,
GST_INFO (" rate %d", strf->rate);
GST_INFO (" av_bps %d", strf->av_bps);
GST_INFO (" blockalign %d", strf->blockalign);
GST_INFO (" size %d", strf->size); /* wordsize, not extrasize! */
GST_INFO (" size %d", strf->size); /* wordsize, not extrasize! */
gst_buffer_unref (buf);
@ -590,8 +574,7 @@ gst_riff_read_strf_auds (GstRiffRead *riff,
}
gboolean
gst_riff_read_strf_iavs (GstRiffRead *riff,
gst_riff_strf_iavs **header)
gst_riff_read_strf_iavs (GstRiffRead * riff, gst_riff_strf_iavs ** header)
{
guint32 tag;
GstBuffer *buf;
@ -607,22 +590,21 @@ gst_riff_read_strf_iavs (GstRiffRead *riff,
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_iavs)) {
g_warning ("Too small strf_iavs (%d available, %d needed)",
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_iavs));
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_iavs));
gst_buffer_unref (buf);
return FALSE;
}
strf = g_memdup (GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
gst_buffer_unref (buf);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
strf->DVAAuxSrc = GUINT32_FROM_LE (strf->DVAAuxSrc);
strf->DVAAuxCtl = GUINT32_FROM_LE (strf->DVAAuxCtl);
strf->DVAAuxSrc1 = GUINT32_FROM_LE (strf->DVAAuxSrc1);
strf->DVAAuxCtl1 = GUINT32_FROM_LE (strf->DVAAuxCtl1);
strf->DVVAuxSrc = GUINT32_FROM_LE (strf->DVVAuxSrc);
strf->DVVAuxCtl = GUINT32_FROM_LE (strf->DVVAuxCtl);
strf->DVAAuxSrc = GUINT32_FROM_LE (strf->DVAAuxSrc);
strf->DVAAuxCtl = GUINT32_FROM_LE (strf->DVAAuxCtl);
strf->DVAAuxSrc1 = GUINT32_FROM_LE (strf->DVAAuxSrc1);
strf->DVAAuxCtl1 = GUINT32_FROM_LE (strf->DVAAuxCtl1);
strf->DVVAuxSrc = GUINT32_FROM_LE (strf->DVVAuxSrc);
strf->DVVAuxCtl = GUINT32_FROM_LE (strf->DVVAuxCtl);
strf->DVReserved1 = GUINT32_FROM_LE (strf->DVReserved1);
strf->DVReserved2 = GUINT32_FROM_LE (strf->DVReserved2);
#endif
@ -648,8 +630,7 @@ gst_riff_read_strf_iavs (GstRiffRead *riff,
*/
gboolean
gst_riff_read_list (GstRiffRead *riff,
guint32 *tag)
gst_riff_read_list (GstRiffRead * riff, guint32 * tag)
{
guint32 length, lst;
GstRiffLevel *level;
@ -667,7 +648,7 @@ gst_riff_read_list (GstRiffRead *riff,
return FALSE;
}
gst_bytestream_flush_fast (riff->bs, 4);
*tag = GUINT32_FROM_LE (* (guint32 *) data);
*tag = GUINT32_FROM_LE (*(guint32 *) data);
/* remember level */
level = g_new (GstRiffLevel, 1);
@ -683,7 +664,7 @@ gst_riff_read_list (GstRiffRead *riff,
*/
gboolean
gst_riff_read_info (GstRiffRead *riff)
gst_riff_read_info (GstRiffRead * riff)
{
guint32 tag;
guint64 end;
@ -713,100 +694,102 @@ gst_riff_read_info (GstRiffRead *riff)
/* find out the type of metadata */
switch (tag) {
case GST_RIFF_INFO_IARL:
type = GST_TAG_LOCATION;
break;
type = GST_TAG_LOCATION;
break;
case GST_RIFF_INFO_IART:
type = GST_TAG_ARTIST;
break;
type = GST_TAG_ARTIST;
break;
case GST_RIFF_INFO_ICMS:
type = NULL; /*"Commissioner";*/
break;
type = NULL; /*"Commissioner"; */
break;
case GST_RIFF_INFO_ICMT:
type = GST_TAG_COMMENT;
break;
type = GST_TAG_COMMENT;
break;
case GST_RIFF_INFO_ICOP:
type = GST_TAG_COPYRIGHT;
break;
type = GST_TAG_COPYRIGHT;
break;
case GST_RIFF_INFO_ICRD:
type = GST_TAG_DATE;
break;
type = GST_TAG_DATE;
break;
case GST_RIFF_INFO_ICRP:
type = NULL; /*"Cropped";*/
break;
type = NULL; /*"Cropped"; */
break;
case GST_RIFF_INFO_IDIM:
type = NULL; /*"Dimensions";*/
break;
type = NULL; /*"Dimensions"; */
break;
case GST_RIFF_INFO_IDPI:
type = NULL; /*"Dots per Inch";*/
break;
type = NULL; /*"Dots per Inch"; */
break;
case GST_RIFF_INFO_IENG:
type = NULL; /*"Engineer";*/
break;
type = NULL; /*"Engineer"; */
break;
case GST_RIFF_INFO_IGNR:
type = GST_TAG_GENRE;
break;
type = GST_TAG_GENRE;
break;
case GST_RIFF_INFO_IKEY:
type = NULL; /*"Keywords";*/;
break;
type = NULL; /*"Keywords"; */ ;
break;
case GST_RIFF_INFO_ILGT:
type = NULL; /*"Lightness";*/
break;
type = NULL; /*"Lightness"; */
break;
case GST_RIFF_INFO_IMED:
type = NULL; /*"Medium";*/
break;
type = NULL; /*"Medium"; */
break;
case GST_RIFF_INFO_INAM:
type = GST_TAG_TITLE;
break;
type = GST_TAG_TITLE;
break;
case GST_RIFF_INFO_IPLT:
type = NULL; /*"Palette";*/
break;
type = NULL; /*"Palette"; */
break;
case GST_RIFF_INFO_IPRD:
type = NULL; /*"Product";*/
break;
type = NULL; /*"Product"; */
break;
case GST_RIFF_INFO_ISBJ:
type = NULL; /*"Subject";*/
break;
type = NULL; /*"Subject"; */
break;
case GST_RIFF_INFO_ISFT:
type = GST_TAG_ENCODER;
break;
type = GST_TAG_ENCODER;
break;
case GST_RIFF_INFO_ISHP:
type = NULL; /*"Sharpness";*/
break;
type = NULL; /*"Sharpness"; */
break;
case GST_RIFF_INFO_ISRC:
type = GST_TAG_ISRC;
break;
type = GST_TAG_ISRC;
break;
case GST_RIFF_INFO_ISRF:
type = NULL; /*"Source Form";*/
break;
type = NULL; /*"Source Form"; */
break;
case GST_RIFF_INFO_ITCH:
type = NULL; /*"Technician";*/
break;
type = NULL; /*"Technician"; */
break;
default:
type = NULL;
GST_WARNING ("Unknown INFO (metadata) tag entry " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (tag));
break;
type = NULL;
GST_WARNING ("Unknown INFO (metadata) tag entry " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (tag));
break;
}
if (type) {
name = NULL;
if (!gst_riff_read_ascii (riff, &tag, &name)) {
return FALSE;
return FALSE;
}
if (name && name[0] != '\0') {
GValue src = { 0 }, dest = { 0 };
GType dest_type = gst_tag_get_type (type);
GValue src = { 0 }
, dest = {
0};
GType dest_type = gst_tag_get_type (type);
have_tags = TRUE;
g_value_init (&src, G_TYPE_STRING);
g_value_set_string (&src, name);
g_value_init (&dest, dest_type);
g_value_transform (&src, &dest);
g_value_unset (&src);
gst_tag_list_add_values (taglist, GST_TAG_MERGE_APPEND,
type, &dest, NULL);
g_value_unset (&dest);
have_tags = TRUE;
g_value_init (&src, G_TYPE_STRING);
g_value_set_string (&src, name);
g_value_init (&dest, dest_type);
g_value_transform (&src, &dest);
g_value_unset (&src);
gst_tag_list_add_values (taglist, GST_TAG_MERGE_APPEND,
type, &dest, NULL);
g_value_unset (&dest);
}
g_free (name);
} else {
@ -821,10 +804,10 @@ gst_riff_read_info (GstRiffRead *riff)
/* let the world know about this wonderful thing */
for (padlist = gst_element_get_pad_list (element);
padlist != NULL; padlist = padlist->next) {
if (GST_PAD_IS_SRC (padlist->data) && GST_PAD_IS_USABLE(padlist->data)) {
gst_event_ref (event);
gst_pad_push (GST_PAD (padlist->data), GST_DATA (event));
padlist != NULL; padlist = padlist->next) {
if (GST_PAD_IS_SRC (padlist->data) && GST_PAD_IS_USABLE (padlist->data)) {
gst_event_ref (event);
gst_pad_push (GST_PAD (padlist->data), GST_DATA (event));
}
}
gst_event_unref (event);
@ -839,8 +822,7 @@ gst_riff_read_info (GstRiffRead *riff)
*/
gboolean
gst_riff_read_header (GstRiffRead *riff,
guint32 *doctype)
gst_riff_read_header (GstRiffRead * riff, guint32 * doctype)
{
GstRiffLevel *level;
guint32 tag, length;
@ -861,7 +843,7 @@ gst_riff_read_header (GstRiffRead *riff,
return FALSE;
}
gst_bytestream_flush_fast (riff->bs, 4);
*doctype = GUINT32_FROM_LE (* (guint32 *) data);
*doctype = GUINT32_FROM_LE (*(guint32 *) data);
/* remember level */
level = g_new (GstRiffLevel, 1);

View file

@ -27,7 +27,6 @@
#include <gst/bytestream/bytestream.h>
G_BEGIN_DECLS
#define GST_TYPE_RIFF_READ \
(gst_riff_read_get_type ())
#define GST_RIFF_READ(obj) \
@ -40,13 +39,13 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RIFF_READ))
#define GST_RIFF_READ_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RIFF_READ, GstRiffReadClass))
typedef struct _GstRiffLevel {
guint64 start,
length;
typedef struct _GstRiffLevel
{
guint64 start, length;
} GstRiffLevel;
typedef struct _GstRiffRead {
typedef struct _GstRiffRead
{
GstElement parent;
GstPad *sinkpad;
@ -55,43 +54,35 @@ typedef struct _GstRiffRead {
GList *level;
} GstRiffRead;
typedef struct _GstRiffReadClass {
typedef struct _GstRiffReadClass
{
GstElementClass parent;
} GstRiffReadClass;
GType gst_riff_read_get_type (void);
GType gst_riff_read_get_type (void);
guint32 gst_riff_peek_tag (GstRiffRead *riff,
guint *level_up);
guint32 gst_riff_peek_list (GstRiffRead *riff);
guint32 gst_riff_peek_tag (GstRiffRead * riff, guint * level_up);
guint32 gst_riff_peek_list (GstRiffRead * riff);
GstEvent *gst_riff_read_seek (GstRiffRead *riff,
guint64 offset);
gboolean gst_riff_read_skip (GstRiffRead *riff);
gboolean gst_riff_read_data (GstRiffRead *riff,
guint32 *tag,
GstBuffer **buf);
gboolean gst_riff_read_ascii (GstRiffRead *riff,
guint32 *tag,
gchar **str);
gboolean gst_riff_read_list (GstRiffRead *riff,
guint32 *tag);
gboolean gst_riff_read_header (GstRiffRead *read,
guint32 *doctype);
GstEvent *gst_riff_read_seek (GstRiffRead * riff, guint64 offset);
gboolean gst_riff_read_skip (GstRiffRead * riff);
gboolean gst_riff_read_data (GstRiffRead * riff,
guint32 * tag, GstBuffer ** buf);
gboolean gst_riff_read_ascii (GstRiffRead * riff, guint32 * tag, gchar ** str);
gboolean gst_riff_read_list (GstRiffRead * riff, guint32 * tag);
gboolean gst_riff_read_header (GstRiffRead * read, guint32 * doctype);
/*
* Utility functions (including byteswapping).
*/
gboolean gst_riff_read_strh (GstRiffRead *riff,
gst_riff_strh **header);
gboolean gst_riff_read_strf_vids (GstRiffRead *riff,
gst_riff_strf_vids **header);
gboolean gst_riff_read_strf_auds (GstRiffRead *riff,
gst_riff_strf_auds **header);
gboolean gst_riff_read_strf_iavs (GstRiffRead *riff,
gst_riff_strf_iavs **header);
gboolean gst_riff_read_info (GstRiffRead *riff);
gboolean gst_riff_read_strh (GstRiffRead * riff, gst_riff_strh ** header);
gboolean gst_riff_read_strf_vids (GstRiffRead * riff,
gst_riff_strf_vids ** header);
gboolean gst_riff_read_strf_auds (GstRiffRead * riff,
gst_riff_strf_auds ** header);
gboolean gst_riff_read_strf_iavs (GstRiffRead * riff,
gst_riff_strf_iavs ** header);
gboolean gst_riff_read_info (GstRiffRead * riff);
G_END_DECLS
#endif /* __GST_RIFF_READ_H__ */

View file

@ -26,19 +26,13 @@
#include <gst/gst.h>
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
return gst_library_load ("gstbytestream");
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"riff",
"RIFF I/O functions",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"riff",
"RIFF I/O functions",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)

View file

@ -24,39 +24,30 @@
#include <gst/gst.h>
G_BEGIN_DECLS
/* functions for vorbis comment manipulation */
G_CONST_RETURN gchar * gst_tag_from_vorbis_tag (const gchar * vorbis_tag);
G_CONST_RETURN gchar *gst_tag_to_vorbis_tag (const gchar * gst_tag);
void gst_vorbis_tag_add (GstTagList * list,
const gchar * tag, const gchar * value);
G_CONST_RETURN gchar * gst_tag_from_vorbis_tag (const gchar * vorbis_tag);
G_CONST_RETURN gchar * gst_tag_to_vorbis_tag (const gchar * gst_tag);
void gst_vorbis_tag_add (GstTagList * list,
const gchar * tag,
const gchar * value);
GList * gst_tag_to_vorbis_comments (const GstTagList * list,
const gchar * tag);
GList *gst_tag_to_vorbis_comments (const GstTagList * list, const gchar * tag);
/* functions to convert GstBuffers with vorbiscomment contents to GstTagLists and back */
GstTagList * gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer,
const guint8 * id_data,
const guint id_data_length,
gchar ** vendor_string);
GstBuffer * gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
const guint8 * id_data,
const guint id_data_length,
const gchar * vendor_string);
GstTagList *gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer,
const guint8 * id_data, const guint id_data_length, gchar ** vendor_string);
GstBuffer *gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
const guint8 * id_data,
const guint id_data_length, const gchar * vendor_string);
/* functions for ID3 tag manipulation */
guint gst_tag_id3_genre_count (void);
G_CONST_RETURN gchar * gst_tag_id3_genre_get (const guint id);
GstTagList * gst_tag_list_new_from_id3v1 (const guint8 * data);
guint gst_tag_id3_genre_count (void);
G_CONST_RETURN gchar *gst_tag_id3_genre_get (const guint id);
GstTagList *gst_tag_list_new_from_id3v1 (const guint8 * data);
G_CONST_RETURN gchar * gst_tag_from_id3_tag (const gchar * vorbis_tag);
G_CONST_RETURN gchar * gst_tag_to_id3_tag (const gchar * gst_tag);
G_CONST_RETURN gchar *gst_tag_from_id3_tag (const gchar * vorbis_tag);
G_CONST_RETURN gchar *gst_tag_to_id3_tag (const gchar * gst_tag);
G_END_DECLS
#endif /* __GST_TAG_TAG_H__ */

View file

@ -28,7 +28,8 @@
#include <string.h>
enum {
enum
{
NORM_CHANGED,
CHANNEL_CHANGED,
FREQUENCY_CHANGED,
@ -36,7 +37,7 @@ enum {
LAST_SIGNAL
};
static void gst_tuner_class_init (GstTunerClass *klass);
static void gst_tuner_class_init (GstTunerClass * klass);
static guint gst_tuner_signals[LAST_SIGNAL] = { 0 };
@ -59,49 +60,47 @@ gst_tuner_get_type (void)
};
gst_tuner_type = g_type_register_static (G_TYPE_INTERFACE,
"GstTuner",
&gst_tuner_info, 0);
"GstTuner", &gst_tuner_info, 0);
g_type_interface_add_prerequisite (gst_tuner_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_tuner_type;
}
static void
gst_tuner_class_init (GstTunerClass *klass)
gst_tuner_class_init (GstTunerClass * klass)
{
static gboolean initialized = FALSE;
if (!initialized) {
gst_tuner_signals[NORM_CHANGED] =
g_signal_new ("norm-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, norm_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_TUNER_NORM);
g_signal_new ("norm-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, norm_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_TUNER_NORM);
gst_tuner_signals[CHANNEL_CHANGED] =
g_signal_new ("channel-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, channel_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_TUNER_CHANNEL);
g_signal_new ("channel-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, channel_changed),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_TUNER_CHANNEL);
gst_tuner_signals[FREQUENCY_CHANGED] =
g_signal_new ("frequency-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, frequency_changed),
NULL, NULL,
gst_tuner_marshal_VOID__OBJECT_ULONG, G_TYPE_NONE, 2,
GST_TYPE_TUNER_CHANNEL, G_TYPE_ULONG);
g_signal_new ("frequency-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, frequency_changed),
NULL, NULL,
gst_tuner_marshal_VOID__OBJECT_ULONG, G_TYPE_NONE, 2,
GST_TYPE_TUNER_CHANNEL, G_TYPE_ULONG);
gst_tuner_signals[SIGNAL_CHANGED] =
g_signal_new ("signal-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, signal_changed),
NULL, NULL,
gst_tuner_marshal_VOID__OBJECT_INT, G_TYPE_NONE, 2,
GST_TYPE_TUNER_CHANNEL, G_TYPE_INT);
g_signal_new ("signal-changed",
GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerClass, signal_changed),
NULL, NULL,
gst_tuner_marshal_VOID__OBJECT_INT, G_TYPE_NONE, 2,
GST_TYPE_TUNER_CHANNEL, G_TYPE_INT);
initialized = TRUE;
}
@ -131,7 +130,7 @@ gst_tuner_class_init (GstTunerClass *klass)
*/
const GList *
gst_tuner_list_channels (GstTuner *tuner)
gst_tuner_list_channels (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -151,8 +150,7 @@ gst_tuner_list_channels (GstTuner *tuner)
*/
void
gst_tuner_set_channel (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_set_channel (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -171,7 +169,7 @@ gst_tuner_set_channel (GstTuner *tuner,
*/
GstTunerChannel *
gst_tuner_get_channel (GstTuner *tuner)
gst_tuner_get_channel (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -194,7 +192,7 @@ gst_tuner_get_channel (GstTuner *tuner)
*/
const GList *
gst_tuner_list_norms (GstTuner *tuner)
gst_tuner_list_norms (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -214,8 +212,7 @@ gst_tuner_list_norms (GstTuner *tuner)
*/
void
gst_tuner_set_norm (GstTuner *tuner,
GstTunerNorm *norm)
gst_tuner_set_norm (GstTuner * tuner, GstTunerNorm * norm)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -235,7 +232,7 @@ gst_tuner_set_norm (GstTuner *tuner,
*/
GstTunerNorm *
gst_tuner_get_norm (GstTuner *tuner)
gst_tuner_get_norm (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
@ -259,14 +256,13 @@ gst_tuner_get_norm (GstTuner *tuner)
*/
void
gst_tuner_set_frequency (GstTuner *tuner,
GstTunerChannel *channel,
gulong frequency)
gst_tuner_set_frequency (GstTuner * tuner,
GstTunerChannel * channel, gulong frequency)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
g_return_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
GST_TUNER_CHANNEL_FREQUENCY));
GST_TUNER_CHANNEL_FREQUENCY));
if (klass->set_frequency) {
klass->set_frequency (tuner, channel, frequency);
@ -285,13 +281,12 @@ gst_tuner_set_frequency (GstTuner *tuner,
*/
gulong
gst_tuner_get_frequency (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_get_frequency (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
GST_TUNER_CHANNEL_FREQUENCY), 0);
GST_TUNER_CHANNEL_FREQUENCY), 0);
if (klass->get_frequency) {
return klass->get_frequency (tuner, channel);
@ -315,13 +310,12 @@ gst_tuner_get_frequency (GstTuner *tuner,
*/
gint
gst_tuner_signal_strength (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
GST_TUNER_CHANNEL_FREQUENCY), 0);
GST_TUNER_CHANNEL_FREQUENCY), 0);
if (klass->signal_strength) {
return klass->signal_strength (tuner, channel);
@ -331,8 +325,7 @@ gst_tuner_signal_strength (GstTuner *tuner,
}
GstTunerNorm *
gst_tuner_find_norm_by_name (GstTuner *tuner,
gchar *norm)
gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm)
{
GList *walk;
@ -349,8 +342,7 @@ gst_tuner_find_norm_by_name (GstTuner *tuner,
}
GstTunerChannel *
gst_tuner_find_channel_by_name (GstTuner *tuner,
gchar *channel)
gst_tuner_find_channel_by_name (GstTuner * tuner, gchar * channel)
{
GList *walk;
@ -367,59 +359,46 @@ gst_tuner_find_channel_by_name (GstTuner *tuner,
}
void
gst_tuner_channel_changed (GstTuner *tuner,
GstTunerChannel *channel)
gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[CHANNEL_CHANGED], 0,
channel);
gst_tuner_signals[CHANNEL_CHANGED], 0, channel);
}
void
gst_tuner_norm_changed (GstTuner *tuner,
GstTunerNorm *norm)
gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_NORM (norm));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[NORM_CHANGED], 0,
norm);
g_signal_emit (G_OBJECT (tuner), gst_tuner_signals[NORM_CHANGED], 0, norm);
}
void
gst_tuner_frequency_changed (GstTuner *tuner,
GstTunerChannel *channel,
gulong frequency)
gst_tuner_frequency_changed (GstTuner * tuner,
GstTunerChannel * channel, gulong frequency)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[FREQUENCY_CHANGED], 0,
channel, frequency);
gst_tuner_signals[FREQUENCY_CHANGED], 0, channel, frequency);
g_signal_emit_by_name (G_OBJECT (channel),
"frequency_changed",
frequency);
g_signal_emit_by_name (G_OBJECT (channel), "frequency_changed", frequency);
}
void
gst_tuner_signal_changed (GstTuner *tuner,
GstTunerChannel *channel,
gint signal)
gst_tuner_signal_changed (GstTuner * tuner,
GstTunerChannel * channel, gint signal)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
gst_tuner_signals[SIGNAL_CHANGED], 0,
channel, signal);
gst_tuner_signals[SIGNAL_CHANGED], 0, channel, signal);
g_signal_emit_by_name (G_OBJECT (channel),
"signal_changed",
signal);
g_signal_emit_by_name (G_OBJECT (channel), "signal_changed", signal);
}

View file

@ -28,7 +28,6 @@
#include <gst/tuner/tuner-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_TUNER \
(gst_tuner_get_type ())
#define GST_TUNER(obj) \
@ -41,87 +40,65 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER))
#define GST_TUNER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_TUNER, GstTunerClass))
typedef struct _GstTuner GstTuner;
typedef struct _GstTunerClass {
typedef struct _GstTunerClass
{
GTypeInterface klass;
/* virtual functions */
const GList * (* list_channels) (GstTuner *tuner);
void (* set_channel) (GstTuner *tuner,
GstTunerChannel *channel);
GstTunerChannel *
(* get_channel) (GstTuner *tuner);
const GList *(*list_channels) (GstTuner * tuner);
void (*set_channel) (GstTuner * tuner, GstTunerChannel * channel);
GstTunerChannel *(*get_channel) (GstTuner * tuner);
const GList * (* list_norms) (GstTuner *tuner);
void (* set_norm) (GstTuner *tuner,
GstTunerNorm *norm);
GstTunerNorm *(* get_norm) (GstTuner *tuner);
const GList *(*list_norms) (GstTuner * tuner);
void (*set_norm) (GstTuner * tuner, GstTunerNorm * norm);
GstTunerNorm *(*get_norm) (GstTuner * tuner);
void (* set_frequency) (GstTuner *tuner,
GstTunerChannel *channel,
gulong frequency);
gulong (* get_frequency) (GstTuner *tuner,
GstTunerChannel *channel);
gint (* signal_strength) (GstTuner *tuner,
GstTunerChannel *channel);
void (*set_frequency) (GstTuner * tuner,
GstTunerChannel * channel, gulong frequency);
gulong (*get_frequency) (GstTuner * tuner, GstTunerChannel * channel);
gint (*signal_strength) (GstTuner * tuner, GstTunerChannel * channel);
/* signals */
void (*channel_changed) (GstTuner *tuner,
GstTunerChannel *channel);
void (*norm_changed) (GstTuner *tuner,
GstTunerNorm *norm);
void (*frequency_changed) (GstTuner *tuner,
GstTunerChannel *channel,
gulong frequency);
void (*signal_changed) (GstTuner *tuner,
GstTunerChannel *channel,
gint signal);
void (*channel_changed) (GstTuner * tuner, GstTunerChannel * channel);
void (*norm_changed) (GstTuner * tuner, GstTunerNorm * norm);
void (*frequency_changed) (GstTuner * tuner,
GstTunerChannel * channel, gulong frequency);
void (*signal_changed) (GstTuner * tuner,
GstTunerChannel * channel, gint signal);
gpointer _gst_reserved[GST_PADDING];
} GstTunerClass;
GType gst_tuner_get_type (void);
GType gst_tuner_get_type (void);
/* virtual class function wrappers */
const GList * gst_tuner_list_channels (GstTuner *tuner);
void gst_tuner_set_channel (GstTuner *tuner,
GstTunerChannel *channel);
GstTunerChannel *
gst_tuner_get_channel (GstTuner *tuner);
const GList *gst_tuner_list_channels (GstTuner * tuner);
void gst_tuner_set_channel (GstTuner * tuner, GstTunerChannel * channel);
GstTunerChannel *gst_tuner_get_channel (GstTuner * tuner);
const GList * gst_tuner_list_norms (GstTuner *tuner);
void gst_tuner_set_norm (GstTuner *tuner,
GstTunerNorm *channel);
GstTunerNorm * gst_tuner_get_norm (GstTuner *tuner);
const GList *gst_tuner_list_norms (GstTuner * tuner);
void gst_tuner_set_norm (GstTuner * tuner, GstTunerNorm * channel);
GstTunerNorm *gst_tuner_get_norm (GstTuner * tuner);
void gst_tuner_set_frequency (GstTuner *tuner,
GstTunerChannel *channel,
gulong frequency);
gulong gst_tuner_get_frequency (GstTuner *tuner,
GstTunerChannel *channel);
gint gst_tuner_signal_strength (GstTuner *tuner,
GstTunerChannel *channel);
void gst_tuner_set_frequency (GstTuner * tuner,
GstTunerChannel * channel, gulong frequency);
gulong gst_tuner_get_frequency (GstTuner * tuner, GstTunerChannel * channel);
gint gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel);
/* helper functions */
GstTunerNorm * gst_tuner_find_norm_by_name (GstTuner *tuner,
gchar *norm);
GstTunerChannel *gst_tuner_find_channel_by_name (GstTuner *tuner,
gchar *channel);
GstTunerNorm *gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm);
GstTunerChannel *gst_tuner_find_channel_by_name (GstTuner * tuner,
gchar * channel);
/* trigger signals */
void gst_tuner_channel_changed (GstTuner *tuner,
GstTunerChannel *channel);
void gst_tuner_norm_changed (GstTuner *tuner,
GstTunerNorm *norm);
void gst_tuner_frequency_changed (GstTuner *tuner,
GstTunerChannel *channel,
gulong frequency);
void gst_tuner_signal_changed (GstTuner *tuner,
GstTunerChannel *channel,
gint signal);
void gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel);
void gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm);
void gst_tuner_frequency_changed (GstTuner * tuner,
GstTunerChannel * channel, gulong frequency);
void gst_tuner_signal_changed (GstTuner * tuner,
GstTunerChannel * channel, gint signal);
G_END_DECLS
#endif /* __GST_TUNER_H__ */

View file

@ -25,16 +25,17 @@
#include "tunerchannel.h"
enum {
enum
{
/* FILL ME */
SIGNAL_FREQUENCY_CHANGED,
SIGNAL_SIGNAL_CHANGED,
LAST_SIGNAL
};
static void gst_tuner_channel_class_init (GstTunerChannelClass *klass);
static void gst_tuner_channel_init (GstTunerChannel *channel);
static void gst_tuner_channel_dispose (GObject *object);
static void gst_tuner_channel_class_init (GstTunerChannelClass * klass);
static void gst_tuner_channel_init (GstTunerChannel * channel);
static void gst_tuner_channel_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
@ -60,40 +61,37 @@ gst_tuner_channel_get_type (void)
gst_tuner_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerChannel",
&tuner_channel_info, 0);
"GstTunerChannel", &tuner_channel_info, 0);
}
return gst_tuner_channel_type;
}
static void
gst_tuner_channel_class_init (GstTunerChannelClass *klass)
gst_tuner_channel_class_init (GstTunerChannelClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
signals[SIGNAL_FREQUENCY_CHANGED] =
g_signal_new ("frequency-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerChannelClass,
frequency_changed),
NULL, NULL, g_cclosure_marshal_VOID__ULONG,
G_TYPE_NONE, 1, G_TYPE_ULONG);
g_signal_new ("frequency-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerChannelClass,
frequency_changed),
NULL, NULL, g_cclosure_marshal_VOID__ULONG, G_TYPE_NONE, 1, G_TYPE_ULONG);
signals[SIGNAL_SIGNAL_CHANGED] =
g_signal_new ("signal-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerChannelClass,
signal_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
g_signal_new ("signal-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerChannelClass,
signal_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_tuner_channel_dispose;
}
static void
gst_tuner_channel_init (GstTunerChannel *channel)
gst_tuner_channel_init (GstTunerChannel * channel)
{
channel->label = NULL;
channel->flags = 0;
@ -102,7 +100,7 @@ gst_tuner_channel_init (GstTunerChannel *channel)
}
static void
gst_tuner_channel_dispose (GObject *object)
gst_tuner_channel_dispose (GObject * object)
{
GstTunerChannel *channel = GST_TUNER_CHANNEL (object);

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_TUNER_CHANNEL \
(gst_tuner_channel_get_type ())
#define GST_TUNER_CHANNEL(obj) \
@ -38,42 +37,39 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TUNER_CHANNEL))
#define GST_IS_TUNER_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER_CHANNEL))
typedef enum {
GST_TUNER_CHANNEL_INPUT = (1<<0),
GST_TUNER_CHANNEL_OUTPUT = (1<<1),
GST_TUNER_CHANNEL_FREQUENCY = (1<<2),
GST_TUNER_CHANNEL_AUDIO = (1<<3),
typedef enum
{
GST_TUNER_CHANNEL_INPUT = (1 << 0),
GST_TUNER_CHANNEL_OUTPUT = (1 << 1),
GST_TUNER_CHANNEL_FREQUENCY = (1 << 2),
GST_TUNER_CHANNEL_AUDIO = (1 << 3),
} GstTunerChannelFlags;
#define GST_TUNER_CHANNEL_HAS_FLAG(channel, flag) \
((channel)->flags & flag)
typedef struct _GstTunerChannel {
GObject parent;
typedef struct _GstTunerChannel
{
GObject parent;
gchar *label;
gchar *label;
GstTunerChannelFlags flags;
gulong min_frequency,
max_frequency;
gint min_signal,
max_signal;
gulong min_frequency, max_frequency;
gint min_signal, max_signal;
} GstTunerChannel;
typedef struct _GstTunerChannelClass {
typedef struct _GstTunerChannelClass
{
GObjectClass parent;
/* signals */
void (*frequency_changed) (GstTunerChannel *channel,
gulong frequency);
void (*signal_changed) (GstTunerChannel *channel,
gint signal);
void (*frequency_changed) (GstTunerChannel * channel, gulong frequency);
void (*signal_changed) (GstTunerChannel * channel, gint signal);
gpointer _gst_reserved[GST_PADDING];
} GstTunerChannelClass;
GType gst_tuner_channel_get_type (void);
GType gst_tuner_channel_get_type (void);
G_END_DECLS
#endif /* __GST_TUNER_CHANNEL_H__ */

View file

@ -25,16 +25,18 @@
#include "tunernorm.h"
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
static void gst_tuner_norm_class_init (GstTunerNormClass *klass);
static void gst_tuner_norm_init (GstTunerNorm *norm);
static void gst_tuner_norm_dispose (GObject *object);
static void gst_tuner_norm_class_init (GstTunerNormClass * klass);
static void gst_tuner_norm_init (GstTunerNorm * norm);
static void gst_tuner_norm_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
/*static guint signals[LAST_SIGNAL] = { 0 };*/
GType
@ -58,15 +60,14 @@ gst_tuner_norm_get_type (void)
gst_tuner_norm_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerNorm",
&tuner_norm_info, 0);
"GstTunerNorm", &tuner_norm_info, 0);
}
return gst_tuner_norm_type;
}
static void
gst_tuner_norm_class_init (GstTunerNormClass *klass)
gst_tuner_norm_class_init (GstTunerNormClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
@ -76,14 +77,14 @@ gst_tuner_norm_class_init (GstTunerNormClass *klass)
}
static void
gst_tuner_norm_init (GstTunerNorm *norm)
gst_tuner_norm_init (GstTunerNorm * norm)
{
norm->label = NULL;
norm->fps = 0.;
}
static void
gst_tuner_norm_dispose (GObject *object)
gst_tuner_norm_dispose (GObject * object)
{
GstTunerNorm *norm = GST_TUNER_NORM (object);

View file

@ -25,7 +25,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_TUNER_NORM \
(gst_tuner_norm_get_type ())
#define GST_TUNER_NORM(obj) \
@ -36,22 +35,22 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TUNER_NORM))
#define GST_IS_TUNER_NORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER_NORM))
typedef struct _GstTunerNorm {
typedef struct _GstTunerNorm
{
GObject parent;
gchar *label;
gfloat fps;
gchar *label;
gfloat fps;
} GstTunerNorm;
typedef struct _GstTunerNormClass {
typedef struct _GstTunerNormClass
{
GObjectClass parent;
gpointer _gst_reserved[GST_PADDING];
} GstTunerNormClass;
GType gst_tuner_norm_get_type (void);
GType gst_tuner_norm_get_type (void);
G_END_DECLS
#endif /* __GST_TUNER_NORM_H__ */

View file

@ -29,19 +29,19 @@ static GstElementClass *parent_class = NULL;
/* Private methods */
static void
gst_videosink_set_clock (GstElement *element, GstClock *clock)
gst_videosink_set_clock (GstElement * element, GstClock * clock)
{
GstVideoSink *videosink;
videosink = GST_VIDEOSINK (element);
videosink->clock = clock;
}
/* Initing stuff */
static void
gst_videosink_init (GstVideoSink *videosink)
gst_videosink_init (GstVideoSink * videosink)
{
videosink->width = 0;
videosink->height = 0;
@ -49,13 +49,13 @@ gst_videosink_init (GstVideoSink *videosink)
}
static void
gst_videosink_class_init (GstVideoSinkClass *klass)
gst_videosink_class_init (GstVideoSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
@ -69,24 +69,22 @@ gst_videosink_get_type (void)
{
static GType videosink_type = 0;
if (!videosink_type)
{
static const GTypeInfo videosink_info = {
sizeof (GstVideoSinkClass),
NULL,
NULL,
(GClassInitFunc) gst_videosink_class_init,
NULL,
NULL,
sizeof (GstVideoSink),
0,
(GInstanceInitFunc) gst_videosink_init,
};
videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstVideoSink",
&videosink_info, 0);
}
if (!videosink_type) {
static const GTypeInfo videosink_info = {
sizeof (GstVideoSinkClass),
NULL,
NULL,
(GClassInitFunc) gst_videosink_class_init,
NULL,
NULL,
sizeof (GstVideoSink),
0,
(GInstanceInitFunc) gst_videosink_init,
};
videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstVideoSink", &videosink_info, 0);
}
return videosink_type;
}

View file

@ -27,7 +27,7 @@
/* This is simply a convenience function, nothing more or less */
gdouble
gst_video_frame_rate (GstPad *pad)
gst_video_frame_rate (GstPad * pad)
{
gdouble fps = 0.;
const GstCaps *caps = NULL;
@ -37,30 +37,25 @@ gst_video_frame_rate (GstPad *pad)
caps = GST_PAD_CAPS (pad);
if (caps == NULL) {
g_warning ("gstvideo: failed to get caps of pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME(pad));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0.;
}
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_double (structure, "framerate", &fps)){
if (!gst_structure_get_double (structure, "framerate", &fps)) {
g_warning ("gstvideo: failed to get framerate property of pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME (pad));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0.;
}
GST_DEBUG ("Framerate request on pad %s:%s: %f",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME(pad), fps);
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad), fps);
return fps;
}
gboolean
gst_video_get_size (GstPad *pad,
gint *width,
gint *height)
gst_video_get_size (GstPad * pad, gint * width, gint * height)
{
const GstCaps *caps = NULL;
GstStructure *structure;
@ -74,8 +69,7 @@ gst_video_get_size (GstPad *pad,
if (caps == NULL) {
g_warning ("gstvideo: failed to get caps of pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME(pad));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return FALSE;
}
@ -85,34 +79,25 @@ gst_video_get_size (GstPad *pad,
if (!ret) {
g_warning ("gstvideo: failed to get size properties on pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME(pad));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return FALSE;
}
GST_DEBUG ("size request on pad %s:%s: %dx%d",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME (pad),
width ? *width : -1,
height ? *height : -1);
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
return TRUE;
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstvideo",
"Convenience routines for video plugins",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstvideo",
"Convenience routines for video plugins",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)

View file

@ -98,31 +98,31 @@
#define GST_VIDEO_CAPS_RGBx \
__GST_VIDEO_CAPS_MAKE_32 (1, 2, 3)
#define GST_VIDEO_CAPS_xRGB \
__GST_VIDEO_CAPS_MAKE_32 (2, 3, 4)
#define GST_VIDEO_CAPS_BGRx \
__GST_VIDEO_CAPS_MAKE_32 (3, 2, 1)
#define GST_VIDEO_CAPS_xBGR \
__GST_VIDEO_CAPS_MAKE_32 (4, 3, 2)
/* note: the macro name uses the order on BE systems */
#if G_BYTE_ORDER == G_BIG_ENDIAN
#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
GST_VIDEO_CAPS_xRGB
#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
GST_VIDEO_CAPS_BGRx
#else
#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
GST_VIDEO_CAPS_BGRx
#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
GST_VIDEO_CAPS_xRGB
#endif
/* 15/16 bit */
#define GST_VIDEO_CAPS_RGB_16 \
"video/x-raw-rgb, " \
"bpp = (int) 16, " \
@ -155,9 +155,7 @@
"framerate = " GST_VIDEO_FPS_RANGE
/* functions */
gdouble gst_video_frame_rate (GstPad *pad);
gboolean gst_video_get_size (GstPad *pad,
gint *width,
gint *height);
gdouble gst_video_frame_rate (GstPad * pad);
gboolean gst_video_get_size (GstPad * pad, gint * width, gint * height);
#endif /* __GST_VIDEO_H__ */

View file

@ -17,16 +17,17 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GST_VIDEOSINK_H__
#define __GST_VIDEOSINK_H__
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern "C"
{
#endif /* __cplusplus */
#define GST_TYPE_VIDEOSINK (gst_videosink_get_type())
#define GST_VIDEOSINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VIDEOSINK, GstVideoSink))
@ -38,37 +39,39 @@ extern "C" {
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VIDEOSINK))
#define GST_VIDEOSINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VIDEOSINK, GstVideoSinkClass))
#define GST_VIDEOSINK_PAD(obj) (GST_VIDEOSINK (obj)->sinkpad)
#define GST_VIDEOSINK_WIDTH(obj) (GST_VIDEOSINK (obj)->width)
#define GST_VIDEOSINK_HEIGHT(obj) (GST_VIDEOSINK (obj)->height)
#define GST_VIDEOSINK_CLOCK(obj) (GST_VIDEOSINK (obj)->clock)
typedef struct _GstVideoSink GstVideoSink;
typedef struct _GstVideoSinkClass GstVideoSinkClass;
struct _GstVideoSink {
GstElement element;
GstPad *sinkpad;
gint width, height;
GstClock *clock;
gpointer _gst_reserved[GST_PADDING];
};
typedef struct _GstVideoSink GstVideoSink;
typedef struct _GstVideoSinkClass GstVideoSinkClass;
struct _GstVideoSinkClass {
GstElementClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstVideoSink
{
GstElement element;
GType gst_videosink_get_type (void);
GstPad *sinkpad;
gint width, height;
GstClock *clock;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstVideoSinkClass
{
GstElementClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
GType gst_videosink_get_type (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* __GST_VIDEOSINK_H__ */
#endif /* __GST_VIDEOSINK_H__ */

View file

@ -25,7 +25,8 @@
#include "xoverlay.h"
enum {
enum
{
HAVE_XWINDOW_ID,
DESIRED_SIZE,
LAST_SIGNAL
@ -54,44 +55,40 @@ gst_x_overlay_get_type (void)
};
gst_x_overlay_type = g_type_register_static (G_TYPE_INTERFACE,
"GstXOverlay",
&gst_x_overlay_info, 0);
"GstXOverlay", &gst_x_overlay_info, 0);
g_type_interface_add_prerequisite (gst_x_overlay_type,
GST_TYPE_IMPLEMENTS_INTERFACE);
GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_x_overlay_type;
}
/* FIXME: evil hack, we should figure out our marshal handling in this interfaces some day */
extern void gst_marshal_VOID__INT_INT (GClosure *closure, GValue *return_value, guint n_param_values,
const GValue *param_values, gpointer invocation_hint, gpointer marshal_data);
extern void gst_marshal_VOID__INT_INT (GClosure * closure,
GValue * return_value, guint n_param_values, const GValue * param_values,
gpointer invocation_hint, gpointer marshal_data);
static void
gst_x_overlay_base_init (gpointer g_class)
{
GstXOverlayClass *overlay_class = (GstXOverlayClass *) g_class;
static gboolean initialized = FALSE;
if (! initialized)
{
gst_x_overlay_signals[HAVE_XWINDOW_ID] =
g_signal_new ("have-xwindow-id",
GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstXOverlayClass, have_xwindow_id),
NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1,
G_TYPE_INT);
gst_x_overlay_signals[DESIRED_SIZE] =
g_signal_new ("desired-size-changed",
GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstXOverlayClass, desired_size),
NULL, NULL,
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_INT);
initialized = TRUE;
}
if (!initialized) {
gst_x_overlay_signals[HAVE_XWINDOW_ID] =
g_signal_new ("have-xwindow-id",
GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstXOverlayClass, have_xwindow_id),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gst_x_overlay_signals[DESIRED_SIZE] =
g_signal_new ("desired-size-changed",
GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstXOverlayClass, desired_size),
NULL, NULL,
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
initialized = TRUE;
}
overlay_class->set_xwindow_id = NULL;
}
@ -107,7 +104,7 @@ gst_x_overlay_base_init (gpointer g_class)
* stop using that window and create an internal one.
*/
void
gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, gulong xwindow_id)
gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
{
GstXOverlayClass *klass = GST_X_OVERLAY_GET_CLASS (overlay);
@ -126,13 +123,13 @@ gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, gulong xwindow_id)
* This function should be used by video overlay developpers.
*/
void
gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id)
gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
{
g_return_if_fail (overlay != NULL);
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
g_signal_emit (G_OBJECT (overlay),
gst_x_overlay_signals[HAVE_XWINDOW_ID], 0, (gint) xwindow_id);
gst_x_overlay_signals[HAVE_XWINDOW_ID], 0, (gint) xwindow_id);
}
/**
@ -145,18 +142,20 @@ gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id)
* size, width and height are set to 0.
*/
void
gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height)
gst_x_overlay_get_desired_size (GstXOverlay * overlay, guint * width,
guint * height)
{
guint width_tmp, height_tmp;
GstXOverlayClass *klass;
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE ((overlay), GST_TYPE_X_OVERLAY));
klass = GST_X_OVERLAY_GET_CLASS (overlay);
if (klass->get_desired_size && GST_IS_X_OVERLAY (overlay)) {
/* this ensures that elements don't need to check width and height for NULL
but apps may use NULL */
klass->get_desired_size (overlay, width ? width : &width_tmp, height ? height : &height_tmp);
klass->get_desired_size (overlay, width ? width : &width_tmp,
height ? height : &height_tmp);
} else {
if (width)
*width = 0;
@ -176,12 +175,13 @@ gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *heigh
* This function should be used by video overlay developpers.
*/
void
gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height)
gst_x_overlay_got_desired_size (GstXOverlay * overlay, guint width,
guint height)
{
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
g_signal_emit (G_OBJECT (overlay),
gst_x_overlay_signals[DESIRED_SIZE], 0, width, height);
gst_x_overlay_signals[DESIRED_SIZE], 0, width, height);
}
/**
@ -192,7 +192,7 @@ gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height)
* in the drawable even if the pipeline is PAUSED.
*/
void
gst_x_overlay_expose (GstXOverlay *overlay)
gst_x_overlay_expose (GstXOverlay * overlay)
{
GstXOverlayClass *klass = GST_X_OVERLAY_GET_CLASS (overlay);

View file

@ -26,7 +26,6 @@
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_X_OVERLAY \
(gst_x_overlay_get_type ())
#define GST_X_OVERLAY(obj) \
@ -40,42 +39,38 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_X_OVERLAY))
#define GST_X_OVERLAY_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_X_OVERLAY, GstXOverlayClass))
typedef struct _GstXOverlay GstXOverlay;
typedef struct _GstXOverlayClass {
typedef struct _GstXOverlayClass
{
GTypeInterface klass;
/* virtual functions */
void (* set_xwindow_id) (GstXOverlay *overlay,
gulong xwindow_id);
void (*set_xwindow_id) (GstXOverlay * overlay, gulong xwindow_id);
/* optional virtual functions */
void (* get_desired_size) (GstXOverlay *overlay,
guint *width,
guint *height);
void (* expose) (GstXOverlay *overlay);
void (*get_desired_size) (GstXOverlay * overlay,
guint * width, guint * height);
void (*expose) (GstXOverlay * overlay);
/* signals */
void (*have_xwindow_id) (GstXOverlay *overlay,
gulong xwindow_id);
void (* desired_size) (GstXOverlay *overlay,
guint width,
guint height);
void (*have_xwindow_id) (GstXOverlay * overlay, gulong xwindow_id);
void (*desired_size) (GstXOverlay * overlay, guint width, guint height);
gpointer _gst_reserved[GST_PADDING];
} GstXOverlayClass;
GType gst_x_overlay_get_type (void);
GType gst_x_overlay_get_type (void);
/* virtual class function wrappers */
void gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, gulong xwindow_id);
void gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height);
void gst_x_overlay_expose (GstXOverlay *overlay);
void gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
void gst_x_overlay_get_desired_size (GstXOverlay * overlay, guint * width,
guint * height);
void gst_x_overlay_expose (GstXOverlay * overlay);
/* public methods to fire signals */
void gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id);
void gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height);
void gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
void gst_x_overlay_got_desired_size (GstXOverlay * overlay, guint width,
guint height);
G_END_DECLS
#endif /* __GST_X_OVERLAY_H__ */

View file

@ -28,12 +28,12 @@
#define NUM_CLIPS 1024
static void gst_x_window_listener_class_init (GstXWindowListenerClass *klass);
static void gst_x_window_listener_init (GstXWindowListener *xwin);
static void gst_x_window_listener_dispose (GObject *object);
static void gst_x_window_listener_class_init (GstXWindowListenerClass * klass);
static void gst_x_window_listener_init (GstXWindowListener * xwin);
static void gst_x_window_listener_dispose (GObject * object);
static void gst_xwin_start (GstXWindowListener *xwin);
static void gst_xwin_stop (GstXWindowListener *xwin);
static void gst_xwin_start (GstXWindowListener * xwin);
static void gst_xwin_stop (GstXWindowListener * xwin);
static GObjectClass *parent_class = NULL;
@ -58,15 +58,14 @@ gst_x_window_listener_get_type (void)
x_window_listener_type =
g_type_register_static (G_TYPE_OBJECT,
"GstXWindowListener",
&x_window_listener_info, 0);
"GstXWindowListener", &x_window_listener_info, 0);
}
return x_window_listener_type;
}
static void
gst_x_window_listener_class_init (GstXWindowListenerClass *klass)
gst_x_window_listener_class_init (GstXWindowListenerClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
@ -76,7 +75,7 @@ gst_x_window_listener_class_init (GstXWindowListenerClass *klass)
}
static void
gst_x_window_listener_init (GstXWindowListener *xwin)
gst_x_window_listener_init (GstXWindowListener * xwin)
{
xwin->xwindow_id = 0;
xwin->display_name = NULL;
@ -88,7 +87,7 @@ gst_x_window_listener_init (GstXWindowListener *xwin)
}
static void
gst_x_window_listener_dispose (GObject *object)
gst_x_window_listener_dispose (GObject * object)
{
GstXWindowListener *xwin = GST_X_WINDOW_LISTENER (object);
@ -105,13 +104,11 @@ gst_x_window_listener_dispose (GObject *object)
}
GstXWindowListener *
gst_x_window_listener_new (gchar *display,
MapWindowFunc map_window_func,
SetWindowFunc set_window_func,
gpointer private_data)
gst_x_window_listener_new (gchar * display,
MapWindowFunc map_window_func,
SetWindowFunc set_window_func, gpointer private_data)
{
GstXWindowListener *xwin =
g_object_new (GST_TYPE_X_WINDOW_LISTENER, NULL);
GstXWindowListener *xwin = g_object_new (GST_TYPE_X_WINDOW_LISTENER, NULL);
xwin->display_name = g_strdup (display);
xwin->map_window_func = map_window_func;
@ -122,8 +119,7 @@ gst_x_window_listener_new (gchar *display,
}
void
gst_x_window_listener_set_xid (GstXWindowListener *xwin,
XID id)
gst_x_window_listener_set_xid (GstXWindowListener * xwin, XID id)
{
g_return_if_fail (xwin != NULL);
@ -137,9 +133,7 @@ gst_x_window_listener_set_xid (GstXWindowListener *xwin,
xwin->xwindow_id = id;
if (xwin->xwindow_id &&
xwin->display_name &&
xwin->display_name[0] == ':') {
if (xwin->xwindow_id && xwin->display_name && xwin->display_name[0] == ':') {
g_return_if_fail (xwin->map_window_func != NULL);
g_return_if_fail (xwin->set_window_func != NULL);
@ -163,8 +157,7 @@ gst_x_window_listener_set_xid (GstXWindowListener *xwin,
GST_DEBUG ("XWL: " format, ##args)
static void
gst_xwin_set_overlay (GstXWindowListener *xwin,
gboolean on)
gst_xwin_set_overlay (GstXWindowListener * xwin, gboolean on)
{
xwin->map_window_func (xwin->private_data, on);
@ -190,22 +183,20 @@ gst_xwin_refresh (gpointer data)
if (!xwin->ov_move && xwin->ov_map &&
xwin->ov_visibility == VisibilityUnobscured) {
g_mutex_unlock (xwin->main_lock);
return FALSE; /* skip */
return FALSE; /* skip */
}
if (xwin->ov_map &&
xwin->ov_visibility != VisibilityFullyObscured) {
if (xwin->ov_map && xwin->ov_visibility != VisibilityFullyObscured) {
xwin->ov_refresh = TRUE;
}
xswa.override_redirect = True;
xswa.backing_store = NotUseful;
xswa.save_under = False;
tmp = XCreateWindow (xwin->main_display,win, 0, 0,
attr.width, attr.height, 0,
CopyFromParent, InputOutput, CopyFromParent,
(CWSaveUnder | CWBackingStore| CWOverrideRedirect ),
&xswa);
tmp = XCreateWindow (xwin->main_display, win, 0, 0,
attr.width, attr.height, 0,
CopyFromParent, InputOutput, CopyFromParent,
(CWSaveUnder | CWBackingStore | CWOverrideRedirect), &xswa);
XMapWindow (xwin->main_display, tmp);
XUnmapWindow (xwin->main_display, tmp);
XDestroyWindow (xwin->main_display, tmp);
@ -218,10 +209,9 @@ gst_xwin_refresh (gpointer data)
}
static int
x11_error_dev_null (Display *display,
XErrorEvent *event)
x11_error_dev_null (Display * display, XErrorEvent * event)
{
return 0;
return 0;
}
#define ADD_CLIP(_x, _y, _w, _h) \
@ -235,7 +225,7 @@ x11_error_dev_null (Display *display,
} while (0);
static void
gst_xwin_set_clips (GstXWindowListener *xwin)
gst_xwin_set_clips (GstXWindowListener * xwin)
{
Window root, rroot, parent, *kids, me;
XWindowAttributes attr;
@ -286,10 +276,9 @@ gst_xwin_set_clips (GstXWindowListener *xwin)
y1 = attr.y - xwin->y;
w1 = attr.width + 2 * attr.border_width;
h1 = attr.height + 2 * attr.border_width;
if (((x1 + w1) < 0) || (x1 > xwin->w) ||
((y1 + h1) < 0) || (y1 > xwin->h))
if (((x1 + w1) < 0) || (x1 > xwin->w) || ((y1 + h1) < 0) || (y1 > xwin->h))
continue;
if (x1 < 0)
x1 = 0;
if (y1 < 0)
@ -306,7 +295,7 @@ gst_xwin_set_clips (GstXWindowListener *xwin)
static gboolean
gst_xwin_window (GstXWindowListener *xwin)
gst_xwin_window (GstXWindowListener * xwin)
{
if (xwin->ov_map && xwin->ov_wmmap &&
xwin->ov_visibility != VisibilityFullyObscured) {
@ -318,20 +307,17 @@ gst_xwin_window (GstXWindowListener *xwin)
if (xwin->ov_conf) {
xwin->set_window_func (xwin->private_data,
xwin->x, xwin->y,
xwin->w, xwin->h,
xwin->clips, xwin->num_clips);
xwin->x, xwin->y, xwin->w, xwin->h, xwin->clips, xwin->num_clips);
if (!xwin->ov_visible)
gst_xwin_set_overlay (xwin, TRUE);
gst_xwin_set_overlay (xwin, TRUE);
g_mutex_lock (xwin->main_lock);
if (xwin->ov_refresh_id)
g_source_remove (xwin->ov_refresh_id);
g_source_remove (xwin->ov_refresh_id);
xwin->ov_refresh_id =
g_timeout_add (200, (GSourceFunc) gst_xwin_refresh,
(gpointer) xwin);
g_timeout_add (200, (GSourceFunc) gst_xwin_refresh, (gpointer) xwin);
xwin->ov_conf = FALSE;
@ -345,10 +331,9 @@ gst_xwin_window (GstXWindowListener *xwin)
g_mutex_lock (xwin->main_lock);
if (xwin->ov_refresh_id)
g_source_remove (xwin->ov_refresh_id);
g_source_remove (xwin->ov_refresh_id);
xwin->ov_refresh_id =
g_timeout_add (200, (GSourceFunc) gst_xwin_refresh,
(gpointer) xwin);
g_timeout_add (200, (GSourceFunc) gst_xwin_refresh, (gpointer) xwin);
xwin->ov_conf = FALSE;
@ -363,31 +348,28 @@ gst_xwin_window (GstXWindowListener *xwin)
}
static void
gst_xwin_configure (GstXWindowListener *xwin)
gst_xwin_configure (GstXWindowListener * xwin)
{
#if 0
/* This part is disabled, because the idle task will be done
* in the main thread instead of here. */
if (!xwin->ov_conf_id)
xwin->ov_conf_id =
g_idle_add ((GSourceFunc) gst_rec_xoverlay_window,
(gpointer) xwin);
g_idle_add ((GSourceFunc) gst_rec_xoverlay_window, (gpointer) xwin);
#endif
gst_xwin_window ((gpointer) xwin);
}
static void
gst_xwin_resize (GstXWindowListener *xwin)
gst_xwin_resize (GstXWindowListener * xwin)
{
Drawable drawable, parent, *kids, root;
guint numkids;
XWindowAttributes attr;
XGetWindowAttributes (xwin->display,
xwin->xwindow_id, &attr);
XMoveResizeWindow (xwin->display, xwin->child,
0, 0, attr.width, attr.height);
XGetWindowAttributes (xwin->display, xwin->xwindow_id, &attr);
XMoveResizeWindow (xwin->display, xwin->child, 0, 0, attr.width, attr.height);
/* set the video window - the first clip is our own window */
xwin->x = 0;
@ -397,10 +379,9 @@ gst_xwin_resize (GstXWindowListener *xwin)
drawable = xwin->child;
while (1) {
XQueryTree (xwin->display, drawable,
&root, &parent, &kids, &numkids);
XQueryTree (xwin->display, drawable, &root, &parent, &kids, &numkids);
if (numkids)
XFree(kids);
XFree (kids);
drawable = parent;
XGetWindowAttributes (xwin->display, drawable, &attr);
xwin->x += attr.x;
@ -416,7 +397,7 @@ gst_xwin_resize (GstXWindowListener *xwin)
}
static void
gst_xwin_init_window (GstXWindowListener *xwin)
gst_xwin_init_window (GstXWindowListener * xwin)
{
XWindowAttributes attr;
@ -438,20 +419,16 @@ gst_xwin_init_window (GstXWindowListener *xwin)
xwin->display = XOpenDisplay (xwin->display_name);
/* window */
XGetWindowAttributes (xwin->display,
xwin->xwindow_id, &attr);
XGetWindowAttributes (xwin->display, xwin->xwindow_id, &attr);
xwin->child = XCreateSimpleWindow (xwin->display,
xwin->xwindow_id, 0, 0,
attr.width, attr.height, 0, 0, 0);
xwin->xwindow_id, 0, 0, attr.width, attr.height, 0, 0, 0);
/* listen to certain X events */
XSelectInput (xwin->display, xwin->xwindow_id,
StructureNotifyMask);
XSelectInput (xwin->display, xwin->xwindow_id, StructureNotifyMask);
XSelectInput (xwin->display, xwin->child,
VisibilityChangeMask | StructureNotifyMask);
VisibilityChangeMask | StructureNotifyMask);
XSelectInput (xwin->display, DefaultRootWindow (xwin->display),
VisibilityChangeMask | StructureNotifyMask |
SubstructureNotifyMask);
VisibilityChangeMask | StructureNotifyMask | SubstructureNotifyMask);
/* show */
XMapWindow (xwin->display, xwin->child);
@ -460,7 +437,7 @@ gst_xwin_init_window (GstXWindowListener *xwin)
}
static void
gst_xwin_exit_window (GstXWindowListener *xwin)
gst_xwin_exit_window (GstXWindowListener * xwin)
{
/* disable overlay */
gst_xwin_set_overlay (xwin, FALSE);
@ -496,89 +473,89 @@ gst_xwin_thread (gpointer data)
break;
if ((event.type == ConfigureNotify &&
event.xconfigure.window == xwin->xwindow_id) ||
(event.type == MapNotify &&
event.xmap.window == xwin->xwindow_id) ||
(event.type == UnmapNotify &&
event.xunmap.window == xwin->xwindow_id)) {
event.xconfigure.window == xwin->xwindow_id) ||
(event.type == MapNotify &&
event.xmap.window == xwin->xwindow_id) ||
(event.type == UnmapNotify &&
event.xunmap.window == xwin->xwindow_id)) {
/* the 'parent' window, i.e. the widget provided by client */
switch (event.type) {
case MapNotify:
xwin->ov_map = TRUE;
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
break;
case MapNotify:
xwin->ov_map = TRUE;
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
break;
case UnmapNotify:
xwin->ov_map = FALSE;
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
break;
case UnmapNotify:
xwin->ov_map = FALSE;
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
break;
case ConfigureNotify:
gst_xwin_resize (xwin);
break;
case ConfigureNotify:
gst_xwin_resize (xwin);
break;
default:
/* nothing */
break;
default:
/* nothing */
break;
}
} else if (event.xany.window == xwin->child) {
/* our own private window */
switch (event.type) {
case Expose:
if (!event.xexpose.count) {
if (xwin->ov_refresh) {
xwin->ov_refresh = FALSE;
} else {
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
}
}
break;
case Expose:
if (!event.xexpose.count) {
if (xwin->ov_refresh) {
xwin->ov_refresh = FALSE;
} else {
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
}
}
break;
case VisibilityNotify:
xwin->ov_visibility = event.xvisibility.state;
if (xwin->ov_refresh) {
if (event.xvisibility.state != VisibilityFullyObscured)
xwin->ov_refresh = FALSE;
} else {
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
}
break;
case VisibilityNotify:
xwin->ov_visibility = event.xvisibility.state;
if (xwin->ov_refresh) {
if (event.xvisibility.state != VisibilityFullyObscured)
xwin->ov_refresh = FALSE;
} else {
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
}
break;
default:
/* nothing */
break;
default:
/* nothing */
break;
}
} else {
/* root window */
switch (event.type) {
case MapNotify:
case UnmapNotify:
/* are we still visible? */
if (!xwin->ov_refresh) {
XWindowAttributes attr;
gboolean on;
XGetWindowAttributes (xwin->display,
xwin->xwindow_id, &attr);
on = (attr.map_state == IsViewable);
xwin->ov_wmmap = on;
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
}
break;
case MapNotify:
case UnmapNotify:
/* are we still visible? */
if (!xwin->ov_refresh) {
XWindowAttributes attr;
gboolean on;
case ConfigureNotify:
if (!xwin->ov_refresh) {
gst_xwin_resize (xwin);
}
break;
XGetWindowAttributes (xwin->display, xwin->xwindow_id, &attr);
on = (attr.map_state == IsViewable);
xwin->ov_wmmap = on;
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
}
break;
default:
/* nothing */
break;
case ConfigureNotify:
if (!xwin->ov_refresh) {
gst_xwin_resize (xwin);
}
break;
default:
/* nothing */
break;
}
}
}
@ -592,7 +569,7 @@ gst_xwin_thread (gpointer data)
}
static void
gst_xwin_start (GstXWindowListener *xwin)
gst_xwin_start (GstXWindowListener * xwin)
{
DEBUG ("Starting XWindow listener");
@ -603,15 +580,13 @@ gst_xwin_start (GstXWindowListener *xwin)
* event handler after we've stopped it */
xwin->main_lock = g_mutex_new ();
xwin->main_display = XOpenDisplay (xwin->display_name);
xwin->thread = g_thread_create (gst_xwin_thread,
(gpointer) xwin,
TRUE, NULL);
xwin->thread = g_thread_create (gst_xwin_thread, (gpointer) xwin, TRUE, NULL);
DEBUG ("Started X-overlay");
}
static void
gst_xwin_stop (GstXWindowListener *xwin)
gst_xwin_stop (GstXWindowListener * xwin)
{
DEBUG ("Stopping XWindow listener");
@ -637,19 +612,13 @@ gst_xwin_stop (GstXWindowListener *xwin)
*/
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"xwindowlistener",
"X11-based XWindow event/motion listener",
plugin_init,
VERSION,
GST_LICENSE,
GST_PACKAGE,
GST_ORIGIN
)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"xwindowlistener",
"X11-based XWindow event/motion listener",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)

View file

@ -26,7 +26,6 @@
#include <X11/Xlib.h>
G_BEGIN_DECLS
#define GST_TYPE_X_WINDOW_LISTENER \
(gst_x_window_listener_get_type())
#define GST_X_WINDOW_LISTENER(obj) \
@ -39,28 +38,22 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_X_WINDOW_LISTENER))
#define GST_IS_X_WINDOW_LISTENER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_X_WINDOW_LISTENER))
typedef struct _GstXWindowListener GstXWindowListener;
typedef struct _GstXWindowListenerClass GstXWindowListenerClass;
typedef struct _GstXWindowClip GstXWindowClip;
typedef void (*MapWindowFunc) (gpointer your_data, gboolean visible);
typedef void (*SetWindowFunc) (gpointer your_data,
gint x, gint y, gint w, gint h, GstXWindowClip * clips, gint num_clips);
typedef struct _GstXWindowListener GstXWindowListener;
typedef struct _GstXWindowListenerClass GstXWindowListenerClass;
typedef struct _GstXWindowClip GstXWindowClip;
typedef void (* MapWindowFunc) (gpointer your_data,
gboolean visible);
typedef void (* SetWindowFunc) (gpointer your_data,
gint x, gint y,
gint w, gint h,
GstXWindowClip *clips,
gint num_clips);
struct _GstXWindowClip {
gint32 x_offset,
y_offset,
width,
height;
struct _GstXWindowClip
{
gint32 x_offset, y_offset, width, height;
gpointer data;
};
struct _GstXWindowListener {
GObject parent;
struct _GstXWindowListener
{
GObject parent;
/* "per-instance virtual functions" */
MapWindowFunc map_window_func;
@ -70,12 +63,12 @@ struct _GstXWindowListener {
gpointer private_data;
/* general information of what we're doing */
gchar *display_name;
XID xwindow_id;
gchar *display_name;
XID xwindow_id;
/* one extra... */
Display *main_display;
GMutex *main_lock;
GMutex *main_lock;
/* oh my g*d, this is going to be so horribly ugly */
GThread *thread;
@ -84,33 +77,24 @@ struct _GstXWindowListener {
/* the overlay window + own thread */
Display *display;
Drawable child;
gboolean ov_conf,
ov_map,
ov_visible,
ov_refresh,
ov_move,
ov_wmmap;
gint ov_visibility;
guint ov_conf_id,
ov_refresh_id;
gint x, y, w, h;
gboolean ov_conf, ov_map, ov_visible, ov_refresh, ov_move, ov_wmmap;
gint ov_visibility;
guint ov_conf_id, ov_refresh_id;
gint x, y, w, h;
GstXWindowClip *clips;
gint num_clips;
gint num_clips;
};
struct _GstXWindowListenerClass {
struct _GstXWindowListenerClass
{
GObjectClass parent;
};
GType gst_x_window_listener_get_type (void);
GstXWindowListener *
gst_x_window_listener_new (gchar *display,
MapWindowFunc map_window_func,
SetWindowFunc set_window_func,
gpointer private_data);
void gst_x_window_listener_set_xid (GstXWindowListener *xwin,
XID id);
GType gst_x_window_listener_get_type (void);
GstXWindowListener *gst_x_window_listener_new (gchar * display,
MapWindowFunc map_window_func,
SetWindowFunc set_window_func, gpointer private_data);
void gst_x_window_listener_set_xid (GstXWindowListener * xwin, XID id);
G_END_DECLS
#endif /* __X_WINDOW_LISTENER_H__ */

View file

@ -28,110 +28,102 @@
#include <gstac3parse.h>
/* struct and table stolen from ac3dec by Aaron Holtzman */
struct frmsize_s {
struct frmsize_s
{
guint16 bit_rate;
guint16 frm_size[3];
};
static struct frmsize_s frmsizecod_tbl[] = {
{ 32 ,{64 ,69 ,96 } },
{ 32 ,{64 ,70 ,96 } },
{ 40 ,{80 ,87 ,120 } },
{ 40 ,{80 ,88 ,120 } },
{ 48 ,{96 ,104 ,144 } },
{ 48 ,{96 ,105 ,144 } },
{ 56 ,{112 ,121 ,168 } },
{ 56 ,{112 ,122 ,168 } },
{ 64 ,{128 ,139 ,192 } },
{ 64 ,{128 ,140 ,192 } },
{ 80 ,{160 ,174 ,240 } },
{ 80 ,{160 ,175 ,240 } },
{ 96 ,{192 ,208 ,288 } },
{ 96 ,{192 ,209 ,288 } },
{ 112 ,{224 ,243 ,336 } },
{ 112 ,{224 ,244 ,336 } },
{ 128 ,{256 ,278 ,384 } },
{ 128 ,{256 ,279 ,384 } },
{ 160 ,{320 ,348 ,480 } },
{ 160 ,{320 ,349 ,480 } },
{ 192 ,{384 ,417 ,576 } },
{ 192 ,{384 ,418 ,576 } },
{ 224 ,{448 ,487 ,672 } },
{ 224 ,{448 ,488 ,672 } },
{ 256 ,{512 ,557 ,768 } },
{ 256 ,{512 ,558 ,768 } },
{ 320 ,{640 ,696 ,960 } },
{ 320 ,{640 ,697 ,960 } },
{ 384 ,{768 ,835 ,1152 } },
{ 384 ,{768 ,836 ,1152 } },
{ 448 ,{896 ,975 ,1344 } },
{ 448 ,{896 ,976 ,1344 } },
{ 512 ,{1024 ,1114 ,1536 } },
{ 512 ,{1024 ,1115 ,1536 } },
{ 576 ,{1152 ,1253 ,1728 } },
{ 576 ,{1152 ,1254 ,1728 } },
{ 640 ,{1280 ,1393 ,1920 } },
{ 640 ,{1280 ,1394 ,1920 } }};
{32, {64, 69, 96}},
{32, {64, 70, 96}},
{40, {80, 87, 120}},
{40, {80, 88, 120}},
{48, {96, 104, 144}},
{48, {96, 105, 144}},
{56, {112, 121, 168}},
{56, {112, 122, 168}},
{64, {128, 139, 192}},
{64, {128, 140, 192}},
{80, {160, 174, 240}},
{80, {160, 175, 240}},
{96, {192, 208, 288}},
{96, {192, 209, 288}},
{112, {224, 243, 336}},
{112, {224, 244, 336}},
{128, {256, 278, 384}},
{128, {256, 279, 384}},
{160, {320, 348, 480}},
{160, {320, 349, 480}},
{192, {384, 417, 576}},
{192, {384, 418, 576}},
{224, {448, 487, 672}},
{224, {448, 488, 672}},
{256, {512, 557, 768}},
{256, {512, 558, 768}},
{320, {640, 696, 960}},
{320, {640, 697, 960}},
{384, {768, 835, 1152}},
{384, {768, 836, 1152}},
{448, {896, 975, 1344}},
{448, {896, 976, 1344}},
{512, {1024, 1114, 1536}},
{512, {1024, 1115, 1536}},
{576, {1152, 1253, 1728}},
{576, {1152, 1254, 1728}},
{640, {1280, 1393, 1920}},
{640, {1280, 1394, 1920}}
};
/* elementfactory information */
static GstElementDetails ac3parse_details = GST_ELEMENT_DETAILS (
"AC3 Parser",
"Codec/Parser/Audio",
"Parses and frames AC3 audio streams, provides seek",
"Erik Walthinsen <omega@cse.ogi.edu>"
);
static GstElementDetails ac3parse_details = GST_ELEMENT_DETAILS ("AC3 Parser",
"Codec/Parser/Audio",
"Parses and frames AC3 audio streams, provides seek",
"Erik Walthinsen <omega@cse.ogi.edu>");
/* GstAc3Parse signals and args */
enum {
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum {
enum
{
ARG_0,
ARG_SKIP,
/* FILL ME */
};
static GstStaticPadTemplate gst_ac3parse_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/ac3, "
"channels = (int) [ 1, 6 ], "
"rate = (int) [ 32000, 48000 ]"
)
);
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/ac3, "
"channels = (int) [ 1, 6 ], " "rate = (int) [ 32000, 48000 ]")
);
static GstStaticPadTemplate gst_ac3parse_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-ac3")
);
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-ac3")
);
static void gst_ac3parse_class_init (gpointer g_class);
static void gst_ac3parse_init (GstAc3Parse *ac3parse);
static void gst_ac3parse_class_init (gpointer g_class);
static void gst_ac3parse_init (GstAc3Parse * ac3parse);
static void gst_ac3parse_chain (GstPad *pad,
GstData *data);
static void gst_ac3parse_chain (GstPad * pad, GstData * data);
static void gst_ac3parse_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gst_ac3parse_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gst_ac3parse_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_ac3parse_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn
gst_ac3parse_change_state (GstElement *element);
static GstElementStateReturn gst_ac3parse_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
/*static guint gst_ac3parse_signals[LAST_SIGNAL] = { 0 };*/
GType
@ -141,16 +133,18 @@ ac3parse_get_type (void)
if (!ac3parse_type) {
static const GTypeInfo ac3parse_info = {
sizeof(GstAc3ParseClass), NULL,
sizeof (GstAc3ParseClass), NULL,
NULL,
(GClassInitFunc)gst_ac3parse_class_init,
(GClassInitFunc) gst_ac3parse_class_init,
NULL,
NULL,
sizeof(GstAc3Parse),
sizeof (GstAc3Parse),
0,
(GInstanceInitFunc)gst_ac3parse_init,
(GInstanceInitFunc) gst_ac3parse_init,
};
ac3parse_type = g_type_register_static(GST_TYPE_ELEMENT, "GstAc3Parse", &ac3parse_info, 0);
ac3parse_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstAc3Parse", &ac3parse_info,
0);
}
return ac3parse_type;
}
@ -162,22 +156,19 @@ gst_ac3parse_class_init (gpointer g_class)
GstElementClass *gstelement_class;
GstAc3ParseClass *klass;
klass = (GstAc3ParseClass *)g_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
klass = (GstAc3ParseClass *) g_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_ac3parse_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_ac3parse_sink_template));
gst_element_class_set_details (gstelement_class,
&ac3parse_details);
gst_element_class_set_details (gstelement_class, &ac3parse_details);
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SKIP,
g_param_spec_int("skip","skip","skip",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SKIP, g_param_spec_int ("skip", "skip", "skip", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_ac3parse_set_property;
gobject_class->get_property = gst_ac3parse_get_property;
@ -186,15 +177,17 @@ gst_ac3parse_class_init (gpointer g_class)
}
static void
gst_ac3parse_init (GstAc3Parse *ac3parse)
gst_ac3parse_init (GstAc3Parse * ac3parse)
{
ac3parse->sinkpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_ac3parse_sink_template), "sink");
ac3parse->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_ac3parse_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (ac3parse), ac3parse->sinkpad);
gst_pad_set_chain_function (ac3parse->sinkpad, gst_ac3parse_chain);
ac3parse->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_ac3parse_src_template), "src");
ac3parse->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_ac3parse_src_template), "src");
gst_pad_use_explicit_caps (ac3parse->srcpad);
gst_element_add_pad (GST_ELEMENT (ac3parse), ac3parse->srcpad);
@ -205,40 +198,40 @@ gst_ac3parse_init (GstAc3Parse *ac3parse)
}
static void
gst_ac3parse_chain (GstPad *pad, GstData *_data)
gst_ac3parse_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstAc3Parse *ac3parse;
guchar *data;
glong size,offset = 0;
glong size, offset = 0;
guint16 header;
guint8 channeldata, acmod, mask;
GstBuffer *outbuf = NULL;
gint bpf;
guint sample_rate = -1, channels = -1;
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
g_return_if_fail(buf != NULL);
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
/* g_return_if_fail(GST_IS_BUFFER(buf)); */
ac3parse = GST_AC3PARSE(GST_OBJECT_PARENT (pad));
ac3parse = GST_AC3PARSE (GST_OBJECT_PARENT (pad));
GST_DEBUG ("ac3parse: received buffer of %d bytes", GST_BUFFER_SIZE (buf));
/* deal with partial frame from previous buffer */
if (ac3parse->partialbuf) {
GstBuffer *merge;
merge = gst_buffer_merge(ac3parse->partialbuf, buf);
gst_buffer_unref(buf);
gst_buffer_unref(ac3parse->partialbuf);
merge = gst_buffer_merge (ac3parse->partialbuf, buf);
gst_buffer_unref (buf);
gst_buffer_unref (ac3parse->partialbuf);
ac3parse->partialbuf = merge;
}
else {
} else {
ac3parse->partialbuf = buf;
}
data = GST_BUFFER_DATA(ac3parse->partialbuf);
size = GST_BUFFER_SIZE(ac3parse->partialbuf);
data = GST_BUFFER_DATA (ac3parse->partialbuf);
size = GST_BUFFER_SIZE (ac3parse->partialbuf);
/* we're searching for at least 7 bytes. first the
* syncinfo, where 2 bytes are for the syncword
@ -247,142 +240,151 @@ gst_ac3parse_chain (GstPad *pad, GstData *_data)
* bitstreaminfo bsid (version), bsmod (data type) and
* acmod (channel info, 3 bits). Then some "maybe"
* bits, and then the LFE indicator (subwoofer bit) */
while (offset < size-6) {
while (offset < size - 6) {
int skipped = 0;
GST_DEBUG ("ac3parse: offset %ld, size %ld ",offset, size);
GST_DEBUG ("ac3parse: offset %ld, size %ld ", offset, size);
/* search for a possible start byte */
for (;((data[offset] != 0x0b) && (offset < size-6));offset++) skipped++ ;
for (; ((data[offset] != 0x0b) && (offset < size - 6)); offset++)
skipped++;
if (skipped) {
fprintf(stderr, "ac3parse: **** now at %ld skipped %d bytes (FIXME?)\n",offset,skipped);
fprintf (stderr, "ac3parse: **** now at %ld skipped %d bytes (FIXME?)\n",
offset, skipped);
}
/* construct the header word */
header = GUINT16_TO_BE(*((guint16 *)(data+offset)));
header = GUINT16_TO_BE (*((guint16 *) (data + offset)));
/* g_print("AC3PARSE: sync word is 0x%02X\n",header); */
/* if it's a valid header, go ahead and send off the frame */
if (header == 0x0b77) {
gint rate, fsize;
/* g_print("AC3PARSE: found sync at %d\n",offset); */
/* get the bits we're interested in */
rate = (data[offset+4] >> 6) & 0x3;
rate = (data[offset + 4] >> 6) & 0x3;
switch (rate) {
case 0x0: /* 00b */
sample_rate = 48000;
break;
case 0x1: /* 01b */
sample_rate = 44100;
break;
case 0x2: /* 10b */
sample_rate = 32000;
break;
case 0x3: /* 11b */
default:
/* reserved. if this happens, we're screwed */
g_assert (0);
break;
case 0x0: /* 00b */
sample_rate = 48000;
break;
case 0x1: /* 01b */
sample_rate = 44100;
break;
case 0x2: /* 10b */
sample_rate = 32000;
break;
case 0x3: /* 11b */
default:
/* reserved. if this happens, we're screwed */
g_assert (0);
break;
}
fsize = data[offset+4] & 0x3f;
fsize = data[offset + 4] & 0x3f;
/* calculate the bpf of the frame */
bpf = frmsizecod_tbl[fsize].frm_size[rate] * 2;
/* calculate number of channels */
channeldata = data[offset+6]; /* skip bsid/bsmod */
channeldata = data[offset + 6]; /* skip bsid/bsmod */
acmod = (channeldata >> 5) & 0x7;
switch (acmod) {
case 0x1: /* 001b = 1 channel */
channels = 1;
break;
case 0x0: /* 000b = 2 independent channels*/
case 0x2: /* 010b = 2x front (stereo) */
channels = 2;
break;
case 0x3: /* 011b = 3 front */
case 0x4: /* 100b = 2 front, 1 rear */
channels = 3;
break;
case 0x5: /* 101b = 3 front, 1 rear */
case 0x6: /* 110b = 2 front, 2 rear */
channels = 4;
break;
case 0x7: /* 111b = 3 front, 2 rear */
channels = 5;
break;
default:
/* whaaaaaaaaaaaaaa!!!!!!!!!!! */
g_assert (0);
case 0x1: /* 001b = 1 channel */
channels = 1;
break;
case 0x0: /* 000b = 2 independent channels */
case 0x2: /* 010b = 2x front (stereo) */
channels = 2;
break;
case 0x3: /* 011b = 3 front */
case 0x4: /* 100b = 2 front, 1 rear */
channels = 3;
break;
case 0x5: /* 101b = 3 front, 1 rear */
case 0x6: /* 110b = 2 front, 2 rear */
channels = 4;
break;
case 0x7: /* 111b = 3 front, 2 rear */
channels = 5;
break;
default:
/* whaaaaaaaaaaaaaa!!!!!!!!!!! */
g_assert (0);
}
/* fetch LFE bit (subwoofer) */
mask = 0x10;
if (acmod & 0x1 && acmod != 0x1) /* 3 front speakers? */
mask >>= 2;
if (acmod & 0x4) /* surround channel? */
mask >>= 2;
if (acmod == 0x2) /* 2/0 mode? */
mask >>= 2;
if (channeldata & mask) /* LFE: do we have a subwoofer channel? */
channels++;
if (acmod & 0x1 && acmod != 0x1) /* 3 front speakers? */
mask >>= 2;
if (acmod & 0x4) /* surround channel? */
mask >>= 2;
if (acmod == 0x2) /* 2/0 mode? */
mask >>= 2;
if (channeldata & mask) /* LFE: do we have a subwoofer channel? */
channels++;
/* if we don't have the whole frame... */
if ((size - offset) < bpf) {
GST_DEBUG ("ac3parse: partial buffer needed %ld < %d ",size-offset, bpf);
GST_DEBUG ("ac3parse: partial buffer needed %ld < %d ", size - offset,
bpf);
break;
} else {
gboolean need_capsnego = FALSE;
gboolean need_capsnego = FALSE;
outbuf = gst_buffer_create_sub (ac3parse->partialbuf,offset,bpf);
outbuf = gst_buffer_create_sub (ac3parse->partialbuf, offset, bpf);
/* make sure our properties still match */
if (channels > 0 && ac3parse->channels != channels) {
ac3parse->channels = channels;
need_capsnego = TRUE;
}
if (sample_rate > 0 && ac3parse->sample_rate != sample_rate) {
ac3parse->sample_rate = sample_rate;
need_capsnego = TRUE;
}
if (need_capsnego) {
GstCaps *newcaps;
newcaps = gst_caps_new_simple ("audio/x-ac3",
/* make sure our properties still match */
if (channels > 0 && ac3parse->channels != channels) {
ac3parse->channels = channels;
need_capsnego = TRUE;
}
if (sample_rate > 0 && ac3parse->sample_rate != sample_rate) {
ac3parse->sample_rate = sample_rate;
need_capsnego = TRUE;
}
if (need_capsnego) {
GstCaps *newcaps;
newcaps = gst_caps_new_simple ("audio/x-ac3",
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, sample_rate, NULL);
gst_pad_set_explicit_caps (ac3parse->srcpad, newcaps);
}
"rate", G_TYPE_INT, sample_rate, NULL);
gst_pad_set_explicit_caps (ac3parse->srcpad, newcaps);
}
offset += bpf;
if (ac3parse->skip == 0 && GST_PAD_IS_LINKED(ac3parse->srcpad)) {
GST_DEBUG ("ac3parse: pushing buffer of %d bytes",GST_BUFFER_SIZE(outbuf));
gst_pad_push(ac3parse->srcpad,GST_DATA (outbuf));
}
else {
GST_DEBUG ("ac3parse: skipping buffer of %d bytes",GST_BUFFER_SIZE(outbuf));
gst_buffer_unref(outbuf);
if (ac3parse->skip == 0 && GST_PAD_IS_LINKED (ac3parse->srcpad)) {
GST_DEBUG ("ac3parse: pushing buffer of %d bytes",
GST_BUFFER_SIZE (outbuf));
gst_pad_push (ac3parse->srcpad, GST_DATA (outbuf));
} else {
GST_DEBUG ("ac3parse: skipping buffer of %d bytes",
GST_BUFFER_SIZE (outbuf));
gst_buffer_unref (outbuf);
ac3parse->skip--;
}
}
} else {
offset++;
fprintf(stderr, "ac3parse: *** wrong header, skipping byte (FIXME?)\n");
fprintf (stderr, "ac3parse: *** wrong header, skipping byte (FIXME?)\n");
}
}
/* if we have processed this block and there are still */
/* bytes left not in a partial block, copy them over. */
if (size-offset > 0) {
if (size - offset > 0) {
gint remainder = (size - offset);
GST_DEBUG ("ac3parse: partial buffer needed %d for trailing bytes",remainder);
outbuf = gst_buffer_create_sub(ac3parse->partialbuf,offset,remainder);
gst_buffer_unref(ac3parse->partialbuf);
GST_DEBUG ("ac3parse: partial buffer needed %d for trailing bytes",
remainder);
outbuf = gst_buffer_create_sub (ac3parse->partialbuf, offset, remainder);
gst_buffer_unref (ac3parse->partialbuf);
ac3parse->partialbuf = outbuf;
}
}
static void
gst_ac3parse_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
gst_ac3parse_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAc3Parse *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AC3PARSE(object));
src = GST_AC3PARSE(object);
g_return_if_fail (GST_IS_AC3PARSE (object));
src = GST_AC3PARSE (object);
switch (prop_id) {
case ARG_SKIP:
@ -394,13 +396,14 @@ gst_ac3parse_set_property (GObject *object, guint prop_id, const GValue *value,
}
static void
gst_ac3parse_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
gst_ac3parse_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstAc3Parse *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AC3PARSE(object));
src = GST_AC3PARSE(object);
g_return_if_fail (GST_IS_AC3PARSE (object));
src = GST_AC3PARSE (object);
switch (prop_id) {
case ARG_SKIP:
@ -412,9 +415,9 @@ gst_ac3parse_get_property (GObject *object, guint prop_id, GValue *value, GParam
}
static GstElementStateReturn
gst_ac3parse_change_state (GstElement *element)
gst_ac3parse_change_state (GstElement * element)
{
GstAc3Parse *ac3parse = GST_AC3PARSE(element);
GstAc3Parse *ac3parse = GST_AC3PARSE (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
@ -430,25 +433,17 @@ gst_ac3parse_change_state (GstElement *element)
}
static gboolean
plugin_init (GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
if(!gst_element_register(plugin, "ac3parse", GST_RANK_SECONDARY,
GST_TYPE_AC3PARSE)){
if (!gst_element_register (plugin, "ac3parse", GST_RANK_SECONDARY,
GST_TYPE_AC3PARSE)) {
return FALSE;
}
return TRUE;
}
GST_PLUGIN_DEFINE(
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"ac3parse",
"ac3 parsing",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"ac3parse",
"ac3 parsing", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)

View file

@ -26,8 +26,9 @@
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern "C"
{
#endif /* __cplusplus */
#define GST_TYPE_AC3PARSE \
@ -41,34 +42,36 @@ extern "C" {
#define GST_IS_AC3PARSE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AC3PARSE)))
typedef struct _GstAc3Parse GstAc3Parse;
typedef struct _GstAc3ParseClass GstAc3ParseClass;
typedef struct _GstAc3Parse GstAc3Parse;
typedef struct _GstAc3ParseClass GstAc3ParseClass;
struct _GstAc3Parse {
GstElement element;
struct _GstAc3Parse
{
GstElement element;
GstPad *sinkpad,*srcpad;
GstPad *sinkpad, *srcpad;
GstBuffer *partialbuf; /* previous buffer (if carryover) */
guint lastframebytes; /* bytes in previous of last frame so far */
guint lastframesize; /* total length of last frame */
guint skip; /* number of frames to skip */
GstBuffer *partialbuf; /* previous buffer (if carryover) */
guint lastframebytes; /* bytes in previous of last frame so far */
guint lastframesize; /* total length of last frame */
guint skip; /* number of frames to skip */
/* some stream parameters */
gint sample_rate;
gint channels;
};
/* some stream parameters */
gint sample_rate;
gint channels;
};
struct _GstAc3ParseClass {
GstElementClass parent_class;
};
struct _GstAc3ParseClass
{
GstElementClass parent_class;
};
GType gst_ac3parse_get_type(void);
GType gst_ac3parse_get_type (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* __AC3PARSE_H__ */
#endif /* __AC3PARSE_H__ */

View file

@ -20,21 +20,24 @@
#ifndef ASFHEADERS_H
#define ASFHEADERS_H
typedef struct {
typedef struct
{
guint32 v1;
guint32 v2;
guint32 v3;
guint32 v4;
} ASFGuid;
typedef struct {
guint8 obj_id;
typedef struct
{
guint8 obj_id;
ASFGuid guid;
} ASFGuidHash;
enum {
enum
{
ASF_OBJ_UNDEFINED = 0,
ASF_OBJ_STREAM,
ASF_OBJ_DATA,
@ -53,40 +56,44 @@ enum {
ASF_OBJ_BITRATE_MUTEX,
};
enum {
enum
{
ASF_STREAM_UNDEFINED = 0,
ASF_STREAM_VIDEO,
ASF_STREAM_AUDIO,
};
enum {
enum
{
ASF_CORRECTION_UNDEFINED = 0,
ASF_CORRECTION_ON,
ASF_CORRECTION_OFF,
};
static ASFGuidHash asf_correction_guids[] = {
{ ASF_CORRECTION_ON, { 0xBFC3CD50, 0x11CF618F, 0xAA00B28B, 0x20E2B400 }},
{ASF_CORRECTION_ON, {0xBFC3CD50, 0x11CF618F, 0xAA00B28B, 0x20E2B400}},
/* { ASF_CORRECTION_OFF, { 0x20FB5700, 0x11CF5B55, 0x8000FDA8, 0x2B445C5F }},*/
{ ASF_CORRECTION_OFF, { 0x49F1A440, 0x11D04ECE, 0xA000ACA3, 0xF64803C9 }},
{ ASF_CORRECTION_UNDEFINED, { 0, 0, 0, 0 }},
{ASF_CORRECTION_OFF, {0x49F1A440, 0x11D04ECE, 0xA000ACA3, 0xF64803C9}},
{ASF_CORRECTION_UNDEFINED, {0, 0, 0, 0}},
};
static ASFGuidHash asf_stream_guids[] = {
{ ASF_STREAM_VIDEO, { 0xBC19EFC0, 0x11CF5B4D, 0x8000FDA8, 0x2B445C5F }},
{ ASF_STREAM_AUDIO, { 0xF8699E40, 0x11CF5B4D, 0x8000FDA8, 0x2B445C5F }},
{ ASF_STREAM_UNDEFINED, { 0, 0, 0, 0 }},
{ASF_STREAM_VIDEO, {0xBC19EFC0, 0x11CF5B4D, 0x8000FDA8, 0x2B445C5F}},
{ASF_STREAM_AUDIO, {0xF8699E40, 0x11CF5B4D, 0x8000FDA8, 0x2B445C5F}},
{ASF_STREAM_UNDEFINED, {0, 0, 0, 0}},
};
struct _asf_obj_header {
struct _asf_obj_header
{
guint32 num_objects;
guint8 unknown1;
guint8 unknown2;
guint8 unknown1;
guint8 unknown2;
};
typedef struct _asf_obj_header asf_obj_header;
struct _asf_obj_comment {
struct _asf_obj_comment
{
guint16 title_length;
guint16 author_length;
guint16 copyright_length;
@ -96,7 +103,8 @@ struct _asf_obj_comment {
typedef struct _asf_obj_comment asf_obj_comment;
struct _asf_obj_file {
struct _asf_obj_file
{
ASFGuid file_id;
guint64 file_size;
guint64 creation_time;
@ -112,7 +120,8 @@ struct _asf_obj_file {
typedef struct _asf_obj_file asf_obj_file;
struct _asf_obj_stream {
struct _asf_obj_stream
{
ASFGuid type;
ASFGuid correction;
guint64 unknown1;
@ -124,7 +133,8 @@ struct _asf_obj_stream {
typedef struct _asf_obj_stream asf_obj_stream;
struct _asf_stream_audio {
struct _asf_stream_audio
{
guint16 codec_tag;
guint16 channels;
guint32 sample_rate;
@ -136,26 +146,29 @@ struct _asf_stream_audio {
typedef struct _asf_stream_audio asf_stream_audio;
struct _asf_stream_correction {
guint8 span;
struct _asf_stream_correction
{
guint8 span;
guint16 packet_size;
guint16 chunk_size;
guint16 data_size;
guint8 silence_data;
guint8 silence_data;
};
typedef struct _asf_stream_correction asf_stream_correction;
struct _asf_stream_video {
struct _asf_stream_video
{
guint32 width;
guint32 height;
guint8 unknown;
guint8 unknown;
guint16 size;
};
typedef struct _asf_stream_video asf_stream_video;
struct _asf_stream_video_format {
struct _asf_stream_video_format
{
guint32 size;
guint32 width;
guint32 height;
@ -171,62 +184,69 @@ struct _asf_stream_video_format {
typedef struct _asf_stream_video_format asf_stream_video_format;
struct _asf_obj_data {
struct _asf_obj_data
{
ASFGuid file_id;
guint64 packets;
guint8 unknown1;
guint8 unknown1;
/* guint8 unknown2; FIXME: this object is supposed to be 26 bytes?! */
guint8 correction;
guint8 correction;
};
typedef struct _asf_obj_data asf_obj_data;
struct _asf_obj_data_correction {
struct _asf_obj_data_correction
{
guint8 type;
guint8 cycle;
};
typedef struct _asf_obj_data_correction asf_obj_data_correction;
struct _asf_obj_data_packet {
guint8 flags;
guint8 property;
struct _asf_obj_data_packet
{
guint8 flags;
guint8 property;
};
typedef struct _asf_obj_data_packet asf_obj_data_packet;
struct _asf_packet_info {
guint32 padsize;
guint8 replicsizetype;
guint8 fragoffsettype;
guint8 seqtype;
guint8 segsizetype;
struct _asf_packet_info
{
guint32 padsize;
guint8 replicsizetype;
guint8 fragoffsettype;
guint8 seqtype;
guint8 segsizetype;
gboolean multiple;
guint32 size_left;
guint32 size_left;
};
typedef struct _asf_packet_info asf_packet_info;
struct _asf_segment_info {
guint8 stream_number;
guint32 chunk_size;
guint32 frag_offset;
guint32 segment_size;
guint32 sequence;
guint32 frag_timestamp;
struct _asf_segment_info
{
guint8 stream_number;
guint32 chunk_size;
guint32 frag_offset;
guint32 segment_size;
guint32 sequence;
guint32 frag_timestamp;
gboolean compressed;
};
typedef struct _asf_segment_info asf_segment_info;
struct _asf_replicated_data {
struct _asf_replicated_data
{
guint32 object_size;
guint32 frag_timestamp;
};
typedef struct _asf_replicated_data asf_replicated_data;
struct _asf_bitrate_record {
struct _asf_bitrate_record
{
guint16 stream_id;
guint32 bitrate;
};
@ -234,22 +254,22 @@ struct _asf_bitrate_record {
typedef struct _asf_bitrate_record asf_bitrate_record;
static ASFGuidHash asf_object_guids[] = {
{ ASF_OBJ_STREAM, { 0xB7DC0791, 0x11CFA9B7, 0xC000E68E, 0x6553200C }},
{ ASF_OBJ_DATA, { 0x75b22636, 0x11cf668e, 0xAA00D9a6, 0x6Cce6200 }},
{ ASF_OBJ_FILE, { 0x8CABDCA1, 0x11CFA947, 0xC000E48E, 0x6553200C }},
{ ASF_OBJ_HEADER, { 0x75B22630, 0x11CF668E, 0xAA00D9A6, 0x6CCE6200 }},
{ ASF_OBJ_CONCEAL_NONE, { 0x20fb5700, 0x11cf5b55, 0x8000FDa8, 0x2B445C5f }},
{ ASF_OBJ_COMMENT, { 0x75b22633, 0x11cf668e, 0xAA00D9a6, 0x6Cce6200 }},
{ ASF_OBJ_CODEC_COMMENT, { 0x86D15240, 0x11D0311D, 0xA000A4A3, 0xF64803C9 }},
{ ASF_OBJ_CODEC_COMMENT1, { 0x86d15241, 0x11d0311d, 0xA000A4a3, 0xF64803c9 }},
{ ASF_OBJ_INDEX, { 0x33000890, 0x11cfe5b1, 0xA000F489, 0xCB4903c9 }},
{ ASF_OBJ_HEAD1, { 0x5fbf03b5, 0x11cfa92e, 0xC000E38e, 0x6553200c }},
{ ASF_OBJ_HEAD2, { 0xabd3d211, 0x11cfa9ba, 0xC000E68e, 0x6553200c }},
{ ASF_OBJ_PADDING, { 0x1806D474, 0x4509CADF, 0xAB9ABAA4, 0xE8AA96CD }},
{ ASF_OBJ_BITRATE_PROPS, { 0x7bf875ce, 0x11d1468d, 0x6000828d, 0xb2a2c997 }},
{ ASF_OBJ_EXT_CONTENT_DESC, { 0xd2d0a440, 0x11d2e307, 0xa000f097, 0x50a85ec9 }},
{ ASF_OBJ_BITRATE_MUTEX, { 0xd6e229dc, 0x11d135da, 0xa0003490, 0xbe4903c9 }},
{ ASF_OBJ_UNDEFINED, { 0, 0, 0, 0 }},
{ASF_OBJ_STREAM, {0xB7DC0791, 0x11CFA9B7, 0xC000E68E, 0x6553200C}},
{ASF_OBJ_DATA, {0x75b22636, 0x11cf668e, 0xAA00D9a6, 0x6Cce6200}},
{ASF_OBJ_FILE, {0x8CABDCA1, 0x11CFA947, 0xC000E48E, 0x6553200C}},
{ASF_OBJ_HEADER, {0x75B22630, 0x11CF668E, 0xAA00D9A6, 0x6CCE6200}},
{ASF_OBJ_CONCEAL_NONE, {0x20fb5700, 0x11cf5b55, 0x8000FDa8, 0x2B445C5f}},
{ASF_OBJ_COMMENT, {0x75b22633, 0x11cf668e, 0xAA00D9a6, 0x6Cce6200}},
{ASF_OBJ_CODEC_COMMENT, {0x86D15240, 0x11D0311D, 0xA000A4A3, 0xF64803C9}},
{ASF_OBJ_CODEC_COMMENT1, {0x86d15241, 0x11d0311d, 0xA000A4a3, 0xF64803c9}},
{ASF_OBJ_INDEX, {0x33000890, 0x11cfe5b1, 0xA000F489, 0xCB4903c9}},
{ASF_OBJ_HEAD1, {0x5fbf03b5, 0x11cfa92e, 0xC000E38e, 0x6553200c}},
{ASF_OBJ_HEAD2, {0xabd3d211, 0x11cfa9ba, 0xC000E68e, 0x6553200c}},
{ASF_OBJ_PADDING, {0x1806D474, 0x4509CADF, 0xAB9ABAA4, 0xE8AA96CD}},
{ASF_OBJ_BITRATE_PROPS, {0x7bf875ce, 0x11d1468d, 0x6000828d, 0xb2a2c997}},
{ASF_OBJ_EXT_CONTENT_DESC, {0xd2d0a440, 0x11d2e307, 0xa000f097, 0x50a85ec9}},
{ASF_OBJ_BITRATE_MUTEX, {0xd6e229dc, 0x11d135da, 0xa0003490, 0xbe4903c9}},
{ASF_OBJ_UNDEFINED, {0, 0, 0, 0}},
};

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,6 @@
#include "asfheaders.h"
G_BEGIN_DECLS
#define GST_TYPE_ASF_DEMUX \
(asf_demux_get_type())
#define GST_ASF_DEMUX(obj) \
@ -37,11 +36,11 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ASF_DEMUX))
#define GST_IS_ASF_DEMUX_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ASF_DEMUX))
typedef struct _GstASFDemux GstASFDemux;
typedef struct _GstASFDemuxClass GstASFDemuxClass;
struct _GstASFStreamContext {
struct _GstASFStreamContext
{
GstPad *pad;
guint64 pts;
};
@ -49,7 +48,7 @@ struct _GstASFStreamContext {
typedef struct
{
GstPad *pad;
GstPad *pad;
guint16 id;
guint32 frag_offset;
guint32 sequence;
@ -57,11 +56,12 @@ typedef struct
GstBuffer *payload;
} asf_stream_context;
struct _GstASFDemux {
GstElement element;
struct _GstASFDemux
{
GstElement element;
/* pads */
GstPad *sinkpad;
GstPad *sinkpad;
GstByteStream *bs;
@ -77,7 +77,7 @@ struct _GstASFDemux {
GstPad *audio_pad[GST_ASF_DEMUX_NUM_AUDIO_PADS];
gint64 audio_PTS[GST_ASF_DEMUX_NUM_AUDIO_PADS];
guint64 last_seek;
guint64 last_seek;
gboolean restart;
guint32 bitrate[GST_ASF_DEMUX_NUM_STREAM_IDS];
@ -96,23 +96,23 @@ struct _GstASFDemux {
guint64 pts;
/* Descrambler settings */
guint8 span;
guint8 span;
guint16 ds_packet_size;
guint16 ds_chunk_size;
guint16 ds_data_size;
};
struct _GstASFDemuxClass {
struct _GstASFDemuxClass
{
GstElementClass parent_class;
};
GType gst_asf_demux_get_type(void);
GType gst_asf_demux_get_type (void);
gboolean gst_asf_demux_plugin_init (GModule *module, GstPlugin *plugin);
gboolean gst_asf_demux_plugin_init (GModule * module, GstPlugin * plugin);
G_END_DECLS
#endif /* __ASF_DEMUX_H__ */

Some files were not shown because too many files have changed in this diff Show more