From 92b3b26d6ee76d0d4b488e9e57d3b3424d2649fb Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 18 Dec 2003 09:51:22 +0000 Subject: Merge HEAD from CAPS-ROOT to CAPS-MERGE-3, plus some caps conversion Original commit message from CVS: Merge HEAD from CAPS-ROOT to CAPS-MERGE-3, plus some caps conversion --- examples/gstplay/Makefile.am | 9 +++ examples/gstplay/player.c | 156 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 examples/gstplay/Makefile.am create mode 100644 examples/gstplay/player.c (limited to 'examples/gstplay') diff --git a/examples/gstplay/Makefile.am b/examples/gstplay/Makefile.am new file mode 100644 index 00000000..f80a8bfa --- /dev/null +++ b/examples/gstplay/Makefile.am @@ -0,0 +1,9 @@ + +noinst_PROGRAMS = player + +player_SOURCES = player.c +player_CFLAGS = $(GST_CFLAGS) +player_LDFLAGS = \ + $(GST_LIBS) \ + $(top_builddir)/gst-libs/gst/play/libgstplay-@GST_MAJORMINOR@.la + diff --git a/examples/gstplay/player.c b/examples/gstplay/player.c new file mode 100644 index 00000000..846d58ac --- /dev/null +++ b/examples/gstplay/player.c @@ -0,0 +1,156 @@ +/* GStreamer + * Copyright (C) 2003 Julien Moutte + * + * 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 + +static GMainLoop *loop = NULL; +static gint64 length = 0; + +static void +print_tag (const GstTagList *list, const gchar *tag, gpointer unused) +{ + gint i, count; + + count = gst_tag_list_get_tag_size (list, tag); + + 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)); + } + + if (i == 0) { + g_print ("%15s: %s\n", gst_tag_get_nick (tag), str); + } else { + g_print (" : %s\n", str); + } + + g_free (str); + } +} + +static void +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) +{ + g_message ("time tick %llu", time_nanos); +} + +static void +got_stream_length (GstPlay *play, gint64 length_nanos) +{ + g_message ("got length %llu", length_nanos); + length = length_nanos; +} + +static void +got_video_size (GstPlay *play, gint width, gint height) +{ + g_message ("got video size %d, %d", width, height); +} + +static void +got_eos (GstPlay *play) +{ + g_main_loop_quit (loop); +} + +static gboolean +seek_timer (GstPlay *play) +{ + gst_play_seek_to_time (play, length / 2); + return FALSE; +} + +static gboolean +idle_iterate (GstPlay *play) +{ + gst_bin_iterate (GST_BIN (play)); + return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING); +} + +int +main (int argc, char *argv[]) +{ + GstPlay *play; + GstElement *data_src, *video_sink, *audio_sink, *vis_element; + + /* Initing GStreamer library */ + gst_init (&argc, &argv); + + if (argc != 2) { + g_print ("usage: %s