summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am4
-rw-r--r--examples/gstplay/Makefile.am9
-rw-r--r--examples/gstplay/player.c156
-rw-r--r--examples/seeking/vorbisfile.c77
4 files changed, 180 insertions, 66 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 6c582d9e..8c10c89e 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -10,5 +10,5 @@ else
GTK_SUBDIRS=
endif
-SUBDIRS=$(GTK_SUBDIRS)
-DIST_SUBDIRS=capsfilter dynparams seeking indexing
+SUBDIRS=$(GTK_SUBDIRS) gstplay
+DIST_SUBDIRS=capsfilter dynparams seeking indexing 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 <julien@moutte.net>
+ *
+ * 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 <gst/play/gstplay.h>
+
+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 <video filename>\n", argv[0]);
+ exit (-1);
+ }
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ /* Creating the GstPlay object */
+ play = gst_play_new ();
+
+ /* Getting default audio and video plugins from GConf */
+ audio_sink = gst_element_factory_make ("osssink", "audio_sink");
+ video_sink = gst_element_factory_make ("xvimagesink", "video_sink");
+ vis_element = gst_element_factory_make ("goom", "vis_element");
+ data_src = gst_element_factory_make ("gnomevfssrc", "source");
+
+ /* Let's send them to GstPlay object */
+ gst_play_set_audio_sink (play, audio_sink);
+ gst_play_set_video_sink (play, video_sink);
+ gst_play_set_data_src (play, data_src);
+ gst_play_set_visualization (play, vis_element);
+
+ /* Setting location we want to play */
+ gst_play_set_location (play, argv[1]);
+
+ /* gst_xml_write_file (GST_ELEMENT (play), stdout); */
+
+ g_signal_connect (G_OBJECT (play), "time_tick",
+ G_CALLBACK (got_time_tick), NULL);
+ g_signal_connect (G_OBJECT (play), "stream_length",
+ G_CALLBACK (got_stream_length), NULL);
+ g_signal_connect (G_OBJECT (play), "have_video_size",
+ G_CALLBACK (got_video_size), NULL);
+ g_signal_connect (G_OBJECT (play), "found_tag",
+ G_CALLBACK (got_found_tag), 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);
+
+ g_idle_add ((GSourceFunc) idle_iterate, play);
+ g_timeout_add (20000, (GSourceFunc) seek_timer, play);
+
+ g_main_loop_run (loop);
+
+ /* unref */
+ gst_object_unref (GST_OBJECT (play));
+
+ exit (0);
+}
diff --git a/examples/seeking/vorbisfile.c b/examples/seeking/vorbisfile.c
index 29fc18cf..f191aa7b 100644
--- a/examples/seeking/vorbisfile.c
+++ b/examples/seeking/vorbisfile.c
@@ -12,78 +12,27 @@ struct probe_context {
gint total_ls;
- GstCaps *metadata;
- GstCaps *streaminfo;
- GstCaps *caps;
+ GstCaps2 *metadata;
+ GstCaps2 *streaminfo;
+ GstCaps2 *caps;
};
static void
-print_caps (GstCaps *caps)
+print_caps (GstCaps2 *caps)
{
- if (caps == NULL) return;
- if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") ||
- !strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo"))
- {
- GstProps *props = caps->properties;
- GList *walk;
- /* ugly hack, but ok for now. If needed, fix by individual strcmp */
- g_print (" %s:\n", gst_caps_get_mime (caps) + 18);
- if (props == NULL) {
- g_print (" none\n");
- return;
- }
- walk = props->properties;
-
- while (walk) {
- GstPropsEntry *entry = (GstPropsEntry *) walk->data;
- const gchar *name;
- const gchar *str_val;
- gint int_val;
- GstPropsType type;
-
- name = gst_props_entry_get_name (entry);
- type = gst_props_entry_get_props_type (entry);
- switch (type) {
- case GST_PROPS_STRING_TYPE:
- gst_props_entry_get_string (entry, &str_val);
- g_print (" %s='%s'\n", name, str_val);
- break;
- case GST_PROPS_INT_TYPE:
- gst_props_entry_get_int (entry, &int_val);
- g_print (" %s=%d\n", name, int_val);
- break;
- default:
- break;
- }
- walk = g_list_next (walk);
- }
- }
- else {
- g_print (" unkown caps type\n");
- }
+ char *s;
+ s = gst_caps2_to_string (caps);
+ g_print(" %s\n", s);
+ g_free (s);
}
static void
-print_format (GstCaps *caps)
+print_format (GstCaps2 *caps)
{
- g_print (" format:\n");
- if (!caps || caps->properties == NULL) {
- g_print (" unkown\n");
- return;
- }
- if (!strcmp (gst_caps_get_mime (caps), "audio/raw")) {
- gint channels;
- gint rate;
-
- gst_caps_get_int (caps, "channels", &channels);
- gst_caps_get_int (caps, "rate", &rate);
-
- g_print (" channels: %d\n", channels);
- g_print (" rate: %d\n", rate);
- }
- else {
- g_print (" unkown format\n");
- }
+ char *s;
+ s = gst_caps2_to_string (caps);
+ g_print(" format: %s\n", s);
+ g_free (s);
}
static void