From 68a093a6aec079c2d13171f765bd860f023fd2f4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 29 Sep 2005 14:12:18 +0000 Subject: [PATCH] ext/vorbis/vorbisdec.c: We use fixed caps. Original commit message from CVS: * ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init): We use fixed caps. * gst/playback/Makefile.am: * gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding), (dump_element_stats), (main): Added example stream introspection code. --- ChangeLog | 10 ++++ ext/vorbis/vorbisdec.c | 1 + gst/playback/Makefile.am | 5 +- gst/playback/test5.c | 123 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 gst/playback/test5.c diff --git a/ChangeLog b/ChangeLog index 0a397b040a..78de239f37 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-09-29 Wim Taymans + + * ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init): + We use fixed caps. + + * gst/playback/Makefile.am: + * gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding), + (dump_element_stats), (main): + Added example stream introspection code. + 2005-09-28 Stefan Kost * gst/adder/gstadder.c: (gst_adder_collected): diff --git a/ext/vorbis/vorbisdec.c b/ext/vorbis/vorbisdec.c index 747ae4cb7e..c146a7800e 100644 --- a/ext/vorbis/vorbisdec.c +++ b/ext/vorbis/vorbisdec.c @@ -175,6 +175,7 @@ gst_vorbis_dec_init (GstVorbisDec * dec, GstVorbisDecClass * g_class) gst_pad_set_event_function (dec->srcpad, vorbis_dec_src_event); gst_pad_set_query_type_function (dec->srcpad, vorbis_get_query_types); gst_pad_set_query_function (dec->srcpad, vorbis_dec_src_query); + gst_pad_use_fixed_caps (dec->srcpad); gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad); dec->queued = NULL; diff --git a/gst/playback/Makefile.am b/gst/playback/Makefile.am index e3efc6f040..28cdc0fb4d 100644 --- a/gst/playback/Makefile.am +++ b/gst/playback/Makefile.am @@ -31,7 +31,7 @@ noinst_HEADERS = \ gststreaminfo.h \ gststreamselector.h -noinst_PROGRAMS = test decodetest test2 test3 test4 +noinst_PROGRAMS = test decodetest test2 test3 test4 test5 test_LDADD = $(GST_LIBS) test_CFLAGS = $(GST_CFLAGS) @@ -45,6 +45,9 @@ test3_CFLAGS = $(GST_CFLAGS) test4_LDADD = $(GST_LIBS) test4_CFLAGS = $(GST_CFLAGS) +test5_LDADD = $(GST_LIBS) +test5_CFLAGS = $(GST_CFLAGS) + decodetest_LDADD = $(GST_LIBS) decodetest_CFLAGS = $(GST_CFLAGS) diff --git a/gst/playback/test5.c b/gst/playback/test5.c new file mode 100644 index 0000000000..f5dc64f736 --- /dev/null +++ b/gst/playback/test5.c @@ -0,0 +1,123 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#include +#include + +static GMainLoop *loop; + +static void +new_pad (GstElement * element, GstPad * pad, gboolean last, GstElement * sink) +{ + g_debug ("New pad..."); +} + +static void +no_more_pads (GstElement * element) +{ + g_debug ("No more pads..."); + g_main_loop_quit (loop); +} + +static gboolean +start_finding (GstElement * pipeline) +{ + GstStateChangeReturn res; + + g_print ("finding caps...\n"); + res = gst_element_set_state (pipeline, GST_STATE_PAUSED); + if (res == GST_STATE_CHANGE_FAILURE) { + g_print ("could not pause\n"); + exit (-1); + } + return FALSE; +} + +static void +dump_element_stats (GstElement * element) +{ + GstIterator *it; + gpointer data; + + it = gst_element_iterate_src_pads (element); + while (gst_iterator_next (it, &data) == GST_ITERATOR_OK) { + GstPad *pad = GST_PAD (data); + GstCaps *caps; + gchar *str; + GstQuery *query; + + g_print ("stream %s:\n", GST_OBJECT_NAME (pad)); + + caps = gst_pad_get_caps (pad); + str = gst_caps_to_string (caps); + g_print (" caps: %s\n", str); + g_free (str); + + query = gst_query_new_position (GST_FORMAT_TIME); + if (gst_pad_query (pad, query)) { + gint64 duration; + + gst_query_parse_position (query, NULL, NULL, &duration); + + g_print (" duration: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (duration)); + } + gst_query_unref (query); + + gst_object_unref (pad); + } + gst_iterator_free (it); +} + +gint +main (gint argc, gchar * argv[]) +{ + GstElement *pipeline, *filesrc, *decodebin; + + gst_init (&argc, &argv); + + pipeline = gst_pipeline_new ("pipeline"); + + filesrc = gst_element_factory_make ("filesrc", "filesrc"); + g_assert (filesrc); + + decodebin = gst_element_factory_make ("decodebin", "decodebin"); + g_assert (decodebin); + + g_signal_connect (G_OBJECT (decodebin), "new-decoded-pad", + G_CALLBACK (new_pad), NULL); + g_signal_connect (G_OBJECT (decodebin), "no-more-pads", + G_CALLBACK (no_more_pads), NULL); + + gst_bin_add_many (GST_BIN (pipeline), filesrc, decodebin, NULL); + gst_element_link (filesrc, decodebin); + + if (argc < 2) { + g_print ("usage: %s \n", argv[0]); + exit (-1); + } + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + + /* event based programming approach */ + loop = g_main_loop_new (NULL, TRUE); + g_idle_add ((GSourceFunc) start_finding, pipeline); + g_main_loop_run (loop); + + dump_element_stats (decodebin); + + return 0; +}