+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:
* 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");
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *filesrc;
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");
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);
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;
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;
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 */
};
/* 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;
};
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;
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;
}
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;
}
void
-ui_feedback_clear (_filter_ui_t *ui)
+ui_feedback_clear (_filter_ui_t * ui)
{
gtk_text_buffer_set_text (ui->fb_buffer, "", 0);
}
/* 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;
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);
/* 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);
/* 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;
}
}
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;
}
}
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;
}
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);
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;
}
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);
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");
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");
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);
+ */
}
{
_filter_data_t filter_data;
_filter_ui_t filter_ui;
-
-
+
+
gtk_init (&argc, &argv);
gst_init (&argc, &argv);
gst_control_init (&argc, &argv);
gtk_widget_show_all (filter_ui.window);
gtk_main ();
-
+
return 0;
}
-
* 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;
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 {
}
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);
/* 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;
/* 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);
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);
}
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;
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;
}
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;
-
- g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link);
+ 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);
}
-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;
}
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;
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];
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;
g_print ("%s\r", status);
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *src;
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);
}
}
/* 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");
/* 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)) {
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) {
return 1;
}
-
#include <string.h>
static void
-get_position_info (GstElement *cdparanoia)
+get_position_info (GstElement * cdparanoia)
{
GstFormat track_format;
const GstFormat *formats;
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);
}
}
static void
-get_track_info (GstElement *cdparanoia)
+get_track_info (GstElement * cdparanoia)
{
GstFormat track_format;
gint64 total_tracks = 0, total_time = 0;
const GstFormat *formats;
gint i;
gint64 time_count = 0;
-
+
track_format = gst_format_get_by_nick ("track");
g_assert (track_format != 0);
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++;
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;
}
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);
}
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);
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)
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");
#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);
return cdaudio;
}
-static gchar*
-format_value (GtkScale *scale,
- gdouble value)
+static gchar *
+format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
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
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},
};
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++;
}
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++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position = 0;
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
+
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
if (clock)
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 ();
}
}
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);
}
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;
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);
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;
}
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);
}
}
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);
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);
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. */
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;
}
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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_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");
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;
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
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
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++;
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);
}
}
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++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
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 ();
}
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);
}
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);
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);
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;
}
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);
}
}
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)
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);
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);
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 ();
#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");
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;
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
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
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++;
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++;
}
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++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
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 ();
}
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);
}
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;
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);
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;
}
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);
}
}
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);
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);
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. */
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);
}
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, };
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);
/* 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");
ready = FALSE;
while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) {
count++;
- if (count > 10) break;
+ if (count > 10)
+ break;
}
print_caps (context->metadata);
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);
}
}
}
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);
* 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;
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;
}
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;
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;
}
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
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);
}
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);
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));
#include "gstalsamixer.h"
/* GObject functions */
-static void gst_alsa_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_alsa_init (GstAlsa * this);
-static void gst_alsa_dispose (GObject * object);
-static void gst_alsa_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void gst_alsa_get_property (GObject * object,
- guint prop_id,
- GValue * value,
- GParamSpec * pspec);
+static void gst_alsa_class_init (gpointer g_class, gpointer class_data);
+static void gst_alsa_init (GstAlsa * this);
+static void gst_alsa_dispose (GObject * object);
+static void gst_alsa_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_alsa_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
/* interface */
-static void gst_alsa_probe_interface_init (GstPropertyProbeInterface *iface);
+static void gst_alsa_probe_interface_init (GstPropertyProbeInterface * iface);
/* GStreamer functions for pads and state changing */
-static GstPad * gst_alsa_request_new_pad (GstElement * element,
- GstPadTemplate * templ,
- const gchar * name);
-static GstElementStateReturn gst_alsa_change_state (GstElement * element);
-static GstClock * gst_alsa_get_clock (GstElement * element);
-static void gst_alsa_set_clock (GstElement * element,
- GstClock * clock);
+static GstPad *gst_alsa_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * name);
+static GstElementStateReturn gst_alsa_change_state (GstElement * element);
+static GstClock *gst_alsa_get_clock (GstElement * element);
+static void gst_alsa_set_clock (GstElement * element, GstClock * clock);
+
/* ALSA setup / start / stop functions */
-static gboolean gst_alsa_probe_hw_params (GstAlsa * this,
- GstAlsaFormat * format);
-static gboolean gst_alsa_set_hw_params (GstAlsa * this);
-static gboolean gst_alsa_set_sw_params (GstAlsa * this);
+static gboolean gst_alsa_probe_hw_params (GstAlsa * this,
+ GstAlsaFormat * format);
+static gboolean gst_alsa_set_hw_params (GstAlsa * this);
+static gboolean gst_alsa_set_sw_params (GstAlsa * this);
-static gboolean gst_alsa_open_audio (GstAlsa * this);
-static gboolean gst_alsa_start_audio (GstAlsa * this);
-static gboolean gst_alsa_drain_audio (GstAlsa * this);
-static gboolean gst_alsa_stop_audio (GstAlsa * this);
-static gboolean gst_alsa_close_audio (GstAlsa * this);
+static gboolean gst_alsa_open_audio (GstAlsa * this);
+static gboolean gst_alsa_start_audio (GstAlsa * this);
+static gboolean gst_alsa_drain_audio (GstAlsa * this);
+static gboolean gst_alsa_stop_audio (GstAlsa * this);
+static gboolean gst_alsa_close_audio (GstAlsa * this);
/* GStreamer querying, conversion, and format functions */
-static const GstFormat * gst_alsa_get_formats (GstPad * pad);
-static gboolean gst_alsa_convert (GstAlsa * this,
- GstFormat src_format,
- gint64 src_value,
- GstFormat * dest_format,
- gint64 * dest_value);
-static gboolean gst_alsa_pad_convert (GstPad * pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat * dest_format,
- gint64 * dest_value);
-static const GstQueryType * gst_alsa_get_query_types (GstPad * pad);
-static gboolean gst_alsa_query_func (GstElement * element,
- GstQueryType type,
- GstFormat * format,
- gint64 * value);
-static gboolean gst_alsa_query (GstElement * element,
- GstQueryType type,
- GstFormat * format,
- gint64 * value);
-static gboolean gst_alsa_pad_query (GstPad * pad,
- GstQueryType type,
- GstFormat * format,
- gint64 * value);
+static const GstFormat *gst_alsa_get_formats (GstPad * pad);
+static gboolean gst_alsa_convert (GstAlsa * this,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_alsa_pad_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static const GstQueryType *gst_alsa_get_query_types (GstPad * pad);
+static gboolean gst_alsa_query_func (GstElement * element,
+ GstQueryType type, GstFormat * format, gint64 * value);
+static gboolean gst_alsa_query (GstElement * element,
+ GstQueryType type, GstFormat * format, gint64 * value);
+static gboolean gst_alsa_pad_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
/*** TYPE FUNCTIONS ***********************************************************/
NULL
};
- alsa_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAlsa", &alsa_info, 0);
+ alsa_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAlsa", &alsa_info, 0);
g_type_add_interface_static (alsa_type,
- GST_TYPE_PROPERTY_PROBE,
- &alsa_probe_info);
+ GST_TYPE_PROPERTY_PROBE, &alsa_probe_info);
}
return alsa_type;
GstElementClass *element_class;
GstAlsaClass *klass;
- klass = (GstAlsaClass *)g_class;
+ klass = (GstAlsaClass *) g_class;
object_class = (GObjectClass *) g_class;
element_class = (GstElementClass *) g_class;
object_class->set_property = gst_alsa_set_property;
g_object_class_install_property (object_class, ARG_DEVICE,
- g_param_spec_string ("device", "Device",
- "ALSA device, as defined in an asoundrc",
- "default", G_PARAM_READWRITE));
+ g_param_spec_string ("device", "Device",
+ "ALSA device, as defined in an asoundrc",
+ "default", G_PARAM_READWRITE));
g_object_class_install_property (object_class, ARG_DEVICE_NAME,
- g_param_spec_string ("device_name", "Device name",
- "Name of the device",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("device_name", "Device name",
+ "Name of the device", NULL, G_PARAM_READABLE));
g_object_class_install_property (object_class, ARG_PERIODCOUNT,
- g_param_spec_int ("period-count", "Period count",
- "Number of hardware buffers to use",
- 2, 64, 2, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_param_spec_int ("period-count", "Period count",
+ "Number of hardware buffers to use",
+ 2, 64, 2, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, ARG_PERIODSIZE,
- g_param_spec_int ("period-size", "Period size",
- "Number of frames (samples on each channel) in one hardware period",
- 2, 8192, 8192, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_param_spec_int ("period-size", "Period size",
+ "Number of frames (samples on each channel) in one hardware period",
+ 2, 8192, 8192, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, ARG_BUFFERSIZE,
- g_param_spec_int ("buffer-size", "Buffer size",
- "Number of frames the hardware buffer can hold",
- 4, 65536, 16384, G_PARAM_READWRITE));
+ g_param_spec_int ("buffer-size", "Buffer size",
+ "Number of frames the hardware buffer can hold",
+ 4, 65536, 16384, G_PARAM_READWRITE));
g_object_class_install_property (object_class, ARG_AUTORECOVER,
- g_param_spec_boolean ("autorecover", "Automatic xrun recovery",
- "When TRUE tries to reduce processor load on xruns",
- TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_param_spec_boolean ("autorecover", "Automatic xrun recovery",
+ "When TRUE tries to reduce processor load on xruns",
+ TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, ARG_MMAP,
- g_param_spec_boolean ("mmap", "Use mmap'ed access",
- "Wether to use mmap (faster) or standard read/write (more compatible)",
- TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_param_spec_boolean ("mmap", "Use mmap'ed access",
+ "Wether to use mmap (faster) or standard read/write (more compatible)",
+ TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, ARG_MAXDISCONT,
- g_param_spec_uint64 ("max-discont", "Maximum Discontinuity",
- "GStreamer timeunits before the timestamp syncing starts dropping/inserting samples",
- /* rounding errors */ 1000, GST_SECOND, GST_ALSA_DEFAULT_DISCONT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_param_spec_uint64 ("max-discont", "Maximum Discontinuity",
+ "GStreamer timeunits before the timestamp syncing starts dropping/inserting samples",
+ /* rounding errors */ 1000, GST_SECOND, GST_ALSA_DEFAULT_DISCONT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- element_class->change_state = GST_DEBUG_FUNCPTR (gst_alsa_change_state);
- element_class->query = GST_DEBUG_FUNCPTR (gst_alsa_query);
+ element_class->change_state = GST_DEBUG_FUNCPTR (gst_alsa_change_state);
+ element_class->query = GST_DEBUG_FUNCPTR (gst_alsa_query);
element_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_alsa_request_new_pad);
- element_class->set_clock = GST_DEBUG_FUNCPTR (gst_alsa_set_clock);
- element_class->get_clock = GST_DEBUG_FUNCPTR (gst_alsa_get_clock);
+ element_class->set_clock = GST_DEBUG_FUNCPTR (gst_alsa_set_clock);
+ element_class->get_clock = GST_DEBUG_FUNCPTR (gst_alsa_get_clock);
}
static void
-gst_alsa_init (GstAlsa *this)
+gst_alsa_init (GstAlsa * this)
{
- this->device = g_strdup("default");
+ this->device = g_strdup ("default");
GST_FLAG_SET (this, GST_ELEMENT_EVENT_AWARE);
GST_FLAG_SET (this, GST_ELEMENT_THREAD_SUGGESTED);
}
static void
-gst_alsa_dispose (GObject *object)
+gst_alsa_dispose (GObject * object)
{
GstAlsa *this = GST_ALSA (object);
}
static void
-gst_alsa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_alsa_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstAlsa *this;
gint buffer_size;
this = (GstAlsa *) object;
switch (prop_id) {
- case ARG_DEVICE:
- if (this->device)
- g_free (this->device);
- this->device = g_strdup (g_value_get_string (value));
- break;
- case ARG_PERIODCOUNT:
- g_return_if_fail (!GST_FLAG_IS_SET (this, GST_ALSA_RUNNING));
- this->period_count = g_value_get_int (value);
- break;
- case ARG_PERIODSIZE:
- g_return_if_fail (!GST_FLAG_IS_SET (this, GST_ALSA_RUNNING));
- this->period_size = g_value_get_int (value);
- break;
- case ARG_BUFFERSIZE:
- g_return_if_fail (!GST_FLAG_IS_SET (this, GST_ALSA_RUNNING));
- buffer_size = g_value_get_int (value);
- this->period_count = buffer_size / this->period_size;
- break;
- case ARG_AUTORECOVER:
- this->autorecover = g_value_get_boolean (value);
- return;
- case ARG_MMAP:
- this->mmap = g_value_get_boolean (value);
- return;
- case ARG_MAXDISCONT:
- this->max_discont = (GstClockTime) g_value_get_uint64 (value);
- return;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- return;
+ case ARG_DEVICE:
+ if (this->device)
+ g_free (this->device);
+ this->device = g_strdup (g_value_get_string (value));
+ break;
+ case ARG_PERIODCOUNT:
+ g_return_if_fail (!GST_FLAG_IS_SET (this, GST_ALSA_RUNNING));
+ this->period_count = g_value_get_int (value);
+ break;
+ case ARG_PERIODSIZE:
+ g_return_if_fail (!GST_FLAG_IS_SET (this, GST_ALSA_RUNNING));
+ this->period_size = g_value_get_int (value);
+ break;
+ case ARG_BUFFERSIZE:
+ g_return_if_fail (!GST_FLAG_IS_SET (this, GST_ALSA_RUNNING));
+ buffer_size = g_value_get_int (value);
+ this->period_count = buffer_size / this->period_size;
+ break;
+ case ARG_AUTORECOVER:
+ this->autorecover = g_value_get_boolean (value);
+ return;
+ case ARG_MMAP:
+ this->mmap = g_value_get_boolean (value);
+ return;
+ case ARG_MAXDISCONT:
+ this->max_discont = (GstClockTime) g_value_get_uint64 (value);
+ return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ return;
}
if (GST_STATE (this) == GST_STATE_NULL)
}
static void
-gst_alsa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_alsa_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAlsa *this;
this = (GstAlsa *) object;
switch (prop_id) {
- case ARG_DEVICE:
- g_value_set_string (value, this->device);
- break;
- case ARG_DEVICE_NAME:
- if (GST_STATE (this) != GST_STATE_NULL) {
- g_value_set_string (value, snd_pcm_info_get_name (this->info));
- } else {
- g_value_set_string (value, NULL);
- }
- break;
- case ARG_PERIODCOUNT:
- g_value_set_int (value, this->period_count);
- break;
- case ARG_PERIODSIZE:
- g_value_set_int (value, this->period_size);
- break;
- case ARG_BUFFERSIZE:
- g_value_set_int (value, this->period_size * this->period_count);
- break;
- case ARG_AUTORECOVER:
- g_value_set_boolean (value, this->autorecover);
- break;
- case ARG_MMAP:
- g_value_set_boolean (value, this->mmap);
- break;
- case ARG_MAXDISCONT:
- g_value_set_uint64 (value, (guint64) this->max_discont);
- return;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_DEVICE:
+ g_value_set_string (value, this->device);
+ break;
+ case ARG_DEVICE_NAME:
+ if (GST_STATE (this) != GST_STATE_NULL) {
+ g_value_set_string (value, snd_pcm_info_get_name (this->info));
+ } else {
+ g_value_set_string (value, NULL);
+ }
+ break;
+ case ARG_PERIODCOUNT:
+ g_value_set_int (value, this->period_count);
+ break;
+ case ARG_PERIODSIZE:
+ g_value_set_int (value, this->period_size);
+ break;
+ case ARG_BUFFERSIZE:
+ g_value_set_int (value, this->period_size * this->period_count);
+ break;
+ case ARG_AUTORECOVER:
+ g_value_set_boolean (value, this->autorecover);
+ break;
+ case ARG_MMAP:
+ g_value_set_boolean (value, this->mmap);
+ break;
+ case ARG_MAXDISCONT:
+ g_value_set_uint64 (value, (guint64) this->max_discont);
+ return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static const GList *
-gst_alsa_probe_get_properties (GstPropertyProbe *probe)
+gst_alsa_probe_get_properties (GstPropertyProbe * probe)
{
GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
static GList *list = NULL;
if (!list) {
- list = g_list_append (NULL, g_object_class_find_property (klass, "device")); }
+ list = g_list_append (NULL, g_object_class_find_property (klass, "device"));
+ }
return list;
}
static gboolean
-gst_alsa_class_probe_devices (GstAlsaClass *klass,
- gboolean check)
+gst_alsa_class_probe_devices (GstAlsaClass * klass, gboolean check)
{
static gboolean init = FALSE;
* do function-wise look-ups. */
if (!init && !check) {
-#define MAX_DEVICES 16 /* random number */
+#define MAX_DEVICES 16 /* random number */
gint num, res;
gchar *dev;
snd_pcm_t *pcm;
dev = g_strdup_printf ("hw:%d", num);
if (!(res = snd_pcm_open (&pcm, dev, 0, SND_PCM_NONBLOCK)) ||
- res == -EBUSY) {
- klass->devices = g_list_append (klass->devices, dev);
+ res == -EBUSY) {
+ klass->devices = g_list_append (klass->devices, dev);
if (res != -EBUSY)
- snd_pcm_close (pcm);
+ snd_pcm_close (pcm);
} else {
- g_free (dev);
+ g_free (dev);
}
}
}
static GValueArray *
-gst_alsa_class_list_devices (GstAlsaClass *klass)
+gst_alsa_class_list_devices (GstAlsaClass * klass)
{
GValueArray *array;
GValue value = { 0 };
g_value_array_append (array, &value);
}
g_value_unset (&value);
-
+
return array;
}
static void
-gst_alsa_probe_probe_property (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_alsa_probe_probe_property (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
GstAlsaClass *klass = GST_ALSA_GET_CLASS (probe);
}
static gboolean
-gst_alsa_probe_needs_probe (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_alsa_probe_needs_probe (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
GstAlsaClass *klass = GST_ALSA_GET_CLASS (probe);
gboolean ret = FALSE;
}
static GValueArray *
-gst_alsa_probe_get_values (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_alsa_probe_get_values (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
GstAlsaClass *klass = GST_ALSA_GET_CLASS (probe);
GValueArray *array = NULL;
}
static void
-gst_alsa_probe_interface_init (GstPropertyProbeInterface *iface)
+gst_alsa_probe_interface_init (GstPropertyProbeInterface * iface)
{
iface->get_properties = gst_alsa_probe_get_properties;
iface->probe_property = gst_alsa_probe_probe_property;
- iface->needs_probe = gst_alsa_probe_needs_probe;
- iface->get_values = gst_alsa_probe_get_values;
+ iface->needs_probe = gst_alsa_probe_needs_probe;
+ iface->get_values = gst_alsa_probe_get_values;
}
/*** GSTREAMER PAD / QUERY / CONVERSION / STATE FUNCTIONS *********************/
static GstPad *
-gst_alsa_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
+gst_alsa_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * name)
{
GstAlsa *this;
gint track = 0;
if (name) {
/* locate the track number in the requested pad name. */
- track = (gint) strtol (name + (strchr(templ->name_template, '%') -
- templ->name_template), NULL, 0);
+ track = (gint) strtol (name + (strchr (templ->name_template, '%') -
+ templ->name_template), NULL, 0);
if (track < 1 || track >= GST_ALSA_MAX_TRACKS) {
GST_INFO_OBJECT (this, "invalid track requested. (%d)", track);
return NULL;
/* if the user doesn't care, use the lowest available track number */
if (track == 0) {
for (track = 1; track < GST_ALSA_MAX_TRACKS; track++) {
- if (this->pad[track] != NULL) goto found_track;
+ if (this->pad[track] != NULL)
+ goto found_track;
}
return NULL;
}
/* gets the matching alsa format or NULL if none matches */
static GstAlsaFormat *
-gst_alsa_get_format (const GstStructure *structure)
+gst_alsa_get_format (const GstStructure * structure)
{
const gchar *mimetype;
GstAlsaFormat *ret;
- if (! (ret = g_new (GstAlsaFormat, 1)))
+ if (!(ret = g_new (GstAlsaFormat, 1)))
return NULL;
/* we have to differentiate between int and float formats */
mimetype = gst_structure_get_name (structure);
- if (! strncmp (mimetype, "audio/x-raw-int", 15)) {
+ if (!strncmp (mimetype, "audio/x-raw-int", 15)) {
gboolean sign;
gint width, depth, endianness;
/* extract the needed information from the cap */
if (!(gst_structure_get_int (structure, "width", &width) &&
- gst_structure_get_int (structure, "depth", &depth) &&
- gst_structure_get_boolean (structure, "signed", &sign)))
- goto error;
+ gst_structure_get_int (structure, "depth", &depth) &&
+ gst_structure_get_boolean (structure, "signed", &sign)))
+ goto error;
/* extract endianness if needed */
if (width > 8) {
if (!gst_structure_get_int (structure, "endianness", &endianness))
- goto error;
+ goto error;
} else {
endianness = G_BYTE_ORDER;
}
- ret->format = snd_pcm_build_linear_format (depth, width, sign ? 0 : 1, endianness == G_LITTLE_ENDIAN ? 0 : 1);
+ ret->format =
+ snd_pcm_build_linear_format (depth, width, sign ? 0 : 1,
+ endianness == G_LITTLE_ENDIAN ? 0 : 1);
- } else if (! strncmp (mimetype, "audio/x-raw-float", 17)) {
+ } else if (!strncmp (mimetype, "audio/x-raw-float", 17)) {
gint width;
/* get layout */
/* match layout to format wrt to endianness */
if (width == 32) {
if (G_BYTE_ORDER == G_LITTLE_ENDIAN) {
- ret->format = SND_PCM_FORMAT_FLOAT_LE;
+ ret->format = SND_PCM_FORMAT_FLOAT_LE;
} else if (G_BYTE_ORDER == G_BIG_ENDIAN) {
- ret->format = SND_PCM_FORMAT_FLOAT_BE;
+ ret->format = SND_PCM_FORMAT_FLOAT_BE;
} else {
- ret->format = SND_PCM_FORMAT_FLOAT;
+ ret->format = SND_PCM_FORMAT_FLOAT;
}
} else if (width == 64) {
if (G_BYTE_ORDER == G_LITTLE_ENDIAN) {
- ret->format = SND_PCM_FORMAT_FLOAT64_LE;
+ ret->format = SND_PCM_FORMAT_FLOAT64_LE;
} else if (G_BYTE_ORDER == G_BIG_ENDIAN) {
- ret->format = SND_PCM_FORMAT_FLOAT64_BE;
+ ret->format = SND_PCM_FORMAT_FLOAT64_BE;
} else {
- ret->format = SND_PCM_FORMAT_FLOAT64;
+ ret->format = SND_PCM_FORMAT_FLOAT64;
}
} else {
goto error;
}
- } else if (! strncmp (mimetype, "audio/x-alaw", 12)) {
+ } else if (!strncmp (mimetype, "audio/x-alaw", 12)) {
ret->format = SND_PCM_FORMAT_A_LAW;
- } else if (! strncmp (mimetype, "audio/x-mulaw", 13)) {
+ } else if (!strncmp (mimetype, "audio/x-mulaw", 13)) {
ret->format = SND_PCM_FORMAT_MU_LAW;
}
/* get rate and channels */
if (!(gst_structure_get_int (structure, "rate", &ret->rate) &&
- gst_structure_get_int (structure, "channels", &ret->channels)))
+ gst_structure_get_int (structure, "channels", &ret->channels)))
goto error;
return ret;
}
static inline gboolean
-gst_alsa_formats_match (GstAlsaFormat *one, GstAlsaFormat *two)
+gst_alsa_formats_match (GstAlsaFormat * one, GstAlsaFormat * two)
{
- if (one == two) return TRUE;
- if (one == NULL || two == NULL) return FALSE;
+ if (one == two)
+ return TRUE;
+ if (one == NULL || two == NULL)
+ return FALSE;
return (one->format == two->format) &&
- (one->rate == two->rate) &&
- (one->channels == two->channels);
+ (one->rate == two->rate) && (one->channels == two->channels);
}
/* get props for a spec */
} else if (snd_pcm_format_linear (format)) {
/* int */
GstStructure *structure = gst_structure_new ("audio/x-raw-int",
- "width", G_TYPE_INT, (gint) snd_pcm_format_physical_width (format),
- "depth", G_TYPE_INT, (gint) snd_pcm_format_width (format),
- "signed", G_TYPE_BOOLEAN, snd_pcm_format_signed (format) == 1 ? TRUE : FALSE,
- NULL);
+ "width", G_TYPE_INT, (gint) snd_pcm_format_physical_width (format),
+ "depth", G_TYPE_INT, (gint) snd_pcm_format_width (format),
+ "signed", G_TYPE_BOOLEAN,
+ snd_pcm_format_signed (format) == 1 ? TRUE : FALSE,
+ NULL);
+
/* endianness */
if (snd_pcm_format_physical_width (format) > 8) {
switch (snd_pcm_format_little_endian (format)) {
- case 0:
- gst_structure_set (structure, "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
- break;
- case 1:
- gst_structure_set (structure, "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL);
- break;
- default:
- GST_WARNING ("Unknown byte order in sound driver. Continuing by assuming system byte order.");
- gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
- break;
+ case 0:
+ gst_structure_set (structure, "endianness", G_TYPE_INT, G_BIG_ENDIAN,
+ NULL);
+ break;
+ case 1:
+ gst_structure_set (structure, "endianness", G_TYPE_INT,
+ G_LITTLE_ENDIAN, NULL);
+ break;
+ default:
+ GST_WARNING
+ ("Unknown byte order in sound driver. Continuing by assuming system byte order.");
+ gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ NULL);
+ break;
}
}
return gst_caps_new_full (structure, NULL);
return NULL;
return gst_caps_new_simple ("audio/x-raw-float",
- "width", G_TYPE_INT, (gint) snd_pcm_format_width (format),
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- NULL);
+ "width", G_TYPE_INT, (gint) snd_pcm_format_width (format),
+ "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
}
return NULL;
}
static inline void
-add_channels (GstStructure *structure, gint min_rate, gint max_rate,
+add_channels (GstStructure * structure, gint min_rate, gint max_rate,
gint min_channels, gint max_channels)
{
if (min_rate < 0) {
gst_structure_set (structure, "rate", G_TYPE_INT, min_rate, NULL);
} else {
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, min_rate,
- max_rate, NULL);
+ max_rate, NULL);
}
if (min_channels < 0) {
min_channels = 1;
gst_structure_set (structure, "channels", G_TYPE_INT, min_channels, NULL);
} else {
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE,
- min_channels, max_channels, NULL);
+ min_channels, max_channels, NULL);
}
}
/* can be NULL, because not all alsa formats can be specified as caps */
if (temp != NULL) {
g_assert (gst_caps_get_size (temp) == 1);
- add_channels (gst_caps_get_structure (temp, 0), rate, -1, channels, -1);
- gst_caps_append (ret_caps, temp);
+ add_channels (gst_caps_get_structure (temp, 0), rate, -1, channels, -1);
+ gst_caps_append (ret_caps, temp);
}
}
}
/* Return better caps when device is open */
GstCaps *
-gst_alsa_get_caps (GstPad *pad)
+gst_alsa_get_caps (GstPad * pad)
{
GstAlsa *this;
snd_pcm_hw_params_t *hw_params;
if (!GST_FLAG_IS_SET (this, GST_ALSA_OPEN))
return gst_caps_copy (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (pad)));
-
+
snd_pcm_hw_params_alloca (&hw_params);
ERROR_CHECK (snd_pcm_hw_params_any (this->handle, hw_params),
- "Broken configuration for this PCM: %s");
+ "Broken configuration for this PCM: %s");
if (((GstElement *) this)->numpads > 1) {
min_channels = 1;
max_channels = -1;
} else {
ERROR_CHECK (snd_pcm_hw_params_get_channels_min (hw_params, &min_rate),
- "Couldn't get minimum channel count for device %s: %s", this->device);
+ "Couldn't get minimum channel count for device %s: %s", this->device);
ERROR_CHECK (snd_pcm_hw_params_get_channels_max (hw_params, &max_rate),
- "Couldn't get maximum channel count for device %s: %s", this->device);
+ "Couldn't get maximum channel count for device %s: %s", this->device);
min_channels = min_rate;
- max_channels = max_rate > GST_ALSA_MAX_CHANNELS ? GST_ALSA_MAX_CHANNELS : max_rate;
+ max_channels =
+ max_rate > GST_ALSA_MAX_CHANNELS ? GST_ALSA_MAX_CHANNELS : max_rate;
}
ERROR_CHECK (snd_pcm_hw_params_get_rate_min (hw_params, &min_rate, &i),
- "Couldn't get minimum rate for device %s: %s", this->device);
+ "Couldn't get minimum rate for device %s: %s", this->device);
min_rate = min_rate < GST_ALSA_MIN_RATE ? GST_ALSA_MIN_RATE : min_rate + i;
ERROR_CHECK (snd_pcm_hw_params_get_rate_max (hw_params, &max_rate, &i),
- "Couldn't get maximum rate for device %s: %s", this->device);
+ "Couldn't get maximum rate for device %s: %s", this->device);
max_rate = max_rate > GST_ALSA_MAX_RATE ? GST_ALSA_MAX_RATE : max_rate + i;
snd_pcm_format_mask_alloca (&mask);
for (i = 0; i <= SND_PCM_FORMAT_LAST; i++) {
if (snd_pcm_format_mask_test (mask, i)) {
GstCaps *caps = gst_alsa_get_caps_internal (i);
+
/* we can never use a format we can't set caps for */
if (caps != NULL) {
g_assert (gst_caps_get_size (caps) == 1);
- add_channels (gst_caps_get_structure (caps, 0), min_rate, max_rate, min_channels, max_channels);
+ add_channels (gst_caps_get_structure (caps, 0), min_rate, max_rate,
+ min_channels, max_channels);
if (ret) {
gst_caps_append (ret, caps);
} else {
return gst_caps_new_empty ();
} else {
G_GNUC_UNUSED gchar *str = gst_caps_to_string (ret);
+
GST_LOG_OBJECT (this, "get_caps returns %s", str);
g_free (str);
return ret;
}
GstCaps *
-gst_alsa_fixate (GstPad *pad, const GstCaps *caps)
+gst_alsa_fixate (GstPad * pad, const GstCaps * caps)
{
GstCaps *newcaps;
GstStructure *structure;
- newcaps = gst_caps_new_full (gst_structure_copy(gst_caps_get_structure (caps, 0)), NULL);
+ newcaps =
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)),
+ NULL);
structure = gst_caps_get_structure (newcaps, 0);
if (gst_caps_structure_fixate_field_nearest_int (structure, "rate", 44100)) {
/* Negotiates the caps */
GstPadLinkReturn
-gst_alsa_link (GstPad *pad, const GstCaps *caps)
+gst_alsa_link (GstPad * pad, const GstCaps * caps)
{
GstAlsa *this;
GstAlsaFormat *format;
format = gst_alsa_get_format (gst_caps_get_structure (caps, 0));
if (format == NULL)
return GST_PAD_LINK_REFUSED;
-
+
GST_DEBUG ("found format %s", snd_pcm_format_name (format->format));
-
+
if (!GST_FLAG_IS_SET (this, GST_ALSA_CAPS_NEGO)) {
gint i;
continue;
if (gst_pad_try_set_caps (this->pad[i], caps) == GST_PAD_LINK_REFUSED) {
if (this->format) {
- GstCaps *old = gst_alsa_caps (this->format->format, this->format->rate, this->format->channels);
+ GstCaps *old =
+ gst_alsa_caps (this->format->format, this->format->rate,
+ this->format->channels);
+
for (--i; i >= 0; i--) {
- if (gst_pad_try_set_caps (this->pad[i], old) == GST_PAD_LINK_REFUSED) {
- GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
- ("could not reset caps to a sane value"));
+ if (gst_pad_try_set_caps (this->pad[i],
+ old) == GST_PAD_LINK_REFUSED) {
+ GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
+ ("could not reset caps to a sane value"));
gst_caps_free (old);
break;
} else {
/* FIXME: unset caps on pads somehow */
}
}
- gst_caps_free (old);
- ret = GST_PAD_LINK_REFUSED;
+ gst_caps_free (old);
+ ret = GST_PAD_LINK_REFUSED;
goto out;
- }
+ }
}
}
GST_FLAG_UNSET (this, GST_ALSA_CAPS_NEGO);
/* sync the params */
- if (GST_FLAG_IS_SET (this, GST_ALSA_RUNNING)) gst_alsa_stop_audio (this);
+ if (GST_FLAG_IS_SET (this, GST_ALSA_RUNNING))
+ gst_alsa_stop_audio (this);
g_free (this->format);
this->format = format;
- if (! gst_alsa_start_audio (this)) {
+ if (!gst_alsa_start_audio (this)) {
GST_ELEMENT_ERROR (this, RESOURCE, SETTINGS, (NULL), (NULL));
return GST_PAD_LINK_REFUSED;
}
}
static GstElementStateReturn
-gst_alsa_change_state (GstElement *element)
+gst_alsa_change_state (GstElement * element)
{
int err;
GstAlsa *this;
this = GST_ALSA (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
- if (! (GST_FLAG_IS_SET (element, GST_ALSA_OPEN) ||
- gst_alsa_open_audio (this))) return GST_STATE_FAILURE;
- break;
- case GST_STATE_READY_TO_PAUSED:
- if (! (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING) ||
- gst_alsa_start_audio (this))) return GST_STATE_FAILURE;
- this->transmitted = 0;
- break;
- case GST_STATE_PAUSED_TO_PLAYING:
- if (snd_pcm_state (this->handle) == SND_PCM_STATE_PAUSED) {
- if ((err = snd_pcm_pause (this->handle, 0)) < 0) {
- GST_ERROR_OBJECT (this, "Error unpausing sound: %s", snd_strerror (err));
- return GST_STATE_FAILURE;
+ case GST_STATE_NULL_TO_READY:
+ if (!(GST_FLAG_IS_SET (element, GST_ALSA_OPEN) ||
+ gst_alsa_open_audio (this)))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_READY_TO_PAUSED:
+ if (!(GST_FLAG_IS_SET (element, GST_ALSA_RUNNING) ||
+ gst_alsa_start_audio (this)))
+ return GST_STATE_FAILURE;
+ this->transmitted = 0;
+ break;
+ case GST_STATE_PAUSED_TO_PLAYING:
+ if (snd_pcm_state (this->handle) == SND_PCM_STATE_PAUSED) {
+ if ((err = snd_pcm_pause (this->handle, 0)) < 0) {
+ GST_ERROR_OBJECT (this, "Error unpausing sound: %s",
+ snd_strerror (err));
+ return GST_STATE_FAILURE;
+ }
+ } else if (!(GST_FLAG_IS_SET (element, GST_ALSA_RUNNING) ||
+ gst_alsa_start_audio (this))) {
+ return GST_STATE_FAILURE;
}
- } else if (! (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING) ||
- gst_alsa_start_audio (this))) {
- return GST_STATE_FAILURE;
- }
- gst_alsa_clock_start (this->clock);
- break;
- case GST_STATE_PLAYING_TO_PAUSED:
- if (GST_ALSA_CAPS_IS_SET (this, GST_ALSA_CAPS_PAUSE)) {
- if (snd_pcm_state (this->handle) == SND_PCM_STATE_RUNNING) {
- if ((err = snd_pcm_pause (this->handle, 1)) < 0) {
- GST_ERROR_OBJECT (this, "Error pausing sound: %s", snd_strerror (err));
- return GST_STATE_FAILURE;
- }
+ gst_alsa_clock_start (this->clock);
+ break;
+ case GST_STATE_PLAYING_TO_PAUSED:
+ if (GST_ALSA_CAPS_IS_SET (this, GST_ALSA_CAPS_PAUSE)) {
+ if (snd_pcm_state (this->handle) == SND_PCM_STATE_RUNNING) {
+ if ((err = snd_pcm_pause (this->handle, 1)) < 0) {
+ GST_ERROR_OBJECT (this, "Error pausing sound: %s",
+ snd_strerror (err));
+ return GST_STATE_FAILURE;
+ }
+ }
+ } else {
+ /* if device doesn't know how to pause, we just stop */
+ if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING))
+ gst_alsa_stop_audio (this);
}
- } else {
- /* if device doesn't know how to pause, we just stop */
- if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING)) gst_alsa_stop_audio (this);
- }
- gst_alsa_clock_stop (this->clock);
- break;
- case GST_STATE_PAUSED_TO_READY:
- if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING)) gst_alsa_stop_audio (this);
- g_free (this->format);
- this->format = NULL;
- break;
- case GST_STATE_READY_TO_NULL:
- if (GST_FLAG_IS_SET (element, GST_ALSA_OPEN)) gst_alsa_close_audio (this);
- break;
-
- default:
- g_assert_not_reached();
+ gst_alsa_clock_stop (this->clock);
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING))
+ gst_alsa_stop_audio (this);
+ g_free (this->format);
+ this->format = NULL;
+ break;
+ case GST_STATE_READY_TO_NULL:
+ if (GST_FLAG_IS_SET (element, GST_ALSA_OPEN))
+ gst_alsa_close_audio (this);
+ break;
+
+ default:
+ g_assert_not_reached ();
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
}
static GstClock *
-gst_alsa_get_clock (GstElement *element)
-{ return GST_CLOCK (GST_ALSA (element)->clock); }
+gst_alsa_get_clock (GstElement * element)
+{
+ return GST_CLOCK (GST_ALSA (element)->clock);
+}
static void
-gst_alsa_set_clock (GstElement *element, GstClock *clock)
-{ /* we need this function just so everybody knows we use a clock */ }
+gst_alsa_set_clock (GstElement * element, GstClock * clock)
+{ /* we need this function just so everybody knows we use a clock */
+}
/*** AUDIO PROCESSING *********************************************************/
inline snd_pcm_sframes_t
-gst_alsa_update_avail (GstAlsa *this)
+gst_alsa_update_avail (GstAlsa * this)
{
snd_pcm_sframes_t avail = snd_pcm_avail_update (this->handle);
+
if (avail < 0) {
if (avail == -EPIPE) {
gst_alsa_xrun_recovery (this);
} else {
- GST_WARNING_OBJECT (this, "unknown ALSA avail_update return value (%d)", (int) avail);
+ GST_WARNING_OBJECT (this, "unknown ALSA avail_update return value (%d)",
+ (int) avail);
}
}
return avail;
/* returns TRUE, if the loop should go on */
inline gboolean
-gst_alsa_pcm_wait (GstAlsa *this)
+gst_alsa_pcm_wait (GstAlsa * this)
{
int err;
if (snd_pcm_state (this->handle) == SND_PCM_STATE_RUNNING) {
if ((err = snd_pcm_wait (this->handle, 1000)) < 0) {
if (err == EINTR) {
- /* happens mostly when run under gdb, or when exiting due to a signal */
- GST_DEBUG ("got interrupted while waiting");
- if (gst_element_interrupt (GST_ELEMENT (this))) {
- return TRUE;
- } else {
- return FALSE;
- }
+ /* happens mostly when run under gdb, or when exiting due to a signal */
+ GST_DEBUG ("got interrupted while waiting");
+ if (gst_element_interrupt (GST_ELEMENT (this))) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
if (!gst_alsa_xrun_recovery (this)) {
- GST_ERROR_OBJECT (this, "error waiting for alsa pcm: (%d: %s)", err, snd_strerror (err));
+ GST_ERROR_OBJECT (this, "error waiting for alsa pcm: (%d: %s)", err,
+ snd_strerror (err));
return FALSE;
}
}
* return FALSE if we're not
*/
inline gboolean
-gst_alsa_start (GstAlsa *this)
+gst_alsa_start (GstAlsa * this)
{
GST_DEBUG ("Setting state to RUNNING");
- switch (snd_pcm_state(this->handle)) {
+ switch (snd_pcm_state (this->handle)) {
case SND_PCM_STATE_XRUN:
gst_alsa_xrun_recovery (this);
return gst_alsa_start (this);
ERROR_CHECK (snd_pcm_prepare (this->handle), "error preparing: %s");
case SND_PCM_STATE_SUSPENDED:
case SND_PCM_STATE_PREPARED:
- ERROR_CHECK (snd_pcm_start(this->handle), "error starting playback: %s");
+ ERROR_CHECK (snd_pcm_start (this->handle), "error starting playback: %s");
break;
case SND_PCM_STATE_PAUSED:
ERROR_CHECK (snd_pcm_pause (this->handle, 0), "error unpausing: %s");
}
gboolean
-gst_alsa_xrun_recovery (GstAlsa *this)
+gst_alsa_xrun_recovery (GstAlsa * this)
{
snd_pcm_status_t *status;
gint err;
gettimeofday (&now, 0);
snd_pcm_status_get_trigger_tstamp (status, &tstamp);
timersub (&now, &tstamp, &diff);
- GST_INFO_OBJECT (this, "alsa: xrun of at least %.3f msecs", diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
+ GST_INFO_OBJECT (this, "alsa: xrun of at least %.3f msecs",
+ diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
/* if we're allowed to recover, ... */
if (this->autorecover) {
prevent further xruns (at the cost of increased latency and memory
usage). */
if (this->period_count >= 4) {
- this->period_size *= 2;
- this->period_count /= 2;
+ this->period_size *= 2;
+ this->period_count /= 2;
} else {
- this->period_count *= 2;
+ this->period_count *= 2;
}
}
}
if (!(gst_alsa_stop_audio (this) && gst_alsa_start_audio (this))) {
GST_ELEMENT_ERROR (this, RESOURCE, FAILED, (NULL),
- ("Error restarting audio after xrun"));
+ ("Error restarting audio after xrun"));
return FALSE;
}
/*** AUDIO SETUP / START / STOP ***********************************************/
void
-gst_alsa_set_eos (GstAlsa *this)
+gst_alsa_set_eos (GstAlsa * this)
{
gst_alsa_drain_audio (this);
gst_element_set_eos (GST_ELEMENT (this));
}
+
static gboolean
-gst_alsa_open_audio (GstAlsa *this)
+gst_alsa_open_audio (GstAlsa * this)
{
g_assert (this != NULL);
g_assert (this->handle == NULL);
- GST_INFO ( "Opening alsa device \"%s\"...\n", this->device);
+ GST_INFO ("Opening alsa device \"%s\"...\n", this->device);
#if 0
/* enable this to get better debugging */
ERROR_CHECK (snd_output_stdio_attach (&this->out, stderr, 0),
- "error opening log output: %s");
+ "error opening log output: %s");
#endif
-
- if (snd_pcm_open (&this->handle, this->device,
- GST_ALSA_GET_CLASS (this)->stream, SND_PCM_NONBLOCK) < 0) {
+
+ if (snd_pcm_open (&this->handle, this->device,
+ GST_ALSA_GET_CLASS (this)->stream, SND_PCM_NONBLOCK) < 0) {
GST_ELEMENT_ERROR (GST_ELEMENT (this), RESOURCE, BUSY,
- (_("Alsa device \"%s\" is already in use by another program."), this->device),
- (NULL));
+ (_("Alsa device \"%s\" is already in use by another program."),
+ this->device), (NULL));
return FALSE;
}
GST_FLAG_SET (this, GST_ALSA_OPEN);
return TRUE;
}
+
/* if someone finds an easy way to merge this with _set_hw_params, go ahead */
static gboolean
-gst_alsa_probe_hw_params (GstAlsa *this, GstAlsaFormat *format)
+gst_alsa_probe_hw_params (GstAlsa * this, GstAlsaFormat * format)
{
snd_pcm_hw_params_t *hw_params;
snd_pcm_access_mask_t *mask;
g_return_val_if_fail (this != NULL, FALSE);
g_return_val_if_fail (format != NULL, FALSE);
-
- GST_INFO ( "Probing format: %s %dHz, %d channels\n",
- snd_pcm_format_name (format->format), format->rate, format->channels);
+
+ GST_INFO ("Probing format: %s %dHz, %d channels\n",
+ snd_pcm_format_name (format->format), format->rate, format->channels);
snd_pcm_hw_params_alloca (&hw_params);
SIMPLE_ERROR_CHECK (snd_pcm_hw_params_any (this->handle, hw_params));
- SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_integer (this->handle, hw_params));
+ SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_integer (this->handle,
+ hw_params));
/* enable this for soundcard specific debugging */
/* snd_pcm_hw_params_dump (hw_params, this->out); */
-
+
mask = alloca (snd_pcm_access_mask_sizeof ());
snd_pcm_access_mask_none (mask);
if (GST_ELEMENT (this)->numpads == 1) {
- snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
+ snd_pcm_access_mask_set (mask,
+ this->
+ mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
} else {
- snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED : SND_PCM_ACCESS_RW_NONINTERLEAVED);
+ snd_pcm_access_mask_set (mask,
+ this->
+ mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED :
+ SND_PCM_ACCESS_RW_NONINTERLEAVED);
}
- SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle, hw_params, mask));
-
- SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params, format->format));
- SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params, format->channels));
- SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params, format->rate, 0));
+ SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle,
+ hw_params, mask));
+
+ SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params,
+ format->format));
+ SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params,
+ format->channels));
+ SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params,
+ format->rate, 0));
period_count = this->period_count;
- SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle, hw_params, &period_count, 0));
+ SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle,
+ hw_params, &period_count, 0));
period_size = this->period_size;
- SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle, hw_params, &period_size, 0));
+ SIMPLE_ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle,
+ hw_params, &period_size, 0));
return TRUE;
}
+
/**
* You must set all hw parameters at once and can't use already set params and
* change them.
* Thx ALSA for not documenting this
*/
static gboolean
-gst_alsa_set_hw_params (GstAlsa *this)
+gst_alsa_set_hw_params (GstAlsa * this)
{
snd_pcm_hw_params_t *hw_params;
snd_pcm_access_mask_t *mask;
g_return_val_if_fail (this->handle != NULL, FALSE);
if (this->format) {
- GST_INFO ( "Preparing format: %s %dHz, %d channels",
- snd_pcm_format_name (this->format->format), this->format->rate, this->format->channels);
+ GST_INFO ("Preparing format: %s %dHz, %d channels",
+ snd_pcm_format_name (this->format->format), this->format->rate,
+ this->format->channels);
} else {
- GST_INFO ( "Preparing format: (none)");
+ GST_INFO ("Preparing format: (none)");
}
snd_pcm_hw_params_alloca (&hw_params);
ERROR_CHECK (snd_pcm_hw_params_any (this->handle, hw_params),
- "Broken configuration for this PCM: %s");
- ERROR_CHECK (snd_pcm_hw_params_set_periods_integer (this->handle, hw_params),
- "cannot restrict period size to integral value: %s");
+ "Broken configuration for this PCM: %s");
+ ERROR_CHECK (snd_pcm_hw_params_set_periods_integer (this->handle, hw_params),
+ "cannot restrict period size to integral value: %s");
/* enable this for soundcard specific debugging */
/* snd_pcm_hw_params_dump (hw_params, this->out); */
-
+
mask = alloca (snd_pcm_access_mask_sizeof ());
snd_pcm_access_mask_none (mask);
if (GST_ELEMENT (this)->numpads == 1) {
- snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
+ snd_pcm_access_mask_set (mask,
+ this->
+ mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED);
} else {
- snd_pcm_access_mask_set (mask, this->mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED : SND_PCM_ACCESS_RW_NONINTERLEAVED);
+ snd_pcm_access_mask_set (mask,
+ this->
+ mmap ? SND_PCM_ACCESS_MMAP_NONINTERLEAVED :
+ SND_PCM_ACCESS_RW_NONINTERLEAVED);
}
- ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle, hw_params, mask),
- "The Gstreamer ALSA plugin does not support your hardware. Error: %s");
-
+ ERROR_CHECK (snd_pcm_hw_params_set_access_mask (this->handle, hw_params,
+ mask),
+ "The Gstreamer ALSA plugin does not support your hardware. Error: %s");
+
if (this->format) {
- ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params, this->format->format),
- "Sample format (%s) not available: %s", snd_pcm_format_name (this->format->format));
- ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params, this->format->channels),
- "Channels count (%d) not available: %s", this->format->channels);
- ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params, this->format->rate, 0),
- "error setting rate (%d): %s", this->format->rate);
+ ERROR_CHECK (snd_pcm_hw_params_set_format (this->handle, hw_params,
+ this->format->format), "Sample format (%s) not available: %s",
+ snd_pcm_format_name (this->format->format));
+ ERROR_CHECK (snd_pcm_hw_params_set_channels (this->handle, hw_params,
+ this->format->channels), "Channels count (%d) not available: %s",
+ this->format->channels);
+ ERROR_CHECK (snd_pcm_hw_params_set_rate (this->handle, hw_params,
+ this->format->rate, 0), "error setting rate (%d): %s",
+ this->format->rate);
}
- ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle, hw_params, &this->period_count, 0),
- "error setting buffer size to %u: %s", (guint) this->period_count);
- ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle, hw_params, &this->period_size, 0),
- "error setting period size to %u frames: %s", (guint) this->period_size);
+ ERROR_CHECK (snd_pcm_hw_params_set_periods_near (this->handle, hw_params,
+ &this->period_count, 0), "error setting buffer size to %u: %s",
+ (guint) this->period_count);
+ ERROR_CHECK (snd_pcm_hw_params_set_period_size_near (this->handle, hw_params,
+ &this->period_size, 0), "error setting period size to %u frames: %s",
+ (guint) this->period_size);
ERROR_CHECK (snd_pcm_hw_params (this->handle, hw_params),
- "Could not set hardware parameters: %s");
+ "Could not set hardware parameters: %s");
/* now get the pcm caps */
- GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_PAUSE, snd_pcm_hw_params_can_pause (hw_params));
- GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_RESUME, snd_pcm_hw_params_can_resume (hw_params));
- GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START, snd_pcm_hw_params_can_sync_start (hw_params));
-
+ GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_PAUSE,
+ snd_pcm_hw_params_can_pause (hw_params));
+ GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_RESUME,
+ snd_pcm_hw_params_can_resume (hw_params));
+ GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START,
+ snd_pcm_hw_params_can_sync_start (hw_params));
+
if (this->mmap) {
this->transmit = GST_ALSA_GET_CLASS (this)->transmit_mmap;
} else {
return TRUE;
}
+
static gboolean
-gst_alsa_set_sw_params (GstAlsa *this)
+gst_alsa_set_sw_params (GstAlsa * this)
{
snd_pcm_sw_params_t *sw_params;
snd_pcm_sw_params_alloca (&sw_params);
ERROR_CHECK (snd_pcm_sw_params_current (this->handle, sw_params),
- "Could not get current software parameters: %s");
-
+ "Could not get current software parameters: %s");
+
ERROR_CHECK (snd_pcm_sw_params_set_silence_size (this->handle, sw_params, 0),
- "could not set silence size: %s");
- ERROR_CHECK (snd_pcm_sw_params_set_silence_threshold (this->handle, sw_params, 0),
- "could not set silence threshold: %s");
- ERROR_CHECK (snd_pcm_sw_params_set_avail_min (this->handle, sw_params, this->period_size),
- "could not set avail min: %s");
+ "could not set silence size: %s");
+ ERROR_CHECK (snd_pcm_sw_params_set_silence_threshold (this->handle, sw_params,
+ 0), "could not set silence threshold: %s");
+ ERROR_CHECK (snd_pcm_sw_params_set_avail_min (this->handle, sw_params,
+ this->period_size), "could not set avail min: %s");
/* we start explicitly */
- ERROR_CHECK (snd_pcm_sw_params_set_start_threshold (this->handle, sw_params, this->period_size * this->period_count + 1),
- "could not set start mode: %s");
- ERROR_CHECK (snd_pcm_sw_params_set_stop_threshold (this->handle, sw_params, this->period_size * this->period_count),
- "could not set stop mode: %s");
- ERROR_CHECK (snd_pcm_sw_params_set_xfer_align(this->handle, sw_params, 1),
- "Unable to set transfer align for playback: %s");
+ ERROR_CHECK (snd_pcm_sw_params_set_start_threshold (this->handle, sw_params,
+ this->period_size * this->period_count + 1),
+ "could not set start mode: %s");
+ ERROR_CHECK (snd_pcm_sw_params_set_stop_threshold (this->handle, sw_params,
+ this->period_size * this->period_count),
+ "could not set stop mode: %s");
+ ERROR_CHECK (snd_pcm_sw_params_set_xfer_align (this->handle, sw_params, 1),
+ "Unable to set transfer align for playback: %s");
ERROR_CHECK (snd_pcm_sw_params (this->handle, sw_params),
- "could not set sw_params: %s");
-
+ "could not set sw_params: %s");
+
return TRUE;
}
static gboolean
-gst_alsa_start_audio (GstAlsa *this)
+gst_alsa_start_audio (GstAlsa * this)
{
g_assert (GST_FLAG_IS_SET (this, GST_ALSA_OPEN));
-
+
if (!gst_alsa_set_hw_params (this))
return FALSE;
if (!gst_alsa_set_sw_params (this))
return FALSE;
-
+
GST_FLAG_SET (this, GST_ALSA_RUNNING);
return TRUE;
}
+
static gboolean
-gst_alsa_drain_audio (GstAlsa *this)
+gst_alsa_drain_audio (GstAlsa * this)
{
g_assert (this != NULL);
g_return_val_if_fail (this->handle != NULL, FALSE);
GST_DEBUG ("stopping alsa");
-
+
switch (snd_pcm_state (this->handle)) {
case SND_PCM_STATE_XRUN:
case SND_PCM_STATE_RUNNING:
/* fall through - clock is already stopped when paused */
case SND_PCM_STATE_PAUSED:
/* snd_pcm_drain only works in blocking mode */
- ERROR_CHECK (snd_pcm_nonblock(this->handle, 0), "couldn't set blocking mode: %s");
- ERROR_CHECK (snd_pcm_drain (this->handle), "couldn't stop and drain buffer: %s");
- ERROR_CHECK (snd_pcm_nonblock(this->handle, 1), "couldn't set non-blocking mode: %s");
+ ERROR_CHECK (snd_pcm_nonblock (this->handle, 0),
+ "couldn't set blocking mode: %s");
+ ERROR_CHECK (snd_pcm_drain (this->handle),
+ "couldn't stop and drain buffer: %s");
+ ERROR_CHECK (snd_pcm_nonblock (this->handle, 1),
+ "couldn't set non-blocking mode: %s");
break;
default:
break;
}
- GST_FLAG_UNSET (this, GST_ALSA_RUNNING);
+ GST_FLAG_UNSET (this, GST_ALSA_RUNNING);
return TRUE;
}
static gboolean
-gst_alsa_stop_audio (GstAlsa *this)
+gst_alsa_stop_audio (GstAlsa * this)
{
g_assert (this != NULL);
g_return_val_if_fail (this->handle != NULL, FALSE);
GST_DEBUG ("stopping alsa, skipping pending frames");
-
+
switch (snd_pcm_state (this->handle)) {
case SND_PCM_STATE_XRUN:
case SND_PCM_STATE_RUNNING:
/* fall through - clock is already stopped when paused */
case SND_PCM_STATE_PAUSED:
ERROR_CHECK (snd_pcm_drop (this->handle),
- "couldn't stop (dropping frames): %s");
+ "couldn't stop (dropping frames): %s");
break;
default:
break;
}
- GST_FLAG_UNSET (this, GST_ALSA_RUNNING);
+ GST_FLAG_UNSET (this, GST_ALSA_RUNNING);
return TRUE;
}
static gboolean
-gst_alsa_close_audio (GstAlsa *this)
+gst_alsa_close_audio (GstAlsa * this)
{
g_return_val_if_fail (this != NULL, FALSE);
g_return_val_if_fail (this->handle != NULL, FALSE);
/*** QUERYING/FORMAT/CONVERSION FUNCTIONS *************************************/
static const GstFormat *
-gst_alsa_get_formats (GstPad *pad)
+gst_alsa_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_TIME,
}
static gboolean
-gst_alsa_pad_convert (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_alsa_pad_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
- return gst_alsa_convert (GST_ALSA (GST_PAD_PARENT (pad)), src_format, src_value, dest_format, dest_value);
+ return gst_alsa_convert (GST_ALSA (GST_PAD_PARENT (pad)), src_format,
+ src_value, dest_format, dest_value);
}
static gboolean
-gst_alsa_convert (GstAlsa *this, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_alsa_convert (GstAlsa * this, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_DEFAULT:
*dest_value = gst_alsa_bytes_to_samples (this, (guint) src_value);
- break;
- case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_TIME:
*dest_value = gst_alsa_bytes_to_timestamp (this, (guint) src_value);
- break;
- default:
- res = FALSE;
+ break;
+ default:
+ res = FALSE;
break;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = gst_alsa_timestamp_to_samples (this, (GstClockTime) src_value);
- break;
- case GST_FORMAT_BYTES:
- *dest_value = gst_alsa_timestamp_to_bytes (this, (GstClockTime) src_value);
- break;
- default:
- res = FALSE;
+ case GST_FORMAT_DEFAULT:
+ *dest_value =
+ gst_alsa_timestamp_to_samples (this, (GstClockTime) src_value);
+ break;
+ case GST_FORMAT_BYTES:
+ *dest_value =
+ gst_alsa_timestamp_to_bytes (this, (GstClockTime) src_value);
+ break;
+ default:
+ res = FALSE;
break;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_TIME:
+ case GST_FORMAT_TIME:
*dest_value = gst_alsa_samples_to_timestamp (this, (guint) src_value);
- break;
- case GST_FORMAT_BYTES:
+ break;
+ case GST_FORMAT_BYTES:
*dest_value = gst_alsa_samples_to_bytes (this, (guint) src_value);
- break;
- case GST_FORMAT_DEFAULT:
- g_assert_not_reached ();
+ break;
+ case GST_FORMAT_DEFAULT:
+ g_assert_not_reached ();
/* fall through */
- default:
- res = FALSE;
+ default:
+ res = FALSE;
break;
}
break;
}
static const GstQueryType *
-gst_alsa_get_query_types (GstPad *pad)
+gst_alsa_get_query_types (GstPad * pad)
{
static const GstQueryType query_types[] = {
GST_QUERY_LATENCY,
}
static gboolean
-gst_alsa_query_func (GstElement *element, GstQueryType type, GstFormat *format, gint64 *value)
+gst_alsa_query_func (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = FALSE;
GstAlsa *this = GST_ALSA (element);
switch (type) {
- case GST_QUERY_LATENCY: {
+ case GST_QUERY_LATENCY:{
snd_pcm_sframes_t delay;
- ERROR_CHECK (snd_pcm_delay (this->handle, &delay), "Error getting delay: %s");
- res = gst_alsa_convert (this, GST_FORMAT_DEFAULT, (gint64) delay, format, value);
+
+ ERROR_CHECK (snd_pcm_delay (this->handle, &delay),
+ "Error getting delay: %s");
+ res =
+ gst_alsa_convert (this, GST_FORMAT_DEFAULT, (gint64) delay, format,
+ value);
break;
}
case GST_QUERY_POSITION:
- res = gst_alsa_convert (this, GST_FORMAT_TIME, gst_element_get_time (GST_ELEMENT (this)), format, value);
+ res =
+ gst_alsa_convert (this, GST_FORMAT_TIME,
+ gst_element_get_time (GST_ELEMENT (this)), format, value);
break;
default:
break;
}
static gboolean
-gst_alsa_query (GstElement *element, GstQueryType type, GstFormat *format, gint64 *value)
+gst_alsa_query (GstElement * element, GstQueryType type, GstFormat * format,
+ gint64 * value)
{
return gst_alsa_pad_query (GST_ALSA (element)->pad[0], type, format, value);
}
static gboolean
-gst_alsa_pad_query (GstPad *pad, GstQueryType type, GstFormat *format, gint64 *value)
+gst_alsa_pad_query (GstPad * pad, GstQueryType type, GstFormat * format,
+ gint64 * value)
{
if (gst_alsa_query_func (GST_PAD_PARENT (pad), type, format, value))
return TRUE;
- if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK && gst_pad_query (gst_pad_get_peer (pad), type, format, value))
+ if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK
+ && gst_pad_query (gst_pad_get_peer (pad), type, format, value))
return TRUE;
return FALSE;
}
inline snd_pcm_uframes_t
-gst_alsa_timestamp_to_samples (GstAlsa *this, GstClockTime time)
+gst_alsa_timestamp_to_samples (GstAlsa * this, GstClockTime time)
{
- return (snd_pcm_uframes_t) ((time * this->format->rate + this->format->rate / 2) / GST_SECOND);
+ return (snd_pcm_uframes_t) ((time * this->format->rate +
+ this->format->rate / 2) / GST_SECOND);
}
inline GstClockTime
-gst_alsa_samples_to_timestamp (GstAlsa *this, snd_pcm_uframes_t samples)
+gst_alsa_samples_to_timestamp (GstAlsa * this, snd_pcm_uframes_t samples)
{
return (GstClockTime) (samples * GST_SECOND / this->format->rate);
}
inline snd_pcm_uframes_t
-gst_alsa_bytes_to_samples (GstAlsa *this, guint bytes)
+gst_alsa_bytes_to_samples (GstAlsa * this, guint bytes)
{
- return bytes / (snd_pcm_format_physical_width (this->format->format) / 8) / (GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
+ return bytes / (snd_pcm_format_physical_width (this->format->format) / 8) /
+ (GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
}
inline guint
-gst_alsa_samples_to_bytes (GstAlsa *this, snd_pcm_uframes_t samples)
+gst_alsa_samples_to_bytes (GstAlsa * this, snd_pcm_uframes_t samples)
{
- return samples * snd_pcm_format_physical_width (this->format->format) / 8 * (GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
+ return samples * snd_pcm_format_physical_width (this->format->format) / 8 *
+ (GST_ELEMENT (this)->numpads == 1 ? this->format->channels : 1);
}
inline GstClockTime
-gst_alsa_bytes_to_timestamp (GstAlsa *this, guint bytes)
+gst_alsa_bytes_to_timestamp (GstAlsa * this, guint bytes)
{
- return gst_alsa_samples_to_timestamp (this, gst_alsa_bytes_to_samples (this, bytes));
+ return gst_alsa_samples_to_timestamp (this, gst_alsa_bytes_to_samples (this,
+ bytes));
}
inline guint
-gst_alsa_timestamp_to_bytes (GstAlsa *this, GstClockTime time)
+gst_alsa_timestamp_to_bytes (GstAlsa * this, GstClockTime time)
{
- return gst_alsa_samples_to_bytes (this, gst_alsa_timestamp_to_samples (this, time));
+ return gst_alsa_samples_to_bytes (this, gst_alsa_timestamp_to_samples (this,
+ time));
}
#define GST_ALSA_MIN_RATE 8000
#define GST_ALSA_MAX_RATE 192000
-#define GST_ALSA_MAX_TRACKS 64 /* we don't support more than 64 tracks */
-#define GST_ALSA_MAX_CHANNELS 32 /* tracks can have up to 32 channels */
+#define GST_ALSA_MAX_TRACKS 64 /* we don't support more than 64 tracks */
+#define GST_ALSA_MAX_CHANNELS 32 /* tracks can have up to 32 channels */
/* Mono is 1 channel ; the 5.1 standard is 6 channels. The value for
GST_ALSA_MAX_CHANNELS comes from alsa/mixer.h. */
#define GST_ALSA_DEFAULT_DISCONT (GST_SECOND / 10)
G_BEGIN_DECLS
-
#define GST_ALSA(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA, GstAlsa))
#define GST_ALSA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA, GstAlsaClass))
#define GST_ALSA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ALSA, GstAlsaClass))
#define GST_IS_ALSA(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA))
#define GST_IS_ALSA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA))
#define GST_TYPE_ALSA (gst_alsa_get_type())
-
-enum {
+ enum
+{
GST_ALSA_OPEN = GST_ELEMENT_FLAG_LAST,
GST_ALSA_RUNNING,
GST_ALSA_CAPS_NEGO,
GST_ALSA_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 3,
};
-typedef enum {
+typedef enum
+{
GST_ALSA_CAPS_PAUSE = 0,
GST_ALSA_CAPS_RESUME,
GST_ALSA_CAPS_SYNC_START
- /* add more */
+ /* add more */
} GstAlsaPcmCaps;
#define GST_ALSA_CAPS_IS_SET(obj, flag) (GST_ALSA (obj)->pcm_caps & (1<<(flag)))
typedef struct _GstAlsa GstAlsa;
typedef struct _GstAlsaClass GstAlsaClass;
-typedef int (*GstAlsaTransmitFunction) (GstAlsa *this, snd_pcm_sframes_t *avail);
+typedef int (*GstAlsaTransmitFunction) (GstAlsa * this,
+ snd_pcm_sframes_t * avail);
-typedef struct {
- snd_pcm_format_t format;
- guint rate;
- gint channels;
+typedef struct
+{
+ snd_pcm_format_t format;
+ guint rate;
+ gint channels;
} GstAlsaFormat;
-struct _GstAlsa {
- GstElement parent;
+struct _GstAlsa
+{
+ GstElement parent;
/* array of GstAlsaPads */
- GstPad * pad[GST_ALSA_MAX_TRACKS];
+ GstPad *pad[GST_ALSA_MAX_TRACKS];
- gchar * device;
- snd_pcm_t * handle;
- snd_pcm_info_t * info;
- guint pcm_caps; /* capabilities of the pcm device, see GstAlsaPcmCaps */
- snd_output_t * out;
+ gchar *device;
+ snd_pcm_t *handle;
+ snd_pcm_info_t *info;
+ guint pcm_caps; /* capabilities of the pcm device, see GstAlsaPcmCaps */
+ snd_output_t *out;
- GstAlsaFormat * format; /* NULL if undefined */
- gboolean mmap; /* use mmap transmit (fast) or read/write (sloooow) */
- GstAlsaTransmitFunction transmit;
+ GstAlsaFormat *format; /* NULL if undefined */
+ gboolean mmap; /* use mmap transmit (fast) or read/write (sloooow) */
+ GstAlsaTransmitFunction transmit;
/* latency / performance parameters */
- snd_pcm_uframes_t period_size;
- unsigned int period_count;
+ snd_pcm_uframes_t period_size;
+ unsigned int period_count;
- gboolean autorecover;
+ gboolean autorecover;
/* clocking */
- GstAlsaClock * clock; /* our provided clock */
- snd_pcm_uframes_t transmitted; /* samples transmitted since last sync
- This thing actually is our master clock.
- We will event insert silent samples or
- drop some to sync to incoming timestamps.
- */
- GstClockTime max_discont; /* max difference between current
- playback timestamp and buffers timestamps
- */
+ GstAlsaClock *clock; /* our provided clock */
+ snd_pcm_uframes_t transmitted; /* samples transmitted since last sync
+ This thing actually is our master clock.
+ We will event insert silent samples or
+ drop some to sync to incoming timestamps.
+ */
+ GstClockTime max_discont; /* max difference between current
+ playback timestamp and buffers timestamps
+ */
};
-struct _GstAlsaClass {
- GstElementClass parent_class;
+struct _GstAlsaClass
+{
+ GstElementClass parent_class;
- snd_pcm_stream_t stream;
+ snd_pcm_stream_t stream;
/* different transmit functions */
- GstAlsaTransmitFunction transmit_mmap;
- GstAlsaTransmitFunction transmit_rw;
+ GstAlsaTransmitFunction transmit_mmap;
+ GstAlsaTransmitFunction transmit_rw;
/* autodetected devices available */
GList *devices;
GType gst_alsa_get_type (void);
-void gst_alsa_set_eos (GstAlsa * this);
-GstPadLinkReturn gst_alsa_link (GstPad * pad,
- const GstCaps * caps);
-GstCaps * gst_alsa_get_caps (GstPad * pad);
-GstCaps * gst_alsa_fixate (GstPad * pad,
- const GstCaps * caps);
-GstCaps * gst_alsa_caps (snd_pcm_format_t format,
- gint rate,
- gint channels);
+void gst_alsa_set_eos (GstAlsa * this);
+GstPadLinkReturn gst_alsa_link (GstPad * pad, const GstCaps * caps);
+GstCaps *gst_alsa_get_caps (GstPad * pad);
+GstCaps *gst_alsa_fixate (GstPad * pad, const GstCaps * caps);
+GstCaps *gst_alsa_caps (snd_pcm_format_t format, gint rate, gint channels);
/* audio processing functions */
-inline snd_pcm_sframes_t gst_alsa_update_avail (GstAlsa * this);
-inline gboolean gst_alsa_pcm_wait (GstAlsa * this);
-inline gboolean gst_alsa_start (GstAlsa * this);
-gboolean gst_alsa_xrun_recovery (GstAlsa * this);
+inline snd_pcm_sframes_t gst_alsa_update_avail (GstAlsa * this);
+inline gboolean gst_alsa_pcm_wait (GstAlsa * this);
+inline gboolean gst_alsa_start (GstAlsa * this);
+gboolean gst_alsa_xrun_recovery (GstAlsa * this);
/* format conversions */
-inline snd_pcm_uframes_t gst_alsa_timestamp_to_samples (GstAlsa * this,
- GstClockTime time);
-inline GstClockTime gst_alsa_samples_to_timestamp (GstAlsa * this,
- snd_pcm_uframes_t samples);
-inline snd_pcm_uframes_t gst_alsa_bytes_to_samples (GstAlsa * this,
- guint bytes);
-inline guint gst_alsa_samples_to_bytes (GstAlsa * this,
- snd_pcm_uframes_t samples);
-inline GstClockTime gst_alsa_bytes_to_timestamp (GstAlsa * this,
- guint bytes);
-inline guint gst_alsa_timestamp_to_bytes (GstAlsa * this,
- GstClockTime time);
+inline snd_pcm_uframes_t gst_alsa_timestamp_to_samples (GstAlsa * this,
+ GstClockTime time);
+inline GstClockTime gst_alsa_samples_to_timestamp (GstAlsa * this,
+ snd_pcm_uframes_t samples);
+inline snd_pcm_uframes_t gst_alsa_bytes_to_samples (GstAlsa * this,
+ guint bytes);
+inline guint gst_alsa_samples_to_bytes (GstAlsa * this,
+ snd_pcm_uframes_t samples);
+inline GstClockTime gst_alsa_bytes_to_timestamp (GstAlsa * this, guint bytes);
+inline guint gst_alsa_timestamp_to_bytes (GstAlsa * this, GstClockTime time);
G_END_DECLS
-
#endif /* __GST_ALSA_H__ */
#include "gstalsaclock.h"
/* clock functions */
-static void gst_alsa_clock_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_alsa_clock_init (GstAlsaClock * clock);
-
-static GstClockTime gst_alsa_clock_get_internal_time (GstClock * clock);
-static guint64 gst_alsa_clock_get_resolution (GstClock * clock);
-static GstClockEntryStatus gst_alsa_clock_wait (GstClock * clock,
- GstClockEntry * entry);
-static void gst_alsa_clock_unlock (GstClock * clock,
- GstClockEntry * entry);
-
-static GstClockClass * clock_parent_class = NULL;
+static void gst_alsa_clock_class_init (gpointer g_class, gpointer class_data);
+static void gst_alsa_clock_init (GstAlsaClock * clock);
+
+static GstClockTime gst_alsa_clock_get_internal_time (GstClock * clock);
+static guint64 gst_alsa_clock_get_resolution (GstClock * clock);
+static GstClockEntryStatus gst_alsa_clock_wait (GstClock * clock,
+ GstClockEntry * entry);
+static void gst_alsa_clock_unlock (GstClock * clock, GstClockEntry * entry);
+
+static GstClockClass *clock_parent_class = NULL;
+
/* static guint gst_alsa_clock_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_alsa_clock_get_type (void)
-{
+{
static GType clock_type = 0;
-
+
if (!clock_type) {
static const GTypeInfo clock_info = {
sizeof (GstAlsaClockClass),
NULL
};
clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstAlsaClock",
- &clock_info, 0);
+ &clock_info, 0);
}
return clock_type;
}
GstAlsaClockClass *klass;
klass = (GstAlsaClockClass *) g_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;
clock_parent_class = g_type_class_ref (GST_TYPE_CLOCK);
gstclock_class->unlock = gst_alsa_clock_unlock;
}
static void
-gst_alsa_clock_init (GstAlsaClock *clock)
+gst_alsa_clock_init (GstAlsaClock * clock)
{
gst_object_set_name (GST_OBJECT (clock), "GstAlsaClock");
clock->start_time = GST_CLOCK_TIME_NONE;
}
-GstAlsaClock*
-gst_alsa_clock_new (gchar *name, GstAlsaClockGetTimeFunc get_time, GstAlsa *owner)
+
+GstAlsaClock *
+gst_alsa_clock_new (gchar * name, GstAlsaClockGetTimeFunc get_time,
+ GstAlsa * owner)
{
- GstAlsaClock *alsa_clock = GST_ALSA_CLOCK (g_object_new (GST_TYPE_ALSA_CLOCK, NULL));
+ GstAlsaClock *alsa_clock =
+ GST_ALSA_CLOCK (g_object_new (GST_TYPE_ALSA_CLOCK, NULL));
g_assert (alsa_clock);
return alsa_clock;
}
+
void
-gst_alsa_clock_start (GstAlsaClock *clock)
+gst_alsa_clock_start (GstAlsaClock * clock)
{
g_assert (!GST_CLOCK_TIME_IS_VALID (clock->start_time));
if (clock->owner->format) {
clock->start_time = gst_clock_get_event_time (GST_CLOCK (clock))
- - clock->get_time (clock->owner);
+ - clock->get_time (clock->owner);
} else {
clock->start_time = gst_clock_get_event_time (GST_CLOCK (clock));
}
}
void
-gst_alsa_clock_stop (GstAlsaClock *clock)
+gst_alsa_clock_stop (GstAlsaClock * clock)
{
GTimeVal timeval;
+
g_get_current_time (&timeval);
g_assert (GST_CLOCK_TIME_IS_VALID (clock->start_time));
- clock->adjust += GST_TIMEVAL_TO_TIME (timeval) - gst_clock_get_event_time (GST_CLOCK (clock));
+ clock->adjust +=
+ GST_TIMEVAL_TO_TIME (timeval) -
+ gst_clock_get_event_time (GST_CLOCK (clock));
clock->start_time = GST_CLOCK_TIME_NONE;
}
+
static GstClockTime
-gst_alsa_clock_get_internal_time (GstClock *clock)
+gst_alsa_clock_get_internal_time (GstClock * clock)
{
GstAlsaClock *alsa_clock = GST_ALSA_CLOCK (clock);
-
+
if (GST_CLOCK_TIME_IS_VALID (alsa_clock->start_time)) {
return alsa_clock->get_time (alsa_clock->owner) + alsa_clock->start_time;
} else {
GTimeVal timeval;
+
g_get_current_time (&timeval);
return GST_TIMEVAL_TO_TIME (timeval) + alsa_clock->adjust;
}
}
static guint64
-gst_alsa_clock_get_resolution (GstClock *clock)
+gst_alsa_clock_get_resolution (GstClock * clock)
{
GstAlsaClock *this = GST_ALSA_CLOCK (clock);
}
}
static GstClockEntryStatus
-gst_alsa_clock_wait (GstClock *clock, GstClockEntry *entry)
+gst_alsa_clock_wait (GstClock * clock, GstClockEntry * entry)
{
GstClockTime target, entry_time;
GstClockTimeDiff diff;
if (diff < 0)
return GST_CLOCK_ENTRY_EARLY;
-
+
if (diff > clock->max_diff) {
- GST_INFO_OBJECT (this, "GstAlsaClock: abnormal clock request diff: %" G_GINT64_FORMAT") >"
- " %"G_GINT64_FORMAT, diff, clock->max_diff);
+ GST_INFO_OBJECT (this,
+ "GstAlsaClock: abnormal clock request diff: %" G_GINT64_FORMAT ") >"
+ " %" G_GINT64_FORMAT, diff, clock->max_diff);
return GST_CLOCK_ENTRY_EARLY;
}
-
+
target = entry_time + diff;
GST_DEBUG_OBJECT (this, "real_target %" G_GUINT64_FORMAT
- " target %" G_GUINT64_FORMAT
- " now %" G_GUINT64_FORMAT,
- target, GST_CLOCK_ENTRY_TIME (entry), entry_time);
-
- while (gst_alsa_clock_get_internal_time (clock) < target &&
- this->last_unlock < entry_time) {
- g_usleep (gst_alsa_clock_get_resolution (clock) * G_USEC_PER_SEC / GST_SECOND);
+ " target %" G_GUINT64_FORMAT
+ " now %" G_GUINT64_FORMAT,
+ target, GST_CLOCK_ENTRY_TIME (entry), entry_time);
+
+ while (gst_alsa_clock_get_internal_time (clock) < target &&
+ this->last_unlock < entry_time) {
+ g_usleep (gst_alsa_clock_get_resolution (clock) * G_USEC_PER_SEC /
+ GST_SECOND);
}
return entry->status;
}
static void
-gst_alsa_clock_unlock (GstClock *clock, GstClockEntry *entry)
+gst_alsa_clock_unlock (GstClock * clock, GstClockEntry * entry)
{
GstAlsaClock *this = GST_ALSA_CLOCK (clock);
this->last_unlock = this->get_time (this->owner);
}
-
#include "gstalsa.h"
G_BEGIN_DECLS
-
#define GST_ALSA_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_CLOCK,GstAlsaClock))
#define GST_ALSA_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_CLOCK,GstAlsaClockClass))
#define GST_IS_ALSA_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_CLOCK))
#define GST_IS_ALSA_CLOCK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_CLOCK))
#define GST_TYPE_ALSA_CLOCK (gst_alsa_clock_get_type())
-
typedef GstClockTime (*GstAlsaClockGetTimeFunc) (GstAlsa *);
-struct _GstAlsaClock {
- GstSystemClock parent;
+struct _GstAlsaClock
+{
+ GstSystemClock parent;
- GstAlsaClockGetTimeFunc get_time;
- GstAlsa * owner;
+ GstAlsaClockGetTimeFunc get_time;
+ GstAlsa *owner;
- GstClockTimeDiff adjust; /* adjustment to real clock (recalculated when stopping) */
- GstClockTime start_time; /* time when the stream started (NONE when stopped) */
- GstClockTime last_unlock; /* time of last unlock request */
+ GstClockTimeDiff adjust; /* adjustment to real clock (recalculated when stopping) */
+ GstClockTime start_time; /* time when the stream started (NONE when stopped) */
+ GstClockTime last_unlock; /* time of last unlock request */
};
-struct _GstAlsaClockClass {
+struct _GstAlsaClockClass
+{
GstSystemClockClass parent_class;
};
-GType gst_alsa_clock_get_type (void);
-GstAlsaClock * gst_alsa_clock_new (gchar * name,
- GstAlsaClockGetTimeFunc func,
- GstAlsa * owner);
+GType gst_alsa_clock_get_type (void);
+GstAlsaClock *gst_alsa_clock_new (gchar * name,
+ GstAlsaClockGetTimeFunc func, GstAlsa * owner);
-void gst_alsa_clock_start (GstAlsaClock * clock);
-void gst_alsa_clock_stop (GstAlsaClock * clock);
+void gst_alsa_clock_start (GstAlsaClock * clock);
+void gst_alsa_clock_stop (GstAlsaClock * clock);
G_END_DECLS
-
#endif /* __GST_ALSA_CLOCK_H__ */
#include "gstalsamixer.h"
/* elementfactory information */
-static GstElementDetails gst_alsa_mixer_details = GST_ELEMENT_DETAILS (
- "Alsa Mixer",
- "Generic/Audio",
- "Control sound input and output levels with ALSA",
- "Leif Johnson <leif@ambient.2y.net>"
-);
-
-static void gst_alsa_interface_init (GstImplementsInterfaceClass *klass);
-
-static void gst_alsa_mixer_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_alsa_mixer_init (GstAlsaMixer * mixer);
-static void gst_alsa_mixer_dispose (GObject * object);
-static void gst_alsa_mixer_interface_init (GstMixerClass* klass);
-static gboolean gst_alsa_mixer_supported (GstImplementsInterface * iface,
- GType iface_type);
+static GstElementDetails gst_alsa_mixer_details =
+GST_ELEMENT_DETAILS ("Alsa Mixer",
+ "Generic/Audio",
+ "Control sound input and output levels with ALSA",
+ "Leif Johnson <leif@ambient.2y.net>");
+
+static void gst_alsa_interface_init (GstImplementsInterfaceClass * klass);
+
+static void gst_alsa_mixer_class_init (gpointer g_class, gpointer class_data);
+static void gst_alsa_mixer_init (GstAlsaMixer * mixer);
+static void gst_alsa_mixer_dispose (GObject * object);
+static void gst_alsa_mixer_interface_init (GstMixerClass * klass);
+static gboolean gst_alsa_mixer_supported (GstImplementsInterface * iface,
+ GType iface_type);
/* GStreamer stuff */
-static GstElementStateReturn gst_alsa_mixer_change_state (GstElement * element);
+static GstElementStateReturn gst_alsa_mixer_change_state (GstElement * element);
-static void gst_alsa_mixer_build_list (GstAlsaMixer * mixer);
-static void gst_alsa_mixer_free_list (GstAlsaMixer * mixer);
+static void gst_alsa_mixer_build_list (GstAlsaMixer * mixer);
+static void gst_alsa_mixer_free_list (GstAlsaMixer * mixer);
/* interface implementation */
-static const GList * gst_alsa_mixer_list_tracks (GstMixer * mixer);
-
-static void gst_alsa_mixer_set_volume (GstMixer * mixer,
- GstMixerTrack* track,
- gint * volumes);
-static void gst_alsa_mixer_get_volume (GstMixer * mixer,
- GstMixerTrack* track,
- gint * volumes);
-
-static void gst_alsa_mixer_set_record (GstMixer * mixer,
- GstMixerTrack* track,
- gboolean record);
-static void gst_alsa_mixer_set_mute (GstMixer * mixer,
- GstMixerTrack* track,
- gboolean mute);
+static const GList *gst_alsa_mixer_list_tracks (GstMixer * mixer);
+
+static void gst_alsa_mixer_set_volume (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes);
+static void gst_alsa_mixer_get_volume (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes);
+
+static void gst_alsa_mixer_set_record (GstMixer * mixer,
+ GstMixerTrack * track, gboolean record);
+static void gst_alsa_mixer_set_mute (GstMixer * mixer,
+ GstMixerTrack * track, gboolean mute);
/*** GOBJECT STUFF ************************************************************/
NULL,
};
- alsa_mixer_type = g_type_register_static (GST_TYPE_ALSA, "GstAlsaMixer", &alsa_mixer_info, 0);
+ alsa_mixer_type =
+ g_type_register_static (GST_TYPE_ALSA, "GstAlsaMixer", &alsa_mixer_info,
+ 0);
- g_type_add_interface_static (alsa_mixer_type, GST_TYPE_IMPLEMENTS_INTERFACE, &alsa_iface_info);
- g_type_add_interface_static (alsa_mixer_type, GST_TYPE_MIXER, &alsa_mixer_iface_info);
+ g_type_add_interface_static (alsa_mixer_type, GST_TYPE_IMPLEMENTS_INTERFACE,
+ &alsa_iface_info);
+ g_type_add_interface_static (alsa_mixer_type, GST_TYPE_MIXER,
+ &alsa_mixer_iface_info);
}
return alsa_mixer_type;
GstElementClass *element_class;
GstAlsaClass *klass;
- klass = (GstAlsaClass *)g_class;
+ klass = (GstAlsaClass *) g_class;
object_class = (GObjectClass *) g_class;
element_class = (GstElementClass *) g_class;
gint err;
GstAlsa *alsa = GST_ALSA (mixer);
- mixer->mixer_handle = (snd_mixer_t *) -1;
+ mixer->mixer_handle = (snd_mixer_t *) - 1;
/* open and initialize the mixer device */
- err = snd_mixer_open(&mixer->mixer_handle, 0);
+ err = snd_mixer_open (&mixer->mixer_handle, 0);
if (err < 0 || mixer->mixer_handle == NULL) {
GST_ERROR_OBJECT (GST_OBJECT (mixer), "Cannot open mixer device.");
- mixer->mixer_handle = (snd_mixer_t *) -1;
+ mixer->mixer_handle = (snd_mixer_t *) - 1;
return;
}
- if ((err = snd_mixer_attach(mixer->mixer_handle, alsa->device)) < 0) {
+ if ((err = snd_mixer_attach (mixer->mixer_handle, alsa->device)) < 0) {
GST_ERROR_OBJECT (GST_OBJECT (mixer),
- "Cannot attach mixer to sound device `%s'.",
- alsa->device);
+ "Cannot attach mixer to sound device `%s'.", alsa->device);
goto error;
}
- if ((err = snd_mixer_selem_register(mixer->mixer_handle, NULL, NULL)) < 0) {
+ if ((err = snd_mixer_selem_register (mixer->mixer_handle, NULL, NULL)) < 0) {
GST_ERROR_OBJECT (GST_OBJECT (mixer), "Cannot register mixer elements.");
goto error;
}
- if ((err = snd_mixer_load(mixer->mixer_handle)) < 0) {
+ if ((err = snd_mixer_load (mixer->mixer_handle)) < 0) {
GST_ERROR_OBJECT (GST_OBJECT (mixer), "Cannot load mixer settings.");
goto error;
}
return;
- error:
+error:
snd_mixer_close (mixer->mixer_handle);
- mixer->mixer_handle = (snd_mixer_t *) -1;
+ mixer->mixer_handle = (snd_mixer_t *) - 1;
}
static void
{
GstAlsaMixer *mixer = GST_ALSA_MIXER (object);
- if (((gint) mixer->mixer_handle) == -1) return;
+ if (((gint) mixer->mixer_handle) == -1)
+ return;
snd_mixer_close (mixer->mixer_handle);
- mixer->mixer_handle = (snd_mixer_t *) -1;
+ mixer->mixer_handle = (snd_mixer_t *) - 1;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-gst_alsa_interface_init (GstImplementsInterfaceClass *klass)
+gst_alsa_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_alsa_mixer_supported;
}
static void
-gst_alsa_mixer_interface_init (GstMixerClass *klass)
+gst_alsa_mixer_interface_init (GstMixerClass * klass)
{
GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE;
-
+
/* set up the interface hooks */
klass->list_tracks = gst_alsa_mixer_list_tracks;
klass->set_volume = gst_alsa_mixer_set_volume;
}
gboolean
-gst_alsa_mixer_supported (GstImplementsInterface *iface, GType iface_type)
+gst_alsa_mixer_supported (GstImplementsInterface * iface, GType iface_type)
{
g_assert (iface_type == GST_TYPE_MIXER);
}
static void
-gst_alsa_mixer_build_list (GstAlsaMixer *mixer)
+gst_alsa_mixer_build_list (GstAlsaMixer * mixer)
{
gint i, count;
snd_mixer_elem_t *element;
g_return_if_fail (((gint) mixer->mixer_handle) != -1);
- count = snd_mixer_get_count(mixer->mixer_handle);
- element = snd_mixer_first_elem(mixer->mixer_handle);
+ count = snd_mixer_get_count (mixer->mixer_handle);
+ element = snd_mixer_first_elem (mixer->mixer_handle);
/* build track list */
for (i = 0; i < count; i++) {
gint channels = 0;
- if (! snd_mixer_selem_is_active(element)) continue;
+ if (!snd_mixer_selem_is_active (element))
+ continue;
/* find out if this element can be an input */
- if (snd_mixer_selem_has_capture_channel(element, 0) ||
- snd_mixer_selem_has_capture_switch(element) ||
- snd_mixer_selem_is_capture_mono(element)) {
- while (snd_mixer_selem_has_capture_channel(element, channels))
- channels++;
+ if (snd_mixer_selem_has_capture_channel (element, 0) ||
+ snd_mixer_selem_has_capture_switch (element) ||
+ snd_mixer_selem_is_capture_mono (element)) {
+ while (snd_mixer_selem_has_capture_channel (element, channels))
+ channels++;
track = gst_alsa_mixer_track_new
- (element, i, channels, GST_MIXER_TRACK_INPUT);
+ (element, i, channels, GST_MIXER_TRACK_INPUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
channels = 0;
- if (snd_mixer_selem_has_playback_channel(element, 0) ||
- snd_mixer_selem_has_playback_switch(element) ||
- snd_mixer_selem_is_playback_mono(element)) {
- while (snd_mixer_selem_has_playback_channel(element, channels))
- channels++;
+ if (snd_mixer_selem_has_playback_channel (element, 0) ||
+ snd_mixer_selem_has_playback_switch (element) ||
+ snd_mixer_selem_is_playback_mono (element)) {
+ while (snd_mixer_selem_has_playback_channel (element, channels))
+ channels++;
track = gst_alsa_mixer_track_new
- (element, i, channels, GST_MIXER_TRACK_OUTPUT);
+ (element, i, channels, GST_MIXER_TRACK_OUTPUT);
mixer->tracklist = g_list_append (mixer->tracklist, track);
}
- element = snd_mixer_elem_next(element);
+ element = snd_mixer_elem_next (element);
}
}
static void
-gst_alsa_mixer_free_list (GstAlsaMixer *mixer)
+gst_alsa_mixer_free_list (GstAlsaMixer * mixer)
{
g_return_if_fail (((gint) mixer->mixer_handle) != -1);
/*** GSTREAMER FUNCTIONS ******************************************************/
static GstElementStateReturn
-gst_alsa_mixer_change_state (GstElement *element)
+gst_alsa_mixer_change_state (GstElement * element)
{
GstAlsaMixer *this;
this = GST_ALSA_MIXER (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
- gst_alsa_mixer_build_list (this); break;
- case GST_STATE_READY_TO_NULL:
- gst_alsa_mixer_free_list (this); break;
- default:
- g_assert_not_reached();
+ case GST_STATE_NULL_TO_READY:
+ gst_alsa_mixer_build_list (this);
+ break;
+ case GST_STATE_READY_TO_NULL:
+ gst_alsa_mixer_free_list (this);
+ break;
+ default:
+ g_assert_not_reached ();
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
/*** INTERFACE IMPLEMENTATION *************************************************/
static const GList *
-gst_alsa_mixer_list_tracks (GstMixer *mixer)
+gst_alsa_mixer_list_tracks (GstMixer * mixer)
{
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
}
static void
-gst_alsa_mixer_get_volume (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes)
+gst_alsa_mixer_get_volume (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes)
{
gint i;
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
} else {
for (i = 0; i < track->num_channels; i++) {
long tmp;
- if (snd_mixer_selem_has_playback_channel(alsa_track->element, i)) {
- snd_mixer_selem_get_playback_volume(alsa_track->element, i, &tmp);
- volumes[i] = (gint) tmp;
- } else if (snd_mixer_selem_has_capture_channel(alsa_track->element, i)) {
- snd_mixer_selem_get_capture_volume(alsa_track->element, i, &tmp);
- volumes[i] = (gint) tmp;
+
+ if (snd_mixer_selem_has_playback_channel (alsa_track->element, i)) {
+ snd_mixer_selem_get_playback_volume (alsa_track->element, i, &tmp);
+ volumes[i] = (gint) tmp;
+ } else if (snd_mixer_selem_has_capture_channel (alsa_track->element, i)) {
+ snd_mixer_selem_get_capture_volume (alsa_track->element, i, &tmp);
+ volumes[i] = (gint) tmp;
}
}
}
}
static void
-gst_alsa_mixer_set_volume (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes)
+gst_alsa_mixer_set_volume (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes)
{
gint i;
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
g_return_if_fail (((gint) alsa_mixer->mixer_handle) != -1);
/* only set the volume with ALSA lib if the track isn't muted. */
- if (! (track->flags & GST_MIXER_TRACK_MUTE)) {
+ if (!(track->flags & GST_MIXER_TRACK_MUTE)) {
for (i = 0; i < track->num_channels; i++) {
- if (snd_mixer_selem_has_playback_channel(alsa_track->element, i))
- snd_mixer_selem_set_playback_volume(alsa_track->element, i, (long) volumes[i]);
- else if (snd_mixer_selem_has_capture_channel(alsa_track->element, i))
- snd_mixer_selem_set_capture_volume(alsa_track->element, i, (long) volumes[i]);
+ if (snd_mixer_selem_has_playback_channel (alsa_track->element, i))
+ snd_mixer_selem_set_playback_volume (alsa_track->element, i,
+ (long) volumes[i]);
+ else if (snd_mixer_selem_has_capture_channel (alsa_track->element, i))
+ snd_mixer_selem_set_capture_volume (alsa_track->element, i,
+ (long) volumes[i]);
}
}
}
static void
-gst_alsa_mixer_set_mute (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean mute)
+gst_alsa_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
gint i;
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
track->flags |= GST_MIXER_TRACK_MUTE;
for (i = 0; i < track->num_channels; i++) {
- if (snd_mixer_selem_has_capture_channel(alsa_track->element, i))
- snd_mixer_selem_set_capture_volume(alsa_track->element, i, 0);
- else if (snd_mixer_selem_has_playback_channel(alsa_track->element, i))
- snd_mixer_selem_set_playback_volume(alsa_track->element, i, 0);
+ if (snd_mixer_selem_has_capture_channel (alsa_track->element, i))
+ snd_mixer_selem_set_capture_volume (alsa_track->element, i, 0);
+ else if (snd_mixer_selem_has_playback_channel (alsa_track->element, i))
+ snd_mixer_selem_set_playback_volume (alsa_track->element, i, 0);
}
} else {
track->flags &= ~GST_MIXER_TRACK_MUTE;
for (i = 0; i < track->num_channels; i++) {
- if (snd_mixer_selem_has_capture_channel(alsa_track->element, i))
- snd_mixer_selem_set_capture_volume(alsa_track->element, i,
- alsa_track->volumes[i]);
- else if (snd_mixer_selem_has_playback_channel(alsa_track->element, i))
- snd_mixer_selem_set_playback_volume(alsa_track->element, i,
- alsa_track->volumes[i]);
+ if (snd_mixer_selem_has_capture_channel (alsa_track->element, i))
+ snd_mixer_selem_set_capture_volume (alsa_track->element, i,
+ alsa_track->volumes[i]);
+ else if (snd_mixer_selem_has_playback_channel (alsa_track->element, i))
+ snd_mixer_selem_set_playback_volume (alsa_track->element, i,
+ alsa_track->volumes[i]);
}
}
}
static void
-gst_alsa_mixer_set_record (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean record)
+gst_alsa_mixer_set_record (GstMixer * mixer,
+ GstMixerTrack * track, gboolean record)
{
GstAlsaMixer *alsa_mixer = GST_ALSA_MIXER (mixer);
#include <gst/mixer/mixer.h>
G_BEGIN_DECLS
-
#define GST_ALSA_MIXER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIXER,GstAlsaMixer))
#define GST_ALSA_MIXER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIXER,GstAlsaMixerClass))
#define GST_IS_ALSA_MIXER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIXER))
#define GST_IS_ALSA_MIXER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIXER))
#define GST_TYPE_ALSA_MIXER (gst_alsa_mixer_get_type())
-
typedef struct _GstAlsaMixer GstAlsaMixer;
typedef struct _GstAlsaMixerClass GstAlsaMixerClass;
-struct _GstAlsaMixer {
- GstAlsa parent;
- GList * tracklist; /* list of available tracks */
- snd_mixer_t * mixer_handle;
+struct _GstAlsaMixer
+{
+ GstAlsa parent;
+ GList *tracklist; /* list of available tracks */
+ snd_mixer_t *mixer_handle;
};
-struct _GstAlsaMixerClass {
- GstAlsaClass parent;
+struct _GstAlsaMixerClass
+{
+ GstAlsaClass parent;
};
-GType gst_alsa_mixer_get_type (void);
+GType gst_alsa_mixer_get_type (void);
G_END_DECLS
-
#endif /* __GST_ALSA_MIXER_H__ */
#include "gstalsamixertrack.h"
-static void gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track);
-static void gst_alsa_mixer_track_class_init (gpointer g_class,
- gpointer class_data);
+static void gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track);
+static void gst_alsa_mixer_track_class_init (gpointer g_class,
+ gpointer class_data);
static GstMixerTrackClass *parent_class = NULL;
(GInstanceInitFunc) gst_alsa_mixer_track_init,
};
- track_type = g_type_register_static (GST_TYPE_MIXER_TRACK, "GstAlsaMixerTrack", &track_info, 0);
+ track_type =
+ g_type_register_static (GST_TYPE_MIXER_TRACK, "GstAlsaMixerTrack",
+ &track_info, 0);
}
return track_type;
}
static void
-gst_alsa_mixer_track_init (GstAlsaMixerTrack *alsa_track)
-{ }
+gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track)
+{
+}
GstMixerTrack *
-gst_alsa_mixer_track_new (snd_mixer_elem_t *element,
- gint track_num,
- gint channels,
- gint flags)
+gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
+ gint track_num, gint channels, gint flags)
{
gint i;
long min, max;
GstAlsaMixerTrack *alsa_track = (GstAlsaMixerTrack *) track;
/* set basic information */
- track->label = g_strdup_printf("%s", snd_mixer_selem_get_name(element));
+ track->label = g_strdup_printf ("%s", snd_mixer_selem_get_name (element));
track->num_channels = channels;
track->flags = flags;
alsa_track->element = element;
alsa_track->track_num = track_num;
/* set volume information */
- snd_mixer_selem_get_playback_volume_range(element, &min, &max);
+ snd_mixer_selem_get_playback_volume_range (element, &min, &max);
track->min_volume = (gint) min;
track->max_volume = (gint) max;
- snd_mixer_selem_get_capture_volume_range(element, &min, &max);
+ snd_mixer_selem_get_capture_volume_range (element, &min, &max);
alsa_track->min_rec_volume = (gint) min;
alsa_track->max_rec_volume = (gint) max;
for (i = 0; i < channels; i++) {
long tmp;
- if (snd_mixer_selem_has_playback_channel(element, i)) {
- snd_mixer_selem_get_playback_volume(element, i, &tmp);
+
+ if (snd_mixer_selem_has_playback_channel (element, i)) {
+ snd_mixer_selem_get_playback_volume (element, i, &tmp);
alsa_track->volumes[i] = (gint) tmp;
- } else if (snd_mixer_selem_has_capture_channel(element, i)) {
- snd_mixer_selem_get_capture_volume(element, i, &tmp);
+ } else if (snd_mixer_selem_has_capture_channel (element, i)) {
+ snd_mixer_selem_get_capture_volume (element, i, &tmp);
alsa_track->volumes[i] = (gint) tmp;
}
}
#include <gst/mixer/mixertrack.h>
G_BEGIN_DECLS
-
#define GST_ALSA_MIXER_TRACK_TYPE (gst_alsa_mixer_track_get_type ())
#define GST_ALSA_MIXER_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIXER_TRACK,GstAlsaMixerTrack))
#define GST_ALSA_MIXER_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIXER_TRACK,GstAlsaMixerTrackClass))
#define GST_IS_ALSA_MIXER_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIXER_TRACK))
#define GST_IS_ALSA_MIXER_TRACK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIXER_TRACK))
#define GST_TYPE_ALSA_MIXER_TRACK (gst_alsa_mixer_track_get_type())
-
typedef struct _GstAlsaMixerTrack GstAlsaMixerTrack;
typedef struct _GstAlsaMixerTrackClass GstAlsaMixerTrackClass;
-struct _GstAlsaMixerTrack {
- GstMixerTrack parent;
- snd_mixer_elem_t *element; /* the ALSA mixer element for this track */
- gint track_num;
- gint min_rec_volume, max_rec_volume;
- gint volumes[GST_ALSA_MAX_CHANNELS];
+struct _GstAlsaMixerTrack
+{
+ GstMixerTrack parent;
+ snd_mixer_elem_t *element; /* the ALSA mixer element for this track */
+ gint track_num;
+ gint min_rec_volume, max_rec_volume;
+ gint volumes[GST_ALSA_MAX_CHANNELS];
};
-struct _GstAlsaMixerTrackClass {
+struct _GstAlsaMixerTrackClass
+{
GstMixerTrackClass parent;
};
-GType gst_alsa_mixer_track_get_type (void);
-GstMixerTrack * gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
- gint track_num,
- gint channels,
- gint flags);
+GType gst_alsa_mixer_track_get_type (void);
+GstMixerTrack *gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
+ gint track_num, gint channels, gint flags);
G_END_DECLS
-
#endif /* __GST_ALSA_MIXER_TRACK_H__ */
{
GST_DEBUG_CATEGORY_INIT (alsa_debug, "alsa", 0, "alsa plugins");
- if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE, GST_TYPE_ALSA_MIXER))
+ if (!gst_element_register (plugin, "alsamixer", GST_RANK_NONE,
+ GST_TYPE_ALSA_MIXER))
return FALSE;
- if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE, GST_TYPE_ALSA_SRC))
+ if (!gst_element_register (plugin, "alsasrc", GST_RANK_NONE,
+ GST_TYPE_ALSA_SRC))
return FALSE;
- if (!gst_element_register (plugin, "alsasink", GST_RANK_NONE, GST_TYPE_ALSA_SINK))
+ if (!gst_element_register (plugin, "alsasink", GST_RANK_NONE,
+ GST_TYPE_ALSA_SINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "alsa",
- "ALSA plugin library",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "alsa",
+ "ALSA plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include "gstalsaclock.h"
/* elementfactory information */
-static GstElementDetails gst_alsa_sink_details = GST_ELEMENT_DETAILS (
- "Alsa Sink",
- "Sink/Audio",
- "Output to a sound card via ALSA",
- "Thomas Nyberg <thomas@codefactory.se>, "
- "Andy Wingo <apwingo@eos.ncsu.edu>, "
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
-
-static GstPadTemplate * gst_alsa_sink_pad_factory (void);
-static GstPadTemplate * gst_alsa_sink_request_pad_factory(void);
-static void gst_alsa_sink_base_init (gpointer g_class);
-static void gst_alsa_sink_class_init (gpointer g_klass,
- gpointer class_data);
-static void gst_alsa_sink_init (GstAlsaSink * this);
-static inline void gst_alsa_sink_flush_one_pad (GstAlsaSink * sink,
- gint i);
-static void gst_alsa_sink_flush_pads (GstAlsaSink * sink);
-static int gst_alsa_sink_mmap (GstAlsa * this,
- snd_pcm_sframes_t * avail);
-static int gst_alsa_sink_write (GstAlsa * this,
- snd_pcm_sframes_t * avail);
-static void gst_alsa_sink_loop (GstElement * element);
-static gboolean gst_alsa_sink_check_event (GstAlsaSink * sink,
- gint pad_nr);
-static GstElementStateReturn gst_alsa_sink_change_state (GstElement * element);
-
-static GstClockTime gst_alsa_sink_get_time (GstAlsa * this);
+static GstElementDetails gst_alsa_sink_details =
+GST_ELEMENT_DETAILS ("Alsa Sink",
+ "Sink/Audio",
+ "Output to a sound card via ALSA",
+ "Thomas Nyberg <thomas@codefactory.se>, "
+ "Andy Wingo <apwingo@eos.ncsu.edu>, "
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
+
+static GstPadTemplate *gst_alsa_sink_pad_factory (void);
+static GstPadTemplate *gst_alsa_sink_request_pad_factory (void);
+static void gst_alsa_sink_base_init (gpointer g_class);
+static void gst_alsa_sink_class_init (gpointer g_klass, gpointer class_data);
+static void gst_alsa_sink_init (GstAlsaSink * this);
+static inline void gst_alsa_sink_flush_one_pad (GstAlsaSink * sink, gint i);
+static void gst_alsa_sink_flush_pads (GstAlsaSink * sink);
+static int gst_alsa_sink_mmap (GstAlsa * this, snd_pcm_sframes_t * avail);
+static int gst_alsa_sink_write (GstAlsa * this, snd_pcm_sframes_t * avail);
+static void gst_alsa_sink_loop (GstElement * element);
+static gboolean gst_alsa_sink_check_event (GstAlsaSink * sink, gint pad_nr);
+static GstElementStateReturn gst_alsa_sink_change_state (GstElement * element);
+
+static GstClockTime gst_alsa_sink_get_time (GstAlsa * this);
static GstAlsa *sink_parent_class = NULL;
if (!template)
template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_alsa_caps (SND_PCM_FORMAT_UNKNOWN, -1, -1));
+ gst_alsa_caps (SND_PCM_FORMAT_UNKNOWN, -1, -1));
return template;
}
if (!template)
template =
- gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_REQUEST,
- gst_alsa_caps (SND_PCM_FORMAT_UNKNOWN, -1, 1));
+ gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_REQUEST,
+ gst_alsa_caps (SND_PCM_FORMAT_UNKNOWN, -1, 1));
return template;
}
+
GType
gst_alsa_sink_get_type (void)
{
(GInstanceInitFunc) gst_alsa_sink_init,
};
- alsa_sink_type = g_type_register_static (GST_TYPE_ALSA, "GstAlsaSink", &alsa_sink_info, 0);
+ alsa_sink_type =
+ g_type_register_static (GST_TYPE_ALSA, "GstAlsaSink", &alsa_sink_info,
+ 0);
}
return alsa_sink_type;
}
gst_alsa_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class, gst_alsa_sink_pad_factory ());
- gst_element_class_add_pad_template (element_class, gst_alsa_sink_request_pad_factory ());
+
+ gst_element_class_add_pad_template (element_class,
+ gst_alsa_sink_pad_factory ());
+ gst_element_class_add_pad_template (element_class,
+ gst_alsa_sink_request_pad_factory ());
gst_element_class_set_details (element_class, &gst_alsa_sink_details);
}
if (sink_parent_class == NULL)
sink_parent_class = g_type_class_ref (GST_TYPE_ALSA);
-
- alsa_class->stream = SND_PCM_STREAM_PLAYBACK;
- alsa_class->transmit_mmap = gst_alsa_sink_mmap;
- alsa_class->transmit_rw = gst_alsa_sink_write;
- element_class->change_state = gst_alsa_sink_change_state;
+ alsa_class->stream = SND_PCM_STREAM_PLAYBACK;
+ alsa_class->transmit_mmap = gst_alsa_sink_mmap;
+ alsa_class->transmit_rw = gst_alsa_sink_write;
+
+ element_class->change_state = gst_alsa_sink_change_state;
}
static void
-gst_alsa_sink_init (GstAlsaSink *sink)
+gst_alsa_sink_init (GstAlsaSink * sink)
{
GstAlsa *this = GST_ALSA (sink);
- this->pad[0] = gst_pad_new_from_template (gst_alsa_sink_pad_factory (), "sink");
+ this->pad[0] =
+ gst_pad_new_from_template (gst_alsa_sink_pad_factory (), "sink");
gst_pad_set_link_function (this->pad[0], gst_alsa_link);
gst_pad_set_getcaps_function (this->pad[0], gst_alsa_get_caps);
gst_pad_set_fixate_function (this->pad[0], gst_alsa_fixate);
gst_element_add_pad (GST_ELEMENT (this), this->pad[0]);
-
- this->clock = gst_alsa_clock_new ("alsasinkclock", gst_alsa_sink_get_time, this);
+
+ this->clock =
+ gst_alsa_clock_new ("alsasinkclock", gst_alsa_sink_get_time, this);
/* we hold a ref to our clock until we're disposed */
gst_object_ref (GST_OBJECT (this->clock));
gst_object_sink (GST_OBJECT (this->clock));
}
static inline void
-gst_alsa_sink_flush_one_pad (GstAlsaSink *sink, gint i)
+gst_alsa_sink_flush_one_pad (GstAlsaSink * sink, gint i)
{
switch (sink->behaviour[i]) {
- case 0:
- if (sink->buf[i])
- gst_data_unref (GST_DATA (sink->buf[i]));
- sink->buf[i] = NULL;
- sink->data[i] = NULL;
- sink->behaviour[i] = 0;
- sink->size[i] = 0;
- break;
- case 1:
- g_free (sink->data[i]);
- sink->data[i] = NULL;
- sink->behaviour[i] = 0;
- sink->size[i] = 0;
- break;
- default:
- g_assert_not_reached ();
+ case 0:
+ if (sink->buf[i])
+ gst_data_unref (GST_DATA (sink->buf[i]));
+ sink->buf[i] = NULL;
+ sink->data[i] = NULL;
+ sink->behaviour[i] = 0;
+ sink->size[i] = 0;
+ break;
+ case 1:
+ g_free (sink->data[i]);
+ sink->data[i] = NULL;
+ sink->behaviour[i] = 0;
+ sink->size[i] = 0;
+ break;
+ default:
+ g_assert_not_reached ();
}
}
static void
-gst_alsa_sink_flush_pads (GstAlsaSink *sink)
+gst_alsa_sink_flush_pads (GstAlsaSink * sink)
{
gint i;
gst_alsa_sink_flush_one_pad (sink, i);
}
}
+
/* TRUE, if everything should continue */
static gboolean
-gst_alsa_sink_check_event (GstAlsaSink *sink, gint pad_nr)
+gst_alsa_sink_check_event (GstAlsaSink * sink, gint pad_nr)
{
gboolean cont = TRUE;
GstEvent *event = GST_EVENT (sink->buf[pad_nr]);
if (event) {
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- gst_alsa_set_eos (this);
- cont = FALSE;
- break;
+ gst_alsa_set_eos (this);
+ cont = FALSE;
+ break;
case GST_EVENT_INTERRUPT:
cont = FALSE;
- break;
- case GST_EVENT_DISCONTINUOUS:
- {
- GstClockTime value;
-
- /* only the first pad my seek */
- if (pad_nr != 0) {
- break;
- }
- if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &value)) {
- gst_element_set_time (GST_ELEMENT (this), value);
- } else if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT, &value)) {
- value = gst_alsa_samples_to_timestamp (this, value);
- gst_element_set_time (GST_ELEMENT (this), value);
- } else if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &value)) {
- value = gst_alsa_bytes_to_timestamp (this, value);
- gst_element_set_time (GST_ELEMENT (this), value);
- } else {
- GST_ERROR_OBJECT (this, "couldn't extract time from discont event. Bad things might happen!");
- }
-
+ break;
+ case GST_EVENT_DISCONTINUOUS:
+ {
+ GstClockTime value;
+ /* only the first pad my seek */
+ if (pad_nr != 0) {
break;
- }
+ }
+ if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &value)) {
+ gst_element_set_time (GST_ELEMENT (this), value);
+ } else if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT,
+ &value)) {
+ value = gst_alsa_samples_to_timestamp (this, value);
+ gst_element_set_time (GST_ELEMENT (this), value);
+ } else if (gst_event_discont_get_value (event, GST_FORMAT_BYTES,
+ &value)) {
+ value = gst_alsa_bytes_to_timestamp (this, value);
+ gst_element_set_time (GST_ELEMENT (this), value);
+ } else {
+ GST_ERROR_OBJECT (this,
+ "couldn't extract time from discont event. Bad things might happen!");
+ }
+
+
+ break;
+ }
default:
- GST_INFO_OBJECT (this, "got an unknown event (Type: %d)", GST_EVENT_TYPE (event));
- break;
+ GST_INFO_OBJECT (this, "got an unknown event (Type: %d)",
+ GST_EVENT_TYPE (event));
+ break;
}
gst_event_unref (event);
sink->buf[pad_nr] = NULL;
return cont;
}
static int
-gst_alsa_sink_mmap (GstAlsa *this, snd_pcm_sframes_t *avail)
+gst_alsa_sink_mmap (GstAlsa * this, snd_pcm_sframes_t * avail)
{
snd_pcm_uframes_t offset;
const snd_pcm_channel_area_t *dst;
int i, err, width = snd_pcm_format_physical_width (this->format->format);
/* areas points to the memory areas that belong to gstreamer. */
- src = g_malloc0 (this->format->channels * sizeof(snd_pcm_channel_area_t));
+ src = g_malloc0 (this->format->channels * sizeof (snd_pcm_channel_area_t));
if (((GstElement *) this)->numpads == 1) {
/* interleaved */
return -1;
}
- if ((err = snd_pcm_areas_copy (dst, offset, src, 0, this->format->channels, *avail, this->format->format)) < 0) {
+ if ((err =
+ snd_pcm_areas_copy (dst, offset, src, 0, this->format->channels,
+ *avail, this->format->format)) < 0) {
snd_pcm_mmap_commit (this->handle, offset, 0);
GST_ERROR_OBJECT (this, "data copy failed: %s", snd_strerror (err));
return -1;
return err;
}
static int
-gst_alsa_sink_write (GstAlsa *this, snd_pcm_sframes_t *avail)
+gst_alsa_sink_write (GstAlsa * this, snd_pcm_sframes_t * avail)
{
GstAlsaSink *sink = GST_ALSA_SINK (this);
void *channels[this->format->channels];
return err;
}
static void
-gst_alsa_sink_loop (GstElement *element)
+gst_alsa_sink_loop (GstElement * element)
{
snd_pcm_sframes_t avail, avail2, copied, sample_diff, max_discont;
snd_pcm_uframes_t samplestamp, time_sample;
gint i;
- guint bytes; /* per channel */
+ guint bytes; /* per channel */
GstAlsa *this = GST_ALSA (element);
GstAlsaSink *sink = GST_ALSA_SINK (element);
sink_restart:
avail = gst_alsa_update_avail (this);
- if (avail == -EPIPE) goto sink_restart;
- if (avail < 0) return;
+ if (avail == -EPIPE)
+ goto sink_restart;
+ if (avail < 0)
+ return;
if (avail > 0) {
- /* Not enough space. We grab data nonetheless and sleep afterwards */
+ /* Not enough space. We grab data nonetheless and sleep afterwards */
if (avail < this->period_size) {
avail = this->period_size;
}
-
+
/* check how many bytes we still have in all our bytestreams */
/* initialize this value to a somewhat sane state, we might alloc this much data below (which would be a bug, but who knows)... */
- bytes = this->period_size * this->period_count * element->numpads * 8; /* must be > max sample size in bytes */
+ bytes = this->period_size * this->period_count * element->numpads * 8; /* must be > max sample size in bytes */
for (i = 0; i < element->numpads; i++) {
g_assert (this->pad[i] != NULL);
while (sink->size[i] == 0) {
- if (!sink->buf[i])
- sink->buf[i] = GST_BUFFER (gst_pad_pull (this->pad[i]));
- if (GST_IS_EVENT (sink->buf[i])) {
+ if (!sink->buf[i])
+ sink->buf[i] = GST_BUFFER (gst_pad_pull (this->pad[i]));
+ if (GST_IS_EVENT (sink->buf[i])) {
if (gst_alsa_sink_check_event (sink, i))
continue;
return;
}
- /* caps nego failed somewhere */
- if (this->format == NULL) {
- GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
- ("ALSA format not negotiated"));
- }
- samplestamp = gst_alsa_timestamp_to_samples (this, GST_BUFFER_TIMESTAMP (sink->buf[i]));
- max_discont = gst_alsa_timestamp_to_samples (this, this->max_discont);
- time_sample = gst_alsa_timestamp_to_samples (this, gst_element_get_time (GST_ELEMENT (this)));
+ /* caps nego failed somewhere */
+ if (this->format == NULL) {
+ GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
+ ("ALSA format not negotiated"));
+ }
+ samplestamp =
+ gst_alsa_timestamp_to_samples (this,
+ GST_BUFFER_TIMESTAMP (sink->buf[i]));
+ max_discont = gst_alsa_timestamp_to_samples (this, this->max_discont);
+ time_sample =
+ gst_alsa_timestamp_to_samples (this,
+ gst_element_get_time (GST_ELEMENT (this)));
snd_pcm_delay (this->handle, &sample_diff);
/* actual diff = buffer samplestamp - played - to_play */
sample_diff = samplestamp - time_sample - sample_diff;
- if ((!GST_BUFFER_TIMESTAMP_IS_VALID (sink->buf[i])) ||
- (-max_discont <= sample_diff && sample_diff <= max_discont)) {
+ if ((!GST_BUFFER_TIMESTAMP_IS_VALID (sink->buf[i])) ||
+ (-max_discont <= sample_diff && sample_diff <= max_discont)) {
- /* difference between expected and current is < GST_ALSA_DEVIATION */
-no_difference:
+ /* difference between expected and current is < GST_ALSA_DEVIATION */
+ no_difference:
sink->size[i] = sink->buf[i]->size;
- sink->data[i] = sink->buf[i]->data;
- sink->behaviour[i] = 0;
+ sink->data[i] = sink->buf[i]->data;
+ sink->behaviour[i] = 0;
} else if (sample_diff > 0) {
/* there are empty samples in front of us, fill them with silence */
int samples = MIN (bytes, sample_diff) *
- (element->numpads == 1 ? this->format->channels : 1);
- int size = samples * snd_pcm_format_physical_width (this->format->format) / 8;
- GST_INFO_OBJECT (this, "Allocating %d bytes (%ld samples) now to resync: sample %ld expected, but got %ld",
- size, MIN (bytes, sample_diff), time_sample, samplestamp);
+ (element->numpads == 1 ? this->format->channels : 1);
+ int size =
+ samples * snd_pcm_format_physical_width (this->format->format) /
+ 8;
+ GST_INFO_OBJECT (this,
+ "Allocating %d bytes (%ld samples) now to resync: sample %ld expected, but got %ld",
+ size, MIN (bytes, sample_diff), time_sample, samplestamp);
sink->data[i] = g_try_malloc (size);
if (!sink->data[i]) {
- GST_WARNING_OBJECT (this, "error allocating %d bytes, buffers unsynced now.", size);
+ GST_WARNING_OBJECT (this,
+ "error allocating %d bytes, buffers unsynced now.", size);
goto no_difference;
}
sink->size[i] = size;
- if (0 != snd_pcm_format_set_silence (this->format->format, sink->data[i], samples)) {
- GST_WARNING_OBJECT (this, "error silencing buffer, enjoy the noise.");
+ if (0 != snd_pcm_format_set_silence (this->format->format,
+ sink->data[i], samples)) {
+ GST_WARNING_OBJECT (this,
+ "error silencing buffer, enjoy the noise.");
}
sink->behaviour[i] = 1;
- } else if (gst_alsa_samples_to_bytes (this, -sample_diff) >= sink->buf[i]->size) {
- GST_INFO_OBJECT (this, "Skipping %lu samples to resync (complete buffer): sample %ld expected, but got %ld",
- gst_alsa_bytes_to_samples (this, sink->buf[i]->size), time_sample, samplestamp);
+ } else if (gst_alsa_samples_to_bytes (this,
+ -sample_diff) >= sink->buf[i]->size) {
+ GST_INFO_OBJECT (this,
+ "Skipping %lu samples to resync (complete buffer): sample %ld expected, but got %ld",
+ gst_alsa_bytes_to_samples (this, sink->buf[i]->size), time_sample,
+ samplestamp);
/* this buffer is way behind */
gst_buffer_unref (sink->buf[i]);
sink->buf[i] = NULL;
continue;
} else if (sample_diff < 0) {
gint difference = gst_alsa_samples_to_bytes (this, -samplestamp);
- GST_INFO_OBJECT (this, "Skipping %lu samples to resync: sample %ld expected, but got %ld",
- (gulong) -sample_diff, time_sample, samplestamp);
+
+ GST_INFO_OBJECT (this,
+ "Skipping %lu samples to resync: sample %ld expected, but got %ld",
+ (gulong) - sample_diff, time_sample, samplestamp);
/* this buffer is only a bit behind */
- sink->size[i] = sink->buf[i]->size - difference;
- sink->data[i] = sink->buf[i]->data + difference;
- sink->behaviour[i] = 0;
+ sink->size[i] = sink->buf[i]->size - difference;
+ sink->data[i] = sink->buf[i]->data + difference;
+ sink->behaviour[i] = 0;
} else {
g_assert_not_reached ();
}
avail = MIN (avail, gst_alsa_bytes_to_samples (this, bytes));
/* wait until the hw buffer has enough space */
- while (gst_element_get_state (element) == GST_STATE_PLAYING && (avail2 = gst_alsa_update_avail (this)) < avail) {
- if (avail2 <= -EPIPE) goto sink_restart;
- if (avail2 < 0) return;
- if (avail2 < avail && snd_pcm_state(this->handle) != SND_PCM_STATE_RUNNING)
- if (!gst_alsa_start (this)) return;
+ while (gst_element_get_state (element) == GST_STATE_PLAYING
+ && (avail2 = gst_alsa_update_avail (this)) < avail) {
+ if (avail2 <= -EPIPE)
+ goto sink_restart;
+ if (avail2 < 0)
+ return;
+ if (avail2 < avail
+ && snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING)
+ if (!gst_alsa_start (this))
+ return;
if (gst_alsa_pcm_wait (this) == FALSE)
- return;
+ return;
}
/* FIXME: lotsa stuff can have happened while fetching data. Do we need to check something? */
-
+
/* put this data into alsa */
if ((copied = this->transmit (this, &avail)) < 0)
return;
bytes = gst_alsa_samples_to_bytes (this, copied);
for (i = 0; i < element->numpads; i++) {
if ((sink->size[i] -= bytes) == 0) {
- gst_alsa_sink_flush_one_pad (sink, i);
- continue;
+ gst_alsa_sink_flush_one_pad (sink, i);
+ continue;
}
g_assert (sink->size[i] > 0);
if (sink->behaviour[i] != 1)
- sink->data[i] += bytes;
+ sink->data[i] += bytes;
}
}
- if (snd_pcm_state(this->handle) != SND_PCM_STATE_RUNNING && snd_pcm_avail_update (this->handle) == 0) {
+ if (snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING
+ && snd_pcm_avail_update (this->handle) == 0) {
gst_alsa_start (this);
}
}
static GstElementStateReturn
-gst_alsa_sink_change_state (GstElement *element)
+gst_alsa_sink_change_state (GstElement * element)
{
GstAlsaSink *sink;
sink = GST_ALSA_SINK (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
- case GST_STATE_READY_TO_PAUSED:
- case GST_STATE_PAUSED_TO_PLAYING:
- case GST_STATE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_PAUSED_TO_READY:
- gst_alsa_sink_flush_pads (sink);
- break;
- case GST_STATE_READY_TO_NULL:
- break;
- default:
- g_assert_not_reached();
+ case GST_STATE_NULL_TO_READY:
+ case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_PLAYING_TO_PAUSED:
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ gst_alsa_sink_flush_pads (sink);
+ break;
+ case GST_STATE_READY_TO_NULL:
+ break;
+ default:
+ g_assert_not_reached ();
}
if (GST_ELEMENT_CLASS (sink_parent_class)->change_state)
}
static GstClockTime
-gst_alsa_sink_get_time (GstAlsa *this)
+gst_alsa_sink_get_time (GstAlsa * this)
{
snd_pcm_sframes_t delay;
-
+
if (snd_pcm_delay (this->handle, &delay) == 0 && this->format) {
- return GST_SECOND * (GstClockTime) (this->transmitted > delay ? this->transmitted - delay : 0) / this->format->rate;
+ return GST_SECOND * (GstClockTime) (this->transmitted >
+ delay ? this->transmitted - delay : 0) / this->format->rate;
} else {
return 0;
}
}
-
#include "gstalsa.h"
G_BEGIN_DECLS
-
#define GST_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SINK, GstAlsaSink))
#define GST_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SINK, GstAlsaSinkClass))
#define GST_IS_ALSA_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA_SINK))
#define GST_IS_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA_SINK))
#define GST_TYPE_ALSA_SINK (gst_alsa_sink_get_type())
-
typedef struct _GstAlsaSink GstAlsaSink;
typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
-struct _GstAlsaSink {
- GstAlsa parent;
+struct _GstAlsaSink
+{
+ GstAlsa parent;
/* array of the data on the channels */
- guint8 *data[GST_ALSA_MAX_TRACKS]; /* pointer into buffer */
- guint size[GST_ALSA_MAX_TRACKS]; /* sink: bytes left in buffer */
- GstBuffer *buf[GST_ALSA_MAX_TRACKS]; /* current buffer */
- guint behaviour[GST_ALSA_MAX_TRACKS]; /* 0 = data points into buffer (so unref when size == 0),
- 1 = data should be freed, use buffer after that */
+ guint8 *data[GST_ALSA_MAX_TRACKS]; /* pointer into buffer */
+ guint size[GST_ALSA_MAX_TRACKS]; /* sink: bytes left in buffer */
+ GstBuffer *buf[GST_ALSA_MAX_TRACKS]; /* current buffer */
+ guint behaviour[GST_ALSA_MAX_TRACKS]; /* 0 = data points into buffer (so unref when size == 0),
+ 1 = data should be freed, use buffer after that */
};
-struct _GstAlsaSinkClass {
+struct _GstAlsaSinkClass
+{
GstAlsaClass parent_class;
};
GType gst_alsa_sink_get_type (void);
-gboolean gst_alsa_sink_factory_init (GstPlugin *plugin);
+gboolean gst_alsa_sink_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __GST_ALSA_SINK_H__ */
#include "gstalsaclock.h"
/* elementfactory information */
-static GstElementDetails gst_alsa_src_details = GST_ELEMENT_DETAILS (
- "Alsa Src",
- "Source/Audio",
- "Read from a sound card via ALSA",
- "Thomas Nyberg <thomas@codefactory.se>, "
- "Andy Wingo <apwingo@eos.ncsu.edu>, "
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
-
-static GstPadTemplate * gst_alsa_src_pad_factory (void);
-static void gst_alsa_src_base_init (gpointer g_class);
-static void gst_alsa_src_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_alsa_src_init (GstAlsaSrc * this);
-static int gst_alsa_src_mmap (GstAlsa * this,
- snd_pcm_sframes_t * avail);
-static int gst_alsa_src_read (GstAlsa * this,
- snd_pcm_sframes_t * avail);
-static void gst_alsa_src_loop (GstElement * element);
-static void gst_alsa_src_flush (GstAlsaSrc * src);
-static GstElementStateReturn gst_alsa_src_change_state (GstElement * element);
-
-static GstClockTime gst_alsa_src_get_time (GstAlsa * this);
+static GstElementDetails gst_alsa_src_details = GST_ELEMENT_DETAILS ("Alsa Src",
+ "Source/Audio",
+ "Read from a sound card via ALSA",
+ "Thomas Nyberg <thomas@codefactory.se>, "
+ "Andy Wingo <apwingo@eos.ncsu.edu>, "
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
+
+static GstPadTemplate *gst_alsa_src_pad_factory (void);
+static void gst_alsa_src_base_init (gpointer g_class);
+static void gst_alsa_src_class_init (gpointer g_class, gpointer class_data);
+static void gst_alsa_src_init (GstAlsaSrc * this);
+static int gst_alsa_src_mmap (GstAlsa * this, snd_pcm_sframes_t * avail);
+static int gst_alsa_src_read (GstAlsa * this, snd_pcm_sframes_t * avail);
+static void gst_alsa_src_loop (GstElement * element);
+static void gst_alsa_src_flush (GstAlsaSrc * src);
+static GstElementStateReturn gst_alsa_src_change_state (GstElement * element);
+
+static GstClockTime gst_alsa_src_get_time (GstAlsa * this);
static GstAlsa *src_parent_class = NULL;
if (!template)
template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_alsa_caps (SND_PCM_FORMAT_UNKNOWN, -1, -1));
+ gst_alsa_caps (SND_PCM_FORMAT_UNKNOWN, -1, -1));
return template;
}
(GInstanceInitFunc) gst_alsa_src_init,
};
- alsa_src_type = g_type_register_static (GST_TYPE_ALSA, "GstAlsaSrc", &alsa_src_info, 0);
+ alsa_src_type =
+ g_type_register_static (GST_TYPE_ALSA, "GstAlsaSrc", &alsa_src_info, 0);
}
return alsa_src_type;
}
gst_alsa_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class, gst_alsa_src_pad_factory ());
+
+ gst_element_class_add_pad_template (element_class,
+ gst_alsa_src_pad_factory ());
gst_element_class_set_details (element_class, &gst_alsa_src_details);
}
if (src_parent_class == NULL)
src_parent_class = g_type_class_ref (GST_TYPE_ALSA);
- alsa_class->stream = SND_PCM_STREAM_CAPTURE;
- alsa_class->transmit_mmap = gst_alsa_src_mmap;
- alsa_class->transmit_rw = gst_alsa_src_read;
+ alsa_class->stream = SND_PCM_STREAM_CAPTURE;
+ alsa_class->transmit_mmap = gst_alsa_src_mmap;
+ alsa_class->transmit_rw = gst_alsa_src_read;
- element_class->change_state = gst_alsa_src_change_state;
+ element_class->change_state = gst_alsa_src_change_state;
}
static void
-gst_alsa_src_init (GstAlsaSrc *src)
+gst_alsa_src_init (GstAlsaSrc * src)
{
GstAlsa *this = GST_ALSA (src);
gst_pad_set_link_function (this->pad[0], gst_alsa_link);
gst_pad_set_getcaps_function (this->pad[0], gst_alsa_get_caps);
gst_element_add_pad (GST_ELEMENT (this), this->pad[0]);
-
- this->clock = gst_alsa_clock_new ("alsasrcclock", gst_alsa_src_get_time, this);
+
+ this->clock =
+ gst_alsa_clock_new ("alsasrcclock", gst_alsa_src_get_time, this);
/* we hold a ref to our clock until we're disposed */
gst_object_ref (GST_OBJECT (this->clock));
gst_object_sink (GST_OBJECT (this->clock));
gst_element_set_loop_function (GST_ELEMENT (this), gst_alsa_src_loop);
}
static int
-gst_alsa_src_mmap (GstAlsa *this, snd_pcm_sframes_t *avail)
+gst_alsa_src_mmap (GstAlsa * this, snd_pcm_sframes_t * avail)
{
snd_pcm_uframes_t offset;
snd_pcm_channel_area_t *dst;
GstAlsaSrc *alsa_src = GST_ALSA_SRC (this);
/* areas points to the memory areas that belong to gstreamer. */
- dst = g_malloc0 (this->format->channels * sizeof(snd_pcm_channel_area_t));
+ dst = g_malloc0 (this->format->channels * sizeof (snd_pcm_channel_area_t));
if (((GstElement *) this)->numpads == 1) {
/* interleaved */
GST_ERROR_OBJECT (this, "mmap failed: %s", snd_strerror (err));
return -1;
}
- if (*avail > 0 && (err = snd_pcm_areas_copy (dst, 0, src, offset, this->format->channels, *avail, this->format->format)) < 0) {
+ if (*avail > 0
+ && (err =
+ snd_pcm_areas_copy (dst, 0, src, offset, this->format->channels,
+ *avail, this->format->format)) < 0) {
snd_pcm_mmap_commit (this->handle, offset, 0);
GST_ERROR_OBJECT (this, "data copy failed: %s", snd_strerror (err));
return -1;
return err;
}
static int
-gst_alsa_src_read (GstAlsa *this, snd_pcm_sframes_t *avail)
+gst_alsa_src_read (GstAlsa * this, snd_pcm_sframes_t * avail)
{
void *channels[this->format->channels];
int err, i;
return 0;
}
+
static gboolean
-gst_alsa_src_set_caps (GstAlsaSrc *src, gboolean aggressive)
+gst_alsa_src_set_caps (GstAlsaSrc * src, gboolean aggressive)
{
GstCaps *all_caps, *caps;
GstStructure *structure, *walk;
GstAlsa *this = GST_ALSA (src);
all_caps = gst_alsa_get_caps (this->pad[0]);
- if (all_caps == NULL) return FALSE;
+ if (all_caps == NULL)
+ return FALSE;
/* now intersect this with all caps of the peers... */
for (i = 0; i < GST_ELEMENT (src)->numpads; i++) {
- all_caps = gst_caps_intersect (all_caps, gst_pad_get_allowed_caps (this->pad[i]));
+ all_caps =
+ gst_caps_intersect (all_caps, gst_pad_get_allowed_caps (this->pad[i]));
if (all_caps == NULL) {
- GST_DEBUG ("No compatible caps found in alsasrc (%s)", GST_ELEMENT_NAME (this));
+ GST_DEBUG ("No compatible caps found in alsasrc (%s)",
+ GST_ELEMENT_NAME (this));
return FALSE;
}
}
/* construct caps */
- caps = gst_caps_new_simple ("audio/x-raw-int",
- NULL);
+ caps = gst_caps_new_simple ("audio/x-raw-int", NULL);
g_assert (gst_caps_get_size (caps) == 1);
structure = gst_caps_get_structure (caps, 0);
for (i = 0; i < gst_caps_get_size (all_caps); i++) {
walk = gst_caps_get_structure (all_caps, i);
if (!(gst_structure_get_int (walk, "signed", &sign) &&
- gst_structure_get_int (walk, "width", &width) &&
- gst_structure_get_int (walk, "depth", &depth))) {
+ gst_structure_get_int (walk, "width", &width) &&
+ gst_structure_get_int (walk, "depth", &depth))) {
GST_ERROR_OBJECT (src, "couldn't parse my own format. Huh?");
continue;
}
if (!gst_structure_get_int (walk, "endianness", &endian)) {
endian = G_BYTE_ORDER;
}
- gst_structure_set (structure,
+ gst_structure_set (structure,
"endianness", G_TYPE_INT, endian,
- "width", G_TYPE_INT, width,
- "depth", G_TYPE_INT, depth,
- "signed", G_TYPE_BOOLEAN, sign,
- NULL);
-
- min_rate = gst_value_get_int_range_min (gst_structure_get_value (walk, "rate"));
- max_rate = gst_value_get_int_range_max (gst_structure_get_value (walk, "rate"));
- min_channels = gst_value_get_int_range_min (gst_structure_get_value (walk, "channels"));
- max_channels = gst_value_get_int_range_max (gst_structure_get_value (walk, "channels"));
+ "width", G_TYPE_INT, width,
+ "depth", G_TYPE_INT, depth, "signed", G_TYPE_BOOLEAN, sign, NULL);
+
+ min_rate =
+ gst_value_get_int_range_min (gst_structure_get_value (walk, "rate"));
+ max_rate =
+ gst_value_get_int_range_max (gst_structure_get_value (walk, "rate"));
+ min_channels =
+ gst_value_get_int_range_min (gst_structure_get_value (walk,
+ "channels"));
+ max_channels =
+ gst_value_get_int_range_max (gst_structure_get_value (walk,
+ "channels"));
for (rate = max_rate;; rate--) {
if ((rate = gst_alsa_src_adjust_rate (rate, aggressive)) < min_rate)
break;
gst_structure_set (structure, "rate", G_TYPE_INT, rate, NULL);
- for (channels = aggressive ? max_channels : MIN (max_channels, 2); channels >= min_channels; channels--) {
- gst_structure_set (structure, "channels", G_TYPE_INT, channels, NULL);
- GST_DEBUG ("trying new caps: %ssigned, endianness: %d, width %d, depth %d, channels %d, rate %d",
- sign ? "" : "un", endian, width, depth, channels, rate);
- if (gst_pad_try_set_caps (this->pad[0], caps) != GST_PAD_LINK_REFUSED)
- gst_alsa_link (this->pad[0], caps);
-
- if (this->format) {
+ for (channels = aggressive ? max_channels : MIN (max_channels, 2);
+ channels >= min_channels; channels--) {
+ gst_structure_set (structure, "channels", G_TYPE_INT, channels, NULL);
+ GST_DEBUG
+ ("trying new caps: %ssigned, endianness: %d, width %d, depth %d, channels %d, rate %d",
+ sign ? "" : "un", endian, width, depth, channels, rate);
+ if (gst_pad_try_set_caps (this->pad[0], caps) != GST_PAD_LINK_REFUSED)
+ gst_alsa_link (this->pad[0], caps);
+
+ if (this->format) {
/* try to set caps here */
return TRUE;
}
return FALSE;
}
+
/* we transmit buffers of period_size frames */
static void
-gst_alsa_src_loop (GstElement *element)
+gst_alsa_src_loop (GstElement * element)
{
snd_pcm_sframes_t avail, copied;
gint i;
/* set the caps on all pads */
if (!this->format) {
if (!gst_alsa_src_set_caps (src, FALSE)) {
- GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
- ("ALSA format not negotiated"));
+ GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
+ ("ALSA format not negotiated"));
return;
}
}
while ((avail = gst_alsa_update_avail (this)) < this->period_size) {
- if (avail == -EPIPE) continue;
- if (avail < 0) return;
- if (snd_pcm_state(this->handle) != SND_PCM_STATE_RUNNING) {
+ if (avail == -EPIPE)
+ continue;
+ if (avail < 0)
+ return;
+ if (snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING) {
if (!gst_alsa_start (this))
return;
continue;
return;
if (copied != this->period_size)
GST_BUFFER_SIZE (src->buf[i]) = gst_alsa_samples_to_bytes (this, copied);
- GST_BUFFER_TIMESTAMP (src->buf[i]) = gst_alsa_samples_to_timestamp (this, this->transmitted);
- GST_BUFFER_DURATION (src->buf[i]) = gst_alsa_samples_to_timestamp (this, copied);
+ GST_BUFFER_TIMESTAMP (src->buf[i]) =
+ gst_alsa_samples_to_timestamp (this, this->transmitted);
+ GST_BUFFER_DURATION (src->buf[i]) =
+ gst_alsa_samples_to_timestamp (this, copied);
gst_pad_push (this->pad[i], GST_DATA (src->buf[i]));
src->buf[i] = NULL;
}
}
static void
-gst_alsa_src_flush (GstAlsaSrc *src)
+gst_alsa_src_flush (GstAlsaSrc * src)
{
gint i;
- for (i = 0; i < GST_ELEMENT (src)->numpads; i++) {
+ for (i = 0; i < GST_ELEMENT (src)->numpads; i++) {
if (src->buf[i]) {
gst_buffer_unref (src->buf[i]);
src->buf[i] = NULL;
}
}
static GstElementStateReturn
-gst_alsa_src_change_state (GstElement *element)
+gst_alsa_src_change_state (GstElement * element)
{
GstAlsaSrc *src;
src = GST_ALSA_SRC (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
- case GST_STATE_READY_TO_PAUSED:
- case GST_STATE_PAUSED_TO_PLAYING:
- case GST_STATE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_PAUSED_TO_READY:
- gst_alsa_src_flush (src);
- break;
- case GST_STATE_READY_TO_NULL:
- break;
- default:
- g_assert_not_reached();
+ case GST_STATE_NULL_TO_READY:
+ case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_PLAYING_TO_PAUSED:
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ gst_alsa_src_flush (src);
+ break;
+ case GST_STATE_READY_TO_NULL:
+ break;
+ default:
+ g_assert_not_reached ();
}
if (GST_ELEMENT_CLASS (src_parent_class)->change_state)
}
static GstClockTime
-gst_alsa_src_get_time (GstAlsa *this)
+gst_alsa_src_get_time (GstAlsa * this)
{
snd_pcm_sframes_t delay;
-
+
if (snd_pcm_delay (this->handle, &delay) == 0) {
return GST_SECOND * (this->transmitted + delay) / this->format->rate;
} else {
return 0;
}
}
-
#include "gstalsa.h"
G_BEGIN_DECLS
-
#define GST_ALSA_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_ALSA_SRC, GstAlsaSrc))
#define GST_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_ALSA_SRC, GstAlsaSrcClass))
#define GST_IS_ALSA_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_ALSA_SRC))
#define GST_IS_ALSA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_ALSA_SRC))
#define GST_TYPE_ALSA_SRC (gst_alsa_src_get_type())
-
typedef struct _GstAlsaSrc GstAlsaSrc;
typedef struct _GstAlsaSrcClass GstAlsaSrcClass;
-struct _GstAlsaSrc {
- GstAlsa parent;
- GstBuffer *buf[GST_ALSA_MAX_TRACKS];
+struct _GstAlsaSrc
+{
+ GstAlsa parent;
+ GstBuffer *buf[GST_ALSA_MAX_TRACKS];
};
-struct _GstAlsaSrcClass {
+struct _GstAlsaSrcClass
+{
GstAlsaClass parent_class;
};
GType gst_alsa_src_get_type (void);
-gboolean gst_alsa_src_factory_init (GstPlugin *plugin);
+gboolean gst_alsa_src_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __GST_ALSA_SRC_H__ */
};
static GstStaticPadTemplate cdparanoia_src_template =
- GST_STATIC_PAD_TEMPLATE (
- "src",
+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) 44100, "
- "channels = (int) 2, "
- "chunksize = (int) " G_STRINGIFY(CD_FRAMESIZE_RAW)
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) 44100, "
+ "channels = (int) 2, "
+ "chunksize = (int) " G_STRINGIFY (CD_FRAMESIZE_RAW)
)
-);
+ );
/********** Define useful types for non-programmatic interfaces **********/
{
static GType paranoia_mode_type = 0;
static GEnumValue paranoia_modes[] = {
- { PARANOIA_MODE_DISABLE, "0", "Disable paranoid checking"},
- { PARANOIA_MODE_OVERLAP, "4", "cdda2wav-style overlap checking"},
- { PARANOIA_MODE_FULL, "255", "Full paranoia"},
+ {PARANOIA_MODE_DISABLE, "0", "Disable paranoid checking"},
+ {PARANOIA_MODE_OVERLAP, "4", "cdda2wav-style overlap checking"},
+ {PARANOIA_MODE_FULL, "255", "Full paranoia"},
{0, NULL, NULL},
};
if (!paranoia_mode_type) {
- paranoia_mode_type = g_enum_register_static ("GstParanoiaMode", paranoia_modes);
+ paranoia_mode_type =
+ g_enum_register_static ("GstParanoiaMode", paranoia_modes);
}
return paranoia_mode_type;
}
{
static GType paranoia_endian_type = 0;
static GEnumValue paranoia_endians[] = {
- { 0, "0", "treat drive as little endian"},
- { 1, "1", "treat drive as big endian"},
- { 0, NULL, NULL},
+ {0, "0", "treat drive as little endian"},
+ {1, "1", "treat drive as big endian"},
+ {0, NULL, NULL},
};
if (!paranoia_endian_type) {
- paranoia_endian_type = g_enum_register_static ("GstParanoiaEndian", paranoia_endians);
+ paranoia_endian_type =
+ g_enum_register_static ("GstParanoiaEndian", paranoia_endians);
}
return paranoia_endian_type;
}
ARG_DISCID
};
-static void cdparanoia_base_init (gpointer g_class);
-static void cdparanoia_class_init (CDParanoiaClass *klass);
-static void cdparanoia_init (CDParanoia *cdparanoia);
-
-static void cdparanoia_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void cdparanoia_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static GstData* cdparanoia_get (GstPad *pad);
-static gboolean cdparanoia_event (GstPad *pad, GstEvent *event);
-static const GstEventMask*
- cdparanoia_get_event_mask (GstPad *pad);
-static const GstFormat*
- cdparanoia_get_formats (GstPad *pad);
-static gboolean cdparanoia_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean cdparanoia_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
-static const GstQueryType*
- cdparanoia_get_query_types (GstPad *pad);
-static void cdparanoia_set_index (GstElement *element, GstIndex *index);
-static GstIndex *cdparanoia_get_index (GstElement *element);
-
-
-static GstElementStateReturn cdparanoia_change_state (GstElement *element);
+static void cdparanoia_base_init (gpointer g_class);
+static void cdparanoia_class_init (CDParanoiaClass * klass);
+static void cdparanoia_init (CDParanoia * cdparanoia);
+
+static void cdparanoia_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void cdparanoia_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstData *cdparanoia_get (GstPad * pad);
+static gboolean cdparanoia_event (GstPad * pad, GstEvent * event);
+static const GstEventMask *cdparanoia_get_event_mask (GstPad * pad);
+static const GstFormat *cdparanoia_get_formats (GstPad * pad);
+static gboolean cdparanoia_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean cdparanoia_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
+static const GstQueryType *cdparanoia_get_query_types (GstPad * pad);
+static void cdparanoia_set_index (GstElement * element, GstIndex * index);
+static GstIndex *cdparanoia_get_index (GstElement * element);
+
+
+static GstElementStateReturn cdparanoia_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
if (!cdparanoia_type) {
static const GTypeInfo cdparanoia_info = {
sizeof (CDParanoiaClass),
- cdparanoia_base_init,
+ cdparanoia_base_init,
NULL,
(GClassInitFunc) cdparanoia_class_init,
NULL,
(GInstanceInitFunc) cdparanoia_init,
};
- cdparanoia_type = g_type_register_static (GST_TYPE_ELEMENT, "CDParanoia", &cdparanoia_info, 0);
-
+ cdparanoia_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "CDParanoia",
+ &cdparanoia_info, 0);
+
/* Register the track format */
track_format = gst_format_register ("track", "CD track");
sector_format = gst_format_register ("sector", "CD sector");
static void
cdparanoia_base_init (gpointer g_class)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&cdparanoia_src_template));
- gst_element_class_set_details (element_class, &cdparanoia_details);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&cdparanoia_src_template));
+ gst_element_class_set_details (element_class, &cdparanoia_details);
}
static void
-cdparanoia_class_init (CDParanoiaClass *klass)
+cdparanoia_class_init (CDParanoiaClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
cdparanoia_signals[SMILIE_CHANGE] =
- g_signal_new ("smilie-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CDParanoiaClass, smilie_change), NULL, NULL,
- g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("smilie-change", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDParanoiaClass, smilie_change), NULL,
+ NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
cdparanoia_signals[TRANSPORT_ERROR] =
- g_signal_new ("transport-error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CDParanoiaClass, transport_error), NULL, NULL,
- g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("transport-error", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDParanoiaClass, transport_error),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
cdparanoia_signals[UNCORRECTED_ERROR] =
- g_signal_new ("uncorrected-error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CDParanoiaClass, uncorrected_error), NULL, NULL,
- g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
-
- 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_GENERIC_DEVICE,
- g_param_spec_string ("generic_device", "Generic device", "Use specified generic scsi device",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEFAULT_SECTORS,
- g_param_spec_int ("default_sectors", "Default sectors",
- "Force default number of sectors in read to n sectors",
- -1, 100, -1, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SEARCH_OVERLAP,
- g_param_spec_int ("search_overlap", "Search overlap",
- "Force minimum overlap search during verification to n sectors",
- -1, 75, -1, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ENDIAN,
- g_param_spec_enum ("endian", "Endian", "Force endian on drive",
- GST_TYPE_PARANOIA_ENDIAN, 0, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_READ_SPEED,
- g_param_spec_int ("read_speed", "Read speed", "Read from device at specified speed",
- G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TOC_OFFSET,
- g_param_spec_int("toc_offset", "TOC offset", "Add <n> sectors to the values reported",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TOC_BIAS,
- g_param_spec_boolean("toc_bias", "TOC bias",
- "Assume that the beginning offset of track 1 as reported in the TOC "
- "will be addressed as LBA 0. Necessary for some Toshiba drives to "
- "get track boundaries",
- TRUE,G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NEVER_SKIP,
- g_param_spec_int ("never_skip", "Never skip",
- "never accept any less than perfect data reconstruction (don't allow "
- "'V's) but if [n] is given, skip after [n] retries without progress.",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ABORT_ON_SKIP,
- g_param_spec_boolean ("abort_on_skip", "Abort on skip", "Abort on imperfect reads/skips",
- TRUE, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARANOIA_MODE,
- g_param_spec_enum ("paranoia_mode", "Paranoia mode", "Type of checking to perform",
- GST_TYPE_PARANOIA_MODE, 0, G_PARAM_READWRITE));
+ g_signal_new ("uncorrected-error", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDParanoiaClass, uncorrected_error),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+
+ 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_GENERIC_DEVICE,
+ g_param_spec_string ("generic_device", "Generic device",
+ "Use specified generic scsi device", NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEFAULT_SECTORS,
+ g_param_spec_int ("default_sectors", "Default sectors",
+ "Force default number of sectors in read to n sectors", -1, 100, -1,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SEARCH_OVERLAP,
+ g_param_spec_int ("search_overlap", "Search overlap",
+ "Force minimum overlap search during verification to n sectors", -1,
+ 75, -1, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ENDIAN,
+ g_param_spec_enum ("endian", "Endian", "Force endian on drive",
+ GST_TYPE_PARANOIA_ENDIAN, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_READ_SPEED,
+ g_param_spec_int ("read_speed", "Read speed",
+ "Read from device at specified speed", G_MININT, G_MAXINT, 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_OFFSET,
+ g_param_spec_int ("toc_offset", "TOC offset",
+ "Add <n> sectors to the values reported", G_MININT, G_MAXINT, 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOC_BIAS,
+ g_param_spec_boolean ("toc_bias", "TOC bias",
+ "Assume that the beginning offset of track 1 as reported in the TOC "
+ "will be addressed as LBA 0. Necessary for some Toshiba drives to "
+ "get track boundaries", TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NEVER_SKIP,
+ g_param_spec_int ("never_skip", "Never skip",
+ "never accept any less than perfect data reconstruction (don't allow "
+ "'V's) but if [n] is given, skip after [n] retries without progress.",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ABORT_ON_SKIP,
+ g_param_spec_boolean ("abort_on_skip", "Abort on skip",
+ "Abort on imperfect reads/skips", TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARANOIA_MODE,
+ g_param_spec_enum ("paranoia_mode", "Paranoia mode",
+ "Type of checking to perform", GST_TYPE_PARANOIA_MODE, 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DISCID,
- g_param_spec_string ("discid", "discid", "The dics id",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("discid", "discid", "The dics id", NULL,
+ G_PARAM_READABLE));
gobject_class->set_property = cdparanoia_set_property;
gobject_class->get_property = cdparanoia_get_property;
gstelement_class->change_state = cdparanoia_change_state;
- gstelement_class->set_index = cdparanoia_set_index;
- gstelement_class->get_index = cdparanoia_get_index;
+ gstelement_class->set_index = cdparanoia_set_index;
+ gstelement_class->get_index = cdparanoia_get_index;
}
static void
-cdparanoia_init (CDParanoia *cdparanoia)
+cdparanoia_init (CDParanoia * cdparanoia)
{
cdparanoia->srcpad =
- gst_pad_new_from_template (
- gst_static_pad_template_get (&cdparanoia_src_template), "src");
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&cdparanoia_src_template), "src");
gst_pad_set_get_function (cdparanoia->srcpad, cdparanoia_get);
gst_pad_set_event_function (cdparanoia->srcpad, cdparanoia_event);
- gst_pad_set_event_mask_function (cdparanoia->srcpad, cdparanoia_get_event_mask);
+ gst_pad_set_event_mask_function (cdparanoia->srcpad,
+ cdparanoia_get_event_mask);
gst_pad_set_convert_function (cdparanoia->srcpad, cdparanoia_convert);
gst_pad_set_query_function (cdparanoia->srcpad, cdparanoia_query);
- gst_pad_set_query_type_function (cdparanoia->srcpad, cdparanoia_get_query_types);
+ gst_pad_set_query_type_function (cdparanoia->srcpad,
+ cdparanoia_get_query_types);
gst_pad_set_formats_function (cdparanoia->srcpad, cdparanoia_get_formats);
gst_element_add_pad (GST_ELEMENT (cdparanoia), cdparanoia->srcpad);
static void
-cdparanoia_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+cdparanoia_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
CDParanoia *src;
}
static void
-cdparanoia_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+cdparanoia_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
CDParanoia *src;
* See cdparanoia/interface/common-interface.c:FixupTOC
*/
if (src->d && src->d->cd_extra)
- g_warning("DiscID on multisession discs might be broken. Use at own risk.");
+ g_warning
+ ("DiscID on multisession discs might be broken. Use at own risk.");
g_value_set_string (value, src->discid);
break;
default:
}
static GstData *
-cdparanoia_get (GstPad *pad)
+cdparanoia_get (GstPad * pad)
{
CDParanoia *src;
GstBuffer *buf;
buf = GST_BUFFER (gst_event_new (GST_EVENT_EOS));
gst_element_set_eos (GST_ELEMENT (src));
- }
- else {
+ } else {
gint16 *cdda_buf;
gint64 timestamp;
GstFormat format;
/* convert the sequence sector number to a timestamp */
format = GST_FORMAT_TIME;
timestamp = 0LL;
- gst_pad_convert (src->srcpad, sector_format, src->seq,
- &format, ×tamp);
+ gst_pad_convert (src->srcpad, sector_format, src->seq, &format, ×tamp);
/* have to copy the buffer for now since we don't own it... */
/* FIXME must ask monty about allowing ownership transfer */
buf = gst_buffer_new_and_alloc (CD_FRAMESIZE_RAW);
memcpy (GST_BUFFER_DATA (buf), cdda_buf, CD_FRAMESIZE_RAW);
GST_BUFFER_TIMESTAMP (buf) = timestamp;
-
+
/* update current sector */
src->cur_sector++;
src->seq++;
/* cdparanoia provides the toc in lba format dang we need it in msf so
* we have to convert it */
static inline void
-lba_to_msf (const gint lba, byte *m, byte *s, byte *f)
+lba_to_msf (const gint lba, byte * m, byte * s, byte * f)
{
gint lba2 = lba;
}
static void
-lba_toc_to_msf_toc (TOC *lba_toc, toc_msf *msf_toc, gint tracks)
+lba_toc_to_msf_toc (TOC * lba_toc, toc_msf * msf_toc, gint tracks)
{
gint i;
for (i = 0; i <= tracks; i++)
- lba_to_msf (lba_toc[i].dwStartSector, &msf_toc[i].m, &msf_toc[i].s, &msf_toc[i].f);
+ lba_to_msf (lba_toc[i].dwStartSector, &msf_toc[i].m, &msf_toc[i].s,
+ &msf_toc[i].f);
}
/* the cddb hash function */
}
static void
-cddb_discid (gchar *discid, toc_msf *toc, gint tracks)
+cddb_discid (gchar * discid, toc_msf * toc, gint tracks)
{
guint i = 0, t = 0, n = 0;
i++;
}
t = ((toc[tracks].m * 60) + toc[tracks].s) - ((toc[0].m * 60)
- + toc[0].s);
+ + toc[0].s);
sprintf (discid, "%08x", ((n % 0xff) << 24 | t << 8 | tracks));
}
/* get all the cddb info at once */
static void
-get_cddb_info (TOC *toc, gint tracks, gchar *discid, gint64 *offsets, gint64 *total_seconds)
+get_cddb_info (TOC * toc, gint tracks, gchar * discid, gint64 * offsets,
+ gint64 * total_seconds)
{
toc_msf msf_toc[MAXTRK];
gint i;
}
static void
-add_index_associations (CDParanoia *src)
+add_index_associations (CDParanoia * src)
{
- int i;
-
- for (i = 0; i < src->d->tracks; i++) {
- gint64 sector;
-
- sector = cdda_track_firstsector (src->d, i + 1);
- gst_index_add_association (src->index, src->index_id,
- GST_ASSOCIATION_FLAG_KEY_UNIT,
- track_format, i,
- sector_format, sector,
- GST_FORMAT_TIME, (gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100),
- GST_FORMAT_BYTES, (gint64) (sector << 2),
- GST_FORMAT_DEFAULT, (gint64) ((CD_FRAMESIZE_RAW >> 2) * sector),
- NULL);
+ int i;
+
+ for (i = 0; i < src->d->tracks; i++) {
+ gint64 sector;
+
+ sector = cdda_track_firstsector (src->d, i + 1);
+ gst_index_add_association (src->index, src->index_id,
+ GST_ASSOCIATION_FLAG_KEY_UNIT,
+ track_format, i,
+ sector_format, sector,
+ GST_FORMAT_TIME,
+ (gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100),
+ GST_FORMAT_BYTES, (gint64) (sector << 2), GST_FORMAT_DEFAULT,
+ (gint64) ((CD_FRAMESIZE_RAW >> 2) * sector), NULL);
#if 0
- g_print ("Added association for track %d\n", i + 1);
- g_print ("Sector: %lld\n", sector);
- g_print ("Time: %lld\n", (gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100));
- g_print ("Bytes: %lld\n", (gint64) (sector << 2));
- g_print ("Units: %lld\n", (gint64) ((CD_FRAMESIZE_RAW >> 2) * sector));
- g_print ("-----------\n");
+ g_print ("Added association for track %d\n", i + 1);
+ g_print ("Sector: %lld\n", sector);
+ g_print ("Time: %lld\n",
+ (gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100));
+ g_print ("Bytes: %lld\n", (gint64) (sector << 2));
+ g_print ("Units: %lld\n", (gint64) ((CD_FRAMESIZE_RAW >> 2) * sector));
+ g_print ("-----------\n");
#endif
- }
+ }
}
-
+
/* open the file, necessary to go to RUNNING state */
static gboolean
-cdparanoia_open (CDParanoia *src)
+cdparanoia_open (CDParanoia * src)
{
gint i;
gint paranoia_mode;
/* fail if the device couldn't be found */
if (src->d == NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open CD device for reading.")),
- ("cdda_identify failed"));
+ (_("Could not open CD device for reading.")), ("cdda_identify failed"));
return FALSE;
}
/* open the disc */
if (cdda_open (src->d)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open CD device for reading.")),
- ("cdda_open failed"));
+ (_("Could not open CD device for reading.")), ("cdda_open failed"));
cdda_close (src->d);
src->d = NULL;
return FALSE;
*/
get_cddb_info (&src->d->disc_toc[0], src->d->tracks, src->discid,
- src->offsets, &src->total_seconds);
+ src->offsets, &src->total_seconds);
g_object_freeze_notify (G_OBJECT (src));
g_object_notify (G_OBJECT (src), "discid");
/* save thse ones */
src->first_sector = cdda_disc_firstsector (src->d);
- src->last_sector = cdda_disc_lastsector (src->d);
+ src->last_sector = cdda_disc_lastsector (src->d);
/* this is the default segment we will play */
src->segment_start_sector = src->first_sector;
- src->segment_end_sector = src->last_sector;
+ src->segment_end_sector = src->last_sector;
/* create the paranoia struct and set it up */
src->p = paranoia_init (src->d);
paranoia_mode = src->paranoia_mode;
if (src->never_skip)
paranoia_mode |= PARANOIA_MODE_NEVERSKIP;
-
+
paranoia_modeset (src->p, paranoia_mode);
if (src->search_overlap != -1) {
GST_FLAG_SET (src, CDPARANOIA_OPEN);
- if (src->index && GST_INDEX_IS_WRITABLE (src->index)) {
- add_index_associations (src);
- }
-
+ if (src->index && GST_INDEX_IS_WRITABLE (src->index)) {
+ add_index_associations (src);
+ }
+
GST_DEBUG_OBJECT (src, "device successfully openend");
return TRUE;
/* close the file */
static void
-cdparanoia_close (CDParanoia *src)
+cdparanoia_close (CDParanoia * src)
{
g_return_if_fail (GST_FLAG_IS_SET (src, CDPARANOIA_OPEN));
}
static GstElementStateReturn
-cdparanoia_change_state (GstElement *element)
+cdparanoia_change_state (GstElement * element)
{
CDParanoia *cdparanoia;
cdparanoia = CDPARANOIA (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
- if (!cdparanoia_open (CDPARANOIA (element))) {
- g_warning ("cdparanoia: failed opening cd");
- return GST_STATE_FAILURE;
- }
- cdparanoia->seq = 0;
- break;
- case GST_STATE_READY_TO_PAUSED:
- break;
- case GST_STATE_PAUSED_TO_PLAYING:
- break;
- case GST_STATE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_PAUSED_TO_READY:
- /* FIXME: Need code here to reset element to start of cd */
- break;
- case GST_STATE_READY_TO_NULL:
- cdparanoia_close (CDPARANOIA (element));
- break;
- default:
- break;
+ case GST_STATE_NULL_TO_READY:
+ if (!cdparanoia_open (CDPARANOIA (element))) {
+ g_warning ("cdparanoia: failed opening cd");
+ return GST_STATE_FAILURE;
+ }
+ cdparanoia->seq = 0;
+ break;
+ case GST_STATE_READY_TO_PAUSED:
+ break;
+ case GST_STATE_PAUSED_TO_PLAYING:
+ break;
+ case GST_STATE_PLAYING_TO_PAUSED:
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ /* FIXME: Need code here to reset element to start of cd */
+ break;
+ case GST_STATE_READY_TO_NULL:
+ cdparanoia_close (CDPARANOIA (element));
+ break;
+ default:
+ break;
}
-
+
/* if we haven't failed already, give the parent class a chance too ;-) */
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
}
static const GstEventMask *
-cdparanoia_get_event_mask (GstPad *pad)
+cdparanoia_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
- {GST_EVENT_SEEK, GST_SEEK_METHOD_SET |
- GST_SEEK_METHOD_CUR |
- GST_SEEK_METHOD_END |
- GST_SEEK_FLAG_FLUSH },
- {GST_EVENT_SEEK_SEGMENT, GST_SEEK_METHOD_SET |
- GST_SEEK_METHOD_CUR |
- GST_SEEK_METHOD_END |
- GST_SEEK_FLAG_FLUSH },
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_SET |
+ GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_SEEK_SEGMENT, GST_SEEK_METHOD_SET |
+ GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
{0,}
};
}
static gboolean
-cdparanoia_event (GstPad *pad, GstEvent *event)
+cdparanoia_event (GstPad * pad, GstEvent * event)
{
CDParanoia *src;
gboolean res = TRUE;
gint64 offset, endoffset;
gint format;
gint64 seg_start_sector = -1, seg_end_sector = -1;
-
- format = GST_EVENT_SEEK_FORMAT (event);
- offset = GST_EVENT_SEEK_OFFSET (event);
+
+ format = GST_EVENT_SEEK_FORMAT (event);
+ offset = GST_EVENT_SEEK_OFFSET (event);
endoffset = GST_EVENT_SEEK_ENDOFFSET (event);
/* we can only seek on sectors, so we convert the requested
* offsets to sectors first */
if (offset != -1) {
- res &= gst_pad_convert (src->srcpad, format, offset,
- §or_format, &seg_start_sector);
+ res &= gst_pad_convert (src->srcpad, format, offset,
+ §or_format, &seg_start_sector);
}
if (endoffset != -1) {
- res &= gst_pad_convert (src->srcpad, format, endoffset,
- §or_format, &seg_end_sector);
+ res &= gst_pad_convert (src->srcpad, format, endoffset,
+ §or_format, &seg_end_sector);
}
-
+
if (!res) {
- GST_DEBUG ("could not convert offsets to sectors");
- goto error;
+ GST_DEBUG ("could not convert offsets to sectors");
+ goto error;
}
-
+
switch (GST_EVENT_SEEK_METHOD (event)) {
- case GST_SEEK_METHOD_SET:
- /* values are set for regular seek set */
- break;
- case GST_SEEK_METHOD_CUR:
- if (seg_start_sector != -1) {
- seg_start_sector += src->cur_sector;
- }
- if (seg_end_sector != -1) {
- seg_end_sector += src->cur_sector;
- }
- break;
- case GST_SEEK_METHOD_END:
- if (seg_start_sector != -1) {
- seg_start_sector = src->last_sector - seg_start_sector;
- }
- if (seg_end_sector != -1) {
- seg_end_sector = src->last_sector - seg_end_sector;
- }
- break;
- default:
- goto error;
+ case GST_SEEK_METHOD_SET:
+ /* values are set for regular seek set */
+ break;
+ case GST_SEEK_METHOD_CUR:
+ if (seg_start_sector != -1) {
+ seg_start_sector += src->cur_sector;
+ }
+ if (seg_end_sector != -1) {
+ seg_end_sector += src->cur_sector;
+ }
+ break;
+ case GST_SEEK_METHOD_END:
+ if (seg_start_sector != -1) {
+ seg_start_sector = src->last_sector - seg_start_sector;
+ }
+ if (seg_end_sector != -1) {
+ seg_end_sector = src->last_sector - seg_end_sector;
+ }
+ break;
+ default:
+ goto error;
}
/* do we need to update the start sector? */
if (seg_start_sector != -1) {
- seg_start_sector = CLAMP (seg_start_sector,
- src->first_sector, src->last_sector);
-
- if (paranoia_seek (src->p, seg_start_sector, SEEK_SET) > -1) {
- GST_DEBUG ("seeked to %" G_GINT64_FORMAT, seg_start_sector);
-
- src->segment_start_sector = seg_start_sector;
- src->cur_sector = src->segment_start_sector;
- }
- else {
- goto error;
- }
+ seg_start_sector = CLAMP (seg_start_sector,
+ src->first_sector, src->last_sector);
+
+ if (paranoia_seek (src->p, seg_start_sector, SEEK_SET) > -1) {
+ GST_DEBUG ("seeked to %" G_GINT64_FORMAT, seg_start_sector);
+
+ src->segment_start_sector = seg_start_sector;
+ src->cur_sector = src->segment_start_sector;
+ } else {
+ goto error;
+ }
}
if (seg_end_sector != -1) {
- seg_end_sector = CLAMP (seg_end_sector,
- src->first_sector, src->last_sector);
- src->segment_end_sector = seg_end_sector;
+ seg_end_sector = CLAMP (seg_end_sector,
+ src->first_sector, src->last_sector);
+ src->segment_end_sector = seg_end_sector;
}
- GST_DEBUG ("configured for %d -> %d sectors\n",
- src->segment_start_sector,
- src->segment_end_sector);
+ GST_DEBUG ("configured for %d -> %d sectors\n",
+ src->segment_start_sector, src->segment_end_sector);
break;
}
- default:
- goto error;
+ default:
+ goto error;
}
-
+
if (FALSE) {
- error:
+ error:
res = FALSE;
}
gst_event_unref (event);
-
+
return res;
}
static const GstFormat *
-cdparanoia_get_formats (GstPad *pad)
+cdparanoia_get_formats (GstPad * pad)
{
static GstFormat formats[] = {
GST_FORMAT_TIME,
GST_FORMAT_BYTES,
GST_FORMAT_DEFAULT,
- 0, /* filled later */
- 0, /* filled later */
+ 0, /* filled later */
+ 0, /* filled later */
0
};
}
static gboolean
-cdparanoia_convert (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+cdparanoia_convert (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
CDParanoia *src;
if (!GST_FLAG_IS_SET (src, CDPARANOIA_OPEN)) {
return FALSE;
- }
+ }
switch (src_format) {
+ case GST_FORMAT_TIME:
+ switch (*dest_format) {
+ case GST_FORMAT_BYTES:
+ src_value <<= 2; /* 4 bytes per sample */
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value * 44100 / GST_SECOND;
+ break;
+ default:
+ if (*dest_format == track_format || *dest_format == sector_format) {
+ gint sector =
+ (src_value * 44100) / ((CD_FRAMESIZE_RAW >> 2) * GST_SECOND);
+
+ if (*dest_format == sector_format) {
+ *dest_value = sector;
+ } else {
+ *dest_value = cdda_sector_gettrack (src->d, sector) - 1;
+ }
+ } else
+ return FALSE;
+ break;
+ }
+ break;
+ case GST_FORMAT_BYTES:
+ src_value >>= 2;
+ case GST_FORMAT_DEFAULT:
+ switch (*dest_format) {
+ case GST_FORMAT_BYTES:
+ *dest_value = src_value * 4;
+ break;
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * GST_SECOND / 44100;
+ break;
+ default:
+ if (*dest_format == track_format || *dest_format == sector_format) {
+ gint sector = src_value / (CD_FRAMESIZE_RAW >> 2);
+
+ if (*dest_format == track_format) {
+ *dest_value = cdda_sector_gettrack (src->d, sector) - 1;
+ } else {
+ *dest_value = sector;
+ }
+ } else
+ return FALSE;
+ break;
+ }
+ break;
+ default:
+ {
+ gint sector;
+
+ if (src_format == track_format) {
+ /* some sanity checks */
+ if (src_value < 0 || src_value > src->d->tracks)
+ return FALSE;
+
+ sector = cdda_track_firstsector (src->d, src_value + 1);
+ } else if (src_format == sector_format) {
+ sector = src_value;
+ } else {
+ return FALSE;
+ }
+
+ switch (*dest_format) {
case GST_FORMAT_TIME:
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- src_value <<= 2; /* 4 bytes per sample */
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * 44100 / GST_SECOND;
- break;
- default:
- if (*dest_format == track_format || *dest_format == sector_format) {
- gint sector = (src_value * 44100) / ((CD_FRAMESIZE_RAW >> 2) * GST_SECOND);
-
- if (*dest_format == sector_format) {
- *dest_value = sector;
- }
- else {
- *dest_value = cdda_sector_gettrack (src->d, sector) - 1;
- }
- }
- else
- return FALSE;
- break;
- }
- break;
+ *dest_value = ((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100;
+ break;
case GST_FORMAT_BYTES:
- src_value >>= 2;
+ sector <<= 2;
case GST_FORMAT_DEFAULT:
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- *dest_value = src_value * 4;
- break;
- case GST_FORMAT_TIME:
- *dest_value = src_value * GST_SECOND / 44100;
- break;
- default:
- if (*dest_format == track_format || *dest_format == sector_format) {
- gint sector = src_value / (CD_FRAMESIZE_RAW >> 2);
-
- if (*dest_format == track_format) {
- *dest_value = cdda_sector_gettrack (src->d, sector) - 1;
- }
- else {
- *dest_value = sector;
- }
- }
- else
- return FALSE;
- break;
- }
- break;
+ *dest_value = (CD_FRAMESIZE_RAW >> 2) * sector;
+ break;
default:
- {
- gint sector;
-
- if (src_format == track_format) {
- /* some sanity checks */
- if (src_value < 0 || src_value > src->d->tracks)
- return FALSE;
-
- sector = cdda_track_firstsector (src->d, src_value + 1);
- }
- else if (src_format == sector_format) {
- sector = src_value;
- }
- else {
- return FALSE;
- }
-
- switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = ((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100;
- break;
- case GST_FORMAT_BYTES:
- sector <<= 2;
- case GST_FORMAT_DEFAULT:
- *dest_value = (CD_FRAMESIZE_RAW >> 2) * sector;
- break;
- default:
- if (*dest_format == sector_format) {
- *dest_value = sector;
- }
- else if (*dest_format == track_format) {
- /* if we go past the last sector, make sure to report the last track */
- if (sector > src->last_sector)
- *dest_value = cdda_sector_gettrack (src->d, src->last_sector);
- else
- *dest_value = cdda_sector_gettrack (src->d, sector) - 1;
- }
- else {
- return FALSE;
- }
- break;
- }
- break;
- }
- }
-
+ if (*dest_format == sector_format) {
+ *dest_value = sector;
+ } else if (*dest_format == track_format) {
+ /* if we go past the last sector, make sure to report the last track */
+ if (sector > src->last_sector)
+ *dest_value = cdda_sector_gettrack (src->d, src->last_sector);
+ else
+ *dest_value = cdda_sector_gettrack (src->d, sector) - 1;
+ } else {
+ return FALSE;
+ }
+ break;
+ }
+ break;
+ }
+ }
+
return TRUE;
}
-static const GstQueryType*
-cdparanoia_get_query_types (GstPad *pad)
+static const GstQueryType *
+cdparanoia_get_query_types (GstPad * pad)
{
static const GstQueryType src_query_types[] = {
GST_QUERY_TOTAL,
}
static gboolean
-cdparanoia_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+cdparanoia_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = TRUE;
CDParanoia *src;
if (!GST_FLAG_IS_SET (src, CDPARANOIA_OPEN)) {
return FALSE;
- }
+ }
switch (type) {
case GST_QUERY_TOTAL:
/* we take the last sector + 1 so that we also have the full
* size of that last sector */
- res = gst_pad_convert (src->srcpad,
- sector_format, src->last_sector + 1,
- format, value);
+ res = gst_pad_convert (src->srcpad,
+ sector_format, src->last_sector + 1, format, value);
break;
case GST_QUERY_POSITION:
/* bring our current sector to the requested format */
- res = gst_pad_convert (src->srcpad,
- sector_format, src->cur_sector,
- format, value);
+ res = gst_pad_convert (src->srcpad,
+ sector_format, src->cur_sector, format, value);
break;
case GST_QUERY_START:
- res = gst_pad_convert (src->srcpad,
- sector_format, src->segment_start_sector,
- format, value);
+ res = gst_pad_convert (src->srcpad,
+ sector_format, src->segment_start_sector, format, value);
break;
case GST_QUERY_SEGMENT_END:
- res = gst_pad_convert (src->srcpad,
- sector_format, src->segment_end_sector,
- format, value);
+ res = gst_pad_convert (src->srcpad,
+ sector_format, src->segment_end_sector, format, value);
break;
default:
res = FALSE;
}
static void
-cdparanoia_set_index (GstElement *element,
- GstIndex *index)
+cdparanoia_set_index (GstElement * element, GstIndex * index)
{
- CDParanoia *cdparanoia;
+ CDParanoia *cdparanoia;
- cdparanoia = CDPARANOIA (element);
+ cdparanoia = CDPARANOIA (element);
- cdparanoia->index = index;
+ cdparanoia->index = index;
- gst_index_get_writer_id (index, GST_OBJECT (cdparanoia->srcpad),
- &cdparanoia->index_id);
- gst_index_add_format (index, cdparanoia->index_id, track_format);
- gst_index_add_format (index, cdparanoia->index_id, sector_format);
+ gst_index_get_writer_id (index, GST_OBJECT (cdparanoia->srcpad),
+ &cdparanoia->index_id);
+ gst_index_add_format (index, cdparanoia->index_id, track_format);
+ gst_index_add_format (index, cdparanoia->index_id, sector_format);
}
static GstIndex *
-cdparanoia_get_index (GstElement *element)
+cdparanoia_get_index (GstElement * element)
{
- CDParanoia *cdparanoia;
+ CDParanoia *cdparanoia;
- cdparanoia = CDPARANOIA (element);
+ cdparanoia = CDPARANOIA (element);
- return cdparanoia->index;
+ return cdparanoia->index;
}
-
+
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "cdparanoia", GST_RANK_NONE, GST_TYPE_CDPARANOIA))
- return FALSE;
+ if (!gst_element_register (plugin, "cdparanoia", GST_RANK_NONE,
+ GST_TYPE_CDPARANOIA))
+ return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "cdparanoia",
- "Read audio from CD in paranoid mode",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "cdparanoia",
+ "Read audio from CD in paranoid mode",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define size16 gint16
#define size32 gint32
#ifdef CDPARANOIA_HEADERS_IN_DIR
- #include <cdda/cdda_interface.h>
- #include <cdda/cdda_paranoia.h>
+#include <cdda/cdda_interface.h>
+#include <cdda/cdda_paranoia.h>
#else
- #include <cdda_interface.h>
- #include <cdda_paranoia.h>
+#include <cdda_interface.h>
+#include <cdda_paranoia.h>
#endif
-
+
/*#define CDPARANOIA_BASEOFFSET 0xf1d2 */
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CDPARANOIA))
/* NOTE: per-element flags start with 16 for now */
-typedef enum {
- CDPARANOIA_OPEN = GST_ELEMENT_FLAG_LAST,
-
- CDPARANOIA_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
-} CDParanoiaFlags;
-
-typedef struct _CDParanoia CDParanoia;
-typedef struct _CDParanoiaClass CDParanoiaClass;
-
-struct _CDParanoia {
- GstElement element;
- /* pads */
- GstPad *srcpad;
-
- /* Index */
- GstIndex *index;
- int index_id;
-
- gchar *device;
- gchar *generic_device;
- gint default_sectors;
- gint search_overlap;
- gint endian;
- gint read_speed;
- gint toc_offset;
- gboolean toc_bias;
- gint never_skip;
- gboolean abort_on_skip;
- gint paranoia_mode;
-
- cdrom_drive *d;
- cdrom_paranoia *p;
-
- gint cur_sector;
- gint segment_start_sector;
- gint segment_end_sector;
-
- gint first_sector;
- gint last_sector;
-
- /* hacks by Gordon Irving */
- gchar discid[20];
- gint64 offsets[MAXTRK];
- gint64 total_seconds;
-
- gint seq;
- gboolean discont_pending;
-};
-
-struct _CDParanoiaClass {
- GstElementClass parent_class;
-
- /* signal callbacks */
- void (*smilie_change) (CDParanoia *cdparanoia, gchar *smilie);
- void (*transport_error) (CDParanoia *cdparanoia, gint offset);
- void (*uncorrected_error) (CDParanoia *cdparanoia, gint offset);
-};
-
-GType cdparanoia_get_type(void);
+ typedef enum
+ {
+ CDPARANOIA_OPEN = GST_ELEMENT_FLAG_LAST,
+
+ CDPARANOIA_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } CDParanoiaFlags;
+
+ typedef struct _CDParanoia CDParanoia;
+ typedef struct _CDParanoiaClass CDParanoiaClass;
+
+ struct _CDParanoia
+ {
+ GstElement element;
+ /* pads */
+ GstPad *srcpad;
+
+ /* Index */
+ GstIndex *index;
+ int index_id;
+
+ gchar *device;
+ gchar *generic_device;
+ gint default_sectors;
+ gint search_overlap;
+ gint endian;
+ gint read_speed;
+ gint toc_offset;
+ gboolean toc_bias;
+ gint never_skip;
+ gboolean abort_on_skip;
+ gint paranoia_mode;
+
+ cdrom_drive *d;
+ cdrom_paranoia *p;
+
+ gint cur_sector;
+ gint segment_start_sector;
+ gint segment_end_sector;
+
+ gint first_sector;
+ gint last_sector;
+
+ /* hacks by Gordon Irving */
+ gchar discid[20];
+ gint64 offsets[MAXTRK];
+ gint64 total_seconds;
+
+ gint seq;
+ gboolean discont_pending;
+ };
+
+ struct _CDParanoiaClass
+ {
+ GstElementClass parent_class;
+
+ /* signal callbacks */
+ void (*smilie_change) (CDParanoia * cdparanoia, gchar * smilie);
+ void (*transport_error) (CDParanoia * cdparanoia, gint offset);
+ void (*uncorrected_error) (CDParanoia * cdparanoia, gint offset);
+ };
+
+ GType cdparanoia_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __CDPARANOIA_H__ */
+#endif /* __CDPARANOIA_H__ */
#include "gstgnomevfs.h"
#include <gst/gst.h>
-static gboolean
-plugin_init(GstPlugin *plugin)
+static gboolean
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "gnomevfssrc",
- GST_RANK_SECONDARY, gst_gnomevfssrc_get_type()) ||
- !gst_element_register (plugin, "gnomevfssink",
- GST_RANK_SECONDARY, gst_gnomevfssink_get_type())) {
+ if (!gst_element_register (plugin, "gnomevfssrc",
+ GST_RANK_SECONDARY, gst_gnomevfssrc_get_type ()) ||
+ !gst_element_register (plugin, "gnomevfssink",
+ GST_RANK_SECONDARY, gst_gnomevfssink_get_type ())) {
return FALSE;
}
-
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gnomevfs",
- "elements to access the Gnome vfs",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gnomevfs",
+ "elements to access the Gnome vfs",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <glib-object.h>
-G_BEGIN_DECLS
-
-
-GType gst_gnomevfssink_get_type (void);
+G_BEGIN_DECLS GType gst_gnomevfssink_get_type (void);
GType gst_gnomevfssrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_GNOME_VFS_H__ */
typedef struct _GstGnomeVFSSink GstGnomeVFSSink;
typedef struct _GstGnomeVFSSinkClass GstGnomeVFSSinkClass;
-typedef enum {
- GST_GNOMEVFSSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+typedef enum
+{
+ GST_GNOMEVFSSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_GNOMEVFSSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ GST_GNOMEVFSSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstGnomeVFSSinkFlags;
-struct _GstGnomeVFSSink {
+struct _GstGnomeVFSSink
+{
GstElement element;
/* filename */
gboolean erase;
};
-struct _GstGnomeVFSSinkClass {
+struct _GstGnomeVFSSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element,GstPad *pad);
- void (*erase_ask) (GstElement *element,GstPad *pad);
+ void (*handoff) (GstElement * element, GstPad * pad);
+ void (*erase_ask) (GstElement * element, GstPad * pad);
};
/* elementfactory information */
-static GstElementDetails gst_gnomevfssink_details = GST_ELEMENT_DETAILS (
- "GnomeVFS Sink",
- "Sink/File",
- "Write stream to a GnomeVFS URI",
- "Bastien Nocera <hadess@hadess.net>"
-);
+static GstElementDetails gst_gnomevfssink_details =
+GST_ELEMENT_DETAILS ("GnomeVFS Sink",
+ "Sink/File",
+ "Write stream to a GnomeVFS URI",
+ "Bastien Nocera <hadess@hadess.net>");
/* GnomeVFSSink signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
SIGNAL_ERASE_ASK,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
ARG_HANDLE,
};
-static void gst_gnomevfssink_base_init (gpointer g_class);
-static void gst_gnomevfssink_class_init (GstGnomeVFSSinkClass *klass);
-static void gst_gnomevfssink_init (GstGnomeVFSSink *gnomevfssink);
+static void gst_gnomevfssink_base_init (gpointer g_class);
+static void gst_gnomevfssink_class_init (GstGnomeVFSSinkClass * klass);
+static void gst_gnomevfssink_init (GstGnomeVFSSink * gnomevfssink);
-static void gst_gnomevfssink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_gnomevfssink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_gnomevfssink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_gnomevfssink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static gboolean gst_gnomevfssink_open_file (GstGnomeVFSSink *sink);
-static void gst_gnomevfssink_close_file (GstGnomeVFSSink *sink);
+static gboolean gst_gnomevfssink_open_file (GstGnomeVFSSink * sink);
+static void gst_gnomevfssink_close_file (GstGnomeVFSSink * sink);
-static void gst_gnomevfssink_chain (GstPad *pad,GstData *_data);
+static void gst_gnomevfssink_chain (GstPad * pad, GstData * _data);
-static GstElementStateReturn gst_gnomevfssink_change_state (GstElement *element);
+static GstElementStateReturn gst_gnomevfssink_change_state (GstElement *
+ element);
static GstElementClass *parent_class = NULL;
static guint gst_gnomevfssink_signals[LAST_SIGNAL] = { 0 };
GType
-gst_gnomevfssink_get_type (void)
+gst_gnomevfssink_get_type (void)
{
static GType gnomevfssink_type = 0;
if (!gnomevfssink_type) {
static const GTypeInfo gnomevfssink_info = {
- sizeof(GstGnomeVFSSinkClass),
+ sizeof (GstGnomeVFSSinkClass),
gst_gnomevfssink_base_init,
NULL,
- (GClassInitFunc)gst_gnomevfssink_class_init,
+ (GClassInitFunc) gst_gnomevfssink_class_init,
NULL,
NULL,
- sizeof(GstGnomeVFSSink),
+ sizeof (GstGnomeVFSSink),
0,
- (GInstanceInitFunc)gst_gnomevfssink_init,
+ (GInstanceInitFunc) gst_gnomevfssink_init,
};
- gnomevfssink_type = g_type_register_static (GST_TYPE_ELEMENT, "GstGnomeVFSSink", &gnomevfssink_info, 0);
+ gnomevfssink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstGnomeVFSSink",
+ &gnomevfssink_info, 0);
}
return gnomevfssink_type;
}
}
static void
-gst_gnomevfssink_class_init (GstGnomeVFSSinkClass *klass)
+gst_gnomevfssink_class_init (GstGnomeVFSSinkClass * 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);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
+ gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
+ "location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
g_object_class_install_property (gobject_class,
- ARG_HANDLE,
- g_param_spec_pointer ("handle",
- "GnomeVFSHandle",
- "Handle for GnomeVFS",
- G_PARAM_READWRITE));
+ ARG_HANDLE,
+ g_param_spec_pointer ("handle",
+ "GnomeVFSHandle", "Handle for GnomeVFS", G_PARAM_READWRITE));
gst_gnomevfssink_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstGnomeVFSSinkClass, handoff), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstGnomeVFSSinkClass, handoff), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_gnomevfssink_signals[SIGNAL_ERASE_ASK] =
- g_signal_new ("erase-ask", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstGnomeVFSSinkClass, erase_ask), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("erase-ask", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstGnomeVFSSinkClass, erase_ask), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_gnomevfssink_set_property;
gstelement_class->change_state = gst_gnomevfssink_change_state;
/* gnome vfs engine init */
- if (gnome_vfs_initialized() == FALSE)
- gnome_vfs_init();
+ if (gnome_vfs_initialized () == FALSE)
+ gnome_vfs_init ();
}
-static void
-gst_gnomevfssink_init (GstGnomeVFSSink *gnomevfssink)
+static void
+gst_gnomevfssink_init (GstGnomeVFSSink * gnomevfssink)
{
GstPad *pad;
+
pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (gnomevfssink), pad);
gst_pad_set_chain_function (pad, gst_gnomevfssink_chain);
}
static void
-gst_gnomevfssink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_gnomevfssink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstGnomeVFSSink *sink;
}
}
-static void
-gst_gnomevfssink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_gnomevfssink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstGnomeVFSSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_GNOMEVFSSINK (object));
-
+
sink = GST_GNOMEVFSSINK (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, sink->filename);
}
static gboolean
-gst_gnomevfssink_open_file (GstGnomeVFSSink *sink)
+gst_gnomevfssink_open_file (GstGnomeVFSSink * sink)
{
GnomeVFSResult result;
if (sink->filename) {
/* open the file */
- result = gnome_vfs_create_uri(&(sink->handle), sink->uri,
- GNOME_VFS_OPEN_WRITE, sink->erase,
- GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE
- | GNOME_VFS_PERM_GROUP_READ);
- GST_DEBUG ("open: %s", gnome_vfs_result_to_string(result));
+ result = gnome_vfs_create_uri (&(sink->handle), sink->uri,
+ GNOME_VFS_OPEN_WRITE, sink->erase,
+ GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE
+ | GNOME_VFS_PERM_GROUP_READ);
+ GST_DEBUG ("open: %s", gnome_vfs_result_to_string (result));
if (result != GNOME_VFS_OK) {
if (sink->erase == FALSE) {
g_signal_emit (G_OBJECT (sink),
- gst_gnomevfssink_signals[SIGNAL_ERASE_ASK], 0,
- sink->erase);
+ gst_gnomevfssink_signals[SIGNAL_ERASE_ASK], 0, sink->erase);
}
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open vfs file \"%s\" for writing."), sink->filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open vfs file \"%s\" for writing."), sink->filename),
+ GST_ERROR_SYSTEM);
return FALSE;
- }
+ }
} else
g_return_val_if_fail (sink->handle != NULL, FALSE);
}
static void
-gst_gnomevfssink_close_file (GstGnomeVFSSink *sink)
+gst_gnomevfssink_close_file (GstGnomeVFSSink * sink)
{
GnomeVFSResult result;
if (sink->filename) {
/* close the file */
- result = gnome_vfs_close(sink->handle);
+ result = gnome_vfs_close (sink->handle);
if (result != GNOME_VFS_OK)
- GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close vfs file \"%s\"."), sink->filename),
- GST_ERROR_SYSTEM);
+ GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
+ (_("Could not close vfs file \"%s\"."), sink->filename),
+ GST_ERROR_SYSTEM);
}
-
+
GST_FLAG_UNSET (sink, GST_GNOMEVFSSINK_OPEN);
}
*
* take the buffer from the pad and write to file if it's open
*/
-static void
-gst_gnomevfssink_chain (GstPad *pad, GstData *_data)
+static void
+gst_gnomevfssink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstGnomeVFSSink *sink;
sink = GST_GNOMEVFSSINK (gst_pad_get_parent (pad));
- if (GST_FLAG_IS_SET (sink, GST_GNOMEVFSSINK_OPEN))
- {
- result = gnome_vfs_write(sink->handle, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE (buf), &bytes_written);
- GST_DEBUG ("write: %s, written_bytes: %" G_GUINT64_FORMAT, gnome_vfs_result_to_string(result), bytes_written);
- if (bytes_written < GST_BUFFER_SIZE (buf))
- {
- printf ("gnomevfssink : Warning : %d bytes should be written, only %" G_GUINT64_FORMAT " bytes written\n",
- GST_BUFFER_SIZE (buf), bytes_written);
+ if (GST_FLAG_IS_SET (sink, GST_GNOMEVFSSINK_OPEN)) {
+ result =
+ gnome_vfs_write (sink->handle, GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf), &bytes_written);
+ GST_DEBUG ("write: %s, written_bytes: %" G_GUINT64_FORMAT,
+ gnome_vfs_result_to_string (result), bytes_written);
+ if (bytes_written < GST_BUFFER_SIZE (buf)) {
+ printf ("gnomevfssink : Warning : %d bytes should be written, only %"
+ G_GUINT64_FORMAT " bytes written\n", GST_BUFFER_SIZE (buf),
+ bytes_written);
}
}
gst_buffer_unref (buf);
g_signal_emit (G_OBJECT (sink), gst_gnomevfssink_signals[SIGNAL_HANDOFF], 0,
- sink);
+ sink);
}
static GstElementStateReturn
-gst_gnomevfssink_change_state (GstElement *element)
+gst_gnomevfssink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_GNOMEVFSSINK (element), GST_STATE_FAILURE);
} else {
if (!GST_FLAG_IS_SET (element, GST_GNOMEVFSSINK_OPEN)) {
if (!gst_gnomevfssink_open_file (GST_GNOMEVFSSINK (element)))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
return GST_STATE_SUCCESS;
}
-
static gint ref_count = 0;
static gboolean vfs_owner = FALSE;
-typedef enum {
- GST_GNOMEVFSSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+typedef enum
+{
+ GST_GNOMEVFSSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_GNOMEVFSSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ GST_GNOMEVFSSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstGnomeVFSSrcFlags;
typedef struct _GstGnomeVFSSrc GstGnomeVFSSrc;
typedef struct _GstGnomeVFSSrcClass GstGnomeVFSSrcClass;
-struct _GstGnomeVFSSrc {
- GstElement element;
- /* pads */
- GstPad *srcpad;
-
- /* filename */
- gchar *filename;
- /* uri */
- GnomeVFSURI *uri;
-
- /* handle */
- GnomeVFSHandle *handle;
- /* Seek stuff */
- gboolean need_flush;
-
- /* details for fallback synchronous read */
- GnomeVFSFileSize size;
- GnomeVFSFileOffset curoffset; /* current offset in file */
- gulong bytes_per_read; /* bytes per read */
- gboolean new_seek;
-
- /* icecast/audiocast metadata extraction handling */
- gboolean iradio_mode;
- gboolean http_callbacks_pushed;
- gboolean seekable;
-
- gint icy_metaint;
- GnomeVFSFileSize icy_count;
-
- gchar *iradio_name;
- gchar *iradio_genre;
- gchar *iradio_url;
- gchar *iradio_title;
-
- GThread *audiocast_thread;
- GList *audiocast_notify_queue;
- GMutex *audiocast_queue_mutex;
- GMutex *audiocast_udpdata_mutex;
- gint audiocast_thread_die_infd;
- gint audiocast_thread_die_outfd;
- gint audiocast_port;
- gint audiocast_fd;
+struct _GstGnomeVFSSrc
+{
+ GstElement element;
+ /* pads */
+ GstPad *srcpad;
+
+ /* filename */
+ gchar *filename;
+ /* uri */
+ GnomeVFSURI *uri;
+
+ /* handle */
+ GnomeVFSHandle *handle;
+ /* Seek stuff */
+ gboolean need_flush;
+
+ /* details for fallback synchronous read */
+ GnomeVFSFileSize size;
+ GnomeVFSFileOffset curoffset; /* current offset in file */
+ gulong bytes_per_read; /* bytes per read */
+ gboolean new_seek;
+
+ /* icecast/audiocast metadata extraction handling */
+ gboolean iradio_mode;
+ gboolean http_callbacks_pushed;
+ gboolean seekable;
+
+ gint icy_metaint;
+ GnomeVFSFileSize icy_count;
+
+ gchar *iradio_name;
+ gchar *iradio_genre;
+ gchar *iradio_url;
+ gchar *iradio_title;
+
+ GThread *audiocast_thread;
+ GList *audiocast_notify_queue;
+ GMutex *audiocast_queue_mutex;
+ GMutex *audiocast_udpdata_mutex;
+ gint audiocast_thread_die_infd;
+ gint audiocast_thread_die_outfd;
+ gint audiocast_port;
+ gint audiocast_fd;
};
-struct _GstGnomeVFSSrcClass {
- GstElementClass parent_class;
+struct _GstGnomeVFSSrcClass
+{
+ GstElementClass parent_class;
};
-static GstElementDetails gst_gnomevfssrc_details = GST_ELEMENT_DETAILS (
- "GnomeVFS Source",
- "Source/File",
- "Read from any GnomeVFS file",
- "Bastien Nocera <hadess@hadess.net>"
-);
+static GstElementDetails gst_gnomevfssrc_details =
+GST_ELEMENT_DETAILS ("GnomeVFS Source",
+ "Source/File",
+ "Read from any GnomeVFS file",
+ "Bastien Nocera <hadess@hadess.net>");
static const GstFormat *
-gst_gnomevfssrc_get_formats (GstPad *pad)
+gst_gnomevfssrc_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_BYTES,
}
static const GstQueryType *
-gst_gnomevfssrc_get_query_types (GstPad *pad)
+gst_gnomevfssrc_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
}
static const GstEventMask *
-gst_gnomevfssrc_get_event_mask (GstPad *pad)
+gst_gnomevfssrc_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
- GST_SEEK_METHOD_SET |
- GST_SEEK_METHOD_END |
- GST_SEEK_FLAG_FLUSH },
- { GST_EVENT_FLUSH, 0 },
- { GST_EVENT_SIZE, 0 },
- { 0, 0 },
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
+ GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_FLUSH, 0},
+ {GST_EVENT_SIZE, 0},
+ {0, 0},
};
return masks;
}
/* GnomeVFSSrc signals and args */
-enum {
- LAST_SIGNAL
+enum
+{
+ LAST_SIGNAL
};
-enum {
- ARG_0,
- ARG_HANDLE,
- ARG_LOCATION,
- ARG_BYTESPERREAD,
- ARG_IRADIO_MODE,
- ARG_IRADIO_NAME,
- ARG_IRADIO_GENRE,
- ARG_IRADIO_URL,
- ARG_IRADIO_TITLE,
- ARG_SEEKABLE,
+enum
+{
+ ARG_0,
+ ARG_HANDLE,
+ ARG_LOCATION,
+ ARG_BYTESPERREAD,
+ ARG_IRADIO_MODE,
+ ARG_IRADIO_NAME,
+ ARG_IRADIO_GENRE,
+ ARG_IRADIO_URL,
+ ARG_IRADIO_TITLE,
+ ARG_SEEKABLE,
};
-static void gst_gnomevfssrc_base_init (gpointer g_class);
-static void gst_gnomevfssrc_class_init (GstGnomeVFSSrcClass *klass);
-static void gst_gnomevfssrc_init (GstGnomeVFSSrc *gnomevfssrc);
-static void gst_gnomevfssrc_dispose (GObject *object);
+static void gst_gnomevfssrc_base_init (gpointer g_class);
+static void gst_gnomevfssrc_class_init (GstGnomeVFSSrcClass * klass);
+static void gst_gnomevfssrc_init (GstGnomeVFSSrc * gnomevfssrc);
+static void gst_gnomevfssrc_dispose (GObject * object);
-static void gst_gnomevfssrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_gnomevfssrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_gnomevfssrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_gnomevfssrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstData* gst_gnomevfssrc_get (GstPad *pad);
+static GstData *gst_gnomevfssrc_get (GstPad * pad);
-static GstElementStateReturn
- gst_gnomevfssrc_change_state (GstElement *element);
+static GstElementStateReturn
+gst_gnomevfssrc_change_state (GstElement * element);
-static void gst_gnomevfssrc_close_file (GstGnomeVFSSrc *src);
-static gboolean gst_gnomevfssrc_open_file (GstGnomeVFSSrc *src);
-static gboolean gst_gnomevfssrc_srcpad_event (GstPad *pad, GstEvent *event);
-static gboolean gst_gnomevfssrc_srcpad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
+static void gst_gnomevfssrc_close_file (GstGnomeVFSSrc * src);
+static gboolean gst_gnomevfssrc_open_file (GstGnomeVFSSrc * src);
+static gboolean gst_gnomevfssrc_srcpad_event (GstPad * pad, GstEvent * event);
+static gboolean gst_gnomevfssrc_srcpad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
-static int audiocast_init(GstGnomeVFSSrc *src);
-static int audiocast_register_listener(gint *port, gint *fd);
-static void audiocast_do_notifications(GstGnomeVFSSrc *src);
-static gpointer audiocast_thread_run(GstGnomeVFSSrc *src);
-static void audiocast_thread_kill(GstGnomeVFSSrc *src);
+static int audiocast_init (GstGnomeVFSSrc * src);
+static int audiocast_register_listener (gint * port, gint * fd);
+static void audiocast_do_notifications (GstGnomeVFSSrc * src);
+static gpointer audiocast_thread_run (GstGnomeVFSSrc * src);
+static void audiocast_thread_kill (GstGnomeVFSSrc * src);
static GstElementClass *parent_class = NULL;
-GType gst_gnomevfssrc_get_type(void)
+GType
+gst_gnomevfssrc_get_type (void)
{
- static GType gnomevfssrc_type = 0;
-
- if (!gnomevfssrc_type) {
- static const GTypeInfo gnomevfssrc_info = {
- sizeof(GstGnomeVFSSrcClass),
- gst_gnomevfssrc_base_init,
- NULL,
- (GClassInitFunc) gst_gnomevfssrc_class_init,
- NULL,
- NULL,
- sizeof(GstGnomeVFSSrc),
- 0,
- (GInstanceInitFunc) gst_gnomevfssrc_init,
- };
- gnomevfssrc_type =
- g_type_register_static(GST_TYPE_ELEMENT,
- "GstGnomeVFSSrc",
- &gnomevfssrc_info,
- 0);
- }
- return gnomevfssrc_type;
+ static GType gnomevfssrc_type = 0;
+
+ if (!gnomevfssrc_type) {
+ static const GTypeInfo gnomevfssrc_info = {
+ sizeof (GstGnomeVFSSrcClass),
+ gst_gnomevfssrc_base_init,
+ NULL,
+ (GClassInitFunc) gst_gnomevfssrc_class_init,
+ NULL,
+ NULL,
+ sizeof (GstGnomeVFSSrc),
+ 0,
+ (GInstanceInitFunc) gst_gnomevfssrc_init,
+ };
+ gnomevfssrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT,
+ "GstGnomeVFSSrc", &gnomevfssrc_info, 0);
+ }
+ return gnomevfssrc_type;
}
static void
gst_element_class_set_details (element_class, &gst_gnomevfssrc_details);
}
-static void gst_gnomevfssrc_class_init(GstGnomeVFSSrcClass *klass)
+static void
+gst_gnomevfssrc_class_init (GstGnomeVFSSrcClass * klass)
{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
-
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "bytesperread", ARG_BYTESPERREAD, G_PARAM_READWRITE,
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
-
- gobject_class->dispose = gst_gnomevfssrc_dispose;
-
- g_object_class_install_property (gobject_class,
- ARG_HANDLE,
- g_param_spec_pointer ("handle",
- "GnomeVFSHandle",
- "Handle for GnomeVFS",
- G_PARAM_READWRITE));
-
- /* icecast stuff */
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_MODE,
- g_param_spec_boolean ("iradio-mode",
- "iradio-mode",
- "Enable internet radio mode (extraction of icecast/audiocast metadata)",
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_NAME,
- g_param_spec_string ("iradio-name",
- "iradio-name",
- "Name of the stream",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_GENRE,
- g_param_spec_string ("iradio-genre",
- "iradio-genre",
- "Genre of the stream",
-
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_URL,
- g_param_spec_string ("iradio-url",
- "iradio-url",
- "Homepage URL for radio stream",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- ARG_IRADIO_TITLE,
- g_param_spec_string ("iradio-title",
- "iradio-title",
- "Name of currently playing song",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property (gobject_class,
- ARG_SEEKABLE,
- g_param_spec_boolean ("seekable",
- "seekable",
- "TRUE is stream is seekable",
- FALSE,
- G_PARAM_READABLE));
-
- gstelement_class->set_property = gst_gnomevfssrc_set_property;
- gstelement_class->get_property = gst_gnomevfssrc_get_property;
-
- gstelement_class->change_state = gst_gnomevfssrc_change_state;
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+
+ gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
+ "bytesperread", ARG_BYTESPERREAD, G_PARAM_READWRITE,
+ "location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
+
+ gobject_class->dispose = gst_gnomevfssrc_dispose;
+
+ g_object_class_install_property (gobject_class,
+ ARG_HANDLE,
+ g_param_spec_pointer ("handle",
+ "GnomeVFSHandle", "Handle for GnomeVFS", G_PARAM_READWRITE));
+
+ /* icecast stuff */
+ g_object_class_install_property (gobject_class,
+ ARG_IRADIO_MODE,
+ g_param_spec_boolean ("iradio-mode",
+ "iradio-mode",
+ "Enable internet radio mode (extraction of icecast/audiocast metadata)",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ ARG_IRADIO_NAME,
+ g_param_spec_string ("iradio-name",
+ "iradio-name", "Name of the stream", NULL, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class,
+ ARG_IRADIO_GENRE,
+ g_param_spec_string ("iradio-genre",
+ "iradio-genre", "Genre of the stream", NULL, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class,
+ ARG_IRADIO_URL,
+ g_param_spec_string ("iradio-url",
+ "iradio-url",
+ "Homepage URL for radio stream", NULL, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class,
+ ARG_IRADIO_TITLE,
+ g_param_spec_string ("iradio-title",
+ "iradio-title",
+ "Name of currently playing song", NULL, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class,
+ ARG_SEEKABLE,
+ g_param_spec_boolean ("seekable",
+ "seekable", "TRUE is stream is seekable", FALSE, G_PARAM_READABLE));
+
+ gstelement_class->set_property = gst_gnomevfssrc_set_property;
+ gstelement_class->get_property = gst_gnomevfssrc_get_property;
+
+ gstelement_class->change_state = gst_gnomevfssrc_change_state;
}
-static void gst_gnomevfssrc_init(GstGnomeVFSSrc *gnomevfssrc)
+static void
+gst_gnomevfssrc_init (GstGnomeVFSSrc * gnomevfssrc)
{
- gnomevfssrc->srcpad = gst_pad_new("src", GST_PAD_SRC);
- gst_pad_set_get_function(gnomevfssrc->srcpad, gst_gnomevfssrc_get);
- gst_pad_set_event_mask_function (gnomevfssrc->srcpad,
- gst_gnomevfssrc_get_event_mask);
- gst_pad_set_event_function (gnomevfssrc->srcpad,
- gst_gnomevfssrc_srcpad_event);
- gst_pad_set_query_type_function (gnomevfssrc->srcpad,
- gst_gnomevfssrc_get_query_types);
- gst_pad_set_query_function (gnomevfssrc->srcpad,
- gst_gnomevfssrc_srcpad_query);
- gst_pad_set_formats_function (gnomevfssrc->srcpad,
- gst_gnomevfssrc_get_formats);
- gst_element_add_pad(GST_ELEMENT(gnomevfssrc), gnomevfssrc->srcpad);
-
- gnomevfssrc->uri = NULL;
- gnomevfssrc->handle = NULL;
- gnomevfssrc->curoffset = 0;
- gnomevfssrc->bytes_per_read = 4096;
- gnomevfssrc->new_seek = FALSE;
-
- gnomevfssrc->icy_metaint = 0;
-
- gnomevfssrc->seekable = FALSE;
-
- gnomevfssrc->iradio_mode = FALSE;
- gnomevfssrc->http_callbacks_pushed = FALSE;
- gnomevfssrc->icy_count = 0;
- gnomevfssrc->iradio_name = NULL;
- gnomevfssrc->iradio_genre = NULL;
- gnomevfssrc->iradio_url = NULL;
- gnomevfssrc->iradio_title = NULL;
-
- gnomevfssrc->audiocast_udpdata_mutex = g_mutex_new();
- gnomevfssrc->audiocast_queue_mutex = g_mutex_new();
- gnomevfssrc->audiocast_notify_queue = NULL;
- gnomevfssrc->audiocast_thread = NULL;
-
- g_static_mutex_lock (&count_lock);
- if (ref_count == 0) {
- /* gnome vfs engine init */
- if (gnome_vfs_initialized() == FALSE) {
- gnome_vfs_init();
- vfs_owner = TRUE;
- }
- }
- ref_count++;
- g_static_mutex_unlock (&count_lock);
+ gnomevfssrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_pad_set_get_function (gnomevfssrc->srcpad, gst_gnomevfssrc_get);
+ gst_pad_set_event_mask_function (gnomevfssrc->srcpad,
+ gst_gnomevfssrc_get_event_mask);
+ gst_pad_set_event_function (gnomevfssrc->srcpad,
+ gst_gnomevfssrc_srcpad_event);
+ gst_pad_set_query_type_function (gnomevfssrc->srcpad,
+ gst_gnomevfssrc_get_query_types);
+ gst_pad_set_query_function (gnomevfssrc->srcpad,
+ gst_gnomevfssrc_srcpad_query);
+ gst_pad_set_formats_function (gnomevfssrc->srcpad,
+ gst_gnomevfssrc_get_formats);
+ gst_element_add_pad (GST_ELEMENT (gnomevfssrc), gnomevfssrc->srcpad);
+
+ gnomevfssrc->uri = NULL;
+ gnomevfssrc->handle = NULL;
+ gnomevfssrc->curoffset = 0;
+ gnomevfssrc->bytes_per_read = 4096;
+ gnomevfssrc->new_seek = FALSE;
+
+ gnomevfssrc->icy_metaint = 0;
+
+ gnomevfssrc->seekable = FALSE;
+
+ gnomevfssrc->iradio_mode = FALSE;
+ gnomevfssrc->http_callbacks_pushed = FALSE;
+ gnomevfssrc->icy_count = 0;
+ gnomevfssrc->iradio_name = NULL;
+ gnomevfssrc->iradio_genre = NULL;
+ gnomevfssrc->iradio_url = NULL;
+ gnomevfssrc->iradio_title = NULL;
+
+ gnomevfssrc->audiocast_udpdata_mutex = g_mutex_new ();
+ gnomevfssrc->audiocast_queue_mutex = g_mutex_new ();
+ gnomevfssrc->audiocast_notify_queue = NULL;
+ gnomevfssrc->audiocast_thread = NULL;
+
+ g_static_mutex_lock (&count_lock);
+ if (ref_count == 0) {
+ /* gnome vfs engine init */
+ if (gnome_vfs_initialized () == FALSE) {
+ gnome_vfs_init ();
+ vfs_owner = TRUE;
+ }
+ }
+ ref_count++;
+ g_static_mutex_unlock (&count_lock);
}
static void
-gst_gnomevfssrc_dispose (GObject *object)
+gst_gnomevfssrc_dispose (GObject * object)
{
- g_static_mutex_lock (&count_lock);
- ref_count--;
- if (ref_count == 0 && vfs_owner) {
- if (gnome_vfs_initialized() == TRUE) {
- gnome_vfs_shutdown();
- }
- }
- g_static_mutex_unlock (&count_lock);
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ g_static_mutex_lock (&count_lock);
+ ref_count--;
+ if (ref_count == 0 && vfs_owner) {
+ if (gnome_vfs_initialized () == TRUE) {
+ gnome_vfs_shutdown ();
+ }
+ }
+ g_static_mutex_unlock (&count_lock);
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
-static void gst_gnomevfssrc_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_gnomevfssrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GstGnomeVFSSrc *src;
- const gchar *location;
- gchar cwd[PATH_MAX];
-
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_GNOMEVFSSRC(object));
-
- src = GST_GNOMEVFSSRC(object);
-
- switch (prop_id) {
- case ARG_LOCATION:
- /* the element must be stopped or paused in order to do this */
- g_return_if_fail((GST_STATE(src) < GST_STATE_PLAYING)
- || (GST_STATE(src) == GST_STATE_PAUSED));
-
- g_free(src->filename);
-
- /* clear the filename if we get a NULL */
- if (g_value_get_string (value) == NULL) {
- gst_element_set_state(GST_ELEMENT(object), GST_STATE_NULL);
- src->filename = NULL;
- } else {
- /* otherwise set the new filename */
- location = g_value_get_string (value);
- /* if it's not a proper uri, default to file: -- this
- * is a crude test */
- if (!strchr (location, ':'))
- {
- gchar *newloc = gnome_vfs_escape_path_string(location);
- if (*newloc == '/')
- src->filename = g_strdup_printf ("file://%s", newloc);
- else
- src->filename = g_strdup_printf ("file://%s/%s", getcwd(cwd, PATH_MAX), newloc);
- g_free(newloc);
- }
- else
- src->filename = g_strdup (g_value_get_string (value));
- }
-
- if ((GST_STATE(src) == GST_STATE_PAUSED)
- && (src->filename != NULL)) {
- gst_gnomevfssrc_close_file(src);
- gst_gnomevfssrc_open_file(src);
- }
- break;
- case ARG_HANDLE:
- src->handle = g_value_get_pointer (value);
- break;
- case ARG_BYTESPERREAD:
- src->bytes_per_read = g_value_get_int (value);
- break;
- case ARG_IRADIO_MODE:
- src->iradio_mode = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GstGnomeVFSSrc *src;
+ const gchar *location;
+ gchar cwd[PATH_MAX];
+
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_GNOMEVFSSRC (object));
+
+ src = GST_GNOMEVFSSRC (object);
+
+ switch (prop_id) {
+ case ARG_LOCATION:
+ /* the element must be stopped or paused in order to do this */
+ g_return_if_fail ((GST_STATE (src) < GST_STATE_PLAYING)
+ || (GST_STATE (src) == GST_STATE_PAUSED));
+
+ g_free (src->filename);
+
+ /* clear the filename if we get a NULL */
+ if (g_value_get_string (value) == NULL) {
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
+ src->filename = NULL;
+ } else {
+ /* otherwise set the new filename */
+ location = g_value_get_string (value);
+ /* if it's not a proper uri, default to file: -- this
+ * is a crude test */
+ if (!strchr (location, ':')) {
+ gchar *newloc = gnome_vfs_escape_path_string (location);
+
+ if (*newloc == '/')
+ src->filename = g_strdup_printf ("file://%s", newloc);
+ else
+ src->filename =
+ g_strdup_printf ("file://%s/%s", getcwd (cwd, PATH_MAX),
+ newloc);
+ g_free (newloc);
+ } else
+ src->filename = g_strdup (g_value_get_string (value));
+ }
+
+ if ((GST_STATE (src) == GST_STATE_PAUSED)
+ && (src->filename != NULL)) {
+ gst_gnomevfssrc_close_file (src);
+ gst_gnomevfssrc_open_file (src);
+ }
+ break;
+ case ARG_HANDLE:
+ src->handle = g_value_get_pointer (value);
+ break;
+ case ARG_BYTESPERREAD:
+ src->bytes_per_read = g_value_get_int (value);
+ break;
+ case ARG_IRADIO_MODE:
+ src->iradio_mode = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static void gst_gnomevfssrc_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_gnomevfssrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstGnomeVFSSrc *src;
-
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_GNOMEVFSSRC(object));
-
- src = GST_GNOMEVFSSRC(object);
-
- switch (prop_id) {
- case ARG_LOCATION:
- g_value_set_string (value, src->filename);
- break;
- case ARG_BYTESPERREAD:
- g_value_set_int (value, src->bytes_per_read);
- break;
- case ARG_HANDLE:
- g_value_set_pointer (value, src->handle);
- break;
- case ARG_IRADIO_MODE:
- g_value_set_boolean (value, src->iradio_mode);
- break;
- case ARG_IRADIO_NAME:
- g_value_set_string (value, src->iradio_name);
- break;
- case ARG_IRADIO_GENRE:
- g_value_set_string (value, src->iradio_genre);
- break;
- case ARG_IRADIO_URL:
- g_value_set_string (value, src->iradio_url);
- break;
- case ARG_IRADIO_TITLE:
- g_mutex_lock(src->audiocast_udpdata_mutex);
- g_value_set_string (value, src->iradio_title);
- g_mutex_unlock(src->audiocast_udpdata_mutex);
- break;
- case ARG_SEEKABLE:
- g_value_set_boolean (value, src->seekable);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GstGnomeVFSSrc *src;
+
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_GNOMEVFSSRC (object));
+
+ src = GST_GNOMEVFSSRC (object);
+
+ switch (prop_id) {
+ case ARG_LOCATION:
+ g_value_set_string (value, src->filename);
+ break;
+ case ARG_BYTESPERREAD:
+ g_value_set_int (value, src->bytes_per_read);
+ break;
+ case ARG_HANDLE:
+ g_value_set_pointer (value, src->handle);
+ break;
+ case ARG_IRADIO_MODE:
+ g_value_set_boolean (value, src->iradio_mode);
+ break;
+ case ARG_IRADIO_NAME:
+ g_value_set_string (value, src->iradio_name);
+ break;
+ case ARG_IRADIO_GENRE:
+ g_value_set_string (value, src->iradio_genre);
+ break;
+ case ARG_IRADIO_URL:
+ g_value_set_string (value, src->iradio_url);
+ break;
+ case ARG_IRADIO_TITLE:
+ g_mutex_lock (src->audiocast_udpdata_mutex);
+ g_value_set_string (value, src->iradio_title);
+ g_mutex_unlock (src->audiocast_udpdata_mutex);
+ break;
+ case ARG_SEEKABLE:
+ g_value_set_boolean (value, src->seekable);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static char *
unicodify (const char *str, int len, ...)
{
- char *ret = NULL, *cset;
- va_list args;
- gsize bytes_read, bytes_written;
-
- if (g_utf8_validate (str, len, NULL))
- return g_strndup (str, len >= 0 ? len : strlen (str));
-
- va_start (args, len);
- while ((cset = va_arg (args, char *)) != NULL)
- {
- if (!strcmp (cset, "locale"))
- ret = g_locale_to_utf8 (str, len, &bytes_read,
- &bytes_written, NULL);
- else
- ret = g_convert (str, len, "UTF-8", cset,
- &bytes_read, &bytes_written, NULL);
- if (ret)
- break;
- }
- va_end (args);
-
- return ret;
+ char *ret = NULL, *cset;
+ va_list args;
+ gsize bytes_read, bytes_written;
+
+ if (g_utf8_validate (str, len, NULL))
+ return g_strndup (str, len >= 0 ? len : strlen (str));
+
+ va_start (args, len);
+ while ((cset = va_arg (args, char *)) != NULL)
+ {
+ if (!strcmp (cset, "locale"))
+ ret = g_locale_to_utf8 (str, len, &bytes_read, &bytes_written, NULL);
+ else
+ ret = g_convert (str, len, "UTF-8", cset,
+ &bytes_read, &bytes_written, NULL);
+ if (ret)
+ break;
+ }
+ va_end (args);
+
+ return ret;
}
static char *
gst_gnomevfssrc_unicodify (const char *str)
{
- return unicodify (str, -1, "locale", "ISO-8859-1", NULL);
+ return unicodify (str, -1, "locale", "ISO-8859-1", NULL);
}
/*
* icecast/audiocast metadata extraction support code
*/
-static int audiocast_init(GstGnomeVFSSrc *src)
+static int
+audiocast_init (GstGnomeVFSSrc * src)
{
- int pipefds[2];
- GError *error = NULL;
- if (!src->iradio_mode)
- return TRUE;
- GST_DEBUG ("audiocast: registering listener");
- if (audiocast_register_listener(&src->audiocast_port, &src->audiocast_fd) < 0) {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
- ("Unable to listen on UDP port %d", src->audiocast_port));
- close(src->audiocast_fd);
- return FALSE;
- }
- GST_DEBUG ("audiocast: creating pipe");
- src->audiocast_notify_queue = NULL;
- if (pipe(pipefds) < 0)
- {
- close(src->audiocast_fd);
- return FALSE;
- }
- src->audiocast_thread_die_infd = pipefds[0];
- src->audiocast_thread_die_outfd = pipefds[1];
- GST_DEBUG ("audiocast: creating audiocast thread");
- src->audiocast_thread = g_thread_create((GThreadFunc) audiocast_thread_run, src, TRUE, &error);
- if (error != NULL) {
- GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
- ("Unable to create thread: %s", error->message));
- close(src->audiocast_fd);
- return FALSE;
- }
- return TRUE;
+ int pipefds[2];
+ GError *error = NULL;
+
+ if (!src->iradio_mode)
+ return TRUE;
+ GST_DEBUG ("audiocast: registering listener");
+ if (audiocast_register_listener (&src->audiocast_port,
+ &src->audiocast_fd) < 0) {
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
+ ("Unable to listen on UDP port %d", src->audiocast_port));
+ close (src->audiocast_fd);
+ return FALSE;
+ }
+ GST_DEBUG ("audiocast: creating pipe");
+ src->audiocast_notify_queue = NULL;
+ if (pipe (pipefds) < 0) {
+ close (src->audiocast_fd);
+ return FALSE;
+ }
+ src->audiocast_thread_die_infd = pipefds[0];
+ src->audiocast_thread_die_outfd = pipefds[1];
+ GST_DEBUG ("audiocast: creating audiocast thread");
+ src->audiocast_thread =
+ g_thread_create ((GThreadFunc) audiocast_thread_run, src, TRUE, &error);
+ if (error != NULL) {
+ GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
+ ("Unable to create thread: %s", error->message));
+ close (src->audiocast_fd);
+ return FALSE;
+ }
+ return TRUE;
}
-static int audiocast_register_listener(gint *port, gint *fd)
+static int
+audiocast_register_listener (gint * port, gint * fd)
{
- struct sockaddr_in sin;
- int sock;
- socklen_t sinlen = sizeof (struct sockaddr_in);
+ struct sockaddr_in sin;
+ int sock;
+ socklen_t sinlen = sizeof (struct sockaddr_in);
- GST_DEBUG ("audiocast: estabilishing UDP listener");
+ GST_DEBUG ("audiocast: estabilishing UDP listener");
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- goto lose;
-
- memset(&sin, 0, sinlen);
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = g_htonl(INADDR_ANY);
-
- if (bind(sock, (struct sockaddr *)&sin, sinlen) < 0)
- goto lose_and_close;
+ if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+ goto lose;
- memset(&sin, 0, sinlen);
- if (getsockname(sock, (struct sockaddr *)&sin, &sinlen) < 0)
- goto lose_and_close;
+ memset (&sin, 0, sinlen);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = g_htonl (INADDR_ANY);
- GST_DEBUG ("audiocast: listening on local %s:%d", inet_ntoa(sin.sin_addr), g_ntohs(sin.sin_port));
+ if (bind (sock, (struct sockaddr *) &sin, sinlen) < 0)
+ goto lose_and_close;
- *port = g_ntohs(sin.sin_port);
- *fd = sock;
+ memset (&sin, 0, sinlen);
+ if (getsockname (sock, (struct sockaddr *) &sin, &sinlen) < 0)
+ goto lose_and_close;
- return 0;
+ GST_DEBUG ("audiocast: listening on local %s:%d", inet_ntoa (sin.sin_addr),
+ g_ntohs (sin.sin_port));
+
+ *port = g_ntohs (sin.sin_port);
+ *fd = sock;
+
+ return 0;
lose_and_close:
- close(sock);
+ close (sock);
lose:
- return -1;
+ return -1;
}
-static void audiocast_do_notifications(GstGnomeVFSSrc *src)
+static void
+audiocast_do_notifications (GstGnomeVFSSrc * src)
{
- /* Send any pending notifications we got from the UDP thread. */
- if (src->iradio_mode)
- {
- GList *entry;
- g_mutex_lock(src->audiocast_queue_mutex);
- for (entry = src->audiocast_notify_queue; entry; entry = entry->next)
- g_object_notify(G_OBJECT (src), (const gchar *) entry->data);
- g_list_free(src->audiocast_notify_queue);
- src->audiocast_notify_queue = NULL;
- g_mutex_unlock(src->audiocast_queue_mutex);
- }
+ /* Send any pending notifications we got from the UDP thread. */
+ if (src->iradio_mode) {
+ GList *entry;
+
+ g_mutex_lock (src->audiocast_queue_mutex);
+ for (entry = src->audiocast_notify_queue; entry; entry = entry->next)
+ g_object_notify (G_OBJECT (src), (const gchar *) entry->data);
+ g_list_free (src->audiocast_notify_queue);
+ src->audiocast_notify_queue = NULL;
+ g_mutex_unlock (src->audiocast_queue_mutex);
+ }
}
-static gpointer audiocast_thread_run(GstGnomeVFSSrc *src)
+static gpointer
+audiocast_thread_run (GstGnomeVFSSrc * src)
{
- char buf[1025], **lines;
- gsize len;
- fd_set fdset, readset;
- struct sockaddr_in from;
- socklen_t fromlen = sizeof(struct sockaddr_in);
-
- FD_ZERO(&fdset);
-
- FD_SET(src->audiocast_fd, &fdset);
- FD_SET(src->audiocast_thread_die_infd, &fdset);
-
- while (1)
- {
- GST_DEBUG ("audiocast thread: dropping into select");
- readset = fdset;
- if (select(FD_SETSIZE, &readset, NULL, NULL, NULL) < 0) {
- perror("select");
- return NULL;
- }
- if (FD_ISSET(src->audiocast_thread_die_infd, &readset)) {
- char buf[1];
- GST_DEBUG ("audiocast thread: got die character");
- read(src->audiocast_thread_die_infd, buf, 1);
- close(src->audiocast_thread_die_infd);
- close(src->audiocast_fd);
- return NULL;
- }
- GST_DEBUG ("audiocast thread: reading data");
- len = recvfrom(src->audiocast_fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &from, &fromlen);
- if (len < 0 && errno == EAGAIN)
- continue;
- else if (len >= 0)
- {
- int i;
- char *valptr, *value;
- buf[len] = '\0';
- lines = g_strsplit(buf, "\n", 0);
- if (!lines)
- continue;
-
- for (i = 0; lines[i]; i++) {
- while ((lines[i][strlen(lines[i]) - 1] == '\n') ||
- (lines[i][strlen(lines[i]) - 1] == '\r'))
- lines[i][strlen(lines[i]) - 1] = '\0';
-
- valptr = strchr(lines[i], ':');
-
- if (!valptr)
- continue;
- else
- valptr++;
-
- g_strstrip(valptr);
- if (!strlen(valptr))
- continue;
-
- value = gst_gnomevfssrc_unicodify (valptr);
- if (!value)
- {
- g_print ("Unable to convert \"%s\" to UTF-8!\n", valptr);
- continue;
- }
-
- if (!strncmp(lines[i], "x-audiocast-streamtitle", 23)) {
- g_mutex_lock(src->audiocast_udpdata_mutex);
- g_free(src->iradio_title);
- src->iradio_title = value;
- g_mutex_unlock(src->audiocast_udpdata_mutex);
-
- g_mutex_lock(src->audiocast_queue_mutex);
- src->audiocast_notify_queue = g_list_append(src->audiocast_notify_queue, "iradio-title");
- GST_DEBUG ("audiocast title: %s\n", src->iradio_title);
- g_mutex_unlock(src->audiocast_queue_mutex);
- } else if (!strncmp(lines[i], "x-audiocast-streamurl", 21)) {
- g_mutex_lock(src->audiocast_udpdata_mutex);
- g_free(src->iradio_url);
- src->iradio_url = value;
- g_mutex_unlock(src->audiocast_udpdata_mutex);
-
- g_mutex_lock(src->audiocast_queue_mutex);
- src->audiocast_notify_queue = g_list_append(src->audiocast_notify_queue, "iradio-url");
- GST_DEBUG ("audiocast url: %s\n", src->iradio_title);
- g_mutex_unlock(src->audiocast_queue_mutex);
- } else if (!strncmp(lines[i], "x-audiocast-udpseqnr", 20)) {
- gchar outbuf[120];
-
- sprintf(outbuf, "x-audiocast-ack: %ld \r\n", atol(value));
- g_free (value);
-
- if (sendto(src->audiocast_fd, outbuf, strlen(outbuf), 0, (struct sockaddr *) &from, fromlen) <= 0) {
- g_print("Error sending response to server: %s\n", strerror(errno));
- continue;
- }
- GST_DEBUG ("sent audiocast ack: %s\n", outbuf);
- }
- }
- g_strfreev(lines);
- }
+ char buf[1025], **lines;
+ gsize len;
+ fd_set fdset, readset;
+ struct sockaddr_in from;
+ socklen_t fromlen = sizeof (struct sockaddr_in);
+
+ FD_ZERO (&fdset);
+
+ FD_SET (src->audiocast_fd, &fdset);
+ FD_SET (src->audiocast_thread_die_infd, &fdset);
+
+ while (1) {
+ GST_DEBUG ("audiocast thread: dropping into select");
+ readset = fdset;
+ if (select (FD_SETSIZE, &readset, NULL, NULL, NULL) < 0) {
+ perror ("select");
+ return NULL;
+ }
+ if (FD_ISSET (src->audiocast_thread_die_infd, &readset)) {
+ char buf[1];
+
+ GST_DEBUG ("audiocast thread: got die character");
+ read (src->audiocast_thread_die_infd, buf, 1);
+ close (src->audiocast_thread_die_infd);
+ close (src->audiocast_fd);
+ return NULL;
+ }
+ GST_DEBUG ("audiocast thread: reading data");
+ len =
+ recvfrom (src->audiocast_fd, buf, sizeof (buf) - 1, 0,
+ (struct sockaddr *) &from, &fromlen);
+ if (len < 0 && errno == EAGAIN)
+ continue;
+ else if (len >= 0) {
+ int i;
+ char *valptr, *value;
+
+ buf[len] = '\0';
+ lines = g_strsplit (buf, "\n", 0);
+ if (!lines)
+ continue;
+
+ for (i = 0; lines[i]; i++) {
+ while ((lines[i][strlen (lines[i]) - 1] == '\n') ||
+ (lines[i][strlen (lines[i]) - 1] == '\r'))
+ lines[i][strlen (lines[i]) - 1] = '\0';
+
+ valptr = strchr (lines[i], ':');
+
+ if (!valptr)
+ continue;
+ else
+ valptr++;
+
+ g_strstrip (valptr);
+ if (!strlen (valptr))
+ continue;
+
+ value = gst_gnomevfssrc_unicodify (valptr);
+ if (!value) {
+ g_print ("Unable to convert \"%s\" to UTF-8!\n", valptr);
+ continue;
+ }
+
+ if (!strncmp (lines[i], "x-audiocast-streamtitle", 23)) {
+ g_mutex_lock (src->audiocast_udpdata_mutex);
+ g_free (src->iradio_title);
+ src->iradio_title = value;
+ g_mutex_unlock (src->audiocast_udpdata_mutex);
+
+ g_mutex_lock (src->audiocast_queue_mutex);
+ src->audiocast_notify_queue =
+ g_list_append (src->audiocast_notify_queue, "iradio-title");
+ GST_DEBUG ("audiocast title: %s\n", src->iradio_title);
+ g_mutex_unlock (src->audiocast_queue_mutex);
+ } else if (!strncmp (lines[i], "x-audiocast-streamurl", 21)) {
+ g_mutex_lock (src->audiocast_udpdata_mutex);
+ g_free (src->iradio_url);
+ src->iradio_url = value;
+ g_mutex_unlock (src->audiocast_udpdata_mutex);
+
+ g_mutex_lock (src->audiocast_queue_mutex);
+ src->audiocast_notify_queue =
+ g_list_append (src->audiocast_notify_queue, "iradio-url");
+ GST_DEBUG ("audiocast url: %s\n", src->iradio_title);
+ g_mutex_unlock (src->audiocast_queue_mutex);
+ } else if (!strncmp (lines[i], "x-audiocast-udpseqnr", 20)) {
+ gchar outbuf[120];
+
+ sprintf (outbuf, "x-audiocast-ack: %ld \r\n", atol (value));
+ g_free (value);
+
+ if (sendto (src->audiocast_fd, outbuf, strlen (outbuf), 0,
+ (struct sockaddr *) &from, fromlen) <= 0) {
+ g_print ("Error sending response to server: %s\n",
+ strerror (errno));
+ continue;
+ }
+ GST_DEBUG ("sent audiocast ack: %s\n", outbuf);
}
- return NULL;
+ }
+ g_strfreev (lines);
+ }
+ }
+ return NULL;
}
-static void audiocast_thread_kill(GstGnomeVFSSrc *src)
+static void
+audiocast_thread_kill (GstGnomeVFSSrc * src)
{
- if (!src->audiocast_thread)
- return;
-
- /*
- We rely on this hack to kill the
- audiocast thread. If we get icecast
- metadata, then we don't need the
- audiocast metadata too.
- */
- GST_DEBUG ("audiocast: writing die character");
- write(src->audiocast_thread_die_outfd, "q", 1);
- close(src->audiocast_thread_die_outfd);
- GST_DEBUG ("audiocast: joining thread");
- g_thread_join(src->audiocast_thread);
- src->audiocast_thread = NULL;
+ if (!src->audiocast_thread)
+ return;
+
+ /*
+ We rely on this hack to kill the
+ audiocast thread. If we get icecast
+ metadata, then we don't need the
+ audiocast metadata too.
+ */
+ GST_DEBUG ("audiocast: writing die character");
+ write (src->audiocast_thread_die_outfd, "q", 1);
+ close (src->audiocast_thread_die_outfd);
+ GST_DEBUG ("audiocast: joining thread");
+ g_thread_join (src->audiocast_thread);
+ src->audiocast_thread = NULL;
}
static void
gst_gnomevfssrc_send_additional_headers_callback (gconstpointer in,
- gsize in_size,
- gpointer out,
- gsize out_size,
- gpointer callback_data)
+ gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
{
- GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (callback_data);
- GnomeVFSModuleCallbackAdditionalHeadersOut *out_args =
- (GnomeVFSModuleCallbackAdditionalHeadersOut *)out;
-
- if (!src->iradio_mode)
- return;
- GST_DEBUG ("sending headers\n");
-
- out_args->headers = g_list_append (out_args->headers,
- g_strdup ("icy-metadata:1\r\n"));
- out_args->headers = g_list_append (out_args->headers,
- g_strdup_printf ("x-audiocast-udpport: %d\r\n", src->audiocast_port));
+ GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (callback_data);
+ GnomeVFSModuleCallbackAdditionalHeadersOut *out_args =
+ (GnomeVFSModuleCallbackAdditionalHeadersOut *) out;
+
+ if (!src->iradio_mode)
+ return;
+ GST_DEBUG ("sending headers\n");
+
+ out_args->headers = g_list_append (out_args->headers,
+ g_strdup ("icy-metadata:1\r\n"));
+ out_args->headers = g_list_append (out_args->headers,
+ g_strdup_printf ("x-audiocast-udpport: %d\r\n", src->audiocast_port));
}
static void
gst_gnomevfssrc_received_headers_callback (gconstpointer in,
- gsize in_size,
- gpointer out,
- gsize out_size,
- gpointer callback_data)
+ gsize in_size, gpointer out, gsize out_size, gpointer callback_data)
{
- GList *i;
- gint icy_metaint;
- GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (callback_data);
- GnomeVFSModuleCallbackReceivedHeadersIn *in_args =
- (GnomeVFSModuleCallbackReceivedHeadersIn *)in;
-
- /* This is only used for internet radio stuff right now */
- if (!src->iradio_mode)
- return;
-
- for (i = in_args->headers; i; i = i->next) {
- char *data = (char *) i->data;
- char *key = data;
- char *value = strchr(data, ':');
- if (!value)
- continue;
-
- value++;
- g_strstrip(value);
- if (!strlen(value))
- continue;
-
- /* Icecast stuff */
- if (!strncmp (data, "icy-metaint:", 12)) /* ugh */
- {
- sscanf (data + 12, "%d", &icy_metaint);
- src->icy_metaint = icy_metaint;
- GST_DEBUG ("got icy-metaint %d, killing audiocast thread",
- src->icy_metaint);
- audiocast_thread_kill(src);
- continue;
- }
-
- if (!strncmp(data, "icy-", 4))
- key = data + 4;
- else if (!strncmp(data, "x-audiocast-", 12))
- key = data + 12;
- else
- continue;
-
- GST_DEBUG ("key: %s", key);
- if (!strncmp (key, "name", 4)) {
- g_free (src->iradio_name);
- src->iradio_name = gst_gnomevfssrc_unicodify (value);
- if (src->iradio_name)
- g_object_notify (G_OBJECT (src), "iradio-name");
- } else if (!strncmp (key, "genre", 5)) {
- g_free (src->iradio_genre);
- src->iradio_genre = gst_gnomevfssrc_unicodify (value);
- if (src->iradio_genre)
- g_object_notify (G_OBJECT (src), "iradio-genre");
- } else if (!strncmp (key, "url", 3)) {
- g_free (src->iradio_url);
- src->iradio_url = gst_gnomevfssrc_unicodify (value);
- if (src->iradio_url)
- g_object_notify (G_OBJECT (src), "iradio-url");
- }
- }
+ GList *i;
+ gint icy_metaint;
+ GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (callback_data);
+ GnomeVFSModuleCallbackReceivedHeadersIn *in_args =
+ (GnomeVFSModuleCallbackReceivedHeadersIn *) in;
+
+ /* This is only used for internet radio stuff right now */
+ if (!src->iradio_mode)
+ return;
+
+ for (i = in_args->headers; i; i = i->next) {
+ char *data = (char *) i->data;
+ char *key = data;
+ char *value = strchr (data, ':');
+
+ if (!value)
+ continue;
+
+ value++;
+ g_strstrip (value);
+ if (!strlen (value))
+ continue;
+
+ /* Icecast stuff */
+ if (!strncmp (data, "icy-metaint:", 12)) { /* ugh */
+ sscanf (data + 12, "%d", &icy_metaint);
+ src->icy_metaint = icy_metaint;
+ GST_DEBUG ("got icy-metaint %d, killing audiocast thread",
+ src->icy_metaint);
+ audiocast_thread_kill (src);
+ continue;
+ }
+
+ if (!strncmp (data, "icy-", 4))
+ key = data + 4;
+ else if (!strncmp (data, "x-audiocast-", 12))
+ key = data + 12;
+ else
+ continue;
+
+ GST_DEBUG ("key: %s", key);
+ if (!strncmp (key, "name", 4)) {
+ g_free (src->iradio_name);
+ src->iradio_name = gst_gnomevfssrc_unicodify (value);
+ if (src->iradio_name)
+ g_object_notify (G_OBJECT (src), "iradio-name");
+ } else if (!strncmp (key, "genre", 5)) {
+ g_free (src->iradio_genre);
+ src->iradio_genre = gst_gnomevfssrc_unicodify (value);
+ if (src->iradio_genre)
+ g_object_notify (G_OBJECT (src), "iradio-genre");
+ } else if (!strncmp (key, "url", 3)) {
+ g_free (src->iradio_url);
+ src->iradio_url = gst_gnomevfssrc_unicodify (value);
+ if (src->iradio_url)
+ g_object_notify (G_OBJECT (src), "iradio-url");
+ }
+ }
}
static void
-gst_gnomevfssrc_push_callbacks (GstGnomeVFSSrc *gnomevfssrc)
+gst_gnomevfssrc_push_callbacks (GstGnomeVFSSrc * gnomevfssrc)
{
- if (gnomevfssrc->http_callbacks_pushed)
- return;
-
- GST_DEBUG ("pushing callbacks");
- gnome_vfs_module_callback_push (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS,
- gst_gnomevfssrc_send_additional_headers_callback,
- gnomevfssrc,
- NULL);
- gnome_vfs_module_callback_push (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS,
- gst_gnomevfssrc_received_headers_callback,
- gnomevfssrc,
- NULL);
-
- gnomevfssrc->http_callbacks_pushed = TRUE;
+ if (gnomevfssrc->http_callbacks_pushed)
+ return;
+
+ GST_DEBUG ("pushing callbacks");
+ gnome_vfs_module_callback_push
+ (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS,
+ gst_gnomevfssrc_send_additional_headers_callback, gnomevfssrc, NULL);
+ gnome_vfs_module_callback_push
+ (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS,
+ gst_gnomevfssrc_received_headers_callback, gnomevfssrc, NULL);
+
+ gnomevfssrc->http_callbacks_pushed = TRUE;
}
static void
-gst_gnomevfssrc_pop_callbacks (GstGnomeVFSSrc *gnomevfssrc)
+gst_gnomevfssrc_pop_callbacks (GstGnomeVFSSrc * gnomevfssrc)
{
- if (!gnomevfssrc->http_callbacks_pushed)
- return;
-
- GST_DEBUG ("popping callbacks");
- gnome_vfs_module_callback_pop (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS);
- gnome_vfs_module_callback_pop (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS);
+ if (!gnomevfssrc->http_callbacks_pushed)
+ return;
+
+ GST_DEBUG ("popping callbacks");
+ gnome_vfs_module_callback_pop
+ (GNOME_VFS_MODULE_CALLBACK_HTTP_SEND_ADDITIONAL_HEADERS);
+ gnome_vfs_module_callback_pop
+ (GNOME_VFS_MODULE_CALLBACK_HTTP_RECEIVED_HEADERS);
}
static void
-gst_gnomevfssrc_get_icy_metadata (GstGnomeVFSSrc *src)
+gst_gnomevfssrc_get_icy_metadata (GstGnomeVFSSrc * src)
{
- GnomeVFSFileSize length = 0;
- GnomeVFSResult res;
- gint metadata_length;
- guchar foobyte;
- guchar *data;
- guchar *pos;
- gchar **tags;
- int i;
-
- GST_DEBUG ("reading icecast metadata");
-
- while (length == 0) {
- res = gnome_vfs_read (src->handle, &foobyte, 1, &length);
- if (res != GNOME_VFS_OK)
- return;
- }
-
- metadata_length = foobyte * 16;
-
- if (metadata_length == 0)
- return;
-
- data = g_new (gchar, metadata_length + 1);
- pos = data;
-
- while (pos - data < metadata_length) {
- res = gnome_vfs_read (src->handle, pos,
- metadata_length - (pos - data),
- &length);
- /* FIXME: better error handling here? */
- if (res != GNOME_VFS_OK) {
- g_free (data);
- return;
- }
-
- pos += length;
- }
-
- data[metadata_length] = 0;
- tags = g_strsplit(data, "';", 0);
-
- for (i = 0; tags[i]; i++)
- {
- if (!g_ascii_strncasecmp(tags[i], "StreamTitle=", 12))
- {
- g_free (src->iradio_title);
- src->iradio_title = gst_gnomevfssrc_unicodify (tags[i]+13);
- if (src->iradio_title)
- {
- GST_DEBUG ("sending notification on icecast title");
- g_object_notify (G_OBJECT (src), "iradio-title");
- }
- else
- g_print ("Unable to convert icecast title \"%s\" to UTF-8!\n",
- tags[i]+13);
-
- }
- if (!g_ascii_strncasecmp(tags[i], "StreamUrl=", 10))
- {
- g_free (src->iradio_url);
- src->iradio_url = gst_gnomevfssrc_unicodify (tags[i]+11);
- if (src->iradio_url)
- {
- GST_DEBUG ("sending notification on icecast url");
- g_object_notify (G_OBJECT (src), "iradio-url");
- }
- else
- g_print ("Unable to convert icecast url \"%s\" to UTF-8!\n",
- tags[i]+11);
- }
- }
-
- g_strfreev(tags);
+ GnomeVFSFileSize length = 0;
+ GnomeVFSResult res;
+ gint metadata_length;
+ guchar foobyte;
+ guchar *data;
+ guchar *pos;
+ gchar **tags;
+ int i;
+
+ GST_DEBUG ("reading icecast metadata");
+
+ while (length == 0) {
+ res = gnome_vfs_read (src->handle, &foobyte, 1, &length);
+ if (res != GNOME_VFS_OK)
+ return;
+ }
+
+ metadata_length = foobyte * 16;
+
+ if (metadata_length == 0)
+ return;
+
+ data = g_new (gchar, metadata_length + 1);
+ pos = data;
+
+ while (pos - data < metadata_length) {
+ res = gnome_vfs_read (src->handle, pos,
+ metadata_length - (pos - data), &length);
+ /* FIXME: better error handling here? */
+ if (res != GNOME_VFS_OK) {
+ g_free (data);
+ return;
+ }
+
+ pos += length;
+ }
+
+ data[metadata_length] = 0;
+ tags = g_strsplit (data, "';", 0);
+
+ for (i = 0; tags[i]; i++) {
+ if (!g_ascii_strncasecmp (tags[i], "StreamTitle=", 12)) {
+ g_free (src->iradio_title);
+ src->iradio_title = gst_gnomevfssrc_unicodify (tags[i] + 13);
+ if (src->iradio_title) {
+ GST_DEBUG ("sending notification on icecast title");
+ g_object_notify (G_OBJECT (src), "iradio-title");
+ } else
+ g_print ("Unable to convert icecast title \"%s\" to UTF-8!\n",
+ tags[i] + 13);
+
+ }
+ if (!g_ascii_strncasecmp (tags[i], "StreamUrl=", 10)) {
+ g_free (src->iradio_url);
+ src->iradio_url = gst_gnomevfssrc_unicodify (tags[i] + 11);
+ if (src->iradio_url) {
+ GST_DEBUG ("sending notification on icecast url");
+ g_object_notify (G_OBJECT (src), "iradio-url");
+ } else
+ g_print ("Unable to convert icecast url \"%s\" to UTF-8!\n",
+ tags[i] + 11);
+ }
+ }
+
+ g_strfreev (tags);
}
/* end of icecast/audiocast metadata extraction support code */
*
* Push a new buffer from the gnomevfssrc at the current offset.
*/
-static GstData *gst_gnomevfssrc_get(GstPad *pad)
+static GstData *
+gst_gnomevfssrc_get (GstPad * pad)
{
- GstGnomeVFSSrc *src;
- GnomeVFSResult result = 0;
- GstBuffer *buf;
- GnomeVFSFileSize readbytes;
- guint8 *data;
-
- g_return_val_if_fail(pad != NULL, NULL);
- src = GST_GNOMEVFSSRC(gst_pad_get_parent(pad));
- g_return_val_if_fail(GST_FLAG_IS_SET(src, GST_GNOMEVFSSRC_OPEN),
- NULL);
-
- /* deal with EOF state */
- if ((src->curoffset >= src->size) && (src->size != 0))
- {
- gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
-
- /* create the buffer */
- /* FIXME: should eventually use a bufferpool for this */
- buf = gst_buffer_new();
- g_return_val_if_fail(buf, NULL);
-
- audiocast_do_notifications(src);
-
- if (src->iradio_mode && src->icy_metaint > 0) {
- GST_BUFFER_DATA (buf) = g_malloc0 (src->icy_metaint);
- data = GST_BUFFER_DATA (buf);
- g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
-
- GST_BUFFER_SIZE (buf) = 0;
- GST_DEBUG ("doing read: icy_count: %" G_GINT64_FORMAT, src->icy_count);
- result = gnome_vfs_read (src->handle, data,
- src->icy_metaint - src->icy_count,
- &readbytes);
-
- /* EOS? */
- if (readbytes == 0) {
- gst_buffer_unref (buf);
- gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
-
- src->icy_count += readbytes;
- GST_BUFFER_OFFSET (buf) = src->curoffset;
- GST_BUFFER_SIZE (buf) += readbytes;
- data += readbytes;
- src->curoffset += readbytes;
-
- if (src->icy_count == src->icy_metaint) {
- gst_gnomevfssrc_get_icy_metadata (src);
- src->icy_count = 0;
- }
- } else {
- /* allocate the space for the buffer data */
- GST_BUFFER_DATA(buf) = g_malloc(src->bytes_per_read);
- g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL);
-
- if (src->need_flush) {
- GstEvent *event = gst_event_new_flush ();
- src->need_flush = FALSE;
- gst_buffer_unref (buf);
- GST_DEBUG ("gnomevfssrc sending flush");
- return GST_DATA (event);
- }
-
- if (src->new_seek) {
- GstEvent *event;
- gst_buffer_unref (buf);
- GST_DEBUG ("new seek %" G_GINT64_FORMAT, src->curoffset);
- src->new_seek = FALSE;
- GST_DEBUG ("gnomevfssrc sending discont");
- event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL);
- return GST_DATA (event);
- }
-
- result = gnome_vfs_read(src->handle, GST_BUFFER_DATA(buf),
- src->bytes_per_read, &readbytes);
-
- GST_DEBUG ("read: %s, readbytes: %" G_GINT64_FORMAT,
- gnome_vfs_result_to_string(result), readbytes);
- /* deal with EOS */
- if (readbytes == 0)
- {
- gst_buffer_unref(buf);
-
- gst_element_set_eos (GST_ELEMENT (src));
-
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
-
- GST_BUFFER_OFFSET(buf) = src->curoffset;
- GST_BUFFER_SIZE(buf) = readbytes;
- src->curoffset += readbytes;
- }
-
- GST_BUFFER_TIMESTAMP (buf) = -1;
-
- /* we're done, return the buffer */
- return GST_DATA (buf);
+ GstGnomeVFSSrc *src;
+ GnomeVFSResult result = 0;
+ GstBuffer *buf;
+ GnomeVFSFileSize readbytes;
+ guint8 *data;
+
+ g_return_val_if_fail (pad != NULL, NULL);
+ src = GST_GNOMEVFSSRC (gst_pad_get_parent (pad));
+ g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_GNOMEVFSSRC_OPEN), NULL);
+
+ /* deal with EOF state */
+ if ((src->curoffset >= src->size) && (src->size != 0)) {
+ gst_element_set_eos (GST_ELEMENT (src));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ }
+
+ /* create the buffer */
+ /* FIXME: should eventually use a bufferpool for this */
+ buf = gst_buffer_new ();
+ g_return_val_if_fail (buf, NULL);
+
+ audiocast_do_notifications (src);
+
+ if (src->iradio_mode && src->icy_metaint > 0) {
+ GST_BUFFER_DATA (buf) = g_malloc0 (src->icy_metaint);
+ data = GST_BUFFER_DATA (buf);
+ g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
+
+ GST_BUFFER_SIZE (buf) = 0;
+ GST_DEBUG ("doing read: icy_count: %" G_GINT64_FORMAT, src->icy_count);
+ result = gnome_vfs_read (src->handle, data,
+ src->icy_metaint - src->icy_count, &readbytes);
+
+ /* EOS? */
+ if (readbytes == 0) {
+ gst_buffer_unref (buf);
+ gst_element_set_eos (GST_ELEMENT (src));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ }
+
+ src->icy_count += readbytes;
+ GST_BUFFER_OFFSET (buf) = src->curoffset;
+ GST_BUFFER_SIZE (buf) += readbytes;
+ data += readbytes;
+ src->curoffset += readbytes;
+
+ if (src->icy_count == src->icy_metaint) {
+ gst_gnomevfssrc_get_icy_metadata (src);
+ src->icy_count = 0;
+ }
+ } else {
+ /* allocate the space for the buffer data */
+ GST_BUFFER_DATA (buf) = g_malloc (src->bytes_per_read);
+ g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
+
+ if (src->need_flush) {
+ GstEvent *event = gst_event_new_flush ();
+
+ src->need_flush = FALSE;
+ gst_buffer_unref (buf);
+ GST_DEBUG ("gnomevfssrc sending flush");
+ return GST_DATA (event);
+ }
+
+ if (src->new_seek) {
+ GstEvent *event;
+
+ gst_buffer_unref (buf);
+ GST_DEBUG ("new seek %" G_GINT64_FORMAT, src->curoffset);
+ src->new_seek = FALSE;
+ GST_DEBUG ("gnomevfssrc sending discont");
+ event =
+ gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset,
+ NULL);
+ return GST_DATA (event);
+ }
+
+ result = gnome_vfs_read (src->handle, GST_BUFFER_DATA (buf),
+ src->bytes_per_read, &readbytes);
+
+ GST_DEBUG ("read: %s, readbytes: %" G_GINT64_FORMAT,
+ gnome_vfs_result_to_string (result), readbytes);
+ /* deal with EOS */
+ if (readbytes == 0) {
+ gst_buffer_unref (buf);
+
+ gst_element_set_eos (GST_ELEMENT (src));
+
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ }
+
+ GST_BUFFER_OFFSET (buf) = src->curoffset;
+ GST_BUFFER_SIZE (buf) = readbytes;
+ src->curoffset += readbytes;
+ }
+
+ GST_BUFFER_TIMESTAMP (buf) = -1;
+
+ /* we're done, return the buffer */
+ return GST_DATA (buf);
}
/* open the file, do stuff necessary to go to READY state */
-static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src)
+static gboolean
+gst_gnomevfssrc_open_file (GstGnomeVFSSrc * src)
{
- GnomeVFSResult result;
- GnomeVFSFileInfo *info;
-
- g_return_val_if_fail(!GST_FLAG_IS_SET(src, GST_GNOMEVFSSRC_OPEN),
- FALSE);
-
- if (src->filename) {
- /* create the uri */
- src->uri = gnome_vfs_uri_new(src->filename);
- if (!src->uri) {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open vfs file \"%s\" for reading."), src->filename), GST_ERROR_SYSTEM);
- return FALSE;
- }
- }
-
- if (!audiocast_init(src))
- return FALSE;
-
- gst_gnomevfssrc_push_callbacks (src);
-
- if (src->filename)
- result = gnome_vfs_open_uri(&(src->handle), src->uri,
- GNOME_VFS_OPEN_READ);
- else
- result = GNOME_VFS_OK;
- if (result != GNOME_VFS_OK) {
- char *escaped;
-
- gst_gnomevfssrc_pop_callbacks (src);
- audiocast_thread_kill(src);
-
- escaped = gnome_vfs_unescape_string_for_display (src->filename);
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open vfs file \"%s\" for reading."), escaped),
- (gnome_vfs_result_to_string (result)));
- g_free (escaped);
- return FALSE;
- }
+ GnomeVFSResult result;
+ GnomeVFSFileInfo *info;
+
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_GNOMEVFSSRC_OPEN), FALSE);
+
+ if (src->filename) {
+ /* create the uri */
+ src->uri = gnome_vfs_uri_new (src->filename);
+ if (!src->uri) {
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("Could not open vfs file \"%s\" for reading."), src->filename),
+ GST_ERROR_SYSTEM);
+ return FALSE;
+ }
+ }
+
+ if (!audiocast_init (src))
+ return FALSE;
+
+ gst_gnomevfssrc_push_callbacks (src);
+
+ if (src->filename)
+ result = gnome_vfs_open_uri (&(src->handle), src->uri, GNOME_VFS_OPEN_READ);
+ else
+ result = GNOME_VFS_OK;
+ if (result != GNOME_VFS_OK) {
+ char *escaped;
+
+ gst_gnomevfssrc_pop_callbacks (src);
+ audiocast_thread_kill (src);
+
+ escaped = gnome_vfs_unescape_string_for_display (src->filename);
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("Could not open vfs file \"%s\" for reading."), escaped),
+ (gnome_vfs_result_to_string (result)));
+ g_free (escaped);
+ return FALSE;
+ }
+
+ info = gnome_vfs_file_info_new ();
+ if (gnome_vfs_get_file_info_from_handle (src->handle, info,
+ GNOME_VFS_FILE_INFO_DEFAULT)
+ == GNOME_VFS_OK) {
+ if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE)
+ src->size = info->size;
+ } else
+ GST_DEBUG ("getting info failed: %s", gnome_vfs_result_to_string (result));
+
+ gnome_vfs_file_info_unref (info);
+
+ GST_DEBUG ("size %" G_GINT64_FORMAT, src->size);
+
+ audiocast_do_notifications (src);
+
+ GST_DEBUG ("open result: %s", gnome_vfs_result_to_string (result));
+
+ if (gnome_vfs_seek (src->handle, GNOME_VFS_SEEK_CURRENT, 0)
+ == GNOME_VFS_OK) {
+ src->seekable = TRUE;
+ } else {
+ src->seekable = FALSE;
+ }
+
+ GST_FLAG_SET (src, GST_GNOMEVFSSRC_OPEN);
+
+ return TRUE;
+}
- info = gnome_vfs_file_info_new ();
- if (gnome_vfs_get_file_info_from_handle (src->handle, info,
- GNOME_VFS_FILE_INFO_DEFAULT)
- == GNOME_VFS_OK)
- {
- if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE)
- src->size = info->size;
- }
- else
- GST_DEBUG ("getting info failed: %s", gnome_vfs_result_to_string (result));
-
- gnome_vfs_file_info_unref(info);
-
- GST_DEBUG ("size %" G_GINT64_FORMAT, src->size);
-
- audiocast_do_notifications(src);
-
- GST_DEBUG ("open result: %s", gnome_vfs_result_to_string (result));
-
- if(gnome_vfs_seek(src->handle, GNOME_VFS_SEEK_CURRENT, 0)
- == GNOME_VFS_OK) {
- src->seekable = TRUE;
- }else{
- src->seekable = FALSE;
- }
+static void
+gst_gnomevfssrc_close_file (GstGnomeVFSSrc * src)
+{
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_GNOMEVFSSRC_OPEN));
- GST_FLAG_SET(src, GST_GNOMEVFSSRC_OPEN);
+ gst_gnomevfssrc_pop_callbacks (src);
+ audiocast_thread_kill (src);
- return TRUE;
-}
+ if (src->filename) {
+ gnome_vfs_close (src->handle);
-static void gst_gnomevfssrc_close_file(GstGnomeVFSSrc *src)
-{
- g_return_if_fail(GST_FLAG_IS_SET(src, GST_GNOMEVFSSRC_OPEN));
-
- gst_gnomevfssrc_pop_callbacks (src);
- audiocast_thread_kill(src);
-
- if (src->filename) {
- gnome_vfs_close(src->handle);
-
- gnome_vfs_uri_unref(src->uri);
- }
- src->size = 0;
- src->curoffset = 0;
- src->new_seek = FALSE;
+ gnome_vfs_uri_unref (src->uri);
+ }
+ src->size = 0;
+ src->curoffset = 0;
+ src->new_seek = FALSE;
- GST_FLAG_UNSET(src, GST_GNOMEVFSSRC_OPEN);
+ GST_FLAG_UNSET (src, GST_GNOMEVFSSRC_OPEN);
}
-static GstElementStateReturn gst_gnomevfssrc_change_state(GstElement *element)
+static GstElementStateReturn
+gst_gnomevfssrc_change_state (GstElement * element)
{
- g_return_val_if_fail(GST_IS_GNOMEVFSSRC(element),
- GST_STATE_FAILURE);
-
- switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_READY_TO_PAUSED:
- if (!GST_FLAG_IS_SET(element, GST_GNOMEVFSSRC_OPEN)) {
- if (!gst_gnomevfssrc_open_file
- (GST_GNOMEVFSSRC(element)))
- return GST_STATE_FAILURE;
- }
- break;
- case GST_STATE_PAUSED_TO_READY:
- if (GST_FLAG_IS_SET(element, GST_GNOMEVFSSRC_OPEN))
- gst_gnomevfssrc_close_file(GST_GNOMEVFSSRC
- (element));
- break;
- case GST_STATE_NULL_TO_READY:
- case GST_STATE_READY_TO_NULL:
- default:
- break;
- }
-
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->
- change_state(element);
-
- return GST_STATE_SUCCESS;
+ g_return_val_if_fail (GST_IS_GNOMEVFSSRC (element), GST_STATE_FAILURE);
+
+ switch (GST_STATE_TRANSITION (element)) {
+ case GST_STATE_READY_TO_PAUSED:
+ if (!GST_FLAG_IS_SET (element, GST_GNOMEVFSSRC_OPEN)) {
+ if (!gst_gnomevfssrc_open_file (GST_GNOMEVFSSRC (element)))
+ return GST_STATE_FAILURE;
+ }
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ if (GST_FLAG_IS_SET (element, GST_GNOMEVFSSRC_OPEN))
+ gst_gnomevfssrc_close_file (GST_GNOMEVFSSRC (element));
+ break;
+ case GST_STATE_NULL_TO_READY:
+ case GST_STATE_READY_TO_NULL:
+ default:
+ break;
+ }
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+
+ return GST_STATE_SUCCESS;
}
static gboolean
-gst_gnomevfssrc_srcpad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_gnomevfssrc_srcpad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
- GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (gst_pad_get_parent (pad));
-
- switch (type) {
- case GST_QUERY_TOTAL:
- if (*format != GST_FORMAT_BYTES) {
- return FALSE;
- }
- *value = src->size;
- break;
- case GST_QUERY_POSITION:
- switch (*format) {
- case GST_FORMAT_BYTES:
- *value = src->curoffset;
- break;
- case GST_FORMAT_PERCENT:
- if (src->size == 0)
- return FALSE;
- *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->size;
- break;
- default:
- return FALSE;
- }
- break;
+ GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (gst_pad_get_parent (pad));
+
+ switch (type) {
+ case GST_QUERY_TOTAL:
+ if (*format != GST_FORMAT_BYTES) {
+ return FALSE;
+ }
+ *value = src->size;
+ break;
+ case GST_QUERY_POSITION:
+ switch (*format) {
+ case GST_FORMAT_BYTES:
+ *value = src->curoffset;
+ break;
+ case GST_FORMAT_PERCENT:
+ if (src->size == 0)
+ return FALSE;
+ *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->size;
+ break;
default:
- return FALSE;
- break;
- }
- return TRUE;
-}
+ return FALSE;
+ }
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+ return TRUE;
+}
static gboolean
-gst_gnomevfssrc_srcpad_event (GstPad *pad, GstEvent *event)
+gst_gnomevfssrc_srcpad_event (GstPad * pad, GstEvent * event)
{
- GstGnomeVFSSrc *src = GST_GNOMEVFSSRC(GST_PAD_PARENT(pad));
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_SEEK:
- {
- gint64 desired_offset;
- GnomeVFSResult result;
-
- if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_BYTES) {
- gst_event_unref (event);
- return FALSE;
- }
- switch (GST_EVENT_SEEK_METHOD (event)) {
- case GST_SEEK_METHOD_SET:
- desired_offset = (guint64) GST_EVENT_SEEK_OFFSET (event);
- break;
- case GST_SEEK_METHOD_CUR:
- desired_offset = src->curoffset + GST_EVENT_SEEK_OFFSET (event);
- break;
- case GST_SEEK_METHOD_END:
- desired_offset = src->size - ABS (GST_EVENT_SEEK_OFFSET (event));
- break;
- default:
- gst_event_unref (event);
- return FALSE;
- break;
- }
-
- result = gnome_vfs_seek(src->handle,
- GNOME_VFS_SEEK_START, desired_offset);
- GST_DEBUG ("new_seek: %s",
- gnome_vfs_result_to_string(result));
-
- if (result != GNOME_VFS_OK) {
- gst_event_unref (event);
- return FALSE;
- }
- src->curoffset = desired_offset;
- src->new_seek = TRUE;
- src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
- break;
- }
- case GST_EVENT_SIZE:
- if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) {
- gst_event_unref (event);
- return FALSE;
- }
- src->bytes_per_read = GST_EVENT_SIZE_VALUE (event);
- g_object_notify (G_OBJECT (src), "bytesperread");
- break;
-
- case GST_EVENT_FLUSH:
- src->need_flush = TRUE;
- break;
- default:
- gst_event_unref (event);
- return FALSE;
- break;
- }
+ GstGnomeVFSSrc *src = GST_GNOMEVFSSRC (GST_PAD_PARENT (pad));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_SEEK:
+ {
+ gint64 desired_offset;
+ GnomeVFSResult result;
+
+ if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_BYTES) {
gst_event_unref (event);
+ return FALSE;
+ }
+ switch (GST_EVENT_SEEK_METHOD (event)) {
+ case GST_SEEK_METHOD_SET:
+ desired_offset = (guint64) GST_EVENT_SEEK_OFFSET (event);
+ break;
+ case GST_SEEK_METHOD_CUR:
+ desired_offset = src->curoffset + GST_EVENT_SEEK_OFFSET (event);
+ break;
+ case GST_SEEK_METHOD_END:
+ desired_offset = src->size - ABS (GST_EVENT_SEEK_OFFSET (event));
+ break;
+ default:
+ gst_event_unref (event);
+ return FALSE;
+ break;
+ }
+
+ result = gnome_vfs_seek (src->handle,
+ GNOME_VFS_SEEK_START, desired_offset);
+ GST_DEBUG ("new_seek: %s", gnome_vfs_result_to_string (result));
- return TRUE;
+ if (result != GNOME_VFS_OK) {
+ gst_event_unref (event);
+ return FALSE;
+ }
+ src->curoffset = desired_offset;
+ src->new_seek = TRUE;
+ src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
+ break;
+ }
+ case GST_EVENT_SIZE:
+ if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) {
+ gst_event_unref (event);
+ return FALSE;
+ }
+ src->bytes_per_read = GST_EVENT_SIZE_VALUE (event);
+ g_object_notify (G_OBJECT (src), "bytesperread");
+ break;
+
+ case GST_EVENT_FLUSH:
+ src->need_flush = TRUE;
+ break;
+ default:
+ gst_event_unref (event);
+ return FALSE;
+ break;
+ }
+ gst_event_unref (event);
+
+ return TRUE;
}
#include <ogg/ogg.h>
/* memcpy - if someone knows a way to get rid of it, please speak up
* note: the ogg docs even say you ned this... */
-#include <string.h>
+#include <string.h>
GST_DEBUG_CATEGORY_STATIC (gst_ogg_demux_debug);
#define GST_CAT_DEFAULT gst_ogg_demux_debug
-#define GST_TYPE_OGG_DEMUX (gst_ogg_demux_get_type())
+#define GST_TYPE_OGG_DEMUX (gst_ogg_demux_get_type())
#define GST_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_DEMUX, GstOggDemux))
#define GST_OGG_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_DEMUX, GstOggDemux))
#define GST_IS_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_DEMUX))
typedef struct _GstOggDemux GstOggDemux;
typedef struct _GstOggDemuxClass GstOggDemuxClass;
-typedef enum {
+typedef enum
+{
/* just because you shouldn't make a valid enum value 0 */
GST_OGG_STATE_INAVLID,
/* just started, we need to decide if we should do setup */
} GstOggState;
/* all information needed for one ogg stream */
-typedef struct {
- GstPad * pad; /* reference for this pad is held by element we belong to */
-
- gint serial;
- ogg_stream_state stream;
- guint64 offset; /* end offset of last buffer */
- guint64 known_offset; /* last known offset */
- gint64 packetno; /* number of next expected packet */
-
- guint64 length; /* length of stream or 0 */
- glong pages; /* number of pages in stream or 0 */
-
- guint flags;
+typedef struct
+{
+ GstPad *pad; /* reference for this pad is held by element we belong to */
+
+ gint serial;
+ ogg_stream_state stream;
+ guint64 offset; /* end offset of last buffer */
+ guint64 known_offset; /* last known offset */
+ gint64 packetno; /* number of next expected packet */
+
+ guint64 length; /* length of stream or 0 */
+ glong pages; /* number of pages in stream or 0 */
+
+ guint flags;
} GstOggPad;
-typedef enum {
- GST_OGG_PAD_NEEDS_DISCONT = (1 << 0),
- GST_OGG_PAD_NEEDS_FLUSH = (1 << 1)
+typedef enum
+{
+ GST_OGG_PAD_NEEDS_DISCONT = (1 << 0),
+ GST_OGG_PAD_NEEDS_FLUSH = (1 << 1)
}
GstOggPadFlags;
/* all information needed for one ogg chain (relevant for chained bitstreams) */
-typedef struct {
- GSList * pads; /* list of GstOggPad */
+typedef struct
+{
+ GSList *pads; /* list of GstOggPad */
} GstOggChain;
+
#define CURRENT_CHAIN(ogg) (&g_array_index ((ogg)->chains, GstOggChain, (ogg)->current_chain))
#define FOR_PAD_IN_CURRENT_CHAIN(ogg, _pad, ...) G_STMT_START{ \
GSList *_walk; \
} \
}G_STMT_END
-typedef enum {
+typedef enum
+{
GST_OGG_FLAG_BOS = GST_ELEMENT_FLAG_LAST,
GST_OGG_FLAG_EOS,
GST_OGG_FLAG_WAIT_FOR_DISCONT
} GstOggFlag;
-struct _GstOggDemux {
- GstElement element;
+struct _GstOggDemux
+{
+ GstElement element;
/* pad */
- GstPad * sinkpad;
-
+ GstPad *sinkpad;
+
/* state */
- GstOggState state;
- GArray * chains;
- gint current_chain;
- guint flags;
-
+ GstOggState state;
+ GArray *chains;
+ gint current_chain;
+ guint flags;
+
/* ogg stuff */
- ogg_sync_state sync;
-
+ ogg_sync_state sync;
+
/* seeking */
- GstOggPad * seek_pad;
- guint64 seek_to;
+ GstOggPad *seek_pad;
+ guint64 seek_to;
};
-struct _GstOggDemuxClass {
+struct _GstOggDemuxClass
+{
GstElementClass parent_class;
};
/* elementfactory information */
-static GstElementDetails gst_ogg_demux_details = GST_ELEMENT_DETAILS (
- "ogg demuxer",
- "Codec/Demuxer",
- "demux ogg streams (info about ogg: http://xiph.org)",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
+static GstElementDetails gst_ogg_demux_details =
+GST_ELEMENT_DETAILS ("ogg demuxer",
+ "Codec/Demuxer",
+ "demux ogg streams (info about ogg: http://xiph.org)",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
/* signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
static GstStaticPadTemplate ogg_demux_src_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_SOMETIMES,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_SOMETIMES,
+ GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate ogg_demux_sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/ogg")
-);
-
-
-static void gst_ogg_demux_finalize (GObject * object);
-
-static gboolean gst_ogg_demux_src_event (GstPad * pad,
- GstEvent * event);
-static const GstEventMask* gst_ogg_demux_get_event_masks (GstPad * pad);
-static const GstQueryType* gst_ogg_demux_get_query_types (GstPad * pad);
-
-static gboolean gst_ogg_demux_src_query (GstPad * pad,
- GstQueryType type,
- GstFormat * format,
- gint64 * value);
-
-static void gst_ogg_demux_chain (GstPad * pad,
- GstData * buffer);
-
-static GstElementStateReturn gst_ogg_demux_change_state (GstElement * element);
-
-static GstOggPad * gst_ogg_pad_new (GstOggDemux * ogg,
- int serial_no);
-static void gst_ogg_pad_remove (GstOggDemux * ogg,
- GstOggPad * ogg_pad);
-static void gst_ogg_pad_reset (GstOggDemux * ogg,
- GstOggPad * pad);
-static void gst_ogg_demux_push (GstOggDemux * ogg,
- ogg_page * page);
-static void gst_ogg_pad_push (GstOggDemux * ogg,
- GstOggPad * ogg_pad);
-
-static GstCaps * gst_ogg_type_find (ogg_packet * packet);
-
-static void gst_ogg_print (GstOggDemux * demux);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("application/ogg")
+ );
+
+
+static void gst_ogg_demux_finalize (GObject * object);
+
+static gboolean gst_ogg_demux_src_event (GstPad * pad, GstEvent * event);
+static const GstEventMask *gst_ogg_demux_get_event_masks (GstPad * pad);
+static const GstQueryType *gst_ogg_demux_get_query_types (GstPad * pad);
+
+static gboolean gst_ogg_demux_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
+
+static void gst_ogg_demux_chain (GstPad * pad, GstData * buffer);
+
+static GstElementStateReturn gst_ogg_demux_change_state (GstElement * element);
+
+static GstOggPad *gst_ogg_pad_new (GstOggDemux * ogg, int serial_no);
+static void gst_ogg_pad_remove (GstOggDemux * ogg, GstOggPad * ogg_pad);
+static void gst_ogg_pad_reset (GstOggDemux * ogg, GstOggPad * pad);
+static void gst_ogg_demux_push (GstOggDemux * ogg, ogg_page * page);
+static void gst_ogg_pad_push (GstOggDemux * ogg, GstOggPad * ogg_pad);
+
+static GstCaps *gst_ogg_type_find (ogg_packet * packet);
+
+static void gst_ogg_print (GstOggDemux * demux);
#define GST_OGG_SET_STATE(ogg, new_state) G_STMT_START{ \
GST_DEBUG_OBJECT (ogg, "setting state to %s", G_STRINGIFY (new_state)); \
ogg->state = new_state; \
}G_STMT_END
-
+
GST_BOILERPLATE (GstOggDemux, gst_ogg_demux, GstElement, GST_TYPE_ELEMENT)
-static void
-gst_ogg_demux_base_init (gpointer g_class)
+ static void gst_ogg_demux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &gst_ogg_demux_details);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&ogg_demux_src_template_factory));
}
static void
-gst_ogg_demux_class_init (GstOggDemuxClass *klass)
+gst_ogg_demux_class_init (GstOggDemuxClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
+
gstelement_class->change_state = gst_ogg_demux_change_state;
gobject_class->finalize = gst_ogg_demux_finalize;
}
static void
-gst_ogg_demux_init (GstOggDemux *ogg)
+gst_ogg_demux_init (GstOggDemux * ogg)
{
/* create the sink pad */
- ogg->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&ogg_demux_sink_template_factory), "sink");
+ ogg->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&ogg_demux_sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (ogg), ogg->sinkpad);
- gst_pad_set_chain_function (ogg->sinkpad, GST_DEBUG_FUNCPTR (gst_ogg_demux_chain));
+ gst_pad_set_chain_function (ogg->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_ogg_demux_chain));
/* initalize variables */
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_START);
ogg->chains = g_array_new (TRUE, TRUE, sizeof (GstOggChain));
ogg->current_chain = -1;
-
+
GST_FLAG_SET (ogg, GST_ELEMENT_EVENT_AWARE);
}
static void
-gst_ogg_demux_finalize (GObject *object)
+gst_ogg_demux_finalize (GObject * object)
{
GstOggDemux *ogg;
g_array_free (ogg->chains, TRUE);
}
-static const GstEventMask*
-gst_ogg_demux_get_event_masks (GstPad *pad)
+static const GstEventMask *
+gst_ogg_demux_get_event_masks (GstPad * pad)
{
static const GstEventMask gst_ogg_demux_src_event_masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH },
- { 0, }
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
+ {0,}
};
return gst_ogg_demux_src_event_masks;
}
-static const GstQueryType*
-gst_ogg_demux_get_query_types (GstPad *pad)
+static const GstQueryType *
+gst_ogg_demux_get_query_types (GstPad * pad)
{
static const GstQueryType gst_ogg_demux_src_query_types[] = {
GST_QUERY_TOTAL,
}
static GstOggPad *
-gst_ogg_get_pad_by_pad (GstOggDemux *ogg, GstPad *pad)
+gst_ogg_get_pad_by_pad (GstOggDemux * ogg, GstPad * pad)
{
GSList *walk;
GstOggPad *cur;
-
+
if (ogg->current_chain == -1) {
GST_DEBUG_OBJECT (ogg, "no active chain, returning NULL");
return NULL;
}
static gboolean
-gst_ogg_demux_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_ogg_demux_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = FALSE;
GstOggDemux *ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
return FALSE;
switch (type) {
- case GST_QUERY_TOTAL: {
+ case GST_QUERY_TOTAL:{
if (*format == GST_FORMAT_DEFAULT) {
*value = cur->length;
res = TRUE;
* really slow.
*/
static gboolean
-gst_ogg_demux_src_event (GstPad *pad, GstEvent *event)
+gst_ogg_demux_src_event (GstPad * pad, GstEvent * event)
{
GstOggDemux *ogg;
GstOggPad *cur;
cur = gst_ogg_get_pad_by_pad (ogg, pad);
/* FIXME: optimize this so events from inactive chains work?
* in theory there shouldn't be an exisiting pad for inactive chains */
- if (cur == NULL) goto error;
-
+ if (cur == NULL)
+ goto error;
+
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
{
gint64 offset;
+
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_DEFAULT)
goto error;
offset = GST_EVENT_SEEK_OFFSET (event);
goto error;
}
if (offset < cur->known_offset) {
- GstEvent *restart = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET | GST_EVENT_SEEK_FLAGS (event), 0);
+ GstEvent *restart =
+ gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET |
+ GST_EVENT_SEEK_FLAGS (event), 0);
if (!gst_pad_send_event (GST_PAD_PEER (ogg->sinkpad), restart))
goto error;
} else {
- FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
- if (GST_PAD_IS_USABLE (pad->pad))
- gst_pad_push (pad->pad, GST_DATA (gst_event_new (GST_EVENT_FLUSH)));
- );
+ FOR_PAD_IN_CURRENT_CHAIN (ogg, pad, if (GST_PAD_IS_USABLE (pad->pad))
+ gst_pad_push (pad->pad,
+ GST_DATA (gst_event_new (GST_EVENT_FLUSH))););
}
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_SEEK);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
- pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;
- );
- GST_DEBUG_OBJECT (ogg, "initiating seeking to offset %"G_GUINT64_FORMAT, offset);
- ogg->seek_pad = cur;
+ pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;);
+ GST_DEBUG_OBJECT (ogg, "initiating seeking to offset %" G_GUINT64_FORMAT,
+ offset);
+ ogg->seek_pad = cur;
ogg->seek_to = offset;
gst_event_unref (event);
return TRUE;
}
g_assert_not_reached ();
-
+
error:
gst_event_unref (event);
return FALSE;
}
static void
-gst_ogg_start_playing (GstOggDemux *ogg)
+gst_ogg_start_playing (GstOggDemux * ogg)
{
GST_DEBUG_OBJECT (ogg, "got EOS in setup, changing to playback now");
if (!gst_pad_send_event (GST_PAD_PEER (ogg->sinkpad),
- gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, 0))) {
- GST_ELEMENT_ERROR (ogg, CORE, SEEK, (NULL),
+ gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, 0))) {
+ GST_ELEMENT_ERROR (ogg, CORE, SEEK, (NULL),
("cannot seek to start after EOS"));
}
ogg->current_chain = 0;
}
static void
-gst_ogg_demux_handle_event (GstPad *pad, GstEvent *event)
+gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event)
{
GstOggDemux *ogg = GST_OGG_DEMUX (gst_pad_get_parent (pad));
-
+
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG_OBJECT (ogg, "got a discont event");
gst_event_unref (event);
GST_FLAG_UNSET (ogg, GST_OGG_FLAG_WAIT_FOR_DISCONT);
FOR_PAD_IN_CURRENT_CHAIN (ogg, pad,
- pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;
- );
+ pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;);
break;
case GST_EVENT_EOS:
if (ogg->state == GST_OGG_STATE_SETUP) {
} else {
guint i;
GSList *walk;
+
GST_DEBUG_OBJECT (ogg, "got EOS");
ogg->current_chain = -1;
for (i = 0; i < ogg->chains->len; i++) {
GstOggChain *chain = &g_array_index (ogg->chains, GstOggChain, i);
+
for (walk = chain->pads; walk; walk = g_slist_next (walk)) {
GstOggPad *pad = (GstOggPad *) walk->data;
+
if (pad->pad && GST_PAD_IS_USABLE (pad->pad)) {
- gst_data_ref (GST_DATA (event));
+ gst_data_ref (GST_DATA (event));
gst_pad_push (pad->pad, GST_DATA (event));
- }
+ }
}
}
gst_element_set_eos (GST_ELEMENT (ogg));
/* get the pad with the given serial in the current stream or NULL if none */
static GstOggPad *
-gst_ogg_pad_get_in_current_chain (GstOggDemux *ogg, int serial)
+gst_ogg_pad_get_in_current_chain (GstOggDemux * ogg, int serial)
{
GSList *walk;
-
- if (ogg->current_chain == -1) return NULL;
+
+ if (ogg->current_chain == -1)
+ return NULL;
g_return_val_if_fail (ogg->current_chain < ogg->chains->len, NULL);
for (walk = CURRENT_CHAIN (ogg)->pads; walk; walk = g_slist_next (walk)) {
GstOggPad *pad = (GstOggPad *) walk->data;
+
if (pad->serial == serial)
return pad;
}
}
static void
-gst_ogg_add_chain (GstOggDemux *ogg)
+gst_ogg_add_chain (GstOggDemux * ogg)
{
GST_LOG_OBJECT (ogg, "adding chain %u", ogg->chains->len);
ogg->current_chain = ogg->chains->len;
}
static void
-gst_ogg_demux_chain (GstPad *pad, GstData *buffer)
+gst_ogg_demux_chain (GstPad * pad, GstData * buffer)
{
GstOggDemux *ogg;
guint8 *data;
if (GST_FLAG_IS_SET (ogg, GST_OGG_FLAG_WAIT_FOR_DISCONT)) {
GST_LOG_OBJECT (ogg, "waiting for discont event, discarding buffer");
gst_data_unref (buffer);
- return;
+ return;
}
- GST_LOG_OBJECT (ogg, "queueing buffer %p with offset %llu", buffer, GST_BUFFER_OFFSET (buffer));
- data = (guint8 *) ogg_sync_buffer(&ogg->sync, GST_BUFFER_SIZE (buffer));
+ GST_LOG_OBJECT (ogg, "queueing buffer %p with offset %llu", buffer,
+ GST_BUFFER_OFFSET (buffer));
+ data = (guint8 *) ogg_sync_buffer (&ogg->sync, GST_BUFFER_SIZE (buffer));
memcpy (data, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
if (ogg_sync_wrote (&ogg->sync, GST_BUFFER_SIZE (buffer)) != 0) {
gst_data_unref (buffer);
- GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL), ("ogg_sync_wrote failed"));
+ GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL),
+ ("ogg_sync_wrote failed"));
return;
}
offset_end = GST_BUFFER_OFFSET_IS_VALID (buffer) ?
- GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) :
- (guint64) -1;
+ GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) : (guint64) - 1;
gst_data_unref (buffer);
while (pageout_ret != 0) {
ogg_page page;
-
+
pageout_ret = ogg_sync_pageout (&ogg->sync, &page);
switch (pageout_ret) {
case -1:
if (ogg->state == GST_OGG_STATE_SETUP) {
guint64 length;
GstFormat format = GST_FORMAT_BYTES;
- if (!gst_pad_query (GST_PAD_PEER (ogg->sinkpad), GST_QUERY_TOTAL, &format, &length))
+
+ if (!gst_pad_query (GST_PAD_PEER (ogg->sinkpad), GST_QUERY_TOTAL,
+ &format, &length))
length = 0;
if (length <= offset_end) {
gst_ogg_start_playing (ogg);
}
break;
case 1:
- GST_LOG_OBJECT (ogg, "processing ogg page (serial %d, packet %ld, granule pos %llu",
- ogg_page_serialno (&page), ogg_page_pageno (&page), ogg_page_granulepos (&page));
+ GST_LOG_OBJECT (ogg,
+ "processing ogg page (serial %d, packet %ld, granule pos %llu",
+ ogg_page_serialno (&page), ogg_page_pageno (&page),
+ ogg_page_granulepos (&page));
switch (ogg->state) {
case GST_OGG_STATE_SETUP:
if (ogg_page_eos (&page)) {
- GstOggPad *cur = gst_ogg_pad_get_in_current_chain (ogg, ogg_page_serialno (&page));
+ GstOggPad *cur = gst_ogg_pad_get_in_current_chain (ogg,
+ ogg_page_serialno (&page));
+
GST_FLAG_SET (ogg, GST_OGG_FLAG_EOS);
if (!cur) {
- GST_ERROR_OBJECT (ogg, "unknown serial %d", ogg_page_serialno (&page));
+ GST_ERROR_OBJECT (ogg, "unknown serial %d",
+ ogg_page_serialno (&page));
} else {
cur->pages = ogg_page_pageno (&page);
cur->length = ogg_page_granulepos (&page);
}
} else {
- if (GST_FLAG_IS_SET (ogg, GST_OGG_FLAG_EOS) && ogg_page_bos (&page)) {
+ if (GST_FLAG_IS_SET (ogg, GST_OGG_FLAG_EOS)
+ && ogg_page_bos (&page)) {
gst_ogg_add_chain (ogg);
}
GST_FLAG_UNSET (ogg, GST_OGG_FLAG_EOS);
}
if (ogg_page_bos (&page)) {
- if (gst_ogg_pad_get_in_current_chain (ogg, ogg_page_serialno (&page))) {
- GST_ERROR_OBJECT (ogg, "multiple BOS page for serial %d (page %ld)",
+ if (gst_ogg_pad_get_in_current_chain (ogg,
+ ogg_page_serialno (&page))) {
+ GST_ERROR_OBJECT (ogg,
+ "multiple BOS page for serial %d (page %ld)",
ogg_page_serialno (&page), ogg_page_pageno (&page));
} else {
- GstOggPad *pad = gst_ogg_pad_new (ogg, ogg_page_serialno (&page));
- CURRENT_CHAIN (ogg)->pads = g_slist_prepend (CURRENT_CHAIN (ogg)->pads, pad);
+ GstOggPad *pad =
+ gst_ogg_pad_new (ogg, ogg_page_serialno (&page));
+ CURRENT_CHAIN (ogg)->pads =
+ g_slist_prepend (CURRENT_CHAIN (ogg)->pads, pad);
}
GST_FLAG_SET (ogg, GST_OGG_FLAG_BOS);
} else {
break;
case GST_OGG_STATE_START:
if (gst_pad_send_event (GST_PAD_PEER (ogg->sinkpad),
- gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END, 0))) {
+ gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END,
+ 0))) {
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_SETUP);
GST_DEBUG_OBJECT (ogg, "stream can seek, try setup now");
if (!gst_pad_send_event (GST_PAD_PEER (ogg->sinkpad),
- gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, 0))) {
- GST_ELEMENT_ERROR (ogg, CORE, SEEK, (NULL),
+ gst_event_new_seek (GST_FORMAT_BYTES |
+ GST_SEEK_METHOD_SET, 0))) {
+ GST_ELEMENT_ERROR (ogg, CORE, SEEK, (NULL),
("stream can seek to end, but not to start. Can't handle that."));
}
gst_ogg_add_chain (ogg);
}
break;
default:
- GST_WARNING_OBJECT (ogg, "unknown return value %d from ogg_sync_pageout", pageout_ret);
+ GST_WARNING_OBJECT (ogg,
+ "unknown return value %d from ogg_sync_pageout", pageout_ret);
pageout_ret = 0;
break;
}
return;
}
static GstOggPad *
-gst_ogg_pad_new (GstOggDemux *ogg, int serial)
+gst_ogg_pad_new (GstOggDemux * ogg, int serial)
{
GstOggPad *ret = g_new0 (GstOggPad, 1);
GstTagList *list = gst_tag_list_new ();
ret->serial = serial;
if (ogg_stream_init (&ret->stream, serial) != 0) {
- GST_ERROR_OBJECT (ogg, "Could not initialize ogg_stream struct for serial %d.", serial);
+ GST_ERROR_OBJECT (ogg,
+ "Could not initialize ogg_stream struct for serial %d.", serial);
g_free (ret);
return NULL;
}
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_SERIAL, serial, NULL);
gst_element_found_tags (GST_ELEMENT (ogg), list);
- GST_LOG_OBJECT (ogg, "created new ogg src %p for stream with serial %d", ret, serial);
+ GST_LOG_OBJECT (ogg, "created new ogg src %p for stream with serial %d", ret,
+ serial);
return ret;
}
static void
-gst_ogg_pad_remove (GstOggDemux *ogg, GstOggPad *pad)
+gst_ogg_pad_remove (GstOggDemux * ogg, GstOggPad * pad)
{
if (pad->pad) {
/* FIXME:
* we do it in the EOS signal already - EOS handling needs to be better thought out.
* Correct way would be pushing EOS on eos page, but scheduler doesn't like that
- if (GST_PAD_IS_USEABLE (pad->pad))
- gst_pad_push (pad->pad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- */
+ if (GST_PAD_IS_USEABLE (pad->pad))
+ gst_pad_push (pad->pad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ */
gst_element_remove_pad (GST_ELEMENT (ogg), pad->pad);
}
if (ogg_stream_clear (&pad->stream) != 0)
- GST_ERROR_OBJECT (ogg, "ogg_stream_clear (serial %d) did not return 0, ignoring this error", pad->serial);
- GST_LOG_OBJECT (ogg, "free ogg src %p for stream with serial %d", pad, pad->serial);
+ GST_ERROR_OBJECT (ogg,
+ "ogg_stream_clear (serial %d) did not return 0, ignoring this error",
+ pad->serial);
+ GST_LOG_OBJECT (ogg, "free ogg src %p for stream with serial %d", pad,
+ pad->serial);
g_free (pad);
}
static void
-gst_ogg_demux_push (GstOggDemux *ogg, ogg_page* page)
+gst_ogg_demux_push (GstOggDemux * ogg, ogg_page * page)
{
GSList *walk;
GstOggPad *cur;
/* now we either have a stream (cur) or not */
if (ogg_page_bos (page)) {
if (cur) {
- GST_DEBUG_OBJECT (ogg, "ogg page declared as BOS while stream %d already existed."
+ GST_DEBUG_OBJECT (ogg,
+ "ogg page declared as BOS while stream %d already existed."
"Possibly a seek happened.", cur->serial);
} else if (cur) {
- GST_DEBUG_OBJECT (ogg, "reactivating deactivated stream %d.", cur->serial);
+ GST_DEBUG_OBJECT (ogg, "reactivating deactivated stream %d.",
+ cur->serial);
} else {
/* FIXME: monitor if we are still in creation stage? */
cur = gst_ogg_pad_new (ogg, ogg_page_serialno (page));
if (!cur) {
- GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL), ("Creating ogg_stream struct failed."));
+ GST_ELEMENT_ERROR (ogg, LIBRARY, TOO_LAZY, (NULL),
+ ("Creating ogg_stream struct failed."));
return;
}
if (ogg->current_chain == -1) {
/* add new one at the end */
gst_ogg_add_chain (ogg);
}
- CURRENT_CHAIN (ogg)->pads = g_slist_prepend (CURRENT_CHAIN (ogg)->pads, cur);
+ CURRENT_CHAIN (ogg)->pads =
+ g_slist_prepend (CURRENT_CHAIN (ogg)->pads, cur);
}
}
if (cur == NULL) {
- GST_ELEMENT_ERROR (ogg, STREAM, DECODE, (NULL), ("invalid ogg stream serial no"));
+ GST_ELEMENT_ERROR (ogg, STREAM, DECODE, (NULL),
+ ("invalid ogg stream serial no"));
return;
}
if (ogg_stream_pagein (&cur->stream, page) != 0) {
- GST_WARNING_OBJECT (ogg, "ogg stream choked on page (serial %d), resetting stream", cur->serial);
+ GST_WARNING_OBJECT (ogg,
+ "ogg stream choked on page (serial %d), resetting stream", cur->serial);
gst_ogg_pad_reset (ogg, cur);
return;
}
switch (ogg->state) {
case GST_OGG_STATE_SEEK:
- GST_LOG_OBJECT (ogg, "in seek - offset now: %"G_GUINT64_FORMAT" (pad %d) - desired offset %"
- G_GUINT64_FORMAT" (pad %d)", cur->known_offset, cur->serial,
- ogg->seek_to, ogg->seek_pad->serial);
+ GST_LOG_OBJECT (ogg,
+ "in seek - offset now: %" G_GUINT64_FORMAT
+ " (pad %d) - desired offset %" G_GUINT64_FORMAT " (pad %d)",
+ cur->known_offset, cur->serial, ogg->seek_to, ogg->seek_pad->serial);
if (cur == ogg->seek_pad) {
if (ogg_page_granulepos (page) > ogg->seek_to) {
GST_OGG_SET_STATE (ogg, GST_OGG_STATE_PLAY);
- GST_DEBUG_OBJECT (ogg, "ended seek at offset %"G_GUINT64_FORMAT" (requested %"G_GUINT64_FORMAT, cur->known_offset, ogg->seek_to);
+ GST_DEBUG_OBJECT (ogg,
+ "ended seek at offset %" G_GUINT64_FORMAT " (requested %"
+ G_GUINT64_FORMAT, cur->known_offset, ogg->seek_to);
ogg->seek_pad = NULL;
ogg->seek_to = 0;
}
GST_DEBUG_OBJECT (ogg, "got EOS for stream with serial %d, sending EOS now",
cur->serial);
#if 0
- /* Removing pads while PLAYING doesn't work with current schedulers */
- /* remove from list, as this will never be called again */
+ /* Removing pads while PLAYING doesn't work with current schedulers */
+ /* remove from list, as this will never be called again */
gst_ogg_pad_remove (ogg, cur);
- /* this is also not possible because sending EOS this way confuses the scheduler */
+ /* this is also not possible because sending EOS this way confuses the scheduler */
gst_pad_push (cur->pad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
#else
#endif
}
}
static void
-gst_ogg_pad_push (GstOggDemux *ogg, GstOggPad *pad)
+gst_ogg_pad_push (GstOggDemux * ogg, GstOggPad * pad)
{
ogg_packet packet;
int ret;
case -1:
gst_ogg_pad_reset (ogg, pad);
break;
- case 1: {
+ case 1:{
/* only push data when playing, not during seek or similar */
if (ogg->state != GST_OGG_STATE_PLAY)
continue;
if (!pad->pad) {
GstCaps *caps = gst_ogg_type_find (&packet);
gchar *name = g_strdup_printf ("serial_%d", pad->serial);
-
+
if (caps == NULL) {
- GST_WARNING_OBJECT (ogg, "couldn't find caps for stream with serial %d", pad->serial);
+ GST_WARNING_OBJECT (ogg,
+ "couldn't find caps for stream with serial %d", pad->serial);
caps = gst_caps_new_simple ("application/octet-stream", NULL);
}
- pad->pad = gst_pad_new_from_template (
- gst_static_pad_template_get (&ogg_demux_src_template_factory),
- name);
+ pad->pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&ogg_demux_src_template_factory), name);
g_free (name);
- gst_pad_set_event_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_src_event));
- gst_pad_set_event_mask_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_get_event_masks));
- gst_pad_set_query_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_src_query));
- gst_pad_set_query_type_function (pad->pad, GST_DEBUG_FUNCPTR (gst_ogg_demux_get_query_types));
+ gst_pad_set_event_function (pad->pad,
+ GST_DEBUG_FUNCPTR (gst_ogg_demux_src_event));
+ gst_pad_set_event_mask_function (pad->pad,
+ GST_DEBUG_FUNCPTR (gst_ogg_demux_get_event_masks));
+ gst_pad_set_query_function (pad->pad,
+ GST_DEBUG_FUNCPTR (gst_ogg_demux_src_query));
+ gst_pad_set_query_type_function (pad->pad,
+ GST_DEBUG_FUNCPTR (gst_ogg_demux_get_query_types));
gst_pad_use_explicit_caps (pad->pad);
gst_pad_set_explicit_caps (pad->pad, caps);
gst_pad_set_active (pad->pad, TRUE);
pad->packetno = packet.packetno + 1;
}
/* send discont if needed */
- if ((pad->flags & GST_OGG_PAD_NEEDS_DISCONT) && GST_PAD_IS_USABLE (pad->pad)) {
- GstEvent *event = gst_event_new_discontinuous (FALSE,
- GST_FORMAT_DEFAULT, pad->known_offset); /* FIXME: this might be wrong because we can only use the last known offset */
+ if ((pad->flags & GST_OGG_PAD_NEEDS_DISCONT)
+ && GST_PAD_IS_USABLE (pad->pad)) {
+ GstEvent *event = gst_event_new_discontinuous (FALSE,
+ GST_FORMAT_DEFAULT, pad->known_offset); /* FIXME: this might be wrong because we can only use the last known offset */
+
gst_pad_push (pad->pad, GST_DATA (event));
pad->flags &= (~GST_OGG_PAD_NEEDS_DISCONT);
};
/* optimization: use a bufferpool containing the ogg packet? */
- buf = gst_pad_alloc_buffer (pad->pad, GST_BUFFER_OFFSET_NONE, packet.bytes);
+ buf =
+ gst_pad_alloc_buffer (pad->pad, GST_BUFFER_OFFSET_NONE,
+ packet.bytes);
memcpy (buf->data, packet.packet, packet.bytes);
if (pad->offset != -1)
GST_BUFFER_OFFSET (buf) = pad->offset;
break;
}
default:
- GST_ERROR_OBJECT (ogg, "invalid return value %d for ogg_stream_packetout, resetting stream", ret);
+ GST_ERROR_OBJECT (ogg,
+ "invalid return value %d for ogg_stream_packetout, resetting stream",
+ ret);
gst_ogg_pad_reset (ogg, pad);
break;
}
}
}
static void
-gst_ogg_pad_reset (GstOggDemux *ogg, GstOggPad *pad)
+gst_ogg_pad_reset (GstOggDemux * ogg, GstOggPad * pad)
{
ogg_stream_reset (&pad->stream);
pad->offset = GST_BUFFER_OFFSET_NONE;
}
static void
-gst_ogg_chains_clear (GstOggDemux *ogg)
+gst_ogg_chains_clear (GstOggDemux * ogg)
{
gint i;
GSList *walk;
-
+
for (i = ogg->chains->len - 1; i >= 0; i--) {
GstOggChain *cur = &g_array_index (ogg->chains, GstOggChain, i);
+
for (walk = cur->pads; walk; walk = g_slist_next (walk)) {
gst_ogg_pad_remove (ogg, (GstOggPad *) walk->data);
}
}
static GstElementStateReturn
-gst_ogg_demux_change_state (GstElement *element)
+gst_ogg_demux_change_state (GstElement * element)
{
GstOggDemux *ogg;
* packet of an ogg stream must identify the stream. Therefore ogg can use a
* simplified approach at typefinding.
*/
-typedef struct {
- ogg_packet * packet;
- guint best_probability;
- GstCaps * caps;
+typedef struct
+{
+ ogg_packet *packet;
+ guint best_probability;
+ GstCaps *caps;
} OggTypeFind;
static guint8 *
ogg_find_peek (gpointer data, gint64 offset, guint size)
{
OggTypeFind *find = (OggTypeFind *) data;
-
+
if (offset + size <= find->packet->bytes) {
return ((guint8 *) find->packet->packet) + offset;
} else {
}
}
static void
-ogg_find_suggest (gpointer data, guint probability, const GstCaps *caps)
+ogg_find_suggest (gpointer data, guint probability, const GstCaps * caps)
{
OggTypeFind *find = (OggTypeFind *) data;
-
+
if (probability > find->best_probability) {
gst_caps_replace (&find->caps, gst_caps_copy (caps));
find->best_probability = probability;
}
}
static GstCaps *
-gst_ogg_type_find (ogg_packet *packet)
+gst_ogg_type_find (ogg_packet * packet)
{
GstTypeFind gst_find;
OggTypeFind find;
GList *walk, *type_list = NULL;
-
+
walk = type_list = gst_type_find_factory_get_list ();
-
+
find.packet = packet;
find.best_probability = 0;
find.caps = NULL;
gst_find.data = &find;
gst_find.peek = ogg_find_peek;
gst_find.suggest = ogg_find_suggest;
-
+
while (walk) {
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data);
-
+
gst_type_find_factory_call_function (factory, &gst_find);
if (find.best_probability >= GST_TYPE_FIND_MAXIMUM)
break;
walk = g_list_next (walk);
}
-
+
if (find.best_probability > 0)
return find.caps;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_debug, "oggdemux", 0, "ogg demuxer");
- return gst_element_register (plugin, "oggdemux", GST_RANK_PRIMARY, GST_TYPE_OGG_DEMUX);
+ return gst_element_register (plugin, "oggdemux", GST_RANK_PRIMARY,
+ GST_TYPE_OGG_DEMUX);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "ogg",
- "ogg stream manipulation (info about ogg: http://xiph.org)",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "ogg",
+ "ogg stream manipulation (info about ogg: http://xiph.org)",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
/* prints all info about the element */
-static void
-gst_ogg_print (GstOggDemux *ogg)
+ static void gst_ogg_print (GstOggDemux * ogg)
{
guint i;
GSList *walk;
-
+
for (i = 0; i < ogg->chains->len; i++) {
GstOggChain *chain = &g_array_index (ogg->chains, GstOggChain, i);
- GST_INFO_OBJECT (ogg, "chain %d (%u streams):", i, g_slist_length (chain->pads));
+
+ GST_INFO_OBJECT (ogg, "chain %d (%u streams):", i,
+ g_slist_length (chain->pads));
for (walk = chain->pads; walk; walk = g_slist_next (walk)) {
GstOggPad *pad = (GstOggPad *) walk->data;
+
GST_INFO_OBJECT (ogg, " stream %d:", pad->serial);
- GST_INFO_OBJECT (ogg, " length %"G_GUINT64_FORMAT, pad->length);
+ GST_INFO_OBJECT (ogg, " length %" G_GUINT64_FORMAT, pad->length);
GST_INFO_OBJECT (ogg, " pages %ld", pad->pages);
}
}
/*#include "SDL_blit.h"*/
static GstElementDetails textoverlay_details = {
- "Text Overlay",
- "Filter/Editor/Video",
- "Adds text strings on top of a video buffer",
- "Gustavo J. A. M. Carneiro <gjc@inescporto.pt>"
+ "Text Overlay",
+ "Filter/Editor/Video",
+ "Adds text strings on top of a video buffer",
+ "Gustavo J. A. M. Carneiro <gjc@inescporto.pt>"
};
-enum {
- ARG_0,
- ARG_TEXT,
- ARG_VALIGN,
- ARG_HALIGN,
- ARG_X0,
- ARG_Y0,
- ARG_FONT_DESC,
+enum
+{
+ ARG_0,
+ ARG_TEXT,
+ ARG_VALIGN,
+ ARG_HALIGN,
+ ARG_X0,
+ ARG_Y0,
+ ARG_FONT_DESC,
};
static GstStaticPadTemplate textoverlay_src_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, "
- "format = (fourcc) I420, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]")
-);
+ "format = (fourcc) I420, "
+ "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
+ );
static GstStaticPadTemplate video_sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "video_sink",
+GST_STATIC_PAD_TEMPLATE ("video_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, "
- "format = (fourcc) I420, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]")
-);
+ "format = (fourcc) I420, "
+ "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
+ );
static GstStaticPadTemplate text_sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "text_sink",
+ GST_STATIC_PAD_TEMPLATE ("text_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("text/x-pango-markup; text/plain")
-);
-
-static void gst_textoverlay_base_init (gpointer g_class);
-static void gst_textoverlay_class_init(GstTextOverlayClass *klass);
-static void gst_textoverlay_init(GstTextOverlay *overlay);
-static void gst_textoverlay_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_textoverlay_get_property(GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstElementStateReturn gst_textoverlay_change_state(GstElement *element);
-static void gst_textoverlay_finalize(GObject *object);
+ );
+
+static void gst_textoverlay_base_init (gpointer g_class);
+static void gst_textoverlay_class_init (GstTextOverlayClass * klass);
+static void gst_textoverlay_init (GstTextOverlay * overlay);
+static void gst_textoverlay_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_textoverlay_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_textoverlay_change_state (GstElement *
+ element);
+static void gst_textoverlay_finalize (GObject * object);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_textoverlay_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_textoverlay_get_type(void)
+gst_textoverlay_get_type (void)
{
- static GType textoverlay_type = 0;
-
- if (!textoverlay_type) {
- static const GTypeInfo textoverlay_info = {
- sizeof(GstTextOverlayClass),
- gst_textoverlay_base_init,
- NULL,
- (GClassInitFunc)gst_textoverlay_class_init,
- NULL,
- NULL,
- sizeof(GstTextOverlay),
- 0,
- (GInstanceInitFunc)gst_textoverlay_init,
- };
- textoverlay_type = g_type_register_static(GST_TYPE_ELEMENT, "GstTextOverlay",
- &textoverlay_info, 0);
- }
- return textoverlay_type;
+ static GType textoverlay_type = 0;
+
+ if (!textoverlay_type) {
+ static const GTypeInfo textoverlay_info = {
+ sizeof (GstTextOverlayClass),
+ gst_textoverlay_base_init,
+ NULL,
+ (GClassInitFunc) gst_textoverlay_class_init,
+ NULL,
+ NULL,
+ sizeof (GstTextOverlay),
+ 0,
+ (GInstanceInitFunc) gst_textoverlay_init,
+ };
+ textoverlay_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstTextOverlay",
+ &textoverlay_info, 0);
+ }
+ return textoverlay_type;
}
static void
gst_textoverlay_base_init (gpointer g_class)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&textoverlay_src_template_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&video_sink_template_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&text_sink_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&textoverlay_src_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&video_sink_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&text_sink_template_factory));
- gst_element_class_set_details (element_class, &textoverlay_details);
+ gst_element_class_set_details (element_class, &textoverlay_details);
}
static void
-gst_textoverlay_class_init(GstTextOverlayClass *klass)
+gst_textoverlay_class_init (GstTextOverlayClass * klass)
{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
-
- parent_class = g_type_class_peek_parent(klass);
-
- gobject_class->finalize = gst_textoverlay_finalize;
- gobject_class->set_property = gst_textoverlay_set_property;
- gobject_class->get_property = gst_textoverlay_get_property;
-
- gstelement_class->change_state = gst_textoverlay_change_state;
- klass->pango_context = pango_ft2_get_context(72, 72);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TEXT,
- g_param_spec_string("text", "text",
- "Text to be display,"
- " in pango markup format.",
- "", G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALIGN,
- g_param_spec_string("valign", "vertical alignment",
- "Vertical alignment of the text. "
- "Can be either 'baseline', 'bottom', or 'top'",
- "baseline", G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HALIGN,
- g_param_spec_string("halign", "horizontal alignment",
- "Horizontal alignment of the text. "
- "Can be either 'left', 'right', or 'center'",
- "center", G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_X0,
- g_param_spec_int("x0", "X position",
- "Initial X position."
- " Horizontal aligment takes this point"
- " as reference.",
- G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_Y0,
- g_param_spec_int("y0", "Y position",
- "Initial Y position."
- " Vertical aligment takes this point"
- " as reference.",
- G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FONT_DESC,
- g_param_spec_string("font-desc", "font description",
- "Pango font description of font "
- "to be used for rendering. "
- "See documentation of "
- "pango_font_description_from_string"
- " for syntax.",
- "", G_PARAM_WRITABLE));
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = gst_textoverlay_finalize;
+ gobject_class->set_property = gst_textoverlay_set_property;
+ gobject_class->get_property = gst_textoverlay_get_property;
+
+ gstelement_class->change_state = gst_textoverlay_change_state;
+ klass->pango_context = pango_ft2_get_context (72, 72);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TEXT,
+ g_param_spec_string ("text", "text",
+ "Text to be display,"
+ " in pango markup format.", "", G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALIGN,
+ g_param_spec_string ("valign", "vertical alignment",
+ "Vertical alignment of the text. "
+ "Can be either 'baseline', 'bottom', or 'top'",
+ "baseline", G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HALIGN,
+ g_param_spec_string ("halign", "horizontal alignment",
+ "Horizontal alignment of the text. "
+ "Can be either 'left', 'right', or 'center'",
+ "center", G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_X0,
+ g_param_spec_int ("x0", "X position",
+ "Initial X position."
+ " Horizontal aligment takes this point"
+ " as reference.", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_Y0,
+ g_param_spec_int ("y0", "Y position",
+ "Initial Y position."
+ " Vertical aligment takes this point"
+ " as reference.", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FONT_DESC,
+ g_param_spec_string ("font-desc", "font description",
+ "Pango font description of font "
+ "to be used for rendering. "
+ "See documentation of "
+ "pango_font_description_from_string"
+ " for syntax.", "", G_PARAM_WRITABLE));
}
static void
-resize_bitmap(GstTextOverlay *overlay, int width, int height)
+resize_bitmap (GstTextOverlay * overlay, int width, int height)
{
- FT_Bitmap *bitmap = &overlay->bitmap;
- int pitch = (width|3) + 1;
- int size = pitch*height;
-
- /* no need to keep reallocating; just keep the maximum size so far */
- if (size <= overlay->bitmap_buffer_size) {
- bitmap->rows = height;
- bitmap->width = width;
- bitmap->pitch = pitch;
- memset(bitmap->buffer, 0, overlay->bitmap_buffer_size);
- return;
- }
- if (!bitmap->buffer) {
- /* initialize */
- bitmap->pixel_mode = ft_pixel_mode_grays;
- bitmap->num_grays = 256;
- }
- if (bitmap->buffer)
- bitmap->buffer = g_realloc(bitmap->buffer, size);
- else
- bitmap->buffer = g_malloc(size);
+ FT_Bitmap *bitmap = &overlay->bitmap;
+ int pitch = (width | 3) + 1;
+ int size = pitch * height;
+
+ /* no need to keep reallocating; just keep the maximum size so far */
+ if (size <= overlay->bitmap_buffer_size) {
bitmap->rows = height;
bitmap->width = width;
bitmap->pitch = pitch;
- memset(bitmap->buffer, 0, size);
- overlay->bitmap_buffer_size = size;
+ memset (bitmap->buffer, 0, overlay->bitmap_buffer_size);
+ return;
+ }
+ if (!bitmap->buffer) {
+ /* initialize */
+ bitmap->pixel_mode = ft_pixel_mode_grays;
+ bitmap->num_grays = 256;
+ }
+ if (bitmap->buffer)
+ bitmap->buffer = g_realloc (bitmap->buffer, size);
+ else
+ bitmap->buffer = g_malloc (size);
+ bitmap->rows = height;
+ bitmap->width = width;
+ bitmap->pitch = pitch;
+ memset (bitmap->buffer, 0, size);
+ overlay->bitmap_buffer_size = size;
}
static void
-render_text(GstTextOverlay *overlay)
+render_text (GstTextOverlay * overlay)
{
- PangoRectangle ink_rect, logical_rect;
+ PangoRectangle ink_rect, logical_rect;
- pango_layout_get_pixel_extents(overlay->layout, &ink_rect, &logical_rect);
- resize_bitmap(overlay, ink_rect.width, ink_rect.height + ink_rect.y);
- pango_ft2_render_layout(&overlay->bitmap, overlay->layout, 0, 0);
- overlay->baseline_y = ink_rect.y;
+ pango_layout_get_pixel_extents (overlay->layout, &ink_rect, &logical_rect);
+ resize_bitmap (overlay, ink_rect.width, ink_rect.height + ink_rect.y);
+ pango_ft2_render_layout (&overlay->bitmap, overlay->layout, 0, 0);
+ overlay->baseline_y = ink_rect.y;
}
/* static GstPadLinkReturn */
static GstPadLinkReturn
-gst_textoverlay_video_sinkconnect(GstPad *pad, const GstCaps *caps)
+gst_textoverlay_video_sinkconnect (GstPad * pad, const GstCaps * caps)
{
- GstTextOverlay *overlay;
- GstStructure *structure;
+ GstTextOverlay *overlay;
+ GstStructure *structure;
- overlay = GST_TEXTOVERLAY(gst_pad_get_parent(pad));
+ overlay = GST_TEXTOVERLAY (gst_pad_get_parent (pad));
- structure = gst_caps_get_structure (caps, 0);
- overlay->width = overlay->height = 0;
- gst_structure_get_int (structure, "width", &overlay->width);
- gst_structure_get_int (structure, "height", &overlay->height);
+ structure = gst_caps_get_structure (caps, 0);
+ overlay->width = overlay->height = 0;
+ gst_structure_get_int (structure, "width", &overlay->width);
+ gst_structure_get_int (structure, "height", &overlay->height);
- return gst_pad_try_set_caps(overlay->srcpad, caps);
+ return gst_pad_try_set_caps (overlay->srcpad, caps);
}
static void
-gst_text_overlay_blit_yuv420(GstTextOverlay *overlay, FT_Bitmap *bitmap,
- guchar *pixbuf, int x0, int y0)
+gst_text_overlay_blit_yuv420 (GstTextOverlay * overlay, FT_Bitmap * bitmap,
+ guchar * pixbuf, int x0, int y0)
{
- int y; /* text bitmap coordinates */
- int x1, y1; /* video buffer coordinates */
- int rowinc, bit_rowinc, uv_rowinc;
- guchar *p, *bitp, *u_p;
- int video_width = overlay->width, video_height = overlay->height;
- int bitmap_x0 = x0 < 1? -(x0 - 1) : 1; /* 1 pixel border */
- int bitmap_y0 = y0 < 1? -(y0 - 1) : 1; /* 1 pixel border */
- int bitmap_width = bitmap->width - bitmap_x0;
- int bitmap_height = bitmap->rows - bitmap_y0;
- int u_plane_size;
- int skip_y, skip_x;
- guchar v;
-
- if (x0 + bitmap_x0 + bitmap_width > video_width - 1) /* 1 pixel border */
- bitmap_width -= x0 + bitmap_x0 + bitmap_width - video_width + 1;
- if (y0 + bitmap_y0 + bitmap_height > video_height - 1) /* 1 pixel border */
- bitmap_height -= y0 + bitmap_y0 + bitmap_height - video_height + 1;
-
- rowinc = video_width - bitmap_width;
- uv_rowinc = video_width / 2 - bitmap_width / 2;
- bit_rowinc = bitmap->pitch - bitmap_width;
- u_plane_size = (video_width / 2)*(video_height / 2);
-
- y1 = y0 + bitmap_y0;
- x1 = x0 + bitmap_x0;
- p = pixbuf + video_width*y1 + x1;
- bitp = bitmap->buffer + bitmap->pitch*bitmap_y0 + bitmap_x0;
- for (y = bitmap_y0; y < bitmap_height; y++){
- int n;
- for(n=bitmap_width; n>0; --n){
- v = *bitp;
- if (v) {
- p[-1] = CLAMP(p[-1] - v, 0, 255);
- p[ 1] = CLAMP(p[ 1] - v, 0, 255);
- p[-video_width] = CLAMP(p[-video_width] - v, 0, 255);
- p[ video_width] = CLAMP(p[ video_width] - v, 0, 255);
- }
- p++;
- bitp++;
+ int y; /* text bitmap coordinates */
+ int x1, y1; /* video buffer coordinates */
+ int rowinc, bit_rowinc, uv_rowinc;
+ guchar *p, *bitp, *u_p;
+ int video_width = overlay->width, video_height = overlay->height;
+ int bitmap_x0 = x0 < 1 ? -(x0 - 1) : 1; /* 1 pixel border */
+ int bitmap_y0 = y0 < 1 ? -(y0 - 1) : 1; /* 1 pixel border */
+ int bitmap_width = bitmap->width - bitmap_x0;
+ int bitmap_height = bitmap->rows - bitmap_y0;
+ int u_plane_size;
+ int skip_y, skip_x;
+ guchar v;
+
+ if (x0 + bitmap_x0 + bitmap_width > video_width - 1) /* 1 pixel border */
+ bitmap_width -= x0 + bitmap_x0 + bitmap_width - video_width + 1;
+ if (y0 + bitmap_y0 + bitmap_height > video_height - 1) /* 1 pixel border */
+ bitmap_height -= y0 + bitmap_y0 + bitmap_height - video_height + 1;
+
+ rowinc = video_width - bitmap_width;
+ uv_rowinc = video_width / 2 - bitmap_width / 2;
+ bit_rowinc = bitmap->pitch - bitmap_width;
+ u_plane_size = (video_width / 2) * (video_height / 2);
+
+ y1 = y0 + bitmap_y0;
+ x1 = x0 + bitmap_x0;
+ p = pixbuf + video_width * y1 + x1;
+ bitp = bitmap->buffer + bitmap->pitch * bitmap_y0 + bitmap_x0;
+ for (y = bitmap_y0; y < bitmap_height; y++) {
+ int n;
+
+ for (n = bitmap_width; n > 0; --n) {
+ v = *bitp;
+ if (v) {
+ p[-1] = CLAMP (p[-1] - v, 0, 255);
+ p[1] = CLAMP (p[1] - v, 0, 255);
+ p[-video_width] = CLAMP (p[-video_width] - v, 0, 255);
+ p[video_width] = CLAMP (p[video_width] - v, 0, 255);
}
- p += rowinc;
- bitp += bit_rowinc;
+ p++;
+ bitp++;
}
+ p += rowinc;
+ bitp += bit_rowinc;
+ }
+
+ y = bitmap_y0;
+ y1 = y0 + bitmap_y0;
+ x1 = x0 + bitmap_x0;
+ bitp = bitmap->buffer + bitmap->pitch * bitmap_y0 + bitmap_x0;
+ p = pixbuf + video_width * y1 + x1;
+ u_p =
+ pixbuf + video_width * video_height + (video_width >> 1) * (y1 >> 1) +
+ (x1 >> 1);
+ skip_y = 0;
+ skip_x = 0;
+
+ for (; y < bitmap_height; y++) {
+ int n;
- y = bitmap_y0;
- y1 = y0 + bitmap_y0;
x1 = x0 + bitmap_x0;
- bitp = bitmap->buffer + bitmap->pitch*bitmap_y0 + bitmap_x0;
- p = pixbuf + video_width*y1 + x1;
- u_p = pixbuf + video_width*video_height + (video_width >> 1)*(y1 >> 1) + (x1 >> 1);
- skip_y = 0;
skip_x = 0;
-
- for ( ; y < bitmap_height; y++){
- int n;
- x1 = x0 + bitmap_x0;
- skip_x = 0;
- for(n = bitmap_width; n>0; --n){
- v = *bitp;
- if (v) {
- *p = v;
- if (!skip_y) {
- u_p[0] = u_p[u_plane_size] = 0x80;
- }
- }
+ for (n = bitmap_width; n > 0; --n) {
+ v = *bitp;
+ if (v) {
+ *p = v;
if (!skip_y) {
- skip_x = !skip_x;
- if (!skip_x) u_p++;
+ u_p[0] = u_p[u_plane_size] = 0x80;
}
- p++;
- bitp++;
}
- /*if (!skip_x && !skip_y) u_p--; */
- p += rowinc;
- bitp += bit_rowinc;
- skip_y = !skip_y;
- u_p += skip_y? uv_rowinc : 0;
+ if (!skip_y) {
+ skip_x = !skip_x;
+ if (!skip_x)
+ u_p++;
+ }
+ p++;
+ bitp++;
}
+ /*if (!skip_x && !skip_y) u_p--; */
+ p += rowinc;
+ bitp += bit_rowinc;
+ skip_y = !skip_y;
+ u_p += skip_y ? uv_rowinc : 0;
+ }
}
static void
-gst_textoverlay_video_chain(GstPad *pad, GstData *_data)
+gst_textoverlay_video_chain (GstPad * pad, GstData * _data)
{
- GstBuffer *buf = GST_BUFFER (_data);
- GstTextOverlay *overlay;
- guchar *pixbuf;
- gint x0, y0;
-
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
- overlay = GST_TEXTOVERLAY(gst_pad_get_parent(pad));
- g_return_if_fail(overlay != NULL);
- g_return_if_fail(GST_IS_TEXTOVERLAY(overlay));
-
- pixbuf = GST_BUFFER_DATA(buf);
-
- x0 = overlay->x0;
- y0 = overlay->y0;
- switch (overlay->valign)
- {
+ GstBuffer *buf = GST_BUFFER (_data);
+ GstTextOverlay *overlay;
+ guchar *pixbuf;
+ gint x0, y0;
+
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
+ overlay = GST_TEXTOVERLAY (gst_pad_get_parent (pad));
+ g_return_if_fail (overlay != NULL);
+ g_return_if_fail (GST_IS_TEXTOVERLAY (overlay));
+
+ pixbuf = GST_BUFFER_DATA (buf);
+
+ x0 = overlay->x0;
+ y0 = overlay->y0;
+ switch (overlay->valign) {
case GST_TEXT_OVERLAY_VALIGN_BOTTOM:
- y0 += overlay->bitmap.rows;
- break;
+ y0 += overlay->bitmap.rows;
+ break;
case GST_TEXT_OVERLAY_VALIGN_BASELINE:
- y0 -= (overlay->bitmap.rows - overlay->baseline_y);
- break;
+ y0 -= (overlay->bitmap.rows - overlay->baseline_y);
+ break;
case GST_TEXT_OVERLAY_VALIGN_TOP:
- break;
- }
+ break;
+ }
- switch (overlay->halign)
- {
+ switch (overlay->halign) {
case GST_TEXT_OVERLAY_HALIGN_LEFT:
- break;
+ break;
case GST_TEXT_OVERLAY_HALIGN_RIGHT:
- x0 -= overlay->bitmap.width;
- break;
+ x0 -= overlay->bitmap.width;
+ break;
case GST_TEXT_OVERLAY_HALIGN_CENTER:
- x0 -= overlay->bitmap.width / 2;
- break;
- }
+ x0 -= overlay->bitmap.width / 2;
+ break;
+ }
- if (overlay->bitmap.buffer)
- gst_text_overlay_blit_yuv420(overlay, &overlay->bitmap, pixbuf, x0, y0);
+ if (overlay->bitmap.buffer)
+ gst_text_overlay_blit_yuv420 (overlay, &overlay->bitmap, pixbuf, x0, y0);
- gst_pad_push(overlay->srcpad, GST_DATA (buf));
+ gst_pad_push (overlay->srcpad, GST_DATA (buf));
}
#define PAST_END(buffer, time) \
< (time))
static void
-gst_textoverlay_loop(GstElement *element)
+gst_textoverlay_loop (GstElement * element)
{
- GstTextOverlay *overlay;
- GstBuffer *video_frame;
- guint64 now;
-
- g_return_if_fail(element != NULL);
- g_return_if_fail(GST_IS_TEXTOVERLAY(element));
- overlay = GST_TEXTOVERLAY(element);
-
- video_frame = GST_BUFFER (gst_pad_pull(overlay->video_sinkpad));
- now = GST_BUFFER_TIMESTAMP(video_frame);
-
- /*
- * This state machine has a bug that can't be resolved easily.
- * (Needs a more complicated state machine.) Basically, if the
- * text that came from a buffer from the sink pad is being
- * displayed, and the default text is changed by set_parameter,
- * we'll incorrectly display the default text.
- *
- * Otherwise, this is a pretty decent state machine that handles
- * buffer timestamps and durations correctly. (I think)
- */
-
- while (overlay->next_buffer == NULL){
- GST_DEBUG("attempting to pull a buffer");
-
- /* read all text buffers until we get one "in the future" */
- if(!GST_PAD_IS_USABLE(overlay->text_sinkpad)){
- break;
- }
- overlay->next_buffer = GST_BUFFER (gst_pad_pull(overlay->text_sinkpad));
- if (!overlay->next_buffer)
- break;
-
- if (PAST_END(overlay->next_buffer, now)){
- gst_buffer_unref(overlay->next_buffer);
- overlay->next_buffer = NULL;
- }
+ GstTextOverlay *overlay;
+ GstBuffer *video_frame;
+ guint64 now;
+
+ g_return_if_fail (element != NULL);
+ g_return_if_fail (GST_IS_TEXTOVERLAY (element));
+ overlay = GST_TEXTOVERLAY (element);
+
+ video_frame = GST_BUFFER (gst_pad_pull (overlay->video_sinkpad));
+ now = GST_BUFFER_TIMESTAMP (video_frame);
+
+ /*
+ * This state machine has a bug that can't be resolved easily.
+ * (Needs a more complicated state machine.) Basically, if the
+ * text that came from a buffer from the sink pad is being
+ * displayed, and the default text is changed by set_parameter,
+ * we'll incorrectly display the default text.
+ *
+ * Otherwise, this is a pretty decent state machine that handles
+ * buffer timestamps and durations correctly. (I think)
+ */
+
+ while (overlay->next_buffer == NULL) {
+ GST_DEBUG ("attempting to pull a buffer");
+
+ /* read all text buffers until we get one "in the future" */
+ if (!GST_PAD_IS_USABLE (overlay->text_sinkpad)) {
+ break;
}
+ overlay->next_buffer = GST_BUFFER (gst_pad_pull (overlay->text_sinkpad));
+ if (!overlay->next_buffer)
+ break;
- if (overlay->next_buffer &&
- (GST_BUFFER_TIMESTAMP(overlay->next_buffer) <= now ||
- GST_BUFFER_TIMESTAMP(overlay->next_buffer) == GST_CLOCK_TIME_NONE)){
- GST_DEBUG("using new buffer");
-
- if (overlay->current_buffer){
- gst_buffer_unref (overlay->current_buffer);
- }
- overlay->current_buffer = overlay->next_buffer;
+ if (PAST_END (overlay->next_buffer, now)) {
+ gst_buffer_unref (overlay->next_buffer);
overlay->next_buffer = NULL;
+ }
+ }
- GST_DEBUG ( "rendering '%*s'",
- GST_BUFFER_SIZE(overlay->current_buffer),
- GST_BUFFER_DATA(overlay->current_buffer));
- pango_layout_set_markup(overlay->layout,
- GST_BUFFER_DATA(overlay->current_buffer),
- GST_BUFFER_SIZE(overlay->current_buffer));
- render_text(overlay);
- overlay->need_render = FALSE;
+ if (overlay->next_buffer &&
+ (GST_BUFFER_TIMESTAMP (overlay->next_buffer) <= now ||
+ GST_BUFFER_TIMESTAMP (overlay->next_buffer) == GST_CLOCK_TIME_NONE)) {
+ GST_DEBUG ("using new buffer");
+
+ if (overlay->current_buffer) {
+ gst_buffer_unref (overlay->current_buffer);
}
+ overlay->current_buffer = overlay->next_buffer;
+ overlay->next_buffer = NULL;
- if (overlay->current_buffer && PAST_END(overlay->current_buffer, now)){
- GST_DEBUG("dropping old buffer");
+ GST_DEBUG ("rendering '%*s'",
+ GST_BUFFER_SIZE (overlay->current_buffer),
+ GST_BUFFER_DATA (overlay->current_buffer));
+ pango_layout_set_markup (overlay->layout,
+ GST_BUFFER_DATA (overlay->current_buffer),
+ GST_BUFFER_SIZE (overlay->current_buffer));
+ render_text (overlay);
+ overlay->need_render = FALSE;
+ }
- gst_buffer_unref(overlay->current_buffer);
- overlay->current_buffer = NULL;
+ if (overlay->current_buffer && PAST_END (overlay->current_buffer, now)) {
+ GST_DEBUG ("dropping old buffer");
- overlay->need_render = TRUE;
- }
+ gst_buffer_unref (overlay->current_buffer);
+ overlay->current_buffer = NULL;
- if(overlay->need_render){
- GST_DEBUG ( "rendering '%s'", overlay->default_text);
- pango_layout_set_markup(overlay->layout,
- overlay->default_text, strlen(overlay->default_text));
- render_text(overlay);
+ overlay->need_render = TRUE;
+ }
- overlay->need_render = FALSE;
- }
+ if (overlay->need_render) {
+ GST_DEBUG ("rendering '%s'", overlay->default_text);
+ pango_layout_set_markup (overlay->layout,
+ overlay->default_text, strlen (overlay->default_text));
+ render_text (overlay);
+
+ overlay->need_render = FALSE;
+ }
- gst_textoverlay_video_chain(overlay->srcpad, GST_DATA (video_frame));
+ gst_textoverlay_video_chain (overlay->srcpad, GST_DATA (video_frame));
}
static GstElementStateReturn
-gst_textoverlay_change_state(GstElement *element)
+gst_textoverlay_change_state (GstElement * element)
{
- GstTextOverlay *overlay;
+ GstTextOverlay *overlay;
- overlay = GST_TEXTOVERLAY(element);
+ overlay = GST_TEXTOVERLAY (element);
- switch (GST_STATE_TRANSITION(element))
- {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_PLAYING:
- break;
+ break;
case GST_STATE_PLAYING_TO_PAUSED:
- break;
+ break;
case GST_STATE_PAUSED_TO_READY:
- break;
- }
+ break;
+ }
- parent_class->change_state(element);
+ parent_class->change_state (element);
- return GST_STATE_SUCCESS;
+ return GST_STATE_SUCCESS;
}
static void
-gst_textoverlay_finalize(GObject *object)
+gst_textoverlay_finalize (GObject * object)
{
- GstTextOverlay *overlay = GST_TEXTOVERLAY(object);
-
- if (overlay->layout) {
- g_object_unref(overlay->layout);
- overlay->layout = NULL;
- }
- if (overlay->bitmap.buffer) {
- g_free(overlay->bitmap.buffer);
- overlay->bitmap.buffer = NULL;
- }
-
- G_OBJECT_CLASS(parent_class)->finalize(object);
+ GstTextOverlay *overlay = GST_TEXTOVERLAY (object);
+
+ if (overlay->layout) {
+ g_object_unref (overlay->layout);
+ overlay->layout = NULL;
+ }
+ if (overlay->bitmap.buffer) {
+ g_free (overlay->bitmap.buffer);
+ overlay->bitmap.buffer = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-gst_textoverlay_init(GstTextOverlay *overlay)
+gst_textoverlay_init (GstTextOverlay * overlay)
{
- /* video sink */
- overlay->video_sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&video_sink_template_factory), "video_sink");
+ /* video sink */
+ overlay->video_sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&video_sink_template_factory), "video_sink");
/* gst_pad_set_chain_function(overlay->video_sinkpad, gst_textoverlay_video_chain); */
- gst_pad_set_link_function(overlay->video_sinkpad, gst_textoverlay_video_sinkconnect);
- gst_element_add_pad(GST_ELEMENT(overlay), overlay->video_sinkpad);
-
- /* text sink */
- overlay->text_sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&text_sink_template_factory), "text_sink");
+ gst_pad_set_link_function (overlay->video_sinkpad,
+ gst_textoverlay_video_sinkconnect);
+ gst_element_add_pad (GST_ELEMENT (overlay), overlay->video_sinkpad);
+
+ /* text sink */
+ overlay->text_sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&text_sink_template_factory), "text_sink");
/* gst_pad_set_link_function(overlay->text_sinkpad, gst_textoverlay_text_sinkconnect); */
- gst_element_add_pad(GST_ELEMENT(overlay), overlay->text_sinkpad);
+ gst_element_add_pad (GST_ELEMENT (overlay), overlay->text_sinkpad);
- /* (video) source */
- overlay->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&textoverlay_src_template_factory), "src");
- gst_element_add_pad(GST_ELEMENT(overlay), overlay->srcpad);
+ /* (video) source */
+ overlay->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&textoverlay_src_template_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (overlay), overlay->srcpad);
- overlay->layout = pango_layout_new(GST_TEXTOVERLAY_GET_CLASS(overlay)->pango_context);
- memset(&overlay->bitmap, 0, sizeof(overlay->bitmap));
+ overlay->layout =
+ pango_layout_new (GST_TEXTOVERLAY_GET_CLASS (overlay)->pango_context);
+ memset (&overlay->bitmap, 0, sizeof (overlay->bitmap));
- overlay->halign = GST_TEXT_OVERLAY_HALIGN_CENTER;
- overlay->valign = GST_TEXT_OVERLAY_VALIGN_BASELINE;
- overlay->x0 = overlay->y0 = 0;
+ overlay->halign = GST_TEXT_OVERLAY_HALIGN_CENTER;
+ overlay->valign = GST_TEXT_OVERLAY_VALIGN_BASELINE;
+ overlay->x0 = overlay->y0 = 0;
- overlay->default_text = g_strdup("");
- overlay->need_render = TRUE;
+ overlay->default_text = g_strdup ("");
+ overlay->need_render = TRUE;
- gst_element_set_loop_function(GST_ELEMENT(overlay), gst_textoverlay_loop);
+ gst_element_set_loop_function (GST_ELEMENT (overlay), gst_textoverlay_loop);
}
static void
-gst_textoverlay_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_textoverlay_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GstTextOverlay *overlay;
+ GstTextOverlay *overlay;
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TEXTOVERLAY(object));
- overlay = GST_TEXTOVERLAY(object);
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_TEXTOVERLAY (object));
+ overlay = GST_TEXTOVERLAY (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_TEXT:
- if(overlay->default_text){
- g_free(overlay->default_text);
- }
- overlay->default_text = g_strdup(g_value_get_string(value));
- overlay->need_render = TRUE;
- break;
+ if (overlay->default_text) {
+ g_free (overlay->default_text);
+ }
+ overlay->default_text = g_strdup (g_value_get_string (value));
+ overlay->need_render = TRUE;
+ break;
case ARG_VALIGN:
- if (strcasecmp(g_value_get_string(value), "baseline") == 0)
- overlay->valign = GST_TEXT_OVERLAY_VALIGN_BASELINE;
- else if (strcasecmp(g_value_get_string(value), "bottom") == 0)
- overlay->valign = GST_TEXT_OVERLAY_VALIGN_BOTTOM;
- else if (strcasecmp(g_value_get_string(value), "top") == 0)
- overlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP;
- else
- g_warning("Invalid 'valign' property value: %s",
- g_value_get_string(value));
- break;
+ if (strcasecmp (g_value_get_string (value), "baseline") == 0)
+ overlay->valign = GST_TEXT_OVERLAY_VALIGN_BASELINE;
+ else if (strcasecmp (g_value_get_string (value), "bottom") == 0)
+ overlay->valign = GST_TEXT_OVERLAY_VALIGN_BOTTOM;
+ else if (strcasecmp (g_value_get_string (value), "top") == 0)
+ overlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP;
+ else
+ g_warning ("Invalid 'valign' property value: %s",
+ g_value_get_string (value));
+ break;
case ARG_HALIGN:
- if (strcasecmp(g_value_get_string(value), "left") == 0)
- overlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT;
- else if (strcasecmp(g_value_get_string(value), "right") == 0)
- overlay->halign = GST_TEXT_OVERLAY_HALIGN_RIGHT;
- else if (strcasecmp(g_value_get_string(value), "center") == 0)
- overlay->halign = GST_TEXT_OVERLAY_HALIGN_CENTER;
- else
- g_warning("Invalid 'halign' property value: %s",
- g_value_get_string(value));
- break;
+ if (strcasecmp (g_value_get_string (value), "left") == 0)
+ overlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT;
+ else if (strcasecmp (g_value_get_string (value), "right") == 0)
+ overlay->halign = GST_TEXT_OVERLAY_HALIGN_RIGHT;
+ else if (strcasecmp (g_value_get_string (value), "center") == 0)
+ overlay->halign = GST_TEXT_OVERLAY_HALIGN_CENTER;
+ else
+ g_warning ("Invalid 'halign' property value: %s",
+ g_value_get_string (value));
+ break;
case ARG_X0:
- overlay->x0 = g_value_get_int(value);
- break;
+ overlay->x0 = g_value_get_int (value);
+ break;
case ARG_Y0:
- overlay->y0 = g_value_get_int(value);
- break;
+ overlay->y0 = g_value_get_int (value);
+ break;
case ARG_FONT_DESC:
{
- PangoFontDescription *desc;
- desc = pango_font_description_from_string(g_value_get_string(value));
- if (desc) {
- g_message("font description set: %s", g_value_get_string(value));
- pango_layout_set_font_description(overlay->layout, desc);
- pango_font_description_free(desc);
- render_text(overlay);
- } else
- g_warning("font description parse failed: %s", g_value_get_string(value));
- break;
+ PangoFontDescription *desc;
+
+ desc = pango_font_description_from_string (g_value_get_string (value));
+ if (desc) {
+ g_message ("font description set: %s", g_value_get_string (value));
+ pango_layout_set_font_description (overlay->layout, desc);
+ pango_font_description_free (desc);
+ render_text (overlay);
+ } else
+ g_warning ("font description parse failed: %s",
+ g_value_get_string (value));
+ break;
}
default:
- break;
- }
+ break;
+ }
}
static void
-gst_textoverlay_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_textoverlay_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstTextOverlay *overlay;
+ GstTextOverlay *overlay;
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TEXTOVERLAY(object));
- overlay = GST_TEXTOVERLAY(object);
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_TEXTOVERLAY (object));
+ overlay = GST_TEXTOVERLAY (object);
- switch (prop_id) {
+ switch (prop_id) {
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static gboolean
-plugin_init(GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "textoverlay", GST_RANK_PRIMARY, GST_TYPE_TEXTOVERLAY))
- return FALSE;
+ if (!gst_element_register (plugin, "textoverlay", GST_RANK_PRIMARY,
+ GST_TYPE_TEXTOVERLAY))
+ return FALSE;
- /*texttestsrc_plugin_init(module, plugin);*/
- /*subparse_plugin_init(module, plugin);*/
- return TRUE;
+ /*texttestsrc_plugin_init(module, plugin); */
+ /*subparse_plugin_init(module, plugin); */
+ return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"textoverlay",
- "Text overlay",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN)
-
+ "Text overlay", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
#include <pango/pangoft2.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TEXTOVERLAY (gst_textoverlay_get_type())
#define GST_TEXTOVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
GST_TYPE_TEXTOVERLAY, GstTextOverlay))
GST_TYPE_TEXTOVERLAY))
#define GST_IS_TEXTOVERLAY_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),\
GST_TYPE_TEXTOVERLAY))
-
-typedef struct _GstTextOverlay GstTextOverlay;
+typedef struct _GstTextOverlay GstTextOverlay;
typedef struct _GstTextOverlayClass GstTextOverlayClass;
typedef enum _GstTextOverlayVAlign GstTextOverlayVAlign;
typedef enum _GstTextOverlayHAlign GstTextOverlayHAlign;
-enum _GstTextOverlayVAlign {
- GST_TEXT_OVERLAY_VALIGN_BASELINE,
- GST_TEXT_OVERLAY_VALIGN_BOTTOM,
- GST_TEXT_OVERLAY_VALIGN_TOP,
+enum _GstTextOverlayVAlign
+{
+ GST_TEXT_OVERLAY_VALIGN_BASELINE,
+ GST_TEXT_OVERLAY_VALIGN_BOTTOM,
+ GST_TEXT_OVERLAY_VALIGN_TOP,
};
-enum _GstTextOverlayHAlign {
- GST_TEXT_OVERLAY_HALIGN_LEFT,
- GST_TEXT_OVERLAY_HALIGN_CENTER,
- GST_TEXT_OVERLAY_HALIGN_RIGHT,
+enum _GstTextOverlayHAlign
+{
+ GST_TEXT_OVERLAY_HALIGN_LEFT,
+ GST_TEXT_OVERLAY_HALIGN_CENTER,
+ GST_TEXT_OVERLAY_HALIGN_RIGHT,
};
-struct _GstTextOverlay {
- GstElement element;
+struct _GstTextOverlay
+{
+ GstElement element;
- GstPad *video_sinkpad;
- GstPad *text_sinkpad;
- GstPad *srcpad;
- gint width;
- gint height;
- PangoLayout *layout;
- FT_Bitmap bitmap;
- gint bitmap_buffer_size;
- gint baseline_y;
- GstTextOverlayVAlign valign;
- GstTextOverlayHAlign halign;
- gint x0;
- gint y0;
- GstBuffer *current_buffer;
- GstBuffer *next_buffer;
- gchar *default_text;
- gboolean need_render;
+ GstPad *video_sinkpad;
+ GstPad *text_sinkpad;
+ GstPad *srcpad;
+ gint width;
+ gint height;
+ PangoLayout *layout;
+ FT_Bitmap bitmap;
+ gint bitmap_buffer_size;
+ gint baseline_y;
+ GstTextOverlayVAlign valign;
+ GstTextOverlayHAlign halign;
+ gint x0;
+ gint y0;
+ GstBuffer *current_buffer;
+ GstBuffer *next_buffer;
+ gchar *default_text;
+ gboolean need_render;
};
-struct _GstTextOverlayClass {
- GstElementClass parent_class;
+struct _GstTextOverlayClass
+{
+ GstElementClass parent_class;
- PangoContext *pango_context;
+ PangoContext *pango_context;
};
-GType gst_textoverlay_get_type(void) G_GNUC_CONST;
+GType
+gst_textoverlay_get_type (void)
+ G_GNUC_CONST;
G_END_DECLS
-
#endif /* __GST_TEXTOVERLAY_H */
/* GstTimeoverlay signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_timeoverlay_base_init (gpointer g_class);
-static void gst_timeoverlay_class_init (gpointer g_class, gpointer class_data);
-static void gst_timeoverlay_init (GTypeInstance *instance, gpointer g_class);
+static void gst_timeoverlay_base_init (gpointer g_class);
+static void gst_timeoverlay_class_init (gpointer g_class, gpointer class_data);
+static void gst_timeoverlay_init (GTypeInstance * instance, gpointer g_class);
-static void gst_timeoverlay_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_timeoverlay_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_timeoverlay_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_timeoverlay_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_timeoverlay_planar411(GstVideofilter *videofilter, void *dest, void *src);
-static void gst_timeoverlay_setup(GstVideofilter *videofilter);
+static void gst_timeoverlay_planar411 (GstVideofilter * videofilter, void *dest,
+ void *src);
+static void gst_timeoverlay_setup (GstVideofilter * videofilter);
GType
gst_timeoverlay_get_type (void)
if (!timeoverlay_type) {
static const GTypeInfo timeoverlay_info = {
- sizeof(GstTimeoverlayClass),
+ sizeof (GstTimeoverlayClass),
gst_timeoverlay_base_init,
NULL,
gst_timeoverlay_class_init,
NULL,
NULL,
- sizeof(GstTimeoverlay),
+ sizeof (GstTimeoverlay),
0,
gst_timeoverlay_init,
};
- timeoverlay_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
- "GstTimeoverlay", &timeoverlay_info, 0);
+ timeoverlay_type = g_type_register_static (GST_TYPE_VIDEOFILTER,
+ "GstTimeoverlay", &timeoverlay_info, 0);
}
return timeoverlay_type;
}
static GstVideofilterFormat gst_timeoverlay_formats[] = {
- { "I420", 12, gst_timeoverlay_planar411, },
+ {"I420", 12, gst_timeoverlay_planar411,},
};
-
+
static void
gst_timeoverlay_base_init (gpointer g_class)
{
- static GstElementDetails timeoverlay_details = GST_ELEMENT_DETAILS (
- "Time Overlay",
- "Filter/Editor/Video",
- "Overlays the time on a video stream",
- "David Schleef <ds@schleef.org>"
- );
+ static GstElementDetails timeoverlay_details =
+ GST_ELEMENT_DETAILS ("Time Overlay",
+ "Filter/Editor/Video",
+ "Overlays the time on a video stream",
+ "David Schleef <ds@schleef.org>");
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
int i;
-
+
gst_element_class_set_details (element_class, &timeoverlay_details);
- for(i=0;i<G_N_ELEMENTS(gst_timeoverlay_formats);i++){
- gst_videofilter_class_add_format(videofilter_class,
+ for (i = 0; i < G_N_ELEMENTS (gst_timeoverlay_formats); i++) {
+ gst_videofilter_class_add_format (videofilter_class,
gst_timeoverlay_formats + i);
}
videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
#if 0
- g_object_class_install_property(gobject_class, ARG_METHOD,
- g_param_spec_enum("method","method","method",
- GST_TYPE_TIMEOVERLAY_METHOD, GST_TIMEOVERLAY_METHOD_1,
- G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_METHOD,
+ g_param_spec_enum ("method", "method", "method",
+ GST_TYPE_TIMEOVERLAY_METHOD, GST_TIMEOVERLAY_METHOD_1,
+ G_PARAM_READWRITE));
#endif
gobject_class->set_property = gst_timeoverlay_set_property;
}
static void
-gst_timeoverlay_init (GTypeInstance *instance, gpointer g_class)
+gst_timeoverlay_init (GTypeInstance * instance, gpointer g_class)
{
GstTimeoverlay *timeoverlay = GST_TIMEOVERLAY (instance);
GstVideofilter *videofilter;
- GST_DEBUG("gst_timeoverlay_init");
+ GST_DEBUG ("gst_timeoverlay_init");
- videofilter = GST_VIDEOFILTER(timeoverlay);
+ videofilter = GST_VIDEOFILTER (timeoverlay);
/* do stuff */
}
static void
-gst_timeoverlay_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_timeoverlay_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstTimeoverlay *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TIMEOVERLAY(object));
- src = GST_TIMEOVERLAY(object);
+ g_return_if_fail (GST_IS_TIMEOVERLAY (object));
+ src = GST_TIMEOVERLAY (object);
- GST_DEBUG("gst_timeoverlay_set_property");
+ GST_DEBUG ("gst_timeoverlay_set_property");
switch (prop_id) {
#if 0
case ARG_METHOD:
}
static void
-gst_timeoverlay_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_timeoverlay_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstTimeoverlay *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TIMEOVERLAY(object));
- src = GST_TIMEOVERLAY(object);
+ g_return_if_fail (GST_IS_TIMEOVERLAY (object));
+ src = GST_TIMEOVERLAY (object);
switch (prop_id) {
#if 0
}
}
-static gboolean plugin_init (GstPlugin *plugin)
+static gboolean
+plugin_init (GstPlugin * plugin)
{
- if(!gst_library_load("gstvideofilter"))
+ if (!gst_library_load ("gstvideofilter"))
return FALSE;
return gst_element_register (plugin, "timeoverlay", GST_RANK_NONE,
GST_TYPE_TIMEOVERLAY);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "timeoverlay",
- "Time overlay",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
-static void gst_timeoverlay_setup(GstVideofilter *videofilter)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "timeoverlay",
+ "Time overlay", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
+
+ static void gst_timeoverlay_setup (GstVideofilter * videofilter)
{
GstTimeoverlay *timeoverlay;
PangoFontDescription *font_description;
PangoContext *context;
- g_return_if_fail(GST_IS_TIMEOVERLAY(videofilter));
- timeoverlay = GST_TIMEOVERLAY(videofilter);
+ g_return_if_fail (GST_IS_TIMEOVERLAY (videofilter));
+ timeoverlay = GST_TIMEOVERLAY (videofilter);
/* if any setup needs to be done, do it here */
}
-static char *gst_timeoverlay_print_smpte_time(guint64 time)
+static char *
+gst_timeoverlay_print_smpte_time (guint64 time)
{
int hours;
int minutes;
int ms;
double x;
- x = rint((time + 500000)*1e-6);
+ x = rint ((time + 500000) * 1e-6);
- hours = floor(x/(60*60*1000));
- x -= hours*60*60*1000;
- minutes = floor(x/(60*1000));
- x -= minutes*60*1000;
- seconds = floor(x/(1000));
- x -= seconds*1000;
- ms = rint(x);
+ hours = floor (x / (60 * 60 * 1000));
+ x -= hours * 60 * 60 * 1000;
+ minutes = floor (x / (60 * 1000));
+ x -= minutes * 60 * 1000;
+ seconds = floor (x / (1000));
+ x -= seconds * 1000;
+ ms = rint (x);
- return g_strdup_printf("%02d:%02d:%02d.%03d",hours,minutes,seconds,ms);
+ return g_strdup_printf ("%02d:%02d:%02d.%03d", hours, minutes, seconds, ms);
}
-static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
- void *dest, void *src)
+static void
+gst_timeoverlay_planar411 (GstVideofilter * videofilter, void *dest, void *src)
{
GstTimeoverlay *timeoverlay;
int width;
char *string;
int i;
- g_return_if_fail(GST_IS_TIMEOVERLAY(videofilter));
- timeoverlay = GST_TIMEOVERLAY(videofilter);
+ g_return_if_fail (GST_IS_TIMEOVERLAY (videofilter));
+ timeoverlay = GST_TIMEOVERLAY (videofilter);
- width = gst_videofilter_get_input_width(videofilter);
- height = gst_videofilter_get_input_height(videofilter);
+ width = gst_videofilter_get_input_width (videofilter);
+ height = gst_videofilter_get_input_height (videofilter);
- width = gst_videofilter_get_input_width(videofilter);
- height = gst_videofilter_get_input_height(videofilter);
+ width = gst_videofilter_get_input_width (videofilter);
+ height = gst_videofilter_get_input_height (videofilter);
layout = pango_layout_new (timeoverlay->context);
- string = gst_timeoverlay_print_smpte_time(GST_BUFFER_TIMESTAMP(videofilter->in_buf));
- pango_layout_set_text (layout, string, strlen(string));
- g_free(string);
+ string =
+ gst_timeoverlay_print_smpte_time (GST_BUFFER_TIMESTAMP (videofilter->
+ in_buf));
+ pango_layout_set_text (layout, string, strlen (string));
+ g_free (string);
pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
pango_layout_set_width (layout, -1);
//hheight = 20;
- memcpy(dest, src, videofilter->from_buf_size);
+ memcpy (dest, src, videofilter->from_buf_size);
- for(i=0;i<b_height;i++){
- memset(dest + i*width, 0, b_width);
+ for (i = 0; i < b_height; i++) {
+ memset (dest + i * width, 0, b_width);
}
- for(i=0;i<b_height/2;i++){
- memset(dest + width*height + i*(width/2), 128, b_width/2);
- memset(dest + width*height + (width/2)*(height/2) + i*(width/2), 128,
- b_width/2);
+ for (i = 0; i < b_height / 2; i++) {
+ memset (dest + width * height + i * (width / 2), 128, b_width / 2);
+ memset (dest + width * height + (width / 2) * (height / 2) +
+ i * (width / 2), 128, b_width / 2);
}
bitmap.rows = b_height;
bitmap.width = b_width;
pango_ft2_render_layout (&bitmap, layout, 0, 0);
}
-
G_BEGIN_DECLS
-
#define GST_TYPE_TIMEOVERLAY \
(gst_timeoverlay_get_type())
#define GST_TIMEOVERLAY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TIMEOVERLAY))
#define GST_IS_TIMEOVERLAY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TIMEOVERLAY))
-
typedef struct _GstTimeoverlay GstTimeoverlay;
typedef struct _GstTimeoverlayClass GstTimeoverlayClass;
-struct _GstTimeoverlay {
+struct _GstTimeoverlay
+{
GstVideofilter videofilter;
PangoFontDescription *font_description;
};
-struct _GstTimeoverlayClass {
+struct _GstTimeoverlayClass
+{
GstVideofilterClass parent_class;
};
-GType gst_timeoverlay_get_type(void);
+GType gst_timeoverlay_get_type (void);
G_END_DECLS
-
#endif /* __GST_TIMEOVERLAY_H__ */
-
typedef struct _GstTheoraDec GstTheoraDec;
typedef struct _GstTheoraDecClass GstTheoraDecClass;
-struct _GstTheoraDec {
- GstElement element;
-
- GstPad * sinkpad;
- GstPad * srcpad;
-
- theora_state state;
- theora_info info;
- theora_comment comment;
-
- guint packetno;
- guint64 granulepos;
+struct _GstTheoraDec
+{
+ GstElement element;
+
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ theora_state state;
+ theora_info info;
+ theora_comment comment;
+
+ guint packetno;
+ guint64 granulepos;
};
-struct _GstTheoraDecClass {
+struct _GstTheoraDecClass
+{
GstElementClass parent_class;
};
};
static GstStaticPadTemplate theora_dec_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-raw-yuv, "
- "format = (fourcc) I420, "
- "framerate = (double) [0, MAX], "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ]"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-yuv, "
+ "format = (fourcc) I420, "
+ "framerate = (double) [0, MAX], "
+ "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
+ );
static GstStaticPadTemplate theora_dec_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-theora"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-theora")
+ );
GST_BOILERPLATE (GstTheoraDec, gst_theora_dec, GstElement, GST_TYPE_ELEMENT);
-
-static void theora_dec_chain (GstPad * pad,
- GstData * data);
-static GstElementStateReturn
- theora_dec_change_state (GstElement * element);
-static gboolean theora_dec_src_event (GstPad * pad,
- GstEvent * event);
-static gboolean theora_dec_src_query (GstPad * pad,
- GstQueryType query,
- GstFormat * format,
- gint64 * value);
+
+static void theora_dec_chain (GstPad * pad, GstData * data);
+static GstElementStateReturn theora_dec_change_state (GstElement * element);
+static gboolean theora_dec_src_event (GstPad * pad, GstEvent * event);
+static gboolean theora_dec_src_query (GstPad * pad,
+ GstQueryType query, GstFormat * format, gint64 * value);
static void
gst_theora_dec_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 (&theora_dec_src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&theora_dec_sink_factory));
}
static void
-gst_theora_dec_class_init (GstTheoraDecClass *klass)
+gst_theora_dec_class_init (GstTheoraDecClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_theora_dec_init (GstTheoraDec *dec)
+gst_theora_dec_init (GstTheoraDec * dec)
{
- dec->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&theora_dec_sink_factory), "sink");
+ dec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&theora_dec_sink_factory), "sink");
gst_pad_set_chain_function (dec->sinkpad, theora_dec_chain);
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
- dec->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&theora_dec_src_factory), "src");
+ dec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&theora_dec_src_factory), "src");
gst_pad_use_explicit_caps (dec->srcpad);
gst_pad_set_event_function (dec->srcpad, theora_dec_src_event);
gst_pad_set_query_function (dec->srcpad, theora_dec_src_query);
}
/* FIXME: copy from libtheora, theora should somehow make this available for seeking */
-static int
-_theora_ilog(unsigned int v){
- int ret=0;
- while(v){
+static int
+_theora_ilog (unsigned int v)
+{
+ int ret = 0;
+
+ while (v) {
ret++;
- v>>=1;
+ v >>= 1;
}
- return(ret);
+ return (ret);
}
static gboolean
-theora_dec_from_granulepos (GstTheoraDec *dec, GstFormat format, guint64 from, guint64 *to)
+theora_dec_from_granulepos (GstTheoraDec * dec, GstFormat format, guint64 from,
+ guint64 * to)
{
guint64 framecount;
guint ilog = _theora_ilog (dec->info.keyframe_frequency_force);
-
- if (dec->packetno < 1) return FALSE;
-
+
+ if (dec->packetno < 1)
+ return FALSE;
+
/* granulepos is last ilog bits for counting pframes since last iframe and
* bits in front of that for the framenumber of the last iframe. */
framecount = from >> ilog;
switch (format) {
case GST_FORMAT_TIME:
- *to = framecount = from * GST_SECOND * dec->info.fps_denominator / dec->info.fps_numerator;
+ *to = framecount =
+ from * GST_SECOND * dec->info.fps_denominator /
+ dec->info.fps_numerator;
break;
case GST_FORMAT_DEFAULT:
*to = framecount;
/* FIXME: we can only seek to keyframes... */
static gboolean
-theora_dec_to_granulepos (GstTheoraDec *dec, GstFormat format, guint64 from, guint64 *to)
+theora_dec_to_granulepos (GstTheoraDec * dec, GstFormat format, guint64 from,
+ guint64 * to)
{
guint64 framecount;
-
- if (dec->packetno < 1) return FALSE;
-
+
+ if (dec->packetno < 1)
+ return FALSE;
+
switch (format) {
case GST_FORMAT_TIME:
- framecount = from * dec->info.fps_numerator / (GST_SECOND * dec->info.fps_denominator);
+ framecount =
+ from * dec->info.fps_numerator / (GST_SECOND *
+ dec->info.fps_denominator);
break;
case GST_FORMAT_DEFAULT:
framecount = from;
}
static gboolean
-theora_dec_src_query (GstPad *pad, GstQueryType query, GstFormat *format, gint64 *value)
+theora_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
+ gint64 * value)
{
gint64 granulepos;
GstTheoraDec *dec = GST_THEORA_DEC (gst_pad_get_parent (pad));
GstFormat my_format = GST_FORMAT_DEFAULT;
- if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format, &granulepos))
+ if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format,
+ &granulepos))
return FALSE;
if (!theora_dec_from_granulepos (dec, *format, granulepos, value))
return FALSE;
- GST_LOG_OBJECT (dec, "query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
+ GST_LOG_OBJECT (dec,
+ "query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
query, granulepos, *value, *format);
return TRUE;
}
static gboolean
-theora_dec_src_event (GstPad *pad, GstEvent *event)
+theora_dec_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
GstTheoraDec *dec;
dec = GST_THEORA_DEC (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_SEEK: {
+ case GST_EVENT_SEEK:{
guint64 value;
-
- res = theora_dec_to_granulepos (dec, GST_EVENT_SEEK_FORMAT (event),
- GST_EVENT_SEEK_OFFSET (event), &value);
+
+ res = theora_dec_to_granulepos (dec, GST_EVENT_SEEK_FORMAT (event),
+ GST_EVENT_SEEK_OFFSET (event), &value);
if (res) {
GstEvent *real_seek = gst_event_new_seek (
- (GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) | GST_FORMAT_DEFAULT,
+ (GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) |
+ GST_FORMAT_DEFAULT,
value);
+
res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek);
}
gst_event_unref (event);
}
static void
-theora_dec_event (GstTheoraDec *dec, GstEvent *event)
+theora_dec_event (GstTheoraDec * dec, GstEvent * event)
{
guint64 value, time, bytes;
-
+
GST_LOG_OBJECT (dec, "handling event");
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT, &value)) {
dec->granulepos = value;
- GST_DEBUG_OBJECT (dec, "setting granuleposition to %"G_GUINT64_FORMAT" after discont\n", value);
+ GST_DEBUG_OBJECT (dec,
+ "setting granuleposition to %" G_GUINT64_FORMAT " after discont\n",
+ value);
} else {
- GST_WARNING_OBJECT (dec,
+ GST_WARNING_OBJECT (dec,
"discont event didn't include offset, we might set it wrong now");
}
if (dec->packetno < 3) {
if (dec->granulepos != 0)
- GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("can't handle discont before parsing first 3 packets"));
+ GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL),
+ ("can't handle discont before parsing first 3 packets"));
dec->packetno = 0;
- gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, (guint64) 0,
- GST_FORMAT_DEFAULT, (guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
+ gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE,
+ GST_FORMAT_TIME, (guint64) 0, GST_FORMAT_DEFAULT,
+ (guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
} else {
dec->packetno = 3;
/* if one of them works, all of them work */
- if (theora_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos, &time) &&
- theora_dec_from_granulepos (dec, GST_FORMAT_DEFAULT, dec->granulepos, &value) &&
- theora_dec_from_granulepos (dec, GST_FORMAT_BYTES, dec->granulepos, &bytes)) {
- gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
- GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes, 0)));
+ if (theora_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos,
+ &time)
+ && theora_dec_from_granulepos (dec, GST_FORMAT_DEFAULT,
+ dec->granulepos, &value)
+ && theora_dec_from_granulepos (dec, GST_FORMAT_BYTES,
+ dec->granulepos, &bytes)) {
+ gst_pad_push (dec->srcpad,
+ GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
+ time, GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes,
+ 0)));
} else {
- GST_ERROR_OBJECT (dec, "failed to parse data for DISCONT event, not sending any");
+ GST_ERROR_OBJECT (dec,
+ "failed to parse data for DISCONT event, not sending any");
}
}
break;
}
static void
-theora_dec_chain (GstPad *pad, GstData *data)
+theora_dec_chain (GstPad * pad, GstData * data)
{
GstBuffer *buf;
GstTheoraDec *dec;
packet.packet = GST_BUFFER_DATA (buf);
packet.bytes = GST_BUFFER_SIZE (buf);
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
- packet.packetno = dec->packetno ++;
+ packet.packetno = dec->packetno++;
packet.b_o_s = (packet.packetno == 0) ? 1 : 0;
packet.e_o_s = 0;
/* switch depending on packet type */
if (packet.packet[0] & 0x80) {
/* header packet */
if (theora_decode_header (&dec->info, &dec->comment, &packet)) {
- GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
+ GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
(NULL), ("couldn't read header packet"));
gst_data_unref (data);
return;
}
if (packet.packetno == 1) {
gchar *encoder = NULL;
- GstTagList *list = gst_tag_list_from_vorbiscomment_buffer (buf, "\201theora", 7, &encoder);
+ GstTagList *list =
+ gst_tag_list_from_vorbiscomment_buffer (buf, "\201theora", 7,
+ &encoder);
+
if (!list) {
GST_ERROR_OBJECT (dec, "failed to parse tags");
list = gst_tag_list_new ();
gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, 0, list);
} else if (packet.packetno == 2) {
GstCaps *caps;
+
/* done */
theora_decode_init (&dec->state, &dec->info);
caps = gst_caps_new_simple ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
- "framerate", G_TYPE_DOUBLE, ((gdouble) dec->info.fps_numerator) / dec->info.fps_denominator,
- "width", G_TYPE_INT, dec->info.width,
- "height", G_TYPE_INT, dec->info.height,
- NULL);
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
+ "framerate", G_TYPE_DOUBLE,
+ ((gdouble) dec->info.fps_numerator) / dec->info.fps_denominator,
+ "width", G_TYPE_INT, dec->info.width, "height", G_TYPE_INT,
+ dec->info.height, NULL);
gst_pad_set_explicit_caps (dec->srcpad, caps);
gst_caps_free (caps);
}
GstBuffer *out;
guint8 *y, *v, *u;
guint i;
+
/* normal data packet */
#if 0
{
GTimeVal tv;
guint64 time;
+
g_get_current_time (&tv);
time = GST_TIMEVAL_TO_TIME (tv);
#endif
- if (theora_decode_packetin (&dec->state, &packet)) {
- GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
- (NULL), ("theora decoder did not read data packet"));
- gst_data_unref (data);
- return;
- }
- if (theora_decode_YUVout (&dec->state, &yuv) < 0) {
- GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
- (NULL), ("couldn't read out YUV image"));
- gst_data_unref (data);
- return;
- }
- g_return_if_fail (yuv.y_width == dec->info.width);
- g_return_if_fail (yuv.y_height == dec->info.height);
- out = gst_pad_alloc_buffer (dec->srcpad, GST_BUFFER_OFFSET_NONE,
- yuv.y_width * yuv.y_height * 12 / 8);
- y = GST_BUFFER_DATA (out);
- u = y + yuv.y_width * yuv.y_height;
- v = u + yuv.y_width * yuv.y_height / 4;
- for (i = 0; i < yuv.y_height; i++) {
- memcpy (y + i * yuv.y_width, yuv.y + i * yuv.y_stride, yuv.y_width);
- }
- for (i = 0; i < yuv.y_height / 2; i++) {
- memcpy (u + i * yuv.uv_width, yuv.u + i * yuv.uv_stride, yuv.uv_width);
- memcpy (v + i * yuv.uv_width, yuv.v + i * yuv.uv_stride, yuv.uv_width);
- }
- GST_BUFFER_OFFSET (out) = dec->packetno - 4;
- GST_BUFFER_OFFSET_END (out) = dec->packetno - 3;
- GST_BUFFER_DURATION (out) = GST_SECOND * ((gdouble) dec->info.fps_denominator) / dec->info.fps_numerator;
- GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_OFFSET (out) * GST_BUFFER_DURATION (out);
+ if (theora_decode_packetin (&dec->state, &packet)) {
+ GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
+ (NULL), ("theora decoder did not read data packet"));
+ gst_data_unref (data);
+ return;
+ }
+ if (theora_decode_YUVout (&dec->state, &yuv) < 0) {
+ GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
+ (NULL), ("couldn't read out YUV image"));
+ gst_data_unref (data);
+ return;
+ }
+ g_return_if_fail (yuv.y_width == dec->info.width);
+ g_return_if_fail (yuv.y_height == dec->info.height);
+ out = gst_pad_alloc_buffer (dec->srcpad, GST_BUFFER_OFFSET_NONE,
+ yuv.y_width * yuv.y_height * 12 / 8);
+ y = GST_BUFFER_DATA (out);
+ u = y + yuv.y_width * yuv.y_height;
+ v = u + yuv.y_width * yuv.y_height / 4;
+ for (i = 0; i < yuv.y_height; i++) {
+ memcpy (y + i * yuv.y_width, yuv.y + i * yuv.y_stride, yuv.y_width);
+ }
+ for (i = 0; i < yuv.y_height / 2; i++) {
+ memcpy (u + i * yuv.uv_width, yuv.u + i * yuv.uv_stride, yuv.uv_width);
+ memcpy (v + i * yuv.uv_width, yuv.v + i * yuv.uv_stride, yuv.uv_width);
+ }
+ GST_BUFFER_OFFSET (out) = dec->packetno - 4;
+ GST_BUFFER_OFFSET_END (out) = dec->packetno - 3;
+ GST_BUFFER_DURATION (out) =
+ GST_SECOND * ((gdouble) dec->info.fps_denominator) /
+ dec->info.fps_numerator;
+ GST_BUFFER_TIMESTAMP (out) =
+ GST_BUFFER_OFFSET (out) * GST_BUFFER_DURATION (out);
#if 0
g_get_current_time (&tv);
time = GST_TIMEVAL_TO_TIME (tv) - time;
}
static GstElementStateReturn
-theora_dec_change_state (GstElement *element)
+theora_dec_change_state (GstElement * element)
{
GstTheoraDec *dec = GST_THEORA_DEC (element);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gsttags"))
return FALSE;
- if (!gst_element_register (plugin, "theoradec", GST_RANK_SECONDARY, gst_theora_dec_get_type ()))
+ if (!gst_element_register (plugin, "theoradec", GST_RANK_SECONDARY,
+ gst_theora_dec_get_type ()))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gsttheora",
- "Theora plugin library",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gsttheora",
+ "Theora plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
GST_DEBUG_CATEGORY (vorbisdec_debug);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
if (!gst_library_load ("gsttags"))
return FALSE;
- if (!gst_element_register (plugin, "vorbisenc", GST_RANK_NONE, GST_TYPE_VORBISENC))
+ if (!gst_element_register (plugin, "vorbisenc", GST_RANK_NONE,
+ GST_TYPE_VORBISENC))
return FALSE;
- if (!gst_element_register (plugin, "vorbisdec", GST_RANK_PRIMARY, gst_vorbis_dec_get_type ()))
+ if (!gst_element_register (plugin, "vorbisdec", GST_RANK_PRIMARY,
+ gst_vorbis_dec_get_type ()))
return FALSE;
- GST_DEBUG_CATEGORY_INIT (vorbisdec_debug, "vorbisdec", 0, "vorbis decoding element");
+ GST_DEBUG_CATEGORY_INIT (vorbisdec_debug, "vorbisdec", 0,
+ "vorbis decoding element");
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "vorbis",
- "Vorbis plugin library",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "vorbis",
+ "Vorbis plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
};
/* Filter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
};
static GstStaticPadTemplate vorbis_dec_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-float, "
- "rate = (int) [ 11025, 48000 ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-float, "
+ "rate = (int) [ 11025, 48000 ], "
+ "channels = (int) [ 1, 2 ], " "endianness = (int) BYTE_ORDER, "
/* no ifdef in macros, please
#ifdef GST_VORBIS_DEC_SEQUENTIAL
"layout = \"sequential\", "
#endif
*/
- "width = (int) 32, "
- "buffer-frames = (int) 0"
- )
-);
+ "width = (int) 32, " "buffer-frames = (int) 0")
+ );
static GstStaticPadTemplate vorbis_dec_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-vorbis"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-vorbis")
+ );
GST_BOILERPLATE (GstVorbisDec, gst_vorbis_dec, GstElement, GST_TYPE_ELEMENT);
-
-static void vorbis_dec_chain (GstPad * pad,
- GstData * data);
-static GstElementStateReturn
- vorbis_dec_change_state (GstElement * element);
-static const GstFormat*
- vorbis_dec_get_formats (GstPad *pad);
-
-static gboolean vorbis_dec_src_event (GstPad * pad,
- GstEvent * event);
-static gboolean vorbis_dec_src_query (GstPad * pad,
- GstQueryType query,
- GstFormat * format,
- gint64 * value);
+
+static void vorbis_dec_chain (GstPad * pad, GstData * data);
+static GstElementStateReturn vorbis_dec_change_state (GstElement * element);
+static const GstFormat *vorbis_dec_get_formats (GstPad * pad);
+
+static gboolean vorbis_dec_src_event (GstPad * pad, GstEvent * event);
+static gboolean vorbis_dec_src_query (GstPad * pad,
+ GstQueryType query, GstFormat * format, gint64 * value);
static void
gst_vorbis_dec_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 (&vorbis_dec_src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&vorbis_dec_sink_factory));
}
static void
-gst_vorbis_dec_class_init (GstVorbisDecClass *klass)
+gst_vorbis_dec_class_init (GstVorbisDecClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
}
static const GstFormat *
-vorbis_dec_get_formats (GstPad *pad)
+vorbis_dec_get_formats (GstPad * pad)
{
static const GstFormat src_formats[] = {
GST_FORMAT_BYTES,
}
static GstPadLinkReturn
-vorbis_dec_link (GstPad *pad, const GstCaps *caps)
+vorbis_dec_link (GstPad * pad, const GstCaps * caps)
{
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
}
static GstCaps *
-vorbis_dec_getcaps (GstPad *pad)
+vorbis_dec_getcaps (GstPad * pad)
{
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
return gst_caps_new_simple ("audio/x-raw-float",
- "rate", G_TYPE_INT, dec->vi.rate,
- "channels", G_TYPE_INT, dec->vi.channels,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 32,
+ "rate", G_TYPE_INT, dec->vi.rate,
+ "channels", G_TYPE_INT, dec->vi.channels,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
#ifdef GST_VORBIS_DEC_SEQUENTIAL
- "layout", G_TYPE_STRING, "sequential",
+ "layout", G_TYPE_STRING, "sequential",
#endif
- "buffer-frames", G_TYPE_INT, 0,
- NULL);
+ "buffer-frames", G_TYPE_INT, 0, NULL);
}
static void
-gst_vorbis_dec_init (GstVorbisDec *dec)
+gst_vorbis_dec_init (GstVorbisDec * dec)
{
- dec->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&vorbis_dec_sink_factory), "sink");
+ dec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&vorbis_dec_sink_factory), "sink");
gst_pad_set_chain_function (dec->sinkpad, vorbis_dec_chain);
gst_pad_set_formats_function (dec->sinkpad, vorbis_dec_get_formats);
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
- dec->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&vorbis_dec_src_factory), "src");
+ dec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&vorbis_dec_src_factory), "src");
gst_pad_set_link_function (dec->srcpad, vorbis_dec_link);
gst_pad_set_getcaps_function (dec->srcpad, vorbis_dec_getcaps);
gst_pad_set_event_function (dec->srcpad, vorbis_dec_src_event);
/* FIXME: plug this to the pad convert function */
static gboolean
-vorbis_dec_to_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, guint64 *to)
+vorbis_dec_to_granulepos (GstVorbisDec * dec, GstFormat format, guint64 from,
+ guint64 * to)
{
- if (dec->packetno < 1) return FALSE;
-
+ if (dec->packetno < 1)
+ return FALSE;
+
switch (format) {
case GST_FORMAT_TIME:
*to = from * dec->vi.rate / GST_SECOND;
}
static gboolean
-vorbis_dec_from_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, guint64 *to)
+vorbis_dec_from_granulepos (GstVorbisDec * dec, GstFormat format, guint64 from,
+ guint64 * to)
{
- if (dec->packetno < 1) return FALSE;
-
+ if (dec->packetno < 1)
+ return FALSE;
+
switch (format) {
case GST_FORMAT_TIME:
*to = from * GST_SECOND / dec->vi.rate;
static gboolean
-vorbis_dec_src_query (GstPad *pad, GstQueryType query, GstFormat *format, gint64 *value)
+vorbis_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
+ gint64 * value)
{
gint64 granulepos;
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
GstFormat my_format = GST_FORMAT_DEFAULT;
- if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format, &granulepos))
+ if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format,
+ &granulepos))
return FALSE;
if (!vorbis_dec_from_granulepos (dec, *format, granulepos, value))
return FALSE;
- GST_LOG_OBJECT (dec, "query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
+ GST_LOG_OBJECT (dec,
+ "query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
query, granulepos, *value, *format);
return TRUE;
}
static gboolean
-vorbis_dec_src_event (GstPad *pad, GstEvent *event)
+vorbis_dec_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_SEEK: {
+ case GST_EVENT_SEEK:{
guint64 value;
-
- res = vorbis_dec_to_granulepos (dec, GST_EVENT_SEEK_FORMAT (event),
- GST_EVENT_SEEK_OFFSET (event), &value);
+
+ res = vorbis_dec_to_granulepos (dec, GST_EVENT_SEEK_FORMAT (event),
+ GST_EVENT_SEEK_OFFSET (event), &value);
if (res) {
GstEvent *real_seek = gst_event_new_seek (
- (GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) | GST_FORMAT_DEFAULT,
+ (GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) |
+ GST_FORMAT_DEFAULT,
value);
+
res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek);
}
gst_event_unref (event);
return res;
}
static void
-vorbis_dec_event (GstVorbisDec *dec, GstEvent *event)
+vorbis_dec_event (GstVorbisDec * dec, GstEvent * event)
{
guint64 value, time, bytes;
-
+
GST_LOG_OBJECT (dec, "handling event");
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT, &value)) {
dec->granulepos = value;
- GST_DEBUG_OBJECT (dec, "setting granuleposition to %"G_GUINT64_FORMAT" after discont", value);
+ GST_DEBUG_OBJECT (dec,
+ "setting granuleposition to %" G_GUINT64_FORMAT " after discont",
+ value);
} else {
- GST_WARNING_OBJECT (dec,
+ GST_WARNING_OBJECT (dec,
"discont event didn't include offset, we might set it wrong now");
}
if (dec->packetno < 3) {
if (dec->granulepos != 0)
- GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("can't handle discont before parsing first 3 packets"));
+ GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL),
+ ("can't handle discont before parsing first 3 packets"));
dec->packetno = 0;
- gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, (guint64) 0,
- GST_FORMAT_DEFAULT, (guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
+ gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE,
+ GST_FORMAT_TIME, (guint64) 0, GST_FORMAT_DEFAULT,
+ (guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
} else {
dec->packetno = 3;
/* if one of them works, all of them work */
- if (vorbis_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos, &time) &&
- vorbis_dec_from_granulepos (dec, GST_FORMAT_DEFAULT, dec->granulepos, &value) &&
- vorbis_dec_from_granulepos (dec, GST_FORMAT_BYTES, dec->granulepos, &bytes)) {
- gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
- GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes, 0)));
+ if (vorbis_dec_from_granulepos (dec, GST_FORMAT_TIME, dec->granulepos,
+ &time)
+ && vorbis_dec_from_granulepos (dec, GST_FORMAT_DEFAULT,
+ dec->granulepos, &value)
+ && vorbis_dec_from_granulepos (dec, GST_FORMAT_BYTES,
+ dec->granulepos, &bytes)) {
+ gst_pad_push (dec->srcpad,
+ GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
+ time, GST_FORMAT_DEFAULT, value, GST_FORMAT_BYTES, bytes,
+ 0)));
} else {
- GST_ERROR_OBJECT (dec, "failed to parse data for DISCONT event, not sending any");
+ GST_ERROR_OBJECT (dec,
+ "failed to parse data for DISCONT event, not sending any");
}
#ifdef HAVE_VORBIS_SYNTHESIS_RESTART
vorbis_synthesis_restart (&dec->vd);
}
static void
-vorbis_dec_chain (GstPad *pad, GstData *data)
+vorbis_dec_chain (GstPad * pad, GstData * data)
{
GstBuffer *buf;
GstVorbisDec *vd;
- ogg_packet packet; /* lol */
+ ogg_packet packet; /* lol */
vd = GST_VORBIS_DEC (gst_pad_get_parent (pad));
if (GST_IS_EVENT (data)) {
packet.packet = GST_BUFFER_DATA (buf);
packet.bytes = GST_BUFFER_SIZE (buf);
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
- packet.packetno = vd->packetno ++;
+ packet.packetno = vd->packetno++;
/* switch depending on packet type */
if (packet.packet[0] & 1) {
/* header packet */
if (packet.packet[0] / 2 != packet.packetno) {
/* FIXME: just skip? */
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
- (NULL), ("unexpected packet type %d, expected %d", (gint) packet.packet[0], (gint) packet.packetno));
+ (NULL), ("unexpected packet type %d, expected %d",
+ (gint) packet.packet[0], (gint) packet.packetno));
gst_data_unref (data);
return;
}
if (vorbis_synthesis_headerin (&vd->vi, &vd->vc, &packet)) {
- GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
+ GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
(NULL), ("couldn't read header packet"));
gst_data_unref (data);
return;
}
if (packet.packetno == 1) {
gchar *encoder = NULL;
- GstTagList *list = gst_tag_list_from_vorbiscomment_buffer (buf, "\003vorbis", 7, &encoder);
+ GstTagList *list =
+ gst_tag_list_from_vorbiscomment_buffer (buf, "\003vorbis", 7,
+ &encoder);
+
if (!list) {
GST_ERROR_OBJECT (vd, "couldn't decode comments");
list = gst_tag_list_new ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_ENCODER_VERSION, vd->vi.version, NULL);
if (vd->vi.bitrate_upper > 0)
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+ gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_MAXIMUM_BITRATE, (guint) vd->vi.bitrate_upper, NULL);
if (vd->vi.bitrate_nominal > 0)
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+ gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_NOMINAL_BITRATE, (guint) vd->vi.bitrate_nominal, NULL);
if (vd->vi.bitrate_lower > 0)
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+ gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_MINIMUM_BITRATE, (guint) vd->vi.bitrate_lower, NULL);
gst_element_found_tags_for_pad (GST_ELEMENT (vd), vd->srcpad, 0, list);
} else if (packet.packetno == 2) {
} else {
float **pcm;
guint sample_count;
-
+
/* normal data packet */
if (vorbis_synthesis (&vd->vb, &packet)) {
- GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
+ GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
(NULL), ("couldn't read data packet"));
gst_data_unref (data);
return;
sample_count = vorbis_synthesis_pcmout (&vd->vd, &pcm);
if (sample_count > 0) {
int i, j;
- GstBuffer *out = gst_pad_alloc_buffer (vd->srcpad, GST_BUFFER_OFFSET_NONE,
+ GstBuffer *out = gst_pad_alloc_buffer (vd->srcpad, GST_BUFFER_OFFSET_NONE,
sample_count * vd->vi.channels * sizeof (float));
float *out_data = (float *) GST_BUFFER_DATA (out);
+
#ifdef GST_VORBIS_DEC_SEQUENTIAL
for (i = 0; i < vd->vi.channels; i++) {
memcpy (out_data, pcm[i], sample_count * sizeof (float));
}
static GstElementStateReturn
-vorbis_dec_change_state (GstElement *element)
+vorbis_dec_change_state (GstElement * element)
{
GstVorbisDec *vd = GST_VORBIS_DEC (element);
#include <vorbis/codec.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_VORBIS_DEC \
#define GST_IS_VORBIS_DEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VORBIS_DEC))
-typedef struct _GstVorbisDec GstVorbisDec;
-typedef struct _GstVorbisDecClass GstVorbisDecClass;
+ typedef struct _GstVorbisDec GstVorbisDec;
+ typedef struct _GstVorbisDecClass GstVorbisDecClass;
-struct _GstVorbisDec {
- GstElement element;
+ struct _GstVorbisDec
+ {
+ GstElement element;
- GstPad * sinkpad;
- GstPad * srcpad;
+ GstPad *sinkpad;
+ GstPad *srcpad;
- vorbis_dsp_state vd;
- vorbis_info vi;
- vorbis_comment vc;
- vorbis_block vb;
- guint packetno;
- guint64 granulepos;
-};
+ vorbis_dsp_state vd;
+ vorbis_info vi;
+ vorbis_comment vc;
+ vorbis_block vb;
+ guint packetno;
+ guint64 granulepos;
+ };
-struct _GstVorbisDecClass {
- GstElementClass parent_class;
-};
+ struct _GstVorbisDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_vorbis_dec_get_type(void);
+ GType gst_vorbis_dec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_VORBIS_DEC_H__ */
+#endif /* __GST_VORBIS_DEC_H__ */
"Ogg Vorbis encoder",
"Codec/Encoder/Audio",
"Encodes audio in OGG Vorbis format",
- "Monty <monty@xiph.org>, "
- "Wim Taymans <wim.taymans@chello.be>",
+ "Monty <monty@xiph.org>, " "Wim Taymans <wim.taymans@chello.be>",
};
/* VorbisEnc signals and args */
ARG_LAST_MESSAGE,
};
-static const GstFormat*
-gst_vorbisenc_get_formats (GstPad *pad)
+static const GstFormat *
+gst_vorbisenc_get_formats (GstPad * pad)
{
static const GstFormat src_formats[] = {
GST_FORMAT_BYTES,
static const GstFormat sink_formats[] = {
GST_FORMAT_BYTES,
GST_FORMAT_DEFAULT,
- GST_FORMAT_TIME,
+ GST_FORMAT_TIME,
0
};
-
+
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
-}
+}
#define MAX_BITRATE_DEFAULT -1
#define BITRATE_DEFAULT -1
#define MIN_BITRATE_DEFAULT -1
#define QUALITY_DEFAULT 0.3
-static void gst_vorbisenc_base_init (gpointer g_class);
-static void gst_vorbisenc_class_init (VorbisEncClass *klass);
-static void gst_vorbisenc_init (VorbisEnc *vorbisenc);
+static void gst_vorbisenc_base_init (gpointer g_class);
+static void gst_vorbisenc_class_init (VorbisEncClass * klass);
+static void gst_vorbisenc_init (VorbisEnc * vorbisenc);
-static void gst_vorbisenc_chain (GstPad *pad, GstData *_data);
-static gboolean gst_vorbisenc_setup (VorbisEnc *vorbisenc);
+static void gst_vorbisenc_chain (GstPad * pad, GstData * _data);
+static gboolean gst_vorbisenc_setup (VorbisEnc * vorbisenc);
-static void gst_vorbisenc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static void gst_vorbisenc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static GstElementStateReturn
- gst_vorbisenc_change_state (GstElement *element);
+static void gst_vorbisenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_vorbisenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_vorbisenc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_vorbisenc_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!vorbisenc_type) {
static const GTypeInfo vorbisenc_info = {
- sizeof (VorbisEncClass),
+ sizeof (VorbisEncClass),
gst_vorbisenc_base_init,
NULL,
(GClassInitFunc) gst_vorbisenc_class_init,
NULL,
NULL
};
-
- vorbisenc_type = g_type_register_static (GST_TYPE_ELEMENT, "VorbisEnc", &vorbisenc_info, 0);
-
- g_type_add_interface_static (vorbisenc_type, GST_TYPE_TAG_SETTER, &tag_setter_info);
+
+ vorbisenc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "VorbisEnc", &vorbisenc_info,
+ 0);
+
+ g_type_add_interface_static (vorbisenc_type, GST_TYPE_TAG_SETTER,
+ &tag_setter_info);
}
return vorbisenc_type;
}
-static GstCaps*
+static GstCaps *
vorbis_caps_factory (void)
{
return gst_caps_new_simple ("application/ogg", NULL);
}
-static GstCaps*
+static GstCaps *
raw_caps_factory (void)
{
return
- 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,
- "rate", GST_TYPE_INT_RANGE, 11025, 48000,
- "channels", GST_TYPE_INT_RANGE, 1, 2,
- NULL);
+ 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,
+ "rate", GST_TYPE_INT_RANGE, 11025, 48000,
+ "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
}
static void
raw_caps = raw_caps_factory ();
vorbis_caps = vorbis_caps_factory ();
- gst_vorbisenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- raw_caps);
- gst_vorbisenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- vorbis_caps);
- gst_element_class_add_pad_template (element_class, gst_vorbisenc_sink_template);
- gst_element_class_add_pad_template (element_class, gst_vorbisenc_src_template);
+ gst_vorbisenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, raw_caps);
+ gst_vorbisenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, vorbis_caps);
+ gst_element_class_add_pad_template (element_class,
+ gst_vorbisenc_sink_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_vorbisenc_src_template);
gst_element_class_set_details (element_class, &vorbisenc_details);
}
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_BITRATE,
- g_param_spec_int ("max_bitrate", "Max bitrate",
- " Specify a minimum bitrate (in bps). Useful for encoding for a fixed-size channel",
- -1, G_MAXINT, MAX_BITRATE_DEFAULT, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
- g_param_spec_int ("bitrate", "Bitrate", "Choose a bitrate to encode at. "
- "Attempt to encode at a bitrate averaging this. Takes an argument in kbps.",
- -1, G_MAXINT, BITRATE_DEFAULT, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MIN_BITRATE,
- g_param_spec_int ("min_bitrate", "Min bitrate",
- "Specify a maximum bitrate in bps. Useful for streaming applications.",
- -1, G_MAXINT, MIN_BITRATE_DEFAULT, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
- g_param_spec_float ("quality", "Quality",
- "Specify quality instead of specifying a particular bitrate.",
- 0.0, 1.0, QUALITY_DEFAULT, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SERIAL,
- g_param_spec_int ("serial", "Serial", "Specify a serial number for the stream. (-1 is random)",
- -1, G_MAXINT, -1, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MANAGED,
- g_param_spec_boolean ("managed", "Managed", "Enable bitrate management engine",
- FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_BITRATE,
+ g_param_spec_int ("max_bitrate", "Max bitrate",
+ " Specify a minimum bitrate (in bps). Useful for encoding for a fixed-size channel",
+ -1, G_MAXINT, MAX_BITRATE_DEFAULT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
+ g_param_spec_int ("bitrate", "Bitrate", "Choose a bitrate to encode at. "
+ "Attempt to encode at a bitrate averaging this. Takes an argument in kbps.",
+ -1, G_MAXINT, BITRATE_DEFAULT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MIN_BITRATE,
+ g_param_spec_int ("min_bitrate", "Min bitrate",
+ "Specify a maximum bitrate in bps. Useful for streaming applications.",
+ -1, G_MAXINT, MIN_BITRATE_DEFAULT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
+ g_param_spec_float ("quality", "Quality",
+ "Specify quality instead of specifying a particular bitrate.",
+ 0.0, 1.0, QUALITY_DEFAULT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SERIAL,
+ g_param_spec_int ("serial", "Serial",
+ "Specify a serial number for the stream. (-1 is random)", -1,
+ G_MAXINT, -1, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MANAGED,
+ g_param_spec_boolean ("managed", "Managed",
+ "Enable bitrate management engine", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last-message", "last-message", "The last status message",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last-message", "last-message",
+ "The last status message", NULL, G_PARAM_READABLE));
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "channels", &vorbisenc->channels);
- gst_structure_get_int (structure, "rate", &vorbisenc->frequency);
+ gst_structure_get_int (structure, "channels", &vorbisenc->channels);
+ gst_structure_get_int (structure, "rate", &vorbisenc->frequency);
gst_vorbisenc_setup (vorbisenc);
}
static gboolean
-gst_vorbisenc_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_vorbisenc_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
VorbisEnc *vorbisenc;
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
- if (vorbisenc->samples_in == 0 ||
- vorbisenc->bytes_out == 0 ||
- vorbisenc->frequency == 0)
+ if (vorbisenc->samples_in == 0 ||
+ vorbisenc->bytes_out == 0 || vorbisenc->frequency == 0)
return FALSE;
- avg = (vorbisenc->bytes_out * vorbisenc->frequency)/
- (vorbisenc->samples_in);
+ avg = (vorbisenc->bytes_out * vorbisenc->frequency) / (vorbisenc->samples_in);
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * GST_SECOND / avg;
- break;
- default:
- res = FALSE;
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * GST_SECOND / avg;
+ break;
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- *dest_value = src_value * avg / GST_SECOND;
- break;
- default:
- res = FALSE;
+ case GST_FORMAT_BYTES:
+ *dest_value = src_value * avg / GST_SECOND;
+ break;
+ default:
+ res = FALSE;
}
break;
default:
}
static gboolean
-gst_vorbisenc_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_vorbisenc_convert_sink (GstPad * pad, GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
guint scale = 1;
VorbisEnc *vorbisenc;
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
-
+
bytes_per_sample = vorbisenc->channels * 2;
-
+
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_DEFAULT:
if (bytes_per_sample == 0)
- return FALSE;
+ return FALSE;
*dest_value = src_value / bytes_per_sample;
- break;
- case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_TIME:
{
- gint byterate = bytes_per_sample * vorbisenc->frequency;
+ gint byterate = bytes_per_sample * vorbisenc->frequency;
if (byterate == 0)
- return FALSE;
+ return FALSE;
*dest_value = src_value * GST_SECOND / byterate;
- break;
+ break;
}
- default:
- res = FALSE;
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
break;
- case GST_FORMAT_TIME:
+ case GST_FORMAT_TIME:
if (vorbisenc->frequency == 0)
- return FALSE;
+ return FALSE;
*dest_value = src_value * GST_SECOND / vorbisenc->frequency;
- break;
- default:
- res = FALSE;
+ break;
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
scale = bytes_per_sample;
/* fallthrough */
- case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_DEFAULT:
*dest_value = src_value * scale * vorbisenc->frequency / GST_SECOND;
- break;
- default:
- res = FALSE;
+ break;
+ default:
+ res = FALSE;
}
break;
default:
return res;
}
-static const GstQueryType*
-gst_vorbisenc_get_query_types (GstPad *pad)
+static const GstQueryType *
+gst_vorbisenc_get_query_types (GstPad * pad)
{
static const GstQueryType gst_vorbisenc_src_query_types[] = {
GST_QUERY_TOTAL,
}
static gboolean
-gst_vorbisenc_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_vorbisenc_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = TRUE;
VorbisEnc *vorbisenc;
-
+
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
switch (type) {
switch (*format) {
case GST_FORMAT_BYTES:
case GST_FORMAT_TIME:
- {
+ {
gint64 peer_value;
- const GstFormat *peer_formats;
+ const GstFormat *peer_formats;
res = FALSE;
- peer_formats = gst_pad_get_formats (GST_PAD_PEER (vorbisenc->sinkpad));
+ peer_formats =
+ gst_pad_get_formats (GST_PAD_PEER (vorbisenc->sinkpad));
while (peer_formats && *peer_formats && !res) {
GstFormat peer_format = *peer_formats;
/* do the probe */
- if (gst_pad_query (GST_PAD_PEER (vorbisenc->sinkpad), GST_QUERY_TOTAL,
- &peer_format, &peer_value))
- {
- GstFormat conv_format;
+ if (gst_pad_query (GST_PAD_PEER (vorbisenc->sinkpad),
+ GST_QUERY_TOTAL, &peer_format, &peer_value)) {
+ GstFormat conv_format;
+
/* convert to TIME */
- conv_format = GST_FORMAT_TIME;
+ conv_format = GST_FORMAT_TIME;
res = gst_pad_convert (vorbisenc->sinkpad,
- peer_format, peer_value,
- &conv_format, value);
+ peer_format, peer_value, &conv_format, value);
/* and to final format */
res &= gst_pad_convert (pad,
- GST_FORMAT_TIME, *value,
- format, value);
+ GST_FORMAT_TIME, *value, format, value);
}
peer_formats++;
}
{
/* we only know about our samples, convert to requested format */
res = gst_pad_convert (pad,
- GST_FORMAT_BYTES, vorbisenc->bytes_out,
- format, value);
+ GST_FORMAT_BYTES, vorbisenc->bytes_out, format, value);
break;
}
}
static void
gst_vorbisenc_init (VorbisEnc * vorbisenc)
{
- vorbisenc->sinkpad = gst_pad_new_from_template (gst_vorbisenc_sink_template, "sink");
+ vorbisenc->sinkpad =
+ gst_pad_new_from_template (gst_vorbisenc_sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->sinkpad);
gst_pad_set_chain_function (vorbisenc->sinkpad, gst_vorbisenc_chain);
gst_pad_set_link_function (vorbisenc->sinkpad, gst_vorbisenc_sinkconnect);
- gst_pad_set_convert_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_sink));
- gst_pad_set_formats_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
-
- vorbisenc->srcpad = gst_pad_new_from_template (gst_vorbisenc_src_template, "src");
- gst_pad_set_query_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_src_query));
- gst_pad_set_query_type_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_get_query_types));
- gst_pad_set_convert_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_src));
- gst_pad_set_formats_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
+ gst_pad_set_convert_function (vorbisenc->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_sink));
+ gst_pad_set_formats_function (vorbisenc->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
+
+ vorbisenc->srcpad =
+ gst_pad_new_from_template (gst_vorbisenc_src_template, "src");
+ gst_pad_set_query_function (vorbisenc->srcpad,
+ GST_DEBUG_FUNCPTR (gst_vorbisenc_src_query));
+ gst_pad_set_query_type_function (vorbisenc->srcpad,
+ GST_DEBUG_FUNCPTR (gst_vorbisenc_get_query_types));
+ gst_pad_set_convert_function (vorbisenc->srcpad,
+ GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_src));
+ gst_pad_set_formats_function (vorbisenc->srcpad,
+ GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->srcpad);
vorbisenc->channels = -1;
vorbisenc->quality_set = FALSE;
vorbisenc->serial = -1;
vorbisenc->last_message = NULL;
-
+
vorbisenc->setup = FALSE;
vorbisenc->eos = FALSE;
vorbisenc->header_sent = FALSE;
vorbisenc->tags = gst_tag_list_new ();
-
+
/* we're chained and we can deal with events */
GST_FLAG_SET (vorbisenc, GST_ELEMENT_EVENT_AWARE);
}
static gchar *
-gst_vorbisenc_get_tag_value (const GstTagList *list, const gchar *tag, int index)
+gst_vorbisenc_get_tag_value (const GstTagList * list, const gchar * tag,
+ int index)
{
gchar *vorbisvalue = NULL;
}
/* get tag name right */
- if ((strcmp (tag, GST_TAG_TRACK_NUMBER) == 0)
- || (strcmp (tag, GST_TAG_ALBUM_VOLUME_NUMBER) == 0)
- || (strcmp (tag, GST_TAG_TRACK_COUNT) == 0)
+ if ((strcmp (tag, GST_TAG_TRACK_NUMBER) == 0)
+ || (strcmp (tag, GST_TAG_ALBUM_VOLUME_NUMBER) == 0)
+ || (strcmp (tag, GST_TAG_TRACK_COUNT) == 0)
|| (strcmp (tag, GST_TAG_ALBUM_VOLUME_COUNT) == 0)) {
guint track_no;
+
g_assert (gst_tag_list_get_uint_index (list, tag, index, &track_no));
vorbisvalue = g_strdup_printf ("%u", track_no);
} else if (strcmp (tag, GST_TAG_DATE) == 0) {
/* FIXME: how are dates represented in vorbis files? */
GDate *date;
guint u;
-
+
g_assert (gst_tag_list_get_uint_index (list, tag, index, &u));
date = g_date_new_julian (u);
- vorbisvalue = g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
- (gint) g_date_get_month (date), (gint) g_date_get_day (date));
+ vorbisvalue =
+ g_strdup_printf ("%04d-%02d-%02d", (gint) g_date_get_year (date),
+ (gint) g_date_get_month (date), (gint) g_date_get_day (date));
g_date_free (date);
} else if (gst_tag_get_type (tag) == G_TYPE_STRING) {
- g_assert (gst_tag_list_get_string_index (list, tag, index, &vorbisvalue));
+ g_assert (gst_tag_list_get_string_index (list, tag, index, &vorbisvalue));
}
return vorbisvalue;
}
static void
-gst_vorbisenc_metadata_set1 (const GstTagList *list, const gchar *tag, gpointer vorbisenc)
+gst_vorbisenc_metadata_set1 (const GstTagList * list, const gchar * tag,
+ gpointer vorbisenc)
{
const gchar *vorbistag = NULL;
gchar *vorbisvalue = NULL;
count = gst_tag_list_get_tag_size (list, tag);
for (i = 0; i < count; i++) {
vorbisvalue = gst_vorbisenc_get_tag_value (list, tag, i);
-
+
if (vorbisvalue != NULL) {
vorbis_comment_add_tag (&enc->vc, g_strdup (vorbistag), vorbisvalue);
}
}
}
-static void
-gst_vorbisenc_set_metadata (VorbisEnc *vorbisenc)
+static void
+gst_vorbisenc_set_metadata (VorbisEnc * vorbisenc)
{
- GstTagList *copy;
+ GstTagList *copy;
const GstTagList *user_tags;
-
+
user_tags = gst_tag_setter_get_list (GST_TAG_SETTER (vorbisenc));
if (!(vorbisenc->tags || user_tags))
return;
- copy = gst_tag_list_merge (user_tags, vorbisenc->tags, gst_tag_setter_get_merge_mode (GST_TAG_SETTER (vorbisenc)));
+ copy =
+ gst_tag_list_merge (user_tags, vorbisenc->tags,
+ gst_tag_setter_get_merge_mode (GST_TAG_SETTER (vorbisenc)));
vorbis_comment_init (&vorbisenc->vc);
gst_tag_list_foreach (copy, gst_vorbisenc_metadata_set1, vorbisenc);
gst_tag_list_free (copy);
}
-static gchar*
-get_constraints_string (VorbisEnc *vorbisenc)
+static gchar *
+get_constraints_string (VorbisEnc * vorbisenc)
{
gint min = vorbisenc->min_bitrate;
gint max = vorbisenc->max_bitrate;
gchar *result;
if (min > 0 && max > 0)
- result = g_strdup_printf ("(min %d bps, max %d bps)", min,max);
+ result = g_strdup_printf ("(min %d bps, max %d bps)", min, max);
else if (min > 0)
result = g_strdup_printf ("(min %d bps, no max)", min);
else if (max > 0)
}
static void
-update_start_message (VorbisEnc *vorbisenc)
+update_start_message (VorbisEnc * vorbisenc)
{
gchar *constraints;
if (vorbisenc->bitrate > 0) {
if (vorbisenc->managed) {
constraints = get_constraints_string (vorbisenc);
- vorbisenc->last_message =
- g_strdup_printf ("encoding at average bitrate %d bps %s",
- vorbisenc->bitrate, constraints);
+ vorbisenc->last_message =
+ g_strdup_printf ("encoding at average bitrate %d bps %s",
+ vorbisenc->bitrate, constraints);
g_free (constraints);
+ } else {
+ vorbisenc->last_message =
+ g_strdup_printf
+ ("encoding at approximate bitrate %d bps (VBR encoding enabled)",
+ vorbisenc->bitrate);
}
- else {
- vorbisenc->last_message =
- g_strdup_printf ("encoding at approximate bitrate %d bps (VBR encoding enabled)",
- vorbisenc->bitrate);
- }
- }
- else {
+ } else {
if (vorbisenc->quality_set) {
if (vorbisenc->managed) {
- constraints = get_constraints_string (vorbisenc);
- vorbisenc->last_message =
- g_strdup_printf ("encoding at quality level %2.2f using constrained VBR %s",
- vorbisenc->quality, constraints);
- g_free (constraints);
- }
- else {
- vorbisenc->last_message =
- g_strdup_printf ("encoding at quality level %2.2f",
- vorbisenc->quality);
+ constraints = get_constraints_string (vorbisenc);
+ vorbisenc->last_message =
+ g_strdup_printf
+ ("encoding at quality level %2.2f using constrained VBR %s",
+ vorbisenc->quality, constraints);
+ g_free (constraints);
+ } else {
+ vorbisenc->last_message =
+ g_strdup_printf ("encoding at quality level %2.2f",
+ vorbisenc->quality);
}
- }
- else {
+ } else {
constraints = get_constraints_string (vorbisenc);
- vorbisenc->last_message =
- g_strdup_printf ("encoding using bitrate management %s",
- constraints);
+ vorbisenc->last_message =
+ g_strdup_printf ("encoding using bitrate management %s", constraints);
g_free (constraints);
}
}
}
static gboolean
-gst_vorbisenc_setup (VorbisEnc *vorbisenc)
+gst_vorbisenc_setup (VorbisEnc * vorbisenc)
{
gint serial;
- if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0 && vorbisenc->max_bitrate < 0) {
+ if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0
+ && vorbisenc->max_bitrate < 0) {
vorbisenc->quality_set = TRUE;
}
update_start_message (vorbisenc);
-
+
/* choose an encoding mode */
/* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
vorbis_info_init (&vorbisenc->vi);
- if(vorbisenc->quality_set){
- if (vorbis_encode_setup_vbr (&vorbisenc->vi,
- vorbisenc->channels,
- vorbisenc->frequency,
- vorbisenc->quality))
- {
- g_warning ("vorbisenc: initialisation failed: invalid parameters for quality");
- vorbis_info_clear(&vorbisenc->vi);
- return FALSE;
+ if (vorbisenc->quality_set) {
+ if (vorbis_encode_setup_vbr (&vorbisenc->vi,
+ vorbisenc->channels, vorbisenc->frequency, vorbisenc->quality)) {
+ g_warning
+ ("vorbisenc: initialisation failed: invalid parameters for quality");
+ vorbis_info_clear (&vorbisenc->vi);
+ return FALSE;
}
/* do we have optional hard quality restrictions? */
- if(vorbisenc->max_bitrate > 0 || vorbisenc->min_bitrate > 0){
+ if (vorbisenc->max_bitrate > 0 || vorbisenc->min_bitrate > 0) {
struct ovectl_ratemanage_arg ai;
+
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_GET, &ai);
/* the bitrates are in kHz */
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, &ai);
}
- }
- else {
- if (vorbis_encode_setup_managed (&vorbisenc->vi,
- vorbisenc->channels,
- vorbisenc->frequency,
- vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1,
- vorbisenc->bitrate,
- vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1))
- {
- g_warning("vorbisenc: initialisation failed: invalid parameters for bitrate\n");
- vorbis_info_clear(&vorbisenc->vi);
+ } else {
+ if (vorbis_encode_setup_managed (&vorbisenc->vi,
+ vorbisenc->channels,
+ vorbisenc->frequency,
+ vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1,
+ vorbisenc->bitrate,
+ vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1)) {
+ g_warning
+ ("vorbisenc: initialisation failed: invalid parameters for bitrate\n");
+ vorbis_info_clear (&vorbisenc->vi);
return FALSE;
}
}
- if(vorbisenc->managed && vorbisenc->bitrate < 0) {
- vorbis_encode_ctl(&vorbisenc->vi, OV_ECTL_RATEMANAGE_AVG, NULL);
- }
- else if(!vorbisenc->managed) {
+ if (vorbisenc->managed && vorbisenc->bitrate < 0) {
+ vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_AVG, NULL);
+ } else if (!vorbisenc->managed) {
/* Turn off management entirely (if it was turned on). */
- vorbis_encode_ctl(&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, NULL);
+ vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, NULL);
}
- vorbis_encode_setup_init(&vorbisenc->vi);
+ vorbis_encode_setup_init (&vorbisenc->vi);
/* set up the analysis state and auxiliary encoding storage */
vorbis_analysis_init (&vorbisenc->vd, &vorbisenc->vi);
if (vorbisenc->serial < 0) {
srand (time (NULL));
serial = rand ();
- }
- else {
+ } else {
serial = vorbisenc->serial;
}
}
static void
-gst_vorbisenc_write_page (VorbisEnc *vorbisenc, ogg_page *page)
+gst_vorbisenc_write_page (VorbisEnc * vorbisenc, ogg_page * page)
{
GstBuffer *outbuf;
- outbuf = gst_buffer_new_and_alloc (page->header_len +
- page->body_len);
+ outbuf = gst_buffer_new_and_alloc (page->header_len + page->body_len);
- memcpy (GST_BUFFER_DATA (outbuf), page->header,
- page->header_len);
- memcpy (GST_BUFFER_DATA (outbuf) + page->header_len,
- page->body,
- page->body_len);
+ memcpy (GST_BUFFER_DATA (outbuf), page->header, page->header_len);
+ memcpy (GST_BUFFER_DATA (outbuf) + page->header_len,
+ page->body, page->body_len);
- GST_DEBUG ("vorbisenc: encoded buffer of %d bytes",
- GST_BUFFER_SIZE (outbuf));
+ GST_DEBUG ("vorbisenc: encoded buffer of %d bytes", GST_BUFFER_SIZE (outbuf));
vorbisenc->bytes_out += GST_BUFFER_SIZE (outbuf);
if (GST_PAD_IS_USABLE (vorbisenc->srcpad)) {
gst_pad_push (vorbisenc->srcpad, GST_DATA (outbuf));
- }
- else {
+ } else {
gst_buffer_unref (outbuf);
}
}
static void
-gst_vorbisenc_chain (GstPad * pad, GstData *_data)
+gst_vorbisenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
VorbisEnc *vorbisenc;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- /* end of file. this can be done implicitly in the mainline,
- but it's easier to see here in non-clever fashion.
- Tell the library we're at end of stream so that it can handle
- the last frame and mark end of stream in the output properly */
- vorbis_analysis_wrote (&vorbisenc->vd, 0);
+ /* end of file. this can be done implicitly in the mainline,
+ but it's easier to see here in non-clever fashion.
+ Tell the library we're at end of stream so that it can handle
+ the last frame and mark end of stream in the output properly */
+ vorbis_analysis_wrote (&vorbisenc->vd, 0);
gst_event_unref (event);
break;
case GST_EVENT_TAG:
if (vorbisenc->tags) {
- gst_tag_list_insert (vorbisenc->tags, gst_event_tag_get_list (event),
- gst_tag_setter_get_merge_mode (GST_TAG_SETTER (vorbisenc)));
+ gst_tag_list_insert (vorbisenc->tags, gst_event_tag_get_list (event),
+ gst_tag_setter_get_merge_mode (GST_TAG_SETTER (vorbisenc)));
} else {
g_assert_not_reached ();
}
return;
default:
gst_pad_event_default (pad, event);
- return;
+ return;
}
- }
- else {
+ } else {
gint16 *data;
gulong size;
gulong i, j;
if (!vorbisenc->setup) {
gst_buffer_unref (buf);
- GST_ELEMENT_ERROR (vorbisenc, CORE, NEGOTIATION, (NULL), ("encoder not initialized (input is not audio?)"));
+ GST_ELEMENT_ERROR (vorbisenc, CORE, NEGOTIATION, (NULL),
+ ("encoder not initialized (input is not audio?)"));
return;
}
if (!vorbisenc->header_sent) {
gint result;
+
/* Vorbis streams begin with three headers; the initial header (with
- most of the codec setup parameters) which is mandated by the Ogg
- bitstream spec. The second header holds any comment fields. The
- third header holds the bitstream codebook. We merely need to
- make the headers, then pass them to libvorbis one at a time;
- libvorbis handles the additional Ogg bitstream constraints */
+ most of the codec setup parameters) which is mandated by the Ogg
+ bitstream spec. The second header holds any comment fields. The
+ third header holds the bitstream codebook. We merely need to
+ make the headers, then pass them to libvorbis one at a time;
+ libvorbis handles the additional Ogg bitstream constraints */
ogg_packet header;
ogg_packet header_comm;
ogg_packet header_code;
gst_vorbisenc_set_metadata (vorbisenc);
- vorbis_analysis_headerout (&vorbisenc->vd, &vorbisenc->vc, &header, &header_comm, &header_code);
- ogg_stream_packetin (&vorbisenc->os, &header); /* automatically placed in its own page */
+ vorbis_analysis_headerout (&vorbisenc->vd, &vorbisenc->vc, &header,
+ &header_comm, &header_code);
+ ogg_stream_packetin (&vorbisenc->os, &header); /* automatically placed in its own page */
ogg_stream_packetin (&vorbisenc->os, &header_comm);
ogg_stream_packetin (&vorbisenc->os, &header_code);
- while ((result = ogg_stream_flush(&vorbisenc->os, &vorbisenc->og))) {
+ while ((result = ogg_stream_flush (&vorbisenc->os, &vorbisenc->og))) {
gst_vorbisenc_write_page (vorbisenc, &vorbisenc->og);
}
vorbisenc->header_sent = TRUE;
}
-
+
/* data to encode */
data = (gint16 *) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf) / (vorbisenc->channels * 2);
/* analysis */
vorbis_analysis (&vorbisenc->vb, NULL);
- vorbis_bitrate_addblock(&vorbisenc->vb);
-
+ vorbis_bitrate_addblock (&vorbisenc->vb);
+
while (vorbis_bitrate_flushpacket (&vorbisenc->vd, &vorbisenc->op)) {
/* weld the packet into the bitstream */
/* write out pages (if any) */
while (!vorbisenc->eos) {
- int result = ogg_stream_pageout (&vorbisenc->os, &vorbisenc->og);
+ int result = ogg_stream_pageout (&vorbisenc->os, &vorbisenc->og);
- if (result == 0)
+ if (result == 0)
break;
gst_vorbisenc_write_page (vorbisenc, &vorbisenc->og);
- /* this could be set above, but for illustrative purposes, I do
- it here (to show that vorbis does know where the stream ends) */
- if (ogg_page_eos (&vorbisenc->og)) {
+ /* this could be set above, but for illustrative purposes, I do
+ it here (to show that vorbis does know where the stream ends) */
+ if (ogg_page_eos (&vorbisenc->og)) {
vorbisenc->eos = 1;
- }
+ }
}
}
}
}
static void
-gst_vorbisenc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_vorbisenc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
VorbisEnc *vorbisenc;
}
static void
-gst_vorbisenc_set_property (GObject * object, guint prop_id, const GValue * value,
- GParamSpec * pspec)
+gst_vorbisenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
VorbisEnc *vorbisenc;
vorbisenc->max_bitrate = g_value_get_int (value);
if (vorbisenc->min_bitrate > 0 && vorbisenc->max_bitrate > 0)
- vorbisenc->managed = TRUE;
+ vorbisenc->managed = TRUE;
else
- vorbisenc->managed = FALSE;
+ vorbisenc->managed = FALSE;
if (old_value != vorbisenc->managed)
g_object_notify (object, "managed");
vorbisenc->min_bitrate = g_value_get_int (value);
if (vorbisenc->min_bitrate > 0 && vorbisenc->max_bitrate > 0)
- vorbisenc->managed = TRUE;
+ vorbisenc->managed = TRUE;
else
- vorbisenc->managed = FALSE;
+ vorbisenc->managed = FALSE;
if (old_value != vorbisenc->managed)
g_object_notify (object, "managed");
case ARG_QUALITY:
vorbisenc->quality = g_value_get_float (value);
if (vorbisenc->quality >= 0.0)
- vorbisenc->quality_set = TRUE;
+ vorbisenc->quality_set = TRUE;
else
- vorbisenc->quality_set = FALSE;
+ vorbisenc->quality_set = FALSE;
break;
case ARG_SERIAL:
vorbisenc->serial = g_value_get_int (value);
}
static GstElementStateReturn
-gst_vorbisenc_change_state (GstElement *element)
+gst_vorbisenc_change_state (GstElement * element)
{
VorbisEnc *vorbisenc = GST_VORBISENC (element);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
case GST_STATE_READY_TO_PAUSED:
return GST_STATE_SUCCESS;
}
-
#include <vorbis/codec.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_VORBISENC \
(vorbisenc_get_type())
#define GST_IS_VORBISENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VORBISENC))
-typedef struct _VorbisEnc VorbisEnc;
-typedef struct _VorbisEncClass VorbisEncClass;
+ typedef struct _VorbisEnc VorbisEnc;
+ typedef struct _VorbisEncClass VorbisEncClass;
-struct _VorbisEnc {
- GstElement element;
+ struct _VorbisEnc
+ {
+ GstElement element;
- GstPad *sinkpad,
- *srcpad;
+ GstPad *sinkpad, *srcpad;
- ogg_stream_state os; /* take physical pages, weld into a logical
- stream of packets */
- ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
- ogg_packet op; /* one raw packet of data for decode */
+ ogg_stream_state os; /* take physical pages, weld into a logical
+ stream of packets */
+ ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
+ ogg_packet op; /* one raw packet of data for decode */
- vorbis_info vi; /* struct that stores all the static vorbis bitstream
- settings */
- vorbis_comment vc; /* struct that stores all the user comments */
+ vorbis_info vi; /* struct that stores all the static vorbis bitstream
+ settings */
+ vorbis_comment vc; /* struct that stores all the user comments */
- vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
- vorbis_block vb; /* local working space for packet->PCM decode */
+ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+ vorbis_block vb; /* local working space for packet->PCM decode */
- gboolean eos;
+ gboolean eos;
- gboolean managed;
- gint bitrate;
- gint min_bitrate;
- gint max_bitrate;
- gfloat quality;
- gboolean quality_set;
- gint serial;
+ gboolean managed;
+ gint bitrate;
+ gint min_bitrate;
+ gint max_bitrate;
+ gfloat quality;
+ gboolean quality_set;
+ gint serial;
- gint channels;
- gint frequency;
+ gint channels;
+ gint frequency;
- guint64 samples_in;
- guint64 bytes_out;
+ guint64 samples_in;
+ guint64 bytes_out;
- GstTagList * tags;
+ GstTagList *tags;
- gboolean setup;
- gboolean header_sent;
- gchar *last_message;
-};
+ gboolean setup;
+ gboolean header_sent;
+ gchar *last_message;
+ };
-struct _VorbisEncClass {
- GstElementClass parent_class;
-};
+ struct _VorbisEncClass
+ {
+ GstElementClass parent_class;
+ };
-GType vorbisenc_get_type(void);
+ GType vorbisenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __VORBISENC_H__ */
+#endif /* __VORBISENC_H__ */
#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
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
/* 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
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
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);
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
*/
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)
* 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 };
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);
}
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);
#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
*
* 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 ], " \
"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, " \
"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 ], " \
"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, " \
"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__ */
#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),
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");
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;
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;
}
}
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;
/* 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);
}
#include <gst/gstsystemclock.h>
G_BEGIN_DECLS
-
#define GST_TYPE_AUDIO_CLOCK \
(gst_audio_clock_get_type())
#define GST_AUDIO_CLOCK(obj) \
(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;
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__ */
/* 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;
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",
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;
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);
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");
-
- 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);
+ 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), "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;
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;
}
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:
}
}
-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)
#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 \
#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;
int bytes_per_sample;
};
-struct _GstAudiofilterClass {
+struct _GstAudiofilterClass
+{
GstElementClass parent_class;
GstCaps *caps;
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__ */
-
#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)
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",
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;
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);
}
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;
}
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:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstaudiofilter"))
return FALSE;
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;
* 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;
/* 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;
* to the destination. */
}
-
#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 };
};
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;
}
const GList *
-gst_color_balance_list_channels (GstColorBalance *balance)
+gst_color_balance_list_channels (GstColorBalance * balance)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (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);
}
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);
}
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);
}
#include <gst/colorbalance/colorbalance-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_COLOR_BALANCE \
(gst_color_balance_get_type ())
#define GST_COLOR_BALANCE(obj) \
(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);
+ const GList *(*list_channels) (GstColorBalance * balance);
- void (* set_value) (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
- gint (* get_value) (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+ 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__ */
#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 };
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)
#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) \
(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__ */
#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;
}
#define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))
G_END_DECLS
-
#endif /* __FLOATCAST_H__ */
-
#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 */
/* 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;
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);
* 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;
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);
}
* 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);
}
* 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;
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;
* 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);
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
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
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
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
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;
}
-
#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 */
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;
}
#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.
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);
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);
-
/* 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 */
* 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
* 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);
}
/* 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);
}
}
#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 */
{
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;
val += (8 >> 1);
val /= 8;
val = -val;
- }
- else {
+ } else {
val = (v + (8 >> 1)) / 8;
}
- 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;
+ 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;
}
-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)
#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;
};
-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__ */
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 */
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 */
/* 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);
- }
-
- 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;
+ 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;
/* 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, "\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);
+ 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");
+
+ 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;
}
/* 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;
}
}
- 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);
}
}
-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;
}
}
- 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);
}
*/
#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
* 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
#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) */
#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
* 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)))
#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;
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--) {
+ 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--) {
/* 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
*/
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;
dataptr[5] = dcval;
dataptr[6] = dcval;
dataptr[7] = dcval;
-
+
dataptr += DCTSIZE; /* advance pointer to next row */
continue;
}
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;
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.
*/
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;
/* 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 */
}
/* 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).
*/
#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;
}
/* 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;
/* 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 */
}
}
* along with GNU Make; see the file COPYING. If not, write to\r
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
*\r
- */\r
-\r
-\r
+ */ \r
+ \r\r
/* MMX32 iDCT algorithm (IEEE-1180 compliant) :: idct_mmx32()\r */
/*\r */
/* MPEG2AVI\r */
/*\r */
/* liaor@umcc.ais.org http://members.tripod.com/~liaor\r */
/* \r */
-\r
-\r
+ \r\r
/*;=============================================================================\r */
/*;\r */
/*; AP-922 http://developer.intel.com/vtune/cbts/strmsimd\r */
/*;=============================================================================\r */
/*\r
mword typedef qword\r
-qword ptr equ mword ptr */\r
-
+qword ptr equ mword ptr */ \r
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-
#include <mmx.h>\r
-\r
+ \r
#define BITS_INV_ACC 4 /*; 4 or 5 for IEEE\r */
- /* 5 yields higher accuracy, but lessens dynamic range on the input matrix\r */
+ /* 5 yields higher accuracy, but lessens dynamic range on the input matrix\r */
#define SHIFT_INV_ROW (16 - BITS_INV_ACC)\r
-#define SHIFT_INV_COL (1 + BITS_INV_ACC +14 ) /* changed from Intel's val)\r */
+#define SHIFT_INV_COL (1 + BITS_INV_ACC +14 ) /* changed from Intel's val)\r */
/*#define SHIFT_INV_COL (1 + BITS_INV_ACC )\r */
-\r
+ \r
#define RND_INV_ROW (1 << (SHIFT_INV_ROW-1))\r
#define RND_INV_COL (1 << (SHIFT_INV_COL-1)) \r
-#define RND_INV_CORR (RND_INV_COL - 1) /*; correction -1.0 and round\r */
+#define RND_INV_CORR (RND_INV_COL - 1) /*; correction -1.0 and round\r */
/*#define RND_INV_ROW (1024 * (6 - BITS_INV_ACC)) //; 1 << (SHIFT_INV_ROW-1)\r */
/*#define RND_INV_COL (16 * (BITS_INV_ACC - 3)) //; 1 << (SHIFT_INV_COL-1)\r */
-\r
-\r
+ \r\r
/*.data\r */
/*Align 16\r */
-const static long r_inv_row[2] = { RND_INV_ROW, RND_INV_ROW};\r
-const static long r_inv_col[2] = {RND_INV_COL, RND_INV_COL};\r
-const static long r_inv_corr[2] = {RND_INV_CORR, RND_INV_CORR };\r
-\r
+const static long r_inv_row[2] = { RND_INV_ROW, RND_INV_ROW };
+\rconst static long r_inv_col[2] = { RND_INV_COL, RND_INV_COL };
+\rconst static long r_inv_corr[2] = { RND_INV_CORR, RND_INV_CORR };
+
+\r\r
/*const static short r_inv_col[4] = \r */
/* {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL};\r */
/*const static short r_inv_corr[4] =\r */
/* {RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR};\r */
-\r
+ \r
/* constants for the forward DCT\r
\r
/*#define BITS_FRW_ACC 3 //; 2 or 3 for accuracy\r */
/*#define SHIFT_FRW_COL BITS_FRW_ACC\r */
/*#define SHIFT_FRW_ROW (BITS_FRW_ACC + 17)\r */
/*#define RND_FRW_ROW (262144 * (BITS_FRW_ACC - 1)) //; 1 << (SHIFT_FRW_ROW-1)\r */
-\r
-const static __int64 one_corr = 0x0001000100010001;\r
-const static long r_frw_row[2] = {RND_FRW_ROW, RND_FRW_ROW };\r
-\r
+\rconst static __int64 one_corr = 0x0001000100010001;
+\rconst static long r_frw_row[2] = { RND_FRW_ROW, RND_FRW_ROW };
+
+\r\r
/*const static short tg_1_16[4] = {13036, 13036, 13036, 13036 }; //tg * (2<<16) + 0.5\r */
/*const static short tg_2_16[4] = {27146, 27146, 27146, 27146 }; //tg * (2<<16) + 0.5\r */
/*const static short tg_3_16[4] = {-21746, -21746, -21746, -21746 }; //tg * (2<<16) + 0.5\r */
/*const static short cos_4_16[4] = {-19195, -19195, -19195, -19195 }; //cos * (2<<16) + 0.5\r */
/*const static short ocos_4_16[4] = {23170, 23170, 23170, 23170 }; //cos * (2<<15) + 0.5\r */
-\r
+ \r
/*concatenated table, for forward DCT transformation\r */
-const static short tg_all_16[] = {\r
- 13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5\r */
- 27146, 27146, 27146, 27146, /*tg * (2<<16) + 0.5\r */
- -21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5\r */
- -19195, -19195, -19195, -19195, /*cos * (2<<16) + 0.5\r */
- 23170, 23170, 23170, 23170 }; /*cos * (2<<15) + 0.5\r */
+const static short tg_all_16[] = { \r13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5\r */
+ 27146, 27146, 27146, 27146, /*tg * (2<<16) + 0.5\r */
+ -21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5\r */
+ -19195, -19195, -19195, -19195, /*cos * (2<<16) + 0.5\r */
+ 23170, 23170, 23170, 23170
+}; /*cos * (2<<15) + 0.5\r */
+
\r
#define tg_1_16 (tg_all_16 + 0)\r
#define tg_2_16 (tg_all_16 + 8)\r
#define tg_3_16 (tg_all_16 + 16)\r
#define cos_4_16 (tg_all_16 + 24)\r
#define ocos_4_16 (tg_all_16 + 32)\r
-*/\r
+ */\r
/*\r
;=============================================================================\r
;\r
;=============================================================================\r
\r
/*; Table for rows 0,4 - constants are multiplied by cos_4_16\r */
-const short tab_i_04[] = {\r
- 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
- 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
- 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
- -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
- 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
- 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
- 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
- -22725, 19266, -12873, -22725 };/*w31 w29 w27 w25\r */
+const short tab_i_04[] = { \r16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
+ 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
+ 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
+ -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
+ 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
+ 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
+ 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
+ -22725, 19266, -12873, -22725
+}; /*w31 w29 w27 w25\r */
+
\r
/*; Table for rows 1,7 - constants are multiplied by cos_1_16\r */
-const short tab_i_17[] = {\r
- 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
- 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
- 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
- -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
- 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
- 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
- 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
- -31521, 26722, -17855, -31521}; /* w31 w29 w27 w25\r */
+const short tab_i_17[] = { \r22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
+ 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
+ 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
+ -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
+ 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
+ 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
+ 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
+ -31521, 26722, -17855, -31521
+}; /* w31 w29 w27 w25\r */
+
\r
/*; Table for rows 2,6 - constants are multiplied by cos_2_16\r */
-const short tab_i_26[] = {\r
- 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
- 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
- 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
- -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
- 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
- 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
- 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
- -29692, 25172, -16819, -29692}; /* ;w31 w29 w27 w25\r */
-\r
-\r
+const short tab_i_26[] = { \r21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
+ 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
+ 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
+ -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
+ 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
+ 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
+ 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
+ -29692, 25172, -16819, -29692
+}; /* ;w31 w29 w27 w25\r */
+
+\r\r
/*; Table for rows 3,5 - constants are multiplied by cos_3_16\r */
-const short tab_i_35[] = {\r
- 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
- 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
- 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
- -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
- 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
- 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
- 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
- -26722, 22654, -15137, -26722}; /*; w31 w29 w27 w25\r */
-*/\r
-\r
+const short tab_i_35[] = { \r19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
+ 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
+ 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
+ -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
+ 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
+ 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
+ 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
+ -26722, 22654, -15137, -26722
+}; /*; w31 w29 w27 w25\r */
+
+*/\r\r
/* CONCATENATED TABLE, rows 0,1,2,3,4,5,6,7 (in order )\r */
/*\r */
/* In our implementation, however, we only use row0 !\r */
/*\r */
-static const short tab_i_01234567[] = {\r
- /*row0, this row is required\r */
- 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
- 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
- 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
- -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
- 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
- 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
- 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
- -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
-\r
- /* the rest of these rows (1-7), aren't used !\r */
-\r
- /*row1\r */
- 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
- 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
- 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
- -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
- 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
- 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
- 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
- -31521, 26722, -17855, -31521, /* w31 w29 w27 w25\r */
-\r
- /*row2\r */
- 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
- 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
- 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
- -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
- 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
- 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
- 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
- -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
-\r
- /*row3\r */
- 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
- 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
- 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
- -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
- 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
- 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
- 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
- -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
-\r
- /*row4\r */
- 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
- 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
- 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
- -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
- 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
- 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
- 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
- -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
-\r
- /*row5\r */
- 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
- 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
- 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
- -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
- 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
- 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
- 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
- -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
-\r
- /*row6\r */
- 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
- 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
- 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
- -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
- 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
- 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
- 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
- -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
-\r
- /*row7\r */
- 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
- 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
- 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
- -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
- 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
- 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
- 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
- -31521, 26722, -17855, -31521}; /* w31 w29 w27 w25\r */
-\r
-\r
-#define INP eax /* pointer to (short *blk)\r */
-#define OUT ecx /* pointer to output (temporary store space qwTemp[])\r */
-#define TABLE ebx /* pointer to tab_i_01234567[]\r */
+static const short tab_i_01234567[] = { \r
+ /*row0, this row is required\r */
+ 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
+ 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
+ 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
+ -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
+ 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
+ 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
+ 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
+ -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
+ \r
+ /* the rest of these rows (1-7), aren't used !\r */
+ \r
+ /*row1\r */
+ 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
+ 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
+ 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
+ -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
+ 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
+ 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
+ 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
+ -31521, 26722, -17855, -31521, /* w31 w29 w27 w25\r */
+ \r
+ /*row2\r */
+ 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
+ 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
+ 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
+ -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
+ 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
+ 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
+ 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
+ -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
+ \r
+ /*row3\r */
+ 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
+ 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
+ 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
+ -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
+ 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
+ 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
+ 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
+ -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
+ \r
+ /*row4\r */
+ 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
+ 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
+ 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
+ -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
+ 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
+ 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
+ 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
+ -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
+ \r
+ /*row5\r */
+ 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
+ 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
+ 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
+ -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
+ 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
+ 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
+ 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
+ -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
+ \r
+ /*row6\r */
+ 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
+ 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
+ 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
+ -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
+ 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
+ 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
+ 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
+ -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
+ \r
+ /*row7\r */
+ 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
+ 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
+ 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
+ -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
+ 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
+ 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
+ 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
+ -31521, 26722, -17855, -31521
+}; /* w31 w29 w27 w25\r */
+
+\r\r
+#define INP eax /* pointer to (short *blk)\r */
+#define OUT ecx /* pointer to output (temporary store space qwTemp[])\r */
+#define TABLE ebx /* pointer to tab_i_01234567[]\r */
#define round_inv_row edx\r
#define round_inv_col edx\r
-\r
-#define ROW_STRIDE 8 /* for 8x8 matrix transposer\r */
-\r
+ \r
+#define ROW_STRIDE 8 /* for 8x8 matrix transposer\r */
+ \r
/* private variables and functions\r */
-\r
+ \r
/*temporary storage space, 8x8 of shorts\r */
-\r
-__inline static void idct_mmx32_rows( short *blk ); /* transform rows\r */
-__inline static void idct_mmx32_cols( short *blk ); /* transform "columns"\r */
+\r__inline static void idct_mmx32_rows (short *blk); /* transform rows\r */
+__inline static void idct_mmx32_cols (short *blk); /* transform "columns"\r */
+
/* the "column" transform actually transforms rows, it is\r */
/* identical to the row-transform except for the ROUNDING\r */
/* and SHIFTING coefficients.\r */
-\r
- \r
-static void \r
-idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block\r */
-{\r
- int x;\r
- short qwTemp[64];\r
- short *out = &qwTemp[0];\r
- short *inptr = blk;\r
- /* this subroutine performs two operations\r */
- /* 1) iDCT row transform\r */
- /* for( i = 0; i < 8; ++ i)\r */
- /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
- /*\r */
- /* 2) transpose the matrix (which was stored in qwTemp[])\r */
- /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
-\r
- for (x=0; x<8; x++) { /* transform one row per iteration\r */
- movq_m2r(*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(inptr+4), mm1); /* 1 ; x7 x6 x5 x4\r */
- movq_r2r(mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
- punpcklwd_r2r(mm1, mm0); /* x5 x1 x4 x0\r */
-\r
- /* ----------\r */
- movq_r2r(mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
- punpckldq_r2r(mm0, mm0); /* x4 x0 x4 x0\r */
-\r
- movq_m2r(*(tab_i_01234567+4), mm4); /* 4 ; w07 w05 w03 w01\r */
- punpckhwd_r2r(mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
-\r
- pmaddwd_r2r(mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
- movq_r2r(mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
-\r
- movq_m2r(*(tab_i_01234567+16), mm1);/* 1 ; w22 w20 w18 w16\r */
- punpckldq_r2r(mm2, mm2); /* x6 x2 x6 x2\r */
-\r
- pmaddwd_r2r(mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
- punpckhdq_r2r(mm5, mm5); /* x5 x1 x5 x1\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+8), mm0);/* x4*w14+x0*w12 x4*w10+x0*w08\r */
- punpckhdq_r2r(mm6, mm6); /* x7 x3 x7 x3\r */
-\r
- movq_m2r(*(tab_i_01234567+20), mm7);/* 7 ; w23 w21 w19 w17\r */
- pmaddwd_r2r(mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
-\r
- paddd_m2r(*(r_inv_row), mm3);/* +rounder\r */
- pmaddwd_r2r(mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+12), mm2);/* x6*w15+x2*w13 x6*w11+x2*w09\r */
- paddd_r2r(mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+24), mm5);/* x5*w30+x1*w28 x5*w26+x1*w24\r */
- movq_r2r(mm3, mm4); /* 4 ; a1 a0\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+28), mm6);/* x7*w31+x3*w29 x7*w27+x3*w25\r */
- paddd_r2r(mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
-\r
- paddd_m2r(*(r_inv_row), mm0);/* +rounder\r */
- psubd_r2r(mm1, mm3); /* a1-b1 a0-b0\r */
-\r
- psrad_i2r(SHIFT_INV_ROW, mm3); /* y6=a1-b1 y7=a0-b0\r */
- paddd_r2r(mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
-\r
- paddd_r2r(mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
- psrad_i2r(SHIFT_INV_ROW, mm1); /* y1=a1+b1 y0=a0+b0\r */
-\r
- paddd_r2r(mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
- movq_r2r(mm0, mm4); /* 4 ; a3 a2\r */
-\r
- paddd_r2r(mm5, mm0); /* a3+b3 a2+b2\r */
- psubd_r2r(mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
-\r
- psrad_i2r(SHIFT_INV_ROW, mm4); /* y4=a3-b3 y5=a2-b2\r */
- psrad_i2r(SHIFT_INV_ROW, mm0); /* y3=a3+b3 y2=a2+b2\r */
-\r
- packssdw_r2r(mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
-\r
- packssdw_r2r(mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
- movq_r2r(mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
-\r
- psrld_i2r(16, mm4); /* 0 y6 0 y4\r */
-\r
- movq_r2m(mm1, *(out)); /* 1 ; save y3 y2 y1 y0\r */
- pslld_i2r(16, mm7); /* y7 0 y5 0\r */
-\r
- por_r2r(mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
-\r
- /* begin processing row 1\r */
- movq_r2m(mm7, *(out+4)); /* 7 ; save y7 y6 y5 y4\r */
-\r
- inptr += 8;\r
- out += 8;\r
- }\r
- \r
-\r
- /* done with the iDCT row-transformation\r */
-\r
- /* now we have to transpose the output 8x8 matrix\r */
- /* 8x8 (OUT) -> 8x8't' (IN)\r */
- /* the transposition is implemented as 4 sub-operations.\r */
- /* 1) transpose upper-left quad\r */
- /* 2) transpose lower-right quad\r */
- /* 3) transpose lower-left quad\r */
- /* 4) transpose upper-right quad\r */
-\r
- \r
- /* mm0 = 1st row [ A B C D ] row1\r */
- /* mm1 = 2nd row [ E F G H ] 2\r */
- /* mm2 = 3rd row [ I J K L ] 3\r */
- /* mm3 = 4th row [ M N O P ] 4\r */
-\r
- /* 1) transpose upper-left quad\r */
- out = &qwTemp[0];\r
-\r
- movq_m2r(*(out + ROW_STRIDE * 0), mm0);\r
-\r
- movq_m2r(*(out + ROW_STRIDE * 1), mm1);\r
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 2), mm2);\r
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 3), mm3);\r
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
-\r
- movq_r2r(mm2, mm6);\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- inptr = blk;\r
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE * 0)); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
+\r\rstatic void \r
+idct_mmx32_rows (short *blk)
+{ /* transform all 8 rows of 8x8 iDCT block\r */
+ \rint x;
+ \rshort qwTemp[64];
+ \rshort *out = &qwTemp[0];
+ \rshort *inptr = blk;
+
+ \r
+ /* this subroutine performs two operations\r */
+ /* 1) iDCT row transform\r */
+ /* for( i = 0; i < 8; ++ i)\r */
+ /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
+ /*\r */
+ /* 2) transpose the matrix (which was stored in qwTemp[])\r */
+ /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
+ \rfor (x = 0; x < 8; x++) { /* transform one row per iteration\r */
+ movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4\r */
+ movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
+ punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0\r */
+ \r
+ /* ----------\r */
+ movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
+ punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0\r */
+ \rmovq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01\r */
+ punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
+ \rpmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
+ movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
+ \rmovq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16\r */
+ punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2\r */
+ \rpmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
+ punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08\r */
+ punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3\r */
+ \rmovq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17\r */
+ pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
+ \rpaddd_m2r (*(r_inv_row), mm3); /* +rounder\r */
+ pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09\r */
+ paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24\r */
+ movq_r2r (mm3, mm4); /* 4 ; a1 a0\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25\r */
+ paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
+ \rpaddd_m2r (*(r_inv_row), mm0); /* +rounder\r */
+ psubd_r2r (mm1, mm3); /* a1-b1 a0-b0\r */
+ \rpsrad_i2r (SHIFT_INV_ROW, mm3); /* y6=a1-b1 y7=a0-b0\r */
+ paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
+ \rpaddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
+ psrad_i2r (SHIFT_INV_ROW, mm1); /* y1=a1+b1 y0=a0+b0\r */
+ \rpaddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
+ movq_r2r (mm0, mm4); /* 4 ; a3 a2\r */
+ \rpaddd_r2r (mm5, mm0); /* a3+b3 a2+b2\r */
+ psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
+ \rpsrad_i2r (SHIFT_INV_ROW, mm4); /* y4=a3-b3 y5=a2-b2\r */
+ psrad_i2r (SHIFT_INV_ROW, mm0); /* y3=a3+b3 y2=a2+b2\r */
+ \rpackssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
+ \rpackssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
+ movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
+ \rpsrld_i2r (16, mm4); /* 0 y6 0 y4\r */
+ \rmovq_r2m (mm1, *(out)); /* 1 ; save y3 y2 y1 y0\r */
+ pslld_i2r (16, mm7); /* y7 0 y5 0\r */
+ \rpor_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
+ \r
+ /* begin processing row 1\r */
+ movq_r2m (mm7, *(out + 4)); /* 7 ; save y7 y6 y5 y4\r */
+ \rinptr += 8;
+ \rout += 8;
+ \r}
+ \r\r\r
+ /* done with the iDCT row-transformation\r */
+ \r
+ /* now we have to transpose the output 8x8 matrix\r */
+ /* 8x8 (OUT) -> 8x8't' (IN)\r */
+ /* the transposition is implemented as 4 sub-operations.\r */
+ /* 1) transpose upper-left quad\r */
+ /* 2) transpose lower-right quad\r */
+ /* 3) transpose lower-left quad\r */
+ /* 4) transpose upper-right quad\r */
+ \r\r
+ /* mm0 = 1st row [ A B C D ] row1\r */
+ /* mm1 = 2nd row [ E F G H ] 2\r */
+ /* mm2 = 3rd row [ I J K L ] 3\r */
+ /* mm3 = 4th row [ M N O P ] 4\r */
+ \r
+ /* 1) transpose upper-left quad\r */
+ out = &qwTemp[0];
+ \r\rmovq_m2r (*(out + ROW_STRIDE * 0), mm0);
+ \r\rmovq_m2r (*(out + ROW_STRIDE * 1), mm1);
+ \rmovq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 2), mm2);
+ \rpunpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 3), mm3);
+ \rpunpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_r2r (mm2, mm6);
+ \rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rinptr = blk;
+ \r\rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rmovq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 0)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \r
/* begin reading next quadrant (lower-right)\r */
- movq_m2r(*(out + ROW_STRIDE*4 + 4), mm0); \r
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
-\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE * 2)); /* store row 3\r */
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE * 1)); /* store row 2\r */
-\r
- movq_m2r(*(out + ROW_STRIDE*5 + 4), mm1);\r
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE * 3)); /* store row 4\r */
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
-\r
- /* 2) transpose lower-right quadrant\r */
-\r
+ movq_m2r (*(out + ROW_STRIDE * 4 + 4), mm0);
+ \rpunpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 2)); /* store row 3\r */
+ movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 1)); /* store row 2\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 5 + 4), mm1);
+ \r\rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 3)); /* store row 4\r */
+ punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
+ \r
+ /* 2) transpose lower-right quadrant\r */
+ \r
/* movq mm0, qword ptr [OUT + ROW_STRIDE*4 + 8]\r */
-\r
+ \r
/* movq mm1, qword ptr [OUT + ROW_STRIDE*5 + 8]\r */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*6 + 4), mm2);\r
-/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*7 + 4), mm3);\r
- movq_r2r(mm2, mm6);\r
-\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
- ; /* slot\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE*4 + 4)); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
- movq_m2r(*(out + ROW_STRIDE * 4 ), mm0);\r
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 6 + 4), mm2);
\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE*6 + 4)); /* store row 3\r */
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE*5 + 4)); /* store row 2\r */
- ; /* slot\r */
+/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
+ punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 7 + 4), mm3);
+ \rmovq_r2r (mm2, mm6);
+ \r\rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ \rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rpunpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ ; /* slot\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 4 + 4)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 4), mm0);
+ \rpunpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 6 + 4)); /* store row 3\r */
+ movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 5 + 4)); /* store row 2\r */
+ ; /* slot\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 5), mm1);
+ \r; /* slot\r */
+ \rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 7 + 4)); /* store row 4\r */
+ punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
\r
- movq_m2r(*(out + ROW_STRIDE * 5 ), mm1);\r
- ; /* slot\r */
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE*7 + 4)); /* store row 4\r */
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
-\r
- /* 3) transpose lower-left\r */
+ /* 3) transpose lower-left\r */
/* movq mm0, qword ptr [OUT + ROW_STRIDE * 4 ]\r */
-\r
+ \r
/* movq mm1, qword ptr [OUT + ROW_STRIDE * 5 ]\r */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 6 ), mm2);\r
+ \rmovq_m2r (*(out + ROW_STRIDE * 6), mm2);
+ \r
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 7 ), mm3);\r
- movq_r2r(mm2, mm6);\r
-\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
- ;/*slot\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE * 0 + 4 )); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
+ punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 7), mm3);
+ \rmovq_r2r (mm2, mm6);
+ \r\rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ \rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rpunpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ ; /*slot\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 0 + 4)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \r
/* begin reading next quadrant (upper-right)\r */
- movq_m2r(*(out + ROW_STRIDE*0 + 4), mm0);\r
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
-\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE * 2 + 4)); /* store row 3\r */
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE * 1 + 4)); /* store row 2\r */
- movq_m2r(*(out + ROW_STRIDE*1 + 4), mm1);\r
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE * 3 + 4)); /* store row 4\r */
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
-\r
-\r
- /* 2) transpose lower-right quadrant\r */
-\r
+ movq_m2r (*(out + ROW_STRIDE * 0 + 4), mm0);
+ \rpunpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 2 + 4)); /* store row 3\r */
+ movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 1 + 4)); /* store row 2\r */
+ movq_m2r (*(out + ROW_STRIDE * 1 + 4), mm1);
+ \r\rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 3 + 4)); /* store row 4\r */
+ punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
+ \r\r
+ /* 2) transpose lower-right quadrant\r */
+ \r
/* movq mm0, qword ptr [OUT + ROW_STRIDE*4 + 8]\r */
-\r
+ \r
/* movq mm1, qword ptr [OUT + ROW_STRIDE*5 + 8]\r */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*2 + 4), mm2);\r
+ \rmovq_m2r (*(out + ROW_STRIDE * 2 + 4), mm2);
+ \r
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*3 + 4), mm3);\r
- movq_r2r(mm2, mm6);\r
-\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
- ; /* slot\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE*4)); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE*5)); /* store row 2\r */
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
-\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE*6)); /* store row 3\r */
- ; /* slot\r */
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE*7)); /* store row 4\r */
- ; /* slot\r */
- \r
-}\r
-\r
-\r
-static void \r
-idct_mmx32_cols( short *blk ) /* transform all 8 cols of 8x8 iDCT block\r */
-{\r
- int x;\r
- short *inptr = blk;\r
-\r
- /* Despite the function's name, the matrix is transformed\r */
- /* row by row. This function is identical to idct_mmx32_rows(),\r */
- /* except for the SHIFT amount and ROUND_INV amount.\r */
-\r
- /* this subroutine performs two operations\r */
- /* 1) iDCT row transform\r */
- /* for( i = 0; i < 8; ++ i)\r */
- /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
- /*\r */
- /* 2) transpose the matrix (which was stored in qwTemp[])\r */
- /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
-\r
-\r
- for (x=0; x<8; x++) { /* transform one row per iteration\r */
-\r
- movq_m2r(*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(inptr+4), mm1); /* 1 ; x7 x6 x5 x4\r */
- movq_r2r(mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
- punpcklwd_r2r(mm1, mm0); /* x5 x1 x4 x0\r */
-\r
+ punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 3 + 4), mm3);
+ \rmovq_r2r (mm2, mm6);
+ \r\rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ \rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rpunpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ ; /* slot\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 4)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 5)); /* store row 2\r */
+ punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 6)); /* store row 3\r */
+ ; /* slot\r */
+ \rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 7)); /* store row 4\r */
+ ; /* slot\r */
+\r}
+\r\r\rstatic void \r
+idct_mmx32_cols (short *blk)
+{ /* transform all 8 cols of 8x8 iDCT block\r */
+ \rint x;
+ \rshort *inptr = blk;
+
+ \r\r
+ /* Despite the function's name, the matrix is transformed\r */
+ /* row by row. This function is identical to idct_mmx32_rows(),\r */
+ /* except for the SHIFT amount and ROUND_INV amount.\r */
+ \r
+ /* this subroutine performs two operations\r */
+ /* 1) iDCT row transform\r */
+ /* for( i = 0; i < 8; ++ i)\r */
+ /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
+ /*\r */
+ /* 2) transpose the matrix (which was stored in qwTemp[])\r */
+ /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
+ \r\rfor (x = 0; x < 8; x++) { /* transform one row per iteration\r */
+ \rmovq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4\r */
+ movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
+ punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0\r */
+ \r
/* ----------\r */
- movq_r2r(mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
- punpckldq_r2r(mm0, mm0); /* x4 x0 x4 x0\r */
-\r
- movq_m2r(*(tab_i_01234567+4), mm4); /* 4 ; w07 w05 w03 w01\r */
- punpckhwd_r2r(mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
-\r
- pmaddwd_r2r(mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
- movq_r2r(mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
-\r
- movq_m2r(*(tab_i_01234567+16), mm1);/* 1 ; w22 w20 w18 w16\r */
- punpckldq_r2r(mm2, mm2); /* x6 x2 x6 x2\r */
-\r
- pmaddwd_r2r(mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
- punpckhdq_r2r(mm5, mm5); /* x5 x1 x5 x1\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+8), mm0);/* x4*w14+x0*w12 x4*w10+x0*w08\r */
- punpckhdq_r2r(mm6, mm6); /* x7 x3 x7 x3\r */
-\r
- movq_m2r(*(tab_i_01234567+20), mm7);/* 7 ; w23 w21 w19 w17\r */
- pmaddwd_r2r(mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
-\r
- paddd_m2r(*(r_inv_col), mm3);/* +rounder\r */
- pmaddwd_r2r(mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+12), mm2);/* x6*w15+x2*w13 x6*w11+x2*w09\r */
- paddd_r2r(mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+24), mm5);/* x5*w30+x1*w28 x5*w26+x1*w24\r */
- movq_r2r(mm3, mm4); /* 4 ; a1 a0\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+28), mm6);/* x7*w31+x3*w29 x7*w27+x3*w25\r */
- paddd_r2r(mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
-\r
- paddd_m2r(*(r_inv_col), mm0);/* +rounder\r */
- psubd_r2r(mm1, mm3); /* a1-b1 a0-b0\r */
-\r
- psrad_i2r(SHIFT_INV_COL, mm3); /* y6=a1-b1 y7=a0-b0\r */
- paddd_r2r(mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
-\r
- paddd_r2r(mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
- psrad_i2r(SHIFT_INV_COL, mm1); /* y1=a1+b1 y0=a0+b0\r */
-\r
- paddd_r2r(mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
- movq_r2r(mm0, mm4); /* 4 ; a3 a2\r */
-\r
- paddd_r2r(mm5, mm0); /* a3+b3 a2+b2\r */
- psubd_r2r(mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
-\r
-\r
- psrad_i2r(SHIFT_INV_COL, mm4); /* y4=a3-b3 y5=a2-b2\r */
- psrad_i2r(SHIFT_INV_COL, mm0); /* y3=a3+b3 y2=a2+b2\r */
-\r
- packssdw_r2r(mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
-\r
- packssdw_r2r(mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
- movq_r2r(mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
-\r
- psrld_i2r(16, mm4); /* 0 y6 0 y4\r */
-\r
- movq_r2m(mm1, *(inptr)); /* 1 ; save y3 y2 y1 y0\r */
- pslld_i2r(16, mm7); /* y7 0 y5 0\r */
-\r
- por_r2r(mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
-\r
- /* begin processing row 1\r */
- movq_r2m(mm7, *(inptr+4)); /* 7 ; save y7 y6 y5 y4\r */
-\r
- inptr += 8;\r
- }\r
- /* done with the iDCT column-transformation\r */
-}\r
-\r
+ movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
+ punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0\r */
+ \rmovq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01\r */
+ punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
+ \rpmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
+ movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
+ \rmovq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16\r */
+ punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2\r */
+ \rpmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
+ punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08\r */
+ punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3\r */
+ \rmovq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17\r */
+ pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
+ \rpaddd_m2r (*(r_inv_col), mm3); /* +rounder\r */
+ pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09\r */
+ paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24\r */
+ movq_r2r (mm3, mm4); /* 4 ; a1 a0\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25\r */
+ paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
+ \rpaddd_m2r (*(r_inv_col), mm0); /* +rounder\r */
+ psubd_r2r (mm1, mm3); /* a1-b1 a0-b0\r */
+ \rpsrad_i2r (SHIFT_INV_COL, mm3); /* y6=a1-b1 y7=a0-b0\r */
+ paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
+ \rpaddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
+ psrad_i2r (SHIFT_INV_COL, mm1); /* y1=a1+b1 y0=a0+b0\r */
+ \rpaddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
+ movq_r2r (mm0, mm4); /* 4 ; a3 a2\r */
+ \rpaddd_r2r (mm5, mm0); /* a3+b3 a2+b2\r */
+ psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
+ \r\rpsrad_i2r (SHIFT_INV_COL, mm4); /* y4=a3-b3 y5=a2-b2\r */
+ psrad_i2r (SHIFT_INV_COL, mm0); /* y3=a3+b3 y2=a2+b2\r */
+ \rpackssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
+ \rpackssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
+ movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
+ \rpsrld_i2r (16, mm4); /* 0 y6 0 y4\r */
+ \rmovq_r2m (mm1, *(inptr)); /* 1 ; save y3 y2 y1 y0\r */
+ pslld_i2r (16, mm7); /* y7 0 y5 0\r */
+ \rpor_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
+ \r
+ /* begin processing row 1\r */
+ movq_r2m (mm7, *(inptr + 4)); /* 7 ; save y7 y6 y5 y4\r */
+ \rinptr += 8;
+ \r}
+ \r
+ /* done with the iDCT column-transformation\r */
+}
+
+\r\r
/* \r */
/* public interface to MMX32 IDCT 8x8 operation\r */
/*\r */
-void\r
-gst_idct_mmx32_idct( short *blk )\r
-{\r
- /* 1) iDCT row transformation\r */
- idct_mmx32_rows( blk ); /* 1) transform iDCT row, and transpose\r */
-\r
- /* 2) iDCT column transformation\r */
- idct_mmx32_cols( blk ); /* 2) transform iDCT row, and transpose\r */
-\r
- emms(); /* restore processor state\r */
- /* all done\r */
-}\r
+void \r
+gst_idct_mmx32_idct (short *blk) \r
+{
+ \r
+ /* 1) iDCT row transformation\r */
+ idct_mmx32_rows (blk); /* 1) transform iDCT row, and transpose\r */
+ \r
+ /* 2) iDCT column transformation\r */
+ idct_mmx32_cols (blk); /* 2) transform iDCT row, and transpose\r */
+ \remms (); /* restore processor state\r */
+ /* all done\r */
+} \r
#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 };
};
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;
}
const GList *
-gst_color_balance_list_channels (GstColorBalance *balance)
+gst_color_balance_list_channels (GstColorBalance * balance)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (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);
}
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);
}
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);
}
#include <gst/colorbalance/colorbalance-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_COLOR_BALANCE \
(gst_color_balance_get_type ())
#define GST_COLOR_BALANCE(obj) \
(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);
+ const GList *(*list_channels) (GstColorBalance * balance);
- void (* set_value) (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
- gint (* get_value) (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+ 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__ */
#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 };
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)
#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) \
(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__ */
#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 };
};
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;
*/
const GList *
-gst_mixer_list_tracks (GstMixer *mixer)
+gst_mixer_list_tracks (GstMixer * mixer)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (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);
*/
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);
*/
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);
*/
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);
}
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);
}
#include <gst/mixer/mixer-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_MIXER \
(gst_mixer_get_type ())
#define GST_MIXER(obj) \
(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
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__ */
#include "mixertrack.h"
-enum {
+enum
+{
/* FILL ME */
SIGNAL_VOLUME_CHANGED,
SIGNAL_RECORD_TOGGLED,
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 };
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;
}
static void
-gst_mixer_track_dispose (GObject *object)
+gst_mixer_track_dispose (GObject * object)
{
GstMixerTrack *channel = GST_MIXER_TRACK (object);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_MIXER_TRACK \
(gst_mixer_track_get_type ())
#define GST_MIXER_TRACK(obj) \
(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:
*
* 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__ */
#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)
};
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);
}
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));
}
-
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_NAVIGATION \
(gst_navigation_get_type ())
#define GST_NAVIGATION(obj) \
(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__ */
#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 };
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;
}
/**
*/
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);
}
void
-gst_property_probe_probe_property (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_probe_property (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
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;
*/
gboolean
-gst_property_probe_needs_probe (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_needs_probe (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
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;
*
* 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;
*/
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;
*/
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;
*/
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;
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_PROPERTY_PROBE \
(gst_property_probe_get_type ())
#define GST_PROPERTY_PROBE(obj) \
(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__ */
#include <string.h>
-enum {
+enum
+{
NORM_CHANGED,
CHANNEL_CHANGED,
FREQUENCY_CHANGED,
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 };
};
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;
}
*/
const GList *
-gst_tuner_list_channels (GstTuner *tuner)
+gst_tuner_list_channels (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (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);
*/
GstTunerChannel *
-gst_tuner_get_channel (GstTuner *tuner)
+gst_tuner_get_channel (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
const GList *
-gst_tuner_list_norms (GstTuner *tuner)
+gst_tuner_list_norms (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (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);
*/
GstTunerNorm *
-gst_tuner_get_norm (GstTuner *tuner)
+gst_tuner_get_norm (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (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);
*/
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);
*/
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);
}
GstTunerNorm *
-gst_tuner_find_norm_by_name (GstTuner *tuner,
- gchar *norm)
+gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm)
{
GList *walk;
}
GstTunerChannel *
-gst_tuner_find_channel_by_name (GstTuner *tuner,
- gchar *channel)
+gst_tuner_find_channel_by_name (GstTuner * tuner, gchar * channel)
{
GList *walk;
}
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);
}
#include <gst/tuner/tuner-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER \
(gst_tuner_get_type ())
#define GST_TUNER(obj) \
(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_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);
+ 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);
+
+ 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_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);
+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);
+
+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__ */
#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 };
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;
}
static void
-gst_tuner_channel_dispose (GObject *object)
+gst_tuner_channel_dispose (GObject * object)
{
GstTunerChannel *channel = GST_TUNER_CHANNEL (object);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER_CHANNEL \
(gst_tuner_channel_get_type ())
#define GST_TUNER_CHANNEL(obj) \
(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__ */
#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
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;
}
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);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER_NORM \
(gst_tuner_norm_get_type ())
#define GST_TUNER_NORM(obj) \
(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__ */
#include "xoverlay.h"
-enum {
+enum
+{
HAVE_XWINDOW_ID,
DESIRED_SIZE,
LAST_SIGNAL
};
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;
}
* 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);
* 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);
}
/**
* 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;
* 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);
}
/**
* 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);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_X_OVERLAY \
(gst_x_overlay_get_type ())
#define GST_X_OVERLAY(obj) \
(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__ */
}
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);
}
/* 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;
/* 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);
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;
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);
/* 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)
/* 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;
/* 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 { \
/* 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) \
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) \
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) \
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;
}
/* 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;
/* 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;
}
/* 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;
/* 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;
/* 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;
/* 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);
* 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;
}
/* 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;
}
/* 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;
}
}
gboolean
-gmip_find_stream_post (GstMediaInfoPriv *priv)
+gmip_find_stream_post (GstMediaInfoPriv * priv)
{
GstMediaInfoStream *stream = priv->stream;
const GstFormat *formats;
/* get supported formats on decoder pad */
formats = gst_pad_get_formats (priv->decoder_pad);
- while (*formats)
- {
+ while (*formats) {
const GstFormatDefinition *definition;
format = *formats;
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:
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");
/* 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");
/* 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);
/* 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;
}
}
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;
}
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;
/* 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;
}
}
gboolean
-gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
+gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv)
{
GstFormat format, track_format;
/* 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 */
}
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;
/* 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;
}
}
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;
}
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;
}
-
-
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);
-
-GstMediaInfoTrack *
- gmi_track_new (void);
-
-void gmip_reset (GstMediaInfoPriv *priv);
-gboolean gmip_init (GstMediaInfoPriv *priv, GError **error);
-
-void gmi_clear_decoder (GstMediaInfo *info);
-
-gboolean gmi_seek_to_track (GstMediaInfo *info,
- long track);
-
-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);
-
-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);
+GstMediaInfoStream *gmi_stream_new (void);
+void gmi_stream_free (GstMediaInfoStream * stream);
+
+GstMediaInfoTrack *gmi_track_new (void);
+
+void gmip_reset (GstMediaInfoPriv * priv);
+gboolean gmip_init (GstMediaInfoPriv * priv, GError ** error);
+
+void gmi_clear_decoder (GstMediaInfo * info);
+
+gboolean gmi_seek_to_track (GstMediaInfo * info, long track);
+
+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);
+
+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__ */
#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;
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) {
}
static void
-info_print (GstMediaInfoStream *stream)
+info_print (GstMediaInfoStream * stream)
{
int i;
GList *p;
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");
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);
}
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);
}
#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;
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;
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;
}
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,
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);
/*
- 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);
/* 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;
}
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);
}
}
* 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;
* 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;
}
* 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;
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 */
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);
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 */
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);
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;
}
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;
#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
{
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];
};
#define GST_MEDIA_INFO_FORMAT 1 << 5
#define GST_MEDIA_INFO_ALL ((1 << 6) - 1)
-GQuark gst_media_info_error_quark (void);
-
-void gst_media_info_init (void);
-GType gst_media_info_get_type (void);
-
-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);
+GQuark gst_media_info_error_quark (void);
+
+void gst_media_info_init (void);
+GType gst_media_info_get_type (void);
+
+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);
+
/*
* FIXME: reset ?
gboolean gst_media_info_write (GstMediaInfo *media_info,
*/
G_END_DECLS
-
#endif /* __GST_MEDIA_INFO_H__ */
#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 };
};
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;
*/
const GList *
-gst_mixer_list_tracks (GstMixer *mixer)
+gst_mixer_list_tracks (GstMixer * mixer)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (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);
*/
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);
*/
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);
*/
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);
}
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);
}
#include <gst/mixer/mixer-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_MIXER \
(gst_mixer_get_type ())
#define GST_MIXER(obj) \
(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
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__ */
#include "mixertrack.h"
-enum {
+enum
+{
/* FILL ME */
SIGNAL_VOLUME_CHANGED,
SIGNAL_RECORD_TOGGLED,
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 };
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;
}
static void
-gst_mixer_track_dispose (GObject *object)
+gst_mixer_track_dispose (GObject * object)
{
GstMixerTrack *channel = GST_MIXER_TRACK (object);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_MIXER_TRACK \
(gst_mixer_track_get_type ())
#define GST_MIXER_TRACK(obj) \
(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:
*
* 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__ */
#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)
};
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);
}
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));
}
-
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_NAVIGATION \
(gst_navigation_get_type ())
#define GST_NAVIGATION(obj) \
(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__ */
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
LAST_SIGNAL
};
-struct _GstPlayPrivate {
+struct _GstPlayPrivate
+{
char *location;
-
+
GHashTable *elements;
-
+
gint64 time_nanos;
gint64 length_nanos;
-
+
gint get_length_attempt;
-
- gint tick_unblock_remaining; /* how many msecs left
- to unblock due to seeking */
+
+ gint tick_unblock_remaining; /* how many msecs left
+ to unblock due to seeking */
guint tick_id;
guint length_id;
-
+
gulong handoff_hid;
/* error/debug handling */
/* */
/* ======================================================= */
-static GstCaps * gst_play_video_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data);
-static GstCaps * gst_play_audio_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data);
+static GstCaps *gst_play_video_fixate (GstPad * pad, const GstCaps * caps,
+ gpointer user_data);
+static GstCaps *gst_play_audio_fixate (GstPad * pad, const GstCaps * caps,
+ gpointer user_data);
static GQuark
gst_play_error_quark (void)
{
static GQuark quark = 0;
+
if (quark == 0)
quark = g_quark_from_static_string ("gst-play-error-quark");
return quark;
/* General GError creation */
static void
-gst_play_error_create (GError ** error, const gchar *message)
+gst_play_error_create (GError ** error, const gchar * message)
{
/* check if caller wanted an error reported */
if (error == NULL)
/* FIXME: what if multiple elements could have been used and they're all
* missing ? varargs ? */
static void
-gst_play_error_plugin (const gchar *element, GError ** error)
+gst_play_error_plugin (const gchar * element, GError ** error)
{
gchar *message;
message = g_strdup_printf ("The %s element could not be found. "
- "This element is essential for playback. "
- "Please install the right plug-in and verify "
- "that it works by running 'gst-inspect %s'",
- element, element);
+ "This element is essential for playback. "
+ "Please install the right plug-in and verify "
+ "that it works by running 'gst-inspect %s'", element, element);
gst_play_error_create (error, message);
g_free (message);
return;
static gboolean
-gst_play_pipeline_setup (GstPlay *play, GError **error)
+gst_play_pipeline_setup (GstPlay * play, GError ** error)
{
/* Threads */
GstElement *work_thread, *audio_thread, *video_thread;
+
/* Main Thread elements */
GstElement *source, *autoplugger, *audioconvert, *volume, *tee, *identity;
GstElement *identity_cs;
+
/* Visualization bin */
GstElement *vis_bin, *vis_queue, *vis_element, *vis_cs;
+
/* Video Thread elements */
GstElement *video_queue, *video_switch, *video_cs, *video_balance;
GstElement *balance_cs, *video_scaler, *video_sink;
+
/* Audio Thread elements */
GstElement *audio_queue, *audio_sink;
+
/* Some useful pads */
GstPad *tee_pad1, *tee_pad2;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* Creating main thread and its elements */
{
- GST_PLAY_MAKE_OR_ERROR (work_thread, "thread", "work_thread", error);
- g_hash_table_insert (play->priv->elements, "work_thread", work_thread);
- gst_bin_add (GST_BIN (play), work_thread);
-
- /* Placeholder for datasrc */
- GST_PLAY_MAKE_OR_ERROR (source, "fakesrc", "source", error);
- g_hash_table_insert (play->priv->elements, "source", source);
-
- /* Autoplugger */
- GST_PLAY_MAKE_OR_ERROR (autoplugger, "spider", "autoplugger", error);
- g_hash_table_insert (play->priv->elements, "autoplugger", autoplugger);
-
- /* Make sure we convert audio to the needed format */
- GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert", error);
- g_hash_table_insert (play->priv->elements, "audioconvert", audioconvert);
-
- /* Duplicate audio signal to audio sink and visualization thread */
- GST_PLAY_MAKE_OR_ERROR (tee, "tee", "tee", error);
- tee_pad1 = gst_element_get_request_pad (tee, "src%d");
- tee_pad2 = gst_element_get_request_pad (tee, "src%d");
- g_hash_table_insert (play->priv->elements, "tee_pad1", tee_pad1);
- g_hash_table_insert (play->priv->elements, "tee_pad2", tee_pad2);
- g_hash_table_insert (play->priv->elements, "tee", tee);
-
- gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, audioconvert, tee, NULL);
- if (!gst_element_link_many (source, autoplugger, audioconvert, tee, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link source thread elements");
-
- /* identity ! colorspace ! switch */
- GST_PLAY_MAKE_OR_ERROR (identity, "identity", "identity", error);
- g_hash_table_insert (play->priv->elements, "identity", identity);
-
- identity_cs = gst_element_factory_make ("ffcolorspace", "identity_cs");
- if (!GST_IS_ELEMENT (identity_cs)) {
- identity_cs = gst_element_factory_make ("colorspace", "identity_cs");
- if (!GST_IS_ELEMENT (identity_cs))
- {
- gst_play_error_plugin ("colorspace", error);
- return FALSE;
+ GST_PLAY_MAKE_OR_ERROR (work_thread, "thread", "work_thread", error);
+ g_hash_table_insert (play->priv->elements, "work_thread", work_thread);
+ gst_bin_add (GST_BIN (play), work_thread);
+
+ /* Placeholder for datasrc */
+ GST_PLAY_MAKE_OR_ERROR (source, "fakesrc", "source", error);
+ g_hash_table_insert (play->priv->elements, "source", source);
+
+ /* Autoplugger */
+ GST_PLAY_MAKE_OR_ERROR (autoplugger, "spider", "autoplugger", error);
+ g_hash_table_insert (play->priv->elements, "autoplugger", autoplugger);
+
+ /* Make sure we convert audio to the needed format */
+ GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert",
+ error);
+ g_hash_table_insert (play->priv->elements, "audioconvert", audioconvert);
+
+ /* Duplicate audio signal to audio sink and visualization thread */
+ GST_PLAY_MAKE_OR_ERROR (tee, "tee", "tee", error);
+ tee_pad1 = gst_element_get_request_pad (tee, "src%d");
+ tee_pad2 = gst_element_get_request_pad (tee, "src%d");
+ g_hash_table_insert (play->priv->elements, "tee_pad1", tee_pad1);
+ g_hash_table_insert (play->priv->elements, "tee_pad2", tee_pad2);
+ g_hash_table_insert (play->priv->elements, "tee", tee);
+
+ gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, audioconvert,
+ tee, NULL);
+ if (!gst_element_link_many (source, autoplugger, audioconvert, tee, NULL))
+ GST_PLAY_ERROR_RETURN (error, "Could not link source thread elements");
+
+ /* identity ! colorspace ! switch */
+ GST_PLAY_MAKE_OR_ERROR (identity, "identity", "identity", error);
+ g_hash_table_insert (play->priv->elements, "identity", identity);
+
+ identity_cs = gst_element_factory_make ("ffcolorspace", "identity_cs");
+ if (!GST_IS_ELEMENT (identity_cs)) {
+ identity_cs = gst_element_factory_make ("colorspace", "identity_cs");
+ if (!GST_IS_ELEMENT (identity_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
}
+ g_hash_table_insert (play->priv->elements, "identity_cs", identity_cs);
+ gst_bin_add_many (GST_BIN (work_thread), identity, identity_cs, NULL);
+ if (!gst_element_link_many (autoplugger, identity, identity_cs, NULL))
+ GST_PLAY_ERROR_RETURN (error, "Could not link work thread elements");
}
- g_hash_table_insert (play->priv->elements, "identity_cs", identity_cs);
- gst_bin_add_many (GST_BIN (work_thread), identity, identity_cs, NULL);
- if (!gst_element_link_many (autoplugger, identity, identity_cs, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link work thread elements");
- }
-
+
/* Visualization bin (note: it s not added to the pipeline yet) */
{
- vis_bin = gst_bin_new ("vis_bin");
- if (!GST_IS_ELEMENT (vis_bin))
- {
- gst_play_error_plugin ("bin", error);
- return FALSE;
- }
-
- g_hash_table_insert (play->priv->elements, "vis_bin", vis_bin);
-
- /* Buffer queue for video data */
- GST_PLAY_MAKE_OR_ERROR (vis_queue, "queue", "vis_queue", error);
- g_hash_table_insert (play->priv->elements, "vis_queue", vis_queue);
-
- /* Visualization element placeholder */
- GST_PLAY_MAKE_OR_ERROR (vis_element, "identity", "vis_element", error);
- g_hash_table_insert (play->priv->elements, "vis_element", vis_element);
-
- /* Colorspace conversion */
- vis_cs = gst_element_factory_make ("ffcolorspace", "vis_cs");
- if (!GST_IS_ELEMENT (vis_cs)) {
- vis_cs = gst_element_factory_make ("colorspace", "vis_cs");
- if (!GST_IS_ELEMENT (vis_cs))
- {
- gst_play_error_plugin ("colorspace", error);
+ vis_bin = gst_bin_new ("vis_bin");
+ if (!GST_IS_ELEMENT (vis_bin)) {
+ gst_play_error_plugin ("bin", error);
return FALSE;
}
- }
-
- g_hash_table_insert (play->priv->elements, "vis_cs", vis_cs);
-
- gst_bin_add_many (GST_BIN (vis_bin), vis_queue, vis_element, vis_cs, NULL);
- if (!gst_element_link_many (vis_queue, vis_element, vis_cs, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link visualisation thread elements");
- gst_element_add_ghost_pad (vis_bin,
- gst_element_get_pad (vis_cs, "src"), "src");
+
+ g_hash_table_insert (play->priv->elements, "vis_bin", vis_bin);
+
+ /* Buffer queue for video data */
+ GST_PLAY_MAKE_OR_ERROR (vis_queue, "queue", "vis_queue", error);
+ g_hash_table_insert (play->priv->elements, "vis_queue", vis_queue);
+
+ /* Visualization element placeholder */
+ GST_PLAY_MAKE_OR_ERROR (vis_element, "identity", "vis_element", error);
+ g_hash_table_insert (play->priv->elements, "vis_element", vis_element);
+
+ /* Colorspace conversion */
+ vis_cs = gst_element_factory_make ("ffcolorspace", "vis_cs");
+ if (!GST_IS_ELEMENT (vis_cs)) {
+ vis_cs = gst_element_factory_make ("colorspace", "vis_cs");
+ if (!GST_IS_ELEMENT (vis_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
+ }
+
+ g_hash_table_insert (play->priv->elements, "vis_cs", vis_cs);
+
+ gst_bin_add_many (GST_BIN (vis_bin), vis_queue, vis_element, vis_cs, NULL);
+ if (!gst_element_link_many (vis_queue, vis_element, vis_cs, NULL))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link visualisation thread elements");
+ gst_element_add_ghost_pad (vis_bin, gst_element_get_pad (vis_cs, "src"),
+ "src");
}
/* Creating our video output bin */
{
- GST_PLAY_MAKE_OR_ERROR (video_thread, "thread", "video_thread", error);
- g_hash_table_insert (play->priv->elements, "video_thread", video_thread);
- gst_bin_add (GST_BIN (work_thread), video_thread);
-
- /* Buffer queue for video data */
- GST_PLAY_MAKE_OR_ERROR (video_queue, "queue", "video_queue", error);
- g_hash_table_insert (play->priv->elements, "video_queue", video_queue);
-
- GST_PLAY_MAKE_OR_ERROR (video_switch, "switch", "video_switch", error);
- g_hash_table_insert (play->priv->elements, "video_switch", video_switch);
-
- /* Colorspace conversion */
- video_cs = gst_element_factory_make ("ffcolorspace", "video_cs");
- if (!GST_IS_ELEMENT (video_cs)) {
- video_cs = gst_element_factory_make ("colorspace", "video_cs");
- if (!GST_IS_ELEMENT (video_cs))
- {
- gst_play_error_plugin ("colorspace", error);
- return FALSE;
+ GST_PLAY_MAKE_OR_ERROR (video_thread, "thread", "video_thread", error);
+ g_hash_table_insert (play->priv->elements, "video_thread", video_thread);
+ gst_bin_add (GST_BIN (work_thread), video_thread);
+
+ /* Buffer queue for video data */
+ GST_PLAY_MAKE_OR_ERROR (video_queue, "queue", "video_queue", error);
+ g_hash_table_insert (play->priv->elements, "video_queue", video_queue);
+
+ GST_PLAY_MAKE_OR_ERROR (video_switch, "switch", "video_switch", error);
+ g_hash_table_insert (play->priv->elements, "video_switch", video_switch);
+
+ /* Colorspace conversion */
+ video_cs = gst_element_factory_make ("ffcolorspace", "video_cs");
+ if (!GST_IS_ELEMENT (video_cs)) {
+ video_cs = gst_element_factory_make ("colorspace", "video_cs");
+ if (!GST_IS_ELEMENT (video_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
}
- }
- g_hash_table_insert (play->priv->elements, "video_cs", video_cs);
-
- /* Software colorbalance */
- GST_PLAY_MAKE_OR_ERROR (video_balance, "videobalance", "video_balance", error);
- g_hash_table_insert (play->priv->elements, "video_balance", video_balance);
-
- /* Colorspace conversion */
- balance_cs = gst_element_factory_make ("ffcolorspace", "balance_cs");
- if (!GST_IS_ELEMENT (balance_cs)) {
- balance_cs = gst_element_factory_make ("colorspace", "balance_cs");
- if (!GST_IS_ELEMENT (balance_cs))
- {
- gst_play_error_plugin ("colorspace", error);
- return FALSE;
+ g_hash_table_insert (play->priv->elements, "video_cs", video_cs);
+
+ /* Software colorbalance */
+ GST_PLAY_MAKE_OR_ERROR (video_balance, "videobalance", "video_balance",
+ error);
+ g_hash_table_insert (play->priv->elements, "video_balance", video_balance);
+
+ /* Colorspace conversion */
+ balance_cs = gst_element_factory_make ("ffcolorspace", "balance_cs");
+ if (!GST_IS_ELEMENT (balance_cs)) {
+ balance_cs = gst_element_factory_make ("colorspace", "balance_cs");
+ if (!GST_IS_ELEMENT (balance_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
}
- }
- g_hash_table_insert (play->priv->elements, "balance_cs", balance_cs);
-
- /* Software scaling of video stream */
- GST_PLAY_MAKE_OR_ERROR (video_scaler, "videoscale", "video_scaler", error);
- g_hash_table_insert (play->priv->elements, "video_scaler", video_scaler);
- g_signal_connect (gst_element_get_pad(video_scaler, "src"), "fixate",
- G_CALLBACK (gst_play_video_fixate), play);
-
- /* Placeholder for future video sink bin */
- GST_PLAY_MAKE_OR_ERROR (video_sink, "fakesink", "video_sink", error);
- g_hash_table_insert (play->priv->elements, "video_sink", video_sink);
-
- gst_bin_add_many (GST_BIN (video_thread), video_queue, video_switch, video_cs,
- video_balance, balance_cs, video_scaler, video_sink, NULL);
- /* break down linking so we can figure out what might be failing */
- if (!gst_element_link (video_queue, video_switch))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (queue and switch)");
- if (!gst_element_link (video_switch, video_cs))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (switch and cs)");
- if (!gst_element_link (video_cs, video_balance))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (cs and balance)");
- if (!gst_element_link (video_balance, balance_cs))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance and balance_cs)");
- if (!gst_element_link (balance_cs, video_scaler))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance_cs and scaler)");
- if (!gst_element_link (video_scaler, video_sink))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance_cs and scaler)");
- gst_element_add_ghost_pad (video_thread,
- gst_element_get_pad (video_queue, "sink"),
- "sink");
- if (!gst_element_link (identity_cs, video_thread))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread elements");
+ g_hash_table_insert (play->priv->elements, "balance_cs", balance_cs);
+
+ /* Software scaling of video stream */
+ GST_PLAY_MAKE_OR_ERROR (video_scaler, "videoscale", "video_scaler", error);
+ g_hash_table_insert (play->priv->elements, "video_scaler", video_scaler);
+ g_signal_connect (gst_element_get_pad (video_scaler, "src"), "fixate",
+ G_CALLBACK (gst_play_video_fixate), play);
+
+ /* Placeholder for future video sink bin */
+ GST_PLAY_MAKE_OR_ERROR (video_sink, "fakesink", "video_sink", error);
+ g_hash_table_insert (play->priv->elements, "video_sink", video_sink);
+
+ gst_bin_add_many (GST_BIN (video_thread), video_queue, video_switch,
+ video_cs, video_balance, balance_cs, video_scaler, video_sink, NULL);
+ /* break down linking so we can figure out what might be failing */
+ if (!gst_element_link (video_queue, video_switch))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (queue and switch)");
+ if (!gst_element_link (video_switch, video_cs))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (switch and cs)");
+ if (!gst_element_link (video_cs, video_balance))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (cs and balance)");
+ if (!gst_element_link (video_balance, balance_cs))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (balance and balance_cs)");
+ if (!gst_element_link (balance_cs, video_scaler))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (balance_cs and scaler)");
+ if (!gst_element_link (video_scaler, video_sink))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (balance_cs and scaler)");
+ gst_element_add_ghost_pad (video_thread, gst_element_get_pad (video_queue,
+ "sink"), "sink");
+ if (!gst_element_link (identity_cs, video_thread))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread elements");
}
/* Creating our audio output bin
{ queue ! fakesink } */
{
- GST_PLAY_MAKE_OR_ERROR (audio_thread, "thread", "audio_thread", error);
- g_hash_table_insert (play->priv->elements, "audio_thread", audio_thread);
- gst_bin_add (GST_BIN (work_thread), audio_thread);
-
- /* Buffer queue for our audio thread */
- GST_PLAY_MAKE_OR_ERROR (audio_queue, "queue", "audio_queue", error);
- g_hash_table_insert (play->priv->elements, "audio_queue", audio_queue);
-
- /* Volume control */
- GST_PLAY_MAKE_OR_ERROR (volume, "volume", "volume", error);
- g_hash_table_insert (play->priv->elements, "volume", volume);
- g_signal_connect (gst_element_get_pad(volume, "src"), "fixate",
- G_CALLBACK (gst_play_audio_fixate), play);
-
- /* Placeholder for future audio sink bin */
- GST_PLAY_MAKE_OR_ERROR (audio_sink, "fakesink", "audio_sink", error);
- g_hash_table_insert (play->priv->elements, "audio_sink", audio_sink);
-
- gst_bin_add_many (GST_BIN (audio_thread), audio_queue, volume, audio_sink, NULL);
- if (!gst_element_link_many (audio_queue, volume, audio_sink, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link audio output thread elements");
- gst_element_add_ghost_pad (audio_thread,
- gst_element_get_pad (audio_queue, "sink"),
- "sink");
- gst_pad_link (tee_pad2, gst_element_get_pad (audio_queue, "sink"));
+ GST_PLAY_MAKE_OR_ERROR (audio_thread, "thread", "audio_thread", error);
+ g_hash_table_insert (play->priv->elements, "audio_thread", audio_thread);
+ gst_bin_add (GST_BIN (work_thread), audio_thread);
+
+ /* Buffer queue for our audio thread */
+ GST_PLAY_MAKE_OR_ERROR (audio_queue, "queue", "audio_queue", error);
+ g_hash_table_insert (play->priv->elements, "audio_queue", audio_queue);
+
+ /* Volume control */
+ GST_PLAY_MAKE_OR_ERROR (volume, "volume", "volume", error);
+ g_hash_table_insert (play->priv->elements, "volume", volume);
+ g_signal_connect (gst_element_get_pad (volume, "src"), "fixate",
+ G_CALLBACK (gst_play_audio_fixate), play);
+
+ /* Placeholder for future audio sink bin */
+ GST_PLAY_MAKE_OR_ERROR (audio_sink, "fakesink", "audio_sink", error);
+ g_hash_table_insert (play->priv->elements, "audio_sink", audio_sink);
+
+ gst_bin_add_many (GST_BIN (audio_thread), audio_queue, volume, audio_sink,
+ NULL);
+ if (!gst_element_link_many (audio_queue, volume, audio_sink, NULL))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link audio output thread elements");
+ gst_element_add_ghost_pad (audio_thread, gst_element_get_pad (audio_queue,
+ "sink"), "sink");
+ gst_pad_link (tee_pad2, gst_element_get_pad (audio_queue, "sink"));
}
-
+
return TRUE;
}
static void
-gst_play_have_video_size (GstElement *element, gint width,
- gint height, GstPlay *play)
+gst_play_have_video_size (GstElement * element, gint width,
+ gint height, GstPlay * play)
{
g_return_if_fail (play != NULL);
g_return_if_fail (GST_IS_PLAY (play));
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIDEO_SIZE],
- 0, width, height);
+ 0, width, height);
}
static gboolean
-gst_play_tick_callback (GstPlay *play)
+gst_play_tick_callback (GstPlay * play)
{
GstFormat format = GST_FORMAT_TIME;
gboolean q = FALSE;
GstElement *audio_sink_element = NULL;
-
+
g_return_val_if_fail (play != NULL, FALSE);
/* just return without updating the UI when we are in the middle of seeking */
- if (play->priv->tick_unblock_remaining > 0)
- {
+ if (play->priv->tick_unblock_remaining > 0) {
play->priv->tick_unblock_remaining -= TICK_INTERVAL_MSEC;
return TRUE;
}
-
+
if (!GST_IS_PLAY (play)) {
play->priv->tick_id = 0;
return FALSE;
}
-
+
audio_sink_element = g_hash_table_lookup (play->priv->elements,
- "audio_sink_element");
-
+ "audio_sink_element");
+
if (!GST_IS_ELEMENT (audio_sink_element)) {
play->priv->tick_id = 0;
return FALSE;
}
-
+
q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
- &(play->priv->time_nanos));
-
+ &(play->priv->time_nanos));
+
if (q)
g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
-
+ 0, play->priv->time_nanos);
+
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING)
return TRUE;
else {
}
static gboolean
-gst_play_get_length_callback (GstPlay *play)
+gst_play_get_length_callback (GstPlay * play)
{
GstElement *audio_sink_element, *video_sink_element;
GstFormat format = GST_FORMAT_TIME;
gint64 value;
gboolean q = FALSE;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* We try to get length from all real sink elements */
audio_sink_element = g_hash_table_lookup (play->priv->elements,
- "audio_sink_element");
+ "audio_sink_element");
video_sink_element = g_hash_table_lookup (play->priv->elements,
- "video_sink_element");
+ "video_sink_element");
if (!GST_IS_ELEMENT (audio_sink_element) &&
!GST_IS_ELEMENT (video_sink_element)) {
play->priv->length_id = 0;
return FALSE;
}
-
+
/* Audio first and then Video */
if (GST_IS_ELEMENT (audio_sink_element))
q = gst_element_query (audio_sink_element, GST_QUERY_TOTAL, &format,
- &value);
- if ( (!q) && (GST_IS_ELEMENT (video_sink_element)) )
+ &value);
+ if ((!q) && (GST_IS_ELEMENT (video_sink_element)))
q = gst_element_query (video_sink_element, GST_QUERY_TOTAL, &format,
- &value);
-
+ &value);
+
if (q) {
play->priv->length_nanos = value;
g_signal_emit (G_OBJECT (play), gst_play_signals[STREAM_LENGTH],
- 0,play->priv->length_nanos);
+ 0, play->priv->length_nanos);
play->priv->length_id = 0;
return FALSE;
}
-
+
play->priv->get_length_attempt++;
-
+
/* We try 16 times */
if (play->priv->get_length_attempt > 15) {
play->priv->length_id = 0;
return FALSE;
- }
- else
+ } else
return TRUE;
}
static GstCaps *
-gst_play_video_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data)
+gst_play_video_fixate (GstPad * pad, const GstCaps * caps, gpointer user_data)
{
GstStructure *structure;
GstCaps *newcaps;
GST_DEBUG ("video fixate %p %" GST_PTR_FORMAT, pad, caps);
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
}
static GstCaps *
-gst_play_audio_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data)
+gst_play_audio_fixate (GstPad * pad, const GstCaps * caps, gpointer user_data)
{
GstCaps *newcaps;
GstStructure *structure;
GST_DEBUG ("audio fixate %p %" GST_PTR_FORMAT, pad, caps);
- newcaps = gst_caps_new_full (gst_structure_copy (
- gst_caps_get_structure (caps, 0)), NULL);
+ newcaps =
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)),
+ NULL);
structure = gst_caps_get_structure (newcaps, 0);
if (gst_caps_structure_fixate_field_nearest_int (structure, "rate", 44100)) {
}
static void
-gst_play_state_change (GstElement *element, GstElementState old,
- GstElementState state)
+gst_play_state_change (GstElement * element, GstElementState old,
+ GstElementState state)
{
GstPlay *play;
-
+
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_PLAY (element));
-
+
play = GST_PLAY (element);
-
+
if (state == GST_STATE_PLAYING) {
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
play->priv->tick_id = 0;
}
-
+
play->priv->tick_id = g_timeout_add (TICK_INTERVAL_MSEC,
- (GSourceFunc) gst_play_tick_callback,
- play);
-
+ (GSourceFunc) gst_play_tick_callback, play);
+
play->priv->get_length_attempt = 0;
-
+
if (play->priv->length_id) {
g_source_remove (play->priv->length_id);
play->priv->length_id = 0;
}
-
+
play->priv->length_id = g_timeout_add (TICK_INTERVAL_MSEC,
- (GSourceFunc) gst_play_get_length_callback,
- play);
- }
- else {
+ (GSourceFunc) gst_play_get_length_callback, play);
+ } else {
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
play->priv->tick_id = 0;
play->priv->length_id = 0;
}
}
-
+
if (GST_ELEMENT_CLASS (parent_class)->state_change)
GST_ELEMENT_CLASS (parent_class)->state_change (element, old, state);
}
static void
-gst_play_identity_handoff (GstElement *identity, GstBuffer *buf, GstPlay *play)
+gst_play_identity_handoff (GstElement * identity, GstBuffer * buf,
+ GstPlay * play)
{
g_signal_handler_disconnect (G_OBJECT (identity), play->priv->handoff_hid);
play->priv->handoff_hid = 0;
/* =========================================== */
static void
-gst_play_dispose (GObject *object)
+gst_play_dispose (GObject * object)
{
GstPlay *play;
-
+
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_PLAY (object));
-
+
play = GST_PLAY (object);
-
+
if (play->priv->length_id) {
g_source_remove (play->priv->length_id);
play->priv->length_id = 0;
}
-
+
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
play->priv->tick_id = 0;
}
-
+
if (play->priv->location) {
g_free (play->priv->location);
play->priv->location = NULL;
}
-
+
if (play->priv->elements) {
g_hash_table_destroy (play->priv->elements);
play->priv->elements = NULL;
}
-
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-gst_play_init (GstPlay *play)
+gst_play_init (GstPlay * play)
{
play->priv = g_new0 (GstPlayPrivate, 1);
play->priv->location = NULL;
play->priv->elements = g_hash_table_new (g_str_hash, g_str_equal);
play->priv->error = NULL;
play->priv->debug = NULL;
-
- if (!gst_play_pipeline_setup (play, &play->priv->error))
- {
+
+ if (!gst_play_pipeline_setup (play, &play->priv->error)) {
g_warning ("libgstplay: failed initializing pipeline, error: %s",
- play->priv->error->message);
+ play->priv->error->message);
}
}
static void
-gst_play_class_init (GstPlayClass *klass)
+gst_play_class_init (GstPlayClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
+
parent_class = g_type_class_peek_parent (klass);
gobject_class->dispose = gst_play_dispose;
element_class->state_change = gst_play_state_change;
-
+
gst_play_signals[TIME_TICK] =
- g_signal_new ("time-tick", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstPlayClass, time_tick), NULL, NULL,
- gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
+ g_signal_new ("time-tick", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstPlayClass, time_tick), NULL, NULL,
+ gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
gst_play_signals[STREAM_LENGTH] =
- g_signal_new ("stream-length", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstPlayClass, stream_length), NULL, NULL,
- gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
+ g_signal_new ("stream-length", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstPlayClass, stream_length), NULL, NULL,
+ gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
gst_play_signals[HAVE_VIDEO_SIZE] =
- g_signal_new ("have-video-size", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstPlayClass, have_video_size), NULL, NULL,
- gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
- G_TYPE_INT, G_TYPE_INT);
+ g_signal_new ("have-video-size", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstPlayClass, have_video_size), NULL, NULL,
+ gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
}
/* ======================================================= */
* Returns: TRUE if location was set successfully.
*/
gboolean
-gst_play_set_location (GstPlay *play, const char *location)
+gst_play_set_location (GstPlay * play, const char *location)
{
GstElement *work_thread, *source, *autoplugger;
GstElement *audioconvert, *identity;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
if (play->priv->location)
g_free (play->priv->location);
-
+
play->priv->location = g_strdup (location);
-
+
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
work_thread = g_hash_table_lookup (play->priv->elements, "work_thread");
if (!GST_IS_ELEMENT (work_thread))
return FALSE;
identity = g_hash_table_lookup (play->priv->elements, "identity");
if (!GST_IS_ELEMENT (identity))
return FALSE;
-
+
/* Spider can autoplugg only once. We remove the actual one and put a new
autoplugger */
gst_element_unlink (source, autoplugger);
gst_element_unlink (autoplugger, identity);
gst_element_unlink (autoplugger, audioconvert);
gst_bin_remove (GST_BIN (work_thread), autoplugger);
-
+
autoplugger = gst_element_factory_make ("spider", "autoplugger");
if (!GST_IS_ELEMENT (autoplugger))
return FALSE;
-
+
gst_bin_add (GST_BIN (work_thread), autoplugger);
gst_element_link (source, autoplugger);
gst_element_link (autoplugger, audioconvert);
gst_element_link (autoplugger, identity);
-
+
g_hash_table_replace (play->priv->elements, "autoplugger", autoplugger);
-
+
/* FIXME: Why don't we have an interface to do that kind of stuff ? */
g_object_set (G_OBJECT (source), "location", play->priv->location, NULL);
-
+
play->priv->length_nanos = 0LL;
play->priv->time_nanos = 0LL;
-
+
g_signal_emit (G_OBJECT (play), gst_play_signals[STREAM_LENGTH], 0, 0LL);
g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK], 0, 0LL);
-
+
return TRUE;
}
* Returns: a const #char* pointer to current location.
*/
char *
-gst_play_get_location (GstPlay *play)
+gst_play_get_location (GstPlay * play)
{
g_return_val_if_fail (play != NULL, NULL);
g_return_val_if_fail (GST_IS_PLAY (play), NULL);
gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
{
GstElement *audio_seek_element, *video_seek_element, *audio_sink_element;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
if (time_nanos < 0LL)
time_nanos = 0LL;
-
+
audio_seek_element = g_hash_table_lookup (play->priv->elements,
- "audioconvert");
+ "audioconvert");
audio_sink_element = g_hash_table_lookup (play->priv->elements,
- "audio_sink_element");
- video_seek_element = g_hash_table_lookup (play->priv->elements,
- "identity");
-
+ "audio_sink_element");
+ video_seek_element = g_hash_table_lookup (play->priv->elements, "identity");
+
if (GST_IS_ELEMENT (audio_seek_element) &&
GST_IS_ELEMENT (video_seek_element) &&
GST_IS_ELEMENT (audio_sink_element)) {
gboolean s = FALSE;
-
+
/* HACK: block tick signal from idler for 500 msec */
/* GStreamer can't currently report when seeking is finished,
so we just chose a .5 sec default block time */
play->priv->tick_unblock_remaining = 500;
-
+
s = gst_element_seek (video_seek_element, GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH,
- time_nanos);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, time_nanos);
if (!s) {
s = gst_element_seek (audio_seek_element, GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH,
- time_nanos);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, time_nanos);
}
-
+
if (s) {
GstFormat format = GST_FORMAT_TIME;
gboolean q = FALSE;
-
+
q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
- &(play->priv->time_nanos));
+ &(play->priv->time_nanos));
if (q)
- g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
+ g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
+ 0, play->priv->time_nanos);
}
}
-
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_data_src (GstPlay *play, GstElement *data_src)
+gst_play_set_data_src (GstPlay * play, GstElement * data_src)
{
GstElement *work_thread, *old_data_src, *autoplugger;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* We bring back the pipeline to READY */
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
/* Getting needed objects */
work_thread = g_hash_table_lookup (play->priv->elements, "work_thread");
if (!GST_IS_ELEMENT (work_thread))
autoplugger = g_hash_table_lookup (play->priv->elements, "autoplugger");
if (!GST_IS_ELEMENT (autoplugger))
return FALSE;
-
+
/* Unlinking old source from autoplugger, removing it from pipeline, adding
the new one and connecting it to autoplugger FIXME: we should put a new
autoplugger here as spider can autoplugg only once */
gst_bin_remove (GST_BIN (work_thread), old_data_src);
gst_bin_add (GST_BIN (work_thread), data_src);
gst_element_link (data_src, autoplugger);
-
+
g_hash_table_replace (play->priv->elements, "source", data_src);
-
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_video_sink (GstPlay *play, GstElement *video_sink)
+gst_play_set_video_sink (GstPlay * play, GstElement * video_sink)
{
GstElement *video_thread, *old_video_sink, *video_scaler, *video_sink_element;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (video_sink != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (video_sink), FALSE);
-
+
/* We bring back the pipeline to READY */
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
/* Getting needed objects */
video_thread = g_hash_table_lookup (play->priv->elements, "video_thread");
if (!GST_IS_ELEMENT (video_thread))
video_scaler = g_hash_table_lookup (play->priv->elements, "video_scaler");
if (!GST_IS_ELEMENT (video_scaler))
return FALSE;
-
+
/* Unlinking old video sink from video scaler, removing it from pipeline,
adding the new one and linking it */
gst_element_unlink (video_scaler, old_video_sink);
gst_bin_remove (GST_BIN (video_thread), old_video_sink);
gst_bin_add (GST_BIN (video_thread), video_sink);
gst_element_link (video_scaler, video_sink);
-
+
g_hash_table_replace (play->priv->elements, "video_sink", video_sink);
-
+
video_sink_element = gst_play_get_sink_element (play, video_sink,
- GST_PLAY_SINK_TYPE_VIDEO);
+ GST_PLAY_SINK_TYPE_VIDEO);
if (GST_IS_ELEMENT (video_sink_element)) {
g_hash_table_replace (play->priv->elements, "video_sink_element",
- video_sink_element);
+ video_sink_element);
if (GST_IS_X_OVERLAY (video_sink_element)) {
g_signal_connect (G_OBJECT (video_sink_element),
- "desired_size_changed",
- G_CALLBACK (gst_play_have_video_size), play);
+ "desired_size_changed", G_CALLBACK (gst_play_have_video_size), play);
}
- }
-
- gst_element_set_state (video_sink, GST_STATE (GST_ELEMENT(play)));
-
+ }
+
+ gst_element_set_state (video_sink, GST_STATE (GST_ELEMENT (play)));
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_audio_sink (GstPlay *play, GstElement *audio_sink)
+gst_play_set_audio_sink (GstPlay * play, GstElement * audio_sink)
{
GstElement *old_audio_sink, *audio_thread, *volume, *audio_sink_element;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (audio_sink != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (audio_sink), FALSE);
-
+
/* We bring back the pipeline to READY */
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
/* Getting needed objects */
old_audio_sink = g_hash_table_lookup (play->priv->elements, "audio_sink");
if (!GST_IS_ELEMENT (old_audio_sink))
volume = g_hash_table_lookup (play->priv->elements, "volume");
if (!GST_IS_ELEMENT (volume))
return FALSE;
-
+
/* Unlinking old audiosink, removing it from pipeline, putting the new one
and linking it */
gst_element_unlink (volume, old_audio_sink);
gst_bin_remove (GST_BIN (audio_thread), old_audio_sink);
gst_bin_add (GST_BIN (audio_thread), audio_sink);
gst_element_link (volume, audio_sink);
-
+
g_hash_table_replace (play->priv->elements, "audio_sink", audio_sink);
-
+
audio_sink_element = gst_play_get_sink_element (play, audio_sink,
- GST_PLAY_SINK_TYPE_AUDIO);
+ GST_PLAY_SINK_TYPE_AUDIO);
if (GST_IS_ELEMENT (audio_sink_element)) {
g_hash_table_replace (play->priv->elements, "audio_sink_element",
- audio_sink_element);
+ audio_sink_element);
}
-
- gst_element_set_state (audio_sink, GST_STATE (GST_ELEMENT(play)));
-
+
+ gst_element_set_state (audio_sink, GST_STATE (GST_ELEMENT (play)));
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_visualization (GstPlay *play, GstElement *vis_element)
+gst_play_set_visualization (GstPlay * play, GstElement * vis_element)
{
GstElement *vis_bin, *vis_queue, *old_vis_element, *vis_cs;
gboolean was_playing = FALSE;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (vis_element != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (vis_element), FALSE);
-
+
/* Getting needed objects */
vis_bin = g_hash_table_lookup (play->priv->elements, "vis_bin");
if (!GST_IS_ELEMENT (vis_bin))
vis_queue = g_hash_table_lookup (play->priv->elements, "vis_queue");
if (!GST_IS_ELEMENT (vis_queue))
return FALSE;
- old_vis_element = g_hash_table_lookup (play->priv->elements,
- "vis_element");
+ old_vis_element = g_hash_table_lookup (play->priv->elements, "vis_element");
if (!GST_IS_ELEMENT (old_vis_element))
return FALSE;
vis_cs = g_hash_table_lookup (play->priv->elements, "vis_cs");
if (!GST_IS_ELEMENT (vis_cs))
return FALSE;
-
+
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
gst_bin_remove (GST_BIN (vis_bin), old_vis_element);
gst_bin_add (GST_BIN (vis_bin), vis_element);
gst_element_link_many (vis_queue, vis_element, vis_cs, NULL);
-
+
g_hash_table_replace (play->priv->elements, "vis_element", vis_element);
-
+
if (was_playing)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
-
+
return TRUE;
}
GstElement *video_thread, *vis_queue, *vis_bin, *video_switch, *identity;
GstPad *tee_pad1, *vis_queue_pad, *vis_bin_pad, *switch_pad;
gboolean was_playing = FALSE;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* Until i fix the switch */
return TRUE;
-
+
/* Getting needed objects */
video_thread = g_hash_table_lookup (play->priv->elements, "video_thread");
if (!GST_IS_ELEMENT (video_thread))
tee_pad1 = g_hash_table_lookup (play->priv->elements, "tee_pad1");
if (!GST_IS_PAD (tee_pad1))
return FALSE;
-
+
vis_queue_pad = gst_element_get_pad (vis_queue, "sink");
-
+
/* Check if the vis element is in the pipeline. That means visualization is
connected already */
if (gst_element_get_managing_bin (vis_bin)) {
-
+
/* If we are supposed to connect then nothing to do we return */
if (connect) {
return TRUE;
}
-
+
/* Disconnecting visualization */
-
+
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
was_playing = TRUE;
}
-
+
/* Unlinking, removing */
gst_pad_unlink (tee_pad1, vis_queue_pad);
vis_bin_pad = gst_element_get_pad (vis_bin, "src");
gst_element_release_request_pad (video_switch, switch_pad);
gst_object_ref (GST_OBJECT (vis_bin));
gst_bin_remove (GST_BIN (video_thread), vis_bin);
- }
- else {
-
+ } else {
+
/* If we are supposed to disconnect then nothing to do we return */
if (!connect) {
return TRUE;
}
-
+
/* Connecting visualization */
-
+
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
was_playing = TRUE;
}
-
+
/* Adding, linking */
play->priv->handoff_hid = g_signal_connect (G_OBJECT (identity),
- "handoff",
- G_CALLBACK (gst_play_identity_handoff), play);
+ "handoff", G_CALLBACK (gst_play_identity_handoff), play);
gst_bin_add (GST_BIN (video_thread), vis_bin);
gst_pad_link (tee_pad1, vis_queue_pad);
gst_element_link (vis_bin, video_switch);
if (was_playing)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
-
+
return TRUE;
}
* Returns: the sink #GstElement of @element.
*/
GstElement *
-gst_play_get_sink_element (GstPlay *play,
- GstElement *element, GstPlaySinkType sink_type)
+gst_play_get_sink_element (GstPlay * play,
+ GstElement * element, GstPlaySinkType sink_type)
{
GList *elements = NULL;
const GList *pads = NULL;
if (GST_IS_BIN (element)) {
element = gst_play_get_sink_element (play, element, sink_type);
if (GST_IS_ELEMENT (element))
- return element;
- }
- else {
+ return element;
+ } else {
pads = gst_element_get_pad_list (element);
has_src = FALSE;
has_correct_type = FALSE;
while (pads) {
- /* check for src pad */
- if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
- has_src = TRUE;
- break;
- }
- else {
- /* If not a src pad checking caps */
- GstCaps *caps;
- GstStructure *structure;
- gboolean has_video_cap = FALSE;
- gboolean has_audio_cap = FALSE;
-
- caps = gst_pad_get_caps (GST_PAD (pads->data));
- structure = gst_caps_get_structure (caps, 0);
-
- if (strcmp (gst_structure_get_name (structure),
- "audio/x-raw-int") == 0) {
- has_audio_cap = TRUE;
- }
-
- if (strcmp (gst_structure_get_name (structure),
- "video/x-raw-yuv") == 0 ||
- strcmp (gst_structure_get_name (structure),
- "video/x-raw-rgb") == 0) {
- has_video_cap = TRUE;
- }
-
- gst_caps_free (caps);
-
- switch (sink_type) {
- case GST_PLAY_SINK_TYPE_AUDIO:
- if (has_audio_cap)
- has_correct_type = TRUE;
- break;
- case GST_PLAY_SINK_TYPE_VIDEO:
- if (has_video_cap)
- has_correct_type = TRUE;
- break;
- case GST_PLAY_SINK_TYPE_ANY:
- if ((has_video_cap) || (has_audio_cap))
- has_correct_type = TRUE;
- break;
- default:
- has_correct_type = FALSE;
- }
- }
-
- pads = g_list_next (pads);
-
+ /* check for src pad */
+ if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
+ has_src = TRUE;
+ break;
+ } else {
+ /* If not a src pad checking caps */
+ GstCaps *caps;
+ GstStructure *structure;
+ gboolean has_video_cap = FALSE;
+ gboolean has_audio_cap = FALSE;
+
+ caps = gst_pad_get_caps (GST_PAD (pads->data));
+ structure = gst_caps_get_structure (caps, 0);
+
+ if (strcmp (gst_structure_get_name (structure),
+ "audio/x-raw-int") == 0) {
+ has_audio_cap = TRUE;
+ }
+
+ if (strcmp (gst_structure_get_name (structure),
+ "video/x-raw-yuv") == 0 ||
+ strcmp (gst_structure_get_name (structure),
+ "video/x-raw-rgb") == 0) {
+ has_video_cap = TRUE;
+ }
+
+ gst_caps_free (caps);
+
+ switch (sink_type) {
+ case GST_PLAY_SINK_TYPE_AUDIO:
+ if (has_audio_cap)
+ has_correct_type = TRUE;
+ break;
+ case GST_PLAY_SINK_TYPE_VIDEO:
+ if (has_video_cap)
+ has_correct_type = TRUE;
+ break;
+ case GST_PLAY_SINK_TYPE_ANY:
+ if ((has_video_cap) || (has_audio_cap))
+ has_correct_type = TRUE;
+ break;
+ default:
+ has_correct_type = FALSE;
+ }
+ }
+
+ pads = g_list_next (pads);
+
}
-
+
if ((!has_src) && (has_correct_type))
- return element;
+ return element;
}
-
+
elements = g_list_next (elements);
}
-
+
/* we didn't find a sink element */
-
+
return NULL;
}
GstPlay *
-gst_play_new (GError **error)
+gst_play_new (GError ** error)
{
GstPlay *play = g_object_new (GST_TYPE_PLAY, NULL);
- if (play->priv->error)
- {
- if (error)
- {
+ if (play->priv->error) {
+ if (error) {
*error = play->priv->error;
play->priv->error = NULL;
- }
- else
- {
- g_warning ("Error creating GstPlay object.\n%s", play->priv->error->message);
+ } else {
+ g_warning ("Error creating GstPlay object.\n%s",
+ play->priv->error->message);
g_error_free (play->priv->error);
}
}
(GInstanceInitFunc) gst_play_init,
NULL
};
-
+
play_type = g_type_register_static (GST_TYPE_PIPELINE, "GstPlay",
- &play_info, 0);
+ &play_info, 0);
}
return play_type;
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_PLAY_H__
#define __GST_PLAY_H__
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__ */
#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 };
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;
}
/**
*/
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);
}
void
-gst_property_probe_probe_property (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_probe_property (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
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;
*/
gboolean
-gst_property_probe_needs_probe (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_needs_probe (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
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;
*
* 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;
*/
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;
*/
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;
*/
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;
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_PROPERTY_PROBE \
(gst_property_probe_get_type ())
#define GST_PROPERTY_PROBE(obj) \
(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__ */
/*#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;
+ }
}
-
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;
- }
-
- 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)];
- }
+ 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;
+ }
+
+ 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)));
+static union
+{
+ int i[4];
+ float f[4];
+} av_tmp __attribute__ ((__aligned__ (16)));
-void conv_double_short_altivec(double *dest, short *src, int n)
+void
+conv_double_short_altivec (double *dest, short *src, int n)
{
- int i;
-
- 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];
-
- 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;
- }
+ int i;
+
+ 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];
+
+ 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
/* 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;
-
- 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);
- }
+ 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);
+ }
}
/* #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;
-
- 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" );
+ 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");
}
#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;
-
- 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;
- }
+ 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;
+ }
}
-
-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;
-
- x -= t->start;
- x /= t->offset;
- i = floor(x);
- x -= i;
-
- 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;
-
- 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;
+ 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;
+
+ 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;
+
+ 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;
}
-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;
-
- x -= t->start;
- x *= t->invoffset;
- floor_x = floor(x);
- i = floor_x;
- x -= floor_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;
-
- 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;
+ 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;
+
+ 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;
+
+ 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;
-
- x -= t->start;
- x *= t->invoffset;
- floor_x = floor(x);
- i = floor_x;
- x -= floor_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;
-
- 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;
-
- }
-
- *r0 = sum0;
- *r1 = sum1;
+ 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;
+
+ 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;
+
+ 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;
+
+ }
+
+ *r0 = sum0;
+ *r1 = sum1;
}
#endif
-
#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
#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__ */
#include <gst/gstplugin.h>
#include <gst/gstversion.h>
-inline double sinc(double x)
+inline double
+sinc (double x)
{
- if(x==0)return 1;
- return sin(x) / x;
+ if (x == 0)
+ return 1;
+ return sin (x) / x;
}
-inline double window_func(double x)
+inline double
+window_func (double x)
{
- x = 1 - x*x;
- return x*x;
+ x = 1 - x * x;
+ return x * x;
}
-signed short double_to_s16(double x)
+signed short
+double_to_s16 (double x)
{
- if(x<-32768){
- printf("clipped\n");
- return -32768;
- }
- if(x>32767){
- printf("clipped\n");
- return -32767;
- }
- return rint(x);
+ if (x < -32768) {
+ printf ("clipped\n");
+ return -32768;
+ }
+ if (x > 32767) {
+ printf ("clipped\n");
+ return -32767;
+ }
+ return rint (x);
}
-signed short double_to_s16_ppcasm(double x)
+signed short
+double_to_s16_ppcasm (double x)
{
- if(x<-32768){
- return -32768;
- }
- if(x>32767){
- return -32767;
- }
- return rint(x);
+ if (x < -32768) {
+ return -32768;
+ }
+ if (x > 32767) {
+ return -32767;
+ }
+ return rint (x);
}
-void gst_resample_init(gst_resample_t * r)
+void
+gst_resample_init (gst_resample_t * r)
{
- r->i_start = 0;
- if(r->filter_length&1){
- r->o_start = 0;
- }else{
- r->o_start = r->o_inc * 0.5;
- }
+ r->i_start = 0;
+ if (r->filter_length & 1) {
+ r->o_start = 0;
+ } else {
+ r->o_start = r->o_inc * 0.5;
+ }
- memset(r->acc, 0, sizeof(r->acc));
+ memset (r->acc, 0, sizeof (r->acc));
- gst_resample_reinit(r);
+ gst_resample_reinit (r);
}
-void gst_resample_reinit(gst_resample_t * r)
+void
+gst_resample_reinit (gst_resample_t * r)
{
- /* i_inc is the number of samples that the output increments for
- * each input sample. o_inc is the opposite. */
- r->i_inc = (double) r->o_rate / r->i_rate;
- r->o_inc = (double) r->i_rate / r->o_rate;
-
- r->halftaps = (r->filter_length - 1.0) * 0.5;
-
- if (r->format == GST_RESAMPLE_S16) {
- switch (r->method) {
- default:
- case GST_RESAMPLE_NEAREST:
- r->scale = gst_resample_nearest_s16;
- break;
- case GST_RESAMPLE_BILINEAR:
- r->scale = gst_resample_bilinear_s16;
- break;
- case GST_RESAMPLE_SINC_SLOW:
- r->scale = gst_resample_sinc_s16;
- break;
- case GST_RESAMPLE_SINC:
- r->scale = gst_resample_sinc_ft_s16;
- break;
- }
- } else if (r->format == GST_RESAMPLE_FLOAT) {
- switch (r->method) {
- default:
- case GST_RESAMPLE_NEAREST:
- r->scale = gst_resample_nearest_float;
- break;
- case GST_RESAMPLE_BILINEAR:
- r->scale = gst_resample_bilinear_float;
- break;
- case GST_RESAMPLE_SINC_SLOW:
- r->scale = gst_resample_sinc_float;
- break;
- case GST_RESAMPLE_SINC:
- r->scale = gst_resample_sinc_ft_float;
- break;
- }
- } else {
- fprintf (stderr, "gst_resample: Unexpected format \"%d\"\n", r->format);
- }
+ /* i_inc is the number of samples that the output increments for
+ * each input sample. o_inc is the opposite. */
+ r->i_inc = (double) r->o_rate / r->i_rate;
+ r->o_inc = (double) r->i_rate / r->o_rate;
+
+ r->halftaps = (r->filter_length - 1.0) * 0.5;
+
+ if (r->format == GST_RESAMPLE_S16) {
+ switch (r->method) {
+ default:
+ case GST_RESAMPLE_NEAREST:
+ r->scale = gst_resample_nearest_s16;
+ break;
+ case GST_RESAMPLE_BILINEAR:
+ r->scale = gst_resample_bilinear_s16;
+ break;
+ case GST_RESAMPLE_SINC_SLOW:
+ r->scale = gst_resample_sinc_s16;
+ break;
+ case GST_RESAMPLE_SINC:
+ r->scale = gst_resample_sinc_ft_s16;
+ break;
+ }
+ } else if (r->format == GST_RESAMPLE_FLOAT) {
+ switch (r->method) {
+ default:
+ case GST_RESAMPLE_NEAREST:
+ r->scale = gst_resample_nearest_float;
+ break;
+ case GST_RESAMPLE_BILINEAR:
+ r->scale = gst_resample_bilinear_float;
+ break;
+ case GST_RESAMPLE_SINC_SLOW:
+ r->scale = gst_resample_sinc_float;
+ break;
+ case GST_RESAMPLE_SINC:
+ r->scale = gst_resample_sinc_ft_float;
+ break;
+ }
+ } else {
+ fprintf (stderr, "gst_resample: Unexpected format \"%d\"\n", r->format);
+ }
}
/*
* i_start_buf is the time of the first sample in the temporary
* buffer.
*/
-void gst_resample_scale(gst_resample_t * r, void *i_buf, unsigned int i_size)
+void
+gst_resample_scale (gst_resample_t * r, void *i_buf, unsigned int i_size)
{
- int o_size;
-
- r->i_buf = i_buf;
-
- r->i_samples = i_size / 2 / r->channels;
-
- r->i_start_buf = r->i_start - r->filter_length * r->i_inc;
-
- /* i_start is the offset (in a given output sample) that is the
- * beginning of the current input buffer */
- r->i_end = r->i_start + r->i_inc * r->i_samples;
-
- r->o_samples = floor(r->i_end - r->halftaps * r->i_inc);
-
- o_size = r->o_samples * r->channels * 2;
- r->o_buf = r->get_buffer(r->priv, o_size);
-
- if(r->verbose){
- printf("gst_resample_scale: i_buf=%p i_size=%d\n",
- i_buf,i_size);
- printf("gst_resample_scale: i_samples=%d o_samples=%d i_inc=%g o_buf=%p\n",
- r->i_samples, r->o_samples, r->i_inc, r->o_buf);
- printf("gst_resample_scale: i_start=%g i_end=%g o_start=%g\n",
- r->i_start, r->i_end, r->o_start);
- }
-
- if ((r->filter_length + r->i_samples)*sizeof(double)*2 > r->buffer_len) {
- int size = (r->filter_length + r->i_samples) * sizeof(double) * 2;
-
- if(r->verbose){
- printf("gst_resample temp buffer size=%d\n",size);
- }
- if(r->buffer)free(r->buffer);
- r->buffer_len = size;
- r->buffer = malloc(size);
- memset(r->buffer, 0, size);
- }
-
- if (r->format==GST_RESAMPLE_S16) {
- if(r->channels==2){
- conv_double_short(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples * 2);
- } else {
- conv_double_short_dstr(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples, sizeof(double) * 2);
- }
- } else if (r->format==GST_RESAMPLE_FLOAT) {
- if(r->channels==2){
- conv_double_float(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples * 2);
- } else {
- conv_double_float_dstr(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples, sizeof(double) * 2);
- }
- }
-
- r->scale(r);
-
- memcpy(r->buffer,
- r->buffer + r->i_samples * sizeof(double) * 2,
- r->filter_length * sizeof(double) * 2);
-
- /* updating times */
- r->i_start += r->i_samples * r->i_inc;
- r->o_start += r->o_samples * r->o_inc - r->i_samples;
-
- /* adjusting timebase zero */
- r->i_start -= r->o_samples;
+ int o_size;
+
+ r->i_buf = i_buf;
+
+ r->i_samples = i_size / 2 / r->channels;
+
+ r->i_start_buf = r->i_start - r->filter_length * r->i_inc;
+
+ /* i_start is the offset (in a given output sample) that is the
+ * beginning of the current input buffer */
+ r->i_end = r->i_start + r->i_inc * r->i_samples;
+
+ r->o_samples = floor (r->i_end - r->halftaps * r->i_inc);
+
+ o_size = r->o_samples * r->channels * 2;
+ r->o_buf = r->get_buffer (r->priv, o_size);
+
+ if (r->verbose) {
+ printf ("gst_resample_scale: i_buf=%p i_size=%d\n", i_buf, i_size);
+ printf ("gst_resample_scale: i_samples=%d o_samples=%d i_inc=%g o_buf=%p\n",
+ r->i_samples, r->o_samples, r->i_inc, r->o_buf);
+ printf ("gst_resample_scale: i_start=%g i_end=%g o_start=%g\n",
+ r->i_start, r->i_end, r->o_start);
+ }
+
+ if ((r->filter_length + r->i_samples) * sizeof (double) * 2 > r->buffer_len) {
+ int size = (r->filter_length + r->i_samples) * sizeof (double) * 2;
+
+ if (r->verbose) {
+ printf ("gst_resample temp buffer size=%d\n", size);
+ }
+ if (r->buffer)
+ free (r->buffer);
+ r->buffer_len = size;
+ r->buffer = malloc (size);
+ memset (r->buffer, 0, size);
+ }
+
+ if (r->format == GST_RESAMPLE_S16) {
+ if (r->channels == 2) {
+ conv_double_short (r->buffer + r->filter_length * sizeof (double) * 2,
+ r->i_buf, r->i_samples * 2);
+ } else {
+ conv_double_short_dstr (r->buffer +
+ r->filter_length * sizeof (double) * 2, r->i_buf, r->i_samples,
+ sizeof (double) * 2);
+ }
+ } else if (r->format == GST_RESAMPLE_FLOAT) {
+ if (r->channels == 2) {
+ conv_double_float (r->buffer + r->filter_length * sizeof (double) * 2,
+ r->i_buf, r->i_samples * 2);
+ } else {
+ conv_double_float_dstr (r->buffer +
+ r->filter_length * sizeof (double) * 2, r->i_buf, r->i_samples,
+ sizeof (double) * 2);
+ }
+ }
+
+ r->scale (r);
+
+ memcpy (r->buffer,
+ r->buffer + r->i_samples * sizeof (double) * 2,
+ r->filter_length * sizeof (double) * 2);
+
+ /* updating times */
+ r->i_start += r->i_samples * r->i_inc;
+ r->o_start += r->o_samples * r->o_inc - r->i_samples;
+
+ /* adjusting timebase zero */
+ r->i_start -= r->o_samples;
}
-void gst_resample_nearest_s16(gst_resample_t * r)
+void
+gst_resample_nearest_s16 (gst_resample_t * r)
{
- signed short *i_ptr, *o_ptr;
- int i_count = 0;
- double a;
- int i;
+ signed short *i_ptr, *o_ptr;
+ int i_count = 0;
+ double a;
+ int i;
- i_ptr = (signed short *) r->i_buf;
- o_ptr = (signed short *) r->o_buf;
+ i_ptr = (signed short *) r->i_buf;
+ o_ptr = (signed short *) r->o_buf;
- a = r->o_start;
- i_count = 0;
+ a = r->o_start;
+ i_count = 0;
#define SCALE_LOOP(COPY,INC) \
for (i = 0; i < r->o_samples; i++) { \
COPY; \
o_ptr+=INC; \
}
- switch (r->channels) {
- case 1:
- SCALE_LOOP(o_ptr[0] = i_ptr[0], 1);
- break;
- case 2:
- SCALE_LOOP(o_ptr[0] = i_ptr[0];
- o_ptr[1] = i_ptr[1], 2);
- break;
- default:
- {
- int n, n_chan = r->channels;
-
- SCALE_LOOP(for (n = 0; n < n_chan; n++) o_ptr[n] =
- i_ptr[n], n_chan);
- }
- }
- if (i_count != r->i_samples) {
- printf("handled %d in samples (expected %d)\n", i_count,
- r->i_samples);
- }
+ switch (r->channels) {
+ case 1:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0], 1);
+ break;
+ case 2:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0]; o_ptr[1] = i_ptr[1], 2);
+ break;
+ default:
+ {
+ int n, n_chan = r->channels;
+
+ SCALE_LOOP (for (n = 0; n < n_chan; n++) o_ptr[n] = i_ptr[n], n_chan);
+ }
+ }
+ if (i_count != r->i_samples) {
+ printf ("handled %d in samples (expected %d)\n", i_count, r->i_samples);
+ }
}
-void gst_resample_bilinear_s16(gst_resample_t * r)
+void
+gst_resample_bilinear_s16 (gst_resample_t * r)
{
- signed short *i_ptr, *o_ptr;
- int o_count = 0;
- double b;
- int i;
- double acc0, acc1;
-
- i_ptr = (signed short *) r->i_buf;
- o_ptr = (signed short *) r->o_buf;
-
- acc0 = r->acc[0];
- acc1 = r->acc[1];
- b = r->i_start;
- for (i = 0; i < r->i_samples; i++) {
- b += r->i_inc;
- /*printf("in %d\n",i_ptr[0]); */
- if(b>=2){
- printf("not expecting b>=2\n");
- }
- if (b >= 1) {
- acc0 += (1.0 - (b-r->i_inc)) * i_ptr[0];
- acc1 += (1.0 - (b-r->i_inc)) * i_ptr[1];
-
- o_ptr[0] = rint(acc0);
- /*printf("out %d\n",o_ptr[0]); */
- o_ptr[1] = rint(acc1);
- o_ptr += 2;
- o_count++;
-
- b -= 1.0;
-
- acc0 = b * i_ptr[0];
- acc1 = b * i_ptr[1];
- } else {
- acc0 += i_ptr[0] * r->i_inc;
- acc1 += i_ptr[1] * r->i_inc;
- }
- i_ptr += 2;
- }
- r->acc[0] = acc0;
- r->acc[1] = acc1;
-
- if (o_count != r->o_samples) {
- printf("handled %d out samples (expected %d)\n", o_count,
- r->o_samples);
- }
+ signed short *i_ptr, *o_ptr;
+ int o_count = 0;
+ double b;
+ int i;
+ double acc0, acc1;
+
+ i_ptr = (signed short *) r->i_buf;
+ o_ptr = (signed short *) r->o_buf;
+
+ acc0 = r->acc[0];
+ acc1 = r->acc[1];
+ b = r->i_start;
+ for (i = 0; i < r->i_samples; i++) {
+ b += r->i_inc;
+ /*printf("in %d\n",i_ptr[0]); */
+ if (b >= 2) {
+ printf ("not expecting b>=2\n");
+ }
+ if (b >= 1) {
+ acc0 += (1.0 - (b - r->i_inc)) * i_ptr[0];
+ acc1 += (1.0 - (b - r->i_inc)) * i_ptr[1];
+
+ o_ptr[0] = rint (acc0);
+ /*printf("out %d\n",o_ptr[0]); */
+ o_ptr[1] = rint (acc1);
+ o_ptr += 2;
+ o_count++;
+
+ b -= 1.0;
+
+ acc0 = b * i_ptr[0];
+ acc1 = b * i_ptr[1];
+ } else {
+ acc0 += i_ptr[0] * r->i_inc;
+ acc1 += i_ptr[1] * r->i_inc;
+ }
+ i_ptr += 2;
+ }
+ r->acc[0] = acc0;
+ r->acc[1] = acc1;
+
+ if (o_count != r->o_samples) {
+ printf ("handled %d out samples (expected %d)\n", o_count, r->o_samples);
+ }
}
-void gst_resample_sinc_slow_s16(gst_resample_t * r)
+void
+gst_resample_sinc_slow_s16 (gst_resample_t * r)
{
- signed short *i_ptr, *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
-
- if (!r->buffer) {
- int size = r->filter_length * 2 * r->channels;
-
- printf("gst_resample temp buffer\n");
- r->buffer = malloc(size);
- memset(r->buffer, 0, size);
- }
-
- i_ptr = (signed short *) r->i_buf;
- o_ptr = (signed short *) r->o_buf;
-
- a = r->i_start;
+ signed short *i_ptr, *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+
+ if (!r->buffer) {
+ int size = r->filter_length * 2 * r->channels;
+
+ printf ("gst_resample temp buffer\n");
+ r->buffer = malloc (size);
+ memset (r->buffer, 0, size);
+ }
+
+ i_ptr = (signed short *) r->i_buf;
+ o_ptr = (signed short *) r->o_buf;
+
+ a = r->i_start;
#define GETBUF(index,chan) (((index)<0) \
? ((short *)(r->buffer))[((index)+r->filter_length)*2+(chan)] \
: i_ptr[(index)*2+(chan)])
- {
- double sinx, cosx, sind, cosd;
- double x, d;
- double t;
-
- for (i = 0; i < r->o_samples; i++) {
- start = floor(a) - r->filter_length;
- center = a - r->halftaps;
- x = M_PI * (start - center) * r->o_inc;
- sinx = sin(M_PI * (start - center) * r->o_inc);
- cosx = cos(M_PI * (start - center) * r->o_inc);
- d = M_PI * r->o_inc;
- sind = sin(M_PI * r->o_inc);
- cosd = cos(M_PI * r->o_inc);
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- weight = (x==0)?1:(sinx/x);
+ {
+ double sinx, cosx, sind, cosd;
+ double x, d;
+ double t;
+
+ for (i = 0; i < r->o_samples; i++) {
+ start = floor (a) - r->filter_length;
+ center = a - r->halftaps;
+ x = M_PI * (start - center) * r->o_inc;
+ sinx = sin (M_PI * (start - center) * r->o_inc);
+ cosx = cos (M_PI * (start - center) * r->o_inc);
+ d = M_PI * r->o_inc;
+ sind = sin (M_PI * r->o_inc);
+ cosd = cos (M_PI * r->o_inc);
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ weight = (x == 0) ? 1 : (sinx / x);
/*printf("j %d sin %g cos %g\n",j,sinx,cosx); */
/*printf("j %d sin %g x %g sinc %g\n",j,sinx,x,weight); */
- c0 += weight * GETBUF((start + j), 0);
- c1 += weight * GETBUF((start + j), 1);
- t = cosx * cosd - sinx * sind;
- sinx = cosx * sind + sinx * cosd;
- cosx = t;
- x += d;
- }
- o_ptr[0] = rint(c0);
- o_ptr[1] = rint(c1);
- o_ptr += 2;
- a += r->o_inc;
- }
- }
+ c0 += weight * GETBUF ((start + j), 0);
+ c1 += weight * GETBUF ((start + j), 1);
+ t = cosx * cosd - sinx * sind;
+ sinx = cosx * sind + sinx * cosd;
+ cosx = t;
+ x += d;
+ }
+ o_ptr[0] = rint (c0);
+ o_ptr[1] = rint (c1);
+ o_ptr += 2;
+ a += r->o_inc;
+ }
+ }
#undef GETBUF
- memcpy(r->buffer,
- i_ptr + (r->i_samples - r->filter_length) * r->channels,
- r->filter_length * 2 * r->channels);
+ memcpy (r->buffer,
+ i_ptr + (r->i_samples - r->filter_length) * r->channels,
+ r->filter_length * 2 * r->channels);
}
/* only works for channels == 2 ???? */
-void gst_resample_sinc_s16(gst_resample_t * r)
+void
+gst_resample_sinc_s16 (gst_resample_t * r)
{
- double *ptr;
- signed short *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
- double x0, x, d;
- double scale;
-
- ptr = (double *) r->buffer;
- o_ptr = (signed short *) r->o_buf;
-
- /* scale provides a cutoff frequency for the low
- * pass filter aspects of sinc(). scale=M_PI
- * will cut off at the input frequency, which is
- * good for up-sampling, but will cause aliasing
- * for downsampling. Downsampling needs to be
- * cut off at o_rate, thus scale=M_PI*r->i_inc. */
- /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
- * Need to research why. */
- scale = M_PI*r->i_inc;
- for (i = 0; i < r->o_samples; i++) {
- a = r->o_start + i * r->o_inc;
- start = floor(a - r->halftaps);
+ double *ptr;
+ signed short *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+ double x0, x, d;
+ double scale;
+
+ ptr = (double *) r->buffer;
+ o_ptr = (signed short *) r->o_buf;
+
+ /* scale provides a cutoff frequency for the low
+ * pass filter aspects of sinc(). scale=M_PI
+ * will cut off at the input frequency, which is
+ * good for up-sampling, but will cause aliasing
+ * for downsampling. Downsampling needs to be
+ * cut off at o_rate, thus scale=M_PI*r->i_inc. */
+ /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
+ * Need to research why. */
+ scale = M_PI * r->i_inc;
+ for (i = 0; i < r->o_samples; i++) {
+ a = r->o_start + i * r->o_inc;
+ start = floor (a - r->halftaps);
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- center = a;
- /*x = M_PI * (start - center) * r->o_inc; */
- /*d = M_PI * r->o_inc; */
- /*x = (start - center) * r->o_inc; */
- x0 = (start - center) * r->o_inc;
- d = r->o_inc;
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- x = x0 + d * j;
- weight = sinc(x*scale*r->i_inc)*scale/M_PI;
- weight *= window_func(x/r->halftaps*r->i_inc);
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- }
- o_ptr[0] = double_to_s16(c0);
- o_ptr[1] = double_to_s16(c1);
- o_ptr += 2;
- }
+ center = a;
+ /*x = M_PI * (start - center) * r->o_inc; */
+ /*d = M_PI * r->o_inc; */
+ /*x = (start - center) * r->o_inc; */
+ x0 = (start - center) * r->o_inc;
+ d = r->o_inc;
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ x = x0 + d * j;
+ weight = sinc (x * scale * r->i_inc) * scale / M_PI;
+ weight *= window_func (x / r->halftaps * r->i_inc);
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ }
+ o_ptr[0] = double_to_s16 (c0);
+ o_ptr[1] = double_to_s16 (c1);
+ o_ptr += 2;
+ }
}
/*
double out_tmp[10000];
-void gst_resample_sinc_ft_s16(gst_resample_t * r)
+void
+gst_resample_sinc_ft_s16 (gst_resample_t * r)
{
- double *ptr;
- signed short *o_ptr;
- int i;
- /*int j; */
- double c0, c1;
- /*double a; */
- double start_f, start_x;
- int start;
- double center;
- /*double weight; */
- double x, d;
- double scale;
- int n = 4;
-
- scale = r->i_inc; /* cutoff at 22050 */
- /*scale = 1.0; // cutoff at 24000 */
- /*scale = r->i_inc * 0.5; // cutoff at 11025 */
-
- if(!ft){
- ft = malloc(sizeof(*ft));
- memset(ft,0,sizeof(*ft));
-
- ft->len = (r->filter_length + 2) * n;
- ft->offset = 1.0 / n;
- ft->start = - ft->len * 0.5 * ft->offset;
-
- ft->func_x = functable_sinc;
- ft->func_dx = functable_dsinc;
- ft->scale = M_PI * scale;
-
- ft->func2_x = functable_window_std;
- ft->func2_dx = functable_window_dstd;
- ft->scale2 = 1.0 / r->halftaps;
-
- functable_init(ft);
-
- /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
- }
-
- ptr = r->buffer;
- o_ptr = (signed short *) r->o_buf;
-
- center = r->o_start;
- start_x = center - r->halftaps;
- start_f = floor(start_x);
- start_x -= start_f;
- start = start_f;
- for (i = 0; i < r->o_samples; i++) {
- /*start_f = floor(center - r->halftaps); */
+ double *ptr;
+ signed short *o_ptr;
+ int i;
+
+ /*int j; */
+ double c0, c1;
+
+ /*double a; */
+ double start_f, start_x;
+ int start;
+ double center;
+
+ /*double weight; */
+ double x, d;
+ double scale;
+ int n = 4;
+
+ scale = r->i_inc; /* cutoff at 22050 */
+ /*scale = 1.0; // cutoff at 24000 */
+ /*scale = r->i_inc * 0.5; // cutoff at 11025 */
+
+ if (!ft) {
+ ft = malloc (sizeof (*ft));
+ memset (ft, 0, sizeof (*ft));
+
+ ft->len = (r->filter_length + 2) * n;
+ ft->offset = 1.0 / n;
+ ft->start = -ft->len * 0.5 * ft->offset;
+
+ ft->func_x = functable_sinc;
+ ft->func_dx = functable_dsinc;
+ ft->scale = M_PI * scale;
+
+ ft->func2_x = functable_window_std;
+ ft->func2_dx = functable_window_dstd;
+ ft->scale2 = 1.0 / r->halftaps;
+
+ functable_init (ft);
+
+ /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
+ }
+
+ ptr = r->buffer;
+ o_ptr = (signed short *) r->o_buf;
+
+ center = r->o_start;
+ start_x = center - r->halftaps;
+ start_f = floor (start_x);
+ start_x -= start_f;
+ start = start_f;
+ for (i = 0; i < r->o_samples; i++) {
+ /*start_f = floor(center - r->halftaps); */
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- x = start_f - center;
- d = 1;
- c0 = 0;
- c1 = 0;
+ x = start_f - center;
+ d = 1;
+ c0 = 0;
+ c1 = 0;
/*#define slow */
#ifdef slow
- for (j = 0; j < r->filter_length; j++) {
- weight = functable_eval(ft,x)*scale;
- /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
- /*weight *= window_func(x / r->halftaps); */
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- x += d;
- }
+ for (j = 0; j < r->filter_length; j++) {
+ weight = functable_eval (ft, x) * scale;
+ /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
+ /*weight *= window_func(x / r->halftaps); */
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ x += d;
+ }
#else
- functable_fir2(ft,
- &c0,&c1,
- x, n,
- ptr+(start + r->filter_length)*2,
- r->filter_length);
- c0 *= scale;
- c1 *= scale;
+ functable_fir2 (ft,
+ &c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
+ c0 *= scale;
+ c1 *= scale;
#endif
- out_tmp[2 * i + 0] = c0;
- out_tmp[2 * i + 1] = c1;
- center += r->o_inc;
- start_x += r->o_inc;
- while(start_x>=1.0){
- start_f++;
- start_x -= 1.0;
- start++;
- }
- }
-
- if(r->channels==2){
- conv_short_double(r->o_buf,out_tmp,2 * r->o_samples);
- }else{
- conv_short_double_sstr(r->o_buf,out_tmp,r->o_samples,2 * sizeof(double));
- }
+ out_tmp[2 * i + 0] = c0;
+ out_tmp[2 * i + 1] = c1;
+ center += r->o_inc;
+ start_x += r->o_inc;
+ while (start_x >= 1.0) {
+ start_f++;
+ start_x -= 1.0;
+ start++;
+ }
+ }
+
+ if (r->channels == 2) {
+ conv_short_double (r->o_buf, out_tmp, 2 * r->o_samples);
+ } else {
+ conv_short_double_sstr (r->o_buf, out_tmp, r->o_samples,
+ 2 * sizeof (double));
+ }
}
/********
********/
-void gst_resample_nearest_float(gst_resample_t * r)
+void
+gst_resample_nearest_float (gst_resample_t * r)
{
- float *i_ptr, *o_ptr;
- int i_count = 0;
- double a;
- int i;
+ float *i_ptr, *o_ptr;
+ int i_count = 0;
+ double a;
+ int i;
- i_ptr = (float *) r->i_buf;
- o_ptr = (float *) r->o_buf;
+ i_ptr = (float *) r->i_buf;
+ o_ptr = (float *) r->o_buf;
- a = r->o_start;
- i_count = 0;
+ a = r->o_start;
+ i_count = 0;
#define SCALE_LOOP(COPY,INC) \
for (i = 0; i < r->o_samples; i++) { \
COPY; \
o_ptr+=INC; \
}
- switch (r->channels) {
- case 1:
- SCALE_LOOP(o_ptr[0] = i_ptr[0], 1);
- break;
- case 2:
- SCALE_LOOP(o_ptr[0] = i_ptr[0];
- o_ptr[1] = i_ptr[1], 2);
- break;
- default:
- {
- int n, n_chan = r->channels;
-
- SCALE_LOOP(for (n = 0; n < n_chan; n++) o_ptr[n] =
- i_ptr[n], n_chan);
- }
- }
- if (i_count != r->i_samples) {
- printf("handled %d in samples (expected %d)\n", i_count,
- r->i_samples);
- }
+ switch (r->channels) {
+ case 1:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0], 1);
+ break;
+ case 2:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0]; o_ptr[1] = i_ptr[1], 2);
+ break;
+ default:
+ {
+ int n, n_chan = r->channels;
+
+ SCALE_LOOP (for (n = 0; n < n_chan; n++) o_ptr[n] = i_ptr[n], n_chan);
+ }
+ }
+ if (i_count != r->i_samples) {
+ printf ("handled %d in samples (expected %d)\n", i_count, r->i_samples);
+ }
}
-void gst_resample_bilinear_float(gst_resample_t * r)
+void
+gst_resample_bilinear_float (gst_resample_t * r)
{
- float *i_ptr, *o_ptr;
- int o_count = 0;
- double b;
- int i;
- double acc0, acc1;
-
- i_ptr = (float *) r->i_buf;
- o_ptr = (float *) r->o_buf;
-
- acc0 = r->acc[0];
- acc1 = r->acc[1];
- b = r->i_start;
- for (i = 0; i < r->i_samples; i++) {
- b += r->i_inc;
- /*printf("in %d\n",i_ptr[0]); */
- if(b>=2){
- printf("not expecting b>=2\n");
- }
- if (b >= 1) {
- acc0 += (1.0 - (b-r->i_inc)) * i_ptr[0];
- acc1 += (1.0 - (b-r->i_inc)) * i_ptr[1];
-
- o_ptr[0] = acc0;
- /*printf("out %d\n",o_ptr[0]); */
- o_ptr[1] = acc1;
- o_ptr += 2;
- o_count++;
-
- b -= 1.0;
-
- acc0 = b * i_ptr[0];
- acc1 = b * i_ptr[1];
- } else {
- acc0 += i_ptr[0] * r->i_inc;
- acc1 += i_ptr[1] * r->i_inc;
- }
- i_ptr += 2;
- }
- r->acc[0] = acc0;
- r->acc[1] = acc1;
-
- if (o_count != r->o_samples) {
- printf("handled %d out samples (expected %d)\n", o_count,
- r->o_samples);
- }
+ float *i_ptr, *o_ptr;
+ int o_count = 0;
+ double b;
+ int i;
+ double acc0, acc1;
+
+ i_ptr = (float *) r->i_buf;
+ o_ptr = (float *) r->o_buf;
+
+ acc0 = r->acc[0];
+ acc1 = r->acc[1];
+ b = r->i_start;
+ for (i = 0; i < r->i_samples; i++) {
+ b += r->i_inc;
+ /*printf("in %d\n",i_ptr[0]); */
+ if (b >= 2) {
+ printf ("not expecting b>=2\n");
+ }
+ if (b >= 1) {
+ acc0 += (1.0 - (b - r->i_inc)) * i_ptr[0];
+ acc1 += (1.0 - (b - r->i_inc)) * i_ptr[1];
+
+ o_ptr[0] = acc0;
+ /*printf("out %d\n",o_ptr[0]); */
+ o_ptr[1] = acc1;
+ o_ptr += 2;
+ o_count++;
+
+ b -= 1.0;
+
+ acc0 = b * i_ptr[0];
+ acc1 = b * i_ptr[1];
+ } else {
+ acc0 += i_ptr[0] * r->i_inc;
+ acc1 += i_ptr[1] * r->i_inc;
+ }
+ i_ptr += 2;
+ }
+ r->acc[0] = acc0;
+ r->acc[1] = acc1;
+
+ if (o_count != r->o_samples) {
+ printf ("handled %d out samples (expected %d)\n", o_count, r->o_samples);
+ }
}
-void gst_resample_sinc_slow_float(gst_resample_t * r)
+void
+gst_resample_sinc_slow_float (gst_resample_t * r)
{
- float *i_ptr, *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
-
- if (!r->buffer) {
- int size = r->filter_length * sizeof(float) * r->channels;
-
- printf("gst_resample temp buffer\n");
- r->buffer = malloc(size);
- memset(r->buffer, 0, size);
- }
-
- i_ptr = (float *) r->i_buf;
- o_ptr = (float *) r->o_buf;
-
- a = r->i_start;
+ float *i_ptr, *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+
+ if (!r->buffer) {
+ int size = r->filter_length * sizeof (float) * r->channels;
+
+ printf ("gst_resample temp buffer\n");
+ r->buffer = malloc (size);
+ memset (r->buffer, 0, size);
+ }
+
+ i_ptr = (float *) r->i_buf;
+ o_ptr = (float *) r->o_buf;
+
+ a = r->i_start;
#define GETBUF(index,chan) (((index)<0) \
? ((float *)(r->buffer))[((index)+r->filter_length)*2+(chan)] \
: i_ptr[(index)*2+(chan)])
- {
- double sinx, cosx, sind, cosd;
- double x, d;
- double t;
-
- for (i = 0; i < r->o_samples; i++) {
- start = floor(a) - r->filter_length;
- center = a - r->halftaps;
- x = M_PI * (start - center) * r->o_inc;
- sinx = sin(M_PI * (start - center) * r->o_inc);
- cosx = cos(M_PI * (start - center) * r->o_inc);
- d = M_PI * r->o_inc;
- sind = sin(M_PI * r->o_inc);
- cosd = cos(M_PI * r->o_inc);
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- weight = (x==0)?1:(sinx/x);
+ {
+ double sinx, cosx, sind, cosd;
+ double x, d;
+ double t;
+
+ for (i = 0; i < r->o_samples; i++) {
+ start = floor (a) - r->filter_length;
+ center = a - r->halftaps;
+ x = M_PI * (start - center) * r->o_inc;
+ sinx = sin (M_PI * (start - center) * r->o_inc);
+ cosx = cos (M_PI * (start - center) * r->o_inc);
+ d = M_PI * r->o_inc;
+ sind = sin (M_PI * r->o_inc);
+ cosd = cos (M_PI * r->o_inc);
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ weight = (x == 0) ? 1 : (sinx / x);
/*printf("j %d sin %g cos %g\n",j,sinx,cosx); */
/*printf("j %d sin %g x %g sinc %g\n",j,sinx,x,weight); */
- c0 += weight * GETBUF((start + j), 0);
- c1 += weight * GETBUF((start + j), 1);
- t = cosx * cosd - sinx * sind;
- sinx = cosx * sind + sinx * cosd;
- cosx = t;
- x += d;
- }
- o_ptr[0] = c0;
- o_ptr[1] = c1;
- o_ptr += 2;
- a += r->o_inc;
- }
- }
+ c0 += weight * GETBUF ((start + j), 0);
+ c1 += weight * GETBUF ((start + j), 1);
+ t = cosx * cosd - sinx * sind;
+ sinx = cosx * sind + sinx * cosd;
+ cosx = t;
+ x += d;
+ }
+ o_ptr[0] = c0;
+ o_ptr[1] = c1;
+ o_ptr += 2;
+ a += r->o_inc;
+ }
+ }
#undef GETBUF
- memcpy(r->buffer,
- i_ptr + (r->i_samples - r->filter_length) * r->channels,
- r->filter_length * sizeof(float) * r->channels);
+ memcpy (r->buffer,
+ i_ptr + (r->i_samples - r->filter_length) * r->channels,
+ r->filter_length * sizeof (float) * r->channels);
}
/* only works for channels == 2 ???? */
-void gst_resample_sinc_float(gst_resample_t * r)
+void
+gst_resample_sinc_float (gst_resample_t * r)
{
- double *ptr;
- float *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
- double x0, x, d;
- double scale;
-
- ptr = (double *) r->buffer;
- o_ptr = (float *) r->o_buf;
-
- /* scale provides a cutoff frequency for the low
- * pass filter aspects of sinc(). scale=M_PI
- * will cut off at the input frequency, which is
- * good for up-sampling, but will cause aliasing
- * for downsampling. Downsampling needs to be
- * cut off at o_rate, thus scale=M_PI*r->i_inc. */
- /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
- * Need to research why. */
- scale = M_PI*r->i_inc;
- for (i = 0; i < r->o_samples; i++) {
- a = r->o_start + i * r->o_inc;
- start = floor(a - r->halftaps);
+ double *ptr;
+ float *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+ double x0, x, d;
+ double scale;
+
+ ptr = (double *) r->buffer;
+ o_ptr = (float *) r->o_buf;
+
+ /* scale provides a cutoff frequency for the low
+ * pass filter aspects of sinc(). scale=M_PI
+ * will cut off at the input frequency, which is
+ * good for up-sampling, but will cause aliasing
+ * for downsampling. Downsampling needs to be
+ * cut off at o_rate, thus scale=M_PI*r->i_inc. */
+ /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
+ * Need to research why. */
+ scale = M_PI * r->i_inc;
+ for (i = 0; i < r->o_samples; i++) {
+ a = r->o_start + i * r->o_inc;
+ start = floor (a - r->halftaps);
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- center = a;
- /*x = M_PI * (start - center) * r->o_inc; */
- /*d = M_PI * r->o_inc; */
- /*x = (start - center) * r->o_inc; */
- x0 = (start - center) * r->o_inc;
- d = r->o_inc;
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- x = x0 + d * j;
- weight = sinc(x*scale*r->i_inc)*scale/M_PI;
- weight *= window_func(x/r->halftaps*r->i_inc);
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- }
- o_ptr[0] = c0;
- o_ptr[1] = c1;
- o_ptr += 2;
- }
+ center = a;
+ /*x = M_PI * (start - center) * r->o_inc; */
+ /*d = M_PI * r->o_inc; */
+ /*x = (start - center) * r->o_inc; */
+ x0 = (start - center) * r->o_inc;
+ d = r->o_inc;
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ x = x0 + d * j;
+ weight = sinc (x * scale * r->i_inc) * scale / M_PI;
+ weight *= window_func (x / r->halftaps * r->i_inc);
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ }
+ o_ptr[0] = c0;
+ o_ptr[1] = c1;
+ o_ptr += 2;
+ }
}
-void gst_resample_sinc_ft_float(gst_resample_t * r)
+void
+gst_resample_sinc_ft_float (gst_resample_t * r)
{
- double *ptr;
- float *o_ptr;
- int i;
- /*int j; */
- double c0, c1;
- /*double a; */
- double start_f, start_x;
- int start;
- double center;
- /*double weight; */
- double x, d;
- double scale;
- int n = 4;
-
- scale = r->i_inc; /* cutoff at 22050 */
- /*scale = 1.0; // cutoff at 24000 */
- /*scale = r->i_inc * 0.5; // cutoff at 11025 */
-
- if(!ft){
- ft = malloc(sizeof(*ft));
- memset(ft,0,sizeof(*ft));
-
- ft->len = (r->filter_length + 2) * n;
- ft->offset = 1.0 / n;
- ft->start = - ft->len * 0.5 * ft->offset;
-
- ft->func_x = functable_sinc;
- ft->func_dx = functable_dsinc;
- ft->scale = M_PI * scale;
-
- ft->func2_x = functable_window_std;
- ft->func2_dx = functable_window_dstd;
- ft->scale2 = 1.0 / r->halftaps;
-
- functable_init(ft);
-
- /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
- }
-
- ptr = r->buffer;
- o_ptr = (float *) r->o_buf;
-
- center = r->o_start;
- start_x = center - r->halftaps;
- start_f = floor(start_x);
- start_x -= start_f;
- start = start_f;
- for (i = 0; i < r->o_samples; i++) {
- /*start_f = floor(center - r->halftaps); */
+ double *ptr;
+ float *o_ptr;
+ int i;
+
+ /*int j; */
+ double c0, c1;
+
+ /*double a; */
+ double start_f, start_x;
+ int start;
+ double center;
+
+ /*double weight; */
+ double x, d;
+ double scale;
+ int n = 4;
+
+ scale = r->i_inc; /* cutoff at 22050 */
+ /*scale = 1.0; // cutoff at 24000 */
+ /*scale = r->i_inc * 0.5; // cutoff at 11025 */
+
+ if (!ft) {
+ ft = malloc (sizeof (*ft));
+ memset (ft, 0, sizeof (*ft));
+
+ ft->len = (r->filter_length + 2) * n;
+ ft->offset = 1.0 / n;
+ ft->start = -ft->len * 0.5 * ft->offset;
+
+ ft->func_x = functable_sinc;
+ ft->func_dx = functable_dsinc;
+ ft->scale = M_PI * scale;
+
+ ft->func2_x = functable_window_std;
+ ft->func2_dx = functable_window_dstd;
+ ft->scale2 = 1.0 / r->halftaps;
+
+ functable_init (ft);
+
+ /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
+ }
+
+ ptr = r->buffer;
+ o_ptr = (float *) r->o_buf;
+
+ center = r->o_start;
+ start_x = center - r->halftaps;
+ start_f = floor (start_x);
+ start_x -= start_f;
+ start = start_f;
+ for (i = 0; i < r->o_samples; i++) {
+ /*start_f = floor(center - r->halftaps); */
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- x = start_f - center;
- d = 1;
- c0 = 0;
- c1 = 0;
+ x = start_f - center;
+ d = 1;
+ c0 = 0;
+ c1 = 0;
/*#define slow */
#ifdef slow
- for (j = 0; j < r->filter_length; j++) {
- weight = functable_eval(ft,x)*scale;
- /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
- /*weight *= window_func(x / r->halftaps); */
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- x += d;
- }
+ for (j = 0; j < r->filter_length; j++) {
+ weight = functable_eval (ft, x) * scale;
+ /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
+ /*weight *= window_func(x / r->halftaps); */
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ x += d;
+ }
#else
- functable_fir2(ft,
- &c0,&c1,
- x, n,
- ptr+(start + r->filter_length)*2,
- r->filter_length);
- c0 *= scale;
- c1 *= scale;
+ functable_fir2 (ft,
+ &c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
+ c0 *= scale;
+ c1 *= scale;
#endif
- out_tmp[2 * i + 0] = c0;
- out_tmp[2 * i + 1] = c1;
- center += r->o_inc;
- start_x += r->o_inc;
- while(start_x>=1.0){
- start_f++;
- start_x -= 1.0;
- start++;
- }
- }
-
- if(r->channels==2){
- conv_float_double(r->o_buf,out_tmp,2 * r->o_samples);
- }else{
- conv_float_double_sstr(r->o_buf,out_tmp,r->o_samples,2 * sizeof(double));
- }
+ out_tmp[2 * i + 0] = c0;
+ out_tmp[2 * i + 1] = c1;
+ center += r->o_inc;
+ start_x += r->o_inc;
+ while (start_x >= 1.0) {
+ start_f++;
+ start_x -= 1.0;
+ start++;
+ }
+ }
+
+ if (r->channels == 2) {
+ conv_float_double (r->o_buf, out_tmp, 2 * r->o_samples);
+ } else {
+ conv_float_double_sstr (r->o_buf, out_tmp, r->o_samples,
+ 2 * sizeof (double));
+ }
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstresample",
- "Resampling routines for use in audio plugins",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstresample",
+ "Resampling routines for use in audio plugins",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#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__ */
-
/*#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;
-
- 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->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);
-
- start_timer();
+ 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;
+ }
+
+ 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;
+
+ resample_init (r);
+
+ 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();
-
- 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));
+ 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);
+ }
+
+ 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;
-
- 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);
- }
+ 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);
+ }
}
-void test_res5(void)
+void
+test_res5 (void)
{
- 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;
+ 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;
}
-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;
-
- 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->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);
-
- start_timer();
+ 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));
+ }
+
+ 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;
+
+ resample_init (r);
+
+ 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();
-
- 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));
+ 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);
+ }
+
+ 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));
}
-
#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)
#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')
#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')
#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;
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)
guint16 size;
} gst_riff_strf_auds;
-typedef struct _gst_riff_strf_iavs {
+typedef struct _gst_riff_strf_iavs
+{
guint32 DVAAuxSrc;
guint32 DVAAuxCtl;
guint32 DVAAuxSrc1;
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)
guint32 size;
} gst_riff_index_entry;
-typedef struct _gst_riff_dmlh {
+typedef struct _gst_riff_dmlh
+{
guint32 totalframes;
} gst_riff_dmlh;
#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;
}
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);
-
- 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);
+ 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);
} 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;
}
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
};
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
};
#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).
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__ */
#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,
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;
}
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:
*/
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);
*/
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;
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;
*/
static GstBuffer *
-gst_riff_read_element_data (GstRiffRead *riff,
- guint length)
+gst_riff_read_element_data (GstRiffRead * riff, guint length)
{
GstBuffer *buf = NULL;
*/
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;
} 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;
}
}
*/
guint32
-gst_riff_peek_tag (GstRiffRead *riff,
- guint *level_up)
+gst_riff_peek_tag (GstRiffRead * riff, guint * level_up)
{
guint32 tag;
*/
guint32
-gst_riff_peek_list (GstRiffRead *riff)
+gst_riff_peek_list (GstRiffRead * riff)
{
guint32 lst;
guint8 *data;
*/
gboolean
-gst_riff_read_skip (GstRiffRead *riff)
+gst_riff_read_skip (GstRiffRead * riff)
{
guint32 tag, length;
GstEvent *event;
/* 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);
*/
gboolean
-gst_riff_read_data (GstRiffRead *riff,
- guint32 *tag,
- GstBuffer **buf)
+gst_riff_read_data (GstRiffRead * riff, guint32 * tag, GstBuffer ** buf)
{
guint32 length;
*/
gboolean
-gst_riff_read_ascii (GstRiffRead *riff,
- guint32 *tag,
- gchar **str)
+gst_riff_read_ascii (GstRiffRead * riff, guint32 * tag, gchar ** str)
{
GstBuffer *buf;
*/
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;
}
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 */
/* 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;
}
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;
}
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);
}
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);
}
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;
}
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 */
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);
}
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;
}
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
*/
gboolean
-gst_riff_read_list (GstRiffRead *riff,
- guint32 *tag)
+gst_riff_read_list (GstRiffRead * riff, guint32 * tag)
{
guint32 length, lst;
GstRiffLevel *level;
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);
*/
gboolean
-gst_riff_read_info (GstRiffRead *riff)
+gst_riff_read_info (GstRiffRead * riff)
{
guint32 tag;
guint64 end;
/* 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);
-
- 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);
+ 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);
}
g_free (name);
} else {
/* 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);
*/
gboolean
-gst_riff_read_header (GstRiffRead *riff,
- guint32 *doctype)
+gst_riff_read_header (GstRiffRead * riff, guint32 * doctype)
{
GstRiffLevel *level;
guint32 tag, length;
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);
#include <gst/bytestream/bytestream.h>
G_BEGIN_DECLS
-
#define GST_TYPE_RIFF_READ \
(gst_riff_read_get_type ())
#define GST_RIFF_READ(obj) \
(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;
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__ */
#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)
#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__ */
#include <string.h>
-enum {
+enum
+{
NORM_CHANGED,
CHANNEL_CHANGED,
FREQUENCY_CHANGED,
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 };
};
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;
}
*/
const GList *
-gst_tuner_list_channels (GstTuner *tuner)
+gst_tuner_list_channels (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (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);
*/
GstTunerChannel *
-gst_tuner_get_channel (GstTuner *tuner)
+gst_tuner_get_channel (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
const GList *
-gst_tuner_list_norms (GstTuner *tuner)
+gst_tuner_list_norms (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (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);
*/
GstTunerNorm *
-gst_tuner_get_norm (GstTuner *tuner)
+gst_tuner_get_norm (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (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);
*/
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);
*/
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);
}
GstTunerNorm *
-gst_tuner_find_norm_by_name (GstTuner *tuner,
- gchar *norm)
+gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm)
{
GList *walk;
}
GstTunerChannel *
-gst_tuner_find_channel_by_name (GstTuner *tuner,
- gchar *channel)
+gst_tuner_find_channel_by_name (GstTuner * tuner, gchar * channel)
{
GList *walk;
}
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);
}
#include <gst/tuner/tuner-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER \
(gst_tuner_get_type ())
#define GST_TUNER(obj) \
(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_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);
+ 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);
+
+ 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_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);
+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);
+
+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__ */
#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 };
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;
}
static void
-gst_tuner_channel_dispose (GObject *object)
+gst_tuner_channel_dispose (GObject * object)
{
GstTunerChannel *channel = GST_TUNER_CHANNEL (object);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER_CHANNEL \
(gst_tuner_channel_get_type ())
#define GST_TUNER_CHANNEL(obj) \
(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__ */
#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
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;
}
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);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER_NORM \
(gst_tuner_norm_get_type ())
#define GST_TUNER_NORM(obj) \
(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__ */
/* GstVideofilter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_METHOD,
/* FILL ME */
};
-static void gst_videofilter_base_init (gpointer g_class);
-static void gst_videofilter_class_init (gpointer g_class, gpointer class_data);
-static void gst_videofilter_init (GTypeInstance *instance, gpointer g_class);
+static void gst_videofilter_base_init (gpointer g_class);
+static void gst_videofilter_class_init (gpointer g_class, gpointer class_data);
+static void gst_videofilter_init (GTypeInstance * instance, gpointer g_class);
-static void gst_videofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_videofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_videofilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_videofilter_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_videofilter_chain (GstPad *pad, GstData *_data);
-GstCaps * gst_videofilter_class_get_capslist(GstVideofilterClass *klass);
-static void gst_videofilter_setup(GstVideofilter *videofilter);
+static void gst_videofilter_chain (GstPad * pad, GstData * _data);
+GstCaps *gst_videofilter_class_get_capslist (GstVideofilterClass * klass);
+static void gst_videofilter_setup (GstVideofilter * videofilter);
static GstElementClass *parent_class = NULL;
if (!videofilter_type) {
static const GTypeInfo videofilter_info = {
- sizeof(GstVideofilterClass),
+ sizeof (GstVideofilterClass),
gst_videofilter_base_init,
NULL,
gst_videofilter_class_init,
NULL,
NULL,
- sizeof(GstVideofilter),
+ sizeof (GstVideofilter),
0,
gst_videofilter_init,
};
- videofilter_type = g_type_register_static(GST_TYPE_ELEMENT,
+ videofilter_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstVideofilter", &videofilter_info, G_TYPE_FLAG_ABSTRACT);
}
return videofilter_type;
}
-static void gst_videofilter_base_init (gpointer g_class)
+static void
+gst_videofilter_base_init (gpointer g_class)
{
static GstElementDetails videofilter_details = {
"Video scaler",
GstVideofilterClass *klass = (GstVideofilterClass *) g_class;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- klass->formats = g_ptr_array_new();
+ klass->formats = g_ptr_array_new ();
gst_element_class_set_details (element_class, &videofilter_details);
}
-static void gst_videofilter_class_init (gpointer g_class, gpointer class_data)
+static void
+gst_videofilter_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstVideofilterClass *klass;
- klass = (GstVideofilterClass *)g_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ klass = (GstVideofilterClass *) 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_videofilter_set_property;
gobject_class->get_property = gst_videofilter_get_property;
}
-static GstStructure *gst_videofilter_format_get_structure(GstVideofilterFormat *format)
+static GstStructure *
+gst_videofilter_format_get_structure (GstVideofilterFormat * format)
{
unsigned int fourcc;
GstStructure *structure;
- if(format->filter_func==NULL)
+ if (format->filter_func == NULL)
return NULL;
- fourcc = GST_MAKE_FOURCC(format->fourcc[0],format->fourcc[1],format->fourcc[2],format->fourcc[3]);
+ fourcc =
+ GST_MAKE_FOURCC (format->fourcc[0], format->fourcc[1], format->fourcc[2],
+ format->fourcc[3]);
- if(format->depth){
+ if (format->depth) {
structure = gst_structure_new ("video/x-raw-rgb",
"depth", G_TYPE_INT, format->depth,
"bpp", G_TYPE_INT, format->bpp,
"red_mask", G_TYPE_INT, format->red_mask,
"green_mask", G_TYPE_INT, format->green_mask,
"blue_mask", G_TYPE_INT, format->blue_mask, NULL);
- }else{
+ } else {
structure = gst_structure_new ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, fourcc, NULL);
}
- gst_structure_set(structure,
+ gst_structure_set (structure,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
return structure;
}
-GstCaps * gst_videofilter_class_get_capslist(GstVideofilterClass *klass)
+GstCaps *
+gst_videofilter_class_get_capslist (GstVideofilterClass * klass)
{
GstCaps *caps;
GstStructure *structure;
int i;
- caps = gst_caps_new_empty();
- for(i=0;i<klass->formats->len;i++){
- structure = gst_videofilter_format_get_structure(g_ptr_array_index(klass->formats,i));
+ caps = gst_caps_new_empty ();
+ for (i = 0; i < klass->formats->len; i++) {
+ structure =
+ gst_videofilter_format_get_structure (g_ptr_array_index (klass->formats,
+ i));
gst_caps_append_structure (caps, structure);
}
}
static GstCaps *
-gst_videofilter_getcaps (GstPad *pad)
+gst_videofilter_getcaps (GstPad * pad)
{
GstVideofilter *videofilter;
GstVideofilterClass *klass;
+
//GstCaps *caps;
GstCaps *othercaps;
GstPad *otherpad;
+
//int i;
- GST_DEBUG("gst_videofilter_getcaps");
+ GST_DEBUG ("gst_videofilter_getcaps");
videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad));
-
- klass = GST_VIDEOFILTER_CLASS(G_OBJECT_GET_CLASS(videofilter));
+
+ klass = GST_VIDEOFILTER_CLASS (G_OBJECT_GET_CLASS (videofilter));
otherpad = (pad == videofilter->srcpad) ? videofilter->sinkpad :
- videofilter->srcpad;
+ videofilter->srcpad;
othercaps = gst_pad_get_allowed_caps (otherpad);
* the peer's formats. Create a list of them. */
/* FIXME optimize if peercaps == NULL */
caps = gst_caps_new_empty ();
- for(i=0;i<klass->formats->len;i++){
+ for (i = 0; i < klass->formats->len; i++) {
GstCaps *icaps;
GstCaps *fromcaps;
-
- fromcaps = gst_caps_new_full (gst_videofilter_format_get_structure (
- g_ptr_array_index (klass->formats,i)), NULL);
+
+ fromcaps =
+ gst_caps_new_full (gst_videofilter_format_get_structure
+ (g_ptr_array_index (klass->formats, i)), NULL);
icaps = gst_caps_intersect (fromcaps, peercaps);
- if(icaps != NULL){
+ if (icaps != NULL) {
gst_caps_append (caps, fromcaps);
} else {
gst_caps_free (fromcaps);
}
- if(icaps) gst_caps_free (icaps);
+ if (icaps)
+ gst_caps_free (icaps);
}
gst_caps_free (peercaps);
}
static GstPadLinkReturn
-gst_videofilter_link (GstPad *pad, const GstCaps *caps)
+gst_videofilter_link (GstPad * pad, const GstCaps * caps)
{
GstVideofilter *videofilter;
GstStructure *structure;
GstPadLinkReturn lret;
GstPad *otherpad;
- GST_DEBUG("gst_videofilter_src_link");
+ GST_DEBUG ("gst_videofilter_src_link");
videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad));
otherpad = (pad == videofilter->srcpad) ? videofilter->sinkpad :
- videofilter->srcpad;
+ videofilter->srcpad;
structure = gst_caps_get_structure (caps, 0);
- videofilter->format = gst_videofilter_find_format_by_structure (
- videofilter, structure);
- g_return_val_if_fail(videofilter->format, GST_PAD_LINK_REFUSED);
+ videofilter->format =
+ gst_videofilter_find_format_by_structure (videofilter, structure);
+ g_return_val_if_fail (videofilter->format, GST_PAD_LINK_REFUSED);
ret = gst_structure_get_int (structure, "width", &width);
ret &= gst_structure_get_int (structure, "height", &height);
ret &= gst_structure_get_double (structure, "framerate", &framerate);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
lret = gst_pad_try_set_caps (otherpad, caps);
- if (GST_PAD_LINK_FAILED (lret)) return lret;
+ if (GST_PAD_LINK_FAILED (lret))
+ return lret;
- GST_DEBUG("width %d height %d",width,height);
+ GST_DEBUG ("width %d height %d", width, height);
#if 0
if (pad == videofilter->srcpad) {
videofilter->from_height = height;
videofilter->framerate = framerate;
- gst_videofilter_setup(videofilter);
+ gst_videofilter_setup (videofilter);
return GST_PAD_LINK_OK;
}
static void
-gst_videofilter_init (GTypeInstance *instance, gpointer g_class)
+gst_videofilter_init (GTypeInstance * instance, gpointer g_class)
{
GstVideofilter *videofilter = GST_VIDEOFILTER (instance);
GstPadTemplate *pad_template;
- GST_DEBUG("gst_videofilter_init");
-
- pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
- "sink");
- g_return_if_fail(pad_template != NULL);
- videofilter->sinkpad = gst_pad_new_from_template(pad_template, "sink");
- gst_element_add_pad(GST_ELEMENT(videofilter),videofilter->sinkpad);
- gst_pad_set_chain_function(videofilter->sinkpad,gst_videofilter_chain);
- gst_pad_set_link_function(videofilter->sinkpad,gst_videofilter_link);
- gst_pad_set_getcaps_function(videofilter->sinkpad,gst_videofilter_getcaps);
-
- pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
- "src");
- g_return_if_fail(pad_template != NULL);
- videofilter->srcpad = gst_pad_new_from_template(pad_template, "src");
- gst_element_add_pad(GST_ELEMENT(videofilter),videofilter->srcpad);
- gst_pad_set_link_function(videofilter->srcpad,gst_videofilter_link);
- gst_pad_set_getcaps_function(videofilter->srcpad,gst_videofilter_getcaps);
+ GST_DEBUG ("gst_videofilter_init");
+
+ pad_template =
+ gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "sink");
+ g_return_if_fail (pad_template != NULL);
+ videofilter->sinkpad = gst_pad_new_from_template (pad_template, "sink");
+ gst_element_add_pad (GST_ELEMENT (videofilter), videofilter->sinkpad);
+ gst_pad_set_chain_function (videofilter->sinkpad, gst_videofilter_chain);
+ gst_pad_set_link_function (videofilter->sinkpad, gst_videofilter_link);
+ gst_pad_set_getcaps_function (videofilter->sinkpad, gst_videofilter_getcaps);
+
+ pad_template =
+ gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
+ g_return_if_fail (pad_template != NULL);
+ videofilter->srcpad = gst_pad_new_from_template (pad_template, "src");
+ gst_element_add_pad (GST_ELEMENT (videofilter), videofilter->srcpad);
+ gst_pad_set_link_function (videofilter->srcpad, gst_videofilter_link);
+ gst_pad_set_getcaps_function (videofilter->srcpad, gst_videofilter_getcaps);
videofilter->inited = FALSE;
}
static void
-gst_videofilter_chain (GstPad *pad, GstData *_data)
+gst_videofilter_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstVideofilter *videofilter;
videofilter = GST_VIDEOFILTER (gst_pad_get_parent (pad));
//g_return_if_fail (videofilter->inited);
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
- if(videofilter->passthru){
- gst_pad_push(videofilter->srcpad, GST_DATA (buf));
+ if (videofilter->passthru) {
+ gst_pad_push (videofilter->srcpad, GST_DATA (buf));
return;
}
- GST_DEBUG ("gst_videofilter_chain: got buffer of %ld bytes in '%s'",size,
- GST_OBJECT_NAME (videofilter));
-
- GST_DEBUG("size=%ld from=%dx%d to=%dx%d fromsize=%ld (should be %d) tosize=%d",
- size,
- videofilter->from_width, videofilter->from_height,
- videofilter->to_width, videofilter->to_height,
- size, videofilter->from_buf_size,
- videofilter->to_buf_size);
+ GST_DEBUG ("gst_videofilter_chain: got buffer of %ld bytes in '%s'", size,
+ GST_OBJECT_NAME (videofilter));
+
+ GST_DEBUG
+ ("size=%ld from=%dx%d to=%dx%d fromsize=%ld (should be %d) tosize=%d",
+ size, videofilter->from_width, videofilter->from_height,
+ videofilter->to_width, videofilter->to_height, size,
+ videofilter->from_buf_size, videofilter->to_buf_size);
g_return_if_fail (size >= videofilter->from_buf_size);
if (size > videofilter->from_buf_size) {
- GST_INFO("buffer size %ld larger than expected (%d)",
- size, videofilter->from_buf_size);
+ GST_INFO ("buffer size %ld larger than expected (%d)",
+ size, videofilter->from_buf_size);
}
- outbuf = gst_pad_alloc_buffer(videofilter->srcpad, GST_BUFFER_OFFSET_NONE,
+ outbuf = gst_pad_alloc_buffer (videofilter->srcpad, GST_BUFFER_OFFSET_NONE,
videofilter->to_buf_size);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
- g_return_if_fail(videofilter->format);
- GST_DEBUG ("format %s",videofilter->format->fourcc);
+ g_return_if_fail (videofilter->format);
+ GST_DEBUG ("format %s", videofilter->format->fourcc);
videofilter->in_buf = buf;
videofilter->out_buf = outbuf;
- videofilter->format->filter_func(videofilter, GST_BUFFER_DATA(outbuf), data);
+ videofilter->format->filter_func (videofilter, GST_BUFFER_DATA (outbuf),
+ data);
- GST_DEBUG ("gst_videofilter_chain: pushing buffer of %d bytes in '%s'",GST_BUFFER_SIZE(outbuf),
- GST_OBJECT_NAME (videofilter));
+ GST_DEBUG ("gst_videofilter_chain: pushing buffer of %d bytes in '%s'",
+ GST_BUFFER_SIZE (outbuf), GST_OBJECT_NAME (videofilter));
- gst_pad_push(videofilter->srcpad, GST_DATA (outbuf));
+ gst_pad_push (videofilter->srcpad, GST_DATA (outbuf));
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_videofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_videofilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstVideofilter *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VIDEOFILTER(object));
- src = GST_VIDEOFILTER(object);
+ g_return_if_fail (GST_IS_VIDEOFILTER (object));
+ src = GST_VIDEOFILTER (object);
- GST_DEBUG("gst_videofilter_set_property");
+ GST_DEBUG ("gst_videofilter_set_property");
switch (prop_id) {
default:
break;
}
static void
-gst_videofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_videofilter_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstVideofilter *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VIDEOFILTER(object));
- src = GST_VIDEOFILTER(object);
+ g_return_if_fail (GST_IS_VIDEOFILTER (object));
+ src = GST_VIDEOFILTER (object);
switch (prop_id) {
default:
}
}
-int gst_videofilter_get_input_width(GstVideofilter *videofilter)
+int
+gst_videofilter_get_input_width (GstVideofilter * videofilter)
{
- g_return_val_if_fail(GST_IS_VIDEOFILTER(videofilter),0);
+ g_return_val_if_fail (GST_IS_VIDEOFILTER (videofilter), 0);
return videofilter->from_width;
}
-int gst_videofilter_get_input_height(GstVideofilter *videofilter)
+int
+gst_videofilter_get_input_height (GstVideofilter * videofilter)
{
- g_return_val_if_fail(GST_IS_VIDEOFILTER(videofilter),0);
+ g_return_val_if_fail (GST_IS_VIDEOFILTER (videofilter), 0);
return videofilter->from_height;
}
-void gst_videofilter_set_output_size(GstVideofilter *videofilter,
+void
+gst_videofilter_set_output_size (GstVideofilter * videofilter,
int width, int height)
{
int ret;
GstCaps *srccaps;
GstStructure *structure;
- g_return_if_fail(GST_IS_VIDEOFILTER(videofilter));
+ g_return_if_fail (GST_IS_VIDEOFILTER (videofilter));
videofilter->to_width = width;
videofilter->to_height = height;
videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height
- * videofilter->format->bpp)/8;
+ * videofilter->format->bpp) / 8;
- srccaps = gst_caps_copy (gst_pad_get_negotiated_caps(videofilter->srcpad));
+ srccaps = gst_caps_copy (gst_pad_get_negotiated_caps (videofilter->srcpad));
structure = gst_caps_get_structure (srccaps, 0);
gst_structure_set (structure, "width", G_TYPE_INT, width,
}
}
-static void gst_videofilter_setup(GstVideofilter *videofilter)
+static void
+gst_videofilter_setup (GstVideofilter * videofilter)
{
GstVideofilterClass *klass;
- klass = GST_VIDEOFILTER_CLASS(G_OBJECT_GET_CLASS(videofilter));
+ klass = GST_VIDEOFILTER_CLASS (G_OBJECT_GET_CLASS (videofilter));
- if(klass->setup){
- klass->setup(videofilter);
+ if (klass->setup) {
+ klass->setup (videofilter);
}
- if(videofilter->to_width == 0){
+ if (videofilter->to_width == 0) {
videofilter->to_width = videofilter->from_width;
}
- if(videofilter->to_height == 0){
+ if (videofilter->to_height == 0) {
videofilter->to_height = videofilter->from_height;
}
- g_return_if_fail(videofilter->format != NULL);
- g_return_if_fail(videofilter->from_width > 0);
- g_return_if_fail(videofilter->from_height > 0);
- g_return_if_fail(videofilter->to_width > 0);
- g_return_if_fail(videofilter->to_height > 0);
+ g_return_if_fail (videofilter->format != NULL);
+ g_return_if_fail (videofilter->from_width > 0);
+ g_return_if_fail (videofilter->from_height > 0);
+ g_return_if_fail (videofilter->to_width > 0);
+ g_return_if_fail (videofilter->to_height > 0);
- videofilter->from_buf_size = (videofilter->from_width * videofilter->from_height *
+ videofilter->from_buf_size =
+ (videofilter->from_width * videofilter->from_height *
videofilter->format->bpp) / 8;
- videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height *
+ videofilter->to_buf_size =
+ (videofilter->to_width * videofilter->to_height *
videofilter->format->bpp) / 8;
videofilter->inited = TRUE;
}
-GstVideofilterFormat *gst_videofilter_find_format_by_structure (
- GstVideofilter *videofilter, const GstStructure *structure)
+GstVideofilterFormat *
+gst_videofilter_find_format_by_structure (GstVideofilter * videofilter,
+ const GstStructure * structure)
{
int i;
GstVideofilterClass *klass;
GstVideofilterFormat *format;
gboolean ret;
- klass = GST_VIDEOFILTER_CLASS(G_OBJECT_GET_CLASS(videofilter));
+ klass = GST_VIDEOFILTER_CLASS (G_OBJECT_GET_CLASS (videofilter));
- g_return_val_if_fail(structure != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
guint32 fourcc;
ret = gst_structure_get_fourcc (structure, "format", &fourcc);
- if (!ret) return NULL;
- for(i=0;i<klass->formats->len;i++){
+ if (!ret)
+ return NULL;
+ for (i = 0; i < klass->formats->len; i++) {
guint32 format_fourcc;
- format = g_ptr_array_index(klass->formats,i);
+
+ format = g_ptr_array_index (klass->formats, i);
format_fourcc = GST_STR_FOURCC (format->fourcc);
if (format->depth == 0 && format_fourcc == fourcc) {
- return format;
+ return format;
}
}
} else if (strcmp (gst_structure_get_name (structure), "video/x-raw-rgb")
ret &= gst_structure_get_int (structure, "red_mask", &red_mask);
ret &= gst_structure_get_int (structure, "green_mask", &green_mask);
ret &= gst_structure_get_int (structure, "blue_mask", &blue_mask);
- if (!ret) return NULL;
- for(i=0;i<klass->formats->len;i++){
- format = g_ptr_array_index(klass->formats,i);
+ if (!ret)
+ return NULL;
+ for (i = 0; i < klass->formats->len; i++) {
+ format = g_ptr_array_index (klass->formats, i);
if (format->bpp == bpp && format->depth == depth &&
- format->endianness == endianness && format->red_mask == red_mask &&
- format->green_mask == green_mask && format->blue_mask == blue_mask) {
- return format;
+ format->endianness == endianness && format->red_mask == red_mask &&
+ format->green_mask == green_mask && format->blue_mask == blue_mask) {
+ return format;
}
}
}
return NULL;
}
-void gst_videofilter_class_add_format(GstVideofilterClass *videofilterclass,
- GstVideofilterFormat *format)
+void
+gst_videofilter_class_add_format (GstVideofilterClass * videofilterclass,
+ GstVideofilterFormat * format)
{
- g_ptr_array_add(videofilterclass->formats, format);
+ g_ptr_array_add (videofilterclass->formats, format);
}
-void gst_videofilter_class_add_pad_templates (GstVideofilterClass *videofilter_class)
+void
+gst_videofilter_class_add_pad_templates (GstVideofilterClass *
+ videofilter_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (videofilter_class);
gst_element_class_add_pad_template (element_class,
- gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_videofilter_class_get_capslist (videofilter_class)));
+ gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ gst_videofilter_class_get_capslist (videofilter_class)));
gst_element_class_add_pad_template (element_class,
- gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_videofilter_class_get_capslist (videofilter_class)));
+ gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+ gst_videofilter_class_get_capslist (videofilter_class)));
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstvideofilter",
- "Video filter parent class",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstvideofilter",
+ "Video filter parent class",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-typedef struct _GstVideofilter GstVideofilter;
+G_BEGIN_DECLS typedef struct _GstVideofilter GstVideofilter;
typedef struct _GstVideofilterClass GstVideofilterClass;
-typedef void (*GstVideofilterFilterFunc)(GstVideofilter *filter,
+typedef void (*GstVideofilterFilterFunc) (GstVideofilter * filter,
void *out_data, void *in_data);
-typedef void (*GstVideofilterSetupFunc)(GstVideofilter *filter);
+typedef void (*GstVideofilterSetupFunc) (GstVideofilter * filter);
typedef struct _GstVideofilterFormat GstVideofilterFormat;
-struct _GstVideofilterFormat {
+struct _GstVideofilterFormat
+{
char *fourcc;
int bpp;
GstVideofilterFilterFunc filter_func;
#define GST_IS_VIDEOFILTER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEOFILTER))
-struct _GstVideofilter {
+struct _GstVideofilter
+{
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
/* video state */
gboolean inited;
GstBuffer *out_buf;
};
-struct _GstVideofilterClass {
+struct _GstVideofilterClass
+{
GstElementClass parent_class;
GPtrArray *formats;
GstVideofilterSetupFunc setup;
};
-GType gst_videofilter_get_type(void);
+GType gst_videofilter_get_type (void);
-int gst_videofilter_get_input_width(GstVideofilter *videofilter);
-int gst_videofilter_get_input_height(GstVideofilter *videofilter);
-void gst_videofilter_set_output_size(GstVideofilter *videofilter,
+int gst_videofilter_get_input_width (GstVideofilter * videofilter);
+int gst_videofilter_get_input_height (GstVideofilter * videofilter);
+void gst_videofilter_set_output_size (GstVideofilter * videofilter,
int width, int height);
-GstVideofilterFormat *gst_videofilter_find_format_by_structure (GstVideofilter *filter,
- const GstStructure *structure);
-GstCaps *gst_videofilter_class_get_capslist(GstVideofilterClass *videofilterclass);
+GstVideofilterFormat *gst_videofilter_find_format_by_structure (GstVideofilter *
+ filter, const GstStructure * structure);
+GstCaps *gst_videofilter_class_get_capslist (GstVideofilterClass *
+ videofilterclass);
-void gst_videofilter_class_add_format(GstVideofilterClass *videofilterclass,
- GstVideofilterFormat *format);
-void gst_videofilter_class_add_pad_templates (GstVideofilterClass *videofilterclass);
+void gst_videofilter_class_add_format (GstVideofilterClass * videofilterclass,
+ GstVideofilterFormat * format);
+void gst_videofilter_class_add_pad_templates (GstVideofilterClass *
+ videofilterclass);
G_END_DECLS
-
#endif /* __GST_VIDEOFILTER_H__ */
-
/* 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;
}
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);
{
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;
}
* 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))
(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];
-};
-
-struct _GstVideoSinkClass {
- GstElementClass parent_class;
-
- gpointer _gst_reserved[GST_PADDING];
-};
-
-GType gst_videosink_get_type (void);
+
+ typedef struct _GstVideoSink GstVideoSink;
+ typedef struct _GstVideoSinkClass GstVideoSinkClass;
+
+ struct _GstVideoSink
+ {
+ GstElement element;
+
+ 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__ */
/* 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;
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;
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;
}
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)
#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, " \
"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__ */
* 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))
(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];
-};
-
-struct _GstVideoSinkClass {
- GstElementClass parent_class;
-
- gpointer _gst_reserved[GST_PADDING];
-};
-
-GType gst_videosink_get_type (void);
+
+ typedef struct _GstVideoSink GstVideoSink;
+ typedef struct _GstVideoSinkClass GstVideoSinkClass;
+
+ struct _GstVideoSink
+ {
+ GstElement element;
+
+ 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__ */
#include "xoverlay.h"
-enum {
+enum
+{
HAVE_XWINDOW_ID,
DESIRED_SIZE,
LAST_SIGNAL
};
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;
}
* 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);
* 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);
}
/**
* 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;
* 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);
}
/**
* 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);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_X_OVERLAY \
(gst_x_overlay_get_type ())
#define GST_X_OVERLAY(obj) \
(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__ */
#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;
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;
}
static void
-gst_x_window_listener_init (GstXWindowListener *xwin)
+gst_x_window_listener_init (GstXWindowListener * xwin)
{
xwin->xwindow_id = 0;
xwin->display_name = NULL;
}
static void
-gst_x_window_listener_dispose (GObject *object)
+gst_x_window_listener_dispose (GObject * object)
{
GstXWindowListener *xwin = GST_X_WINDOW_LISTENER (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;
}
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);
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);
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);
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);
}
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) \
} while (0);
static void
-gst_xwin_set_clips (GstXWindowListener *xwin)
+gst_xwin_set_clips (GstXWindowListener * xwin)
{
Window root, rroot, parent, *kids, me;
XWindowAttributes attr;
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)
static gboolean
-gst_xwin_window (GstXWindowListener *xwin)
+gst_xwin_window (GstXWindowListener * xwin)
{
if (xwin->ov_map && xwin->ov_wmmap &&
xwin->ov_visibility != VisibilityFullyObscured) {
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;
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;
}
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;
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;
}
static void
-gst_xwin_init_window (GstXWindowListener *xwin)
+gst_xwin_init_window (GstXWindowListener * xwin)
{
XWindowAttributes attr;
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);
}
static void
-gst_xwin_exit_window (GstXWindowListener *xwin)
+gst_xwin_exit_window (GstXWindowListener * xwin)
{
/* disable overlay */
gst_xwin_set_overlay (xwin, FALSE);
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 UnmapNotify:
- xwin->ov_map = FALSE;
- xwin->ov_conf = TRUE;
- gst_xwin_configure (xwin);
- break;
-
- case ConfigureNotify:
- gst_xwin_resize (xwin);
- break;
-
- default:
- /* nothing */
- 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 ConfigureNotify:
+ gst_xwin_resize (xwin);
+ 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 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;
+ 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;
+
+ 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 ConfigureNotify:
- if (!xwin->ov_refresh) {
- gst_xwin_resize (xwin);
- }
- break;
-
- default:
- /* nothing */
- break;
+ 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 ConfigureNotify:
+ if (!xwin->ov_refresh) {
+ gst_xwin_resize (xwin);
+ }
+ break;
+
+ default:
+ /* nothing */
+ break;
}
}
}
}
static void
-gst_xwin_start (GstXWindowListener *xwin)
+gst_xwin_start (GstXWindowListener * xwin)
{
DEBUG ("Starting XWindow listener");
* 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");
*/
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)
#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) \
(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);
-
-struct _GstXWindowClip {
- gint32 x_offset,
- y_offset,
- width,
- height;
+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;
gpointer data;
};
-struct _GstXWindowListener {
- GObject parent;
+struct _GstXWindowListener
+{
+ GObject parent;
/* "per-instance virtual functions" */
MapWindowFunc map_window_func;
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;
/* 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__ */
#endif
#include "gstadder.h"
#include <gst/audio/audio.h>
-#include <string.h> /* strcmp */
+#include <string.h> /* strcmp */
#define GST_ADDER_BUFFER_SIZE 4096
#define GST_ADDER_NUM_BUFFERS 8
/* elementfactory information */
-static GstElementDetails adder_details = GST_ELEMENT_DETAILS (
- "Adder",
- "Generic/Audio",
- "Add N audio channels together",
- "Thomas <thomas@apestaart.org>"
-);
+static GstElementDetails adder_details = GST_ELEMENT_DETAILS ("Adder",
+ "Generic/Audio",
+ "Add N audio channels together",
+ "Thomas <thomas@apestaart.org>");
/* Adder signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_NUM_PADS,
/* FILL ME */
};
static GstStaticPadTemplate gst_adder_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
+ GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
static GstStaticPadTemplate gst_adder_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS(
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
-
-static void gst_adder_class_init (GstAdderClass *klass);
-static void gst_adder_init (GstAdder *adder);
-
-static void gst_adder_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static GstPad* gst_adder_request_new_pad (GstElement *element, GstPadTemplate *temp,
- const gchar *unused);
-static GstElementStateReturn
- gst_adder_change_state (GstElement *element);
+ GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
+
+static void gst_adder_class_init (GstAdderClass * klass);
+static void gst_adder_init (GstAdder * adder);
+
+static void gst_adder_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstPad *gst_adder_request_new_pad (GstElement * element,
+ GstPadTemplate * temp, const gchar * unused);
+static GstElementStateReturn gst_adder_change_state (GstElement * element);
/* we do need a loop function */
-static void gst_adder_loop (GstElement *element);
+static void gst_adder_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_adder_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_adder_get_type (void) {
+gst_adder_get_type (void)
+{
static GType adder_type = 0;
if (!adder_type) {
sizeof (GstAdder), 0,
(GInstanceInitFunc) gst_adder_init,
};
- adder_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAdder",
- &adder_info, 0);
+ adder_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAdder",
+ &adder_info, 0);
}
return adder_type;
}
static GstPadLinkReturn
-gst_adder_link (GstPad *pad, const GstCaps *caps)
+gst_adder_link (GstPad * pad, const GstCaps * caps)
{
GstAdder *adder;
const char *media_type;
GstElement *element;
g_return_val_if_fail (caps != NULL, GST_PAD_LINK_REFUSED);
- g_return_val_if_fail (pad != NULL, GST_PAD_LINK_REFUSED);
+ g_return_val_if_fail (pad != NULL, GST_PAD_LINK_REFUSED);
element = GST_PAD_PARENT (pad);
adder = GST_ADDER (element);
if (otherpad != pad) {
ret = gst_pad_try_set_caps (otherpad, caps);
if (GST_PAD_LINK_FAILED (ret)) {
- return ret;
+ return ret;
}
}
pads = g_list_next (pads);
if (otherpad != pad) {
ret = gst_pad_try_set_caps (otherpad, caps);
if (GST_PAD_LINK_FAILED (ret)) {
- return ret;
+ return ret;
}
}
pads = g_list_next (pads);
media_type = gst_structure_get_name (structure);
if (strcmp (media_type, "audio/x-raw-int") == 0) {
GST_DEBUG ("parse_caps sets adder to format int");
- adder->format = GST_ADDER_FORMAT_INT;
- gst_structure_get_int (structure, "width", &adder->width);
- gst_structure_get_int (structure, "depth", &adder->depth);
- gst_structure_get_int (structure, "endianness", &adder->endianness);
- gst_structure_get_boolean (structure, "signed", &adder->is_signed);
- gst_structure_get_int (structure, "channels", &adder->channels);
- gst_structure_get_int (structure, "rate", &adder->rate);
+ adder->format = GST_ADDER_FORMAT_INT;
+ gst_structure_get_int (structure, "width", &adder->width);
+ gst_structure_get_int (structure, "depth", &adder->depth);
+ gst_structure_get_int (structure, "endianness", &adder->endianness);
+ gst_structure_get_boolean (structure, "signed", &adder->is_signed);
+ gst_structure_get_int (structure, "channels", &adder->channels);
+ gst_structure_get_int (structure, "rate", &adder->rate);
} else if (strcmp (media_type, "audio/x-raw-float") == 0) {
GST_DEBUG ("parse_caps sets adder to format float");
- adder->format = GST_ADDER_FORMAT_FLOAT;
- gst_structure_get_int (structure, "width", &adder->width);
- gst_structure_get_int (structure, "channels", &adder->channels);
- gst_structure_get_int (structure, "rate", &adder->rate);
+ adder->format = GST_ADDER_FORMAT_FLOAT;
+ gst_structure_get_int (structure, "width", &adder->width);
+ gst_structure_get_int (structure, "channels", &adder->channels);
+ gst_structure_get_int (structure, "rate", &adder->rate);
}
-
+
return GST_PAD_LINK_OK;
}
static void
-gst_adder_class_init (GstAdderClass *klass)
+gst_adder_class_init (GstAdderClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
- g_param_spec_int ("num_pads","number of pads","Number Of Pads",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("num_pads", "number of pads", "Number Of Pads",
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
gobject_class->get_property = gst_adder_get_property;
gstelement_class->request_new_pad = gst_adder_request_new_pad;
- gstelement_class->change_state = gst_adder_change_state;
+ gstelement_class->change_state = gst_adder_change_state;
}
-static void
-gst_adder_init (GstAdder *adder)
+static void
+gst_adder_init (GstAdder * adder)
{
- adder->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_adder_src_template), "src");
+ adder->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_adder_src_template), "src");
gst_element_add_pad (GST_ELEMENT (adder), adder->srcpad);
gst_element_set_loop_function (GST_ELEMENT (adder), gst_adder_loop);
- gst_pad_set_getcaps_function(adder->srcpad, gst_pad_proxy_getcaps);
+ gst_pad_set_getcaps_function (adder->srcpad, gst_pad_proxy_getcaps);
gst_pad_set_link_function (adder->srcpad, gst_adder_link);
adder->format = GST_ADDER_FORMAT_UNSET;
/* keep track of the sinkpads requested */
-
+
adder->numsinkpads = 0;
adder->input_channels = NULL;
}
-static GstPad*
-gst_adder_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused)
+static GstPad *
+gst_adder_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
- gchar *name;
- GstAdder *adder;
+ gchar *name;
+ GstAdder *adder;
GstAdderInputChannel *input;
g_return_val_if_fail (GST_IS_ADDER (element), NULL);
g_warning ("gstadder: could not allocate adder input channel !\n");
return NULL;
}
-
+
adder = GST_ADDER (element);
/* fill in input_channel structure */
gst_element_add_pad (GST_ELEMENT (adder), input->sinkpad);
gst_pad_set_getcaps_function (input->sinkpad, gst_pad_proxy_getcaps);
- gst_pad_set_link_function(input->sinkpad, gst_adder_link);
+ gst_pad_set_link_function (input->sinkpad, gst_adder_link);
/* add the input_channel to the list of input channels */
-
+
adder->input_channels = g_slist_append (adder->input_channels, input);
adder->numsinkpads++;
-
+
return input->sinkpad;
}
static void
-gst_adder_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_adder_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAdder *adder;
g_value_set_int (value, adder->numsinkpads);
break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/* use this loop */
static void
-gst_adder_loop (GstElement *element)
+gst_adder_loop (GstElement * element)
{
/*
* combine channels by adding sample values
* - otherwise add the gotten bytes to the output buffer
* - push out the output buffer
*/
- GstAdder *adder;
+ GstAdder *adder;
GstBuffer *buf_out;
- GSList *inputs;
+ GSList *inputs;
register guint i;
if (buf_out == NULL) {
GST_ELEMENT_ERROR (adder, CORE, TOO_LAZY, (NULL),
- ("could not get new output buffer"));
+ ("could not get new output buffer"));
return;
}
if (!GST_PAD_IS_USABLE (input->sinkpad)) {
GST_DEBUG ("adder ignoring pad %s:%s",
- GST_DEBUG_PAD_NAME (input->sinkpad));
+ GST_DEBUG_PAD_NAME (input->sinkpad));
continue;
}
/* Get data from the bytestream of each input channel. We need to check for
events before passing on the data to the output buffer. */
got_bytes = gst_bytestream_peek_bytes (input->bytestream, &raw_in,
- GST_BUFFER_SIZE (buf_out));
+ GST_BUFFER_SIZE (buf_out));
/* FIXME we should do something with the data if got_bytes > 0 */
- if (got_bytes < GST_BUFFER_SIZE(buf_out)) {
- GstEvent *event = NULL;
- guint32 waiting;
+ if (got_bytes < GST_BUFFER_SIZE (buf_out)) {
+ GstEvent *event = NULL;
+ guint32 waiting;
/* we need to check for an event. */
gst_bytestream_get_status (input->bytestream, &waiting, &event);
if (event) {
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- /* if we get an EOS event from one of our sink pads, we assume that
- pad's finished handling data. just skip this pad. */
- GST_DEBUG ("got an EOS event");
+ /* if we get an EOS event from one of our sink pads, we assume that
+ pad's finished handling data. just skip this pad. */
+ GST_DEBUG ("got an EOS event");
gst_event_unref (event);
- continue;
+ continue;
case GST_EVENT_INTERRUPT:
gst_event_unref (event);
- GST_DEBUG ("got an interrupt event");
+ GST_DEBUG ("got an interrupt event");
/* we have to call interrupt here, the scheduler will switch out
this element ASAP or returns TRUE if we need to exit the loop */
if (gst_element_interrupt (GST_ELEMENT (adder))) {
}
default:
break;
- }
+ }
}
} else {
/* here's where the data gets copied. */
GST_DEBUG ("copying %d bytes from channel %p to output data %p "
- "in buffer %p",
- GST_BUFFER_SIZE (buf_out), input,
- GST_BUFFER_DATA (buf_out), buf_out);
+ "in buffer %p",
+ GST_BUFFER_SIZE (buf_out), input, GST_BUFFER_DATA (buf_out), buf_out);
if (adder->format == GST_ADDER_FORMAT_INT) {
- if (adder->width == 32) {
- gint32 *in = (gint32 *) raw_in;
- gint32 *out = (gint32 *) GST_BUFFER_DATA (buf_out);
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 4; i++)
- out[i] = CLAMP(out[i] + in[i], 0x80000000, 0x7fffffff);
- } else if (adder->width == 16) {
- gint16 *in = (gint16 *) raw_in;
- gint16 *out = (gint16 *) GST_BUFFER_DATA (buf_out);
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 2; i++)
- out[i] = CLAMP(out[i] + in[i], 0x8000, 0x7fff);
- } else if (adder->width == 8) {
- gint8 *in = (gint8 *) raw_in;
- gint8 *out = (gint8 *) GST_BUFFER_DATA (buf_out);
- for (i = 0; i < GST_BUFFER_SIZE (buf_out); i++)
- out[i] = CLAMP(out[i] + in[i], 0x80, 0x7f);
- } else {
- GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
- ("invalid width (%u) for integer audio in gstadder",
- adder->width));
+ if (adder->width == 32) {
+ gint32 *in = (gint32 *) raw_in;
+ gint32 *out = (gint32 *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 4; i++)
+ out[i] = CLAMP (out[i] + in[i], 0x80000000, 0x7fffffff);
+ } else if (adder->width == 16) {
+ gint16 *in = (gint16 *) raw_in;
+ gint16 *out = (gint16 *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / 2; i++)
+ out[i] = CLAMP (out[i] + in[i], 0x8000, 0x7fff);
+ } else if (adder->width == 8) {
+ gint8 *in = (gint8 *) raw_in;
+ gint8 *out = (gint8 *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out); i++)
+ out[i] = CLAMP (out[i] + in[i], 0x80, 0x7f);
+ } else {
+ GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
+ ("invalid width (%u) for integer audio in gstadder",
+ adder->width));
return;
- }
+ }
} else if (adder->format == GST_ADDER_FORMAT_FLOAT) {
- if (adder->width == 64) {
- gdouble *in = (gdouble *) raw_in;
- gdouble *out = (gdouble *) GST_BUFFER_DATA (buf_out);
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gdouble); i++)
- out[i] = CLAMP(out[i] + in[i], -1.0, 1.0);
- } else if (adder->width == 32) {
- gfloat *in = (gfloat *) raw_in;
- gfloat *out = (gfloat *) GST_BUFFER_DATA (buf_out);
- for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gfloat); i++)
- out[i] = CLAMP(out[i] + in[i], -1.0, 1.0);
- } else {
- GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
- ("invalid width (%u) for float audio in gstadder",
- adder->width));
- return;
- }
+ if (adder->width == 64) {
+ gdouble *in = (gdouble *) raw_in;
+ gdouble *out = (gdouble *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gdouble); i++)
+ out[i] = CLAMP (out[i] + in[i], -1.0, 1.0);
+ } else if (adder->width == 32) {
+ gfloat *in = (gfloat *) raw_in;
+ gfloat *out = (gfloat *) GST_BUFFER_DATA (buf_out);
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf_out) / sizeof (gfloat); i++)
+ out[i] = CLAMP (out[i] + in[i], -1.0, 1.0);
+ } else {
+ GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
+ ("invalid width (%u) for float audio in gstadder", adder->width));
+ return;
+ }
} else {
- GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
- ("invalid audio format (%d) in gstadder",
- adder->format));
+ GST_ELEMENT_ERROR (adder, STREAM, FORMAT, (NULL),
+ ("invalid audio format (%d) in gstadder", adder->format));
return;
}
GST_BUFFER_TIMESTAMP (buf_out) = adder->timestamp;
if (adder->format == GST_ADDER_FORMAT_FLOAT)
- adder->offset += GST_BUFFER_SIZE (buf_out) / sizeof (gfloat) / adder->channels;
+ adder->offset +=
+ GST_BUFFER_SIZE (buf_out) / sizeof (gfloat) / adder->channels;
else
- adder->offset += GST_BUFFER_SIZE (buf_out) * 8 / adder->width / adder->channels;
+ adder->offset +=
+ GST_BUFFER_SIZE (buf_out) * 8 / adder->width / adder->channels;
adder->timestamp = adder->offset * GST_SECOND / adder->rate;
/* send it out */
static GstElementStateReturn
-gst_adder_change_state (GstElement *element)
+gst_adder_change_state (GstElement * element)
{
GstAdder *adder;
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE(
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "adder",
- "Adds multiple streams",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "adder",
+ "Adds multiple streams",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/bytestream/bytestream.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
-extern GstElementDetails gst_adder_details;
+ extern GstElementDetails gst_adder_details;
#define GST_TYPE_ADDER \
(gst_adder_get_type())
#define GST_IS_ADDER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ADDER))
-typedef struct _GstAdder GstAdder;
-typedef struct _GstAdderClass GstAdderClass;
-typedef struct _GstAdderInputChannel GstAdderInputChannel;
-typedef enum _GstAdderFormat GstAdderFormat;
-
-enum _GstAdderFormat {
- GST_ADDER_FORMAT_UNSET,
- GST_ADDER_FORMAT_INT,
- GST_ADDER_FORMAT_FLOAT
-};
-
-struct _GstAdderInputChannel {
- GstPad *sinkpad;
- GstByteStream *bytestream;
-};
-
-struct _GstAdder {
- GstElement element;
-
- GstPad *srcpad;
-
- /* keep track of the sinkpads */
- guint numsinkpads;
- GSList *input_channels;
-
- /* the next are valid for both int and float */
- GstAdderFormat format;
- guint rate;
- guint channels;
- guint width;
- guint endianness;
-
- /* the next are valid only for format == GST_ADDER_FORMAT_INT */
- guint depth;
- gboolean is_signed;
-
- /* counters to keep track of timestamps */
- gint64 timestamp;
- gint64 offset;
-};
-
-struct _GstAdderClass {
- GstElementClass parent_class;
-};
-
-GType gst_adder_get_type (void);
-gboolean gst_adder_factory_init (GstElementFactory *factory);
+ typedef struct _GstAdder GstAdder;
+ typedef struct _GstAdderClass GstAdderClass;
+ typedef struct _GstAdderInputChannel GstAdderInputChannel;
+ typedef enum _GstAdderFormat GstAdderFormat;
+
+ enum _GstAdderFormat
+ {
+ GST_ADDER_FORMAT_UNSET,
+ GST_ADDER_FORMAT_INT,
+ GST_ADDER_FORMAT_FLOAT
+ };
+
+ struct _GstAdderInputChannel
+ {
+ GstPad *sinkpad;
+ GstByteStream *bytestream;
+ };
+
+ struct _GstAdder
+ {
+ GstElement element;
+
+ GstPad *srcpad;
+
+ /* keep track of the sinkpads */
+ guint numsinkpads;
+ GSList *input_channels;
+
+ /* the next are valid for both int and float */
+ GstAdderFormat format;
+ guint rate;
+ guint channels;
+ guint width;
+ guint endianness;
+
+ /* the next are valid only for format == GST_ADDER_FORMAT_INT */
+ guint depth;
+ gboolean is_signed;
+
+ /* counters to keep track of timestamps */
+ gint64 timestamp;
+ gint64 offset;
+ };
+
+ struct _GstAdderClass
+ {
+ GstElementClass parent_class;
+ };
+
+ GType gst_adder_get_type (void);
+ gboolean gst_adder_factory_init (GstElementFactory * factory);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_ADDER_H__ */
+#endif /* __GST_ADDER_H__ */
typedef struct _GstAudioConvertClass GstAudioConvertClass;
/* this struct is a handy way of passing around all the caps info ... */
-struct _GstAudioConvertCaps {
+struct _GstAudioConvertCaps
+{
/* general caps */
- gboolean is_int;
- gint endianness;
- gint width;
- gint rate;
- gint channels;
+ gboolean is_int;
+ gint endianness;
+ gint width;
+ gint rate;
+ gint channels;
/* int audio caps */
- gboolean sign;
- gint depth;
+ gboolean sign;
+ gint depth;
/* float audio caps */
- gint buffer_frames;
+ gint buffer_frames;
};
-struct _GstAudioConvert {
- GstElement element;
+struct _GstAudioConvert
+{
+ GstElement element;
/* pads */
- GstPad * sink;
- GstPad * src;
+ GstPad *sink;
+ GstPad *src;
- GstAudioConvertCaps srccaps;
- GstAudioConvertCaps sinkcaps;
+ GstAudioConvertCaps srccaps;
+ GstAudioConvertCaps sinkcaps;
/* conversion functions */
- GstBuffer * (* convert_internal) (GstAudioConvert *this, GstBuffer *buf);
+ GstBuffer *(*convert_internal) (GstAudioConvert * this, GstBuffer * buf);
};
-struct _GstAudioConvertClass {
+struct _GstAudioConvertClass
+{
GstElementClass parent_class;
};
};
/* type functions */
-static GType gst_audio_convert_get_type (void);
-static void gst_audio_convert_base_init (gpointer g_class);
-static void gst_audio_convert_class_init (GstAudioConvertClass *klass);
-static void gst_audio_convert_init (GstAudioConvert *audio_convert);
+static GType gst_audio_convert_get_type (void);
+static void gst_audio_convert_base_init (gpointer g_class);
+static void gst_audio_convert_class_init (GstAudioConvertClass * klass);
+static void gst_audio_convert_init (GstAudioConvert * audio_convert);
/* gstreamer functions */
-static void gst_audio_convert_chain (GstPad *pad, GstData *_data);
-static GstPadLinkReturn gst_audio_convert_link (GstPad *pad, const GstCaps *caps);
-static GstCaps * gst_audio_convert_getcaps (GstPad *pad);
-static GstElementStateReturn gst_audio_convert_change_state (GstElement *element);
+static void gst_audio_convert_chain (GstPad * pad, GstData * _data);
+static GstPadLinkReturn gst_audio_convert_link (GstPad * pad,
+ const GstCaps * caps);
+static GstCaps *gst_audio_convert_getcaps (GstPad * pad);
+static GstElementStateReturn gst_audio_convert_change_state (GstElement *
+ element);
-static GstBuffer * gst_audio_convert_buffer_to_default_format (GstAudioConvert *this, GstBuffer *buf);
-static GstBuffer * gst_audio_convert_buffer_from_default_format (GstAudioConvert *this, GstBuffer *buf);
+static GstBuffer *gst_audio_convert_buffer_to_default_format (GstAudioConvert *
+ this, GstBuffer * buf);
+static GstBuffer *gst_audio_convert_buffer_from_default_format (GstAudioConvert
+ * this, GstBuffer * buf);
-static GstBuffer * gst_audio_convert_channels (GstAudioConvert *this, GstBuffer *buf);
+static GstBuffer *gst_audio_convert_channels (GstAudioConvert * this,
+ GstBuffer * buf);
/* AudioConvert signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_AGGRESSIVE,
};
#define DEBUG_INIT(bla) \
GST_DEBUG_CATEGORY_INIT (audio_convert_debug, "audioconvert", 0, "audio conversion element");
-
-GST_BOILERPLATE_FULL (GstAudioConvert, gst_audio_convert, GstElement, GST_TYPE_ELEMENT, DEBUG_INIT);
+
+GST_BOILERPLATE_FULL (GstAudioConvert, gst_audio_convert, GstElement,
+ GST_TYPE_ELEMENT, DEBUG_INIT);
/*** GSTREAMER PROTOTYPES *****************************************************/
)
static GstStaticPadTemplate gst_audio_convert_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- STATIC_CAPS
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ STATIC_CAPS);
static GstStaticPadTemplate gst_audio_convert_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- STATIC_CAPS
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ STATIC_CAPS);
/*** TYPE FUNCTIONS ***********************************************************/
}
static void
-gst_audio_convert_class_init (GstAudioConvertClass *klass)
+gst_audio_convert_class_init (GstAudioConvertClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_audio_convert_init (GstAudioConvert *this)
+gst_audio_convert_init (GstAudioConvert * this)
{
/* sinkpad */
- this->sink = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_audio_convert_sink_template), "sink");
+ this->sink =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_audio_convert_sink_template), "sink");
gst_pad_set_getcaps_function (this->sink, gst_audio_convert_getcaps);
gst_pad_set_link_function (this->sink, gst_audio_convert_link);
- gst_element_add_pad (GST_ELEMENT(this), this->sink);
+ gst_element_add_pad (GST_ELEMENT (this), this->sink);
/* srcpad */
- this->src = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_audio_convert_src_template), "src");
+ this->src =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_audio_convert_src_template), "src");
gst_pad_set_getcaps_function (this->src, gst_audio_convert_getcaps);
gst_pad_set_link_function (this->src, gst_audio_convert_link);
- gst_element_add_pad (GST_ELEMENT(this), this->src);
+ gst_element_add_pad (GST_ELEMENT (this), this->src);
- gst_pad_set_chain_function(this->sink, gst_audio_convert_chain);
+ gst_pad_set_chain_function (this->sink, gst_audio_convert_chain);
/* clear important variables */
this->convert_internal = NULL;
/*** GSTREAMER FUNCTIONS ******************************************************/
static void
-gst_audio_convert_chain (GstPad *pad, GstData *data)
+gst_audio_convert_chain (GstPad * pad, GstData * data)
{
GstBuffer *buf = GST_BUFFER (data);
GstAudioConvert *this;
return;
}
- if (!gst_pad_is_negotiated (this->sink))
- {
+ if (!gst_pad_is_negotiated (this->sink)) {
GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
- ("Sink pad not negotiated before chain function"));
+ ("Sink pad not negotiated before chain function"));
return;
}
if (!gst_pad_is_negotiated (this->src)) {
gst_data_unref (data);
return;
}
-
+
/**
* Theory of operation:
* - convert the format (endianness, signedness, width, depth) to
/* this function is complicated now, but it will be unnecessary when we convert
* rate. */
static GstCaps *
-gst_audio_convert_getcaps (GstPad *pad)
+gst_audio_convert_getcaps (GstPad * pad)
{
GstAudioConvert *this;
GstPad *otherpad;
const GstCaps *templcaps;
int i, size;
- g_return_val_if_fail(GST_IS_PAD(pad), NULL);
- g_return_val_if_fail(GST_IS_AUDIO_CONVERT(GST_OBJECT_PARENT (pad)), NULL);
- this = GST_AUDIO_CONVERT(GST_OBJECT_PARENT (pad));
+ g_return_val_if_fail (GST_IS_PAD (pad), NULL);
+ g_return_val_if_fail (GST_IS_AUDIO_CONVERT (GST_OBJECT_PARENT (pad)), NULL);
+ this = GST_AUDIO_CONVERT (GST_OBJECT_PARENT (pad));
otherpad = (pad == this->src) ? this->sink : this->src;
}
caps = gst_caps_intersect (othercaps, templcaps);
gst_caps_free (othercaps);
-
+
return caps;
}
static gboolean
-gst_audio_convert_parse_caps (const GstCaps* gst_caps, GstAudioConvertCaps *caps)
+gst_audio_convert_parse_caps (const GstCaps * gst_caps,
+ GstAudioConvertCaps * caps)
{
GstStructure *structure = gst_caps_get_structure (gst_caps, 0);
+
g_return_val_if_fail (gst_caps_is_fixed (gst_caps), FALSE);
g_return_val_if_fail (caps != NULL, FALSE);
-
+
caps->endianness = G_BYTE_ORDER;
- caps->is_int = (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0);
- if (!gst_structure_get_int (structure, "channels", &caps->channels) ||
- !gst_structure_get_int (structure, "width", &caps->width) ||
- !gst_structure_get_int (structure, "rate", &caps->rate) ||
- (caps->is_int &&
- (!gst_structure_get_boolean (structure, "signed", &caps->sign) ||
- !gst_structure_get_int (structure, "depth", &caps->depth) ||
- (caps->width != 8 &&
- !gst_structure_get_int (structure, "endianness", &caps->endianness)))) ||
- (!caps->is_int &&
- !gst_structure_get_int (structure, "buffer-frames", &caps->buffer_frames))) {
+ caps->is_int =
+ (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0);
+ if (!gst_structure_get_int (structure, "channels", &caps->channels)
+ || !gst_structure_get_int (structure, "width", &caps->width)
+ || !gst_structure_get_int (structure, "rate", &caps->rate)
+ || (caps->is_int
+ && (!gst_structure_get_boolean (structure, "signed", &caps->sign)
+ || !gst_structure_get_int (structure, "depth", &caps->depth)
+ || (caps->width != 8
+ && !gst_structure_get_int (structure, "endianness",
+ &caps->endianness)))) || (!caps->is_int
+ && !gst_structure_get_int (structure, "buffer-frames",
+ &caps->buffer_frames))) {
GST_DEBUG ("could not get some values from structure");
return FALSE;
}
}
static GstPadLinkReturn
-gst_audio_convert_link (GstPad *pad, const GstCaps *caps)
+gst_audio_convert_link (GstPad * pad, const GstCaps * caps)
{
GstAudioConvert *this;
GstPad *otherpad;
guint i;
GstPadLinkReturn ret;
- g_return_val_if_fail(GST_IS_PAD(pad), GST_PAD_LINK_REFUSED);
- g_return_val_if_fail(GST_IS_AUDIO_CONVERT(GST_OBJECT_PARENT (pad)), GST_PAD_LINK_REFUSED);
-
- this = GST_AUDIO_CONVERT(GST_OBJECT_PARENT (pad));
+ g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_LINK_REFUSED);
+ g_return_val_if_fail (GST_IS_AUDIO_CONVERT (GST_OBJECT_PARENT (pad)),
+ GST_PAD_LINK_REFUSED);
+
+ this = GST_AUDIO_CONVERT (GST_OBJECT_PARENT (pad));
otherpad = (pad == this->src ? this->sink : this->src);
/* negotiate sinkpad first */
- if (pad == this->src &&
- !gst_pad_is_negotiated (this->sink))
+ if (pad == this->src && !gst_pad_is_negotiated (this->sink))
return GST_PAD_LINK_DELAYED;
-
+
if (!gst_audio_convert_parse_caps (caps, &ac_caps))
return GST_PAD_LINK_REFUSED;
-
+
/* try setting our caps on the other side first */
if (gst_pad_try_set_caps (otherpad, caps) >= GST_PAD_LINK_OK) {
this->srccaps = ac_caps;
this->sinkcaps = ac_caps;
return GST_PAD_LINK_OK;
}
-
+
/* ok, not those - try setting "any" caps */
othercaps = gst_pad_get_allowed_caps (otherpad);
for (i = 0; i < gst_caps_get_size (othercaps); i++) {
GstStructure *structure = gst_caps_get_structure (othercaps, i);
+
gst_structure_set (structure, "rate", G_TYPE_INT, ac_caps.rate, NULL);
if (strcmp (gst_structure_get_name (structure), "audio/x-raw-float") == 0) {
if (!ac_caps.is_int) {
- gst_structure_set (structure, "buffer-frames", G_TYPE_INT, ac_caps.buffer_frames, NULL);
+ gst_structure_set (structure, "buffer-frames", G_TYPE_INT,
+ ac_caps.buffer_frames, NULL);
} else {
gst_structure_set (structure, "buffer-frames", G_TYPE_INT, 0, NULL);
}
gst_caps_free (othercaps);
if (ret < GST_PAD_LINK_OK)
return ret;
-
+
/* woohoo, got it */
if (!gst_audio_convert_parse_caps (gst_pad_get_negotiated_caps (otherpad),
- &other_ac_caps)) {
+ &other_ac_caps)) {
g_critical ("internal negotiation error");
return GST_PAD_LINK_REFUSED;
}
}
static GstElementStateReturn
-gst_audio_convert_change_state (GstElement *element)
+gst_audio_convert_change_state (GstElement * element)
{
GstAudioConvert *this = GST_AUDIO_CONVERT (element);
/* return a writable buffer of size which ideally is the same as before
- You must unref the new buffer
- The size of the old buffer is undefined after this operation */
-static GstBuffer*
-gst_audio_convert_get_buffer (GstBuffer *buf, guint size)
+static GstBuffer *
+gst_audio_convert_get_buffer (GstBuffer * buf, guint size)
{
GstBuffer *ret;
- GST_LOG ("new buffer of size %u requested. Current is: data: %p - size: %u - maxsize: %u",
+
+ GST_LOG
+ ("new buffer of size %u requested. Current is: data: %p - size: %u - maxsize: %u",
size, buf->data, buf->size, buf->maxsize);
if (buf->maxsize >= size && gst_buffer_is_writable (buf)) {
gst_buffer_ref (buf);
buf->size = size;
- GST_LOG ("returning same buffer with adjusted values. data: %p - size: %u - maxsize: %u",
+ GST_LOG
+ ("returning same buffer with adjusted values. data: %p - size: %u - maxsize: %u",
buf->data, buf->size, buf->maxsize);
return buf;
} else {
}
}
-static inline guint8 GUINT8_IDENTITY (guint8 x) { return x; }
-static inline guint8 GINT8_IDENTITY (gint8 x) { return x; }
+static inline guint8
+GUINT8_IDENTITY (guint8 x)
+{
+ return x;
+}
+static inline guint8
+GINT8_IDENTITY (gint8 x)
+{
+ return x;
+}
#define CONVERT_TO(to, from, type, sign, endianness, LE_FUNC, BE_FUNC) \
G_STMT_START{ \
} \
}G_STMT_END;
-static GstBuffer*
-gst_audio_convert_buffer_to_default_format (GstAudioConvert *this, GstBuffer *buf)
+static GstBuffer *
+gst_audio_convert_buffer_to_default_format (GstAudioConvert * this,
+ GstBuffer * buf)
{
GstBuffer *ret;
gint i, count;
if (this->sinkcaps.is_int) {
if (this->sinkcaps.width == 32 && this->sinkcaps.depth == 32 &&
- this->sinkcaps.endianness == G_BYTE_ORDER && this->sinkcaps.sign == TRUE)
+ this->sinkcaps.endianness == G_BYTE_ORDER
+ && this->sinkcaps.sign == TRUE)
return buf;
- ret = gst_audio_convert_get_buffer (buf, buf->size * 32 / this->sinkcaps.width);
+ ret =
+ gst_audio_convert_get_buffer (buf,
+ buf->size * 32 / this->sinkcaps.width);
count = ret->size / 4;
src = buf->data + (count - 1) * (this->sinkcaps.width / 8);
dest = (gint32 *) ret->data;
for (i = count - 1; i >= 0; i--) {
switch (this->sinkcaps.width) {
- case 8:
- if (this->sinkcaps.sign) {
- CONVERT_TO (cur, src, gint8, this->sinkcaps.sign, this->sinkcaps.endianness, GINT8_IDENTITY, GINT8_IDENTITY);
- } else {
- CONVERT_TO (cur, src, guint8, this->sinkcaps.sign, this->sinkcaps.endianness, GUINT8_IDENTITY, GUINT8_IDENTITY);
- }
- break;
- case 16:
- if (this->sinkcaps.sign) {
- CONVERT_TO (cur, src, gint16, this->sinkcaps.sign, this->sinkcaps.endianness, GINT16_FROM_LE, GINT16_FROM_BE);
- } else {
- CONVERT_TO (cur, src, guint16, this->sinkcaps.sign, this->sinkcaps.endianness, GUINT16_FROM_LE, GUINT16_FROM_BE);
- }
- break;
- case 32:
- if (this->sinkcaps.sign) {
- CONVERT_TO (cur, src, gint32, this->sinkcaps.sign, this->sinkcaps.endianness, GINT32_FROM_LE, GINT32_FROM_BE);
- } else {
- CONVERT_TO (cur, src, guint32, this->sinkcaps.sign, this->sinkcaps.endianness, GUINT32_FROM_LE, GUINT32_FROM_BE);
- }
- break;
- default:
- g_assert_not_reached ();
+ case 8:
+ if (this->sinkcaps.sign) {
+ CONVERT_TO (cur, src, gint8, this->sinkcaps.sign,
+ this->sinkcaps.endianness, GINT8_IDENTITY, GINT8_IDENTITY);
+ } else {
+ CONVERT_TO (cur, src, guint8, this->sinkcaps.sign,
+ this->sinkcaps.endianness, GUINT8_IDENTITY, GUINT8_IDENTITY);
+ }
+ break;
+ case 16:
+ if (this->sinkcaps.sign) {
+ CONVERT_TO (cur, src, gint16, this->sinkcaps.sign,
+ this->sinkcaps.endianness, GINT16_FROM_LE, GINT16_FROM_BE);
+ } else {
+ CONVERT_TO (cur, src, guint16, this->sinkcaps.sign,
+ this->sinkcaps.endianness, GUINT16_FROM_LE, GUINT16_FROM_BE);
+ }
+ break;
+ case 32:
+ if (this->sinkcaps.sign) {
+ CONVERT_TO (cur, src, gint32, this->sinkcaps.sign,
+ this->sinkcaps.endianness, GINT32_FROM_LE, GINT32_FROM_BE);
+ } else {
+ CONVERT_TO (cur, src, guint32, this->sinkcaps.sign,
+ this->sinkcaps.endianness, GUINT32_FROM_LE, GUINT32_FROM_BE);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
cur = cur * ((gint64) 1 << (32 - this->sinkcaps.depth));
- cur = CLAMP (cur, -((gint64)1 << 32), (gint64) 0x7FFFFFFF);
+ cur = CLAMP (cur, -((gint64) 1 << 32), (gint64) 0x7FFFFFFF);
write = cur;
memcpy (&dest[i], &write, 4);
}
* already 32 bits */
ret = gst_audio_convert_get_buffer (buf, buf->size);
- in = (gfloat*)GST_BUFFER_DATA (buf);
- out = (gint32*)GST_BUFFER_DATA (ret);
+ in = (gfloat *) GST_BUFFER_DATA (buf);
+ out = (gint32 *) GST_BUFFER_DATA (ret);
/* increment `in' via the for, cause CLAMP duplicates the first arg */
- for (i = buf->size / sizeof(float); i > 0; i--) {
+ for (i = buf->size / sizeof (float); i > 0; i--) {
*in *= 2147483647.0f + .5;
- *out = (gint32) CLAMP ((gint64) *in, -2147483648ll, 2147483647ll);
+ *out = (gint32) CLAMP ((gint64) * in, -2147483648ll, 2147483647ll);
out++;
in++;
}
}G_STMT_END
static GstBuffer *
-gst_audio_convert_buffer_from_default_format (GstAudioConvert *this, GstBuffer *buf)
+gst_audio_convert_buffer_from_default_format (GstAudioConvert * this,
+ GstBuffer * buf)
{
GstBuffer *ret;
guint count, i;
gint32 *src;
- if (this->srccaps.is_int && this->srccaps.width == 32 && this->srccaps.depth == 32 &&
- this->srccaps.endianness == G_BYTE_ORDER && this->srccaps.sign == TRUE)
+ if (this->srccaps.is_int && this->srccaps.width == 32
+ && this->srccaps.depth == 32 && this->srccaps.endianness == G_BYTE_ORDER
+ && this->srccaps.sign == TRUE)
return buf;
if (this->srccaps.is_int) {
guint8 *dest;
-
- count = buf->size / 4; /* size is undefined after gst_audio_convert_get_buffer! */
- ret = gst_audio_convert_get_buffer (buf, buf->size * this->srccaps.width / 32);
+
+ count = buf->size / 4; /* size is undefined after gst_audio_convert_get_buffer! */
+ ret =
+ gst_audio_convert_get_buffer (buf,
+ buf->size * this->srccaps.width / 32);
dest = ret->data;
src = (gint32 *) buf->data;
for (i = 0; i < count; i++) {
gint32 int_value = *src;
+
src++;
switch (this->srccaps.width) {
- case 8:
- if (this->srccaps.sign) {
- POPULATE (gint8, GINT8_IDENTITY, GINT8_IDENTITY);
- } else {
- POPULATE (guint8, GUINT8_IDENTITY, GUINT8_IDENTITY);
- }
- break;
- case 16:
- if (this->srccaps.sign) {
- POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE);
- } else {
- POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE);
- }
- break;
- case 32:
- if (this->srccaps.sign) {
- POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE);
- } else {
- POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE);
- }
- break;
- default:
- g_assert_not_reached ();
+ case 8:
+ if (this->srccaps.sign) {
+ POPULATE (gint8, GINT8_IDENTITY, GINT8_IDENTITY);
+ } else {
+ POPULATE (guint8, GUINT8_IDENTITY, GUINT8_IDENTITY);
+ }
+ break;
+ case 16:
+ if (this->srccaps.sign) {
+ POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE);
+ } else {
+ POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE);
+ }
+ break;
+ case 32:
+ if (this->srccaps.sign) {
+ POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE);
+ } else {
+ POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
}
} else {
gfloat *dest;
/* 1 / (2^31-1) * i */
- #define INT2FLOAT(i) (4.6566128752457969e-10 * ((gfloat)i))
- count = buf->size / 4; /* size is undefined after gst_audio_convert_get_buffer! */
- ret = gst_audio_convert_get_buffer (buf, buf->size * this->srccaps.width / 32);
-
+#define INT2FLOAT(i) (4.6566128752457969e-10 * ((gfloat)i))
+ count = buf->size / 4; /* size is undefined after gst_audio_convert_get_buffer! */
+ ret =
+ gst_audio_convert_get_buffer (buf,
+ buf->size * this->srccaps.width / 32);
+
dest = (gfloat *) ret->data;
src = (gint32 *) buf->data;
for (i = 0; i < count; i++) {
- *dest = (4.6566128752457969e-10 * ((gfloat) *src));
+ *dest = (4.6566128752457969e-10 * ((gfloat) * src));
dest++;
src++;
}
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
return ret;
}
static GstBuffer *
-gst_audio_convert_channels (GstAudioConvert *this, GstBuffer *buf)
+gst_audio_convert_channels (GstAudioConvert * this, GstBuffer * buf)
{
GstBuffer *ret;
gint i, count;
}
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
return ret;
}
/*** PLUGIN DETAILS ***********************************************************/
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "audioconvert", GST_RANK_PRIMARY, GST_TYPE_AUDIO_CONVERT))
+ if (!gst_element_register (plugin, "audioconvert", GST_RANK_PRIMARY,
+ GST_TYPE_AUDIO_CONVERT))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstaudioconvert",
- "Convert audio to different formats",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstaudioconvert",
+ "Convert audio to different formats",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/resample/resample.h>
/* elementfactory information */
-static GstElementDetails gst_audioscale_details = GST_ELEMENT_DETAILS (
- "Audio scaler",
- "Filter/Converter/Audio",
- "Resample audio",
- "David Schleef <ds@schleef.org>"
-);
+static GstElementDetails gst_audioscale_details =
+GST_ELEMENT_DETAILS ("Audio scaler",
+ "Filter/Converter/Audio",
+ "Resample audio",
+ "David Schleef <ds@schleef.org>");
/* Audioscale signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FILTERLEN,
ARG_METHOD,
};
static GstStaticPadTemplate gst_audioscale_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
+ );
static GstStaticPadTemplate gst_audioscale_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
+ );
#define GST_TYPE_AUDIOSCALE_METHOD (gst_audioscale_method_get_type())
static GType
{
static GType audioscale_method_type = 0;
static GEnumValue audioscale_methods[] = {
- { GST_RESAMPLE_NEAREST, "0", "Nearest" },
- { GST_RESAMPLE_BILINEAR, "1", "Bilinear" },
- { GST_RESAMPLE_SINC, "2", "Sinc" },
- { 0, NULL, NULL },
+ {GST_RESAMPLE_NEAREST, "0", "Nearest"},
+ {GST_RESAMPLE_BILINEAR, "1", "Bilinear"},
+ {GST_RESAMPLE_SINC, "2", "Sinc"},
+ {0, NULL, NULL},
};
- if(!audioscale_method_type){
- audioscale_method_type = g_enum_register_static("GstAudioscaleMethod",
- audioscale_methods);
+ if (!audioscale_method_type) {
+ audioscale_method_type = g_enum_register_static ("GstAudioscaleMethod",
+ audioscale_methods);
}
return audioscale_method_type;
}
-static void gst_audioscale_base_init (gpointer g_class);
-static void gst_audioscale_class_init (AudioscaleClass *klass);
-static void gst_audioscale_init (Audioscale *audioscale);
+static void gst_audioscale_base_init (gpointer g_class);
+static void gst_audioscale_class_init (AudioscaleClass * klass);
+static void gst_audioscale_init (Audioscale * audioscale);
-static void gst_audioscale_chain (GstPad *pad, GstData *_data);
+static void gst_audioscale_chain (GstPad * pad, GstData * _data);
static void gst_audioscale_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
+ const GValue * value, GParamSpec * pspec);
static void gst_audioscale_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
if (!audioscale_type) {
static const GTypeInfo audioscale_info = {
- sizeof(AudioscaleClass),
+ sizeof (AudioscaleClass),
gst_audioscale_base_init,
NULL,
- (GClassInitFunc)gst_audioscale_class_init,
+ (GClassInitFunc) gst_audioscale_class_init,
NULL,
NULL,
- sizeof(Audioscale),
+ sizeof (Audioscale),
0,
- (GInstanceInitFunc)gst_audioscale_init,
+ (GInstanceInitFunc) gst_audioscale_init,
};
- audioscale_type = g_type_register_static(GST_TYPE_ELEMENT, "Audioscale", &audioscale_info, 0);
+ audioscale_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "Audioscale",
+ &audioscale_info, 0);
}
return audioscale_type;
}
}
static void
-gst_audioscale_class_init (AudioscaleClass *klass)
+gst_audioscale_class_init (AudioscaleClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_audioscale_set_property;
gobject_class->get_property = gst_audioscale_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILTERLEN,
- g_param_spec_int ("filter_length", "filter_length", "filter_length",
- 0, G_MAXINT, 16, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+ g_param_spec_int ("filter_length", "filter_length", "filter_length",
+ 0, G_MAXINT, 16, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_METHOD,
- g_param_spec_enum ("method", "method", "method", GST_TYPE_AUDIOSCALE_METHOD,
- GST_RESAMPLE_SINC, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+ g_param_spec_enum ("method", "method", "method",
+ GST_TYPE_AUDIOSCALE_METHOD, GST_RESAMPLE_SINC,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static GstCaps *
-gst_audioscale_getcaps (GstPad *pad)
+gst_audioscale_getcaps (GstPad * pad)
{
Audioscale *audioscale;
GstCaps *caps;
audioscale = GST_AUDIOSCALE (gst_pad_get_parent (pad));
otherpad = (pad == audioscale->srcpad) ? audioscale->sinkpad :
- audioscale->srcpad;
+ audioscale->srcpad;
caps = gst_pad_get_allowed_caps (otherpad);
/* we do this hack, because the audioscale lib doesn't handle
* rate conversions larger than a factor of 2 */
- for (i=0;i<gst_caps_get_size(caps);i++){
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
int rate_min, rate_max;
GstStructure *structure = gst_caps_get_structure (caps, i);
const GValue *value;
value = gst_structure_get_value (structure, "rate");
- if (value == NULL) return NULL;
+ if (value == NULL)
+ return NULL;
if (G_VALUE_TYPE (value) == G_TYPE_INT) {
rate_min = g_value_get_int (value);
}
rate_min /= 2;
- if (rate_max < G_MAXINT/2){
- rate_max *=2;
+ if (rate_max < G_MAXINT / 2) {
+ rate_max *= 2;
} else {
rate_max = G_MAXINT;
}
r = audioscale->gst_resample;
otherpad = (pad == audioscale->srcpad) ? audioscale->sinkpad
- : audioscale->srcpad;
+ : audioscale->srcpad;
structure = gst_caps_get_structure (caps, 0);
ret &= gst_structure_get_int (structure, "channels", &channels);
link_ret = gst_pad_try_set_caps (otherpad, gst_caps_copy (caps));
- if (GST_PAD_LINK_SUCCESSFUL (link_ret)){
+ if (GST_PAD_LINK_SUCCESSFUL (link_ret)) {
audioscale->passthru = TRUE;
r->channels = channels;
r->i_rate = rate;
GstCaps *trycaps = gst_caps_copy (caps);
gst_caps_set_simple (trycaps,
- "rate", G_TYPE_INT,
- (int)((pad == audioscale->srcpad) ? r->i_rate : r->o_rate),
- NULL);
+ "rate", G_TYPE_INT,
+ (int) ((pad == audioscale->srcpad) ? r->i_rate : r->o_rate), NULL);
link_ret = gst_pad_try_set_caps (otherpad, trycaps);
- if (GST_PAD_LINK_FAILED (link_ret)){
+ if (GST_PAD_LINK_FAILED (link_ret)) {
return link_ret;
}
}
} else {
r->i_rate = rate;
}
- gst_resample_reinit(r);
+ gst_resample_reinit (r);
return GST_PAD_LINK_OK;
}
static void *
gst_audioscale_get_buffer (void *priv, unsigned int size)
{
- Audioscale * audioscale = priv;
+ Audioscale *audioscale = priv;
- audioscale->outbuf = gst_buffer_new();
- GST_BUFFER_SIZE(audioscale->outbuf) = size;
- GST_BUFFER_DATA(audioscale->outbuf) = g_malloc(size);
- GST_BUFFER_TIMESTAMP(audioscale->outbuf) = audioscale->offset * GST_SECOND / audioscale->gst_resample->o_rate;
- audioscale->offset += size / sizeof(gint16) / audioscale->gst_resample->channels;
+ audioscale->outbuf = gst_buffer_new ();
+ GST_BUFFER_SIZE (audioscale->outbuf) = size;
+ GST_BUFFER_DATA (audioscale->outbuf) = g_malloc (size);
+ GST_BUFFER_TIMESTAMP (audioscale->outbuf) =
+ audioscale->offset * GST_SECOND / audioscale->gst_resample->o_rate;
+ audioscale->offset +=
+ size / sizeof (gint16) / audioscale->gst_resample->channels;
- return GST_BUFFER_DATA(audioscale->outbuf);
+ return GST_BUFFER_DATA (audioscale->outbuf);
}
static void
-gst_audioscale_init (Audioscale *audioscale)
+gst_audioscale_init (Audioscale * audioscale)
{
gst_resample_t *r;
- audioscale->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_audioscale_sink_template), "sink");
- gst_element_add_pad(GST_ELEMENT(audioscale),audioscale->sinkpad);
- gst_pad_set_chain_function(audioscale->sinkpad,gst_audioscale_chain);
+ audioscale->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_audioscale_sink_template), "sink");
+ gst_element_add_pad (GST_ELEMENT (audioscale), audioscale->sinkpad);
+ gst_pad_set_chain_function (audioscale->sinkpad, gst_audioscale_chain);
gst_pad_set_link_function (audioscale->sinkpad, gst_audioscale_link);
gst_pad_set_getcaps_function (audioscale->sinkpad, gst_audioscale_getcaps);
- audioscale->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_audioscale_src_template), "src");
+ audioscale->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_audioscale_src_template), "src");
- gst_element_add_pad(GST_ELEMENT(audioscale),audioscale->srcpad);
+ gst_element_add_pad (GST_ELEMENT (audioscale), audioscale->srcpad);
gst_pad_set_link_function (audioscale->srcpad, gst_audioscale_link);
gst_pad_set_getcaps_function (audioscale->srcpad, gst_audioscale_getcaps);
- r = g_new0(gst_resample_t,1);
+ r = g_new0 (gst_resample_t, 1);
audioscale->gst_resample = r;
r->priv = audioscale;
r->format = GST_RESAMPLE_S16;
/*r->verbose = 1; */
- gst_resample_init(r);
+ gst_resample_init (r);
/* we will be reinitialized when the G_PARAM_CONSTRUCTs hit */
}
static void
-gst_audioscale_chain (GstPad *pad, GstData *_data)
+gst_audioscale_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
Audioscale *audioscale;
guchar *data;
gulong size;
- 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);
audioscale = GST_AUDIOSCALE (gst_pad_get_parent (pad));
- if (audioscale->passthru){
+ if (audioscale->passthru) {
gst_pad_push (audioscale->srcpad, GST_DATA (buf));
return;
}
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
GST_DEBUG ("gst_audioscale_chain: got buffer of %ld bytes in '%s'\n",
size, gst_element_get_name (GST_ELEMENT (audioscale)));
static void
gst_audioscale_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
+ const GValue * value, GParamSpec * pspec)
{
Audioscale *src;
gst_resample_t *r;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_AUDIOSCALE(object));
- src = GST_AUDIOSCALE(object);
+ g_return_if_fail (GST_IS_AUDIOSCALE (object));
+ src = GST_AUDIOSCALE (object);
r = src->gst_resample;
switch (prop_id) {
case ARG_FILTERLEN:
r->filter_length = g_value_get_int (value);
- GST_DEBUG_OBJECT (GST_ELEMENT(src), "new filter length %d\n", r->filter_length);
+ GST_DEBUG_OBJECT (GST_ELEMENT (src), "new filter length %d\n",
+ r->filter_length);
break;
case ARG_METHOD:
r->method = g_value_get_enum (value);
}
static void
-gst_audioscale_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_audioscale_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
Audioscale *src;
gst_resample_t *r;
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* load support library */
if (!gst_library_load ("gstresample"))
return FALSE;
if (!gst_element_register (plugin, "audioscale", GST_RANK_NONE,
- GST_TYPE_AUDIOSCALE)) {
+ GST_TYPE_AUDIOSCALE)) {
return FALSE;
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "audioscale",
- "Resamples audio",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "audioscale",
+ "Resamples audio", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
G_BEGIN_DECLS
-
-
#define GST_TYPE_AUDIOSCALE \
(audioscale_get_type())
#define GST_AUDIOSCALE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIOSCALE))
#define GST_IS_AUDIOSCALE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOSCALE))
-
-typedef enum {
+ typedef enum
+{
GST_AUDIOSCALE_NEAREST,
GST_AUDIOSCALE_BILINEAR,
GST_AUDIOSCALE_SINC,
typedef struct _Audioscale Audioscale;
typedef struct _AudioscaleClass AudioscaleClass;
-struct _Audioscale {
+struct _Audioscale
+{
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
/* audio state */
gboolean passthru;
GstBuffer *outbuf;
};
-struct _AudioscaleClass {
+struct _AudioscaleClass
+{
GstElementClass parent_class;
};
-GType gst_audioscale_get_type(void);
+GType gst_audioscale_get_type (void);
G_END_DECLS
-
-
#endif /* __AUDIOSCALE_H__ */
#define ZERO(mem) memset(&mem, 0, sizeof(mem))
-static gint quit_live(GtkWidget *window, GdkEventAny *e, gpointer data)
+static gint
+quit_live (GtkWidget * window, GdkEventAny * e, gpointer data)
{
- gtk_main_quit();
+ gtk_main_quit ();
return FALSE;
}
-static void dynparm_log_value_changed(GtkAdjustment *adj,GstDParam *dparam)
+static void
+dynparm_log_value_changed (GtkAdjustment * adj, GstDParam * dparam)
{
gdouble value;
- g_return_if_fail(dparam != NULL);
- g_return_if_fail(GST_IS_DPARAM (dparam));
- value = exp(adj->value);
-
- g_print("setting value to %f\n", value);
- g_object_set(G_OBJECT(dparam), "value_double", value, NULL);
+ g_return_if_fail (dparam != NULL);
+ g_return_if_fail (GST_IS_DPARAM (dparam));
+
+ value = exp (adj->value);
+
+ g_print ("setting value to %f\n", value);
+ g_object_set (G_OBJECT (dparam), "value_double", value, NULL);
}
-static void dynparm_value_changed(GtkAdjustment *adj,GstDParam *dparam)
+static void
+dynparm_value_changed (GtkAdjustment * adj, GstDParam * dparam)
{
- g_return_if_fail(dparam != NULL);
- g_return_if_fail(GST_IS_DPARAM (dparam));
+ g_return_if_fail (dparam != NULL);
+ g_return_if_fail (GST_IS_DPARAM (dparam));
- g_print("setting value to %f\n", adj->value);
- g_object_set(G_OBJECT(dparam), "value_double", (gdouble)adj->value, NULL);
+ g_print ("setting value to %f\n", adj->value);
+ g_object_set (G_OBJECT (dparam), "value_double", (gdouble) adj->value, NULL);
}
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GtkWidget *window;
GtkWidget *hbox;
GtkAdjustment *volume_adj;
GstDParam *freq;
GParamSpecDouble *spec;
- gtk_init(&argc,&argv);
- gst_init(&argc,&argv);
- gst_control_init(&argc,&argv);
+ gtk_init (&argc, &argv);
+ gst_init (&argc, &argv);
+ gst_control_init (&argc, &argv);
/***** construct the pipeline *****/
-
- g_print("creating elements\n");
- thread = gst_thread_new("live-example");
- sinesrc = gst_element_factory_make("sinesrc","sine-source");
- osssink = gst_element_factory_make("osssink","sound-sink");
- volfilter = gst_element_factory_make("volume","volume-filter");
- gst_bin_add_many(GST_BIN(thread), sinesrc, volfilter, osssink, NULL);
- gst_element_link_many(sinesrc, volfilter, osssink, NULL);
+
+ g_print ("creating elements\n");
+ thread = gst_thread_new ("live-example");
+ sinesrc = gst_element_factory_make ("sinesrc", "sine-source");
+ osssink = gst_element_factory_make ("osssink", "sound-sink");
+ volfilter = gst_element_factory_make ("volume", "volume-filter");
+ gst_bin_add_many (GST_BIN (thread), sinesrc, volfilter, osssink, NULL);
+ gst_element_link_many (sinesrc, volfilter, osssink, NULL);
/* this breaks with current alsa oss compat lib */
- g_object_set(G_OBJECT(osssink),"fragment",0x00180008,NULL);
- g_object_set(G_OBJECT(osssink),"sync",FALSE,NULL);
+ g_object_set (G_OBJECT (osssink), "fragment", 0x00180008, NULL);
+ g_object_set (G_OBJECT (osssink), "sync", FALSE, NULL);
+
+ g_object_set (G_OBJECT (sinesrc), "samplesperbuffer", 1024, NULL);
- g_object_set(G_OBJECT(sinesrc),"samplesperbuffer",1024,NULL);
-
/***** set up the GUI *****/
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(window), 80, 400);
- g_signal_connect(window,"delete_event",GTK_SIGNAL_FUNC(quit_live),NULL);
- hbox = gtk_hbox_new(TRUE,0);
- gtk_container_add(GTK_CONTAINER(window),hbox);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (window), 80, 400);
+ g_signal_connect (window, "delete_event", GTK_SIGNAL_FUNC (quit_live), NULL);
+ hbox = gtk_hbox_new (TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (window), hbox);
/***** set up the dparams *****/
- freq = gst_dpsmooth_new(G_TYPE_DOUBLE);
-
- g_object_set(G_OBJECT(freq), "update_period", 2000000LL, NULL);
-
+ freq = gst_dpsmooth_new (G_TYPE_DOUBLE);
+
+ g_object_set (G_OBJECT (freq), "update_period", 2000000LL, NULL);
+
/* this defines the maximum slope that this *
- * param can change. This says that in 50ms *
- * the value can change by a maximum of one semitone *
- * (the log of one semitone is 0.693) */
- g_object_set(G_OBJECT(freq), "slope_delta_double", 0.693, NULL);
- g_object_set(G_OBJECT(freq), "slope_time", 50000000LL, NULL);
-
+ * param can change. This says that in 50ms *
+ * the value can change by a maximum of one semitone *
+ * (the log of one semitone is 0.693) */
+ g_object_set (G_OBJECT (freq), "slope_delta_double", 0.693, NULL);
+ g_object_set (G_OBJECT (freq), "slope_time", 50000000LL, NULL);
+
dpman = gst_dpman_get_manager (sinesrc);
- g_assert(gst_dpman_attach_dparam (dpman, "freq", freq));
- gst_dpman_set_mode(dpman, "asynchronous");
-
- spec = (GParamSpecDouble*)gst_dpman_get_param_spec (dpman, "freq");
- freq_adj = (GtkAdjustment*)gtk_adjustment_new(log(spec->default_value),
- log(spec->minimum), log(spec->maximum), 0.1, 0.01, 0.01);
-
-
- freq_slider = gtk_vscale_new(freq_adj);
- gtk_scale_set_digits(GTK_SCALE(freq_slider), 2);
- gtk_box_pack_start(GTK_BOX(hbox),freq_slider,TRUE,TRUE,0);
-
- volume = gst_dpsmooth_new(G_TYPE_DOUBLE);
-
- g_object_set(G_OBJECT(volume), "update_period", 2000000LL, NULL);
-
+ g_assert (gst_dpman_attach_dparam (dpman, "freq", freq));
+ gst_dpman_set_mode (dpman, "asynchronous");
+
+ spec = (GParamSpecDouble *) gst_dpman_get_param_spec (dpman, "freq");
+ freq_adj = (GtkAdjustment *) gtk_adjustment_new (log (spec->default_value),
+ log (spec->minimum), log (spec->maximum), 0.1, 0.01, 0.01);
+
+
+ freq_slider = gtk_vscale_new (freq_adj);
+ gtk_scale_set_digits (GTK_SCALE (freq_slider), 2);
+ gtk_box_pack_start (GTK_BOX (hbox), freq_slider, TRUE, TRUE, 0);
+
+ volume = gst_dpsmooth_new (G_TYPE_DOUBLE);
+
+ g_object_set (G_OBJECT (volume), "update_period", 2000000LL, NULL);
+
/* this defines the maximum slope that this *
- * param can change. This says that in 50ms *
- * the value can change from 0.0 to 1.0 */
- g_object_set(G_OBJECT(volume), "slope_delta_double", 0.1, NULL);
- g_object_set(G_OBJECT(volume), "slope_time", 50000000LL, NULL);
-
+ * param can change. This says that in 50ms *
+ * the value can change from 0.0 to 1.0 */
+ g_object_set (G_OBJECT (volume), "slope_delta_double", 0.1, NULL);
+ g_object_set (G_OBJECT (volume), "slope_time", 50000000LL, NULL);
+
dpman = gst_dpman_get_manager (volfilter);
- g_assert(gst_dpman_attach_dparam (dpman, "volume", volume));
- gst_dpman_set_mode(dpman, "asynchronous");
-
- g_object_set(G_OBJECT(volfilter), "mute", FALSE, NULL);
-
- spec = (GParamSpecDouble*)gst_dpman_get_param_spec (dpman, "volume");
- volume_adj = (GtkAdjustment*)gtk_adjustment_new(spec->default_value, 0.0, 1.2, 0.1, 0.01, 0.01);
- volume_slider = gtk_vscale_new(volume_adj);
- gtk_scale_set_digits(GTK_SCALE(volume_slider), 2);
- gtk_box_pack_start(GTK_BOX(hbox),volume_slider,TRUE,TRUE,0);
-
+ g_assert (gst_dpman_attach_dparam (dpman, "volume", volume));
+ gst_dpman_set_mode (dpman, "asynchronous");
+
+ g_object_set (G_OBJECT (volfilter), "mute", FALSE, NULL);
+
+ spec = (GParamSpecDouble *) gst_dpman_get_param_spec (dpman, "volume");
+ volume_adj =
+ (GtkAdjustment *) gtk_adjustment_new (spec->default_value, 0.0, 1.2, 0.1,
+ 0.01, 0.01);
+ volume_slider = gtk_vscale_new (volume_adj);
+ gtk_scale_set_digits (GTK_SCALE (volume_slider), 2);
+ gtk_box_pack_start (GTK_BOX (hbox), volume_slider, TRUE, TRUE, 0);
+
/***** set up the handlers and such *****/
/*gtk_signal_connect(volume_adj,"value-changed",GTK_SIGNAL_FUNC(volume_changed),sinesrc); */
- g_signal_connect(volume_adj,"value-changed",
- GTK_SIGNAL_FUNC(dynparm_value_changed),
- volume);
-
- g_signal_connect(freq_adj,"value-changed",
- GTK_SIGNAL_FUNC(dynparm_log_value_changed),
- freq);
- gtk_adjustment_value_changed(volume_adj);
- gtk_adjustment_value_changed(freq_adj);
-
- g_print("starting pipeline\n");
-
+ g_signal_connect (volume_adj, "value-changed",
+ GTK_SIGNAL_FUNC (dynparm_value_changed), volume);
+
+ g_signal_connect (freq_adj, "value-changed",
+ GTK_SIGNAL_FUNC (dynparm_log_value_changed), freq);
+ gtk_adjustment_value_changed (volume_adj);
+ gtk_adjustment_value_changed (freq_adj);
+
+ g_print ("starting pipeline\n");
+
/***** start everything up *****/
- gst_element_set_state(thread,GST_STATE_PLAYING);
+ gst_element_set_state (thread, GST_STATE_PLAYING);
+
+ gtk_widget_show_all (window);
+ gtk_main ();
- gtk_widget_show_all(window);
- gtk_main();
-
return 0;
}
/* SineSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_TABLESIZE,
ARG_SAMPLES_PER_BUFFER,
};
static GstStaticPadTemplate gst_sinesrc_src_template =
-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) [ 8000, 48000 ], "
- "channels = (int) 1"
- )
-);
-
-static void gst_sinesrc_class_init (GstSineSrcClass *klass);
-static void gst_sinesrc_base_init (GstSineSrcClass *klass);
-static void gst_sinesrc_init (GstSineSrc *src);
-static void gst_sinesrc_dispose (GObject *object);
-static void gst_sinesrc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_sinesrc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstPadLinkReturn
- gst_sinesrc_link (GstPad *pad,
- const GstCaps *caps);
-static GstElementStateReturn
- gst_sinesrc_change_state (GstElement *element);
-static void gst_sinesrc_set_clock (GstElement *element, GstClock *clock);
-
-static void gst_sinesrc_update_freq (const GValue *value,
- gpointer data);
-static void gst_sinesrc_populate_sinetable (GstSineSrc *src);
-static inline void gst_sinesrc_update_table_inc (GstSineSrc *src);
-
-static const GstQueryType *
- gst_sinesrc_get_query_types (GstPad *pad);
-static gboolean gst_sinesrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
-
-static GstData* gst_sinesrc_get (GstPad *pad);
-static GstCaps * gst_sinesrc_src_fixate (GstPad *pad, const GstCaps *caps);
+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) [ 8000, 48000 ], " "channels = (int) 1")
+ );
+
+static void gst_sinesrc_class_init (GstSineSrcClass * klass);
+static void gst_sinesrc_base_init (GstSineSrcClass * klass);
+static void gst_sinesrc_init (GstSineSrc * src);
+static void gst_sinesrc_dispose (GObject * object);
+static void gst_sinesrc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_sinesrc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstPadLinkReturn gst_sinesrc_link (GstPad * pad, const GstCaps * caps);
+static GstElementStateReturn gst_sinesrc_change_state (GstElement * element);
+static void gst_sinesrc_set_clock (GstElement * element, GstClock * clock);
+
+static void gst_sinesrc_update_freq (const GValue * value, gpointer data);
+static void gst_sinesrc_populate_sinetable (GstSineSrc * src);
+static inline void gst_sinesrc_update_table_inc (GstSineSrc * src);
+
+static const GstQueryType *gst_sinesrc_get_query_types (GstPad * pad);
+static gboolean gst_sinesrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
+
+static GstData *gst_sinesrc_get (GstPad * pad);
+static GstCaps *gst_sinesrc_src_fixate (GstPad * pad, const GstCaps * caps);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_sinesrc_signals[LAST_SIGNAL] = { 0 }; */
GType
sizeof (GstSineSrc), 0,
(GInstanceInitFunc) gst_sinesrc_init,
};
- sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSineSrc",
- &sinesrc_info, 0);
+ sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSineSrc",
+ &sinesrc_info, 0);
}
return sinesrc_type;
}
static void
-gst_sinesrc_base_init (GstSineSrcClass *klass)
+gst_sinesrc_base_init (GstSineSrcClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_sinesrc_class_init (GstSineSrcClass *klass)
+gst_sinesrc_class_init (GstSineSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TABLESIZE,
- g_param_spec_int ("tablesize", "tablesize", "tablesize",
- 1, G_MAXINT, 1024, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass),
- ARG_SAMPLES_PER_BUFFER,
- g_param_spec_int ("samplesperbuffer", "Samples per buffer",
- "Number of samples in each outgoing buffer",
- 1, G_MAXINT, 1024, G_PARAM_READWRITE));
+ g_param_spec_int ("tablesize", "tablesize", "tablesize",
+ 1, G_MAXINT, 1024, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_SAMPLES_PER_BUFFER,
+ g_param_spec_int ("samplesperbuffer", "Samples per buffer",
+ "Number of samples in each outgoing buffer",
+ 1, G_MAXINT, 1024, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FREQ,
- g_param_spec_double ("freq", "Frequency", "Frequency of sine source",
- 0.0, 20000.0, 440.0, G_PARAM_READWRITE));
+ g_param_spec_double ("freq", "Frequency", "Frequency of sine source",
+ 0.0, 20000.0, 440.0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VOLUME,
- g_param_spec_double ("volume", "Volume", "Volume",
- 0.0, 1.0, 0.8, G_PARAM_READWRITE));
+ g_param_spec_double ("volume", "Volume", "Volume",
+ 0.0, 1.0, 0.8, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Synchronize to clock",
- FALSE, G_PARAM_READWRITE));
-
+ FALSE, G_PARAM_READWRITE));
+
gobject_class->set_property = gst_sinesrc_set_property;
gobject_class->get_property = gst_sinesrc_get_property;
gobject_class->dispose = gst_sinesrc_dispose;
gstelement_class->set_clock = gst_sinesrc_set_clock;
}
-static void
-gst_sinesrc_init (GstSineSrc *src)
+static void
+gst_sinesrc_init (GstSineSrc * src)
{
- src->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_sinesrc_src_template), "src");
+ src->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_sinesrc_src_template), "src");
gst_pad_set_link_function (src->srcpad, gst_sinesrc_link);
gst_pad_set_fixate_function (src->srcpad, gst_sinesrc_src_fixate);
gst_pad_set_get_function (src->srcpad, gst_sinesrc_get);
gst_pad_set_query_function (src->srcpad, gst_sinesrc_src_query);
gst_pad_set_query_type_function (src->srcpad, gst_sinesrc_get_query_types);
- gst_element_add_pad (GST_ELEMENT(src), src->srcpad);
-
+ gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
+
src->samplerate = 44100;
src->volume = 1.0;
src->freq = 440.0;
src->sync = FALSE;
-
+
src->table_pos = 0.0;
src->table_size = 1024;
- src->samples_per_buffer=1024;
- src->timestamp=0LLU;
- src->offset=0LLU;
-
+ src->samples_per_buffer = 1024;
+ src->timestamp = 0LLU;
+ src->offset = 0LLU;
+
src->seq = 0;
- src->dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src));
-
- gst_dpman_add_required_dparam_callback (
- src->dpman,
- g_param_spec_double("freq","Frequency (Hz)","Frequency of the tone",
- 10.0, 10000.0, 350.0, G_PARAM_READWRITE),
- "hertz",
- gst_sinesrc_update_freq,
- src
- );
-
- gst_dpman_add_required_dparam_direct (
- src->dpman,
- g_param_spec_double("volume","Volume","Volume of the tone",
- 0.0, 1.0, 0.8, G_PARAM_READWRITE),
- "scalar",
- &(src->volume)
- );
-
- gst_dpman_set_rate(src->dpman, src->samplerate);
-
- gst_sinesrc_populate_sinetable(src);
- gst_sinesrc_update_table_inc(src);
+ src->dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT (src));
+
+ gst_dpman_add_required_dparam_callback (src->dpman,
+ g_param_spec_double ("freq", "Frequency (Hz)", "Frequency of the tone",
+ 10.0, 10000.0, 350.0, G_PARAM_READWRITE),
+ "hertz", gst_sinesrc_update_freq, src);
+
+ gst_dpman_add_required_dparam_direct (src->dpman,
+ g_param_spec_double ("volume", "Volume", "Volume of the tone",
+ 0.0, 1.0, 0.8, G_PARAM_READWRITE), "scalar", &(src->volume)
+ );
+
+ gst_dpman_set_rate (src->dpman, src->samplerate);
+
+ gst_sinesrc_populate_sinetable (src);
+ gst_sinesrc_update_table_inc (src);
}
static void
-gst_sinesrc_dispose (GObject *object)
+gst_sinesrc_dispose (GObject * object)
{
GstSineSrc *sinesrc = GST_SINESRC (object);
g_free (sinesrc->table_data);
sinesrc->table_data = NULL;
-
+
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
static void
-gst_sinesrc_set_clock (GstElement *element, GstClock *clock)
+gst_sinesrc_set_clock (GstElement * element, GstClock * clock)
{
GstSineSrc *sinesrc = GST_SINESRC (element);
- gst_object_replace ((GstObject **)&sinesrc->clock, (GstObject *)clock);
+ gst_object_replace ((GstObject **) & sinesrc->clock, (GstObject *) clock);
}
static GstCaps *
-gst_sinesrc_src_fixate (GstPad *pad, const GstCaps *caps)
+gst_sinesrc_src_fixate (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstCaps *newcaps;
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
}
static GstPadLinkReturn
-gst_sinesrc_link (GstPad *pad, const GstCaps *caps)
+gst_sinesrc_link (GstPad * pad, const GstCaps * caps)
{
GstSineSrc *sinesrc;
const GstStructure *structure;
ret = gst_structure_get_int (structure, "rate", &sinesrc->samplerate);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
}
static const GstQueryType *
-gst_sinesrc_get_query_types (GstPad *pad)
+gst_sinesrc_get_query_types (GstPad * pad)
{
static const GstQueryType query_types[] = {
GST_QUERY_POSITION,
};
return query_types;
-}
+}
static gboolean
-gst_sinesrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value)
+gst_sinesrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value)
{
gboolean res = FALSE;
GstSineSrc *src;
-
+
src = GST_SINESRC (gst_pad_get_parent (pad));
-
+
switch (type) {
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = src->timestamp;
- res = TRUE;
- break;
- case GST_FORMAT_DEFAULT: /* samples */
- *value = src->offset / 2; /* 16bpp audio */
- res = TRUE;
- break;
- case GST_FORMAT_BYTES:
- *value = src->offset;
- res = TRUE;
- break;
- default:
- break;
+ case GST_FORMAT_TIME:
+ *value = src->timestamp;
+ res = TRUE;
+ break;
+ case GST_FORMAT_DEFAULT: /* samples */
+ *value = src->offset / 2; /* 16bpp audio */
+ res = TRUE;
+ break;
+ case GST_FORMAT_BYTES:
+ *value = src->offset;
+ res = TRUE;
+ break;
+ default:
+ break;
}
break;
default:
}
static GstData *
-gst_sinesrc_get (GstPad *pad)
+gst_sinesrc_get (GstPad * pad)
{
GstSineSrc *src;
GstBuffer *buf;
guint tdiff;
-
+
gint16 *samples;
- gint i=0;
-
+ gint i = 0;
+
g_return_val_if_fail (pad != NULL, NULL);
src = GST_SINESRC (gst_pad_get_parent (pad));
taglist = gst_tag_list_new ();
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND,
- GST_TAG_DESCRIPTION, "sine wave", NULL);
+ GST_TAG_DESCRIPTION, "sine wave", NULL);
gst_element_found_tags (GST_ELEMENT (src), taglist);
event = gst_event_new_tag (taglist);
/* note: the 2 is because of the format we use */
buf = gst_buffer_new_and_alloc (src->samples_per_buffer * 2);
- GST_BUFFER_TIMESTAMP(buf) = src->timestamp;
+ GST_BUFFER_TIMESTAMP (buf) = src->timestamp;
if (src->sync) {
if (src->clock) {
- gst_element_wait (GST_ELEMENT(src), GST_BUFFER_TIMESTAMP (buf));
+ gst_element_wait (GST_ELEMENT (src), GST_BUFFER_TIMESTAMP (buf));
}
}
GST_BUFFER_OFFSET (buf) = src->offset;
GST_BUFFER_DURATION (buf) = tdiff;
- samples = (gint16 *) GST_BUFFER_DATA(buf);
+ samples = (gint16 *) GST_BUFFER_DATA (buf);
+
+ GST_DPMAN_PREPROCESS (src->dpman, src->samples_per_buffer, src->timestamp);
- GST_DPMAN_PREPROCESS(src->dpman, src->samples_per_buffer, src->timestamp);
-
src->timestamp += tdiff;
src->offset += GST_BUFFER_SIZE (buf);
-
- while(GST_DPMAN_PROCESS(src->dpman, i)) {
+
+ while (GST_DPMAN_PROCESS (src->dpman, i)) {
#if 0
- src->table_lookup = (gint)(src->table_pos);
+ src->table_lookup = (gint) (src->table_pos);
src->table_lookup_next = src->table_lookup + 1;
src->table_interp = src->table_pos - src->table_lookup;
/* wrap the array lookups if we're out of bounds */
- if (src->table_lookup_next >= src->table_size){
+ if (src->table_lookup_next >= src->table_size) {
src->table_lookup_next -= src->table_size;
- if (src->table_lookup >= src->table_size){
- src->table_lookup -= src->table_size;
- src->table_pos -= src->table_size;
+ if (src->table_lookup >= src->table_size) {
+ src->table_lookup -= src->table_size;
+ src->table_pos -= src->table_size;
}
}
-
+
src->table_pos += src->table_inc;
/*no interpolation */
/* * src->volume * 32767.0; */
/*linear interpolation */
- samples[i] = ((src->table_interp
- *(src->table_data[src->table_lookup_next]
- -src->table_data[src->table_lookup]
- )
- )+src->table_data[src->table_lookup]
- )* src->volume * 32767.0;
+ samples[i] = ((src->table_interp * (src->table_data[src->table_lookup_next]
+ - src->table_data[src->table_lookup]
+ )
+ ) + src->table_data[src->table_lookup]
+ ) * src->volume * 32767.0;
#endif
- src->accumulator += 2*M_PI*src->freq / src->samplerate;
- if(src->accumulator >= 2*M_PI){
- src->accumulator -= 2*M_PI;
+ src->accumulator += 2 * M_PI * src->freq / src->samplerate;
+ if (src->accumulator >= 2 * M_PI) {
+ src->accumulator -= 2 * M_PI;
}
- samples[i] = sin(src->accumulator) * src->volume * 32767.0;
+ samples[i] = sin (src->accumulator) * src->volume * 32767.0;
i++;
}
if (!GST_PAD_CAPS (src->srcpad)) {
if (gst_sinesrc_link (src->srcpad,
- gst_pad_get_allowed_caps (src->srcpad)) <= 0) {
+ gst_pad_get_allowed_caps (src->srcpad)) <= 0) {
GST_ELEMENT_ERROR (src, CORE, NEGOTIATION, (NULL), (NULL));
return NULL;
}
return GST_DATA (buf);
}
-static void
-gst_sinesrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+static void
+gst_sinesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSineSrc *src;
break;
case ARG_FREQ:
gst_dpman_bypass_dparam (src->dpman, "freq");
- gst_sinesrc_update_freq (value, src);
+ gst_sinesrc_update_freq (value, src);
break;
case ARG_VOLUME:
gst_dpman_bypass_dparam (src->dpman, "volume");
}
}
-static void
-gst_sinesrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+gst_sinesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstSineSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SINESRC(object));
- src = GST_SINESRC(object);
+ g_return_if_fail (GST_IS_SINESRC (object));
+ src = GST_SINESRC (object);
switch (prop_id) {
case ARG_TABLESIZE:
break;
case ARG_VOLUME:
g_value_set_double (value, src->volume);
- break;
+ break;
case ARG_SYNC:
g_value_set_boolean (value, src->sync);
break;
}
static GstElementStateReturn
-gst_sinesrc_change_state (GstElement *element)
+gst_sinesrc_change_state (GstElement * element)
{
GstSineSrc *src = GST_SINESRC (element);
break;
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state (element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
-static void
-gst_sinesrc_populate_sinetable (GstSineSrc *src)
+static void
+gst_sinesrc_populate_sinetable (GstSineSrc * src)
{
gint i;
gdouble pi2scaled = M_PI * 2 / src->table_size;
gdouble *table = g_new (gdouble, src->table_size);
- for(i=0 ; i < src->table_size ; i++){
- table[i] = (gdouble) sin(i * pi2scaled);
+ for (i = 0; i < src->table_size; i++) {
+ table[i] = (gdouble) sin (i * pi2scaled);
}
-
+
g_free (src->table_data);
src->table_data = table;
}
static void
-gst_sinesrc_update_freq (const GValue *value, gpointer data)
+gst_sinesrc_update_freq (const GValue * value, gpointer data)
{
GstSineSrc *src = (GstSineSrc *) data;
+
g_return_if_fail (GST_IS_SINESRC (src));
src->freq = g_value_get_double (value);
src->table_inc = src->table_size * src->freq / src->samplerate;
-
+
/*GST_DEBUG ("freq %f", src->freq); */
}
-static inline void
-gst_sinesrc_update_table_inc (GstSineSrc *src)
+static inline void
+gst_sinesrc_update_table_inc (GstSineSrc * src)
{
src->table_inc = src->table_size * src->freq / src->samplerate;
}
#if 0
-static gboolean
-gst_sinesrc_force_caps (GstSineSrc *src)
+static gboolean
+gst_sinesrc_force_caps (GstSineSrc * src)
{
static GstStaticCaps static_caps = GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
- "rate = (int) [ 8000, 48000 ], "
- "channels = (int) 1"
- );
+ "rate = (int) [ 8000, 48000 ], " "channels = (int) 1");
GstCaps *caps;
GstStructure *structure;
if (!src->newcaps)
return TRUE;
-
+
caps = gst_caps_copy (gst_static_caps_get (&static_caps));
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "rate", G_TYPE_INT, src->samplerate, NULL);
-
+
src->newcaps = gst_pad_try_set_caps (src->srcpad, caps) < GST_PAD_LINK_OK;
return !src->newcaps;
#endif
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* initialize dparam support library */
- gst_control_init(NULL,NULL);
+ gst_control_init (NULL, NULL);
return gst_element_register (plugin, "sinesrc",
- GST_RANK_NONE, GST_TYPE_SINESRC);
+ GST_RANK_NONE, GST_TYPE_SINESRC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "sine",
- "Sine audio wave generator",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "sine",
+ "Sine audio wave generator",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-
-GstElementDetails gst_sinesrc_details;
+G_BEGIN_DECLS GstElementDetails gst_sinesrc_details;
#define GST_TYPE_SINESRC \
typedef struct _GstSineSrc GstSineSrc;
typedef struct _GstSineSrcClass GstSineSrcClass;
-struct _GstSineSrc {
+struct _GstSineSrc
+{
GstElement element;
/* pads */
gdouble volume;
gdouble freq;
gboolean sync;
-
+
/* lookup table data */
gdouble *table_data;
gdouble table_pos;
gdouble table_interp;
gint table_lookup;
gint table_lookup_next;
-
+
/* audio parameters */
gint samplerate;
gint samples_per_buffer;
gulong seq;
-
+
guint64 timestamp;
guint64 offset;
GstClock *clock;
};
-struct _GstSineSrcClass {
+struct _GstSineSrcClass
+{
GstElementClass parent_class;
};
-GType gst_sinesrc_get_type(void);
-gboolean gst_sinesrc_factory_init (GstElementFactory *factory);
+GType gst_sinesrc_get_type (void);
+gboolean gst_sinesrc_factory_init (GstElementFactory * factory);
G_END_DECLS
-
-
#endif /* __GST_SINESRC_H__ */
};
static GstTagEntryMatch tag_matches[] = {
- { GST_TAG_TITLE, "TIT2" },
- { GST_TAG_ALBUM, "TALB" },
- { GST_TAG_TRACK_NUMBER, "TRCK" },
- { GST_TAG_ARTIST, "TPE1" },
- { GST_TAG_COPYRIGHT, "TCOP" },
- { GST_TAG_GENRE, "TCON" },
- { GST_TAG_DATE, "TDRC" },
- { GST_TAG_COMMENT, "COMM" },
- { GST_TAG_ALBUM_VOLUME_NUMBER, "TPOS" },
- { GST_TAG_DURATION, "TLEN" },
- { NULL, NULL }
+ {GST_TAG_TITLE, "TIT2"},
+ {GST_TAG_ALBUM, "TALB"},
+ {GST_TAG_TRACK_NUMBER, "TRCK"},
+ {GST_TAG_ARTIST, "TPE1"},
+ {GST_TAG_COPYRIGHT, "TCOP"},
+ {GST_TAG_GENRE, "TCON"},
+ {GST_TAG_DATE, "TDRC"},
+ {GST_TAG_COMMENT, "COMM"},
+ {GST_TAG_ALBUM_VOLUME_NUMBER, "TPOS"},
+ {GST_TAG_DURATION, "TLEN"},
+ {NULL, NULL}
};
+
/**
* gst_tag_from_id3_tag:
* @id3_tag: ID3v2 tag to convert to GStreamer tag
* Returns: The corresponding GStreamer tag or NULL if none exists.
*/
G_CONST_RETURN gchar *
-gst_tag_from_id3_tag (const gchar *id3_tag)
+gst_tag_from_id3_tag (const gchar * id3_tag)
{
int i = 0;
}
return tag_matches[i].gstreamer_tag;
}
+
/**
* gst_tag_to_id3_tag:
* @gst_tag: GStreamer tag to convert to vorbiscomment tag
* Returns: The corresponding ID3v2 tag or NULL if none exists.
*/
G_CONST_RETURN gchar *
-gst_tag_to_id3_tag (const gchar *gst_tag)
+gst_tag_to_id3_tag (const gchar * gst_tag)
{
int i = 0;
if (strcmp (gst_tag, tag_matches[i].gstreamer_tag) == 0) {
return tag_matches[i].original_tag;
}
- i++;
+ i++;
}
-return NULL;
+ return NULL;
}
static void
-gst_tag_extract (GstTagList *list, const gchar *tag, const gchar *start, const guint size)
+gst_tag_extract (GstTagList * list, const gchar * tag, const gchar * start,
+ const guint size)
{
gsize bytes_read;
gchar *conv;
-
+
/* FIXME: better charset detection? */
if (g_utf8_validate (start, size, NULL)) {
conv = g_strchomp (g_strndup (start, size));
conv = g_locale_to_utf8 (start, size, &bytes_read, NULL, NULL);
if (bytes_read != size) {
g_free (conv);
- conv = g_convert (start, size, "UTF-8", "ISO-8859-1", &bytes_read, NULL, NULL);
+ conv =
+ g_convert (start, size, "UTF-8", "ISO-8859-1", &bytes_read, NULL,
+ NULL);
if (bytes_read != size) {
g_free (conv);
return;
}
g_free (conv);
}
+
/**
* gst_tag_list_new_from_id3v1:
* @data: 128 bytes of data containing the ID3v1 tag
* Returns: A new tag list or NULL if the data was not an ID3v1 tag.
*/
GstTagList *
-gst_tag_list_new_from_id3v1 (const guint8 *data)
+gst_tag_list_new_from_id3v1 (const guint8 * data)
{
guint year;
gchar *ystr;
GstTagList *list;
g_return_val_if_fail (data != NULL, NULL);
-
- if (data[0] != 'T' || data[1] != 'A' || data[2] != 'G') return NULL;
+
+ if (data[0] != 'T' || data[1] != 'A' || data[2] != 'G')
+ return NULL;
list = gst_tag_list_new ();
gst_tag_extract (list, GST_TAG_TITLE, &data[3], 30);
gst_tag_extract (list, GST_TAG_ARTIST, &data[33], 30);
g_free (ystr);
if (year > 0) {
GDate *date = g_date_new_dmy (1, 1, year);
+
year = g_date_get_julian (date);
g_date_free (date);
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_DATE, year, NULL);
}
if (data[125] == 0) {
gst_tag_extract (list, GST_TAG_COMMENT, &data[97], 28);
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_TRACK_NUMBER, (guint) data[126], NULL);
+ gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_TRACK_NUMBER,
+ (guint) data[126], NULL);
} else {
gst_tag_extract (list, GST_TAG_COMMENT, &data[97], 30);
}
if (data[127] < gst_tag_id3_genre_count ()) {
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE, gst_tag_id3_genre_get (data[127]), NULL);
+ gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE,
+ gst_tag_id3_genre_get (data[127]), NULL);
}
return list;
}
+
/**
* gst_tag_id3_genre_count:
*
{
return G_N_ELEMENTS (genres);
}
+
/**
* gst_tag_id3_genre_get:
* @id: ID of genre to query
G_CONST_RETURN gchar *
gst_tag_id3_genre_get (const guint id)
{
- if (id >= G_N_ELEMENTS (genres)) return NULL;
+ if (id >= G_N_ELEMENTS (genres))
+ return NULL;
return genres[id];
}
-
#include "gsttageditingprivate.h"
#include <gst/gst.h>
-static gboolean
-plugin_init(GstPlugin *plugin)
+static gboolean
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "vorbistag",
- GST_RANK_PRIMARY, gst_vorbis_tag_get_type())) {
+ if (!gst_element_register (plugin, "vorbistag",
+ GST_RANK_PRIMARY, gst_vorbis_tag_get_type ())) {
return FALSE;
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gsttags",
- "elements for manipulating data from ogg streams",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gsttags",
+ "elements for manipulating data from ogg streams",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/tag/tag.h>
-G_BEGIN_DECLS
-
-
-typedef struct _GstTagEntryMatch GstTagEntryMatch;
-struct _GstTagEntryMatch {
- gchar * gstreamer_tag;
- gchar * original_tag;
+G_BEGIN_DECLS typedef struct _GstTagEntryMatch GstTagEntryMatch;
+struct _GstTagEntryMatch
+{
+ gchar *gstreamer_tag;
+ gchar *original_tag;
};
G_END_DECLS
-
#endif /* __GST_TAG_EDIT_PRIVATE_H__ */
typedef struct _GstVorbisTag GstVorbisTag;
typedef struct _GstVorbisTagClass GstVorbisTagClass;
-struct _GstVorbisTag {
- GstElement element;
+struct _GstVorbisTag
+{
+ GstElement element;
/* pads */
- GstPad * sinkpad;
- GstPad * srcpad;
+ GstPad *sinkpad;
+ GstPad *srcpad;
/* output mode */
- guint output;
+ guint output;
};
-struct _GstVorbisTagClass {
+struct _GstVorbisTagClass
+{
GstElementClass parent_class;
};
/* elementfactory information */
-static GstElementDetails gst_vorbis_tag_details = GST_ELEMENT_DETAILS (
- "vorbis tag extractor",
- "Tag",
- "Extract tagging information from vorbis streams",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
-
-enum {
+static GstElementDetails gst_vorbis_tag_details =
+GST_ELEMENT_DETAILS ("vorbis tag extractor",
+ "Tag",
+ "Extract tagging information from vorbis streams",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
+
+enum
+{
OUTPUT_UNKNOWN,
OUTPUT_TAGS,
OUTPUT_DATA
};
/* signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
static GstStaticPadTemplate gst_vorbis_tag_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-vorbis; application/x-gst-tags")
-);
+ GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-vorbis; application/x-gst-tags")
+ );
static GstStaticPadTemplate gst_vorbis_tag_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "audio/x-vorbis" )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-vorbis")
+ );
-static void gst_vorbis_tag_base_init (gpointer g_class);
-static void gst_vorbis_tag_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_vorbis_tag_init (GTypeInstance * instance,
- gpointer g_class);
+static void gst_vorbis_tag_base_init (gpointer g_class);
+static void gst_vorbis_tag_class_init (gpointer g_class, gpointer class_data);
+static void gst_vorbis_tag_init (GTypeInstance * instance, gpointer g_class);
-static void gst_vorbis_tag_chain (GstPad * pad,
- GstData * data);
+static void gst_vorbis_tag_chain (GstPad * pad, GstData * data);
-static GstElementStateReturn gst_vorbis_tag_change_state (GstElement * element);
+static GstElementStateReturn gst_vorbis_tag_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_vorbis_tag_signals[LAST_SIGNAL] = { 0 }; */
GType
NULL,
NULL
};
-
- vorbis_tag_type = g_type_register_static(GST_TYPE_ELEMENT, "GstVorbisTag", &vorbis_tag_info, 0);
- g_type_add_interface_static (vorbis_tag_type, GST_TYPE_TAG_SETTER, &tag_setter_info);
+ vorbis_tag_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstVorbisTag",
+ &vorbis_tag_info, 0);
+
+ g_type_add_interface_static (vorbis_tag_type, GST_TYPE_TAG_SETTER,
+ &tag_setter_info);
- GST_DEBUG_CATEGORY_INIT (gst_vorbis_tag_debug, "vorbistag", 0, "vorbis tagging element");
+ GST_DEBUG_CATEGORY_INIT (gst_vorbis_tag_debug, "vorbistag", 0,
+ "vorbis tagging element");
}
return vorbis_tag_type;
}
gst_vorbis_tag_class_init (gpointer g_class, gpointer class_data)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
parent_class = g_type_class_peek_parent (g_class);
gstelement_class->change_state = gst_vorbis_tag_change_state;
}
static void
-gst_vorbis_tag_init (GTypeInstance *instance, gpointer g_class)
+gst_vorbis_tag_init (GTypeInstance * instance, gpointer g_class)
{
GstVorbisTag *tag = GST_VORBIS_TAG (instance);
-
+
/* create the sink and src pads */
- tag->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&gst_vorbis_tag_sink_template), "sink");
+ tag->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_vorbis_tag_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (tag), tag->sinkpad);
- gst_pad_set_chain_function (tag->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbis_tag_chain));
+ gst_pad_set_chain_function (tag->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_vorbis_tag_chain));
- tag->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&gst_vorbis_tag_src_template), "src");
+ tag->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_vorbis_tag_src_template), "src");
gst_element_add_pad (GST_ELEMENT (tag), tag->srcpad);
}
static GstTagEntryMatch tag_matches[] = {
- { GST_TAG_TITLE, "TITLE" },
- { GST_TAG_VERSION, "VERSION" },
- { GST_TAG_ALBUM, "ALBUM" },
- { GST_TAG_TRACK_NUMBER, "TRACKNUMBER" },
- { GST_TAG_ALBUM_VOLUME_NUMBER, "DISCNUMBER" },
- { GST_TAG_TRACK_COUNT, "TRACKTOTAL" },
- { GST_TAG_ALBUM_VOLUME_COUNT, "DISCTOTAL" },
- { GST_TAG_ARTIST, "ARTIST" },
- { GST_TAG_PERFORMER, "PERFORMER" },
- { GST_TAG_COPYRIGHT, "COPYRIGHT" },
- { GST_TAG_LICENSE, "LICENSE" },
- { GST_TAG_ORGANIZATION, "ORGANIZATION" },
- { GST_TAG_DESCRIPTION, "DESCRIPTION" },
- { GST_TAG_GENRE, "GENRE" },
- { GST_TAG_DATE, "DATE" },
- { GST_TAG_CONTACT, "CONTACT" },
- { GST_TAG_ISRC, "ISRC" },
- { GST_TAG_COMMENT, "COMMENT" },
- { GST_TAG_TRACK_GAIN, "REPLAYGAIN_TRACK_GAIN" },
- { GST_TAG_TRACK_PEAK, "REPLAYGAIN_TRACK_PEAK" },
- { GST_TAG_ALBUM_GAIN, "REPLAYGAIN_ALBUM_GAIN" },
- { GST_TAG_ALBUM_PEAK, "REPLAYGAIN_ALBUM_PEAK" },
- { NULL, NULL }
+ {GST_TAG_TITLE, "TITLE"},
+ {GST_TAG_VERSION, "VERSION"},
+ {GST_TAG_ALBUM, "ALBUM"},
+ {GST_TAG_TRACK_NUMBER, "TRACKNUMBER"},
+ {GST_TAG_ALBUM_VOLUME_NUMBER, "DISCNUMBER"},
+ {GST_TAG_TRACK_COUNT, "TRACKTOTAL"},
+ {GST_TAG_ALBUM_VOLUME_COUNT, "DISCTOTAL"},
+ {GST_TAG_ARTIST, "ARTIST"},
+ {GST_TAG_PERFORMER, "PERFORMER"},
+ {GST_TAG_COPYRIGHT, "COPYRIGHT"},
+ {GST_TAG_LICENSE, "LICENSE"},
+ {GST_TAG_ORGANIZATION, "ORGANIZATION"},
+ {GST_TAG_DESCRIPTION, "DESCRIPTION"},
+ {GST_TAG_GENRE, "GENRE"},
+ {GST_TAG_DATE, "DATE"},
+ {GST_TAG_CONTACT, "CONTACT"},
+ {GST_TAG_ISRC, "ISRC"},
+ {GST_TAG_COMMENT, "COMMENT"},
+ {GST_TAG_TRACK_GAIN, "REPLAYGAIN_TRACK_GAIN"},
+ {GST_TAG_TRACK_PEAK, "REPLAYGAIN_TRACK_PEAK"},
+ {GST_TAG_ALBUM_GAIN, "REPLAYGAIN_ALBUM_GAIN"},
+ {GST_TAG_ALBUM_PEAK, "REPLAYGAIN_ALBUM_PEAK"},
+ {NULL, NULL}
};
+
/**
* gst_tag_from_vorbis_tag:
* @vorbis_tag: vorbiscomment tag to convert to GStreamer tag
* Returns: The corresponding GStreamer tag or NULL if none exists.
*/
G_CONST_RETURN gchar *
-gst_tag_from_vorbis_tag (const gchar *vorbis_tag)
+gst_tag_from_vorbis_tag (const gchar * vorbis_tag)
{
int i = 0;
gchar *real_vorbis_tag;
-
+
g_return_val_if_fail (vorbis_tag != NULL, NULL);
-
+
real_vorbis_tag = g_ascii_strup (vorbis_tag, -1);
while (tag_matches[i].gstreamer_tag != NULL) {
if (strcmp (real_vorbis_tag, tag_matches[i].original_tag) == 0) {
g_free (real_vorbis_tag);
return tag_matches[i].gstreamer_tag;
}
+
/**
* gst_tag_to_vorbis_tag:
* @gst_tag: GStreamer tag to convert to vorbiscomment tag
* Returns: The corresponding vorbiscommment tag or NULL if none exists.
*/
G_CONST_RETURN gchar *
-gst_tag_to_vorbis_tag (const gchar *gst_tag)
+gst_tag_to_vorbis_tag (const gchar * gst_tag)
{
int i = 0;
g_return_val_if_fail (gst_tag != NULL, NULL);
-
+
while (tag_matches[i].gstreamer_tag != NULL) {
if (strcmp (gst_tag, tag_matches[i].gstreamer_tag) == 0) {
return tag_matches[i].original_tag;
void
-gst_vorbis_tag_add (GstTagList *list, const gchar *tag, const gchar *value)
+gst_vorbis_tag_add (GstTagList * list, const gchar * tag, const gchar * value)
{
const gchar *gst_tag = gst_tag_from_vorbis_tag (tag);
-
- if (gst_tag == NULL) return;
-
+
+ if (gst_tag == NULL)
+ return;
+
switch (gst_tag_get_type (gst_tag)) {
case G_TYPE_UINT:
if (strcmp (gst_tag, GST_TAG_DATE) == 0) {
- GDate *date;
- guint y, d = 1, m = 1;
- gchar *check = (gchar *) value;
- y = strtoul (check, &check, 10);
- if (*check == '-') {
- check++;
- m = strtoul (check, &check, 10);
- if (*check == '-') {
- check++;
- d = strtoul (check, &check, 10);
- }
- }
- if (*check != '\0') break;
- if (y == 0) break;
- date = g_date_new_dmy (d, m, y);
- y = g_date_get_julian (date);
- g_date_free (date);
- gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, y, NULL);
- break;
+ GDate *date;
+ guint y, d = 1, m = 1;
+ gchar *check = (gchar *) value;
+
+ y = strtoul (check, &check, 10);
+ if (*check == '-') {
+ check++;
+ m = strtoul (check, &check, 10);
+ if (*check == '-') {
+ check++;
+ d = strtoul (check, &check, 10);
+ }
+ }
+ if (*check != '\0')
+ break;
+ if (y == 0)
+ break;
+ date = g_date_new_dmy (d, m, y);
+ y = g_date_get_julian (date);
+ g_date_free (date);
+ gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, y, NULL);
+ break;
} else {
- guint tmp;
- gchar *check;
+ guint tmp;
+ gchar *check;
gboolean is_track_number_tag;
gboolean is_disc_number_tag;
is_track_number_tag = (strcmp (gst_tag, GST_TAG_TRACK_NUMBER) == 0);
- is_disc_number_tag = (strcmp (gst_tag, GST_TAG_ALBUM_VOLUME_NUMBER) == 0);
- tmp = strtoul (value, &check, 10);
- if (*check == '/' && (is_track_number_tag || is_disc_number_tag)) {
- guint count;
- check++;
- count = strtoul (check, &check, 10);
- if (*check != '\0' || count == 0) break;
+ is_disc_number_tag =
+ (strcmp (gst_tag, GST_TAG_ALBUM_VOLUME_NUMBER) == 0);
+ tmp = strtoul (value, &check, 10);
+ if (*check == '/' && (is_track_number_tag || is_disc_number_tag)) {
+ guint count;
+
+ check++;
+ count = strtoul (check, &check, 10);
+ if (*check != '\0' || count == 0)
+ break;
if (is_track_number_tag) {
- gst_tag_list_add (list, GST_TAG_MERGE_APPEND, GST_TAG_TRACK_COUNT, count, NULL);
+ gst_tag_list_add (list, GST_TAG_MERGE_APPEND, GST_TAG_TRACK_COUNT,
+ count, NULL);
} else {
- gst_tag_list_add (list, GST_TAG_MERGE_APPEND, GST_TAG_ALBUM_VOLUME_COUNT, count, NULL);
+ gst_tag_list_add (list, GST_TAG_MERGE_APPEND,
+ GST_TAG_ALBUM_VOLUME_COUNT, count, NULL);
}
- }
- if (*check != '\0') break;
- gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, tmp, NULL);
+ }
+ if (*check != '\0')
+ break;
+ gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, tmp, NULL);
}
break;
case G_TYPE_STRING:
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, value, NULL);
break;
case G_TYPE_DOUBLE:
- gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, g_strtod (value, NULL), NULL);
+ gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, g_strtod (value,
+ NULL), NULL);
break;
default:
break;
}
}
+
/**
* gst_tag_list_from_vorbiscomment_buffer:
* @buffer: buffer to convert
* given vorbiscomment buffer or NULL on error.
*/
GstTagList *
-gst_tag_list_from_vorbiscomment_buffer (const GstBuffer *buffer, const guint8 *id_data,
- const guint id_data_length, gchar **vendor_string)
+gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer,
+ const guint8 * id_data, const guint id_data_length, gchar ** vendor_string)
{
#define ADVANCE(x) G_STMT_START{ \
data += x; \
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
g_return_val_if_fail (id_data != NULL, NULL);
g_return_val_if_fail (id_data_length > 0, NULL);
-
+
data = GST_BUFFER_DATA (buffer);
size = GST_BUFFER_SIZE (buffer);
list = gst_tag_list_new ();
- if (size < 11) goto error;
- if (memcmp (data, id_data, id_data_length) != 0) goto error;
+ if (size < 11)
+ goto error;
+ if (memcmp (data, id_data, id_data_length) != 0)
+ goto error;
ADVANCE (id_data_length);
- if (vendor_string) *vendor_string = g_strndup (cur, cur_size);
+ if (vendor_string)
+ *vendor_string = g_strndup (cur, cur_size);
ADVANCE (cur_size);
iterations = cur_size;
cur_size = 0;
ADVANCE (cur_size);
iterations--;
cur = g_strndup (cur, cur_size);
- value = strchr(cur, '=');
+ value = strchr (cur, '=');
if (value == NULL) {
g_free (cur);
continue;
gst_vorbis_tag_add (list, cur, value);
g_free (cur);
}
-
+
return list;
-
+
error:
gst_tag_list_free (list);
return NULL;
#undef ADVANCE
}
-typedef struct {
+typedef struct
+{
guint count;
guint data_count;
GList *entries;
} MyForEach;
GList *
-gst_tag_to_vorbis_comments (const GstTagList *list, const gchar *tag)
+gst_tag_to_vorbis_comments (const GstTagList * list, const gchar * tag)
{
gchar *result;
GList *l = NULL;
guint i;
const gchar *vorbis_tag = gst_tag_to_vorbis_tag (tag);
- if (!vorbis_tag) return NULL;
+ if (!vorbis_tag)
+ return NULL;
for (i = 0; i < gst_tag_list_get_tag_size (list, tag); i++) {
switch (gst_tag_get_type (tag)) {
- case G_TYPE_UINT:
+ case G_TYPE_UINT:
if (strcmp (tag, GST_TAG_DATE) == 0) {
GDate *date;
guint u;
-
+
g_assert (gst_tag_list_get_uint_index (list, tag, i, &u));
date = g_date_new_julian (u);
/* vorbis suggests using ISO date formats */
- result = g_strdup_printf ("%s=%04d-%02d-%02d", vorbis_tag, (gint) g_date_get_year (date),
- (gint) g_date_get_month (date), (gint) g_date_get_day (date));
- g_date_free (date);
+ result =
+ g_strdup_printf ("%s=%04d-%02d-%02d", vorbis_tag,
+ (gint) g_date_get_year (date), (gint) g_date_get_month (date),
+ (gint) g_date_get_day (date));
+ g_date_free (date);
} else {
guint u;
-
+
g_assert (gst_tag_list_get_uint_index (list, tag, i, &u));
result = g_strdup_printf ("%s=%u", vorbis_tag, u);
}
break;
- case G_TYPE_STRING: {
+ case G_TYPE_STRING:{
gchar *str;
+
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
result = g_strdup_printf ("%s=%s", vorbis_tag, str);
break;
}
- case G_TYPE_DOUBLE: {
+ case G_TYPE_DOUBLE:{
gdouble value;
+
g_assert (gst_tag_list_get_double_index (list, tag, i, &value));
result = g_strdup_printf ("%s=%f", vorbis_tag, value);
}
}
static void
-write_one_tag (const GstTagList *list, const gchar *tag, gpointer user_data)
+write_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
MyForEach *data = (MyForEach *) user_data;
GList *comments;
for (it = comments; it != NULL; it = it->next) {
gchar *result = it->data;
- data->count ++;
+
+ data->count++;
data->data_count += strlen (result);
- data->entries = g_list_prepend (data->entries, result);
+ data->entries = g_list_prepend (data->entries, result);
}
}
+
/**
* gst_tag_list_to_vorbiscomment_buffer:
* @buffer: tag list to convert
* could be converted from the given tag list.
*/
GstBuffer *
-gst_tag_list_to_vorbiscomment_buffer (const GstTagList *list, const guint8 *id_data,
- const guint id_data_length, const gchar *vendor_string)
+gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
+ const guint8 * id_data, const guint id_data_length,
+ const gchar * vendor_string)
{
GstBuffer *buffer;
guint8 *data;
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
g_return_val_if_fail (id_data != NULL, NULL);
g_return_val_if_fail (id_data_length > 0, NULL);
-
+
if (vendor_string == NULL)
vendor_string = "GStreamer encoded vorbiscomment";
vendor_len = strlen (vendor_string);
return buffer;
}
static void
-gst_vorbis_tag_chain (GstPad *pad, GstData *data)
+gst_vorbis_tag_chain (GstPad * pad, GstData * data)
{
GstVorbisTag *tag;
GstBuffer *buffer;
buffer = GST_BUFFER (data);
tag = GST_VORBIS_TAG (gst_pad_get_parent (pad));
-
+
if (tag->output == OUTPUT_UNKNOWN) {
/* caps nego */
do {
- if (gst_pad_try_set_caps (tag->srcpad, gst_caps_new_simple (
- "audio/x-vorbis", NULL)) >= 0) {
+ if (gst_pad_try_set_caps (tag->srcpad,
+ gst_caps_new_simple ("audio/x-vorbis", NULL)) >= 0) {
tag->output = OUTPUT_DATA;
- } else if (gst_pad_try_set_caps (tag->srcpad, gst_caps_new_simple (
- "application/x-gst-tags", NULL)) >= 0) {
+ } else if (gst_pad_try_set_caps (tag->srcpad,
+ gst_caps_new_simple ("application/x-gst-tags", NULL)) >= 0) {
tag->output = OUTPUT_TAGS;
} else {
- const GstCaps *caps = gst_static_caps_get (
- &gst_vorbis_tag_src_template.static_caps);
+ const GstCaps *caps =
+ gst_static_caps_get (&gst_vorbis_tag_src_template.static_caps);
if (gst_pad_recover_caps_error (tag->srcpad, caps))
continue;
return;
}
} while (FALSE);
}
-
+
if (GST_BUFFER_SIZE (buffer) == 0)
- GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL), ("empty buffers are not allowed in vorbis data"));
-
+ GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL),
+ ("empty buffers are not allowed in vorbis data"));
+
if (GST_BUFFER_DATA (buffer)[0] == 3) {
gchar *vendor;
- GstTagList *list = gst_tag_list_from_vorbiscomment_buffer (buffer, "\003vorbis", 7, &vendor);
+ GstTagList *list =
+ gst_tag_list_from_vorbiscomment_buffer (buffer, "\003vorbis", 7,
+ &vendor);
gst_data_unref (data);
if (list == NULL) {
- GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL), ("invalid data in vorbis comments"));
+ GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL),
+ ("invalid data in vorbis comments"));
return;
}
gst_element_found_tags_for_pad (GST_ELEMENT (tag), tag->srcpad, 0,
- gst_tag_list_copy (list));
- gst_tag_list_merge (list, gst_tag_setter_get_list (GST_TAG_SETTER (tag)), gst_tag_setter_get_merge_mode (GST_TAG_SETTER (tag)));
- data = GST_DATA (gst_tag_list_to_vorbiscomment_buffer (list, "\003vorbis", 7, vendor));
+ gst_tag_list_copy (list));
+ gst_tag_list_merge (list, gst_tag_setter_get_list (GST_TAG_SETTER (tag)),
+ gst_tag_setter_get_merge_mode (GST_TAG_SETTER (tag)));
+ data =
+ GST_DATA (gst_tag_list_to_vorbiscomment_buffer (list, "\003vorbis", 7,
+ vendor));
gst_tag_list_free (list);
g_free (vendor);
}
}
}
static GstElementStateReturn
-gst_vorbis_tag_change_state (GstElement *element)
+gst_vorbis_tag_change_state (GstElement * element)
{
GstVorbisTag *tag;
#include "gsttcpsink.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "tcpsink", GST_RANK_NONE, GST_TYPE_TCPSINK))
+ if (!gst_element_register (plugin, "tcpsink", GST_RANK_NONE,
+ GST_TYPE_TCPSINK))
return FALSE;
if (!gst_element_register (plugin, "tcpsrc", GST_RANK_NONE, GST_TYPE_TCPSRC))
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "tcp",
- "transfer data over the network via TCP",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "tcp",
+ "transfer data over the network via TCP",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_TCP_H__ */
+#endif /* __GST_TCP_H__ */
#include "gsttcpsink.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "tcpsink", GST_RANK_NONE, GST_TYPE_TCPSINK))
+ if (!gst_element_register (plugin, "tcpsink", GST_RANK_NONE,
+ GST_TYPE_TCPSINK))
return FALSE;
if (!gst_element_register (plugin, "tcpsrc", GST_RANK_NONE, GST_TYPE_TCPSRC))
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "tcp",
- "transfer data over the network via TCP",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "tcp",
+ "transfer data over the network via TCP",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_TCP_H__ */
+#endif /* __GST_TCP_H__ */
#define TCP_DEFAULT_PORT 4953
/* elementfactory information */
-static GstElementDetails gst_tcpsink_details = GST_ELEMENT_DETAILS (
- "TCP packet sender",
- "Sink/Network",
- "Send data over the network via TCP",
- "Zeeshan Ali <zak147@yahoo.com>"
-);
+static GstElementDetails gst_tcpsink_details =
+GST_ELEMENT_DETAILS ("TCP packet sender",
+ "Sink/Network",
+ "Send data over the network via TCP",
+ "Zeeshan Ali <zak147@yahoo.com>");
/* TCPSink signals and args */
-enum {
+enum
+{
FRAME_ENCODED,
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_HOST,
ARG_PORT,
ARG_CONTROL,
ARG_MTU
- /* FILL ME */
+ /* FILL ME */
};
#define GST_TYPE_TCPSINK_CONTROL (gst_tcpsink_control_get_type())
static GType
-gst_tcpsink_control_get_type(void) {
+gst_tcpsink_control_get_type (void)
+{
static GType tcpsink_control_type = 0;
static GEnumValue tcpsink_control[] = {
{CONTROL_NONE, "1", "none"},
{CONTROL_ZERO, NULL, NULL}
};
if (!tcpsink_control_type) {
- tcpsink_control_type = g_enum_register_static("GstTCPSinkControl", tcpsink_control);
+ tcpsink_control_type =
+ g_enum_register_static ("GstTCPSinkControl", tcpsink_control);
}
return tcpsink_control_type;
}
-static void gst_tcpsink_base_init (gpointer g_class);
-static void gst_tcpsink_class_init (GstTCPSink *klass);
-static void gst_tcpsink_init (GstTCPSink *tcpsink);
+static void gst_tcpsink_base_init (gpointer g_class);
+static void gst_tcpsink_class_init (GstTCPSink * klass);
+static void gst_tcpsink_init (GstTCPSink * tcpsink);
-static void gst_tcpsink_set_clock (GstElement *element, GstClock *clock);
+static void gst_tcpsink_set_clock (GstElement * element, GstClock * clock);
-static void gst_tcpsink_chain (GstPad *pad,GstData *_data);
-static GstElementStateReturn gst_tcpsink_change_state (GstElement *element);
+static void gst_tcpsink_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_tcpsink_change_state (GstElement * element);
-static void gst_tcpsink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_tcpsink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_tcpsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_tcpsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_tcpsink_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!tcpsink_type) {
static const GTypeInfo tcpsink_info = {
- sizeof(GstTCPSinkClass),
+ sizeof (GstTCPSinkClass),
gst_tcpsink_base_init,
NULL,
- (GClassInitFunc)gst_tcpsink_class_init,
+ (GClassInitFunc) gst_tcpsink_class_init,
NULL,
NULL,
- sizeof(GstTCPSink),
+ sizeof (GstTCPSink),
0,
- (GInstanceInitFunc)gst_tcpsink_init,
+ (GInstanceInitFunc) gst_tcpsink_init,
NULL
};
- tcpsink_type = g_type_register_static (GST_TYPE_ELEMENT, "GstTCPSink", &tcpsink_info, 0);
+ tcpsink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstTCPSink", &tcpsink_info,
+ 0);
}
return tcpsink_type;
}
}
static void
-gst_tcpsink_class_init (GstTCPSink *klass)
+gst_tcpsink_class_init (GstTCPSink * 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_HOST,
- g_param_spec_string ("host", "host", "The host/IP to send the packets to",
- TCP_DEFAULT_HOST, G_PARAM_READWRITE));
+ g_param_spec_string ("host", "host", "The host/IP to send the packets to",
+ TCP_DEFAULT_HOST, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
- g_param_spec_int ("port", "port", "The port to send the packets to",
- 0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
+ g_param_spec_int ("port", "port", "The port to send the packets to",
+ 0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_CONTROL,
- g_param_spec_enum ("control", "control", "The type of control",
- GST_TYPE_TCPSINK_CONTROL, CONTROL_TCP, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, ARG_MTU,
- g_param_spec_int ("mtu", "mtu", "mtu", G_MININT, G_MAXINT,
- 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_param_spec_enum ("control", "control", "The type of control",
+ GST_TYPE_TCPSINK_CONTROL, CONTROL_TCP, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_MTU, g_param_spec_int ("mtu", "mtu", "mtu", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_tcpsink_set_property;
gobject_class->get_property = gst_tcpsink_get_property;
static GstPadLinkReturn
-gst_tcpsink_sink_link (GstPad *pad, const GstCaps *caps)
+gst_tcpsink_sink_link (GstPad * pad, const GstCaps * caps)
{
GstTCPSink *tcpsink;
struct sockaddr_in serv_addr;
struct hostent *he;
int fd;
FILE *f;
+
#ifndef GST_DISABLE_LOADSAVE
xmlDocPtr doc;
tcpsink = GST_TCPSINK (gst_pad_get_parent (pad));
-
+
switch (tcpsink->control) {
case CONTROL_TCP:
- memset (&serv_addr, 0, sizeof(serv_addr));
-
- /* if its an IP address */
- if (inet_aton (tcpsink->host, &addr)) {
- memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
- }
-
- /* we dont need to lookup for localhost */
- else if (strcmp (tcpsink->host, TCP_DEFAULT_HOST) == 0) {
- if (inet_aton ("127.0.0.1", &addr)) {
- memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
- }
- }
-
- /* if its a hostname */
- else if ((he = gethostbyname (tcpsink->host))) {
- memmove (&(serv_addr.sin_addr), he->h_addr, he->h_length);
- }
-
- else {
- perror("hostname lookup error?");
- return GST_PAD_LINK_REFUSED;
- }
-
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(tcpsink->port+1);
-
- doc = xmlNewDoc ("1.0");
- doc->xmlRootNode = xmlNewDocNode (doc, NULL, "NewCaps", NULL);
-
- gst_caps_save_thyself (caps, doc->xmlRootNode);
-
- if ((fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- perror("socket");
- return GST_PAD_LINK_REFUSED;
- }
-
- if (connect(fd, (struct sockaddr *)&serv_addr, sizeof (serv_addr)) != 0)
- {
- g_printerr ("tcpsink: connect to %s port %d failed: %s\n",
- tcpsink->host, tcpsink->port+1, g_strerror(errno));
- return GST_PAD_LINK_REFUSED;
- }
-
- f = fdopen (dup (fd), "wb");
-
- xmlDocDump(f, doc);
- fclose (f);
- close (fd);
- #endif
- break;
+ memset (&serv_addr, 0, sizeof (serv_addr));
+
+ /* if its an IP address */
+ if (inet_aton (tcpsink->host, &addr)) {
+ memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
+ }
+
+ /* we dont need to lookup for localhost */
+ else if (strcmp (tcpsink->host, TCP_DEFAULT_HOST) == 0) {
+ if (inet_aton ("127.0.0.1", &addr)) {
+ memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
+ }
+ }
+
+ /* if its a hostname */
+ else if ((he = gethostbyname (tcpsink->host))) {
+ memmove (&(serv_addr.sin_addr), he->h_addr, he->h_length);
+ }
+
+ else {
+ perror ("hostname lookup error?");
+ return GST_PAD_LINK_REFUSED;
+ }
+
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_port = htons (tcpsink->port + 1);
+
+ doc = xmlNewDoc ("1.0");
+ doc->xmlRootNode = xmlNewDocNode (doc, NULL, "NewCaps", NULL);
+
+ gst_caps_save_thyself (caps, doc->xmlRootNode);
+
+ if ((fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
+ perror ("socket");
+ return GST_PAD_LINK_REFUSED;
+ }
+
+ if (connect (fd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) != 0) {
+ g_printerr ("tcpsink: connect to %s port %d failed: %s\n",
+ tcpsink->host, tcpsink->port + 1, g_strerror (errno));
+ return GST_PAD_LINK_REFUSED;
+ }
+
+ f = fdopen (dup (fd), "wb");
+
+ xmlDocDump (f, doc);
+ fclose (f);
+ close (fd);
+#endif
+ break;
case CONTROL_NONE:
- return GST_PAD_LINK_OK;
- break;
+ return GST_PAD_LINK_OK;
+ break;
default:
- return GST_PAD_LINK_REFUSED;
- break;
+ return GST_PAD_LINK_REFUSED;
+ break;
}
-
+
return GST_PAD_LINK_OK;
}
static void
-gst_tcpsink_set_clock (GstElement *element, GstClock *clock)
+gst_tcpsink_set_clock (GstElement * element, GstClock * clock)
{
GstTCPSink *tcpsink;
-
+
tcpsink = GST_TCPSINK (element);
tcpsink->clock = clock;
}
static void
-gst_tcpsink_init (GstTCPSink *tcpsink)
+gst_tcpsink_init (GstTCPSink * tcpsink)
{
/* create the sink and src pads */
tcpsink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
tcpsink->control = CONTROL_TCP;
/* should support as minimum 576 for IPV4 and 1500 for IPV6 */
tcpsink->mtu = 1500;
-
+
tcpsink->clock = NULL;
}
static void
-gst_tcpsink_chain (GstPad *pad, GstData *_data)
+gst_tcpsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstTCPSink *tcpsink;
-
+
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
tcpsink = GST_TCPSINK (GST_OBJECT_PARENT (pad));
-
+
if (tcpsink->clock && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
gst_element_wait (GST_ELEMENT (tcpsink), GST_BUFFER_TIMESTAMP (buf));
}
-
- if (write (tcpsink->sock, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)) <= 0)
- {
- perror("write");
+
+ if (write (tcpsink->sock, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)) <= 0) {
+ perror ("write");
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_tcpsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_tcpsink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstTCPSink *tcpsink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TCPSINK(object));
- tcpsink = GST_TCPSINK(object);
+ g_return_if_fail (GST_IS_TCPSINK (object));
+ tcpsink = GST_TCPSINK (object);
switch (prop_id) {
case ARG_HOST:
- if (tcpsink->host != NULL) g_free(tcpsink->host);
+ if (tcpsink->host != NULL)
+ g_free (tcpsink->host);
if (g_value_get_string (value) == NULL)
- tcpsink->host = NULL;
+ tcpsink->host = NULL;
else
- tcpsink->host = g_strdup (g_value_get_string (value));
+ tcpsink->host = g_strdup (g_value_get_string (value));
break;
case ARG_PORT:
- tcpsink->port = g_value_get_int (value);
+ tcpsink->port = g_value_get_int (value);
break;
case ARG_CONTROL:
- tcpsink->control = g_value_get_enum (value);
+ tcpsink->control = g_value_get_enum (value);
break;
case ARG_MTU:
- tcpsink->mtu = g_value_get_int (value);
- break;
+ tcpsink->mtu = g_value_get_int (value);
+ break;
default:
break;
}
}
static void
-gst_tcpsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tcpsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstTCPSink *tcpsink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TCPSINK(object));
- tcpsink = GST_TCPSINK(object);
+ g_return_if_fail (GST_IS_TCPSINK (object));
+ tcpsink = GST_TCPSINK (object);
switch (prop_id) {
case ARG_HOST:
/* create a socket for sending to remote machine */
static gboolean
-gst_tcpsink_init_send (GstTCPSink *sink)
+gst_tcpsink_init_send (GstTCPSink * sink)
{
struct hostent *he;
struct in_addr addr;
memset (&sink->theiraddr, 0, sizeof (sink->theiraddr));
- sink->theiraddr.sin_family = AF_INET; /* host byte order */
- sink->theiraddr.sin_port = htons (sink->port); /* short, network byte order */
+ sink->theiraddr.sin_family = AF_INET; /* host byte order */
+ sink->theiraddr.sin_port = htons (sink->port); /* short, network byte order */
/* if its an IP address */
if (inet_aton (sink->host, &addr)) {
memmove (&(sink->theiraddr.sin_addr), &addr, sizeof (struct in_addr));
}
-
+
/* we dont need to lookup for localhost */
else if (strcmp (sink->host, TCP_DEFAULT_HOST) == 0) {
if (inet_aton ("127.0.0.1", &addr)) {
else if ((he = gethostbyname (sink->host))) {
memmove (&(sink->theiraddr.sin_addr), he->h_addr, he->h_length);
}
-
+
else {
- perror("hostname lookup error?");
- return FALSE;
+ perror ("hostname lookup error?");
+ return FALSE;
}
if ((sink->sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- perror("socket");
- return FALSE;
+ perror ("socket");
+ return FALSE;
}
- if (connect (sink->sock, (struct sockaddr *)&(sink->theiraddr), sizeof (sink->theiraddr)) != 0) {
- perror("stream connect");
- return FALSE;
+ if (connect (sink->sock, (struct sockaddr *) &(sink->theiraddr),
+ sizeof (sink->theiraddr)) != 0) {
+ perror ("stream connect");
+ return FALSE;
}
-
+
GST_FLAG_SET (sink, GST_TCPSINK_OPEN);
return TRUE;
}
static void
-gst_tcpsink_close (GstTCPSink *sink)
+gst_tcpsink_close (GstTCPSink * sink)
{
close (sink->sock);
}
static GstElementStateReturn
-gst_tcpsink_change_state (GstElement *element)
+gst_tcpsink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_TCPSINK (element), GST_STATE_FAILURE);
} else {
if (!GST_FLAG_IS_SET (element, GST_TCPSINK_OPEN)) {
if (!gst_tcpsink_init_send (GST_TCPSINK (element)))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
return GST_STATE_SUCCESS;
}
-
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#include <stdio.h>
#include <stdlib.h>
#define GST_IS_TCPSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCPSINK))
-typedef struct _GstTCPSink GstTCPSink;
-typedef struct _GstTCPSinkClass GstTCPSinkClass;
+ typedef struct _GstTCPSink GstTCPSink;
+ typedef struct _GstTCPSinkClass GstTCPSinkClass;
-typedef enum {
- GST_TCPSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_TCPSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_TCPSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstTCPSinkFlags;
+ GST_TCPSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstTCPSinkFlags;
-struct _GstTCPSink {
- GstElement element;
+ struct _GstTCPSink
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad,*srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- int sock;
- struct sockaddr_in theiraddr;
- Gst_TCP_Control control;
+ int sock;
+ struct sockaddr_in theiraddr;
+ Gst_TCP_Control control;
- gint port;
- gchar *host;
-
- guint mtu;
-
- GstClock *clock;
-};
+ gint port;
+ gchar *host;
-struct _GstTCPSinkClass {
- GstElementClass parent_class;
-};
+ guint mtu;
-GType gst_tcpsink_get_type(void);
+ GstClock *clock;
+ };
+
+ struct _GstTCPSinkClass
+ {
+ GstElementClass parent_class;
+ };
+
+ GType gst_tcpsink_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_TCPSINK_H__ */
+#endif /* __GST_TCPSINK_H__ */
#define TCP_DEFAULT_PORT 4953
/* elementfactory information */
-static GstElementDetails gst_tcpsrc_details = GST_ELEMENT_DETAILS (
- "TCP packet receiver",
- "Source/Network",
- "Receive data over the network via TCP",
- "Zeeshan Ali <zak147@yahoo.com>"
-);
+static GstElementDetails gst_tcpsrc_details =
+GST_ELEMENT_DETAILS ("TCP packet receiver",
+ "Source/Network",
+ "Receive data over the network via TCP",
+ "Zeeshan Ali <zak147@yahoo.com>");
/* TCPSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_PORT,
ARG_CONTROL,
#define GST_TYPE_TCPSRC_CONTROL (gst_tcpsrc_control_get_type())
static GType
-gst_tcpsrc_control_get_type(void) {
+gst_tcpsrc_control_get_type (void)
+{
static GType tcpsrc_control_type = 0;
static GEnumValue tcpsrc_control[] = {
{CONTROL_NONE, "1", "none"},
{CONTROL_ZERO, NULL, NULL}
};
if (!tcpsrc_control_type) {
- tcpsrc_control_type = g_enum_register_static("GstTCPSrcControl", tcpsrc_control);
+ tcpsrc_control_type =
+ g_enum_register_static ("GstTCPSrcControl", tcpsrc_control);
}
return tcpsrc_control_type;
}
-static void gst_tcpsrc_base_init (gpointer g_class);
-static void gst_tcpsrc_class_init (GstTCPSrc *klass);
-static void gst_tcpsrc_init (GstTCPSrc *tcpsrc);
+static void gst_tcpsrc_base_init (gpointer g_class);
+static void gst_tcpsrc_class_init (GstTCPSrc * klass);
+static void gst_tcpsrc_init (GstTCPSrc * tcpsrc);
-static GstData* gst_tcpsrc_get (GstPad *pad);
-static GstElementStateReturn
- gst_tcpsrc_change_state (GstElement *element);
+static GstData *gst_tcpsrc_get (GstPad * pad);
+static GstElementStateReturn gst_tcpsrc_change_state (GstElement * element);
-static void gst_tcpsrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_tcpsrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static void gst_tcpsrc_set_clock (GstElement *element, GstClock *clock);
+static void gst_tcpsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_tcpsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_tcpsrc_set_clock (GstElement * element, GstClock * clock);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_tcpsrc_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!tcpsrc_type) {
static const GTypeInfo tcpsrc_info = {
- sizeof(GstTCPSrcClass),
+ sizeof (GstTCPSrcClass),
gst_tcpsrc_base_init,
NULL,
- (GClassInitFunc)gst_tcpsrc_class_init,
+ (GClassInitFunc) gst_tcpsrc_class_init,
NULL,
NULL,
- sizeof(GstTCPSrc),
+ sizeof (GstTCPSrc),
0,
- (GInstanceInitFunc)gst_tcpsrc_init,
+ (GInstanceInitFunc) gst_tcpsrc_init,
NULL
};
- tcpsrc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstTCPSrc", &tcpsrc_info, 0);
+ tcpsrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstTCPSrc", &tcpsrc_info, 0);
}
return tcpsrc_type;
}
}
static void
-gst_tcpsrc_class_init (GstTCPSrc *klass)
+gst_tcpsrc_class_init (GstTCPSrc * 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_PORT,
- g_param_spec_int ("port", "port", "The port to receive the packets from",
- 0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
+ g_param_spec_int ("port", "port", "The port to receive the packets from",
+ 0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_CONTROL,
- g_param_spec_enum ("control", "control", "The type of control",
- GST_TYPE_TCPSRC_CONTROL, CONTROL_TCP, G_PARAM_READWRITE));
+ g_param_spec_enum ("control", "control", "The type of control",
+ GST_TYPE_TCPSRC_CONTROL, CONTROL_TCP, G_PARAM_READWRITE));
/*
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SOCKET_OPTIONS,
g_param_spec_boolean ("socketop", "socketop", "Enable or disable socket options REUSEADDR and KEEPALIVE",
}
static void
-gst_tcpsrc_set_clock (GstElement *element, GstClock *clock)
+gst_tcpsrc_set_clock (GstElement * element, GstClock * clock)
{
GstTCPSrc *tcpsrc;
-
+
tcpsrc = GST_TCPSRC (element);
tcpsrc->clock = clock;
}
static void
-gst_tcpsrc_init (GstTCPSrc *tcpsrc)
+gst_tcpsrc_init (GstTCPSrc * tcpsrc)
{
/* create the src and src pads */
tcpsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
tcpsrc->sock = -1;
tcpsrc->control_sock = -1;
tcpsrc->client_sock = -1;
- /*tcpsrc->socket_options = FALSE;*/
+ /*tcpsrc->socket_options = FALSE; */
GST_FLAG_UNSET (tcpsrc, GST_TCPSRC_OPEN);
GST_FLAG_SET (tcpsrc, GST_TCPSRC_1ST_BUF);
GST_FLAG_UNSET (tcpsrc, GST_TCPSRC_CONNECTED);
}
-static GstData*
-gst_tcpsrc_get (GstPad *pad)
+static GstData *
+gst_tcpsrc_get (GstPad * pad)
{
GstTCPSrc *tcpsrc;
GstBuffer *outbuf;
if (tcpsrc->control_sock >= 0) {
FD_SET (tcpsrc->control_sock, &read_fds);
- max_sock = MAX(tcpsrc->sock, tcpsrc->control_sock);
+ max_sock = MAX (tcpsrc->sock, tcpsrc->control_sock);
}
- /* Add to FD_SET client socket, when connection has been established */
- if (tcpsrc->client_sock >= 0)
- {
- FD_SET (tcpsrc->client_sock, &read_fds);
- max_sock = MAX(tcpsrc->client_sock , max_sock);
+ /* Add to FD_SET client socket, when connection has been established */
+ if (tcpsrc->client_sock >= 0) {
+ FD_SET (tcpsrc->client_sock, &read_fds);
+ max_sock = MAX (tcpsrc->client_sock, max_sock);
}
-
- if (select (max_sock+1, &read_fds, NULL, NULL, NULL) > 0) {
- if ((tcpsrc->control_sock != -1) && FD_ISSET (tcpsrc->control_sock, &read_fds))
- {
- guchar *buf=NULL;
+
+ if (select (max_sock + 1, &read_fds, NULL, NULL, NULL) > 0) {
+ if ((tcpsrc->control_sock != -1)
+ && FD_ISSET (tcpsrc->control_sock, &read_fds)) {
+ guchar *buf = NULL;
xmlDocPtr doc;
GstCaps *caps;
-
+
switch (tcpsrc->control) {
- case CONTROL_TCP:
+ case CONTROL_TCP:
#ifndef GST_DISABLE_LOADSAVE
- buf = g_malloc (1024*10);
-
- len = sizeof (struct sockaddr);
- client_sock = accept (tcpsrc->control_sock, &client_addr, &len);
-
- if (client_sock <= 0) {
- perror ("control_sock accept");
- }
-
- else if ((ret = read (client_sock, buf, 1024*10)) <= 0) {
- perror ("control_sock read");
- }
-
- else {
- buf[ret] = '\0';
- doc = xmlParseMemory(buf, ret);
- caps = gst_caps_load_thyself(doc->xmlRootNode);
-
- /* foward the connect, we don't signal back the result here... */
- gst_pad_try_set_caps (tcpsrc->srcpad, caps);
- }
-
- g_free (buf);
+ buf = g_malloc (1024 * 10);
+
+ len = sizeof (struct sockaddr);
+ client_sock = accept (tcpsrc->control_sock, &client_addr, &len);
+
+ if (client_sock <= 0) {
+ perror ("control_sock accept");
+ }
+
+ else if ((ret = read (client_sock, buf, 1024 * 10)) <= 0) {
+ perror ("control_sock read");
+ }
+
+ else {
+ buf[ret] = '\0';
+ doc = xmlParseMemory (buf, ret);
+ caps = gst_caps_load_thyself (doc->xmlRootNode);
+
+ /* foward the connect, we don't signal back the result here... */
+ gst_pad_try_set_caps (tcpsrc->srcpad, caps);
+ }
+
+ g_free (buf);
#endif
- break;
- case CONTROL_NONE:
+ break;
+ case CONTROL_NONE:
default:
- g_free (buf);
- return NULL;
- break;
+ g_free (buf);
+ return NULL;
+ break;
}
-
+
outbuf = NULL;
- }
- else {
+ } else {
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (24000);
GST_BUFFER_SIZE (outbuf) = 24000;
if (GST_FLAG_IS_SET (tcpsrc, GST_TCPSRC_1ST_BUF)) {
- if (tcpsrc->clock) {
- GstClockTime current_time;
- GstEvent *discont;
+ if (tcpsrc->clock) {
+ GstClockTime current_time;
+ GstEvent *discont;
+
+ current_time = gst_clock_get_time (tcpsrc->clock);
- current_time = gst_clock_get_time (tcpsrc->clock);
-
- GST_BUFFER_TIMESTAMP (outbuf) = current_time;
+ GST_BUFFER_TIMESTAMP (outbuf) = current_time;
- discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
- current_time, NULL);
+ discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
+ current_time, NULL);
- gst_pad_push (tcpsrc->srcpad, GST_DATA (discont));
+ gst_pad_push (tcpsrc->srcpad, GST_DATA (discont));
}
-
+
GST_FLAG_UNSET (tcpsrc, GST_TCPSRC_1ST_BUF);
}
-
+
else {
- GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
}
-
+
if (!GST_FLAG_IS_SET (tcpsrc, GST_TCPSRC_CONNECTED)) {
- tcpsrc->client_sock = accept (tcpsrc->sock, &client_addr, &len);
-
- if (tcpsrc->client_sock <= 0) {
- perror ("accept");
- }
+ tcpsrc->client_sock = accept (tcpsrc->sock, &client_addr, &len);
+
+ if (tcpsrc->client_sock <= 0) {
+ perror ("accept");
+ }
- else {
+ else {
GST_FLAG_SET (tcpsrc, GST_TCPSRC_CONNECTED);
}
}
- numbytes =
- read (tcpsrc->client_sock, GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
+ numbytes =
+ read (tcpsrc->client_sock, GST_BUFFER_DATA (outbuf),
+ GST_BUFFER_SIZE (outbuf));
if (numbytes > 0) {
- GST_BUFFER_SIZE (outbuf) = numbytes;
+ GST_BUFFER_SIZE (outbuf) = numbytes;
}
-
+
else {
- if (numbytes == -1){
- perror ("read");
- }
- else g_print("End of Stream reached\n");
- gst_buffer_unref (outbuf);
- outbuf = NULL;
+ if (numbytes == -1) {
+ perror ("read");
+ } else
+ g_print ("End of Stream reached\n");
+ gst_buffer_unref (outbuf);
+ outbuf = NULL;
close (tcpsrc->client_sock);
tcpsrc->client_sock = -1;
GST_FLAG_UNSET (tcpsrc, GST_TCPSRC_CONNECTED);
}
}
}
-
+
else {
perror ("select");
outbuf = NULL;
}
-
+
return GST_DATA (outbuf);
}
static void
-gst_tcpsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_tcpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstTCPSrc *tcpsrc;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TCPSRC(object));
- tcpsrc = GST_TCPSRC(object);
+ g_return_if_fail (GST_IS_TCPSRC (object));
+ tcpsrc = GST_TCPSRC (object);
switch (prop_id) {
case ARG_PORT:
- tcpsrc->port = g_value_get_int (value);
+ tcpsrc->port = g_value_get_int (value);
break;
case ARG_CONTROL:
- tcpsrc->control = g_value_get_enum (value);
+ tcpsrc->control = g_value_get_enum (value);
break;
/* case ARG_SOCKET_OPTIONS:
tcpsrc->socket_options = g_value_get_boolean(value);
}
static void
-gst_tcpsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tcpsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstTCPSrc *tcpsrc;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_TCPSRC(object));
- tcpsrc = GST_TCPSRC(object);
+ g_return_if_fail (GST_IS_TCPSRC (object));
+ tcpsrc = GST_TCPSRC (object);
switch (prop_id) {
case ARG_PORT:
/* create a socket for sending to remote machine */
static gboolean
-gst_tcpsrc_init_receive (GstTCPSrc *src)
+gst_tcpsrc_init_receive (GstTCPSrc * src)
{
- guint val=0;
+ guint val = 0;
+
memset (&src->myaddr, 0, sizeof (src->myaddr));
- src->myaddr.sin_family = AF_INET; /* host byte order */
- src->myaddr.sin_port = htons (src->port); /* short, network byte order */
+ src->myaddr.sin_family = AF_INET; /* host byte order */
+ src->myaddr.sin_port = htons (src->port); /* short, network byte order */
src->myaddr.sin_addr.s_addr = INADDR_ANY;
if ((src->sock = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
- perror("stream_socket");
+ perror ("stream_socket");
return FALSE;
}
/* if (src->socket_options)
{*/
- g_print("Socket Options SO_REUSEADDR, SO_KEEPALIVE\n");
- /* Sock Options */
+ g_print ("Socket Options SO_REUSEADDR, SO_KEEPALIVE\n");
+ /* Sock Options */
val = 1;
- /* allow local address reuse */
- if( setsockopt( src->sock,SOL_SOCKET,SO_REUSEADDR, &val, sizeof( int )) <0)
- perror( "setsockopt()" );
+ /* allow local address reuse */
+ if (setsockopt (src->sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof (int)) < 0)
+ perror ("setsockopt()");
val = 1;
- /* periodically test if connection still alive */
- if( setsockopt( src->sock,SOL_SOCKET,SO_KEEPALIVE, &val, sizeof( int )) <0)
- perror( "setsockopt()" );
+ /* periodically test if connection still alive */
+ if (setsockopt (src->sock, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof (int)) < 0)
+ perror ("setsockopt()");
/* Sock Options */
/* } */
- if (bind (src->sock, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr)) == -1) {
- perror("stream_sock bind");
+ if (bind (src->sock, (struct sockaddr *) &src->myaddr,
+ sizeof (src->myaddr)) == -1) {
+ perror ("stream_sock bind");
return FALSE;
}
if (listen (src->sock, 5) == -1) {
- perror("stream_sock listen");
+ perror ("stream_sock listen");
return FALSE;
}
-
+
fcntl (src->sock, F_SETFL, O_NONBLOCK);
-
+
switch (src->control) {
case CONTROL_TCP:
- if ((src->control_sock = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
- perror("control_socket");
- return FALSE;
- }
-
- src->myaddr.sin_port = htons (src->port+1);
- if (bind (src->control_sock, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr)) == -1)
- {
- perror("control bind");
- return FALSE;
- }
-
- if (listen (src->control_sock, 5) == -1) {
- perror("control listen");
- return FALSE;
- }
-
- fcntl (src->control_sock, F_SETFL, O_NONBLOCK);
+ if ((src->control_sock = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
+ perror ("control_socket");
+ return FALSE;
+ }
+
+ src->myaddr.sin_port = htons (src->port + 1);
+ if (bind (src->control_sock, (struct sockaddr *) &src->myaddr,
+ sizeof (src->myaddr)) == -1) {
+ perror ("control bind");
+ return FALSE;
+ }
+
+ if (listen (src->control_sock, 5) == -1) {
+ perror ("control listen");
+ return FALSE;
+ }
+
+ fcntl (src->control_sock, F_SETFL, O_NONBLOCK);
case CONTROL_NONE:
- GST_FLAG_SET (src, GST_TCPSRC_OPEN);
- return TRUE;
- break;
+ GST_FLAG_SET (src, GST_TCPSRC_OPEN);
+ return TRUE;
+ break;
default:
- return FALSE;
- break;
+ return FALSE;
+ break;
}
-
+
GST_FLAG_SET (src, GST_TCPSRC_OPEN);
-
+
return TRUE;
}
static void
-gst_tcpsrc_close (GstTCPSrc *src)
+gst_tcpsrc_close (GstTCPSrc * src)
{
if (src->sock != -1) {
close (src->sock);
src->control_sock = -1;
}
if (src->client_sock != -1) {
- close(src->client_sock);
+ close (src->client_sock);
src->client_sock = -1;
- }
+ }
GST_FLAG_UNSET (src, GST_TCPSRC_OPEN);
}
static GstElementStateReturn
-gst_tcpsrc_change_state (GstElement *element)
+gst_tcpsrc_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_TCPSRC (element), GST_STATE_FAILURE);
} else {
if (!GST_FLAG_IS_SET (element, GST_TCPSRC_OPEN)) {
if (!gst_tcpsrc_init_receive (GST_TCPSRC (element)))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
return GST_STATE_SUCCESS;
}
-
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#include <errno.h>
#include <string.h>
#define GST_IS_TCPSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCPSRC))
-typedef struct _GstTCPSrc GstTCPSrc;
-typedef struct _GstTCPSrcClass GstTCPSrcClass;
+ typedef struct _GstTCPSrc GstTCPSrc;
+ typedef struct _GstTCPSrcClass GstTCPSrcClass;
-typedef enum {
- GST_TCPSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_TCPSRC_1ST_BUF,
- GST_TCPSRC_CONNECTED,
+ typedef enum
+ {
+ GST_TCPSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ GST_TCPSRC_1ST_BUF,
+ GST_TCPSRC_CONNECTED,
- GST_TCPSRC_FLAG_LAST,
-} GstTCPSrcFlags;
+ GST_TCPSRC_FLAG_LAST,
+ } GstTCPSrcFlags;
-struct _GstTCPSrc {
- GstElement element;
+ struct _GstTCPSrc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad,*srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- int port;
- int sock;
- int client_sock;
- int control_sock;
+ int port;
+ int sock;
+ int client_sock;
+ int control_sock;
/* gboolean socket_options;*/
- Gst_TCP_Control control;
+ Gst_TCP_Control control;
- struct sockaddr_in myaddr;
- GstClock *clock;
-};
+ struct sockaddr_in myaddr;
+ GstClock *clock;
+ };
-struct _GstTCPSrcClass {
- GstElementClass parent_class;
-};
+ struct _GstTCPSrcClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_tcpsrc_get_type(void);
+ GType gst_tcpsrc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_TCPSRC_H__ */
+#endif /* __GST_TCPSRC_H__ */
#include <string.h>
#include <ctype.h>
-
+
GST_DEBUG_CATEGORY_STATIC (type_find_debug);
#define GST_CAT_DEFAULT type_find_debug
/*** text/plain ****************************************************************/
static GstStaticCaps utf8_caps = GST_STATIC_CAPS ("text/plain");
+
#define UTF8_CAPS gst_static_caps_get(&utf8_caps)
static void
-utf8_type_find (GstTypeFind *tf, gpointer unused)
+utf8_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data;
+
/* randomly decided values */
- guint size = 1024; /* starting size */
- guint probability = 95; /* starting probability */
- guint step = 10; /* how much we reduce probability in each iteration */
+ guint size = 1024; /* starting size */
+ guint probability = 95; /* starting probability */
+ guint step = 10; /* how much we reduce probability in each iteration */
while (probability > step) {
data = gst_type_find_peek (tf, 0, size);
gchar *end;
gchar *start = (gchar *) data;
- if (g_utf8_validate (start, size, (const gchar **) &end) ||
- (end - start + 4 > size)) { /* allow last char to be cut off */
+ if (g_utf8_validate (start, size, (const gchar **) &end) || (end - start + 4 > size)) { /* allow last char to be cut off */
gst_type_find_suggest (tf, probability, UTF8_CAPS);
}
return;
/*** text/uri-list ************************************************************/
static GstStaticCaps uri_caps = GST_STATIC_CAPS ("text/uri-list");
+
#define URI_CAPS (gst_static_caps_get(&uri_caps))
-#define BUFFER_SIZE 16 /* If the string is < 16 bytes we're screwed */
+#define BUFFER_SIZE 16 /* If the string is < 16 bytes we're screwed */
#define INC_BUFFER { \
pos++; \
if (pos == BUFFER_SIZE) { \
} \
}
static void
-uri_type_find (GstTypeFind *tf, gpointer unused)
+uri_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE);
guint pos = 0;
guint offset = 0;
-
+
if (data) {
/* Search for # comment lines */
while (*data == '#') {
/* Goto end of line */
while (*data != '\n') {
- INC_BUFFER;
+ INC_BUFFER;
}
INC_BUFFER;
}
INC_BUFFER;
-
+
while (g_ascii_isalnum (*data)) {
INC_BUFFER;
}
/* Get the next 2 bytes as well */
data = gst_type_find_peek (tf, offset + pos, 3);
- if (data == NULL) return;
-
+ if (data == NULL)
+ return;
+
if (data[1] != '/' && data[2] != '/') {
return;
}
/*** video/x-fli **************************************************************/
static GstStaticCaps flx_caps = GST_STATIC_CAPS ("video/x-fli");
+
#define FLX_CAPS gst_static_caps_get(&flx_caps)
static void
-flx_type_find (GstTypeFind *tf, gpointer unused)
+flx_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8* data = gst_type_find_peek (tf, 0, 134);
+ guint8 *data = gst_type_find_peek (tf, 0, 134);
if (data) {
/* check magic and the frame type of the first frame */
if ((data[4] == 0x11 || data[4] == 0x12 ||
- data[4] == 0x30 || data[4] == 0x44) &&
+ data[4] == 0x30 || data[4] == 0x44) &&
data[5] == 0xaf &&
((data[132] == 0x00 || data[132] == 0xfa) && data[133] == 0xf1)) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, FLX_CAPS);
if (data) {
/* check magic only */
if ((data[4] == 0x11 || data[4] == 0x12 ||
- data[4] == 0x30 || data[4] == 0x44) &&
- data[5] == 0xaf) {
+ data[4] == 0x30 || data[4] == 0x44) && data[5] == 0xaf) {
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, FLX_CAPS);
}
return;
/*** application/x-id3 **************************************************************/
static GstStaticCaps id3_caps = GST_STATIC_CAPS ("application/x-id3");
+
#define ID3_CAPS gst_static_caps_get(&id3_caps)
static void
-id3_type_find (GstTypeFind *tf, gpointer unused)
+id3_type_find (GstTypeFind * tf, gpointer unused)
{
/* detect ID3v2 first */
- guint8* data = gst_type_find_peek (tf, 0, 10);
+ guint8 *data = gst_type_find_peek (tf, 0, 10);
+
if (data) {
/* detect valid header */
if (memcmp (data, "ID3", 3) == 0 &&
*/
static guint mp3types_bitrates[2][3][16] =
-{ { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, },
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, },
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, } },
- { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, } },
+ { {{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
+ {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
+ {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}},
+{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}},
};
-static guint mp3types_freqs[3][3] =
-{ {11025, 12000, 8000},
- {22050, 24000, 16000},
- {44100, 48000, 32000}};
+static guint mp3types_freqs[3][3] = { {11025, 12000, 8000},
+{22050, 24000, 16000},
+{44100, 48000, 32000}
+};
static inline guint
-mp3_type_frame_length_from_header (guint32 header, guint *put_layer,
- guint *put_channels, guint *put_bitrate,
- guint *put_samplerate)
+mp3_type_frame_length_from_header (guint32 header, guint * put_layer,
+ guint * put_channels, guint * put_bitrate, guint * put_samplerate)
{
guint bitrate, layer, length, mode, samplerate, version, channels;
if (layer == 1) {
length = ((12000 * bitrate / samplerate) + length) * 4;
} else {
- length += ((layer == 3 && version != 3) ? 72000 : 144000) * bitrate / samplerate;
+ length += ((layer == 3
+ && version != 3) ? 72000 : 144000) * bitrate / samplerate;
}
-
+
GST_LOG ("mp3typefind: alculated mp3 frame length of %u bytes", length);
- GST_LOG ("mp3typefind: samplerate = %u - bitrate = %u - layer = %u - version = %u"
- " - channels = %u",
- samplerate, bitrate, layer, version, channels);
-
+ GST_LOG
+ ("mp3typefind: samplerate = %u - bitrate = %u - layer = %u - version = %u"
+ " - channels = %u", samplerate, bitrate, layer, version, channels);
+
if (put_layer)
*put_layer = layer;
if (put_channels)
* / TRY_SYNC)
*/
#define GST_MP3_TYPEFIND_TRY_HEADERS 5
-#define GST_MP3_TYPEFIND_TRY_SYNC (GST_TYPE_FIND_MAXIMUM * 100) /* 10kB */
+#define GST_MP3_TYPEFIND_TRY_SYNC (GST_TYPE_FIND_MAXIMUM * 100) /* 10kB */
#define GST_MP3_TYPEFIND_SYNC_SIZE 2048
static void
-mp3_type_find (GstTypeFind *tf, gpointer unused)
+mp3_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = NULL;
guint size = 0;
size = GST_MP3_TYPEFIND_SYNC_SIZE;
}
if (*data == 0xFF) {
- guint8* head_data = NULL;
+ guint8 *head_data = NULL;
guint layer, bitrate, samplerate, channels;
- guint found = 0; /* number of valid headers found */
+ guint found = 0; /* number of valid headers found */
guint64 offset = skipped;
-
+
while (found < GST_MP3_TYPEFIND_TRY_HEADERS) {
guint32 head;
guint length;
guint prev_layer = 0, prev_bitrate = 0,
- prev_channels = 0, prev_samplerate = 0;
-
+ prev_channels = 0, prev_samplerate = 0;
+
if (offset + 4 <= skipped + size) {
head_data = data + offset - skipped;
} else {
}
if (!head_data)
break;
- head = GUINT32_FROM_BE(*((guint32 *) head_data));
- if (!(length = mp3_type_frame_length_from_header (head, &layer,
- &channels, &bitrate, &samplerate))) {
- GST_LOG ("%d. header at offset %"G_GUINT64_FORMAT" was not an mp3 header", found + 1, offset);
+ head = GUINT32_FROM_BE (*((guint32 *) head_data));
+ if (!(length = mp3_type_frame_length_from_header (head, &layer,
+ &channels, &bitrate, &samplerate))) {
+ GST_LOG ("%d. header at offset %" G_GUINT64_FORMAT
+ " was not an mp3 header", found + 1, offset);
break;
}
if ((prev_layer && prev_layer != layer) ||
/* (prev_bitrate && prev_bitrate != bitrate) || <-- VBR */
(prev_samplerate && prev_samplerate != samplerate) ||
(prev_channels && prev_channels != channels)) {
- /* this means an invalid property, or a change, which might mean
+ /* this means an invalid property, or a change, which might mean
* that this is not a mp3 but just a random bytestream. It could
* be a freaking funky encoded mp3 though. We'll just not count
* this header*/
offset += length;
}
g_assert (found <= GST_MP3_TYPEFIND_TRY_HEADERS);
- if (found == GST_MP3_TYPEFIND_TRY_HEADERS ||
- head_data == NULL) {
+ if (found == GST_MP3_TYPEFIND_TRY_HEADERS || head_data == NULL) {
/* we can make a valid guess */
- guint probability = found * GST_TYPE_FIND_MAXIMUM *
- (GST_MP3_TYPEFIND_TRY_SYNC - skipped) /
- GST_MP3_TYPEFIND_TRY_HEADERS / GST_MP3_TYPEFIND_TRY_SYNC;
+ guint probability = found * GST_TYPE_FIND_MAXIMUM *
+ (GST_MP3_TYPEFIND_TRY_SYNC - skipped) /
+ GST_MP3_TYPEFIND_TRY_HEADERS / GST_MP3_TYPEFIND_TRY_SYNC;
if (probability < GST_TYPE_FIND_MINIMUM)
probability = GST_TYPE_FIND_MINIMUM;
g_assert (probability <= GST_TYPE_FIND_MAXIMUM);
if (probability > 0) {
GstCaps *caps;
+
g_assert (layer > 0);
caps = gst_caps_copy (MP3_CAPS);
gst_structure_set (gst_caps_get_structure (caps, 0), "layer",
G_TYPE_INT, layer, 0);
- gst_type_find_suggest (tf, probability, caps);
+ gst_type_find_suggest (tf, probability, caps);
gst_caps_free (caps);
}
return;
(((guint8 *)data)[2] == 0x01) && \
((((guint8 *)data)[3] & 0x80) == 0x80))
static void
-mpeg2_sys_type_find (GstTypeFind *tf, gpointer unused)
+mpeg2_sys_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, 5);
if ((data[4] & 0xC0) == 0x40) {
/* type 2 */
GstCaps *caps = gst_caps_copy (MPEG_SYS_CAPS);
+
gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion",
G_TYPE_INT, 2, 0);
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, caps);
} else if ((data[4] & 0xF0) == 0x20) {
GstCaps *caps = gst_caps_copy (MPEG_SYS_CAPS);
+
gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion",
- G_TYPE_INT, 1, 0);
+ G_TYPE_INT, 1, 0);
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, caps);
gst_caps_free (caps);
}
}
};
+
/* ATTANTION: ugly return value:
* 0 - invalid data
* 1 - not enough data
* anything else - size until next package
*/
static guint
-mpeg1_parse_header (GstTypeFind *tf, guint64 offset)
+mpeg1_parse_header (GstTypeFind * tf, guint64 offset)
{
guint8 *data = gst_type_find_peek (tf, offset, 4);
guint size;
-
+
if (!data) {
GST_LOG ("couldn't get MPEG header bytes");
return 1;
offset += 4;
switch (data[3]) {
- case 0xBA: /* pack header */
+ case 0xBA: /* pack header */
data = gst_type_find_peek (tf, offset, 8);
if (!data) {
- GST_LOG ("couldn't get MPEG pack header bytes");
- return 1;
+ GST_LOG ("couldn't get MPEG pack header bytes");
+ return 1;
}
size = 12;
/* check marker bits */
if ((data[0] & 0xF1) != 0x21 ||
- (data[2] & 0x01) != 0x01 ||
- (data[4] & 0x01) != 0x01 ||
- (data[5] & 0x80) != 0x80 ||
- (data[7] & 0x01) != 0x01)
- return 0;
+ (data[2] & 0x01) != 0x01 ||
+ (data[4] & 0x01) != 0x01 ||
+ (data[5] & 0x80) != 0x80 || (data[7] & 0x01) != 0x01)
+ return 0;
break;
- case 0xB9: /* ISO end code */
+ case 0xB9: /* ISO end code */
size = 4;
break;
- case 0xBB: /* system header */
+ case 0xBB: /* system header */
data = gst_type_find_peek (tf, offset, 2);
if (!data) {
- GST_LOG ("couldn't get MPEG pack header bytes");
- return 1;
+ GST_LOG ("couldn't get MPEG pack header bytes");
+ return 1;
}
- size = GUINT16_FROM_BE (* (guint16 *) data) + 6;
+ size = GUINT16_FROM_BE (*(guint16 *) data) + 6;
offset += 2;
data = gst_type_find_peek (tf, offset, size - 6);
if (!data) {
- GST_LOG ("couldn't get MPEG pack header bytes");
- return 1;
+ GST_LOG ("couldn't get MPEG pack header bytes");
+ return 1;
}
/* check marker bits */
if ((data[0] & 0x80) != 0x80 ||
- (data[2] & 0x01) != 0x01 ||
- (data[4] & 0x20) != 0x20)
- return 0;
+ (data[2] & 0x01) != 0x01 || (data[4] & 0x20) != 0x20)
+ return 0;
/* check stream marker bits */
for (offset = 6; offset < (size - 6); offset += 3) {
- if (data[offset] <= 0xBB ||
- (data[offset + 1] & 0xC0) != 0xC0)
- return 0;
+ if (data[offset] <= 0xBB || (data[offset + 1] & 0xC0) != 0xC0)
+ return 0;
}
break;
default:
if (data[3] < 0xB9)
- return 0;
+ return 0;
data = gst_type_find_peek (tf, offset, 2);
if (!data) {
- GST_LOG ("couldn't get MPEG pack header bytes");
- return 1;
+ GST_LOG ("couldn't get MPEG pack header bytes");
+ return 1;
}
- size = GUINT16_FROM_BE (* (guint16 *) data) + 6;
+ size = GUINT16_FROM_BE (*(guint16 *) data) + 6;
/* FIXME: we could check PTS/DTS marker bits here... (bit overkill) */
break;
}
return size;
}
+
/* calculation of possibility to identify random data as mpeg systemstream:
* bits that must match in header detection: 32 (or more)
* chance that random data is identifed: 1/2^32
* = <some_number>
*/
#define GST_MPEG_TYPEFIND_TRY_HEADERS 4
-#define GST_MPEG_TYPEFIND_TRY_SYNC (100 * 1024) /* 100kB */
+#define GST_MPEG_TYPEFIND_TRY_SYNC (100 * 1024) /* 100kB */
#define GST_MPEG_TYPEFIND_SYNC_SIZE 2048
static void
-mpeg1_sys_type_find (GstTypeFind *tf, gpointer unused)
+mpeg1_sys_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = NULL;
guint size = 0;
found++;
}
g_assert (found <= GST_MPEG_TYPEFIND_TRY_HEADERS);
- if (found == GST_MPEG_TYPEFIND_TRY_HEADERS ||
- packet_size == 1) {
+ if (found == GST_MPEG_TYPEFIND_TRY_HEADERS || packet_size == 1) {
caps = gst_caps_copy (MPEG_SYS_CAPS);
gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion",
G_TYPE_INT, 1, 0);
- gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps);
+ gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps);
gst_caps_free (caps);
return;
}
"systemstream = (boolean) false");
#define MPEG_VIDEO_CAPS gst_static_caps_get(&mpeg_video_caps)
static void
-mpeg_video_type_find (GstTypeFind *tf, gpointer unused)
+mpeg_video_type_find (GstTypeFind * tf, gpointer unused)
{
static const guint8 sequence_header[] = { 0x00, 0x00, 0x01, 0xb3 };
guint8 *data = NULL;
data = gst_type_find_peek (tf, 0, 8);
- if (data && memcmp(data, sequence_header, 4)==0){
+ if (data && memcmp (data, sequence_header, 4) == 0) {
GstCaps *caps = gst_caps_copy (MPEG_VIDEO_CAPS);
+
gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion",
- G_TYPE_INT, 1, 0);
+ G_TYPE_INT, 1, 0);
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 1, caps);
gst_caps_free (caps);
}
*/
#define GST_MPEGVID_TYPEFIND_TRY_PICTURES 6
-#define GST_MPEGVID_TYPEFIND_TRY_SYNC (100 * 1024) /* 100 kB */
+#define GST_MPEGVID_TYPEFIND_TRY_SYNC (100 * 1024) /* 100 kB */
#define GST_MPEGVID_TYPEFIND_SYNC_SIZE 2048
static void
-mpeg_video_stream_type_find (GstTypeFind *tf, gpointer unused)
+mpeg_video_stream_type_find (GstTypeFind * tf, gpointer unused)
{
gint size = 0, found = 0;
guint64 skipped = 0;
while (1) {
if (found >= GST_MPEGVID_TYPEFIND_TRY_PICTURES) {
GstCaps *caps = gst_caps_copy (MPEG_VIDEO_CAPS);
+
gst_structure_set (gst_caps_get_structure (caps, 0), "mpegversion",
- G_TYPE_INT, 1, 0);
+ G_TYPE_INT, 1, 0);
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM - 2, caps);
gst_caps_free (caps);
return;
if (size < 4) {
data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE);
if (!data)
- break;
+ break;
size = GST_MPEGVID_TYPEFIND_SYNC_SIZE;
}
/* are we a sequence (0xB3) or GOP (0xB8) header? */
if (data[0] == 0x0 && data[1] == 0x0 && data[2] == 0x1 &&
- (data[3] == 0xB3 || data[3] == 0xB8)) {
+ (data[3] == 0xB3 || data[3] == 0xB8)) {
size -= 8;
data += 8;
skipped += 8;
if (data[3] == 0xB3)
- continue;
+ continue;
else if (size < 4) {
- data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE);
- size = GST_MPEGVID_TYPEFIND_SYNC_SIZE;
- if (!data)
- break;
+ data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE);
+ size = GST_MPEGVID_TYPEFIND_SYNC_SIZE;
+ if (!data)
+ break;
}
/* else, we should now see an image */
}
/* image header (and, when found, slice header) */
- if (data[0] == 0x0 && data[1] == 0x0 &&
- data[2] == 0x1 && data[4] == 0x0) {
+ if (data[0] == 0x0 && data[1] == 0x0 && data[2] == 0x1 && data[4] == 0x0) {
size -= 8;
data += 8;
skipped += 8;
if (size < 5) {
- data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE);
- size = GST_MPEGVID_TYPEFIND_SYNC_SIZE;
- if (!data)
- break;
+ data = gst_type_find_peek (tf, skipped, GST_MPEGVID_TYPEFIND_SYNC_SIZE);
+ size = GST_MPEGVID_TYPEFIND_SYNC_SIZE;
+ if (!data)
+ break;
}
if ((data[0] == 0x0 && data[1] == 0x0 &&
- data[2] == 0x1 && data[3] == 0x1) ||
- (data[1] == 0x0 && data[2] == 0x0 &&
- data[3] == 0x1 && data[4] == 0x1)) {
- size -= 4;
- data += 4;
- skipped += 4;
- found += 1;
- continue;
+ data[2] == 0x1 && data[3] == 0x1) ||
+ (data[1] == 0x0 && data[2] == 0x0 &&
+ data[3] == 0x1 && data[4] == 0x1)) {
+ size -= 4;
+ data += 4;
+ skipped += 4;
+ found += 1;
+ continue;
}
}
/*** video/quicktime***********************************************************/
static GstStaticCaps qt_caps = GST_STATIC_CAPS ("video/quicktime");
+
#define QT_CAPS gst_static_caps_get(&qt_caps)
static void
-qt_type_find (GstTypeFind *tf, gpointer unused)
+qt_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data;
guint tip = 0;
/*** audio/x-aiff *********************************************/
static GstStaticCaps aiff_caps = GST_STATIC_CAPS ("audio/x-aiff");
+
#define AIFF_CAPS gst_static_caps_get(&aiff_caps)
static void
-aiff_type_find (GstTypeFind *tf, gpointer unused)
+aiff_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, 4);
/*** audio/x-shorten ****************************************/
static GstStaticCaps shn_caps = GST_STATIC_CAPS ("audio/x-shorten");
+
#define SHN_CAPS gst_static_caps_get(&shn_caps)
static void
-shn_type_find (GstTypeFind *tf, gpointer unused)
+shn_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, 4);
+
if (data && memcmp (data, "ajkg", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SHN_CAPS);
}
/*** audio/x-m4a *********************************************/
static GstStaticCaps aac_caps = GST_STATIC_CAPS ("audio/x-m4a");
+
#define AAC_CAPS (gst_static_caps_get(&aac_caps))
static void
-m4a_type_find (GstTypeFind *tf, gpointer unused)
+m4a_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 4, 8);
+
if (data && memcmp (data, "ftypM4A ", 8) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, AAC_CAPS);
}
/*** audio/x-mod *********************************************/
static GstStaticCaps mod_caps = GST_STATIC_CAPS ("audio/x-mod");
+
#define MOD_CAPS gst_static_caps_get(&mod_caps)
/* FIXME: M15 CheckType to do */
static void
-mod_type_find (GstTypeFind *tf, gpointer unused)
+mod_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data;
-
+
/* MOD */
- if ((data = gst_type_find_peek (tf, 1080, 4)) != NULL) {
- /* Protracker and variants */
- if ((memcmp(data, "M.K.", 4) == 0) ||
- (memcmp(data, "M!K!", 4) == 0) ||
+ if ((data = gst_type_find_peek (tf, 1080, 4)) != NULL) {
+ /* Protracker and variants */
+ if ((memcmp (data, "M.K.", 4) == 0) || (memcmp (data, "M!K!", 4) == 0) ||
/* Star Tracker */
- (memcmp(data, "FLT", 3) == 0 && isdigit (data[3])) ||
- (memcmp(data, "EXO", 3) == 0 && isdigit (data[3])) ||
+ (memcmp (data, "FLT", 3) == 0 && isdigit (data[3])) ||
+ (memcmp (data, "EXO", 3) == 0 && isdigit (data[3])) ||
/* Oktalyzer (Amiga) */
- (memcmp(data, "OKTA", 4) == 0) ||
+ (memcmp (data, "OKTA", 4) == 0) ||
/* Oktalyser (Atari) */
- (memcmp(data, "CD81", 4) == 0) ||
+ (memcmp (data, "CD81", 4) == 0) ||
/* Fasttracker */
- (memcmp(data + 1, "CHN", 3) == 0 && isdigit (data[0])) ||
+ (memcmp (data + 1, "CHN", 3) == 0 && isdigit (data[0])) ||
/* Fasttracker or Taketracker */
- (memcmp(data + 2, "CH", 2) == 0 && isdigit (data[0]) && isdigit (data[1])) ||
- (memcmp(data + 2, "CN", 2) == 0 && isdigit (data[0]) && isdigit (data[1]))) {
+ (memcmp (data + 2, "CH", 2) == 0 && isdigit (data[0])
+ && isdigit (data[1])) || (memcmp (data + 2, "CN", 2) == 0
+ && isdigit (data[0]) && isdigit (data[1]))) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
return;
}
}
/* XM */
if ((data = gst_type_find_peek (tf, 0, 38)) != NULL) {
- if (memcmp(data, "Extended Module: ", 17) == 0 &&
- data[37] == 0x1A) {
+ if (memcmp (data, "Extended Module: ", 17) == 0 && data[37] == 0x1A) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
return;
}
}
/* OKT */
if (data || (data = gst_type_find_peek (tf, 0, 8)) != NULL) {
- if (memcmp(data, "OKTASONG", 8) == 0) {
+ if (memcmp (data, "OKTASONG", 8) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
return;
}
}
- if (data || (data = gst_type_find_peek (tf, 0, 4)) != NULL) {
+ if (data || (data = gst_type_find_peek (tf, 0, 4)) != NULL) {
/* 669 */
- if ((memcmp(data, "if", 2) == 0) ||
- (memcmp(data, "JN", 2) == 0)) {
+ if ((memcmp (data, "if", 2) == 0) || (memcmp (data, "JN", 2) == 0)) {
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, MOD_CAPS);
return;
}
- /* AMF */
- if ((memcmp(data, "AMF", 3) == 0 && data[3] > 10 && data[3] < 14) ||
+ /* AMF */
+ if ((memcmp (data, "AMF", 3) == 0 && data[3] > 10 && data[3] < 14) ||
/* IT */
- (memcmp(data, "IMPM", 4) == 0) ||
+ (memcmp (data, "IMPM", 4) == 0) ||
/* MED */
- (memcmp(data, "MMD0", 4) == 0) ||
- (memcmp(data, "MMD1", 4) == 0) ||
+ (memcmp (data, "MMD0", 4) == 0) || (memcmp (data, "MMD1", 4) == 0) ||
/* MTM */
- (memcmp(data, "MTM", 3) == 0)){
+ (memcmp (data, "MTM", 3) == 0)) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
return;
}
/* DSM */
- if (memcmp(data, "RIFF", 4) == 0) {
+ if (memcmp (data, "RIFF", 4) == 0) {
guint8 *data2 = gst_type_find_peek (tf, 8, 4);
+
if (data2) {
if (memcmp (data2, "DSMF", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
}
}
/* FAM */
- if (memcmp(data, "FAM\xFE", 4) == 0) {
+ if (memcmp (data, "FAM\xFE", 4) == 0) {
guint8 *data2 = gst_type_find_peek (tf, 44, 3);
+
if (data2) {
if (memcmp (data2, "compare", 3) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
}
}
/* GDM */
- if (memcmp(data, "GDM\xFE", 4) == 0) {
+ if (memcmp (data, "GDM\xFE", 4) == 0) {
guint8 *data2 = gst_type_find_peek (tf, 71, 4);
+
if (data2) {
if (memcmp (data2, "GMFS", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
}
/* IMF */
if ((data = gst_type_find_peek (tf, 60, 4)) != NULL) {
- if (memcmp(data, "IM10", 4) == 0) {
+ if (memcmp (data, "IM10", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
return;
}
}
/* S3M */
if ((data = gst_type_find_peek (tf, 44, 4)) != NULL) {
- if (memcmp(data, "SCRM", 4) == 0) {
+ if (memcmp (data, "SCRM", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, MOD_CAPS);
return;
}
/*** application/x-shockwave-flash ********************************************/
-static GstStaticCaps swf_caps = GST_STATIC_CAPS ("application/x-shockwave-flash");
+static GstStaticCaps swf_caps =
+GST_STATIC_CAPS ("application/x-shockwave-flash");
#define SWF_CAPS (gst_static_caps_get(&swf_caps))
static void
-swf_type_find (GstTypeFind *tf, gpointer unused)
+swf_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, 4);
- if (data && (data[0] == 'F' || data[0] == 'C') &&
+ if (data && (data[0] == 'F' || data[0] == 'C') &&
data[1] == 'W' && data[2] == 'S') {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SWF_CAPS);
}
/*** image/jpeg ***************************************************************/
static GstStaticCaps jpeg_caps = GST_STATIC_CAPS ("image/jpeg");
+
#define JPEG_CAPS (gst_static_caps_get(&jpeg_caps))
static void
-jpeg_type_find (GstTypeFind *tf, gpointer unused)
+jpeg_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, 10);
- guint8 header[2] = {0xFF, 0xD8};
+ guint8 header[2] = { 0xFF, 0xD8 };
if (data && memcmp (data, header, 2) == 0) {
if (memcmp (data + 6, "JFIF", 4) == 0) {
/*** image/bmp *********************/
static GstStaticCaps bmp_caps = GST_STATIC_CAPS ("image/bmp");
+
#define BMP_CAPS (gst_static_caps_get(&bmp_caps))
static void
-bmp_type_find (GstTypeFind *tf, gpointer unused)
+bmp_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data = gst_type_find_peek (tf, 0, 18);
if (data && memcmp (data, "BM", 2) == 0) {
if ((data[14] == 0x0C ||
- data[14] == 0x28 ||
- data[14] == 0xF0) &&
- data[15] == 0 &&
- data[16] == 0 &&
- data[17] == 0) {
+ data[14] == 0x28 ||
+ data[14] == 0xF0) &&
+ data[15] == 0 && data[16] == 0 && data[17] == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, BMP_CAPS);
}
}
/*** image/tiff ********************/
static GstStaticCaps tiff_caps = GST_STATIC_CAPS ("image/tiff, "
- "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }" );
+ "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }");
#define TIFF_CAPS (gst_static_caps_get(&tiff_caps))
static GstStaticCaps tiff_be_caps = GST_STATIC_CAPS ("image/tiff, "
"endianness = (int) BIG_ENDIAN");
"endianness = (int) LITTLE_ENDIAN");
#define TIFF_LE_CAPS (gst_static_caps_get(&tiff_le_caps))
static void
-tiff_type_find (GstTypeFind *tf, gpointer ununsed)
+tiff_type_find (GstTypeFind * tf, gpointer ununsed)
{
guint8 *data = gst_type_find_peek (tf, 0, 8);
- guint8 le_header[4] = {0x49, 0x49, 0x2A, 0x00};
- guint8 be_header[4] = {0x4D, 0x4D, 0x00, 0x2A};
-
+ guint8 le_header[4] = { 0x49, 0x49, 0x2A, 0x00 };
+ guint8 be_header[4] = { 0x4D, 0x4D, 0x00, 0x2A };
+
if (data) {
if (memcmp (data, le_header, 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, TIFF_LE_CAPS);
}
/*** video/x-matroska ********************/
-static GstStaticCaps matroska_caps = GST_STATIC_CAPS ("video/x-matroska" );
+static GstStaticCaps matroska_caps = GST_STATIC_CAPS ("video/x-matroska");
+
#define MATROSKA_CAPS (gst_static_caps_get(&matroska_caps))
static void
-matroska_type_find (GstTypeFind *tf, gpointer ununsed)
+matroska_type_find (GstTypeFind * tf, gpointer ununsed)
{
/* 4 bytes for EBML ID, 1 byte for header length identifier */
guint8 *data = gst_type_find_peek (tf, 0, 4 + 1);
return;
/* ebml header? */
- if (data[0] != 0x1A || data[1] != 0x45 ||
- data[2] != 0xDF || data[3] != 0xA3)
+ if (data[0] != 0x1A || data[1] != 0x45 || data[2] != 0xDF || data[3] != 0xA3)
return;
/* length of header */
"systemstream = (boolean) true");
#define DV_CAPS (gst_static_caps_get(&dv_caps))
static void
-dv_type_find (GstTypeFind *tf, gpointer private)
+dv_type_find (GstTypeFind * tf, gpointer private)
{
guint8 *data;
/* check for DIF and DV flag */
if (data && (data[0] == 0x1f) && (data[1] == 0x07) && (data[2] == 0x00) &&
- ((data[4]&0x01) == 0)){
+ ((data[4] & 0x01) == 0)) {
gchar *format;
GstCaps *caps = gst_caps_copy (DV_CAPS);
/*** audio/x-vorbis ***********************************************************/
static GstStaticCaps vorbis_caps = GST_STATIC_CAPS ("audio/x-vorbis");
+
#define VORBIS_CAPS (gst_static_caps_get(&vorbis_caps))
static void
-vorbis_type_find (GstTypeFind *tf, gpointer private)
+vorbis_type_find (GstTypeFind * tf, gpointer private)
{
guint8 *data = gst_type_find_peek (tf, 0, 30);
if (data) {
guint blocksize_0;
guint blocksize_1;
+
/* 1 byte packet type (identification=0x01)
6 byte string "vorbis"
4 byte vorbis version */
- if (memcmp (data, "\001vorbis\000\000\000\000", 11) != 0) return;
+ if (memcmp (data, "\001vorbis\000\000\000\000", 11) != 0)
+ return;
data += 11;
/* 1 byte channels must be != 0 */
- if (data[0] == 0) return;
+ if (data[0] == 0)
+ return;
data++;
/* 4 byte samplerate must be != 0 */
- if (*((guint32 *) data) == 0) return;
+ if (*((guint32 *) data) == 0)
+ return;
data += 16;
/* blocksize checks */
blocksize_0 = data[0] & 0x0F;
blocksize_1 = (data[0] & 0xF0) >> 4;
- if (blocksize_0 > blocksize_1) return;
- if (blocksize_0 < 6 || blocksize_0 > 13) return;
- if (blocksize_1 < 6 || blocksize_1 > 13) return;
+ if (blocksize_0 > blocksize_1)
+ return;
+ if (blocksize_0 < 6 || blocksize_0 > 13)
+ return;
+ if (blocksize_1 < 6 || blocksize_1 > 13)
+ return;
data++;
/* framing bit */
- if ((data[0] & 0x01) != 1) return;
+ if ((data[0] & 0x01) != 1)
+ return;
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, VORBIS_CAPS);
- }
+ }
}
/*** video/x-theora ***********************************************************/
static GstStaticCaps theora_caps = GST_STATIC_CAPS ("video/x-theora");
+
#define THEORA_CAPS (gst_static_caps_get(&theora_caps))
static void
-theora_type_find (GstTypeFind *tf, gpointer private)
+theora_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 7); //42);
+ guint8 *data = gst_type_find_peek (tf, 0, 7); //42);
if (data) {
- if (data[0] != 0x80) return;
- if (memcmp (&data[1], "theora", 6) != 0) return;
+ if (data[0] != 0x80)
+ return;
+ if (memcmp (&data[1], "theora", 6) != 0)
+ return;
/* FIXME: make this more reliable when specs are out */
}
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, THEORA_CAPS);
/*** audio/x-speex ***********************************************************/
static GstStaticCaps speex_caps = GST_STATIC_CAPS ("audio/x-speex");
+
#define SPEEX_CAPS (gst_static_caps_get(&speex_caps))
static void
-speex_type_find (GstTypeFind *tf, gpointer private)
+speex_type_find (GstTypeFind * tf, gpointer private)
{
guint8 *data = gst_type_find_peek (tf, 0, 80);
if (data) {
/* 8 byte string "Speex "
24 byte speex version string + int */
- if (memcmp (data, "Speex ", 8) != 0) return;
+ if (memcmp (data, "Speex ", 8) != 0)
+ return;
data += 32;
/* 4 byte header size >= 80 */
- if (GINT32_FROM_LE (*((gint32 *) data)) < 80) return;
+ if (GINT32_FROM_LE (*((gint32 *) data)) < 80)
+ return;
data += 4;
/* 4 byte sample rate <= 48000 */
- if (GINT32_FROM_LE (*((gint32 *) data)) > 48000) return;
+ if (GINT32_FROM_LE (*((gint32 *) data)) > 48000)
+ return;
data += 4;
/* currently there are only 3 speex modes. */
- if (GINT32_FROM_LE (*((gint32 *) data)) > 3) return;
+ if (GINT32_FROM_LE (*((gint32 *) data)) > 3)
+ return;
data += 12;
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SPEEX_CAPS);
- }
+ }
}
/*** generic typefind for streams that have some data at a specific position***/
-typedef struct {
- guint8 * data;
- guint size;
- guint probability;
- GstCaps * caps;
+typedef struct
+{
+ guint8 *data;
+ guint size;
+ guint probability;
+ GstCaps *caps;
} GstTypeFindData;
static void
-start_with_type_find (GstTypeFind *tf, gpointer private)
+start_with_type_find (GstTypeFind * tf, gpointer private)
{
GstTypeFindData *start_with = (GstTypeFindData *) private;
guint8 *data;
- GST_LOG ("trying to find mime type %s with the first %u bytes of data",
- gst_structure_get_name (gst_caps_get_structure(start_with->caps, 0)),
- start_with->size);
+ GST_LOG ("trying to find mime type %s with the first %u bytes of data",
+ gst_structure_get_name (gst_caps_get_structure (start_with->caps, 0)),
+ start_with->size);
data = gst_type_find_peek (tf, 0, start_with->size);
- if (data && memcmp (data, start_with->data, start_with->size)==0) {
+ if (data && memcmp (data, start_with->data, start_with->size) == 0) {
gst_type_find_suggest (tf, start_with->probability, start_with->caps);
}
}
+
#define TYPE_FIND_REGISTER_START_WITH(plugin,name,rank,ext,_data,_size,_probability)\
G_BEGIN_DECLS{ \
GstTypeFindData *sw_data = g_new (GstTypeFindData, 1); \
/*** same for riff types ******************************************************/
static void
-riff_type_find (GstTypeFind *tf, gpointer private)
+riff_type_find (GstTypeFind * tf, gpointer private)
{
GstTypeFindData *riff_data = (GstTypeFindData *) private;
guint8 *data = gst_type_find_peek (tf, 0, 12);
gst_type_find_suggest (tf, riff_data->probability, riff_data->caps);
}
}
+
#define TYPE_FIND_REGISTER_RIFF(plugin,name,rank,ext,_data) \
G_BEGIN_DECLS{ \
GstTypeFindData *sw_data = g_new (GstTypeFindData, 1); \
return FALSE; \
}G_END_DECLS
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* can't initialize this via a struct as caps can't be statically initialized */
-
+
/* note: asx/wax/wmx are XML files, asf doesn't handle them */
- static gchar * asf_exts[] = {"asf", "wm", "wma", "wmv", NULL};
- static gchar * au_exts[] = {"au", "snd", NULL};
- static gchar * avi_exts[] = {"avi", NULL};
- static gchar * cdxa_exts[] = {"dat", NULL};
- static gchar * flac_exts[] = {"flac", NULL};
- static gchar * flx_exts[] = {"flc", "fli", NULL};
- static gchar * id3_exts[] = {"mp3", "mp2", "mp1", "mpga", "ogg", "flac", NULL};
- static gchar * mod_exts[] = {"669", "amf", "dsm", "gdm", "far", "imf",
- "it", "med", "mod", "mtm", "okt", "sam",
- "s3m", "stm", "stx", "ult", "xm", NULL};
- static gchar * mp3_exts[] = {"mp3", "mp2", "mp1", "mpga", NULL};
- static gchar * mpeg_sys_exts[] = {"mpe", "mpeg", "mpg", NULL};
- static gchar * mpeg_video_exts[] = {"mpv", "mpeg", "mpg", NULL};
- static gchar * ogg_exts[] = {"ogg", NULL};
- static gchar * qt_exts[] = {"mov", NULL};
- static gchar * rm_exts[] = {"ra", "ram", "rm", NULL};
- static gchar * swf_exts[] = {"swf", "swfl", NULL};
- static gchar * utf8_exts[] = {"txt", NULL};
- static gchar * wav_exts[] = {"wav", NULL};
- static gchar * aiff_exts[] = {"aiff", "aif", "aifc", NULL};
- static gchar * shn_exts[] = {"shn", NULL};
- static gchar * uri_exts[] = {"ram", NULL};
- static gchar * jpeg_exts[] = {"jpg", "jpe", "jpeg", NULL};
- static gchar * gif_exts[] = {"gif", NULL};
- static gchar * png_exts[] = {"png", NULL};
- static gchar * bmp_exts[] = {"bmp", NULL};
- static gchar * tiff_exts[] = {"tif", "tiff", NULL};
- static gchar * matroska_exts[] = {"mkv", "mka", NULL};
- static gchar * dv_exts[] = {"dv", NULL};
- static gchar * sid_exts[] = {"sid", NULL};
- static gchar * xcf_exts[] = {"xcf", NULL};
- static gchar * mng_exts[] = {"mng", NULL};
- static gchar * jng_exts[] = {"jng", NULL};
- static gchar * xpm_exts[] = {"xpm", NULL};
- static gchar * ras_exts[] = {"ras", NULL};
- static gchar * bz2_exts[] = {"bz2", NULL};
- static gchar * gz_exts[] = {"gz", NULL};
- static gchar * zip_exts[] = {"zip", NULL};
- static gchar * compress_exts[] = {"Z", NULL};
- static gchar * m4a_exts[] = {"m4a", NULL};
-
- GST_DEBUG_CATEGORY_INIT (type_find_debug, "typefindfunctions", GST_DEBUG_FG_GREEN | GST_DEBUG_BG_RED, "generic type find functions");
+ static gchar *asf_exts[] = { "asf", "wm", "wma", "wmv", NULL };
+ static gchar *au_exts[] = { "au", "snd", NULL };
+ static gchar *avi_exts[] = { "avi", NULL };
+ static gchar *cdxa_exts[] = { "dat", NULL };
+ static gchar *flac_exts[] = { "flac", NULL };
+ static gchar *flx_exts[] = { "flc", "fli", NULL };
+ static gchar *id3_exts[] =
+ { "mp3", "mp2", "mp1", "mpga", "ogg", "flac", NULL };
+ static gchar *mod_exts[] = { "669", "amf", "dsm", "gdm", "far", "imf",
+ "it", "med", "mod", "mtm", "okt", "sam",
+ "s3m", "stm", "stx", "ult", "xm", NULL
+ };
+ static gchar *mp3_exts[] = { "mp3", "mp2", "mp1", "mpga", NULL };
+ static gchar *mpeg_sys_exts[] = { "mpe", "mpeg", "mpg", NULL };
+ static gchar *mpeg_video_exts[] = { "mpv", "mpeg", "mpg", NULL };
+ static gchar *ogg_exts[] = { "ogg", NULL };
+ static gchar *qt_exts[] = { "mov", NULL };
+ static gchar *rm_exts[] = { "ra", "ram", "rm", NULL };
+ static gchar *swf_exts[] = { "swf", "swfl", NULL };
+ static gchar *utf8_exts[] = { "txt", NULL };
+ static gchar *wav_exts[] = { "wav", NULL };
+ static gchar *aiff_exts[] = { "aiff", "aif", "aifc", NULL };
+ static gchar *shn_exts[] = { "shn", NULL };
+ static gchar *uri_exts[] = { "ram", NULL };
+ static gchar *jpeg_exts[] = { "jpg", "jpe", "jpeg", NULL };
+ static gchar *gif_exts[] = { "gif", NULL };
+ static gchar *png_exts[] = { "png", NULL };
+ static gchar *bmp_exts[] = { "bmp", NULL };
+ static gchar *tiff_exts[] = { "tif", "tiff", NULL };
+ static gchar *matroska_exts[] = { "mkv", "mka", NULL };
+ static gchar *dv_exts[] = { "dv", NULL };
+ static gchar *sid_exts[] = { "sid", NULL };
+ static gchar *xcf_exts[] = { "xcf", NULL };
+ static gchar *mng_exts[] = { "mng", NULL };
+ static gchar *jng_exts[] = { "jng", NULL };
+ static gchar *xpm_exts[] = { "xpm", NULL };
+ static gchar *ras_exts[] = { "ras", NULL };
+ static gchar *bz2_exts[] = { "bz2", NULL };
+ static gchar *gz_exts[] = { "gz", NULL };
+ static gchar *zip_exts[] = { "zip", NULL };
+ static gchar *compress_exts[] = { "Z", NULL };
+ static gchar *m4a_exts[] = { "m4a", NULL };
+
+ GST_DEBUG_CATEGORY_INIT (type_find_debug, "typefindfunctions",
+ GST_DEBUG_FG_GREEN | GST_DEBUG_BG_RED, "generic type find functions");
/* must use strings, macros don't accept initializers */
- TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-ms-asf", GST_RANK_SECONDARY, asf_exts,
- "\060\046\262\165\216\146\317\021\246\331\000\252\000\142\316\154",
- 16, GST_TYPE_FIND_MAXIMUM);
- TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-au", GST_RANK_MARGINAL, au_exts,
- ".snd", 4, GST_TYPE_FIND_MAXIMUM);
- TYPE_FIND_REGISTER_RIFF (plugin, "video/x-msvideo", GST_RANK_PRIMARY, avi_exts, "AVI ");
- TYPE_FIND_REGISTER_RIFF (plugin, "video/x-cdxa", GST_RANK_SECONDARY, cdxa_exts, "CDXA");
+ TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-ms-asf", GST_RANK_SECONDARY,
+ asf_exts,
+ "\060\046\262\165\216\146\317\021\246\331\000\252\000\142\316\154", 16,
+ GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-au", GST_RANK_MARGINAL,
+ au_exts, ".snd", 4, GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER_RIFF (plugin, "video/x-msvideo", GST_RANK_PRIMARY,
+ avi_exts, "AVI ");
+ TYPE_FIND_REGISTER_RIFF (plugin, "video/x-cdxa", GST_RANK_SECONDARY,
+ cdxa_exts, "CDXA");
TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-flac", GST_RANK_PRIMARY,
- flac_exts, "fLaC", 4, GST_TYPE_FIND_MAXIMUM);
- TYPE_FIND_REGISTER (plugin, "video/x-fli", GST_RANK_MARGINAL,
- flx_type_find, flx_exts, FLX_CAPS, NULL);
+ flac_exts, "fLaC", 4, GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER (plugin, "video/x-fli", GST_RANK_MARGINAL, flx_type_find,
+ flx_exts, FLX_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "application/x-id3", GST_RANK_PRIMARY,
- id3_type_find, id3_exts, ID3_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "audio/x-mod", GST_RANK_SECONDARY,
- mod_type_find, mod_exts, MOD_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "audio/mpeg", GST_RANK_PRIMARY,
- mp3_type_find, mp3_exts, MP3_CAPS, NULL);
+ id3_type_find, id3_exts, ID3_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "audio/x-mod", GST_RANK_SECONDARY, mod_type_find,
+ mod_exts, MOD_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "audio/mpeg", GST_RANK_PRIMARY, mp3_type_find,
+ mp3_exts, MP3_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "video/mpeg1", GST_RANK_PRIMARY,
- mpeg1_sys_type_find, mpeg_sys_exts, MPEG_SYS_CAPS, NULL);
+ mpeg1_sys_type_find, mpeg_sys_exts, MPEG_SYS_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "video/mpeg2", GST_RANK_SECONDARY,
- mpeg2_sys_type_find, mpeg_sys_exts, MPEG_SYS_CAPS, NULL);
+ mpeg2_sys_type_find, mpeg_sys_exts, MPEG_SYS_CAPS, NULL);
TYPE_FIND_REGISTER_START_WITH (plugin, "application/ogg", GST_RANK_PRIMARY,
- ogg_exts, "OggS", 4, GST_TYPE_FIND_MAXIMUM);
+ ogg_exts, "OggS", 4, GST_TYPE_FIND_MAXIMUM);
TYPE_FIND_REGISTER (plugin, "video/mpeg", GST_RANK_SECONDARY,
- mpeg_video_type_find, mpeg_video_exts, MPEG_VIDEO_CAPS, NULL);
+ mpeg_video_type_find, mpeg_video_exts, MPEG_VIDEO_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "video/mpeg", GST_RANK_MARGINAL,
- mpeg_video_stream_type_find, mpeg_video_exts, MPEG_VIDEO_CAPS, NULL);
+ mpeg_video_stream_type_find, mpeg_video_exts, MPEG_VIDEO_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "video/quicktime", GST_RANK_SECONDARY,
- qt_type_find, qt_exts, QT_CAPS, NULL);
- TYPE_FIND_REGISTER_START_WITH (plugin, "application/vnd.rn-realmedia", GST_RANK_SECONDARY,
- rm_exts, ".RMF", 4, GST_TYPE_FIND_MAXIMUM);
- TYPE_FIND_REGISTER (plugin, "application/x-shockwave-flash", GST_RANK_SECONDARY,
- swf_type_find, swf_exts, SWF_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "text/plain", GST_RANK_MARGINAL,
- utf8_type_find, utf8_exts, UTF8_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "text/uri-list", GST_RANK_MARGINAL,
- uri_type_find, uri_exts, URI_CAPS, NULL);
- TYPE_FIND_REGISTER_RIFF (plugin, "audio/x-wav", GST_RANK_PRIMARY, wav_exts, "WAVE");
+ qt_type_find, qt_exts, QT_CAPS, NULL);
+ TYPE_FIND_REGISTER_START_WITH (plugin, "application/vnd.rn-realmedia",
+ GST_RANK_SECONDARY, rm_exts, ".RMF", 4, GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER (plugin, "application/x-shockwave-flash",
+ GST_RANK_SECONDARY, swf_type_find, swf_exts, SWF_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "text/plain", GST_RANK_MARGINAL, utf8_type_find,
+ utf8_exts, UTF8_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "text/uri-list", GST_RANK_MARGINAL, uri_type_find,
+ uri_exts, URI_CAPS, NULL);
+ TYPE_FIND_REGISTER_RIFF (plugin, "audio/x-wav", GST_RANK_PRIMARY, wav_exts,
+ "WAVE");
TYPE_FIND_REGISTER (plugin, "audio/x-aiff", GST_RANK_SECONDARY,
- aiff_type_find, aiff_exts, AIFF_CAPS, NULL);
+ aiff_type_find, aiff_exts, AIFF_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "audio/x-shorten", GST_RANK_SECONDARY,
- shn_type_find, shn_exts, SHN_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "image/jpeg", GST_RANK_PRIMARY,
- jpeg_type_find, jpeg_exts, JPEG_CAPS, NULL);
+ shn_type_find, shn_exts, SHN_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "image/jpeg", GST_RANK_PRIMARY, jpeg_type_find,
+ jpeg_exts, JPEG_CAPS, NULL);
TYPE_FIND_REGISTER_START_WITH (plugin, "image/gif", GST_RANK_PRIMARY,
- gif_exts, "GIF8", 4, GST_TYPE_FIND_MAXIMUM);
+ gif_exts, "GIF8", 4, GST_TYPE_FIND_MAXIMUM);
TYPE_FIND_REGISTER_START_WITH (plugin, "image/png", GST_RANK_PRIMARY,
- png_exts, "\211PNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM);
- TYPE_FIND_REGISTER (plugin, "image/bmp", GST_RANK_PRIMARY,
- bmp_type_find, bmp_exts, BMP_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "image/tiff", GST_RANK_PRIMARY,
- tiff_type_find, tiff_exts, TIFF_CAPS, NULL);
+ png_exts, "\211PNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER (plugin, "image/bmp", GST_RANK_PRIMARY, bmp_type_find,
+ bmp_exts, BMP_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "image/tiff", GST_RANK_PRIMARY, tiff_type_find,
+ tiff_exts, TIFF_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "video/x-matroska", GST_RANK_PRIMARY,
- matroska_type_find, matroska_exts, MATROSKA_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "video/x-dv", GST_RANK_SECONDARY,
- dv_type_find, dv_exts, DV_CAPS, NULL);
+ matroska_type_find, matroska_exts, MATROSKA_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "video/x-dv", GST_RANK_SECONDARY, dv_type_find,
+ dv_exts, DV_CAPS, NULL);
TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-sid", GST_RANK_MARGINAL,
- sid_exts, "PSID", 4, GST_TYPE_FIND_MAXIMUM);
+ sid_exts, "PSID", 4, GST_TYPE_FIND_MAXIMUM);
TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-xcf", GST_RANK_SECONDARY,
- xcf_exts, "gimp xcf", 8, GST_TYPE_FIND_MAXIMUM);
+ xcf_exts, "gimp xcf", 8, GST_TYPE_FIND_MAXIMUM);
TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-mng", GST_RANK_SECONDARY,
- mng_exts, "\212MNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM);
+ mng_exts, "\212MNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM);
TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-jng", GST_RANK_SECONDARY,
- jng_exts, "\213JNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM);
+ jng_exts, "\213JNG\015\012\032\012", 8, GST_TYPE_FIND_MAXIMUM);
TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-xpixmap", GST_RANK_SECONDARY,
- xpm_exts, "/* XPM */", 9, GST_TYPE_FIND_MAXIMUM);
- TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-sun-raster", GST_RANK_SECONDARY,
- ras_exts, "\131\246\152\225", 4, GST_TYPE_FIND_MAXIMUM);
- TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-bzip", GST_RANK_SECONDARY,
- bz2_exts, "BZh", 3, GST_TYPE_FIND_LIKELY);
- TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-gzip", GST_RANK_SECONDARY,
- gz_exts, "\037\213", 2, GST_TYPE_FIND_LIKELY);
+ xpm_exts, "/* XPM */", 9, GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER_START_WITH (plugin, "image/x-sun-raster",
+ GST_RANK_SECONDARY, ras_exts, "\131\246\152\225", 4,
+ GST_TYPE_FIND_MAXIMUM);
+ TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-bzip",
+ GST_RANK_SECONDARY, bz2_exts, "BZh", 3, GST_TYPE_FIND_LIKELY);
+ TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-gzip",
+ GST_RANK_SECONDARY, gz_exts, "\037\213", 2, GST_TYPE_FIND_LIKELY);
TYPE_FIND_REGISTER_START_WITH (plugin, "application/zip", GST_RANK_SECONDARY,
- zip_exts, "PK\003\004", 4, GST_TYPE_FIND_LIKELY);
- TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-compress", GST_RANK_SECONDARY,
- compress_exts, "\037\235", 2, GST_TYPE_FIND_LIKELY);
+ zip_exts, "PK\003\004", 4, GST_TYPE_FIND_LIKELY);
+ TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-compress",
+ GST_RANK_SECONDARY, compress_exts, "\037\235", 2, GST_TYPE_FIND_LIKELY);
TYPE_FIND_REGISTER (plugin, "audio/x-vorbis", GST_RANK_PRIMARY,
- vorbis_type_find, NULL, VORBIS_CAPS, NULL);
+ vorbis_type_find, NULL, VORBIS_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "video/x-theora", GST_RANK_PRIMARY,
- theora_type_find, NULL, THEORA_CAPS, NULL);
+ theora_type_find, NULL, THEORA_CAPS, NULL);
TYPE_FIND_REGISTER (plugin, "audio/x-speex", GST_RANK_PRIMARY,
- speex_type_find, NULL, SPEEX_CAPS, NULL);
- TYPE_FIND_REGISTER (plugin, "audio/x-m4a", GST_RANK_PRIMARY,
- m4a_type_find, m4a_exts, AAC_CAPS, NULL);
-
+ speex_type_find, NULL, SPEEX_CAPS, NULL);
+ TYPE_FIND_REGISTER (plugin, "audio/x-m4a", GST_RANK_PRIMARY, m4a_type_find,
+ m4a_exts, AAC_CAPS, NULL);
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "typefindfunctions",
- "default typefind functions",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "typefindfunctions",
+ "default typefind functions",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
GST_DEBUG_CATEGORY (videoscale_debug);
/* elementfactory information */
-static GstElementDetails videoscale_details = GST_ELEMENT_DETAILS (
- "Video scaler",
- "Filter/Effect/Video",
- "Resizes video",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails videoscale_details =
+GST_ELEMENT_DETAILS ("Video scaler",
+ "Filter/Effect/Video",
+ "Resizes video",
+ "Wim Taymans <wim.taymans@chello.be>");
/* GstVideoscale signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_METHOD,
/* FILL ME */
{
static GType videoscale_method_type = 0;
static GEnumValue videoscale_methods[] = {
- { GST_VIDEOSCALE_POINT_SAMPLE, "0", "Point Sample" },
- { GST_VIDEOSCALE_NEAREST, "1", "Nearest" },
- { GST_VIDEOSCALE_BILINEAR, "2", "Bilinear" },
- { GST_VIDEOSCALE_BICUBIC, "3", "Bicubic" },
- { 0, NULL, NULL },
+ {GST_VIDEOSCALE_POINT_SAMPLE, "0", "Point Sample"},
+ {GST_VIDEOSCALE_NEAREST, "1", "Nearest"},
+ {GST_VIDEOSCALE_BILINEAR, "2", "Bilinear"},
+ {GST_VIDEOSCALE_BICUBIC, "3", "Bicubic"},
+ {0, NULL, NULL},
};
if (!videoscale_method_type) {
- videoscale_method_type = g_enum_register_static ("GstVideoscaleMethod", videoscale_methods);
+ videoscale_method_type =
+ g_enum_register_static ("GstVideoscaleMethod", videoscale_methods);
}
return videoscale_method_type;
}
static GstCaps *
-gst_videoscale_get_capslist(void)
+gst_videoscale_get_capslist (void)
{
GstCaps *caps;
int i;
- caps = gst_caps_new_empty();
- for(i=0;i<videoscale_n_formats;i++){
+ caps = gst_caps_new_empty ();
+ for (i = 0; i < videoscale_n_formats; i++) {
gst_caps_append_structure (caps,
videoscale_get_structure (videoscale_formats + i));
}
}
static GstPadTemplate *
-gst_videoscale_src_template_factory(void)
+gst_videoscale_src_template_factory (void)
{
return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_videoscale_get_capslist());
+ gst_videoscale_get_capslist ());
}
static GstPadTemplate *
-gst_videoscale_sink_template_factory(void)
+gst_videoscale_sink_template_factory (void)
{
return gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_videoscale_get_capslist());
+ gst_videoscale_get_capslist ());
}
-static void gst_videoscale_base_init (gpointer g_class);
-static void gst_videoscale_class_init (GstVideoscaleClass *klass);
-static void gst_videoscale_init (GstVideoscale *videoscale);
-static gboolean gst_videoscale_handle_src_event (GstPad *pad, GstEvent *event);
+static void gst_videoscale_base_init (gpointer g_class);
+static void gst_videoscale_class_init (GstVideoscaleClass * klass);
+static void gst_videoscale_init (GstVideoscale * videoscale);
+static gboolean gst_videoscale_handle_src_event (GstPad * pad,
+ GstEvent * event);
-static void gst_videoscale_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_videoscale_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_videoscale_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_videoscale_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_videoscale_chain (GstPad *pad, GstData *_data);
-static GstCaps * gst_videoscale_get_capslist(void);
+static void gst_videoscale_chain (GstPad * pad, GstData * _data);
+static GstCaps *gst_videoscale_get_capslist (void);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_videoscale_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!videoscale_type) {
static const GTypeInfo videoscale_info = {
- sizeof(GstVideoscaleClass),
+ sizeof (GstVideoscaleClass),
gst_videoscale_base_init,
NULL,
- (GClassInitFunc)gst_videoscale_class_init,
+ (GClassInitFunc) gst_videoscale_class_init,
NULL,
NULL,
- sizeof(GstVideoscale),
+ sizeof (GstVideoscale),
0,
- (GInstanceInitFunc)gst_videoscale_init,
+ (GInstanceInitFunc) gst_videoscale_init,
};
- videoscale_type = g_type_register_static(GST_TYPE_ELEMENT, "GstVideoscale", &videoscale_info, 0);
+ videoscale_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstVideoscale",
+ &videoscale_info, 0);
}
return videoscale_type;
}
gst_element_class_set_details (element_class, &videoscale_details);
- gst_element_class_add_pad_template (element_class, gst_videoscale_sink_template_factory());
- gst_element_class_add_pad_template (element_class, gst_videoscale_src_template_factory());
+ gst_element_class_add_pad_template (element_class,
+ gst_videoscale_sink_template_factory ());
+ gst_element_class_add_pad_template (element_class,
+ gst_videoscale_src_template_factory ());
}
static void
-gst_videoscale_class_init (GstVideoscaleClass *klass)
+gst_videoscale_class_init (GstVideoscaleClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD,
- g_param_spec_enum("method","method","method",
- GST_TYPE_VIDEOSCALE_METHOD,0,G_PARAM_READWRITE)); /* CHECKME! */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_METHOD, g_param_spec_enum ("method", "method", "method", GST_TYPE_VIDEOSCALE_METHOD, 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_videoscale_set_property;
gobject_class->get_property = gst_videoscale_get_property;
}
static GstCaps *
-gst_videoscale_getcaps (GstPad *pad)
+gst_videoscale_getcaps (GstPad * pad)
{
GstVideoscale *videoscale;
GstCaps *othercaps;
GST_DEBUG ("gst_videoscale_getcaps");
videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
-
+
otherpad = (pad == videoscale->srcpad) ? videoscale->sinkpad :
- videoscale->srcpad;
+ videoscale->srcpad;
othercaps = gst_pad_get_allowed_caps (otherpad);
GST_DEBUG ("othercaps are: %" GST_PTR_FORMAT, othercaps);
caps = gst_caps_copy (othercaps);
- for(i=0;i<gst_caps_get_size(caps);i++) {
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
GstStructure *structure = gst_caps_get_structure (caps, i);
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 16, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 16, G_MAXINT,
- NULL);
+ "height", GST_TYPE_INT_RANGE, 16, G_MAXINT, NULL);
}
GST_DEBUG ("returning caps: %" GST_PTR_FORMAT, caps);
static GstPadLinkReturn
-gst_videoscale_link (GstPad *pad, const GstCaps *caps)
+gst_videoscale_link (GstPad * pad, const GstCaps * caps)
{
GstVideoscale *videoscale;
GstPadLinkReturn ret;
videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
otherpad = (pad == videoscale->srcpad) ? videoscale->sinkpad :
- videoscale->srcpad;
+ videoscale->srcpad;
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width", &width);
format = videoscale_find_by_structure (structure);
- if(!ret || format==NULL) return GST_PAD_LINK_REFUSED;
+ if (!ret || format == NULL)
+ return GST_PAD_LINK_REFUSED;
ret = gst_pad_try_set_caps (otherpad, caps);
if (ret == GST_PAD_LINK_OK) {
if (pad == videoscale->srcpad) {
gst_caps_set_simple (newcaps,
- "width", G_TYPE_INT, videoscale->from_width,
- "height", G_TYPE_INT, videoscale->from_height,
- NULL);
+ "width", G_TYPE_INT, videoscale->from_width,
+ "height", G_TYPE_INT, videoscale->from_height, NULL);
} else {
gst_caps_set_simple (newcaps,
- "width", G_TYPE_INT, videoscale->to_width,
- "height", G_TYPE_INT, videoscale->to_height,
- NULL);
+ "width", G_TYPE_INT, videoscale->to_width,
+ "height", G_TYPE_INT, videoscale->to_height, NULL);
}
ret = gst_pad_try_set_caps (otherpad, newcaps);
if (GST_PAD_LINK_FAILED (ret)) {
}
static void
-gst_videoscale_init (GstVideoscale *videoscale)
+gst_videoscale_init (GstVideoscale * videoscale)
{
GST_DEBUG_OBJECT (videoscale, "_init");
- videoscale->sinkpad = gst_pad_new_from_template (
- gst_videoscale_sink_template_factory(),
- "sink");
- gst_element_add_pad(GST_ELEMENT(videoscale),videoscale->sinkpad);
- gst_pad_set_chain_function(videoscale->sinkpad,gst_videoscale_chain);
- gst_pad_set_link_function(videoscale->sinkpad,gst_videoscale_link);
- gst_pad_set_getcaps_function(videoscale->sinkpad,gst_videoscale_getcaps);
-
- videoscale->srcpad = gst_pad_new_from_template (
- gst_videoscale_src_template_factory(),
- "src");
- gst_element_add_pad(GST_ELEMENT(videoscale),videoscale->srcpad);
- gst_pad_set_event_function (videoscale->srcpad, gst_videoscale_handle_src_event);
- gst_pad_set_link_function(videoscale->srcpad,gst_videoscale_link);
- gst_pad_set_getcaps_function(videoscale->srcpad,gst_videoscale_getcaps);
+ videoscale->sinkpad =
+ gst_pad_new_from_template (gst_videoscale_sink_template_factory (),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (videoscale), videoscale->sinkpad);
+ gst_pad_set_chain_function (videoscale->sinkpad, gst_videoscale_chain);
+ gst_pad_set_link_function (videoscale->sinkpad, gst_videoscale_link);
+ gst_pad_set_getcaps_function (videoscale->sinkpad, gst_videoscale_getcaps);
+
+ videoscale->srcpad =
+ gst_pad_new_from_template (gst_videoscale_src_template_factory (), "src");
+ gst_element_add_pad (GST_ELEMENT (videoscale), videoscale->srcpad);
+ gst_pad_set_event_function (videoscale->srcpad,
+ gst_videoscale_handle_src_event);
+ gst_pad_set_link_function (videoscale->srcpad, gst_videoscale_link);
+ gst_pad_set_getcaps_function (videoscale->srcpad, gst_videoscale_getcaps);
videoscale->inited = FALSE;
}
static gboolean
-gst_videoscale_handle_src_event (GstPad *pad, GstEvent *event)
+gst_videoscale_handle_src_event (GstPad * pad, GstEvent * event)
{
GstVideoscale *videoscale;
double a;
case GST_EVENT_NAVIGATION:
structure = gst_structure_copy (event->event_data.structure.structure);
if (gst_structure_get_double (event->event_data.structure.structure,
- "pointer_x", &a)) {
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
- a*videoscale->from_width/videoscale->to_width, NULL);
+ "pointer_x", &a)) {
+ gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE,
+ a * videoscale->from_width / videoscale->to_width, NULL);
}
if (gst_structure_get_double (event->event_data.structure.structure,
- "pointer_y", &a)) {
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
- a*videoscale->from_height/videoscale->to_height, NULL);
+ "pointer_y", &a)) {
+ gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE,
+ a * videoscale->from_height / videoscale->to_height, NULL);
}
gst_event_unref (event);
new_event = gst_event_new (GST_EVENT_NAVIGATION);
}
static void
-gst_videoscale_chain (GstPad *pad, GstData *_data)
+gst_videoscale_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstVideoscale *videoscale;
videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
g_return_if_fail (videoscale->inited);
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
- if(videoscale->passthru){
- GST_LOG_OBJECT (videoscale, "passing through buffer of %ld bytes in '%s'",
- size, GST_OBJECT_NAME (videoscale));
+ if (videoscale->passthru) {
+ GST_LOG_OBJECT (videoscale, "passing through buffer of %ld bytes in '%s'",
+ size, GST_OBJECT_NAME (videoscale));
gst_pad_push (videoscale->srcpad, GST_DATA (buf));
return;
}
- GST_LOG_OBJECT (videoscale, "got buffer of %ld bytes in '%s'",size,
- GST_OBJECT_NAME (videoscale));
- GST_LOG_OBJECT (videoscale, "size=%ld from=%dx%d to=%dx%d fromsize=%ld (should be %d) tosize=%d",
- size,
- videoscale->from_width, videoscale->from_height,
- videoscale->to_width, videoscale->to_height,
- size, videoscale->from_buf_size,
- videoscale->to_buf_size);
+ GST_LOG_OBJECT (videoscale, "got buffer of %ld bytes in '%s'", size,
+ GST_OBJECT_NAME (videoscale));
+ GST_LOG_OBJECT (videoscale,
+ "size=%ld from=%dx%d to=%dx%d fromsize=%ld (should be %d) tosize=%d",
+ size, videoscale->from_width, videoscale->from_height,
+ videoscale->to_width, videoscale->to_height, size,
+ videoscale->from_buf_size, videoscale->to_buf_size);
g_return_if_fail (size == videoscale->from_buf_size);
outbuf = gst_pad_alloc_buffer (videoscale->srcpad,
- GST_BUFFER_OFFSET_NONE, videoscale->to_buf_size);
-
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
+ GST_BUFFER_OFFSET_NONE, videoscale->to_buf_size);
+
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
- g_return_if_fail(videoscale->format);
- GST_DEBUG_OBJECT (videoscale, "format " GST_FOURCC_FORMAT,GST_FOURCC_ARGS(videoscale->format->fourcc));
- g_return_if_fail(videoscale->format->scale);
+ g_return_if_fail (videoscale->format);
+ GST_DEBUG_OBJECT (videoscale, "format " GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (videoscale->format->fourcc));
+ g_return_if_fail (videoscale->format->scale);
- videoscale->format->scale(videoscale, GST_BUFFER_DATA(outbuf), data);
+ videoscale->format->scale (videoscale, GST_BUFFER_DATA (outbuf), data);
- GST_DEBUG_OBJECT (videoscale, "pushing buffer of %d bytes in '%s'",GST_BUFFER_SIZE(outbuf),
- GST_OBJECT_NAME (videoscale));
+ GST_DEBUG_OBJECT (videoscale, "pushing buffer of %d bytes in '%s'",
+ GST_BUFFER_SIZE (outbuf), GST_OBJECT_NAME (videoscale));
- gst_pad_push(videoscale->srcpad, GST_DATA (outbuf));
+ gst_pad_push (videoscale->srcpad, GST_DATA (outbuf));
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_videoscale_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_videoscale_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstVideoscale *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VIDEOSCALE(object));
- src = GST_VIDEOSCALE(object);
+ g_return_if_fail (GST_IS_VIDEOSCALE (object));
+ src = GST_VIDEOSCALE (object);
GST_DEBUG_OBJECT (src, "gst_videoscale_set_property");
switch (prop_id) {
}
static void
-gst_videoscale_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_videoscale_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstVideoscale *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VIDEOSCALE(object));
- src = GST_VIDEOSCALE(object);
+ g_return_if_fail (GST_IS_VIDEOSCALE (object));
+ src = GST_VIDEOSCALE (object);
switch (prop_id) {
case ARG_METHOD:
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "videoscale", GST_RANK_NONE, GST_TYPE_VIDEOSCALE))
+ if (!gst_element_register (plugin, "videoscale", GST_RANK_NONE,
+ GST_TYPE_VIDEOSCALE))
return FALSE;
- GST_DEBUG_CATEGORY_INIT (videoscale_debug, "videoscale", 0, "videoscale element");
+ GST_DEBUG_CATEGORY_INIT (videoscale_debug, "videoscale", 0,
+ "videoscale element");
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "videoscale",
- "Resizes video",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "videoscale",
+ "Resizes video", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/* debugging */
-GST_DEBUG_CATEGORY_EXTERN (videoscale_debug);
+ GST_DEBUG_CATEGORY_EXTERN (videoscale_debug);
#define GST_CAT_DEFAULT videoscale_debug
#define GST_TYPE_VIDEOSCALE \
#define GST_IS_VIDEOSCALE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEOSCALE))
-typedef enum {
- GST_VIDEOSCALE_POINT_SAMPLE,
- GST_VIDEOSCALE_NEAREST,
- GST_VIDEOSCALE_BILINEAR,
- GST_VIDEOSCALE_BICUBIC
-} GstVideoScaleMethod;
-
-typedef struct _GstVideoscale GstVideoscale;
-typedef struct _GstVideoscaleClass GstVideoscaleClass;
-
-struct _GstVideoscale {
- GstElement element;
-
- GstPad *sinkpad,*srcpad;
-
- /* video state */
- gboolean inited;
- struct videoscale_format_struct *format;
- gint to_width;
- gint to_height;
- gint from_width;
- gint from_height;
- gboolean passthru;
- float framerate;
-
- GstVideoScaleMethod method;
-
- /* private */
- gint from_buf_size;
- gint to_buf_size;
+ typedef enum
+ {
+ GST_VIDEOSCALE_POINT_SAMPLE,
+ GST_VIDEOSCALE_NEAREST,
+ GST_VIDEOSCALE_BILINEAR,
+ GST_VIDEOSCALE_BICUBIC
+ } GstVideoScaleMethod;
+
+ typedef struct _GstVideoscale GstVideoscale;
+ typedef struct _GstVideoscaleClass GstVideoscaleClass;
+
+ struct _GstVideoscale
+ {
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+ /* video state */
+ gboolean inited;
+ struct videoscale_format_struct *format;
+ gint to_width;
+ gint to_height;
+ gint from_width;
+ gint from_height;
+ gboolean passthru;
+ float framerate;
+
+ GstVideoScaleMethod method;
+
+ /* private */
+ gint from_buf_size;
+ gint to_buf_size;
#if 0
- guchar *temp;
- guchar (*filter) (guchar *src, gdouble x, gdouble y, gint sw, gint sh);
- guchar copy_row[8192];
+ guchar *temp;
+ guchar (*filter) (guchar * src, gdouble x, gdouble y, gint sw, gint sh);
+ guchar copy_row[8192];
#endif
-};
+ };
-struct _GstVideoscaleClass {
- GstElementClass parent_class;
-};
+ struct _GstVideoscaleClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_videoscale_get_type(void);
+ GType gst_videoscale_get_type (void);
-void gst_videoscale_setup(GstVideoscale *);
+ void gst_videoscale_setup (GstVideoscale *);
#define gst_videoscale_scale(scale, src, dest) (scale)->scale_cc((scale), (src), (dest))
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_VIDEOSCALE_H__ */
+#endif /* __GST_VIDEOSCALE_H__ */
#endif
/* scalers */
-static void gst_videoscale_scale_nearest (GstVideoscale *scale, unsigned char *dest, unsigned char *src,
- int sw, int sh, int dw, int dh);
+static void gst_videoscale_scale_nearest (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
#if 0
-static void gst_videoscale_scale_plane_slow (GstVideoscale *scale, unsigned char *src, unsigned char *dest,
- int sw, int sh, int dw, int dh);
-static void gst_videoscale_scale_point_sample (GstVideoscale *scale, unsigned char *src, unsigned char *dest,
- int sw, int sh, int dw, int dh);
+static void gst_videoscale_scale_plane_slow (GstVideoscale * scale,
+ unsigned char *src, unsigned char *dest, int sw, int sh, int dw, int dh);
+static void gst_videoscale_scale_point_sample (GstVideoscale * scale,
+ unsigned char *src, unsigned char *dest, int sw, int sh, int dw, int dh);
/* filters */
-static unsigned char gst_videoscale_bilinear (unsigned char *src, double x, double y, int sw, int sh);
-static unsigned char gst_videoscale_bicubic (unsigned char *src, double x, double y, int sw, int sh);
+static unsigned char gst_videoscale_bilinear (unsigned char *src, double x,
+ double y, int sw, int sh);
+static unsigned char gst_videoscale_bicubic (unsigned char *src, double x,
+ double y, int sw, int sh);
#endif
-static void gst_videoscale_planar411 (GstVideoscale *scale, unsigned char *dest, unsigned char *src);
-static void gst_videoscale_planar400 (GstVideoscale *scale, unsigned char *dest, unsigned char *src);
-static void gst_videoscale_packed422 (GstVideoscale *scale, unsigned char *dest, unsigned char *src);
-static void gst_videoscale_packed422rev (GstVideoscale *scale, unsigned char *dest, unsigned char *src);
-static void gst_videoscale_32bit (GstVideoscale *scale, unsigned char *dest, unsigned char *src);
-static void gst_videoscale_24bit (GstVideoscale *scale, unsigned char *dest, unsigned char *src);
-static void gst_videoscale_16bit (GstVideoscale *scale, unsigned char *dest, unsigned char *src);
-
-static void gst_videoscale_scale_nearest_str2 (GstVideoscale *scale,
- unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
-static void gst_videoscale_scale_nearest_str4 (GstVideoscale *scale,
- unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
-static void gst_videoscale_scale_nearest_32bit (GstVideoscale *scale,
- unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
-static void gst_videoscale_scale_nearest_24bit (GstVideoscale *scale,
- unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
-static void gst_videoscale_scale_nearest_16bit (GstVideoscale *scale,
- unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
+static void gst_videoscale_planar411 (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src);
+static void gst_videoscale_planar400 (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src);
+static void gst_videoscale_packed422 (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src);
+static void gst_videoscale_packed422rev (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src);
+static void gst_videoscale_32bit (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src);
+static void gst_videoscale_24bit (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src);
+static void gst_videoscale_16bit (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src);
+
+static void gst_videoscale_scale_nearest_str2 (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
+static void gst_videoscale_scale_nearest_str4 (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
+static void gst_videoscale_scale_nearest_32bit (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
+static void gst_videoscale_scale_nearest_24bit (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
+static void gst_videoscale_scale_nearest_16bit (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
#define fourcc_YUY2 GST_MAKE_FOURCC('Y','U','Y','2')
#define fourcc_UYVY GST_MAKE_FOURCC('U','Y','V','Y')
#define fourcc_RGB_ GST_MAKE_FOURCC('R','G','B',' ')
struct videoscale_format_struct videoscale_formats[] = {
- /* packed */
- { fourcc_YUY2, 16, gst_videoscale_packed422, },
- { fourcc_UYVY, 16, gst_videoscale_packed422rev, },
- { fourcc_Y422, 16, gst_videoscale_packed422rev, },
- { fourcc_UYNV, 16, gst_videoscale_packed422rev, },
- { fourcc_YVYU, 16, gst_videoscale_packed422, },
- /* planar */
- { fourcc_YV12, 12, gst_videoscale_planar411, },
- { fourcc_I420, 12, gst_videoscale_planar411, },
- { fourcc_Y800, 8, gst_videoscale_planar400, },
- /* RGB */
- { fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x00ff0000, 0x0000ff00, 0x000000ff },
- { fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x000000ff, 0x0000ff00, 0x00ff0000 },
- { fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0xff000000, 0x00ff0000, 0x0000ff00 },
- { fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x0000ff00, 0x00ff0000, 0xff000000 },
- { fourcc_RGB_, 24, gst_videoscale_24bit, 24, G_BIG_ENDIAN, 0xff0000, 0x00ff00, 0x0000ff },
- { fourcc_RGB_, 24, gst_videoscale_24bit, 24, G_BIG_ENDIAN, 0x0000ff, 0x00ff00, 0xff0000 },
- { fourcc_RGB_, 16, gst_videoscale_16bit, 16, G_BYTE_ORDER, 0xf800, 0x07e0, 0x001f },
- { fourcc_RGB_, 16, gst_videoscale_16bit, 15, G_BYTE_ORDER, 0x7c00, 0x03e0, 0x001f },
+ /* packed */
+ {fourcc_YUY2, 16, gst_videoscale_packed422,},
+ {fourcc_UYVY, 16, gst_videoscale_packed422rev,},
+ {fourcc_Y422, 16, gst_videoscale_packed422rev,},
+ {fourcc_UYNV, 16, gst_videoscale_packed422rev,},
+ {fourcc_YVYU, 16, gst_videoscale_packed422,},
+ /* planar */
+ {fourcc_YV12, 12, gst_videoscale_planar411,},
+ {fourcc_I420, 12, gst_videoscale_planar411,},
+ {fourcc_Y800, 8, gst_videoscale_planar400,},
+ /* RGB */
+ {fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x00ff0000,
+ 0x0000ff00, 0x000000ff},
+ {fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x000000ff,
+ 0x0000ff00, 0x00ff0000},
+ {fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0xff000000,
+ 0x00ff0000, 0x0000ff00},
+ {fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x0000ff00,
+ 0x00ff0000, 0xff000000},
+ {fourcc_RGB_, 24, gst_videoscale_24bit, 24, G_BIG_ENDIAN, 0xff0000, 0x00ff00,
+ 0x0000ff},
+ {fourcc_RGB_, 24, gst_videoscale_24bit, 24, G_BIG_ENDIAN, 0x0000ff, 0x00ff00,
+ 0xff0000},
+ {fourcc_RGB_, 16, gst_videoscale_16bit, 16, G_BYTE_ORDER, 0xf800, 0x07e0,
+ 0x001f},
+ {fourcc_RGB_, 16, gst_videoscale_16bit, 15, G_BYTE_ORDER, 0x7c00, 0x03e0,
+ 0x001f},
};
-int videoscale_n_formats = sizeof(videoscale_formats)/sizeof(videoscale_formats[0]);
+int videoscale_n_formats =
+ sizeof (videoscale_formats) / sizeof (videoscale_formats[0]);
GstStructure *
videoscale_get_structure (struct videoscale_format_struct *format)
{
GstStructure *structure;
- if(format->scale==NULL)
+ if (format->scale == NULL)
return NULL;
- if(format->depth){
+ if (format->depth) {
structure = gst_structure_new ("video/x-raw-rgb",
"depth", G_TYPE_INT, format->depth,
"bpp", G_TYPE_INT, format->bpp,
"endianness", G_TYPE_INT, format->endianness,
"red_mask", G_TYPE_INT, format->red_mask,
"green_mask", G_TYPE_INT, format->green_mask,
- "blue_mask", G_TYPE_INT, format->blue_mask,
- NULL);
- }else{
+ "blue_mask", G_TYPE_INT, format->blue_mask, NULL);
+ } else {
structure = gst_structure_new ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, format->fourcc, NULL);
}
- gst_structure_set(structure,
+ gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 100, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 100, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
return structure;
}
struct videoscale_format_struct *
-videoscale_find_by_structure(GstStructure *structure)
+videoscale_find_by_structure (GstStructure * structure)
{
int i;
gboolean ret;
struct videoscale_format_struct *format;
- GST_DEBUG ("finding %s",gst_structure_to_string(structure));
+ GST_DEBUG ("finding %s", gst_structure_to_string (structure));
- g_return_val_if_fail(structure != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
- if(strcmp(gst_structure_get_name(structure),"video/x-raw-yuv")==0){
+ if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
unsigned int fourcc;
ret = gst_structure_get_fourcc (structure, "format", &fourcc);
- if(!ret) return NULL;
- for (i = 0; i < videoscale_n_formats; i++){
+ if (!ret)
+ return NULL;
+ for (i = 0; i < videoscale_n_formats; i++) {
format = videoscale_formats + i;
- if(format->depth==0 && format->fourcc == fourcc){
+ if (format->depth == 0 && format->fourcc == fourcc) {
return format;
}
}
- }else{
+ } else {
int bpp;
int depth;
int endianness;
ret &= gst_structure_get_int (structure, "red_mask", &red_mask);
ret &= gst_structure_get_int (structure, "green_mask", &green_mask);
ret &= gst_structure_get_int (structure, "blue_mask", &blue_mask);
- if(!ret) return NULL;
- for (i = 0; i < videoscale_n_formats; i++){
+ if (!ret)
+ return NULL;
+ for (i = 0; i < videoscale_n_formats; i++) {
format = videoscale_formats + i;
- if(format->bpp == bpp && format->depth == depth &&
+ if (format->bpp == bpp && format->depth == depth &&
format->endianness == endianness && format->red_mask == red_mask &&
format->green_mask == green_mask && format->blue_mask == blue_mask) {
return format;
}
void
-gst_videoscale_setup (GstVideoscale *videoscale)
+gst_videoscale_setup (GstVideoscale * videoscale)
{
g_return_if_fail (GST_IS_VIDEOSCALE (videoscale));
g_return_if_fail (videoscale->format != NULL);
GST_DEBUG_OBJECT (videoscale, "format=%p " GST_FOURCC_FORMAT
- " from %dx%d to %dx%d",
- videoscale->format,
- GST_FOURCC_ARGS(videoscale->format->fourcc),
- videoscale->from_width, videoscale->from_height,
- videoscale->to_width, videoscale->to_height);
-
- if(videoscale->to_width==0 || videoscale->to_height==0 ||
- videoscale->from_width==0 || videoscale->from_height==0){
+ " from %dx%d to %dx%d",
+ videoscale->format,
+ GST_FOURCC_ARGS (videoscale->format->fourcc),
+ videoscale->from_width, videoscale->from_height,
+ videoscale->to_width, videoscale->to_height);
+
+ if (videoscale->to_width == 0 || videoscale->to_height == 0 ||
+ videoscale->from_width == 0 || videoscale->from_height == 0) {
g_critical ("bad sizes %dx%d %dx%d",
- videoscale->from_width, videoscale->from_height,
- videoscale->to_width, videoscale->to_height);
+ videoscale->from_width, videoscale->from_height,
+ videoscale->to_width, videoscale->to_height);
return;
}
- if(videoscale->to_width == videoscale->from_width &&
- videoscale->to_height == videoscale->from_height){
+ if (videoscale->to_width == videoscale->from_width &&
+ videoscale->to_height == videoscale->from_height) {
GST_DEBUG_OBJECT (videoscale, "using passthru");
videoscale->passthru = TRUE;
videoscale->inited = TRUE;
GST_DEBUG_OBJECT (videoscale, "scaling method POINT_SAMPLE");
videoscale->from_buf_size = (videoscale->from_width * videoscale->from_height
- * videoscale->format->bpp) / 8;
+ * videoscale->format->bpp) / 8;
videoscale->to_buf_size = (videoscale->to_width * videoscale->to_height
- * videoscale->format->bpp) / 8;
+ * videoscale->format->bpp) / 8;
videoscale->passthru = FALSE;
videoscale->inited = TRUE;
#if 0
static void
-gst_videoscale_scale_rgb (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_scale_rgb (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
int dw = scale->to_width;
int dh = scale->to_height;
+
GST_DEBUG_OBJECT (scale, "scaling RGB %dx%d to %dx%d", sw, sh, dw, dh);
switch (scale->scale_bytes) {
case 2:
- dw = ((dw + 1) & ~1) << 1;
- sw = sw<<1;
- break;
+ dw = ((dw + 1) & ~1) << 1;
+ sw = sw << 1;
+ break;
case 4:
- dw = ((dw + 2) & ~3) << 2;
- sw = sw<<2;
- break;
- default:
- break;
+ dw = ((dw + 2) & ~3) << 2;
+ sw = sw << 2;
+ break;
+ default:
+ break;
}
GST_DEBUG_OBJECT (scale, "%p %p", src, dest);
#endif
static void
-gst_videoscale_planar411 (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_planar411 (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
int dw = scale->to_width;
int dh = scale->to_height;
- GST_DEBUG_OBJECT (scale, "scaling planar 4:1:1 %dx%d to %dx%d", sw, sh, dw, dh);
+ GST_DEBUG_OBJECT (scale, "scaling planar 4:1:1 %dx%d to %dx%d", sw, sh, dw,
+ dh);
- gst_videoscale_scale_nearest(scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
- src += sw*sh;
- dest += dw*dh;
+ src += sw * sh;
+ dest += dw * dh;
- dh = dh>>1;
- dw = dw>>1;
- sh = sh>>1;
- sw = sw>>1;
+ dh = dh >> 1;
+ dw = dw >> 1;
+ sh = sh >> 1;
+ sw = sw >> 1;
- gst_videoscale_scale_nearest(scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
- src += sw*sh;
- dest += dw*dh;
+ src += sw * sh;
+ dest += dw * dh;
- gst_videoscale_scale_nearest(scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
}
static void
-gst_videoscale_planar400 (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_planar400 (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
GST_DEBUG_OBJECT (scale, "scaling Y-only %dx%d to %dx%d", sw, sh, dw, dh);
- gst_videoscale_scale_nearest(scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
}
static void
-gst_videoscale_packed422 (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_packed422 (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
GST_DEBUG_OBJECT (scale, "scaling 4:2:2 %dx%d to %dx%d", sw, sh, dw, dh);
- gst_videoscale_scale_nearest_str2(scale, dest, src, sw, sh, dw, dh);
- gst_videoscale_scale_nearest_str4(scale, dest+1, src+1, sw/2, sh, dw/2, dh);
- gst_videoscale_scale_nearest_str4(scale, dest+3, src+3, sw/2, sh, dw/2, dh);
+ gst_videoscale_scale_nearest_str2 (scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest_str4 (scale, dest + 1, src + 1, sw / 2, sh,
+ dw / 2, dh);
+ gst_videoscale_scale_nearest_str4 (scale, dest + 3, src + 3, sw / 2, sh,
+ dw / 2, dh);
}
static void
-gst_videoscale_packed422rev (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_packed422rev (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
GST_DEBUG_OBJECT (scale, "scaling 4:2:2 %dx%d to %dx%d", sw, sh, dw, dh);
- gst_videoscale_scale_nearest_str2(scale, dest+1, src, sw, sh, dw, dh);
- gst_videoscale_scale_nearest_str4(scale, dest, src+1, sw/2, sh, dw/2, dh);
- gst_videoscale_scale_nearest_str4(scale, dest+2, src+3, sw/2, sh, dw/2, dh);
+ gst_videoscale_scale_nearest_str2 (scale, dest + 1, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest_str4 (scale, dest, src + 1, sw / 2, sh, dw / 2,
+ dh);
+ gst_videoscale_scale_nearest_str4 (scale, dest + 2, src + 3, sw / 2, sh,
+ dw / 2, dh);
}
static void
-gst_videoscale_32bit (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_32bit (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
GST_DEBUG_OBJECT (scale, "scaling 32bit %dx%d to %dx%d", sw, sh, dw, dh);
- gst_videoscale_scale_nearest_32bit(scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest_32bit (scale, dest, src, sw, sh, dw, dh);
}
static void
-gst_videoscale_24bit (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_24bit (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
GST_DEBUG_OBJECT (scale, "scaling 24bit %dx%d to %dx%d", sw, sh, dw, dh);
- gst_videoscale_scale_nearest_24bit(scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest_24bit (scale, dest, src, sw, sh, dw, dh);
}
static void
-gst_videoscale_16bit (GstVideoscale *scale, unsigned char *dest, unsigned char *src)
+gst_videoscale_16bit (GstVideoscale * scale, unsigned char *dest,
+ unsigned char *src)
{
int sw = scale->from_width;
int sh = scale->from_height;
GST_DEBUG_OBJECT (scale, "scaling 16bit %dx%d to %dx%d", sw, sh, dw, dh);
- gst_videoscale_scale_nearest_16bit(scale, dest, src, sw, sh, dw, dh);
+ gst_videoscale_scale_nearest_16bit (scale, dest, src, sw, sh, dw, dh);
}
static unsigned char
gst_videoscale_bilinear (unsigned char *src, double x, double y, int sw, int sh)
{
- int j=floor(x);
- int k=floor(y);
- double a=x-j;
- double b=y-k;
+ int j = floor (x);
+ int k = floor (y);
+ double a = x - j;
+ double b = y - k;
double dest;
int color;
GST_DEBUG_OBJECT (scale, "scaling bilinear %f %f %dx%d", x, y, sw, sh);
- dest=(1-a)*(1-b)*RC(j,k)+
- a*(1-b)*RC(j+1,k);
+ dest = (1 - a) * (1 - b) * RC (j, k) + a * (1 - b) * RC (j + 1, k);
- k = MIN(sh-1, k);
- dest+= b*(1-a)*RC(j,k+1)+
- a*b*RC(j+1,k+1);
+ k = MIN (sh - 1, k);
+ dest += b * (1 - a) * RC (j, k + 1) + a * b * RC (j + 1, k + 1);
- color=rint(dest);
- if (color<0) color=abs(color); /* cannot have negative values ! */
+ color = rint (dest);
+ if (color < 0)
+ color = abs (color); /* cannot have negative values ! */
/*if (color<0) color=0; // cannot have negative values ! */
- if (color>255) color=255;
+ if (color > 255)
+ color = 255;
return (unsigned char) color;
}
static unsigned char
gst_videoscale_bicubic (unsigned char *src, double x, double y, int sw, int sh)
{
- int j=floor(x);
- int k=floor(y), k2;
- double a=x-j;
- double b=y-k;
+ int j = floor (x);
+ int k = floor (y), k2;
+ double a = x - j;
+ double b = y - k;
double dest;
int color;
double t1, t2, t3, t4;
GST_DEBUG_OBJECT (scale, "scaling bicubic %dx%d", sw, sh);
- a1 = -a*(1-a)*(1-a);
- a2 = (1-2*a*a+a*a*a);
- a3 = a*(1+a-a*a);
- a4 = a*a*(1-a);
-
- k2 = MAX(0, k-1);
- t1=a1*RC(j-1,k2)+ a2*RC(j,k2)+ a3*RC(j+1,k2)- a4*RC(j+2,k2);
- t2=a1*RC(j-1,k)+ a2*RC(j,k)+ a3*RC(j+1,k)- a4*RC(j+2,k);
- k2 = MIN(sh, k+1);
- t3=a1*RC(j-1,k2)+ a2*RC(j,k2)+ a3*RC(j+1,k2)- a4*RC(j+2,k2);
- k2 = MIN(sh, k+2);
- t4=a1*RC(j-1,k2)+ a2*RC(j,k2)+ a3*RC(j+1,k2)- a4*RC(j+2,k2);
-
- dest= -b*(1-b)*(1-b)*t1+ (1-2*b*b+b*b*b)*t2+ b*(1+b-b*b)*t3+ b*b*(b-1)*t4;
-
- color=rint(dest);
- if (color<0) color=abs(color); /* cannot have negative values ! */
- if (color>255) color=255;
+ a1 = -a * (1 - a) * (1 - a);
+ a2 = (1 - 2 * a * a + a * a * a);
+ a3 = a * (1 + a - a * a);
+ a4 = a * a * (1 - a);
+
+ k2 = MAX (0, k - 1);
+ t1 = a1 * RC (j - 1, k2) + a2 * RC (j, k2) + a3 * RC (j + 1,
+ k2) - a4 * RC (j + 2, k2);
+ t2 = a1 * RC (j - 1, k) + a2 * RC (j, k) + a3 * RC (j + 1,
+ k) - a4 * RC (j + 2, k);
+ k2 = MIN (sh, k + 1);
+ t3 = a1 * RC (j - 1, k2) + a2 * RC (j, k2) + a3 * RC (j + 1,
+ k2) - a4 * RC (j + 2, k2);
+ k2 = MIN (sh, k + 2);
+ t4 = a1 * RC (j - 1, k2) + a2 * RC (j, k2) + a3 * RC (j + 1,
+ k2) - a4 * RC (j + 2, k2);
+
+ dest =
+ -b * (1 - b) * (1 - b) * t1 + (1 - 2 * b * b + b * b * b) * t2 + b * (1 +
+ b - b * b) * t3 + b * b * (b - 1) * t4;
+
+ color = rint (dest);
+ if (color < 0)
+ color = abs (color); /* cannot have negative values ! */
+ if (color > 255)
+ color = 255;
return (unsigned char) color;
}
static void
-gst_videoscale_scale_plane_slow (GstVideoscale *scale, unsigned char *src, unsigned char *dest,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_plane_slow (GstVideoscale * scale, unsigned char *src,
+ unsigned char *dest, int sw, int sh, int dw, int dh)
{
- double zoomx = ((double)dw)/(double)sw;
- double zoomy = ((double)dh)/(double)sh;
+ double zoomx = ((double) dw) / (double) sw;
+ double zoomy = ((double) dh) / (double) sh;
double xr, yr;
int x, y;
- GST_DEBUG_OBJECT (scale, "scale plane slow %dx%d %dx%d %g %g %p %p", sw, sh, dw, dh, zoomx, zoomy, src, dest);
+ GST_DEBUG_OBJECT (scale, "scale plane slow %dx%d %dx%d %g %g %p %p", sw, sh,
+ dw, dh, zoomx, zoomy, src, dest);
- for (y=0; y<dh; y++) {
- yr = ((double)y)/zoomy;
- for (x=0; x<dw; x++) {
- xr = ((double)x)/zoomx;
+ for (y = 0; y < dh; y++) {
+ yr = ((double) y) / zoomy;
+ for (x = 0; x < dw; x++) {
+ xr = ((double) x) / zoomx;
- GST_DEBUG_OBJECT (scale, "scale plane slow %g %g %p", xr, yr, (src+(int)(x)+(int)((y)*sw)));
+ GST_DEBUG_OBJECT (scale, "scale plane slow %g %g %p", xr, yr,
+ (src + (int) (x) + (int) ((y) * sw)));
- if (floor(xr) == xr && floor(yr) == yr){
- GST_DEBUG_OBJECT (scale, "scale plane %g %g %p %p", xr, yr, (src+(int)(x)+(int)((y)*sw)), dest);
- *dest++ = RC(xr, yr);
- }
- else {
- *dest++ = scale->filter(src, xr, yr, sw, sh);
+ if (floor (xr) == xr && floor (yr) == yr) {
+ GST_DEBUG_OBJECT (scale, "scale plane %g %g %p %p", xr, yr,
+ (src + (int) (x) + (int) ((y) * sw)), dest);
+ *dest++ = RC (xr, yr);
+ } else {
+ *dest++ = scale->filter (src, xr, yr, sw, sh);
/**dest++ = gst_videoscale_bicubic(src, xr, yr, sw, sh); */
}
}
#if 0
static void
-gst_videoscale_scale_point_sample (GstVideoscale *scale, unsigned char *src, unsigned char *dest,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_point_sample (GstVideoscale * scale, unsigned char *src,
+ unsigned char *dest, int sw, int sh, int dw, int dh)
{
int ypos, yinc, y;
int xpos, xinc, x;
int sum, xcount, ycount, loop;
unsigned char *srcp, *srcp2;
- GST_DEBUG_OBJECT (scale, "scaling nearest point sample %p %p %d", src, dest, dw);
+ GST_DEBUG_OBJECT (scale, "scaling nearest point sample %p %p %d", src, dest,
+ dw);
ypos = 0x10000;
- yinc = (sh<<16)/dh;
- xinc = (sw<<16)/dw;
+ yinc = (sh << 16) / dh;
+ xinc = (sw << 16) / dw;
for (y = dh; y; y--) {
ycount = 1;
srcp = src;
- while (ypos >0x10000) {
+ while (ypos > 0x10000) {
ycount++;
- ypos-=0x10000;
+ ypos -= 0x10000;
src += sw;
}
xpos = 0x10000;
- for ( x=dw; x; x-- ) {
+ for (x = dw; x; x--) {
xcount = 0;
- sum=0;
- while ( xpos >= 0x10000L ) {
+ sum = 0;
+ while (xpos >= 0x10000L) {
loop = ycount;
- srcp2 = srcp;
- while (loop--) {
- sum += *srcp2;
- srcp2 += sw;
+ srcp2 = srcp;
+ while (loop--) {
+ sum += *srcp2;
+ srcp2 += sw;
}
srcp++;
- xcount++;
- xpos -= 0x10000L;
+ xcount++;
+ xpos -= 0x10000L;
}
- *dest++ = sum/(xcount*ycount);
+ *dest++ = sum / (xcount * ycount);
xpos += xinc;
}
#endif
static void
-gst_videoscale_scale_nearest (GstVideoscale *scale,
- unsigned char *dest,
- unsigned char *src,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_nearest (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
{
int ypos, yinc, y;
int xpos, xinc, x;
ypos = 0x10000;
- yinc = (sh<<16)/dh;
- xinc = (sw<<16)/dw;
+ yinc = (sh << 16) / dh;
+ xinc = (sw << 16) / dw;
for (y = dh; y; y--) {
- while (ypos >0x10000) {
- ypos-=0x10000;
+ while (ypos > 0x10000) {
+ ypos -= 0x10000;
src += sw;
}
srcp = src;
destp = dest;
- for ( x=dw; x; x-- ) {
- while ( xpos >= 0x10000L ) {
- srcp++;
- xpos -= 0x10000L;
+ for (x = dw; x; x--) {
+ while (xpos >= 0x10000L) {
+ srcp++;
+ xpos -= 0x10000L;
}
*destp++ = *srcp;
xpos += xinc;
}
static void
-gst_videoscale_scale_nearest_str2 (GstVideoscale *scale,
- unsigned char *dest,
- unsigned char *src,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_nearest_str2 (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
{
int ypos, yinc, y;
int xpos, xinc, x;
ypos = 0x10000;
- yinc = (sh<<16)/dh;
- xinc = (sw<<16)/dw;
+ yinc = (sh << 16) / dh;
+ xinc = (sw << 16) / dw;
for (y = dh; y; y--) {
- while (ypos >0x10000) {
- ypos-=0x10000;
- src += sw*2;
+ while (ypos > 0x10000) {
+ ypos -= 0x10000;
+ src += sw * 2;
}
xpos = 0x10000;
srcp = src;
destp = dest;
- for ( x=dw; x; x-- ) {
- while ( xpos >= 0x10000L ) {
- srcp+=2;
- xpos -= 0x10000L;
+ for (x = dw; x; x--) {
+ while (xpos >= 0x10000L) {
+ srcp += 2;
+ xpos -= 0x10000L;
}
*destp = *srcp;
- destp+=2;
+ destp += 2;
xpos += xinc;
}
- dest += dw*2;
+ dest += dw * 2;
ypos += yinc;
}
}
static void
-gst_videoscale_scale_nearest_str4 (GstVideoscale *scale,
- unsigned char *dest,
- unsigned char *src,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_nearest_str4 (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
{
int ypos, yinc, y;
int xpos, xinc, x;
ypos = 0x10000;
- yinc = (sh<<16)/dh;
- xinc = (sw<<16)/dw;
+ yinc = (sh << 16) / dh;
+ xinc = (sw << 16) / dw;
for (y = dh; y; y--) {
- while (ypos >0x10000) {
- ypos-=0x10000;
- src += sw*4;
+ while (ypos > 0x10000) {
+ ypos -= 0x10000;
+ src += sw * 4;
}
xpos = 0x10000;
srcp = src;
destp = dest;
- for ( x=dw; x; x-- ) {
- while ( xpos >= 0x10000L ) {
- srcp+=4;
- xpos -= 0x10000L;
+ for (x = dw; x; x--) {
+ while (xpos >= 0x10000L) {
+ srcp += 4;
+ xpos -= 0x10000L;
}
*destp = *srcp;
- destp+=4;
+ destp += 4;
xpos += xinc;
}
- dest += dw*4;
+ dest += dw * 4;
ypos += yinc;
}
}
static void
-gst_videoscale_scale_nearest_32bit (GstVideoscale *scale,
- unsigned char *dest,
- unsigned char *src,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_nearest_32bit (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
{
int ypos, yinc, y;
int xpos, xinc, x;
ypos = 0x10000;
- yinc = (sh<<16)/dh;
- xinc = (sw<<16)/dw;
+ yinc = (sh << 16) / dh;
+ xinc = (sw << 16) / dw;
for (y = dh; y; y--) {
- while (ypos >0x10000) {
- ypos-=0x10000;
- src += sw*4;
+ while (ypos > 0x10000) {
+ ypos -= 0x10000;
+ src += sw * 4;
}
xpos = 0x10000;
srcp = src;
destp = dest;
- for ( x=dw; x; x-- ) {
- while ( xpos >= 0x10000L ) {
- srcp+=4;
- xpos -= 0x10000L;
+ for (x = dw; x; x--) {
+ while (xpos >= 0x10000L) {
+ srcp += 4;
+ xpos -= 0x10000L;
}
- *(guint32 *)destp = *(guint32 *)srcp;
- destp+=4;
+ *(guint32 *) destp = *(guint32 *) srcp;
+ destp += 4;
xpos += xinc;
}
- dest += dw*4;
+ dest += dw * 4;
ypos += yinc;
}
}
static void
-gst_videoscale_scale_nearest_24bit (GstVideoscale *scale,
- unsigned char *dest,
- unsigned char *src,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_nearest_24bit (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
{
int ypos, yinc, y;
int xpos, xinc, x;
ypos = 0x10000;
- yinc = (sh<<16)/dh;
- xinc = (sw<<16)/dw;
+ yinc = (sh << 16) / dh;
+ xinc = (sw << 16) / dw;
for (y = dh; y; y--) {
- while (ypos >0x10000) {
- ypos-=0x10000;
- src += sw*3;
+ while (ypos > 0x10000) {
+ ypos -= 0x10000;
+ src += sw * 3;
}
xpos = 0x10000;
srcp = src;
destp = dest;
- for ( x=dw; x; x-- ) {
- while ( xpos >= 0x10000L ) {
- srcp+=3;
- xpos -= 0x10000L;
+ for (x = dw; x; x--) {
+ while (xpos >= 0x10000L) {
+ srcp += 3;
+ xpos -= 0x10000L;
}
destp[0] = srcp[0];
destp[1] = srcp[1];
destp[2] = srcp[2];
- destp+=3;
+ destp += 3;
xpos += xinc;
}
- dest += dw*3;
+ dest += dw * 3;
ypos += yinc;
}
}
static void
-gst_videoscale_scale_nearest_16bit (GstVideoscale *scale,
- unsigned char *dest,
- unsigned char *src,
- int sw, int sh, int dw, int dh)
+gst_videoscale_scale_nearest_16bit (GstVideoscale * scale,
+ unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
{
int ypos, yinc, y;
int xpos, xinc, x;
ypos = 0x10000;
- yinc = (sh<<16)/dh;
- xinc = (sw<<16)/dw;
+ yinc = (sh << 16) / dh;
+ xinc = (sw << 16) / dw;
for (y = dh; y; y--) {
- while (ypos >0x10000) {
- ypos-=0x10000;
- src += sw*2;
+ while (ypos > 0x10000) {
+ ypos -= 0x10000;
+ src += sw * 2;
}
xpos = 0x10000;
srcp = src;
destp = dest;
- for ( x=dw; x; x-- ) {
- while ( xpos >= 0x10000L ) {
- srcp+=2;
- xpos -= 0x10000L;
+ for (x = dw; x; x--) {
+ while (xpos >= 0x10000L) {
+ srcp += 2;
+ xpos -= 0x10000L;
}
destp[0] = srcp[0];
destp[1] = srcp[1];
- destp+=2;
+ destp += 2;
xpos += xinc;
}
- dest += dw*2;
+ dest += dw * 2;
ypos += yinc;
}
}
-
#include "gstvideoscale.h"
-struct videoscale_format_struct {
- unsigned int fourcc;
- int bpp;
- void (*scale)(GstVideoscale *,unsigned char *dest, unsigned char *src);
- int depth;
- unsigned int endianness;
- unsigned int red_mask;
- unsigned int green_mask;
- unsigned int blue_mask;
+struct videoscale_format_struct
+{
+ unsigned int fourcc;
+ int bpp;
+ void (*scale) (GstVideoscale *, unsigned char *dest, unsigned char *src);
+ int depth;
+ unsigned int endianness;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
};
extern struct videoscale_format_struct videoscale_formats[];
extern int videoscale_n_formats;
-GstStructure *videoscale_get_structure(struct videoscale_format_struct *format);
+GstStructure *videoscale_get_structure (struct videoscale_format_struct
+ *format);
-struct videoscale_format_struct *videoscale_find_by_structure (GstStructure *structure);
+struct videoscale_format_struct *videoscale_find_by_structure (GstStructure *
+ structure);
#endif
-
#include "gstvideoscale.h"
/* scalers */
-void gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w, int dst_w, int bpp);
-void gst_videoscale_scale_nearest_x86 (GstVideoscale *scale,
- unsigned char *src, unsigned char *dest,
- int sw, int sh, int dw, int dh);
+void gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w,
+ int dst_w, int bpp);
+void gst_videoscale_scale_nearest_x86 (GstVideoscale * scale,
+ unsigned char *src, unsigned char *dest, int sw, int sh, int dw, int dh);
#define PREFIX16 0x66
#define STORE_BYTE 0xAA
#define RETURN 0xC3
void
-gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w, int dst_w, int bpp)
+gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w,
+ int dst_w, int bpp)
{
int i;
int pos, inc;
pos = 0x10000;
inc = (src_w << 16) / dst_w;
eip = copy_row;
- for ( i=0; i<dst_w; ++i ) {
- while ( pos >= 0x10000L ) {
- if ( bpp == 2 ) {
- *eip++ = PREFIX16;
+ for (i = 0; i < dst_w; ++i) {
+ while (pos >= 0x10000L) {
+ if (bpp == 2) {
+ *eip++ = PREFIX16;
}
*eip++ = load;
pos -= 0x10000L;
}
- if ( bpp == 2 ) {
+ if (bpp == 2) {
*eip++ = PREFIX16;
}
*eip++ = store;
pos += inc;
}
*eip++ = RETURN;
- GST_DEBUG ("scaler start/end %p %p %p", copy_row, eip, (void*)(eip-copy_row));
+ GST_DEBUG ("scaler start/end %p %p %p", copy_row, eip,
+ (void *) (eip - copy_row));
}
-
/* scalers */
-void gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w, int dst_w, int bpp);
-void gst_videoscale_scale_nearest_x86 (GstVideoscale *scale,
- unsigned char *src, unsigned char *dest,
- int sw, int sh, int dw, int dh);
+void gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w,
+ int dst_w, int bpp);
+void gst_videoscale_scale_nearest_x86 (GstVideoscale * scale,
+ unsigned char *src, unsigned char *dest, int sw, int sh, int dw, int dh);
#endif /* __GST_VIDEOSCALE__X86_H__ */
/* elementfactory information */
-static GstElementDetails videotestsrc_details = GST_ELEMENT_DETAILS (
- "Video test source",
- "Source/Video",
- "Creates a test video stream",
- "David A. Schleef <ds@schleef.org>"
-);
+static GstElementDetails videotestsrc_details =
+GST_ELEMENT_DETAILS ("Video test source",
+ "Source/Video",
+ "Creates a test video stream",
+ "David A. Schleef <ds@schleef.org>");
/* GstVideotestsrc signals and args */
enum
static void gst_videotestsrc_base_init (gpointer g_class);
static void gst_videotestsrc_class_init (GstVideotestsrcClass * klass);
static void gst_videotestsrc_init (GstVideotestsrc * videotestsrc);
-static GstElementStateReturn gst_videotestsrc_change_state (GstElement * element);
-static void gst_videotestsrc_set_clock (GstElement *element, GstClock *clock);
+static GstElementStateReturn gst_videotestsrc_change_state (GstElement *
+ element);
+static void gst_videotestsrc_set_clock (GstElement * element, GstClock * clock);
-static void gst_videotestsrc_set_pattern (GstVideotestsrc *src, int pattern_type);
+static void gst_videotestsrc_set_pattern (GstVideotestsrc * src,
+ int pattern_type);
static void gst_videotestsrc_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec);
+ const GValue * value, GParamSpec * pspec);
+static void gst_videotestsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstData *gst_videotestsrc_get (GstPad * pad);
-static const GstQueryType *
- gst_videotestsrc_get_query_types (GstPad *pad);
-static gboolean gst_videotestsrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
+static const GstQueryType *gst_videotestsrc_get_query_types (GstPad * pad);
+static gboolean gst_videotestsrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
static GstElementClass *parent_class = NULL;
-static GstCaps * gst_videotestsrc_get_capslist (void);
+static GstCaps *gst_videotestsrc_get_capslist (void);
+
#if 0
-static GstCaps * gst_videotestsrc_get_capslist_size (int width, int height, double rate);
+static GstCaps *gst_videotestsrc_get_capslist_size (int width, int height,
+ double rate);
#endif
static GstPadTemplate *
-gst_videotestsrc_src_template_factory(void)
+gst_videotestsrc_src_template_factory (void)
{
return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_videotestsrc_get_capslist());
+ gst_videotestsrc_get_capslist ());
}
GType
};
videotestsrc_type =
- g_type_register_static (GST_TYPE_ELEMENT, "GstVideotestsrc", &videotestsrc_info, 0);
+ g_type_register_static (GST_TYPE_ELEMENT, "GstVideotestsrc",
+ &videotestsrc_info, 0);
}
return videotestsrc_type;
}
{
static GType videotestsrc_pattern_type = 0;
static GEnumValue pattern_types[] = {
- { GST_VIDEOTESTSRC_SMPTE, "smpte", "SMPTE 100% color bars" },
- { GST_VIDEOTESTSRC_SNOW, "snow", "Random (television snow)" },
- { GST_VIDEOTESTSRC_BLACK, "black", "0% Black" },
- { 0, NULL, NULL },
+ {GST_VIDEOTESTSRC_SMPTE, "smpte", "SMPTE 100% color bars"},
+ {GST_VIDEOTESTSRC_SNOW, "snow", "Random (television snow)"},
+ {GST_VIDEOTESTSRC_BLACK, "black", "0% Black"},
+ {0, NULL, NULL},
};
- if (!videotestsrc_pattern_type){
- videotestsrc_pattern_type = g_enum_register_static("GstVideotestsrcPattern",
- pattern_types);
+ if (!videotestsrc_pattern_type) {
+ videotestsrc_pattern_type =
+ g_enum_register_static ("GstVideotestsrcPattern", pattern_types);
}
return videotestsrc_pattern_type;
}
gst_element_class_set_details (element_class, &videotestsrc_details);
gst_element_class_add_pad_template (element_class,
- gst_videotestsrc_src_template_factory());
+ gst_videotestsrc_src_template_factory ());
}
static void
gst_videotestsrc_class_init (GstVideotestsrcClass * klass)
gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE,
- g_param_spec_enum ("pattern", "Pattern", "Type of test pattern to generate",
- GST_TYPE_VIDEOTESTSRC_PATTERN, 1, G_PARAM_READWRITE));
+ g_param_spec_enum ("pattern", "Pattern",
+ "Type of test pattern to generate", GST_TYPE_VIDEOTESTSRC_PATTERN, 1,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
- g_param_spec_boolean ("sync", "Sync", "Synchronize to clock",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("sync", "Sync", "Synchronize to clock", TRUE,
+ G_PARAM_READWRITE));
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->get_property = gst_videotestsrc_get_property;
gstelement_class->change_state = gst_videotestsrc_change_state;
- gstelement_class->set_clock = gst_videotestsrc_set_clock;
+ gstelement_class->set_clock = gst_videotestsrc_set_clock;
}
static void
-gst_videotestsrc_set_clock (GstElement *element, GstClock *clock)
+gst_videotestsrc_set_clock (GstElement * element, GstClock * clock)
{
GstVideotestsrc *v;
v = GST_VIDEOTESTSRC (element);
- gst_object_replace ((GstObject **)&v->clock, (GstObject *)clock);
+ gst_object_replace ((GstObject **) & v->clock, (GstObject *) clock);
}
static GstCaps *
/* FIXME this function isn't very intelligent in choosing "good" caps */
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
structure = gst_caps_get_structure (caps, 0);
- videotestsrc->fourcc = paintinfo_find_by_structure(structure);
+ videotestsrc->fourcc = paintinfo_find_by_structure (structure);
if (!videotestsrc->fourcc) {
g_critical ("videotestsrc format not found\n");
return GST_PAD_LINK_REFUSED;
ret = gst_structure_get_int (structure, "width", &videotestsrc->width);
ret &= gst_structure_get_int (structure, "height", &videotestsrc->height);
- ret &= gst_structure_get_double (structure, "framerate",
- &videotestsrc->rate);
+ ret &= gst_structure_get_double (structure, "framerate", &videotestsrc->rate);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
videotestsrc->bpp = videotestsrc->fourcc->bitspp;
GstStructure *structure;
int i;
- caps = gst_caps_new_empty();
- for(i=0;i<n_fourccs;i++){
+ caps = gst_caps_new_empty ();
+ for (i = 0; i < n_fourccs; i++) {
structure = paint_get_structure (fourcc_list + i);
- gst_structure_set(structure,
+ gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
GstStructure *structure;
int i;
- caps = gst_caps_new_empty();
- for(i=0;i<n_fourccs;i++){
+ caps = gst_caps_new_empty ();
+ for (i = 0; i < n_fourccs; i++) {
structure = paint_get_structure (fourcc_list + i);
- gst_structure_set(structure,
+ gst_structure_set (structure,
"width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_INT, rate, NULL);
+ "height", G_TYPE_INT, height, "framerate", G_TYPE_INT, rate, NULL);
gst_caps_append_structure (caps, structure);
}
{
GST_DEBUG ("gst_videotestsrc_init");
- videotestsrc->srcpad = gst_pad_new_from_template (
- gst_videotestsrc_src_template_factory(), "src");
+ videotestsrc->srcpad =
+ gst_pad_new_from_template (gst_videotestsrc_src_template_factory (),
+ "src");
gst_pad_set_getcaps_function (videotestsrc->srcpad, gst_videotestsrc_getcaps);
- gst_pad_set_fixate_function (videotestsrc->srcpad, gst_videotestsrc_src_fixate);
+ gst_pad_set_fixate_function (videotestsrc->srcpad,
+ gst_videotestsrc_src_fixate);
gst_element_add_pad (GST_ELEMENT (videotestsrc), videotestsrc->srcpad);
gst_pad_set_get_function (videotestsrc->srcpad, gst_videotestsrc_get);
gst_pad_set_link_function (videotestsrc->srcpad, gst_videotestsrc_src_link);
- gst_pad_set_unlink_function (videotestsrc->srcpad, gst_videotestsrc_src_unlink);
+ gst_pad_set_unlink_function (videotestsrc->srcpad,
+ gst_videotestsrc_src_unlink);
gst_pad_set_query_function (videotestsrc->srcpad, gst_videotestsrc_src_query);
gst_pad_set_query_type_function (videotestsrc->srcpad,
- gst_videotestsrc_get_query_types);
+ gst_videotestsrc_get_query_types);
- gst_videotestsrc_set_pattern(videotestsrc, GST_VIDEOTESTSRC_SMPTE);
+ gst_videotestsrc_set_pattern (videotestsrc, GST_VIDEOTESTSRC_SMPTE);
videotestsrc->sync = TRUE;
}
static const GstQueryType *
-gst_videotestsrc_get_query_types (GstPad *pad)
+gst_videotestsrc_get_query_types (GstPad * pad)
{
static const GstQueryType query_types[] = {
GST_QUERY_POSITION,
};
return query_types;
-}
+}
static gboolean
-gst_videotestsrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value)
+gst_videotestsrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value)
{
gboolean res = FALSE;
GstVideotestsrc *videotestsrc = GST_VIDEOTESTSRC (gst_pad_get_parent (pad));
-
+
switch (type) {
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = videotestsrc->n_frames * GST_SECOND / (double) videotestsrc->rate;
- res = TRUE;
- break;
- case GST_FORMAT_DEFAULT: /* frames */
- *value = videotestsrc->n_frames;
- res = TRUE;
- break;
- default:
- break;
+ case GST_FORMAT_TIME:
+ *value =
+ videotestsrc->n_frames * GST_SECOND / (double) videotestsrc->rate;
+ res = TRUE;
+ break;
+ case GST_FORMAT_DEFAULT: /* frames */
+ *value = videotestsrc->n_frames;
+ res = TRUE;
+ break;
+ default:
+ break;
}
break;
default:
if (videotestsrc->fourcc == NULL) {
GST_ELEMENT_ERROR (videotestsrc, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before get function"));
+ ("format wasn't negotiated before get function"));
return NULL;
}
videotestsrc->height);
g_return_val_if_fail (newsize > 0, NULL);
- GST_DEBUG ("size=%ld %dx%d", newsize, videotestsrc->width, videotestsrc->height);
+ GST_DEBUG ("size=%ld %dx%d", newsize, videotestsrc->width,
+ videotestsrc->height);
buf = gst_pad_alloc_buffer (pad, GST_BUFFER_OFFSET_NONE, newsize);
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
videotestsrc->make_image (videotestsrc, (void *) GST_BUFFER_DATA (buf),
- videotestsrc->width, videotestsrc->height);
-
- if (videotestsrc->sync){
+ videotestsrc->width, videotestsrc->height);
+
+ if (videotestsrc->sync) {
GST_BUFFER_TIMESTAMP (buf) = videotestsrc->timestamp_offset +
- (videotestsrc->n_frames * GST_SECOND)/(double)videotestsrc->rate;
+ (videotestsrc->n_frames * GST_SECOND) / (double) videotestsrc->rate;
videotestsrc->n_frames++;
/* FIXME this is not correct if we do QoS */
if (videotestsrc->clock) {
gst_element_wait (GST_ELEMENT (videotestsrc), GST_BUFFER_TIMESTAMP (buf));
}
- }else{
+ } else {
GST_BUFFER_TIMESTAMP (buf) = videotestsrc->timestamp_offset +
- (videotestsrc->n_frames * GST_SECOND)/(double)videotestsrc->rate;
+ (videotestsrc->n_frames * GST_SECOND) / (double) videotestsrc->rate;
videotestsrc->n_frames++;
}
GST_BUFFER_DURATION (buf) = GST_SECOND / (double) videotestsrc->rate;
}
static void
-gst_videotestsrc_set_pattern (GstVideotestsrc *src, int pattern_type)
+gst_videotestsrc_set_pattern (GstVideotestsrc * src, int pattern_type)
{
src->type = pattern_type;
- GST_DEBUG ("setting pattern to %d\n",pattern_type);
- switch(pattern_type){
+ GST_DEBUG ("setting pattern to %d\n", pattern_type);
+ switch (pattern_type) {
case GST_VIDEOTESTSRC_SMPTE:
src->make_image = gst_videotestsrc_smpte;
break;
src->make_image = gst_videotestsrc_black;
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
}
}
static void
-gst_videotestsrc_set_property (GObject * object, guint prop_id, const GValue * value,
- GParamSpec * pspec)
+gst_videotestsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstVideotestsrc *src;
}
static void
-gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstVideotestsrc *src;
plugin_init (GstPlugin * plugin)
{
#ifdef HAVE_LIBOIL
- oil_init();
+ oil_init ();
#endif
- return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE, GST_TYPE_VIDEOTESTSRC);
+ return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE,
+ GST_TYPE_VIDEOTESTSRC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "videotestsrc",
- "Creates a test video stream",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "videotestsrc",
+ "Creates a test video stream",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_VIDEOTESTSRC \
(gst_videotestsrc_get_type())
#define GST_VIDEOTESTSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEOTESTSRC))
#define GST_IS_VIDEOTESTSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEOTESTSRC))
-
-typedef enum {
+ typedef enum
+{
GST_VIDEOTESTSRC_SMPTE,
GST_VIDEOTESTSRC_SNOW,
GST_VIDEOTESTSRC_BLACK,
typedef struct _GstVideotestsrc GstVideotestsrc;
typedef struct _GstVideotestsrcClass GstVideotestsrcClass;
-struct _GstVideotestsrc {
+struct _GstVideotestsrc
+{
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
/* parameters */
gboolean sync;
gint width;
gint height;
struct fourcc_list_struct *fourcc;
-
+
/* private */
gint64 timestamp_offset;
gint64 n_frames;
int type;
GstClock *clock;
- void (*make_image)(GstVideotestsrc *v, unsigned char *dest, int w, int h);
+ void (*make_image) (GstVideotestsrc * v, unsigned char *dest, int w, int h);
};
-struct _GstVideotestsrcClass {
+struct _GstVideotestsrcClass
+{
GstElementClass parent_class;
};
-GType gst_videotestsrc_get_type(void) G_GNUC_CONST;
+GType
+gst_videotestsrc_get_type (void)
+ G_GNUC_CONST;
G_END_DECLS
-
#endif /* __GST_VIDEOTESTSRC_H__ */
#if 0
static void
-paint_rect (unsigned char *dest, int stride, int x, int y, int w, int h, unsigned char color)
+paint_rect (unsigned char *dest, int stride, int x, int y, int w, int h,
+ unsigned char color)
{
unsigned char *d = dest + stride * y + x;
int i;
#if 0
static void
-paint_rect_s2 (unsigned char *dest, int stride, int x, int y, int w, int h, unsigned char col)
+paint_rect_s2 (unsigned char *dest, int stride, int x, int y, int w, int h,
+ unsigned char col)
{
unsigned char *d = dest + stride * y + x * 2;
unsigned char *dp;
#if 0
static void
-paint_rect2 (unsigned char *dest, int stride, int x, int y, int w, int h, unsigned char *col)
+paint_rect2 (unsigned char *dest, int stride, int x, int y, int w, int h,
+ unsigned char *col)
{
unsigned char *d = dest + stride * y + x * 2;
unsigned char *dp;
#if 0
static void
-paint_rect3 (unsigned char *dest, int stride, int x, int y, int w, int h, unsigned char *col)
+paint_rect3 (unsigned char *dest, int stride, int x, int y, int w, int h,
+ unsigned char *col)
{
unsigned char *d = dest + stride * y + x * 3;
unsigned char *dp;
#if 0
static void
-paint_rect4 (unsigned char *dest, int stride, int x, int y, int w, int h, unsigned char *col)
+paint_rect4 (unsigned char *dest, int stride, int x, int y, int w, int h,
+ unsigned char *col)
{
unsigned char *d = dest + stride * y + x * 4;
unsigned char *dp;
#if 0
static void
-paint_rect_s4 (unsigned char *dest, int stride, int x, int y, int w, int h, unsigned char col)
+paint_rect_s4 (unsigned char *dest, int stride, int x, int y, int w, int h,
+ unsigned char col)
{
unsigned char *d = dest + stride * y + x * 4;
unsigned char *dp;
}
#endif
-enum {
- COLOR_WHITE = 0,
- COLOR_YELLOW,
- COLOR_CYAN,
- COLOR_GREEN,
- COLOR_MAGENTA,
- COLOR_RED,
- COLOR_BLUE,
- COLOR_BLACK,
- COLOR_NEG_I,
- COLOR_POS_Q,
- COLOR_SUPER_BLACK,
- COLOR_DARK_GREY,
+enum
+{
+ COLOR_WHITE = 0,
+ COLOR_YELLOW,
+ COLOR_CYAN,
+ COLOR_GREEN,
+ COLOR_MAGENTA,
+ COLOR_RED,
+ COLOR_BLUE,
+ COLOR_BLACK,
+ COLOR_NEG_I,
+ COLOR_POS_Q,
+ COLOR_SUPER_BLACK,
+ COLOR_DARK_GREY,
};
static struct vts_color_struct vts_colors[] = {
- /* 100% white */
- { 255, 128, 128, 255, 255, 255 },
- /* yellow */
- { 226, 0, 155, 255, 255, 0 },
- /* cyan */
- { 179, 170, 0, 0, 255, 255 },
- /* green */
- { 150, 46, 21, 0, 255, 0 },
- /* magenta */
- { 105, 212, 235, 255, 0, 255 },
- /* red */
- { 76, 85, 255, 255, 0, 0 },
- /* blue */
- { 29, 255, 107, 0, 0, 255 },
- /* black */
- { 16, 128, 128, 0, 0, 0 },
- /* -I */
- { 16, 198, 21, 0, 0, 128 },
- /* +Q */
- { 16, 235, 198, 0, 128, 255 },
- /* superblack */
- { 0, 128, 128, 0, 0, 0 },
- /* 5% grey */
- { 32, 128, 128, 32, 32, 32 },
+ /* 100% white */
+ {255, 128, 128, 255, 255, 255},
+ /* yellow */
+ {226, 0, 155, 255, 255, 0},
+ /* cyan */
+ {179, 170, 0, 0, 255, 255},
+ /* green */
+ {150, 46, 21, 0, 255, 0},
+ /* magenta */
+ {105, 212, 235, 255, 0, 255},
+ /* red */
+ {76, 85, 255, 255, 0, 0},
+ /* blue */
+ {29, 255, 107, 0, 0, 255},
+ /* black */
+ {16, 128, 128, 0, 0, 0},
+ /* -I */
+ {16, 198, 21, 0, 0, 128},
+ /* +Q */
+ {16, 235, 198, 0, 128, 255},
+ /* superblack */
+ {0, 128, 128, 0, 0, 0},
+ /* 5% grey */
+ {32, 128, 128, 32, 32, 32},
};
#if 0
/* wht yel cya grn mag red blu blk -I Q, superblack, dark grey */
-static int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 16, 0, 32 };
-static int u_colors[] = { 128, 0, 170, 46, 212, 85, 255, 128, 198, 235, 128, 128 };
-static int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 21, 198, 128, 128 };
+static int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 16, 0, 32 };
+static int u_colors[] =
+ { 128, 0, 170, 46, 212, 85, 255, 128, 198, 235, 128, 128 };
+static int v_colors[] =
+ { 128, 155, 0, 21, 235, 255, 107, 128, 21, 198, 128, 128 };
/* wht yel cya grn mag red blu blk -I Q superblack, dark grey */
-static int r_colors[] = { 255, 255, 0, 0, 255, 255, 0, 0, 0, 0, 0, 32 };
-static int g_colors[] = { 255, 255, 255, 255, 0, 0, 0, 0, 0, 128, 0, 32 };
-static int b_colors[] = { 255, 0, 255, 0, 255, 0, 255, 0, 128, 255, 0, 32 };
+static int r_colors[] = { 255, 255, 0, 0, 255, 255, 0, 0, 0, 0, 0, 32 };
+static int g_colors[] = { 255, 255, 255, 255, 0, 0, 0, 0, 0, 128, 0, 32 };
+static int b_colors[] = { 255, 0, 255, 0, 255, 0, 255, 0, 128, 255, 0, 32 };
#endif
static void paint_setup_YVYU (paintinfo * p, char *dest);
static void paint_setup_IYU2 (paintinfo * p, char *dest);
static void paint_setup_Y800 (paintinfo * p, char *dest);
+
#if 0
static void paint_setup_IMC1 (paintinfo * p, char *dest);
static void paint_setup_IMC2 (paintinfo * p, char *dest);
static void paint_hline_YUY2 (paintinfo * p, int x, int y, int w);
static void paint_hline_IYU2 (paintinfo * p, int x, int y, int w);
static void paint_hline_Y800 (paintinfo * p, int x, int y, int w);
+
#if 0
static void paint_hline_IMC1 (paintinfo * p, int x, int y, int w);
#endif
{"YUY2", "YUY2", 16, paint_setup_YUY2, paint_hline_YUY2},
{"UYVY", "UYVY", 16, paint_setup_UYVY, paint_hline_YUY2},
{"Y422", "Y422", 16, paint_setup_UYVY, paint_hline_YUY2},
- {"UYNV", "UYNV", 16, paint_setup_UYVY, paint_hline_YUY2}, /* FIXME: UYNV? */
+ {"UYNV", "UYNV", 16, paint_setup_UYVY, paint_hline_YUY2}, /* FIXME: UYNV? */
{"YVYU", "YVYU", 16, paint_setup_YVYU, paint_hline_YUY2},
/* interlaced */
/*{ "Y42P", "Y42P", 16, paint_setup_YVYU, paint_hline_YUY2 }, */
/*{ "CLJR", "CLJR", 8, paint_setup_YVYU, paint_hline_YUY2 }, */
/*{ "IYU1", "IYU1", 12, paint_setup_YVYU, paint_hline_YUY2 }, */
- { "IYU2", "IYU2", 24, paint_setup_IYU2, paint_hline_IYU2 },
+ {"IYU2", "IYU2", 24, paint_setup_IYU2, paint_hline_IYU2},
/* planar */
/* YVU9 */
{"Y800", "Y800", 8, paint_setup_Y800, paint_hline_Y800},
{"RGB ", "xRGB8888", 32, paint_setup_xRGB8888, paint_hline_str4, 1, 24,
- 0x00ff0000, 0x0000ff00, 0x000000ff },
+ 0x00ff0000, 0x0000ff00, 0x000000ff},
{"RGB ", "xBGR8888", 32, paint_setup_xBGR8888, paint_hline_str4, 1, 24,
- 0x000000ff, 0x0000ff00, 0x00ff0000 },
+ 0x000000ff, 0x0000ff00, 0x00ff0000},
{"RGB ", "RGBx8888", 32, paint_setup_RGBx8888, paint_hline_str4, 1, 24,
- 0xff000000, 0x00ff0000, 0x0000ff00 },
+ 0xff000000, 0x00ff0000, 0x0000ff00},
{"RGB ", "BGRx8888", 32, paint_setup_BGRx8888, paint_hline_str4, 1, 24,
- 0x0000ff00, 0x00ff0000, 0xff000000 },
+ 0x0000ff00, 0x00ff0000, 0xff000000},
{"RGB ", "RGB888", 24, paint_setup_RGB888, paint_hline_str3, 1, 24,
- 0x00ff0000, 0x0000ff00, 0x000000ff },
+ 0x00ff0000, 0x0000ff00, 0x000000ff},
{"RGB ", "BGR888", 24, paint_setup_BGR888, paint_hline_str3, 1, 24,
- 0x000000ff, 0x0000ff00, 0x00ff0000 },
+ 0x000000ff, 0x0000ff00, 0x00ff0000},
{"RGB ", "RGB565", 16, paint_setup_RGB565, paint_hline_RGB565, 1, 16,
- 0x0000f800, 0x000007e0, 0x0000001f },
+ 0x0000f800, 0x000007e0, 0x0000001f},
{"RGB ", "xRGB1555", 16, paint_setup_xRGB1555, paint_hline_xRGB1555, 1, 15,
- 0x00007c00, 0x000003e0, 0x0000001f },
+ 0x00007c00, 0x000003e0, 0x0000001f},
};
int n_fourccs = sizeof (fourcc_list) / sizeof (fourcc_list[0]);
-struct fourcc_list_struct *paintinfo_find_by_structure(const GstStructure *structure)
+struct fourcc_list_struct *
+paintinfo_find_by_structure (const GstStructure * structure)
{
int i;
- const char *media_type = gst_structure_get_name(structure);
+ const char *media_type = gst_structure_get_name (structure);
int ret;
g_return_val_if_fail (structure, NULL);
- if(strcmp(media_type, "video/x-raw-yuv")==0){
+ if (strcmp (media_type, "video/x-raw-yuv") == 0) {
char *s;
int fourcc;
guint32 format;
ret = gst_structure_get_fourcc (structure, "format", &format);
- if (!ret) return NULL;
+ if (!ret)
+ return NULL;
for (i = 0; i < n_fourccs; i++) {
s = fourcc_list[i].fourcc;
//g_print("testing " GST_FOURCC_FORMAT " and %s\n", GST_FOURCC_ARGS(format), s);
fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
- if(fourcc == format){
- return fourcc_list + i;
+ if (fourcc == format) {
+ return fourcc_list + i;
}
}
- }else if(strcmp(media_type, "video/x-raw-rgb")==0){
+ } else if (strcmp (media_type, "video/x-raw-rgb") == 0) {
int red_mask;
int green_mask;
int blue_mask;
ret &= gst_structure_get_int (structure, "bpp", &bpp);
for (i = 0; i < n_fourccs; i++) {
- if (strcmp(fourcc_list[i].fourcc, "RGB ") == 0 &&
+ if (strcmp (fourcc_list[i].fourcc, "RGB ") == 0 &&
fourcc_list[i].red_mask == red_mask &&
fourcc_list[i].green_mask == green_mask &&
fourcc_list[i].blue_mask == blue_mask &&
- fourcc_list[i].depth == depth &&
- fourcc_list[i].bitspp == bpp){
+ fourcc_list[i].depth == depth && fourcc_list[i].bitspp == bpp) {
return fourcc_list + i;
}
return NULL;
}
- g_critical("format not found for media type %s", media_type);
+ g_critical ("format not found for media type %s", media_type);
return NULL;
}
-struct fourcc_list_struct * paintrect_find_fourcc (int find_fourcc)
+struct fourcc_list_struct *
+paintrect_find_fourcc (int find_fourcc)
{
int i;
fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
if (find_fourcc == fourcc) {
/* If YUV format, it's good */
- if(!fourcc_list[i].ext_caps){
- return fourcc_list + i;
+ if (!fourcc_list[i].ext_caps) {
+ return fourcc_list + i;
}
return fourcc_list + i;
return NULL;
}
-struct fourcc_list_struct * paintrect_find_name (const char *name)
+struct fourcc_list_struct *
+paintrect_find_name (const char *name)
{
int i;
for (i = 0; i < n_fourccs; i++) {
- if(strcmp(name,fourcc_list[i].name)==0){
+ if (strcmp (name, fourcc_list[i].name) == 0) {
return fourcc_list + i;
}
}
}
-GstStructure *paint_get_structure(struct fourcc_list_struct *format)
+GstStructure *
+paint_get_structure (struct fourcc_list_struct * format)
{
unsigned int fourcc;
- g_return_val_if_fail(format, NULL);
+ g_return_val_if_fail (format, NULL);
- fourcc = GST_MAKE_FOURCC (format->fourcc[0], format->fourcc[1], format->fourcc[2], format->fourcc[3]);
+ fourcc =
+ GST_MAKE_FOURCC (format->fourcc[0], format->fourcc[1], format->fourcc[2],
+ format->fourcc[3]);
- if(format->ext_caps){
+ if (format->ext_caps) {
int endianness;
- if(format->bitspp==16){
+ if (format->bitspp == 16) {
endianness = G_BYTE_ORDER;
- }else{
+ } else {
endianness = G_BIG_ENDIAN;
}
return gst_structure_new ("video/x-raw-rgb",
"depth", G_TYPE_INT, format->depth,
"red_mask", G_TYPE_INT, format->red_mask,
"green_mask", G_TYPE_INT, format->green_mask,
- "blue_mask", G_TYPE_INT, format->blue_mask,
- NULL);
- }else{
+ "blue_mask", G_TYPE_INT, format->blue_mask, NULL);
+ } else {
return gst_structure_new ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, fourcc,
- NULL);
+ "format", GST_TYPE_FOURCC, fourcc, NULL);
}
}
fourcc->paint_setup (p, NULL);
- return (unsigned long)p->endptr;
+ return (unsigned long) p->endptr;
}
void
/* superblack, black, dark grey */
for (i = 0; i < 3; i++) {
- int x1 = w/2 + i * w / 12;
- int x2 = w/2 + (i + 1) * w / 12;
+ int x1 = w / 2 + i * w / 12;
+ int x2 = w / 2 + (i + 1) * w / 12;
int k;
if (i == 0) {
}
{
- int x1 = w*3 / 4;
+ int x1 = w * 3 / 4;
struct vts_color_struct color;
color = vts_colors[COLOR_BLACK];
for (j = y2; j < h; j++) {
/* FIXME not strictly correct */
color.Y = random_char ();
- color.R = color.Y;
- color.G = color.Y;
- color.B = color.Y;
+ color.R = color.Y;
+ color.G = color.Y;
+ color.B = color.Y;
p->paint_hline (p, i, j, 1);
}
}
paint_setup_I420 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->ystride = ROUND_UP_4(p->width);
- p->up = p->yp + p->ystride * ROUND_UP_2(p->height);
- p->ustride = ROUND_UP_8(p->width)/2;
+ p->ystride = ROUND_UP_4 (p->width);
+ p->up = p->yp + p->ystride * ROUND_UP_2 (p->height);
+ p->ustride = ROUND_UP_8 (p->width) / 2;
p->vp = p->up + p->ustride * ROUND_UP_2 (p->height) / 2;
- p->vstride = ROUND_UP_8(p->ystride)/2;
+ p->vstride = ROUND_UP_8 (p->ystride) / 2;
p->endptr = p->vp + p->vstride * ROUND_UP_2 (p->height) / 2;
}
paint_setup_YV12 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->ystride = ROUND_UP_4(p->width);
- p->vp = p->yp + p->ystride * ROUND_UP_2(p->height);
- p->vstride = ROUND_UP_8(p->ystride)/2;
- p->up = p->vp + p->vstride * ROUND_UP_2(p->height) / 2;
- p->ustride = ROUND_UP_8(p->ystride)/2;
- p->endptr = p->up + p->ustride * ROUND_UP_2(p->height) / 2;
+ p->ystride = ROUND_UP_4 (p->width);
+ p->vp = p->yp + p->ystride * ROUND_UP_2 (p->height);
+ p->vstride = ROUND_UP_8 (p->ystride) / 2;
+ p->up = p->vp + p->vstride * ROUND_UP_2 (p->height) / 2;
+ p->ustride = ROUND_UP_8 (p->ystride) / 2;
+ p->endptr = p->up + p->ustride * ROUND_UP_2 (p->height) / 2;
}
static void
p->yp = dest;
p->up = dest + 1;
p->vp = dest + 3;
- p->ystride = ROUND_UP_2(p->width) * 2;
+ p->ystride = ROUND_UP_2 (p->width) * 2;
p->endptr = dest + p->ystride * p->height;
}
p->yp = dest + 1;
p->up = dest;
p->vp = dest + 2;
- p->ystride = ROUND_UP_2(p->width) * 2;
+ p->ystride = ROUND_UP_2 (p->width) * 2;
p->endptr = dest + p->ystride * p->height;
}
p->yp = dest;
p->up = dest + 3;
p->vp = dest + 1;
- p->ystride = ROUND_UP_2(p->width * 2);
+ p->ystride = ROUND_UP_2 (p->width * 2);
p->endptr = dest + p->ystride * p->height;
}
#ifndef HAVE_LIBOIL
-void splat_u8 (guint8 *dest, int dstr, guint8 val, int n)
+void
+splat_u8 (guint8 * dest, int dstr, guint8 val, int n)
{
int i;
- for(i=0;i<n;i++){
+
+ for (i = 0; i < n; i++) {
*dest = val;
dest += dstr;
}
p->yp = dest + 1;
p->up = dest + 0;
p->vp = dest + 2;
- p->ystride = ROUND_UP_4(p->width * 3);
+ p->ystride = ROUND_UP_4 (p->width * 3);
p->endptr = dest + p->ystride * p->height;
}
static void
paint_setup_YVU9 (paintinfo * p, char *dest)
{
- int h = ROUND_UP_4(p->height);
+ int h = ROUND_UP_4 (p->height);
+
p->yp = dest;
- p->ystride = ROUND_UP_4(p->width);
- p->vp = p->yp + p->ystride * ROUND_UP_4(p->height);
- p->vstride = ROUND_UP_4(p->ystride/4);
- p->up = p->vp + p->vstride * ROUND_UP_4(h/4);
- p->ustride = ROUND_UP_4(p->ystride/4);
- p->endptr = p->up + p->ustride * ROUND_UP_4(h/4);
+ p->ystride = ROUND_UP_4 (p->width);
+ p->vp = p->yp + p->ystride * ROUND_UP_4 (p->height);
+ p->vstride = ROUND_UP_4 (p->ystride / 4);
+ p->up = p->vp + p->vstride * ROUND_UP_4 (h / 4);
+ p->ustride = ROUND_UP_4 (p->ystride / 4);
+ p->endptr = p->up + p->ustride * ROUND_UP_4 (h / 4);
}
static void
paint_setup_YUV9 (paintinfo * p, char *dest)
{
/* untested */
- int h = ROUND_UP_4(p->height);
+ int h = ROUND_UP_4 (p->height);
+
p->yp = dest;
- p->ystride = ROUND_UP_4(p->width);
+ p->ystride = ROUND_UP_4 (p->width);
p->up = p->yp + p->ystride * h;
- p->ustride = ROUND_UP_4(p->ystride/4);
- p->vp = p->up + p->ustride * ROUND_UP_4(h/4);
- p->vstride = ROUND_UP_4(p->ystride/4);
- p->endptr = p->vp + p->vstride * ROUND_UP_4(h/4);
+ p->ustride = ROUND_UP_4 (p->ystride / 4);
+ p->vp = p->up + p->ustride * ROUND_UP_4 (h / 4);
+ p->vstride = ROUND_UP_4 (p->ystride / 4);
+ p->endptr = p->vp + p->vstride * ROUND_UP_4 (h / 4);
}
static void
p->yp = dest + 1;
p->up = dest + 2;
p->vp = dest + 3;
- p->ystride = p->width*4;
+ p->ystride = p->width * 4;
p->endptr = p->dest + p->ystride * p->height;
}
p->yp = dest + 3;
p->up = dest + 2;
p->vp = dest + 1;
- p->ystride = p->width*4;
+ p->ystride = p->width * 4;
p->endptr = p->dest + p->ystride * p->height;
}
p->yp = dest + 0;
p->up = dest + 1;
p->vp = dest + 2;
- p->ystride = p->width*4;
+ p->ystride = p->width * 4;
p->endptr = p->dest + p->ystride * p->height;
}
p->yp = dest + 2;
p->up = dest + 1;
p->vp = dest + 0;
- p->ystride = p->width*4;
+ p->ystride = p->width * 4;
p->endptr = p->dest + p->ystride * p->height;
}
p->yp = dest + 0;
p->up = dest + 1;
p->vp = dest + 2;
- p->ystride = ROUND_UP_4(p->width*3);
+ p->ystride = ROUND_UP_4 (p->width * 3);
p->endptr = p->dest + p->ystride * p->height;
}
p->yp = dest + 2;
p->up = dest + 1;
p->vp = dest + 0;
- p->ystride = ROUND_UP_4(p->width*3);
+ p->ystride = ROUND_UP_4 (p->width * 3);
p->endptr = p->dest + p->ystride * p->height;
}
paint_setup_RGB565 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->ystride = ROUND_UP_4(p->width*2);
+ p->ystride = ROUND_UP_4 (p->width * 2);
p->endptr = p->dest + p->ystride * p->height;
}
paint_hline_RGB565 (paintinfo * p, int x, int y, int w)
{
int offset = y * p->ystride;
- unsigned int a,b;
+ unsigned int a, b;
- a = (p->color->R&0xf8) | (p->color->G>>5);
- b = ((p->color->G<<3)&0xe0) | (p->color->B>>3);
+ a = (p->color->R & 0xf8) | (p->color->G >> 5);
+ b = ((p->color->G << 3) & 0xe0) | (p->color->B >> 3);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
splat_u8 (p->yp + offset + x * 2 + 0, 2, b, w);
paint_setup_xRGB1555 (paintinfo * p, char *dest)
{
p->yp = dest;
- p->ystride = ROUND_UP_4(p->width*2);
+ p->ystride = ROUND_UP_4 (p->width * 2);
p->endptr = p->dest + p->ystride * p->height;
}
paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w)
{
int offset = y * p->ystride;
- unsigned int a,b;
+ unsigned int a, b;
- a = ((p->color->R>>1)&0x7c) | (p->color->G>>6);
- b = ((p->color->G<<2)&0xe0) | (p->color->B>>3);
+ a = ((p->color->R >> 1) & 0x7c) | (p->color->G >> 6);
+ b = ((p->color->G << 2) & 0xe0) | (p->color->B >> 3);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
splat_u8 (p->yp + offset + x * 2 + 0, 2, b, w);
splat_u8 (p->yp + offset + x * 2 + 1, 2, b, w);
#endif
}
-
#ifndef __VIDEOTESTSRC_H__
#define __VIDEOTESTSRC_H__
-struct vts_color_struct{
- int Y,U,V;
- int R,G,B;
+struct vts_color_struct
+{
+ int Y, U, V;
+ int R, G, B;
};
typedef struct paintinfo_struct paintinfo;
unsigned int blue_mask;
};
-struct fourcc_list_struct * paintrect_find_fourcc (int find_fourcc);
-struct fourcc_list_struct * paintrect_find_name (const char *name);
-struct fourcc_list_struct *paintinfo_find_by_structure(
- const GstStructure *structure);
-GstStructure *paint_get_structure(struct fourcc_list_struct *format);
+struct fourcc_list_struct *paintrect_find_fourcc (int find_fourcc);
+struct fourcc_list_struct *paintrect_find_name (const char *name);
+struct fourcc_list_struct *paintinfo_find_by_structure (const GstStructure *
+ structure);
+GstStructure *paint_get_structure (struct fourcc_list_struct *format);
int gst_videotestsrc_get_size (GstVideotestsrc * v, int w, int h);
-void gst_videotestsrc_smpte (GstVideotestsrc * v, unsigned char *dest, int w, int h);
-void gst_videotestsrc_snow (GstVideotestsrc * v, unsigned char *dest, int w, int h);
-void gst_videotestsrc_black (GstVideotestsrc * v, unsigned char *dest, int w, int h);
+void gst_videotestsrc_smpte (GstVideotestsrc * v, unsigned char *dest, int w,
+ int h);
+void gst_videotestsrc_snow (GstVideotestsrc * v, unsigned char *dest, int w,
+ int h);
+void gst_videotestsrc_black (GstVideotestsrc * v, unsigned char *dest, int w,
+ int h);
extern struct fourcc_list_struct fourcc_list[];
extern int n_fourccs;
#endif
-
/* the volume factor is a range from 0.0 to (arbitrary) 4.0
* we map 1.0 to VOLUME_UNITY_INT
*/
-#define VOLUME_UNITY_INT 8192 /* internal int for unity */
-#define VOLUME_UNITY_BIT_SHIFT 13 /* number of bits to shift
- for unity */
+#define VOLUME_UNITY_INT 8192 /* internal int for unity */
+#define VOLUME_UNITY_BIT_SHIFT 13 /* number of bits to shift
+ for unity */
#define VOLUME_MAX_DOUBLE 4.0
#define VOLUME_MAX_INT16 32767
#define VOLUME_MIN_INT16 -32768
/* Filter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SILENT,
ARG_MUTE,
};
static GstStaticPadTemplate volume_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-float, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 32, "
- "buffer-frames = (int) [ 1, MAX]; "
- "audio/x-raw-int, "
- "channels = (int) [ 1, MAX ], "
- "rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "signed = (bool) TRUE"
- )
-);
-
-static GstStaticPadTemplate volume_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-float, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 32, "
- "buffer-frames = (int) [ 1, MAX]; "
- "audio/x-raw-int, "
- "channels = (int) [ 1, MAX ], "
- "rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "signed = (bool) TRUE"
- )
-);
-
-static void volume_base_init (gpointer g_class);
-static void volume_class_init (GstVolumeClass *klass);
-static void volume_init (GstVolume *filter);
-
-static void volume_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void volume_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void volume_update_volume (const GValue *value, gpointer data);
-static void volume_update_mute (const GValue *value, gpointer data);
-
-static gboolean volume_parse_caps (GstVolume *filter, GstStructure *structure);
-
-static void volume_chain_float (GstPad *pad, GstData *_data);
-static void volume_chain_int16 (GstPad *pad, GstData *_data);
-
-static void gst_volume_interface_init (GstImplementsInterfaceClass *klass);
-static void gst_volume_mixer_init (GstMixerClass *iface);
+ GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-float, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) 32, "
+ "buffer-frames = (int) [ 1, MAX]; "
+ "audio/x-raw-int, "
+ "channels = (int) [ 1, MAX ], "
+ "rate = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
+ );
+
+static GstStaticPadTemplate volume_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-float, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) 32, "
+ "buffer-frames = (int) [ 1, MAX]; "
+ "audio/x-raw-int, "
+ "channels = (int) [ 1, MAX ], "
+ "rate = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
+ );
+
+static void volume_base_init (gpointer g_class);
+static void volume_class_init (GstVolumeClass * klass);
+static void volume_init (GstVolume * filter);
+
+static void volume_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void volume_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void volume_update_volume (const GValue * value, gpointer data);
+static void volume_update_mute (const GValue * value, gpointer data);
+
+static gboolean volume_parse_caps (GstVolume * filter,
+ GstStructure * structure);
+
+static void volume_chain_float (GstPad * pad, GstData * _data);
+static void volume_chain_int16 (GstPad * pad, GstData * _data);
+
+static void gst_volume_interface_init (GstImplementsInterfaceClass * klass);
+static void gst_volume_mixer_init (GstMixerClass * iface);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
static gboolean
-gst_volume_interface_supported (GstImplementsInterface *iface, GType type)
+gst_volume_interface_supported (GstImplementsInterface * iface, GType type)
{
g_assert (type == GST_TYPE_MIXER);
return TRUE;
}
static void
-gst_volume_interface_init (GstImplementsInterfaceClass *klass)
+gst_volume_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_volume_interface_supported;
}
static const GList *
-gst_volume_list_tracks (GstMixer *mixer)
+gst_volume_list_tracks (GstMixer * mixer)
{
GstVolume *filter = GST_VOLUME (mixer);
-
+
g_return_val_if_fail (filter != NULL, NULL);
g_return_val_if_fail (GST_IS_VOLUME (filter), NULL);
-
+
return filter->tracklist;
}
static void
-gst_volume_set_volume (GstMixer *mixer, GstMixerTrack *track,
- gint *volumes)
+gst_volume_set_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstVolume *filter = GST_VOLUME (mixer);
-
+
g_return_if_fail (filter != NULL);
g_return_if_fail (GST_IS_VOLUME (filter));
-
+
gst_dpman_bypass_dparam (filter->dpman, "volume");
-
- filter->volume_f = (gfloat) volumes[0] / VOLUME_STEPS;
- filter->volume_i = filter->volume_f * VOLUME_UNITY_INT;
-
+
+ filter->volume_f = (gfloat) volumes[0] / VOLUME_STEPS;
+ filter->volume_i = filter->volume_f * VOLUME_UNITY_INT;
+
if (filter->mute) {
filter->real_vol_f = 0.0;
filter->real_vol_i = 0;
- }
- else {
+ } else {
filter->real_vol_f = filter->volume_f;
filter->real_vol_i = filter->volume_i;
}
}
static void
-gst_volume_get_volume (GstMixer *mixer, GstMixerTrack *track,
- gint *volumes)
+gst_volume_get_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstVolume *filter = GST_VOLUME (mixer);
-
+
g_return_if_fail (filter != NULL);
g_return_if_fail (GST_IS_VOLUME (filter));
-
+
volumes[0] = (gint) filter->volume_f * VOLUME_STEPS;
}
static void
-gst_volume_set_mute (GstMixer *mixer, GstMixerTrack *track,
- gboolean mute)
+gst_volume_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
GstVolume *filter = GST_VOLUME (mixer);
-
+
g_return_if_fail (filter != NULL);
g_return_if_fail (GST_IS_VOLUME (filter));
-
+
gst_dpman_bypass_dparam (filter->dpman, "volume");
-
+
filter->mute = mute;
-
+
if (filter->mute) {
filter->real_vol_f = 0.0;
filter->real_vol_i = 0;
- }
- else {
+ } else {
filter->real_vol_f = filter->volume_f;
filter->real_vol_i = filter->volume_i;
}
}
static void
-gst_volume_mixer_init (GstMixerClass *klass)
+gst_volume_mixer_init (GstMixerClass * klass)
{
GST_MIXER_TYPE (klass) = GST_MIXER_SOFTWARE;
-
+
/* default virtual functions */
klass->list_tracks = gst_volume_list_tracks;
klass->set_volume = gst_volume_set_volume;
}
static void
-gst_volume_dispose (GObject *object)
+gst_volume_dispose (GObject * object)
{
GstVolume *volume;
volume = GST_VOLUME (object);
-
- if (volume->tracklist)
- {
- if (volume->tracklist->data)
- g_object_unref (volume->tracklist->data);
- g_list_free (volume->tracklist);
- volume->tracklist = NULL;
- }
-
+
+ if (volume->tracklist) {
+ if (volume->tracklist->data)
+ g_object_unref (volume->tracklist->data);
+ g_list_free (volume->tracklist);
+ volume->tracklist = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static GstPadLinkReturn
-volume_connect (GstPad *pad, const GstCaps *caps)
+volume_connect (GstPad * pad, const GstCaps * caps)
{
GstVolume *filter;
GstPad *otherpad;
gint rate;
GstPadLinkReturn link_ret;
GstStructure *structure;
-
+
filter = GST_VOLUME (gst_pad_get_parent (pad));
g_return_val_if_fail (GST_IS_VOLUME (filter), GST_PAD_LINK_REFUSED);
otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "rate", &rate);
-
+
link_ret = gst_pad_try_set_caps (otherpad, caps);
- if (GST_PAD_LINK_FAILED (link_ret)){
+ if (GST_PAD_LINK_FAILED (link_ret)) {
return link_ret;
}
if (!volume_parse_caps (filter, structure))
return GST_PAD_LINK_REFUSED;
- gst_dpman_set_rate(filter->dpman, rate);
-
+ gst_dpman_set_rate (filter->dpman, rate);
+
return GST_PAD_LINK_OK;
}
static gboolean
-volume_parse_caps (GstVolume *filter, GstStructure *structure)
+volume_parse_caps (GstVolume * filter, GstStructure * structure)
{
const gchar *mimetype;
-
- g_return_val_if_fail(filter!=NULL,FALSE);
- g_return_val_if_fail(structure!=NULL,FALSE);
-
+
+ g_return_val_if_fail (filter != NULL, FALSE);
+ g_return_val_if_fail (structure != NULL, FALSE);
+
mimetype = gst_structure_get_name (structure);
-
- if (strcmp(mimetype, "audio/x-raw-int")==0) {
- gst_pad_set_chain_function(filter->sinkpad,volume_chain_int16);
+
+ if (strcmp (mimetype, "audio/x-raw-int") == 0) {
+ gst_pad_set_chain_function (filter->sinkpad, volume_chain_int16);
return TRUE;
}
-
- if (strcmp(mimetype, "audio/x-raw-float")==0) {
- gst_pad_set_chain_function(filter->sinkpad,volume_chain_float);
+
+ if (strcmp (mimetype, "audio/x-raw-float") == 0) {
+ gst_pad_set_chain_function (filter->sinkpad, volume_chain_float);
return TRUE;
}
GType
-gst_volume_get_type(void) {
+gst_volume_get_type (void)
+{
static GType volume_type = 0;
if (!volume_type) {
static const GTypeInfo volume_info = {
- sizeof(GstVolumeClass),
+ sizeof (GstVolumeClass),
volume_base_init,
NULL,
- (GClassInitFunc)volume_class_init,
+ (GClassInitFunc) volume_class_init,
NULL,
NULL,
- sizeof(GstVolume),
+ sizeof (GstVolume),
0,
- (GInstanceInitFunc)volume_init
+ (GInstanceInitFunc) volume_init
};
static const GInterfaceInfo voliface_info = {
(GInterfaceInitFunc) gst_volume_interface_init,
NULL,
NULL
};
-
- volume_type = g_type_register_static(GST_TYPE_ELEMENT, "GstVolume", &volume_info, 0);
- g_type_add_interface_static (volume_type,
- GST_TYPE_IMPLEMENTS_INTERFACE,
- &voliface_info);
- g_type_add_interface_static (volume_type,
- GST_TYPE_MIXER,
- &volmixer_info);
+
+ volume_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstVolume", &volume_info, 0);
+ g_type_add_interface_static (volume_type, GST_TYPE_IMPLEMENTS_INTERFACE,
+ &voliface_info);
+ g_type_add_interface_static (volume_type, GST_TYPE_MIXER, &volmixer_info);
}
return volume_type;
}
volume_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 (&volume_src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&volume_sink_factory));
gst_element_class_set_details (element_class, &volume_details);
}
static void
-volume_class_init (GstVolumeClass *klass)
+volume_class_init (GstVolumeClass * 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_MUTE,
+ g_param_spec_boolean ("mute", "mute", "mute", FALSE, G_PARAM_READWRITE));
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VOLUME,
+ g_param_spec_double ("volume", "volume", "volume",
+ 0.0, VOLUME_MAX_DOUBLE, 1.0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUTE,
- g_param_spec_boolean("mute","mute","mute",
- FALSE,G_PARAM_READWRITE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VOLUME,
- g_param_spec_double("volume","volume","volume",
- 0.0,VOLUME_MAX_DOUBLE,1.0,G_PARAM_READWRITE));
-
gobject_class->set_property = volume_set_property;
gobject_class->get_property = volume_get_property;
gobject_class->dispose = gst_volume_dispose;
}
static void
-volume_init (GstVolume *filter)
+volume_init (GstVolume * filter)
{
GstMixerTrack *track = NULL;
-
- filter->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&volume_sink_factory), "sink");
+
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&volume_sink_factory), "sink");
gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps);
gst_pad_set_link_function (filter->sinkpad, volume_connect);
-
- filter->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&volume_src_factory), "src");
+
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&volume_src_factory), "src");
gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps);
- gst_pad_set_link_function(filter->srcpad,volume_connect);
-
+ gst_pad_set_link_function (filter->srcpad, volume_connect);
+
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
-
+
gst_pad_set_chain_function (filter->sinkpad, volume_chain_int16);
-
+
filter->mute = FALSE;
filter->volume_i = VOLUME_UNITY_INT;
filter->volume_f = 1.0;
filter->real_vol_f = 1.0;
filter->tracklist = NULL;
- filter->dpman = gst_dpman_new ("volume_dpman", GST_ELEMENT(filter));
- gst_dpman_add_required_dparam_callback (
- filter->dpman,
- g_param_spec_int("mute","Mute","Mute the audio",
- 0, 1, 0, G_PARAM_READWRITE),
- "int",
- volume_update_mute,
- filter
- );
- gst_dpman_add_required_dparam_callback (
- filter->dpman,
- g_param_spec_double("volume","Volume","Volume of the audio",
- 0.0, VOLUME_MAX_DOUBLE, 1.0, G_PARAM_READWRITE),
- "scalar",
- volume_update_volume,
- filter
- );
-
+ filter->dpman = gst_dpman_new ("volume_dpman", GST_ELEMENT (filter));
+ gst_dpman_add_required_dparam_callback (filter->dpman,
+ g_param_spec_int ("mute", "Mute", "Mute the audio",
+ 0, 1, 0, G_PARAM_READWRITE), "int", volume_update_mute, filter);
+ gst_dpman_add_required_dparam_callback (filter->dpman,
+ g_param_spec_double ("volume", "Volume", "Volume of the audio",
+ 0.0, VOLUME_MAX_DOUBLE, 1.0, G_PARAM_READWRITE),
+ "scalar", volume_update_volume, filter);
+
track = g_object_new (GST_TYPE_MIXER_TRACK, NULL);
-
- if (GST_IS_MIXER_TRACK (track))
- {
- track->label = g_strdup ("volume");
- track->num_channels = 1;
- track->min_volume = 0;
- track->max_volume = VOLUME_STEPS;
- track->flags = GST_MIXER_TRACK_SOFTWARE;
- filter->tracklist = g_list_append (filter->tracklist, track);
- }
+
+ if (GST_IS_MIXER_TRACK (track)) {
+ track->label = g_strdup ("volume");
+ track->num_channels = 1;
+ track->min_volume = 0;
+ track->max_volume = VOLUME_STEPS;
+ track->flags = GST_MIXER_TRACK_SOFTWARE;
+ filter->tracklist = g_list_append (filter->tracklist, track);
+ }
}
static void
-volume_chain_float (GstPad *pad, GstData *_data)
+volume_chain_float (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstVolume *filter;
gfloat *data;
gint i, num_samples;
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
-
- filter = GST_VOLUME(GST_OBJECT_PARENT (pad));
- g_return_if_fail(GST_IS_VOLUME(filter));
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
+
+ filter = GST_VOLUME (GST_OBJECT_PARENT (pad));
+ g_return_if_fail (GST_IS_VOLUME (filter));
out_buf = gst_buffer_copy_on_write (buf);
- data = (gfloat *)GST_BUFFER_DATA(out_buf);
- num_samples = GST_BUFFER_SIZE(out_buf)/sizeof(gfloat);
- GST_DPMAN_PREPROCESS(filter->dpman, num_samples, GST_BUFFER_TIMESTAMP(out_buf));
+ data = (gfloat *) GST_BUFFER_DATA (out_buf);
+ num_samples = GST_BUFFER_SIZE (out_buf) / sizeof (gfloat);
+ GST_DPMAN_PREPROCESS (filter->dpman, num_samples,
+ GST_BUFFER_TIMESTAMP (out_buf));
i = 0;
-
- while(GST_DPMAN_PROCESS(filter->dpman, i)) {
+
+ while (GST_DPMAN_PROCESS (filter->dpman, i)) {
data[i++] *= filter->real_vol_f;
}
-
- gst_pad_push(filter->srcpad,GST_DATA (out_buf));
-
+
+ gst_pad_push (filter->srcpad, GST_DATA (out_buf));
+
}
static void
-volume_chain_int16 (GstPad *pad, GstData *_data)
+volume_chain_int16 (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstVolume *filter;
gint16 *data;
gint i, num_samples;
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
-
- filter = GST_VOLUME(GST_OBJECT_PARENT (pad));
- g_return_if_fail(GST_IS_VOLUME(filter));
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
+
+ filter = GST_VOLUME (GST_OBJECT_PARENT (pad));
+ g_return_if_fail (GST_IS_VOLUME (filter));
out_buf = gst_buffer_copy_on_write (buf);
data = (gint16 *) GST_BUFFER_DATA (out_buf);
g_assert (data);
- num_samples = GST_BUFFER_SIZE(out_buf)/sizeof(gint16);
- GST_DPMAN_PREPROCESS(filter->dpman, num_samples, GST_BUFFER_TIMESTAMP(out_buf));
+ num_samples = GST_BUFFER_SIZE (out_buf) / sizeof (gint16);
+ GST_DPMAN_PREPROCESS (filter->dpman, num_samples,
+ GST_BUFFER_TIMESTAMP (out_buf));
i = 0;
-
- while(GST_DPMAN_PROCESS(filter->dpman, i)) {
+
+ while (GST_DPMAN_PROCESS (filter->dpman, i)) {
/* only clamp if the gain is greater than 1.0 */
- if (filter->real_vol_i > VOLUME_UNITY_INT){
- while (i < GST_DPMAN_NEXT_UPDATE_FRAME(filter->dpman)){
- /* we use bitshifting instead of dividing by UNITY_INT for speed */
- data[i] = (gint16) CLAMP((filter->real_vol_i * (gint) data[i]) >> VOLUME_UNITY_BIT_SHIFT, VOLUME_MIN_INT16, VOLUME_MAX_INT16);
+ if (filter->real_vol_i > VOLUME_UNITY_INT) {
+ while (i < GST_DPMAN_NEXT_UPDATE_FRAME (filter->dpman)) {
+ /* we use bitshifting instead of dividing by UNITY_INT for speed */
+ data[i] =
+ (gint16) CLAMP ((filter->real_vol_i *
+ (gint) data[i]) >> VOLUME_UNITY_BIT_SHIFT, VOLUME_MIN_INT16,
+ VOLUME_MAX_INT16);
i++;
}
- }
- else {
- while (i < GST_DPMAN_NEXT_UPDATE_FRAME(filter->dpman)){
- /* we use bitshifting instead of dividing by UNITY_INT for speed */
- data[i] = (gint16) ((filter->real_vol_i * (gint) data[i]) >> VOLUME_UNITY_BIT_SHIFT);
- i++;
+ } else {
+ while (i < GST_DPMAN_NEXT_UPDATE_FRAME (filter->dpman)) {
+ /* we use bitshifting instead of dividing by UNITY_INT for speed */
+ data[i] =
+ (gint16) ((filter->real_vol_i *
+ (gint) data[i]) >> VOLUME_UNITY_BIT_SHIFT);
+ i++;
}
}
}
- gst_pad_push(filter->srcpad,GST_DATA (out_buf));
-
+ gst_pad_push (filter->srcpad, GST_DATA (out_buf));
+
}
static void
-volume_update_mute(const GValue *value, gpointer data)
+volume_update_mute (const GValue * value, gpointer data)
{
- GstVolume *filter = (GstVolume*)data;
- g_return_if_fail(GST_IS_VOLUME(filter));
+ GstVolume *filter = (GstVolume *) data;
- if (G_VALUE_HOLDS_BOOLEAN(value)){
- filter->mute = g_value_get_boolean(value);
- }
- else if (G_VALUE_HOLDS_INT(value)){
- filter->mute = (g_value_get_int(value) == 1);
+ g_return_if_fail (GST_IS_VOLUME (filter));
+
+ if (G_VALUE_HOLDS_BOOLEAN (value)) {
+ filter->mute = g_value_get_boolean (value);
+ } else if (G_VALUE_HOLDS_INT (value)) {
+ filter->mute = (g_value_get_int (value) == 1);
}
-
- if (filter->mute){
+
+ if (filter->mute) {
filter->real_vol_f = 0.0;
filter->real_vol_i = 0;
- }
- else {
+ } else {
filter->real_vol_f = filter->volume_f;
filter->real_vol_i = filter->volume_i;
}
}
static void
-volume_update_volume(const GValue *value, gpointer data)
+volume_update_volume (const GValue * value, gpointer data)
{
- GstVolume *filter = (GstVolume*)data;
- g_return_if_fail(GST_IS_VOLUME(filter));
+ GstVolume *filter = (GstVolume *) data;
- filter->volume_f = g_value_get_double (value);
- filter->volume_i = filter->volume_f*VOLUME_UNITY_INT;
- if (filter->mute){
+ g_return_if_fail (GST_IS_VOLUME (filter));
+
+ filter->volume_f = g_value_get_double (value);
+ filter->volume_i = filter->volume_f * VOLUME_UNITY_INT;
+ if (filter->mute) {
filter->real_vol_f = 0.0;
filter->real_vol_i = 0;
- }
- else {
+ } else {
filter->real_vol_f = filter->volume_f;
filter->real_vol_i = filter->volume_i;
}
}
static void
-volume_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+volume_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstVolume *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VOLUME(object));
- filter = GST_VOLUME(object);
-
- switch (prop_id)
- {
- case ARG_MUTE:
- gst_dpman_bypass_dparam(filter->dpman, "mute");
- volume_update_mute(value, filter);
- break;
- case ARG_VOLUME:
- gst_dpman_bypass_dparam(filter->dpman, "volume");
- volume_update_volume(value, filter);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ g_return_if_fail (GST_IS_VOLUME (object));
+ filter = GST_VOLUME (object);
+
+ switch (prop_id) {
+ case ARG_MUTE:
+ gst_dpman_bypass_dparam (filter->dpman, "mute");
+ volume_update_mute (value, filter);
+ break;
+ case ARG_VOLUME:
+ gst_dpman_bypass_dparam (filter->dpman, "volume");
+ volume_update_volume (value, filter);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-volume_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+volume_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstVolume *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VOLUME(object));
- filter = GST_VOLUME(object);
-
+ g_return_if_fail (GST_IS_VOLUME (object));
+ filter = GST_VOLUME (object);
+
switch (prop_id) {
- case ARG_MUTE:
- g_value_set_boolean (value, filter->mute);
- break;
- case ARG_VOLUME:
- g_value_set_double (value, filter->volume_f);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_MUTE:
+ g_value_set_boolean (value, filter->mute);
+ break;
+ case ARG_VOLUME:
+ g_value_set_double (value, filter->volume_f);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- gst_control_init(NULL,NULL);
-
- return gst_element_register (plugin, "volume", GST_RANK_NONE, GST_TYPE_VOLUME);
+ gst_control_init (NULL, NULL);
+
+ return gst_element_register (plugin, "volume", GST_RANK_NONE,
+ GST_TYPE_VOLUME);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "volume",
- "element for controlling audio volume",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "volume",
+ "element for controlling audio volume",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_VOLUME \
#define GST_IS_VOLUME_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VOLUME))
-typedef struct _GstVolume GstVolume;
-typedef struct _GstVolumeClass GstVolumeClass;
-typedef enum _GstVolumeFormat GstVolumeFormat;
+ typedef struct _GstVolume GstVolume;
+ typedef struct _GstVolumeClass GstVolumeClass;
+ typedef enum _GstVolumeFormat GstVolumeFormat;
-enum _GstVolumeFormat {
- GST_VOLUME_FORMAT_INT=1,
- GST_VOLUME_FORMAT_FLOAT
-};
+ enum _GstVolumeFormat
+ {
+ GST_VOLUME_FORMAT_INT = 1,
+ GST_VOLUME_FORMAT_FLOAT
+ };
-struct _GstVolume {
- GstElement element;
+ struct _GstVolume
+ {
+ GstElement element;
- GstPad *sinkpad, *srcpad;
- GstDParamManager *dpman;
+ GstPad *sinkpad, *srcpad;
+ GstDParamManager *dpman;
- gboolean mute;
- gint volume_i, real_vol_i; /* the _i(nt) values get synchronized with the */
- gfloat volume_f, real_vol_f; /* _f(loat) values on each update */
-
- GList *tracklist;
-};
+ gboolean mute;
+ gint volume_i, real_vol_i; /* the _i(nt) values get synchronized with the */
+ gfloat volume_f, real_vol_f; /* _f(loat) values on each update */
-struct _GstVolumeClass {
- GstElementClass parent_class;
-};
+ GList *tracklist;
+ };
-GType gst_volume_get_type(void);
+ struct _GstVolumeClass
+ {
+ GstElementClass parent_class;
+ };
+
+ GType gst_volume_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_VOLUME_H__ */
+#endif /* __GST_VOLUME_H__ */
#include "gstv4lmjpegsink.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* actually, we can survive without it, but I'll create
* that handling later on. */
return FALSE;
if (!gst_element_register (plugin, "v4lelement",
- GST_RANK_NONE, GST_TYPE_V4LELEMENT) ||
+ GST_RANK_NONE, GST_TYPE_V4LELEMENT) ||
!gst_element_register (plugin, "v4lsrc",
- GST_RANK_NONE, GST_TYPE_V4LSRC) ||
+ GST_RANK_NONE, GST_TYPE_V4LSRC) ||
!gst_element_register (plugin, "v4lmjpegsrc",
- GST_RANK_NONE, GST_TYPE_V4LMJPEGSRC) ||
+ GST_RANK_NONE, GST_TYPE_V4LMJPEGSRC) ||
!gst_element_register (plugin, "v4lmjpegsink",
- GST_RANK_NONE, GST_TYPE_V4LMJPEGSINK))
+ GST_RANK_NONE, GST_TYPE_V4LMJPEGSINK))
return FALSE;
#ifdef ENABLE_NLS
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "video4linux",
- "elements for Video 4 Linux",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "video4linux",
+ "elements for Video 4 Linux",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include "gstv4lelement.h"
static void
-gst_v4l_color_balance_channel_class_init(GstV4lColorBalanceChannelClass *klass);
-static void
-gst_v4l_color_balance_channel_init (GstV4lColorBalanceChannel *channel);
-
-static const GList *
-gst_v4l_color_balance_list_channels (GstColorBalance *balance);
-static void
-gst_v4l_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
-static gint
-gst_v4l_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+gst_v4l_color_balance_channel_class_init (GstV4lColorBalanceChannelClass *
+ klass);
+static void gst_v4l_color_balance_channel_init (GstV4lColorBalanceChannel *
+ channel);
+
+static const GList *gst_v4l_color_balance_list_channels (GstColorBalance *
+ balance);
+static void gst_v4l_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
+static gint gst_v4l_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel);
static GstColorBalanceChannelClass *parent_class = NULL;
gst_v4l_color_balance_channel_type =
g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
- "GstV4lColorBalanceChannel",
- &v4l_tuner_channel_info, 0);
+ "GstV4lColorBalanceChannel", &v4l_tuner_channel_info, 0);
}
return gst_v4l_color_balance_channel_type;
}
static void
-gst_v4l_color_balance_channel_class_init (GstV4lColorBalanceChannelClass *klass)
+gst_v4l_color_balance_channel_class_init (GstV4lColorBalanceChannelClass *
+ klass)
{
parent_class = g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
}
static void
-gst_v4l_color_balance_channel_init (GstV4lColorBalanceChannel *channel)
+gst_v4l_color_balance_channel_init (GstV4lColorBalanceChannel * channel)
{
channel->index = 0;
}
void
-gst_v4l_color_balance_interface_init (GstColorBalanceClass *klass)
+gst_v4l_color_balance_interface_init (GstColorBalanceClass * klass)
{
GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
-
+
/* default virtual functions */
klass->list_channels = gst_v4l_color_balance_list_channels;
klass->set_value = gst_v4l_color_balance_set_value;
}
static gboolean
-gst_v4l_color_balance_contains_channel (GstV4lElement *v4lelement,
- GstV4lColorBalanceChannel *v4lchannel)
+gst_v4l_color_balance_contains_channel (GstV4lElement * v4lelement,
+ GstV4lColorBalanceChannel * v4lchannel)
{
const GList *item;
}
static const GList *
-gst_v4l_color_balance_list_channels (GstColorBalance *balance)
+gst_v4l_color_balance_list_channels (GstColorBalance * balance)
{
return GST_V4LELEMENT (balance)->colors;
}
static void
-gst_v4l_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value)
+gst_v4l_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (balance);
GstV4lColorBalanceChannel *v4lchannel =
- GST_V4L_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L_COLOR_BALANCE_CHANNEL (channel);
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L_IS_OPEN (v4lelement));
g_return_if_fail (gst_v4l_color_balance_contains_channel (v4lelement,
- v4lchannel));
+ v4lchannel));
gst_v4l_set_picture (v4lelement, v4lchannel->index, value);
}
static gint
-gst_v4l_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel)
+gst_v4l_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (balance);
GstV4lColorBalanceChannel *v4lchannel =
- GST_V4L_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L_COLOR_BALANCE_CHANNEL (channel);
gint value;
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L_IS_OPEN (v4lelement), 0);
g_return_val_if_fail (gst_v4l_color_balance_contains_channel (v4lelement,
- v4lchannel),
- 0);
+ v4lchannel), 0);
if (!gst_v4l_get_picture (v4lelement, v4lchannel->index, &value))
return 0;
#include "v4l_calls.h"
G_BEGIN_DECLS
-
#define GST_TYPE_V4L_COLOR_BALANCE_CHANNEL \
(gst_v4l_color_balance_channel_get_type ())
#define GST_V4L_COLOR_BALANCE_CHANNEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L_COLOR_BALANCE_CHANNEL))
#define GST_IS_V4L_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L_COLOR_BALANCE_CHANNEL))
-
-typedef struct _GstV4lColorBalanceChannel {
+ typedef struct _GstV4lColorBalanceChannel
+{
GstColorBalanceChannel parent;
GstV4lPictureType index;
} GstV4lColorBalanceChannel;
-typedef struct _GstV4lColorBalanceChannelClass {
+typedef struct _GstV4lColorBalanceChannelClass
+{
GstColorBalanceChannelClass parent;
} GstV4lColorBalanceChannelClass;
-GType gst_v4l_color_balance_channel_get_type (void);
+GType gst_v4l_color_balance_channel_get_type (void);
-void gst_v4l_color_balance_interface_init (GstColorBalanceClass *klass);
+void gst_v4l_color_balance_interface_init (GstColorBalanceClass * klass);
#endif /* __GST_V4L_COLOR_BALANCE_H__ */
#include <gst/propertyprobe/propertyprobe.h>
/* elementfactory information */
-static GstElementDetails gst_v4lelement_details = GST_ELEMENT_DETAILS (
- "Generic video4linux Element",
- "Generic/Video",
- "Generic plugin for handling common video4linux calls",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
-);
+static GstElementDetails gst_v4lelement_details =
+GST_ELEMENT_DETAILS ("Generic video4linux Element",
+ "Generic/Video",
+ "Generic plugin for handling common video4linux calls",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* V4lElement signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_OPEN,
SIGNAL_CLOSE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_DEVICE,
ARG_DEVICE_NAME,
};
-static void gst_v4lelement_base_init (gpointer g_class);
-static void gst_v4lelement_class_init (GstV4lElementClass *klass);
-static void gst_v4lelement_init (GstV4lElement *v4lelement);
-static void gst_v4lelement_dispose (GObject *object);
-static void gst_v4lelement_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4lelement_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstElementStateReturn
- gst_v4lelement_change_state (GstElement *element);
+static void gst_v4lelement_base_init (gpointer g_class);
+static void gst_v4lelement_class_init (GstV4lElementClass * klass);
+static void gst_v4lelement_init (GstV4lElement * v4lelement);
+static void gst_v4lelement_dispose (GObject * object);
+static void gst_v4lelement_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4lelement_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_v4lelement_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_v4lelement_signals[LAST_SIGNAL] = { 0 };
static gboolean
-gst_v4l_iface_supported (GstImplementsInterface *iface,
- GType iface_type)
+gst_v4l_iface_supported (GstImplementsInterface * iface, GType iface_type)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (iface);
g_assert (iface_type == GST_TYPE_TUNER ||
- iface_type == GST_TYPE_X_OVERLAY ||
- iface_type == GST_TYPE_COLOR_BALANCE);
+ iface_type == GST_TYPE_X_OVERLAY || iface_type == GST_TYPE_COLOR_BALANCE);
if (v4lelement->video_fd == -1)
return FALSE;
- if (iface_type == GST_TYPE_X_OVERLAY &&
- !GST_V4L_IS_OVERLAY(v4lelement))
+ if (iface_type == GST_TYPE_X_OVERLAY && !GST_V4L_IS_OVERLAY (v4lelement))
return FALSE;
return TRUE;
}
static void
-gst_v4l_interface_init (GstImplementsInterfaceClass *klass)
+gst_v4l_interface_init (GstImplementsInterfaceClass * klass)
{
/* default virtual functions */
klass->supported = gst_v4l_iface_supported;
}
static const GList *
-gst_v4l_probe_get_properties (GstPropertyProbe *probe)
+gst_v4l_probe_get_properties (GstPropertyProbe * probe)
{
GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
static GList *list = NULL;
}
static gboolean
-gst_v4l_class_probe_devices (GstV4lElementClass *klass,
- gboolean check)
+gst_v4l_class_probe_devices (GstV4lElementClass * klass, gboolean check)
{
static gboolean init = FALSE;
static GList *devices = NULL;
/* detect /dev entries */
for (n = 0; n < 64; n++) {
for (base = 0; dev_base[base] != NULL; base++) {
- struct stat s;
- gchar *device = g_strdup_printf ("%s%d", dev_base[base], n);
-
- /* does the /dev/ entry exist at all? */
- if (stat (device, &s) == 0) {
- /* yes: is a device attached? */
- if ((fd = open (device, O_RDONLY)) > 0 || errno == EBUSY) {
- if (fd > 0)
- close (fd);
-
- devices = g_list_append (devices, device);
- break;
- }
- }
- g_free (device);
+ struct stat s;
+ gchar *device = g_strdup_printf ("%s%d", dev_base[base], n);
+
+ /* does the /dev/ entry exist at all? */
+ if (stat (device, &s) == 0) {
+ /* yes: is a device attached? */
+ if ((fd = open (device, O_RDONLY)) > 0 || errno == EBUSY) {
+ if (fd > 0)
+ close (fd);
+
+ devices = g_list_append (devices, device);
+ break;
+ }
+ }
+ g_free (device);
}
}
}
static void
-gst_v4l_probe_probe_property (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l_probe_probe_property (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
GstV4lElementClass *klass = GST_V4LELEMENT_GET_CLASS (probe);
}
static gboolean
-gst_v4l_probe_needs_probe (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l_probe_needs_probe (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
GstV4lElementClass *klass = GST_V4LELEMENT_GET_CLASS (probe);
gboolean ret = FALSE;
}
static GValueArray *
-gst_v4l_class_list_devices (GstV4lElementClass *klass)
+gst_v4l_class_list_devices (GstV4lElementClass * klass)
{
GValueArray *array;
GValue value = { 0 };
}
static GValueArray *
-gst_v4l_probe_get_values (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l_probe_get_values (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
GstV4lElementClass *klass = GST_V4LELEMENT_GET_CLASS (probe);
GValueArray *array = NULL;
}
static void
-gst_v4l_property_probe_interface_init (GstPropertyProbeInterface *iface)
+gst_v4l_property_probe_interface_init (GstPropertyProbeInterface * iface)
{
iface->get_properties = gst_v4l_probe_get_properties;
iface->probe_property = gst_v4l_probe_probe_property;
- iface->needs_probe = gst_v4l_probe_needs_probe;
- iface->get_values = gst_v4l_probe_get_values;
+ iface->needs_probe = gst_v4l_probe_needs_probe;
+ iface->get_values = gst_v4l_probe_get_values;
}
#define GST_TYPE_V4L_DEVICE_FLAGS (gst_v4l_device_get_type ())
if (v4l_device_type == 0) {
static const GFlagsValue values[] = {
- { VID_TYPE_CAPTURE, "CAPTURE", "Device can capture" },
- { VID_TYPE_TUNER, "TUNER", "Device has a tuner" },
- { VID_TYPE_OVERLAY, "OVERLAY", "Device can do overlay" },
- { VID_TYPE_MPEG_DECODER, "MPEG_DECODER", "Device can decode MPEG" },
- { VID_TYPE_MPEG_ENCODER, "MPEG_ENCODER", "Device can encode MPEG" },
- { VID_TYPE_MJPEG_DECODER, "MJPEG_DECODER", "Device can decode MJPEG" },
- { VID_TYPE_MJPEG_ENCODER, "MJPEG_ENCODER", "Device can encode MJPEG" },
- { 0x10000, "AUDIO", "Device handles audio" },
- { 0, NULL, NULL }
+ {VID_TYPE_CAPTURE, "CAPTURE", "Device can capture"},
+ {VID_TYPE_TUNER, "TUNER", "Device has a tuner"},
+ {VID_TYPE_OVERLAY, "OVERLAY", "Device can do overlay"},
+ {VID_TYPE_MPEG_DECODER, "MPEG_DECODER", "Device can decode MPEG"},
+ {VID_TYPE_MPEG_ENCODER, "MPEG_ENCODER", "Device can encode MPEG"},
+ {VID_TYPE_MJPEG_DECODER, "MJPEG_DECODER", "Device can decode MJPEG"},
+ {VID_TYPE_MJPEG_ENCODER, "MJPEG_ENCODER", "Device can encode MJPEG"},
+ {0x10000, "AUDIO", "Device handles audio"},
+ {0, NULL, NULL}
};
- v4l_device_type = g_flags_register_static ("GstV4lDeviceTypeFlags",
- values);
+ v4l_device_type = g_flags_register_static ("GstV4lDeviceTypeFlags", values);
}
return v4l_device_type;
if (!v4lelement_type) {
static const GTypeInfo v4lelement_info = {
- sizeof(GstV4lElementClass),
+ sizeof (GstV4lElementClass),
gst_v4lelement_base_init,
NULL,
- (GClassInitFunc)gst_v4lelement_class_init,
+ (GClassInitFunc) gst_v4lelement_class_init,
NULL,
NULL,
- sizeof(GstV4lElement),
+ sizeof (GstV4lElement),
0,
- (GInstanceInitFunc)gst_v4lelement_init,
+ (GInstanceInitFunc) gst_v4lelement_init,
NULL
};
static const GInterfaceInfo v4liface_info = {
NULL,
};
- v4lelement_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstV4lElement",
- &v4lelement_info, 0);
+ v4lelement_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstV4lElement", &v4lelement_info, 0);
g_type_add_interface_static (v4lelement_type,
- GST_TYPE_IMPLEMENTS_INTERFACE,
- &v4liface_info);
+ GST_TYPE_IMPLEMENTS_INTERFACE, &v4liface_info);
g_type_add_interface_static (v4lelement_type,
- GST_TYPE_TUNER,
- &v4l_tuner_info);
+ GST_TYPE_TUNER, &v4l_tuner_info);
g_type_add_interface_static (v4lelement_type,
- GST_TYPE_X_OVERLAY,
- &v4l_xoverlay_info);
+ GST_TYPE_X_OVERLAY, &v4l_xoverlay_info);
g_type_add_interface_static (v4lelement_type,
- GST_TYPE_COLOR_BALANCE,
- &v4l_colorbalance_info);
+ GST_TYPE_COLOR_BALANCE, &v4l_colorbalance_info);
g_type_add_interface_static (v4lelement_type,
- GST_TYPE_PROPERTY_PROBE,
- &v4l_propertyprobe_info);
+ GST_TYPE_PROPERTY_PROBE, &v4l_propertyprobe_info);
}
return v4lelement_type;
}
-static void
+static void
gst_v4lelement_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
GstV4lElementClass *klass = GST_V4LELEMENT_CLASS (g_class);
klass->devices = NULL;
-
+
gst_element_class_set_details (gstelement_class, &gst_v4lelement_details);
}
static void
-gst_v4lelement_class_init (GstV4lElementClass *klass)
+gst_v4lelement_class_init (GstV4lElementClass * 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);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DEVICE,
- g_param_spec_string("device","Device","Device location",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DEVICE_NAME,
- g_param_spec_string("device_name","Device name","Name of the device",
- NULL, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FLAGS,
- g_param_spec_flags("flags","Flags","Device type flags",
- GST_TYPE_V4L_DEVICE_FLAGS, 0,G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEVICE,
+ g_param_spec_string ("device", "Device", "Device location",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEVICE_NAME,
+ g_param_spec_string ("device_name", "Device name", "Name of the device",
+ NULL, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FLAGS,
+ g_param_spec_flags ("flags", "Flags", "Device type flags",
+ GST_TYPE_V4L_DEVICE_FLAGS, 0, G_PARAM_READABLE));
/* signals */
gst_v4lelement_signals[SIGNAL_OPEN] =
- g_signal_new("open", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lElementClass, open),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("open", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4lElementClass, open),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gst_v4lelement_signals[SIGNAL_CLOSE] =
- g_signal_new("close", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lElementClass, close),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("close", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4lElementClass, close),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gobject_class->set_property = gst_v4lelement_set_property;
gobject_class->get_property = gst_v4lelement_get_property;
static void
-gst_v4lelement_init (GstV4lElement *v4lelement)
+gst_v4lelement_init (GstV4lElement * v4lelement)
{
/* some default values */
v4lelement->video_fd = -1;
v4lelement->buffer = NULL;
v4lelement->videodev = g_strdup ("/dev/video");
- v4lelement->display = g_strdup(g_getenv("DISPLAY"));
+ v4lelement->display = g_strdup (g_getenv ("DISPLAY"));
v4lelement->norms = NULL;
v4lelement->channels = NULL;
static void
-gst_v4lelement_dispose (GObject *object)
+gst_v4lelement_dispose (GObject * object)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (object);
static void
-gst_v4lelement_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4lelement_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstV4lElement *v4lelement;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_V4LELEMENT(object));
- v4lelement = GST_V4LELEMENT(object);
+ g_return_if_fail (GST_IS_V4LELEMENT (object));
+ v4lelement = GST_V4LELEMENT (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_DEVICE:
if (v4lelement->videodev)
- g_free(v4lelement->videodev);
- v4lelement->videodev = g_strdup(g_value_get_string(value));
+ g_free (v4lelement->videodev);
+ v4lelement->videodev = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static void
-gst_v4lelement_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4lelement_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstV4lElement *v4lelement;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_V4LELEMENT(object));
- v4lelement = GST_V4LELEMENT(object);
+ g_return_if_fail (GST_IS_V4LELEMENT (object));
+ v4lelement = GST_V4LELEMENT (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_DEVICE:
- g_value_set_string(value, v4lelement->videodev);
+ g_value_set_string (value, v4lelement->videodev);
break;
- case ARG_DEVICE_NAME: {
+ case ARG_DEVICE_NAME:{
gchar *new = NULL;
- if (GST_V4L_IS_OPEN(v4lelement))
- new = v4lelement->vcap.name;
- g_value_set_string(value, new);
+
+ if (GST_V4L_IS_OPEN (v4lelement))
+ new = v4lelement->vcap.name;
+ g_value_set_string (value, new);
break;
}
- case ARG_FLAGS: {
+ case ARG_FLAGS:{
guint flags = 0;
- if (GST_V4L_IS_OPEN(v4lelement)) {
- flags |= v4lelement->vcap.type & 0x3C0B;
- if (v4lelement->vcap.audios)
- flags |= 0x10000;
+
+ if (GST_V4L_IS_OPEN (v4lelement)) {
+ flags |= v4lelement->vcap.type & 0x3C0B;
+ if (v4lelement->vcap.audios)
+ flags |= 0x10000;
}
- g_value_set_flags(value, flags);
+ g_value_set_flags (value, flags);
break;
}
default:
static GstElementStateReturn
-gst_v4lelement_change_state (GstElement *element)
+gst_v4lelement_change_state (GstElement * element)
{
GstV4lElement *v4lelement;
-
- g_return_val_if_fail(GST_IS_V4LELEMENT(element), GST_STATE_FAILURE);
-
- v4lelement = GST_V4LELEMENT(element);
+
+ g_return_val_if_fail (GST_IS_V4LELEMENT (element), GST_STATE_FAILURE);
+
+ v4lelement = GST_V4LELEMENT (element);
/* if going down into NULL state, close the device if it's open
* if going to READY, open the device (and set some options)
*/
- switch (GST_STATE_TRANSITION(element))
- {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
- gst_v4l_set_overlay(v4lelement);
+ gst_v4l_set_overlay (v4lelement);
- if (!gst_v4l_open(v4lelement))
- return GST_STATE_FAILURE;
+ if (!gst_v4l_open (v4lelement))
+ return GST_STATE_FAILURE;
gst_v4l_xoverlay_open (v4lelement);
- g_signal_emit(G_OBJECT(v4lelement),
- gst_v4lelement_signals[SIGNAL_OPEN], 0,
- v4lelement->videodev);
+ g_signal_emit (G_OBJECT (v4lelement),
+ gst_v4lelement_signals[SIGNAL_OPEN], 0, v4lelement->videodev);
break;
case GST_STATE_READY_TO_NULL:
gst_v4l_xoverlay_close (v4lelement);
- if (!gst_v4l_close(v4lelement))
- return GST_STATE_FAILURE;
+ if (!gst_v4l_close (v4lelement))
+ return GST_STATE_FAILURE;
- g_signal_emit(G_OBJECT(v4lelement),
- gst_v4lelement_signals[SIGNAL_CLOSE], 0,
- v4lelement->videodev);
+ g_signal_emit (G_OBJECT (v4lelement),
+ gst_v4lelement_signals[SIGNAL_CLOSE], 0, v4lelement->videodev);
break;
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_V4LELEMENT \
(gst_v4lelement_get_type())
#define GST_V4LELEMENT(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4LELEMENT))
#define GST_V4LELEMENT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4LELEMENT, GstV4lElementClass))
-
typedef struct _GstV4lElement GstV4lElement;
typedef struct _GstV4lElementClass GstV4lElementClass;
-struct _GstV4lElement {
+struct _GstV4lElement
+{
GstElement element;
/* the video device */
gchar *display;
};
-struct _GstV4lElementClass {
+struct _GstV4lElementClass
+{
GstElementClass parent_class;
/* probed devices */
GList *devices;
/* signals */
- void (*open) (GstElement *element,
- const gchar *device);
- void (*close) (GstElement *element,
- const gchar *device);
+ void (*open) (GstElement * element, const gchar * device);
+ void (*close) (GstElement * element, const gchar * device);
/* actions */
- gboolean (*get_attribute) (GstElement *element,
- const gchar *attr_name,
- int *value);
- gboolean (*set_attribute) (GstElement *element,
- const gchar *attr_name,
- const int value);
+ gboolean (*get_attribute) (GstElement * element,
+ const gchar * attr_name, int *value);
+ gboolean (*set_attribute) (GstElement * element,
+ const gchar * attr_name, const int value);
};
-GType gst_v4lelement_get_type(void);
+GType gst_v4lelement_get_type (void);
G_END_DECLS
-
#endif /* __GST_V4LELEMENT_H__ */
};
/* v4lmjpegsink signals and args */
-enum {
+enum
+{
SIGNAL_FRAME_DISPLAYED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_NUMBUFS,
ARG_BUFSIZE,
/* init functions */
-static void gst_v4lmjpegsink_base_init (gpointer g_class);
-static void gst_v4lmjpegsink_class_init (GstV4lMjpegSinkClass *klass);
-static void gst_v4lmjpegsink_init (GstV4lMjpegSink *v4lmjpegsink);
+static void gst_v4lmjpegsink_base_init (gpointer g_class);
+static void gst_v4lmjpegsink_class_init (GstV4lMjpegSinkClass * klass);
+static void gst_v4lmjpegsink_init (GstV4lMjpegSink * v4lmjpegsink);
/* the chain of buffers */
-static GstPadLinkReturn gst_v4lmjpegsink_sinkconnect (GstPad *pad,
- const GstCaps *vscapslist);
-static void gst_v4lmjpegsink_chain (GstPad *pad,
- GstData *_data);
+static GstPadLinkReturn gst_v4lmjpegsink_sinkconnect (GstPad * pad,
+ const GstCaps * vscapslist);
+static void gst_v4lmjpegsink_chain (GstPad * pad, GstData * _data);
/* get/set gst object functions */
-static void gst_v4lmjpegsink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4lmjpegsink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstElementStateReturn gst_v4lmjpegsink_change_state (GstElement *element);
-static void gst_v4lmjpegsink_set_clock (GstElement *element, GstClock *clock);
+static void gst_v4lmjpegsink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4lmjpegsink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_v4lmjpegsink_change_state (GstElement *
+ element);
+static void gst_v4lmjpegsink_set_clock (GstElement * element, GstClock * clock);
static GstElementClass *parent_class = NULL;
if (!v4lmjpegsink_type) {
static const GTypeInfo v4lmjpegsink_info = {
- sizeof(GstV4lMjpegSinkClass),
+ sizeof (GstV4lMjpegSinkClass),
gst_v4lmjpegsink_base_init,
NULL,
- (GClassInitFunc)gst_v4lmjpegsink_class_init,
+ (GClassInitFunc) gst_v4lmjpegsink_class_init,
NULL,
NULL,
- sizeof(GstV4lMjpegSink),
+ sizeof (GstV4lMjpegSink),
0,
- (GInstanceInitFunc)gst_v4lmjpegsink_init,
+ (GInstanceInitFunc) gst_v4lmjpegsink_init,
};
- v4lmjpegsink_type = g_type_register_static(GST_TYPE_V4LELEMENT, "GstV4lMjpegSink", &v4lmjpegsink_info, 0);
+ v4lmjpegsink_type =
+ g_type_register_static (GST_TYPE_V4LELEMENT, "GstV4lMjpegSink",
+ &v4lmjpegsink_info, 0);
}
return v4lmjpegsink_type;
}
static void
gst_v4lmjpegsink_base_init (gpointer g_class)
{
- static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
+ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-jpeg, "
- "width = (int) [ 1, MAX ], "
- "height = (int) [ 1, MAX ], "
- "framerate = (double) [ 0, MAX ]")
- );
+ "width = (int) [ 1, MAX ], "
+ "height = (int) [ 1, MAX ], " "framerate = (double) [ 0, MAX ]")
+ );
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_v4lmjpegsink_details);
gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get(&sink_template));
+ gst_static_pad_template_get (&sink_template));
}
static void
-gst_v4lmjpegsink_class_init (GstV4lMjpegSinkClass *klass)
+gst_v4lmjpegsink_class_init (GstV4lMjpegSinkClass * 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_V4LELEMENT);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUMBUFS,
- g_param_spec_int("num_buffers","num_buffers","num_buffers",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFSIZE,
- g_param_spec_int("buffer_size","buffer_size","buffer_size",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_X_OFFSET,
- g_param_spec_int("x_offset","x_offset","x_offset",
- G_MININT,G_MAXINT,0,G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_Y_OFFSET,
- g_param_spec_int("y_offset","y_offset","y_offset",
- G_MININT,G_MAXINT,0,G_PARAM_WRITABLE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FRAMES_DISPLAYED,
- g_param_spec_int("frames_displayed","frames_displayed","frames_displayed",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FRAME_TIME,
- g_param_spec_int("frame_time","frame_time","frame_time",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUMBUFS,
+ g_param_spec_int ("num_buffers", "num_buffers", "num_buffers",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
+ g_param_spec_int ("buffer_size", "buffer_size", "buffer_size",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_X_OFFSET,
+ g_param_spec_int ("x_offset", "x_offset", "x_offset",
+ G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_Y_OFFSET,
+ g_param_spec_int ("y_offset", "y_offset", "y_offset",
+ G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAMES_DISPLAYED,
+ g_param_spec_int ("frames_displayed", "frames_displayed",
+ "frames_displayed", G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAME_TIME,
+ g_param_spec_int ("frame_time", "frame_time", "frame_time", G_MININT,
+ G_MAXINT, 0, G_PARAM_READABLE));
gobject_class->set_property = gst_v4lmjpegsink_set_property;
gobject_class->get_property = gst_v4lmjpegsink_get_property;
gst_v4lmjpegsink_signals[SIGNAL_FRAME_DISPLAYED] =
- g_signal_new ("frame-displayed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstV4lMjpegSinkClass, frame_displayed), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("frame-displayed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4lMjpegSinkClass,
+ frame_displayed), NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
gstelement_class->change_state = gst_v4lmjpegsink_change_state;
- gstelement_class->set_clock = gst_v4lmjpegsink_set_clock;
+ gstelement_class->set_clock = gst_v4lmjpegsink_set_clock;
}
static void
-gst_v4lmjpegsink_init (GstV4lMjpegSink *v4lmjpegsink)
+gst_v4lmjpegsink_init (GstV4lMjpegSink * v4lmjpegsink)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (v4lmjpegsink);
- v4lmjpegsink->sinkpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "sink"), "sink");
+ v4lmjpegsink->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (v4lmjpegsink), v4lmjpegsink->sinkpad);
gst_pad_set_chain_function (v4lmjpegsink->sinkpad, gst_v4lmjpegsink_chain);
- gst_pad_set_link_function (v4lmjpegsink->sinkpad, gst_v4lmjpegsink_sinkconnect);
+ gst_pad_set_link_function (v4lmjpegsink->sinkpad,
+ gst_v4lmjpegsink_sinkconnect);
v4lmjpegsink->clock = NULL;
v4lmjpegsink->numbufs = 64;
v4lmjpegsink->bufsize = 256;
- GST_FLAG_SET(v4lmjpegsink, GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (v4lmjpegsink, GST_ELEMENT_THREAD_SUGGESTED);
}
static GstPadLinkReturn
-gst_v4lmjpegsink_sinkconnect (GstPad *pad,
- const GstCaps *vscapslist)
+gst_v4lmjpegsink_sinkconnect (GstPad * pad, const GstCaps * vscapslist)
{
GstV4lMjpegSink *v4lmjpegsink;
GstStructure *structure;
/* in case the buffers are active (which means that we already
* did capsnego before and didn't clean up), clean up anyways */
- if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)))
- if (!gst_v4lmjpegsink_playback_deinit(v4lmjpegsink))
+ if (GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsink)))
+ if (!gst_v4lmjpegsink_playback_deinit (v4lmjpegsink))
return GST_PAD_LINK_REFUSED;
structure = gst_caps_get_structure (vscapslist, 0);
- gst_structure_get_int (structure, "width", &v4lmjpegsink->width);
- gst_structure_get_int (structure, "height", &v4lmjpegsink->height);
+ gst_structure_get_int (structure, "width", &v4lmjpegsink->width);
+ gst_structure_get_int (structure, "height", &v4lmjpegsink->height);
- if (!gst_v4lmjpegsink_set_playback(v4lmjpegsink,
- v4lmjpegsink->width, v4lmjpegsink->height,
- v4lmjpegsink->x_offset, v4lmjpegsink->y_offset,
- GST_V4LELEMENT(v4lmjpegsink)->vchan.norm, 0)) /* TODO: interlacing */
+ if (!gst_v4lmjpegsink_set_playback (v4lmjpegsink, v4lmjpegsink->width, v4lmjpegsink->height, v4lmjpegsink->x_offset, v4lmjpegsink->y_offset, GST_V4LELEMENT (v4lmjpegsink)->vchan.norm, 0)) /* TODO: interlacing */
return GST_PAD_LINK_REFUSED;
/* set buffer info */
- if (!gst_v4lmjpegsink_set_buffer(v4lmjpegsink,
- v4lmjpegsink->numbufs, v4lmjpegsink->bufsize))
+ if (!gst_v4lmjpegsink_set_buffer (v4lmjpegsink,
+ v4lmjpegsink->numbufs, v4lmjpegsink->bufsize))
return GST_PAD_LINK_REFUSED;
- if (!gst_v4lmjpegsink_playback_init(v4lmjpegsink))
+ if (!gst_v4lmjpegsink_playback_init (v4lmjpegsink))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
static void
-gst_v4lmjpegsink_set_clock (GstElement *element, GstClock *clock)
+gst_v4lmjpegsink_set_clock (GstElement * element, GstClock * clock)
{
GstV4lMjpegSink *v4mjpegsink = GST_V4LMJPEGSINK (element);
static void
-gst_v4lmjpegsink_chain (GstPad *pad,
- GstData *_data)
+gst_v4lmjpegsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstV4lMjpegSink *v4lmjpegsink;
v4lmjpegsink = GST_V4LMJPEGSINK (gst_pad_get_parent (pad));
if (v4lmjpegsink->clock) {
- GST_DEBUG ("videosink: clock wait: %" G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP(buf));
+ GST_DEBUG ("videosink: clock wait: %" G_GUINT64_FORMAT,
+ GST_BUFFER_TIMESTAMP (buf));
- gst_element_wait (GST_ELEMENT(v4lmjpegsink), GST_BUFFER_TIMESTAMP(buf));
+ gst_element_wait (GST_ELEMENT (v4lmjpegsink), GST_BUFFER_TIMESTAMP (buf));
}
-
#if 0
- if (GST_BUFFER_POOL(buf) == v4lmjpegsink->bufferpool)
- {
- num = GPOINTER_TO_INT(GST_BUFFER_POOL_PRIVATE(buf));
- gst_v4lmjpegsink_play_frame(v4lmjpegsink, num);
- }
- else
- {
+ if (GST_BUFFER_POOL (buf) == v4lmjpegsink->bufferpool) {
+ num = GPOINTER_TO_INT (GST_BUFFER_POOL_PRIVATE (buf));
+ gst_v4lmjpegsink_play_frame (v4lmjpegsink, num);
+ } else {
#endif
/* check size */
- if (GST_BUFFER_SIZE(buf) > v4lmjpegsink->breq.size)
- {
+ if (GST_BUFFER_SIZE (buf) > v4lmjpegsink->breq.size) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, WRITE, (NULL),
- ("Buffer too big (%d KB), max. buffersize is %ld KB",
- GST_BUFFER_SIZE(buf)/1024, v4lmjpegsink->breq.size/1024));
+ ("Buffer too big (%d KB), max. buffersize is %ld KB",
+ GST_BUFFER_SIZE (buf) / 1024, v4lmjpegsink->breq.size / 1024));
return;
}
/* put JPEG data to the device */
- gst_v4lmjpegsink_wait_frame(v4lmjpegsink, &num);
- memcpy(gst_v4lmjpegsink_get_buffer(v4lmjpegsink, num),
- GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
- gst_v4lmjpegsink_play_frame(v4lmjpegsink, num);
+ gst_v4lmjpegsink_wait_frame (v4lmjpegsink, &num);
+ memcpy (gst_v4lmjpegsink_get_buffer (v4lmjpegsink, num),
+ GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ gst_v4lmjpegsink_play_frame (v4lmjpegsink, num);
#if 0
}
#endif
- g_signal_emit(G_OBJECT(v4lmjpegsink),gst_v4lmjpegsink_signals[SIGNAL_FRAME_DISPLAYED],0);
+ g_signal_emit (G_OBJECT (v4lmjpegsink),
+ gst_v4lmjpegsink_signals[SIGNAL_FRAME_DISPLAYED], 0);
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
#if 0
static GstBuffer *
-gst_v4lmjpegsink_buffer_new (GstBufferPool *pool,
- guint64 offset,
- guint size,
- gpointer user_data)
+gst_v4lmjpegsink_buffer_new (GstBufferPool * pool,
+ guint64 offset, guint size, gpointer user_data)
{
- GstV4lMjpegSink *v4lmjpegsink = GST_V4LMJPEGSINK(user_data);
+ GstV4lMjpegSink *v4lmjpegsink = GST_V4LMJPEGSINK (user_data);
GstBuffer *buffer = NULL;
guint8 *data;
gint num;
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)))
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsink)))
return NULL;
if (v4lmjpegsink->breq.size < size) {
GST_DEBUG ("Requested buffer size is too large (%d > %ld)",
- size, v4lmjpegsink->breq.size);
+ size, v4lmjpegsink->breq.size);
return NULL;
}
- if (!gst_v4lmjpegsink_wait_frame(v4lmjpegsink, &num))
+ if (!gst_v4lmjpegsink_wait_frame (v4lmjpegsink, &num))
return NULL;
- data = gst_v4lmjpegsink_get_buffer(v4lmjpegsink, num);
+ data = gst_v4lmjpegsink_get_buffer (v4lmjpegsink, num);
if (!data)
return NULL;
- buffer = gst_buffer_new();
- GST_BUFFER_DATA(buffer) = data;
- GST_BUFFER_MAXSIZE(buffer) = v4lmjpegsink->breq.size;
- GST_BUFFER_SIZE(buffer) = size;
- GST_BUFFER_POOL(buffer) = pool;
- GST_BUFFER_POOL_PRIVATE(buffer) = GINT_TO_POINTER(num);
+ buffer = gst_buffer_new ();
+ GST_BUFFER_DATA (buffer) = data;
+ GST_BUFFER_MAXSIZE (buffer) = v4lmjpegsink->breq.size;
+ GST_BUFFER_SIZE (buffer) = size;
+ GST_BUFFER_POOL (buffer) = pool;
+ GST_BUFFER_POOL_PRIVATE (buffer) = GINT_TO_POINTER (num);
/* with this flag set, we don't need our own buffer_free() function */
- GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_DONTFREE);
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
return buffer;
}
static void
-gst_v4lmjpegsink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4lmjpegsink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstV4lMjpegSink *v4lmjpegsink;
v4lmjpegsink = GST_V4LMJPEGSINK (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_NUMBUFS:
- v4lmjpegsink->numbufs = g_value_get_int(value);
+ v4lmjpegsink->numbufs = g_value_get_int (value);
break;
case ARG_BUFSIZE:
- v4lmjpegsink->bufsize = g_value_get_int(value);
+ v4lmjpegsink->bufsize = g_value_get_int (value);
break;
case ARG_X_OFFSET:
- v4lmjpegsink->x_offset = g_value_get_int(value);
+ v4lmjpegsink->x_offset = g_value_get_int (value);
break;
case ARG_Y_OFFSET:
- v4lmjpegsink->y_offset = g_value_get_int(value);
+ v4lmjpegsink->y_offset = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static void
-gst_v4lmjpegsink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4lmjpegsink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstV4lMjpegSink *v4lmjpegsink;
/* it's not null if we got it, but it might not be ours */
- v4lmjpegsink = GST_V4LMJPEGSINK(object);
+ v4lmjpegsink = GST_V4LMJPEGSINK (object);
switch (prop_id) {
case ARG_FRAMES_DISPLAYED:
g_value_set_int (value, v4lmjpegsink->frames_displayed);
break;
case ARG_FRAME_TIME:
- g_value_set_int (value, v4lmjpegsink->frame_time/1000000);
+ g_value_set_int (value, v4lmjpegsink->frame_time / 1000000);
break;
case ARG_NUMBUFS:
g_value_set_int (value, v4lmjpegsink->numbufs);
static GstElementStateReturn
-gst_v4lmjpegsink_change_state (GstElement *element)
+gst_v4lmjpegsink_change_state (GstElement * element)
{
GstV4lMjpegSink *v4lmjpegsink;
GstElementStateReturn parent_value;
g_return_val_if_fail (GST_IS_V4LMJPEGSINK (element), GST_STATE_FAILURE);
- v4lmjpegsink = GST_V4LMJPEGSINK(element);
+ v4lmjpegsink = GST_V4LMJPEGSINK (element);
/* set up change state */
- switch (GST_STATE_TRANSITION(element)) {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
/* we used to do buffer setup here, but that's now done
* right after capsnego */
break;
case GST_STATE_PAUSED_TO_PLAYING:
/* start */
- if (!gst_v4lmjpegsink_playback_start(v4lmjpegsink))
- return GST_STATE_FAILURE;
+ if (!gst_v4lmjpegsink_playback_start (v4lmjpegsink))
+ return GST_STATE_FAILURE;
break;
case GST_STATE_PLAYING_TO_PAUSED:
/* de-queue all queued buffers */
- if (!gst_v4lmjpegsink_playback_stop(v4lmjpegsink))
- return GST_STATE_FAILURE;
+ if (!gst_v4lmjpegsink_playback_stop (v4lmjpegsink))
+ return GST_STATE_FAILURE;
break;
case GST_STATE_PAUSED_TO_READY:
/* stop playback, unmap all buffers */
- if (!gst_v4lmjpegsink_playback_deinit(v4lmjpegsink))
- return GST_STATE_FAILURE;
+ if (!gst_v4lmjpegsink_playback_deinit (v4lmjpegsink))
+ return GST_STATE_FAILURE;
break;
}
G_BEGIN_DECLS
-
-
#define GST_TYPE_V4LMJPEGSINK \
(gst_v4lmjpegsink_get_type())
#define GST_V4LMJPEGSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_V4LMJPEGSINK))
#define GST_IS_V4LMJPEGSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4LMJPEGSINK))
-
typedef struct _GstV4lMjpegSink GstV4lMjpegSink;
typedef struct _GstV4lMjpegSinkClass GstV4lMjpegSinkClass;
-struct _GstV4lMjpegSink {
+struct _GstV4lMjpegSink
+{
GstV4lElement v4lelement;
/* the sink pas */
struct mjpeg_requestbuffers breq;
/* thread to keep track of synced frames */
- gint8 *isqueued_queued_frames; /* 1 = queued, 0 = unqueued, -1 = error */
+ gint8 *isqueued_queued_frames; /* 1 = queued, 0 = unqueued, -1 = error */
GThread *thread_queued_frames;
GMutex *mutex_queued_frames;
GCond **cond_queued_frames;
gint y_offset;
gint numbufs;
- gint bufsize; /* in KB */
+ gint bufsize; /* in KB */
};
-struct _GstV4lMjpegSinkClass {
+struct _GstV4lMjpegSinkClass
+{
GstV4lElementClass parent_class;
/* signals */
- void (*frame_displayed) (GstElement *element);
+ void (*frame_displayed) (GstElement * element);
};
-GType gst_v4lmjpegsink_get_type(void);
+GType gst_v4lmjpegsink_get_type (void);
G_END_DECLS
-
#endif /* __GST_SDLVIDEOSINK_H__ */
};
/* V4lMjpegSrc signals and args */
-enum {
+enum
+{
SIGNAL_FRAME_CAPTURE,
SIGNAL_FRAME_DROP,
SIGNAL_FRAME_INSERT,
};
/* arguments */
-enum {
+enum
+{
ARG_0,
#if 0
ARG_X_OFFSET,
};
GST_FORMATS_FUNCTION (GstPad *, gst_v4lmjpegsrc_get_formats,
- GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
+ GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
GST_QUERY_TYPE_FUNCTION (GstPad *, gst_v4lmjpegsrc_get_query_types,
- GST_QUERY_POSITION);
+ GST_QUERY_POSITION);
/* init functions */
-static void gst_v4lmjpegsrc_base_init (gpointer g_class);
-static void gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass *klass);
-static void gst_v4lmjpegsrc_init (GstV4lMjpegSrc *v4lmjpegsrc);
+static void gst_v4lmjpegsrc_base_init (gpointer g_class);
+static void gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass * klass);
+static void gst_v4lmjpegsrc_init (GstV4lMjpegSrc * v4lmjpegsrc);
/* pad/info functions */
-static gboolean gst_v4lmjpegsrc_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_v4lmjpegsrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
+static gboolean gst_v4lmjpegsrc_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_v4lmjpegsrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
/* buffer functions */
-static GstPadLinkReturn gst_v4lmjpegsrc_srcconnect (GstPad *pad,
- const GstCaps *caps);
-static GstData* gst_v4lmjpegsrc_get (GstPad *pad);
-static GstCaps* gst_v4lmjpegsrc_getcaps (GstPad *pad);
+static GstPadLinkReturn gst_v4lmjpegsrc_srcconnect (GstPad * pad,
+ const GstCaps * caps);
+static GstData *gst_v4lmjpegsrc_get (GstPad * pad);
+static GstCaps *gst_v4lmjpegsrc_getcaps (GstPad * pad);
/* get/set params */
-static void gst_v4lmjpegsrc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4lmjpegsrc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4lmjpegsrc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4lmjpegsrc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
/* set_clock function for A/V sync */
-static void gst_v4lmjpegsrc_set_clock (GstElement *element,
- GstClock *clock);
+static void gst_v4lmjpegsrc_set_clock (GstElement * element, GstClock * clock);
/* state handling */
-static GstElementStateReturn gst_v4lmjpegsrc_change_state (GstElement *element);
+static GstElementStateReturn gst_v4lmjpegsrc_change_state (GstElement *
+ element);
/* requeue buffer after use */
-static void gst_v4lmjpegsrc_buffer_free (GstBuffer *buffer);
+static void gst_v4lmjpegsrc_buffer_free (GstBuffer * buffer);
static GstElementClass *parent_class = NULL;
static guint gst_v4lmjpegsrc_signals[LAST_SIGNAL] = { 0 };
if (!v4lmjpegsrc_type) {
static const GTypeInfo v4lmjpegsrc_info = {
- sizeof(GstV4lMjpegSrcClass),
+ sizeof (GstV4lMjpegSrcClass),
gst_v4lmjpegsrc_base_init,
NULL,
- (GClassInitFunc)gst_v4lmjpegsrc_class_init,
+ (GClassInitFunc) gst_v4lmjpegsrc_class_init,
NULL,
NULL,
- sizeof(GstV4lMjpegSrc),
+ sizeof (GstV4lMjpegSrc),
0,
- (GInstanceInitFunc)gst_v4lmjpegsrc_init,
+ (GInstanceInitFunc) gst_v4lmjpegsrc_init,
NULL
};
- v4lmjpegsrc_type = g_type_register_static(GST_TYPE_V4LELEMENT, "GstV4lMjpegSrc", &v4lmjpegsrc_info, 0);
+ v4lmjpegsrc_type =
+ g_type_register_static (GST_TYPE_V4LELEMENT, "GstV4lMjpegSrc",
+ &v4lmjpegsrc_info, 0);
}
return v4lmjpegsrc_type;
}
static void
gst_v4lmjpegsrc_base_init (gpointer g_class)
{
- static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
+ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-jpeg, "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], "
- "framerate = (double) [ 0, MAX ]"
- )
- );
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], " "framerate = (double) [ 0, MAX ]")
+ );
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_v4lmjpegsrc_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_template));
}
static void
-gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass *klass)
+gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass * 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_V4LELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_V4LELEMENT);
#if 0
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_X_OFFSET,
- g_param_spec_int("x_offset","x_offset","x_offset",
- G_MININT,G_MAXINT,0,G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_Y_OFFSET,
- g_param_spec_int("y_offset","y_offset","y_offset",
- G_MININT,G_MAXINT,0,G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_F_WIDTH,
- g_param_spec_int("frame_width","frame_width","frame_width",
- G_MININT,G_MAXINT,0,G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_F_HEIGHT,
- g_param_spec_int("frame_height","frame_height","frame_height",
- G_MININT,G_MAXINT,0,G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_X_OFFSET,
+ g_param_spec_int ("x_offset", "x_offset", "x_offset",
+ G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_Y_OFFSET,
+ g_param_spec_int ("y_offset", "y_offset", "y_offset",
+ G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_F_WIDTH,
+ g_param_spec_int ("frame_width", "frame_width", "frame_width",
+ G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_F_HEIGHT,
+ g_param_spec_int ("frame_height", "frame_height", "frame_height",
+ G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
#endif
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_QUALITY,
- g_param_spec_int("quality","Quality","JPEG frame quality",
- 1,100,50,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
+ g_param_spec_int ("quality", "Quality", "JPEG frame quality",
+ 1, 100, 50, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUMBUFS,
- g_param_spec_int("num_buffers","Num Buffers","Number of Buffers",
- 1,256,64,G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFSIZE,
- g_param_spec_int("buffer_size", "Buffer Size", "Size of buffers",
- 0, 512*1024, 128*1024, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUMBUFS,
+ g_param_spec_int ("num_buffers", "Num Buffers", "Number of Buffers",
+ 1, 256, 64, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
+ g_param_spec_int ("buffer_size", "Buffer Size", "Size of buffers",
+ 0, 512 * 1024, 128 * 1024, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_USE_FIXED_FPS,
- g_param_spec_boolean("use_fixed_fps", "Use Fixed FPS",
- "Drop/Insert frames to reach a certain FPS (TRUE) "
- "or adapt FPS to suit the number of frabbed frames",
- TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_FIXED_FPS,
+ g_param_spec_boolean ("use_fixed_fps", "Use Fixed FPS",
+ "Drop/Insert frames to reach a certain FPS (TRUE) "
+ "or adapt FPS to suit the number of frabbed frames",
+ TRUE, G_PARAM_READWRITE));
/* signals */
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_CAPTURE] =
- g_signal_new("frame-capture", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lMjpegSrcClass, frame_capture),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-capture", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4lMjpegSrcClass, frame_capture),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_DROP] =
- g_signal_new("frame-drop", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lMjpegSrcClass, frame_drop),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-drop", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4lMjpegSrcClass, frame_drop), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_INSERT] =
- g_signal_new("frame-insert", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lMjpegSrcClass, frame_insert),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-insert", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4lMjpegSrcClass, frame_insert),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_LOST] =
- g_signal_new("frame-lost", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lMjpegSrcClass, frame_lost),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("frame-lost", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4lMjpegSrcClass, frame_lost), NULL, NULL,
+ g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gobject_class->set_property = gst_v4lmjpegsrc_set_property;
gobject_class->get_property = gst_v4lmjpegsrc_get_property;
static void
-gst_v4lmjpegsrc_init (GstV4lMjpegSrc *v4lmjpegsrc)
+gst_v4lmjpegsrc_init (GstV4lMjpegSrc * v4lmjpegsrc)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (v4lmjpegsrc);
- GST_FLAG_SET(GST_ELEMENT(v4lmjpegsrc), GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (GST_ELEMENT (v4lmjpegsrc), GST_ELEMENT_THREAD_SUGGESTED);
- v4lmjpegsrc->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "src"), "src");
- gst_element_add_pad(GST_ELEMENT(v4lmjpegsrc), v4lmjpegsrc->srcpad);
+ v4lmjpegsrc->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "src"), "src");
+ gst_element_add_pad (GST_ELEMENT (v4lmjpegsrc), v4lmjpegsrc->srcpad);
gst_pad_set_get_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_get);
gst_pad_set_getcaps_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_getcaps);
gst_pad_set_link_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_srcconnect);
- gst_pad_set_convert_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_src_convert);
- gst_pad_set_formats_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_get_formats);
+ gst_pad_set_convert_function (v4lmjpegsrc->srcpad,
+ gst_v4lmjpegsrc_src_convert);
+ gst_pad_set_formats_function (v4lmjpegsrc->srcpad,
+ gst_v4lmjpegsrc_get_formats);
gst_pad_set_query_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_src_query);
- gst_pad_set_query_type_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_get_query_types);
+ gst_pad_set_query_type_function (v4lmjpegsrc->srcpad,
+ gst_v4lmjpegsrc_get_query_types);
#if 0
v4lmjpegsrc->frame_width = 0;
static gfloat
-gst_v4lmjpegsrc_get_fps (GstV4lMjpegSrc *v4lmjpegsrc)
+gst_v4lmjpegsrc_get_fps (GstV4lMjpegSrc * v4lmjpegsrc)
{
gint norm;
gfloat fps;
-
+
if (!v4lmjpegsrc->use_fixed_fps &&
- v4lmjpegsrc->clock != NULL &&
- v4lmjpegsrc->handled > 0) {
+ v4lmjpegsrc->clock != NULL && v4lmjpegsrc->handled > 0) {
/* try to get time from clock master and calculate fps */
- GstClockTime time = gst_clock_get_time(v4lmjpegsrc->clock) - v4lmjpegsrc->substract_time;
+ GstClockTime time =
+ gst_clock_get_time (v4lmjpegsrc->clock) - v4lmjpegsrc->substract_time;
return v4lmjpegsrc->handled * GST_SECOND / time;
}
/* if that failed ... */
- if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsrc)))
+ if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lmjpegsrc)))
return 0.;
- if (!gst_v4l_get_chan_norm(GST_V4LELEMENT(v4lmjpegsrc), NULL, &norm))
+ if (!gst_v4l_get_chan_norm (GST_V4LELEMENT (v4lmjpegsrc), NULL, &norm))
return 0.;
if (norm == VIDEO_MODE_NTSC)
- fps = 30000/1001;
+ fps = 30000 / 1001;
else
fps = 25.;
}
static gboolean
-gst_v4lmjpegsrc_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value)
+gst_v4lmjpegsrc_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
{
GstV4lMjpegSrc *v4lmjpegsrc;
gdouble fps;
v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
- if ((fps = gst_v4lmjpegsrc_get_fps(v4lmjpegsrc)) == 0)
+ if ((fps = gst_v4lmjpegsrc_get_fps (v4lmjpegsrc)) == 0)
return FALSE;
switch (src_format) {
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * fps / GST_SECOND;
- break;
- default:
- return FALSE;
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value * fps / GST_SECOND;
+ break;
+ default:
+ return FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * GST_SECOND / fps;
- break;
- default:
- return FALSE;
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * GST_SECOND / fps;
+ break;
+ default:
+ return FALSE;
}
break;
}
static gboolean
-gst_v4lmjpegsrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value)
+gst_v4lmjpegsrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value)
{
GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
gboolean res = TRUE;
gdouble fps;
- if ((fps = gst_v4lmjpegsrc_get_fps(v4lmjpegsrc)) == 0)
+ if ((fps = gst_v4lmjpegsrc_get_fps (v4lmjpegsrc)) == 0)
return FALSE;
switch (type) {
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = v4lmjpegsrc->handled * GST_SECOND / fps;
- break;
- case GST_FORMAT_DEFAULT:
- *value = v4lmjpegsrc->handled;
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *value = v4lmjpegsrc->handled * GST_SECOND / fps;
+ break;
+ case GST_FORMAT_DEFAULT:
+ *value = v4lmjpegsrc->handled;
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
}
static inline gulong
-calc_bufsize (int hor_dec,
- int ver_dec)
+calc_bufsize (int hor_dec, int ver_dec)
{
- guint8 div = hor_dec * ver_dec;
- guint32 num = (1024 * 512) / (div);
- guint32 result = 2;
-
- num--;
- while (num) {
- num >>= 1;
- result <<= 1;
- }
-
- if (result > (512 * 1024))
- return (512 * 1024);
- if (result < 8192)
- return 8192;
- return result;
+ guint8 div = hor_dec * ver_dec;
+ guint32 num = (1024 * 512) / (div);
+ guint32 result = 2;
+
+ num--;
+ while (num) {
+ num >>= 1;
+ result <<= 1;
+ }
+
+ if (result > (512 * 1024))
+ return (512 * 1024);
+ if (result < 8192)
+ return 8192;
+ return result;
}
static GstPadLinkReturn
-gst_v4lmjpegsrc_srcconnect (GstPad *pad,
- const GstCaps *caps)
+gst_v4lmjpegsrc_srcconnect (GstPad * pad, const GstCaps * caps)
{
- GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC(gst_pad_get_parent(pad));
+ GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
gint hor_dec, ver_dec;
gint w, h;
- gint max_w = GST_V4LELEMENT(v4lmjpegsrc)->vcap.maxwidth,
- max_h = GST_V4LELEMENT(v4lmjpegsrc)->vcap.maxheight;
+ gint max_w = GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxwidth,
+ max_h = GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxheight;
gulong bufsize;
GstStructure *structure;
/* in case the buffers are active (which means that we already
* did capsnego before and didn't clean up), clean up anyways */
- if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)))
- {
- if (!gst_v4lmjpegsrc_capture_deinit(v4lmjpegsrc))
+ if (GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc))) {
+ if (!gst_v4lmjpegsrc_capture_deinit (v4lmjpegsrc))
return GST_PAD_LINK_REFUSED;
- }
- else if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsrc)))
- {
+ } else if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lmjpegsrc))) {
return GST_PAD_LINK_DELAYED;
}
/* figure out decimation */
if (w >= max_w) {
hor_dec = 1;
- } else if (w*2 >= max_w) {
+ } else if (w * 2 >= max_w) {
hor_dec = 2;
} else {
hor_dec = 4;
}
if (h >= max_h) {
ver_dec = 1;
- } else if (h*2 >= max_h) {
+ } else if (h * 2 >= max_h) {
ver_dec = 2;
} else {
ver_dec = 4;
}
/* calculate bufsize */
- bufsize = calc_bufsize(hor_dec, ver_dec);
+ bufsize = calc_bufsize (hor_dec, ver_dec);
/* set buffer info */
- if (!gst_v4lmjpegsrc_set_buffer(v4lmjpegsrc,
- v4lmjpegsrc->numbufs, bufsize)) {
+ if (!gst_v4lmjpegsrc_set_buffer (v4lmjpegsrc, v4lmjpegsrc->numbufs, bufsize)) {
return GST_PAD_LINK_REFUSED;
}
/* set capture parameters and mmap the buffers */
if (hor_dec == ver_dec) {
- if (!gst_v4lmjpegsrc_set_capture(v4lmjpegsrc,
- hor_dec,
- v4lmjpegsrc->quality)) {
+ if (!gst_v4lmjpegsrc_set_capture (v4lmjpegsrc,
+ hor_dec, v4lmjpegsrc->quality)) {
return GST_PAD_LINK_REFUSED;
}
} else {
- if (!gst_v4lmjpegsrc_set_capture_m(v4lmjpegsrc,
- 0, 0, max_w, max_h,
- hor_dec, ver_dec,
- v4lmjpegsrc->quality)) {
+ if (!gst_v4lmjpegsrc_set_capture_m (v4lmjpegsrc,
+ 0, 0, max_w, max_h, hor_dec, ver_dec, v4lmjpegsrc->quality)) {
return GST_PAD_LINK_REFUSED;
}
}
#if 0
if (!v4lmjpegsrc->frame_width && !v4lmjpegsrc->frame_height &&
- v4lmjpegsrc->x_offset < 0 && v4lmjpegsrc->y_offset < 0 &&
- v4lmjpegsrc->horizontal_decimation == v4lmjpegsrc->vertical_decimation)
- {
- if (!gst_v4lmjpegsrc_set_capture(v4lmjpegsrc,
- v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->quality))
+ v4lmjpegsrc->x_offset < 0 && v4lmjpegsrc->y_offset < 0 &&
+ v4lmjpegsrc->horizontal_decimation == v4lmjpegsrc->vertical_decimation) {
+ if (!gst_v4lmjpegsrc_set_capture (v4lmjpegsrc,
+ v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->quality))
return GST_PAD_LINK_REFUSED;
- }
- else
- {
- if (!gst_v4lmjpegsrc_set_capture_m(v4lmjpegsrc,
- v4lmjpegsrc->x_offset, v4lmjpegsrc->y_offset,
- v4lmjpegsrc->frame_width, v4lmjpegsrc->frame_height,
- v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->vertical_decimation,
- v4lmjpegsrc->quality))
+ } else {
+ if (!gst_v4lmjpegsrc_set_capture_m (v4lmjpegsrc,
+ v4lmjpegsrc->x_offset, v4lmjpegsrc->y_offset,
+ v4lmjpegsrc->frame_width, v4lmjpegsrc->frame_height,
+ v4lmjpegsrc->horizontal_decimation,
+ v4lmjpegsrc->vertical_decimation, v4lmjpegsrc->quality))
return GST_PAD_LINK_REFUSED;
}
#endif
}
-static GstData*
-gst_v4lmjpegsrc_get (GstPad *pad)
+static GstData *
+gst_v4lmjpegsrc_get (GstPad * pad)
{
GstV4lMjpegSrc *v4lmjpegsrc;
GstBuffer *buf;
v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
if (v4lmjpegsrc->use_fixed_fps &&
- (fps = gst_v4lmjpegsrc_get_fps(v4lmjpegsrc)) == 0)
+ (fps = gst_v4lmjpegsrc_get_fps (v4lmjpegsrc)) == 0)
return NULL;
if (v4lmjpegsrc->need_writes > 0) {
v4lmjpegsrc->need_writes = 1;
/* grab a frame from the device */
- if (!gst_v4lmjpegsrc_grab_frame(v4lmjpegsrc, &num, &v4lmjpegsrc->last_size))
- return NULL;
+ if (!gst_v4lmjpegsrc_grab_frame (v4lmjpegsrc, &num,
+ &v4lmjpegsrc->last_size))
+ return NULL;
v4lmjpegsrc->last_frame = num;
- time = GST_TIMEVAL_TO_TIME(v4lmjpegsrc->bsync.timestamp) -
- v4lmjpegsrc->substract_time;
+ time = GST_TIMEVAL_TO_TIME (v4lmjpegsrc->bsync.timestamp) -
+ v4lmjpegsrc->substract_time;
/* first check whether we lost any frames according to the device */
if (v4lmjpegsrc->last_seq != 0) {
- if (v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq > 1) {
- v4lmjpegsrc->need_writes = v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq;
- g_signal_emit(G_OBJECT(v4lmjpegsrc),
- gst_v4lmjpegsrc_signals[SIGNAL_FRAME_LOST], 0,
- v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq - 1);
- }
+ if (v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq > 1) {
+ v4lmjpegsrc->need_writes =
+ v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq;
+ g_signal_emit (G_OBJECT (v4lmjpegsrc),
+ gst_v4lmjpegsrc_signals[SIGNAL_FRAME_LOST], 0,
+ v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq - 1);
+ }
}
v4lmjpegsrc->last_seq = v4lmjpegsrc->bsync.seq;
* timeframe. This means that if time - begin_time = X sec,
* we want to have written X*fps frames. If we've written
* more - drop, if we've written less - dup... */
- if (v4lmjpegsrc->handled * (GST_SECOND/fps) - time > 1.5 * (GST_SECOND/fps)) {
- /* yo dude, we've got too many frames here! Drop! DROP! */
- v4lmjpegsrc->need_writes--; /* -= (v4lmjpegsrc->handled - (time / fps)); */
- g_signal_emit(G_OBJECT(v4lmjpegsrc),
- gst_v4lmjpegsrc_signals[SIGNAL_FRAME_DROP], 0);
- } else if (v4lmjpegsrc->handled * (GST_SECOND/fps) - time < - 1.5 * (GST_SECOND/fps)) {
- /* this means we're lagging far behind */
- v4lmjpegsrc->need_writes++; /* += ((time / fps) - v4lmjpegsrc->handled); */
- g_signal_emit(G_OBJECT(v4lmjpegsrc),
- gst_v4lmjpegsrc_signals[SIGNAL_FRAME_INSERT], 0);
+ if (v4lmjpegsrc->handled * (GST_SECOND / fps) - time >
+ 1.5 * (GST_SECOND / fps)) {
+ /* yo dude, we've got too many frames here! Drop! DROP! */
+ v4lmjpegsrc->need_writes--; /* -= (v4lmjpegsrc->handled - (time / fps)); */
+ g_signal_emit (G_OBJECT (v4lmjpegsrc),
+ gst_v4lmjpegsrc_signals[SIGNAL_FRAME_DROP], 0);
+ } else if (v4lmjpegsrc->handled * (GST_SECOND / fps) - time <
+ -1.5 * (GST_SECOND / fps)) {
+ /* this means we're lagging far behind */
+ v4lmjpegsrc->need_writes++; /* += ((time / fps) - v4lmjpegsrc->handled); */
+ g_signal_emit (G_OBJECT (v4lmjpegsrc),
+ gst_v4lmjpegsrc_signals[SIGNAL_FRAME_INSERT], 0);
}
if (v4lmjpegsrc->need_writes > 0) {
- have_frame = TRUE;
- v4lmjpegsrc->use_num_times[num] = v4lmjpegsrc->need_writes;
- v4lmjpegsrc->need_writes--;
+ have_frame = TRUE;
+ v4lmjpegsrc->use_num_times[num] = v4lmjpegsrc->need_writes;
+ v4lmjpegsrc->need_writes--;
} else {
- gst_v4lmjpegsrc_requeue_frame(v4lmjpegsrc, num);
+ gst_v4lmjpegsrc_requeue_frame (v4lmjpegsrc, num);
}
} while (!have_frame);
} else {
/* grab a frame from the device */
- if (!gst_v4lmjpegsrc_grab_frame(v4lmjpegsrc, &num, &v4lmjpegsrc->last_size))
+ if (!gst_v4lmjpegsrc_grab_frame (v4lmjpegsrc, &num,
+ &v4lmjpegsrc->last_size))
return NULL;
v4lmjpegsrc->use_num_times[num] = 1;
buf = gst_buffer_new ();
GST_BUFFER_FREE_DATA_FUNC (buf) = gst_v4lmjpegsrc_buffer_free;
GST_BUFFER_PRIVATE (buf) = v4lmjpegsrc;
- GST_BUFFER_DATA(buf) = gst_v4lmjpegsrc_get_buffer(v4lmjpegsrc, num);
- GST_BUFFER_SIZE(buf) = v4lmjpegsrc->last_size;
- GST_BUFFER_MAXSIZE(buf) = v4lmjpegsrc->breq.size;
+ GST_BUFFER_DATA (buf) = gst_v4lmjpegsrc_get_buffer (v4lmjpegsrc, num);
+ GST_BUFFER_SIZE (buf) = v4lmjpegsrc->last_size;
+ GST_BUFFER_MAXSIZE (buf) = v4lmjpegsrc->breq.size;
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY | GST_BUFFER_DONTFREE);
if (v4lmjpegsrc->use_fixed_fps)
- GST_BUFFER_TIMESTAMP(buf) = v4lmjpegsrc->handled * GST_SECOND / fps;
- else /* calculate time based on our own clock */
- GST_BUFFER_TIMESTAMP(buf) = GST_TIMEVAL_TO_TIME(v4lmjpegsrc->bsync.timestamp) -
- v4lmjpegsrc->substract_time;
+ GST_BUFFER_TIMESTAMP (buf) = v4lmjpegsrc->handled * GST_SECOND / fps;
+ else /* calculate time based on our own clock */
+ GST_BUFFER_TIMESTAMP (buf) =
+ GST_TIMEVAL_TO_TIME (v4lmjpegsrc->bsync.timestamp) -
+ v4lmjpegsrc->substract_time;
v4lmjpegsrc->handled++;
- g_signal_emit(G_OBJECT(v4lmjpegsrc),
- gst_v4lmjpegsrc_signals[SIGNAL_FRAME_CAPTURE], 0);
+ g_signal_emit (G_OBJECT (v4lmjpegsrc),
+ gst_v4lmjpegsrc_signals[SIGNAL_FRAME_CAPTURE], 0);
return GST_DATA (buf);
}
-static GstCaps*
-gst_v4lmjpegsrc_getcaps (GstPad *pad)
+static GstCaps *
+gst_v4lmjpegsrc_getcaps (GstPad * pad)
{
- GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC(gst_pad_get_parent(pad));
- struct video_capability *vcap = &GST_V4LELEMENT(v4lmjpegsrc)->vcap;
+ GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
+ struct video_capability *vcap = &GST_V4LELEMENT (v4lmjpegsrc)->vcap;
- if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsrc))) {
+ if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lmjpegsrc))) {
return NULL;
}
return gst_caps_new_simple ("video/x-jpeg",
- "width", GST_TYPE_INT_RANGE, vcap->maxwidth/4, vcap->maxwidth,
- "height", GST_TYPE_INT_RANGE, vcap->maxheight/4, vcap->maxheight,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
- NULL);
+ "width", GST_TYPE_INT_RANGE, vcap->maxwidth / 4, vcap->maxwidth,
+ "height", GST_TYPE_INT_RANGE, vcap->maxheight / 4, vcap->maxheight,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
}
static void
-gst_v4lmjpegsrc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4lmjpegsrc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstV4lMjpegSrc *v4lmjpegsrc;
- g_return_if_fail(GST_IS_V4LMJPEGSRC(object));
- v4lmjpegsrc = GST_V4LMJPEGSRC(object);
+ g_return_if_fail (GST_IS_V4LMJPEGSRC (object));
+ v4lmjpegsrc = GST_V4LMJPEGSRC (object);
switch (prop_id) {
#if 0
case ARG_X_OFFSET:
- v4lmjpegsrc->x_offset = g_value_get_int(value);
+ v4lmjpegsrc->x_offset = g_value_get_int (value);
break;
case ARG_Y_OFFSET:
- v4lmjpegsrc->y_offset = g_value_get_int(value);
+ v4lmjpegsrc->y_offset = g_value_get_int (value);
break;
case ARG_F_WIDTH:
- v4lmjpegsrc->frame_width = g_value_get_int(value);
+ v4lmjpegsrc->frame_width = g_value_get_int (value);
break;
case ARG_F_HEIGHT:
- v4lmjpegsrc->frame_height = g_value_get_int(value);
+ v4lmjpegsrc->frame_height = g_value_get_int (value);
break;
#endif
case ARG_QUALITY:
- v4lmjpegsrc->quality = g_value_get_int(value);
+ v4lmjpegsrc->quality = g_value_get_int (value);
break;
case ARG_NUMBUFS:
- v4lmjpegsrc->numbufs = g_value_get_int(value);
+ v4lmjpegsrc->numbufs = g_value_get_int (value);
break;
case ARG_USE_FIXED_FPS:
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc))) {
- v4lmjpegsrc->use_fixed_fps = g_value_get_boolean(value);
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc))) {
+ v4lmjpegsrc->use_fixed_fps = g_value_get_boolean (value);
}
break;
default:
static void
-gst_v4lmjpegsrc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4lmjpegsrc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstV4lMjpegSrc *v4lmjpegsrc;
- g_return_if_fail(GST_IS_V4LMJPEGSRC(object));
- v4lmjpegsrc = GST_V4LMJPEGSRC(object);
+ g_return_if_fail (GST_IS_V4LMJPEGSRC (object));
+ v4lmjpegsrc = GST_V4LMJPEGSRC (object);
switch (prop_id) {
#if 0
case ARG_X_OFFSET:
- g_value_set_int(value, v4lmjpegsrc->x_offset);
+ g_value_set_int (value, v4lmjpegsrc->x_offset);
break;
case ARG_Y_OFFSET:
- g_value_set_int(value, v4lmjpegsrc->y_offset);
+ g_value_set_int (value, v4lmjpegsrc->y_offset);
break;
case ARG_F_WIDTH:
- g_value_set_int(value, v4lmjpegsrc->frame_width);
+ g_value_set_int (value, v4lmjpegsrc->frame_width);
break;
case ARG_F_HEIGHT:
- g_value_set_int(value, v4lmjpegsrc->frame_height);
+ g_value_set_int (value, v4lmjpegsrc->frame_height);
break;
#endif
case ARG_QUALITY:
- g_value_set_int(value, v4lmjpegsrc->quality);
+ g_value_set_int (value, v4lmjpegsrc->quality);
break;
case ARG_NUMBUFS:
- if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)))
- g_value_set_int(value, v4lmjpegsrc->breq.count);
+ if (GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc)))
+ g_value_set_int (value, v4lmjpegsrc->breq.count);
else
- g_value_set_int(value, v4lmjpegsrc->numbufs);
+ g_value_set_int (value, v4lmjpegsrc->numbufs);
break;
case ARG_BUFSIZE:
- g_value_set_int(value, v4lmjpegsrc->breq.size);
+ g_value_set_int (value, v4lmjpegsrc->breq.size);
break;
case ARG_USE_FIXED_FPS:
- g_value_set_boolean(value, v4lmjpegsrc->use_fixed_fps);
+ g_value_set_boolean (value, v4lmjpegsrc->use_fixed_fps);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static GstElementStateReturn
-gst_v4lmjpegsrc_change_state (GstElement *element)
+gst_v4lmjpegsrc_change_state (GstElement * element)
{
GstV4lMjpegSrc *v4lmjpegsrc;
GTimeVal time;
- g_return_val_if_fail(GST_IS_V4LMJPEGSRC(element), GST_STATE_FAILURE);
-
- v4lmjpegsrc = GST_V4LMJPEGSRC(element);
+ g_return_val_if_fail (GST_IS_V4LMJPEGSRC (element), GST_STATE_FAILURE);
+
+ v4lmjpegsrc = GST_V4LMJPEGSRC (element);
- switch (GST_STATE_TRANSITION(element)) {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
/* actual buffer set-up used to be done here - but I moved
* it to capsnego itself */
break;
case GST_STATE_PAUSED_TO_PLAYING:
/* queue all buffer, start streaming capture */
- if (!gst_v4lmjpegsrc_capture_start(v4lmjpegsrc))
- return GST_STATE_FAILURE;
- g_get_current_time(&time);
- v4lmjpegsrc->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4lmjpegsrc->substract_time;
+ if (!gst_v4lmjpegsrc_capture_start (v4lmjpegsrc))
+ return GST_STATE_FAILURE;
+ g_get_current_time (&time);
+ v4lmjpegsrc->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4lmjpegsrc->substract_time;
v4lmjpegsrc->last_seq = 0;
break;
case GST_STATE_PLAYING_TO_PAUSED:
- g_get_current_time(&time);
- v4lmjpegsrc->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4lmjpegsrc->substract_time;
+ g_get_current_time (&time);
+ v4lmjpegsrc->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4lmjpegsrc->substract_time;
/* de-queue all queued buffers */
- if (!gst_v4lmjpegsrc_capture_stop(v4lmjpegsrc))
- return GST_STATE_FAILURE;
+ if (!gst_v4lmjpegsrc_capture_stop (v4lmjpegsrc))
+ return GST_STATE_FAILURE;
break;
case GST_STATE_PAUSED_TO_READY:
/* stop capturing, unmap all buffers */
- if (!gst_v4lmjpegsrc_capture_deinit(v4lmjpegsrc))
- return GST_STATE_FAILURE;
+ if (!gst_v4lmjpegsrc_capture_deinit (v4lmjpegsrc))
+ return GST_STATE_FAILURE;
break;
}
static void
-gst_v4lmjpegsrc_set_clock (GstElement *element,
- GstClock *clock)
+gst_v4lmjpegsrc_set_clock (GstElement * element, GstClock * clock)
{
- GST_V4LMJPEGSRC(element)->clock = clock;
+ GST_V4LMJPEGSRC (element)->clock = clock;
}
#if 0
-static GstBuffer*
-gst_v4lmjpegsrc_buffer_new (GstBufferPool *pool,
- guint64 offset,
- guint size,
- gpointer user_data)
+static GstBuffer *
+gst_v4lmjpegsrc_buffer_new (GstBufferPool * pool,
+ guint64 offset, guint size, gpointer user_data)
{
GstBuffer *buffer;
- GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC(user_data);
+ GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (user_data);
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)))
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc)))
return NULL;
- buffer = gst_buffer_new();
+ buffer = gst_buffer_new ();
if (!buffer)
return NULL;
/* TODO: add interlacing info to buffer as metadata */
- GST_BUFFER_MAXSIZE(buffer) = v4lmjpegsrc->breq.size;
- GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_DONTFREE);
+ GST_BUFFER_MAXSIZE (buffer) = v4lmjpegsrc->breq.size;
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
return buffer;
}
#endif
static void
-gst_v4lmjpegsrc_buffer_free (GstBuffer *buf)
+gst_v4lmjpegsrc_buffer_free (GstBuffer * buf)
{
GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (GST_BUFFER_PRIVATE (buf));
int n;
- if (gst_element_get_state(GST_ELEMENT(v4lmjpegsrc)) != GST_STATE_PLAYING)
- return; /* we've already cleaned up ourselves */
+ if (gst_element_get_state (GST_ELEMENT (v4lmjpegsrc)) != GST_STATE_PLAYING)
+ return; /* we've already cleaned up ourselves */
- for (n=0;n<v4lmjpegsrc->breq.count;n++)
- if (GST_BUFFER_DATA(buf) == gst_v4lmjpegsrc_get_buffer(v4lmjpegsrc, n))
- {
+ for (n = 0; n < v4lmjpegsrc->breq.count; n++)
+ if (GST_BUFFER_DATA (buf) == gst_v4lmjpegsrc_get_buffer (v4lmjpegsrc, n)) {
v4lmjpegsrc->use_num_times[n]--;
if (v4lmjpegsrc->use_num_times[n] <= 0) {
- gst_v4lmjpegsrc_requeue_frame(v4lmjpegsrc, n);
+ gst_v4lmjpegsrc_requeue_frame (v4lmjpegsrc, n);
}
break;
}
if (n == v4lmjpegsrc->breq.count)
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Couldn't find the buffer"));
+ ("Couldn't find the buffer"));
}
#include <videodev_mjpeg.h>
G_BEGIN_DECLS
-
#define GST_TYPE_V4LMJPEGSRC \
(gst_v4lmjpegsrc_get_type())
#define GST_V4LMJPEGSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_V4LMJPEGSRC))
#define GST_IS_V4LMJPEGSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4LMJPEGSRC))
-
typedef struct _GstV4lMjpegSrc GstV4lMjpegSrc;
typedef struct _GstV4lMjpegSrcClass GstV4lMjpegSrcClass;
-struct _GstV4lMjpegSrc {
+struct _GstV4lMjpegSrc
+{
GstV4lElement v4lelement;
/* pads */
gint numbufs;
};
-struct _GstV4lMjpegSrcClass {
+struct _GstV4lMjpegSrcClass
+{
GstV4lElementClass parent_class;
- void (*frame_capture) (GObject *object);
- void (*frame_drop) (GObject *object);
- void (*frame_insert) (GObject *object);
- void (*frame_lost) (GObject *object,
- gint num_lost);
+ void (*frame_capture) (GObject * object);
+ void (*frame_drop) (GObject * object);
+ void (*frame_insert) (GObject * object);
+ void (*frame_lost) (GObject * object, gint num_lost);
};
-GType gst_v4lmjpegsrc_get_type(void);
+GType gst_v4lmjpegsrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_V4LMJPEGSRC_H__ */
#include "v4lsrc_calls.h"
/* elementfactory information */
-static GstElementDetails gst_v4lsrc_details = GST_ELEMENT_DETAILS (
- "Video (video4linux/raw) Source",
- "Source/Video",
- "Reads raw frames from a video4linux (BT8x8) device",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
-);
+static GstElementDetails gst_v4lsrc_details =
+GST_ELEMENT_DETAILS ("Video (video4linux/raw) Source",
+ "Source/Video",
+ "Reads raw frames from a video4linux (BT8x8) device",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* V4lSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_FRAME_CAPTURE,
SIGNAL_FRAME_DROP,
};
/* arguments */
-enum {
+enum
+{
ARG_0,
ARG_NUMBUFS,
ARG_BUFSIZE,
};
GST_FORMATS_FUNCTION (GstPad *, gst_v4lsrc_get_formats,
- GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
+ GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
GST_QUERY_TYPE_FUNCTION (GstPad *, gst_v4lsrc_get_query_types,
- GST_QUERY_POSITION);
+ GST_QUERY_POSITION);
/* init functions */
-static void gst_v4lsrc_base_init (gpointer g_class);
-static void gst_v4lsrc_class_init (GstV4lSrcClass *klass);
-static void gst_v4lsrc_init (GstV4lSrc *v4lsrc);
+static void gst_v4lsrc_base_init (gpointer g_class);
+static void gst_v4lsrc_class_init (GstV4lSrcClass * klass);
+static void gst_v4lsrc_init (GstV4lSrc * v4lsrc);
/* parent class virtual functions */
-static void gst_v4lsrc_open (GstElement *element,
- const gchar *device);
-static void gst_v4lsrc_close (GstElement *element,
- const gchar *device);
+static void gst_v4lsrc_open (GstElement * element, const gchar * device);
+static void gst_v4lsrc_close (GstElement * element, const gchar * device);
/* pad/info functions */
-static gboolean gst_v4lsrc_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_v4lsrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
+static gboolean gst_v4lsrc_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_v4lsrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
/* buffer functions */
-static GstPadLinkReturn gst_v4lsrc_srcconnect (GstPad *pad,
- const GstCaps *caps);
-static GstCaps* gst_v4lsrc_getcaps (GstPad *pad);
-static GstData* gst_v4lsrc_get (GstPad *pad);
+static GstPadLinkReturn gst_v4lsrc_srcconnect (GstPad * pad,
+ const GstCaps * caps);
+static GstCaps *gst_v4lsrc_getcaps (GstPad * pad);
+static GstData *gst_v4lsrc_get (GstPad * pad);
/* get/set params */
-static void gst_v4lsrc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4lsrc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4lsrc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4lsrc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
/* state handling */
-static GstElementStateReturn gst_v4lsrc_change_state (GstElement *element);
+static GstElementStateReturn gst_v4lsrc_change_state (GstElement * element);
/* set_clock function for a/V sync */
-static void gst_v4lsrc_set_clock (GstElement *element,
- GstClock *clock);
+static void gst_v4lsrc_set_clock (GstElement * element, GstClock * clock);
/* requeue buffer if it's back available */
-static void gst_v4lsrc_buffer_free (GstBuffer *buffer);
+static void gst_v4lsrc_buffer_free (GstBuffer * buffer);
static GstElementClass *parent_class = NULL;
static guint gst_v4lsrc_signals[LAST_SIGNAL] = { 0 };
if (!v4lsrc_type) {
static const GTypeInfo v4lsrc_info = {
- sizeof(GstV4lSrcClass),
+ sizeof (GstV4lSrcClass),
gst_v4lsrc_base_init,
NULL,
- (GClassInitFunc)gst_v4lsrc_class_init,
+ (GClassInitFunc) gst_v4lsrc_class_init,
NULL,
NULL,
- sizeof(GstV4lSrc),
+ sizeof (GstV4lSrc),
0,
- (GInstanceInitFunc)gst_v4lsrc_init,
+ (GInstanceInitFunc) gst_v4lsrc_init,
NULL
};
- v4lsrc_type = g_type_register_static(GST_TYPE_V4LELEMENT, "GstV4lSrc", &v4lsrc_info, 0);
+ v4lsrc_type =
+ g_type_register_static (GST_TYPE_V4LELEMENT, "GstV4lSrc", &v4lsrc_info,
+ 0);
}
return v4lsrc_type;
}
{
GstPadTemplate *src_template;
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_v4lsrc_details);
- src_template = gst_pad_template_new (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- NULL);
+ src_template = gst_pad_template_new ("src",
+ GST_PAD_SRC, GST_PAD_ALWAYS, NULL);
gst_element_class_add_pad_template (gstelement_class, src_template);
}
static void
-gst_v4lsrc_class_init (GstV4lSrcClass *klass)
+gst_v4lsrc_class_init (GstV4lSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstV4lElementClass *v4lelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
v4lelement_class = (GstV4lElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_V4LELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_V4LELEMENT);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUMBUFS,
- g_param_spec_int("num_buffers","Num Buffers","Number of buffers",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFSIZE,
- g_param_spec_int("buffer_size","Buffer Size","Size of buffers",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_USE_FIXED_FPS,
- g_param_spec_boolean("use_fixed_fps", "Use Fixed FPS",
- "Drop/Insert frames to reach a certain FPS (TRUE) "
- "or adapt FPS to suit the number of frabbed frames",
- TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUMBUFS,
+ g_param_spec_int ("num_buffers", "Num Buffers", "Number of buffers",
+ G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
+ g_param_spec_int ("buffer_size", "Buffer Size", "Size of buffers",
+ G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_FIXED_FPS,
+ g_param_spec_boolean ("use_fixed_fps", "Use Fixed FPS",
+ "Drop/Insert frames to reach a certain FPS (TRUE) "
+ "or adapt FPS to suit the number of frabbed frames",
+ TRUE, G_PARAM_READWRITE));
/* signals */
gst_v4lsrc_signals[SIGNAL_FRAME_CAPTURE] =
- g_signal_new("frame-capture", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lSrcClass, frame_capture),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-capture", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4lSrcClass, frame_capture), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4lsrc_signals[SIGNAL_FRAME_DROP] =
- g_signal_new("frame-drop", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lSrcClass, frame_drop),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-drop", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4lSrcClass, frame_drop), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4lsrc_signals[SIGNAL_FRAME_INSERT] =
- g_signal_new("frame-insert", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4lSrcClass, frame_insert),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-insert", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4lSrcClass, frame_insert), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_v4lsrc_set_property;
gobject_class->get_property = gst_v4lsrc_get_property;
gstelement_class->set_clock = gst_v4lsrc_set_clock;
- v4lelement_class->open = gst_v4lsrc_open;
+ v4lelement_class->open = gst_v4lsrc_open;
v4lelement_class->close = gst_v4lsrc_close;
}
static void
-gst_v4lsrc_init (GstV4lSrc *v4lsrc)
+gst_v4lsrc_init (GstV4lSrc * v4lsrc)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (v4lsrc);
- GST_FLAG_SET(GST_ELEMENT(v4lsrc), GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (GST_ELEMENT (v4lsrc), GST_ELEMENT_THREAD_SUGGESTED);
- v4lsrc->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "src"), "src");
- gst_element_add_pad(GST_ELEMENT(v4lsrc), v4lsrc->srcpad);
+ v4lsrc->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "src"), "src");
+ gst_element_add_pad (GST_ELEMENT (v4lsrc), v4lsrc->srcpad);
gst_pad_set_get_function (v4lsrc->srcpad, gst_v4lsrc_get);
gst_pad_set_getcaps_function (v4lsrc->srcpad, gst_v4lsrc_getcaps);
}
static void
-gst_v4lsrc_open (GstElement *element,
- const gchar *device)
+gst_v4lsrc_open (GstElement * element, const gchar * device)
{
GstV4lSrc *v4lsrc = GST_V4LSRC (element);
int palette[] = {
for (i = 0; palette[i] != -1; i++) {
/* try palette out */
- if (!gst_v4lsrc_try_palette(v4lsrc, palette[i]))
+ if (!gst_v4lsrc_try_palette (v4lsrc, palette[i]))
continue;
v4lsrc->colourspaces = g_list_append (v4lsrc->colourspaces,
- GINT_TO_POINTER (palette[i]));
+ GINT_TO_POINTER (palette[i]));
}
}
static void
-gst_v4lsrc_close (GstElement *element,
- const gchar *device)
+gst_v4lsrc_close (GstElement * element, const gchar * device)
{
GstV4lSrc *v4lsrc = GST_V4LSRC (element);
}
static gfloat
-gst_v4lsrc_get_fps (GstV4lSrc *v4lsrc)
+gst_v4lsrc_get_fps (GstV4lSrc * v4lsrc)
{
gint norm;
gfloat fps;
- if (!v4lsrc->use_fixed_fps &&
- v4lsrc->clock != NULL &&
- v4lsrc->handled > 0) {
+ if (!v4lsrc->use_fixed_fps && v4lsrc->clock != NULL && v4lsrc->handled > 0) {
/* try to get time from clock master and calculate fps */
- GstClockTime time = gst_clock_get_time(v4lsrc->clock) - v4lsrc->substract_time;
+ GstClockTime time =
+ gst_clock_get_time (v4lsrc->clock) - v4lsrc->substract_time;
return v4lsrc->handled * GST_SECOND / time;
}
/* if that failed ... */
- if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lsrc)))
+ if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc)))
return 0.;
- if (!gst_v4l_get_chan_norm(GST_V4LELEMENT(v4lsrc), NULL, &norm))
+ if (!gst_v4l_get_chan_norm (GST_V4LELEMENT (v4lsrc), NULL, &norm))
return 0.;
if (norm == VIDEO_MODE_NTSC)
- fps = 30000/1001;
+ fps = 30000 / 1001;
else
fps = 25.;
}
static gboolean
-gst_v4lsrc_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value)
+gst_v4lsrc_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
{
GstV4lSrc *v4lsrc;
gdouble fps;
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
- if ((fps = gst_v4lsrc_get_fps(v4lsrc)) == 0)
+ if ((fps = gst_v4lsrc_get_fps (v4lsrc)) == 0)
return FALSE;
switch (src_format) {
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * fps / GST_SECOND;
- break;
- default:
- return FALSE;
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value * fps / GST_SECOND;
+ break;
+ default:
+ return FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * GST_SECOND / fps;
- break;
- default:
- return FALSE;
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * GST_SECOND / fps;
+ break;
+ default:
+ return FALSE;
}
break;
}
static gboolean
-gst_v4lsrc_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value)
+gst_v4lsrc_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value)
{
GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
gboolean res = TRUE;
gdouble fps;
- if ((fps = gst_v4lsrc_get_fps(v4lsrc)) == 0)
+ if ((fps = gst_v4lsrc_get_fps (v4lsrc)) == 0)
return FALSE;
switch (type) {
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = v4lsrc->handled * GST_SECOND / fps;
- break;
- case GST_FORMAT_DEFAULT:
- *value = v4lsrc->handled;
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *value = v4lsrc->handled * GST_SECOND / fps;
+ break;
+ case GST_FORMAT_DEFAULT:
+ *value = v4lsrc->handled;
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
switch (palette) {
case VIDEO_PALETTE_YUV422:
case VIDEO_PALETTE_YUYV:
- fourcc = GST_MAKE_FOURCC('Y','U','Y','2');
+ fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
break;
case VIDEO_PALETTE_YUV420P:
- fourcc = GST_MAKE_FOURCC('I','4','2','0');
+ fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
break;
case VIDEO_PALETTE_UYVY:
- fourcc = GST_MAKE_FOURCC('U','Y','V','Y');
+ fourcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
break;
case VIDEO_PALETTE_YUV411P:
- fourcc = GST_MAKE_FOURCC('Y','4','1','B');
+ fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
break;
case VIDEO_PALETTE_YUV411:
- fourcc = GST_MAKE_FOURCC('Y','4','1','P');
+ fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'P');
break;
case VIDEO_PALETTE_YUV422P:
- fourcc = GST_MAKE_FOURCC('Y','4','2','B');
+ fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
break;
case VIDEO_PALETTE_YUV410P:
- fourcc = GST_MAKE_FOURCC('Y','U','V','9');
+ fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
break;
case VIDEO_PALETTE_RGB555:
case VIDEO_PALETTE_RGB565:
case VIDEO_PALETTE_RGB24:
case VIDEO_PALETTE_RGB32:
- fourcc = GST_MAKE_FOURCC('R','G','B',' ');
+ fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
break;
default:
return NULL;
}
- if (fourcc == GST_MAKE_FOURCC('R','G','B',' ')) {
+ if (fourcc == GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
switch (palette) {
case VIDEO_PALETTE_RGB555:
caps = gst_caps_from_string ("video/x-raw-rgb, "
"bpp = (int) 16, "
"depth = (int) 15, "
"endianness = (int) BYTE_ORDER, "
- "red_mask = 0x7c00, "
- "green_mask = 0x03e0, "
- "blue_mask = 0x001f");
- break;
+ "red_mask = 0x7c00, " "green_mask = 0x03e0, " "blue_mask = 0x001f");
+ break;
case VIDEO_PALETTE_RGB565:
caps = gst_caps_from_string ("video/x-raw-rgb, "
"bpp = (int) 16, "
"depth = (int) 16, "
"endianness = (int) BYTE_ORDER, "
- "red_mask = 0xf800, "
- "green_mask = 0x07f0, "
- "blue_mask = 0x001f");
- break;
+ "red_mask = 0xf800, " "green_mask = 0x07f0, " "blue_mask = 0x001f");
+ break;
case VIDEO_PALETTE_RGB24:
caps = gst_caps_from_string ("video/x-raw-rgb, "
"bpp = (int) 24, "
"depth = (int) 24, "
"endianness = (int) BIG_ENDIAN, "
"red_mask = 0xFF0000, "
- "green_mask = 0x00FF00, "
- "blue_mask = 0x0000FF");
- break;
+ "green_mask = 0x00FF00, " "blue_mask = 0x0000FF");
+ break;
case VIDEO_PALETTE_RGB32:
caps = gst_caps_from_string ("video/x-raw-rgb, "
"bpp = (int) 24, "
"depth = (int) 32, "
"endianness = (int) BIG_ENDIAN, "
"red_mask = 0xFF000000, "
- "green_mask = 0x00FF0000, "
- "blue_mask = 0x0000FF00");
- break;
+ "green_mask = 0x00FF0000, " "blue_mask = 0x0000FF00");
+ break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
return NULL;
}
} else {
static GstPadLinkReturn
-gst_v4lsrc_srcconnect (GstPad *pad, const GstCaps *vscapslist)
+gst_v4lsrc_srcconnect (GstPad * pad, const GstCaps * vscapslist)
{
GstV4lSrc *v4lsrc;
guint32 fourcc;
/* in case the buffers are active (which means that we already
* did capsnego before and didn't clean up), clean up anyways */
- if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc)))
- {
+ if (GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc))) {
if (was_capturing) {
- if (!gst_v4lsrc_capture_stop(v4lsrc))
- return GST_PAD_LINK_REFUSED;
+ if (!gst_v4lsrc_capture_stop (v4lsrc))
+ return GST_PAD_LINK_REFUSED;
}
- if (!gst_v4lsrc_capture_deinit(v4lsrc))
+ if (!gst_v4lsrc_capture_deinit (v4lsrc))
return GST_PAD_LINK_REFUSED;
- } else if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lsrc))) {
+ } else if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
return GST_PAD_LINK_DELAYED;
}
structure = gst_caps_get_structure (vscapslist, 0);
- if (!strcmp(gst_structure_get_name (structure), "video/x-raw-yuv"))
+ if (!strcmp (gst_structure_get_name (structure), "video/x-raw-yuv"))
gst_structure_get_fourcc (structure, "format", &fourcc);
else
- fourcc = GST_MAKE_FOURCC('R','G','B',' ');
+ fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_int (structure, "width", &w);
gst_structure_get_int (structure, "height", &h);
gst_structure_get_double (structure, "framerate", &fps);
- switch (fourcc)
- {
- case GST_MAKE_FOURCC('I','4','2','0'):
+ switch (fourcc) {
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
palette = VIDEO_PALETTE_YUV420P;
- v4lsrc->buffer_size = ((w+1)&~1) * ((h+1)&~1) * 1.5;
+ v4lsrc->buffer_size = ((w + 1) & ~1) * ((h + 1) & ~1) * 1.5;
break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
palette = VIDEO_PALETTE_YUV422;
- v4lsrc->buffer_size = ((w+1)&~1) * h * 2;
+ v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
palette = VIDEO_PALETTE_UYVY;
- v4lsrc->buffer_size = ((w+1)&~1) * h * 2;
+ v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
break;
- case GST_MAKE_FOURCC('Y','4','1','B'):
+ case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
palette = VIDEO_PALETTE_YUV411P;
- v4lsrc->buffer_size = ((w+3)&~3) * h * 1.5;
+ v4lsrc->buffer_size = ((w + 3) & ~3) * h * 1.5;
break;
- case GST_MAKE_FOURCC('Y','4','1','P'):
+ case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
palette = VIDEO_PALETTE_YUV411;
- v4lsrc->buffer_size = ((w+3)&~3) * h * 1.5;
+ v4lsrc->buffer_size = ((w + 3) & ~3) * h * 1.5;
break;
- case GST_MAKE_FOURCC('Y','U','V','9'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
palette = VIDEO_PALETTE_YUV410P;
- v4lsrc->buffer_size = ((w+3)&~3) * ((h+3)&~3) * 1.125;
+ v4lsrc->buffer_size = ((w + 3) & ~3) * ((h + 3) & ~3) * 1.125;
break;
- case GST_MAKE_FOURCC('Y','4','2','B'):
+ case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
palette = VIDEO_PALETTE_YUV422P;
- v4lsrc->buffer_size = ((w+1)&~1) * h * 2;
+ v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
break;
- case GST_MAKE_FOURCC('R','G','B',' '):
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
gst_structure_get_int (structure, "depth", &depth);
- switch (depth)
- {
+ switch (depth) {
case 15:
palette = VIDEO_PALETTE_RGB555;
v4lsrc->buffer_size = w * h * 2;
- break;
+ break;
case 16:
palette = VIDEO_PALETTE_RGB565;
v4lsrc->buffer_size = w * h * 2;
- break;
+ break;
case 24:
- gst_structure_get_int (structure, "bpp", &bpp);
- switch (bpp) {
- case 24:
+ gst_structure_get_int (structure, "bpp", &bpp);
+ switch (bpp) {
+ case 24:
palette = VIDEO_PALETTE_RGB24;
v4lsrc->buffer_size = w * h * 3;
- break;
+ break;
case 32:
palette = VIDEO_PALETTE_RGB32;
v4lsrc->buffer_size = w * h * 4;
- break;
- default:
- break;
- }
- break;
+ break;
+ default:
+ break;
+ }
+ break;
default:
- break;
+ break;
}
break;
default:
if (palette == -1)
return GST_PAD_LINK_REFUSED;
- if (!gst_v4lsrc_set_capture(v4lsrc, w, h, palette))
+ if (!gst_v4lsrc_set_capture (v4lsrc, w, h, palette))
return GST_PAD_LINK_REFUSED;
- if (!gst_v4lsrc_capture_init(v4lsrc))
+ if (!gst_v4lsrc_capture_init (v4lsrc))
return GST_PAD_LINK_REFUSED;
if (was_capturing) {
- if (!gst_v4lsrc_capture_start(v4lsrc))
+ if (!gst_v4lsrc_capture_start (v4lsrc))
return GST_PAD_LINK_REFUSED;
}
static GstCaps *
-gst_v4lsrc_getcaps (GstPad *pad)
+gst_v4lsrc_getcaps (GstPad * pad)
{
GstCaps *list;
- GstV4lSrc *v4lsrc = GST_V4LSRC(gst_pad_get_parent(pad));
- struct video_capability *vcap = &GST_V4LELEMENT(v4lsrc)->vcap;
+ GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
+ struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
GList *item;
- if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lsrc))) {
+ if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
return gst_caps_new_any ();
}
- list = gst_caps_new_empty();
+ list = gst_caps_new_empty ();
for (item = v4lsrc->colourspaces; item != NULL; item = item->next) {
GstCaps *one;
- one = gst_v4lsrc_palette_to_caps(GPOINTER_TO_INT (item->data));
+ one = gst_v4lsrc_palette_to_caps (GPOINTER_TO_INT (item->data));
if (!one)
- g_print ("Palette %d gave no caps\n",
- GPOINTER_TO_INT (item->data));
+ g_print ("Palette %d gave no caps\n", GPOINTER_TO_INT (item->data));
gst_caps_set_simple (one,
- "width", GST_TYPE_INT_RANGE, vcap->minwidth, vcap->maxwidth,
+ "width", GST_TYPE_INT_RANGE, vcap->minwidth, vcap->maxwidth,
"height", GST_TYPE_INT_RANGE, vcap->minheight, vcap->maxheight,
- "framerate", G_TYPE_DOUBLE, gst_v4lsrc_get_fps(v4lsrc),
- NULL);
- gst_caps_append(list, one);
+ "framerate", G_TYPE_DOUBLE, gst_v4lsrc_get_fps (v4lsrc), NULL);
+ gst_caps_append (list, one);
}
return list;
static GstData *
-gst_v4lsrc_get (GstPad *pad)
+gst_v4lsrc_get (GstPad * pad)
{
GstV4lSrc *v4lsrc;
GstBuffer *buf;
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
- if (v4lsrc->use_fixed_fps &&
- (fps = gst_v4lsrc_get_fps(v4lsrc)) == 0)
+ if (v4lsrc->use_fixed_fps && (fps = gst_v4lsrc_get_fps (v4lsrc)) == 0)
return NULL;
if (v4lsrc->need_writes > 0) {
v4lsrc->need_writes = 1;
/* grab a frame from the device */
- if (!gst_v4lsrc_grab_frame(v4lsrc, &num))
- return NULL;
+ if (!gst_v4lsrc_grab_frame (v4lsrc, &num))
+ return NULL;
v4lsrc->last_frame = num;
time = v4lsrc->timestamp_sync - v4lsrc->substract_time;
* timeframe. This means that if time - begin_time = X sec,
* we want to have written X*fps frames. If we've written
* more - drop, if we've written less - dup... */
- if (v4lsrc->handled * (GST_SECOND/fps) - time > 1.5 * (GST_SECOND/fps)) {
- /* yo dude, we've got too many frames here! Drop! DROP! */
- v4lsrc->need_writes--; /* -= (v4lsrc->handled - (time / fps)); */
- g_signal_emit(G_OBJECT(v4lsrc),
- gst_v4lsrc_signals[SIGNAL_FRAME_DROP], 0);
- } else if (v4lsrc->handled * (GST_SECOND/fps) - time < - 1.5 * (GST_SECOND/fps)) {
- /* this means we're lagging far behind */
- v4lsrc->need_writes++; /* += ((time / fps) - v4lsrc->handled); */
- g_signal_emit(G_OBJECT(v4lsrc),
- gst_v4lsrc_signals[SIGNAL_FRAME_INSERT], 0);
+ if (v4lsrc->handled * (GST_SECOND / fps) - time >
+ 1.5 * (GST_SECOND / fps)) {
+ /* yo dude, we've got too many frames here! Drop! DROP! */
+ v4lsrc->need_writes--; /* -= (v4lsrc->handled - (time / fps)); */
+ g_signal_emit (G_OBJECT (v4lsrc),
+ gst_v4lsrc_signals[SIGNAL_FRAME_DROP], 0);
+ } else if (v4lsrc->handled * (GST_SECOND / fps) - time <
+ -1.5 * (GST_SECOND / fps)) {
+ /* this means we're lagging far behind */
+ v4lsrc->need_writes++; /* += ((time / fps) - v4lsrc->handled); */
+ g_signal_emit (G_OBJECT (v4lsrc),
+ gst_v4lsrc_signals[SIGNAL_FRAME_INSERT], 0);
}
if (v4lsrc->need_writes > 0) {
- have_frame = TRUE;
- v4lsrc->use_num_times[num] = v4lsrc->need_writes;
- v4lsrc->need_writes--;
+ have_frame = TRUE;
+ v4lsrc->use_num_times[num] = v4lsrc->need_writes;
+ v4lsrc->need_writes--;
} else {
- gst_v4lsrc_requeue_frame(v4lsrc, num);
+ gst_v4lsrc_requeue_frame (v4lsrc, num);
}
} while (!have_frame);
} else {
/* grab a frame from the device */
- if (!gst_v4lsrc_grab_frame(v4lsrc, &num))
+ if (!gst_v4lsrc_grab_frame (v4lsrc, &num))
return NULL;
v4lsrc->use_num_times[num] = 1;
buf = gst_buffer_new ();
GST_BUFFER_FREE_DATA_FUNC (buf) = gst_v4lsrc_buffer_free;
- GST_BUFFER_PRIVATE (buf) = v4lsrc; /* hack to re-queue buffer on free */
+ GST_BUFFER_PRIVATE (buf) = v4lsrc; /* hack to re-queue buffer on free */
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY | GST_BUFFER_DONTFREE);
- GST_BUFFER_DATA(buf) = gst_v4lsrc_get_buffer(v4lsrc, num);
+ GST_BUFFER_DATA (buf) = gst_v4lsrc_get_buffer (v4lsrc, num);
GST_BUFFER_MAXSIZE (buf) = v4lsrc->mbuf.size / v4lsrc->mbuf.frames;
- GST_BUFFER_SIZE(buf) = v4lsrc->buffer_size;
+ GST_BUFFER_SIZE (buf) = v4lsrc->buffer_size;
if (v4lsrc->use_fixed_fps)
- GST_BUFFER_TIMESTAMP(buf) = v4lsrc->handled * GST_SECOND / fps;
- else /* calculate time based on our own clock */
- GST_BUFFER_TIMESTAMP(buf) = v4lsrc->timestamp_sync - v4lsrc->substract_time;
+ GST_BUFFER_TIMESTAMP (buf) = v4lsrc->handled * GST_SECOND / fps;
+ else /* calculate time based on our own clock */
+ GST_BUFFER_TIMESTAMP (buf) =
+ v4lsrc->timestamp_sync - v4lsrc->substract_time;
v4lsrc->handled++;
- g_signal_emit(G_OBJECT(v4lsrc),
- gst_v4lsrc_signals[SIGNAL_FRAME_CAPTURE], 0);
+ g_signal_emit (G_OBJECT (v4lsrc),
+ gst_v4lsrc_signals[SIGNAL_FRAME_CAPTURE], 0);
return GST_DATA (buf);
}
static void
-gst_v4lsrc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4lsrc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstV4lSrc *v4lsrc;
- g_return_if_fail(GST_IS_V4LSRC(object));
- v4lsrc = GST_V4LSRC(object);
+ g_return_if_fail (GST_IS_V4LSRC (object));
+ v4lsrc = GST_V4LSRC (object);
switch (prop_id) {
case ARG_USE_FIXED_FPS:
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc))) {
- v4lsrc->use_fixed_fps = g_value_get_boolean(value);
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc))) {
+ v4lsrc->use_fixed_fps = g_value_get_boolean (value);
}
break;
static void
-gst_v4lsrc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4lsrc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstV4lSrc *v4lsrc;
- g_return_if_fail(GST_IS_V4LSRC(object));
- v4lsrc = GST_V4LSRC(object);
+ g_return_if_fail (GST_IS_V4LSRC (object));
+ v4lsrc = GST_V4LSRC (object);
switch (prop_id) {
case ARG_NUMBUFS:
- g_value_set_int(value, v4lsrc->mbuf.frames);
+ g_value_set_int (value, v4lsrc->mbuf.frames);
break;
case ARG_BUFSIZE:
if (v4lsrc->mbuf.frames == 0)
- g_value_set_int(value, 0);
+ g_value_set_int (value, 0);
else
- g_value_set_int(value, v4lsrc->mbuf.size/(v4lsrc->mbuf.frames*1024));
+ g_value_set_int (value,
+ v4lsrc->mbuf.size / (v4lsrc->mbuf.frames * 1024));
break;
case ARG_USE_FIXED_FPS:
- g_value_set_boolean(value, v4lsrc->use_fixed_fps);
+ g_value_set_boolean (value, v4lsrc->use_fixed_fps);
break;
default:
static GstElementStateReturn
-gst_v4lsrc_change_state (GstElement *element)
+gst_v4lsrc_change_state (GstElement * element)
{
GstV4lSrc *v4lsrc;
GTimeVal time;
gint transition = GST_STATE_TRANSITION (element);
- g_return_val_if_fail(GST_IS_V4LSRC(element), GST_STATE_FAILURE);
-
- v4lsrc = GST_V4LSRC(element);
+ g_return_val_if_fail (GST_IS_V4LSRC (element), GST_STATE_FAILURE);
+
+ v4lsrc = GST_V4LSRC (element);
switch (transition) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_PAUSED_TO_PLAYING:
/* queue all buffer, start streaming capture */
- if (!gst_v4lsrc_capture_start(v4lsrc))
- return GST_STATE_FAILURE;
- g_get_current_time(&time);
- v4lsrc->substract_time = GST_TIMEVAL_TO_TIME(time) - v4lsrc->substract_time;
+ if (!gst_v4lsrc_capture_start (v4lsrc))
+ return GST_STATE_FAILURE;
+ g_get_current_time (&time);
+ v4lsrc->substract_time =
+ GST_TIMEVAL_TO_TIME (time) - v4lsrc->substract_time;
break;
case GST_STATE_PLAYING_TO_PAUSED:
/* de-queue all queued buffers */
- if (!gst_v4lsrc_capture_stop(v4lsrc))
- return GST_STATE_FAILURE;
- g_get_current_time(&time);
- v4lsrc->substract_time = GST_TIMEVAL_TO_TIME(time) - v4lsrc->substract_time;
+ if (!gst_v4lsrc_capture_stop (v4lsrc))
+ return GST_STATE_FAILURE;
+ g_get_current_time (&time);
+ v4lsrc->substract_time =
+ GST_TIMEVAL_TO_TIME (time) - v4lsrc->substract_time;
break;
case GST_STATE_PAUSED_TO_READY:
/* stop capturing, unmap all buffers */
- if (!gst_v4lsrc_capture_deinit(v4lsrc))
- return GST_STATE_FAILURE;
+ if (!gst_v4lsrc_capture_deinit (v4lsrc))
+ return GST_STATE_FAILURE;
break;
case GST_STATE_READY_TO_NULL:
break;
#if 0
-static GstBuffer*
-gst_v4lsrc_buffer_new (GstBufferPool *pool,
- guint64 offset,
- guint size,
- gpointer user_data)
+static GstBuffer *
+gst_v4lsrc_buffer_new (GstBufferPool * pool,
+ guint64 offset, guint size, gpointer user_data)
{
GstBuffer *buffer;
- GstV4lSrc *v4lsrc = GST_V4LSRC(user_data);
+ GstV4lSrc *v4lsrc = GST_V4LSRC (user_data);
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc)))
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc)))
return NULL;
- buffer = gst_buffer_new();
+ buffer = gst_buffer_new ();
if (!buffer)
return NULL;
/* TODO: add interlacing info to buffer as metadata
* (height>288 or 240 = topfieldfirst, else noninterlaced) */
- GST_BUFFER_MAXSIZE(buffer) = v4lsrc->mbuf.size / v4lsrc->mbuf.frames;
- GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_DONTFREE);
+ GST_BUFFER_MAXSIZE (buffer) = v4lsrc->mbuf.size / v4lsrc->mbuf.frames;
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
return buffer;
}
#endif
static void
-gst_v4lsrc_buffer_free (GstBuffer *buf)
+gst_v4lsrc_buffer_free (GstBuffer * buf)
{
GstV4lSrc *v4lsrc = GST_V4LSRC (GST_BUFFER_PRIVATE (buf));
int n;
- if (gst_element_get_state(GST_ELEMENT(v4lsrc)) != GST_STATE_PLAYING)
- return; /* we've already cleaned up ourselves */
+ if (gst_element_get_state (GST_ELEMENT (v4lsrc)) != GST_STATE_PLAYING)
+ return; /* we've already cleaned up ourselves */
- for (n=0;n<v4lsrc->mbuf.frames;n++)
- if (GST_BUFFER_DATA(buf) == gst_v4lsrc_get_buffer(v4lsrc, n))
- {
+ for (n = 0; n < v4lsrc->mbuf.frames; n++)
+ if (GST_BUFFER_DATA (buf) == gst_v4lsrc_get_buffer (v4lsrc, n)) {
v4lsrc->use_num_times[n]--;
if (v4lsrc->use_num_times[n] <= 0) {
- gst_v4lsrc_requeue_frame(v4lsrc, n);
+ gst_v4lsrc_requeue_frame (v4lsrc, n);
}
break;
}
if (n == v4lsrc->mbuf.frames)
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Couldn\'t find the buffer"));
+ ("Couldn\'t find the buffer"));
}
static void
-gst_v4lsrc_set_clock (GstElement *element,
- GstClock *clock)
+gst_v4lsrc_set_clock (GstElement * element, GstClock * clock)
{
- GST_V4LSRC(element)->clock = clock;
+ GST_V4LSRC (element)->clock = clock;
}
#include <gstv4lelement.h>
G_BEGIN_DECLS
-
#define GST_TYPE_V4LSRC \
(gst_v4lsrc_get_type())
#define GST_V4LSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_V4LSRC))
#define GST_IS_V4LSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4LSRC))
-
typedef struct _GstV4lSrc GstV4lSrc;
typedef struct _GstV4lSrcClass GstV4lSrcClass;
-enum {
+enum
+{
QUEUE_STATE_ERROR = -1,
QUEUE_STATE_READY_FOR_QUEUE,
QUEUE_STATE_QUEUED,
QUEUE_STATE_SYNCED,
};
-struct _GstV4lSrc {
+struct _GstV4lSrc
+{
GstV4lElement v4lelement;
/* pads */
gboolean use_fixed_fps;
};
-struct _GstV4lSrcClass {
+struct _GstV4lSrcClass
+{
GstV4lElementClass parent_class;
- void (*frame_capture) (GObject *object);
- void (*frame_drop) (GObject *object);
- void (*frame_insert) (GObject *object);
+ void (*frame_capture) (GObject * object);
+ void (*frame_drop) (GObject * object);
+ void (*frame_insert) (GObject * object);
};
-GType gst_v4lsrc_get_type(void);
+GType gst_v4lsrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_V4LSRC_H__ */
#include "gstv4lelement.h"
#include "v4l_calls.h"
-static void gst_v4l_tuner_channel_class_init(GstV4lTunerChannelClass *klass);
-static void gst_v4l_tuner_channel_init (GstV4lTunerChannel *channel);
+static void gst_v4l_tuner_channel_class_init (GstV4lTunerChannelClass * klass);
+static void gst_v4l_tuner_channel_init (GstV4lTunerChannel * channel);
-static void gst_v4l_tuner_norm_class_init (GstV4lTunerNormClass *klass);
-static void gst_v4l_tuner_norm_init (GstV4lTunerNorm *norm);
+static void gst_v4l_tuner_norm_class_init (GstV4lTunerNormClass * klass);
+static void gst_v4l_tuner_norm_init (GstV4lTunerNorm * norm);
-static const GList *
- gst_v4l_tuner_list_channels (GstTuner *tuner);
-static void gst_v4l_tuner_set_channel (GstTuner *tuner,
- GstTunerChannel *channel);
-static GstTunerChannel *
- gst_v4l_tuner_get_channel (GstTuner *tuner);
+static const GList *gst_v4l_tuner_list_channels (GstTuner * tuner);
+static void gst_v4l_tuner_set_channel (GstTuner * tuner,
+ GstTunerChannel * channel);
+static GstTunerChannel *gst_v4l_tuner_get_channel (GstTuner * tuner);
-static const GList *
- gst_v4l_tuner_list_norms (GstTuner *tuner);
-static void gst_v4l_tuner_set_norm (GstTuner *tuner,
- GstTunerNorm *norm);
-static GstTunerNorm *
- gst_v4l_tuner_get_norm (GstTuner *tuner);
+static const GList *gst_v4l_tuner_list_norms (GstTuner * tuner);
+static void gst_v4l_tuner_set_norm (GstTuner * tuner, GstTunerNorm * norm);
+static GstTunerNorm *gst_v4l_tuner_get_norm (GstTuner * tuner);
-static void gst_v4l_tuner_set_frequency (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency);
-static gulong gst_v4l_tuner_get_frequency (GstTuner *tuner,
- GstTunerChannel *channel);
-static gint gst_v4l_tuner_signal_strength (GstTuner *tuner,
- GstTunerChannel *channel);
+static void gst_v4l_tuner_set_frequency (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency);
+static gulong gst_v4l_tuner_get_frequency (GstTuner * tuner,
+ GstTunerChannel * channel);
+static gint gst_v4l_tuner_signal_strength (GstTuner * tuner,
+ GstTunerChannel * channel);
static GstTunerNormClass *norm_parent_class = NULL;
static GstTunerChannelClass *channel_parent_class = NULL;
gst_v4l_tuner_channel_type =
g_type_register_static (GST_TYPE_TUNER_CHANNEL,
- "GstV4lTunerChannel",
- &v4l_tuner_channel_info, 0);
+ "GstV4lTunerChannel", &v4l_tuner_channel_info, 0);
}
return gst_v4l_tuner_channel_type;
}
static void
-gst_v4l_tuner_channel_class_init (GstV4lTunerChannelClass *klass)
+gst_v4l_tuner_channel_class_init (GstV4lTunerChannelClass * klass)
{
channel_parent_class = g_type_class_ref (GST_TYPE_TUNER_CHANNEL);
}
static void
-gst_v4l_tuner_channel_init (GstV4lTunerChannel *channel)
+gst_v4l_tuner_channel_init (GstV4lTunerChannel * channel)
{
channel->index = 0;
channel->audio = 0;
gst_v4l_tuner_norm_type =
g_type_register_static (GST_TYPE_TUNER_NORM,
- "GstV4lTunerNorm",
- &v4l_tuner_norm_info, 0);
+ "GstV4lTunerNorm", &v4l_tuner_norm_info, 0);
}
return gst_v4l_tuner_norm_type;
}
static void
-gst_v4l_tuner_norm_class_init (GstV4lTunerNormClass *klass)
+gst_v4l_tuner_norm_class_init (GstV4lTunerNormClass * klass)
{
norm_parent_class = g_type_class_ref (GST_TYPE_TUNER_NORM);
}
static void
-gst_v4l_tuner_norm_init (GstV4lTunerNorm *norm)
+gst_v4l_tuner_norm_init (GstV4lTunerNorm * norm)
{
norm->index = 0;
}
void
-gst_v4l_tuner_interface_init (GstTunerClass *klass)
+gst_v4l_tuner_interface_init (GstTunerClass * klass)
{
/* default virtual functions */
klass->list_channels = gst_v4l_tuner_list_channels;
}
static gboolean
-gst_v4l_tuner_contains_channel (GstV4lElement *v4lelement,
- GstV4lTunerChannel *v4lchannel)
+gst_v4l_tuner_contains_channel (GstV4lElement * v4lelement,
+ GstV4lTunerChannel * v4lchannel)
{
const GList *item;
}
static const GList *
-gst_v4l_tuner_list_channels (GstTuner *tuner)
+gst_v4l_tuner_list_channels (GstTuner * tuner)
{
return GST_V4LELEMENT (tuner)->channels;
}
static void
-gst_v4l_tuner_set_channel (GstTuner *tuner,
- GstTunerChannel *channel)
+gst_v4l_tuner_set_channel (GstTuner * tuner, GstTunerChannel * channel)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (tuner);
GstV4lTunerChannel *v4lchannel = GST_V4L_TUNER_CHANNEL (channel);
}
static GstTunerChannel *
-gst_v4l_tuner_get_channel (GstTuner *tuner)
+gst_v4l_tuner_get_channel (GstTuner * tuner)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (tuner);
GList *item;
}
static gboolean
-gst_v4l_tuner_contains_norm (GstV4lElement *v4lelement,
- GstV4lTunerNorm *v4lnorm)
+gst_v4l_tuner_contains_norm (GstV4lElement * v4lelement,
+ GstV4lTunerNorm * v4lnorm)
{
const GList *item;
}
static const GList *
-gst_v4l_tuner_list_norms (GstTuner *tuner)
+gst_v4l_tuner_list_norms (GstTuner * tuner)
{
return GST_V4LELEMENT (tuner)->norms;
}
static void
-gst_v4l_tuner_set_norm (GstTuner *tuner,
- GstTunerNorm *norm)
+gst_v4l_tuner_set_norm (GstTuner * tuner, GstTunerNorm * norm)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (tuner);
GstV4lTunerNorm *v4lnorm = GST_V4L_TUNER_NORM (norm);
}
static GstTunerNorm *
-gst_v4l_tuner_get_norm (GstTuner *tuner)
+gst_v4l_tuner_get_norm (GstTuner * tuner)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (tuner);
GList *item;
}
static void
-gst_v4l_tuner_set_frequency (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency)
+gst_v4l_tuner_set_frequency (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (tuner);
- GstV4lTunerChannel *v4lchannel = GST_V4L_TUNER_CHANNEL(channel);
+ GstV4lTunerChannel *v4lchannel = GST_V4L_TUNER_CHANNEL (channel);
gint chan;
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L_IS_OPEN (v4lelement));
g_return_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY));
+ GST_TUNER_CHANNEL_FREQUENCY));
g_return_if_fail (gst_v4l_tuner_contains_channel (v4lelement, v4lchannel));
gst_v4l_get_chan_norm (v4lelement, &chan, NULL);
}
static gulong
-gst_v4l_tuner_get_frequency (GstTuner *tuner,
- GstTunerChannel *channel)
+gst_v4l_tuner_get_frequency (GstTuner * tuner, GstTunerChannel * channel)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (tuner);
- GstV4lTunerChannel *v4lchannel = GST_V4L_TUNER_CHANNEL(channel);
+ GstV4lTunerChannel *v4lchannel = GST_V4L_TUNER_CHANNEL (channel);
gint chan;
gulong frequency = 0;
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L_IS_OPEN (v4lelement), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l_tuner_contains_channel (v4lelement,
- v4lchannel), 0);
+ v4lchannel), 0);
gst_v4l_get_chan_norm (v4lelement, &chan, NULL);
if (chan == GST_V4L_TUNER_CHANNEL (channel)->index) {
}
static gint
-gst_v4l_tuner_signal_strength (GstTuner *tuner,
- GstTunerChannel *channel)
+gst_v4l_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (tuner);
- GstV4lTunerChannel *v4lchannel = GST_V4L_TUNER_CHANNEL(channel);
+ GstV4lTunerChannel *v4lchannel = GST_V4L_TUNER_CHANNEL (channel);
gint chan;
gint signal = 0;
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L_IS_OPEN (v4lelement), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l_tuner_contains_channel (v4lelement,
- v4lchannel), 0);
+ v4lchannel), 0);
gst_v4l_get_chan_norm (v4lelement, &chan, NULL);
if (chan == GST_V4L_TUNER_CHANNEL (channel)->index &&
#include <gst/tuner/tuner.h>
G_BEGIN_DECLS
-
#define GST_TYPE_V4L_TUNER_CHANNEL \
(gst_v4l_tuner_channel_get_type ())
#define GST_V4L_TUNER_CHANNEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L_TUNER_CHANNEL))
#define GST_IS_V4L_TUNER_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L_TUNER_CHANNEL))
-
-typedef struct _GstV4lTunerChannel {
+ typedef struct _GstV4lTunerChannel
+{
GstTunerChannel parent;
- gint index;
- gint tuner;
- gint audio;
+ gint index;
+ gint tuner;
+ gint audio;
} GstV4lTunerChannel;
-typedef struct _GstV4lTunerChannelClass {
+typedef struct _GstV4lTunerChannelClass
+{
GstTunerChannelClass parent;
} GstV4lTunerChannelClass;
#define GST_IS_V4L_TUNER_NORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L_TUNER_NORM))
-typedef struct _GstV4lTunerNorm {
+typedef struct _GstV4lTunerNorm
+{
GstTunerNorm parent;
- gint index;
+ gint index;
} GstV4lTunerNorm;
-typedef struct _GstV4lTunerNormClass {
+typedef struct _GstV4lTunerNormClass
+{
GstTunerNormClass parent;
} GstV4lTunerNormClass;
-GType gst_v4l_tuner_channel_get_type (void);
-GType gst_v4l_tuner_norm_get_type (void);
+GType gst_v4l_tuner_channel_get_type (void);
+GType gst_v4l_tuner_norm_get_type (void);
-void gst_v4l_tuner_interface_init (GstTunerClass *klass);
+void gst_v4l_tuner_interface_init (GstTunerClass * klass);
#endif /* __GST_V4L_TUNER_H__ */
#include "gstv4lelement.h"
#include "v4l_calls.h"
-static void gst_v4l_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id);
+static void gst_v4l_xoverlay_set_xwindow_id (GstXOverlay * overlay,
+ XID xwindow_id);
void
-gst_v4l_xoverlay_interface_init (GstXOverlayClass *klass)
+gst_v4l_xoverlay_interface_init (GstXOverlayClass * klass)
{
/* default virtual functions */
klass->set_xwindow_id = gst_v4l_xoverlay_set_xwindow_id;
}
GstXWindowListener *
-gst_v4l_xoverlay_new (GstV4lElement *v4lelement)
+gst_v4l_xoverlay_new (GstV4lElement * v4lelement)
{
- GstXWindowListener *xwin =
- gst_x_window_listener_new (NULL,
- (MapWindowFunc) gst_v4l_enable_overlay,
- (SetWindowFunc) gst_v4l_set_window,
- (gpointer) v4lelement);
+ GstXWindowListener *xwin = gst_x_window_listener_new (NULL,
+ (MapWindowFunc) gst_v4l_enable_overlay,
+ (SetWindowFunc) gst_v4l_set_window,
+ (gpointer) v4lelement);
v4lelement->overlay = xwin;
v4lelement->xwindow_id = 0;
}
void
-gst_v4l_xoverlay_free (GstV4lElement *v4lelement)
+gst_v4l_xoverlay_free (GstV4lElement * v4lelement)
{
gst_v4l_xoverlay_close (v4lelement);
g_object_unref (G_OBJECT (v4lelement->overlay));
}
void
-gst_v4l_xoverlay_open (GstV4lElement *v4lelement)
+gst_v4l_xoverlay_open (GstV4lElement * v4lelement)
{
GstXWindowListener *xwin = v4lelement->overlay;
xwin->display_name = g_strdup (v4lelement->display);
if (v4lelement->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4lelement->xwindow_id);
}
}
}
void
-gst_v4l_xoverlay_close (GstV4lElement *v4lelement)
+gst_v4l_xoverlay_close (GstV4lElement * v4lelement)
{
GstXWindowListener *xwin = v4lelement->overlay;
if (xwin != NULL) {
if (v4lelement->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
}
static void
-gst_v4l_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id)
+gst_v4l_xoverlay_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
{
GstV4lElement *v4lelement = GST_V4LELEMENT (overlay);
GstXWindowListener *xwin = v4lelement->overlay;
if (gst_element_get_state (GST_ELEMENT (v4lelement)) != GST_STATE_NULL &&
v4lelement->xwindow_id != 0 &&
- xwin && xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
if (gst_element_get_state (GST_ELEMENT (v4lelement)) != GST_STATE_NULL &&
v4lelement->xwindow_id != 0 &&
- xwin && xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4lelement->xwindow_id);
}
}
#include "gstv4lelement.h"
-G_BEGIN_DECLS
+G_BEGIN_DECLS void gst_v4l_xoverlay_interface_init (GstXOverlayClass * klass);
-void gst_v4l_xoverlay_interface_init (GstXOverlayClass *klass);
-
-GstXWindowListener *
- gst_v4l_xoverlay_new (GstV4lElement *v4lelement);
-void gst_v4l_xoverlay_free (GstV4lElement *v4lelement);
+GstXWindowListener *gst_v4l_xoverlay_new (GstV4lElement * v4lelement);
+void gst_v4l_xoverlay_free (GstV4lElement * v4lelement);
/* signal handlers */
-void gst_v4l_xoverlay_open (GstV4lElement *v4lelement);
-void gst_v4l_xoverlay_close (GstV4lElement *v4lelement);
+void gst_v4l_xoverlay_open (GstV4lElement * v4lelement);
+void gst_v4l_xoverlay_close (GstV4lElement * v4lelement);
#endif /* __GST_V4L_X_OVERLAY_H__ */
******************************************************/
gboolean
-gst_v4l_set_overlay (GstV4lElement *v4lelement)
+gst_v4l_set_overlay (GstV4lElement * v4lelement)
{
gchar *buff;
if (v4lelement->display)
- g_free(v4lelement->display);
- v4lelement->display = g_strdup(g_getenv("DISPLAY"));
+ g_free (v4lelement->display);
+ v4lelement->display = g_strdup (g_getenv ("DISPLAY"));
- DEBUG("setting display to '%s'", v4lelement->display);
- GST_V4L_CHECK_NOT_OPEN(v4lelement);
+ DEBUG ("setting display to '%s'", v4lelement->display);
+ GST_V4L_CHECK_NOT_OPEN (v4lelement);
if (!v4lelement->display || v4lelement->display[0] != ':')
return FALSE;
/* start v4l-conf */
- buff = g_strdup_printf("v4l-conf -q -c %s -d %s",
- v4lelement->videodev, v4lelement->display);
+ buff = g_strdup_printf ("v4l-conf -q -c %s -d %s",
+ v4lelement->videodev, v4lelement->display);
- switch (system(buff))
- {
+ switch (system (buff)) {
case -1:
GST_ELEMENT_ERROR (v4lelement, RESOURCE, FAILED,
- (_("Could not start v4l-conf.")), GST_ERROR_SYSTEM);
- g_free(buff);
+ (_("Could not start v4l-conf.")), GST_ERROR_SYSTEM);
+ g_free (buff);
return FALSE;
case 0:
break;
default:
GST_ELEMENT_ERROR (v4lelement, RESOURCE, FAILED,
- (_("Executing v4l-conf failed.")), GST_ERROR_SYSTEM);
- g_free(buff);
+ (_("Executing v4l-conf failed.")), GST_ERROR_SYSTEM);
+ g_free (buff);
return FALSE;
}
- g_free(buff);
+ g_free (buff);
return TRUE;
}
******************************************************/
gboolean
-gst_v4l_set_window (GstElement *element,
- gint x,
- gint y,
- gint w,
- gint h,
- struct video_clip *clips,
- gint num_clips)
+gst_v4l_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct video_clip * clips, gint num_clips)
{
- GstV4lElement *v4lelement = GST_V4LELEMENT(element);
+ GstV4lElement *v4lelement = GST_V4LELEMENT (element);
struct video_window vwin;
- DEBUG("setting video window to position (x,y/wxh) = %d,%d/%dx%d",
- x, y, w, h);
- GST_V4L_CHECK_OPEN(v4lelement);
- GST_V4L_CHECK_OVERLAY(v4lelement);
+ DEBUG ("setting video window to position (x,y/wxh) = %d,%d/%dx%d",
+ x, y, w, h);
+ GST_V4L_CHECK_OPEN (v4lelement);
+ GST_V4L_CHECK_OVERLAY (v4lelement);
vwin.x = x;
vwin.y = y;
vwin.height = h;
vwin.flags = 0;
- if (clips && !(v4lelement->vcap.type & VID_TYPE_CLIPPING))
- {
- DEBUG("Device \'%s\' doesn't do clipping",
- v4lelement->videodev?v4lelement->videodev:"/dev/video");
+ if (clips && !(v4lelement->vcap.type & VID_TYPE_CLIPPING)) {
+ DEBUG ("Device \'%s\' doesn't do clipping",
+ v4lelement->videodev ? v4lelement->videodev : "/dev/video");
vwin.clips = 0;
- }
- else
- {
+ } else {
vwin.clips = clips;
vwin.clipcount = num_clips;
}
- if (ioctl(v4lelement->video_fd, VIDIOCSWIN, &vwin) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCSWIN, &vwin) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to set the video window: %s", g_strerror (errno)));
+ ("Failed to set the video window: %s", g_strerror (errno)));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_enable_overlay (GstV4lElement *v4lelement,
- gboolean enable)
+gst_v4l_enable_overlay (GstV4lElement * v4lelement, gboolean enable)
{
- gint doit = enable?1:0;
+ gint doit = enable ? 1 : 0;
- DEBUG("%s overlay", enable?"enabling":"disabling");
- GST_V4L_CHECK_OPEN(v4lelement);
- GST_V4L_CHECK_OVERLAY(v4lelement);
+ DEBUG ("%s overlay", enable ? "enabling" : "disabling");
+ GST_V4L_CHECK_OPEN (v4lelement);
+ GST_V4L_CHECK_OVERLAY (v4lelement);
- if (ioctl(v4lelement->video_fd, VIDIOCCAPTURE, &doit) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCCAPTURE, &doit) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to %s overlay display: %s",
- enable?"enable":"disable", g_strerror (errno)));
+ ("Failed to %s overlay display: %s",
+ enable ? "enable" : "disable", g_strerror (errno)));
return FALSE;
}
******************************************************/
static gboolean
-gst_v4l_get_capabilities (GstV4lElement *v4lelement)
+gst_v4l_get_capabilities (GstV4lElement * v4lelement)
{
- DEBUG("getting capabilities");
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("getting capabilities");
+ GST_V4L_CHECK_OPEN (v4lelement);
- if (ioctl(v4lelement->video_fd, VIDIOCGCAP, &(v4lelement->vcap)) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGCAP, &(v4lelement->vcap)) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("error getting capabilities %s of from device %s",
- g_strerror (errno), v4lelement->videodev));
+ ("error getting capabilities %s of from device %s",
+ g_strerror (errno), v4lelement->videodev));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_open (GstV4lElement *v4lelement)
+gst_v4l_open (GstV4lElement * v4lelement)
{
int num;
- DEBUG("opening device %s", v4lelement->videodev);
- GST_V4L_CHECK_NOT_OPEN(v4lelement);
- GST_V4L_CHECK_NOT_ACTIVE(v4lelement);
+ DEBUG ("opening device %s", v4lelement->videodev);
+ GST_V4L_CHECK_NOT_OPEN (v4lelement);
+ GST_V4L_CHECK_NOT_ACTIVE (v4lelement);
/* be sure we have a device */
if (!v4lelement->videodev) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, NOT_FOUND,
- (_("No device specified.")), (NULL));
+ (_("No device specified.")), (NULL));
return FALSE;
}
/* open the device */
- v4lelement->video_fd = open(v4lelement->videodev, O_RDWR);
- if (!GST_V4L_IS_OPEN(v4lelement))
- {
+ v4lelement->video_fd = open (v4lelement->videodev, O_RDWR);
+ if (!GST_V4L_IS_OPEN (v4lelement)) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, OPEN_READ_WRITE,
- (_("Could not open device \"%s\" for reading and writing."), v4lelement->videodev),
- GST_ERROR_SYSTEM);
+ (_("Could not open device \"%s\" for reading and writing."),
+ v4lelement->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
/* get capabilities */
- if (!gst_v4l_get_capabilities(v4lelement))
- {
- close(v4lelement->video_fd);
+ if (!gst_v4l_get_capabilities (v4lelement)) {
+ close (v4lelement->video_fd);
v4lelement->video_fd = -1;
return FALSE;
}
/* device type check */
- if ((GST_IS_V4LSRC(v4lelement) &&
- !(v4lelement->vcap.type & VID_TYPE_CAPTURE)) ||
- (GST_IS_V4LMJPEGSRC(v4lelement) &&
- !(v4lelement->vcap.type & VID_TYPE_MJPEG_ENCODER)) ||
- (GST_IS_V4LMJPEGSINK(v4lelement) &&
- !(v4lelement->vcap.type & VID_TYPE_MJPEG_DECODER))) {
+ if ((GST_IS_V4LSRC (v4lelement) &&
+ !(v4lelement->vcap.type & VID_TYPE_CAPTURE)) ||
+ (GST_IS_V4LMJPEGSRC (v4lelement) &&
+ !(v4lelement->vcap.type & VID_TYPE_MJPEG_ENCODER)) ||
+ (GST_IS_V4LMJPEGSINK (v4lelement) &&
+ !(v4lelement->vcap.type & VID_TYPE_MJPEG_DECODER))) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Device opened, but wrong type (0x%x)",
- v4lelement->vcap.type));
- close(v4lelement->video_fd);
+ ("Device opened, but wrong type (0x%x)", v4lelement->vcap.type));
+ close (v4lelement->video_fd);
v4lelement->video_fd = -1;
return FALSE;
}
- gst_info("Opened device \'%s\' (\'%s\') successfully\n",
- v4lelement->vcap.name, v4lelement->videodev);
+ gst_info ("Opened device \'%s\' (\'%s\') successfully\n",
+ v4lelement->vcap.name, v4lelement->videodev);
/* norms + inputs, for the tuner interface */
- for (num=0;norm_name[num]!=NULL;num++) {
+ for (num = 0; norm_name[num] != NULL; num++) {
GstV4lTunerNorm *v4lnorm = g_object_new (GST_TYPE_V4L_TUNER_NORM,
- NULL);
+ NULL);
GstTunerNorm *norm = GST_TUNER_NORM (v4lnorm);
norm->label = g_strdup (norm_name[num]);
- norm->fps = (num == 1) ? (30000./1001) : 25.;
+ norm->fps = (num == 1) ? (30000. / 1001) : 25.;
v4lnorm->index = num;
- v4lelement->norms = g_list_append(v4lelement->norms,
- (gpointer) norm);
+ v4lelement->norms = g_list_append (v4lelement->norms, (gpointer) norm);
}
- v4lelement->channels = gst_v4l_get_chan_names(v4lelement);
+ v4lelement->channels = gst_v4l_get_chan_names (v4lelement);
- for (num=0;picture_name[num]!=NULL;num++)
- {
+ for (num = 0; picture_name[num] != NULL; num++) {
GstV4lColorBalanceChannel *v4lchannel =
g_object_new (GST_TYPE_V4L_COLOR_BALANCE_CHANNEL, NULL);
GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (v4lchannel);
+
channel->label = g_strdup (picture_name[num]);
channel->min_value = 0;
channel->max_value = 65535;
v4lchannel->index = num;
- v4lelement->colors = g_list_append(v4lelement->colors, channel);
+ v4lelement->colors = g_list_append (v4lelement->colors, channel);
}
- DEBUG("Setting default norm/input");
+ DEBUG ("Setting default norm/input");
gst_v4l_set_chan_norm (v4lelement, 0, 0);
return TRUE;
******************************************************/
gboolean
-gst_v4l_close (GstV4lElement *v4lelement)
+gst_v4l_close (GstV4lElement * v4lelement)
{
- DEBUG("closing device");
- GST_V4L_CHECK_OPEN(v4lelement);
- GST_V4L_CHECK_NOT_ACTIVE(v4lelement);
+ DEBUG ("closing device");
+ GST_V4L_CHECK_OPEN (v4lelement);
+ GST_V4L_CHECK_NOT_ACTIVE (v4lelement);
- close(v4lelement->video_fd);
+ close (v4lelement->video_fd);
v4lelement->video_fd = -1;
g_list_foreach (v4lelement->channels, (GFunc) g_object_unref, NULL);
******************************************************/
gint
-gst_v4l_get_num_chans (GstV4lElement *v4lelement)
+gst_v4l_get_num_chans (GstV4lElement * v4lelement)
{
- DEBUG("getting number of channels");
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("getting number of channels");
+ GST_V4L_CHECK_OPEN (v4lelement);
return v4lelement->vcap.channels;
}
******************************************************/
GList *
-gst_v4l_get_chan_names (GstV4lElement *v4lelement)
+gst_v4l_get_chan_names (GstV4lElement * v4lelement)
{
struct video_channel vchan;
const GList *pads = gst_element_get_pad_list (GST_ELEMENT (v4lelement));
GList *list = NULL;
gint i;
- DEBUG("getting channel names");
+ DEBUG ("getting channel names");
- if (!GST_V4L_IS_OPEN(v4lelement))
+ if (!GST_V4L_IS_OPEN (v4lelement))
return NULL;
/* sinks don't have inputs in v4l */
if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SINK)
return NULL;
- for (i=0;i<gst_v4l_get_num_chans(v4lelement);i++)
- {
+ for (i = 0; i < gst_v4l_get_num_chans (v4lelement); i++) {
GstV4lTunerChannel *v4lchannel = g_object_new (GST_TYPE_V4L_TUNER_CHANNEL,
- NULL);
+ NULL);
GstTunerChannel *channel = GST_TUNER_CHANNEL (v4lchannel);
vchan.channel = i;
- if (ioctl(v4lelement->video_fd, VIDIOCGCHAN, &vchan) < 0)
- return NULL; /* memleak... */
+ if (ioctl (v4lelement->video_fd, VIDIOCGCHAN, &vchan) < 0)
+ return NULL; /* memleak... */
channel->label = g_strdup (vchan.name);
channel->flags = GST_TUNER_CHANNEL_INPUT;
v4lchannel->index = i;
struct video_tuner vtun;
gint n;
- for (n = 0; ; n++) {
- vtun.tuner = n;
- if (ioctl(v4lelement->video_fd, VIDIOCGTUNER, &vtun) < 0)
- break; /* no more tuners */
- if (!strcmp(vtun.name, vchan.name)) {
- v4lchannel->tuner = n;
- channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
- channel->min_frequency = vtun.rangelow;
- channel->max_frequency = vtun.rangehigh;
- channel->min_signal = 0;
- channel->max_signal = 0xffff;
- break;
- }
+ for (n = 0;; n++) {
+ vtun.tuner = n;
+ if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &vtun) < 0)
+ break; /* no more tuners */
+ if (!strcmp (vtun.name, vchan.name)) {
+ v4lchannel->tuner = n;
+ channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
+ channel->min_frequency = vtun.rangelow;
+ channel->max_frequency = vtun.rangehigh;
+ channel->min_signal = 0;
+ channel->max_signal = 0xffff;
+ break;
+ }
}
}
if (vchan.flags & VIDEO_VC_AUDIO) {
gint n;
for (n = 0; n < v4lelement->vcap.audios; n++) {
- vaud.audio = n;
- if (ioctl(v4lelement->video_fd, VIDIOCGAUDIO, &vaud) < 0)
- continue;
- if (!strcmp(vaud.name, vchan.name)) {
- v4lchannel->audio = n;
- channel->flags |= GST_TUNER_CHANNEL_AUDIO;
- break;
- }
+ vaud.audio = n;
+ if (ioctl (v4lelement->video_fd, VIDIOCGAUDIO, &vaud) < 0)
+ continue;
+ if (!strcmp (vaud.name, vchan.name)) {
+ v4lchannel->audio = n;
+ channel->flags |= GST_TUNER_CHANNEL_AUDIO;
+ break;
+ }
}
}
- list = g_list_append(list, (gpointer) channel);
+ list = g_list_append (list, (gpointer) channel);
}
return list;
******************************************************/
gboolean
-gst_v4l_get_chan_norm (GstV4lElement *v4lelement,
- gint *channel,
- gint *norm)
+gst_v4l_get_chan_norm (GstV4lElement * v4lelement, gint * channel, gint * norm)
{
- DEBUG("getting current channel and norm");
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("getting current channel and norm");
+ GST_V4L_CHECK_OPEN (v4lelement);
if (channel)
*channel = v4lelement->vchan.channel;
******************************************************/
gboolean
-gst_v4l_set_chan_norm (GstV4lElement *v4lelement,
- gint channel,
- gint norm)
+gst_v4l_set_chan_norm (GstV4lElement * v4lelement, gint channel, gint norm)
{
- DEBUG("setting channel = %d, norm = %d (%s)",
- channel, norm, norm_name[norm]);
- GST_V4L_CHECK_OPEN(v4lelement);
- GST_V4L_CHECK_NOT_ACTIVE(v4lelement);
+ DEBUG ("setting channel = %d, norm = %d (%s)",
+ channel, norm, norm_name[norm]);
+ GST_V4L_CHECK_OPEN (v4lelement);
+ GST_V4L_CHECK_NOT_ACTIVE (v4lelement);
v4lelement->vchan.channel = channel;
v4lelement->vchan.norm = norm;
- if (ioctl(v4lelement->video_fd, VIDIOCSCHAN, &(v4lelement->vchan)) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCSCHAN, &(v4lelement->vchan)) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error setting the channel/norm settings: %s",
- g_strerror(errno)));
+ ("Error setting the channel/norm settings: %s", g_strerror (errno)));
return FALSE;
}
- if (ioctl(v4lelement->video_fd, VIDIOCGCHAN, &(v4lelement->vchan)) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGCHAN, &(v4lelement->vchan)) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting the channel/norm settings: %s",
- g_strerror(errno)));
+ ("Error getting the channel/norm settings: %s", g_strerror (errno)));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_get_signal (GstV4lElement *v4lelement,
- gint tunernum,
- guint *signal)
+gst_v4l_get_signal (GstV4lElement * v4lelement, gint tunernum, guint * signal)
{
struct video_tuner tuner;
- DEBUG("getting tuner signal");
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("getting tuner signal");
+ GST_V4L_CHECK_OPEN (v4lelement);
tuner.tuner = tunernum;
- if (ioctl(v4lelement->video_fd, VIDIOCGTUNER, &tuner) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &tuner) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting tuner signal: %s", g_strerror (errno)));
+ ("Error getting tuner signal: %s", g_strerror (errno)));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_get_frequency (GstV4lElement *v4lelement,
- gint tunernum,
- gulong *frequency)
+gst_v4l_get_frequency (GstV4lElement * v4lelement,
+ gint tunernum, gulong * frequency)
{
struct video_tuner vtun;
- DEBUG("getting tuner frequency");
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("getting tuner frequency");
+ GST_V4L_CHECK_OPEN (v4lelement);
/* check that this is the current input */
vtun.tuner = tunernum;
if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &vtun) < 0)
return FALSE;
- if (strcmp(vtun.name, v4lelement->vchan.name))
+ if (strcmp (vtun.name, v4lelement->vchan.name))
return FALSE;
- if (ioctl(v4lelement->video_fd, VIDIOCGFREQ, frequency) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGFREQ, frequency) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting tuner frequency: %s", g_strerror (errno)));
+ ("Error getting tuner frequency: %s", g_strerror (errno)));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_set_frequency (GstV4lElement *v4lelement,
- gint tunernum,
- gulong frequency)
+gst_v4l_set_frequency (GstV4lElement * v4lelement,
+ gint tunernum, gulong frequency)
{
struct video_tuner vtun;
- DEBUG("setting tuner frequency to %lu", frequency);
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("setting tuner frequency to %lu", frequency);
+ GST_V4L_CHECK_OPEN (v4lelement);
/* check that this is the current input */
vtun.tuner = tunernum;
if (ioctl (v4lelement->video_fd, VIDIOCGTUNER, &vtun) < 0)
return FALSE;
- if (strcmp(vtun.name, v4lelement->vchan.name))
+ if (strcmp (vtun.name, v4lelement->vchan.name))
return FALSE;
- if (ioctl(v4lelement->video_fd, VIDIOCSFREQ, &frequency) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCSFREQ, &frequency) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error setting tuner frequency: %s", g_strerror (errno)));
+ ("Error setting tuner frequency: %s", g_strerror (errno)));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_get_picture (GstV4lElement *v4lelement,
- GstV4lPictureType type,
- gint *value)
+gst_v4l_get_picture (GstV4lElement * v4lelement,
+ GstV4lPictureType type, gint * value)
{
struct video_picture vpic;
- DEBUG("getting picture property type %d (%s)",
- type, picture_name[type]);
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("getting picture property type %d (%s)", type, picture_name[type]);
+ GST_V4L_CHECK_OPEN (v4lelement);
- if (ioctl(v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting picture parameters: %s", g_strerror (errno)));
+ ("Error getting picture parameters: %s", g_strerror (errno)));
return FALSE;
}
- switch (type)
- {
+ switch (type) {
case V4L_PICTURE_HUE:
*value = vpic.hue;
break;
break;
default:
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting picture parameters: unknown type %d", type));
+ ("Error getting picture parameters: unknown type %d", type));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_set_picture (GstV4lElement *v4lelement,
- GstV4lPictureType type,
- gint value)
+gst_v4l_set_picture (GstV4lElement * v4lelement,
+ GstV4lPictureType type, gint value)
{
struct video_picture vpic;
- DEBUG("setting picture type %d (%s) to value %d",
- type, picture_name[type], value);
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("setting picture type %d (%s) to value %d",
+ type, picture_name[type], value);
+ GST_V4L_CHECK_OPEN (v4lelement);
- if (ioctl(v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGPICT, &vpic) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting picture parameters: %s", g_strerror (errno)));
+ ("Error getting picture parameters: %s", g_strerror (errno)));
return FALSE;
}
- switch (type)
- {
+ switch (type) {
case V4L_PICTURE_HUE:
vpic.hue = value;
break;
break;
default:
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error setting picture parameters: unknown type %d", type));
+ ("Error setting picture parameters: unknown type %d", type));
return FALSE;
}
- if (ioctl(v4lelement->video_fd, VIDIOCSPICT, &vpic) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCSPICT, &vpic) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error setting picture parameters: %s", g_strerror (errno)));
+ ("Error setting picture parameters: %s", g_strerror (errno)));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_get_audio (GstV4lElement *v4lelement,
- gint audionum,
- GstV4lAudioType type,
- gint *value)
+gst_v4l_get_audio (GstV4lElement * v4lelement,
+ gint audionum, GstV4lAudioType type, gint * value)
{
struct video_audio vau;
- DEBUG("getting audio parameter type %d (%s)",
- type, audio_name[type]);
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("getting audio parameter type %d (%s)", type, audio_name[type]);
+ GST_V4L_CHECK_OPEN (v4lelement);
vau.audio = audionum;
- if (ioctl(v4lelement->video_fd, VIDIOCGAUDIO, &vau) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGAUDIO, &vau) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting audio parameters: %s", g_strerror (errno)));
+ ("Error getting audio parameters: %s", g_strerror (errno)));
return FALSE;
}
- switch (type)
- {
+ switch (type) {
case V4L_AUDIO_MUTE:
*value = (vau.flags & VIDEO_AUDIO_MUTE);
break;
*value = vau.mode;
break;
default:
- GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting audio parameters: unknown type %d", type));
+ GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
+ ("Error getting audio parameters: unknown type %d", type));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l_set_audio (GstV4lElement *v4lelement,
- gint audionum,
- GstV4lAudioType type,
- gint value)
+gst_v4l_set_audio (GstV4lElement * v4lelement,
+ gint audionum, GstV4lAudioType type, gint value)
{
struct video_audio vau;
- DEBUG("setting audio parameter type %d (%s) to value %d",
- type, audio_name[type], value);
- GST_V4L_CHECK_OPEN(v4lelement);
+ DEBUG ("setting audio parameter type %d (%s) to value %d",
+ type, audio_name[type], value);
+ GST_V4L_CHECK_OPEN (v4lelement);
vau.audio = audionum;
- if (ioctl(v4lelement->video_fd, VIDIOCGAUDIO, &vau) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCGAUDIO, &vau) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error getting audio parameters: %s", g_strerror (errno)));
+ ("Error getting audio parameters: %s", g_strerror (errno)));
return FALSE;
}
- switch (type)
- {
+ switch (type) {
case V4L_AUDIO_MUTE:
- if (!(vau.flags & VIDEO_AUDIO_MUTABLE))
- {
- GST_ELEMENT_ERROR (v4lelement, CORE, NOT_IMPLEMENTED, (NULL),
- ("Error setting audio mute: (un)setting mute is not supported"));
- return FALSE;
+ if (!(vau.flags & VIDEO_AUDIO_MUTABLE)) {
+ GST_ELEMENT_ERROR (v4lelement, CORE, NOT_IMPLEMENTED, (NULL),
+ ("Error setting audio mute: (un)setting mute is not supported"));
+ return FALSE;
}
if (value)
- vau.flags |= VIDEO_AUDIO_MUTE;
+ vau.flags |= VIDEO_AUDIO_MUTE;
else
- vau.flags &= ~VIDEO_AUDIO_MUTE;
+ vau.flags &= ~VIDEO_AUDIO_MUTE;
break;
case V4L_AUDIO_VOLUME:
- if (!(vau.flags & VIDEO_AUDIO_VOLUME))
- {
- GST_ELEMENT_ERROR (v4lelement, CORE, NOT_IMPLEMENTED, (NULL),
- ("Error setting audio volume: setting volume is not supported"));
- return FALSE;
+ if (!(vau.flags & VIDEO_AUDIO_VOLUME)) {
+ GST_ELEMENT_ERROR (v4lelement, CORE, NOT_IMPLEMENTED, (NULL),
+ ("Error setting audio volume: setting volume is not supported"));
+ return FALSE;
}
vau.volume = value;
break;
break;
default:
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error setting audio parameters: unknown type %d", type));
+ ("Error setting audio parameters: unknown type %d", type));
return FALSE;
}
- if (ioctl(v4lelement->video_fd, VIDIOCSAUDIO, &vau) < 0)
- {
+ if (ioctl (v4lelement->video_fd, VIDIOCSAUDIO, &vau) < 0) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
- ("Error setting audio parameters: %s", g_strerror (errno)));
+ ("Error setting audio parameters: %s", g_strerror (errno)));
return FALSE;
}
#include "gst/gst-i18n-plugin.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/* simple check whether the device is open */
}
-typedef enum {
- V4L_PICTURE_HUE = 0,
- V4L_PICTURE_BRIGHTNESS,
- V4L_PICTURE_CONTRAST,
- V4L_PICTURE_SATURATION,
-} GstV4lPictureType;
+ typedef enum
+ {
+ V4L_PICTURE_HUE = 0,
+ V4L_PICTURE_BRIGHTNESS,
+ V4L_PICTURE_CONTRAST,
+ V4L_PICTURE_SATURATION,
+ } GstV4lPictureType;
-typedef enum {
- V4L_AUDIO_VOLUME = 0,
- V4L_AUDIO_MUTE,
- V4L_AUDIO_MODE, /* stereo, mono, ... (see videodev.h) */
-} GstV4lAudioType;
+ typedef enum
+ {
+ V4L_AUDIO_VOLUME = 0,
+ V4L_AUDIO_MUTE,
+ V4L_AUDIO_MODE, /* stereo, mono, ... (see videodev.h) */
+ } GstV4lAudioType;
/* open/close the device */
-gboolean gst_v4l_open (GstV4lElement *v4lelement);
-gboolean gst_v4l_close (GstV4lElement *v4lelement);
+ gboolean gst_v4l_open (GstV4lElement * v4lelement);
+ gboolean gst_v4l_close (GstV4lElement * v4lelement);
/* norm control (norm = VIDEO_MODE_{PAL|NTSC|SECAM|AUTO}) */
-gboolean gst_v4l_get_chan_norm (GstV4lElement *v4lelement,
- gint *channel,
- gint *norm);
-gboolean gst_v4l_set_chan_norm (GstV4lElement *v4lelement,
- gint channel,
- gint norm);
-GList *gst_v4l_get_chan_names (GstV4lElement *v4lelement);
+ gboolean gst_v4l_get_chan_norm (GstV4lElement * v4lelement,
+ gint * channel, gint * norm);
+ gboolean gst_v4l_set_chan_norm (GstV4lElement * v4lelement,
+ gint channel, gint norm);
+ GList *gst_v4l_get_chan_names (GstV4lElement * v4lelement);
/* frequency control */
-gboolean gst_v4l_get_signal (GstV4lElement *v4lelement,
- gint tunernum,
- guint *signal);
-gboolean gst_v4l_get_frequency (GstV4lElement *v4lelement,
- gint tunernum,
- gulong *frequency);
-gboolean gst_v4l_set_frequency (GstV4lElement *v4lelement,
- gint tunernum,
- gulong frequency);
+ gboolean gst_v4l_get_signal (GstV4lElement * v4lelement,
+ gint tunernum, guint * signal);
+ gboolean gst_v4l_get_frequency (GstV4lElement * v4lelement,
+ gint tunernum, gulong * frequency);
+ gboolean gst_v4l_set_frequency (GstV4lElement * v4lelement,
+ gint tunernum, gulong frequency);
/* picture control */
-gboolean gst_v4l_get_picture (GstV4lElement *v4lelement,
- GstV4lPictureType type,
- gint *value);
-gboolean gst_v4l_set_picture (GstV4lElement *v4lelement,
- GstV4lPictureType type,
- gint value);
+ gboolean gst_v4l_get_picture (GstV4lElement * v4lelement,
+ GstV4lPictureType type, gint * value);
+ gboolean gst_v4l_set_picture (GstV4lElement * v4lelement,
+ GstV4lPictureType type, gint value);
/* audio control */
-gboolean gst_v4l_get_audio (GstV4lElement *v4lelement,
- gint audionum,
- GstV4lAudioType type,
- gint *value);
-gboolean gst_v4l_set_audio (GstV4lElement *v4lelement,
- gint audionum,
- GstV4lAudioType type,
- gint value);
+ gboolean gst_v4l_get_audio (GstV4lElement * v4lelement,
+ gint audionum, GstV4lAudioType type, gint * value);
+ gboolean gst_v4l_set_audio (GstV4lElement * v4lelement,
+ gint audionum, GstV4lAudioType type, gint value);
/* overlay */
-gboolean gst_v4l_set_overlay (GstV4lElement *v4lelement);
-gboolean gst_v4l_set_window (GstElement *element,
- gint x, gint y,
- gint w, gint h,
- struct video_clip *clips,
- gint num_clips);
-gboolean gst_v4l_enable_overlay (GstV4lElement *v4lelement,
- gboolean enable);
+ gboolean gst_v4l_set_overlay (GstV4lElement * v4lelement);
+ gboolean gst_v4l_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct video_clip *clips, gint num_clips);
+ gboolean gst_v4l_enable_overlay (GstV4lElement * v4lelement, gboolean enable);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __V4L_CALLS_H__ */
+#endif /* __V4L_CALLS_H__ */
static void *
gst_v4lmjpegsink_sync_thread (void *arg)
{
- GstV4lMjpegSink *v4lmjpegsink = GST_V4LMJPEGSINK(arg);
- gint frame = 0; /* frame that we're currently syncing on */
+ GstV4lMjpegSink *v4lmjpegsink = GST_V4LMJPEGSINK (arg);
+ gint frame = 0; /* frame that we're currently syncing on */
- DEBUG("starting sync thread");
+ DEBUG ("starting sync thread");
#if 0
/* Allow easy shutting down by other processes... */
- pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL );
- pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NULL );
+ pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
+ pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
#endif
- while (1)
- {
- g_mutex_lock(v4lmjpegsink->mutex_queued_frames);
- if (!v4lmjpegsink->isqueued_queued_frames[frame])
- {
- g_cond_wait(v4lmjpegsink->cond_queued_frames[frame],
- v4lmjpegsink->mutex_queued_frames);
+ while (1) {
+ g_mutex_lock (v4lmjpegsink->mutex_queued_frames);
+ if (!v4lmjpegsink->isqueued_queued_frames[frame]) {
+ g_cond_wait (v4lmjpegsink->cond_queued_frames[frame],
+ v4lmjpegsink->mutex_queued_frames);
}
- if (v4lmjpegsink->isqueued_queued_frames[frame] != 1)
- {
- g_mutex_unlock(v4lmjpegsink->mutex_queued_frames);
+ if (v4lmjpegsink->isqueued_queued_frames[frame] != 1) {
+ g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
goto end;
}
- g_mutex_unlock(v4lmjpegsink->mutex_queued_frames);
+ g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
- DEBUG("thread-syncing on next frame");
- if (ioctl(GST_V4LELEMENT(v4lmjpegsink)->video_fd, MJPIOC_SYNC,
- &(v4lmjpegsink->bsync)) < 0)
- {
+ DEBUG ("thread-syncing on next frame");
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsink)->video_fd, MJPIOC_SYNC,
+ &(v4lmjpegsink->bsync)) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, SYNC, (NULL),
- ("Failed to sync on frame %d: %s",
- frame, g_strerror (errno)));
- g_mutex_lock(v4lmjpegsink->mutex_queued_frames);
+ ("Failed to sync on frame %d: %s", frame, g_strerror (errno)));
+ g_mutex_lock (v4lmjpegsink->mutex_queued_frames);
v4lmjpegsink->isqueued_queued_frames[frame] = -1;
- g_cond_broadcast(v4lmjpegsink->cond_queued_frames[frame]);
- g_mutex_unlock(v4lmjpegsink->mutex_queued_frames);
+ g_cond_broadcast (v4lmjpegsink->cond_queued_frames[frame]);
+ g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
goto end;
- }
- else
- {
+ } else {
/* be sure that we're not confusing */
- if (frame != v4lmjpegsink->bsync.frame)
- {
- GST_ELEMENT_ERROR (v4lmjpegsink, CORE, TOO_LAZY, (NULL),
- ("Internal error: frame number confusion"));
- goto end;
+ if (frame != v4lmjpegsink->bsync.frame) {
+ GST_ELEMENT_ERROR (v4lmjpegsink, CORE, TOO_LAZY, (NULL),
+ ("Internal error: frame number confusion"));
+ goto end;
}
- g_mutex_lock(v4lmjpegsink->mutex_queued_frames);
+ g_mutex_lock (v4lmjpegsink->mutex_queued_frames);
v4lmjpegsink->isqueued_queued_frames[frame] = 0;
- g_cond_broadcast(v4lmjpegsink->cond_queued_frames[frame]);
- g_mutex_unlock(v4lmjpegsink->mutex_queued_frames);
+ g_cond_broadcast (v4lmjpegsink->cond_queued_frames[frame]);
+ g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
}
- frame = (frame+1)%v4lmjpegsink->breq.count;
+ frame = (frame + 1) % v4lmjpegsink->breq.count;
}
end:
- DEBUG("Sync thread got signalled to exit");
- g_thread_exit(NULL);
+ DEBUG ("Sync thread got signalled to exit");
+ g_thread_exit (NULL);
return NULL;
}
******************************************************/
static gboolean
-gst_v4lmjpegsink_queue_frame (GstV4lMjpegSink *v4lmjpegsink,
- gint num)
+gst_v4lmjpegsink_queue_frame (GstV4lMjpegSink * v4lmjpegsink, gint num)
{
- DEBUG("queueing frame %d", num);
+ DEBUG ("queueing frame %d", num);
/* queue on this frame */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsink)->video_fd, MJPIOC_QBUF_PLAY, &num) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsink)->video_fd, MJPIOC_QBUF_PLAY,
+ &num) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, WRITE, (NULL),
- ("Failed to queue frame %d: %s",
- num, g_strerror(errno)));
+ ("Failed to queue frame %d: %s", num, g_strerror (errno)));
return FALSE;
}
- g_mutex_lock(v4lmjpegsink->mutex_queued_frames);
+ g_mutex_lock (v4lmjpegsink->mutex_queued_frames);
v4lmjpegsink->isqueued_queued_frames[num] = 1;
- g_cond_broadcast(v4lmjpegsink->cond_queued_frames[num]);
- g_mutex_unlock(v4lmjpegsink->mutex_queued_frames);
+ g_cond_broadcast (v4lmjpegsink->cond_queued_frames[num]);
+ g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
return TRUE;
}
******************************************************/
static gboolean
-gst_v4lmjpegsink_sync_frame (GstV4lMjpegSink *v4lmjpegsink,
- gint *num)
+gst_v4lmjpegsink_sync_frame (GstV4lMjpegSink * v4lmjpegsink, gint * num)
{
- DEBUG("syncing on next frame");
+ DEBUG ("syncing on next frame");
/* calculate next frame */
- v4lmjpegsink->current_frame = (v4lmjpegsink->current_frame+1)%v4lmjpegsink->breq.count;
+ v4lmjpegsink->current_frame =
+ (v4lmjpegsink->current_frame + 1) % v4lmjpegsink->breq.count;
*num = v4lmjpegsink->current_frame;
- g_mutex_lock(v4lmjpegsink->mutex_queued_frames);
- if (v4lmjpegsink->isqueued_queued_frames[*num] == 1)
- {
- g_cond_wait(v4lmjpegsink->cond_queued_frames[*num],
- v4lmjpegsink->mutex_queued_frames);
+ g_mutex_lock (v4lmjpegsink->mutex_queued_frames);
+ if (v4lmjpegsink->isqueued_queued_frames[*num] == 1) {
+ g_cond_wait (v4lmjpegsink->cond_queued_frames[*num],
+ v4lmjpegsink->mutex_queued_frames);
}
- if (v4lmjpegsink->isqueued_queued_frames[*num] != 0)
- {
- g_mutex_unlock(v4lmjpegsink->mutex_queued_frames);
+ if (v4lmjpegsink->isqueued_queued_frames[*num] != 0) {
+ g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
return FALSE;
- }
- else
- g_mutex_unlock(v4lmjpegsink->mutex_queued_frames);
+ } else
+ g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lmjpegsink_set_buffer (GstV4lMjpegSink *v4lmjpegsink,
- gint numbufs,
- gint bufsize)
+gst_v4lmjpegsink_set_buffer (GstV4lMjpegSink * v4lmjpegsink,
+ gint numbufs, gint bufsize)
{
- DEBUG("setting buffer info to numbufs = %d, bufsize = %d KB",
- numbufs, bufsize);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG ("setting buffer info to numbufs = %d, bufsize = %d KB",
+ numbufs, bufsize);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
v4lmjpegsink->breq.size = bufsize * 1024;
v4lmjpegsink->breq.count = numbufs;
******************************************************/
gboolean
-gst_v4lmjpegsink_set_playback (GstV4lMjpegSink *v4lmjpegsink,
- gint width,
- gint height,
- gint x_offset,
- gint y_offset,
- gint norm,
- gint interlacing)
+gst_v4lmjpegsink_set_playback (GstV4lMjpegSink * v4lmjpegsink,
+ gint width,
+ gint height, gint x_offset, gint y_offset, gint norm, gint interlacing)
{
gint mw, mh;
struct mjpeg_params bparm;
- DEBUG("setting size = %dx%d, X/Y-offsets = %d/%d, norm = %d, interlacing = %d\n",
- width, height, x_offset, y_offset, norm, interlacing);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG
+ ("setting size = %dx%d, X/Y-offsets = %d/%d, norm = %d, interlacing = %d\n",
+ width, height, x_offset, y_offset, norm, interlacing);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
/*GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsink)->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
- {
- GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, SETTINGS, (NULL), GST_ERROR_SYSTEM);
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsink)->video_fd, MJPIOC_G_PARAMS,
+ &bparm) < 0) {
+ GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, SETTINGS, (NULL),
+ GST_ERROR_SYSTEM);
return FALSE;
}
bparm.input = 0;
bparm.norm = norm;
- bparm.decimation = 0; /* we'll set proper values later on */
+ bparm.decimation = 0; /* we'll set proper values later on */
/* maxwidth is broken on marvel cards */
- mw = GST_V4LELEMENT(v4lmjpegsink)->vcap.maxwidth;
+ mw = GST_V4LELEMENT (v4lmjpegsink)->vcap.maxwidth;
if (mw != 768 && mw != 640)
mw = 720;
- mh = (norm==VIDEO_MODE_NTSC?480:576);
+ mh = (norm == VIDEO_MODE_NTSC ? 480 : 576);
- if (width > mw || height > mh)
- {
+ if (width > mw || height > mh) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, TOO_LAZY, (NULL),
- ("Video dimensions (%dx%d) are larger than device max (%dx%d)",
- width, height, mw, mh));
+ ("Video dimensions (%dx%d) are larger than device max (%dx%d)",
+ width, height, mw, mh));
return FALSE;
}
- if (width <= mw/4)
+ if (width <= mw / 4)
bparm.HorDcm = 4;
- else if (width <= mw/2)
+ else if (width <= mw / 2)
bparm.HorDcm = 2;
else
bparm.HorDcm = 1;
/* TODO: add proper interlacing handling */
#if 0
- if (interlacing != INTERLACING_NOT_INTERLACED)
- {
+ if (interlacing != INTERLACING_NOT_INTERLACED) {
bparm.field_per_buff = 2;
bparm.TmpDcm = 1;
- if (height <= mh/2)
+ if (height <= mh / 2)
bparm.VerDcm = 2;
else
bparm.VerDcm = 1;
- }
- else
+ } else
#endif
{
- if (height > mh/2)
- {
- GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, TOO_LAZY, (NULL),
- ("Video dimensions (%dx%d) too large for non-interlaced playback (%dx%d)",
- width, height, mw, mh/2));
+ if (height > mh / 2) {
+ GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, TOO_LAZY, (NULL),
+ ("Video dimensions (%dx%d) too large for non-interlaced playback (%dx%d)",
+ width, height, mw, mh / 2));
return FALSE;
}
bparm.field_per_buff = 1;
bparm.TmpDcm = 2;
- if (height <= mh/4)
+ if (height <= mh / 4)
bparm.VerDcm = 2;
else
bparm.VerDcm = 1;
/* TODO: add proper interlacing handling */
#if 0
- bparm.odd_even = (interlacing==INTERLACING_TOP_FIRST);
+ bparm.odd_even = (interlacing == INTERLACING_TOP_FIRST);
#endif
bparm.quality = 100;
- bparm.img_width = bparm.HorDcm * width;
- bparm.img_height = bparm.VerDcm * height/bparm.field_per_buff;
+ bparm.img_width = bparm.HorDcm * width;
+ bparm.img_height = bparm.VerDcm * height / bparm.field_per_buff;
/* image X/Y offset on device */
if (x_offset < 0)
- bparm.img_x = (mw - bparm.img_width)/2;
- else
- {
+ bparm.img_x = (mw - bparm.img_width) / 2;
+ else {
if (x_offset + bparm.img_width > mw)
bparm.img_x = mw - bparm.img_width;
else
}
if (y_offset < 0)
- bparm.img_y = (mh/2 - bparm.img_height)/2;
- else
- {
- if (y_offset + bparm.img_height*2 > mh)
- bparm.img_y = mh/2 - bparm.img_height;
+ bparm.img_y = (mh / 2 - bparm.img_height) / 2;
+ else {
+ if (y_offset + bparm.img_height * 2 > mh)
+ bparm.img_y = mh / 2 - bparm.img_height;
else
- bparm.img_y = y_offset/2;
+ bparm.img_y = y_offset / 2;
}
- if (ioctl(GST_V4LELEMENT(v4lmjpegsink)->video_fd, MJPIOC_S_PARAMS, &bparm) < 0)
- {
- GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, SETTINGS, (NULL), GST_ERROR_SYSTEM);
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsink)->video_fd, MJPIOC_S_PARAMS,
+ &bparm) < 0) {
+ GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, SETTINGS, (NULL),
+ GST_ERROR_SYSTEM);
return FALSE;
}
******************************************************/
gboolean
-gst_v4lmjpegsink_playback_init (GstV4lMjpegSink *v4lmjpegsink)
+gst_v4lmjpegsink_playback_init (GstV4lMjpegSink * v4lmjpegsink)
{
gint n;
- DEBUG("initting playback subsystem");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG ("initting playback subsystem");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
/* Request buffers */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsink)->video_fd, MJPIOC_REQBUFS, &(v4lmjpegsink->breq)) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsink)->video_fd, MJPIOC_REQBUFS,
+ &(v4lmjpegsink->breq)) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
- gst_info("Got %ld buffers of size %ld KB\n",
- v4lmjpegsink->breq.count, v4lmjpegsink->breq.size/1024);
+ gst_info ("Got %ld buffers of size %ld KB\n",
+ v4lmjpegsink->breq.count, v4lmjpegsink->breq.size / 1024);
/* Map the buffers */
- GST_V4LELEMENT(v4lmjpegsink)->buffer = mmap(0,
- v4lmjpegsink->breq.count * v4lmjpegsink->breq.size,
- PROT_READ|PROT_WRITE, MAP_SHARED, GST_V4LELEMENT(v4lmjpegsink)->video_fd, 0);
- if (GST_V4LELEMENT(v4lmjpegsink)->buffer == MAP_FAILED)
- {
+ GST_V4LELEMENT (v4lmjpegsink)->buffer = mmap (0,
+ v4lmjpegsink->breq.count * v4lmjpegsink->breq.size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ GST_V4LELEMENT (v4lmjpegsink)->video_fd, 0);
+ if (GST_V4LELEMENT (v4lmjpegsink)->buffer == MAP_FAILED) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, TOO_LAZY, (NULL),
- ("Error mapping video buffers: %s",
- g_strerror(errno)));
- GST_V4LELEMENT(v4lmjpegsink)->buffer = NULL;
+ ("Error mapping video buffers: %s", g_strerror (errno)));
+ GST_V4LELEMENT (v4lmjpegsink)->buffer = NULL;
return FALSE;
}
/* allocate/init the GThread thingies */
- v4lmjpegsink->mutex_queued_frames = g_mutex_new();
+ v4lmjpegsink->mutex_queued_frames = g_mutex_new ();
v4lmjpegsink->isqueued_queued_frames = (gint8 *)
- malloc(sizeof(gint8) * v4lmjpegsink->breq.count);
- if (!v4lmjpegsink->isqueued_queued_frames)
- {
+ malloc (sizeof (gint8) * v4lmjpegsink->breq.count);
+ if (!v4lmjpegsink->isqueued_queued_frames) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to create queue tracker: %s",
- g_strerror(errno)));
+ ("Failed to create queue tracker: %s", g_strerror (errno)));
return FALSE;
}
v4lmjpegsink->cond_queued_frames = (GCond **)
- malloc(sizeof(GCond *) * v4lmjpegsink->breq.count);
- if (!v4lmjpegsink->cond_queued_frames)
- {
+ malloc (sizeof (GCond *) * v4lmjpegsink->breq.count);
+ if (!v4lmjpegsink->cond_queued_frames) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to create queue condition holders: %s",
- g_strerror(errno)));
+ ("Failed to create queue condition holders: %s", g_strerror (errno)));
return FALSE;
}
- for (n=0;n<v4lmjpegsink->breq.count;n++)
- v4lmjpegsink->cond_queued_frames[n] = g_cond_new();
+ for (n = 0; n < v4lmjpegsink->breq.count; n++)
+ v4lmjpegsink->cond_queued_frames[n] = g_cond_new ();
return TRUE;
}
******************************************************/
gboolean
-gst_v4lmjpegsink_playback_start (GstV4lMjpegSink *v4lmjpegsink)
+gst_v4lmjpegsink_playback_start (GstV4lMjpegSink * v4lmjpegsink)
{
GError *error;
gint n;
- DEBUG("starting playback");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG ("starting playback");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
/* mark all buffers as unqueued */
- for (n=0;n<v4lmjpegsink->breq.count;n++)
+ for (n = 0; n < v4lmjpegsink->breq.count; n++)
v4lmjpegsink->isqueued_queued_frames[n] = 0;
v4lmjpegsink->current_frame = -1;
/* create sync() thread */
- v4lmjpegsink->thread_queued_frames = g_thread_create(
- gst_v4lmjpegsink_sync_thread, (void *) v4lmjpegsink, TRUE, &error);
- if(!v4lmjpegsink->thread_queued_frames)
- {
+ v4lmjpegsink->thread_queued_frames =
+ g_thread_create (gst_v4lmjpegsink_sync_thread, (void *) v4lmjpegsink,
+ TRUE, &error);
+ if (!v4lmjpegsink->thread_queued_frames) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to create sync thread: %s", error->message));
+ ("Failed to create sync thread: %s", error->message));
return FALSE;
}
******************************************************/
guint8 *
-gst_v4lmjpegsink_get_buffer (GstV4lMjpegSink *v4lmjpegsink,
- gint num)
+gst_v4lmjpegsink_get_buffer (GstV4lMjpegSink * v4lmjpegsink, gint num)
{
- /*DEBUG("gst_v4lmjpegsink_get_buffer(), num = %d", num);*/
+ /*DEBUG("gst_v4lmjpegsink_get_buffer(), num = %d", num); */
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)) ||
- !GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsink)))
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsink)) ||
+ !GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lmjpegsink)))
return NULL;
if (num < 0 || num >= v4lmjpegsink->breq.count)
return NULL;
- return GST_V4LELEMENT(v4lmjpegsink)->buffer+(v4lmjpegsink->breq.size*num);
+ return GST_V4LELEMENT (v4lmjpegsink)->buffer +
+ (v4lmjpegsink->breq.size * num);
}
******************************************************/
gboolean
-gst_v4lmjpegsink_play_frame (GstV4lMjpegSink *v4lmjpegsink,
- gint num)
+gst_v4lmjpegsink_play_frame (GstV4lMjpegSink * v4lmjpegsink, gint num)
{
- DEBUG("playing frame %d", num);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG ("playing frame %d", num);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
- if (!gst_v4lmjpegsink_queue_frame(v4lmjpegsink, num))
+ if (!gst_v4lmjpegsink_queue_frame (v4lmjpegsink, num))
return FALSE;
return TRUE;
******************************************************/
gboolean
-gst_v4lmjpegsink_wait_frame (GstV4lMjpegSink *v4lmjpegsink,
- gint *num)
+gst_v4lmjpegsink_wait_frame (GstV4lMjpegSink * v4lmjpegsink, gint * num)
{
- DEBUG("waiting for next frame to be finished playing");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG ("waiting for next frame to be finished playing");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
- if (!gst_v4lmjpegsink_sync_frame(v4lmjpegsink, num))
+ if (!gst_v4lmjpegsink_sync_frame (v4lmjpegsink, num))
return FALSE;
return TRUE;
******************************************************/
gboolean
-gst_v4lmjpegsink_playback_stop (GstV4lMjpegSink *v4lmjpegsink)
+gst_v4lmjpegsink_playback_stop (GstV4lMjpegSink * v4lmjpegsink)
{
gint num;
- DEBUG("stopping playback");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG ("stopping playback");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
/* mark next buffer as wrong */
- if (!gst_v4lmjpegsink_sync_frame(v4lmjpegsink, &num) ||
- !gst_v4lmjpegsink_queue_frame(v4lmjpegsink, num))
- {
+ if (!gst_v4lmjpegsink_sync_frame (v4lmjpegsink, &num) ||
+ !gst_v4lmjpegsink_queue_frame (v4lmjpegsink, num)) {
return FALSE;
}
/* .. and wait for all buffers to be queued on */
- g_thread_join(v4lmjpegsink->thread_queued_frames);
+ g_thread_join (v4lmjpegsink->thread_queued_frames);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lmjpegsink_playback_deinit (GstV4lMjpegSink *v4lmjpegsink)
+gst_v4lmjpegsink_playback_deinit (GstV4lMjpegSink * v4lmjpegsink)
{
int n;
- DEBUG("quitting playback subsystem");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsink));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsink));
+ DEBUG ("quitting playback subsystem");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
/* free GThread thingies */
- g_mutex_free(v4lmjpegsink->mutex_queued_frames);
- for (n=0;n<v4lmjpegsink->breq.count;n++)
- g_cond_free(v4lmjpegsink->cond_queued_frames[n]);
- free(v4lmjpegsink->cond_queued_frames);
- free(v4lmjpegsink->isqueued_queued_frames);
+ g_mutex_free (v4lmjpegsink->mutex_queued_frames);
+ for (n = 0; n < v4lmjpegsink->breq.count; n++)
+ g_cond_free (v4lmjpegsink->cond_queued_frames[n]);
+ free (v4lmjpegsink->cond_queued_frames);
+ free (v4lmjpegsink->isqueued_queued_frames);
/* unmap the buffer */
- munmap(GST_V4LELEMENT(v4lmjpegsink)->buffer, v4lmjpegsink->breq.size * v4lmjpegsink->breq.count);
- GST_V4LELEMENT(v4lmjpegsink)->buffer = NULL;
+ munmap (GST_V4LELEMENT (v4lmjpegsink)->buffer,
+ v4lmjpegsink->breq.size * v4lmjpegsink->breq.count);
+ GST_V4LELEMENT (v4lmjpegsink)->buffer = NULL;
return TRUE;
}
#include "v4l_calls.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/* frame playback on device */
-gboolean gst_v4lmjpegsink_set_buffer (GstV4lMjpegSink *v4lmjpegsink,
- gint numbufs,
- gint bufsize);
-gboolean gst_v4lmjpegsink_set_playback (GstV4lMjpegSink *v4lmjpegsink,
- gint width,
- gint height,
- gint x_offset,
- gint y_offset,
- gint norm,
- gint interlacing);
-gboolean gst_v4lmjpegsink_playback_init (GstV4lMjpegSink *v4lmjpegsink);
-gboolean gst_v4lmjpegsink_playback_start (GstV4lMjpegSink *v4lmjpegsink);
-guint8 * gst_v4lmjpegsink_get_buffer (GstV4lMjpegSink *v4lmjpegsink,
- gint num);
-gboolean gst_v4lmjpegsink_play_frame (GstV4lMjpegSink *v4lmjpegsink,
- gint num);
-gboolean gst_v4lmjpegsink_wait_frame (GstV4lMjpegSink *v4lmjpegsink,
- gint *num);
-gboolean gst_v4lmjpegsink_playback_stop (GstV4lMjpegSink *v4lmjpegsink);
-gboolean gst_v4lmjpegsink_playback_deinit (GstV4lMjpegSink *v4lmjpegsink);
+ gboolean gst_v4lmjpegsink_set_buffer (GstV4lMjpegSink * v4lmjpegsink,
+ gint numbufs, gint bufsize);
+ gboolean gst_v4lmjpegsink_set_playback (GstV4lMjpegSink * v4lmjpegsink,
+ gint width,
+ gint height, gint x_offset, gint y_offset, gint norm, gint interlacing);
+ gboolean gst_v4lmjpegsink_playback_init (GstV4lMjpegSink * v4lmjpegsink);
+ gboolean gst_v4lmjpegsink_playback_start (GstV4lMjpegSink * v4lmjpegsink);
+ guint8 *gst_v4lmjpegsink_get_buffer (GstV4lMjpegSink * v4lmjpegsink,
+ gint num);
+ gboolean gst_v4lmjpegsink_play_frame (GstV4lMjpegSink * v4lmjpegsink,
+ gint num);
+ gboolean gst_v4lmjpegsink_wait_frame (GstV4lMjpegSink * v4lmjpegsink,
+ gint * num);
+ gboolean gst_v4lmjpegsink_playback_stop (GstV4lMjpegSink * v4lmjpegsink);
+ gboolean gst_v4lmjpegsink_playback_deinit (GstV4lMjpegSink * v4lmjpegsink);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __V4L_MJPEG_SINK_CALLS_H__ */
+#endif /* __V4L_MJPEG_SINK_CALLS_H__ */
GST_ELEMENT(v4lmjpegsrc), \
"V4LMJPEGSRC: " format, ##args)
-enum {
+enum
+{
QUEUE_STATE_ERROR = -1,
QUEUE_STATE_READY_FOR_QUEUE,
QUEUE_STATE_QUEUED,
******************************************************/
static gboolean
-gst_v4lmjpegsrc_queue_frame (GstV4lMjpegSrc *v4lmjpegsrc,
- gint num)
+gst_v4lmjpegsrc_queue_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint num)
{
- DEBUG("queueing frame %d", num);
+ DEBUG ("queueing frame %d", num);
if (v4lmjpegsrc->frame_queue_state[num] != QUEUE_STATE_READY_FOR_QUEUE) {
return FALSE;
}
- if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd, MJPIOC_QBUF_CAPT, &num) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsrc)->video_fd, MJPIOC_QBUF_CAPT,
+ &num) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, READ, (NULL),
- ("Error queueing a buffer (%d): %s",
- num, g_strerror(errno)));
+ ("Error queueing a buffer (%d): %s", num, g_strerror (errno)));
return FALSE;
}
******************************************************/
static gboolean
-gst_v4lmjpegsrc_sync_next_frame (GstV4lMjpegSrc *v4lmjpegsrc,
- gint *num)
+gst_v4lmjpegsrc_sync_next_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint * num)
{
- DEBUG("syncing on next frame");
+ DEBUG ("syncing on next frame");
if (v4lmjpegsrc->num_queued <= 0) {
return FALSE;
}
- while (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd,
- MJPIOC_SYNC, &(v4lmjpegsrc->bsync)) < 0) {
+ while (ioctl (GST_V4LELEMENT (v4lmjpegsrc)->video_fd,
+ MJPIOC_SYNC, &(v4lmjpegsrc->bsync)) < 0) {
if (errno != EINTR) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, SYNC, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
- DEBUG("Sync got interrupted");
+ DEBUG ("Sync got interrupted");
}
*num = v4lmjpegsrc->bsync.frame;
******************************************************/
gboolean
-gst_v4lmjpegsrc_set_buffer (GstV4lMjpegSrc *v4lmjpegsrc,
- gint numbufs,
- gint bufsize)
+gst_v4lmjpegsrc_set_buffer (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint numbufs, gint bufsize)
{
- DEBUG("setting buffer info to numbufs = %d, bufsize = %d KB",
- numbufs, bufsize);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("setting buffer info to numbufs = %d, bufsize = %d KB",
+ numbufs, bufsize);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
v4lmjpegsrc->breq.size = bufsize * 1024;
v4lmjpegsrc->breq.count = numbufs;
******************************************************/
gboolean
-gst_v4lmjpegsrc_set_capture (GstV4lMjpegSrc *v4lmjpegsrc,
- gint decimation,
- gint quality)
+gst_v4lmjpegsrc_set_capture (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint decimation, gint quality)
{
int norm, input, mw;
struct mjpeg_params bparm;
- DEBUG("setting decimation = %d, quality = %d",
- decimation, quality);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("setting decimation = %d, quality = %d", decimation, quality);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
- gst_v4l_get_chan_norm(GST_V4LELEMENT(v4lmjpegsrc), &input, &norm);
+ gst_v4l_get_chan_norm (GST_V4LELEMENT (v4lmjpegsrc), &input, &norm);
/* Query params for capture */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsrc)->video_fd, MJPIOC_G_PARAMS,
+ &bparm) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, SETTINGS, (NULL),
- GST_ERROR_SYSTEM);
+ GST_ERROR_SYSTEM);
return FALSE;
}
bparm.quality = quality;
bparm.norm = norm;
bparm.input = input;
- bparm.APP_len = 0; /* no JPEG markers - TODO: this is definately not right for decimation==1 */
+ bparm.APP_len = 0; /* no JPEG markers - TODO: this is definately not right for decimation==1 */
- mw = GST_V4LELEMENT(v4lmjpegsrc)->vcap.maxwidth;
- if (mw != 768 && mw != 640)
- {
+ mw = GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxwidth;
+ if (mw != 768 && mw != 640) {
if (decimation == 1)
mw = 720;
else
mw = 704;
}
v4lmjpegsrc->end_width = mw / decimation;
- v4lmjpegsrc->end_height = (norm==VIDEO_MODE_NTSC?480:576) / decimation;
+ v4lmjpegsrc->end_height = (norm == VIDEO_MODE_NTSC ? 480 : 576) / decimation;
/* TODO: interlacing */
/* Set params for capture */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd, MJPIOC_S_PARAMS, &bparm) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsrc)->video_fd, MJPIOC_S_PARAMS,
+ &bparm) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, SETTINGS, (NULL),
- GST_ERROR_SYSTEM);
+ GST_ERROR_SYSTEM);
return FALSE;
}
* return value: TRUE on success, FALSE on error
******************************************************/
-gboolean gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc *v4lmjpegsrc,
- gint x_offset,
- gint y_offset,
- gint width,
- gint height,
- gint h_decimation,
- gint v_decimation,
- gint quality)
+gboolean
+gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint x_offset,
+ gint y_offset,
+ gint width, gint height, gint h_decimation, gint v_decimation, gint quality)
{
gint norm, input;
gint maxwidth;
struct mjpeg_params bparm;
- DEBUG("setting x_offset = %d, y_offset = %d, "
- "width = %d, height = %d, h_decimation = %d, v_decimation = %d, quality = %d\n",
- x_offset, y_offset, width, height, h_decimation, v_decimation, quality);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("setting x_offset = %d, y_offset = %d, "
+ "width = %d, height = %d, h_decimation = %d, v_decimation = %d, quality = %d\n",
+ x_offset, y_offset, width, height, h_decimation, v_decimation, quality);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
- gst_v4l_get_chan_norm(GST_V4LELEMENT(v4lmjpegsrc), &input, &norm);
+ gst_v4l_get_chan_norm (GST_V4LELEMENT (v4lmjpegsrc), &input, &norm);
- if (GST_V4LELEMENT(v4lmjpegsrc)->vcap.maxwidth != 768 &&
- GST_V4LELEMENT(v4lmjpegsrc)->vcap.maxwidth != 640)
+ if (GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxwidth != 768 &&
+ GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxwidth != 640)
maxwidth = 720;
else
- maxwidth = GST_V4LELEMENT(v4lmjpegsrc)->vcap.maxwidth;
+ maxwidth = GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxwidth;
/* Query params for capture */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsrc)->video_fd, MJPIOC_G_PARAMS,
+ &bparm) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, SETTINGS, (NULL),
- GST_ERROR_SYSTEM);
+ GST_ERROR_SYSTEM);
return FALSE;
}
bparm.quality = quality;
bparm.norm = norm;
bparm.input = input;
- bparm.APP_len = 0; /* no JPEG markers - TODO: this is definately
- * not right for decimation==1 */
+ bparm.APP_len = 0; /* no JPEG markers - TODO: this is definately
+ * not right for decimation==1 */
- if (width <= 0)
- {
- if (x_offset < 0) x_offset = 0;
- width = (maxwidth==720&&h_decimation!=1)?704:maxwidth - 2*x_offset;
- }
- else
- {
+ if (width <= 0) {
+ if (x_offset < 0)
+ x_offset = 0;
+ width = (maxwidth == 720
+ && h_decimation != 1) ? 704 : maxwidth - 2 * x_offset;
+ } else {
if (x_offset < 0)
- x_offset = (maxwidth - width)/2;
+ x_offset = (maxwidth - width) / 2;
}
- if (height <= 0)
- {
- if (y_offset < 0) y_offset = 0;
- height = (norm==VIDEO_MODE_NTSC)?480:576 - 2*y_offset;
- }
- else
- {
+ if (height <= 0) {
if (y_offset < 0)
- y_offset = ((norm==VIDEO_MODE_NTSC)?480:576 - height)/2;
+ y_offset = 0;
+ height = (norm == VIDEO_MODE_NTSC) ? 480 : 576 - 2 * y_offset;
+ } else {
+ if (y_offset < 0)
+ y_offset = ((norm == VIDEO_MODE_NTSC) ? 480 : 576 - height) / 2;
}
- if (width + x_offset > maxwidth)
- {
+ if (width + x_offset > maxwidth) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Image width+offset (%d) bigger than maximum (%d)",
- width + x_offset, maxwidth));
+ ("Image width+offset (%d) bigger than maximum (%d)",
+ width + x_offset, maxwidth));
return FALSE;
}
- if ((width%(bparm.HorDcm*16))!=0)
- {
+ if ((width % (bparm.HorDcm * 16)) != 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, STREAM, FORMAT, (NULL),
- ("Image width (%d) not multiple of %d (required for JPEG)",
- width, bparm.HorDcm*16));
+ ("Image width (%d) not multiple of %d (required for JPEG)",
+ width, bparm.HorDcm * 16));
return FALSE;
}
- if (height + y_offset > (norm==VIDEO_MODE_NTSC ? 480 : 576))
- {
+ if (height + y_offset > (norm == VIDEO_MODE_NTSC ? 480 : 576)) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Image height+offset (%d) bigger than maximum (%d)",
- height + y_offset, (norm==VIDEO_MODE_NTSC ? 480 : 576)));
+ ("Image height+offset (%d) bigger than maximum (%d)",
+ height + y_offset, (norm == VIDEO_MODE_NTSC ? 480 : 576)));
return FALSE;
}
/* RJ: Image height must only be a multiple of 8, but geom_height
* is double the field height
*/
- if ((height%(bparm.VerDcm*16))!=0)
- {
+ if ((height % (bparm.VerDcm * 16)) != 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, STREAM, FORMAT, (NULL),
- ("Image height (%d) not multiple of %d (required for JPEG)",
- height, bparm.VerDcm*16));
+ ("Image height (%d) not multiple of %d (required for JPEG)",
+ height, bparm.VerDcm * 16));
return FALSE;
}
bparm.img_y = y_offset;
bparm.img_height = height;
bparm.HorDcm = h_decimation;
- bparm.VerDcm = (v_decimation==4) ? 2 : 1;
- bparm.TmpDcm = (v_decimation==1) ? 1 : 2;
- bparm.field_per_buff = (v_decimation==1) ? 2 : 1;
+ bparm.VerDcm = (v_decimation == 4) ? 2 : 1;
+ bparm.TmpDcm = (v_decimation == 1) ? 1 : 2;
+ bparm.field_per_buff = (v_decimation == 1) ? 2 : 1;
v4lmjpegsrc->end_width = width / h_decimation;
v4lmjpegsrc->end_width = height / v_decimation;
/* TODO: interlacing */
/* Set params for capture */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd, MJPIOC_S_PARAMS, &bparm) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsrc)->video_fd, MJPIOC_S_PARAMS,
+ &bparm) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, SETTINGS, (NULL),
- GST_ERROR_SYSTEM);
+ GST_ERROR_SYSTEM);
return FALSE;
}
******************************************************/
gboolean
-gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc *v4lmjpegsrc)
+gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc * v4lmjpegsrc)
{
- DEBUG("initting capture subsystem");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("initting capture subsystem");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
/* Request buffers */
- if (ioctl(GST_V4LELEMENT(v4lmjpegsrc)->video_fd,
- MJPIOC_REQBUFS, &(v4lmjpegsrc->breq)) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lmjpegsrc)->video_fd,
+ MJPIOC_REQBUFS, &(v4lmjpegsrc->breq)) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
- if (v4lmjpegsrc->breq.count < MIN_BUFFERS_QUEUED)
- {
+ if (v4lmjpegsrc->breq.count < MIN_BUFFERS_QUEUED) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, READ, (NULL),
- ("Too little buffers. We got %ld, we want at least %d",
- v4lmjpegsrc->breq.count, MIN_BUFFERS_QUEUED));
+ ("Too little buffers. We got %ld, we want at least %d",
+ v4lmjpegsrc->breq.count, MIN_BUFFERS_QUEUED));
return FALSE;
}
- gst_info("Got %ld buffers of size %ld KB\n",
- v4lmjpegsrc->breq.count, v4lmjpegsrc->breq.size/1024);
+ gst_info ("Got %ld buffers of size %ld KB\n",
+ v4lmjpegsrc->breq.count, v4lmjpegsrc->breq.size / 1024);
/* keep track of queued buffers */
v4lmjpegsrc->frame_queue_state = (gint8 *)
- g_malloc(sizeof(gint8) * v4lmjpegsrc->breq.count);
+ g_malloc (sizeof (gint8) * v4lmjpegsrc->breq.count);
/* track how often to use each frame */
v4lmjpegsrc->use_num_times = (gint *)
- g_malloc(sizeof(gint) * v4lmjpegsrc->breq.count);
+ g_malloc (sizeof (gint) * v4lmjpegsrc->breq.count);
/* lock for the frame_state */
- v4lmjpegsrc->mutex_queue_state = g_mutex_new();
- v4lmjpegsrc->cond_queue_state = g_cond_new();
+ v4lmjpegsrc->mutex_queue_state = g_mutex_new ();
+ v4lmjpegsrc->cond_queue_state = g_cond_new ();
/* Map the buffers */
- GST_V4LELEMENT(v4lmjpegsrc)->buffer = mmap(0,
- v4lmjpegsrc->breq.count * v4lmjpegsrc->breq.size,
- PROT_READ|PROT_WRITE, MAP_SHARED, GST_V4LELEMENT(v4lmjpegsrc)->video_fd, 0);
- if (GST_V4LELEMENT(v4lmjpegsrc)->buffer == MAP_FAILED)
- {
+ GST_V4LELEMENT (v4lmjpegsrc)->buffer = mmap (0,
+ v4lmjpegsrc->breq.count * v4lmjpegsrc->breq.size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ GST_V4LELEMENT (v4lmjpegsrc)->video_fd, 0);
+ if (GST_V4LELEMENT (v4lmjpegsrc)->buffer == MAP_FAILED) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Error mapping video buffers: %s", g_strerror (errno)));
- GST_V4LELEMENT(v4lmjpegsrc)->buffer = NULL;
+ ("Error mapping video buffers: %s", g_strerror (errno)));
+ GST_V4LELEMENT (v4lmjpegsrc)->buffer = NULL;
return FALSE;
}
******************************************************/
gboolean
-gst_v4lmjpegsrc_capture_start (GstV4lMjpegSrc *v4lmjpegsrc)
+gst_v4lmjpegsrc_capture_start (GstV4lMjpegSrc * v4lmjpegsrc)
{
int n;
- DEBUG("starting capture");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("starting capture");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
- g_mutex_lock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_lock (v4lmjpegsrc->mutex_queue_state);
v4lmjpegsrc->quit = FALSE;
v4lmjpegsrc->num_queued = 0;
v4lmjpegsrc->queue_frame = 0;
/* set all buffers ready to queue , this starts streaming capture */
- for (n=0;n<v4lmjpegsrc->breq.count;n++) {
+ for (n = 0; n < v4lmjpegsrc->breq.count; n++) {
v4lmjpegsrc->frame_queue_state[n] = QUEUE_STATE_READY_FOR_QUEUE;
- if (!gst_v4lmjpegsrc_queue_frame(v4lmjpegsrc, n)) {
- g_mutex_unlock(v4lmjpegsrc->mutex_queue_state);
- gst_v4lmjpegsrc_capture_stop(v4lmjpegsrc);
+ if (!gst_v4lmjpegsrc_queue_frame (v4lmjpegsrc, n)) {
+ g_mutex_unlock (v4lmjpegsrc->mutex_queue_state);
+ gst_v4lmjpegsrc_capture_stop (v4lmjpegsrc);
return FALSE;
}
}
- g_mutex_unlock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_unlock (v4lmjpegsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lmjpegsrc_grab_frame (GstV4lMjpegSrc *v4lmjpegsrc,
- gint *num,
- gint *size)
+gst_v4lmjpegsrc_grab_frame (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint * num, gint * size)
{
- DEBUG("grabbing frame");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("grabbing frame");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
- g_mutex_lock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_lock (v4lmjpegsrc->mutex_queue_state);
/* do we have enough frames? */
while (v4lmjpegsrc->num_queued < MIN_BUFFERS_QUEUED ||
- v4lmjpegsrc->frame_queue_state[v4lmjpegsrc->queue_frame] ==
- QUEUE_STATE_READY_FOR_QUEUE) {
+ v4lmjpegsrc->frame_queue_state[v4lmjpegsrc->queue_frame] ==
+ QUEUE_STATE_READY_FOR_QUEUE) {
while (v4lmjpegsrc->frame_queue_state[v4lmjpegsrc->queue_frame] !=
- QUEUE_STATE_READY_FOR_QUEUE &&
- !v4lmjpegsrc->quit) {
- GST_DEBUG (
- "Waiting for frames to become available (%d < %d)",
- v4lmjpegsrc->num_queued, MIN_BUFFERS_QUEUED);
- g_cond_wait(v4lmjpegsrc->cond_queue_state,
- v4lmjpegsrc->mutex_queue_state);
+ QUEUE_STATE_READY_FOR_QUEUE && !v4lmjpegsrc->quit) {
+ GST_DEBUG ("Waiting for frames to become available (%d < %d)",
+ v4lmjpegsrc->num_queued, MIN_BUFFERS_QUEUED);
+ g_cond_wait (v4lmjpegsrc->cond_queue_state,
+ v4lmjpegsrc->mutex_queue_state);
}
if (v4lmjpegsrc->quit) {
- g_mutex_unlock(v4lmjpegsrc->mutex_queue_state);
- return TRUE; /* it won't get through anyway */
+ g_mutex_unlock (v4lmjpegsrc->mutex_queue_state);
+ return TRUE; /* it won't get through anyway */
}
- if (!gst_v4lmjpegsrc_queue_frame(v4lmjpegsrc, v4lmjpegsrc->queue_frame)) {
- g_mutex_unlock(v4lmjpegsrc->mutex_queue_state);
+ if (!gst_v4lmjpegsrc_queue_frame (v4lmjpegsrc, v4lmjpegsrc->queue_frame)) {
+ g_mutex_unlock (v4lmjpegsrc->mutex_queue_state);
return FALSE;
}
- v4lmjpegsrc->queue_frame = (v4lmjpegsrc->queue_frame + 1) % v4lmjpegsrc->breq.count;
+ v4lmjpegsrc->queue_frame =
+ (v4lmjpegsrc->queue_frame + 1) % v4lmjpegsrc->breq.count;
}
/* syncing on the buffer grabs it */
- if (!gst_v4lmjpegsrc_sync_next_frame(v4lmjpegsrc, num)) {
+ if (!gst_v4lmjpegsrc_sync_next_frame (v4lmjpegsrc, num)) {
return FALSE;
}
*size = v4lmjpegsrc->bsync.length;
- g_mutex_unlock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_unlock (v4lmjpegsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
guint8 *
-gst_v4lmjpegsrc_get_buffer (GstV4lMjpegSrc *v4lmjpegsrc,
- gint num)
+gst_v4lmjpegsrc_get_buffer (GstV4lMjpegSrc * v4lmjpegsrc, gint num)
{
- /*DEBUG("gst_v4lmjpegsrc_get_buffer(), num = %d", num);*/
+ /*DEBUG("gst_v4lmjpegsrc_get_buffer(), num = %d", num); */
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc)) ||
- !GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lmjpegsrc)))
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc)) ||
+ !GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lmjpegsrc)))
return NULL;
if (num < 0 || num >= v4lmjpegsrc->breq.count)
return NULL;
- return GST_V4LELEMENT(v4lmjpegsrc)->buffer+(v4lmjpegsrc->breq.size*num);
+ return GST_V4LELEMENT (v4lmjpegsrc)->buffer + (v4lmjpegsrc->breq.size * num);
}
******************************************************/
gboolean
-gst_v4lmjpegsrc_requeue_frame (GstV4lMjpegSrc *v4lmjpegsrc,
- gint num)
+gst_v4lmjpegsrc_requeue_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint num)
{
- DEBUG("requeueing frame %d", num);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("requeueing frame %d", num);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
/* mark frame as 'ready to requeue' */
- g_mutex_lock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_lock (v4lmjpegsrc->mutex_queue_state);
if (v4lmjpegsrc->frame_queue_state[num] != QUEUE_STATE_SYNCED) {
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Invalid state %d (expected %d), can't requeue",
- v4lmjpegsrc->frame_queue_state[num],
- QUEUE_STATE_SYNCED));
+ ("Invalid state %d (expected %d), can't requeue",
+ v4lmjpegsrc->frame_queue_state[num], QUEUE_STATE_SYNCED));
return FALSE;
}
v4lmjpegsrc->frame_queue_state[num] = QUEUE_STATE_READY_FOR_QUEUE;
/* let an optional wait know */
- g_cond_broadcast(v4lmjpegsrc->cond_queue_state);
+ g_cond_broadcast (v4lmjpegsrc->cond_queue_state);
- g_mutex_unlock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_unlock (v4lmjpegsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc *v4lmjpegsrc)
+gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc * v4lmjpegsrc)
{
int n;
- DEBUG("stopping capture");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("stopping capture");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
- g_mutex_lock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_lock (v4lmjpegsrc->mutex_queue_state);
/* make an optional pending wait stop */
v4lmjpegsrc->quit = TRUE;
- g_cond_broadcast(v4lmjpegsrc->cond_queue_state);
-
+ g_cond_broadcast (v4lmjpegsrc->cond_queue_state);
+
/* sync on remaining frames */
while (v4lmjpegsrc->num_queued > 0) {
- gst_v4lmjpegsrc_sync_next_frame(v4lmjpegsrc, &n);
+ gst_v4lmjpegsrc_sync_next_frame (v4lmjpegsrc, &n);
}
- g_mutex_unlock(v4lmjpegsrc->mutex_queue_state);
+ g_mutex_unlock (v4lmjpegsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lmjpegsrc_capture_deinit (GstV4lMjpegSrc *v4lmjpegsrc)
+gst_v4lmjpegsrc_capture_deinit (GstV4lMjpegSrc * v4lmjpegsrc)
{
- DEBUG("quitting capture subsystem");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lmjpegsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lmjpegsrc));
+ DEBUG ("quitting capture subsystem");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
/* unmap the buffer */
- munmap(GST_V4LELEMENT(v4lmjpegsrc)->buffer, v4lmjpegsrc->breq.size * v4lmjpegsrc->breq.count);
- GST_V4LELEMENT(v4lmjpegsrc)->buffer = NULL;
+ munmap (GST_V4LELEMENT (v4lmjpegsrc)->buffer,
+ v4lmjpegsrc->breq.size * v4lmjpegsrc->breq.count);
+ GST_V4LELEMENT (v4lmjpegsrc)->buffer = NULL;
/* free buffer tracker */
- g_mutex_free(v4lmjpegsrc->mutex_queue_state);
- g_cond_free(v4lmjpegsrc->cond_queue_state);
- g_free(v4lmjpegsrc->frame_queue_state);
- g_free(v4lmjpegsrc->use_num_times);
+ g_mutex_free (v4lmjpegsrc->mutex_queue_state);
+ g_cond_free (v4lmjpegsrc->cond_queue_state);
+ g_free (v4lmjpegsrc->frame_queue_state);
+ g_free (v4lmjpegsrc->use_num_times);
return TRUE;
}
#include "v4l_calls.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/* frame grabbing/capture */
-gboolean gst_v4lmjpegsrc_set_buffer (GstV4lMjpegSrc *v4lmjpegsrc,
- gint numbufs,
- gint bufsize);
-gboolean gst_v4lmjpegsrc_set_capture (GstV4lMjpegSrc *v4lmjpegsrc,
- gint decimation,
- gint quality);
-gboolean gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc *v4lmjpegsrc,
- gint x_offset,
- gint y_offset,
- gint width,
- gint height,
- gint h_decimation,
- gint v_decimation,
- gint quality);
-gboolean gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc *v4lmjpegsrc);
-gboolean gst_v4lmjpegsrc_capture_start (GstV4lMjpegSrc *v4lmjpegsrc);
-gboolean gst_v4lmjpegsrc_grab_frame (GstV4lMjpegSrc *v4lmjpegsrc,
- gint *num,
- gint *size);
-guint8 * gst_v4lmjpegsrc_get_buffer (GstV4lMjpegSrc *v4lmjpegsrc,
- gint num);
-gboolean gst_v4lmjpegsrc_requeue_frame (GstV4lMjpegSrc *v4lmjpegsrc,
- gint num);
-gboolean gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc *v4lmjpegsrc);
-gboolean gst_v4lmjpegsrc_capture_deinit (GstV4lMjpegSrc *v4lmjpegsrc);
+ gboolean gst_v4lmjpegsrc_set_buffer (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint numbufs, gint bufsize);
+ gboolean gst_v4lmjpegsrc_set_capture (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint decimation, gint quality);
+ gboolean gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint x_offset,
+ gint y_offset,
+ gint width,
+ gint height, gint h_decimation, gint v_decimation, gint quality);
+ gboolean gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc * v4lmjpegsrc);
+ gboolean gst_v4lmjpegsrc_capture_start (GstV4lMjpegSrc * v4lmjpegsrc);
+ gboolean gst_v4lmjpegsrc_grab_frame (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint * num, gint * size);
+ guint8 *gst_v4lmjpegsrc_get_buffer (GstV4lMjpegSrc * v4lmjpegsrc, gint num);
+ gboolean gst_v4lmjpegsrc_requeue_frame (GstV4lMjpegSrc * v4lmjpegsrc,
+ gint num);
+ gboolean gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc * v4lmjpegsrc);
+ gboolean gst_v4lmjpegsrc_capture_deinit (GstV4lMjpegSrc * v4lmjpegsrc);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __V4L_MJPEG_SRC_CALLS_H__ */
+#endif /* __V4L_MJPEG_SRC_CALLS_H__ */
/* palette names */
static const char *palette_name[] = {
- "", /* 0 */
- "grayscale", /* VIDEO_PALETTE_GREY */
- "Hi-420", /* VIDEO_PALETTE_HI420 */
- "16-bit RGB (RGB-565)", /* VIDEO_PALETTE_RB565 */
- "24-bit RGB", /* VIDEO_PALETTE_RGB24 */
- "32-bit RGB", /* VIDEO_PALETTE_RGB32 */
- "15-bit RGB (RGB-555)", /* VIDEO_PALETTE_RGB555 */
- "YUV-4:2:2 (packed)", /* VIDEO_PALETTE_YUV422 */
- "YUYV", /* VIDEO_PALETTE_YUYV */
- "UYVY", /* VIDEO_PALETTE_UYVY */
- "YUV-4:2:0 (packed)", /* VIDEO_PALETTE_YUV420 */
- "YUV-4:1:1 (packed)", /* VIDEO_PALETTE_YUV411 */
- "Raw", /* VIDEO_PALETTE_RAW */
- "YUV-4:2:2 (planar)", /* VIDEO_PALETTE_YUV422P */
- "YUV-4:1:1 (planar)", /* VIDEO_PALETTE_YUV411P */
- "YUV-4:2:0 (planar)", /* VIDEO_PALETTE_YUV420P */
- "YUV-4:1:0 (planar)" /* VIDEO_PALETTE_YUV410P */
+ "", /* 0 */
+ "grayscale", /* VIDEO_PALETTE_GREY */
+ "Hi-420", /* VIDEO_PALETTE_HI420 */
+ "16-bit RGB (RGB-565)", /* VIDEO_PALETTE_RB565 */
+ "24-bit RGB", /* VIDEO_PALETTE_RGB24 */
+ "32-bit RGB", /* VIDEO_PALETTE_RGB32 */
+ "15-bit RGB (RGB-555)", /* VIDEO_PALETTE_RGB555 */
+ "YUV-4:2:2 (packed)", /* VIDEO_PALETTE_YUV422 */
+ "YUYV", /* VIDEO_PALETTE_YUYV */
+ "UYVY", /* VIDEO_PALETTE_UYVY */
+ "YUV-4:2:0 (packed)", /* VIDEO_PALETTE_YUV420 */
+ "YUV-4:1:1 (packed)", /* VIDEO_PALETTE_YUV411 */
+ "Raw", /* VIDEO_PALETTE_RAW */
+ "YUV-4:2:2 (planar)", /* VIDEO_PALETTE_YUV422P */
+ "YUV-4:1:1 (planar)", /* VIDEO_PALETTE_YUV411P */
+ "YUV-4:2:0 (planar)", /* VIDEO_PALETTE_YUV420P */
+ "YUV-4:1:0 (planar)" /* VIDEO_PALETTE_YUV410P */
};
/******************************************************
******************************************************/
static gboolean
-gst_v4lsrc_queue_frame (GstV4lSrc *v4lsrc,
- gint num)
+gst_v4lsrc_queue_frame (GstV4lSrc * v4lsrc, gint num)
{
- DEBUG("queueing frame %d", num);
+ DEBUG ("queueing frame %d", num);
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_READY_FOR_QUEUE) {
return FALSE;
v4lsrc->mmap.frame = num;
- if (ioctl(GST_V4LELEMENT(v4lsrc)->video_fd,
- VIDIOCMCAPTURE, &(v4lsrc->mmap)) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd,
+ VIDIOCMCAPTURE, &(v4lsrc->mmap)) < 0) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, WRITE, (NULL),
- ("Error queueing a buffer (%d): %s", num, g_strerror (errno)));
+ ("Error queueing a buffer (%d): %s", num, g_strerror (errno)));
return FALSE;
}
* Requires queue_state lock to be held
*****************************************************/
-static gboolean
-gst_v4lsrc_sync_frame (GstV4lSrc *v4lsrc, gint num)
+static gboolean
+gst_v4lsrc_sync_frame (GstV4lSrc * v4lsrc, gint num)
{
- DEBUG("Syncing on frame %d",num);
+ DEBUG ("Syncing on frame %d", num);
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_QUEUED) {
return FALSE;
}
- while (ioctl(GST_V4LELEMENT(v4lsrc)->video_fd, VIDIOCSYNC, &num) < 0) {
+ while (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCSYNC, &num) < 0) {
/* if the sync() got interrupted, we can retry */
if (errno != EINTR) {
v4lsrc->frame_queue_state[num] = QUEUE_STATE_ERROR;
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SYNC, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
- DEBUG("Sync got interrupted");
+ DEBUG ("Sync got interrupted");
}
if (v4lsrc->clock) {
- v4lsrc->timestamp_sync = gst_clock_get_time(v4lsrc->clock);
+ v4lsrc->timestamp_sync = gst_clock_get_time (v4lsrc->clock);
} else {
GTimeVal time;
- g_get_current_time(&time);
- v4lsrc->timestamp_sync = GST_TIMEVAL_TO_TIME(time);
+
+ g_get_current_time (&time);
+ v4lsrc->timestamp_sync = GST_TIMEVAL_TO_TIME (time);
}
v4lsrc->frame_queue_state[num] = QUEUE_STATE_SYNCED;
******************************************************/
gboolean
-gst_v4lsrc_set_capture (GstV4lSrc *v4lsrc,
- gint width,
- gint height,
- gint palette)
+gst_v4lsrc_set_capture (GstV4lSrc * v4lsrc,
+ gint width, gint height, gint palette)
{
- DEBUG("capture properties set to width = %d, height = %d, palette = %d",
- width, height, palette);
+ DEBUG ("capture properties set to width = %d, height = %d, palette = %d",
+ width, height, palette);
- /*GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));*/
- /*GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc));*/
+ /*GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); */
+ /*GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc)); */
v4lsrc->mmap.width = width;
v4lsrc->mmap.height = height;
******************************************************/
gboolean
-gst_v4lsrc_capture_init (GstV4lSrc *v4lsrc)
+gst_v4lsrc_capture_init (GstV4lSrc * v4lsrc)
{
- DEBUG("initting capture subsystem");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc));
+ DEBUG ("initting capture subsystem");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lsrc));
/* request buffer info */
- if (ioctl(GST_V4LELEMENT(v4lsrc)->video_fd, VIDIOCGMBUF, &(v4lsrc->mbuf)) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCGMBUF,
+ &(v4lsrc->mbuf)) < 0) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, READ, (NULL),
- ("Error getting buffer information: %s", g_strerror (errno)));
+ ("Error getting buffer information: %s", g_strerror (errno)));
return FALSE;
}
- if (v4lsrc->mbuf.frames < MIN_BUFFERS_QUEUED)
- {
+ if (v4lsrc->mbuf.frames < MIN_BUFFERS_QUEUED) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, READ, (NULL),
- ("Not enough buffers. We got %d, we want at least %d",
- v4lsrc->mbuf.frames, MIN_BUFFERS_QUEUED));
+ ("Not enough buffers. We got %d, we want at least %d",
+ v4lsrc->mbuf.frames, MIN_BUFFERS_QUEUED));
return FALSE;
}
- gst_info("Got %d buffers (\'%s\') of size %d KB\n",
- v4lsrc->mbuf.frames, palette_name[v4lsrc->mmap.format],
- v4lsrc->mbuf.size/(v4lsrc->mbuf.frames*1024));
+ gst_info ("Got %d buffers (\'%s\') of size %d KB\n",
+ v4lsrc->mbuf.frames, palette_name[v4lsrc->mmap.format],
+ v4lsrc->mbuf.size / (v4lsrc->mbuf.frames * 1024));
/* keep track of queued buffers */
v4lsrc->frame_queue_state = (gint8 *)
- g_malloc(sizeof(gint8) * v4lsrc->mbuf.frames);
+ g_malloc (sizeof (gint8) * v4lsrc->mbuf.frames);
/* track how often to use each frame */
v4lsrc->use_num_times = (gint *)
- g_malloc(sizeof(gint) * v4lsrc->mbuf.frames);
+ g_malloc (sizeof (gint) * v4lsrc->mbuf.frames);
/* lock for the frame_state */
- v4lsrc->mutex_queue_state = g_mutex_new();
- v4lsrc->cond_queue_state = g_cond_new();
+ v4lsrc->mutex_queue_state = g_mutex_new ();
+ v4lsrc->cond_queue_state = g_cond_new ();
/* Map the buffers */
- GST_V4LELEMENT(v4lsrc)->buffer = mmap(0, v4lsrc->mbuf.size,
- PROT_READ|PROT_WRITE, MAP_SHARED, GST_V4LELEMENT(v4lsrc)->video_fd, 0);
- if (GST_V4LELEMENT(v4lsrc)->buffer == MAP_FAILED)
- {
+ GST_V4LELEMENT (v4lsrc)->buffer = mmap (0, v4lsrc->mbuf.size,
+ PROT_READ | PROT_WRITE, MAP_SHARED, GST_V4LELEMENT (v4lsrc)->video_fd, 0);
+ if (GST_V4LELEMENT (v4lsrc)->buffer == MAP_FAILED) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Error mapping video buffers: %s", g_strerror (errno)));
- GST_V4LELEMENT(v4lsrc)->buffer = NULL;
+ ("Error mapping video buffers: %s", g_strerror (errno)));
+ GST_V4LELEMENT (v4lsrc)->buffer = NULL;
return FALSE;
}
******************************************************/
gboolean
-gst_v4lsrc_capture_start (GstV4lSrc *v4lsrc)
+gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc)
{
int n;
- DEBUG("starting capture");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc));
+ DEBUG ("starting capture");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
- g_mutex_lock(v4lsrc->mutex_queue_state);
+ g_mutex_lock (v4lsrc->mutex_queue_state);
v4lsrc->quit = FALSE;
v4lsrc->num_queued = 0;
v4lsrc->queue_frame = 0;
/* set all buffers ready to queue , this starts streaming capture */
- for (n=0;n<v4lsrc->mbuf.frames;n++) {
+ for (n = 0; n < v4lsrc->mbuf.frames; n++) {
v4lsrc->frame_queue_state[n] = QUEUE_STATE_READY_FOR_QUEUE;
- if (!gst_v4lsrc_queue_frame(v4lsrc, n)) {
- g_mutex_unlock(v4lsrc->mutex_queue_state);
- gst_v4lsrc_capture_stop(v4lsrc);
+ if (!gst_v4lsrc_queue_frame (v4lsrc, n)) {
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
+ gst_v4lsrc_capture_stop (v4lsrc);
return FALSE;
}
}
v4lsrc->is_capturing = TRUE;
- g_mutex_unlock(v4lsrc->mutex_queue_state);
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lsrc_grab_frame (GstV4lSrc *v4lsrc, gint *num)
+gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
{
- DEBUG("grabbing frame");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc));
+ DEBUG ("grabbing frame");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
- g_mutex_lock(v4lsrc->mutex_queue_state);
+ g_mutex_lock (v4lsrc->mutex_queue_state);
/* do we have enough frames? */
while (v4lsrc->num_queued < MIN_BUFFERS_QUEUED ||
- v4lsrc->frame_queue_state[v4lsrc->queue_frame] ==
- QUEUE_STATE_READY_FOR_QUEUE) {
+ v4lsrc->frame_queue_state[v4lsrc->queue_frame] ==
+ QUEUE_STATE_READY_FOR_QUEUE) {
while (v4lsrc->frame_queue_state[v4lsrc->queue_frame] !=
- QUEUE_STATE_READY_FOR_QUEUE &&
- !v4lsrc->quit) {
+ QUEUE_STATE_READY_FOR_QUEUE && !v4lsrc->quit) {
GST_DEBUG ("Waiting for frames to become available (%d < %d)",
- v4lsrc->num_queued, MIN_BUFFERS_QUEUED);
- g_cond_wait(v4lsrc->cond_queue_state,
- v4lsrc->mutex_queue_state);
+ v4lsrc->num_queued, MIN_BUFFERS_QUEUED);
+ g_cond_wait (v4lsrc->cond_queue_state, v4lsrc->mutex_queue_state);
}
if (v4lsrc->quit) {
- g_mutex_unlock(v4lsrc->mutex_queue_state);
- return TRUE; /* it won't get through anyway */
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
+ return TRUE; /* it won't get through anyway */
}
- if (!gst_v4lsrc_queue_frame(v4lsrc, v4lsrc->queue_frame)) {
- g_mutex_unlock(v4lsrc->mutex_queue_state);
+ if (!gst_v4lsrc_queue_frame (v4lsrc, v4lsrc->queue_frame)) {
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
return FALSE;
}
v4lsrc->queue_frame = (v4lsrc->queue_frame + 1) % v4lsrc->mbuf.frames;
/* syncing on the buffer grabs it */
*num = v4lsrc->sync_frame;
- if (!gst_v4lsrc_sync_frame(v4lsrc, *num)) {
- g_mutex_unlock(v4lsrc->mutex_queue_state);
+ if (!gst_v4lsrc_sync_frame (v4lsrc, *num)) {
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
return FALSE;
}
v4lsrc->sync_frame = (v4lsrc->sync_frame + 1) % v4lsrc->mbuf.frames;
- g_mutex_unlock(v4lsrc->mutex_queue_state);
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
guint8 *
-gst_v4lsrc_get_buffer (GstV4lSrc *v4lsrc, gint num)
+gst_v4lsrc_get_buffer (GstV4lSrc * v4lsrc, gint num)
{
- if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc)) ||
- !GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lsrc)))
+ if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc)) ||
+ !GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc)))
return NULL;
if (num < 0 || num >= v4lsrc->mbuf.frames)
return NULL;
- return GST_V4LELEMENT(v4lsrc)->buffer+v4lsrc->mbuf.offsets[num];
+ return GST_V4LELEMENT (v4lsrc)->buffer + v4lsrc->mbuf.offsets[num];
}
******************************************************/
gboolean
-gst_v4lsrc_requeue_frame (GstV4lSrc *v4lsrc, gint num)
+gst_v4lsrc_requeue_frame (GstV4lSrc * v4lsrc, gint num)
{
- DEBUG("requeueing frame %d", num);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc));
+ DEBUG ("requeueing frame %d", num);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
/* mark frame as 'ready to requeue' */
- g_mutex_lock(v4lsrc->mutex_queue_state);
+ g_mutex_lock (v4lsrc->mutex_queue_state);
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_SYNCED) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Invalid state %d (expected %d), can't requeue",
- v4lsrc->frame_queue_state[num],
- QUEUE_STATE_SYNCED));
+ ("Invalid state %d (expected %d), can't requeue",
+ v4lsrc->frame_queue_state[num], QUEUE_STATE_SYNCED));
return FALSE;
}
v4lsrc->frame_queue_state[num] = QUEUE_STATE_READY_FOR_QUEUE;
/* let an optional wait know */
- g_cond_broadcast(v4lsrc->cond_queue_state);
+ g_cond_broadcast (v4lsrc->cond_queue_state);
- g_mutex_unlock(v4lsrc->mutex_queue_state);
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lsrc_capture_stop (GstV4lSrc *v4lsrc)
+gst_v4lsrc_capture_stop (GstV4lSrc * v4lsrc)
{
- DEBUG("stopping capture");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc));
+ DEBUG ("stopping capture");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
- g_mutex_lock(v4lsrc->mutex_queue_state);
+ g_mutex_lock (v4lsrc->mutex_queue_state);
v4lsrc->is_capturing = FALSE;
/* make an optional pending wait stop */
v4lsrc->quit = TRUE;
- g_cond_broadcast(v4lsrc->cond_queue_state);
-
+ g_cond_broadcast (v4lsrc->cond_queue_state);
+
/* sync on remaining frames */
while (1) {
if (v4lsrc->frame_queue_state[v4lsrc->sync_frame] == QUEUE_STATE_QUEUED) {
- gst_v4lsrc_sync_frame(v4lsrc, v4lsrc->sync_frame);
+ gst_v4lsrc_sync_frame (v4lsrc, v4lsrc->sync_frame);
v4lsrc->sync_frame = (v4lsrc->sync_frame + 1) % v4lsrc->mbuf.frames;
} else {
break;
}
}
- g_mutex_unlock(v4lsrc->mutex_queue_state);
+ g_mutex_unlock (v4lsrc->mutex_queue_state);
return TRUE;
}
******************************************************/
gboolean
-gst_v4lsrc_capture_deinit (GstV4lSrc *v4lsrc)
+gst_v4lsrc_capture_deinit (GstV4lSrc * v4lsrc)
{
- DEBUG("quitting capture subsystem");
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));
- GST_V4L_CHECK_ACTIVE(GST_V4LELEMENT(v4lsrc));
+ DEBUG ("quitting capture subsystem");
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
+ GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
/* free buffer tracker */
- g_mutex_free(v4lsrc->mutex_queue_state);
- g_cond_free(v4lsrc->cond_queue_state);
- g_free(v4lsrc->frame_queue_state);
- g_free(v4lsrc->use_num_times);
+ g_mutex_free (v4lsrc->mutex_queue_state);
+ g_cond_free (v4lsrc->cond_queue_state);
+ g_free (v4lsrc->frame_queue_state);
+ g_free (v4lsrc->use_num_times);
/* unmap the buffer */
- munmap(GST_V4LELEMENT(v4lsrc)->buffer, v4lsrc->mbuf.size);
- GST_V4LELEMENT(v4lsrc)->buffer = NULL;
+ munmap (GST_V4LELEMENT (v4lsrc)->buffer, v4lsrc->mbuf.size);
+ GST_V4LELEMENT (v4lsrc)->buffer = NULL;
return TRUE;
}
******************************************************/
gboolean
-gst_v4lsrc_try_palette (GstV4lSrc *v4lsrc,
- gint palette)
+gst_v4lsrc_try_palette (GstV4lSrc * v4lsrc, gint palette)
{
/* so, we need a buffer and some more stuff */
int frame = 0;
struct video_mbuf vmbuf;
struct video_mmap vmmap;
- DEBUG("gonna try out palette format %d (%s)",
- palette, palette_name[palette]);
- GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc));
- GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc));
+ DEBUG ("gonna try out palette format %d (%s)",
+ palette, palette_name[palette]);
+ GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
+ GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lsrc));
/* let's start by requesting a buffer and mmap()'ing it */
- if (ioctl(GST_V4LELEMENT(v4lsrc)->video_fd, VIDIOCGMBUF, &vmbuf) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCGMBUF, &vmbuf) < 0) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, READ, (NULL),
- ("Error getting buffer information: %s", g_strerror(errno)));
+ ("Error getting buffer information: %s", g_strerror (errno)));
return FALSE;
}
/* Map the buffers */
- buffer = mmap(0, vmbuf.size, PROT_READ|PROT_WRITE,
- MAP_SHARED, GST_V4LELEMENT(v4lsrc)->video_fd, 0);
- if (buffer == MAP_FAILED)
- {
+ buffer = mmap (0, vmbuf.size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, GST_V4LELEMENT (v4lsrc)->video_fd, 0);
+ if (buffer == MAP_FAILED) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Error mapping our try-out buffer: %s", g_strerror(errno)));
+ ("Error mapping our try-out buffer: %s", g_strerror (errno)));
return FALSE;
}
/* now that we have a buffer, let's try out our format */
- vmmap.width = GST_V4LELEMENT(v4lsrc)->vcap.minwidth;
- vmmap.height = GST_V4LELEMENT(v4lsrc)->vcap.minheight;
+ vmmap.width = GST_V4LELEMENT (v4lsrc)->vcap.minwidth;
+ vmmap.height = GST_V4LELEMENT (v4lsrc)->vcap.minheight;
vmmap.format = palette;
vmmap.frame = frame;
- if (ioctl(GST_V4LELEMENT(v4lsrc)->video_fd, VIDIOCMCAPTURE, &vmmap) < 0)
- {
- if (errno != EINVAL) /* our format failed! */
- GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
- ("Error queueing our try-out buffer: %s", g_strerror(errno)));
- munmap(buffer, vmbuf.size);
+ if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCMCAPTURE, &vmmap) < 0) {
+ if (errno != EINVAL) /* our format failed! */
+ GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
+ ("Error queueing our try-out buffer: %s", g_strerror (errno)));
+ munmap (buffer, vmbuf.size);
return FALSE;
}
- if (ioctl(GST_V4LELEMENT(v4lsrc)->video_fd, VIDIOCSYNC, &frame) < 0)
- {
+ if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCSYNC, &frame) < 0) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SYNC, (NULL), GST_ERROR_SYSTEM);
- munmap(buffer, vmbuf.size);
+ munmap (buffer, vmbuf.size);
return FALSE;
}
- munmap(buffer, vmbuf.size);
+ munmap (buffer, vmbuf.size);
/* if we got here, it worked! woohoo, the format is supported! */
return TRUE;
}
-
#include "v4l_calls.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/* frame grabbing/capture (palette = VIDEO_PALETTE_* - see videodev.h) */
-gboolean gst_v4lsrc_set_capture (GstV4lSrc *v4lsrc, gint width, gint height, gint palette);
-gboolean gst_v4lsrc_capture_init (GstV4lSrc *v4lsrc);
-gboolean gst_v4lsrc_capture_start (GstV4lSrc *v4lsrc);
-gboolean gst_v4lsrc_grab_frame (GstV4lSrc *v4lsrc, gint *num);
-guint8 * gst_v4lsrc_get_buffer (GstV4lSrc *v4lsrc, gint num);
-gboolean gst_v4lsrc_requeue_frame (GstV4lSrc *v4lsrc, gint num);
-gboolean gst_v4lsrc_capture_stop (GstV4lSrc *v4lsrc);
-gboolean gst_v4lsrc_capture_deinit (GstV4lSrc *v4lsrc);
+ gboolean gst_v4lsrc_set_capture (GstV4lSrc * v4lsrc, gint width, gint height,
+ gint palette);
+ gboolean gst_v4lsrc_capture_init (GstV4lSrc * v4lsrc);
+ gboolean gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc);
+ gboolean gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num);
+ guint8 *gst_v4lsrc_get_buffer (GstV4lSrc * v4lsrc, gint num);
+ gboolean gst_v4lsrc_requeue_frame (GstV4lSrc * v4lsrc, gint num);
+ gboolean gst_v4lsrc_capture_stop (GstV4lSrc * v4lsrc);
+ gboolean gst_v4lsrc_capture_deinit (GstV4lSrc * v4lsrc);
/* "the ugliest hack ever, now available at your local mirror" */
-gboolean gst_v4lsrc_try_palette (GstV4lSrc *v4lsrc, gint palette);
+ gboolean gst_v4lsrc_try_palette (GstV4lSrc * v4lsrc, gint palette);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __V4L_SRC_CALLS_H__ */
+#endif /* __V4L_SRC_CALLS_H__ */
struct mjpeg_params
{
- /* The following parameters can only be queried */
-
- int major_version; /* Major version number of driver */
- int minor_version; /* Minor version number of driver */
-
- /* Main control parameters */
-
- int input; /* Input channel: 0 = Composite, 1 = S-VHS */
- int norm; /* Norm: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
- int decimation; /* decimation of captured video,
- enlargement of video played back.
- Valid values are 1, 2, 4 or 0.
- 0 is a special value where the user
- has full control over video scaling */
-
- /* The following parameters only have to be set if decimation==0,
- for other values of decimation they provide the data how the image is captured */
-
- int HorDcm; /* Horizontal decimation: 1, 2 or 4 */
- int VerDcm; /* Vertical decimation: 1 or 2 */
- int TmpDcm; /* Temporal decimation: 1 or 2,
- if TmpDcm==2 in capture every second frame is dropped,
- in playback every frame is played twice */
- int field_per_buff; /* Number of fields per buffer: 1 or 2 */
- int img_x; /* start of image in x direction */
- int img_y; /* start of image in y direction */
- int img_width; /* image width BEFORE decimation,
- must be a multiple of HorDcm*16 */
- int img_height; /* image height BEFORE decimation,
- must be a multiple of VerDcm*8 */
-
- /* --- End of parameters for decimation==0 only --- */
-
- /* JPEG control parameters */
-
- int quality; /* Measure for quality of compressed images.
- Scales linearly with the size of the compressed images.
- Must be beetween 0 and 100, 100 is a compression
- ratio of 1:4 */
-
- int odd_even; /* Which field should come first ???
- This is more aptly named "top_first",
- i.e. (odd_even==1) --> top-field-first */
-
- int APPn; /* Number of APP segment to be written, must be 0..15 */
- int APP_len; /* Length of data in JPEG APPn segment */
- char APP_data[60]; /* Data in the JPEG APPn segment. */
-
- int COM_len; /* Length of data in JPEG COM segment */
- char COM_data[60]; /* Data in JPEG COM segment */
-
- unsigned long jpeg_markers; /* Which markers should go into the JPEG output.
- Unless you exactly know what you do, leave them untouched.
- Inluding less markers will make the resulting code
- smaller, but there will be fewer aplications
- which can read it.
- The presence of the APP and COM marker is
- influenced by APP0_len and COM_len ONLY! */
-#define JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */
-#define JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */
-#define JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
-#define JPEG_MARKER_COM (1<<6) /* Comment segment */
-#define JPEG_MARKER_APP (1<<7) /* App segment, driver will allways use APP0 */
-
- int VFIFO_FB; /* Flag for enabling Video Fifo Feedback.
- If this flag is turned on and JPEG decompressing
- is going to the screen, the decompress process
- is stopped every time the Video Fifo is full.
- This enables a smooth decompress to the screen
- but the video output signal will get scrambled */
-
- /* Misc */
-
- char reserved[312]; /* Makes 512 bytes for this structure */
+ /* The following parameters can only be queried */
+
+ int major_version; /* Major version number of driver */
+ int minor_version; /* Minor version number of driver */
+
+ /* Main control parameters */
+
+ int input; /* Input channel: 0 = Composite, 1 = S-VHS */
+ int norm; /* Norm: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
+ int decimation; /* decimation of captured video,
+ enlargement of video played back.
+ Valid values are 1, 2, 4 or 0.
+ 0 is a special value where the user
+ has full control over video scaling */
+
+ /* The following parameters only have to be set if decimation==0,
+ for other values of decimation they provide the data how the image is captured */
+
+ int HorDcm; /* Horizontal decimation: 1, 2 or 4 */
+ int VerDcm; /* Vertical decimation: 1 or 2 */
+ int TmpDcm; /* Temporal decimation: 1 or 2,
+ if TmpDcm==2 in capture every second frame is dropped,
+ in playback every frame is played twice */
+ int field_per_buff; /* Number of fields per buffer: 1 or 2 */
+ int img_x; /* start of image in x direction */
+ int img_y; /* start of image in y direction */
+ int img_width; /* image width BEFORE decimation,
+ must be a multiple of HorDcm*16 */
+ int img_height; /* image height BEFORE decimation,
+ must be a multiple of VerDcm*8 */
+
+ /* --- End of parameters for decimation==0 only --- */
+
+ /* JPEG control parameters */
+
+ int quality; /* Measure for quality of compressed images.
+ Scales linearly with the size of the compressed images.
+ Must be beetween 0 and 100, 100 is a compression
+ ratio of 1:4 */
+
+ int odd_even; /* Which field should come first ???
+ This is more aptly named "top_first",
+ i.e. (odd_even==1) --> top-field-first */
+
+ int APPn; /* Number of APP segment to be written, must be 0..15 */
+ int APP_len; /* Length of data in JPEG APPn segment */
+ char APP_data[60]; /* Data in the JPEG APPn segment. */
+
+ int COM_len; /* Length of data in JPEG COM segment */
+ char COM_data[60]; /* Data in JPEG COM segment */
+
+ unsigned long jpeg_markers; /* Which markers should go into the JPEG output.
+ Unless you exactly know what you do, leave them untouched.
+ Inluding less markers will make the resulting code
+ smaller, but there will be fewer aplications
+ which can read it.
+ The presence of the APP and COM marker is
+ influenced by APP0_len and COM_len ONLY! */
+#define JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */
+#define JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */
+#define JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
+#define JPEG_MARKER_COM (1<<6) /* Comment segment */
+#define JPEG_MARKER_APP (1<<7) /* App segment, driver will allways use APP0 */
+
+ int VFIFO_FB; /* Flag for enabling Video Fifo Feedback.
+ If this flag is turned on and JPEG decompressing
+ is going to the screen, the decompress process
+ is stopped every time the Video Fifo is full.
+ This enables a smooth decompress to the screen
+ but the video output signal will get scrambled */
+
+ /* Misc */
+
+ char reserved[312]; /* Makes 512 bytes for this structure */
};
struct mjpeg_requestbuffers
{
- unsigned long count; /* Number of buffers for MJPEG grabbing */
- unsigned long size; /* Size PER BUFFER in bytes */
+ unsigned long count; /* Number of buffers for MJPEG grabbing */
+ unsigned long size; /* Size PER BUFFER in bytes */
};
struct mjpeg_sync
{
- unsigned long frame; /* Frame (0 - n) for double buffer */
- unsigned long length; /* number of code bytes in buffer (capture only) */
- unsigned long seq; /* frame sequence number */
- struct timeval timestamp; /* timestamp */
+ unsigned long frame; /* Frame (0 - n) for double buffer */
+ unsigned long length; /* number of code bytes in buffer (capture only) */
+ unsigned long seq; /* frame sequence number */
+ struct timeval timestamp; /* timestamp */
};
struct mjpeg_status
{
- int input; /* Input channel, has to be set prior to BUZIOC_G_STATUS */
- int signal; /* Returned: 1 if valid video signal detected */
- int norm; /* Returned: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
- int color; /* Returned: 1 if color signal detected */
+ int input; /* Input channel, has to be set prior to BUZIOC_G_STATUS */
+ int signal; /* Returned: 1 if valid video signal detected */
+ int norm; /* Returned: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
+ int color; /* Returned: 1 if color signal detected */
};
/*
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Object header */
#include "ximagesink.h"
-static void gst_ximagesink_buffer_free (GstBuffer *buffer);
+static void gst_ximagesink_buffer_free (GstBuffer * buffer);
/* ElementFactory information */
-static GstElementDetails gst_ximagesink_details = GST_ELEMENT_DETAILS (
- "Video sink",
- "Sink/Video",
- "A standard X based videosink",
- "Julien Moutte <julien@moutte.net>"
-);
+static GstElementDetails gst_ximagesink_details =
+GST_ELEMENT_DETAILS ("Video sink",
+ "Sink/Video",
+ "A standard X based videosink",
+ "Julien Moutte <julien@moutte.net>");
/* Default template - initiated with class struct to allow gst-register to work
without X running */
static GstStaticPadTemplate gst_ximagesink_sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb, "
- "framerate = (double) [ 1.0, 100.0 ], "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ]")
-);
-
-enum {
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb, "
+ "framerate = (double) [ 1.0, 100.0 ], "
+ "width = (int) [ 0, MAX ], " "height = (int) [ 0, MAX ]")
+ );
+
+enum
+{
ARG_0,
ARG_DISPLAY,
ARG_SYNCHRONOUS
- /* FILL ME */
+ /* FILL ME */
};
static GstVideoSinkClass *parent_class = NULL;
/* X11 stuff */
static int
-gst_ximagesink_handle_xerror (Display *display, XErrorEvent *xevent)
+gst_ximagesink_handle_xerror (Display * display, XErrorEvent * xevent)
{
- char error_msg [1024];
+ char error_msg[1024];
+
XGetErrorText (display, xevent->error_code, error_msg, 1024);
- GST_DEBUG ("ximagesink failed to use XShm calls. error: %s",
- error_msg);
+ GST_DEBUG ("ximagesink failed to use XShm calls. error: %s", error_msg);
error_catched = TRUE;
return 0;
}
/* This function checks that it is actually really possible to create an image
using XShm */
static gboolean
-gst_ximagesink_check_xshm_calls (GstXContext *xcontext)
+gst_ximagesink_check_xshm_calls (GstXContext * xcontext)
{
GstXImage *ximage = NULL;
- int (*handler)(Display *, XErrorEvent *);
-
+ int (*handler) (Display *, XErrorEvent *);
+
g_return_val_if_fail (xcontext != NULL, FALSE);
-
+
#ifdef HAVE_XSHM
ximage = g_new0 (GstXImage, 1);
-
+
/* Setting an error handler to catch failure */
handler = XSetErrorHandler (gst_ximagesink_handle_xerror);
-
- ximage->size = (xcontext->bpp / 8);
+
+ ximage->size = (xcontext->bpp / 8);
/* Trying to create a 1x1 picture */
ximage->ximage = XShmCreateImage (xcontext->disp, xcontext->visual,
- xcontext->depth, ZPixmap, NULL,
- &ximage->SHMInfo, 1, 1);
+ xcontext->depth, ZPixmap, NULL, &ximage->SHMInfo, 1, 1);
ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size, IPC_CREAT | 0777);
ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, 0, 0);
ximage->ximage->data = ximage->SHMInfo.shmaddr;
ximage->SHMInfo.readOnly = FALSE;
-
+
XShmAttach (xcontext->disp, &ximage->SHMInfo);
error_catched = FALSE;
- XSync(xcontext->disp, 0);
-
+ XSync (xcontext->disp, 0);
+
XSetErrorHandler (handler);
-
- if (error_catched)
- { /* Failed, detaching shared memory, destroying image and telling we can't
- use XShm */
- error_catched = FALSE;
- XDestroyImage (ximage->ximage);
- shmdt (ximage->SHMInfo.shmaddr);
- shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
- g_free (ximage);
- XSync (xcontext->disp, FALSE);
- return FALSE;
- }
- else
- {
- XShmDetach (xcontext->disp, &ximage->SHMInfo);
- XDestroyImage (ximage->ximage);
- shmdt (ximage->SHMInfo.shmaddr);
- shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
- g_free (ximage);
- XSync (xcontext->disp, FALSE);
- }
+
+ if (error_catched) { /* Failed, detaching shared memory, destroying image and telling we can't
+ use XShm */
+ error_catched = FALSE;
+ XDestroyImage (ximage->ximage);
+ shmdt (ximage->SHMInfo.shmaddr);
+ shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
+ g_free (ximage);
+ XSync (xcontext->disp, FALSE);
+ return FALSE;
+ } else {
+ XShmDetach (xcontext->disp, &ximage->SHMInfo);
+ XDestroyImage (ximage->ximage);
+ shmdt (ximage->SHMInfo.shmaddr);
+ shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
+ g_free (ximage);
+ XSync (xcontext->disp, FALSE);
+ }
#endif /* HAVE_XSHM */
-
+
return TRUE;
}
/* This function handles GstXImage creation depending on XShm availability */
static GstXImage *
-gst_ximagesink_ximage_new (GstXImageSink *ximagesink, gint width, gint height)
+gst_ximagesink_ximage_new (GstXImageSink * ximagesink, gint width, gint height)
{
GstXImage *ximage = NULL;
-
+
g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
-
+
ximage = g_new0 (GstXImage, 1);
-
+
ximage->width = width;
ximage->height = height;
ximage->data = NULL;
ximage->ximagesink = ximagesink;
-
+
g_mutex_lock (ximagesink->x_lock);
- ximage->size = (ximagesink->xcontext->bpp / 8) * ximage->width * ximage->height;
-
+ ximage->size =
+ (ximagesink->xcontext->bpp / 8) * ximage->width * ximage->height;
+
#ifdef HAVE_XSHM
- if (ximagesink->xcontext->use_xshm)
- {
- ximage->ximage = XShmCreateImage (ximagesink->xcontext->disp,
- ximagesink->xcontext->visual,
- ximagesink->xcontext->depth,
- ZPixmap, NULL, &ximage->SHMInfo,
- ximage->width, ximage->height);
-
- ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size,
- IPC_CREAT | 0777);
-
- ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, 0, 0);
- ximage->ximage->data = ximage->SHMInfo.shmaddr;
-
- ximage->SHMInfo.readOnly = FALSE;
-
- XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo);
-
- XSync (ximagesink->xcontext->disp, FALSE);
-
- shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
- ximage->SHMInfo.shmid = -1;
- }
- else
+ if (ximagesink->xcontext->use_xshm) {
+ ximage->ximage = XShmCreateImage (ximagesink->xcontext->disp,
+ ximagesink->xcontext->visual,
+ ximagesink->xcontext->depth,
+ ZPixmap, NULL, &ximage->SHMInfo, ximage->width, ximage->height);
+
+ ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size,
+ IPC_CREAT | 0777);
+
+ ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, 0, 0);
+ ximage->ximage->data = ximage->SHMInfo.shmaddr;
+
+ ximage->SHMInfo.readOnly = FALSE;
+
+ XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo);
+
+ XSync (ximagesink->xcontext->disp, FALSE);
+
+ shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
+ ximage->SHMInfo.shmid = -1;
+ } else
#endif /* HAVE_XSHM */
- {
- ximage->data = g_malloc (ximage->size);
-
- ximage->ximage = XCreateImage (ximagesink->xcontext->disp,
- ximagesink->xcontext->visual,
- ximagesink->xcontext->depth,
- ZPixmap, 0, ximage->data,
- ximage->width, ximage->height,
- ximagesink->xcontext->bpp,
- ximage->width * (ximagesink->xcontext->bpp / 8));
-
- XSync (ximagesink->xcontext->disp, FALSE);
- }
-
- if (!ximage->ximage)
- {
- if (ximage->data)
- g_free (ximage->data);
-
- g_free (ximage);
-
- ximage = NULL;
- }
-
+ {
+ ximage->data = g_malloc (ximage->size);
+
+ ximage->ximage = XCreateImage (ximagesink->xcontext->disp,
+ ximagesink->xcontext->visual,
+ ximagesink->xcontext->depth,
+ ZPixmap, 0, ximage->data,
+ ximage->width, ximage->height,
+ ximagesink->xcontext->bpp,
+ ximage->width * (ximagesink->xcontext->bpp / 8));
+
+ XSync (ximagesink->xcontext->disp, FALSE);
+ }
+
+ if (!ximage->ximage) {
+ if (ximage->data)
+ g_free (ximage->data);
+
+ g_free (ximage);
+
+ ximage = NULL;
+ }
+
g_mutex_unlock (ximagesink->x_lock);
-
+
return ximage;
}
-/* This function destroys a GstXImage handling XShm availability */
+/* This function destroys a GstXImage handling XShm availability */
static void
-gst_ximagesink_ximage_destroy (GstXImageSink *ximagesink, GstXImage *ximage)
+gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink, GstXImage * ximage)
{
g_return_if_fail (ximage != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
/* If the destroyed image is the current one we destroy our reference too */
if (ximagesink->cur_image == ximage)
ximagesink->cur_image = NULL;
-
+
g_mutex_lock (ximagesink->x_lock);
-
+
#ifdef HAVE_XSHM
- if (ximagesink->xcontext->use_xshm)
- {
- if (ximage->SHMInfo.shmaddr)
- XShmDetach (ximagesink->xcontext->disp, &ximage->SHMInfo);
-
- if (ximage->ximage)
- XDestroyImage (ximage->ximage);
-
- if (ximage->SHMInfo.shmaddr)
- shmdt (ximage->SHMInfo.shmaddr);
-
- if (ximage->SHMInfo.shmid > 0)
- shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
- }
- else
-#endif /* HAVE_XSHM */
- {
- if (ximage->ximage)
- XDestroyImage (ximage->ximage);
- }
-
+ if (ximagesink->xcontext->use_xshm) {
+ if (ximage->SHMInfo.shmaddr)
+ XShmDetach (ximagesink->xcontext->disp, &ximage->SHMInfo);
+
+ if (ximage->ximage)
+ XDestroyImage (ximage->ximage);
+
+ if (ximage->SHMInfo.shmaddr)
+ shmdt (ximage->SHMInfo.shmaddr);
+
+ if (ximage->SHMInfo.shmid > 0)
+ shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
+ } else
+#endif /* HAVE_XSHM */
+ {
+ if (ximage->ximage)
+ XDestroyImage (ximage->ximage);
+ }
+
XSync (ximagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (ximagesink->x_lock);
-
+
g_free (ximage);
}
/* This function puts a GstXImage on a GstXImageSink's window */
static void
-gst_ximagesink_ximage_put (GstXImageSink *ximagesink, GstXImage *ximage)
+gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImage * ximage)
{
gint x, y;
-
+
g_return_if_fail (ximage != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
/* Store a reference to the last image we put */
if (ximagesink->cur_image != ximage)
ximagesink->cur_image = ximage;
-
+
/* We center the image in the window */
x = MAX (0, (ximagesink->xwindow->width - ximage->width) / 2);
- y = MAX (0, (ximagesink->xwindow->height- ximage->height) / 2);
+ y = MAX (0, (ximagesink->xwindow->height - ximage->height) / 2);
g_mutex_lock (ximagesink->x_lock);
#ifdef HAVE_XSHM
- if (ximagesink->xcontext->use_xshm)
- {
- XShmPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
- ximagesink->xwindow->gc, ximage->ximage,
- 0, 0, x, y, ximage->width, ximage->height,
- FALSE);
- }
- else
+ if (ximagesink->xcontext->use_xshm) {
+ XShmPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
+ ximagesink->xwindow->gc, ximage->ximage,
+ 0, 0, x, y, ximage->width, ximage->height, FALSE);
+ } else
#endif /* HAVE_XSHM */
- {
- XPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
- ximagesink->xwindow->gc, ximage->ximage,
- 0, 0, x, y, ximage->width, ximage->height);
- }
-
+ {
+ XPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
+ ximagesink->xwindow->gc, ximage->ximage,
+ 0, 0, x, y, ximage->width, ximage->height);
+ }
+
XSync (ximagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (ximagesink->x_lock);
}
/* This function handles a GstXWindow creation */
static GstXWindow *
-gst_ximagesink_xwindow_new (GstXImageSink *ximagesink, gint width, gint height)
+gst_ximagesink_xwindow_new (GstXImageSink * ximagesink, gint width, gint height)
{
GstXWindow *xwindow = NULL;
-
+
g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
-
+
xwindow = g_new0 (GstXWindow, 1);
-
+
xwindow->width = width;
xwindow->height = height;
xwindow->internal = TRUE;
-
+
g_mutex_lock (ximagesink->x_lock);
-
+
xwindow->win = XCreateSimpleWindow (ximagesink->xcontext->disp,
- ximagesink->xcontext->root,
- 0, 0, xwindow->width, xwindow->height,
- 0, 0, ximagesink->xcontext->black);
+ ximagesink->xcontext->root,
+ 0, 0, xwindow->width, xwindow->height, 0, 0, ximagesink->xcontext->black);
XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |
- StructureNotifyMask | PointerMotionMask | KeyPressMask |
- KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
-
- xwindow->gc = XCreateGC (ximagesink->xcontext->disp,
- xwindow->win, 0, NULL);
+ StructureNotifyMask | PointerMotionMask | KeyPressMask |
+ KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
+
+ xwindow->gc = XCreateGC (ximagesink->xcontext->disp, xwindow->win, 0, NULL);
XMapRaised (ximagesink->xcontext->disp, xwindow->win);
-
+
XSync (ximagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (ximagesink->x_lock);
-
+
gst_x_overlay_got_xwindow_id (GST_X_OVERLAY (ximagesink), xwindow->win);
-
+
return xwindow;
}
/* This function destroys a GstXWindow */
static void
-gst_ximagesink_xwindow_destroy (GstXImageSink *ximagesink, GstXWindow *xwindow)
+gst_ximagesink_xwindow_destroy (GstXImageSink * ximagesink,
+ GstXWindow * xwindow)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
g_mutex_lock (ximagesink->x_lock);
-
+
/* If we did not create that window we just free the GC and let it live */
if (xwindow->internal)
XDestroyWindow (ximagesink->xcontext->disp, xwindow->win);
else
XSelectInput (ximagesink->xcontext->disp, xwindow->win, 0);
-
+
XFreeGC (ximagesink->xcontext->disp, xwindow->gc);
-
+
XSync (ximagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (ximagesink->x_lock);
-
+
g_free (xwindow);
}
/* This function resizes a GstXWindow */
static void
-gst_ximagesink_xwindow_resize (GstXImageSink *ximagesink, GstXWindow *xwindow,
- guint width, guint height)
+gst_ximagesink_xwindow_resize (GstXImageSink * ximagesink, GstXWindow * xwindow,
+ guint width, guint height)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
g_mutex_lock (ximagesink->x_lock);
-
+
xwindow->width = width;
xwindow->height = height;
-
+
XResizeWindow (ximagesink->xcontext->disp, xwindow->win,
- xwindow->width, xwindow->height);
-
+ xwindow->width, xwindow->height);
+
XSync (ximagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (ximagesink->x_lock);
}
static void
-gst_ximagesink_xwindow_clear (GstXImageSink *ximagesink, GstXWindow *xwindow)
+gst_ximagesink_xwindow_clear (GstXImageSink * ximagesink, GstXWindow * xwindow)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
g_mutex_lock (ximagesink->x_lock);
-
+
XSetForeground (ximagesink->xcontext->disp, xwindow->gc,
- ximagesink->xcontext->black);
-
+ ximagesink->xcontext->black);
+
XFillRectangle (ximagesink->xcontext->disp, xwindow->win, xwindow->gc,
- 0, 0, xwindow->width, xwindow->height);
-
+ 0, 0, xwindow->width, xwindow->height);
+
XSync (ximagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (ximagesink->x_lock);
}
static void
-gst_ximagesink_xwindow_update_geometry (GstXImageSink *ximagesink,
- GstXWindow *xwindow)
+gst_ximagesink_xwindow_update_geometry (GstXImageSink * ximagesink,
+ GstXWindow * xwindow)
{
XWindowAttributes attr;
-
+
g_return_if_fail (xwindow != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
/* Update the window geometry */
g_mutex_lock (ximagesink->x_lock);
XGetWindowAttributes (ximagesink->xcontext->disp,
- ximagesink->xwindow->win, &attr);
+ ximagesink->xwindow->win, &attr);
g_mutex_unlock (ximagesink->x_lock);
-
+
ximagesink->xwindow->width = attr.width;
ximagesink->xwindow->height = attr.height;
}
static void
-gst_ximagesink_renegotiate_size (GstXImageSink *ximagesink)
+gst_ximagesink_renegotiate_size (GstXImageSink * ximagesink)
{
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
if (!ximagesink->xwindow)
return;
-
+
gst_ximagesink_xwindow_update_geometry (ximagesink, ximagesink->xwindow);
-
+
if (ximagesink->sw_scaling_failed)
return;
-
+
if (ximagesink->xwindow->width <= 1 || ximagesink->xwindow->height <= 1)
return;
-
+
if (GST_PAD_IS_NEGOTIATING (GST_VIDEOSINK_PAD (ximagesink)) ||
!gst_pad_is_negotiated (GST_VIDEOSINK_PAD (ximagesink)))
return;
-
+
/* Window got resized or moved. We do caps negotiation again to get video
scaler to fit that new size only if size of the window differs from our
size. */
-
+
if (GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->xwindow->width ||
- GST_VIDEOSINK_HEIGHT (ximagesink) != ximagesink->xwindow->height)
- {
- GstPadLinkReturn r;
-
- r = gst_pad_try_set_caps (GST_VIDEOSINK_PAD (ximagesink),
- gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, ximagesink->xcontext->bpp,
- "depth", G_TYPE_INT, ximagesink->xcontext->depth,
- "endianness", G_TYPE_INT, ximagesink->xcontext->endianness,
- "red_mask", G_TYPE_INT, ximagesink->xcontext->visual->red_mask,
- "green_mask", G_TYPE_INT, ximagesink->xcontext->visual->green_mask,
- "blue_mask", G_TYPE_INT, ximagesink->xcontext->visual->blue_mask,
- "width", G_TYPE_INT, ximagesink->xwindow->width,
- "height", G_TYPE_INT, ximagesink->xwindow->height,
- "framerate", G_TYPE_DOUBLE, ximagesink->framerate,
- NULL));
-
- if ( (r == GST_PAD_LINK_OK) || (r == GST_PAD_LINK_DONE) )
- {
- /* Renegotiation succeeded, we update our size and image */
- GST_VIDEOSINK_WIDTH (ximagesink) = ximagesink->xwindow->width;
- GST_VIDEOSINK_HEIGHT (ximagesink) = ximagesink->xwindow->height;
-
- if ( (ximagesink->ximage) &&
- ( (GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) ||
- (GST_VIDEOSINK_HEIGHT (ximagesink) != ximagesink->ximage->height) ) )
- {
- /* We renew our ximage only if size changed */
- gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
-
- ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
- }
- }
- else
- {
- ximagesink->sw_scaling_failed = TRUE;
- }
+ GST_VIDEOSINK_HEIGHT (ximagesink) != ximagesink->xwindow->height) {
+ GstPadLinkReturn r;
+
+ r = gst_pad_try_set_caps (GST_VIDEOSINK_PAD (ximagesink),
+ gst_caps_new_simple ("video/x-raw-rgb",
+ "bpp", G_TYPE_INT, ximagesink->xcontext->bpp,
+ "depth", G_TYPE_INT, ximagesink->xcontext->depth,
+ "endianness", G_TYPE_INT, ximagesink->xcontext->endianness,
+ "red_mask", G_TYPE_INT, ximagesink->xcontext->visual->red_mask,
+ "green_mask", G_TYPE_INT, ximagesink->xcontext->visual->green_mask,
+ "blue_mask", G_TYPE_INT, ximagesink->xcontext->visual->blue_mask,
+ "width", G_TYPE_INT, ximagesink->xwindow->width,
+ "height", G_TYPE_INT, ximagesink->xwindow->height,
+ "framerate", G_TYPE_DOUBLE, ximagesink->framerate, NULL));
+
+ if ((r == GST_PAD_LINK_OK) || (r == GST_PAD_LINK_DONE)) {
+ /* Renegotiation succeeded, we update our size and image */
+ GST_VIDEOSINK_WIDTH (ximagesink) = ximagesink->xwindow->width;
+ GST_VIDEOSINK_HEIGHT (ximagesink) = ximagesink->xwindow->height;
+
+ if ((ximagesink->ximage) &&
+ ((GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) ||
+ (GST_VIDEOSINK_HEIGHT (ximagesink) !=
+ ximagesink->ximage->height))) {
+ /* We renew our ximage only if size changed */
+ gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
+
+ ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
+ GST_VIDEOSINK_WIDTH (ximagesink),
+ GST_VIDEOSINK_HEIGHT (ximagesink));
+ }
+ } else {
+ ximagesink->sw_scaling_failed = TRUE;
}
+ }
}
/* This function handles XEvents that might be in the queue. It generates
and navigation. It will also listen for configure events on the window to
trigger caps renegotiation so on the fly software scaling can work. */
static void
-gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
+gst_ximagesink_handle_xevents (GstXImageSink * ximagesink, GstPad * pad)
{
XEvent e;
guint pointer_x = 0, pointer_y = 0;
gboolean pointer_moved = FALSE;
-
+
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
gst_ximagesink_renegotiate_size (ximagesink);
-
+
/* Then we get all pointer motion events, only the last position is
interesting. */
g_mutex_lock (ximagesink->x_lock);
while (XCheckWindowEvent (ximagesink->xcontext->disp,
- ximagesink->xwindow->win,
- PointerMotionMask, &e))
- {
- g_mutex_unlock (ximagesink->x_lock);
-
- switch (e.type)
- {
- case MotionNotify:
- pointer_x = e.xmotion.x;
- pointer_y = e.xmotion.y;
- pointer_moved = TRUE;
- break;
- default:
- break;
- }
-
- g_mutex_lock (ximagesink->x_lock);
+ ximagesink->xwindow->win, PointerMotionMask, &e)) {
+ g_mutex_unlock (ximagesink->x_lock);
+
+ switch (e.type) {
+ case MotionNotify:
+ pointer_x = e.xmotion.x;
+ pointer_y = e.xmotion.y;
+ pointer_moved = TRUE;
+ break;
+ default:
+ break;
}
+
+ g_mutex_lock (ximagesink->x_lock);
+ }
g_mutex_unlock (ximagesink->x_lock);
- if (pointer_moved)
- {
- GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
- pointer_x, pointer_y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
- "mouse-move", 0, pointer_x, pointer_y);
- }
-
+ if (pointer_moved) {
+ GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
+ pointer_x, pointer_y);
+ gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
+ "mouse-move", 0, pointer_x, pointer_y);
+ }
+
/* We get all remaining events on our window to throw them upstream */
g_mutex_lock (ximagesink->x_lock);
while (XCheckWindowEvent (ximagesink->xcontext->disp,
- ximagesink->xwindow->win,
- KeyPressMask | KeyReleaseMask |
- ButtonPressMask | ButtonReleaseMask, &e))
- {
- KeySym keysym;
-
- /* We lock only for the X function call */
- g_mutex_unlock (ximagesink->x_lock);
-
- switch (e.type)
- {
- case ButtonPress:
- /* Mouse button pressed/released over our window. We send upstream
- events for interactivity/navigation */
- GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
- e.xbutton.button, e.xbutton.x, e.xbutton.x);
- gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
- "mouse-button-press",
- e.xbutton.button,
- e.xbutton.x, e.xbutton.y);
- break;
- case ButtonRelease:
- GST_DEBUG ("ximagesink button %d release over window at %d,%d",
- e.xbutton.button, e.xbutton.x, e.xbutton.x);
- gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
- "mouse-button-release",
- e.xbutton.button,
- e.xbutton.x, e.xbutton.y);
- break;
- case KeyPress:
- case KeyRelease:
- /* Key pressed/released over our window. We send upstream
- events for interactivity/navigation */
- GST_DEBUG ("ximagesink key %d pressed over window at %d,%d",
- e.xkey.keycode, e.xkey.x, e.xkey.x);
- keysym = XKeycodeToKeysym (ximagesink->xcontext->disp,
- e.xkey.keycode, 0);
- if (keysym != NoSymbol) {
- gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
- e.type == KeyPress ?
- "key-press" : "key-release",
- XKeysymToString (keysym));
- }
- else {
- gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
- e.type == KeyPress ?
- "key-press" : "key-release",
- "unknown");
- }
- break;
- default:
- GST_DEBUG ("ximagesink unhandled X event (%d)", e.type);
- }
-
- g_mutex_lock (ximagesink->x_lock);
+ ximagesink->xwindow->win,
+ KeyPressMask | KeyReleaseMask |
+ ButtonPressMask | ButtonReleaseMask, &e)) {
+ KeySym keysym;
+
+ /* We lock only for the X function call */
+ g_mutex_unlock (ximagesink->x_lock);
+
+ switch (e.type) {
+ case ButtonPress:
+ /* Mouse button pressed/released over our window. We send upstream
+ events for interactivity/navigation */
+ GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
+ e.xbutton.button, e.xbutton.x, e.xbutton.x);
+ gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
+ "mouse-button-press", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ break;
+ case ButtonRelease:
+ GST_DEBUG ("ximagesink button %d release over window at %d,%d",
+ e.xbutton.button, e.xbutton.x, e.xbutton.x);
+ gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
+ "mouse-button-release", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ break;
+ case KeyPress:
+ case KeyRelease:
+ /* Key pressed/released over our window. We send upstream
+ events for interactivity/navigation */
+ GST_DEBUG ("ximagesink key %d pressed over window at %d,%d",
+ e.xkey.keycode, e.xkey.x, e.xkey.x);
+ keysym = XKeycodeToKeysym (ximagesink->xcontext->disp,
+ e.xkey.keycode, 0);
+ if (keysym != NoSymbol) {
+ gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
+ e.type == KeyPress ?
+ "key-press" : "key-release", XKeysymToString (keysym));
+ } else {
+ gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
+ e.type == KeyPress ? "key-press" : "key-release", "unknown");
+ }
+ break;
+ default:
+ GST_DEBUG ("ximagesink unhandled X event (%d)", e.type);
}
+
+ g_mutex_lock (ximagesink->x_lock);
+ }
g_mutex_unlock (ximagesink->x_lock);
}
here that caps for supported format are generated without any window or
image creation */
static GstXContext *
-gst_ximagesink_xcontext_get (GstXImageSink *ximagesink)
+gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
{
GstXContext *xcontext = NULL;
XPixmapFormatValues *px_formats = NULL;
gint nb_formats = 0, i;
-
+
g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
-
+
xcontext = g_new0 (GstXContext, 1);
-
+
g_mutex_lock (ximagesink->x_lock);
-
+
xcontext->disp = XOpenDisplay (ximagesink->display_name);
-
- if (!xcontext->disp)
- {
- g_mutex_unlock (ximagesink->x_lock);
- g_free (xcontext);
- GST_ELEMENT_ERROR (ximagesink, RESOURCE, TOO_LAZY, (NULL),
- ("Could not open display"));
- return NULL;
- }
-
+
+ if (!xcontext->disp) {
+ g_mutex_unlock (ximagesink->x_lock);
+ g_free (xcontext);
+ GST_ELEMENT_ERROR (ximagesink, RESOURCE, TOO_LAZY, (NULL),
+ ("Could not open display"));
+ return NULL;
+ }
+
xcontext->screen = DefaultScreenOfDisplay (xcontext->disp);
xcontext->screen_num = DefaultScreen (xcontext->disp);
- xcontext->visual = DefaultVisual(xcontext->disp, xcontext->screen_num);
+ xcontext->visual = DefaultVisual (xcontext->disp, xcontext->screen_num);
xcontext->root = DefaultRootWindow (xcontext->disp);
xcontext->white = XWhitePixel (xcontext->disp, xcontext->screen_num);
xcontext->black = XBlackPixel (xcontext->disp, xcontext->screen_num);
xcontext->depth = DefaultDepthOfScreen (xcontext->screen);
-
+
/* We get supported pixmap formats at supported depth */
px_formats = XListPixmapFormats (xcontext->disp, &nb_formats);
-
- if (!px_formats)
- {
- XCloseDisplay (xcontext->disp);
- g_mutex_unlock (ximagesink->x_lock);
- g_free (xcontext);
- return NULL;
- }
-
+
+ if (!px_formats) {
+ XCloseDisplay (xcontext->disp);
+ g_mutex_unlock (ximagesink->x_lock);
+ g_free (xcontext);
+ return NULL;
+ }
+
/* We get bpp value corresponding to our running depth */
- for (i=0; i<nb_formats; i++)
- {
- if (px_formats[i].depth == xcontext->depth)
- xcontext->bpp = px_formats[i].bits_per_pixel;
- }
-
+ for (i = 0; i < nb_formats; i++) {
+ if (px_formats[i].depth == xcontext->depth)
+ xcontext->bpp = px_formats[i].bits_per_pixel;
+ }
+
XFree (px_formats);
-
- xcontext->endianness = (ImageByteOrder (xcontext->disp) == LSBFirst) ? G_LITTLE_ENDIAN:G_BIG_ENDIAN;
-
+
+ xcontext->endianness =
+ (ImageByteOrder (xcontext->disp) ==
+ LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
+
#ifdef HAVE_XSHM
/* Search for XShm extension support */
if (XShmQueryExtension (xcontext->disp) &&
- gst_ximagesink_check_xshm_calls (xcontext))
- {
- xcontext->use_xshm = TRUE;
- GST_DEBUG ("ximagesink is using XShm extension");
- }
- else
- {
- xcontext->use_xshm = FALSE;
- GST_DEBUG ("ximagesink is not using XShm extension");
- }
+ gst_ximagesink_check_xshm_calls (xcontext)) {
+ xcontext->use_xshm = TRUE;
+ GST_DEBUG ("ximagesink is using XShm extension");
+ } else {
+ xcontext->use_xshm = FALSE;
+ GST_DEBUG ("ximagesink is not using XShm extension");
+ }
#endif /* HAVE_XSHM */
/* our caps system handles 24/32bpp RGB as big-endian. */
xcontext->visual->blue_mask >>= 8;
}
}
-
+
xcontext->caps = gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, xcontext->bpp,
- "depth", G_TYPE_INT, xcontext->depth,
+ "bpp", G_TYPE_INT, xcontext->bpp,
+ "depth", G_TYPE_INT, xcontext->depth,
"endianness", G_TYPE_INT, xcontext->endianness,
- "red_mask", G_TYPE_INT, xcontext->visual->red_mask,
+ "red_mask", G_TYPE_INT, xcontext->visual->red_mask,
"green_mask", G_TYPE_INT, xcontext->visual->green_mask,
- "blue_mask", G_TYPE_INT, xcontext->visual->blue_mask,
- "width", GST_TYPE_INT_RANGE, 0, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 0, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 1.0, 100.0,
- NULL);
-
+ "blue_mask", G_TYPE_INT, xcontext->visual->blue_mask,
+ "width", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 1.0, 100.0, NULL);
+
g_mutex_unlock (ximagesink->x_lock);
-
+
return xcontext;
}
/* This function cleans the X context. Closing the Display and unrefing the
caps for supported formats. */
static void
-gst_ximagesink_xcontext_clear (GstXImageSink *ximagesink)
+gst_ximagesink_xcontext_clear (GstXImageSink * ximagesink)
{
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
gst_caps_free (ximagesink->xcontext->caps);
-
+
g_mutex_lock (ximagesink->x_lock);
-
+
XCloseDisplay (ximagesink->xcontext->disp);
-
+
g_mutex_unlock (ximagesink->x_lock);
-
+
ximagesink->xcontext = NULL;
}
static void
-gst_ximagesink_imagepool_clear (GstXImageSink *ximagesink)
+gst_ximagesink_imagepool_clear (GstXImageSink * ximagesink)
{
- g_mutex_lock(ximagesink->pool_lock);
-
- while (ximagesink->image_pool)
- {
- GstXImage *ximage = ximagesink->image_pool->data;
- ximagesink->image_pool = g_slist_delete_link (ximagesink->image_pool,
- ximagesink->image_pool);
- gst_ximagesink_ximage_destroy (ximagesink, ximage);
- }
-
- g_mutex_unlock(ximagesink->pool_lock);
+ g_mutex_lock (ximagesink->pool_lock);
+
+ while (ximagesink->image_pool) {
+ GstXImage *ximage = ximagesink->image_pool->data;
+
+ ximagesink->image_pool = g_slist_delete_link (ximagesink->image_pool,
+ ximagesink->image_pool);
+ gst_ximagesink_ximage_destroy (ximagesink, ximage);
+ }
+
+ g_mutex_unlock (ximagesink->pool_lock);
}
/* Element stuff */
static GstCaps *
-gst_ximagesink_fixate (GstPad *pad, const GstCaps *caps)
+gst_ximagesink_fixate (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstCaps *newcaps;
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
}
static GstCaps *
-gst_ximagesink_getcaps (GstPad *pad)
+gst_ximagesink_getcaps (GstPad * pad)
{
GstXImageSink *ximagesink;
-
+
ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
-
+
if (ximagesink->xcontext)
return gst_caps_copy (ximagesink->xcontext->caps);
return gst_caps_from_string ("video/x-raw-rgb, "
"framerate = (double) [ 1, 100 ], "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ]");
+ "width = (int) [ 0, MAX ], " "height = (int) [ 0, MAX ]");
}
static GstPadLinkReturn
-gst_ximagesink_sink_link (GstPad *pad, const GstCaps *caps)
+gst_ximagesink_sink_link (GstPad * pad, const GstCaps * caps)
{
GstXImageSink *ximagesink;
char *caps_str1, *caps_str2;
if (!ximagesink->xcontext)
return GST_PAD_LINK_DELAYED;
-
+
caps_str1 = gst_caps_to_string (ximagesink->xcontext->caps);
caps_str2 = gst_caps_to_string (caps);
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width",
- &(GST_VIDEOSINK_WIDTH (ximagesink)));
+ &(GST_VIDEOSINK_WIDTH (ximagesink)));
ret &= gst_structure_get_int (structure, "height",
- &(GST_VIDEOSINK_HEIGHT (ximagesink)));
+ &(GST_VIDEOSINK_HEIGHT (ximagesink)));
ret &= gst_structure_get_double (structure,
- "framerate", &ximagesink->framerate);
- if (!ret) return GST_PAD_LINK_REFUSED;
-
+ "framerate", &ximagesink->framerate);
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
+
ximagesink->pixel_width = 1;
- gst_structure_get_int (structure, "pixel_width",
- &ximagesink->pixel_width);
+ gst_structure_get_int (structure, "pixel_width", &ximagesink->pixel_width);
ximagesink->pixel_height = 1;
- gst_structure_get_int (structure, "pixel_height",
- &ximagesink->pixel_height);
-
+ gst_structure_get_int (structure, "pixel_height", &ximagesink->pixel_height);
+
/* Creating our window and our image */
if (!ximagesink->xwindow)
ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
- else
- {
- if (ximagesink->xwindow->internal)
- gst_ximagesink_xwindow_resize (ximagesink, ximagesink->xwindow,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
- }
-
- if ( (ximagesink->ximage) &&
- ( (GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) ||
- (GST_VIDEOSINK_HEIGHT (ximagesink) != ximagesink->ximage->height) ) )
- { /* We renew our ximage only if size changed */
- gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
-
- ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
- }
- else if (!ximagesink->ximage) /* If no ximage, creating one */
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+ else {
+ if (ximagesink->xwindow->internal)
+ gst_ximagesink_xwindow_resize (ximagesink, ximagesink->xwindow,
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+ }
+
+ if ((ximagesink->ximage) && ((GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) || (GST_VIDEOSINK_HEIGHT (ximagesink) != ximagesink->ximage->height))) { /* We renew our ximage only if size changed */
+ gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
+
+ ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+ } else if (!ximagesink->ximage) /* If no ximage, creating one */
ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
-
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+
gst_x_overlay_got_desired_size (GST_X_OVERLAY (ximagesink),
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
-
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+
return GST_PAD_LINK_OK;
}
static GstElementStateReturn
-gst_ximagesink_change_state (GstElement *element)
+gst_ximagesink_change_state (GstElement * element)
{
GstXImageSink *ximagesink;
case GST_STATE_NULL_TO_READY:
/* Initializing the XContext */
if (!ximagesink->xcontext)
- ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink);
+ ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink);
if (!ximagesink->xcontext)
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
break;
case GST_STATE_READY_TO_PAUSED:
if (ximagesink->xwindow)
- gst_ximagesink_xwindow_clear (ximagesink, ximagesink->xwindow);
+ gst_ximagesink_xwindow_clear (ximagesink, ximagesink->xwindow);
ximagesink->time = 0;
break;
case GST_STATE_PAUSED_TO_PLAYING:
GST_VIDEOSINK_HEIGHT (ximagesink) = 0;
break;
case GST_STATE_READY_TO_NULL:
- if (ximagesink->ximage)
- {
- gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
- ximagesink->ximage = NULL;
- }
-
+ if (ximagesink->ximage) {
+ gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
+ ximagesink->ximage = NULL;
+ }
+
if (ximagesink->image_pool)
- gst_ximagesink_imagepool_clear (ximagesink);
-
- if (ximagesink->xwindow)
- {
- gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);
- ximagesink->xwindow = NULL;
- }
-
- if (ximagesink->xcontext)
- {
- gst_ximagesink_xcontext_clear (ximagesink);
- ximagesink->xcontext = NULL;
- }
+ gst_ximagesink_imagepool_clear (ximagesink);
+
+ if (ximagesink->xwindow) {
+ gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);
+ ximagesink->xwindow = NULL;
+ }
+
+ if (ximagesink->xcontext) {
+ gst_ximagesink_xcontext_clear (ximagesink);
+ ximagesink->xcontext = NULL;
+ }
break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return GST_STATE_SUCCESS;
}
static void
-gst_ximagesink_chain (GstPad *pad, GstData *data)
+gst_ximagesink_chain (GstPad * pad, GstData * data)
{
GstBuffer *buf = GST_BUFFER (data);
GstXImageSink *ximagesink;
-
+
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
-
- if (GST_IS_EVENT (data))
- {
- gst_pad_event_default (pad, GST_EVENT (data));
- return;
- }
-
+
+ if (GST_IS_EVENT (data)) {
+ gst_pad_event_default (pad, GST_EVENT (data));
+ return;
+ }
+
buf = GST_BUFFER (data);
/* update time */
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
if (GST_VIDEOSINK_CLOCK (ximagesink)) {
gst_element_wait (GST_ELEMENT (ximagesink), ximagesink->time);
}
-
+
/* If this buffer has been allocated using our buffer management we simply
put the ximage which is in the PRIVATE pointer */
- if (GST_BUFFER_FREE_DATA_FUNC (buf) == gst_ximagesink_buffer_free)
- {
- gst_ximagesink_ximage_put (ximagesink, GST_BUFFER_PRIVATE (buf));
- }
- else /* Else we have to copy the data into our private image, */
- { /* if we have one... */
- if (ximagesink->ximage)
- {
- memcpy (ximagesink->ximage->ximage->data,
- GST_BUFFER_DATA (buf),
- MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size));
- gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage);
- }
- else /* No image available. Something went wrong during capsnego ! */
- {
- gst_buffer_unref (buf);
- GST_ELEMENT_ERROR (ximagesink, CORE, NEGOTIATION, (NULL), ("no format defined before chain function"));
- return;
- }
+ if (GST_BUFFER_FREE_DATA_FUNC (buf) == gst_ximagesink_buffer_free) {
+ gst_ximagesink_ximage_put (ximagesink, GST_BUFFER_PRIVATE (buf));
+ } else { /* Else we have to copy the data into our private image, */
+ /* if we have one... */
+ if (ximagesink->ximage) {
+ memcpy (ximagesink->ximage->ximage->data,
+ GST_BUFFER_DATA (buf),
+ MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size));
+ gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage);
+ } else { /* No image available. Something went wrong during capsnego ! */
+
+ gst_buffer_unref (buf);
+ GST_ELEMENT_ERROR (ximagesink, CORE, NEGOTIATION, (NULL),
+ ("no format defined before chain function"));
+ return;
}
+ }
/* set correct time for next buffer */
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf) && ximagesink->framerate > 0) {
ximagesink->time += GST_SECOND / ximagesink->framerate;
}
-
+
gst_buffer_unref (buf);
-
+
gst_ximagesink_handle_xevents (ximagesink, pad);
}
/* Buffer management */
static void
-gst_ximagesink_buffer_free (GstBuffer *buffer)
+gst_ximagesink_buffer_free (GstBuffer * buffer)
{
GstXImageSink *ximagesink;
GstXImage *ximage;
-
+
ximage = GST_BUFFER_PRIVATE (buffer);
-
+
g_assert (GST_IS_XIMAGESINK (ximage->ximagesink));
ximagesink = ximage->ximagesink;
-
+
/* If our geometry changed we can't reuse that image. */
- if ( (ximage->width != GST_VIDEOSINK_WIDTH (ximagesink)) ||
- (ximage->height != GST_VIDEOSINK_HEIGHT (ximagesink)) )
+ if ((ximage->width != GST_VIDEOSINK_WIDTH (ximagesink)) ||
+ (ximage->height != GST_VIDEOSINK_HEIGHT (ximagesink)))
gst_ximagesink_ximage_destroy (ximagesink, ximage);
- else /* In that case we can reuse the image and add it to our image pool. */
- {
- g_mutex_lock (ximagesink->pool_lock);
- ximagesink->image_pool = g_slist_prepend (ximagesink->image_pool, ximage);
- g_mutex_unlock (ximagesink->pool_lock);
- }
+ else { /* In that case we can reuse the image and add it to our image pool. */
+
+ g_mutex_lock (ximagesink->pool_lock);
+ ximagesink->image_pool = g_slist_prepend (ximagesink->image_pool, ximage);
+ g_mutex_unlock (ximagesink->pool_lock);
+ }
}
static GstBuffer *
-gst_ximagesink_buffer_alloc (GstPad *pad, guint64 offset, guint size)
+gst_ximagesink_buffer_alloc (GstPad * pad, guint64 offset, guint size)
{
GstXImageSink *ximagesink;
GstBuffer *buffer;
GstXImage *ximage = NULL;
gboolean not_found = TRUE;
-
+
ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
g_mutex_lock (ximagesink->pool_lock);
-
+
/* Walking through the pool cleaning unsuable images and searching for a
suitable one */
- while (not_found && ximagesink->image_pool)
- {
- ximage = ximagesink->image_pool->data;
-
- if (ximage)
- {
- /* Removing from the pool */
- ximagesink->image_pool = g_slist_delete_link (ximagesink->image_pool,
- ximagesink->image_pool);
-
- if ( (ximage->width != GST_VIDEOSINK_WIDTH (ximagesink)) ||
- (ximage->height != GST_VIDEOSINK_HEIGHT (ximagesink)) )
- { /* This image is unusable. Destroying... */
- gst_ximagesink_ximage_destroy (ximagesink, ximage);
- ximage = NULL;
- }
- else /* We found a suitable image */
- {
- break;
- }
- }
+ while (not_found && ximagesink->image_pool) {
+ ximage = ximagesink->image_pool->data;
+
+ if (ximage) {
+ /* Removing from the pool */
+ ximagesink->image_pool = g_slist_delete_link (ximagesink->image_pool,
+ ximagesink->image_pool);
+
+ if ((ximage->width != GST_VIDEOSINK_WIDTH (ximagesink)) || (ximage->height != GST_VIDEOSINK_HEIGHT (ximagesink))) { /* This image is unusable. Destroying... */
+ gst_ximagesink_ximage_destroy (ximagesink, ximage);
+ ximage = NULL;
+ } else { /* We found a suitable image */
+
+ break;
+ }
}
-
+ }
+
g_mutex_unlock (ximagesink->pool_lock);
-
- if (!ximage) /* We found no suitable image in the pool. Creating... */
- {
- ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
- }
-
- if (ximage)
- {
- buffer = gst_buffer_new ();
-
- /* Storing some pointers in the buffer */
- GST_BUFFER_PRIVATE (buffer) = ximage;
-
- GST_BUFFER_DATA (buffer) = ximage->ximage->data;
- GST_BUFFER_FREE_DATA_FUNC (buffer) = gst_ximagesink_buffer_free;
- GST_BUFFER_SIZE (buffer) = ximage->size;
- return buffer;
- }
- else
+
+ if (!ximage) { /* We found no suitable image in the pool. Creating... */
+ ximage = gst_ximagesink_ximage_new (ximagesink,
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+ }
+
+ if (ximage) {
+ buffer = gst_buffer_new ();
+
+ /* Storing some pointers in the buffer */
+ GST_BUFFER_PRIVATE (buffer) = ximage;
+
+ GST_BUFFER_DATA (buffer) = ximage->ximage->data;
+ GST_BUFFER_FREE_DATA_FUNC (buffer) = gst_ximagesink_buffer_free;
+ GST_BUFFER_SIZE (buffer) = ximage->size;
+ return buffer;
+ } else
return NULL;
}
/* Interfaces stuff */
static gboolean
-gst_ximagesink_interface_supported (GstImplementsInterface *iface, GType type)
+gst_ximagesink_interface_supported (GstImplementsInterface * iface, GType type)
{
g_assert (type == GST_TYPE_NAVIGATION || type == GST_TYPE_X_OVERLAY);
return TRUE;
}
static void
-gst_ximagesink_interface_init (GstImplementsInterfaceClass *klass)
+gst_ximagesink_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_ximagesink_interface_supported;
}
static void
-gst_ximagesink_navigation_send_event (GstNavigation *navigation,
- GstStructure *structure)
+gst_ximagesink_navigation_send_event (GstNavigation * navigation,
+ GstStructure * structure)
{
GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
GstEvent *event;
gint x_offset, y_offset;
- double x,y;
-
+ double x, y;
+
event = gst_event_new (GST_EVENT_NAVIGATION);
event->event_data.structure.structure = structure;
videoscale will have to catch those events and tranform the coordinates
to match the applied scaling. So here we just add the offset if the image
is centered in the window. */
-
+
x_offset = ximagesink->xwindow->width - GST_VIDEOSINK_WIDTH (ximagesink);
y_offset = ximagesink->xwindow->height - GST_VIDEOSINK_HEIGHT (ximagesink);
-
- if (gst_structure_get_double (structure, "pointer_x", &x))
- {
- x += x_offset;
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
- }
- if (gst_structure_get_double (structure, "pointer_y", &y))
- {
- y += y_offset;
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
- }
-
+
+ if (gst_structure_get_double (structure, "pointer_x", &x)) {
+ x += x_offset;
+ gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
+ }
+ if (gst_structure_get_double (structure, "pointer_y", &y)) {
+ y += y_offset;
+ gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
+ }
+
gst_pad_send_event (gst_pad_get_peer (GST_VIDEOSINK_PAD (ximagesink)), event);
}
static void
-gst_ximagesink_navigation_init (GstNavigationInterface *iface)
+gst_ximagesink_navigation_init (GstNavigationInterface * iface)
{
iface->send_event = gst_ximagesink_navigation_send_event;
}
static void
-gst_ximagesink_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id)
+gst_ximagesink_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
{
GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);
GstXWindow *xwindow = NULL;
XWindowAttributes attr;
-
+
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
+
/* If we already use that window return */
if (ximagesink->xwindow && (xwindow_id == ximagesink->xwindow->win))
return;
-
+
/* If the element has not initialized the X11 context try to do so */
if (!ximagesink->xcontext)
ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink);
-
- if (!ximagesink->xcontext)
- {
- g_warning ("ximagesink was unable to obtain the X11 context.");
- return;
- }
-
+
+ if (!ximagesink->xcontext) {
+ g_warning ("ximagesink was unable to obtain the X11 context.");
+ return;
+ }
+
/* Clear image pool as the images are unusable anyway */
gst_ximagesink_imagepool_clear (ximagesink);
-
+
/* Clear the ximage */
- if (ximagesink->ximage)
- {
- gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
- ximagesink->ximage = NULL;
- }
-
+ if (ximagesink->ximage) {
+ gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
+ ximagesink->ximage = NULL;
+ }
+
/* If a window is there already we destroy it */
- if (ximagesink->xwindow)
- {
- gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);
- ximagesink->xwindow = NULL;
- }
-
+ if (ximagesink->xwindow) {
+ gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);
+ ximagesink->xwindow = NULL;
+ }
+
/* If the xid is 0 we go back to an internal window */
- if (xwindow_id == 0)
- {
- /* If no width/height caps nego did not happen window will be created
- during caps nego then */
- if (GST_VIDEOSINK_WIDTH (ximagesink) &&
- GST_VIDEOSINK_HEIGHT (ximagesink))
- {
- xwindow = gst_ximagesink_xwindow_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
- }
+ if (xwindow_id == 0) {
+ /* If no width/height caps nego did not happen window will be created
+ during caps nego then */
+ if (GST_VIDEOSINK_WIDTH (ximagesink) && GST_VIDEOSINK_HEIGHT (ximagesink)) {
+ xwindow = gst_ximagesink_xwindow_new (ximagesink,
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
}
- else
- {
- xwindow = g_new0 (GstXWindow, 1);
-
- xwindow->win = xwindow_id;
-
- /* We get window geometry, set the event we want to receive,
- and create a GC */
- g_mutex_lock (ximagesink->x_lock);
- XGetWindowAttributes (ximagesink->xcontext->disp, xwindow->win, &attr);
- xwindow->width = attr.width;
- xwindow->height = attr.height;
- xwindow->internal = FALSE;
- XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |
- StructureNotifyMask | PointerMotionMask | KeyPressMask |
- KeyReleaseMask);
-
- xwindow->gc = XCreateGC (ximagesink->xcontext->disp,
- xwindow->win, 0, NULL);
- g_mutex_unlock (ximagesink->x_lock);
-
- /* If that new window geometry differs from our one we try to
- renegotiate caps */
- if (gst_pad_is_negotiated (GST_VIDEOSINK_PAD (ximagesink)) &&
- (xwindow->width != GST_VIDEOSINK_WIDTH (ximagesink) ||
- xwindow->height != GST_VIDEOSINK_HEIGHT (ximagesink)))
- {
- GstPadLinkReturn r;
- r = gst_pad_try_set_caps (GST_VIDEOSINK_PAD (ximagesink),
- gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, ximagesink->xcontext->bpp,
- "depth", G_TYPE_INT, ximagesink->xcontext->depth,
- "endianness", G_TYPE_INT, ximagesink->xcontext->endianness,
- "red_mask", G_TYPE_INT, ximagesink->xcontext->visual->red_mask,
- "green_mask", G_TYPE_INT, ximagesink->xcontext->visual->green_mask,
- "blue_mask", G_TYPE_INT, ximagesink->xcontext->visual->blue_mask,
- "width", G_TYPE_INT, xwindow->width,
- "height", G_TYPE_INT, xwindow->height,
- "framerate", G_TYPE_DOUBLE, ximagesink->framerate,
- NULL));
-
- /* If caps nego succeded updating our size */
- if ( (r == GST_PAD_LINK_OK) || (r == GST_PAD_LINK_DONE) )
- {
- GST_VIDEOSINK_WIDTH (ximagesink) = xwindow->width;
- GST_VIDEOSINK_HEIGHT (ximagesink) = xwindow->height;
- }
- }
+ } else {
+ xwindow = g_new0 (GstXWindow, 1);
+
+ xwindow->win = xwindow_id;
+
+ /* We get window geometry, set the event we want to receive,
+ and create a GC */
+ g_mutex_lock (ximagesink->x_lock);
+ XGetWindowAttributes (ximagesink->xcontext->disp, xwindow->win, &attr);
+ xwindow->width = attr.width;
+ xwindow->height = attr.height;
+ xwindow->internal = FALSE;
+ XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |
+ StructureNotifyMask | PointerMotionMask | KeyPressMask |
+ KeyReleaseMask);
+
+ xwindow->gc = XCreateGC (ximagesink->xcontext->disp, xwindow->win, 0, NULL);
+ g_mutex_unlock (ximagesink->x_lock);
+
+ /* If that new window geometry differs from our one we try to
+ renegotiate caps */
+ if (gst_pad_is_negotiated (GST_VIDEOSINK_PAD (ximagesink)) &&
+ (xwindow->width != GST_VIDEOSINK_WIDTH (ximagesink) ||
+ xwindow->height != GST_VIDEOSINK_HEIGHT (ximagesink))) {
+ GstPadLinkReturn r;
+
+ r = gst_pad_try_set_caps (GST_VIDEOSINK_PAD (ximagesink),
+ gst_caps_new_simple ("video/x-raw-rgb",
+ "bpp", G_TYPE_INT, ximagesink->xcontext->bpp,
+ "depth", G_TYPE_INT, ximagesink->xcontext->depth,
+ "endianness", G_TYPE_INT, ximagesink->xcontext->endianness,
+ "red_mask", G_TYPE_INT, ximagesink->xcontext->visual->red_mask,
+ "green_mask", G_TYPE_INT,
+ ximagesink->xcontext->visual->green_mask, "blue_mask", G_TYPE_INT,
+ ximagesink->xcontext->visual->blue_mask, "width", G_TYPE_INT,
+ xwindow->width, "height", G_TYPE_INT, xwindow->height,
+ "framerate", G_TYPE_DOUBLE, ximagesink->framerate, NULL));
+
+ /* If caps nego succeded updating our size */
+ if ((r == GST_PAD_LINK_OK) || (r == GST_PAD_LINK_DONE)) {
+ GST_VIDEOSINK_WIDTH (ximagesink) = xwindow->width;
+ GST_VIDEOSINK_HEIGHT (ximagesink) = xwindow->height;
+ }
}
-
+ }
+
/* Recreating our ximage */
if (!ximagesink->ximage &&
- GST_VIDEOSINK_WIDTH (ximagesink) &&
- GST_VIDEOSINK_HEIGHT (ximagesink))
- {
- ximagesink->ximage = gst_ximagesink_ximage_new (
- ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
- }
-
+ GST_VIDEOSINK_WIDTH (ximagesink) && GST_VIDEOSINK_HEIGHT (ximagesink)) {
+ ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+ }
+
if (xwindow)
ximagesink->xwindow = xwindow;
}
static void
-gst_ximagesink_get_desired_size (GstXOverlay *overlay,
- guint *width, guint *height)
+gst_ximagesink_get_desired_size (GstXOverlay * overlay,
+ guint * width, guint * height)
{
GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);
}
static void
-gst_ximagesink_expose (GstXOverlay *overlay)
+gst_ximagesink_expose (GstXOverlay * overlay)
{
GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);
-
+
if (!ximagesink->xwindow)
return;
-
+
gst_ximagesink_xwindow_update_geometry (ximagesink, ximagesink->xwindow);
-
+
/* We don't act on internal window from outside that could cause some thread
race with the video sink own thread checking for configure event */
if (ximagesink->xwindow->internal)
return;
-
+
gst_ximagesink_xwindow_clear (ximagesink, ximagesink->xwindow);
-
+
if (ximagesink->cur_image)
gst_ximagesink_ximage_put (ximagesink, ximagesink->cur_image);
}
static void
-gst_ximagesink_xoverlay_init (GstXOverlayClass *iface)
+gst_ximagesink_xoverlay_init (GstXOverlayClass * iface)
{
iface->set_xwindow_id = gst_ximagesink_set_xwindow_id;
iface->get_desired_size = gst_ximagesink_get_desired_size;
/* =========================================== */
static void
-gst_ximagesink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_ximagesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstXImageSink *ximagesink;
-
+
g_return_if_fail (GST_IS_XIMAGESINK (object));
-
+
ximagesink = GST_XIMAGESINK (object);
-
- switch (prop_id)
- {
- case ARG_DISPLAY:
- ximagesink->display_name = g_strdup (g_value_get_string (value));
- break;
- case ARG_SYNCHRONOUS:
- ximagesink->synchronous = g_value_get_boolean (value);
- if (ximagesink->xcontext) {
- XSynchronize (ximagesink->xcontext->disp,
- ximagesink->synchronous);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+
+ switch (prop_id) {
+ case ARG_DISPLAY:
+ ximagesink->display_name = g_strdup (g_value_get_string (value));
+ break;
+ case ARG_SYNCHRONOUS:
+ ximagesink->synchronous = g_value_get_boolean (value);
+ if (ximagesink->xcontext) {
+ XSynchronize (ximagesink->xcontext->disp, ximagesink->synchronous);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gst_ximagesink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_ximagesink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstXImageSink *ximagesink;
-
+
g_return_if_fail (GST_IS_XIMAGESINK (object));
-
+
ximagesink = GST_XIMAGESINK (object);
-
- switch (prop_id)
- {
- case ARG_DISPLAY:
- g_value_set_string (value, g_strdup (ximagesink->display_name));
- break;
- case ARG_SYNCHRONOUS:
- g_value_set_boolean (value, ximagesink->synchronous);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+
+ switch (prop_id) {
+ case ARG_DISPLAY:
+ g_value_set_string (value, g_strdup (ximagesink->display_name));
+ break;
+ case ARG_SYNCHRONOUS:
+ g_value_set_boolean (value, ximagesink->synchronous);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gst_ximagesink_dispose (GObject *object)
+gst_ximagesink_dispose (GObject * object)
{
GstXImageSink *ximagesink;
ximagesink = GST_XIMAGESINK (object);
- if (ximagesink->display_name)
- {
- g_free (ximagesink->display_name);
- ximagesink->display_name = NULL;
- }
+ if (ximagesink->display_name) {
+ g_free (ximagesink->display_name);
+ ximagesink->display_name = NULL;
+ }
g_mutex_free (ximagesink->x_lock);
g_mutex_free (ximagesink->pool_lock);
}
static void
-gst_ximagesink_init (GstXImageSink *ximagesink)
+gst_ximagesink_init (GstXImageSink * ximagesink)
{
- GST_VIDEOSINK_PAD (ximagesink) = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_ximagesink_sink_template_factory),
- "sink");
-
+ GST_VIDEOSINK_PAD (ximagesink) =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_ximagesink_sink_template_factory), "sink");
+
gst_element_add_pad (GST_ELEMENT (ximagesink),
- GST_VIDEOSINK_PAD (ximagesink));
+ GST_VIDEOSINK_PAD (ximagesink));
gst_pad_set_chain_function (GST_VIDEOSINK_PAD (ximagesink),
- gst_ximagesink_chain);
+ gst_ximagesink_chain);
gst_pad_set_link_function (GST_VIDEOSINK_PAD (ximagesink),
- gst_ximagesink_sink_link);
+ gst_ximagesink_sink_link);
gst_pad_set_getcaps_function (GST_VIDEOSINK_PAD (ximagesink),
- gst_ximagesink_getcaps);
+ gst_ximagesink_getcaps);
gst_pad_set_fixate_function (GST_VIDEOSINK_PAD (ximagesink),
- gst_ximagesink_fixate);
+ gst_ximagesink_fixate);
gst_pad_set_bufferalloc_function (GST_VIDEOSINK_PAD (ximagesink),
- gst_ximagesink_buffer_alloc);
-
+ gst_ximagesink_buffer_alloc);
+
ximagesink->display_name = NULL;
ximagesink->xcontext = NULL;
ximagesink->xwindow = NULL;
ximagesink->ximage = NULL;
ximagesink->cur_image = NULL;
-
+
ximagesink->framerate = 0;
-
+
ximagesink->x_lock = g_mutex_new ();
-
+
ximagesink->pixel_width = ximagesink->pixel_height = 1;
-
+
ximagesink->image_pool = NULL;
ximagesink->pool_lock = g_mutex_new ();
-
+
ximagesink->sw_scaling_failed = FALSE;
ximagesink->synchronous = FALSE;
- GST_FLAG_SET(ximagesink, GST_ELEMENT_THREAD_SUGGESTED);
- GST_FLAG_SET(ximagesink, GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (ximagesink, GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (ximagesink, GST_ELEMENT_EVENT_AWARE);
}
static void
gst_ximagesink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &gst_ximagesink_details);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_ximagesink_sink_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_ximagesink_sink_template_factory));
}
static void
-gst_ximagesink_class_init (GstXImageSinkClass *klass)
+gst_ximagesink_class_init (GstXImageSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_VIDEOSINK);
-
+
g_object_class_install_property (gobject_class, ARG_DISPLAY,
- g_param_spec_string ("display", "Display", "X Display name",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("display", "Display", "X Display name",
+ NULL, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_SYNCHRONOUS,
- g_param_spec_boolean ("synchronous", "Synchronous", "When enabled, runs "
- "the X display in synchronous mode. (used only for debugging)", FALSE,
- G_PARAM_READWRITE));
-
+ g_param_spec_boolean ("synchronous", "Synchronous", "When enabled, runs "
+ "the X display in synchronous mode. (used only for debugging)", FALSE,
+ G_PARAM_READWRITE));
+
gobject_class->dispose = gst_ximagesink_dispose;
gobject_class->set_property = gst_ximagesink_set_property;
gobject_class->get_property = gst_ximagesink_get_property;
-
+
gstelement_class->change_state = gst_ximagesink_change_state;
}
{
static GType ximagesink_type = 0;
- if (!ximagesink_type)
- {
- static const GTypeInfo ximagesink_info = {
- sizeof(GstXImageSinkClass),
- gst_ximagesink_base_init,
- NULL,
- (GClassInitFunc) gst_ximagesink_class_init,
- NULL,
- NULL,
- sizeof(GstXImageSink),
- 0,
- (GInstanceInitFunc) gst_ximagesink_init,
- };
- static const GInterfaceInfo iface_info = {
- (GInterfaceInitFunc) gst_ximagesink_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo navigation_info = {
- (GInterfaceInitFunc) gst_ximagesink_navigation_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo overlay_info = {
- (GInterfaceInitFunc) gst_ximagesink_xoverlay_init,
- NULL,
- NULL,
- };
-
- ximagesink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
- "GstXImageSink",
- &ximagesink_info, 0);
-
- g_type_add_interface_static (ximagesink_type, GST_TYPE_IMPLEMENTS_INTERFACE,
- &iface_info);
- g_type_add_interface_static (ximagesink_type, GST_TYPE_NAVIGATION,
- &navigation_info);
- g_type_add_interface_static (ximagesink_type, GST_TYPE_X_OVERLAY,
- &overlay_info);
- }
-
+ if (!ximagesink_type) {
+ static const GTypeInfo ximagesink_info = {
+ sizeof (GstXImageSinkClass),
+ gst_ximagesink_base_init,
+ NULL,
+ (GClassInitFunc) gst_ximagesink_class_init,
+ NULL,
+ NULL,
+ sizeof (GstXImageSink),
+ 0,
+ (GInstanceInitFunc) gst_ximagesink_init,
+ };
+ static const GInterfaceInfo iface_info = {
+ (GInterfaceInitFunc) gst_ximagesink_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo navigation_info = {
+ (GInterfaceInitFunc) gst_ximagesink_navigation_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo overlay_info = {
+ (GInterfaceInitFunc) gst_ximagesink_xoverlay_init,
+ NULL,
+ NULL,
+ };
+
+ ximagesink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
+ "GstXImageSink", &ximagesink_info, 0);
+
+ g_type_add_interface_static (ximagesink_type, GST_TYPE_IMPLEMENTS_INTERFACE,
+ &iface_info);
+ g_type_add_interface_static (ximagesink_type, GST_TYPE_NAVIGATION,
+ &navigation_info);
+ g_type_add_interface_static (ximagesink_type, GST_TYPE_X_OVERLAY,
+ &overlay_info);
+ }
+
return ximagesink_type;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* Loading the library containing GstVideoSink, our parent object */
if (!gst_library_load ("gstvideo"))
return FALSE;
-
+
if (!gst_element_register (plugin, "ximagesink",
- GST_RANK_SECONDARY, GST_TYPE_XIMAGESINK))
+ GST_RANK_SECONDARY, GST_TYPE_XIMAGESINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "ximagesink",
- "XFree86 video output plugin based on standard Xlib calls",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "ximagesink",
+ "XFree86 video output plugin based on standard Xlib calls",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_XIMAGESINK_H__
#define __GST_XIMAGESINK_H__
#include <math.h>
G_BEGIN_DECLS
-
#define GST_TYPE_XIMAGESINK \
(gst_ximagesink_get_type())
#define GST_XIMAGESINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_XIMAGESINK))
#define GST_IS_XIMAGESINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XIMAGESINK))
-
typedef struct _GstXContext GstXContext;
typedef struct _GstXWindow GstXWindow;
typedef struct _GstXImage GstXImage;
typedef struct _GstXImageSinkClass GstXImageSinkClass;
/* Global X Context stuff */
-struct _GstXContext {
+struct _GstXContext
+{
Display *disp;
-
+
Screen *screen;
gint screen_num;
-
+
Visual *visual;
-
+
Window root;
-
+
gulong white, black;
-
+
gint depth;
gint bpp;
gint endianness;
-
+
gboolean use_xshm;
-
+
GstCaps *caps;
};
/* XWindow stuff */
-struct _GstXWindow {
+struct _GstXWindow
+{
Window win;
gint width, height;
gboolean internal;
};
/* XImage stuff */
-struct _GstXImage {
+struct _GstXImage
+{
/* Reference to the ximagesink we belong to */
GstXImageSink *ximagesink;
-
+
XImage *ximage;
-
+
#ifdef HAVE_XSHM
XShmSegmentInfo SHMInfo;
-#endif /* HAVE_XSHM */
-
+#endif /* HAVE_XSHM */
+
char *data;
gint width, height, size;
};
-struct _GstXImageSink {
+struct _GstXImageSink
+{
/* Our element stuff */
GstVideoSink videosink;
char *display_name;
-
+
GstXContext *xcontext;
GstXWindow *xwindow;
GstXImage *ximage;
GstXImage *cur_image;
-
+
gdouble framerate;
GMutex *x_lock;
-
+
/* Unused */
gint pixel_width, pixel_height;
-
+
GstClockTime time;
-
+
GMutex *pool_lock;
GSList *image_pool;
-
+
gboolean synchronous;
gboolean sw_scaling_failed;
};
-struct _GstXImageSinkClass {
+struct _GstXImageSinkClass
+{
GstVideoSinkClass parent_class;
};
-GType gst_ximagesink_get_type(void);
+GType gst_ximagesink_get_type (void);
G_END_DECLS
-
#endif /* __GST_XIMAGESINK_H__ */
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Object header */
#include "xvimagesink.h"
-static void gst_xvimagesink_buffer_free (GstBuffer *buffer);
+static void gst_xvimagesink_buffer_free (GstBuffer * buffer);
/* ElementFactory information */
-static GstElementDetails gst_xvimagesink_details = GST_ELEMENT_DETAILS (
- "Video sink",
- "Sink/Video",
- "A Xv based videosink",
- "Julien Moutte <julien@moutte.net>"
-);
+static GstElementDetails gst_xvimagesink_details =
+GST_ELEMENT_DETAILS ("Video sink",
+ "Sink/Video",
+ "A Xv based videosink",
+ "Julien Moutte <julien@moutte.net>");
/* Default template - initiated with class struct to allow gst-register to work
without X running */
static GstStaticPadTemplate gst_xvimagesink_sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-raw-rgb, "
- "framerate = (double) [ 1.0, 100.0 ], "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ]; "
- "video/x-raw-yuv, "
- "framerate = (double) [ 1.0, 100.0 ], "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ]"
- )
-);
-
-enum {
+ GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb, "
+ "framerate = (double) [ 1.0, 100.0 ], "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ]; "
+ "video/x-raw-yuv, "
+ "framerate = (double) [ 1.0, 100.0 ], "
+ "width = (int) [ 0, MAX ], " "height = (int) [ 0, MAX ]")
+ );
+
+enum
+{
ARG_0,
ARG_CONTRAST,
ARG_BRIGHTNESS,
ARG_SATURATION,
ARG_DISPLAY,
ARG_SYNCHRONOUS
- /* FILL ME */
+ /* FILL ME */
};
static GstVideoSinkClass *parent_class = NULL;
/* X11 stuff */
static int
-gst_xvimagesink_handle_xerror (Display *display, XErrorEvent *xevent)
+gst_xvimagesink_handle_xerror (Display * display, XErrorEvent * xevent)
{
- char error_msg [1024];
+ char error_msg[1024];
+
XGetErrorText (display, xevent->error_code, error_msg, 1024);
- GST_DEBUG ("xvimagesink failed to use XShm calls. error: %s",
- error_msg);
+ GST_DEBUG ("xvimagesink failed to use XShm calls. error: %s", error_msg);
error_catched = TRUE;
return 0;
}
/* This function checks that it is actually really possible to create an image
using XShm */
static gboolean
-gst_xvimagesink_check_xshm_calls (GstXContext *xcontext)
+gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
{
GstXvImage *xvimage = NULL;
- int (*handler)(Display *, XErrorEvent *);
-
+ int (*handler) (Display *, XErrorEvent *);
+
g_return_val_if_fail (xcontext != NULL, FALSE);
-
+
#ifdef HAVE_XSHM
xvimage = g_new0 (GstXvImage, 1);
-
+
/* Setting an error handler to catch failure */
handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
-
- xvimage->size = (xcontext->bpp / 8);
+
+ xvimage->size = (xcontext->bpp / 8);
/* Trying to create a 1x1 picture */
xvimage->xvimage = XvShmCreateImage (xcontext->disp, xcontext->xv_port_id,
- xcontext->im_format, NULL, 1, 1,
- &xvimage->SHMInfo);
+ xcontext->im_format, NULL, 1, 1, &xvimage->SHMInfo);
xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
- IPC_CREAT | 0777);
+ IPC_CREAT | 0777);
xvimage->SHMInfo.shmaddr = shmat (xvimage->SHMInfo.shmid, 0, 0);
xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
xvimage->SHMInfo.readOnly = FALSE;
-
+
XShmAttach (xcontext->disp, &xvimage->SHMInfo);
error_catched = FALSE;
- XSync(xcontext->disp, 0);
-
+ XSync (xcontext->disp, 0);
+
XSetErrorHandler (handler);
-
- if (error_catched)
- { /* Failed, detaching shared memory, destroying image and telling we can't
- use XShm */
- error_catched = FALSE;
- XFree (xvimage->xvimage);
- shmdt (xvimage->SHMInfo.shmaddr);
- shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
- g_free (xvimage);
- XSync (xcontext->disp, FALSE);
- return FALSE;
- }
- else
- {
- XShmDetach (xcontext->disp, &xvimage->SHMInfo);
- XFree (xvimage->xvimage);
- shmdt (xvimage->SHMInfo.shmaddr);
- shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
- g_free (xvimage);
- XSync (xcontext->disp, FALSE);
- }
+
+ if (error_catched) { /* Failed, detaching shared memory, destroying image and telling we can't
+ use XShm */
+ error_catched = FALSE;
+ XFree (xvimage->xvimage);
+ shmdt (xvimage->SHMInfo.shmaddr);
+ shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
+ g_free (xvimage);
+ XSync (xcontext->disp, FALSE);
+ return FALSE;
+ } else {
+ XShmDetach (xcontext->disp, &xvimage->SHMInfo);
+ XFree (xvimage->xvimage);
+ shmdt (xvimage->SHMInfo.shmaddr);
+ shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
+ g_free (xvimage);
+ XSync (xcontext->disp, FALSE);
+ }
#endif /* HAVE_XSHM */
-
+
return TRUE;
}
/* This function handles GstXvImage creation depending on XShm availability */
static GstXvImage *
-gst_xvimagesink_xvimage_new (GstXvImageSink *xvimagesink,
- gint width, gint height)
+gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink,
+ gint width, gint height)
{
GstXvImage *xvimage = NULL;
-
+
g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
-
+
xvimage = g_new0 (GstXvImage, 1);
-
+
xvimage->width = width;
xvimage->height = height;
xvimage->data = NULL;
xvimage->xvimagesink = xvimagesink;
-
+
g_mutex_lock (xvimagesink->x_lock);
- xvimage->size = (xvimagesink->xcontext->bpp / 8) * xvimage->width * xvimage->height;
-
+ xvimage->size =
+ (xvimagesink->xcontext->bpp / 8) * xvimage->width * xvimage->height;
+
#ifdef HAVE_XSHM
- if (xvimagesink->xcontext->use_xshm)
- {
- xvimage->xvimage = XvShmCreateImage (xvimagesink->xcontext->disp,
- xvimagesink->xcontext->xv_port_id,
- xvimagesink->xcontext->im_format,
- NULL, xvimage->width,
- xvimage->height, &xvimage->SHMInfo);
-
- xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
- IPC_CREAT | 0777);
-
- xvimage->SHMInfo.shmaddr = shmat (xvimage->SHMInfo.shmid, 0, 0);
- xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
-
- xvimage->SHMInfo.readOnly = FALSE;
-
- XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo);
-
- XSync (xvimagesink->xcontext->disp, FALSE);
-
- shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
- xvimage->SHMInfo.shmid = -1;
- }
- else
+ if (xvimagesink->xcontext->use_xshm) {
+ xvimage->xvimage = XvShmCreateImage (xvimagesink->xcontext->disp,
+ xvimagesink->xcontext->xv_port_id,
+ xvimagesink->xcontext->im_format,
+ NULL, xvimage->width, xvimage->height, &xvimage->SHMInfo);
+
+ xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
+ IPC_CREAT | 0777);
+
+ xvimage->SHMInfo.shmaddr = shmat (xvimage->SHMInfo.shmid, 0, 0);
+ xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
+
+ xvimage->SHMInfo.readOnly = FALSE;
+
+ XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo);
+
+ XSync (xvimagesink->xcontext->disp, FALSE);
+
+ shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
+ xvimage->SHMInfo.shmid = -1;
+ } else
#endif /* HAVE_XSHM */
- {
- xvimage->xvimage = XvCreateImage (xvimagesink->xcontext->disp,
- xvimagesink->xcontext->xv_port_id,
- xvimagesink->xcontext->im_format,
- xvimage->data,
- xvimage->width, xvimage->height);
-
- xvimage->data = g_malloc (xvimage->xvimage->data_size);
-
- XSync (xvimagesink->xcontext->disp, FALSE);
- }
+ {
+ xvimage->xvimage = XvCreateImage (xvimagesink->xcontext->disp,
+ xvimagesink->xcontext->xv_port_id,
+ xvimagesink->xcontext->im_format,
+ xvimage->data, xvimage->width, xvimage->height);
+
+ xvimage->data = g_malloc (xvimage->xvimage->data_size);
+
+ XSync (xvimagesink->xcontext->disp, FALSE);
+ }
+
+ if (!xvimage->xvimage) {
+ if (xvimage->data)
+ g_free (xvimage->data);
+
+ g_free (xvimage);
+
+ xvimage = NULL;
+ }
- if (!xvimage->xvimage)
- {
- if (xvimage->data)
- g_free (xvimage->data);
-
- g_free (xvimage);
-
- xvimage = NULL;
- }
-
g_mutex_unlock (xvimagesink->x_lock);
-
+
return xvimage;
}
-/* This function destroys a GstXvImage handling XShm availability */
+/* This function destroys a GstXvImage handling XShm availability */
static void
-gst_xvimagesink_xvimage_destroy (GstXvImageSink *xvimagesink,
- GstXvImage *xvimage)
+gst_xvimagesink_xvimage_destroy (GstXvImageSink * xvimagesink,
+ GstXvImage * xvimage)
{
g_return_if_fail (xvimage != NULL);
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
/* If the destroyed image is the current one we destroy our reference too */
if (xvimagesink->cur_image == xvimage)
xvimagesink->cur_image = NULL;
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
#ifdef HAVE_XSHM
- if (xvimagesink->xcontext->use_xshm)
- {
- if (xvimage->SHMInfo.shmaddr)
- XShmDetach (xvimagesink->xcontext->disp, &xvimage->SHMInfo);
-
- if (xvimage->xvimage)
- XFree (xvimage->xvimage);
-
- if (xvimage->SHMInfo.shmaddr)
- shmdt (xvimage->SHMInfo.shmaddr);
-
- if (xvimage->SHMInfo.shmid > 0)
- shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
- }
- else
-#endif /* HAVE_XSHM */
- {
- if (xvimage->xvimage)
- XFree (xvimage->xvimage);
- }
+ if (xvimagesink->xcontext->use_xshm) {
+ if (xvimage->SHMInfo.shmaddr)
+ XShmDetach (xvimagesink->xcontext->disp, &xvimage->SHMInfo);
+
+ if (xvimage->xvimage)
+ XFree (xvimage->xvimage);
+
+ if (xvimage->SHMInfo.shmaddr)
+ shmdt (xvimage->SHMInfo.shmaddr);
+
+ if (xvimage->SHMInfo.shmid > 0)
+ shmctl (xvimage->SHMInfo.shmid, IPC_RMID, 0);
+ } else
+#endif /* HAVE_XSHM */
+ {
+ if (xvimage->xvimage)
+ XFree (xvimage->xvimage);
+ }
XSync (xvimagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (xvimagesink->x_lock);
-
+
g_free (xvimage);
}
/* This function puts a GstXvImage on a GstXvImageSink's window */
static void
-gst_xvimagesink_xvimage_put (GstXvImageSink *xvimagesink, GstXvImage *xvimage)
+gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink, GstXvImage * xvimage)
{
g_return_if_fail (xvimage != NULL);
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
/* Store a reference to the last image we put */
if (xvimagesink->cur_image != xvimage)
xvimagesink->cur_image = xvimage;
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
/* We scale to the window's geometry */
#ifdef HAVE_XSHM
- if (xvimagesink->xcontext->use_xshm)
- {
- XvShmPutImage (xvimagesink->xcontext->disp,
- xvimagesink->xcontext->xv_port_id,
- xvimagesink->xwindow->win,
- xvimagesink->xwindow->gc, xvimage->xvimage,
- 0, 0, xvimage->width, xvimage->height,
- 0, 0, xvimagesink->xwindow->width,
- xvimagesink->xwindow->height, FALSE);
- }
- else
+ if (xvimagesink->xcontext->use_xshm) {
+ XvShmPutImage (xvimagesink->xcontext->disp,
+ xvimagesink->xcontext->xv_port_id,
+ xvimagesink->xwindow->win,
+ xvimagesink->xwindow->gc, xvimage->xvimage,
+ 0, 0, xvimage->width, xvimage->height,
+ 0, 0, xvimagesink->xwindow->width, xvimagesink->xwindow->height, FALSE);
+ } else
#endif /* HAVE_XSHM */
- {
- XvPutImage (xvimagesink->xcontext->disp,
- xvimagesink->xcontext->xv_port_id,
- xvimagesink->xwindow->win,
- xvimagesink->xwindow->gc, xvimage->xvimage,
- 0, 0, xvimage->width, xvimage->height,
- 0, 0, xvimagesink->xwindow->width,
- xvimagesink->xwindow->height);
- }
-
- XSync(xvimagesink->xcontext->disp, FALSE);
-
+ {
+ XvPutImage (xvimagesink->xcontext->disp,
+ xvimagesink->xcontext->xv_port_id,
+ xvimagesink->xwindow->win,
+ xvimagesink->xwindow->gc, xvimage->xvimage,
+ 0, 0, xvimage->width, xvimage->height,
+ 0, 0, xvimagesink->xwindow->width, xvimagesink->xwindow->height);
+ }
+
+ XSync (xvimagesink->xcontext->disp, FALSE);
+
g_mutex_unlock (xvimagesink->x_lock);
}
/* This function handles a GstXWindow creation */
static GstXWindow *
-gst_xvimagesink_xwindow_new (GstXvImageSink *xvimagesink,
- gint width, gint height)
+gst_xvimagesink_xwindow_new (GstXvImageSink * xvimagesink,
+ gint width, gint height)
{
GstXWindow *xwindow = NULL;
XGCValues values;
-
+
g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
-
+
xwindow = g_new0 (GstXWindow, 1);
-
+
xwindow->width = width;
xwindow->height = height;
xwindow->internal = TRUE;
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
xwindow->win = XCreateSimpleWindow (xvimagesink->xcontext->disp,
- xvimagesink->xcontext->root,
- 0, 0, xwindow->width, xwindow->height,
- 0, 0, xvimagesink->xcontext->black);
-
- XSelectInput (xvimagesink->xcontext->disp, xwindow->win, ExposureMask |
- StructureNotifyMask | PointerMotionMask | KeyPressMask |
- KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
-
+ xvimagesink->xcontext->root,
+ 0, 0, xwindow->width, xwindow->height,
+ 0, 0, xvimagesink->xcontext->black);
+
+ XSelectInput (xvimagesink->xcontext->disp, xwindow->win, ExposureMask |
+ StructureNotifyMask | PointerMotionMask | KeyPressMask |
+ KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
+
xwindow->gc = XCreateGC (xvimagesink->xcontext->disp,
- xwindow->win, 0, &values);
-
+ xwindow->win, 0, &values);
+
XMapRaised (xvimagesink->xcontext->disp, xwindow->win);
-
- XSync(xvimagesink->xcontext->disp, FALSE);
-
+
+ XSync (xvimagesink->xcontext->disp, FALSE);
+
g_mutex_unlock (xvimagesink->x_lock);
-
+
gst_x_overlay_got_xwindow_id (GST_X_OVERLAY (xvimagesink), xwindow->win);
-
+
return xwindow;
}
/* This function destroys a GstXWindow */
static void
-gst_xvimagesink_xwindow_destroy (GstXvImageSink *xvimagesink, GstXWindow *xwindow)
+gst_xvimagesink_xwindow_destroy (GstXvImageSink * xvimagesink,
+ GstXWindow * xwindow)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
/* If we did not create that window we just free the GC and let it live */
if (xwindow->internal)
XDestroyWindow (xvimagesink->xcontext->disp, xwindow->win);
else
XSelectInput (xvimagesink->xcontext->disp, xwindow->win, 0);
-
+
XFreeGC (xvimagesink->xcontext->disp, xwindow->gc);
-
- XSync(xvimagesink->xcontext->disp, FALSE);
-
+
+ XSync (xvimagesink->xcontext->disp, FALSE);
+
g_mutex_unlock (xvimagesink->x_lock);
-
+
g_free (xwindow);
}
/* This function resizes a GstXWindow */
static void
-gst_xvimagesink_xwindow_resize (GstXvImageSink *xvimagesink,
- GstXWindow *xwindow, guint width, guint height)
+gst_xvimagesink_xwindow_resize (GstXvImageSink * xvimagesink,
+ GstXWindow * xwindow, guint width, guint height)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
xwindow->width = width;
xwindow->height = height;
-
+
XResizeWindow (xvimagesink->xcontext->disp, xwindow->win,
- xwindow->width, xwindow->height);
+ xwindow->width, xwindow->height);
+
+ XSync (xvimagesink->xcontext->disp, FALSE);
- XSync(xvimagesink->xcontext->disp, FALSE);
-
g_mutex_unlock (xvimagesink->x_lock);
}
static void
-gst_xvimagesink_xwindow_clear (GstXvImageSink *xvimagesink, GstXWindow *xwindow)
+gst_xvimagesink_xwindow_clear (GstXvImageSink * xvimagesink,
+ GstXWindow * xwindow)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
XSetForeground (xvimagesink->xcontext->disp, xwindow->gc,
- xvimagesink->xcontext->black);
-
+ xvimagesink->xcontext->black);
+
XFillRectangle (xvimagesink->xcontext->disp, xwindow->win, xwindow->gc,
- 0, 0, xwindow->width, xwindow->height);
-
+ 0, 0, xwindow->width, xwindow->height);
+
XSync (xvimagesink->xcontext->disp, FALSE);
-
+
g_mutex_unlock (xvimagesink->x_lock);
}
/* This function commits our internal colorbalance settings to our grabbed Xv
port. If the xcontext is not initialized yet it simply returns */
static void
-gst_xvimagesink_update_colorbalance (GstXvImageSink *xvimagesink)
+gst_xvimagesink_update_colorbalance (GstXvImageSink * xvimagesink)
{
GList *channels = NULL;
-
+
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
/* If we haven't initialized the X context we can't update anything */
if (xvimagesink->xcontext == NULL)
return;
-
+
/* For each channel of the colorbalance we calculate the correct value
doing range conversion and then set the Xv port attribute to match our
values. */
channels = xvimagesink->xcontext->channels_list;
-
- while (channels)
- {
- if (channels->data && GST_IS_COLOR_BALANCE_CHANNEL (channels->data))
- {
- GstColorBalanceChannel *channel = NULL;
- gint value = 0;
- gdouble convert_coef;
-
- channel = GST_COLOR_BALANCE_CHANNEL (channels->data);
- g_object_ref (channel);
-
- /* Our range conversion coef */
- convert_coef = (channel->max_value - channel->min_value) / 2000.0;
-
- if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0)
- {
- value = (xvimagesink->hue + 1000) * convert_coef +
- channel->min_value;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_SATURATION") == 0)
- {
- value = (xvimagesink->saturation + 1000) * convert_coef +
- channel->min_value;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_CONTRAST") == 0)
- {
- value = (xvimagesink->contrast + 1000) * convert_coef +
- channel->min_value;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_BRIGHTNESS") == 0)
- {
- value = (xvimagesink->brightness + 1000) * convert_coef +
- channel->min_value;
- }
- else
- {
- g_warning ("got an unknown channel %s", channel->label);
- g_object_unref (channel);
- return;
- }
-
- /* Committing to Xv port */
- g_mutex_lock (xvimagesink->x_lock);
- XvSetPortAttribute (xvimagesink->xcontext->disp,
- xvimagesink->xcontext->xv_port_id,
- XInternAtom (xvimagesink->xcontext->disp,
- channel->label, 1), value);
- g_mutex_unlock (xvimagesink->x_lock);
-
- g_object_unref (channel);
- }
- channels = g_list_next (channels);
+
+ while (channels) {
+ if (channels->data && GST_IS_COLOR_BALANCE_CHANNEL (channels->data)) {
+ GstColorBalanceChannel *channel = NULL;
+ gint value = 0;
+ gdouble convert_coef;
+
+ channel = GST_COLOR_BALANCE_CHANNEL (channels->data);
+ g_object_ref (channel);
+
+ /* Our range conversion coef */
+ convert_coef = (channel->max_value - channel->min_value) / 2000.0;
+
+ if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0) {
+ value = (xvimagesink->hue + 1000) * convert_coef + channel->min_value;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_SATURATION") == 0) {
+ value = (xvimagesink->saturation + 1000) * convert_coef +
+ channel->min_value;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_CONTRAST") == 0) {
+ value = (xvimagesink->contrast + 1000) * convert_coef +
+ channel->min_value;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_BRIGHTNESS") == 0) {
+ value = (xvimagesink->brightness + 1000) * convert_coef +
+ channel->min_value;
+ } else {
+ g_warning ("got an unknown channel %s", channel->label);
+ g_object_unref (channel);
+ return;
+ }
+
+ /* Committing to Xv port */
+ g_mutex_lock (xvimagesink->x_lock);
+ XvSetPortAttribute (xvimagesink->xcontext->disp,
+ xvimagesink->xcontext->xv_port_id,
+ XInternAtom (xvimagesink->xcontext->disp, channel->label, 1), value);
+ g_mutex_unlock (xvimagesink->x_lock);
+
+ g_object_unref (channel);
}
+ channels = g_list_next (channels);
+ }
}
/* This function handles XEvents that might be in the queue. It generates
and navigation. It will also listen for configure events on the window to
trigger caps renegotiation so on the fly software scaling can work. */
static void
-gst_xvimagesink_handle_xevents (GstXvImageSink *xvimagesink, GstPad *pad)
+gst_xvimagesink_handle_xevents (GstXvImageSink * xvimagesink, GstPad * pad)
{
XEvent e;
guint pointer_x = 0, pointer_y = 0;
gboolean pointer_moved = FALSE;
-
+
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
/* We get all pointer motion events, only the last position is
interesting. */
g_mutex_lock (xvimagesink->x_lock);
while (XCheckWindowEvent (xvimagesink->xcontext->disp,
- xvimagesink->xwindow->win,
- PointerMotionMask, &e))
- {
- g_mutex_unlock (xvimagesink->x_lock);
-
- switch (e.type)
- {
- case MotionNotify:
- pointer_x = e.xmotion.x;
- pointer_y = e.xmotion.y;
- pointer_moved = TRUE;
- break;
- default:
- break;
- }
-
- g_mutex_lock (xvimagesink->x_lock);
+ xvimagesink->xwindow->win, PointerMotionMask, &e)) {
+ g_mutex_unlock (xvimagesink->x_lock);
+
+ switch (e.type) {
+ case MotionNotify:
+ pointer_x = e.xmotion.x;
+ pointer_y = e.xmotion.y;
+ pointer_moved = TRUE;
+ break;
+ default:
+ break;
}
+
+ g_mutex_lock (xvimagesink->x_lock);
+ }
g_mutex_unlock (xvimagesink->x_lock);
- if (pointer_moved)
- {
- GST_DEBUG ("xvimagesink pointer moved over window at %d,%d",
- pointer_x, pointer_y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
- "mouse-move", 0, pointer_x, pointer_y);
- }
-
+ if (pointer_moved) {
+ GST_DEBUG ("xvimagesink pointer moved over window at %d,%d",
+ pointer_x, pointer_y);
+ gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
+ "mouse-move", 0, pointer_x, pointer_y);
+ }
+
/* We get all events on our window to throw them upstream */
g_mutex_lock (xvimagesink->x_lock);
while (XCheckWindowEvent (xvimagesink->xcontext->disp,
- xvimagesink->xwindow->win,
- StructureNotifyMask | KeyPressMask |
- KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask, &e))
- {
- KeySym keysym;
-
- /* We lock only for the X function call */
- g_mutex_unlock (xvimagesink->x_lock);
-
- switch (e.type)
- {
- case ConfigureNotify:
- /* Window got resized or moved. We update our data. */
- GST_DEBUG ("xvimagesink window is at %d, %d with geometry : %d,%d",
- e.xconfigure.x, e.xconfigure.y,
- e.xconfigure.width, e.xconfigure.height);
- xvimagesink->xwindow->width = e.xconfigure.width;
- xvimagesink->xwindow->height = e.xconfigure.height;
- break;
- case ButtonPress:
- /* Mouse button pressed over our window. We send upstream
- events for interactivity/navigation */
- GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d",
- e.xbutton.button, e.xbutton.x, e.xbutton.y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
- "mouse-button-press",
- e.xbutton.button,
- e.xbutton.x, e.xbutton.y);
- break;
- case ButtonRelease:
- /* Mouse button released over our window. We send upstream
- events for interactivity/navigation */
- GST_DEBUG ("xvimagesink button %d released over window at %d,%d",
- e.xbutton.button, e.xbutton.x, e.xbutton.y);
- gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
- "mouse-button-release",
- e.xbutton.button,
- e.xbutton.x, e.xbutton.y);
- break;
- case KeyPress:
- case KeyRelease:
- /* Key pressed/released over our window. We send upstream
- events for interactivity/navigation */
- GST_DEBUG ("xvimagesink key %d pressed over window at %d,%d",
- e.xkey.keycode, e.xkey.x, e.xkey.y);
- keysym = XKeycodeToKeysym (xvimagesink->xcontext->disp,
- e.xkey.keycode, 0);
- if (keysym != NoSymbol) {
- gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
- e.type == KeyPress ?
- "key-press" : "key-release",
- XKeysymToString (keysym));
- }
- else {
- gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
- e.type == KeyPress ?
- "key-press" : "key-release",
- "unknown");
- }
- break;
- default:
- GST_DEBUG ("xvimagesink unhandled X event (%d)", e.type);
- }
-
- g_mutex_lock (xvimagesink->x_lock);
+ xvimagesink->xwindow->win,
+ StructureNotifyMask | KeyPressMask |
+ KeyReleaseMask | ButtonPressMask | ButtonReleaseMask, &e)) {
+ KeySym keysym;
+
+ /* We lock only for the X function call */
+ g_mutex_unlock (xvimagesink->x_lock);
+
+ switch (e.type) {
+ case ConfigureNotify:
+ /* Window got resized or moved. We update our data. */
+ GST_DEBUG ("xvimagesink window is at %d, %d with geometry : %d,%d",
+ e.xconfigure.x, e.xconfigure.y,
+ e.xconfigure.width, e.xconfigure.height);
+ xvimagesink->xwindow->width = e.xconfigure.width;
+ xvimagesink->xwindow->height = e.xconfigure.height;
+ break;
+ case ButtonPress:
+ /* Mouse button pressed over our window. We send upstream
+ events for interactivity/navigation */
+ GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d",
+ e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
+ "mouse-button-press", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ break;
+ case ButtonRelease:
+ /* Mouse button released over our window. We send upstream
+ events for interactivity/navigation */
+ GST_DEBUG ("xvimagesink button %d released over window at %d,%d",
+ e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
+ "mouse-button-release", e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ break;
+ case KeyPress:
+ case KeyRelease:
+ /* Key pressed/released over our window. We send upstream
+ events for interactivity/navigation */
+ GST_DEBUG ("xvimagesink key %d pressed over window at %d,%d",
+ e.xkey.keycode, e.xkey.x, e.xkey.y);
+ keysym = XKeycodeToKeysym (xvimagesink->xcontext->disp,
+ e.xkey.keycode, 0);
+ if (keysym != NoSymbol) {
+ gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
+ e.type == KeyPress ?
+ "key-press" : "key-release", XKeysymToString (keysym));
+ } else {
+ gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
+ e.type == KeyPress ? "key-press" : "key-release", "unknown");
+ }
+ break;
+ default:
+ GST_DEBUG ("xvimagesink unhandled X event (%d)", e.type);
}
+
+ g_mutex_lock (xvimagesink->x_lock);
+ }
g_mutex_unlock (xvimagesink->x_lock);
}
Xv grabable port we find. We store each one of the supported formats in a
format list and append the format to a newly created caps that we return */
static GstCaps *
-gst_xvimagesink_get_xv_support (GstXContext *xcontext)
+gst_xvimagesink_get_xv_support (GstXContext * xcontext)
{
gint i, nb_adaptors;
XvAdaptorInfo *adaptors;
-
+
g_return_val_if_fail (xcontext != NULL, NULL);
-
+
/* First let's check that XVideo extension is available */
- if (!XQueryExtension (xcontext->disp, "XVideo", &i, &i, &i))
- {
- GST_DEBUG ("XVideo extension is not available");
- return NULL;
- }
-
+ if (!XQueryExtension (xcontext->disp, "XVideo", &i, &i, &i)) {
+ GST_DEBUG ("XVideo extension is not available");
+ return NULL;
+ }
+
/* Then we get adaptors list */
if (Success != XvQueryAdaptors (xcontext->disp, xcontext->root,
- &nb_adaptors, &adaptors))
- {
- GST_DEBUG ("Failed getting XV adaptors list");
- return NULL;
- }
-
+ &nb_adaptors, &adaptors)) {
+ GST_DEBUG ("Failed getting XV adaptors list");
+ return NULL;
+ }
+
xcontext->xv_port_id = 0;
-
+
GST_DEBUG ("Found %d XV adaptor(s)", nb_adaptors);
-
+
/* Now search for an adaptor that supports XvImageMask */
- for (i = 0; i < nb_adaptors && !xcontext->xv_port_id; i++)
- {
- if (adaptors[i].type & XvImageMask)
- {
- gint j;
-
- /* We found such an adaptor, looking for an available port */
- for (j = 0; j < adaptors[i].num_ports && !xcontext->xv_port_id; j++)
- {
- /* We try to grab the port */
- if (Success == XvGrabPort (xcontext->disp,
- adaptors[i].base_id + j, 0))
- {
- xcontext->xv_port_id = adaptors[i].base_id + j;
- }
- }
- }
-
- GST_DEBUG ("XV Adaptor %s with %ld ports", adaptors[i].name,
- adaptors[i].num_ports);
-
+ for (i = 0; i < nb_adaptors && !xcontext->xv_port_id; i++) {
+ if (adaptors[i].type & XvImageMask) {
+ gint j;
+
+ /* We found such an adaptor, looking for an available port */
+ for (j = 0; j < adaptors[i].num_ports && !xcontext->xv_port_id; j++) {
+ /* We try to grab the port */
+ if (Success == XvGrabPort (xcontext->disp, adaptors[i].base_id + j, 0)) {
+ xcontext->xv_port_id = adaptors[i].base_id + j;
+ }
+ }
}
+
+ GST_DEBUG ("XV Adaptor %s with %ld ports", adaptors[i].name,
+ adaptors[i].num_ports);
+
+ }
XvFreeAdaptorInfo (adaptors);
-
- if (xcontext->xv_port_id)
- {
- gint nb_formats;
- XvImageFormatValues *formats = NULL;
- GstCaps *caps = NULL;
-
- /* We get all image formats supported by our port */
- formats = XvListImageFormats (xcontext->disp,
- xcontext->xv_port_id, &nb_formats);
- caps = gst_caps_new_empty ();
- for (i = 0; i < nb_formats; i++)
- {
- GstCaps *format_caps = NULL;
-
- /* We set the image format of the xcontext to an existing one. Sink
- connect method will override that but we need to have at least a
- valid image format so that we can make our xshm calls check before
- caps negotiation really happens. */
- xcontext->im_format = formats[i].id;
-
- switch (formats[i].type)
- {
- case XvRGB:
- {
- format_caps = gst_caps_new_simple ("video/x-raw-rgb",
- "endianness", G_TYPE_INT, xcontext->endianness,
- "depth", G_TYPE_INT, xcontext->depth,
- "bpp", G_TYPE_INT, xcontext->bpp,
- "blue_mask", G_TYPE_INT, formats[i].red_mask,
- "green_mask", G_TYPE_INT, formats[i].green_mask,
- "red_mask", G_TYPE_INT, formats[i].blue_mask,
- "width", GST_TYPE_INT_RANGE, 0, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 0, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 1.0, 100.0,
- NULL);
-
- /* For RGB caps we store them and the image
- format so that we can get back the format
- when sinkconnect will give us a caps without
- format property */
- if (format_caps)
- {
- GstXvImageFormat *format = NULL;
- format = g_new0 (GstXvImageFormat, 1);
- if (format)
- {
- format->format = formats[i].id;
- format->caps = gst_caps_copy (format_caps);
- xcontext->formats_list = g_list_append (
- xcontext->formats_list, format);
- }
- }
- break;
- }
- case XvYUV:
- format_caps = gst_caps_new_simple ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC,formats[i].id,
- "width", GST_TYPE_INT_RANGE, 0, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 0, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 1.0, 100.0,
- NULL);
- break;
- default:
- g_assert_not_reached();
- break;
- }
-
- gst_caps_append (caps, format_caps);
- }
-
- if (formats)
- XFree (formats);
-
- GST_DEBUG ("Generated the following caps: " GST_PTR_FORMAT, caps);
-
- return caps;
+
+ if (xcontext->xv_port_id) {
+ gint nb_formats;
+ XvImageFormatValues *formats = NULL;
+ GstCaps *caps = NULL;
+
+ /* We get all image formats supported by our port */
+ formats = XvListImageFormats (xcontext->disp,
+ xcontext->xv_port_id, &nb_formats);
+ caps = gst_caps_new_empty ();
+ for (i = 0; i < nb_formats; i++) {
+ GstCaps *format_caps = NULL;
+
+ /* We set the image format of the xcontext to an existing one. Sink
+ connect method will override that but we need to have at least a
+ valid image format so that we can make our xshm calls check before
+ caps negotiation really happens. */
+ xcontext->im_format = formats[i].id;
+
+ switch (formats[i].type) {
+ case XvRGB:
+ {
+ format_caps = gst_caps_new_simple ("video/x-raw-rgb",
+ "endianness", G_TYPE_INT, xcontext->endianness,
+ "depth", G_TYPE_INT, xcontext->depth,
+ "bpp", G_TYPE_INT, xcontext->bpp,
+ "blue_mask", G_TYPE_INT, formats[i].red_mask,
+ "green_mask", G_TYPE_INT, formats[i].green_mask,
+ "red_mask", G_TYPE_INT, formats[i].blue_mask,
+ "width", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 1.0, 100.0, NULL);
+
+ /* For RGB caps we store them and the image
+ format so that we can get back the format
+ when sinkconnect will give us a caps without
+ format property */
+ if (format_caps) {
+ GstXvImageFormat *format = NULL;
+
+ format = g_new0 (GstXvImageFormat, 1);
+ if (format) {
+ format->format = formats[i].id;
+ format->caps = gst_caps_copy (format_caps);
+ xcontext->formats_list =
+ g_list_append (xcontext->formats_list, format);
+ }
+ }
+ break;
+ }
+ case XvYUV:
+ format_caps = gst_caps_new_simple ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, formats[i].id,
+ "width", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 1.0, 100.0, NULL);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ gst_caps_append (caps, format_caps);
}
-
+
+ if (formats)
+ XFree (formats);
+
+ GST_DEBUG ("Generated the following caps: " GST_PTR_FORMAT, caps);
+
+ return caps;
+ }
+
return NULL;
}
here that caps for supported format are generated without any window or
image creation */
static GstXContext *
-gst_xvimagesink_xcontext_get (GstXvImageSink *xvimagesink)
+gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
{
GstXContext *xcontext = NULL;
XPixmapFormatValues *px_formats = NULL;
gint nb_formats = 0, i, j, N_attr;
XvAttribute *xv_attr;
char *channels[4] = { "XV_HUE", "XV_SATURATION",
- "XV_BRIGHTNESS", "XV_CONTRAST" };
-
+ "XV_BRIGHTNESS", "XV_CONTRAST"
+ };
+
g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
-
+
xcontext = g_new0 (GstXContext, 1);
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
xcontext->disp = XOpenDisplay (xvimagesink->display_name);
-
- if (!xcontext->disp)
- {
- g_mutex_unlock (xvimagesink->x_lock);
- g_free (xcontext);
- GST_ELEMENT_ERROR (xvimagesink, RESOURCE, TOO_LAZY, (NULL),
- ("Could not open display"));
- return NULL;
- }
-
+
+ if (!xcontext->disp) {
+ g_mutex_unlock (xvimagesink->x_lock);
+ g_free (xcontext);
+ GST_ELEMENT_ERROR (xvimagesink, RESOURCE, TOO_LAZY, (NULL),
+ ("Could not open display"));
+ return NULL;
+ }
+
xcontext->screen = DefaultScreenOfDisplay (xcontext->disp);
xcontext->screen_num = DefaultScreen (xcontext->disp);
- xcontext->visual = DefaultVisual(xcontext->disp, xcontext->screen_num);
+ xcontext->visual = DefaultVisual (xcontext->disp, xcontext->screen_num);
xcontext->root = DefaultRootWindow (xcontext->disp);
xcontext->white = XWhitePixel (xcontext->disp, xcontext->screen_num);
xcontext->black = XBlackPixel (xcontext->disp, xcontext->screen_num);
xcontext->depth = DefaultDepthOfScreen (xcontext->screen);
-
+
/* We get supported pixmap formats at supported depth */
px_formats = XListPixmapFormats (xcontext->disp, &nb_formats);
-
- if (!px_formats)
- {
- XCloseDisplay (xcontext->disp);
- g_mutex_unlock (xvimagesink->x_lock);
- g_free (xcontext);
- return NULL;
- }
-
+
+ if (!px_formats) {
+ XCloseDisplay (xcontext->disp);
+ g_mutex_unlock (xvimagesink->x_lock);
+ g_free (xcontext);
+ return NULL;
+ }
+
/* We get bpp value corresponding to our running depth */
- for (i=0; i<nb_formats; i++)
- {
- if (px_formats[i].depth == xcontext->depth)
- xcontext->bpp = px_formats[i].bits_per_pixel;
- }
-
+ for (i = 0; i < nb_formats; i++) {
+ if (px_formats[i].depth == xcontext->depth)
+ xcontext->bpp = px_formats[i].bits_per_pixel;
+ }
+
XFree (px_formats);
-
- xcontext->endianness = (ImageByteOrder (xcontext->disp) == LSBFirst) ? G_LITTLE_ENDIAN:G_BIG_ENDIAN;
-
+
+ xcontext->endianness =
+ (ImageByteOrder (xcontext->disp) ==
+ LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
+
/* our caps system handles 24/32bpp RGB as big-endian. */
if ((xcontext->bpp == 24 || xcontext->bpp == 32) &&
xcontext->endianness == G_LITTLE_ENDIAN) {
xcontext->visual->blue_mask >>= 8;
}
}
-
+
xcontext->caps = gst_xvimagesink_get_xv_support (xcontext);
-
- if (!xcontext->caps)
- {
- XCloseDisplay (xcontext->disp);
- g_mutex_unlock (xvimagesink->x_lock);
- g_free (xcontext);
- return NULL;
- }
+ if (!xcontext->caps) {
+ XCloseDisplay (xcontext->disp);
+ g_mutex_unlock (xvimagesink->x_lock);
+ g_free (xcontext);
+ return NULL;
+ }
#ifdef HAVE_XSHM
/* Search for XShm extension support */
if (XShmQueryExtension (xcontext->disp) &&
- gst_xvimagesink_check_xshm_calls (xcontext))
- {
- xcontext->use_xshm = TRUE;
- GST_DEBUG ("xvimagesink is using XShm extension");
- }
- else
- {
- xcontext->use_xshm = FALSE;
- GST_DEBUG ("xvimagesink is not using XShm extension");
- }
+ gst_xvimagesink_check_xshm_calls (xcontext)) {
+ xcontext->use_xshm = TRUE;
+ GST_DEBUG ("xvimagesink is using XShm extension");
+ } else {
+ xcontext->use_xshm = FALSE;
+ GST_DEBUG ("xvimagesink is not using XShm extension");
+ }
#endif /* HAVE_XSHM */
-
+
xv_attr = XvQueryPortAttributes (xcontext->disp,
- xcontext->xv_port_id,
- &N_attr);
-
-
+ xcontext->xv_port_id, &N_attr);
+
+
/* Generate the channels list */
- for (i = 0; i < (sizeof (channels) / sizeof (char *)); i++)
- {
- XvAttribute *matching_attr = NULL;
-
- if (xv_attr != NULL)
- {
- for (j = 0; j < N_attr && matching_attr == NULL; ++j)
- if (! g_ascii_strcasecmp (channels[i], xv_attr[j].name))
- matching_attr = xv_attr + j;
- }
-
- if (matching_attr) {
- GstColorBalanceChannel *channel;
- channel = g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL, NULL);
- channel->label = g_strdup (channels[i]);
- channel->min_value = matching_attr ? matching_attr->min_value : -1000;
- channel->max_value = matching_attr ? matching_attr->max_value : 1000;
-
- xcontext->channels_list = g_list_append (xcontext->channels_list,
- channel);
-
- /* If the colorbalance settings have not been touched we get Xv values
- as defaults and update our internal variables */
- if (!xvimagesink->cb_changed) {
- gint val;
- XvGetPortAttribute (xcontext->disp, xcontext->xv_port_id,
- XInternAtom (xcontext->disp, channel->label, 1),
- &val);
- /* Normalize val to [-1000, 1000] */
- val = -1000 + 2000 * (val - channel->min_value) /
- (channel->max_value - channel->min_value);
-
- if (!g_ascii_strcasecmp (channels[i], "XV_HUE"))
- xvimagesink->hue = val;
- else if (!g_ascii_strcasecmp (channels[i], "XV_SATURATION"))
- xvimagesink->saturation = val;
- else if (!g_ascii_strcasecmp (channels[i], "XV_BRIGHTNESS"))
- xvimagesink->brightness = val;
- else if (!g_ascii_strcasecmp (channels[i], "XV_CONTRAST"))
- xvimagesink->contrast = val;
- }
+ for (i = 0; i < (sizeof (channels) / sizeof (char *)); i++) {
+ XvAttribute *matching_attr = NULL;
+
+ if (xv_attr != NULL) {
+ for (j = 0; j < N_attr && matching_attr == NULL; ++j)
+ if (!g_ascii_strcasecmp (channels[i], xv_attr[j].name))
+ matching_attr = xv_attr + j;
+ }
+
+ if (matching_attr) {
+ GstColorBalanceChannel *channel;
+
+ channel = g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL, NULL);
+ channel->label = g_strdup (channels[i]);
+ channel->min_value = matching_attr ? matching_attr->min_value : -1000;
+ channel->max_value = matching_attr ? matching_attr->max_value : 1000;
+
+ xcontext->channels_list = g_list_append (xcontext->channels_list,
+ channel);
+
+ /* If the colorbalance settings have not been touched we get Xv values
+ as defaults and update our internal variables */
+ if (!xvimagesink->cb_changed) {
+ gint val;
+
+ XvGetPortAttribute (xcontext->disp, xcontext->xv_port_id,
+ XInternAtom (xcontext->disp, channel->label, 1), &val);
+ /* Normalize val to [-1000, 1000] */
+ val = -1000 + 2000 * (val - channel->min_value) /
+ (channel->max_value - channel->min_value);
+
+ if (!g_ascii_strcasecmp (channels[i], "XV_HUE"))
+ xvimagesink->hue = val;
+ else if (!g_ascii_strcasecmp (channels[i], "XV_SATURATION"))
+ xvimagesink->saturation = val;
+ else if (!g_ascii_strcasecmp (channels[i], "XV_BRIGHTNESS"))
+ xvimagesink->brightness = val;
+ else if (!g_ascii_strcasecmp (channels[i], "XV_CONTRAST"))
+ xvimagesink->contrast = val;
}
}
+ }
if (xv_attr)
XFree (xv_attr);
/* This function cleans the X context. Closing the Display, releasing the XV
port and unrefing the caps for supported formats. */
static void
-gst_xvimagesink_xcontext_clear (GstXvImageSink *xvimagesink)
+gst_xvimagesink_xcontext_clear (GstXvImageSink * xvimagesink)
{
GList *formats_list, *channels_list;
-
+
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
formats_list = xvimagesink->xcontext->formats_list;
-
- while (formats_list)
- {
- GstXvImageFormat *format = formats_list->data;
- gst_caps_free (format->caps);
- g_free (format);
- formats_list = g_list_next (formats_list);
- }
-
+
+ while (formats_list) {
+ GstXvImageFormat *format = formats_list->data;
+
+ gst_caps_free (format->caps);
+ g_free (format);
+ formats_list = g_list_next (formats_list);
+ }
+
if (xvimagesink->xcontext->formats_list)
g_list_free (xvimagesink->xcontext->formats_list);
-
+
channels_list = xvimagesink->xcontext->channels_list;
-
- while (channels_list)
- {
- GstColorBalanceChannel *channel = channels_list->data;
- g_object_unref (channel);
- channels_list = g_list_next (channels_list);
- }
-
+
+ while (channels_list) {
+ GstColorBalanceChannel *channel = channels_list->data;
+
+ g_object_unref (channel);
+ channels_list = g_list_next (channels_list);
+ }
+
if (xvimagesink->xcontext->channels_list)
g_list_free (xvimagesink->xcontext->channels_list);
-
+
gst_caps_free (xvimagesink->xcontext->caps);
-
+
g_mutex_lock (xvimagesink->x_lock);
-
+
XvUngrabPort (xvimagesink->xcontext->disp,
- xvimagesink->xcontext->xv_port_id, 0);
-
+ xvimagesink->xcontext->xv_port_id, 0);
+
XCloseDisplay (xvimagesink->xcontext->disp);
-
+
g_mutex_unlock (xvimagesink->x_lock);
-
+
xvimagesink->xcontext = NULL;
}
static void
-gst_xvimagesink_imagepool_clear (GstXvImageSink *xvimagesink)
+gst_xvimagesink_imagepool_clear (GstXvImageSink * xvimagesink)
{
- g_mutex_lock(xvimagesink->pool_lock);
-
- while (xvimagesink->image_pool)
- {
- GstXvImage *xvimage = xvimagesink->image_pool->data;
- xvimagesink->image_pool = g_slist_delete_link (xvimagesink->image_pool,
- xvimagesink->image_pool);
- gst_xvimagesink_xvimage_destroy (xvimagesink, xvimage);
- }
-
- g_mutex_unlock(xvimagesink->pool_lock);
+ g_mutex_lock (xvimagesink->pool_lock);
+
+ while (xvimagesink->image_pool) {
+ GstXvImage *xvimage = xvimagesink->image_pool->data;
+
+ xvimagesink->image_pool = g_slist_delete_link (xvimagesink->image_pool,
+ xvimagesink->image_pool);
+ gst_xvimagesink_xvimage_destroy (xvimagesink, xvimage);
+ }
+
+ g_mutex_unlock (xvimagesink->pool_lock);
}
/* Element stuff */
static GstCaps *
-gst_xvimagesink_fixate (GstPad *pad, const GstCaps *caps)
+gst_xvimagesink_fixate (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstCaps *newcaps;
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
/* This function tries to get a format matching with a given caps in the
supported list of formats we generated in gst_xvimagesink_get_xv_support */
static gint
-gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink *xvimagesink,
- GstCaps *caps)
+gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink * xvimagesink,
+ GstCaps * caps)
{
GList *list = NULL;
-
+
g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), 0);
-
+
list = xvimagesink->xcontext->formats_list;
-
- while (list)
- {
- GstXvImageFormat *format = list->data;
-
- if (format)
- {
- GstCaps *icaps = NULL;
- icaps = gst_caps_intersect (caps, format->caps);
- if (!gst_caps_is_empty(icaps))
- return format->format;
- }
- list = g_list_next (list);
+
+ while (list) {
+ GstXvImageFormat *format = list->data;
+
+ if (format) {
+ GstCaps *icaps = NULL;
+
+ icaps = gst_caps_intersect (caps, format->caps);
+ if (!gst_caps_is_empty (icaps))
+ return format->format;
}
-
+ list = g_list_next (list);
+ }
+
return 0;
}
static GstCaps *
-gst_xvimagesink_getcaps (GstPad *pad)
+gst_xvimagesink_getcaps (GstPad * pad)
{
GstXvImageSink *xvimagesink;
xvimagesink = GST_XVIMAGESINK (gst_pad_get_parent (pad));
-
+
if (xvimagesink->xcontext)
return gst_caps_copy (xvimagesink->xcontext->caps);
- return gst_caps_from_string(
- "video/x-raw-rgb, "
+ return gst_caps_from_string ("video/x-raw-rgb, "
"framerate = (double) [ 1.0, 100.0 ], "
"width = (int) [ 0, MAX ], "
"height = (int) [ 0, MAX ]; "
- "video/x-raw-yuv, "
+ "video/x-raw-yuv, "
"framerate = (double) [ 0, MAX ], "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ]");
+ "width = (int) [ 0, MAX ], " "height = (int) [ 0, MAX ]");
}
static GstPadLinkReturn
-gst_xvimagesink_sink_link (GstPad *pad, const GstCaps *caps)
+gst_xvimagesink_sink_link (GstPad * pad, const GstCaps * caps)
{
GstXvImageSink *xvimagesink;
char *caps_str1, *caps_str2;
g_free (caps_str1);
g_free (caps_str2);
-
+
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width",
- &(GST_VIDEOSINK_WIDTH (xvimagesink)));
+ &(GST_VIDEOSINK_WIDTH (xvimagesink)));
ret &= gst_structure_get_int (structure, "height",
- &(GST_VIDEOSINK_HEIGHT (xvimagesink)));
+ &(GST_VIDEOSINK_HEIGHT (xvimagesink)));
ret &= gst_structure_get_double (structure, "framerate",
- &xvimagesink->framerate);
- if (!ret) return GST_PAD_LINK_REFUSED;
-
+ &xvimagesink->framerate);
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
+
xvimagesink->xcontext->im_format = 0;
if (!gst_structure_get_fourcc (structure, "format",
- &xvimagesink->xcontext->im_format)) {
- xvimagesink->xcontext->im_format = gst_xvimagesink_get_fourcc_from_caps (
- xvimagesink, gst_caps_copy(caps));
+ &xvimagesink->xcontext->im_format)) {
+ xvimagesink->xcontext->im_format =
+ gst_xvimagesink_get_fourcc_from_caps (xvimagesink,
+ gst_caps_copy (caps));
}
if (xvimagesink->xcontext->im_format == 0) {
return GST_PAD_LINK_REFUSED;
}
-
+
xvimagesink->pixel_width = 1;
gst_structure_get_int (structure, "pixel_width", &xvimagesink->pixel_width);
xvimagesink->pixel_height = 1;
- gst_structure_get_int (structure, "pixel_height",
- &xvimagesink->pixel_height);
-
+ gst_structure_get_int (structure, "pixel_height", &xvimagesink->pixel_height);
+
/* Creating our window and our image */
if (!xvimagesink->xwindow)
xvimagesink->xwindow = gst_xvimagesink_xwindow_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
- else
- {
- if (xvimagesink->xwindow->internal)
- gst_xvimagesink_xwindow_resize (xvimagesink, xvimagesink->xwindow,
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
- }
-
- if ( (xvimagesink->xvimage) &&
- ( (GST_VIDEOSINK_WIDTH (xvimagesink) != xvimagesink->xvimage->width) ||
- (GST_VIDEOSINK_HEIGHT (xvimagesink) != xvimagesink->xvimage->height) ) )
- { /* We renew our xvimage only if size changed */
- gst_xvimagesink_xvimage_destroy (xvimagesink, xvimagesink->xvimage);
-
- xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
- }
- else if (!xvimagesink->xvimage) /* If no xvimage, creating one */
+ GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
+ else {
+ if (xvimagesink->xwindow->internal)
+ gst_xvimagesink_xwindow_resize (xvimagesink, xvimagesink->xwindow,
+ GST_VIDEOSINK_WIDTH (xvimagesink),
+ GST_VIDEOSINK_HEIGHT (xvimagesink));
+ }
+
+ if ((xvimagesink->xvimage) && ((GST_VIDEOSINK_WIDTH (xvimagesink) != xvimagesink->xvimage->width) || (GST_VIDEOSINK_HEIGHT (xvimagesink) != xvimagesink->xvimage->height))) { /* We renew our xvimage only if size changed */
+ gst_xvimagesink_xvimage_destroy (xvimagesink, xvimagesink->xvimage);
+
+ xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
+ GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
+ } else if (!xvimagesink->xvimage) /* If no xvimage, creating one */
xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
-
+ GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
+
gst_x_overlay_got_desired_size (GST_X_OVERLAY (xvimagesink),
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
-
+ GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
+
return GST_PAD_LINK_OK;
}
static GstElementStateReturn
-gst_xvimagesink_change_state (GstElement *element)
+gst_xvimagesink_change_state (GstElement * element)
{
GstXvImageSink *xvimagesink;
case GST_STATE_NULL_TO_READY:
/* Initializing the XContext */
if (!xvimagesink->xcontext)
- xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
+ xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
if (!xvimagesink->xcontext)
- return GST_STATE_FAILURE;
- else /* If context initialized correctly let's commit our colorbalance */
- gst_xvimagesink_update_colorbalance (xvimagesink);
+ return GST_STATE_FAILURE;
+ else /* If context initialized correctly let's commit our colorbalance */
+ gst_xvimagesink_update_colorbalance (xvimagesink);
break;
case GST_STATE_READY_TO_PAUSED:
if (xvimagesink->xwindow)
- gst_xvimagesink_xwindow_clear (xvimagesink, xvimagesink->xwindow);
+ gst_xvimagesink_xwindow_clear (xvimagesink, xvimagesink->xwindow);
xvimagesink->time = 0;
break;
case GST_STATE_PAUSED_TO_PLAYING:
GST_VIDEOSINK_HEIGHT (xvimagesink) = 0;
break;
case GST_STATE_READY_TO_NULL:
- if (xvimagesink->xvimage)
- {
- gst_xvimagesink_xvimage_destroy (xvimagesink, xvimagesink->xvimage);
- xvimagesink->xvimage = NULL;
- }
-
+ if (xvimagesink->xvimage) {
+ gst_xvimagesink_xvimage_destroy (xvimagesink, xvimagesink->xvimage);
+ xvimagesink->xvimage = NULL;
+ }
+
if (xvimagesink->image_pool)
- gst_xvimagesink_imagepool_clear (xvimagesink);
-
- if (xvimagesink->xwindow)
- {
- gst_xvimagesink_xwindow_destroy (xvimagesink, xvimagesink->xwindow);
- xvimagesink->xwindow = NULL;
- }
-
- if (xvimagesink->xcontext)
- {
- gst_xvimagesink_xcontext_clear (xvimagesink);
- xvimagesink->xcontext = NULL;
- }
+ gst_xvimagesink_imagepool_clear (xvimagesink);
+
+ if (xvimagesink->xwindow) {
+ gst_xvimagesink_xwindow_destroy (xvimagesink, xvimagesink->xwindow);
+ xvimagesink->xwindow = NULL;
+ }
+
+ if (xvimagesink->xcontext) {
+ gst_xvimagesink_xcontext_clear (xvimagesink);
+ xvimagesink->xcontext = NULL;
+ }
break;
}
}
static void
-gst_xvimagesink_chain (GstPad *pad, GstData *data)
+gst_xvimagesink_chain (GstPad * pad, GstData * data)
{
GstBuffer *buf = NULL;
GstXvImageSink *xvimagesink;
g_return_if_fail (data != NULL);
xvimagesink = GST_XVIMAGESINK (gst_pad_get_parent (pad));
-
- if (GST_IS_EVENT (data))
- {
- gst_pad_event_default (pad, GST_EVENT (data));
- return;
- }
-
+
+ if (GST_IS_EVENT (data)) {
+ gst_pad_event_default (pad, GST_EVENT (data));
+ return;
+ }
+
buf = GST_BUFFER (data);
/* update time */
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
if (GST_VIDEOSINK_CLOCK (xvimagesink)) {
gst_element_wait (GST_ELEMENT (xvimagesink), xvimagesink->time);
}
-
+
/* If this buffer has been allocated using our buffer management we simply
put the ximage which is in the PRIVATE pointer */
- if (GST_BUFFER_FREE_DATA_FUNC (buf) == gst_xvimagesink_buffer_free)
- {
- gst_xvimagesink_xvimage_put (xvimagesink, GST_BUFFER_PRIVATE (buf));
- }
- else /* Else we have to copy the data into our private image, */
- { /* if we have one... */
- if (xvimagesink->xvimage)
- {
- memcpy (xvimagesink->xvimage->xvimage->data,
- GST_BUFFER_DATA (buf),
- MIN (GST_BUFFER_SIZE (buf), xvimagesink->xvimage->size));
- gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->xvimage);
- }
- else /* No image available. Something went wrong during capsnego ! */
- {
- gst_buffer_unref (buf);
- GST_ELEMENT_ERROR (xvimagesink, CORE, NEGOTIATION, (NULL), ("no format defined before chain function"));
- return;
- }
+ if (GST_BUFFER_FREE_DATA_FUNC (buf) == gst_xvimagesink_buffer_free) {
+ gst_xvimagesink_xvimage_put (xvimagesink, GST_BUFFER_PRIVATE (buf));
+ } else { /* Else we have to copy the data into our private image, */
+ /* if we have one... */
+ if (xvimagesink->xvimage) {
+ memcpy (xvimagesink->xvimage->xvimage->data,
+ GST_BUFFER_DATA (buf),
+ MIN (GST_BUFFER_SIZE (buf), xvimagesink->xvimage->size));
+ gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->xvimage);
+ } else { /* No image available. Something went wrong during capsnego ! */
+
+ gst_buffer_unref (buf);
+ GST_ELEMENT_ERROR (xvimagesink, CORE, NEGOTIATION, (NULL),
+ ("no format defined before chain function"));
+ return;
}
+ }
/* set correct time for next buffer */
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf) && xvimagesink->framerate > 0) {
}
gst_buffer_unref (buf);
-
+
gst_xvimagesink_handle_xevents (xvimagesink, pad);
}
/* Buffer management */
static void
-gst_xvimagesink_buffer_free (GstBuffer *buffer)
+gst_xvimagesink_buffer_free (GstBuffer * buffer)
{
GstXvImageSink *xvimagesink;
GstXvImage *xvimage;
-
+
xvimage = GST_BUFFER_PRIVATE (buffer);
-
+
g_assert (GST_IS_XVIMAGESINK (xvimage->xvimagesink));
xvimagesink = xvimage->xvimagesink;
-
+
/* If our geometry changed we can't reuse that image. */
- if ( (xvimage->width != GST_VIDEOSINK_WIDTH (xvimagesink)) ||
- (xvimage->height != GST_VIDEOSINK_HEIGHT (xvimagesink)) )
+ if ((xvimage->width != GST_VIDEOSINK_WIDTH (xvimagesink)) ||
+ (xvimage->height != GST_VIDEOSINK_HEIGHT (xvimagesink)))
gst_xvimagesink_xvimage_destroy (xvimagesink, xvimage);
- else /* In that case we can reuse the image and add it to our image pool. */
- {
- g_mutex_lock (xvimagesink->pool_lock);
- xvimagesink->image_pool = g_slist_prepend (xvimagesink->image_pool,
- xvimage);
- g_mutex_unlock (xvimagesink->pool_lock);
- }
+ else { /* In that case we can reuse the image and add it to our image pool. */
+
+ g_mutex_lock (xvimagesink->pool_lock);
+ xvimagesink->image_pool = g_slist_prepend (xvimagesink->image_pool,
+ xvimage);
+ g_mutex_unlock (xvimagesink->pool_lock);
+ }
}
static GstBuffer *
-gst_xvimagesink_buffer_alloc (GstPad *pad, guint64 offset, guint size)
+gst_xvimagesink_buffer_alloc (GstPad * pad, guint64 offset, guint size)
{
GstXvImageSink *xvimagesink;
GstBuffer *buffer;
GstXvImage *xvimage = NULL;
gboolean not_found = TRUE;
-
+
xvimagesink = GST_XVIMAGESINK (gst_pad_get_parent (pad));
g_mutex_lock (xvimagesink->pool_lock);
-
+
/* Walking through the pool cleaning unsuable images and searching for a
suitable one */
- while (not_found && xvimagesink->image_pool)
- {
- xvimage = xvimagesink->image_pool->data;
-
- if (xvimage)
- {
- /* Removing from the pool */
- xvimagesink->image_pool = g_slist_delete_link (xvimagesink->image_pool,
- xvimagesink->image_pool);
-
- if ( (xvimage->width != GST_VIDEOSINK_WIDTH (xvimagesink)) ||
- (xvimage->height != GST_VIDEOSINK_HEIGHT (xvimagesink)) )
- { /* This image is unusable. Destroying... */
- gst_xvimagesink_xvimage_destroy (xvimagesink, xvimage);
- xvimage = NULL;
- }
- else /* We found a suitable image */
- {
- break;
- }
- }
+ while (not_found && xvimagesink->image_pool) {
+ xvimage = xvimagesink->image_pool->data;
+
+ if (xvimage) {
+ /* Removing from the pool */
+ xvimagesink->image_pool = g_slist_delete_link (xvimagesink->image_pool,
+ xvimagesink->image_pool);
+
+ if ((xvimage->width != GST_VIDEOSINK_WIDTH (xvimagesink)) || (xvimage->height != GST_VIDEOSINK_HEIGHT (xvimagesink))) { /* This image is unusable. Destroying... */
+ gst_xvimagesink_xvimage_destroy (xvimagesink, xvimage);
+ xvimage = NULL;
+ } else { /* We found a suitable image */
+
+ break;
+ }
}
-
+ }
+
g_mutex_unlock (xvimagesink->pool_lock);
-
- if (!xvimage) /* We found no suitable image in the pool. Creating... */
- {
- xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
- }
-
- if (xvimage)
- {
- buffer = gst_buffer_new ();
-
- /* Storing some pointers in the buffer */
- GST_BUFFER_PRIVATE (buffer) = xvimage;
-
- GST_BUFFER_DATA (buffer) = xvimage->xvimage->data;
- GST_BUFFER_FREE_DATA_FUNC (buffer) = gst_xvimagesink_buffer_free;
- GST_BUFFER_SIZE (buffer) = xvimage->size;
- return buffer;
- }
- else
+
+ if (!xvimage) { /* We found no suitable image in the pool. Creating... */
+ xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
+ GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
+ }
+
+ if (xvimage) {
+ buffer = gst_buffer_new ();
+
+ /* Storing some pointers in the buffer */
+ GST_BUFFER_PRIVATE (buffer) = xvimage;
+
+ GST_BUFFER_DATA (buffer) = xvimage->xvimage->data;
+ GST_BUFFER_FREE_DATA_FUNC (buffer) = gst_xvimagesink_buffer_free;
+ GST_BUFFER_SIZE (buffer) = xvimage->size;
+ return buffer;
+ } else
return NULL;
}
/* Interfaces stuff */
static gboolean
-gst_xvimagesink_interface_supported (GstImplementsInterface *iface, GType type)
+gst_xvimagesink_interface_supported (GstImplementsInterface * iface, GType type)
{
g_assert (type == GST_TYPE_NAVIGATION ||
- type == GST_TYPE_X_OVERLAY ||
- type == GST_TYPE_COLOR_BALANCE);
+ type == GST_TYPE_X_OVERLAY || type == GST_TYPE_COLOR_BALANCE);
return TRUE;
}
static void
-gst_xvimagesink_interface_init (GstImplementsInterfaceClass *klass)
+gst_xvimagesink_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_xvimagesink_interface_supported;
}
static void
-gst_xvimagesink_navigation_send_event (GstNavigation *navigation,
- GstStructure *structure)
+gst_xvimagesink_navigation_send_event (GstNavigation * navigation,
+ GstStructure * structure)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (navigation);
GstEvent *event;
- double x,y;
+ double x, y;
event = gst_event_new (GST_EVENT_NAVIGATION);
event->event_data.structure.structure = structure;
-
+
/* Converting pointer coordinates to the non scaled geometry */
- if (gst_structure_get_double (structure, "pointer_x", &x))
- {
- x *= GST_VIDEOSINK_WIDTH (xvimagesink);
- x /= xvimagesink->xwindow->width;
- gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
- }
- if (gst_structure_get_double (structure, "pointer_y", &y))
- {
- y *= GST_VIDEOSINK_HEIGHT (xvimagesink);
- y /= xvimagesink->xwindow->height;
- gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
- }
+ if (gst_structure_get_double (structure, "pointer_x", &x)) {
+ x *= GST_VIDEOSINK_WIDTH (xvimagesink);
+ x /= xvimagesink->xwindow->width;
+ gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
+ }
+ if (gst_structure_get_double (structure, "pointer_y", &y)) {
+ y *= GST_VIDEOSINK_HEIGHT (xvimagesink);
+ y /= xvimagesink->xwindow->height;
+ gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
+ }
gst_pad_send_event (gst_pad_get_peer (GST_VIDEOSINK_PAD (xvimagesink)),
- event);
+ event);
}
static void
-gst_xvimagesink_navigation_init (GstNavigationInterface *iface)
+gst_xvimagesink_navigation_init (GstNavigationInterface * iface)
{
iface->send_event = gst_xvimagesink_navigation_send_event;
}
static void
-gst_xvimagesink_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id)
+gst_xvimagesink_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
GstXWindow *xwindow = NULL;
XWindowAttributes attr;
-
+
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
+
/* If we already use that window return */
if (xvimagesink->xwindow && (xwindow_id == xvimagesink->xwindow->win))
return;
-
+
/* If the element has not initialized the X11 context try to do so */
if (!xvimagesink->xcontext)
xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
-
- if (!xvimagesink->xcontext)
- {
- g_warning ("xvimagesink was unable to obtain the X11 context.");
- return;
- }
- else /* If context initialized correctly let's commit our colorbalance */
+
+ if (!xvimagesink->xcontext) {
+ g_warning ("xvimagesink was unable to obtain the X11 context.");
+ return;
+ } else /* If context initialized correctly let's commit our colorbalance */
gst_xvimagesink_update_colorbalance (xvimagesink);
-
+
/* Clear image pool as the images are unusable anyway */
gst_xvimagesink_imagepool_clear (xvimagesink);
-
+
/* Clear the xvimage */
- if (xvimagesink->xvimage)
- {
- gst_xvimagesink_xvimage_destroy (xvimagesink, xvimagesink->xvimage);
- xvimagesink->xvimage = NULL;
- }
-
+ if (xvimagesink->xvimage) {
+ gst_xvimagesink_xvimage_destroy (xvimagesink, xvimagesink->xvimage);
+ xvimagesink->xvimage = NULL;
+ }
+
/* If a window is there already we destroy it */
- if (xvimagesink->xwindow)
- {
- gst_xvimagesink_xwindow_destroy (xvimagesink, xvimagesink->xwindow);
- xvimagesink->xwindow = NULL;
- }
-
+ if (xvimagesink->xwindow) {
+ gst_xvimagesink_xwindow_destroy (xvimagesink, xvimagesink->xwindow);
+ xvimagesink->xwindow = NULL;
+ }
+
/* If the xid is 0 we go back to an internal window */
- if (xwindow_id == 0)
- {
- /* If no width/height caps nego did not happen window will be created
- during caps nego then */
- if (GST_VIDEOSINK_WIDTH (xvimagesink) &&
- GST_VIDEOSINK_HEIGHT (xvimagesink))
- {
- xwindow = gst_xvimagesink_xwindow_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
- }
+ if (xwindow_id == 0) {
+ /* If no width/height caps nego did not happen window will be created
+ during caps nego then */
+ if (GST_VIDEOSINK_WIDTH (xvimagesink) && GST_VIDEOSINK_HEIGHT (xvimagesink)) {
+ xwindow = gst_xvimagesink_xwindow_new (xvimagesink,
+ GST_VIDEOSINK_WIDTH (xvimagesink),
+ GST_VIDEOSINK_HEIGHT (xvimagesink));
}
- else
- {
- xwindow = g_new0 (GstXWindow, 1);
+ } else {
+ xwindow = g_new0 (GstXWindow, 1);
+
+ xwindow->win = xwindow_id;
+
+ /* We get window geometry, set the event we want to receive,
+ and create a GC */
+ g_mutex_lock (xvimagesink->x_lock);
+ XGetWindowAttributes (xvimagesink->xcontext->disp, xwindow->win, &attr);
+ xwindow->width = attr.width;
+ xwindow->height = attr.height;
+ xwindow->internal = FALSE;
+ XSelectInput (xvimagesink->xcontext->disp, xwindow->win, ExposureMask |
+ StructureNotifyMask | PointerMotionMask | KeyPressMask |
+ KeyReleaseMask);
+
+ xwindow->gc = XCreateGC (xvimagesink->xcontext->disp,
+ xwindow->win, 0, NULL);
+ g_mutex_unlock (xvimagesink->x_lock);
+ }
- xwindow->win = xwindow_id;
-
- /* We get window geometry, set the event we want to receive,
- and create a GC */
- g_mutex_lock (xvimagesink->x_lock);
- XGetWindowAttributes (xvimagesink->xcontext->disp, xwindow->win, &attr);
- xwindow->width = attr.width;
- xwindow->height = attr.height;
- xwindow->internal = FALSE;
- XSelectInput (xvimagesink->xcontext->disp, xwindow->win, ExposureMask |
- StructureNotifyMask | PointerMotionMask | KeyPressMask |
- KeyReleaseMask);
-
- xwindow->gc = XCreateGC (xvimagesink->xcontext->disp,
- xwindow->win, 0, NULL);
- g_mutex_unlock (xvimagesink->x_lock);
- }
-
/* Recreating our xvimage */
if (!xvimagesink->xvimage &&
- GST_VIDEOSINK_WIDTH (xvimagesink) &&
- GST_VIDEOSINK_HEIGHT (xvimagesink))
- {
- xvimagesink->xvimage = gst_xvimagesink_xvimage_new (
- xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink),
- GST_VIDEOSINK_HEIGHT (xvimagesink));
- }
-
+ GST_VIDEOSINK_WIDTH (xvimagesink) && GST_VIDEOSINK_HEIGHT (xvimagesink)) {
+ xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
+ GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
+ }
+
if (xwindow)
xvimagesink->xwindow = xwindow;
}
static void
-gst_xvimagesink_get_desired_size (GstXOverlay *overlay,
- guint *width, guint *height)
+gst_xvimagesink_get_desired_size (GstXOverlay * overlay,
+ guint * width, guint * height)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
}
static void
-gst_xvimagesink_expose (GstXOverlay *overlay)
+gst_xvimagesink_expose (GstXOverlay * overlay)
{
XWindowAttributes attr;
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
if (!xvimagesink->xwindow)
return;
-
+
/* Update the window geometry */
g_mutex_lock (xvimagesink->x_lock);
XGetWindowAttributes (xvimagesink->xcontext->disp,
- xvimagesink->xwindow->win, &attr);
+ xvimagesink->xwindow->win, &attr);
g_mutex_unlock (xvimagesink->x_lock);
-
+
xvimagesink->xwindow->width = attr.width;
xvimagesink->xwindow->height = attr.height;
-
+
if (xvimagesink->cur_image) {
gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->cur_image);
}
}
static void
-gst_xvimagesink_xoverlay_init (GstXOverlayClass *iface)
+gst_xvimagesink_xoverlay_init (GstXOverlayClass * iface)
{
iface->set_xwindow_id = gst_xvimagesink_set_xwindow_id;
iface->get_desired_size = gst_xvimagesink_get_desired_size;
}
static const GList *
-gst_xvimagesink_colorbalance_list_channels (GstColorBalance *balance)
+gst_xvimagesink_colorbalance_list_channels (GstColorBalance * balance)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (balance);
-
+
g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
-
+
if (xvimagesink->xcontext)
return xvimagesink->xcontext->channels_list;
else
}
static void
-gst_xvimagesink_colorbalance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value)
+gst_xvimagesink_colorbalance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (balance);
-
+
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
g_return_if_fail (channel->label != NULL);
-
+
xvimagesink->cb_changed = TRUE;
-
+
/* Normalize val to [-1000, 1000] */
value = -1000 + 2000 * (value - channel->min_value) /
- (channel->max_value - channel->min_value);
-
- if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0)
- {
- xvimagesink->hue = value;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_SATURATION") == 0)
- {
- xvimagesink->saturation = value;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_CONTRAST") == 0)
- {
- xvimagesink->contrast = value;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_BRIGHTNESS") == 0)
- {
- xvimagesink->brightness = value;
- }
- else
- {
- g_warning ("got an unknown channel %s", channel->label);
- return;
- }
-
+ (channel->max_value - channel->min_value);
+
+ if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0) {
+ xvimagesink->hue = value;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_SATURATION") == 0) {
+ xvimagesink->saturation = value;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_CONTRAST") == 0) {
+ xvimagesink->contrast = value;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_BRIGHTNESS") == 0) {
+ xvimagesink->brightness = value;
+ } else {
+ g_warning ("got an unknown channel %s", channel->label);
+ return;
+ }
+
gst_xvimagesink_update_colorbalance (xvimagesink);
}
static gint
-gst_xvimagesink_colorbalance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel)
+gst_xvimagesink_colorbalance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (balance);
gint value = 0;
-
+
g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), 0);
g_return_val_if_fail (channel->label != NULL, 0);
-
- if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0)
- {
- value = xvimagesink->hue;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_SATURATION") == 0)
- {
- value = xvimagesink->saturation;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_CONTRAST") == 0)
- {
- value = xvimagesink->contrast;
- }
- else if (g_ascii_strcasecmp (channel->label, "XV_BRIGHTNESS") == 0)
- {
- value = xvimagesink->brightness;
- }
- else
- {
- g_warning ("got an unknown channel %s", channel->label);
- }
-
+
+ if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0) {
+ value = xvimagesink->hue;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_SATURATION") == 0) {
+ value = xvimagesink->saturation;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_CONTRAST") == 0) {
+ value = xvimagesink->contrast;
+ } else if (g_ascii_strcasecmp (channel->label, "XV_BRIGHTNESS") == 0) {
+ value = xvimagesink->brightness;
+ } else {
+ g_warning ("got an unknown channel %s", channel->label);
+ }
+
/* Normalize val to [channel->min_value, channel->max_value] */
value = channel->min_value + (channel->max_value - channel->min_value) *
- (value + 1000) / 2000;
-
+ (value + 1000) / 2000;
+
return value;
}
static void
-gst_xvimagesink_colorbalance_init (GstColorBalanceClass *iface)
+gst_xvimagesink_colorbalance_init (GstColorBalanceClass * iface)
{
GST_COLOR_BALANCE_TYPE (iface) = GST_COLOR_BALANCE_HARDWARE;
iface->list_channels = gst_xvimagesink_colorbalance_list_channels;
/* =========================================== */
static void
-gst_xvimagesink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_xvimagesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstXvImageSink *xvimagesink;
-
+
g_return_if_fail (GST_IS_XVIMAGESINK (object));
-
+
xvimagesink = GST_XVIMAGESINK (object);
-
- switch (prop_id)
- {
- case ARG_HUE:
- xvimagesink->hue = g_value_get_int (value);
- xvimagesink->cb_changed = TRUE;
- gst_xvimagesink_update_colorbalance (xvimagesink);
- break;
- case ARG_CONTRAST:
- xvimagesink->contrast = g_value_get_int (value);
- xvimagesink->cb_changed = TRUE;
- gst_xvimagesink_update_colorbalance (xvimagesink);
- break;
- case ARG_BRIGHTNESS:
- xvimagesink->brightness = g_value_get_int (value);
- xvimagesink->cb_changed = TRUE;
- gst_xvimagesink_update_colorbalance (xvimagesink);
- break;
- case ARG_SATURATION:
- xvimagesink->saturation = g_value_get_int (value);
- xvimagesink->cb_changed = TRUE;
- gst_xvimagesink_update_colorbalance (xvimagesink);
- break;
- case ARG_DISPLAY:
- xvimagesink->display_name = g_strdup (g_value_get_string (value));
- break;
- case ARG_SYNCHRONOUS:
- xvimagesink->synchronous = g_value_get_boolean (value);
- if (xvimagesink->xcontext) {
- XSynchronize (xvimagesink->xcontext->disp,
- xvimagesink->synchronous);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+
+ switch (prop_id) {
+ case ARG_HUE:
+ xvimagesink->hue = g_value_get_int (value);
+ xvimagesink->cb_changed = TRUE;
+ gst_xvimagesink_update_colorbalance (xvimagesink);
+ break;
+ case ARG_CONTRAST:
+ xvimagesink->contrast = g_value_get_int (value);
+ xvimagesink->cb_changed = TRUE;
+ gst_xvimagesink_update_colorbalance (xvimagesink);
+ break;
+ case ARG_BRIGHTNESS:
+ xvimagesink->brightness = g_value_get_int (value);
+ xvimagesink->cb_changed = TRUE;
+ gst_xvimagesink_update_colorbalance (xvimagesink);
+ break;
+ case ARG_SATURATION:
+ xvimagesink->saturation = g_value_get_int (value);
+ xvimagesink->cb_changed = TRUE;
+ gst_xvimagesink_update_colorbalance (xvimagesink);
+ break;
+ case ARG_DISPLAY:
+ xvimagesink->display_name = g_strdup (g_value_get_string (value));
+ break;
+ case ARG_SYNCHRONOUS:
+ xvimagesink->synchronous = g_value_get_boolean (value);
+ if (xvimagesink->xcontext) {
+ XSynchronize (xvimagesink->xcontext->disp, xvimagesink->synchronous);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gst_xvimagesink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_xvimagesink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstXvImageSink *xvimagesink;
-
+
g_return_if_fail (GST_IS_XVIMAGESINK (object));
-
+
xvimagesink = GST_XVIMAGESINK (object);
-
- switch (prop_id)
- {
- case ARG_HUE:
- g_value_set_int (value, xvimagesink->hue);
- break;
- case ARG_CONTRAST:
- g_value_set_int (value, xvimagesink->contrast);
- break;
- case ARG_BRIGHTNESS:
- g_value_set_int (value, xvimagesink->brightness);
- break;
- case ARG_SATURATION:
- g_value_set_int (value, xvimagesink->saturation);
- break;
- case ARG_DISPLAY:
- g_value_set_string (value, g_strdup (xvimagesink->display_name));
- break;
- case ARG_SYNCHRONOUS:
- g_value_set_boolean (value, xvimagesink->synchronous);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+
+ switch (prop_id) {
+ case ARG_HUE:
+ g_value_set_int (value, xvimagesink->hue);
+ break;
+ case ARG_CONTRAST:
+ g_value_set_int (value, xvimagesink->contrast);
+ break;
+ case ARG_BRIGHTNESS:
+ g_value_set_int (value, xvimagesink->brightness);
+ break;
+ case ARG_SATURATION:
+ g_value_set_int (value, xvimagesink->saturation);
+ break;
+ case ARG_DISPLAY:
+ g_value_set_string (value, g_strdup (xvimagesink->display_name));
+ break;
+ case ARG_SYNCHRONOUS:
+ g_value_set_boolean (value, xvimagesink->synchronous);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gst_xvimagesink_dispose (GObject *object)
+gst_xvimagesink_dispose (GObject * object)
{
GstXvImageSink *xvimagesink;
xvimagesink = GST_XVIMAGESINK (object);
- if (xvimagesink->display_name)
- {
- g_free (xvimagesink->display_name);
- xvimagesink->display_name = NULL;
- }
+ if (xvimagesink->display_name) {
+ g_free (xvimagesink->display_name);
+ xvimagesink->display_name = NULL;
+ }
g_mutex_free (xvimagesink->x_lock);
g_mutex_free (xvimagesink->pool_lock);
}
static void
-gst_xvimagesink_init (GstXvImageSink *xvimagesink)
+gst_xvimagesink_init (GstXvImageSink * xvimagesink)
{
- GST_VIDEOSINK_PAD (xvimagesink) = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_xvimagesink_sink_template_factory),
- "sink");
-
+ GST_VIDEOSINK_PAD (xvimagesink) =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_xvimagesink_sink_template_factory), "sink");
+
gst_element_add_pad (GST_ELEMENT (xvimagesink),
- GST_VIDEOSINK_PAD (xvimagesink));
+ GST_VIDEOSINK_PAD (xvimagesink));
gst_pad_set_chain_function (GST_VIDEOSINK_PAD (xvimagesink),
- gst_xvimagesink_chain);
+ gst_xvimagesink_chain);
gst_pad_set_link_function (GST_VIDEOSINK_PAD (xvimagesink),
- gst_xvimagesink_sink_link);
+ gst_xvimagesink_sink_link);
gst_pad_set_getcaps_function (GST_VIDEOSINK_PAD (xvimagesink),
- gst_xvimagesink_getcaps);
+ gst_xvimagesink_getcaps);
gst_pad_set_fixate_function (GST_VIDEOSINK_PAD (xvimagesink),
- gst_xvimagesink_fixate);
+ gst_xvimagesink_fixate);
gst_pad_set_bufferalloc_function (GST_VIDEOSINK_PAD (xvimagesink),
- gst_xvimagesink_buffer_alloc);
-
+ gst_xvimagesink_buffer_alloc);
+
xvimagesink->display_name = NULL;
xvimagesink->xcontext = NULL;
xvimagesink->xwindow = NULL;
xvimagesink->xvimage = NULL;
xvimagesink->cur_image = NULL;
-
+
xvimagesink->hue = xvimagesink->saturation = 0;
xvimagesink->contrast = xvimagesink->brightness = 0;
xvimagesink->cb_changed = FALSE;
-
+
xvimagesink->framerate = 0;
-
+
xvimagesink->x_lock = g_mutex_new ();
-
+
xvimagesink->pixel_width = xvimagesink->pixel_height = 1;
-
+
xvimagesink->image_pool = NULL;
xvimagesink->pool_lock = g_mutex_new ();
xvimagesink->synchronous = FALSE;
- GST_FLAG_SET(xvimagesink, GST_ELEMENT_THREAD_SUGGESTED);
- GST_FLAG_SET(xvimagesink, GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (xvimagesink, GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (xvimagesink, GST_ELEMENT_EVENT_AWARE);
}
static void
gst_xvimagesink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &gst_xvimagesink_details);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_xvimagesink_sink_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_xvimagesink_sink_template_factory));
}
static void
-gst_xvimagesink_class_init (GstXvImageSinkClass *klass)
+gst_xvimagesink_class_init (GstXvImageSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
parent_class = g_type_class_ref (GST_TYPE_VIDEOSINK);
g_object_class_install_property (gobject_class, ARG_CONTRAST,
- g_param_spec_int ("contrast", "Contrast", "The contrast of the video",
- -1000, 1000, 0, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_BRIGHTNESS,
- g_param_spec_int ("brightness", "Brightness", "The brightness of the video",
- -1000, 1000, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("contrast", "Contrast", "The contrast of the video",
+ -1000, 1000, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BRIGHTNESS,
+ g_param_spec_int ("brightness", "Brightness",
+ "The brightness of the video", -1000, 1000, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_HUE,
- g_param_spec_int ("hue", "Hue", "The hue of the video",
- -1000, 1000, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("hue", "Hue", "The hue of the video", -1000, 1000, 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_SATURATION,
- g_param_spec_int ("saturation", "Saturation", "The saturation of the video",
- -1000, 1000, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("saturation", "Saturation",
+ "The saturation of the video", -1000, 1000, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_DISPLAY,
- g_param_spec_string ("display", "Display", "X Display name",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("display", "Display", "X Display name", NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_SYNCHRONOUS,
- g_param_spec_boolean ("synchronous", "Synchronous", "When enabled, runs "
- "the X display in synchronous mode. (used only for debugging)", FALSE,
- G_PARAM_READWRITE));
-
+ g_param_spec_boolean ("synchronous", "Synchronous",
+ "When enabled, runs "
+ "the X display in synchronous mode. (used only for debugging)", FALSE,
+ G_PARAM_READWRITE));
+
gobject_class->dispose = gst_xvimagesink_dispose;
gobject_class->set_property = gst_xvimagesink_set_property;
gobject_class->get_property = gst_xvimagesink_get_property;
-
+
gstelement_class->change_state = gst_xvimagesink_change_state;
}
{
static GType xvimagesink_type = 0;
- if (!xvimagesink_type)
- {
- static const GTypeInfo xvimagesink_info = {
- sizeof(GstXvImageSinkClass),
- gst_xvimagesink_base_init,
- NULL,
- (GClassInitFunc) gst_xvimagesink_class_init,
- NULL,
- NULL,
- sizeof(GstXvImageSink),
- 0,
- (GInstanceInitFunc) gst_xvimagesink_init,
- };
- static const GInterfaceInfo iface_info = {
- (GInterfaceInitFunc) gst_xvimagesink_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo navigation_info = {
- (GInterfaceInitFunc) gst_xvimagesink_navigation_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo overlay_info = {
- (GInterfaceInitFunc) gst_xvimagesink_xoverlay_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo colorbalance_info = {
- (GInterfaceInitFunc) gst_xvimagesink_colorbalance_init,
- NULL,
- NULL,
- };
-
- xvimagesink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
- "GstXvImageSink",
- &xvimagesink_info, 0);
-
- g_type_add_interface_static (xvimagesink_type, GST_TYPE_IMPLEMENTS_INTERFACE,
- &iface_info);
- g_type_add_interface_static (xvimagesink_type, GST_TYPE_NAVIGATION,
- &navigation_info);
- g_type_add_interface_static (xvimagesink_type, GST_TYPE_X_OVERLAY,
- &overlay_info);
- g_type_add_interface_static (xvimagesink_type, GST_TYPE_COLOR_BALANCE,
- &colorbalance_info);
- }
-
+ if (!xvimagesink_type) {
+ static const GTypeInfo xvimagesink_info = {
+ sizeof (GstXvImageSinkClass),
+ gst_xvimagesink_base_init,
+ NULL,
+ (GClassInitFunc) gst_xvimagesink_class_init,
+ NULL,
+ NULL,
+ sizeof (GstXvImageSink),
+ 0,
+ (GInstanceInitFunc) gst_xvimagesink_init,
+ };
+ static const GInterfaceInfo iface_info = {
+ (GInterfaceInitFunc) gst_xvimagesink_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo navigation_info = {
+ (GInterfaceInitFunc) gst_xvimagesink_navigation_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo overlay_info = {
+ (GInterfaceInitFunc) gst_xvimagesink_xoverlay_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo colorbalance_info = {
+ (GInterfaceInitFunc) gst_xvimagesink_colorbalance_init,
+ NULL,
+ NULL,
+ };
+
+ xvimagesink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
+ "GstXvImageSink", &xvimagesink_info, 0);
+
+ g_type_add_interface_static (xvimagesink_type,
+ GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info);
+ g_type_add_interface_static (xvimagesink_type, GST_TYPE_NAVIGATION,
+ &navigation_info);
+ g_type_add_interface_static (xvimagesink_type, GST_TYPE_X_OVERLAY,
+ &overlay_info);
+ g_type_add_interface_static (xvimagesink_type, GST_TYPE_COLOR_BALANCE,
+ &colorbalance_info);
+ }
+
return xvimagesink_type;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* Loading the library containing GstVideoSink, our parent object */
if (!gst_library_load ("gstvideo"))
return FALSE;
-
+
if (!gst_element_register (plugin, "xvimagesink",
- GST_RANK_PRIMARY, GST_TYPE_XVIMAGESINK))
+ GST_RANK_PRIMARY, GST_TYPE_XVIMAGESINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "xvimagesink",
- "XFree86 video output plugin using Xv extension",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "xvimagesink",
+ "XFree86 video output plugin using Xv extension",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_XVIMAGESINK_H__
#define __GST_XVIMAGESINK_H__
#include <math.h>
G_BEGIN_DECLS
-
#define GST_TYPE_XVIMAGESINK \
(gst_xvimagesink_get_type())
#define GST_XVIMAGESINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_XVIMAGESINK))
#define GST_IS_XVIMAGESINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIMAGESINK))
-
typedef struct _GstXContext GstXContext;
typedef struct _GstXWindow GstXWindow;
typedef struct _GstXvImage GstXvImage;
typedef struct _GstXvImageFormat GstXvImageFormat;
-
+
typedef struct _GstXvImageSink GstXvImageSink;
typedef struct _GstXvImageSinkClass GstXvImageSinkClass;
/* Global X Context stuff */
-struct _GstXContext {
+struct _GstXContext
+{
Display *disp;
-
+
Screen *screen;
gint screen_num;
-
+
Visual *visual;
-
+
Window root;
-
+
gulong white, black;
-
+
gint depth;
gint bpp;
gint endianness;
-
+
gboolean use_xshm;
-
+
XvPortID xv_port_id;
gint im_format;
-
+
GList *formats_list;
GList *channels_list;
-
+
GstCaps *caps;
};
/* XWindow stuff */
-struct _GstXWindow {
+struct _GstXWindow
+{
Window win;
gint width, height;
gboolean internal;
};
/* XvImage format stuff */
-struct _GstXvImageFormat {
+struct _GstXvImageFormat
+{
gint format;
GstCaps *caps;
};
/* XvImage stuff */
-struct _GstXvImage {
+struct _GstXvImage
+{
/* Reference to the xvimagesink we belong to */
GstXvImageSink *xvimagesink;
-
+
XvImage *xvimage;
-
+
#ifdef HAVE_XSHM
XShmSegmentInfo SHMInfo;
-#endif /* HAVE_XSHM */
-
+#endif /* HAVE_XSHM */
+
char *data;
gint width, height, size;
};
-struct _GstXvImageSink {
+struct _GstXvImageSink
+{
/* Our element stuff */
GstVideoSink videosink;
-
+
char *display_name;
-
+
GstXContext *xcontext;
GstXWindow *xwindow;
GstXvImage *xvimage;
GstXvImage *cur_image;
-
+
gdouble framerate;
-
+
gint brightness;
gint contrast;
gint hue;
gint saturation;
gboolean cb_changed;
-
+
GMutex *x_lock;
-
+
/* Unused */
gint pixel_width, pixel_height;
GstClockTime time;
-
+
GMutex *pool_lock;
GSList *image_pool;
gboolean synchronous;
};
-struct _GstXvImageSinkClass {
+struct _GstXvImageSinkClass
+{
GstVideoSinkClass parent_class;
};
-GType gst_xvimagesink_get_type(void);
+GType gst_xvimagesink_get_type (void);
G_END_DECLS
-
#endif /* __GST_XVIMAGESINK_H__ */
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;
}
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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_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");
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;
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
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
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++;
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);
}
}
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++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
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 ();
}
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);
}
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);
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);
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;
}
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);
}
}
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)
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);
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);
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 ();
#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");
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;
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
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
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++;
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++;
}
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++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
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 ();
}
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);
}
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;
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);
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;
}
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);
}
}
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);
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);
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. */
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);
}
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, };
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);
/* 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");
ready = FALSE;
while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) {
count++;
- if (count > 10) break;
+ if (count > 10)
+ break;
}
print_caps (context->metadata);
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);
}
}
}
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);
* 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");
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *filesrc;
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");
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);
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;
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;
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 */
};
/* 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;
};
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;
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;
}
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;
}
void
-ui_feedback_clear (_filter_ui_t *ui)
+ui_feedback_clear (_filter_ui_t * ui)
{
gtk_text_buffer_set_text (ui->fb_buffer, "", 0);
}
/* 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;
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);
/* 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);
/* 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;
}
}
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;
}
}
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;
}
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);
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;
}
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);
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");
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");
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);
+ */
}
{
_filter_data_t filter_data;
_filter_ui_t filter_ui;
-
-
+
+
gtk_init (&argc, &argv);
gst_init (&argc, &argv);
gst_control_init (&argc, &argv);
gtk_widget_show_all (filter_ui.window);
gtk_main ();
-
+
return 0;
}
-
* 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;
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 {
}
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);
/* 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;
/* 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);
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);
}
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;
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;
}
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;
-
- g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link);
+ 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);
}
-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;
}
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;
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];
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;
g_print ("%s\r", status);
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *src;
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);
}
}
/* 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");
/* 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)) {
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) {
return 1;
}
-
#include <string.h>
static void
-get_position_info (GstElement *cdparanoia)
+get_position_info (GstElement * cdparanoia)
{
GstFormat track_format;
const GstFormat *formats;
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);
}
}
static void
-get_track_info (GstElement *cdparanoia)
+get_track_info (GstElement * cdparanoia)
{
GstFormat track_format;
gint64 total_tracks = 0, total_time = 0;
const GstFormat *formats;
gint i;
gint64 time_count = 0;
-
+
track_format = gst_format_get_by_nick ("track");
g_assert (track_format != 0);
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++;
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;
}
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);
}
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);
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)
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");
#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);
return cdaudio;
}
-static gchar*
-format_value (GtkScale *scale,
- gdouble value)
+static gchar *
+format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
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
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},
};
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++;
}
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++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position = 0;
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
+
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
if (clock)
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 ();
}
}
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);
}
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;
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);
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;
}
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);
}
}
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);
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);
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. */
#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");
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;
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
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
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++;
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++;
}
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++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
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 ();
}
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);
}
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;
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);
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;
}
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);
}
}
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);
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);
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. */
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);
}
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, };
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);
/* 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");
ready = FALSE;
while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) {
count++;
- if (count > 10) break;
+ if (count > 10)
+ break;
}
print_caps (context->metadata);
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);
}
}
}
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);
* 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;
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;
}
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;
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;
}
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
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);
}
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);
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));
#include "sinesrc.h"
#include <math.h>
-#include <string.h> /* memcpy */
+#include <string.h> /* memcpy */
#define SAMPLES_PER_WAVE 200
static GstStaticPadTemplate sinesrc_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, "
- "signed = (boolean) { FALSE, TRUE }, "
- "width = (int) [8, 32], "
- "depth = (int) [8, 32], "
- "rate = (int) [8000, 192000], "
- "channels = (int) [1, 16];"
- "audio/x-raw-float, "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) {32, 64}, "
- "rate = (int) [8000, 192000], "
- "channels = (int) [1, 16]"
- )
-);
+ GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, "
+ "signed = (boolean) { FALSE, TRUE }, "
+ "width = (int) [8, 32], "
+ "depth = (int) [8, 32], "
+ "rate = (int) [8000, 192000], "
+ "channels = (int) [1, 16];"
+ "audio/x-raw-float, "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) {32, 64}, "
+ "rate = (int) [8000, 192000], " "channels = (int) [1, 16]")
+ );
static GstElementClass *parent_class = NULL;
-static void sinesrc_init (SineSrc *src);
-static void sinesrc_class_init (SineSrcClass *klass);
+static void sinesrc_init (SineSrc * src);
+static void sinesrc_class_init (SineSrcClass * klass);
-static GstData * sinesrc_get (GstPad *pad);
-static GstElementStateReturn sinesrc_change_state (GstElement *element);
+static GstData *sinesrc_get (GstPad * pad);
+static GstElementStateReturn sinesrc_change_state (GstElement * element);
GType
sizeof (SineSrc), 0,
(GInstanceInitFunc) sinesrc_init,
};
- sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "SineSrc",
- &sinesrc_info, 0);
+ sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "SineSrc",
+ &sinesrc_info, 0);
}
return sinesrc_type;
}
static void
-sinesrc_class_init (SineSrcClass *klass)
+sinesrc_class_init (SineSrcClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
-static void
-sinesrc_init (SineSrc *src)
+static void
+sinesrc_init (SineSrc * src)
{
- src->src = gst_pad_new_from_template (
- gst_static_pad_template_get (&sinesrc_src_factory), "src");
- gst_element_add_pad (GST_ELEMENT(src), src->src);
+ src->src =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&sinesrc_src_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (src), src->src);
gst_pad_set_get_function (src->src, sinesrc_get);
src->width = 16;
src->channels = 1;
src->type = SINE_SRC_INT;
src->newcaps = TRUE;
-
+
src->pre_get_func = NULL;
-
+
GST_OBJECT (src)->name = "sinesrc";
}
-static void
-sinesrc_force_caps (SineSrc *src) {
+static void
+sinesrc_force_caps (SineSrc * src)
+{
GstCaps *caps;
if (!src->newcaps)
return;
-
+
src->newcaps = FALSE;
switch (src->type) {
case SINE_SRC_INT:
caps = gst_caps_new_simple ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, src->sign,
- "depth", G_TYPE_INT, src->depth,
- NULL);
+ "signed", G_TYPE_BOOLEAN, src->sign,
+ "depth", G_TYPE_INT, src->depth, NULL);
if (src->width > 8)
- gst_caps_set_simple (caps,
- "endianness", G_TYPE_INT, src->endianness,
- NULL);
+ gst_caps_set_simple (caps,
+ "endianness", G_TYPE_INT, src->endianness, NULL);
break;
case SINE_SRC_FLOAT:
g_assert (src->width == 32 || src->width == 64);
caps = gst_caps_new_simple ("audio/x-raw-float",
- "endianness", G_TYPE_INT, src->endianness,
- NULL);
+ "endianness", G_TYPE_INT, src->endianness, NULL);
break;
default:
caps = NULL;
- g_assert_not_reached();
+ g_assert_not_reached ();
}
- gst_caps_set_simple (caps,
- "width", G_TYPE_INT, src->width,
- "rate", G_TYPE_INT, src->rate,
- "channels", G_TYPE_INT, src->channels,
- NULL);
-
+ gst_caps_set_simple (caps,
+ "width", G_TYPE_INT, src->width,
+ "rate", G_TYPE_INT, src->rate,
+ "channels", G_TYPE_INT, src->channels, NULL);
+
g_assert (gst_pad_try_set_caps (src->src, caps) == GST_PAD_LINK_OK);
}
+
/* always return 1 wave
* there are 200 waves in 1 second, so the frequency is samplerate/200
*/
-static guint8 UIDENTITY(guint8 x) { return x; };
-static gint8 IDENTITY(gint8 x) { return x; };
+static guint8
+UIDENTITY (guint8 x)
+{
+ return x;
+};
+static gint8
+IDENTITY (gint8 x)
+{
+ return x;
+};
+
#define POPULATE(format, be_func, le_func) G_STMT_START {\
format val = (format) int_value;\
format *p = data;\
} G_STMT_END
static GstData *
-sinesrc_get (GstPad *pad)
+sinesrc_get (GstPad * pad)
{
GstBuffer *buf;
SineSrc *src;
-
+
void *data;
gint i, j;
gdouble value;
-
+
g_return_val_if_fail (pad != NULL, NULL);
- src = SINESRC(gst_pad_get_parent (pad));
+ src = SINESRC (gst_pad_get_parent (pad));
if (src->pre_get_func)
src->pre_get_func (src);
-
- g_assert ((buf = gst_buffer_new_and_alloc ((src->width / 8) * src->channels * SAMPLES_PER_WAVE)));
- g_assert ((data = GST_BUFFER_DATA(buf)));
-
+
+ g_assert ((buf =
+ gst_buffer_new_and_alloc ((src->width / 8) * src->channels *
+ SAMPLES_PER_WAVE)));
+ g_assert ((data = GST_BUFFER_DATA (buf)));
+
for (i = 0; i < SAMPLES_PER_WAVE; i++) {
value = sin (i * 2 * M_PI / SAMPLES_PER_WAVE);
switch (src->type) {
- case SINE_SRC_INT: {
- gint64 int_value = (value + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1));
- if (int_value == (1 + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1))) int_value--;
- switch (src->width) {
- case 8:
- if (src->sign)
- POPULATE (gint8, IDENTITY, IDENTITY);
- else
- POPULATE (guint8, UIDENTITY, UIDENTITY);
- break;
- case 16:
- if (src->sign)
- POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE);
- else
- POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE);
- break;
- case 24:
- if (src->sign) {
+ case SINE_SRC_INT:{
+ gint64 int_value =
+ (value + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1));
+ if (int_value ==
+ (1 + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1)))
+ int_value--;
+ switch (src->width) {
+ case 8:
+ if (src->sign)
+ POPULATE (gint8, IDENTITY, IDENTITY);
+ else
+ POPULATE (guint8, UIDENTITY, UIDENTITY);
+ break;
+ case 16:
+ if (src->sign)
+ POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE);
+ else
+ POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE);
+ break;
+ case 24:
+ if (src->sign) {
gpointer p;
- gint32 val = (gint32) int_value;
- switch (src->endianness) {
- case G_LITTLE_ENDIAN:
- val = GINT32_TO_LE (val);
- break;
- case G_BIG_ENDIAN:
- val = GINT32_TO_BE (val);
- break;
- default:
- g_assert_not_reached ();
- };
+ gint32 val = (gint32) int_value;
+
+ switch (src->endianness) {
+ case G_LITTLE_ENDIAN:
+ val = GINT32_TO_LE (val);
+ break;
+ case G_BIG_ENDIAN:
+ val = GINT32_TO_BE (val);
+ break;
+ default:
+ g_assert_not_reached ();
+ };
p = &val;
if (src->endianness == G_BIG_ENDIAN)
- p++;
- for (j = 0; j < src->channels; j++) {
- memcpy (data, p, 3);
- data += 3;
- }
+ p++;
+ for (j = 0; j < src->channels; j++) {
+ memcpy (data, p, 3);
+ data += 3;
+ }
} else {
gpointer p;
- guint32 val = (guint32) int_value;
- switch (src->endianness) {
- case G_LITTLE_ENDIAN:
- val = GUINT32_TO_LE (val);
- break;
- case G_BIG_ENDIAN:
- val = GUINT32_TO_BE (val);
- break;
- default:
- g_assert_not_reached ();
- };
+ guint32 val = (guint32) int_value;
+
+ switch (src->endianness) {
+ case G_LITTLE_ENDIAN:
+ val = GUINT32_TO_LE (val);
+ break;
+ case G_BIG_ENDIAN:
+ val = GUINT32_TO_BE (val);
+ break;
+ default:
+ g_assert_not_reached ();
+ };
p = &val;
if (src->endianness == G_BIG_ENDIAN)
- p++;
- for (j = 0; j < src->channels; j++) {
- memcpy (data, p, 3);
- data += 3;
+ p++;
+ for (j = 0; j < src->channels; j++) {
+ memcpy (data, p, 3);
+ data += 3;
}
- }
- break;
- case 32:
- if (src->sign)
- POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE);
- else
- POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE);
- break;
- default:
- g_assert_not_reached ();
- }
- break;
+ }
+ break;
+ case 32:
+ if (src->sign)
+ POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE);
+ else
+ POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ break;
}
- case SINE_SRC_FLOAT:
- if (src->width == 32) {
- gfloat *p = (gfloat *) data;
- gfloat fval = (gfloat) value;
- for (j = 0; j < src->channels; j++) {
- *p = fval;
- p++;
- }
- data = p;
- break;
- }
- if (src->width == 64) {
- gdouble *p = (gdouble *) data;
- for (j = 0; j < src->channels; j++) {
- *p = value;
- p++;
- }
- data = p;
- break;
- }
- g_assert_not_reached ();
+ case SINE_SRC_FLOAT:
+ if (src->width == 32) {
+ gfloat *p = (gfloat *) data;
+ gfloat fval = (gfloat) value;
+
+ for (j = 0; j < src->channels; j++) {
+ *p = fval;
+ p++;
+ }
+ data = p;
+ break;
+ }
+ if (src->width == 64) {
+ gdouble *p = (gdouble *) data;
+
+ for (j = 0; j < src->channels; j++) {
+ *p = value;
+ p++;
+ }
+ data = p;
+ break;
+ }
+ g_assert_not_reached ();
default:
- g_assert_not_reached ();
+ g_assert_not_reached ();
}
}
-
+
if (src->newcaps) {
- sinesrc_force_caps(src);
+ sinesrc_force_caps (src);
}
- return GST_DATA(buf);
+ return GST_DATA (buf);
}
GstElement *
{
return GST_ELEMENT (g_object_new (TYPE_SINESRC, NULL));
}
+
void
-sinesrc_set_pre_get_func (SineSrc *src, PreGetFunc func)
+sinesrc_set_pre_get_func (SineSrc * src, PreGetFunc func)
{
src->pre_get_func = func;
}
+
static GstElementStateReturn
-sinesrc_change_state (GstElement *element)
+sinesrc_change_state (GstElement * element)
{
SineSrc *sinesrc;
sinesrc = SINESRC (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
- case GST_STATE_READY_TO_PAUSED:
- case GST_STATE_PAUSED_TO_PLAYING:
- case GST_STATE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_PAUSED_TO_READY:
- sinesrc->newcaps = TRUE;
- break;
- case GST_STATE_READY_TO_NULL:
- break;
- default:
- g_assert_not_reached();
+ case GST_STATE_NULL_TO_READY:
+ case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_PLAYING_TO_PAUSED:
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ sinesrc->newcaps = TRUE;
+ break;
+ case GST_STATE_READY_TO_NULL:
+ break;
+ default:
+ g_assert_not_reached ();
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
+extern "C"
+{
+#endif /* __cplusplus */
+
#define TYPE_SINESRC \
(sinesrc_get_type())
#define IS_SINESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),TYPE_SINESRC))
-typedef struct _SineSrc SineSrc;
-typedef struct _SineSrcClass SineSrcClass;
+ typedef struct _SineSrc SineSrc;
+ typedef struct _SineSrcClass SineSrcClass;
+
+ typedef void (*PreGetFunc) (SineSrc * src);
+
+ typedef enum
+ {
+ SINE_SRC_INT,
+ SINE_SRC_FLOAT
+ } SineSrcAudio;
+
+ struct _SineSrc
+ {
+ GstElement element;
-typedef void (*PreGetFunc) (SineSrc *src);
+ /* pads */
+ GstPad *src;
-typedef enum {
- SINE_SRC_INT,
- SINE_SRC_FLOAT
-} SineSrcAudio;
+ /* audio parameters */
+ SineSrcAudio type;
+ gint width; /* int + float */
+ gint depth; /* int */
+ gboolean sign; /* int */
+ gint endianness; /* int */
-struct _SineSrc {
- GstElement element;
+ gint rate;
+ gint channels; /* interleaved */
- /* pads */
- GstPad *src;
+ gboolean newcaps;
- /* audio parameters */
- SineSrcAudio type;
- gint width; /* int + float */
- gint depth; /* int */
- gboolean sign; /* int */
- gint endianness; /* int */
-
- gint rate;
- gint channels; /* interleaved */
-
- gboolean newcaps;
-
- /* freaky stuff for testing */
- PreGetFunc pre_get_func;
-};
+ /* freaky stuff for testing */
+ PreGetFunc pre_get_func;
+ };
-struct _SineSrcClass {
- GstElementClass parent_class;
-};
+ struct _SineSrcClass
+ {
+ GstElementClass parent_class;
+ };
-GType sinesrc_get_type (void);
-GstElement * sinesrc_new (void);
+ GType sinesrc_get_type (void);
+ GstElement *sinesrc_new (void);
-void sinesrc_set_pre_get_func (SineSrc *src, PreGetFunc func);
+ void sinesrc_set_pre_get_func (SineSrc * src, PreGetFunc func);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SINESRC_H__ */
+#endif /* __GST_SINESRC_H__ */
set_state (GstElementState state)
{
GstElementState old_state = gst_element_get_state (pipeline);
-
- g_print ("Setting state from %s to %s...", gst_element_state_get_name (old_state), gst_element_state_get_name (state));
+
+ g_print ("Setting state from %s to %s...",
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (state));
if (!gst_element_set_state (pipeline, state)) {
g_print (" ERROR\n");
if (state == GST_STATE_PLAYING) {
gint i;
+
g_print (" DONE - iterating a bit...");
for (i = 0; i < 400; i++) {
if (!gst_bin_iterate (GST_BIN (pipeline))) {
- g_print (" ERROR in iteration %d\n", i);
+ g_print (" ERROR in iteration %d\n", i);
exit (-2);
}
}
static void
create_pipeline (void)
{
- GstElement *src;
+ GstElement *src;
SineSrc *sinesrc;
GstElement *alsasink;
-
+
pipeline = gst_pipeline_new ("pipeline");
src = sinesrc_new ();
alsasink = gst_element_factory_make ("alsasink", "alsasink");
-
+
gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL);
gst_element_link (src, alsasink);
-
+
/* prepare our sinesrc */
sinesrc = (SineSrc *) src;
sinesrc->newcaps = TRUE;
sinesrc->depth = 16;
sinesrc->width = 16;
}
-gint
-main (gint argc, gchar *argv[])
+
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
g_print ("\n"
- "This test will check if state changes work on the alsasink.\n"
- "You will hear some short sine tones on your default ALSA soundcard,\n"
- "but they are not important in this test.\n"
- "\n");
+ "This test will check if state changes work on the alsasink.\n"
+ "You will hear some short sine tones on your default ALSA soundcard,\n"
+ "but they are not important in this test.\n" "\n");
create_pipeline ();
-
+
/* simulate some state changes here */
set_state (GST_STATE_READY);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
-
+
g_print ("The alsa plugin mastered another test.\n");
- gst_object_unref (GST_OBJECT (pipeline));
+ gst_object_unref (GST_OBJECT (pipeline));
return 0;
}
#if 0
static int
-configure(GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
+configure (GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
{
- printf("configure\n");
- if (wind){
- gdk_window_resize(wind, evt->width, evt->height);
- gdk_window_reparent(wind, window->window, 0, 0);
- }
+ printf ("configure\n");
+ if (wind) {
+ gdk_window_resize (wind, evt->width, evt->height);
+ gdk_window_reparent (wind, window->window, 0, 0);
+ }
- return FALSE;
+ return FALSE;
}
static int
-map_event(GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
+map_event (GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
{
- printf("map\n");
- return FALSE;
+ printf ("map\n");
+ return FALSE;
}
#endif
-static int have_xid(GstElement * xv, gint xid, gpointer data)
+static int
+have_xid (GstElement * xv, gint xid, gpointer data)
{
- printf("have_xid\n");
+ printf ("have_xid\n");
- wind = gdk_window_foreign_new(xid);
-printf("gdk_window_reparent() wind=%p window=%p xid=%d\n",wind,window->window,xid);
- gdk_window_reparent(wind, window->window, 0, 0);
- gdk_window_show(wind);
+ wind = gdk_window_foreign_new (xid);
+ printf ("gdk_window_reparent() wind=%p window=%p xid=%d\n", wind,
+ window->window, xid);
+ gdk_window_reparent (wind, window->window, 0, 0);
+ gdk_window_show (wind);
- return FALSE;
+ return FALSE;
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- //GValue value = { 0 };
+ //GValue value = { 0 };
- gtk_init(&argc, &argv);
- gst_init(&argc, &argv);
+ gtk_init (&argc, &argv);
+ gst_init (&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
#if 0
- gtk_signal_connect(GTK_OBJECT(window), "configure_event",
- GTK_SIGNAL_FUNC(configure), NULL);
- gtk_signal_connect(GTK_OBJECT(window), "map",
- GTK_SIGNAL_FUNC(map_event), NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "configure_event",
+ GTK_SIGNAL_FUNC (configure), NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "map",
+ GTK_SIGNAL_FUNC (map_event), NULL);
#endif
- gtk_widget_show_all(window);
+ gtk_widget_show_all (window);
- pipeline = gst_element_factory_make("pipeline", NULL);
+ pipeline = gst_element_factory_make ("pipeline", NULL);
- testsrc = gst_element_factory_make("videotestsrc", NULL);
+ testsrc = gst_element_factory_make ("videotestsrc", NULL);
#if 0
- g_value_init(&value, G_TYPE_INT);
- g_value_set_int(&value, 640);
- g_object_set_property(G_OBJECT(testsrc), "width", &value);
- g_value_set_int(&value, 480);
- g_object_set_property(G_OBJECT(testsrc), "height", &value);
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, 640);
+ g_object_set_property (G_OBJECT (testsrc), "width", &value);
+ g_value_set_int (&value, 480);
+ g_object_set_property (G_OBJECT (testsrc), "height", &value);
#endif
- xvideosink = gst_element_factory_make("xvideosink", NULL);
- g_object_set(xvideosink, "toplevel", FALSE, NULL);
- g_signal_connect(xvideosink, "have_xid", (GCallback) (have_xid),
- NULL);
+ xvideosink = gst_element_factory_make ("xvideosink", NULL);
+ g_object_set (xvideosink, "toplevel", FALSE, NULL);
+ g_signal_connect (xvideosink, "have_xid", (GCallback) (have_xid), NULL);
- gst_bin_add(GST_BIN(pipeline), testsrc);
- gst_bin_add(GST_BIN(pipeline), xvideosink);
+ gst_bin_add (GST_BIN (pipeline), testsrc);
+ gst_bin_add (GST_BIN (pipeline), xvideosink);
- gst_element_connect(testsrc, xvideosink);
+ gst_element_connect (testsrc, xvideosink);
- if (pipeline == NULL) {
- g_warning("Could not generate usable pipeline\n");
- return 1;
- }
+ if (pipeline == NULL) {
+ g_warning ("Could not generate usable pipeline\n");
+ return 1;
+ }
- g_idle_add((GSourceFunc) gst_bin_iterate, pipeline);
+ g_idle_add ((GSourceFunc) gst_bin_iterate, pipeline);
- gst_element_set_state(pipeline, GST_STATE_PLAYING);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
- gtk_main();
+ gtk_main ();
- return 0;
+ return 0;
}
#include "sinesrc.h"
#include <math.h>
-#include <string.h> /* memcpy */
+#include <string.h> /* memcpy */
#define SAMPLES_PER_WAVE 200
static GstStaticPadTemplate sinesrc_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, "
- "signed = (boolean) { FALSE, TRUE }, "
- "width = (int) [8, 32], "
- "depth = (int) [8, 32], "
- "rate = (int) [8000, 192000], "
- "channels = (int) [1, 16];"
- "audio/x-raw-float, "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) {32, 64}, "
- "rate = (int) [8000, 192000], "
- "channels = (int) [1, 16]"
- )
-);
+ GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, "
+ "signed = (boolean) { FALSE, TRUE }, "
+ "width = (int) [8, 32], "
+ "depth = (int) [8, 32], "
+ "rate = (int) [8000, 192000], "
+ "channels = (int) [1, 16];"
+ "audio/x-raw-float, "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) {32, 64}, "
+ "rate = (int) [8000, 192000], " "channels = (int) [1, 16]")
+ );
static GstElementClass *parent_class = NULL;
-static void sinesrc_init (SineSrc *src);
-static void sinesrc_class_init (SineSrcClass *klass);
+static void sinesrc_init (SineSrc * src);
+static void sinesrc_class_init (SineSrcClass * klass);
-static GstData * sinesrc_get (GstPad *pad);
-static GstElementStateReturn sinesrc_change_state (GstElement *element);
+static GstData *sinesrc_get (GstPad * pad);
+static GstElementStateReturn sinesrc_change_state (GstElement * element);
GType
sizeof (SineSrc), 0,
(GInstanceInitFunc) sinesrc_init,
};
- sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "SineSrc",
- &sinesrc_info, 0);
+ sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "SineSrc",
+ &sinesrc_info, 0);
}
return sinesrc_type;
}
static void
-sinesrc_class_init (SineSrcClass *klass)
+sinesrc_class_init (SineSrcClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
-static void
-sinesrc_init (SineSrc *src)
+static void
+sinesrc_init (SineSrc * src)
{
- src->src = gst_pad_new_from_template (
- gst_static_pad_template_get (&sinesrc_src_factory), "src");
- gst_element_add_pad (GST_ELEMENT(src), src->src);
+ src->src =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&sinesrc_src_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (src), src->src);
gst_pad_set_get_function (src->src, sinesrc_get);
src->width = 16;
src->channels = 1;
src->type = SINE_SRC_INT;
src->newcaps = TRUE;
-
+
src->pre_get_func = NULL;
-
+
GST_OBJECT (src)->name = "sinesrc";
}
-static void
-sinesrc_force_caps (SineSrc *src) {
+static void
+sinesrc_force_caps (SineSrc * src)
+{
GstCaps *caps;
if (!src->newcaps)
return;
-
+
src->newcaps = FALSE;
switch (src->type) {
case SINE_SRC_INT:
caps = gst_caps_new_simple ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, src->sign,
- "depth", G_TYPE_INT, src->depth,
- NULL);
+ "signed", G_TYPE_BOOLEAN, src->sign,
+ "depth", G_TYPE_INT, src->depth, NULL);
if (src->width > 8)
- gst_caps_set_simple (caps,
- "endianness", G_TYPE_INT, src->endianness,
- NULL);
+ gst_caps_set_simple (caps,
+ "endianness", G_TYPE_INT, src->endianness, NULL);
break;
case SINE_SRC_FLOAT:
g_assert (src->width == 32 || src->width == 64);
caps = gst_caps_new_simple ("audio/x-raw-float",
- "endianness", G_TYPE_INT, src->endianness,
- NULL);
+ "endianness", G_TYPE_INT, src->endianness, NULL);
break;
default:
caps = NULL;
- g_assert_not_reached();
+ g_assert_not_reached ();
}
- gst_caps_set_simple (caps,
- "width", G_TYPE_INT, src->width,
- "rate", G_TYPE_INT, src->rate,
- "channels", G_TYPE_INT, src->channels,
- NULL);
-
+ gst_caps_set_simple (caps,
+ "width", G_TYPE_INT, src->width,
+ "rate", G_TYPE_INT, src->rate,
+ "channels", G_TYPE_INT, src->channels, NULL);
+
g_assert (gst_pad_try_set_caps (src->src, caps) == GST_PAD_LINK_OK);
}
+
/* always return 1 wave
* there are 200 waves in 1 second, so the frequency is samplerate/200
*/
-static guint8 UIDENTITY(guint8 x) { return x; };
-static gint8 IDENTITY(gint8 x) { return x; };
+static guint8
+UIDENTITY (guint8 x)
+{
+ return x;
+};
+static gint8
+IDENTITY (gint8 x)
+{
+ return x;
+};
+
#define POPULATE(format, be_func, le_func) G_STMT_START {\
format val = (format) int_value;\
format *p = data;\
} G_STMT_END
static GstData *
-sinesrc_get (GstPad *pad)
+sinesrc_get (GstPad * pad)
{
GstBuffer *buf;
SineSrc *src;
-
+
void *data;
gint i, j;
gdouble value;
-
+
g_return_val_if_fail (pad != NULL, NULL);
- src = SINESRC(gst_pad_get_parent (pad));
+ src = SINESRC (gst_pad_get_parent (pad));
if (src->pre_get_func)
src->pre_get_func (src);
-
- g_assert ((buf = gst_buffer_new_and_alloc ((src->width / 8) * src->channels * SAMPLES_PER_WAVE)));
- g_assert ((data = GST_BUFFER_DATA(buf)));
-
+
+ g_assert ((buf =
+ gst_buffer_new_and_alloc ((src->width / 8) * src->channels *
+ SAMPLES_PER_WAVE)));
+ g_assert ((data = GST_BUFFER_DATA (buf)));
+
for (i = 0; i < SAMPLES_PER_WAVE; i++) {
value = sin (i * 2 * M_PI / SAMPLES_PER_WAVE);
switch (src->type) {
- case SINE_SRC_INT: {
- gint64 int_value = (value + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1));
- if (int_value == (1 + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1))) int_value--;
- switch (src->width) {
- case 8:
- if (src->sign)
- POPULATE (gint8, IDENTITY, IDENTITY);
- else
- POPULATE (guint8, UIDENTITY, UIDENTITY);
- break;
- case 16:
- if (src->sign)
- POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE);
- else
- POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE);
- break;
- case 24:
- if (src->sign) {
+ case SINE_SRC_INT:{
+ gint64 int_value =
+ (value + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1));
+ if (int_value ==
+ (1 + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1)))
+ int_value--;
+ switch (src->width) {
+ case 8:
+ if (src->sign)
+ POPULATE (gint8, IDENTITY, IDENTITY);
+ else
+ POPULATE (guint8, UIDENTITY, UIDENTITY);
+ break;
+ case 16:
+ if (src->sign)
+ POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE);
+ else
+ POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE);
+ break;
+ case 24:
+ if (src->sign) {
gpointer p;
- gint32 val = (gint32) int_value;
- switch (src->endianness) {
- case G_LITTLE_ENDIAN:
- val = GINT32_TO_LE (val);
- break;
- case G_BIG_ENDIAN:
- val = GINT32_TO_BE (val);
- break;
- default:
- g_assert_not_reached ();
- };
+ gint32 val = (gint32) int_value;
+
+ switch (src->endianness) {
+ case G_LITTLE_ENDIAN:
+ val = GINT32_TO_LE (val);
+ break;
+ case G_BIG_ENDIAN:
+ val = GINT32_TO_BE (val);
+ break;
+ default:
+ g_assert_not_reached ();
+ };
p = &val;
if (src->endianness == G_BIG_ENDIAN)
- p++;
- for (j = 0; j < src->channels; j++) {
- memcpy (data, p, 3);
- data += 3;
- }
+ p++;
+ for (j = 0; j < src->channels; j++) {
+ memcpy (data, p, 3);
+ data += 3;
+ }
} else {
gpointer p;
- guint32 val = (guint32) int_value;
- switch (src->endianness) {
- case G_LITTLE_ENDIAN:
- val = GUINT32_TO_LE (val);
- break;
- case G_BIG_ENDIAN:
- val = GUINT32_TO_BE (val);
- break;
- default:
- g_assert_not_reached ();
- };
+ guint32 val = (guint32) int_value;
+
+ switch (src->endianness) {
+ case G_LITTLE_ENDIAN:
+ val = GUINT32_TO_LE (val);
+ break;
+ case G_BIG_ENDIAN:
+ val = GUINT32_TO_BE (val);
+ break;
+ default:
+ g_assert_not_reached ();
+ };
p = &val;
if (src->endianness == G_BIG_ENDIAN)
- p++;
- for (j = 0; j < src->channels; j++) {
- memcpy (data, p, 3);
- data += 3;
+ p++;
+ for (j = 0; j < src->channels; j++) {
+ memcpy (data, p, 3);
+ data += 3;
}
- }
- break;
- case 32:
- if (src->sign)
- POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE);
- else
- POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE);
- break;
- default:
- g_assert_not_reached ();
- }
- break;
+ }
+ break;
+ case 32:
+ if (src->sign)
+ POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE);
+ else
+ POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ break;
}
- case SINE_SRC_FLOAT:
- if (src->width == 32) {
- gfloat *p = (gfloat *) data;
- gfloat fval = (gfloat) value;
- for (j = 0; j < src->channels; j++) {
- *p = fval;
- p++;
- }
- data = p;
- break;
- }
- if (src->width == 64) {
- gdouble *p = (gdouble *) data;
- for (j = 0; j < src->channels; j++) {
- *p = value;
- p++;
- }
- data = p;
- break;
- }
- g_assert_not_reached ();
+ case SINE_SRC_FLOAT:
+ if (src->width == 32) {
+ gfloat *p = (gfloat *) data;
+ gfloat fval = (gfloat) value;
+
+ for (j = 0; j < src->channels; j++) {
+ *p = fval;
+ p++;
+ }
+ data = p;
+ break;
+ }
+ if (src->width == 64) {
+ gdouble *p = (gdouble *) data;
+
+ for (j = 0; j < src->channels; j++) {
+ *p = value;
+ p++;
+ }
+ data = p;
+ break;
+ }
+ g_assert_not_reached ();
default:
- g_assert_not_reached ();
+ g_assert_not_reached ();
}
}
-
+
if (src->newcaps) {
- sinesrc_force_caps(src);
+ sinesrc_force_caps (src);
}
- return GST_DATA(buf);
+ return GST_DATA (buf);
}
GstElement *
{
return GST_ELEMENT (g_object_new (TYPE_SINESRC, NULL));
}
+
void
-sinesrc_set_pre_get_func (SineSrc *src, PreGetFunc func)
+sinesrc_set_pre_get_func (SineSrc * src, PreGetFunc func)
{
src->pre_get_func = func;
}
+
static GstElementStateReturn
-sinesrc_change_state (GstElement *element)
+sinesrc_change_state (GstElement * element)
{
SineSrc *sinesrc;
sinesrc = SINESRC (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_NULL_TO_READY:
- case GST_STATE_READY_TO_PAUSED:
- case GST_STATE_PAUSED_TO_PLAYING:
- case GST_STATE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_PAUSED_TO_READY:
- sinesrc->newcaps = TRUE;
- break;
- case GST_STATE_READY_TO_NULL:
- break;
- default:
- g_assert_not_reached();
+ case GST_STATE_NULL_TO_READY:
+ case GST_STATE_READY_TO_PAUSED:
+ case GST_STATE_PAUSED_TO_PLAYING:
+ case GST_STATE_PLAYING_TO_PAUSED:
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ sinesrc->newcaps = TRUE;
+ break;
+ case GST_STATE_READY_TO_NULL:
+ break;
+ default:
+ g_assert_not_reached ();
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
+extern "C"
+{
+#endif /* __cplusplus */
+
#define TYPE_SINESRC \
(sinesrc_get_type())
#define IS_SINESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),TYPE_SINESRC))
-typedef struct _SineSrc SineSrc;
-typedef struct _SineSrcClass SineSrcClass;
+ typedef struct _SineSrc SineSrc;
+ typedef struct _SineSrcClass SineSrcClass;
+
+ typedef void (*PreGetFunc) (SineSrc * src);
+
+ typedef enum
+ {
+ SINE_SRC_INT,
+ SINE_SRC_FLOAT
+ } SineSrcAudio;
+
+ struct _SineSrc
+ {
+ GstElement element;
-typedef void (*PreGetFunc) (SineSrc *src);
+ /* pads */
+ GstPad *src;
-typedef enum {
- SINE_SRC_INT,
- SINE_SRC_FLOAT
-} SineSrcAudio;
+ /* audio parameters */
+ SineSrcAudio type;
+ gint width; /* int + float */
+ gint depth; /* int */
+ gboolean sign; /* int */
+ gint endianness; /* int */
-struct _SineSrc {
- GstElement element;
+ gint rate;
+ gint channels; /* interleaved */
- /* pads */
- GstPad *src;
+ gboolean newcaps;
- /* audio parameters */
- SineSrcAudio type;
- gint width; /* int + float */
- gint depth; /* int */
- gboolean sign; /* int */
- gint endianness; /* int */
-
- gint rate;
- gint channels; /* interleaved */
-
- gboolean newcaps;
-
- /* freaky stuff for testing */
- PreGetFunc pre_get_func;
-};
+ /* freaky stuff for testing */
+ PreGetFunc pre_get_func;
+ };
-struct _SineSrcClass {
- GstElementClass parent_class;
-};
+ struct _SineSrcClass
+ {
+ GstElementClass parent_class;
+ };
-GType sinesrc_get_type (void);
-GstElement * sinesrc_new (void);
+ GType sinesrc_get_type (void);
+ GstElement *sinesrc_new (void);
-void sinesrc_set_pre_get_func (SineSrc *src, PreGetFunc func);
+ void sinesrc_set_pre_get_func (SineSrc * src, PreGetFunc func);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SINESRC_H__ */
+#endif /* __GST_SINESRC_H__ */
set_state (GstElementState state)
{
GstElementState old_state = gst_element_get_state (pipeline);
-
- g_print ("Setting state from %s to %s...", gst_element_state_get_name (old_state), gst_element_state_get_name (state));
+
+ g_print ("Setting state from %s to %s...",
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (state));
if (!gst_element_set_state (pipeline, state)) {
g_print (" ERROR\n");
if (state == GST_STATE_PLAYING) {
gint i;
+
g_print (" DONE - iterating a bit...");
for (i = 0; i < 400; i++) {
if (!gst_bin_iterate (GST_BIN (pipeline))) {
- g_print (" ERROR in iteration %d\n", i);
+ g_print (" ERROR in iteration %d\n", i);
exit (-2);
}
}
static void
create_pipeline (void)
{
- GstElement *src;
+ GstElement *src;
SineSrc *sinesrc;
GstElement *alsasink;
-
+
pipeline = gst_pipeline_new ("pipeline");
src = sinesrc_new ();
alsasink = gst_element_factory_make ("alsasink", "alsasink");
-
+
gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL);
gst_element_link (src, alsasink);
-
+
/* prepare our sinesrc */
sinesrc = (SineSrc *) src;
sinesrc->newcaps = TRUE;
sinesrc->depth = 16;
sinesrc->width = 16;
}
-gint
-main (gint argc, gchar *argv[])
+
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
g_print ("\n"
- "This test will check if state changes work on the alsasink.\n"
- "You will hear some short sine tones on your default ALSA soundcard,\n"
- "but they are not important in this test.\n"
- "\n");
+ "This test will check if state changes work on the alsasink.\n"
+ "You will hear some short sine tones on your default ALSA soundcard,\n"
+ "but they are not important in this test.\n" "\n");
create_pipeline ();
-
+
/* simulate some state changes here */
set_state (GST_STATE_READY);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
-
+
g_print ("The alsa plugin mastered another test.\n");
- gst_object_unref (GST_OBJECT (pipeline));
+ gst_object_unref (GST_OBJECT (pipeline));
return 0;
}
#if 0
static int
-configure(GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
+configure (GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
{
- printf("configure\n");
- if (wind){
- gdk_window_resize(wind, evt->width, evt->height);
- gdk_window_reparent(wind, window->window, 0, 0);
- }
+ printf ("configure\n");
+ if (wind) {
+ gdk_window_resize (wind, evt->width, evt->height);
+ gdk_window_reparent (wind, window->window, 0, 0);
+ }
- return FALSE;
+ return FALSE;
}
static int
-map_event(GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
+map_event (GtkWidget * widget, GdkEventConfigure * evt, gpointer data)
{
- printf("map\n");
- return FALSE;
+ printf ("map\n");
+ return FALSE;
}
#endif
-static int have_xid(GstElement * xv, gint xid, gpointer data)
+static int
+have_xid (GstElement * xv, gint xid, gpointer data)
{
- printf("have_xid\n");
+ printf ("have_xid\n");
- wind = gdk_window_foreign_new(xid);
-printf("gdk_window_reparent() wind=%p window=%p xid=%d\n",wind,window->window,xid);
- gdk_window_reparent(wind, window->window, 0, 0);
- gdk_window_show(wind);
+ wind = gdk_window_foreign_new (xid);
+ printf ("gdk_window_reparent() wind=%p window=%p xid=%d\n", wind,
+ window->window, xid);
+ gdk_window_reparent (wind, window->window, 0, 0);
+ gdk_window_show (wind);
- return FALSE;
+ return FALSE;
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- //GValue value = { 0 };
+ //GValue value = { 0 };
- gtk_init(&argc, &argv);
- gst_init(&argc, &argv);
+ gtk_init (&argc, &argv);
+ gst_init (&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
#if 0
- gtk_signal_connect(GTK_OBJECT(window), "configure_event",
- GTK_SIGNAL_FUNC(configure), NULL);
- gtk_signal_connect(GTK_OBJECT(window), "map",
- GTK_SIGNAL_FUNC(map_event), NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "configure_event",
+ GTK_SIGNAL_FUNC (configure), NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "map",
+ GTK_SIGNAL_FUNC (map_event), NULL);
#endif
- gtk_widget_show_all(window);
+ gtk_widget_show_all (window);
- pipeline = gst_element_factory_make("pipeline", NULL);
+ pipeline = gst_element_factory_make ("pipeline", NULL);
- testsrc = gst_element_factory_make("videotestsrc", NULL);
+ testsrc = gst_element_factory_make ("videotestsrc", NULL);
#if 0
- g_value_init(&value, G_TYPE_INT);
- g_value_set_int(&value, 640);
- g_object_set_property(G_OBJECT(testsrc), "width", &value);
- g_value_set_int(&value, 480);
- g_object_set_property(G_OBJECT(testsrc), "height", &value);
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, 640);
+ g_object_set_property (G_OBJECT (testsrc), "width", &value);
+ g_value_set_int (&value, 480);
+ g_object_set_property (G_OBJECT (testsrc), "height", &value);
#endif
- xvideosink = gst_element_factory_make("xvideosink", NULL);
- g_object_set(xvideosink, "toplevel", FALSE, NULL);
- g_signal_connect(xvideosink, "have_xid", (GCallback) (have_xid),
- NULL);
+ xvideosink = gst_element_factory_make ("xvideosink", NULL);
+ g_object_set (xvideosink, "toplevel", FALSE, NULL);
+ g_signal_connect (xvideosink, "have_xid", (GCallback) (have_xid), NULL);
- gst_bin_add(GST_BIN(pipeline), testsrc);
- gst_bin_add(GST_BIN(pipeline), xvideosink);
+ gst_bin_add (GST_BIN (pipeline), testsrc);
+ gst_bin_add (GST_BIN (pipeline), xvideosink);
- gst_element_connect(testsrc, xvideosink);
+ gst_element_connect (testsrc, xvideosink);
- if (pipeline == NULL) {
- g_warning("Could not generate usable pipeline\n");
- return 1;
- }
+ if (pipeline == NULL) {
+ g_warning ("Could not generate usable pipeline\n");
+ return 1;
+ }
- g_idle_add((GSourceFunc) gst_bin_iterate, pipeline);
+ g_idle_add ((GSourceFunc) gst_bin_iterate, pipeline);
- gst_element_set_state(pipeline, GST_STATE_PLAYING);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
- gtk_main();
+ gtk_main ();
- return 0;
+ return 0;
}