From 2b12546e024ea2044230bdb4b8f15c91885fb277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 25 May 2011 19:03:44 +0100 Subject: [PATCH] seek: add --audiosink and --videosink command line options --- tests/examples/seek/seek.c | 66 +++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 2a2a9d18c8..459ea30739 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -63,24 +63,8 @@ gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a) #define SOURCE "filesrc" -#define ASINK DEFAULT_AUDIOSINK -//#define ASINK "pulsesink" -//#define ASINK "alsasink" -//#define ASINK "osssink" -//#define ASINK "directsoundsink" - -#ifdef G_OS_WIN32 -#define VSINK "directdrawsink" -#else -#define VSINK "xvimagesink" -#endif -//#define VSINK "sdlvideosink" -//#define VSINK "ximagesink" -//#define VSINK "aasink" -//#define VSINK "cacasink" -//#define VSINK "dshowvideosink" -//#define VSINK "sdlvideosink" -//#define VSINK "glimagesink" +static gchar *opt_audiosink_str; /* NULL */ +static gchar *opt_videosink_str; /* NULL */ #define FILL_INTERVAL 100 //#define UPDATE_INTERVAL 500 @@ -232,7 +216,7 @@ make_mod_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("modplug", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -267,7 +251,7 @@ make_dv_pipeline (const gchar * location) demux = gst_element_factory_make_or_warn ("dvdemux", "demuxer"); v_queue = gst_element_factory_make_or_warn ("queue", "v_queue"); decoder = gst_element_factory_make_or_warn ("ffdec_dvvideo", "decoder"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); audiosink = gst_element_factory_make_or_warn ("alsasink", "a_sink"); @@ -308,7 +292,7 @@ make_wav_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("wavparse", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -340,7 +324,7 @@ make_flac_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("flacdec", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -372,7 +356,7 @@ make_sid_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("siddec", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -439,7 +423,7 @@ make_vorbis_pipeline (const gchar * location) demux = gst_element_factory_make_or_warn ("oggdemux", "demux"); decoder = gst_element_factory_make_or_warn ("vorbisdec", "decoder"); convert = gst_element_factory_make_or_warn ("audioconvert", "convert"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); g_object_set (G_OBJECT (audiosink), "sync", TRUE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -486,7 +470,7 @@ make_theora_pipeline (const gchar * location) demux = gst_element_factory_make_or_warn ("oggdemux", "demux"); decoder = gst_element_factory_make_or_warn ("theoradec", "decoder"); convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "convert"); - videosink = gst_element_factory_make_or_warn (VSINK, "sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "sink"); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -544,7 +528,7 @@ make_vorbis_theora_pipeline (const gchar * location) a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); a_decoder = gst_element_factory_make_or_warn ("vorbisdec", "a_dec"); a_convert = gst_element_factory_make_or_warn ("audioconvert", "a_convert"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); gst_bin_add (GST_BIN (pipeline), audio_bin); @@ -570,7 +554,7 @@ make_vorbis_theora_pipeline (const gchar * location) v_convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert"); v_scale = gst_element_factory_make_or_warn ("videoscale", "v_scale"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); gst_bin_add (GST_BIN (pipeline), video_bin); @@ -624,7 +608,7 @@ make_avi_msmpeg4v3_mp3_pipeline (const gchar * location) a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); a_convert = gst_element_factory_make_or_warn ("audioconvert", "a_convert"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); gst_bin_add (GST_BIN (audio_bin), a_queue); gst_bin_add (GST_BIN (audio_bin), a_decoder); @@ -649,7 +633,7 @@ make_avi_msmpeg4v3_mp3_pipeline (const gchar * location) v_decoder = gst_element_factory_make_or_warn ("ffdec_msmpeg4", "v_dec"); v_convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); gst_bin_add (GST_BIN (video_bin), v_queue); gst_bin_add (GST_BIN (video_bin), v_decoder); @@ -690,7 +674,7 @@ make_mp3_pipeline (const gchar * location) parser = gst_element_factory_make_or_warn ("mp3parse", "parse"); decoder = gst_element_factory_make_or_warn ("mad", "dec"); queue = gst_element_factory_make_or_warn ("queue", "queue"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); seekable_elements = g_list_prepend (seekable_elements, audiosink); @@ -739,7 +723,7 @@ make_avi_pipeline (const gchar * location) audio_bin = gst_bin_new ("a_decoder_bin"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); gst_element_link (a_decoder, a_queue); gst_element_link (a_queue, audiosink); @@ -760,7 +744,7 @@ make_avi_pipeline (const gchar * location) video_bin = gst_bin_new ("v_decoder_bin"); v_decoder = gst_element_factory_make_or_warn ("ffmpegdecall", "v_dec"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); v_queue = gst_element_factory_make_or_warn ("queue", "v_queue"); gst_element_link (v_decoder, v_queue); gst_element_link (v_queue, videosink); @@ -808,7 +792,7 @@ make_mpeg_pipeline (const gchar * location) audio_bin = gst_bin_new ("a_decoder_bin"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); gst_bin_add (GST_BIN (audio_bin), a_decoder); gst_bin_add (GST_BIN (audio_bin), a_queue); gst_bin_add (GST_BIN (audio_bin), audiosink); @@ -829,7 +813,7 @@ make_mpeg_pipeline (const gchar * location) v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec"); v_queue = gst_element_factory_make_or_warn ("queue", "v_queue"); v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); gst_bin_add (GST_BIN (video_bin), v_decoder); gst_bin_add (GST_BIN (video_bin), v_queue); @@ -885,7 +869,7 @@ make_mpegnt_pipeline (const gchar * location) audio_bin = gst_bin_new ("a_decoder_bin"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL); g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); gst_element_link (a_decoder, a_queue); @@ -907,7 +891,7 @@ make_mpegnt_pipeline (const gchar * location) 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 ("ffmpegcolorspace", "v_filter"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "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); @@ -2656,12 +2640,16 @@ main (int argc, char **argv) GtkWidget *scrub_checkbox, *play_scrub_checkbox; GtkWidget *rate_label, *volume_label; GOptionEntry options[] = { + {"audiosink", '\0', 0, G_OPTION_ARG_STRING, &opt_audiosink_str, + "audio sink to use (default: " DEFAULT_AUDIOSINK ")", NULL}, {"stats", 's', 0, G_OPTION_ARG_NONE, &stats, "Show pad stats", NULL}, {"elem", 'e', 0, G_OPTION_ARG_NONE, &elem_seek, "Seek on elements instead of pads", NULL}, {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Verbose properties", NULL}, + {"videosink", '\0', 0, G_OPTION_ARG_STRING, &opt_videosink_str, + "video sink to use (default: " DEFAULT_VIDEOSINK ")", NULL}, {NULL} }; GOptionContext *ctx; @@ -2680,6 +2668,12 @@ main (int argc, char **argv) exit (1); } + if (opt_audiosink_str == NULL) + opt_audiosink_str = g_strdup (DEFAULT_AUDIOSINK); + + if (opt_videosink_str == NULL) + opt_videosink_str = g_strdup (DEFAULT_VIDEOSINK); + GST_DEBUG_CATEGORY_INIT (seek_debug, "seek", 0, "seek example"); if (argc != 3) {