diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch) | |
tree | f863b467dea9559a6ec9c48affbfae11f8104164 /examples | |
parent | a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff) | |
download | gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2 gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'examples')
-rw-r--r-- | examples/capsfilter/capsfilter1.c | 19 | ||||
-rw-r--r-- | examples/dynparams/filter.c | 294 | ||||
-rw-r--r-- | examples/gstplay/player.c | 46 | ||||
-rw-r--r-- | examples/indexing/indexmpeg.c | 141 | ||||
-rw-r--r-- | examples/seeking/cdparanoia.c | 60 | ||||
-rw-r--r-- | examples/seeking/cdplayer.c | 104 | ||||
-rw-r--r-- | examples/seeking/seek.c | 291 | ||||
-rw-r--r-- | examples/seeking/spider_seek.c | 127 | ||||
-rw-r--r-- | examples/seeking/vorbisfile.c | 81 | ||||
-rw-r--r-- | examples/stats/mp2ogg.c | 41 | ||||
-rw-r--r-- | examples/switch/switcher.c | 49 |
11 files changed, 615 insertions, 638 deletions
diff --git a/examples/capsfilter/capsfilter1.c b/examples/capsfilter/capsfilter1.c index 4d71109f..46e127a2 100644 --- a/examples/capsfilter/capsfilter1.c +++ b/examples/capsfilter/capsfilter1.c @@ -6,7 +6,7 @@ * connection would use the I420 format (assuming Xv is enabled) */ static void -new_pad_func (GstElement *element, GstPad *newpad, gpointer data) +new_pad_func (GstElement * element, GstPad * newpad, gpointer data) { GstElement *pipeline = (GstElement *) data; GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue"); @@ -19,7 +19,7 @@ new_pad_func (GstElement *element, GstPad *newpad, gpointer data) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *filesrc; @@ -44,7 +44,8 @@ main (gint argc, gchar *argv[]) g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); demux = gst_element_factory_make ("mpegdemux", "demux"); g_return_val_if_fail (demux, -1); - g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline); + g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), + pipeline); thread = gst_thread_new ("thread"); queue = gst_element_factory_make ("queue", "queue"); @@ -58,7 +59,7 @@ main (gint argc, gchar *argv[]) gst_bin_add (GST_BIN (pipeline), filesrc); gst_bin_add (GST_BIN (pipeline), demux); - + gst_bin_add (GST_BIN (thread), queue); gst_bin_add (GST_BIN (thread), mpeg2dec); gst_bin_add (GST_BIN (thread), colorspace); @@ -70,11 +71,9 @@ main (gint argc, gchar *argv[]) gst_element_link (mpeg2dec, "src", colorspace, "sink"); /* force RGB data passing between colorspace and xvideosink */ res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink", - GST_CAPS_NEW ( - "filtercaps", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) - )); + GST_CAPS_NEW ("filtercaps", + "video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) + )); if (!res) { g_print ("could not connect colorspace and xvideosink\n"); return -1; @@ -83,7 +82,7 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); - + gst_element_set_state (pipeline, GST_STATE_NULL); return 0; diff --git a/examples/dynparams/filter.c b/examples/dynparams/filter.c index ed0dd5aa..982a4c7a 100644 --- a/examples/dynparams/filter.c +++ b/examples/dynparams/filter.c @@ -18,13 +18,13 @@ struct _filter_ui GtkWidget *window; /* top-level interface window */ GtkWidget *buttons; /* all of the control buttons */ - GtkWidget *parse, *play, *stop; /* control buttons */ - + GtkWidget *parse, *play, *stop; /* control buttons */ + GtkWidget *feedback; /* here's where we'll tell you stuff */ GtkTextBuffer *fb_buffer; /* feedback buffer */ GtkWidget *selection; /* the place to input element stuff */ - GtkWidget *input, *filter, *output; /* the selection widgets */ - + GtkWidget *input, *filter, *output; /* the selection widgets */ + GtkWidget *control; /* the dynamically generated control UI */ }; @@ -33,13 +33,13 @@ typedef struct _filter_ui _filter_ui_t; /* back-end data */ struct _filter_data { - _filter_ui_t *ui; /* the UI data */ + _filter_ui_t *ui; /* the UI data */ gchar *input_pipe, *output_pipe, *filter_element; gchar *pipe_string; GList *filter_choices; gboolean playing; - GstElement *input, *output; /* these are in and out bins */ + GstElement *input, *output; /* these are in and out bins */ GstElement *pipeline; GstElement *filter; }; @@ -47,17 +47,18 @@ struct _filter_data typedef struct _filter_data _filter_data_t; /* internal prototypes when they can't be avoided */ -void cb_remove_and_destroy (GtkWidget *widget, gpointer user_data); -//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data); -void cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam); +void cb_remove_and_destroy (GtkWidget * widget, gpointer user_data); + +//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data); +void cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam); /* GStreamer helper functions go here */ - + /* go through a bin, finding the one pad that is unconnected in the given * direction, and return a ghost pad */ GstPad * -gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction, - gchar *name) +gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction, + gchar * name) { GstPad *pad = NULL; GList *elements = NULL; @@ -67,39 +68,36 @@ gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction, g_print ("DEBUG: find_unconnected start\n"); elements = (GList *) gst_bin_get_list (bin); /* traverse all elements looking for unconnected pads */ - while (elements && pad == NULL) - { + while (elements && pad == NULL) { element = GST_ELEMENT (elements->data); g_print ("DEBUG: looking in element %s\n", gst_element_get_name (element)); pads = gst_element_get_pad_list (element); - while (pads) - { + while (pads) { /* check if the direction matches */ - if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) - { - if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) - { + if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) { + if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) { /* found it ! */ g_print ("DEBUG: found an unconnected pad !\n"); pad = GST_PAD (pads->data); } } - if (pad) break; /* found one already */ + if (pad) + break; /* found one already */ pads = g_list_next (pads); } elements = g_list_next (elements); } g_print ("DEBUG: find_unconnected stop\n"); - if (pad == NULL) /* we didn't find it at all */ + if (pad == NULL) /* we didn't find it at all */ return NULL; - + pad = gst_ghost_pad_new (name, pad); return pad; } void -ui_feedback_add_text (_filter_ui_t *ui, const gchar *text) +ui_feedback_add_text (_filter_ui_t * ui, const gchar * text) { GtkTextIter iter; @@ -108,7 +106,7 @@ ui_feedback_add_text (_filter_ui_t *ui, const gchar *text) } void -ui_feedback_add (_filter_ui_t *ui, const gchar *format, ...) +ui_feedback_add (_filter_ui_t * ui, const gchar * format, ...) { va_list args; gchar *buffer = NULL; @@ -121,7 +119,7 @@ ui_feedback_add (_filter_ui_t *ui, const gchar *format, ...) } void -ui_feedback_clear (_filter_ui_t *ui) +ui_feedback_clear (_filter_ui_t * ui) { gtk_text_buffer_set_text (ui->fb_buffer, "", 0); } @@ -129,7 +127,7 @@ ui_feedback_clear (_filter_ui_t *ui) /* create the control widget using the element's dynparams * control is a vbox which we need to empty first */ void -ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui) +ui_control_create (GstElement * element, GtkWidget * control, _filter_ui_t * ui) { GtkWidget *hbox = NULL; GtkWidget *widget = NULL; @@ -137,70 +135,63 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui) GstDParam *dparam = NULL; GParamSpec **specs = NULL; int i = 0; - + g_assert (GTK_IS_VBOX (control)); /* empty control vbox */ g_print ("DEBUG: emptying control widget\n"); - gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy, - (gpointer) control); + gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy, + (gpointer) control); g_print ("DEBUG: adding label to control widget\n"); widget = gtk_label_new ("Dynamic Parameters"); gtk_container_add (GTK_CONTAINER (control), widget); gtk_widget_show (widget); - - if ((dpman = gst_dpman_get_manager (element))) - { + + if ((dpman = gst_dpman_get_manager (element))) { ui_feedback_add (ui, "Found Dynamic Parameters on filter element.\n"); specs = gst_dpman_list_dparam_specs (dpman); - for (i = 0; specs[i] != NULL; ++i) - { + for (i = 0; specs[i] != NULL; ++i) { hbox = gtk_hbox_new (FALSE, 0); widget = gtk_label_new (g_param_spec_get_name (specs[i])); gtk_container_add (GTK_CONTAINER (hbox), widget); gtk_widget_show (widget); - switch (G_PARAM_SPEC_VALUE_TYPE (specs[i])) - { - case G_TYPE_INT64: + switch (G_PARAM_SPEC_VALUE_TYPE (specs[i])) { + case G_TYPE_INT64: widget = gtk_hscale_new_with_range ( - (gdouble) (((GParamSpecInt64*)specs[i])->minimum), - (gdouble) (((GParamSpecInt64*)specs[i])->maximum), - 1.0); + (gdouble) (((GParamSpecInt64 *) specs[i])->minimum), + (gdouble) (((GParamSpecInt64 *) specs[i])->maximum), 1.0); gtk_range_set_value (GTK_RANGE (widget), - (gdouble) ((GParamSpecInt64*)specs[i])->default_value); - break; + (gdouble) ((GParamSpecInt64 *) specs[i])->default_value); + break; case G_TYPE_INT: widget = gtk_hscale_new_with_range ( - (gdouble) (((GParamSpecInt*)specs[i])->minimum), - (gdouble) (((GParamSpecInt*)specs[i])->maximum), - 1.0); + (gdouble) (((GParamSpecInt *) specs[i])->minimum), + (gdouble) (((GParamSpecInt *) specs[i])->maximum), 1.0); gtk_range_set_value (GTK_RANGE (widget), - (gdouble) ((GParamSpecInt*)specs[i])->default_value); - break; - case G_TYPE_FLOAT: + (gdouble) ((GParamSpecInt *) specs[i])->default_value); + break; + case G_TYPE_FLOAT: widget = gtk_hscale_new_with_range ( - (gdouble) (((GParamSpecFloat*)specs[i])->minimum), - (gdouble) (((GParamSpecFloat*)specs[i])->maximum), - 0.00001); + (gdouble) (((GParamSpecFloat *) specs[i])->minimum), + (gdouble) (((GParamSpecFloat *) specs[i])->maximum), 0.00001); gtk_range_set_value (GTK_RANGE (widget), - (gdouble) ((GParamSpecFloat*)specs[i])->default_value); + (gdouble) ((GParamSpecFloat *) specs[i])->default_value); break; } /* create the dparam object */ dparam = gst_dpsmooth_new (G_PARAM_SPEC_VALUE_TYPE (specs[i])); g_object_set (G_OBJECT (dparam), "update_period", 2000000LL, NULL); - g_assert (gst_dpman_attach_dparam (dpman, - (gchar *) g_param_spec_get_name (specs[i]), - dparam)); - gst_dpman_set_mode(dpman, "asynchronous"); + g_assert (gst_dpman_attach_dparam (dpman, + (gchar *) g_param_spec_get_name (specs[i]), dparam)); + gst_dpman_set_mode (dpman, "asynchronous"); g_signal_connect (widget, "value-changed", - G_CALLBACK (cb_dynparm_value_changed), dparam); + G_CALLBACK (cb_dynparm_value_changed), dparam); cb_dynparm_value_changed (GTK_RANGE (widget), dparam); - + gtk_container_add (GTK_CONTAINER (hbox), widget); - gtk_widget_show (widget); + gtk_widget_show (widget); } gtk_container_add (GTK_CONTAINER (control), hbox); gtk_widget_show (hbox); @@ -209,7 +200,7 @@ ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui) /* all the pretty callbacks gather here please */ void -cb_remove_and_destroy (GtkWidget *widget, gpointer user_data) +cb_remove_and_destroy (GtkWidget * widget, gpointer user_data) { GtkContainer *container = GTK_CONTAINER (user_data); @@ -220,55 +211,51 @@ cb_remove_and_destroy (GtkWidget *widget, gpointer user_data) /* when the scale associated with a dparam changes, respond */ void -cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam) +cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam) { /* - GstDParam *dparam = GST_DPARAM (user_data); - GtkHScale *adj = GTK_HSCALE (widget); - */ + GstDParam *dparam = GST_DPARAM (user_data); + GtkHScale *adj = GTK_HSCALE (widget); + */ gdouble value = 0.0; + g_assert (GST_IS_DPARAM (dparam)); g_assert (GTK_IS_RANGE (range)); value = gtk_range_get_value (range); - g_print ("DEBUG: setting value to %f\n", value); + g_print ("DEBUG: setting value to %f\n", value); - switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam))) - { + switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam))) { case G_TYPE_INT64: - g_object_set (G_OBJECT (dparam), "value_int64", - (gint64) value, NULL); + g_object_set (G_OBJECT (dparam), "value_int64", (gint64) value, NULL); break; case G_TYPE_INT: - g_object_set (G_OBJECT (dparam), "value_int", - (gint) value, NULL); + g_object_set (G_OBJECT (dparam), "value_int", (gint) value, NULL); break; case G_TYPE_FLOAT: - g_object_set (G_OBJECT (dparam), "value_float", - (gfloat) value, NULL); + g_object_set (G_OBJECT (dparam), "value_float", (gfloat) value, NULL); break; } } - + void -cb_entry_activate (GtkEntry *entry, gpointer user_data) +cb_entry_activate (GtkEntry * entry, gpointer user_data) { g_print ("DEBUG: oi ! you activated an entry !\n"); g_print ("DEBUG: pipeline: %s\n", gtk_entry_get_text (entry)); } void -cb_play_clicked (GtkButton *button, gpointer *user_data) +cb_play_clicked (GtkButton * button, gpointer * user_data) { _filter_data_t *fd = (_filter_data_t *) user_data; g_return_if_fail (GST_IS_PIPELINE (fd->pipeline)); - if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING) - { + if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING) { ui_feedback_add (fd->ui, "Pipeline is already playing !\n"); return; } @@ -276,12 +263,11 @@ cb_play_clicked (GtkButton *button, gpointer *user_data) } void -cb_stop_clicked (GtkButton *button, gpointer *user_data) +cb_stop_clicked (GtkButton * button, gpointer * user_data) { _filter_data_t *fd = (_filter_data_t *) user_data; - if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING) - { + if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING) { ui_feedback_add (fd->ui, "Pipeline is not playing !\n"); return; } @@ -289,67 +275,72 @@ cb_stop_clicked (GtkButton *button, gpointer *user_data) } void -cb_parse_clicked (GtkButton *button, gpointer *user_data) +cb_parse_clicked (GtkButton * button, gpointer * user_data) { _filter_data_t *fd = (_filter_data_t *) user_data; GtkCombo *filter = GTK_COMBO (fd->ui->filter); GError *error = NULL; GstPad *src_pad, *sink_pad; - + g_print ("DEBUG: you pressed parse.\n"); ui_feedback_clear (fd->ui); ui_feedback_add (fd->ui, "Parsing pipeline ...\n"); - if (fd->input_pipe) g_free (fd->input_pipe); - if (fd->output_pipe) g_free (fd->output_pipe); - if (fd->filter_element) g_free (fd->filter_element); + if (fd->input_pipe) + g_free (fd->input_pipe); + if (fd->output_pipe) + g_free (fd->output_pipe); + if (fd->filter_element) + g_free (fd->filter_element); fd->input_pipe = g_strdup_printf ("bin.( %s )", - gtk_entry_get_text (GTK_ENTRY (fd->ui->input))); + gtk_entry_get_text (GTK_ENTRY (fd->ui->input))); fd->output_pipe = g_strdup_printf ("bin.( %s )", - gtk_entry_get_text (GTK_ENTRY (fd->ui->output))); + gtk_entry_get_text (GTK_ENTRY (fd->ui->output))); /* gtkcombo.h says I can access the entry field directly */ - fd->filter_element = g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry))); - g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe, (int)strlen (fd->input_pipe)); - g_print ("Filter element :\t%s (%d)\n", fd->filter_element, (int)strlen (fd->filter_element)); - g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe, (int)strlen (fd->output_pipe)); + fd->filter_element = + g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry))); + g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe, + (int) strlen (fd->input_pipe)); + g_print ("Filter element :\t%s (%d)\n", fd->filter_element, + (int) strlen (fd->filter_element)); + g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe, + (int) strlen (fd->output_pipe)); /* try to create in and out bins */ - if (strlen (fd->input_pipe) == 0) - { + if (strlen (fd->input_pipe) == 0) { ui_feedback_add (fd->ui, "Error : try setting an input pipe.\n"); return; } - if (fd->input) gst_object_unref (GST_OBJECT (fd->input)); + if (fd->input) + gst_object_unref (GST_OBJECT (fd->input)); fd->input = GST_ELEMENT (gst_parse_launch (fd->input_pipe, &error)); - if (error) - { - ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n", - error->message); + if (error) { + ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n", + error->message); g_error_free (error); return; } - - if (strlen (fd->output_pipe) == 0) - { + + if (strlen (fd->output_pipe) == 0) { ui_feedback_add (fd->ui, "Error : try setting an output pipe.\n"); return; } - if (fd->output) gst_object_unref (GST_OBJECT (fd->output)); + if (fd->output) + gst_object_unref (GST_OBJECT (fd->output)); fd->output = GST_ELEMENT (gst_parse_launch (fd->output_pipe, &error)); - if (error) - { - ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n", - error->message); + if (error) { + ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n", + error->message); g_error_free (error); return; } /* try to create filter */ - if (fd->filter) gst_object_unref (GST_OBJECT (fd->filter)); + if (fd->filter) + gst_object_unref (GST_OBJECT (fd->filter)); fd->filter = gst_element_factory_make (fd->filter_element, "filter"); - if (fd->filter == NULL) - { + if (fd->filter == NULL) { ui_feedback_add (fd->ui, "Error : could not create element %s\n", - fd->filter_element); + fd->filter_element); return; } @@ -360,35 +351,33 @@ cb_parse_clicked (GtkButton *button, gpointer *user_data) fd->pipeline = gst_thread_new ("toplevel"); /* add the players to it */ - gst_bin_add_many (GST_BIN (fd->pipeline), - fd->input, fd->filter, - fd->output, NULL); + gst_bin_add_many (GST_BIN (fd->pipeline), + fd->input, fd->filter, fd->output, NULL); /* connect filter to input and output bin */ - src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC, - "source"); - if (src_pad == NULL) - { - ui_feedback_add (fd->ui, - "Error : could not find an unconnected source pad !\n"); + src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC, + "source"); + if (src_pad == NULL) { + ui_feedback_add (fd->ui, + "Error : could not find an unconnected source pad !\n"); return; } - sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK, - "sink"); - if (sink_pad == NULL) - { - ui_feedback_add (fd->ui, - "Error : could not find an unconnected sink pad !\n"); + sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK, + "sink"); + if (sink_pad == NULL) { + ui_feedback_add (fd->ui, + "Error : could not find an unconnected sink pad !\n"); return; } gst_element_add_pad (fd->input, src_pad); gst_element_add_pad (fd->output, sink_pad); gst_element_link_many (fd->input, fd->filter, fd->output, NULL); - - if (fd->pipe_string) g_free (fd->pipe_string); + + if (fd->pipe_string) + g_free (fd->pipe_string); fd->pipe_string = g_strdup_printf ("%s ! %s ! %s", fd->input_pipe, - fd->filter_element, fd->output_pipe); + fd->filter_element, fd->output_pipe); g_print ("Pipeline : %s\n", fd->pipe_string); ui_feedback_add (fd->ui, "Complete parsed pipeline: %s\n", fd->pipe_string); @@ -404,12 +393,12 @@ get_filter_choices (void) choices = g_list_append (choices, "volume"); choices = g_list_append (choices, "ladspa_lpf"); choices = g_list_append (choices, "ladspa_hpf"); - + return choices; } void -init_data (_filter_data_t *fd) +init_data (_filter_data_t * fd) { fd->input_pipe = NULL; fd->output_pipe = NULL; @@ -426,11 +415,11 @@ init_data (_filter_data_t *fd) } void -create_ui (_filter_ui_t *fui, _filter_data_t *fd) +create_ui (_filter_ui_t * fui, _filter_data_t * fd) { GtkWidget *widget; /* temporary widget */ GtkWidget *vbox; /* temporary vbox */ - + g_print ("DEBUG: creating top-level window\n"); fui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); widget = gtk_vbox_new (FALSE, 0); @@ -452,22 +441,22 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd) fui->parse = gtk_button_new_with_label ("Parse"); gtk_container_add (GTK_CONTAINER (fui->buttons), fui->parse); g_signal_connect (G_OBJECT (fui->parse), "clicked", - G_CALLBACK (cb_parse_clicked), fd); + G_CALLBACK (cb_parse_clicked), fd); fui->play = gtk_button_new_with_label ("Play"); gtk_container_add (GTK_CONTAINER (fui->buttons), fui->play); g_signal_connect (G_OBJECT (fui->play), "clicked", - G_CALLBACK (cb_play_clicked), fd); + G_CALLBACK (cb_play_clicked), fd); fui->stop = gtk_button_new_with_label ("Stop"); gtk_container_add (GTK_CONTAINER (fui->buttons), fui->stop); g_signal_connect (G_OBJECT (fui->stop), "clicked", - G_CALLBACK (cb_stop_clicked), fd); + G_CALLBACK (cb_stop_clicked), fd); /* feedback widget */ fui->fb_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (fui->feedback)); - gtk_text_buffer_set_text (fui->fb_buffer, - "Hello, and welcome to the GStreamer filter demo app !\n"\ + gtk_text_buffer_set_text (fui->fb_buffer, + "Hello, and welcome to the GStreamer filter demo app !\n" "I'll be your feedback window for today.\n", -1); - + /* selection widget */ vbox = gtk_vbox_new (FALSE, 0); widget = gtk_label_new ("Input Pipe"); @@ -476,8 +465,8 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd) gtk_entry_set_text (GTK_ENTRY (fui->input), "sinesrc"); gtk_container_add (GTK_CONTAINER (vbox), fui->input); gtk_container_add (GTK_CONTAINER (fui->selection), vbox); - g_signal_connect (G_OBJECT (fui->input), "activate", - G_CALLBACK (cb_entry_activate), NULL); + g_signal_connect (G_OBJECT (fui->input), "activate", + G_CALLBACK (cb_entry_activate), NULL); vbox = gtk_vbox_new (FALSE, 0); widget = gtk_label_new ("Filter"); @@ -491,18 +480,18 @@ create_ui (_filter_ui_t *fui, _filter_data_t *fd) widget = gtk_label_new ("Output Pipe"); gtk_container_add (GTK_CONTAINER (vbox), widget); fui->output = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */ + gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */ gtk_container_add (GTK_CONTAINER (vbox), fui->output); gtk_container_add (GTK_CONTAINER (fui->selection), vbox); - g_signal_connect (G_OBJECT (fui->output), "activate", - G_CALLBACK (cb_entry_activate), NULL); + g_signal_connect (G_OBJECT (fui->output), "activate", + G_CALLBACK (cb_entry_activate), NULL); /* control widget is dynamically generated */ /* - g_print ("DEBUG: labeling control area.\n"); - widget = gtk_label_new ("This is the big control area."); - gtk_container_add (GTK_CONTAINER (fui->control), widget); - */ + g_print ("DEBUG: labeling control area.\n"); + widget = gtk_label_new ("This is the big control area."); + gtk_container_add (GTK_CONTAINER (fui->control), widget); + */ } @@ -511,8 +500,8 @@ main (int argc, char *argv[]) { _filter_data_t filter_data; _filter_ui_t filter_ui; - - + + gtk_init (&argc, &argv); gst_init (&argc, &argv); gst_control_init (&argc, &argv); @@ -524,7 +513,6 @@ main (int argc, char *argv[]) gtk_widget_show_all (filter_ui.window); gtk_main (); - + return 0; } - diff --git a/examples/gstplay/player.c b/examples/gstplay/player.c index 32001a90..3272778b 100644 --- a/examples/gstplay/player.c +++ b/examples/gstplay/player.c @@ -16,14 +16,14 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - + #include <gst/play/play.h> static GMainLoop *loop = NULL; static gint64 length = 0; static void -print_tag (const GstTagList *list, const gchar *tag, gpointer unused) +print_tag (const GstTagList * list, const gchar * tag, gpointer unused) { gint i, count; @@ -31,14 +31,14 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused) for (i = 0; i < count; i++) { gchar *str; - + if (gst_tag_get_type (tag) == G_TYPE_STRING) { g_assert (gst_tag_list_get_string_index (list, tag, i, &str)); } else { - str = g_strdup_value_contents ( - gst_tag_list_get_value_index (list, tag, i)); + str = + g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i)); } - + if (i == 0) { g_print ("%15s: %s\n", gst_tag_get_nick (tag), str); } else { @@ -50,46 +50,46 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused) } static void -got_found_tag (GstPlay *play,GstElement *source, GstTagList *tag_list) +got_found_tag (GstPlay * play, GstElement * source, GstTagList * tag_list) { gst_tag_list_foreach (tag_list, print_tag, NULL); } static void -got_time_tick (GstPlay *play, gint64 time_nanos) +got_time_tick (GstPlay * play, gint64 time_nanos) { g_print ("time tick %f\n", time_nanos / (float) GST_SECOND); } static void -got_stream_length (GstPlay *play, gint64 length_nanos) +got_stream_length (GstPlay * play, gint64 length_nanos) { g_print ("got length %llu\n", length_nanos); length = length_nanos; } static void -got_video_size (GstPlay *play, gint width, gint height) +got_video_size (GstPlay * play, gint width, gint height) { g_print ("got video size %d, %d\n", width, height); } static void -got_eos (GstPlay *play) +got_eos (GstPlay * play) { g_print ("End Of Stream\n"); g_main_loop_quit (loop); } static gboolean -seek_timer (GstPlay *play) +seek_timer (GstPlay * play) { gst_play_seek_to_time (play, length / 2); return FALSE; } static gboolean -idle_iterate (GstPlay *play) +idle_iterate (GstPlay * play) { gst_bin_iterate (GST_BIN (play)); return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING); @@ -114,8 +114,7 @@ main (int argc, char *argv[]) /* Creating the GstPlay object */ play = gst_play_new (&error); - if (error) - { + if (error) { g_print ("Error: could not create play object:\n%s\n", error->message); g_error_free (error); return 1; @@ -140,17 +139,16 @@ main (int argc, char *argv[]) /* gst_xml_write_file (GST_ELEMENT (play), stdout); */ g_signal_connect (G_OBJECT (play), "time_tick", - G_CALLBACK (got_time_tick), NULL); + G_CALLBACK (got_time_tick), NULL); g_signal_connect (G_OBJECT (play), "stream_length", - G_CALLBACK (got_stream_length), NULL); + G_CALLBACK (got_stream_length), NULL); g_signal_connect (G_OBJECT (play), "have_video_size", - G_CALLBACK (got_video_size), NULL); + G_CALLBACK (got_video_size), NULL); g_signal_connect (G_OBJECT (play), "found_tag", - G_CALLBACK (got_found_tag), NULL); + G_CALLBACK (got_found_tag), NULL); g_signal_connect (G_OBJECT (play), "error", - G_CALLBACK (gst_element_default_error), NULL); - g_signal_connect (G_OBJECT (play), "eos", - G_CALLBACK (got_eos), NULL); + G_CALLBACK (gst_element_default_error), NULL); + g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL); /* Change state to PLAYING */ gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING); @@ -163,9 +161,9 @@ main (int argc, char *argv[]) g_print ("setting pipeline to ready\n"); gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY); - + /* unref - gst_object_unref (GST_OBJECT (play)); */ + gst_object_unref (GST_OBJECT (play)); */ exit (0); } diff --git a/examples/indexing/indexmpeg.c b/examples/indexing/indexmpeg.c index 29b89280..48a7ca23 100644 --- a/examples/indexing/indexmpeg.c +++ b/examples/indexing/indexmpeg.c @@ -24,26 +24,26 @@ static gboolean verbose = FALSE; static gboolean quiet = FALSE; static void -entry_added (GstIndex *index, GstIndexEntry *entry) +entry_added (GstIndex * index, GstIndexEntry * entry) { switch (entry->type) { case GST_INDEX_ENTRY_ID: - g_print ("id %d describes writer %s\n", entry->id, - GST_INDEX_ID_DESCRIPTION (entry)); + g_print ("id %d describes writer %s\n", entry->id, + GST_INDEX_ID_DESCRIPTION (entry)); break; case GST_INDEX_ENTRY_FORMAT: - g_print ("%d: registered format %d for %s\n", entry->id, - GST_INDEX_FORMAT_FORMAT (entry), - GST_INDEX_FORMAT_KEY (entry)); + g_print ("%d: registered format %d for %s\n", entry->id, + GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_KEY (entry)); break; case GST_INDEX_ENTRY_ASSOCIATION: { gint i; - g_print ("%p, %d: %08x ", entry, entry->id, GST_INDEX_ASSOC_FLAGS (entry)); + g_print ("%p, %d: %08x ", entry, entry->id, + GST_INDEX_ASSOC_FLAGS (entry)); for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) { - g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i), - GST_INDEX_ASSOC_VALUE (entry, i)); + g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i), + GST_INDEX_ASSOC_VALUE (entry, i)); } g_print ("\n"); break; @@ -55,15 +55,15 @@ entry_added (GstIndex *index, GstIndexEntry *entry) typedef struct { - const gchar *padname; - GstPad *target; - GstElement *bin; - GstElement *pipeline; - GstIndex *index; + const gchar *padname; + GstPad *target; + GstElement *bin; + GstElement *pipeline; + GstIndex *index; } dyn_link; static void -dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) +dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data) { dyn_link *link = (dyn_link *) data; @@ -77,27 +77,25 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) } static void -setup_dynamic_linking (GstElement *pipeline, - GstElement *element, - const gchar *padname, - GstPad *target, - GstElement *bin, - GstIndex *index) +setup_dynamic_linking (GstElement * pipeline, + GstElement * element, + const gchar * padname, GstPad * target, GstElement * bin, GstIndex * index) { dyn_link *link; link = g_new0 (dyn_link, 1); - link->padname = g_strdup (padname); - link->target = target; - link->bin = bin; - link->pipeline = pipeline; - link->index = index; - - 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; @@ -117,12 +115,12 @@ make_mpeg_systems_pipeline (const gchar *path, GstIndex *index) } gst_element_link_pads (src, "src", demux, "sink"); - + return pipeline; } -static GstElement* -make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index) +static GstElement * +make_mpeg_decoder_pipeline (const gchar * path, GstIndex * index) { GstElement *pipeline; GstElement *src, *demux; @@ -145,29 +143,27 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index) video_decoder = gst_element_factory_make ("mpeg2dec", "video_decoder"); gst_bin_add (GST_BIN (video_bin), video_decoder); - - setup_dynamic_linking (pipeline, demux, "video_00", - gst_element_get_pad (video_decoder, "sink"), - video_bin, index); + + setup_dynamic_linking (pipeline, demux, "video_00", + gst_element_get_pad (video_decoder, "sink"), video_bin, index); audio_bin = gst_bin_new ("audio_bin"); audio_decoder = gst_element_factory_make ("mad", "audio_decoder"); - setup_dynamic_linking (pipeline, demux, "audio_00", - gst_element_get_pad (audio_decoder, "sink"), - audio_bin, index); + setup_dynamic_linking (pipeline, demux, "audio_00", + gst_element_get_pad (audio_decoder, "sink"), audio_bin, index); gst_bin_add (GST_BIN (audio_bin), audio_decoder); if (index) { gst_element_set_index (pipeline, index); } - + return pipeline; } static void -print_progress (GstPad *pad) +print_progress (GstPad * pad) { gint i = 0; gchar status[53]; @@ -181,14 +177,14 @@ print_progress (GstPad *pad) format = GST_FORMAT_PERCENT; res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value); if (res) { - percent = value / (2 * GST_FORMAT_PERCENT_SCALE); + percent = value / (2 * GST_FORMAT_PERCENT_SCALE); } - + for (i = 0; i < percent; i++) { - status[i+1] = '='; + status[i + 1] = '='; } for (i = percent; i < 50; i++) { - status[i+1] = ' '; + status[i + 1] = ' '; } status[51] = '|'; status[52] = 0; @@ -196,8 +192,8 @@ print_progress (GstPad *pad) g_print ("%s\r", status); } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *src; @@ -208,27 +204,28 @@ main (gint argc, gchar *argv[]) gboolean res; GstElement *sink; struct poptOption options[] = { - { "verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0, - "Print index entries", NULL}, - { "quiet", 'q', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &quiet, 0, - "don't print progress bar", NULL}, - POPT_TABLEEND - }; + {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0, + "Print index entries", NULL}, + {"quiet", 'q', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &quiet, 0, + "don't print progress bar", NULL}, + POPT_TABLEEND + }; if (!gst_init_check_with_popt_table (&argc, &argv, options) || argc < 3) { - g_print ("usage: %s [-v] <type> <filename> \n" - " type can be: 0 mpeg_systems\n" - " 1 mpeg_decoder\n" - " -v : report added index entries\n" - " -q : don't print progress\n" , argv[0]); + g_print ("usage: %s [-v] <type> <filename> \n" + " type can be: 0 mpeg_systems\n" + " 1 mpeg_decoder\n" + " -v : report added index entries\n" + " -q : don't print progress\n", argv[0]); return -1; } /* create index that elements can fill */ index = gst_index_factory_make ("memindex"); if (index) { - if (verbose) - g_signal_connect (G_OBJECT (index), "entry_added", G_CALLBACK (entry_added), NULL); + if (verbose) + g_signal_connect (G_OBJECT (index), "entry_added", + G_CALLBACK (entry_added), NULL); g_object_set (G_OBJECT (index), "resolver", 1, NULL); } @@ -247,10 +244,10 @@ main (gint argc, gchar *argv[]) } /* setup some default info/error handlers */ - g_signal_connect (G_OBJECT (pipeline), "deep_notify", - G_CALLBACK (gst_element_default_deep_notify), NULL); - g_signal_connect (G_OBJECT (pipeline), "error", - G_CALLBACK (gst_element_default_error), NULL); + g_signal_connect (G_OBJECT (pipeline), "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (G_OBJECT (pipeline), "error", + G_CALLBACK (gst_element_default_error), NULL); /* get a pad to perform progress reporting on */ src = gst_bin_get_by_name (GST_BIN (pipeline), "src"); @@ -259,7 +256,7 @@ main (gint argc, gchar *argv[]) /* prepare for iteration */ gst_element_set_state (pipeline, GST_STATE_PLAYING); - g_print ("indexing %s...\n", argv [2]); + g_print ("indexing %s...\n", argv[2]); /* run through the complete stream to let it generate an index */ while (gst_bin_iterate (GST_BIN (pipeline))) { if (!quiet && (count % 1000 == 0)) { @@ -285,24 +282,23 @@ main (gint argc, gchar *argv[]) gint total_tm; gst_index_get_writer_id (index, GST_OBJECT (src), &id); - + entry = gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_BEFORE, 0, - GST_FORMAT_TIME, G_MAXINT64); + GST_FORMAT_TIME, G_MAXINT64); g_assert (entry); gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &result); total_tm = result * 60 / GST_SECOND; g_print ("total time = %.2fs\n", total_tm / 60.0); } - + pad = gst_element_get_pad (src, "src"); sink = gst_element_factory_make ("fakesink", "sink"); gst_element_link_pads (src, "src", sink, "sink"); gst_bin_add (GST_BIN (pipeline), sink); - g_print ("seeking %s...\n", argv [2]); + g_print ("seeking %s...\n", argv[2]); event = gst_event_new_seek (GST_FORMAT_TIME | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND); + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND); res = gst_pad_send_event (pad, event); if (!res) { @@ -322,4 +318,3 @@ main (gint argc, gchar *argv[]) return 1; } - diff --git a/examples/seeking/cdparanoia.c b/examples/seeking/cdparanoia.c index 646c121c..e750f346 100644 --- a/examples/seeking/cdparanoia.c +++ b/examples/seeking/cdparanoia.c @@ -3,7 +3,7 @@ #include <string.h> static void -get_position_info (GstElement *cdparanoia) +get_position_info (GstElement * cdparanoia) { GstFormat track_format; const GstFormat *formats; @@ -24,14 +24,13 @@ get_position_info (GstElement *cdparanoia) definition = gst_format_get_details (*formats); format = *formats; - res = gst_pad_query (pad, GST_QUERY_POSITION, - &format, &position); + res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &position); if (format == GST_FORMAT_TIME) { position /= GST_SECOND; - g_print ("%s: %lld:%02lld", definition->nick, position/60, position%60); - } - else { + g_print ("%s: %lld:%02lld", definition->nick, position / 60, + position % 60); + } else { g_print ("%s: %lld", definition->nick, position); } @@ -44,7 +43,7 @@ get_position_info (GstElement *cdparanoia) } static void -get_track_info (GstElement *cdparanoia) +get_track_info (GstElement * cdparanoia) { GstFormat track_format; gint64 total_tracks = 0, total_time = 0; @@ -52,7 +51,7 @@ get_track_info (GstElement *cdparanoia) const GstFormat *formats; gint i; gint64 time_count = 0; - + track_format = gst_format_get_by_nick ("track"); g_assert (track_format != 0); @@ -66,26 +65,24 @@ get_track_info (GstElement *cdparanoia) gint64 total; GstFormat format; gboolean res; - + definition = gst_format_get_details (*formats); format = *formats; - res = gst_pad_query (pad, GST_QUERY_TOTAL, - &format, &total); + res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &total); if (res) { if (format == GST_FORMAT_TIME) { total /= GST_SECOND; - g_print ("%s total: %lld:%02lld\n", definition->nick, total/60, total%60); - } - else - g_print ("%s total: %lld\n", definition->nick, total); + g_print ("%s total: %lld:%02lld\n", definition->nick, total / 60, + total % 60); + } else + g_print ("%s total: %lld\n", definition->nick, total); if (format == track_format) total_tracks = total; else if (format == GST_FORMAT_TIME) total_time = total; - } - else + } else g_print ("failed to get %s total\n", definition->nick); formats++; @@ -102,11 +99,9 @@ get_track_info (GstElement *cdparanoia) GstFormat format; format = GST_FORMAT_TIME; - res = gst_pad_convert (pad, track_format, i, - &format, &time); + res = gst_pad_convert (pad, track_format, i, &format, &time); time /= GST_SECOND; - } - else { + } else { time = total_time; res = TRUE; } @@ -117,14 +112,12 @@ get_track_info (GstElement *cdparanoia) if (i > 0) { gint64 length = time - time_count; - g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n", - i-1, - time_count / 60, time_count % 60, - time / 60, time % 60, - length / 60, length % 60); + g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n", + i - 1, + time_count / 60, time_count % 60, + time / 60, time % 60, length / 60, length % 60); } - } - else { + } else { g_print ("could not get time for track %d\n", i); } @@ -161,7 +154,7 @@ main (int argc, char **argv) gst_element_link_pads (cdparanoia, "src", osssink, "sink"); g_signal_connect (G_OBJECT (pipeline), "deep_notify", - G_CALLBACK (gst_element_default_deep_notify), NULL); + G_CALLBACK (gst_element_default_deep_notify), NULL); gst_element_set_state (pipeline, GST_STATE_PAUSED); @@ -177,9 +170,7 @@ main (int argc, char **argv) g_print ("playing from track 3\n"); /* seek to track3 */ event = gst_event_new_seek (track_format | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, - 3); + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 3); res = gst_pad_send_event (pad, event); if (!res) @@ -198,9 +189,8 @@ main (int argc, char **argv) g_print ("\nplaying from second 25 to second 29\n"); /* seek to some seconds */ event = gst_event_new_segment_seek (GST_FORMAT_TIME | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, - 25 * GST_SECOND, 29 * GST_SECOND); + GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH, 25 * GST_SECOND, 29 * GST_SECOND); res = gst_pad_send_event (pad, event); if (!res) g_warning ("seek failed"); diff --git a/examples/seeking/cdplayer.c b/examples/seeking/cdplayer.c index 6ce55471..1e823cc5 100644 --- a/examples/seeking/cdplayer.c +++ b/examples/seeking/cdplayer.c @@ -15,11 +15,11 @@ static guint update_id; #define UPDATE_INTERVAL 500 -static GstElement* -make_cdaudio_pipeline (void) +static GstElement * +make_cdaudio_pipeline (void) { GstElement *cdaudio; - + cdaudio = gst_element_factory_make ("cdaudio", "cdaudio"); g_assert (cdaudio != NULL); @@ -28,9 +28,8 @@ make_cdaudio_pipeline (void) return cdaudio; } -static gchar* -format_value (GtkScale *scale, - gdouble value) +static gchar * +format_value (GtkScale * scale, gdouble value) { gint64 real; gint64 seconds; @@ -41,9 +40,7 @@ format_value (GtkScale *scale, subseconds = (gint64) real / (GST_SECOND / 100); return g_strdup_printf ("%02lld:%02lld:%02lld", - seconds/60, - seconds%60, - subseconds%100); + seconds / 60, seconds % 60, subseconds % 100); } typedef struct @@ -52,13 +49,12 @@ typedef struct const GstFormat format; } seek_format; -static seek_format seek_formats[] = -{ - { "tim", GST_FORMAT_TIME }, - { "byt", GST_FORMAT_BYTES }, - { "buf", GST_FORMAT_BUFFERS }, - { "def", GST_FORMAT_DEFAULT }, - { NULL, 0 }, +static seek_format seek_formats[] = { + {"tim", GST_FORMAT_TIME}, + {"byt", GST_FORMAT_BYTES}, + {"buf", GST_FORMAT_BUFFERS}, + {"def", GST_FORMAT_DEFAULT}, + {NULL, 0}, }; @@ -80,10 +76,9 @@ query_durations () format = seek_formats[i].format; res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value); if (res) { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; } @@ -110,10 +105,9 @@ query_positions () format = seek_formats[i].format; res = gst_element_query (element, GST_QUERY_POSITION, &format, &value); if (res) { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; } @@ -123,7 +117,7 @@ query_positions () } static gboolean -update_scale (gpointer data) +update_scale (gpointer data) { GstClock *clock; guint64 position = 0; @@ -134,6 +128,7 @@ update_scale (gpointer data) if (seekable_elements) { GstElement *element = GST_ELEMENT (seekable_elements->data); + gst_element_query (element, GST_QUERY_TOTAL, &format, &duration); } if (clock) @@ -141,7 +136,8 @@ update_scale (gpointer data) if (stats) { if (clock) - g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock))); + g_print ("clock: %13llu (%s)\n", position, + gst_object_get_name (GST_OBJECT (clock))); query_durations (); query_positions (); } @@ -167,7 +163,7 @@ iterate (gpointer data) } static gboolean -start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data) { gst_element_set_state (pipeline, GST_STATE_PAUSED); gtk_timeout_remove (update_id); @@ -176,7 +172,7 @@ start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) } static gboolean -stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data) { gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100; gboolean res; @@ -188,8 +184,7 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable)); s_event = gst_event_new_seek (GST_FORMAT_TIME | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real); res = gst_element_send_event (seekable, s_event); @@ -199,7 +194,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) gst_element_set_state (pipeline, GST_STATE_PLAYING); if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE)) gtk_idle_add ((GtkFunction) iterate, pipeline); - update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); + update_id = + gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); return FALSE; } @@ -211,7 +207,8 @@ play_cb (GtkButton * button, gpointer data) gst_element_set_state (pipeline, GST_STATE_PLAYING); if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE)) gtk_idle_add ((GtkFunction) iterate, pipeline); - update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); + update_id = + gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); } } @@ -236,22 +233,23 @@ stop_cb (GtkButton * button, gpointer data) int main (int argc, char **argv) { - GtkWidget *window, *hbox, *vbox, - *play_button, *pause_button, *stop_button, - *hscale; + GtkWidget *window, *hbox, *vbox, + *play_button, *pause_button, *stop_button, *hscale; struct poptOption options[] = { - {"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0, - "Show element stats", NULL}, - POPT_TABLEEND - }; + {"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0, + "Show element stats", NULL}, + POPT_TABLEEND + }; gst_init_with_popt_table (&argc, &argv, options); gtk_init (&argc, &argv); pipeline = make_cdaudio_pipeline (); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); - g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL); + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), + NULL); /* initialize gui elements ... */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -261,17 +259,18 @@ main (int argc, char **argv) pause_button = gtk_button_new_with_label ("pause"); stop_button = gtk_button_new_with_label ("stop"); - adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0)); + adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0)); hscale = gtk_hscale_new (adjustment); gtk_scale_set_digits (GTK_SCALE (hscale), 2); gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS); - gtk_signal_connect(GTK_OBJECT(hscale), - "button_press_event", G_CALLBACK (start_seek), pipeline); - gtk_signal_connect(GTK_OBJECT(hscale), - "button_release_event", G_CALLBACK (stop_seek), pipeline); - gtk_signal_connect(GTK_OBJECT(hscale), - "format_value", G_CALLBACK (format_value), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "button_press_event", G_CALLBACK (start_seek), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "button_release_event", G_CALLBACK (stop_seek), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "format_value", G_CALLBACK (format_value), pipeline); /* do the packing stuff ... */ gtk_window_set_default_size (GTK_WINDOW (window), 96, 96); @@ -283,9 +282,12 @@ main (int argc, char **argv) gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2); /* connect things ... */ - g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline); - g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline); - g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline); + g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), + pipeline); + g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), + pipeline); + g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), + pipeline); g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL); /* show the gui. */ diff --git a/examples/seeking/seek.c b/examples/seeking/seek.c index 2ad1ca7f..34a6958d 100644 --- a/examples/seeking/seek.c +++ b/examples/seeking/seek.c @@ -25,26 +25,25 @@ static guint update_id; typedef struct { - const gchar *padname; - GstPad *target; - GstElement *bin; + const gchar *padname; + GstPad *target; + GstElement *bin; } dyn_link; static GstElement * -gst_element_factory_make_or_warn (gchar *type, gchar *name) +gst_element_factory_make_or_warn (gchar * type, gchar * name) { GstElement *element = gst_element_factory_make (type, name); if (!element) { - g_warning ("Failed to create element %s of type %s", - name, type); + g_warning ("Failed to create element %s of type %s", name, type); } return element; } static void -dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) +dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data) { dyn_link *connect = (dyn_link *) data; @@ -60,25 +59,27 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) } static void -setup_dynamic_link (GstElement *element, const gchar *padname, GstPad *target, GstElement *bin) +setup_dynamic_link (GstElement * element, const gchar * padname, + GstPad * target, GstElement * bin) { dyn_link *connect; connect = g_new0 (dyn_link, 1); - connect->padname = g_strdup (padname); - connect->target = target; - connect->bin = bin; + connect->padname = g_strdup (padname); + connect->target = target; + connect->bin = bin; - g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), connect); + g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), + connect); } -static GstElement* -make_mod_pipeline (const gchar *location) +static GstElement * +make_mod_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *decoder, *audiosink; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -103,13 +104,13 @@ make_mod_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_dv_pipeline (const gchar *location) +static GstElement * +make_dv_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *decoder, *audiosink, *videosink; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -140,13 +141,13 @@ make_dv_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_wav_pipeline (const gchar *location) +static GstElement * +make_wav_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *decoder, *audiosink; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -171,13 +172,13 @@ make_wav_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_flac_pipeline (const gchar *location) +static GstElement * +make_flac_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *decoder, *audiosink; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -202,13 +203,13 @@ make_flac_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_sid_pipeline (const gchar *location) +static GstElement * +make_sid_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *decoder, *audiosink; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -233,13 +234,13 @@ make_sid_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_parse_pipeline (const gchar *location) +static GstElement * +make_parse_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *parser, *fakesink; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -265,13 +266,13 @@ make_parse_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_vorbis_pipeline (const gchar *location) +static GstElement * +make_vorbis_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *decoder, *audiosink; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -296,13 +297,13 @@ make_vorbis_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_mp3_pipeline (const gchar *location) +static GstElement * +make_mp3_pipeline (const gchar * location) { GstElement *pipeline; GstElement *src, *decoder, *osssink, *queue, *audio_thread; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -335,14 +336,15 @@ make_mp3_pipeline (const gchar *location) return pipeline; } -static GstElement* -make_avi_pipeline (const gchar *location) +static GstElement * +make_avi_pipeline (const gchar * location) { GstElement *pipeline, *audio_bin, *video_bin; GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink; - GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue = NULL, *video_thread = NULL; + GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue = + NULL, *video_thread = NULL; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -369,12 +371,14 @@ make_avi_pipeline (const gchar *location) gst_bin_add (GST_BIN (audio_thread), audiosink); gst_element_set_state (audio_bin, GST_STATE_PAUSED); - setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin); + setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, + "sink"), audio_bin); seekable = gst_element_get_pad (a_queue, "src"); seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink")); video_bin = gst_bin_new ("v_decoder_bin"); //v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec"); @@ -395,25 +399,27 @@ make_avi_pipeline (const gchar *location) gst_element_set_state (video_bin, GST_STATE_PAUSED); - setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin); + setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, + "sink"), video_bin); seekable = gst_element_get_pad (v_queue, "src"); seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink")); return pipeline; } -static GstElement* -make_mpeg_pipeline (const gchar *location) +static GstElement * +make_mpeg_pipeline (const gchar * location) { GstElement *pipeline, *audio_bin, *video_bin; GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter; GstElement *audiosink, *videosink; GstElement *a_queue, *audio_thread, *v_queue, *video_thread; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -441,12 +447,14 @@ make_mpeg_pipeline (const gchar *location) gst_bin_add (GST_BIN (audio_thread), a_queue); gst_bin_add (GST_BIN (audio_thread), audiosink); - setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin); + setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, + "sink"), audio_bin); seekable = gst_element_get_pad (a_queue, "src"); seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink")); video_bin = gst_bin_new ("v_decoder_bin"); v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec"); @@ -456,30 +464,32 @@ make_mpeg_pipeline (const gchar *location) v_filter = gst_element_factory_make_or_warn ("colorspace", "v_filter"); videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink"); gst_element_link_many (v_decoder, v_queue, v_filter, NULL); - + gst_element_link (v_filter, videosink); gst_bin_add_many (GST_BIN (video_bin), v_decoder, video_thread, NULL); gst_bin_add_many (GST_BIN (video_thread), v_queue, v_filter, videosink, NULL); - setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin); + setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, + "sink"), video_bin); seekable = gst_element_get_pad (v_queue, "src"); seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink")); return pipeline; } -static GstElement* -make_mpegnt_pipeline (const gchar *location) +static GstElement * +make_mpegnt_pipeline (const gchar * location) { GstElement *pipeline, *audio_bin, *video_bin; GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter; GstElement *audiosink, *videosink; GstElement *a_queue, *audio_thread; GstPad *seekable; - + pipeline = gst_pipeline_new ("app"); src = gst_element_factory_make_or_warn (SOURCE, "src"); @@ -508,40 +518,43 @@ make_mpegnt_pipeline (const gchar *location) gst_bin_add (GST_BIN (audio_thread), a_queue); gst_bin_add (GST_BIN (audio_thread), audiosink); - setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin); + setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, + "sink"), audio_bin); seekable = gst_element_get_pad (a_queue, "src"); seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink")); video_bin = gst_bin_new ("v_decoder_bin"); v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec"); v_filter = gst_element_factory_make_or_warn ("colorspace", "v_filter"); videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink"); gst_element_link_many (v_decoder, v_filter, videosink, NULL); - + gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL); - setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin); + setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, + "sink"), video_bin); seekable = gst_element_get_pad (v_decoder, "src"); seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink")); return pipeline; } -static GstElement* -make_playerbin_pipeline (const gchar *location) +static GstElement * +make_playerbin_pipeline (const gchar * location) { return NULL; } -static gchar* -format_value (GtkScale *scale, - gdouble value) +static gchar * +format_value (GtkScale * scale, gdouble value) { gint64 real; gint64 seconds; @@ -552,9 +565,7 @@ format_value (GtkScale *scale, subseconds = (gint64) real / (GST_SECOND / 100); return g_strdup_printf ("%02lld:%02lld:%02lld", - seconds/60, - seconds%60, - subseconds%100); + seconds / 60, seconds % 60, subseconds % 100); } typedef struct @@ -563,13 +574,12 @@ typedef struct const GstFormat format; } seek_format; -static seek_format seek_formats[] = -{ - { "tim", GST_FORMAT_TIME }, - { "byt", GST_FORMAT_BYTES }, - { "buf", GST_FORMAT_BUFFERS }, - { "def", GST_FORMAT_DEFAULT }, - { NULL, 0 }, +static seek_format seek_formats[] = { + {"tim", GST_FORMAT_TIME}, + {"byt", GST_FORMAT_BYTES}, + {"buf", GST_FORMAT_BUFFERS}, + {"def", GST_FORMAT_DEFAULT}, + {NULL, 0}, }; G_GNUC_UNUSED static void @@ -588,13 +598,10 @@ query_rates (void) format = seek_formats[i].format; - if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, - &format, &value)) - { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) { + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; @@ -623,15 +630,14 @@ query_durations () format = seek_formats[i].format; res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &value); if (res) { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; } g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad)); - + walk = g_list_next (walk); } } @@ -654,10 +660,9 @@ query_positions () format = seek_formats[i].format; res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value); if (res) { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; } @@ -668,7 +673,7 @@ query_positions () } static gboolean -update_scale (gpointer data) +update_scale (gpointer data) { GstClock *clock; guint64 position; @@ -679,12 +684,14 @@ update_scale (gpointer data) if (seekable_pads) { GstPad *pad = GST_PAD (seekable_pads->data); + gst_pad_query (pad, GST_QUERY_TOTAL, &format, &duration); } position = gst_clock_get_time (clock); if (stats) { - g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock))); + g_print ("clock: %13llu (%s)\n", position, + gst_object_get_name (GST_OBJECT (clock))); query_durations (); query_positions (); query_rates (); @@ -711,7 +718,7 @@ iterate (gpointer data) } static gboolean -start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data) { gst_element_set_state (pipeline, GST_STATE_PAUSED); gtk_timeout_remove (update_id); @@ -720,21 +727,23 @@ start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) } static gboolean -stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data) { gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100; gboolean res; GstEvent *s_event; + #ifdef PAD_SEEK GList *walk = seekable_pads; while (walk) { GstPad *seekable = GST_PAD (walk->data); - g_print ("seek to %lld on pad %s:%s\n", real, GST_DEBUG_PAD_NAME (seekable)); - s_event = gst_event_new_seek (GST_FORMAT_TIME | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + g_print ("seek to %lld on pad %s:%s\n", real, + GST_DEBUG_PAD_NAME (seekable)); + s_event = + gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH, real); res = gst_pad_send_event (seekable, s_event); @@ -746,10 +755,11 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) while (walk) { GstElement *seekable = GST_ELEMENT (walk->data); - g_print ("seek to %lld on element %s\n", real, gst_element_get_name (seekable)); - s_event = gst_event_new_seek (GST_FORMAT_TIME | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + g_print ("seek to %lld on element %s\n", real, + gst_element_get_name (seekable)); + s_event = + gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH, real); res = gst_element_send_event (seekable, s_event); @@ -759,7 +769,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) gst_element_set_state (pipeline, GST_STATE_PLAYING); gtk_idle_add ((GtkFunction) iterate, pipeline); - update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); + update_id = + gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); return FALSE; } @@ -770,7 +781,8 @@ play_cb (GtkButton * button, gpointer data) if (gst_element_get_state (pipeline) != GST_STATE_PLAYING) { gst_element_set_state (pipeline, GST_STATE_PLAYING); gtk_idle_add ((GtkFunction) iterate, pipeline); - update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); + update_id = + gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); } } @@ -795,23 +807,23 @@ stop_cb (GtkButton * button, gpointer data) typedef struct { gchar *name; - GstElement* (*func) (const gchar *location); + GstElement *(*func) (const gchar * location); } Pipeline; static Pipeline pipelines[] = { - { "mp3", make_mp3_pipeline }, - { "avi", make_avi_pipeline }, - { "mpeg1", make_mpeg_pipeline }, - { "mpegparse", make_parse_pipeline }, - { "vorbis", make_vorbis_pipeline }, - { "sid", make_sid_pipeline }, - { "flac", make_flac_pipeline }, - { "wav", make_wav_pipeline }, - { "mod", make_mod_pipeline }, - { "dv", make_dv_pipeline }, - { "mpeg1nothreads", make_mpegnt_pipeline }, - { "playerbin", make_playerbin_pipeline }, - { NULL, NULL}, + {"mp3", make_mp3_pipeline}, + {"avi", make_avi_pipeline}, + {"mpeg1", make_mpeg_pipeline}, + {"mpegparse", make_parse_pipeline}, + {"vorbis", make_vorbis_pipeline}, + {"sid", make_sid_pipeline}, + {"flac", make_flac_pipeline}, + {"wav", make_wav_pipeline}, + {"mod", make_mod_pipeline}, + {"dv", make_dv_pipeline}, + {"mpeg1nothreads", make_mpegnt_pipeline}, + {"playerbin", make_playerbin_pipeline}, + {NULL, NULL}, }; #define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1) @@ -832,16 +844,15 @@ print_usage (int argc, char **argv) int main (int argc, char **argv) { - GtkWidget *window, *hbox, *vbox, - *play_button, *pause_button, *stop_button, - *hscale; + GtkWidget *window, *hbox, *vbox, + *play_button, *pause_button, *stop_button, *hscale; struct poptOption options[] = { - { "stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0, - "Show pad stats", NULL }, + {"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0, + "Show pad stats", NULL}, POPT_TABLEEND }; gint type; - + gst_init_with_popt_table (&argc, &argv, options); gtk_init (&argc, &argv); @@ -868,17 +879,18 @@ main (int argc, char **argv) pause_button = gtk_button_new_with_label ("pause"); stop_button = gtk_button_new_with_label ("stop"); - adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0)); + adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0)); hscale = gtk_hscale_new (adjustment); gtk_scale_set_digits (GTK_SCALE (hscale), 2); gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS); - gtk_signal_connect(GTK_OBJECT(hscale), - "button_press_event", G_CALLBACK (start_seek), pipeline); - gtk_signal_connect(GTK_OBJECT(hscale), - "button_release_event", G_CALLBACK (stop_seek), pipeline); - gtk_signal_connect(GTK_OBJECT(hscale), - "format_value", G_CALLBACK (format_value), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "button_press_event", G_CALLBACK (start_seek), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "button_release_event", G_CALLBACK (stop_seek), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "format_value", G_CALLBACK (format_value), pipeline); /* do the packing stuff ... */ gtk_window_set_default_size (GTK_WINDOW (window), 96, 96); @@ -890,16 +902,21 @@ main (int argc, char **argv) gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2); /* connect things ... */ - g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline); - g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline); - g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline); + g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), + pipeline); + g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), + pipeline); + g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), + pipeline); g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL); /* show the gui. */ gtk_widget_show_all (window); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); - g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL); + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), + NULL); gtk_main (); diff --git a/examples/seeking/spider_seek.c b/examples/seeking/spider_seek.c index a21aac16..d2c2c6b2 100644 --- a/examples/seeking/spider_seek.c +++ b/examples/seeking/spider_seek.c @@ -19,19 +19,19 @@ static guint update_id; #define UPDATE_INTERVAL 500 -static GstElement* -make_spider_pipeline (const gchar *location, gboolean thread) +static GstElement * +make_spider_pipeline (const gchar * location, gboolean thread) { GstElement *pipeline; - GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread, *a_queue, *v_queue; - + GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread, + *a_queue, *v_queue; + if (thread) { pipeline = gst_thread_new ("app"); - } - else { + } else { pipeline = gst_pipeline_new ("app"); } - + src = gst_element_factory_make (SOURCE, "src"); decoder = gst_element_factory_make ("spider", "decoder"); @@ -64,15 +64,16 @@ make_spider_pipeline (const gchar *location, gboolean thread) seekable_elements = g_list_prepend (seekable_elements, videosink); seekable_elements = g_list_prepend (seekable_elements, audiosink); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink")); - rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink")); + rate_pads = + g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink")); return pipeline; } -static gchar* -format_value (GtkScale *scale, - gdouble value) +static gchar * +format_value (GtkScale * scale, gdouble value) { gint64 real; gint64 seconds; @@ -83,9 +84,7 @@ format_value (GtkScale *scale, subseconds = (gint64) real / (GST_SECOND / 100); return g_strdup_printf ("%02lld:%02lld:%02lld", - seconds/60, - seconds%60, - subseconds%100); + seconds / 60, seconds % 60, subseconds % 100); } typedef struct @@ -94,13 +93,12 @@ typedef struct const GstFormat format; } seek_format; -static seek_format seek_formats[] = -{ - { "tim", GST_FORMAT_TIME }, - { "byt", GST_FORMAT_BYTES }, - { "buf", GST_FORMAT_BUFFERS }, - { "def", GST_FORMAT_DEFAULT }, - { NULL, 0 }, +static seek_format seek_formats[] = { + {"tim", GST_FORMAT_TIME}, + {"byt", GST_FORMAT_BYTES}, + {"buf", GST_FORMAT_BUFFERS}, + {"def", GST_FORMAT_DEFAULT}, + {NULL, 0}, }; G_GNUC_UNUSED static void @@ -119,13 +117,10 @@ query_rates (void) format = seek_formats[i].format; - if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, - &format, &value)) - { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) { + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; @@ -154,10 +149,9 @@ query_durations () format = seek_formats[i].format; res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value); if (res) { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; } @@ -184,10 +178,9 @@ query_positions () format = seek_formats[i].format; res = gst_element_query (element, GST_QUERY_POSITION, &format, &value); if (res) { - g_print ("%s %13lld | ", seek_formats[i].name, value); - } - else { - g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); + g_print ("%s %13lld | ", seek_formats[i].name, value); + } else { + g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*"); } i++; } @@ -197,7 +190,7 @@ query_positions () } static gboolean -update_scale (gpointer data) +update_scale (gpointer data) { GstClock *clock; guint64 position; @@ -208,12 +201,14 @@ update_scale (gpointer data) if (seekable_elements) { GstElement *element = GST_ELEMENT (seekable_elements->data); + gst_element_query (element, GST_QUERY_TOTAL, &format, &duration); } position = gst_clock_get_time (clock); if (stats) { - g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock))); + g_print ("clock: %13llu (%s)\n", position, + gst_object_get_name (GST_OBJECT (clock))); query_durations (); query_positions (); query_rates (); @@ -239,7 +234,7 @@ iterate (gpointer data) } static gboolean -start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data) { gst_element_set_state (pipeline, GST_STATE_PAUSED); gtk_timeout_remove (update_id); @@ -248,7 +243,7 @@ start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) } static gboolean -stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data) { gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100; gboolean res; @@ -260,8 +255,7 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable)); s_event = gst_event_new_seek (GST_FORMAT_TIME | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real); res = gst_element_send_event (seekable, s_event); @@ -271,7 +265,8 @@ stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data) gst_element_set_state (pipeline, GST_STATE_PLAYING); if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE)) gtk_idle_add ((GtkFunction) iterate, pipeline); - update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); + update_id = + gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); return FALSE; } @@ -283,7 +278,8 @@ play_cb (GtkButton * button, gpointer data) gst_element_set_state (pipeline, GST_STATE_PLAYING); if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE)) gtk_idle_add ((GtkFunction) iterate, pipeline); - update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); + update_id = + gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline); } } @@ -308,17 +304,16 @@ stop_cb (GtkButton * button, gpointer data) int main (int argc, char **argv) { - GtkWidget *window, *hbox, *vbox, - *play_button, *pause_button, *stop_button, - *hscale; + GtkWidget *window, *hbox, *vbox, + *play_button, *pause_button, *stop_button, *hscale; gboolean threaded = FALSE; struct poptOption options[] = { - {"threaded", 't', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &threaded, 0, - "Run the pipeline in a toplevel thread", NULL}, - {"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0, - "Show element stats", NULL}, - POPT_TABLEEND - }; + {"threaded", 't', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &threaded, 0, + "Run the pipeline in a toplevel thread", NULL}, + {"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0, + "Show element stats", NULL}, + POPT_TABLEEND + }; gst_init_with_popt_table (&argc, &argv, options); gtk_init (&argc, &argv); @@ -338,17 +333,18 @@ main (int argc, char **argv) pause_button = gtk_button_new_with_label ("pause"); stop_button = gtk_button_new_with_label ("stop"); - adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0)); + adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0)); hscale = gtk_hscale_new (adjustment); gtk_scale_set_digits (GTK_SCALE (hscale), 2); gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS); - gtk_signal_connect(GTK_OBJECT(hscale), - "button_press_event", G_CALLBACK (start_seek), pipeline); - gtk_signal_connect(GTK_OBJECT(hscale), - "button_release_event", G_CALLBACK (stop_seek), pipeline); - gtk_signal_connect(GTK_OBJECT(hscale), - "format_value", G_CALLBACK (format_value), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "button_press_event", G_CALLBACK (start_seek), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "button_release_event", G_CALLBACK (stop_seek), pipeline); + gtk_signal_connect (GTK_OBJECT (hscale), + "format_value", G_CALLBACK (format_value), pipeline); /* do the packing stuff ... */ gtk_window_set_default_size (GTK_WINDOW (window), 96, 96); @@ -360,9 +356,12 @@ main (int argc, char **argv) gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2); /* connect things ... */ - g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline); - g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline); - g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline); + g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), + pipeline); + g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), + pipeline); + g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), + pipeline); g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL); /* show the gui. */ diff --git a/examples/seeking/vorbisfile.c b/examples/seeking/vorbisfile.c index acaa60c9..ec6844a0 100644 --- a/examples/seeking/vorbisfile.c +++ b/examples/seeking/vorbisfile.c @@ -4,34 +4,37 @@ static gboolean ready = FALSE; -struct probe_context { +struct probe_context +{ GstElement *pipeline; GstElement *element; - GstPad *pad; - GstFormat ls_format; + GstPad *pad; + GstFormat ls_format; - gint total_ls; + gint total_ls; - GstCaps *metadata; - GstCaps *streaminfo; - GstCaps *caps; + GstCaps *metadata; + GstCaps *streaminfo; + GstCaps *caps; }; static void -print_caps (GstCaps *caps) +print_caps (GstCaps * caps) { char *s; + s = gst_caps_to_string (caps); - g_print(" %s\n", s); + g_print (" %s\n", s); g_free (s); } static void -print_format (GstCaps *caps) +print_format (GstCaps * caps) { char *s; + s = gst_caps_to_string (caps); - g_print(" format: %s\n", s); + g_print (" format: %s\n", s); g_free (s); } @@ -61,35 +64,31 @@ print_lbs_info (struct probe_context *context, gint stream) definition = gst_format_get_details (format); /* get start and end position of this stream */ - res = gst_pad_convert (context->pad, - context->ls_format, stream, - &format, &value_start); + res = gst_pad_convert (context->pad, + context->ls_format, stream, &format, &value_start); res &= gst_pad_convert (context->pad, - context->ls_format, stream + 1, - &format, &value_end); + context->ls_format, stream + 1, &format, &value_end); if (res) { /* substract to get the length */ value_end -= value_start; if (format == GST_FORMAT_TIME) { - value_end /= (GST_SECOND/100); - g_print (" %s: %lld:%02lld.%02lld\n", definition->nick, - value_end/6000, (value_end/100)%60, (value_end%100)); + value_end /= (GST_SECOND / 100); + g_print (" %s: %lld:%02lld.%02lld\n", definition->nick, + value_end / 6000, (value_end / 100) % 60, (value_end % 100)); + } else { + g_print (" %s: %lld\n", definition->nick, value_end); } - else { - g_print (" %s: %lld\n", definition->nick, value_end); - } - } - else + } else g_print (" could not get logical stream %s\n", definition->nick); } } static void -deep_notify (GObject *object, GstObject *origin, - GParamSpec *pspec, gpointer data) +deep_notify (GObject * object, GstObject * origin, + GParamSpec * pspec, gpointer data) { struct probe_context *context = (struct probe_context *) data; GValue value = { 0, }; @@ -99,8 +98,7 @@ deep_notify (GObject *object, GstObject *origin, g_value_init (&value, pspec->value_type); g_object_get_property (G_OBJECT (origin), pspec->name, &value); context->metadata = g_value_peek_pointer (&value); - } - else if (!strcmp (pspec->name, "streaminfo")) { + } else if (!strcmp (pspec->name, "streaminfo")) { g_value_init (&value, pspec->value_type); g_object_get_property (G_OBJECT (origin), pspec->name, &value); @@ -127,9 +125,7 @@ collect_logical_stream_properties (struct probe_context *context, gint stream) /* seek to stream */ event = gst_event_new_seek (context->ls_format | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, - stream); + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, stream); res = gst_pad_send_event (context->pad, event); if (!res) { g_warning ("seek to logical track failed"); @@ -141,7 +137,8 @@ collect_logical_stream_properties (struct probe_context *context, gint stream) ready = FALSE; while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) { count++; - if (count > 10) break; + if (count > 10) + break; } print_caps (context->metadata); @@ -177,21 +174,19 @@ collect_stream_properties (struct probe_context *context) format = *formats; formats++; - res = gst_pad_query (context->pad, GST_QUERY_TOTAL, - &format, &value); + res = gst_pad_query (context->pad, GST_QUERY_TOTAL, &format, &value); definition = gst_format_get_details (format); if (res) { if (format == GST_FORMAT_TIME) { - value /= (GST_SECOND/100); - g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick, - value/6000, (value/100)%60, (value%100)); - } - else { - if (format == context->ls_format) - context->total_ls = value; - g_print (" total %s: %lld\n", definition->nick, value); + value /= (GST_SECOND / 100); + g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick, + value / 6000, (value / 100) % 60, (value % 100)); + } else { + if (format == context->ls_format) + context->total_ls = value; + g_print (" total %s: %lld\n", definition->nick, value); } } } @@ -248,7 +243,7 @@ main (int argc, char **argv) context->ls_format = logical_stream_format; g_signal_connect (G_OBJECT (pipeline), "deep_notify", - G_CALLBACK (deep_notify), context); + G_CALLBACK (deep_notify), context); gst_element_set_state (pipeline, GST_STATE_PLAYING); diff --git a/examples/stats/mp2ogg.c b/examples/stats/mp2ogg.c index e5d3fbd9..55d79e90 100644 --- a/examples/stats/mp2ogg.c +++ b/examples/stats/mp2ogg.c @@ -24,8 +24,8 @@ * compression status of mpeg audio to ogg vorbis transcoding. */ -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstElement *pipeline; GError *error = NULL; @@ -34,21 +34,22 @@ main (gint argc, gchar *argv[]) GstPad *dec_sink, *enc_src; gst_init (&argc, &argv); - + if (argc < 3) { g_print ("usage: %s <inputfile> <outputfile>\n", argv[0]); return -1; } description = g_strdup_printf ("filesrc location=\"%s\" ! mad name=decoder ! " - "vorbisenc name=encoder ! filesink location=\"%s\"", argv[1], argv[2]); + "vorbisenc name=encoder ! filesink location=\"%s\"", argv[1], argv[2]); pipeline = GST_ELEMENT (gst_parse_launch (description, &error)); if (!pipeline) { if (error) - g_print ("ERROR: pipeline could not be constructed: %s\n", error->message); + g_print ("ERROR: pipeline could not be constructed: %s\n", + error->message); else - g_print ("ERROR: pipeline could not be constructed\n"); + g_print ("ERROR: pipeline could not be constructed\n"); return -1; } @@ -57,7 +58,7 @@ main (gint argc, gchar *argv[]) dec_sink = gst_element_get_pad (decoder, "sink"); enc_src = gst_element_get_pad (encoder, "src"); - + if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) { g_print ("pipeline doesn't want to play\n"); return -1; @@ -71,33 +72,29 @@ main (gint argc, gchar *argv[]) format = GST_FORMAT_TIME; /* get the position */ - gst_pad_query (enc_src, GST_QUERY_POSITION, - &format, &position); + gst_pad_query (enc_src, GST_QUERY_POSITION, &format, &position); /* get the total duration */ - gst_pad_query (enc_src, GST_QUERY_TOTAL, - &format, &duration); + gst_pad_query (enc_src, GST_QUERY_TOTAL, &format, &duration); format = GST_FORMAT_BYTES; /* see how many bytes are genereated per 8 seconds (== bitrate) */ gst_pad_convert (enc_src, GST_FORMAT_TIME, 8 * GST_SECOND, - &format, &bitrate_enc); + &format, &bitrate_enc); gst_pad_convert (dec_sink, GST_FORMAT_TIME, 8 * GST_SECOND, - &format, &bitrate_dec); + &format, &bitrate_dec); g_print ("[%2dm %.2ds] of [%2dm %.2ds], " - "src avg bitrate: %lld, dest avg birate: %lld, ratio [%02.2f] \r", - (gint)(position / (GST_SECOND * 60)), - (gint)(position / (GST_SECOND)) % 60, - (gint)(duration / (GST_SECOND * 60)), - (gint)(duration / (GST_SECOND)) % 60, - bitrate_dec, - bitrate_enc, - (gfloat)bitrate_dec/bitrate_enc); + "src avg bitrate: %lld, dest avg birate: %lld, ratio [%02.2f] \r", + (gint) (position / (GST_SECOND * 60)), + (gint) (position / (GST_SECOND)) % 60, + (gint) (duration / (GST_SECOND * 60)), + (gint) (duration / (GST_SECOND)) % 60, + bitrate_dec, bitrate_enc, (gfloat) bitrate_dec / bitrate_enc); } g_print ("\n"); - + return 0; } diff --git a/examples/switch/switcher.c b/examples/switch/switcher.c index d0bc4a67..6296f6ad 100644 --- a/examples/switch/switcher.c +++ b/examples/switch/switcher.c @@ -16,7 +16,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -28,38 +28,36 @@ static GMainLoop *loop = NULL; static void -got_eos (GstElement *pipeline) +got_eos (GstElement * pipeline) { g_main_loop_quit (loop); } static gboolean -idle_iterate (GstElement *pipeline) +idle_iterate (GstElement * pipeline) { gst_bin_iterate (GST_BIN (pipeline)); return (GST_STATE (GST_ELEMENT (pipeline)) == GST_STATE_PLAYING); } static gboolean -switch_timer (GstElement *video_switch) +switch_timer (GstElement * video_switch) { gint nb_sources, active_source; - + g_object_get (G_OBJECT (video_switch), "nb_sources", &nb_sources, NULL); - g_object_get (G_OBJECT (video_switch), "active_source", - &active_source, NULL); - - active_source ++; - + g_object_get (G_OBJECT (video_switch), "active_source", &active_source, NULL); + + active_source++; + if (active_source > nb_sources - 1) active_source = 0; - - g_object_set (G_OBJECT (video_switch), "active_source", - active_source, NULL); - + + g_object_set (G_OBJECT (video_switch), "active_source", active_source, NULL); + g_message ("current number of sources : %d, active source %d", - nb_sources, active_source); - + nb_sources, active_source); + return (GST_STATE (GST_ELEMENT (video_switch)) == GST_STATE_PLAYING); } @@ -72,7 +70,7 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); - + pipeline = gst_pipeline_new ("pipeline"); src1 = gst_element_factory_make ("videotestsrc", "src1"); g_object_set (G_OBJECT (src1), "pattern", 0, NULL); @@ -80,26 +78,25 @@ main (int argc, char *argv[]) g_object_set (G_OBJECT (src2), "pattern", 1, NULL); video_switch = gst_element_factory_make ("switch", "video_switch"); video_sink = gst_element_factory_make ("ximagesink", "video_sink"); - + gst_bin_add_many (GST_BIN (pipeline), src1, src2, video_switch, - video_sink, NULL); - + video_sink, NULL); + gst_element_link (src1, video_switch); gst_element_link (src2, video_switch); gst_element_link (video_switch, video_sink); - - g_signal_connect (G_OBJECT (pipeline), "eos", - G_CALLBACK (got_eos), NULL); + + g_signal_connect (G_OBJECT (pipeline), "eos", G_CALLBACK (got_eos), NULL); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - + g_idle_add ((GSourceFunc) idle_iterate, pipeline); g_timeout_add (2000, (GSourceFunc) switch_timer, video_switch); - + g_main_loop_run (loop); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY); - + /* unref */ gst_object_unref (GST_OBJECT (pipeline)); |