summaryrefslogtreecommitdiff
path: root/tests/examples
diff options
context:
space:
mode:
Diffstat (limited to 'tests/examples')
-rw-r--r--tests/examples/Makefile.am13
-rw-r--r--tests/examples/app/.gitignore6
-rw-r--r--tests/examples/app/Makefile.am32
-rw-r--r--tests/examples/app/appsink-src.c192
-rw-r--r--tests/examples/app/appsrc-ra.c229
-rw-r--r--tests/examples/app/appsrc-seekable.c234
-rw-r--r--tests/examples/app/appsrc-stream.c254
-rw-r--r--tests/examples/app/appsrc-stream2.c224
-rw-r--r--tests/examples/app/appsrc_ex.c95
-rw-r--r--tests/examples/dynamic/.gitignore5
-rw-r--r--tests/examples/dynamic/Makefile.am21
-rw-r--r--tests/examples/dynamic/addstream.c253
-rw-r--r--tests/examples/dynamic/codec-select.c298
-rw-r--r--tests/examples/dynamic/sprinkle.c264
-rw-r--r--tests/examples/dynamic/sprinkle2.c288
-rw-r--r--tests/examples/dynamic/sprinkle3.c301
-rw-r--r--tests/examples/gio/.gitignore1
-rw-r--r--tests/examples/gio/Makefile.am8
-rw-r--r--tests/examples/gio/giosrc-mounting.c126
-rw-r--r--tests/examples/overlay/.gitignore5
-rw-r--r--tests/examples/overlay/Makefile.am47
-rw-r--r--tests/examples/overlay/gtk-xoverlay.c147
-rw-r--r--tests/examples/overlay/qt-xoverlay.cpp130
-rw-r--r--tests/examples/overlay/qtgv-xoverlay.cpp128
-rw-r--r--tests/examples/overlay/qtgv-xoverlay.h45
-rw-r--r--tests/examples/seek/.gitignore4
-rw-r--r--tests/examples/seek/Makefile.am13
-rw-r--r--tests/examples/seek/scrubby.c570
-rw-r--r--tests/examples/seek/seek.c2945
-rw-r--r--tests/examples/seek/stepping.c124
-rw-r--r--tests/examples/seek/stepping2.c142
-rw-r--r--tests/examples/snapshot/.gitignore2
-rw-r--r--tests/examples/snapshot/Makefile.am10
-rw-r--r--tests/examples/snapshot/snapshot.c151
-rw-r--r--tests/examples/v4l/.gitignore1
-rw-r--r--tests/examples/v4l/Makefile.am10
-rw-r--r--tests/examples/v4l/probe.c85
-rw-r--r--tests/examples/volume/.gitignore1
-rw-r--r--tests/examples/volume/Makefile.am6
-rw-r--r--tests/examples/volume/volume.c172
40 files changed, 0 insertions, 7582 deletions
diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am
deleted file mode 100644
index 7c4e1f8a..00000000
--- a/tests/examples/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-if HAVE_FT2
-FT2_SUBDIRS = seek snapshot
-else
-FT2_SUBDIRS =
-endif
-
-if USE_GIO
-GIO_SUBDIRS = gio
-endif
-
-SUBDIRS = app $(FT2_SUBDIRS) $(GIO_SUBDIRS) volume dynamic v4l overlay
-
-DIST_SUBDIRS = app seek volume dynamic snapshot gio v4l overlay
diff --git a/tests/examples/app/.gitignore b/tests/examples/app/.gitignore
deleted file mode 100644
index 8a2c7615..00000000
--- a/tests/examples/app/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-appsrc_ex
-appsrc-ra
-appsrc-seekable
-appsrc-stream
-appsrc-stream2
-appsink-src
diff --git a/tests/examples/app/Makefile.am b/tests/examples/app/Makefile.am
deleted file mode 100644
index 7d721b4c..00000000
--- a/tests/examples/app/Makefile.am
+++ /dev/null
@@ -1,32 +0,0 @@
-
-noinst_PROGRAMS = appsrc_ex appsrc-stream appsrc-stream2 appsrc-ra \
- appsrc-seekable appsink-src
-
-appsrc_ex_SOURCES = appsrc_ex.c
-appsrc_ex_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-appsrc_ex_LDFLAGS = \
- $(top_builddir)/gst-libs/gst/app/libgstapp-@GST_MAJORMINOR@.la \
- $(GST_LIBS)
-
-appsrc_stream_SOURCES = appsrc-stream.c
-appsrc_stream_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-appsrc_stream_LDFLAGS = $(GST_LIBS)
-
-appsrc_stream2_SOURCES = appsrc-stream2.c
-appsrc_stream2_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-appsrc_stream2_LDFLAGS = $(GST_LIBS)
-
-appsrc_ra_SOURCES = appsrc-ra.c
-appsrc_ra_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-appsrc_ra_LDFLAGS = $(GST_LIBS)
-
-appsrc_seekable_SOURCES = appsrc-seekable.c
-appsrc_seekable_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-appsrc_seekable_LDFLAGS = $(GST_LIBS)
-
-appsink_src_SOURCES = appsink-src.c
-appsink_src_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-appsink_src_LDFLAGS = \
- $(top_builddir)/gst-libs/gst/app/libgstapp-@GST_MAJORMINOR@.la \
- $(GST_LIBS)
-
diff --git a/tests/examples/app/appsink-src.c b/tests/examples/app/appsink-src.c
deleted file mode 100644
index a92dfb51..00000000
--- a/tests/examples/app/appsink-src.c
+++ /dev/null
@@ -1,192 +0,0 @@
-#include <gst/gst.h>
-
-#include <string.h>
-
-#include <gst/app/gstappsrc.h>
-#include <gst/app/gstappsink.h>
-#include <gst/app/gstappbuffer.h>
-
-/* these are the caps we are going to pass through the appsink and appsrc */
-const gchar *audio_caps =
- "audio/x-raw-int,channels=1,rate=8000,signed=(boolean)true,width=16,depth=16,endianness=1234";
-
-typedef struct
-{
- GMainLoop *loop;
- GstElement *source;
- GstElement *sink;
-} ProgramData;
-
-/* called when the appsink notifies us that there is a new buffer ready for
- * processing */
-static void
-on_new_buffer_from_source (GstElement * elt, ProgramData * data)
-{
- guint size;
- gpointer raw_buffer;
- GstBuffer *app_buffer, *buffer;
- GstElement *source;
-
- /* get the buffer from appsink */
- buffer = gst_app_sink_pull_buffer (GST_APP_SINK (elt));
-
- /* turn it into an app buffer, it's not really needed, we could simply push
- * the retrieved buffer from appsink into appsrc just fine. */
- size = GST_BUFFER_SIZE (buffer);
- g_print ("Pushing a buffer of size %d\n", size);
- raw_buffer = g_malloc0 (size);
- memcpy (raw_buffer, GST_BUFFER_DATA (buffer), size);
- app_buffer = gst_app_buffer_new (raw_buffer, size, g_free, raw_buffer);
-
- /* newer basesrc will set caps for use automatically but it does not really
- * hurt to set it on the buffer again */
- gst_buffer_set_caps (app_buffer, GST_BUFFER_CAPS (buffer));
-
- /* we don't need the appsink buffer anymore */
- gst_buffer_unref (buffer);
-
- /* get source an push new buffer */
- source = gst_bin_get_by_name (GST_BIN (data->sink), "testsource");
- gst_app_src_push_buffer (GST_APP_SRC (source), app_buffer);
-}
-
-/* called when we get a GstMessage from the source pipeline when we get EOS, we
- * notify the appsrc of it. */
-static gboolean
-on_source_message (GstBus * bus, GstMessage * message, ProgramData * data)
-{
- GstElement *source;
-
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- g_print ("The source got dry\n");
- source = gst_bin_get_by_name (GST_BIN (data->sink), "testsource");
- gst_app_src_end_of_stream (GST_APP_SRC (source));
- break;
- case GST_MESSAGE_ERROR:
- g_print ("Received error\n");
- g_main_loop_quit (data->loop);
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-/* called when we get a GstMessage from the sink pipeline when we get EOS, we
- * exit the mainloop and this testapp. */
-static gboolean
-on_sink_message (GstBus * bus, GstMessage * message, ProgramData * data)
-{
- /* nil */
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- g_print ("Finished playback\n");
- g_main_loop_quit (data->loop);
- break;
- case GST_MESSAGE_ERROR:
- g_print ("Received error\n");
- g_main_loop_quit (data->loop);
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- gchar *filename = NULL;
- ProgramData *data = NULL;
- gchar *string = NULL;
- GstBus *bus = NULL;
- GstElement *testsink = NULL;
- GstElement *testsource = NULL;
-
- gst_init (&argc, &argv);
-
- if (argc == 2)
- filename = g_strdup (argv[1]);
- else
- filename = g_strdup ("/usr/share/sounds/ekiga/ring.wav");
-
- data = g_new0 (ProgramData, 1);
-
- data->loop = g_main_loop_new (NULL, FALSE);
-
- /* setting up source pipeline, we read from a file and convert to our desired
- * caps. */
- string =
- g_strdup_printf
- ("filesrc location=\"%s\" ! wavparse ! audioconvert ! audioresample ! appsink caps=\"%s\" name=testsink",
- filename, audio_caps);
- g_free (filename);
- data->source = gst_parse_launch (string, NULL);
- g_free (string);
-
- if (data->source == NULL) {
- g_print ("Bad source\n");
- return -1;
- }
-
- /* to be notified of messages from this pipeline, mostly EOS */
- bus = gst_element_get_bus (data->source);
- gst_bus_add_watch (bus, (GstBusFunc) on_source_message, data);
- gst_object_unref (bus);
-
- /* we use appsink in push mode, it sends us a signal when data is available
- * and we pull out the data in the signal callback. We want the appsink to
- * push as fast as it can, hence the sync=false */
- testsink = gst_bin_get_by_name (GST_BIN (data->source), "testsink");
- g_object_set (G_OBJECT (testsink), "emit-signals", TRUE, "sync", FALSE, NULL);
- g_signal_connect (testsink, "new-buffer",
- G_CALLBACK (on_new_buffer_from_source), data);
- gst_object_unref (testsink);
-
- /* setting up sink pipeline, we push audio data into this pipeline that will
- * then play it back using the default audio sink. We have no blocking
- * behaviour on the src which means that we will push the entire file into
- * memory. */
- string =
- g_strdup_printf ("appsrc name=testsource caps=\"%s\" ! autoaudiosink",
- audio_caps);
- data->sink = gst_parse_launch (string, NULL);
- g_free (string);
-
- if (data->sink == NULL) {
- g_print ("Bad sink\n");
- return -1;
- }
-
- testsource = gst_bin_get_by_name (GST_BIN (data->sink), "testsource");
- /* configure for time-based format */
- g_object_set (testsource, "format", GST_FORMAT_TIME, NULL);
- /* uncomment the next line to block when appsrc has buffered enough */
- /* g_object_set (testsource, "block", TRUE, NULL); */
- gst_object_unref (testsource);
-
- bus = gst_element_get_bus (data->sink);
- gst_bus_add_watch (bus, (GstBusFunc) on_sink_message, data);
- gst_object_unref (bus);
-
- /* launching things */
- gst_element_set_state (data->sink, GST_STATE_PLAYING);
- gst_element_set_state (data->source, GST_STATE_PLAYING);
-
- /* let's run !, this loop will quit when the sink pipeline goes EOS or when an
- * error occurs in the source or sink pipelines. */
- g_print ("Let's run!\n");
- g_main_loop_run (data->loop);
- g_print ("Going out\n");
-
- gst_element_set_state (data->source, GST_STATE_NULL);
- gst_element_set_state (data->sink, GST_STATE_NULL);
-
- gst_object_unref (data->source);
- gst_object_unref (data->sink);
- g_main_loop_unref (data->loop);
- g_free (data);
-
- return 0;
-}
diff --git a/tests/examples/app/appsrc-ra.c b/tests/examples/app/appsrc-ra.c
deleted file mode 100644
index 46b19cae..00000000
--- a/tests/examples/app/appsrc-ra.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/* GStreamer
- *
- * appsrc-ra.c: example for using appsrc in random-access mode.
- *
- * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-/* FIXME: remove once we depend on GLib >= 2.22 */
-#if !GLIB_CHECK_VERSION (2, 22, 0)
-#define g_mapped_file_unref g_mapped_file_free
-#endif
-
-GST_DEBUG_CATEGORY (appsrc_playbin_debug);
-#define GST_CAT_DEFAULT appsrc_playbin_debug
-
-/*
- * an example application of using appsrc in random-access mode. When the
- * appsrc requests data with the need-data signal, we retrieve a buffer of the
- * requested size and push it to appsrc.
- *
- * This is a good example how one would deal with a local file resource.
- *
- * Appsrc in random-access mode needs seeking support and we must thus connect
- * to the seek signal to perform any seeks when requested.
- *
- * In random-access mode we must set the size of the source material.
- */
-typedef struct _App App;
-
-struct _App
-{
- GstElement *playbin;
- GstElement *appsrc;
-
- GMainLoop *loop;
-
- GMappedFile *file;
- guint8 *data;
- gsize length;
- guint64 offset;
-};
-
-App s_app;
-
-/* This method is called by the need-data signal callback, we feed data into the
- * appsrc with the requested size.
- */
-static void
-feed_data (GstElement * appsrc, guint size, App * app)
-{
- GstBuffer *buffer;
- GstFlowReturn ret;
-
- buffer = gst_buffer_new ();
-
- if (app->offset >= app->length) {
- /* we are EOS, send end-of-stream */
- g_signal_emit_by_name (app->appsrc, "end-of-stream", &ret);
- return;
- }
-
- /* read the amount of data, we are allowed to return less if we are EOS */
- if (app->offset + size > app->length)
- size = app->length - app->offset;
-
- GST_BUFFER_DATA (buffer) = app->data + app->offset;
- GST_BUFFER_SIZE (buffer) = size;
- /* we need to set an offset for random access */
- GST_BUFFER_OFFSET (buffer) = app->offset;
- GST_BUFFER_OFFSET_END (buffer) = app->offset + size;
-
- GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
- app->offset, size);
- g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
- gst_buffer_unref (buffer);
-
- app->offset += size;
-
- return;
-}
-
-/* called when appsrc wants us to return data from a new position with the next
- * call to push-buffer. */
-static gboolean
-seek_data (GstElement * appsrc, guint64 position, App * app)
-{
- GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position);
- app->offset = position;
-
- return TRUE;
-}
-
-/* this callback is called when playbin2 has constructed a source object to read
- * from. Since we provided the appsrc:// uri to playbin2, this will be the
- * appsrc that we must handle. We set up some signals to push data into appsrc
- * and one to perform a seek. */
-static void
-found_source (GObject * object, GObject * orig, GParamSpec * pspec, App * app)
-{
- /* get a handle to the appsrc */
- g_object_get (orig, pspec->name, &app->appsrc, NULL);
-
- GST_DEBUG ("got appsrc %p", app->appsrc);
-
- /* we can set the length in appsrc. This allows some elements to estimate the
- * total duration of the stream. It's a good idea to set the property when you
- * can but it's not required. */
- g_object_set (app->appsrc, "size", (gint64) app->length, NULL);
- gst_util_set_object_arg (G_OBJECT (app->appsrc), "stream-type",
- "random-access");
-
- /* configure the appsrc, we will push a buffer to appsrc when it needs more
- * data */
- g_signal_connect (app->appsrc, "need-data", G_CALLBACK (feed_data), app);
- g_signal_connect (app->appsrc, "seek-data", G_CALLBACK (seek_data), app);
-}
-
-static gboolean
-bus_message (GstBus * bus, GstMessage * message, App * app)
-{
- GST_DEBUG ("got message %s",
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
-
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_ERROR:
- g_error ("received error");
- g_main_loop_quit (app->loop);
- break;
- case GST_MESSAGE_EOS:
- g_main_loop_quit (app->loop);
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- App *app = &s_app;
- GError *error = NULL;
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- GST_DEBUG_CATEGORY_INIT (appsrc_playbin_debug, "appsrc-playbin", 0,
- "appsrc playbin example");
-
- if (argc < 2) {
- g_print ("usage: %s <filename>\n", argv[0]);
- return -1;
- }
-
- /* try to open the file as an mmapped file */
- app->file = g_mapped_file_new (argv[1], FALSE, &error);
- if (error) {
- g_print ("failed to open file: %s\n", error->message);
- g_error_free (error);
- return -2;
- }
- /* get some vitals, this will be used to read data from the mmapped file and
- * feed it to appsrc. */
- app->length = g_mapped_file_get_length (app->file);
- app->data = (guint8 *) g_mapped_file_get_contents (app->file);
- app->offset = 0;
-
- /* create a mainloop to get messages */
- app->loop = g_main_loop_new (NULL, TRUE);
-
- app->playbin = gst_element_factory_make ("playbin2", NULL);
- g_assert (app->playbin);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));
-
- /* add watch for messages */
- gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
-
- /* set to read from appsrc */
- g_object_set (app->playbin, "uri", "appsrc://", NULL);
-
- /* get notification when the source is created so that we get a handle to it
- * and can configure it */
- g_signal_connect (app->playbin, "deep-notify::source",
- (GCallback) found_source, app);
-
- /* go to playing and wait in a mainloop. */
- gst_element_set_state (app->playbin, GST_STATE_PLAYING);
-
- /* this mainloop is stopped when we receive an error or EOS */
- g_main_loop_run (app->loop);
-
- GST_DEBUG ("stopping");
-
- gst_element_set_state (app->playbin, GST_STATE_NULL);
-
- /* free the file */
- g_mapped_file_unref (app->file);
-
- gst_object_unref (bus);
- g_main_loop_unref (app->loop);
-
- return 0;
-}
diff --git a/tests/examples/app/appsrc-seekable.c b/tests/examples/app/appsrc-seekable.c
deleted file mode 100644
index adff5bb9..00000000
--- a/tests/examples/app/appsrc-seekable.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/* GStreamer
- *
- * appsrc-seekable.c: example for using appsrc in seekable mode.
- *
- * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-/* FIXME: remove once we depend on GLib >= 2.22 */
-#if !GLIB_CHECK_VERSION (2, 22, 0)
-#define g_mapped_file_unref g_mapped_file_free
-#endif
-
-GST_DEBUG_CATEGORY (appsrc_playbin_debug);
-#define GST_CAT_DEFAULT appsrc_playbin_debug
-
-/*
- * an example application of using appsrc in seekable mode. When the
- * appsrc requests data with the need-data signal, we retrieve a buffer and
- * push it to appsrc. We can also use the method as demonstrated in
- * appsrc-stream.c, ie. pushing buffers when we can.
- *
- * This is a good example how one would deal with a remote http server that
- * supports range requests.
- *
- * Appsrc in seekable mode needs seeking support and we must thus connect
- * to the seek signal to perform any seeks when requested.
- *
- * In seekable mode we should set the size of the source material.
- */
-typedef struct _App App;
-
-struct _App
-{
- GstElement *playbin;
- GstElement *appsrc;
-
- GMainLoop *loop;
-
- GMappedFile *file;
- guint8 *data;
- gsize length;
- guint64 offset;
-};
-
-App s_app;
-
-#define CHUNK_SIZE 4096
-
-/* This method is called by the need-data signal callback, we feed data into the
- * appsrc with an arbitrary size.
- */
-static void
-feed_data (GstElement * appsrc, guint size, App * app)
-{
- GstBuffer *buffer;
- guint len;
- GstFlowReturn ret;
-
- buffer = gst_buffer_new ();
-
- if (app->offset >= app->length) {
- /* we are EOS, send end-of-stream */
- g_signal_emit_by_name (app->appsrc, "end-of-stream", &ret);
- return;
- }
-
- /* read any amount of data, we are allowed to return less if we are EOS */
- len = CHUNK_SIZE;
- if (app->offset + len > app->length)
- len = app->length - app->offset;
-
- GST_BUFFER_DATA (buffer) = app->data + app->offset;
- GST_BUFFER_SIZE (buffer) = len;
-
- GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
- app->offset, len);
- g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
- gst_buffer_unref (buffer);
-
- app->offset += len;
-
- return;
-}
-
-/* called when appsrc wants us to return data from a new position with the next
- * call to push-buffer. */
-static gboolean
-seek_data (GstElement * appsrc, guint64 position, App * app)
-{
- GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position);
- app->offset = position;
-
- return TRUE;
-}
-
-/* this callback is called when playbin2 has constructed a source object to read
- * from. Since we provided the appsrc:// uri to playbin2, this will be the
- * appsrc that we must handle. We set up some signals to push data into appsrc
- * and one to perform a seek. */
-static void
-found_source (GObject * object, GObject * orig, GParamSpec * pspec, App * app)
-{
- /* get a handle to the appsrc */
- g_object_get (orig, pspec->name, &app->appsrc, NULL);
-
- GST_DEBUG ("got appsrc %p", app->appsrc);
-
- /* we can set the length in appsrc. This allows some elements to estimate the
- * total duration of the stream. It's a good idea to set the property when you
- * can but it's not required. */
- g_object_set (app->appsrc, "size", (gint64) app->length, NULL);
- /* we are seekable in push mode, this means that the element usually pushes
- * out buffers of an undefined size and that seeks happen only occasionally
- * and only by request of the user. */
- gst_util_set_object_arg (G_OBJECT (app->appsrc), "stream-type", "seekable");
-
- /* configure the appsrc, we will push a buffer to appsrc when it needs more
- * data */
- g_signal_connect (app->appsrc, "need-data", G_CALLBACK (feed_data), app);
- g_signal_connect (app->appsrc, "seek-data", G_CALLBACK (seek_data), app);
-}
-
-static gboolean
-bus_message (GstBus * bus, GstMessage * message, App * app)
-{
- GST_DEBUG ("got message %s",
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
-
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_ERROR:
- g_error ("received error");
- g_main_loop_quit (app->loop);
- break;
- case GST_MESSAGE_EOS:
- g_main_loop_quit (app->loop);
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- App *app = &s_app;
- GError *error = NULL;
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- GST_DEBUG_CATEGORY_INIT (appsrc_playbin_debug, "appsrc-playbin", 0,
- "appsrc playbin example");
-
- if (argc < 2) {
- g_print ("usage: %s <filename>\n", argv[0]);
- return -1;
- }
-
- /* try to open the file as an mmapped file */
- app->file = g_mapped_file_new (argv[1], FALSE, &error);
- if (error) {
- g_print ("failed to open file: %s\n", error->message);
- g_error_free (error);
- return -2;
- }
- /* get some vitals, this will be used to read data from the mmapped file and
- * feed it to appsrc. */
- app->length = g_mapped_file_get_length (app->file);
- app->data = (guint8 *) g_mapped_file_get_contents (app->file);
- app->offset = 0;
-
- /* create a mainloop to get messages */
- app->loop = g_main_loop_new (NULL, TRUE);
-
- app->playbin = gst_element_factory_make ("playbin2", NULL);
- g_assert (app->playbin);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));
-
- /* add watch for messages */
- gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
-
- /* set to read from appsrc */
- g_object_set (app->playbin, "uri", "appsrc://", NULL);
-
- /* get notification when the source is created so that we get a handle to it
- * and can configure it */
- g_signal_connect (app->playbin, "deep-notify::source",
- (GCallback) found_source, app);
-
- /* go to playing and wait in a mainloop. */
- gst_element_set_state (app->playbin, GST_STATE_PLAYING);
-
- /* this mainloop is stopped when we receive an error or EOS */
- g_main_loop_run (app->loop);
-
- GST_DEBUG ("stopping");
-
- gst_element_set_state (app->playbin, GST_STATE_NULL);
-
- /* free the file */
- g_mapped_file_unref (app->file);
-
- gst_object_unref (bus);
- g_main_loop_unref (app->loop);
-
- return 0;
-}
diff --git a/tests/examples/app/appsrc-stream.c b/tests/examples/app/appsrc-stream.c
deleted file mode 100644
index ea3286f2..00000000
--- a/tests/examples/app/appsrc-stream.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* GStreamer
- *
- * appsrc-stream.c: example for using appsrc in streaming mode.
- *
- * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-/* FIXME: remove once we depend on GLib >= 2.22 */
-#if !GLIB_CHECK_VERSION (2, 22, 0)
-#define g_mapped_file_unref g_mapped_file_free
-#endif
-
-GST_DEBUG_CATEGORY (appsrc_playbin_debug);
-#define GST_CAT_DEFAULT appsrc_playbin_debug
-
-/*
- * an example application of using appsrc in streaming push mode. We simply push
- * buffers into appsrc. The size of the buffers we push can be any size we
- * choose.
- *
- * This example is very close to how one would deal with a streaming webserver
- * that does not support range requests or does not report the total file size.
- *
- * Some optimisations are done so that we don't push too much data. We connect
- * to the need-data and enough-data signals to start/stop sending buffers.
- *
- * Appsrc in streaming mode (the default) does not support seeking so we don't
- * have to handle any seek callbacks.
- *
- * Some formats are able to estimate the duration of the media file based on the
- * file length (mp3, mpeg,..), others report an unknown length (ogg,..).
- */
-typedef struct _App App;
-
-struct _App
-{
- GstElement *playbin;
- GstElement *appsrc;
-
- GMainLoop *loop;
- guint sourceid;
-
- GMappedFile *file;
- guint8 *data;
- gsize length;
- guint64 offset;
-};
-
-App s_app;
-
-#define CHUNK_SIZE 4096
-
-/* This method is called by the idle GSource in the mainloop. We feed CHUNK_SIZE
- * bytes into appsrc.
- * The ide handler is added to the mainloop when appsrc requests us to start
- * sending data (need-data signal) and is removed when appsrc has enough data
- * (enough-data signal).
- */
-static gboolean
-read_data (App * app)
-{
- GstBuffer *buffer;
- guint len;
- GstFlowReturn ret;
-
- buffer = gst_buffer_new ();
-
- if (app->offset >= app->length) {
- /* we are EOS, send end-of-stream and remove the source */
- g_signal_emit_by_name (app->appsrc, "end-of-stream", &ret);
- return FALSE;
- }
-
- /* read the next chunk */
- len = CHUNK_SIZE;
- if (app->offset + len > app->length)
- len = app->length - app->offset;
-
- GST_BUFFER_DATA (buffer) = app->data + app->offset;
- GST_BUFFER_SIZE (buffer) = len;
-
- GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
- app->offset, len);
- g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
- gst_buffer_unref (buffer);
- if (ret != GST_FLOW_OK) {
- /* some error, stop sending data */
- return FALSE;
- }
-
- app->offset += len;
-
- return TRUE;
-}
-
-/* This signal callback is called when appsrc needs data, we add an idle handler
- * to the mainloop to start pushing data into the appsrc */
-static void
-start_feed (GstElement * playbin, guint size, App * app)
-{
- if (app->sourceid == 0) {
- GST_DEBUG ("start feeding");
- app->sourceid = g_idle_add ((GSourceFunc) read_data, app);
- }
-}
-
-/* This callback is called when appsrc has enough data and we can stop sending.
- * We remove the idle handler from the mainloop */
-static void
-stop_feed (GstElement * playbin, App * app)
-{
- if (app->sourceid != 0) {
- GST_DEBUG ("stop feeding");
- g_source_remove (app->sourceid);
- app->sourceid = 0;
- }
-}
-
-/* this callback is called when playbin2 has constructed a source object to read
- * from. Since we provided the appsrc:// uri to playbin2, this will be the
- * appsrc that we must handle. We set up some signals to start and stop pushing
- * data into appsrc */
-static void
-found_source (GObject * object, GObject * orig, GParamSpec * pspec, App * app)
-{
- /* get a handle to the appsrc */
- g_object_get (orig, pspec->name, &app->appsrc, NULL);
-
- GST_DEBUG ("got appsrc %p", app->appsrc);
-
- /* we can set the length in appsrc. This allows some elements to estimate the
- * total duration of the stream. It's a good idea to set the property when you
- * can but it's not required. */
- g_object_set (app->appsrc, "size", (gint64) app->length, NULL);
-
- /* configure the appsrc, we will push data into the appsrc from the
- * mainloop. */
- g_signal_connect (app->appsrc, "need-data", G_CALLBACK (start_feed), app);
- g_signal_connect (app->appsrc, "enough-data", G_CALLBACK (stop_feed), app);
-}
-
-static gboolean
-bus_message (GstBus * bus, GstMessage * message, App * app)
-{
- GST_DEBUG ("got message %s",
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
-
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_ERROR:
- g_error ("received error");
- g_main_loop_quit (app->loop);
- break;
- case GST_MESSAGE_EOS:
- g_main_loop_quit (app->loop);
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- App *app = &s_app;
- GError *error = NULL;
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- GST_DEBUG_CATEGORY_INIT (appsrc_playbin_debug, "appsrc-playbin", 0,
- "appsrc playbin example");
-
- if (argc < 2) {
- g_print ("usage: %s <filename>\n", argv[0]);
- return -1;
- }
-
- /* try to open the file as an mmapped file */
- app->file = g_mapped_file_new (argv[1], FALSE, &error);
- if (error) {
- g_print ("failed to open file: %s\n", error->message);
- g_error_free (error);
- return -2;
- }
- /* get some vitals, this will be used to read data from the mmapped file and
- * feed it to appsrc. */
- app->length = g_mapped_file_get_length (app->file);
- app->data = (guint8 *) g_mapped_file_get_contents (app->file);
- app->offset = 0;
-
- /* create a mainloop to get messages and to handle the idle handler that will
- * feed data to appsrc. */
- app->loop = g_main_loop_new (NULL, TRUE);
-
- app->playbin = gst_element_factory_make ("playbin2", NULL);
- g_assert (app->playbin);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));
-
- /* add watch for messages */
- gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
-
- /* set to read from appsrc */
- g_object_set (app->playbin, "uri", "appsrc://", NULL);
-
- /* get notification when the source is created so that we get a handle to it
- * and can configure it */
- g_signal_connect (app->playbin, "deep-notify::source",
- (GCallback) found_source, app);
-
- /* go to playing and wait in a mainloop. */
- gst_element_set_state (app->playbin, GST_STATE_PLAYING);
-
- /* this mainloop is stopped when we receive an error or EOS */
- g_main_loop_run (app->loop);
-
- GST_DEBUG ("stopping");
-
- gst_element_set_state (app->playbin, GST_STATE_NULL);
-
- /* free the file */
- g_mapped_file_unref (app->file);
-
- gst_object_unref (bus);
- g_main_loop_unref (app->loop);
-
- return 0;
-}
diff --git a/tests/examples/app/appsrc-stream2.c b/tests/examples/app/appsrc-stream2.c
deleted file mode 100644
index e0c8922a..00000000
--- a/tests/examples/app/appsrc-stream2.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/* GStreamer
- *
- * appsrc-stream2.c: example for using appsrc in streaming mode.
- *
- * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-/* FIXME: remove once we depend on GLib >= 2.22 */
-#if !GLIB_CHECK_VERSION (2, 22, 0)
-#define g_mapped_file_unref g_mapped_file_free
-#endif
-
-GST_DEBUG_CATEGORY (appsrc_playbin_debug);
-#define GST_CAT_DEFAULT appsrc_playbin_debug
-
-/*
- * an example application of using appsrc in streaming pull mode. When the
- * appsrc request data with the need-data signal, we retrieve a buffer of an
- * arbitrary size and push it to appsrc.
- *
- * This example keeps the internal buffer queue of appsrc to a minimal size,
- * only feeding data to appsrc when needed.
- *
- * This is a good example how one would deal with a live resource, such as a udp
- * socket where one would feed the most recently acquired buffer to appsrc.
- *
- * Usually one would timestamp the buffers with the running_time of the
- * pipeline or configure the appsrc to do timestamping by setting the
- * do-timestamp property to TRUE.
- *
- * Appsrc in streaming mode (the default) does not support seeking so we don't
- * have to handle any seek callbacks.
- *
- * Some formats are able to estimate the duration of the media file based on the
- * file length (mp3, mpeg,..), others report an unknown length (ogg,..).
- */
-typedef struct _App App;
-
-struct _App
-{
- GstElement *playbin;
- GstElement *appsrc;
-
- GMainLoop *loop;
-
- GMappedFile *file;
- guint8 *data;
- gsize length;
- guint64 offset;
-};
-
-App s_app;
-
-#define CHUNK_SIZE 4096
-
-/* This method is called by the need-data signal callback, we feed data into the
- * appsrc.
- */
-static void
-feed_data (GstElement * appsrc, guint size, App * app)
-{
- GstBuffer *buffer;
- guint len;
- GstFlowReturn ret;
-
- buffer = gst_buffer_new ();
-
- if (app->offset >= app->length) {
- /* we are EOS, send end-of-stream */
- g_signal_emit_by_name (app->appsrc, "end-of-stream", &ret);
- return;
- }
-
- /* read the next chunk */
- len = CHUNK_SIZE;
- if (app->offset + len > app->length)
- len = app->length - app->offset;
-
- GST_BUFFER_DATA (buffer) = app->data + app->offset;
- GST_BUFFER_SIZE (buffer) = len;
-
- GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
- app->offset, len);
- g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
- gst_buffer_unref (buffer);
-
- app->offset += len;
-
- return;
-}
-
-/* this callback is called when playbin2 has constructed a source object to read
- * from. Since we provided the appsrc:// uri to playbin2, this will be the
- * appsrc that we must handle. We set up a signals to push data into appsrc. */
-static void
-found_source (GObject * object, GObject * orig, GParamSpec * pspec, App * app)
-{
- /* get a handle to the appsrc */
- g_object_get (orig, pspec->name, &app->appsrc, NULL);
-
- GST_DEBUG ("got appsrc %p", app->appsrc);
-
- /* we can set the length in appsrc. This allows some elements to estimate the
- * total duration of the stream. It's a good idea to set the property when you
- * can but it's not required. */
- g_object_set (app->appsrc, "size", (gint64) app->length, NULL);
-
- /* configure the appsrc, we will push a buffer to appsrc when it needs more
- * data */
- g_signal_connect (app->appsrc, "need-data", G_CALLBACK (feed_data), app);
-}
-
-static gboolean
-bus_message (GstBus * bus, GstMessage * message, App * app)
-{
- GST_DEBUG ("got message %s",
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
-
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_ERROR:
- g_error ("received error");
- g_main_loop_quit (app->loop);
- break;
- case GST_MESSAGE_EOS:
- g_main_loop_quit (app->loop);
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- App *app = &s_app;
- GError *error = NULL;
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- GST_DEBUG_CATEGORY_INIT (appsrc_playbin_debug, "appsrc-playbin", 0,
- "appsrc playbin example");
-
- if (argc < 2) {
- g_print ("usage: %s <filename>\n", argv[0]);
- return -1;
- }
-
- /* try to open the file as an mmapped file */
- app->file = g_mapped_file_new (argv[1], FALSE, &error);
- if (error) {
- g_print ("failed to open file: %s\n", error->message);
- g_error_free (error);
- return -2;
- }
- /* get some vitals, this will be used to read data from the mmapped file and
- * feed it to appsrc. */
- app->length = g_mapped_file_get_length (app->file);
- app->data = (guint8 *) g_mapped_file_get_contents (app->file);
- app->offset = 0;
-
- /* create a mainloop to get messages */
- app->loop = g_main_loop_new (NULL, TRUE);
-
- app->playbin = gst_element_factory_make ("playbin2", NULL);
- g_assert (app->playbin);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));
-
- /* add watch for messages */
- gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
-
- /* set to read from appsrc */
- g_object_set (app->playbin, "uri", "appsrc://", NULL);
-
- /* get notification when the source is created so that we get a handle to it
- * and can configure it */
- g_signal_connect (app->playbin, "deep-notify::source",
- (GCallback) found_source, app);
-
- /* go to playing and wait in a mainloop. */
- gst_element_set_state (app->playbin, GST_STATE_PLAYING);
-
- /* this mainloop is stopped when we receive an error or EOS */
- g_main_loop_run (app->loop);
-
- GST_DEBUG ("stopping");
-
- gst_element_set_state (app->playbin, GST_STATE_NULL);
-
- /* free the file */
- g_mapped_file_unref (app->file);
-
- gst_object_unref (bus);
- g_main_loop_unref (app->loop);
-
- return 0;
-}
diff --git a/tests/examples/app/appsrc_ex.c b/tests/examples/app/appsrc_ex.c
deleted file mode 100644
index c7aa4b6c..00000000
--- a/tests/examples/app/appsrc_ex.c
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-#include <gst/app/gstappsrc.h>
-#include <gst/app/gstappbuffer.h>
-#include <gst/app/gstappsink.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-
-typedef struct _App App;
-struct _App
-{
- GstElement *pipe;
- GstElement *src;
- GstElement *id;
- GstElement *sink;
-};
-
-App s_app;
-
-static void dont_eat_my_chicken_wings (void *priv);
-
-int
-main (int argc, char *argv[])
-{
- App *app = &s_app;
- int i;
-
- gst_init (&argc, &argv);
-
- app->pipe = gst_pipeline_new (NULL);
- g_assert (app->pipe);
-
- app->src = gst_element_factory_make ("appsrc", NULL);
- g_assert (app->src);
- gst_bin_add (GST_BIN (app->pipe), app->src);
-
- app->id = gst_element_factory_make ("identity", NULL);
- g_assert (app->id);
- gst_bin_add (GST_BIN (app->pipe), app->id);
-
- app->sink = gst_element_factory_make ("appsink", NULL);
- g_assert (app->sink);
- gst_bin_add (GST_BIN (app->pipe), app->sink);
-
- gst_element_link (app->src, app->id);
- gst_element_link (app->id, app->sink);
-
- gst_element_set_state (app->pipe, GST_STATE_PLAYING);
-
- for (i = 0; i < 10; i++) {
- GstBuffer *buf;
- void *data;
-
- data = malloc (100);
- memset (data, i, 100);
-
- buf = gst_app_buffer_new (data, 100, dont_eat_my_chicken_wings, data);
- printf ("%d: creating buffer for pointer %p, %p\n", i, data, buf);
- gst_app_src_push_buffer (GST_APP_SRC (app->src), buf);
- }
-
- /* push EOS */
- gst_app_src_end_of_stream (GST_APP_SRC (app->src));
-
- /* _is_eos() does not block and returns TRUE if there is not currently an EOS
- * to be retrieved */
- while (!gst_app_sink_is_eos (GST_APP_SINK (app->sink))) {
- GstBuffer *buf;
-
- /* pull the next item, this can return NULL when there is no more data and
- * EOS has been received */
- buf = gst_app_sink_pull_buffer (GST_APP_SINK (app->sink));
- printf ("retrieved buffer %p\n", buf);
- if (buf)
- gst_buffer_unref (buf);
- }
- gst_element_set_state (app->pipe, GST_STATE_NULL);
-
- return 0;
-}
-
-static void
-dont_eat_my_chicken_wings (void *priv)
-{
- printf ("freeing buffer for pointer %p\n", priv);
- free (priv);
-}
diff --git a/tests/examples/dynamic/.gitignore b/tests/examples/dynamic/.gitignore
deleted file mode 100644
index 99b7654b..00000000
--- a/tests/examples/dynamic/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-addstream
-codec-select
-sprinkle
-sprinkle2
-sprinkle3
diff --git a/tests/examples/dynamic/Makefile.am b/tests/examples/dynamic/Makefile.am
deleted file mode 100644
index 087d5fe4..00000000
--- a/tests/examples/dynamic/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-noinst_PROGRAMS = addstream codec-select sprinkle sprinkle2 sprinkle3
-
-addstream_SOURCES = addstream.c
-addstream_CFLAGS = $(GST_CFLAGS) -D_GNU_SOURCE
-addstream_LDFLAGS = $(GST_LIBS)
-
-codec_select_SOURCES = codec-select.c
-codec_select_CFLAGS = $(GST_CFLAGS) -D_GNU_SOURCE
-codec_select_LDFLAGS = $(GST_LIBS)
-
-sprinkle_SOURCES = sprinkle.c
-sprinkle_CFLAGS = $(GST_CFLAGS) -D_GNU_SOURCE
-sprinkle_LDFLAGS = $(GST_LIBS)
-
-sprinkle2_SOURCES = sprinkle2.c
-sprinkle2_CFLAGS = $(GST_CFLAGS) -D_GNU_SOURCE
-sprinkle2_LDFLAGS = $(GST_LIBS)
-
-sprinkle3_SOURCES = sprinkle3.c
-sprinkle3_CFLAGS = $(GST_CFLAGS) -D_GNU_SOURCE
-sprinkle3_LDFLAGS = $(GST_LIBS)
diff --git a/tests/examples/dynamic/addstream.c b/tests/examples/dynamic/addstream.c
deleted file mode 100644
index 66ad0bec..00000000
--- a/tests/examples/dynamic/addstream.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/* GStreamer
- *
- * addstream.c: sample application to dynamically add streams to a running
- * pipeline
- *
- * Copyright (C) <2007> Wim Taymans <wim dot taymans at gmail dot com>
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-static GstElement *pipeline;
-static GstClock *theclock;
-static GMainLoop *loop;
-static GstElement *bin1, *bin2, *bin3, *bin4, *bin5;
-
-/* start a bin with the given description */
-static GstElement *
-create_stream (const gchar * descr)
-{
- GstElement *bin;
- GError *error = NULL;
-
- bin = gst_parse_launch (descr, &error);
- if (error) {
- g_print ("pipeline could not be constructed: %s\n", error->message);
- g_error_free (error);
- return NULL;
- }
-
- /* add the bin to the pipeline now, this will set the current base_time of the
- * pipeline on the new bin. */
- gst_bin_add (GST_BIN_CAST (pipeline), bin);
-
- return bin;
-}
-
-static gboolean
-pause_play_stream (GstElement * bin, gint seconds)
-{
- gboolean punch_in;
- GstStateChangeReturn ret;
- GstClockTime now, base_time, running_time;
-
- /* get current running time, we need this value to continue playback of
- * non-live pipelines. */
- now = gst_clock_get_time (theclock);
- base_time = gst_element_get_base_time (bin);
-
- running_time = now - base_time;
-
- /* set the new bin to PAUSED, the parent bin will notice (because of the ASYNC
- * message and will perform latency calculations again when going to PLAYING
- * later. */
- ret = gst_element_set_state (bin, GST_STATE_PAUSED);
-
- switch (ret) {
- case GST_STATE_CHANGE_NO_PREROLL:
- /* live source, timestamps are running_time of the pipeline clock. */
- punch_in = FALSE;
- break;
- case GST_STATE_CHANGE_SUCCESS:
- /* success, no async state changes, same as async, timestamps start
- * from 0 */
- case GST_STATE_CHANGE_ASYNC:
- /* no live source, bin will preroll. We have to punch it in because in
- * this situation timestamps start from 0. */
- punch_in = TRUE;
- break;
- default:
- case GST_STATE_CHANGE_FAILURE:
- return FALSE;
- }
-
- if (seconds)
- g_usleep (seconds * G_USEC_PER_SEC);
-
- if (punch_in) {
- /* new bin has to be aligned with previous running_time. We do this by taking
- * the current absolute clock time and calculating the base time that would
- * give the previous running_time. We set this base_time on the bin before
- * setting it to PLAYING. */
- now = gst_clock_get_time (theclock);
- base_time = now - running_time;
-
- gst_element_set_base_time (bin, base_time);
- }
-
- /* now set the pipeline to PLAYING */
- gst_element_set_state (bin, GST_STATE_PLAYING);
-
- return TRUE;
-}
-
-static void
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
- g_print ("message from \"%s\" (%s): ",
- GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))),
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
- if (s) {
- gchar *sstr;
-
- sstr = gst_structure_to_string (s);
- g_print ("%s\n", sstr);
- g_free (sstr);
- } else {
- g_print ("no message details\n");
- }
-}
-
-static void
-eos_message_received (GstBus * bus, GstMessage * message,
- GstPipeline * pipeline)
-{
- message_received (bus, message, pipeline);
- g_main_loop_quit (loop);
-}
-
-static gboolean
-perform_step (gpointer pstep)
-{
- gint step = GPOINTER_TO_INT (pstep);
-
- switch (step) {
- case 0:
- /* live stream locks on to running_time, pipeline configures latency. */
- g_print ("creating bin1\n");
- bin1 =
- create_stream
- ("( v4l2src ! ffmpegcolorspace ! timeoverlay ! queue ! xvimagesink name=v4llive )");
- pause_play_stream (bin1, 0);
- g_timeout_add (1000, (GSourceFunc) perform_step, GINT_TO_POINTER (1));
- break;
- case 1:
- /* live stream locks on to running_time, pipeline reconfigures latency
- * together with the previously added bin so that they run synchronized. */
- g_print ("creating bin2\n");
- bin2 = create_stream ("( alsasrc ! queue ! alsasink name=alsalive )");
- pause_play_stream (bin2, 0);
- g_timeout_add (1000, (GSourceFunc) perform_step, GINT_TO_POINTER (2));
- break;
- case 2:
- /* non-live stream, need base_time to align with current running live sources. */
- g_print ("creating bin3\n");
- bin3 = create_stream ("( audiotestsrc ! alsasink name=atnonlive )");
- pause_play_stream (bin3, 0);
- g_timeout_add (1000, (GSourceFunc) perform_step, GINT_TO_POINTER (3));
- break;
- case 3:
- g_print ("creating bin4\n");
- bin4 =
- create_stream
- ("( videotestsrc ! timeoverlay ! ffmpegcolorspace ! ximagesink name=vtnonlive )");
- pause_play_stream (bin4, 0);
- g_timeout_add (1000, (GSourceFunc) perform_step, GINT_TO_POINTER (4));
- break;
- case 4:
- /* live stream locks on to running_time */
- g_print ("creating bin5\n");
- bin5 =
- create_stream
- ("( videotestsrc is-live=1 ! timeoverlay ! ffmpegcolorspace ! ximagesink name=vtlive )");
- pause_play_stream (bin5, 0);
- g_timeout_add (1000, (GSourceFunc) perform_step, GINT_TO_POINTER (5));
- break;
- case 5:
- /* pause the fist live stream for 2 seconds */
- g_print ("PAUSE bin1 for 2 seconds\n");
- pause_play_stream (bin1, 2);
- /* pause the non-live stream for 2 seconds */
- g_print ("PAUSE bin4 for 2 seconds\n");
- pause_play_stream (bin4, 2);
- /* pause the pseudo live stream for 2 seconds */
- g_print ("PAUSE bin5 for 2 seconds\n");
- pause_play_stream (bin5, 2);
- g_print ("Waiting 5 seconds\n");
- g_timeout_add (5000, (GSourceFunc) perform_step, GINT_TO_POINTER (6));
- break;
- case 6:
- g_print ("quiting\n");
- g_main_loop_quit (loop);
- break;
- default:
- break;
- }
- return FALSE;
-}
-
-int
-main (int argc, char *argv[])
-{
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- loop = g_main_loop_new (NULL, TRUE);
-
- pipeline = gst_pipeline_new ("pipeline");
-
- /* setup message handling */
- bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
- g_signal_connect (bus, "message::error", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::warning", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::eos", (GCallback) eos_message_received,
- pipeline);
-
- /* we set the pipeline to PLAYING, this will distribute a default clock and
- * start running. no preroll is needed */
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- /* get the clock now. Since we never set the pipeline to PAUSED again, the
- * clock will not change, even when we add new clock providers later. */
- theclock = gst_element_get_clock (pipeline);
-
- /* start our actions while we are in the mainloop so that we can catch errors
- * and other messages. */
- g_idle_add ((GSourceFunc) perform_step, GINT_TO_POINTER (0));
- /* go to main loop */
- g_main_loop_run (loop);
-
- gst_element_set_state (pipeline, GST_STATE_NULL);
-
- gst_object_unref (bus);
- gst_object_unref (pipeline);
- gst_object_unref (theclock);
-
- return 0;
-}
diff --git a/tests/examples/dynamic/codec-select.c b/tests/examples/dynamic/codec-select.c
deleted file mode 100644
index 2d8f9fac..00000000
--- a/tests/examples/dynamic/codec-select.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/* GStreamer
- *
- * codec-select.c: sample application to dynamically select a codec
- *
- * Copyright (C) <2008> Wim Taymans <wim dot taymans at gmail dot com>
- *
- * 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.
- */
-
-/*
- * This example sets up a pipeline to 'encode' an audiotestsrc into 3 different
- * formats. The format can be selected dynamically at runtime.
- *
- * Each of the encoders require the audio in a specific different format.
- *
- * This example uses identity as the encoder and enforces the caps on identity
- * with a capsfilter.
- *
- * This is a good example of input and output selector and how these elements
- * preserve segment and timing information while switching between streams.
- */
-
-#include <string.h>
-#include <gst/gst.h>
-
-/* Create an encoder element.
- * We make a bin containing:
- *
- * audioresample ! <enccaps> ! identity
- *
- * The sinkpad of audioresample and source pad of identity are ghosted on the
- * bin.
- */
-static GstElement *
-make_encoder (const GstCaps * caps)
-{
- GstElement *result;
- GstElement *audioresample;
- GstElement *capsfilter;
- GstElement *identity;
- GstPad *pad;
-
- /* create result bin */
- result = gst_bin_new (NULL);
- g_assert (result);
-
- /* create elements */
- audioresample = gst_element_factory_make ("audioresample", NULL);
- g_assert (audioresample);
-
- capsfilter = gst_element_factory_make ("capsfilter", NULL);
- g_assert (capsfilter);
- g_object_set (capsfilter, "caps", caps, NULL);
-
- identity = gst_element_factory_make ("identity", NULL);
- g_assert (identity);
- g_object_set (identity, "silent", TRUE, NULL);
-
- /* add elements to result bin */
- gst_bin_add (GST_BIN (result), audioresample);
- gst_bin_add (GST_BIN (result), capsfilter);
- gst_bin_add (GST_BIN (result), identity);
-
- /* link elements */
- gst_element_link_pads (audioresample, "src", capsfilter, "sink");
- gst_element_link_pads (capsfilter, "src", identity, "sink");
-
- /* ghost src and sink pads */
- pad = gst_element_get_static_pad (audioresample, "sink");
- gst_element_add_pad (result, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- pad = gst_element_get_static_pad (identity, "src");
- gst_element_add_pad (result, gst_ghost_pad_new ("src", pad));
- gst_object_unref (pad);
-
- return result;
-}
-
-/*
- * We generate:
- *
- * audiotestsrc ! <audiocaps> ! output-selector ! [enc1 .. enc3] ! input-selector
- * select-all = true ! fakesink
- *
- * <audiocaps> makes sure we only produce one format from the audiotestsrc.
- *
- * Each encX element consists of:
- *
- * audioresample ! <enccaps> ! identity !
- *
- * This way we can simply switch encoders without having to renegotiate.
- */
-static GstElement *
-make_pipeline (void)
-{
- GstElement *result;
- GstElement *audiotestsrc;
- GstElement *audiocaps;
- GstElement *outputselect;
- GstElement *inputselect;
- GstElement *sink;
- GstCaps *caps;
- GstCaps *capslist[3];
- gint i;
-
- /* create result pipeline */
- result = gst_pipeline_new (NULL);
- g_assert (result);
-
- /* create various elements */
- audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL);
- g_object_set (audiotestsrc, "num-buffers", 1000, NULL);
- g_assert (audiotestsrc);
-
- audiocaps = gst_element_factory_make ("capsfilter", NULL);
- g_assert (audiocaps);
-
- caps =
- gst_caps_from_string
- ("audio/x-raw-int,signed=true,width=16,depth=16,rate=48000,channels=1");
- g_object_set (audiocaps, "caps", caps, NULL);
- gst_caps_unref (caps);
-
- outputselect = gst_element_factory_make ("output-selector", "select");
- g_assert (outputselect);
-
- inputselect = gst_element_factory_make ("input-selector", NULL);
- g_assert (inputselect);
- g_object_set (inputselect, "select-all", TRUE, NULL);
-
- sink = gst_element_factory_make ("fakesink", NULL);
- g_object_set (sink, "sync", TRUE, NULL);
- g_object_set (sink, "silent", TRUE, NULL);
- g_assert (sink);
-
- /* add elements */
- gst_bin_add (GST_BIN (result), audiotestsrc);
- gst_bin_add (GST_BIN (result), audiocaps);
- gst_bin_add (GST_BIN (result), outputselect);
- gst_bin_add (GST_BIN (result), inputselect);
- gst_bin_add (GST_BIN (result), sink);
-
- /* link elements */
- gst_element_link_pads (audiotestsrc, "src", audiocaps, "sink");
- gst_element_link_pads (audiocaps, "src", outputselect, "sink");
- gst_element_link_pads (inputselect, "src", sink, "sink");
-
- /* make caps */
- capslist[0] =
- gst_caps_from_string
- ("audio/x-raw-int,signed=true,width=16,depth=16,rate=48000,channels=1");
- capslist[1] =
- gst_caps_from_string
- ("audio/x-raw-int,signed=true,width=16,depth=16,rate=16000,channels=1");
- capslist[2] =
- gst_caps_from_string
- ("audio/x-raw-int,signed=true,width=16,depth=16,rate=8000,channels=1");
-
- /* create encoder elements */
- for (i = 0; i < 3; i++) {
- GstElement *encoder;
- GstPad *srcpad, *sinkpad;
-
- encoder = make_encoder (capslist[i]);
- g_assert (encoder);
-
- gst_bin_add (GST_BIN (result), encoder);
-
- srcpad = gst_element_get_request_pad (outputselect, "src%d");
- sinkpad = gst_element_get_static_pad (encoder, "sink");
- gst_pad_link (srcpad, sinkpad);
- gst_object_unref (srcpad);
- gst_object_unref (sinkpad);
-
- srcpad = gst_element_get_static_pad (encoder, "src");
- sinkpad = gst_element_get_request_pad (inputselect, "sink%d");
- gst_pad_link (srcpad, sinkpad);
- gst_object_unref (srcpad);
- gst_object_unref (sinkpad);
- }
-
- return result;
-}
-
-static gboolean
-do_switch (GstElement * pipeline)
-{
- gint rand;
- GstElement *select;
- gchar *name;
- GstPad *pad;
-
- rand = g_random_int_range (0, 3);
-
- g_print ("switching to %d\n", rand);
-
- /* find the selector */
- select = gst_bin_get_by_name (GST_BIN (pipeline), "select");
-
- /* get the named pad */
- name = g_strdup_printf ("src%d", rand);
- pad = gst_element_get_static_pad (select, name);
- g_free (name);
-
- /* set the active pad */
- g_object_set (select, "active-pad", pad, NULL);
-
- return TRUE;
-}
-
-static gboolean
-my_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
-{
- GstElement *sender = (GstElement *) GST_MESSAGE_SRC (message);
- const gchar *name = gst_element_get_name (sender);
- GMainLoop *loop = (GMainLoop *) data;
-
- g_print ("Got %s message from %s\n", GST_MESSAGE_TYPE_NAME (message), name);
-
- switch (GST_MESSAGE_TYPE (message)) {
-
- case GST_MESSAGE_ERROR:{
- GError *err;
- gchar *debug;
-
- gst_message_parse_error (message, &err, &debug);
- g_print ("Error: %s (%s)\n", err->message, debug);
- g_error_free (err);
- g_free (debug);
-
- g_main_loop_quit (loop);
- break;
- }
- case GST_MESSAGE_EOS:
- /* end-of-stream */
- g_main_loop_quit (loop);
- break;
- default:
- /* unhandled message */
- break;
- }
-
- return TRUE;
-}
-
-gint
-main (gint argc, gchar * argv[])
-{
- GstElement *pipeline;
- GstBus *bus;
- GMainLoop *loop;
-
- /* init GStreamer */
- gst_init (&argc, &argv);
- loop = g_main_loop_new (NULL, FALSE);
-
- /* set up */
- pipeline = make_pipeline ();
-
- g_signal_connect (pipeline, "deep_notify",
- G_CALLBACK (gst_object_default_deep_notify), NULL);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- gst_bus_add_watch (bus, my_bus_callback, loop);
- gst_object_unref (bus);
-
- g_print ("Starting pipeline\n");
-
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- /* add a timeout to cycle between the formats */
- g_timeout_add (1000, (GSourceFunc) do_switch, pipeline);
-
- /* now run */
- g_main_loop_run (loop);
-
- g_print ("Nulling pipeline\n");
-
- /* also clean up */
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
-
- return 0;
-}
diff --git a/tests/examples/dynamic/sprinkle.c b/tests/examples/dynamic/sprinkle.c
deleted file mode 100644
index 1b75840a..00000000
--- a/tests/examples/dynamic/sprinkle.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* GStreamer
- *
- * sprinkle.c: sample application to dynamically mix tones with adder
- *
- * Copyright (C) <2009> Wim Taymans <wim dot taymans at gmail dot com>
- *
- * 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.
- */
-
-/*
- * Produces a sweeping sprinkle of tones by dynamically adding and removing
- * elements to adder.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-static GstElement *pipeline, *adder;
-static GMainLoop *loop;
-
-typedef struct
-{
- GstElement *element;
- GstPad *srcpad;
- GstPad *sinkpad;
- gdouble freq;
-} SourceInfo;
-
-/* dynamically add the source to the pipeline and link it to a new pad on
- * adder */
-static SourceInfo *
-add_source (gdouble freq)
-{
- SourceInfo *info;
-
- info = g_new0 (SourceInfo, 1);
- info->freq = freq;
-
- /* make source with unique name */
- info->element = gst_element_factory_make ("audiotestsrc", NULL);
-
- g_object_set (info->element, "freq", freq, NULL);
-
- /* add to the bin */
- gst_bin_add (GST_BIN (pipeline), info->element);
-
- /* get pad from the element */
- info->srcpad = gst_element_get_static_pad (info->element, "src");
-
- /* get new pad from adder, adder will now wait for data on this pad */
- info->sinkpad = gst_element_get_request_pad (adder, "sink%d");
-
- /* link pad to adder */
- gst_pad_link (info->srcpad, info->sinkpad);
-
- /* and play the element */
- gst_element_set_state (info->element, GST_STATE_PLAYING);
-
- g_print ("added freq %f\n", info->freq);
-
- return info;
-}
-
-/* remove the source from the pipeline after removing it from adder */
-static void
-remove_source (SourceInfo * info)
-{
- g_print ("remove freq %f\n", info->freq);
-
- /* lock the state so that we can put it to NULL without the parent messing
- * with our state */
- gst_element_set_locked_state (info->element, TRUE);
-
- /* first stop the source. Remember that this might block when in the PAUSED
- * state. Alternatively one could send EOS to the source, install an event
- * probe and schedule a state change/unlink/release from the mainthread.
- * Note that changing the state of a source makes it emit an EOS, which can
- * make adder go EOS. */
- gst_element_set_state (info->element, GST_STATE_NULL);
-
- /* unlink from adder */
- gst_pad_unlink (info->srcpad, info->sinkpad);
- gst_object_unref (info->srcpad);
-
- /* remove from the bin */
- gst_bin_remove (GST_BIN (pipeline), info->element);
-
- /* give back the pad */
- gst_element_release_request_pad (adder, info->sinkpad);
- gst_object_unref (info->sinkpad);
-
- g_free (info);
-}
-
-/* we'll keep the state of the sources in this structure. We keep 3 sources
- * alive */
-typedef struct
-{
- guint count;
- SourceInfo *infos[3];
-} SprinkleState;
-
-static SprinkleState *
-create_state (void)
-{
- SprinkleState *state;
-
- state = g_new0 (SprinkleState, 1);
-
- return state;
-}
-
-static void
-free_state (SprinkleState * state)
-{
- SourceInfo *info;
- gint i;
-
- for (i = 0; i < 3; i++) {
- info = state->infos[i];
- if (info)
- remove_source (info);
- }
-
- g_free (state);
-}
-
-static gboolean
-do_sprinkle (SprinkleState * state)
-{
- SourceInfo *info;
- gint i;
-
- /* first remove the oldest info */
- info = state->infos[2];
-
- if (info)
- remove_source (info);
-
- /* move sources */
- for (i = 2; i > 0; i--) {
- state->infos[i] = state->infos[i - 1];
- }
-
- /* add new source, stop adding sources after 10 rounds. */
- if (state->count < 10) {
- state->infos[0] = add_source ((state->count * 100) + 200);
- state->count++;
- } else {
- state->infos[0] = NULL;
- }
- return TRUE;
-}
-
-static void
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
- g_print ("message from \"%s\" (%s): ",
- GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))),
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
- if (s) {
- gchar *sstr;
-
- sstr = gst_structure_to_string (s);
- g_print ("%s\n", sstr);
- g_free (sstr);
- } else {
- g_print ("no message details\n");
- }
-}
-
-static void
-eos_message_received (GstBus * bus, GstMessage * message,
- GstPipeline * pipeline)
-{
- message_received (bus, message, pipeline);
- g_main_loop_quit (loop);
-}
-
-int
-main (int argc, char *argv[])
-{
- GstBus *bus;
- GstElement *filter, *convert, *sink;
- GstCaps *caps;
- gboolean res;
- SprinkleState *state;
-
- gst_init (&argc, &argv);
-
- loop = g_main_loop_new (NULL, TRUE);
-
- pipeline = gst_pipeline_new ("pipeline");
-
- /* add the fixed part to the pipeline. Remember that we need a capsfilter
- * after adder so that multiple sources are not racing to negotiate
- * a format */
- adder = gst_element_factory_make ("adder", "adder");
- filter = gst_element_factory_make ("capsfilter", "filter");
- convert = gst_element_factory_make ("audioconvert", "convert");
- sink = gst_element_factory_make ("autoaudiosink", "sink");
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
- "channels", G_TYPE_INT, 1,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 44100, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
- g_object_set (filter, "caps", caps, NULL);
- gst_caps_unref (caps);
-
- gst_bin_add_many (GST_BIN (pipeline), adder, filter, convert, sink, NULL);
-
- res = gst_element_link_many (adder, filter, convert, sink, NULL);
- g_assert (res);
-
- /* setup message handling */
- bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
- g_signal_connect (bus, "message::error", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::warning", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::eos", (GCallback) eos_message_received,
- pipeline);
-
- /* we set the pipeline to PLAYING, the pipeline will not yet preroll because
- * there is no source providing data for it yet */
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- /* and add the function that modifies the pipeline every 100ms */
- state = create_state ();
- g_timeout_add (100, (GSourceFunc) do_sprinkle, state);
-
- /* go to main loop */
- g_main_loop_run (loop);
-
- gst_element_set_state (pipeline, GST_STATE_NULL);
-
- free_state (state);
- gst_object_unref (bus);
- gst_object_unref (pipeline);
-
- return 0;
-}
diff --git a/tests/examples/dynamic/sprinkle2.c b/tests/examples/dynamic/sprinkle2.c
deleted file mode 100644
index abab47ce..00000000
--- a/tests/examples/dynamic/sprinkle2.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/* GStreamer
- *
- * sprinkle.c: sample application to dynamically mix tones with adder
- *
- * Copyright (C) <2009> Wim Taymans <wim dot taymans at gmail dot com>
- *
- * 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.
- */
-
-/*
- * Produces a sweeping sprinkle of tones by dynamically adding and removing
- * elements to adder.
- *
- * gcc `pkg-config --cflags --libs gstreamer-0.10` sprinkle2.c -osprinkle2
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-static GstElement *pipeline, *adder;
-static GMainLoop *loop;
-
-typedef struct
-{
- GstElement *src, *fx;
- GstPad *src_srcpad;
- GstPad *fx_sinkpad, *fx_srcpad;
- GstPad *adder_sinkpad;
- gdouble freq;
- gfloat pos;
-} SourceInfo;
-
-/* dynamically add the source to the pipeline and link it to a new pad on
- * adder */
-static SourceInfo *
-add_source (gdouble freq, gfloat pos)
-{
- SourceInfo *info;
-
- info = g_new0 (SourceInfo, 1);
- info->freq = freq;
- info->pos = pos;
-
- /* make source with unique name */
- info->src = gst_element_factory_make ("audiotestsrc", NULL);
- info->fx = gst_element_factory_make ("audiopanorama", NULL);
-
- g_object_set (info->src, "freq", freq, "volume", (gdouble) 0.35, NULL);
- g_object_set (info->fx, "panorama", pos, NULL);
-
- /* add to the bin */
- gst_bin_add (GST_BIN (pipeline), info->src);
- gst_bin_add (GST_BIN (pipeline), info->fx);
-
- /* get pads from the elements */
- info->src_srcpad = gst_element_get_static_pad (info->src, "src");
- info->fx_srcpad = gst_element_get_static_pad (info->fx, "src");
- info->fx_sinkpad = gst_element_get_static_pad (info->fx, "sink");
-
- /* get new pad from adder, adder will now wait for data on this pad */
- info->adder_sinkpad = gst_element_get_request_pad (adder, "sink%d");
-
- /* link src to fx and fx to adder */
- gst_pad_link (info->fx_srcpad, info->adder_sinkpad);
- gst_pad_link (info->src_srcpad, info->fx_sinkpad);
-
- /* and play the elements, change the state from sink to source */
- gst_element_set_state (info->fx, GST_STATE_PLAYING);
- gst_element_set_state (info->src, GST_STATE_PLAYING);
-
- g_print ("added freq %5.0f, pos %3.1f\n", info->freq, info->pos);
-
- return info;
-}
-
-/* remove the source from the pipeline after removing it from adder */
-static void
-remove_source (SourceInfo * info)
-{
- g_print ("remove freq %5.0f, pos %3.1f\n", info->freq, info->pos);
-
- /* lock the state so that we can put it to NULL without the parent messing
- * with our state */
- gst_element_set_locked_state (info->src, TRUE);
- gst_element_set_locked_state (info->fx, TRUE);
-
- /* first stop the source. Remember that this might block when in the PAUSED
- * state. Alternatively one could send EOS to the source, install an event
- * probe and schedule a state change/unlink/release from the mainthread. */
- gst_element_set_state (info->fx, GST_STATE_NULL);
- /* NOTE that the source emits EOS when shutting down but the EOS will not
- * reach the adder sinkpad because the effect is in the NULL state. We will
- * send an EOS to adder later. */
- gst_element_set_state (info->src, GST_STATE_NULL);
-
- /* unlink from adder */
- gst_pad_unlink (info->src_srcpad, info->fx_sinkpad);
- gst_pad_unlink (info->fx_srcpad, info->adder_sinkpad);
- gst_object_unref (info->src_srcpad);
- gst_object_unref (info->fx_srcpad);
- gst_object_unref (info->fx_sinkpad);
-
- /* remove from the bin */
- gst_bin_remove (GST_BIN (pipeline), info->src);
- gst_bin_remove (GST_BIN (pipeline), info->fx);
-
- /* send EOS to the sinkpad to make adder EOS when needed */
- gst_pad_send_event (info->adder_sinkpad, gst_event_new_eos ());
-
- /* give back the pad */
- gst_element_release_request_pad (adder, info->adder_sinkpad);
- gst_object_unref (info->adder_sinkpad);
-
- g_free (info);
-}
-
-/* we'll keep the state of the sources in this structure. We keep 3 sources
- * alive */
-typedef struct
-{
- guint count;
- SourceInfo *infos[3];
-} SprinkleState;
-
-static SprinkleState *
-create_state (void)
-{
- SprinkleState *state;
-
- state = g_new0 (SprinkleState, 1);
-
- return state;
-}
-
-static void
-free_state (SprinkleState * state)
-{
- SourceInfo *info;
- gint i;
-
- for (i = 0; i < 3; i++) {
- info = state->infos[i];
- if (info)
- remove_source (info);
- }
-
- g_free (state);
-}
-
-static gboolean
-do_sprinkle (SprinkleState * state)
-{
- SourceInfo *info;
- gint i;
-
- /* first remove the oldest info */
- info = state->infos[2];
-
- if (info)
- remove_source (info);
-
- /* move sources */
- for (i = 2; i > 0; i--) {
- state->infos[i] = state->infos[i - 1];
- }
-
- /* add new source, stop adding sources after 10 rounds. */
- if (state->count < 20) {
- state->infos[0] = add_source (
- (gdouble) ((state->count * 100) + 200),
- ((gfloat) (state->count % 5) / 2.0 - 1.0));
- state->count++;
- } else {
- state->infos[0] = NULL;
- }
- return TRUE;
-}
-
-static void
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
- g_print ("message from \"%s\" (%s): ",
- GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))),
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
- if (s) {
- gchar *sstr;
-
- sstr = gst_structure_to_string (s);
- g_print ("%s\n", sstr);
- g_free (sstr);
- } else {
- g_print ("no message details\n");
- }
-}
-
-static void
-eos_message_received (GstBus * bus, GstMessage * message,
- GstPipeline * pipeline)
-{
- message_received (bus, message, pipeline);
- g_main_loop_quit (loop);
-}
-
-int
-main (int argc, char *argv[])
-{
- GstBus *bus;
- GstElement *filter, *convert, *sink;
- GstCaps *caps;
- gboolean res;
- SprinkleState *state;
-
- gst_init (&argc, &argv);
-
- loop = g_main_loop_new (NULL, TRUE);
-
- pipeline = gst_pipeline_new ("pipeline");
-
- /* add the fixed part to the pipeline. Remember that we need a capsfilter
- * after adder so that multiple sources are not racing to negotiate
- * a format */
- adder = gst_element_factory_make ("adder", "adder");
- filter = gst_element_factory_make ("capsfilter", "filter");
- convert = gst_element_factory_make ("audioconvert", "convert");
- sink = gst_element_factory_make ("autoaudiosink", "sink");
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
- "channels", G_TYPE_INT, 2,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 44100, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
- g_object_set (filter, "caps", caps, NULL);
- gst_caps_unref (caps);
-
- gst_bin_add_many (GST_BIN (pipeline), adder, filter, convert, sink, NULL);
-
- res = gst_element_link_many (adder, filter, convert, sink, NULL);
- g_assert (res);
-
- /* setup message handling */
- bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
- g_signal_connect (bus, "message::error", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::warning", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::eos", (GCallback) eos_message_received,
- pipeline);
-
- /* we set the pipeline to PLAYING, the pipeline will not yet preroll because
- * there is no source providing data for it yet */
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- /* and add the function that modifies the pipeline every 100ms */
- state = create_state ();
- g_timeout_add (100, (GSourceFunc) do_sprinkle, state);
-
- /* go to main loop */
- g_main_loop_run (loop);
-
- gst_element_set_state (pipeline, GST_STATE_NULL);
-
- free_state (state);
- gst_object_unref (bus);
- gst_object_unref (pipeline);
-
- return 0;
-}
diff --git a/tests/examples/dynamic/sprinkle3.c b/tests/examples/dynamic/sprinkle3.c
deleted file mode 100644
index 5983c335..00000000
--- a/tests/examples/dynamic/sprinkle3.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/* GStreamer
- *
- * sprinkle.c: sample application to dynamically mix tones with adder
- *
- * Copyright (C) <2009> Wim Taymans <wim dot taymans at gmail dot com>
- *
- * 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.
- */
-
-/*
- * Produces a sweeping sprinkle of tones by dynamically adding and removing
- * elements to adder.
- *
- * gcc `pkg-config --cflags --libs gstreamer-0.10` sprinkle3.c -osprinkle3
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-static GstElement *pipeline, *adder;
-static GMainLoop *loop;
-
-typedef struct
-{
- GstElement *bin, *src, *fx;
- GstPad *src_srcpad;
- GstPad *fx_sinkpad, *fx_srcpad;
- GstPad *adder_sinkpad;
- GstPad *bin_srcpad;
- gdouble freq;
- gfloat pos;
-} SourceInfo;
-
-/* dynamically add the source to the pipeline and link it to a new pad on
- * adder */
-static SourceInfo *
-add_source (gdouble freq, gfloat pos)
-{
- SourceInfo *info;
-
- info = g_new0 (SourceInfo, 1);
- info->freq = freq;
- info->pos = pos;
-
- /* make source with unique name */
- info->bin = gst_element_factory_make ("bin", NULL);
- info->src = gst_element_factory_make ("audiotestsrc", NULL);
- info->fx = gst_element_factory_make ("audiopanorama", NULL);
-
- g_object_set (info->src, "freq", freq, "volume", (gdouble) 0.35, NULL);
- g_object_set (info->fx, "panorama", pos, NULL);
-
- /* add to the bin */
- gst_bin_add (GST_BIN (info->bin), info->src);
- gst_bin_add (GST_BIN (info->bin), info->fx);
-
- /* get pads from the elements */
- info->src_srcpad = gst_element_get_static_pad (info->src, "src");
- info->fx_srcpad = gst_element_get_static_pad (info->fx, "src");
- info->fx_sinkpad = gst_element_get_static_pad (info->fx, "sink");
-
- /* create and add a pad for the bin */
- info->bin_srcpad = gst_ghost_pad_new ("src", info->fx_srcpad);
- gst_element_add_pad (info->bin, info->bin_srcpad);
-
- /* get new pad from adder, adder will now wait for data on this pad */
- info->adder_sinkpad = gst_element_get_request_pad (adder, "sink%d");
-
- /* link inside the bin */
- gst_pad_link (info->src_srcpad, info->fx_sinkpad);
-
- /* add bin to pipeline */
- gst_bin_add (GST_BIN (pipeline), info->bin);
-
- /* link bin to adder */
- gst_pad_link (info->bin_srcpad, info->adder_sinkpad);
-
- /* and play the elements */
- gst_element_set_state (info->bin, GST_STATE_PLAYING);
-
- g_print ("added freq %5.0f, pos %3.1f\n", info->freq, info->pos);
-
- return info;
-}
-
-/* remove the source from the pipeline after removing it from adder */
-static void
-remove_source (SourceInfo * info)
-{
- g_print ("remove freq %5.0f, pos %3.1f\n", info->freq, info->pos);
-
- /* lock the state so that we can put it to NULL without the parent messing
- * with our state */
- gst_element_set_locked_state (info->bin, TRUE);
-
- /* first stop the source. Remember that this might block when in the PAUSED
- * state. Alternatively one could send EOS to the source, install an event
- * probe and schedule a state change/unlink/release from the mainthread. */
- /* NOTE that the source inside the bin will emit EOS but it will not reach
- * adder because the element after the source is shut down first. We will send
- * EOS later */
- gst_element_set_state (info->bin, GST_STATE_NULL);
-
- /* unlink bin from adder */
- gst_pad_unlink (info->bin_srcpad, info->adder_sinkpad);
-
- /* release pads */
- gst_object_unref (info->src_srcpad);
- gst_object_unref (info->fx_srcpad);
- gst_object_unref (info->fx_sinkpad);
-
- /* remove from the bin */
- gst_bin_remove (GST_BIN (pipeline), info->bin);
-
- /* send EOS to the sinkpad to make adder EOS when needed */
- gst_pad_send_event (info->adder_sinkpad, gst_event_new_eos ());
-
- /* give back the pad */
- gst_element_release_request_pad (adder, info->adder_sinkpad);
- gst_object_unref (info->adder_sinkpad);
-
- g_free (info);
-}
-
-/* we'll keep the state of the sources in this structure. We keep 3 sources
- * alive */
-typedef struct
-{
- guint count;
- SourceInfo *infos[3];
-} SprinkleState;
-
-static SprinkleState *
-create_state (void)
-{
- SprinkleState *state;
-
- state = g_new0 (SprinkleState, 1);
-
- return state;
-}
-
-static void
-free_state (SprinkleState * state)
-{
- SourceInfo *info;
- gint i;
-
- for (i = 0; i < 3; i++) {
- info = state->infos[i];
- if (info)
- remove_source (info);
- }
-
- g_free (state);
-}
-
-static gboolean
-do_sprinkle (SprinkleState * state)
-{
- SourceInfo *info;
- gint i;
-
- /* first remove the oldest info */
- info = state->infos[2];
-
- if (info)
- remove_source (info);
-
- /* move sources */
- for (i = 2; i > 0; i--) {
- state->infos[i] = state->infos[i - 1];
- }
-
- /* add new source, stop adding sources after 10 rounds. */
- if (state->count < 20) {
- state->infos[0] = add_source (
- (gdouble) ((state->count * 100) + 200),
- ((gfloat) (state->count % 5) / 2.0 - 1.0));
- state->count++;
- } else {
- state->infos[0] = NULL;
- }
-
- GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
- /*GST_DEBUG_GRAPH_SHOW_ALL, */
- GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS | GST_DEBUG_GRAPH_SHOW_STATES,
- "sprinkle3");
- return TRUE;
-}
-
-static void
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
- g_print ("message from \"%s\" (%s): ",
- GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))),
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
- if (s) {
- gchar *sstr;
-
- sstr = gst_structure_to_string (s);
- g_print ("%s\n", sstr);
- g_free (sstr);
- } else {
- g_print ("no message details\n");
- }
-}
-
-static void
-eos_message_received (GstBus * bus, GstMessage * message,
- GstPipeline * pipeline)
-{
- message_received (bus, message, pipeline);
- g_main_loop_quit (loop);
-}
-
-int
-main (int argc, char *argv[])
-{
- GstBus *bus;
- GstElement *filter, *convert, *sink;
- GstCaps *caps;
- gboolean res;
- SprinkleState *state;
-
- gst_init (&argc, &argv);
-
- loop = g_main_loop_new (NULL, TRUE);
-
- pipeline = gst_pipeline_new ("pipeline");
-
- /* add the fixed part to the pipeline. Remember that we need a capsfilter
- * after adder so that multiple sources are not racing to negotiate
- * a format */
- adder = gst_element_factory_make ("adder", "adder");
- filter = gst_element_factory_make ("capsfilter", "filter");
- convert = gst_element_factory_make ("audioconvert", "convert");
- sink = gst_element_factory_make ("autoaudiosink", "sink");
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
- "channels", G_TYPE_INT, 2,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 44100, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
- g_object_set (filter, "caps", caps, NULL);
- gst_caps_unref (caps);
-
- gst_bin_add_many (GST_BIN (pipeline), adder, filter, convert, sink, NULL);
-
- res = gst_element_link_many (adder, filter, convert, sink, NULL);
- g_assert (res);
-
- /* setup message handling */
- bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
- g_signal_connect (bus, "message::error", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::warning", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::eos", (GCallback) eos_message_received,
- pipeline);
-
- /* we set the pipeline to PLAYING, the pipeline will not yet preroll because
- * there is no source providing data for it yet */
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- /* and add the function that modifies the pipeline every 100ms */
- state = create_state ();
- g_timeout_add (100, (GSourceFunc) do_sprinkle, state);
-
- /* go to main loop */
- g_main_loop_run (loop);
-
- gst_element_set_state (pipeline, GST_STATE_NULL);
-
- free_state (state);
- gst_object_unref (bus);
- gst_object_unref (pipeline);
-
- return 0;
-}
diff --git a/tests/examples/gio/.gitignore b/tests/examples/gio/.gitignore
deleted file mode 100644
index 673c0788..00000000
--- a/tests/examples/gio/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-giosrc-mounting
diff --git a/tests/examples/gio/Makefile.am b/tests/examples/gio/Makefile.am
deleted file mode 100644
index 278edb71..00000000
--- a/tests/examples/gio/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-if HAVE_GTK
-if USE_GIO
-noinst_PROGRAMS = giosrc-mounting
-giosrc_mounting_SOURCES = giosrc-mounting.c
-giosrc_mounting_CFLAGS = $(GTK_CFLAGS) $(GIO_CFLAGS) $(GST_CFLAGS)
-giosrc_mounting_LDFLAGS = $(GTK_LIBS) $(GIO_LIBS) $(GST_LIBS)
-endif
-endif
diff --git a/tests/examples/gio/giosrc-mounting.c b/tests/examples/gio/giosrc-mounting.c
deleted file mode 100644
index b6d4731a..00000000
--- a/tests/examples/gio/giosrc-mounting.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
- *
- * 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/gst.h>
-#include <gtk/gtk.h>
-
-#include <string.h>
-
-static GstElement *pipeline = NULL;
-
-static void
-mount_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
-{
- gboolean ret;
- GError *err = NULL;
-
- ret = g_file_mount_enclosing_volume_finish (G_FILE (obj), res, &err);
-
- if (ret) {
- g_print ("mounted successfully\n");
- gst_bus_set_flushing ((GstBus *) user_data, FALSE);
-
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- } else {
- g_print ("mounting failed: %s\n", err->message);
- g_clear_error (&err);
- gtk_main_quit ();
- }
-}
-
-gboolean
-message_handler (GstBus * bus, GstMessage * message, gpointer user_data)
-{
-
- switch (message->type) {
- case GST_MESSAGE_ELEMENT:{
- const GstStructure *s = gst_message_get_structure (message);
- const gchar *name = gst_structure_get_name (s);
-
- if (strcmp (name, "not-mounted") == 0) {
- GMountOperation *mop = gtk_mount_operation_new (NULL);
- GFile *file =
- G_FILE (g_value_get_object (gst_structure_get_value
- (message->structure, "file")));
-
- g_print ("not-mounted\n");
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_bus_set_flushing (bus, TRUE);
-
- g_file_mount_enclosing_volume (file, G_MOUNT_MOUNT_NONE,
- mop, NULL, mount_cb, bus);
-
- g_object_unref (mop);
- }
- break;
- }
-
- case GST_MESSAGE_EOS:
- g_print ("EOS\n");
- gtk_main_quit ();
- break;
- case GST_MESSAGE_ERROR:{
- GError *err = NULL;
-
- gst_message_parse_error (message, &err, NULL);
- g_print ("error: %s\n", err->message);
- g_clear_error (&err);
-
- gtk_main_quit ();
- break;
- }
- default:
- break;
- }
-
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- GstBus *bus;
- gint watch_id;
-
- if (argc != 2) {
- g_print ("usage: giosrc-mounting URI\n");
- return -1;
- }
-
- gst_init (NULL, NULL);
- gtk_init (NULL, NULL);
-
- pipeline = gst_element_factory_make ("playbin2", NULL);
- g_assert (pipeline);
- g_object_set (G_OBJECT (pipeline), "uri", argv[1], NULL);
-
- bus = gst_element_get_bus (pipeline);
- watch_id = gst_bus_add_watch (bus, message_handler, NULL);
- gst_object_unref (bus);
-
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- gtk_main ();
-
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
-
- return 0;
-}
diff --git a/tests/examples/overlay/.gitignore b/tests/examples/overlay/.gitignore
deleted file mode 100644
index c8795e7f..00000000
--- a/tests/examples/overlay/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-gtk-xoverlay
-qt-xoverlay
-qtgv-xoverlay
-moc_*.cpp
-
diff --git a/tests/examples/overlay/Makefile.am b/tests/examples/overlay/Makefile.am
deleted file mode 100644
index 55085521..00000000
--- a/tests/examples/overlay/Makefile.am
+++ /dev/null
@@ -1,47 +0,0 @@
-EXAMPLES =
-
-if USE_X
-
-if HAVE_GTK_X11
-EXAMPLES += gtk-xoverlay
-
-gtk_xoverlay_SOURCES = gtk-xoverlay.c
-gtk_xoverlay_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(X_CFLAGS) $(GTK_CFLAGS)
-gtk_xoverlay_LDADD = $(GST_LIBS) $(X_LIBS) $(LIBM) $(GTK_LIBS) \
- $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-$(GST_MAJORMINOR).la
-endif
-
-if HAVE_QT
-EXAMPLES += qt-xoverlay
-
-qt_xoverlay_SOURCES = qt-xoverlay.cpp
-qt_xoverlay_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(X_CFLAGS) $(QT_CFLAGS)
-qt_xoverlay_LDADD = $(GST_LIBS) $(X_LIBS) $(LIBM) $(QT_LIBS) \
- $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-$(GST_MAJORMINOR).la
-
-endif
-
-if HAVE_QT_GV
-EXAMPLES += qtgv-xoverlay
-
-qtgv_xoverlay_SOURCES = qtgv-xoverlay.cpp
-qtgv_xoverlay_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) $(X_CFLAGS) $(QT_CFLAGS)
-qtgv_xoverlay_LDADD = $(GST_LIBS) $(X_LIBS) $(LIBM) $(QT_LIBS) \
- $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-$(GST_MAJORMINOR).la
-
-# qt moc support, according to http://qtnode.net/wiki/Qt_with_autotools
-
-nodist_qtgv_xoverlay_SOURCES = moc_qtgv-xoverlay.cpp
-
-moc_%.cpp:%.h
- moc $< -o $@
-
-EXTRA_DIST = $(nodist_qtgv_xoverlay_SOURCES:moc_%.cpp=%.h) qtgv-xoverlay.h
-CLEANFILES = $(nodist_qtgv_xoverlay_SOURCES)
-
-endif
-
-endif
-
-noinst_PROGRAMS = $(EXAMPLES)
-
diff --git a/tests/examples/overlay/gtk-xoverlay.c b/tests/examples/overlay/gtk-xoverlay.c
deleted file mode 100644
index 9a08c95f..00000000
--- a/tests/examples/overlay/gtk-xoverlay.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/* GStreamer
- * Copyright (C) <2010> Stefan Kost <ensonic@users.sf.net>
- *
- * gtk-xoverlay: demonstrate overlay handling using gtk
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib.h>
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include <gst/gst.h>
-#include <gst/interfaces/xoverlay.h>
-
-#include <string.h>
-
-static void
-window_closed (GtkWidget * widget, GdkEvent * event, gpointer user_data)
-{
- GstElement *pipeline = user_data;
-
- gtk_widget_hide_all (widget);
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gtk_main_quit ();
-}
-
-/* slightly convoluted way to find a working video sink that's not a bin,
- * one could use autovideosink from gst-plugins-good instead
- */
-static GstElement *
-find_video_sink (void)
-{
- GstStateChangeReturn sret;
- GstElement *sink;
-
- if ((sink = gst_element_factory_make ("xvimagesink", NULL))) {
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret == GST_STATE_CHANGE_SUCCESS)
- return sink;
-
- gst_element_set_state (sink, GST_STATE_NULL);
- }
- gst_object_unref (sink);
-
- if ((sink = gst_element_factory_make ("ximagesink", NULL))) {
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret == GST_STATE_CHANGE_SUCCESS)
- return sink;
-
- gst_element_set_state (sink, GST_STATE_NULL);
- }
- gst_object_unref (sink);
-
- if (strcmp (DEFAULT_VIDEOSINK, "xvimagesink") == 0 ||
- strcmp (DEFAULT_VIDEOSINK, "ximagesink") == 0)
- return NULL;
-
- if ((sink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL))) {
- if (GST_IS_BIN (sink)) {
- gst_object_unref (sink);
- return NULL;
- }
-
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret == GST_STATE_CHANGE_SUCCESS)
- return sink;
-
- gst_element_set_state (sink, GST_STATE_NULL);
- }
- gst_object_unref (sink);
- return NULL;
-}
-
-int
-main (int argc, char **argv)
-{
- GtkWidget *window, *video_window;
- GstElement *pipeline, *src, *sink;
- gulong embed_xid;
- GstStateChangeReturn sret;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
- gst_init (&argc, &argv);
- gtk_init (&argc, &argv);
-
- /* prepare the pipeline */
-
- pipeline = gst_pipeline_new ("xvoverlay");
- src = gst_element_factory_make ("videotestsrc", NULL);
- sink = find_video_sink ();
-
- if (sink == NULL)
- g_error ("Couldn't find a working video sink.");
-
- gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
- gst_element_link (src, sink);
-
- /* prepare the ui */
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (G_OBJECT (window), "delete-event",
- G_CALLBACK (window_closed), (gpointer) pipeline);
- gtk_window_set_default_size (GTK_WINDOW (window), 320, 240);
- gtk_window_set_title (GTK_WINDOW (window), "GstXOverlay Gtk+ demo");
-
- video_window = gtk_drawing_area_new ();
- gtk_widget_set_double_buffered (video_window, FALSE);
- gtk_container_add (GTK_CONTAINER (window), video_window);
- gtk_container_set_border_width (GTK_CONTAINER (window), 16);
-
- gtk_widget_show_all (window);
- gtk_widget_realize (window);
-
- embed_xid = GDK_WINDOW_XID (video_window->window);
- gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), embed_xid);
-
- /* run the pipeline */
-
- sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
- if (sret == GST_STATE_CHANGE_FAILURE)
- gst_element_set_state (pipeline, GST_STATE_NULL);
- else
- gtk_main ();
-
- gst_object_unref (pipeline);
- return 0;
-}
diff --git a/tests/examples/overlay/qt-xoverlay.cpp b/tests/examples/overlay/qt-xoverlay.cpp
deleted file mode 100644
index 7edfabb7..00000000
--- a/tests/examples/overlay/qt-xoverlay.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/* GStreamer
- * Copyright (C) <2010> Stefan Kost <ensonic@users.sf.net>
- *
- * qt-xoverlay: demonstrate overlay handling using qt
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib.h>
-#include <gst/gst.h>
-#include <gst/interfaces/xoverlay.h>
-
-#include <QApplication>
-#include <QTimer>
-#include <QWidget>
-
-/* slightly convoluted way to find a working video sink that's not a bin,
- * one could use autovideosink from gst-plugins-good instead
- */
-static GstElement *
-find_video_sink (void)
-{
- GstStateChangeReturn sret;
- GstElement *sink;
-
- if ((sink = gst_element_factory_make ("xvimagesink", NULL))) {
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret == GST_STATE_CHANGE_SUCCESS)
- return sink;
-
- gst_element_set_state (sink, GST_STATE_NULL);
- }
- gst_object_unref (sink);
-
- if ((sink = gst_element_factory_make ("ximagesink", NULL))) {
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret == GST_STATE_CHANGE_SUCCESS)
- return sink;
-
- gst_element_set_state (sink, GST_STATE_NULL);
- }
- gst_object_unref (sink);
-
- if (strcmp (DEFAULT_VIDEOSINK, "xvimagesink") == 0 ||
- strcmp (DEFAULT_VIDEOSINK, "ximagesink") == 0)
- return NULL;
-
- if ((sink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL))) {
- if (GST_IS_BIN (sink)) {
- gst_object_unref (sink);
- return NULL;
- }
-
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret == GST_STATE_CHANGE_SUCCESS)
- return sink;
-
- gst_element_set_state (sink, GST_STATE_NULL);
- }
- gst_object_unref (sink);
- return NULL;
-}
-
-int main(int argc, char *argv[])
-{
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
- gst_init (&argc, &argv);
- QApplication app(argc, argv);
- app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
-
- /* prepare the pipeline */
-
- GstElement *pipeline = gst_pipeline_new ("xvoverlay");
- GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
- GstElement *sink = find_video_sink ();
-
- if (sink == NULL)
- g_error ("Couldn't find a working video sink.");
-
- gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
- gst_element_link (src, sink);
-
- /* prepare the ui */
-
- QWidget window;
- window.resize(320, 240);
- window.setWindowTitle("GstXOverlay Qt demo");
- window.show();
-
- WId xwinid = window.winId();
- gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), xwinid);
-
- /* run the pipeline */
-
- GstStateChangeReturn sret = gst_element_set_state (pipeline,
- GST_STATE_PLAYING);
- if (sret == GST_STATE_CHANGE_FAILURE) {
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
- /* Exit application */
- QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
- }
-
- int ret = app.exec();
-
- window.hide();
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
-
- return ret;
-}
diff --git a/tests/examples/overlay/qtgv-xoverlay.cpp b/tests/examples/overlay/qtgv-xoverlay.cpp
deleted file mode 100644
index 69252864..00000000
--- a/tests/examples/overlay/qtgv-xoverlay.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/* GStreamer
- * Copyright (C) <2010> Alexander Bokovoy <ab@samba.org>
- *
- * qtgv-xoverlay: demonstrate overlay handling using qt graphics view
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "qtgv-xoverlay.h"
-
-#include <QApplication>
-#include <QTimer>
-
-#include <gst/interfaces/xoverlay.h>
-
-SinkPipeline::SinkPipeline(QGraphicsView *parent) : QObject(parent)
-{
- GstStateChangeReturn sret;
-
- pipeline = gst_pipeline_new ("xvoverlay");
- src = gst_element_factory_make ("videotestsrc", NULL);
-
- if ((sink = gst_element_factory_make ("xvimagesink", NULL))) {
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret != GST_STATE_CHANGE_SUCCESS) {
- gst_element_set_state (sink, GST_STATE_NULL);
- gst_object_unref (sink);
-
- if ((sink = gst_element_factory_make ("ximagesink", NULL))) {
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret != GST_STATE_CHANGE_SUCCESS) {
- gst_element_set_state (sink, GST_STATE_NULL);
- gst_object_unref (sink);
-
- if (strcmp (DEFAULT_VIDEOSINK, "xvimagesink") != 0 &&
- strcmp (DEFAULT_VIDEOSINK, "ximagesink") != 0) {
-
- if ((sink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL))) {
- if (!GST_IS_BIN (sink)) {
- sret = gst_element_set_state (sink, GST_STATE_READY);
- if (sret != GST_STATE_CHANGE_SUCCESS) {
- gst_element_set_state (sink, GST_STATE_NULL);
- gst_object_unref (sink);
- sink = NULL;
- }
- } else {
- gst_object_unref (sink);
- sink = NULL;
- }
- }
- }
- }
- }
- }
- }
-
- if (sink == NULL)
- g_error ("Couldn't find a working video sink.");
-
- gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
- gst_element_link (src, sink);
- xwinid = parent->winId();
-}
-
-SinkPipeline::~SinkPipeline()
-{
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
-}
-
-void SinkPipeline::startPipeline()
-{
- GstStateChangeReturn sret;
-
- /* we know what the video sink is in this case (xvimagesink), so we can
- * just set it directly here now (instead of waiting for a prepare-xwindow-id
- * element message in a sync bus handler and setting it there) */
-
- gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), xwinid);
-
- sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
- if (sret == GST_STATE_CHANGE_FAILURE) {
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
- /* Exit application */
- QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
- }
-}
-
-int main( int argc, char **argv )
-{
- QApplication app(argc, argv);
-
- QGraphicsScene scene;
- scene.setSceneRect( -100.0, -100.0, 200.0, 200.0 );
-
- QGraphicsView view( &scene );
- view.resize(320, 240);
- view.setWindowTitle("GstXOverlay Qt GraphicsView demo");
- view.show();
-
- gst_init (&argc, &argv);
- SinkPipeline pipeline(&view);
- pipeline.startPipeline();
-
- int ret = app.exec();
-
- view.hide();
-
- return ret;
-}
diff --git a/tests/examples/overlay/qtgv-xoverlay.h b/tests/examples/overlay/qtgv-xoverlay.h
deleted file mode 100644
index 091fff8b..00000000
--- a/tests/examples/overlay/qtgv-xoverlay.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* GStreamer
- * Copyright (C) <2010> Alexander Bokovoy <ab@samba.org>
- *
- * qtgv-xoverlay: demonstrate overlay handling using qt graphics view
- *
- * 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.
- */
-
-#ifndef QTGV_XOVERLAY_H
-#define QTGV_XOVERLAY_H
-
-#include <QGraphicsView>
-#include <gst/gst.h>
-
-
-class SinkPipeline : public QObject
-{
- Q_OBJECT
-public:
- SinkPipeline(QGraphicsView *parent = 0);
- ~SinkPipeline();
-
- void startPipeline();
-
-private:
- GstElement *pipeline;
- GstElement *sink;
- GstElement *src;
- WId xwinid;
-};
-
-#endif // QTGV_XOVERLAY_H
diff --git a/tests/examples/seek/.gitignore b/tests/examples/seek/.gitignore
deleted file mode 100644
index e64781b2..00000000
--- a/tests/examples/seek/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-scrubby
-seek
-stepping
-stepping2
diff --git a/tests/examples/seek/Makefile.am b/tests/examples/seek/Makefile.am
deleted file mode 100644
index 792f96c1..00000000
--- a/tests/examples/seek/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-if HAVE_GTK_X11
-GTK_EXAMPLES=seek scrubby
-endif
-
-examples = $(GTK_EXAMPLES) stepping stepping2
-
-noinst_PROGRAMS = $(examples)
-
-LDADD = \
- $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
- $(GST_LIBS) $(GTK_LIBS) $(LIBM)
-
-AM_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GTK_CFLAGS) -I$(top_builddir)/gst-libs
diff --git a/tests/examples/seek/scrubby.c b/tests/examples/seek/scrubby.c
deleted file mode 100644
index 7517ec2a..00000000
--- a/tests/examples/seek/scrubby.c
+++ /dev/null
@@ -1,570 +0,0 @@
-#include <stdlib.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gst/gst.h>
-#include <string.h>
-
-GST_DEBUG_CATEGORY_STATIC (scrubby_debug);
-#define GST_CAT_DEFAULT (scrubby_debug)
-
-static GstElement *pipeline;
-static gint64 position;
-static gint64 duration;
-static GtkAdjustment *adjustment;
-static GtkWidget *hscale;
-static GtkAdjustment *sadjustment;
-static GtkWidget *shscale;
-static gboolean verbose = FALSE;
-
-static guint bus_watch = 0;
-static guint update_id = 0;
-static guint changed_id = 0;
-static guint schanged_id = 0;
-
-//#define SOURCE "filesrc"
-#define SOURCE "gnomevfssrc"
-#define ASINK "alsasink"
-//#define ASINK "osssink"
-#define VSINK "xvimagesink"
-//#define VSINK "ximagesink"
-//#define VSINK "aasink"
-//#define VSINK "cacasink"
-
-#define RANGE_PREC 10000
-#define SEGMENT_LEN 100
-#define UPDATE_INTERVAL 500
-
-static gdouble prev_range = -1.0;
-static GstClockTime prev_time = GST_CLOCK_TIME_NONE;
-static gdouble cur_range;
-static GstClockTime cur_time;
-static GstClockTimeDiff diff;
-static gdouble cur_speed = 1.0;
-
-typedef struct
-{
- const gchar *padname;
- GstPad *target;
- GstElement *bin;
-}
-dyn_link;
-
-static GstElement *
-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);
- }
-
- return element;
-}
-
-static void
-dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
-{
- dyn_link *connect = (dyn_link *) data;
-
- if (connect->padname == NULL ||
- !strcmp (gst_pad_get_name (newpad), connect->padname)) {
- if (connect->bin)
- gst_bin_add (GST_BIN (pipeline), connect->bin);
- gst_pad_link (newpad, connect->target);
- }
-}
-
-static void
-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;
-
- g_signal_connect (G_OBJECT (element), "pad-added", G_CALLBACK (dynamic_link),
- connect);
-}
-
-static GstElement *
-make_wav_pipeline (const gchar * location)
-{
- GstElement *pipeline;
- GstElement *src, *decoder, *audiosink;
-
- pipeline = gst_pipeline_new ("app");
-
- 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");
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), decoder);
- gst_bin_add (GST_BIN (pipeline), audiosink);
-
- gst_element_link (src, decoder);
-
- setup_dynamic_link (decoder, "src", gst_element_get_static_pad (audiosink,
- "sink"), NULL);
-
- return pipeline;
-}
-
-static GstElement *
-make_playerbin_pipeline (const gchar * location)
-{
- GstElement *player;
-
- player = gst_element_factory_make ("playbin", "player");
- g_assert (player);
-
- g_object_set (G_OBJECT (player), "uri", location, NULL);
-
- return player;
-}
-
-static gchar *
-format_value (GtkScale * scale, gdouble value)
-{
- gint64 real;
- gint64 seconds;
- gint64 subseconds;
-
- real = value * duration / RANGE_PREC;
- seconds = (gint64) real / GST_SECOND;
- subseconds = (gint64) real / (GST_SECOND / RANGE_PREC);
-
- return g_strdup_printf ("%02" G_GINT64_FORMAT ":%02" G_GINT64_FORMAT ":%02"
- G_GINT64_FORMAT, seconds / 60, seconds % 60, subseconds % 100);
-}
-
-static gboolean
-update_scale (gpointer data)
-{
- GstFormat format;
-
- position = 0;
- duration = 0;
-
- format = GST_FORMAT_TIME;
-
- gst_element_query_position (pipeline, &format, &position);
- gst_element_query_duration (pipeline, &format, &duration);
-
- if (position >= duration)
- duration = position;
-
- if (duration > 0) {
- gtk_adjustment_set_value (adjustment,
- position * (gdouble) RANGE_PREC / duration);
- gtk_widget_queue_draw (hscale);
- }
-
- return TRUE;
-}
-
-static void
-speed_cb (GtkWidget * widget)
-{
- GstEvent *s_event;
- gboolean res;
-
- GST_DEBUG ("speed change");
- cur_speed = gtk_range_get_value (GTK_RANGE (widget));
-
- if (cur_speed == 0.0)
- return;
-
- s_event = gst_event_new_seek (cur_speed,
- GST_FORMAT_TIME, 0, GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_NONE, -1);
-
- res = gst_element_send_event (pipeline, s_event);
- if (!res)
- g_print ("speed change failed\n");
-}
-
-static gboolean do_seek (GtkWidget * widget, gboolean flush, gboolean segment);
-
-static void
-seek_cb (GtkWidget * widget)
-{
- if (changed_id) {
- GST_DEBUG ("seek because of slider move");
-
- if (do_seek (widget, TRUE, TRUE)) {
- g_source_remove (changed_id);
- changed_id = 0;
- }
- }
-}
-
-static gboolean
-do_seek (GtkWidget * widget, gboolean flush, gboolean segment)
-{
- gint64 start, stop;
- gboolean res = FALSE;
- GstEvent *s_event;
- gdouble rate;
- GTimeVal tv;
- gboolean valid;
- gdouble new_range;
-
- if (segment)
- new_range = gtk_range_get_value (GTK_RANGE (widget));
- else {
- new_range = (gdouble) RANGE_PREC;
- cur_time = -1;
- }
-
- valid = prev_time != -1;
-
- GST_DEBUG ("flush %d, segment %d, valid %d", flush, segment, valid);
-
- if (new_range == cur_range)
- return FALSE;
-
- prev_time = cur_time;
- prev_range = cur_range;
-
- cur_range = new_range;
-
- g_get_current_time (&tv);
- cur_time = GST_TIMEVAL_TO_TIME (tv);
-
- if (!valid)
- return FALSE;
-
- GST_DEBUG ("cur: %lf, %" GST_TIME_FORMAT, cur_range,
- GST_TIME_ARGS (cur_time));
- GST_DEBUG ("prev: %lf, %" GST_TIME_FORMAT, prev_range,
- GST_TIME_ARGS (prev_time));
-
- diff = cur_time - prev_time;
-
- GST_DEBUG ("diff: %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
-
- start = prev_range * duration / RANGE_PREC;
- /* play 50 milliseconds */
- stop = segment ? cur_range * duration / RANGE_PREC : duration;
-
- if (start == stop)
- return FALSE;
-
- if (segment)
- rate = (stop - start) / (gdouble) diff;
- else
- rate = cur_speed;
-
- if (start > stop) {
- gint64 tmp;
-
- tmp = start;
- start = stop;
- stop = tmp;
- }
-
- if (rate == 0.0)
- return TRUE;
-
- GST_DEBUG ("seek to %" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT ", rate %lf"
- " on element %s",
- GST_TIME_ARGS (start), GST_TIME_ARGS (stop), rate,
- GST_ELEMENT_NAME (pipeline));
-
- s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME,
- (flush ? GST_SEEK_FLAG_FLUSH : 0) |
- (segment ? GST_SEEK_FLAG_SEGMENT : 0),
- GST_SEEK_TYPE_SET, start, GST_SEEK_TYPE_SET, stop);
-
- res = gst_element_send_event (pipeline, s_event);
- if (!res)
- g_print ("seek failed\n");
-
- gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
-
- return TRUE;
-}
-
-static gboolean
-start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- if (update_id) {
- g_source_remove (update_id);
- update_id = 0;
- }
-
- if (changed_id == 0) {
- changed_id =
- g_signal_connect (hscale, "value_changed", G_CALLBACK (seek_cb),
- pipeline);
- }
-
- GST_DEBUG ("start seek");
-
- return FALSE;
-}
-
-static gboolean
-stop_seek (GtkWidget * widget, gpointer user_data)
-{
- update_id =
- g_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
-
- GST_DEBUG ("stop seek");
-
- if (changed_id) {
- g_source_remove (changed_id);
- changed_id = 0;
- }
-
- do_seek (hscale, FALSE, FALSE);
-
- return FALSE;
-}
-
-static void
-play_cb (GtkButton * button, gpointer data)
-{
- GstState state;
-
- gst_element_get_state (pipeline, &state, NULL, GST_CLOCK_TIME_NONE);
- if (state != GST_STATE_PLAYING) {
- g_print ("PLAY pipeline\n");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- update_id =
- g_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
- }
-}
-
-static void
-pause_cb (GtkButton * button, gpointer data)
-{
- GstState state;
-
- gst_element_get_state (pipeline, &state, NULL, GST_CLOCK_TIME_NONE);
- if (state != GST_STATE_PAUSED) {
- g_print ("PAUSE pipeline\n");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- g_source_remove (update_id);
- }
-}
-
-static void
-stop_cb (GtkButton * button, gpointer data)
-{
- GstState state;
-
- gst_element_get_state (pipeline, &state, NULL, GST_CLOCK_TIME_NONE);
- if (state != GST_STATE_READY) {
- g_print ("READY pipeline\n");
- gst_element_set_state (pipeline, GST_STATE_READY);
- /* position and speed return to their default values */
- gtk_adjustment_set_value (adjustment, 0.0);
- gtk_adjustment_set_value (sadjustment, 1.0);
- g_source_remove (update_id);
- }
-}
-
-static void
-print_message (GstMessage * message)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
- g_print ("Got Message from element \"%s\"\n",
- GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))));
-
- if (s) {
- gchar *sstr;
-
- sstr = gst_structure_to_string (s);
- g_print ("%s\n", sstr);
- g_free (sstr);
- }
-}
-
-static gboolean
-bus_message (GstBus * bus, GstMessage * message, gpointer data)
-{
- switch (GST_MESSAGE_TYPE (message)) {
- case GST_MESSAGE_EOS:
- g_print ("EOS\n");
- break;
- case GST_MESSAGE_ERROR:
- case GST_MESSAGE_WARNING:
- print_message (message);
- break;
- case GST_MESSAGE_SEGMENT_START:
- break;
- case GST_MESSAGE_SEGMENT_DONE:
- GST_DEBUG ("segment_done, doing next seek");
- if (!do_seek (hscale, FALSE, update_id == 0)) {
- if (changed_id == 0) {
- changed_id =
- g_signal_connect (hscale, "value_changed", G_CALLBACK (seek_cb),
- pipeline);
- }
- }
- break;
- default:
- break;
- }
-
- return TRUE;
-}
-
-typedef struct
-{
- gchar *name;
- GstElement *(*func) (const gchar * location);
-}
-Pipeline;
-
-static Pipeline pipelines[] = {
- {"wav", make_wav_pipeline},
- {"playerbin", make_playerbin_pipeline},
- {NULL, NULL},
-};
-
-#define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
-
-static void
-print_usage (int argc, char **argv)
-{
- gint i;
-
- g_print ("usage: %s <type> <filename>\n", argv[0]);
- g_print (" possible types:\n");
-
- for (i = 0; i < NUM_TYPES; i++) {
- g_print (" %d = %s\n", i, pipelines[i].name);
- }
-}
-
-int
-main (int argc, char **argv)
-{
- GtkWidget *window, *hbox, *vbox, *play_button, *pause_button, *stop_button;
- GstBus *bus;
- GOptionEntry options[] = {
- {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
- "Verbose properties", NULL},
- {NULL}
- };
- gint type;
- GOptionContext *ctx;
- GError *err = NULL;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
- ctx = g_option_context_new ("seek");
- g_option_context_add_main_entries (ctx, options, NULL);
- g_option_context_add_group (ctx, gst_init_get_option_group ());
-
- if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
- g_print ("Error initializing: %s\n", err->message);
- exit (1);
- }
-
- GST_DEBUG_CATEGORY_INIT (scrubby_debug, "scrubby", 0, "scrubby example");
-
- gtk_init (&argc, &argv);
-
- if (argc != 3) {
- print_usage (argc, argv);
- exit (-1);
- }
-
- type = atoi (argv[1]);
-
- if (type < 0 || type >= NUM_TYPES) {
- print_usage (argc, argv);
- exit (-1);
- }
-
- pipeline = pipelines[type].func (argv[2]);
- g_assert (pipeline);
-
- /* initialize gui elements ... */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- hbox = gtk_hbox_new (FALSE, 0);
- vbox = gtk_vbox_new (FALSE, 0);
- play_button = gtk_button_new_with_label ("play");
- 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.0, (gdouble) RANGE_PREC, 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);
-
- sadjustment =
- GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 0.0, 5.0, 0.1, 1.0, 0.0));
- shscale = gtk_hscale_new (sadjustment);
- gtk_scale_set_digits (GTK_SCALE (shscale), 2);
- gtk_range_set_update_policy (GTK_RANGE (shscale), GTK_UPDATE_CONTINUOUS);
-
- schanged_id =
- g_signal_connect (shscale, "value_changed", G_CALLBACK (speed_cb),
- pipeline);
-
- g_signal_connect (hscale, "button_press_event", G_CALLBACK (start_seek),
- pipeline);
- g_signal_connect (hscale, "button_release_event", G_CALLBACK (stop_seek),
- pipeline);
- g_signal_connect (hscale, "format_value", G_CALLBACK (format_value),
- pipeline);
-
- /* do the packing stuff ... */
- gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_container_add (GTK_CONTAINER (vbox), hbox);
- gtk_box_pack_start (GTK_BOX (hbox), play_button, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), pause_button, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), stop_button, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), shscale, 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 (window), "delete_event", gtk_main_quit, NULL);
-
- /* show the gui. */
- gtk_widget_show_all (window);
-
- if (verbose) {
- g_signal_connect (pipeline, "deep_notify",
- G_CALLBACK (gst_object_default_deep_notify), NULL);
- }
- bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- g_assert (bus);
-
- bus_watch = gst_bus_add_watch_full (bus,
- G_PRIORITY_HIGH, bus_message, pipeline, NULL);
-
- gtk_main ();
-
- g_print ("NULL pipeline\n");
- gst_element_set_state (pipeline, GST_STATE_NULL);
-
- g_print ("free pipeline\n");
- gst_object_unref (pipeline);
-
- return 0;
-}
diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c
deleted file mode 100644
index 405e00ed..00000000
--- a/tests/examples/seek/seek.c
+++ /dev/null
@@ -1,2945 +0,0 @@
-/* GStreamer
- *
- * seek.c: seeking sample application
- *
- * Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
- * 2006 Stefan Kost <ensonic@users.sf.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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <math.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gst/gst.h>
-#include <string.h>
-
-#ifdef HAVE_X
-#include <gdk/gdkx.h>
-#endif
-#include <gst/interfaces/xoverlay.h>
-
-GST_DEBUG_CATEGORY_STATIC (seek_debug);
-#define GST_CAT_DEFAULT (seek_debug)
-
-/* configuration */
-
-//#define SOURCE "filesrc"
-#define SOURCE "gnomevfssrc"
-
-#define ASINK "alsasink"
-//#define ASINK "osssink"
-
-#define VSINK "xvimagesink"
-//#define VSINK "sdlvideosink"
-//#define VSINK "ximagesink"
-//#define VSINK "aasink"
-//#define VSINK "cacasink"
-
-#define FILL_INTERVAL 100
-//#define UPDATE_INTERVAL 500
-//#define UPDATE_INTERVAL 100
-#define UPDATE_INTERVAL 40
-
-/* number of milliseconds to play for after a seek */
-#define SCRUB_TIME 100
-
-/* timeout for gst_element_get_state() after a seek */
-#define SEEK_TIMEOUT 40 * GST_MSECOND
-
-#define DEFAULT_VIDEO_HEIGHT 300
-
-/* the state to go to when stop is pressed */
-#define STOP_STATE GST_STATE_READY
-
-
-static GList *seekable_pads = NULL;
-static GList *rate_pads = NULL;
-static GList *seekable_elements = NULL;
-
-static gboolean accurate_seek = FALSE;
-static gboolean keyframe_seek = FALSE;
-static gboolean loop_seek = FALSE;
-static gboolean flush_seek = TRUE;
-static gboolean scrub = TRUE;
-static gboolean play_scrub = FALSE;
-static gboolean skip_seek = FALSE;
-static gdouble rate = 1.0;
-
-static GstElement *pipeline;
-static gint pipeline_type;
-static const gchar *pipeline_spec;
-static gint64 position = -1;
-static gint64 duration = -1;
-static GtkAdjustment *adjustment;
-static GtkWidget *hscale, *statusbar;
-static guint status_id = 0;
-static gboolean stats = FALSE;
-static gboolean elem_seek = FALSE;
-static gboolean verbose = FALSE;
-
-static gboolean is_live = FALSE;
-static gboolean buffering = FALSE;
-static GstBufferingMode mode;
-static gint64 buffering_left;
-static GstState state = GST_STATE_NULL;
-static guint update_id = 0;
-static guint seek_timeout_id = 0;
-static gulong changed_id;
-static guint fill_id = 0;
-
-static gint n_video = 0, n_audio = 0, n_text = 0;
-static gboolean need_streams = TRUE;
-static GtkWidget *video_combo, *audio_combo, *text_combo, *vis_combo;
-static GtkWidget *vis_checkbox, *video_checkbox, *audio_checkbox;
-static GtkWidget *text_checkbox, *mute_checkbox, *volume_spinbutton;
-static GtkWidget *skip_checkbox, *video_window, *download_checkbox;
-static GtkWidget *buffer_checkbox, *rate_spinbutton;
-
-static GStaticMutex state_mutex = G_STATIC_MUTEX_INIT;
-
-static GtkWidget *format_combo, *step_amount_spinbutton, *step_rate_spinbutton;
-static GtkWidget *shuttle_checkbox, *step_button;
-static GtkWidget *shuttle_hscale;
-static GtkAdjustment *shuttle_adjustment;
-
-static GList *paths = NULL, *l = NULL;
-
-/* we keep an array of the visualisation entries so that we can easily switch
- * with the combo box index. */
-typedef struct
-{
- GstElementFactory *factory;
-} VisEntry;
-
-static GArray *vis_entries;
-
-static void clear_streams (GstElement * pipeline);
-static void volume_notify_cb (GstElement * pipeline, GParamSpec * arg,
- gpointer user_dat);
-
-/* pipeline construction */
-
-typedef struct
-{
- const gchar *padname;
- GstPad *target;
- GstElement *bin;
-}
-dyn_link;
-
-static GstElement *
-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);
- }
-
- return element;
-}
-
-static void
-dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
-{
- gchar *padname;
- dyn_link *connect = (dyn_link *) data;
-
- padname = gst_pad_get_name (newpad);
-
- if (connect->padname == NULL || !strcmp (padname, connect->padname)) {
- if (connect->bin)
- gst_bin_add (GST_BIN (pipeline), connect->bin);
- gst_pad_link (newpad, connect->target);
-
- //seekable_pads = g_list_prepend (seekable_pads, newpad);
- rate_pads = g_list_prepend (rate_pads, newpad);
- }
- g_free (padname);
-}
-
-static void
-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;
-
- g_signal_connect (G_OBJECT (element), "pad-added", G_CALLBACK (dynamic_link),
- connect);
-}
-
-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");
- decoder = gst_element_factory_make_or_warn ("modplug", "decoder");
- audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
- //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), decoder);
- gst_bin_add (GST_BIN (pipeline), audiosink);
-
- gst_element_link (src, decoder);
- gst_element_link (decoder, audiosink);
-
- seekable = gst_element_get_static_pad (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_static_pad (decoder, "sink"));
-
- return pipeline;
-}
-
-static GstElement *
-make_dv_pipeline (const gchar * location)
-{
- GstElement *pipeline;
- GstElement *src, *demux, *decoder, *audiosink, *videosink;
- GstElement *a_queue, *v_queue;
- GstPad *seekable;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- 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");
- a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
- audiosink = gst_element_factory_make_or_warn ("alsasink", "a_sink");
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_bin_add (GST_BIN (pipeline), a_queue);
- gst_bin_add (GST_BIN (pipeline), audiosink);
- gst_bin_add (GST_BIN (pipeline), v_queue);
- gst_bin_add (GST_BIN (pipeline), decoder);
- gst_bin_add (GST_BIN (pipeline), videosink);
-
- gst_element_link (src, demux);
- gst_element_link (a_queue, audiosink);
- gst_element_link (v_queue, decoder);
- gst_element_link (decoder, videosink);
-
- setup_dynamic_link (demux, "video", gst_element_get_static_pad (v_queue,
- "sink"), NULL);
- setup_dynamic_link (demux, "audio", gst_element_get_static_pad (a_queue,
- "sink"), NULL);
-
- seekable = gst_element_get_static_pad (decoder, "src");
- seekable_pads = g_list_prepend (seekable_pads, seekable);
- rate_pads = g_list_prepend (rate_pads, seekable);
-
- return pipeline;
-}
-
-static GstElement *
-make_wav_pipeline (const gchar * location)
-{
- GstElement *pipeline;
- GstElement *src, *decoder, *audiosink;
-
- pipeline = gst_pipeline_new ("app");
-
- 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");
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), decoder);
- gst_bin_add (GST_BIN (pipeline), audiosink);
-
- gst_element_link (src, decoder);
-
- setup_dynamic_link (decoder, "src", gst_element_get_static_pad (audiosink,
- "sink"), NULL);
-
- seekable_elements = g_list_prepend (seekable_elements, audiosink);
-
- /* force element seeking on this pipeline */
- elem_seek = TRUE;
-
- return pipeline;
-}
-
-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");
- decoder = gst_element_factory_make_or_warn ("flacdec", "decoder");
- audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
- g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), decoder);
- gst_bin_add (GST_BIN (pipeline), audiosink);
-
- gst_element_link (src, decoder);
- gst_element_link (decoder, audiosink);
-
- seekable = gst_element_get_static_pad (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_static_pad (decoder, "sink"));
-
- return pipeline;
-}
-
-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");
- decoder = gst_element_factory_make_or_warn ("siddec", "decoder");
- audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
- //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), decoder);
- gst_bin_add (GST_BIN (pipeline), audiosink);
-
- gst_element_link (src, decoder);
- gst_element_link (decoder, audiosink);
-
- seekable = gst_element_get_static_pad (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_static_pad (decoder, "sink"));
-
- return pipeline;
-}
-
-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");
- parser = gst_element_factory_make_or_warn ("mpegparse", "parse");
- fakesink = gst_element_factory_make_or_warn ("fakesink", "sink");
- g_object_set (G_OBJECT (fakesink), "silent", TRUE, NULL);
- g_object_set (G_OBJECT (fakesink), "sync", TRUE, NULL);
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), parser);
- gst_bin_add (GST_BIN (pipeline), fakesink);
-
- gst_element_link (src, parser);
- gst_element_link (parser, fakesink);
-
- seekable = gst_element_get_static_pad (parser, "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_static_pad (parser, "sink"));
-
- return pipeline;
-}
-
-static GstElement *
-make_vorbis_pipeline (const gchar * location)
-{
- GstElement *pipeline, *audio_bin;
- GstElement *src, *demux, *decoder, *convert, *audiosink;
- GstPad *pad, *seekable;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- 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");
- g_object_set (G_OBJECT (audiosink), "sync", TRUE, NULL);
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- audio_bin = gst_bin_new ("a_decoder_bin");
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_bin_add (GST_BIN (audio_bin), decoder);
- gst_bin_add (GST_BIN (audio_bin), convert);
- gst_bin_add (GST_BIN (audio_bin), audiosink);
- gst_bin_add (GST_BIN (pipeline), audio_bin);
-
- gst_element_link (src, demux);
- gst_element_link (decoder, convert);
- gst_element_link (convert, audiosink);
-
- pad = gst_element_get_static_pad (decoder, "sink");
- gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, NULL, gst_element_get_static_pad (audio_bin,
- "sink"), NULL);
-
- seekable = gst_element_get_static_pad (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_static_pad (decoder, "sink"));
-
- return pipeline;
-}
-
-static GstElement *
-make_theora_pipeline (const gchar * location)
-{
- GstElement *pipeline, *video_bin;
- GstElement *src, *demux, *decoder, *convert, *videosink;
- GstPad *pad, *seekable;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- 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");
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- video_bin = gst_bin_new ("v_decoder_bin");
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_bin_add (GST_BIN (video_bin), decoder);
- gst_bin_add (GST_BIN (video_bin), convert);
- gst_bin_add (GST_BIN (video_bin), videosink);
- gst_bin_add (GST_BIN (pipeline), video_bin);
-
- gst_element_link (src, demux);
- gst_element_link (decoder, convert);
- gst_element_link (convert, videosink);
-
- pad = gst_element_get_static_pad (decoder, "sink");
- gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, NULL, gst_element_get_static_pad (video_bin,
- "sink"), NULL);
-
- seekable = gst_element_get_static_pad (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_static_pad (decoder, "sink"));
-
- return pipeline;
-}
-
-static GstElement *
-make_vorbis_theora_pipeline (const gchar * location)
-{
- GstElement *pipeline, *audio_bin, *video_bin;
- GstElement *src, *demux, *a_decoder, *a_convert, *v_decoder, *v_convert;
- GstElement *audiosink, *videosink;
- GstElement *a_queue, *v_queue, *v_scale;
- GstPad *seekable;
- GstPad *pad;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- demux = gst_element_factory_make_or_warn ("oggdemux", "demux");
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_element_link (src, demux);
-
- audio_bin = gst_bin_new ("a_decoder_bin");
- 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");
-
- gst_bin_add (GST_BIN (pipeline), audio_bin);
-
- gst_bin_add (GST_BIN (audio_bin), a_queue);
- gst_bin_add (GST_BIN (audio_bin), a_decoder);
- gst_bin_add (GST_BIN (audio_bin), a_convert);
- gst_bin_add (GST_BIN (audio_bin), audiosink);
-
- gst_element_link (a_queue, a_decoder);
- gst_element_link (a_decoder, a_convert);
- gst_element_link (a_convert, audiosink);
-
- pad = gst_element_get_static_pad (a_queue, "sink");
- gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, NULL, gst_element_get_static_pad (audio_bin,
- "sink"), NULL);
-
- video_bin = gst_bin_new ("v_decoder_bin");
- v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
- v_decoder = gst_element_factory_make_or_warn ("theoradec", "v_dec");
- 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");
-
- gst_bin_add (GST_BIN (pipeline), video_bin);
-
- gst_bin_add (GST_BIN (video_bin), v_queue);
- gst_bin_add (GST_BIN (video_bin), v_decoder);
- gst_bin_add (GST_BIN (video_bin), v_convert);
- gst_bin_add (GST_BIN (video_bin), v_scale);
- gst_bin_add (GST_BIN (video_bin), videosink);
-
- gst_element_link_many (v_queue, v_decoder, v_convert, v_scale, videosink,
- NULL);
-
- pad = gst_element_get_static_pad (v_queue, "sink");
- gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, NULL, gst_element_get_static_pad (video_bin,
- "sink"), NULL);
-
- seekable = gst_element_get_static_pad (a_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_static_pad (a_decoder,
- "sink"));
-
- return pipeline;
-}
-
-static GstElement *
-make_avi_msmpeg4v3_mp3_pipeline (const gchar * location)
-{
- GstElement *pipeline, *audio_bin, *video_bin;
- GstElement *src, *demux, *a_decoder, *a_convert, *v_decoder, *v_convert;
- GstElement *audiosink, *videosink;
- GstElement *a_queue, *v_queue;
- GstPad *seekable, *pad;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- demux = gst_element_factory_make_or_warn ("avidemux", "demux");
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_element_link (src, demux);
-
- audio_bin = gst_bin_new ("a_decoder_bin");
- 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");
-
- gst_bin_add (GST_BIN (audio_bin), a_queue);
- gst_bin_add (GST_BIN (audio_bin), a_decoder);
- gst_bin_add (GST_BIN (audio_bin), a_convert);
- gst_bin_add (GST_BIN (audio_bin), audiosink);
-
- gst_element_link (a_queue, a_decoder);
- gst_element_link (a_decoder, a_convert);
- gst_element_link (a_convert, audiosink);
-
- gst_bin_add (GST_BIN (pipeline), audio_bin);
-
- pad = gst_element_get_static_pad (a_queue, "sink");
- gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, NULL, gst_element_get_static_pad (audio_bin,
- "sink"), NULL);
-
- video_bin = gst_bin_new ("v_decoder_bin");
- v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
- 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");
-
- gst_bin_add (GST_BIN (video_bin), v_queue);
- gst_bin_add (GST_BIN (video_bin), v_decoder);
- gst_bin_add (GST_BIN (video_bin), v_convert);
- gst_bin_add (GST_BIN (video_bin), videosink);
-
- gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
-
- gst_bin_add (GST_BIN (pipeline), video_bin);
-
- pad = gst_element_get_static_pad (v_queue, "sink");
- gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, NULL, gst_element_get_static_pad (video_bin,
- "sink"), NULL);
-
- seekable = gst_element_get_static_pad (a_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_static_pad (a_decoder,
- "sink"));
-
- return pipeline;
-}
-
-static GstElement *
-make_mp3_pipeline (const gchar * location)
-{
- GstElement *pipeline;
- GstElement *src, *parser, *decoder, *audiosink, *queue;
- GstPad *seekable;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- 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");
-
- seekable_elements = g_list_prepend (seekable_elements, audiosink);
-
- g_object_set (G_OBJECT (src), "location", location, NULL);
- //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), parser);
- gst_bin_add (GST_BIN (pipeline), decoder);
- gst_bin_add (GST_BIN (pipeline), queue);
- gst_bin_add (GST_BIN (pipeline), audiosink);
-
- gst_element_link (src, parser);
- gst_element_link (parser, decoder);
- gst_element_link (decoder, queue);
- gst_element_link (queue, audiosink);
-
- seekable = gst_element_get_static_pad (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_static_pad (decoder, "sink"));
-
- return pipeline;
-}
-
-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, *v_queue = NULL;
- GstPad *seekable;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- demux = gst_element_factory_make_or_warn ("avidemux", "demux");
- seekable_elements = g_list_prepend (seekable_elements, demux);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_element_link (src, demux);
-
- 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");
- a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
- gst_element_link (a_decoder, a_queue);
- gst_element_link (a_queue, audiosink);
- 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);
- gst_element_set_state (audio_bin, GST_STATE_PAUSED);
-
- setup_dynamic_link (demux, "audio_00", gst_element_get_static_pad (a_decoder,
- "sink"), audio_bin);
-
- seekable = gst_element_get_static_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_static_pad (a_decoder,
- "sink"));
-
- 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");
- v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
- gst_element_link (v_decoder, v_queue);
- gst_element_link (v_queue, videosink);
- gst_bin_add (GST_BIN (video_bin), v_decoder);
- gst_bin_add (GST_BIN (video_bin), v_queue);
- gst_bin_add (GST_BIN (video_bin), videosink);
-
- gst_element_set_state (video_bin, GST_STATE_PAUSED);
-
- setup_dynamic_link (demux, "video_00", gst_element_get_static_pad (v_decoder,
- "sink"), video_bin);
-
- seekable = gst_element_get_static_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_static_pad (v_decoder,
- "sink"));
-
- return pipeline;
-}
-
-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, *v_queue;
- GstPad *seekable;
- GstPad *pad;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- //demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
- demux = gst_element_factory_make_or_warn ("flupsdemux", "demux");
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_element_link (src, demux);
-
- 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");
- 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);
-
- gst_element_link (a_decoder, a_queue);
- gst_element_link (a_queue, audiosink);
-
- gst_bin_add (GST_BIN (pipeline), audio_bin);
-
- pad = gst_element_get_static_pad (a_decoder, "sink");
- gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, "audio_c0", gst_element_get_static_pad (audio_bin,
- "sink"), NULL);
-
- video_bin = gst_bin_new ("v_decoder_bin");
- 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");
-
- gst_bin_add (GST_BIN (video_bin), v_decoder);
- gst_bin_add (GST_BIN (video_bin), v_queue);
- gst_bin_add (GST_BIN (video_bin), v_filter);
- gst_bin_add (GST_BIN (video_bin), videosink);
-
- gst_element_link (v_decoder, v_queue);
- gst_element_link (v_queue, v_filter);
- gst_element_link (v_filter, videosink);
-
- gst_bin_add (GST_BIN (pipeline), video_bin);
-
- pad = gst_element_get_static_pad (v_decoder, "sink");
- gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- setup_dynamic_link (demux, "video_e0", gst_element_get_static_pad (video_bin,
- "sink"), NULL);
-
- seekable = gst_element_get_static_pad (v_filter, "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_static_pad (v_decoder,
- "sink"));
-
- return pipeline;
-}
-
-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;
- GstPad *seekable;
-
- pipeline = gst_pipeline_new ("app");
-
- src = gst_element_factory_make_or_warn (SOURCE, "src");
- g_object_set (G_OBJECT (src), "location", location, NULL);
-
- demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
- //g_object_set (G_OBJECT (demux), "sync", TRUE, NULL);
-
- seekable_elements = g_list_prepend (seekable_elements, demux);
-
- gst_bin_add (GST_BIN (pipeline), src);
- gst_bin_add (GST_BIN (pipeline), demux);
- gst_element_link (src, demux);
-
- 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");
- //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);
- gst_element_link (a_queue, audiosink);
- 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);
-
- setup_dynamic_link (demux, "audio_00", gst_element_get_static_pad (a_decoder,
- "sink"), audio_bin);
-
- seekable = gst_element_get_static_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_static_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 ("ffmpegcolorspace", "v_filter");
- videosink = gst_element_factory_make_or_warn (VSINK, "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_static_pad (v_decoder,
- "sink"), video_bin);
-
- seekable = gst_element_get_static_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_static_pad (v_decoder,
- "sink"));
-
- return pipeline;
-}
-
-static void
-playerbin_set_uri (GstElement * player, const gchar * location)
-{
- gchar *uri;
-
- /* Add "file://" prefix for convenience */
- if (g_str_has_prefix (location, "/")) {
- uri = g_strconcat ("file://", location, NULL);
- g_object_set (G_OBJECT (player), "uri", uri, NULL);
- g_free (uri);
- } else {
- g_object_set (G_OBJECT (player), "uri", location, NULL);
- }
-}
-
-static GstElement *
-construct_playerbin (const gchar * name, const gchar * location)
-{
- GstElement *player;
-
- player = gst_element_factory_make (name, "player");
- g_assert (player);
-
- playerbin_set_uri (player, location);
-
- seekable_elements = g_list_prepend (seekable_elements, player);
-
- /* force element seeking on this pipeline */
- elem_seek = TRUE;
-
- return player;
-}
-
-static GstElement *
-make_playerbin_pipeline (const gchar * location)
-{
- return construct_playerbin ("playbin", location);
-}
-
-static GstElement *
-make_playerbin2_pipeline (const gchar * location)
-{
- GstElement *pipeline = construct_playerbin ("playbin2", location);
-
- /* FIXME: this is not triggered, playbin2 is not forwarding it from the sink */
- g_signal_connect (pipeline, "notify::volume", G_CALLBACK (volume_notify_cb),
- NULL);
- return pipeline;
-}
-
-#ifndef GST_DISABLE_PARSE
-static GstElement *
-make_parselaunch_pipeline (const gchar * description)
-{
- GstElement *pipeline;
- GError *error = NULL;
-
- pipeline = gst_parse_launch (description, &error);
-
- seekable_elements = g_list_prepend (seekable_elements, pipeline);
-
- elem_seek = TRUE;
-
- return pipeline;
-}
-#endif
-
-typedef struct
-{
- gchar *name;
- 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},
- {"theora", make_theora_pipeline},
- {"ogg/v/t", make_vorbis_theora_pipeline},
- {"avi/msmpeg4v3/mp3", make_avi_msmpeg4v3_mp3_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},
-#ifndef GST_DISABLE_PARSE
- {"parse-launch", make_parselaunch_pipeline},
-#endif
- {"playerbin2", make_playerbin2_pipeline},
- {NULL, NULL},
-};
-
-#define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
-
-/* ui callbacks and helpers */
-
-static gchar *
-format_value (GtkScale * scale, gdouble value)
-{
- gint64 real;
- gint64 seconds;
- gint64 subseconds;
-
- real = value * duration / 100;
- seconds = (gint64) real / GST_SECOND;
- subseconds = (gint64) real / (GST_SECOND / 100);
-
- return g_strdup_printf ("%02" G_GINT64_FORMAT ":%02" G_GINT64_FORMAT ":%02"
- G_GINT64_FORMAT, seconds / 60, seconds % 60, subseconds % 100);
-}
-
-
-static gchar *
-shuttle_format_value (GtkScale * scale, gdouble value)
-{
- return g_strdup_printf ("%0.*g", gtk_scale_get_digits (scale), value);
-}
-
-typedef struct
-{
- const gchar *name;
- 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},
-};
-
-G_GNUC_UNUSED static void
-query_rates (void)
-{
- GList *walk = rate_pads;
-
- while (walk) {
- GstPad *pad = GST_PAD (walk->data);
- gint i = 0;
-
- g_print ("rate/sec %8.8s: ", GST_PAD_NAME (pad));
- while (seek_formats[i].name) {
- gint64 value;
- GstFormat format;
-
- format = seek_formats[i].format;
-
- if (gst_pad_query_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format,
- &value)) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", 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);
- }
-}
-
-G_GNUC_UNUSED static void
-query_positions_elems (void)
-{
- GList *walk = seekable_elements;
-
- while (walk) {
- GstElement *element = GST_ELEMENT (walk->data);
- gint i = 0;
-
- g_print ("positions %8.8s: ", GST_ELEMENT_NAME (element));
- while (seek_formats[i].name) {
- gint64 position, total;
- GstFormat format;
-
- format = seek_formats[i].format;
-
- if (gst_element_query_position (element, &format, &position) &&
- gst_element_query_duration (element, &format, &total)) {
- g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
- seek_formats[i].name, position, total);
- } else {
- g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
- "*NA*");
- }
- i++;
- }
- g_print (" %s\n", GST_ELEMENT_NAME (element));
-
- walk = g_list_next (walk);
- }
-}
-
-G_GNUC_UNUSED static void
-query_positions_pads (void)
-{
- GList *walk = seekable_pads;
-
- while (walk) {
- GstPad *pad = GST_PAD (walk->data);
- gint i = 0;
-
- g_print ("positions %8.8s: ", GST_PAD_NAME (pad));
- while (seek_formats[i].name) {
- GstFormat format;
- gint64 position, total;
-
- format = seek_formats[i].format;
-
- if (gst_pad_query_position (pad, &format, &position) &&
- gst_pad_query_duration (pad, &format, &total)) {
- g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
- seek_formats[i].name, position, total);
- } else {
- g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
- "*NA*");
- }
-
- i++;
- }
- g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
-
- walk = g_list_next (walk);
- }
-}
-
-static gboolean start_seek (GtkWidget * widget, GdkEventButton * event,
- gpointer user_data);
-static gboolean stop_seek (GtkWidget * widget, GdkEventButton * event,
- gpointer user_data);
-static void seek_cb (GtkWidget * widget);
-
-static void
-set_scale (gdouble value)
-{
- g_signal_handlers_block_by_func (hscale, (void *) start_seek,
- (void *) pipeline);
- g_signal_handlers_block_by_func (hscale, (void *) stop_seek,
- (void *) pipeline);
- g_signal_handlers_block_by_func (hscale, (void *) seek_cb, (void *) pipeline);
- gtk_adjustment_set_value (adjustment, value);
- g_signal_handlers_unblock_by_func (hscale, (void *) start_seek,
- (void *) pipeline);
- g_signal_handlers_unblock_by_func (hscale, (void *) stop_seek,
- (void *) pipeline);
- g_signal_handlers_unblock_by_func (hscale, (void *) seek_cb,
- (void *) pipeline);
- gtk_widget_queue_draw (hscale);
-}
-
-static gboolean
-update_fill (gpointer data)
-{
- if (elem_seek) {
- if (seekable_elements) {
- GstElement *element = GST_ELEMENT (seekable_elements->data);
- GstQuery *query;
-
- query = gst_query_new_buffering (GST_FORMAT_PERCENT);
- if (gst_element_query (element, query)) {
- gint64 start, stop;
- GstFormat format;
- gdouble fill;
- gboolean busy;
- gint percent;
-
- gst_query_parse_buffering_percent (query, &busy, &percent);
- gst_query_parse_buffering_range (query, &format, &start, &stop, NULL);
-
- GST_DEBUG ("start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT,
- start, stop);
-
- if (stop != -1)
- fill = 100.0 * stop / GST_FORMAT_PERCENT_MAX;
- else
- fill = 100.0;
-
- gtk_range_set_fill_level (GTK_RANGE (hscale), fill);
- }
- gst_query_unref (query);
- }
- }
- return TRUE;
-}
-
-static gboolean
-update_scale (gpointer data)
-{
- GstFormat format = GST_FORMAT_TIME;
-
- //position = 0;
- //duration = 0;
-
- if (elem_seek) {
- if (seekable_elements) {
- GstElement *element = GST_ELEMENT (seekable_elements->data);
-
- gst_element_query_position (element, &format, &position);
- gst_element_query_duration (element, &format, &duration);
- }
- } else {
- if (seekable_pads) {
- GstPad *pad = GST_PAD (seekable_pads->data);
-
- gst_pad_query_position (pad, &format, &position);
- gst_pad_query_duration (pad, &format, &duration);
- }
- }
-
- if (stats) {
- if (elem_seek) {
- query_positions_elems ();
- } else {
- query_positions_pads ();
- }
- query_rates ();
- }
-
- if (position >= duration)
- duration = position;
-
- if (duration > 0) {
- set_scale (position * 100.0 / duration);
- }
-
- /* FIXME: see make_playerbin2_pipeline() and volume_notify_cb() */
- if (pipeline_type == 16) {
- g_object_notify (G_OBJECT (pipeline), "volume");
- }
-
- return TRUE;
-}
-
-static void do_seek (GtkWidget * widget);
-static void connect_bus_signals (GstElement * pipeline);
-static void set_update_scale (gboolean active);
-static void set_update_fill (gboolean active);
-
-static gboolean
-end_scrub (GtkWidget * widget)
-{
- GST_DEBUG ("end scrub, PAUSE");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- seek_timeout_id = 0;
-
- return FALSE;
-}
-
-static gboolean
-send_event (GstEvent * event)
-{
- gboolean res = FALSE;
-
- if (!elem_seek) {
- GList *walk = seekable_pads;
-
- while (walk) {
- GstPad *seekable = GST_PAD (walk->data);
-
- GST_DEBUG ("send event on pad %s:%s", GST_DEBUG_PAD_NAME (seekable));
-
- gst_event_ref (event);
- res = gst_pad_send_event (seekable, event);
-
- walk = g_list_next (walk);
- }
- } else {
- GList *walk = seekable_elements;
-
- while (walk) {
- GstElement *seekable = GST_ELEMENT (walk->data);
-
- GST_DEBUG ("send event on element %s", GST_ELEMENT_NAME (seekable));
-
- gst_event_ref (event);
- res = gst_element_send_event (seekable, event);
-
- walk = g_list_next (walk);
- }
- }
- gst_event_unref (event);
- return res;
-}
-
-static void
-do_seek (GtkWidget * widget)
-{
- gint64 real;
- gboolean res = FALSE;
- GstEvent *s_event;
- GstSeekFlags flags;
-
- real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
-
- flags = 0;
- if (flush_seek)
- flags |= GST_SEEK_FLAG_FLUSH;
- if (accurate_seek)
- flags |= GST_SEEK_FLAG_ACCURATE;
- if (keyframe_seek)
- flags |= GST_SEEK_FLAG_KEY_UNIT;
- if (loop_seek)
- flags |= GST_SEEK_FLAG_SEGMENT;
- if (skip_seek)
- flags |= GST_SEEK_FLAG_SKIP;
-
- if (rate >= 0) {
- s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_SET,
- GST_CLOCK_TIME_NONE);
- GST_DEBUG ("seek with rate %lf to %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
- rate, GST_TIME_ARGS (real), GST_TIME_ARGS (duration));
- } else {
- s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
- GST_SEEK_TYPE_SET, real);
- GST_DEBUG ("seek with rate %lf to %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
- rate, GST_TIME_ARGS (0), GST_TIME_ARGS (real));
- }
-
- res = send_event (s_event);
-
- if (res) {
- if (flush_seek) {
- gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, SEEK_TIMEOUT);
- } else {
- set_update_scale (TRUE);
- }
- } else {
- g_print ("seek failed\n");
- set_update_scale (TRUE);
- }
-}
-
-static void
-seek_cb (GtkWidget * widget)
-{
- /* If the timer hasn't expired yet, then the pipeline is running */
- if (play_scrub && seek_timeout_id != 0) {
- GST_DEBUG ("do scrub seek, PAUSED");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- }
-
- GST_DEBUG ("do seek");
- do_seek (widget);
-
- if (play_scrub) {
- GST_DEBUG ("do scrub seek, PLAYING");
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
- if (seek_timeout_id == 0) {
- seek_timeout_id =
- g_timeout_add (SCRUB_TIME, (GSourceFunc) end_scrub, widget);
- }
- }
-}
-
-static void
-set_update_fill (gboolean active)
-{
- GST_DEBUG ("fill scale is %d", active);
-
- if (active) {
- if (fill_id == 0) {
- fill_id =
- g_timeout_add (FILL_INTERVAL, (GtkFunction) update_fill, pipeline);
- }
- } else {
- if (fill_id) {
- g_source_remove (fill_id);
- fill_id = 0;
- }
- }
-}
-
-static void
-set_update_scale (gboolean active)
-{
-
- GST_DEBUG ("update scale is %d", active);
-
- if (active) {
- if (update_id == 0) {
- update_id =
- g_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
- }
- } else {
- if (update_id) {
- g_source_remove (update_id);
- update_id = 0;
- }
- }
-}
-
-static gboolean
-start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- if (event->type != GDK_BUTTON_PRESS)
- return FALSE;
-
- set_update_scale (FALSE);
-
- if (state == GST_STATE_PLAYING && flush_seek && scrub) {
- GST_DEBUG ("start scrub seek, PAUSE");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- }
-
- if (changed_id == 0 && flush_seek && scrub) {
- changed_id =
- g_signal_connect (hscale, "value_changed", G_CALLBACK (seek_cb),
- pipeline);
- }
-
- return FALSE;
-}
-
-static gboolean
-stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- if (changed_id) {
- g_signal_handler_disconnect (hscale, changed_id);
- changed_id = 0;
- }
-
- if (!flush_seek || !scrub) {
- GST_DEBUG ("do final seek");
- do_seek (widget);
- }
-
- if (seek_timeout_id != 0) {
- g_source_remove (seek_timeout_id);
- seek_timeout_id = 0;
- /* Still scrubbing, so the pipeline is playing, see if we need PAUSED
- * instead. */
- if (state == GST_STATE_PAUSED) {
- GST_DEBUG ("stop scrub seek, PAUSED");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- }
- } else {
- if (state == GST_STATE_PLAYING) {
- GST_DEBUG ("stop scrub seek, PLAYING");
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- }
- }
-
- return FALSE;
-}
-
-static void
-play_cb (GtkButton * button, gpointer data)
-{
- GstStateChangeReturn ret;
-
- if (state != GST_STATE_PLAYING) {
- g_print ("PLAY pipeline\n");
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
-
- ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
- switch (ret) {
- case GST_STATE_CHANGE_FAILURE:
- goto failed;
- case GST_STATE_CHANGE_NO_PREROLL:
- is_live = TRUE;
- break;
- default:
- break;
- }
- state = GST_STATE_PLAYING;
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Playing");
- }
-
- return;
-
-failed:
- {
- g_print ("PLAY failed\n");
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Play failed");
- }
-}
-
-static void
-pause_cb (GtkButton * button, gpointer data)
-{
- g_static_mutex_lock (&state_mutex);
- if (state != GST_STATE_PAUSED) {
- GstStateChangeReturn ret;
-
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
- g_print ("PAUSE pipeline\n");
- ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
- switch (ret) {
- case GST_STATE_CHANGE_FAILURE:
- goto failed;
- case GST_STATE_CHANGE_NO_PREROLL:
- is_live = TRUE;
- break;
- default:
- break;
- }
-
- state = GST_STATE_PAUSED;
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Paused");
- }
- g_static_mutex_unlock (&state_mutex);
-
- return;
-
-failed:
- {
- g_static_mutex_unlock (&state_mutex);
- g_print ("PAUSE failed\n");
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Pause failed");
- }
-}
-
-static void
-stop_cb (GtkButton * button, gpointer data)
-{
- if (state != STOP_STATE) {
- GstStateChangeReturn ret;
-
- g_print ("READY pipeline\n");
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
-
- g_static_mutex_lock (&state_mutex);
- ret = gst_element_set_state (pipeline, STOP_STATE);
- if (ret == GST_STATE_CHANGE_FAILURE)
- goto failed;
-
- state = STOP_STATE;
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
-
- is_live = FALSE;
- buffering = FALSE;
- set_update_scale (FALSE);
- set_scale (0.0);
- set_update_fill (FALSE);
-
- if (pipeline_type == 16)
- clear_streams (pipeline);
- g_static_mutex_unlock (&state_mutex);
-
-#if 0
- /* if one uses parse_launch, play, stop and play again it fails as all the
- * pads after the demuxer can't be reconnected
- */
- if (!strcmp (pipelines[pipeline_type].name, "parse-launch")) {
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
-
- g_list_free (seekable_elements);
- seekable_elements = NULL;
- g_list_free (seekable_pads);
- seekable_pads = NULL;
- g_list_free (rate_pads);
- rate_pads = NULL;
-
- pipeline = pipelines[pipeline_type].func (pipeline_spec);
- g_assert (pipeline);
- gst_element_set_state (pipeline, STOP_STATE);
- connect_bus_signals (pipeline);
- }
-#endif
- }
- return;
-
-failed:
- {
- g_static_mutex_unlock (&state_mutex);
- g_print ("STOP failed\n");
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stop failed");
- }
-}
-
-static void
-accurate_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- accurate_seek = gtk_toggle_button_get_active (button);
-}
-
-static void
-key_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- keyframe_seek = gtk_toggle_button_get_active (button);
-}
-
-static void
-loop_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- loop_seek = gtk_toggle_button_get_active (button);
- if (state == GST_STATE_PLAYING) {
- do_seek (hscale);
- }
-}
-
-static void
-flush_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- flush_seek = gtk_toggle_button_get_active (button);
-}
-
-static void
-scrub_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- scrub = gtk_toggle_button_get_active (button);
-}
-
-static void
-play_scrub_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- play_scrub = gtk_toggle_button_get_active (button);
-}
-
-static void
-skip_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- skip_seek = gtk_toggle_button_get_active (button);
- if (state == GST_STATE_PLAYING) {
- do_seek (hscale);
- }
-}
-
-static void
-rate_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
-{
- gboolean res = FALSE;
- GstEvent *s_event;
- GstSeekFlags flags;
-
- rate = gtk_spin_button_get_value (button);
-
- GST_DEBUG ("rate changed to %lf", rate);
-
- flags = 0;
- if (flush_seek)
- flags |= GST_SEEK_FLAG_FLUSH;
- if (loop_seek)
- flags |= GST_SEEK_FLAG_SEGMENT;
- if (accurate_seek)
- flags |= GST_SEEK_FLAG_ACCURATE;
- if (keyframe_seek)
- flags |= GST_SEEK_FLAG_KEY_UNIT;
- if (skip_seek)
- flags |= GST_SEEK_FLAG_SKIP;
-
- if (rate >= 0.0) {
- s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
- GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
- } else {
- s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
- GST_SEEK_TYPE_SET, position);
- }
-
- res = send_event (s_event);
-
- if (res) {
- if (flush_seek) {
- gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, SEEK_TIMEOUT);
- }
- } else
- g_print ("seek failed\n");
-}
-
-static void
-update_flag (GstPipeline * pipeline, gint num, gboolean state)
-{
- gint flags;
-
- g_object_get (pipeline, "flags", &flags, NULL);
- if (state)
- flags |= (1 << num);
- else
- flags &= ~(1 << num);
- g_object_set (pipeline, "flags", flags, NULL);
-}
-
-static void
-vis_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- gboolean state;
-
- state = gtk_toggle_button_get_active (button);
- update_flag (pipeline, 3, state);
- gtk_widget_set_sensitive (vis_combo, state);
-}
-
-static void
-audio_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- gboolean state;
-
- state = gtk_toggle_button_get_active (button);
- update_flag (pipeline, 1, state);
- gtk_widget_set_sensitive (audio_combo, state);
-}
-
-static void
-video_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- gboolean state;
-
- state = gtk_toggle_button_get_active (button);
- update_flag (pipeline, 0, state);
- gtk_widget_set_sensitive (video_combo, state);
-}
-
-static void
-text_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- gboolean state;
-
- state = gtk_toggle_button_get_active (button);
- update_flag (pipeline, 2, state);
- gtk_widget_set_sensitive (text_combo, state);
-}
-
-static void
-mute_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- gboolean mute;
-
- mute = gtk_toggle_button_get_active (button);
- g_object_set (pipeline, "mute", mute, NULL);
-}
-
-static void
-download_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- gboolean state;
-
- state = gtk_toggle_button_get_active (button);
- update_flag (pipeline, 7, state);
-}
-
-static void
-buffer_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
-{
- gboolean state;
-
- state = gtk_toggle_button_get_active (button);
- update_flag (pipeline, 8, state);
-}
-
-static void
-clear_streams (GstElement * pipeline)
-{
- gint i;
-
- /* remove previous info */
- for (i = 0; i < n_video; i++)
- gtk_combo_box_remove_text (GTK_COMBO_BOX (video_combo), 0);
- for (i = 0; i < n_audio; i++)
- gtk_combo_box_remove_text (GTK_COMBO_BOX (audio_combo), 0);
- for (i = 0; i < n_text; i++)
- gtk_combo_box_remove_text (GTK_COMBO_BOX (text_combo), 0);
-
- n_audio = n_video = n_text = 0;
- gtk_widget_set_sensitive (video_combo, FALSE);
- gtk_widget_set_sensitive (audio_combo, FALSE);
- gtk_widget_set_sensitive (text_combo, FALSE);
-
- need_streams = TRUE;
-}
-
-static void
-update_streams (GstPipeline * pipeline)
-{
- gint i;
-
- if (pipeline_type == 16 && need_streams) {
- GstTagList *tags;
- gchar *name, *str;
- gint active_idx;
- gboolean state;
-
- /* remove previous info */
- clear_streams (GST_ELEMENT_CAST (pipeline));
-
- /* here we get and update the different streams detected by playbin2 */
- g_object_get (pipeline, "n-video", &n_video, NULL);
- g_object_get (pipeline, "n-audio", &n_audio, NULL);
- g_object_get (pipeline, "n-text", &n_text, NULL);
-
- g_print ("video %d, audio %d, text %d\n", n_video, n_audio, n_text);
-
- active_idx = 0;
- for (i = 0; i < n_video; i++) {
- g_signal_emit_by_name (pipeline, "get-video-tags", i, &tags);
- if (tags) {
- str = gst_structure_to_string ((GstStructure *) tags);
- g_print ("video %d: %s\n", i, str);
- g_free (str);
- }
- /* find good name for the label */
- name = g_strdup_printf ("video %d", i + 1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (video_combo), name);
- g_free (name);
- }
- state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (video_checkbox));
- gtk_widget_set_sensitive (video_combo, state && n_video > 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (video_combo), active_idx);
-
- active_idx = 0;
- for (i = 0; i < n_audio; i++) {
- g_signal_emit_by_name (pipeline, "get-audio-tags", i, &tags);
- if (tags) {
- str = gst_structure_to_string ((GstStructure *) tags);
- g_print ("audio %d: %s\n", i, str);
- g_free (str);
- }
- /* find good name for the label */
- name = g_strdup_printf ("audio %d", i + 1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (audio_combo), name);
- g_free (name);
- }
- state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (audio_checkbox));
- gtk_widget_set_sensitive (audio_combo, state && n_audio > 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (audio_combo), active_idx);
-
- active_idx = 0;
- for (i = 0; i < n_text; i++) {
- g_signal_emit_by_name (pipeline, "get-text-tags", i, &tags);
-
- name = NULL;
- if (tags) {
- const GValue *value;
-
- str = gst_structure_to_string ((GstStructure *) tags);
- g_print ("text %d: %s\n", i, str);
- g_free (str);
-
- /* get the language code if we can */
- value = gst_tag_list_get_value_index (tags, GST_TAG_LANGUAGE_CODE, 0);
- if (value && G_VALUE_HOLDS_STRING (value)) {
- name = g_strdup_printf ("text %s", g_value_get_string (value));
- }
- }
- /* find good name for the label if we didn't use a tag */
- if (name == NULL)
- name = g_strdup_printf ("text %d", i + 1);
-
- gtk_combo_box_append_text (GTK_COMBO_BOX (text_combo), name);
- g_free (name);
- }
- state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_checkbox));
- gtk_widget_set_sensitive (text_combo, state && n_text > 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (text_combo), active_idx);
-
- need_streams = FALSE;
- }
-}
-
-static void
-video_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
-{
- gint active;
-
- active = gtk_combo_box_get_active (combo);
-
- g_print ("setting current video track %d\n", active);
- g_object_set (pipeline, "current-video", active, NULL);
-}
-
-static void
-audio_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
-{
- gint active;
-
- active = gtk_combo_box_get_active (combo);
-
- g_print ("setting current audio track %d\n", active);
- g_object_set (pipeline, "current-audio", active, NULL);
-}
-
-static void
-text_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
-{
- gint active;
-
- active = gtk_combo_box_get_active (combo);
-
- g_print ("setting current text track %d\n", active);
- g_object_set (pipeline, "current-text", active, NULL);
-}
-
-static gboolean
-filter_features (GstPluginFeature * feature, gpointer data)
-{
- GstElementFactory *f;
-
- if (!GST_IS_ELEMENT_FACTORY (feature))
- return FALSE;
- f = GST_ELEMENT_FACTORY (feature);
- if (!g_strrstr (gst_element_factory_get_klass (f), "Visualization"))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-init_visualization_features (void)
-{
- GList *list, *walk;
-
- vis_entries = g_array_new (FALSE, FALSE, sizeof (VisEntry));
-
- list = gst_registry_feature_filter (gst_registry_get_default (),
- filter_features, FALSE, NULL);
-
- for (walk = list; walk; walk = g_list_next (walk)) {
- VisEntry entry;
- const gchar *name;
-
- entry.factory = GST_ELEMENT_FACTORY (walk->data);
- name = gst_element_factory_get_longname (entry.factory);
-
- g_array_append_val (vis_entries, entry);
- gtk_combo_box_append_text (GTK_COMBO_BOX (vis_combo), name);
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (vis_combo), 0);
-}
-
-static void
-vis_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
-{
- guint index;
- VisEntry *entry;
- GstElement *element;
-
- /* get the selected index and get the factory for this index */
- index = gtk_combo_box_get_active (GTK_COMBO_BOX (vis_combo));
- if (vis_entries->len > 0) {
- entry = &g_array_index (vis_entries, VisEntry, index);
-
- /* create an instance of the element from the factory */
- element = gst_element_factory_create (entry->factory, NULL);
- if (!element)
- return;
-
- /* set vis plugin for playbin2 */
- g_object_set (pipeline, "vis-plugin", element, NULL);
- }
-}
-
-static void
-volume_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
-{
- gdouble volume;
-
- volume = gtk_spin_button_get_value (button);
-
- g_object_set (pipeline, "volume", volume, NULL);
-}
-
-static void
-volume_notify_cb (GstElement * pipeline, GParamSpec * arg, gpointer user_dat)
-{
- gdouble cur_volume, new_volume;
-
- g_object_get (pipeline, "volume", &new_volume, NULL);
- cur_volume = gtk_spin_button_get_value (GTK_SPIN_BUTTON (volume_spinbutton));
- if (fabs (cur_volume - new_volume) > 0.001) {
- g_signal_handlers_block_by_func (volume_spinbutton,
- volume_spinbutton_changed_cb, pipeline);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), new_volume);
- g_signal_handlers_unblock_by_func (volume_spinbutton,
- volume_spinbutton_changed_cb, pipeline);
- }
-}
-
-static void
-shot_cb (GtkButton * button, gpointer data)
-{
- GstBuffer *buffer;
- GstCaps *caps;
-
- /* convert to our desired format (RGB24) */
- caps = gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, 24, "depth", G_TYPE_INT, 24,
- /* Note: we don't ask for a specific width/height here, so that
- * videoscale can adjust dimensions from a non-1/1 pixel aspect
- * ratio to a 1/1 pixel-aspect-ratio */
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
- "endianness", G_TYPE_INT, G_BIG_ENDIAN,
- "red_mask", G_TYPE_INT, 0xff0000,
- "green_mask", G_TYPE_INT, 0x00ff00,
- "blue_mask", G_TYPE_INT, 0x0000ff, NULL);
-
- /* convert the latest frame to the requested format */
- g_signal_emit_by_name (pipeline, "convert-frame", caps, &buffer);
- gst_caps_unref (caps);
-
- if (buffer) {
- GstCaps *caps;
- GstStructure *s;
- gboolean res;
- gint width, height;
- GdkPixbuf *pixbuf;
- GError *error = NULL;
-
- /* get the snapshot buffer format now. We set the caps on the appsink so
- * that it can only be an rgb buffer. The only thing we have not specified
- * on the caps is the height, which is dependant on the pixel-aspect-ratio
- * of the source material */
- caps = GST_BUFFER_CAPS (buffer);
- if (!caps) {
- g_warning ("could not get snapshot format\n");
- goto done;
- }
- s = gst_caps_get_structure (caps, 0);
-
- /* we need to get the final caps on the buffer to get the size */
- res = gst_structure_get_int (s, "width", &width);
- res |= gst_structure_get_int (s, "height", &height);
- if (!res) {
- g_warning ("could not get snapshot dimension\n");
- goto done;
- }
-
- /* create pixmap from buffer and save, gstreamer video buffers have a stride
- * that is rounded up to the nearest multiple of 4 */
- pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer),
- GDK_COLORSPACE_RGB, FALSE, 8, width, height,
- GST_ROUND_UP_4 (width * 3), NULL, NULL);
-
- /* save the pixbuf */
- gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
-
- done:
- gst_buffer_unref (buffer);
- }
-}
-
-/* called when the Step button is pressed */
-static void
-step_cb (GtkButton * button, gpointer data)
-{
- GstEvent *event;
- GstFormat format;
- guint64 amount;
- gdouble rate;
- gboolean flush, res;
- gint active;
-
- active = gtk_combo_box_get_active (GTK_COMBO_BOX (format_combo));
- amount =
- gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
- (step_amount_spinbutton));
- rate = gtk_spin_button_get_value (GTK_SPIN_BUTTON (step_rate_spinbutton));
- flush = TRUE;
-
- switch (active) {
- case 0:
- format = GST_FORMAT_BUFFERS;
- break;
- case 1:
- format = GST_FORMAT_TIME;
- amount *= GST_MSECOND;
- break;
- default:
- format = GST_FORMAT_UNDEFINED;
- break;
- }
-
- event = gst_event_new_step (format, amount, rate, flush, FALSE);
-
- res = send_event (event);
-}
-
-static void
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
- g_print ("message from \"%s\" (%s): ",
- GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))),
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
- if (s) {
- gchar *sstr;
-
- sstr = gst_structure_to_string (s);
- g_print ("%s\n", sstr);
- g_free (sstr);
- } else {
- g_print ("no message details\n");
- }
-}
-
-static gboolean shuttling = FALSE;
-static gdouble shuttle_rate = 0.0;
-static gdouble play_rate = 1.0;
-
-static void
-do_shuttle (GstElement * element)
-{
- guint64 duration;
-
- if (shuttling)
- duration = 40 * GST_MSECOND;
- else
- duration = -1;
-
- gst_element_send_event (element,
- gst_event_new_step (GST_FORMAT_TIME, duration, shuttle_rate, FALSE,
- FALSE));
-}
-
-static void
-msg_sync_step_done (GstBus * bus, GstMessage * message, GstElement * element)
-{
- GstFormat format;
- guint64 amount;
- gdouble rate;
- gboolean flush;
- gboolean intermediate;
- guint64 duration;
- gboolean eos;
-
- gst_message_parse_step_done (message, &format, &amount, &rate, &flush,
- &intermediate, &duration, &eos);
-
- if (eos) {
- g_print ("stepped till EOS\n");
- return;
- }
-
- if (g_static_mutex_trylock (&state_mutex)) {
- if (shuttling)
- do_shuttle (element);
- g_static_mutex_unlock (&state_mutex);
- } else {
- /* ignore step messages that come while we are doing a state change */
- g_print ("state change is busy\n");
- }
-}
-
-static void
-shuttle_toggled (GtkToggleButton * button, GstElement * element)
-{
- gboolean active;
-
- active = gtk_toggle_button_get_active (button);
-
- if (active != shuttling) {
- shuttling = active;
- g_print ("shuttling %s\n", shuttling ? "active" : "inactive");
- if (active) {
- shuttle_rate = 0.0;
- play_rate = 1.0;
- pause_cb (NULL, NULL);
- gst_element_get_state (element, NULL, NULL, -1);
- }
- }
-}
-
-static void
-shuttle_rate_switch (GstElement * element)
-{
- GstSeekFlags flags;
- GstEvent *s_event;
- gboolean res;
-
- if (state == GST_STATE_PLAYING) {
- /* pause when we need to */
- pause_cb (NULL, NULL);
- gst_element_get_state (element, NULL, NULL, -1);
- }
-
- if (play_rate == 1.0)
- play_rate = -1.0;
- else
- play_rate = 1.0;
-
- g_print ("rate changed to %lf %" GST_TIME_FORMAT "\n", play_rate,
- GST_TIME_ARGS (position));
-
- flags = GST_SEEK_FLAG_FLUSH;
- flags |= GST_SEEK_FLAG_ACCURATE;
-
- if (play_rate >= 0.0) {
- s_event = gst_event_new_seek (play_rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
- GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
- } else {
- s_event = gst_event_new_seek (play_rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
- GST_SEEK_TYPE_SET, position);
- }
- res = send_event (s_event);
- if (res) {
- gst_element_get_state (element, NULL, NULL, SEEK_TIMEOUT);
- } else {
- g_print ("seek failed\n");
- }
-}
-
-static void
-shuttle_value_changed (GtkRange * range, GstElement * element)
-{
- gdouble rate;
-
- rate = gtk_adjustment_get_value (shuttle_adjustment);
-
- if (rate == 0.0) {
- g_print ("rate 0.0, pause\n");
- pause_cb (NULL, NULL);
- gst_element_get_state (element, NULL, NULL, -1);
- } else {
- g_print ("rate changed %0.3g\n", rate);
-
- if ((rate < 0.0 && play_rate > 0.0) || (rate > 0.0 && play_rate < 0.0)) {
- shuttle_rate_switch (element);
- }
-
- shuttle_rate = ABS (rate);
- if (state != GST_STATE_PLAYING) {
- do_shuttle (element);
- play_cb (NULL, NULL);
- }
- }
-}
-
-static void
-msg_async_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- GST_DEBUG ("async done");
- /* when we get ASYNC_DONE we can query position, duration and other
- * properties */
- update_scale (pipeline);
-
- /* update the available streams */
- update_streams (pipeline);
-}
-
-static void
-msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
-
- /* We only care about state changed on the pipeline */
- if (s && GST_MESSAGE_SRC (message) == GST_OBJECT_CAST (pipeline)) {
- GstState old, new, pending;
-
- gst_message_parse_state_changed (message, &old, &new, &pending);
-
- /* When state of the pipeline changes to paused or playing we start updating scale */
- if (new == GST_STATE_PLAYING) {
- set_update_scale (TRUE);
- } else {
- set_update_scale (FALSE);
- }
- }
-}
-
-static void
-msg_segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- GstEvent *s_event;
- GstSeekFlags flags;
- gboolean res;
- GstFormat format;
-
- GST_DEBUG ("position is %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
- gst_message_parse_segment_done (message, &format, &position);
- GST_DEBUG ("end of segment at %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
-
- flags = 0;
- /* in the segment-done callback we never flush as this would not make sense
- * for seamless playback. */
- if (loop_seek)
- flags |= GST_SEEK_FLAG_SEGMENT;
- if (skip_seek)
- flags |= GST_SEEK_FLAG_SKIP;
-
- s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
- GST_SEEK_TYPE_SET, duration);
-
- GST_DEBUG ("restart loop with rate %lf to 0 / %" GST_TIME_FORMAT,
- rate, GST_TIME_ARGS (duration));
-
- res = send_event (s_event);
- if (!res)
- g_print ("segment seek failed\n");
-}
-
-/* in stream buffering mode we PAUSE the pipeline until we receive a 100%
- * message */
-static void
-do_stream_buffering (gint percent)
-{
- gchar *bufstr;
-
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
- bufstr = g_strdup_printf ("Buffering...%d", percent);
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, bufstr);
- g_free (bufstr);
-
- if (percent == 100) {
- /* a 100% message means buffering is done */
- buffering = FALSE;
- /* if the desired state is playing, go back */
- if (state == GST_STATE_PLAYING) {
- /* no state management needed for live pipelines */
- if (!is_live) {
- fprintf (stderr, "Done buffering, setting pipeline to PLAYING ...\n");
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- }
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Playing");
- }
- } else {
- /* buffering busy */
- if (buffering == FALSE && state == GST_STATE_PLAYING) {
- /* we were not buffering but PLAYING, PAUSE the pipeline. */
- if (!is_live) {
- fprintf (stderr, "Buffering, setting pipeline to PAUSED ...\n");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- }
- }
- buffering = TRUE;
- }
-}
-
-static void
-do_download_buffering (gint percent)
-{
- if (!buffering && percent < 100) {
- gchar *bufstr;
-
- buffering = TRUE;
-
- bufstr = g_strdup_printf ("Downloading...");
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, bufstr);
- g_free (bufstr);
-
- /* once we get a buffering message, we'll do the fill update */
- set_update_fill (TRUE);
-
- if (state == GST_STATE_PLAYING && !is_live) {
- fprintf (stderr, "Downloading, setting pipeline to PAUSED ...\n");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- /* user has to manually start the playback */
- state = GST_STATE_PAUSED;
- }
- }
-}
-
-static void
-msg_buffering (GstBus * bus, GstMessage * message, GstPipeline * data)
-{
- gint percent;
-
- gst_message_parse_buffering (message, &percent);
-
- /* get more stats */
- gst_message_parse_buffering_stats (message, &mode, NULL, NULL,
- &buffering_left);
-
- switch (mode) {
- case GST_BUFFERING_DOWNLOAD:
- do_download_buffering (percent);
- break;
- case GST_BUFFERING_LIVE:
- case GST_BUFFERING_TIMESHIFT:
- case GST_BUFFERING_STREAM:
- do_stream_buffering (percent);
- break;
- }
-}
-
-static void
-msg_clock_lost (GstBus * bus, GstMessage * message, GstPipeline * data)
-{
- g_print ("clock lost! PAUSE and PLAY to select a new clock\n");
-
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
-}
-
-#ifdef HAVE_X
-
-static gulong embed_xid = 0;
-
-/* We set the xid here in response to the prepare-xwindow-id message via a
- * bus sync handler because we don't know the actual videosink used from the
- * start (as we don't know the pipeline, or bin elements such as autovideosink
- * or gconfvideosink may be used which create the actual videosink only once
- * the pipeline is started) */
-static GstBusSyncReply
-bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
-{
- if ((GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) &&
- gst_structure_has_name (message->structure, "prepare-xwindow-id")) {
- GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
-
- g_print ("got prepare-xwindow-id, setting XID %lu\n", embed_xid);
-
- if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
- "force-aspect-ratio")) {
- g_object_set (element, "force-aspect-ratio", TRUE, NULL);
- }
-
- /* Should have been initialised from main thread before (can't use
- * GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
- * be called from a streaming thread and GDK_WINDOW_XID maps to more than
- * a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
- * shouldn't be done from a non-GUI thread without explicit locking). */
- g_assert (embed_xid != 0);
-
- gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (element), embed_xid);
- }
- return GST_BUS_PASS;
-}
-#endif
-
-static gboolean
-handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
-{
- if (state < GST_STATE_PAUSED) {
- gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE,
- 0, 0, widget->allocation.width, widget->allocation.height);
- }
- return FALSE;
-}
-
-static void
-realize_cb (GtkWidget * widget, gpointer data)
-{
-#if GTK_CHECK_VERSION(2,18,0)
- /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
- * as well */
- if (!gdk_window_ensure_native (widget->window))
- g_error ("Couldn't create native window needed for GstXOverlay!");
-#endif
-
-#ifdef HAVE_X
- embed_xid = GDK_WINDOW_XID (video_window->window);
- g_print ("Window realize: video window XID = %lu\n", embed_xid);
-#endif
-}
-
-static void
-msg_eos (GstBus * bus, GstMessage * message, GstPipeline * data)
-{
- message_received (bus, message, data);
-
- /* Set new uri for playerbins and continue playback */
- if (l && (pipeline_type == 14 || pipeline_type == 16)) {
- stop_cb (NULL, NULL);
- l = g_list_next (l);
- if (l) {
- playerbin_set_uri (GST_ELEMENT (data), l->data);
- play_cb (NULL, NULL);
- }
- }
-}
-
-static void
-msg_step_done (GstBus * bus, GstMessage * message, GstPipeline * data)
-{
- if (!shuttling)
- message_received (bus, message, data);
-}
-
-static void
-connect_bus_signals (GstElement * pipeline)
-{
- GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
-
-#ifdef HAVE_X
- /* handle prepare-xwindow-id element message synchronously */
- gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler,
- pipeline);
-#endif
-
- gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
- gst_bus_enable_sync_message_emission (bus);
-
- g_signal_connect (bus, "message::state-changed",
- (GCallback) msg_state_changed, pipeline);
- g_signal_connect (bus, "message::segment-done", (GCallback) msg_segment_done,
- pipeline);
- g_signal_connect (bus, "message::async-done", (GCallback) msg_async_done,
- pipeline);
-
- g_signal_connect (bus, "message::new-clock", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::clock-lost", (GCallback) msg_clock_lost,
- pipeline);
- g_signal_connect (bus, "message::error", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::warning", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::eos", (GCallback) msg_eos, pipeline);
- g_signal_connect (bus, "message::tag", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::element", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::segment-done", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::buffering", (GCallback) msg_buffering,
- pipeline);
-// g_signal_connect (bus, "message::step-done", (GCallback) msg_step_done,
-// pipeline);
- g_signal_connect (bus, "message::step-start", (GCallback) msg_step_done,
- pipeline);
- g_signal_connect (bus, "sync-message::step-done",
- (GCallback) msg_sync_step_done, pipeline);
-
- gst_object_unref (bus);
-}
-
-/* Return GList of paths described in location string */
-static GList *
-handle_wildcards (const gchar * location)
-{
- GList *res = NULL;
- gchar *path = g_path_get_dirname (location);
- gchar *pattern = g_path_get_basename (location);
- GPatternSpec *pspec = g_pattern_spec_new (pattern);
- GDir *dir = g_dir_open (path, 0, NULL);
- const gchar *name;
-
- g_print ("matching %s from %s\n", pattern, path);
-
- if (!dir) {
- g_print ("opening directory %s failed\n", path);
- goto out;
- }
-
- while ((name = g_dir_read_name (dir)) != NULL) {
- if (g_pattern_match_string (pspec, name)) {
- res = g_list_append (res, g_strjoin ("/", path, name, NULL));
- g_print (" found clip %s\n", name);
- }
- }
-
- g_dir_close (dir);
-out:
- g_pattern_spec_free (pspec);
- g_free (pattern);
- g_free (path);
-
- return res;
-}
-
-static void
-delete_event_cb (void)
-{
- stop_cb (NULL, NULL);
- gtk_main_quit ();
-}
-
-static void
-print_usage (int argc, char **argv)
-{
- gint i;
-
- g_print ("usage: %s <type> <filename>\n", argv[0]);
- g_print (" possible types:\n");
-
- for (i = 0; i < NUM_TYPES; i++) {
- g_print (" %d = %s\n", i, pipelines[i].name);
- }
-}
-
-int
-main (int argc, char **argv)
-{
- GtkWidget *window, *hbox, *vbox, *panel, *expander, *pb2vbox, *boxes,
- *flagtable, *boxes2, *step;
- GtkWidget *play_button, *pause_button, *stop_button, *shot_button;
- GtkWidget *accurate_checkbox, *key_checkbox, *loop_checkbox, *flush_checkbox;
- GtkWidget *scrub_checkbox, *play_scrub_checkbox;
- GtkWidget *rate_label, *volume_label;
- GOptionEntry options[] = {
- {"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},
- {NULL}
- };
- GOptionContext *ctx;
- GError *err = NULL;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
- ctx = g_option_context_new ("- test seeking in gsteamer");
- g_option_context_add_main_entries (ctx, options, NULL);
- g_option_context_add_group (ctx, gst_init_get_option_group ());
- g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
-
- if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
- g_print ("Error initializing: %s\n", err->message);
- exit (1);
- }
-
- GST_DEBUG_CATEGORY_INIT (seek_debug, "seek", 0, "seek example");
-
- if (argc != 3) {
- print_usage (argc, argv);
- exit (-1);
- }
-
- pipeline_type = atoi (argv[1]);
-
- if (pipeline_type < 0 || pipeline_type >= NUM_TYPES) {
- print_usage (argc, argv);
- exit (-1);
- }
-
- pipeline_spec = argv[2];
-
- if (g_strrstr (pipeline_spec, "*") != NULL ||
- g_strrstr (pipeline_spec, "?") != NULL) {
- paths = handle_wildcards (pipeline_spec);
- } else {
- paths = g_list_prepend (paths, g_strdup (pipeline_spec));
- }
-
- if (!paths) {
- g_print ("opening %s failed\n", pipeline_spec);
- exit (-1);
- }
-
- l = paths;
-
- pipeline = pipelines[pipeline_type].func ((gchar *) l->data);
- g_assert (pipeline);
-
- /* initialize gui elements ... */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- video_window = gtk_drawing_area_new ();
- g_signal_connect (video_window, "expose-event",
- G_CALLBACK (handle_expose_cb), NULL);
- g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), NULL);
- gtk_widget_set_double_buffered (video_window, FALSE);
-
- statusbar = gtk_statusbar_new ();
- status_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "seek");
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
- hbox = gtk_hbox_new (FALSE, 0);
- vbox = gtk_vbox_new (FALSE, 0);
- flagtable = gtk_table_new (4, 2, FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
-
- /* media controls */
- play_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
- pause_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PAUSE);
- stop_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_STOP);
-
- /* seek flags */
- accurate_checkbox = gtk_check_button_new_with_label ("Accurate Seek");
- key_checkbox = gtk_check_button_new_with_label ("Key-unit Seek");
- loop_checkbox = gtk_check_button_new_with_label ("Loop");
- flush_checkbox = gtk_check_button_new_with_label ("Flush");
- scrub_checkbox = gtk_check_button_new_with_label ("Scrub");
- play_scrub_checkbox = gtk_check_button_new_with_label ("Play Scrub");
- skip_checkbox = gtk_check_button_new_with_label ("Play Skip");
- rate_spinbutton = gtk_spin_button_new_with_range (-100, 100, 0.1);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (rate_spinbutton), 3);
- rate_label = gtk_label_new ("Rate");
-
- gtk_widget_set_tooltip_text (accurate_checkbox,
- "accurate position is requested, this might be considerably slower for some formats");
- gtk_widget_set_tooltip_text (key_checkbox,
- "seek to the nearest keyframe. This might be faster but less accurate");
- gtk_widget_set_tooltip_text (loop_checkbox, "loop playback");
- gtk_widget_set_tooltip_text (flush_checkbox, "flush pipeline after seeking");
- gtk_widget_set_tooltip_text (rate_spinbutton, "define the playback rate, "
- "negative value trigger reverse playback");
- gtk_widget_set_tooltip_text (scrub_checkbox, "show images while seeking");
- gtk_widget_set_tooltip_text (play_scrub_checkbox, "play video while seeking");
- gtk_widget_set_tooltip_text (skip_checkbox,
- "Skip frames while playing at high frame rates");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (flush_checkbox), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scrub_checkbox), TRUE);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (rate_spinbutton), rate);
-
- /* step expander */
- {
- GtkWidget *hbox;
-
- step = gtk_expander_new ("step options");
- hbox = gtk_hbox_new (FALSE, 0);
-
- format_combo = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (format_combo), "frames");
- gtk_combo_box_append_text (GTK_COMBO_BOX (format_combo), "time (ms)");
- gtk_combo_box_set_active (GTK_COMBO_BOX (format_combo), 0);
- gtk_box_pack_start (GTK_BOX (hbox), format_combo, FALSE, FALSE, 2);
-
- step_amount_spinbutton = gtk_spin_button_new_with_range (1, 1000, 1);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (step_amount_spinbutton), 0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (step_amount_spinbutton), 1.0);
- gtk_box_pack_start (GTK_BOX (hbox), step_amount_spinbutton, FALSE, FALSE,
- 2);
-
- step_rate_spinbutton = gtk_spin_button_new_with_range (0.0, 100, 0.1);
- gtk_spin_button_set_digits (GTK_SPIN_BUTTON (step_rate_spinbutton), 3);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (step_rate_spinbutton), 1.0);
- gtk_box_pack_start (GTK_BOX (hbox), step_rate_spinbutton, FALSE, FALSE, 2);
-
- step_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_FORWARD);
- gtk_button_set_label (GTK_BUTTON (step_button), "Step");
- gtk_box_pack_start (GTK_BOX (hbox), step_button, FALSE, FALSE, 2);
-
- g_signal_connect (G_OBJECT (step_button), "clicked", G_CALLBACK (step_cb),
- pipeline);
-
- /* shuttle scale */
- shuttle_checkbox = gtk_check_button_new_with_label ("Shuttle");
- gtk_box_pack_start (GTK_BOX (hbox), shuttle_checkbox, FALSE, FALSE, 2);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shuttle_checkbox), FALSE);
- g_signal_connect (shuttle_checkbox, "toggled", G_CALLBACK (shuttle_toggled),
- pipeline);
-
- shuttle_adjustment =
- GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -3.00, 4.0, 0.1, 1.0, 1.0));
- shuttle_hscale = gtk_hscale_new (shuttle_adjustment);
- gtk_scale_set_digits (GTK_SCALE (shuttle_hscale), 2);
- gtk_scale_set_value_pos (GTK_SCALE (shuttle_hscale), GTK_POS_TOP);
- gtk_range_set_update_policy (GTK_RANGE (shuttle_hscale),
- GTK_UPDATE_CONTINUOUS);
- g_signal_connect (shuttle_hscale, "value_changed",
- G_CALLBACK (shuttle_value_changed), pipeline);
- g_signal_connect (shuttle_hscale, "format_value",
- G_CALLBACK (shuttle_format_value), pipeline);
-
- gtk_box_pack_start (GTK_BOX (hbox), shuttle_hscale, TRUE, TRUE, 2);
-
- gtk_container_add (GTK_CONTAINER (step), hbox);
- }
-
- /* seek bar */
- 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_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_RIGHT);
-#if GTK_CHECK_VERSION(2,12,0)
- gtk_range_set_show_fill_level (GTK_RANGE (hscale), TRUE);
- gtk_range_set_fill_level (GTK_RANGE (hscale), 100.0);
-#endif
- gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
-
- g_signal_connect (hscale, "button_press_event", G_CALLBACK (start_seek),
- pipeline);
- g_signal_connect (hscale, "button_release_event", G_CALLBACK (stop_seek),
- pipeline);
- g_signal_connect (hscale, "format_value", G_CALLBACK (format_value),
- pipeline);
-
- if (pipeline_type == 16) {
- /* the playbin2 panel controls for the video/audio/subtitle tracks */
- panel = gtk_hbox_new (FALSE, 0);
- video_combo = gtk_combo_box_new_text ();
- audio_combo = gtk_combo_box_new_text ();
- text_combo = gtk_combo_box_new_text ();
- gtk_widget_set_sensitive (video_combo, FALSE);
- gtk_widget_set_sensitive (audio_combo, FALSE);
- gtk_widget_set_sensitive (text_combo, FALSE);
- gtk_box_pack_start (GTK_BOX (panel), video_combo, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (panel), audio_combo, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (panel), text_combo, TRUE, TRUE, 2);
- g_signal_connect (G_OBJECT (video_combo), "changed",
- G_CALLBACK (video_combo_cb), pipeline);
- g_signal_connect (G_OBJECT (audio_combo), "changed",
- G_CALLBACK (audio_combo_cb), pipeline);
- g_signal_connect (G_OBJECT (text_combo), "changed",
- G_CALLBACK (text_combo_cb), pipeline);
- /* playbin2 panel for flag checkboxes and volume/mute */
- boxes = gtk_hbox_new (FALSE, 0);
- vis_checkbox = gtk_check_button_new_with_label ("Vis");
- video_checkbox = gtk_check_button_new_with_label ("Video");
- audio_checkbox = gtk_check_button_new_with_label ("Audio");
- text_checkbox = gtk_check_button_new_with_label ("Text");
- mute_checkbox = gtk_check_button_new_with_label ("Mute");
- download_checkbox = gtk_check_button_new_with_label ("Download");
- buffer_checkbox = gtk_check_button_new_with_label ("Buffer");
- volume_label = gtk_label_new ("Volume");
- volume_spinbutton = gtk_spin_button_new_with_range (0, 10.0, 0.1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), 1.0);
- gtk_box_pack_start (GTK_BOX (boxes), video_checkbox, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), audio_checkbox, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), text_checkbox, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), vis_checkbox, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), mute_checkbox, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), download_checkbox, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), buffer_checkbox, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), volume_label, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes), volume_spinbutton, TRUE, TRUE, 2);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vis_checkbox), FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (audio_checkbox), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (video_checkbox), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text_checkbox), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_checkbox), FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (download_checkbox), FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buffer_checkbox), FALSE);
- g_signal_connect (G_OBJECT (vis_checkbox), "toggled",
- G_CALLBACK (vis_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (audio_checkbox), "toggled",
- G_CALLBACK (audio_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (video_checkbox), "toggled",
- G_CALLBACK (video_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (text_checkbox), "toggled",
- G_CALLBACK (text_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (mute_checkbox), "toggled",
- G_CALLBACK (mute_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (download_checkbox), "toggled",
- G_CALLBACK (download_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (buffer_checkbox), "toggled",
- G_CALLBACK (buffer_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (volume_spinbutton), "value_changed",
- G_CALLBACK (volume_spinbutton_changed_cb), pipeline);
- /* playbin2 panel for snapshot */
- boxes2 = gtk_hbox_new (FALSE, 0);
- shot_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
- gtk_widget_set_tooltip_text (shot_button,
- "save a screenshot .png in the current directory");
- g_signal_connect (G_OBJECT (shot_button), "clicked", G_CALLBACK (shot_cb),
- pipeline);
- vis_combo = gtk_combo_box_new_text ();
- g_signal_connect (G_OBJECT (vis_combo), "changed",
- G_CALLBACK (vis_combo_cb), pipeline);
- gtk_widget_set_sensitive (vis_combo, FALSE);
- gtk_box_pack_start (GTK_BOX (boxes2), shot_button, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (boxes2), vis_combo, TRUE, TRUE, 2);
-
- /* fill the vis combo box and the array of factories */
- init_visualization_features ();
- } else {
- panel = boxes = boxes2 = NULL;
- }
-
- /* do the packing stuff ... */
- gtk_window_set_default_size (GTK_WINDOW (window), 250, 96);
- /* FIXME: can we avoid this for audio only? */
- gtk_widget_set_size_request (GTK_WIDGET (video_window), -1,
- DEFAULT_VIDEO_HEIGHT);
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_box_pack_start (GTK_BOX (vbox), video_window, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), play_button, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), pause_button, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), stop_button, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), flagtable, FALSE, FALSE, 2);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), accurate_checkbox, 0, 1, 0,
- 1);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), flush_checkbox, 1, 2, 0, 1);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), loop_checkbox, 2, 3, 0, 1);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), key_checkbox, 0, 1, 1, 2);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), scrub_checkbox, 1, 2, 1, 2);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), play_scrub_checkbox, 2, 3,
- 1, 2);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), skip_checkbox, 3, 4, 0, 1);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_label, 4, 5, 0, 1);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_spinbutton, 4, 5, 1,
- 2);
- if (panel && boxes && boxes2) {
- expander = gtk_expander_new ("playbin2 options");
- pb2vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (pb2vbox), panel, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (pb2vbox), boxes, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (pb2vbox), boxes2, FALSE, FALSE, 2);
- gtk_container_add (GTK_CONTAINER (expander), pb2vbox);
- gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 2);
- }
- gtk_box_pack_start (GTK_BOX (vbox), step, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), hscale, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 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 (accurate_checkbox), "toggled",
- G_CALLBACK (accurate_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (key_checkbox), "toggled",
- G_CALLBACK (key_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (loop_checkbox), "toggled",
- G_CALLBACK (loop_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (flush_checkbox), "toggled",
- G_CALLBACK (flush_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (scrub_checkbox), "toggled",
- G_CALLBACK (scrub_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (play_scrub_checkbox), "toggled",
- G_CALLBACK (play_scrub_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (skip_checkbox), "toggled",
- G_CALLBACK (skip_toggle_cb), pipeline);
- g_signal_connect (G_OBJECT (rate_spinbutton), "value_changed",
- G_CALLBACK (rate_spinbutton_changed_cb), pipeline);
-
- g_signal_connect (G_OBJECT (window), "delete-event", delete_event_cb, NULL);
-
- /* show the gui. */
- gtk_widget_show_all (window);
-
- /* realize window now so that the video window gets created and we can
- * obtain its XID before the pipeline is started up and the videosink
- * asks for the XID of the window to render onto */
- gtk_widget_realize (window);
-
- /* we should have the XID now */
- g_assert (embed_xid != 0);
-
- if (verbose) {
- g_signal_connect (pipeline, "deep_notify",
- G_CALLBACK (gst_object_default_deep_notify), NULL);
- }
-
- connect_bus_signals (pipeline);
- gtk_main ();
-
- g_print ("NULL pipeline\n");
- gst_element_set_state (pipeline, GST_STATE_NULL);
-
- g_print ("free pipeline\n");
- gst_object_unref (pipeline);
-
- g_list_foreach (paths, (GFunc) g_free, NULL);
- g_list_free (paths);
-
- return 0;
-}
diff --git a/tests/examples/seek/stepping.c b/tests/examples/seek/stepping.c
deleted file mode 100644
index 6f6997fc..00000000
--- a/tests/examples/seek/stepping.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* GStreamer
- *
- * stepping.c: stepping sample application
- *
- * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.com>
- *
- * 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 <stdlib.h>
-#include <math.h>
-
-#include <gst/gst.h>
-
-static GMainLoop *loop;
-
-static gdouble period = 0.0;
-
-static gboolean
-do_step (GstElement * bin)
-{
- gdouble length;
-
- length = sin (period);
-
- period += M_PI / 40;
-
- length += 1.1;
- length *= 100 * GST_MSECOND;
-
- gst_element_send_event (bin,
- gst_event_new_step (GST_FORMAT_TIME, length, 1.0, TRUE, FALSE));
-
- return FALSE;
-}
-
-static gboolean
-handle_message (GstBus * bus, GstMessage * message, gpointer data)
-{
- GstElement *bin = GST_ELEMENT_CAST (data);
-
- switch (message->type) {
- case GST_MESSAGE_EOS:
- g_message ("got EOS");
- g_main_loop_quit (loop);
- break;
- case GST_MESSAGE_WARNING:
- case GST_MESSAGE_ERROR:
- {
- GError *gerror;
- gchar *debug;
-
- if (message->type == GST_MESSAGE_ERROR)
- gst_message_parse_error (message, &gerror, &debug);
- else
- gst_message_parse_warning (message, &gerror, &debug);
-
- gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- g_error_free (gerror);
- g_free (debug);
- g_main_loop_quit (loop);
- break;
- }
- case GST_MESSAGE_ASYNC_DONE:
- g_timeout_add (40, (GSourceFunc) do_step, bin);
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- GstElement *bin;
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- if (argc < 2) {
- g_print ("usage: %s <uri>\n", argv[0]);
- return -1;
- }
-
- /* create a new bin to hold the elements */
- bin = gst_element_factory_make ("playbin2", "bin");
- g_assert (bin);
- g_object_set (bin, "uri", argv[1], NULL);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
- gst_bus_add_watch (bus, handle_message, bin);
-
- /* go to the PAUSED state and wait for preroll */
- g_message ("prerolling first frame");
- gst_element_set_state (bin, GST_STATE_PAUSED);
- gst_element_get_state (bin, NULL, NULL, -1);
-
- loop = g_main_loop_new (NULL, TRUE);
- g_main_loop_run (loop);
-
- g_message ("finished");
-
- /* stop the bin */
- gst_element_set_state (bin, GST_STATE_NULL);
-
- g_main_loop_unref (loop);
- gst_object_unref (bus);
-
- exit (0);
-}
diff --git a/tests/examples/seek/stepping2.c b/tests/examples/seek/stepping2.c
deleted file mode 100644
index 8cea180e..00000000
--- a/tests/examples/seek/stepping2.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* GStreamer
- *
- * stepping.c: stepping sample application
- *
- * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.com>
- *
- * 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 <stdlib.h>
-#include <math.h>
-
-#include <gst/gst.h>
-
-static GMainLoop *loop;
-
-static gdouble period = 0.0;
-
-static void
-do_step (GstElement * bin)
-{
- gdouble rate;
-
- rate = sin (period);
-
- period += M_PI / 150;
-
- rate += 1.2;
-
- gst_element_send_event (bin,
- gst_event_new_step (GST_FORMAT_TIME, 40 * GST_MSECOND, rate, FALSE,
- FALSE));
-}
-
-static void
-handle_sync_message (GstBus * bus, GstMessage * message, gpointer data)
-{
- GstElement *bin;
-
- bin = GST_ELEMENT_CAST (data);
-
- switch (message->type) {
- case GST_MESSAGE_STEP_DONE:
- do_step (bin);
- break;
- default:
- break;
- }
-}
-
-static void
-handle_message (GstBus * bus, GstMessage * message, gpointer data)
-{
- switch (message->type) {
- case GST_MESSAGE_EOS:
- g_message ("got EOS");
- g_main_loop_quit (loop);
- break;
- case GST_MESSAGE_WARNING:
- case GST_MESSAGE_ERROR:
- {
- GError *gerror;
- gchar *debug;
-
- if (message->type == GST_MESSAGE_ERROR)
- gst_message_parse_error (message, &gerror, &debug);
- else
- gst_message_parse_warning (message, &gerror, &debug);
-
- gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- g_error_free (gerror);
- g_free (debug);
- if (message->type == GST_MESSAGE_ERROR)
- g_main_loop_quit (loop);
- break;
- }
- default:
- break;
- }
-}
-
-int
-main (int argc, char *argv[])
-{
- GstElement *bin;
- GstBus *bus;
-
- gst_init (&argc, &argv);
-
- if (argc < 2) {
- g_print ("usage: %s <uri>\n", argv[0]);
- return -1;
- }
-
- /* create a new bin to hold the elements */
- bin = gst_element_factory_make ("playbin2", "bin");
- g_assert (bin);
- g_object_set (bin, "uri", argv[1], NULL);
-
- bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
- gst_bus_add_signal_watch (bus);
- gst_bus_enable_sync_message_emission (bus);
-
- g_signal_connect (bus, "message", (GCallback) handle_message, bin);
- g_signal_connect (bus, "sync-message", (GCallback) handle_sync_message, bin);
-
- /* go to the PAUSED state and wait for preroll */
- g_message ("prerolling first frame");
- gst_element_set_state (bin, GST_STATE_PAUSED);
- gst_element_get_state (bin, NULL, NULL, -1);
-
- /* queue step */
- do_step (bin);
-
- gst_element_set_state (bin, GST_STATE_PLAYING);
-
- loop = g_main_loop_new (NULL, TRUE);
- g_main_loop_run (loop);
-
- g_message ("finished");
-
- /* stop the bin */
- gst_element_set_state (bin, GST_STATE_NULL);
-
- g_main_loop_unref (loop);
- gst_object_unref (bus);
-
- exit (0);
-}
diff --git a/tests/examples/snapshot/.gitignore b/tests/examples/snapshot/.gitignore
deleted file mode 100644
index a701b4cb..00000000
--- a/tests/examples/snapshot/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-snapshot
-snapshot.png
diff --git a/tests/examples/snapshot/Makefile.am b/tests/examples/snapshot/Makefile.am
deleted file mode 100644
index 16830eef..00000000
--- a/tests/examples/snapshot/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-if HAVE_GTK
-GTK_EXAMPLES=snapshot
-endif
-
-examples = $(GTK_EXAMPLES)
-
-noinst_PROGRAMS = $(examples)
-
-LIBS = $(GST_LIBS) $(GTK_LIBS)
-AM_CFLAGS = $(GST_CFLAGS) $(GTK_CFLAGS)
diff --git a/tests/examples/snapshot/snapshot.c b/tests/examples/snapshot/snapshot.c
deleted file mode 100644
index b3071113..00000000
--- a/tests/examples/snapshot/snapshot.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/* GStreamer snapshot example
- * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
- *
- * 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/gst.h>
-#include <gtk/gtk.h>
-
-#include <stdlib.h>
-
-#define CAPS "video/x-raw-rgb,width=160,pixel-aspect-ratio=1/1,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)0xff0000, green_mask=(int)0x00ff00, blue_mask=(int)0x0000ff"
-
-int
-main (int argc, char *argv[])
-{
- GstElement *pipeline, *sink;
- gint width, height;
- GstBuffer *buffer;
- gchar *descr;
- GError *error = NULL;
- GdkPixbuf *pixbuf;
- gint64 duration, position;
- GstFormat format;
- GstStateChangeReturn ret;
- gboolean res;
-
- gst_init (&argc, &argv);
-
- if (argc != 2) {
- g_print ("usage: %s <uri>\n Writes snapshot.png in the current directory",
- argv[0]);
- exit (-1);
- }
-
- /* create a new pipeline */
- descr =
- g_strdup_printf ("uridecodebin uri=%s ! ffmpegcolorspace ! videoscale ! "
- " appsink name=sink caps=\"" CAPS "\"", argv[1]);
- pipeline = gst_parse_launch (descr, &error);
-
- if (error != NULL) {
- g_print ("could not construct pipeline: %s", error->message);
- g_error_free (error);
- exit (-1);
- }
-
- /* get sink */
- sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
-
- /* set to PAUSED to make the first frame arrive in the sink */
- ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
- switch (ret) {
- case GST_STATE_CHANGE_FAILURE:
- g_print ("failed to play the file\n");
- exit (-1);
- case GST_STATE_CHANGE_NO_PREROLL:
- /* for live sources, we need to set the pipeline to PLAYING before we can
- * receive a buffer. We don't do that yet */
- g_print ("live sources not supported yet\n");
- exit (-1);
- default:
- break;
- }
- /* This can block for up to 5 seconds. If your machine is really overloaded,
- * it might time out before the pipeline prerolled and we generate an error. A
- * better way is to run a mainloop and catch errors there. */
- ret = gst_element_get_state (pipeline, NULL, NULL, 5 * GST_SECOND);
- if (ret == GST_STATE_CHANGE_FAILURE) {
- g_print ("failed to play the file\n");
- exit (-1);
- }
-
- /* get the duration */
- format = GST_FORMAT_TIME;
- gst_element_query_duration (pipeline, &format, &duration);
-
- if (duration != -1)
- /* we have a duration, seek to 5% */
- position = duration * 5 / 100;
- else
- /* no duration, seek to 1 second, this could EOS */
- position = 1 * GST_SECOND;
-
- /* seek to the a position in the file. Most files have a black first frame so
- * by seeking to somewhere else we have a bigger chance of getting something
- * more interesting. An optimisation would be to detect black images and then
- * seek a little more */
- gst_element_seek_simple (pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
- position);
-
- /* get the preroll buffer from appsink, this block untils appsink really
- * prerolls */
- g_signal_emit_by_name (sink, "pull-preroll", &buffer, NULL);
-
- /* if we have a buffer now, convert it to a pixbuf. It's possible that we
- * don't have a buffer because we went EOS right away or had an error. */
- if (buffer) {
- GstCaps *caps;
- GstStructure *s;
-
- /* get the snapshot buffer format now. We set the caps on the appsink so
- * that it can only be an rgb buffer. The only thing we have not specified
- * on the caps is the height, which is dependant on the pixel-aspect-ratio
- * of the source material */
- caps = GST_BUFFER_CAPS (buffer);
- if (!caps) {
- g_print ("could not get snapshot format\n");
- exit (-1);
- }
- s = gst_caps_get_structure (caps, 0);
-
- /* we need to get the final caps on the buffer to get the size */
- res = gst_structure_get_int (s, "width", &width);
- res |= gst_structure_get_int (s, "height", &height);
- if (!res) {
- g_print ("could not get snapshot dimension\n");
- exit (-1);
- }
-
- /* create pixmap from buffer and save, gstreamer video buffers have a stride
- * that is rounded up to the nearest multiple of 4 */
- pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer),
- GDK_COLORSPACE_RGB, FALSE, 8, width, height,
- GST_ROUND_UP_4 (width * 3), NULL, NULL);
-
- /* save the pixbuf */
- gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
- } else {
- g_print ("could not make snapshot\n");
- }
-
- /* cleanup and exit */
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
-
- exit (0);
-}
diff --git a/tests/examples/v4l/.gitignore b/tests/examples/v4l/.gitignore
deleted file mode 100644
index da0c4eb8..00000000
--- a/tests/examples/v4l/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-probe
diff --git a/tests/examples/v4l/Makefile.am b/tests/examples/v4l/Makefile.am
deleted file mode 100644
index 6132cdc0..00000000
--- a/tests/examples/v4l/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-noinst_PROGRAMS = probe
-
-probe_SOURCES = probe.c
-probe_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
- $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-probe_LDFLAGS = \
- $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
- $(GST_PLUGINS_BASE_LIBS) \
- $(GST_BASE_LIBS) $(GST_LIBS)
-
diff --git a/tests/examples/v4l/probe.c b/tests/examples/v4l/probe.c
deleted file mode 100644
index 435aeac9..00000000
--- a/tests/examples/v4l/probe.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* GStreamer
- * Copyright (C) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
- *
- * 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 <stdlib.h>
-#include <gst/gst.h>
-#include <gst/interfaces/propertyprobe.h>
-
-int
-main (int argc, char *argv[])
-{
- GstElement *src, *sink;
- GstElement *bin;
- GstPropertyProbe *probe = NULL;
- const GParamSpec *pspec = NULL;
- GValueArray *array = NULL;
- gint i, ret;
- GValue *value;
- const gchar *device;
- gchar *name;
- guint flags;
-
- gst_init (&argc, &argv);
-
- bin = gst_pipeline_new ("pipeline");
- g_assert (bin);
-
- src = gst_element_factory_make ("v4lsrc", "v4l_source");
- g_assert (src);
- sink = gst_element_factory_make ("fakesink", "fake_sink");
- g_assert (sink);
-
- /* add objects to the main pipeline */
- gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
- /* link the elements */
- gst_element_link_many (src, sink, NULL);
-
- /* probe devices */
- g_print ("Probing devices with propertyprobe...\n");
- probe = GST_PROPERTY_PROBE (src);
- pspec = gst_property_probe_get_property (probe, "device");
- array = gst_property_probe_probe_and_get_values (probe, pspec);
-
- if (!array) {
- g_print ("No device found\n");
- exit (1);
- }
-
- for (i = 0; i < array->n_values; i++) {
- value = g_value_array_get_nth (array, i);
- device = g_value_get_string (value);
- g_print ("Device: %s\n", device);
- g_object_set_property (G_OBJECT (src), "device", value);
- gst_element_set_state (bin, GST_STATE_READY);
- ret = gst_element_get_state (bin, NULL, NULL, 10 * GST_SECOND);
- if (ret != GST_STATE_CHANGE_SUCCESS) {
- g_print ("Couldn't set STATE_READY\n");
- continue;
- }
- g_object_get (G_OBJECT (src), "device-name", &name, NULL);
- g_print ("Name: %s\n", name);
- g_free (name);
- g_object_get (G_OBJECT (src), "flags", &flags, NULL);
- g_print ("Flags: 0x%08X\n", flags);
- gst_element_set_state (bin, GST_STATE_NULL);
- g_print ("\n");
- }
-
- exit (0);
-}
diff --git a/tests/examples/volume/.gitignore b/tests/examples/volume/.gitignore
deleted file mode 100644
index 4833bbb0..00000000
--- a/tests/examples/volume/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-volume
diff --git a/tests/examples/volume/Makefile.am b/tests/examples/volume/Makefile.am
deleted file mode 100644
index c4da3371..00000000
--- a/tests/examples/volume/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-if HAVE_GTK
-noinst_PROGRAMS = volume
-volume_SOURCES = volume.c
-volume_CFLAGS = $(GTK_CFLAGS) $(GST_CFLAGS) -D_GNU_SOURCE
-volume_LDFLAGS = $(GTK_LIBS) $(GST_LIBS) $(LIBM)
-endif
diff --git a/tests/examples/volume/volume.c b/tests/examples/volume/volume.c
deleted file mode 100644
index 59e4981f..00000000
--- a/tests/examples/volume/volume.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* GStreamer
- *
- * volume.c: sample application to change the volume of a pipeline
- *
- * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include <gst/gst.h>
-#include <gtk/gtk.h>
-
-/* global pointer for the scale widget */
-GtkWidget *elapsed;
-GtkWidget *scale;
-
-#ifndef M_LN10
-#define M_LN10 (log(10.0))
-#endif
-
-static void
-value_changed_callback (GtkWidget * widget, GstElement * volume)
-{
- gdouble value;
- gdouble level;
-
- value = gtk_range_get_value (GTK_RANGE (widget));
- level = exp (value / 20.0 * M_LN10);
- g_print ("Value: %f dB, level: %f\n", value, level);
- g_object_set (volume, "volume", level, NULL);
-}
-
-static void
-setup_gui (GstElement * volume)
-{
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *label, *hbox;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
-
- vbox = gtk_vbox_new (TRUE, 0);
- gtk_container_add (GTK_CONTAINER (window), vbox);
-
- /* elapsed widget */
- hbox = gtk_hbox_new (TRUE, 0);
- label = gtk_label_new ("Elapsed");
- elapsed = gtk_label_new ("0.000");
- gtk_container_add (GTK_CONTAINER (hbox), label);
- gtk_container_add (GTK_CONTAINER (hbox), elapsed);
- gtk_container_add (GTK_CONTAINER (vbox), hbox);
-
- /* volume */
- hbox = gtk_hbox_new (TRUE, 0);
- label = gtk_label_new ("volume");
- gtk_container_add (GTK_CONTAINER (hbox), label);
- scale = gtk_hscale_new_with_range (-90.0, 10.0, 0.2);
- gtk_range_set_value (GTK_RANGE (scale), 0.0);
- gtk_widget_set_size_request (scale, 100, -1);
- gtk_container_add (GTK_CONTAINER (hbox), scale);
- gtk_container_add (GTK_CONTAINER (vbox), hbox);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (value_changed_callback), volume);
-
- gtk_widget_show_all (GTK_WIDGET (window));
-}
-
-static void
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
-{
- const GstStructure *s;
-
- s = gst_message_get_structure (message);
- g_print ("message from \"%s\" (%s): ",
- GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))),
- gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
- if (s) {
- gchar *sstr;
-
- sstr = gst_structure_to_string (s);
- g_print ("%s\n", sstr);
- g_free (sstr);
- } else {
- g_print ("no message details\n");
- }
-}
-
-static void
-eos_message_received (GstBus * bus, GstMessage * message,
- GstPipeline * pipeline)
-{
- message_received (bus, message, pipeline);
- gtk_main_quit ();
-}
-
-int
-main (int argc, char *argv[])
-{
-
- GstElement *pipeline = NULL;
-
-#ifndef GST_DISABLE_PARSE
- GError *error = NULL;
-#endif
- GstElement *volume;
- GstBus *bus;
-
-#ifdef GST_DISABLE_PARSE
- g_print ("GStreamer was built without pipeline parsing capabilities.\n");
- g_print
- ("Please rebuild GStreamer with pipeline parsing capabilities activated to use this example.\n");
- return 1;
-#else
- gst_init (&argc, &argv);
- gtk_init (&argc, &argv);
-
- pipeline = gst_parse_launchv ((const gchar **) &argv[1], &error);
- if (error) {
- g_print ("pipeline could not be constructed: %s\n", error->message);
- g_print ("Please give a complete pipeline with a 'volume' element.\n");
- g_print ("Example: audiotestsrc ! volume ! %s\n", DEFAULT_AUDIOSINK);
- g_error_free (error);
- return 1;
- }
-#endif
- volume = gst_bin_get_by_name (GST_BIN (pipeline), "volume0");
- if (volume == NULL) {
- g_print ("Please give a pipeline with a 'volume' element in it\n");
- return 1;
- }
-
- /* setup message handling */
- bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
- gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
- g_signal_connect (bus, "message::error", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::warning", (GCallback) message_received,
- pipeline);
- g_signal_connect (bus, "message::eos", (GCallback) eos_message_received,
- pipeline);
-
- /* setup GUI */
- setup_gui (volume);
-
- /* go to main loop */
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- gtk_main ();
- gst_element_set_state (pipeline, GST_STATE_NULL);
- gst_object_unref (pipeline);
-
- return 0;
-}