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/seeking | |
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/seeking')
-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 |
5 files changed, 333 insertions, 330 deletions
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); |