2002-08-11 11:45:07 +00:00
|
|
|
#include <stdlib.h>
|
2002-05-28 20:30:11 +00:00
|
|
|
#include <glib.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
static GList *seekable_pads = NULL;
|
2002-05-28 20:30:11 +00:00
|
|
|
static GList *rate_pads = NULL;
|
2002-06-06 20:26:52 +00:00
|
|
|
static GList *seekable_elements = NULL;
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
static GstElement *pipeline;
|
2002-06-11 19:20:52 +00:00
|
|
|
static guint64 duration;
|
2002-05-28 20:30:11 +00:00
|
|
|
static GtkAdjustment *adjustment;
|
2002-06-11 19:20:52 +00:00
|
|
|
static gboolean stats = FALSE;
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
static guint update_id;
|
|
|
|
|
2002-07-08 19:29:16 +00:00
|
|
|
//#define SOURCE "gnomevfssrc"
|
|
|
|
#define SOURCE "filesrc"
|
2002-06-06 20:26:52 +00:00
|
|
|
|
2002-05-28 20:30:11 +00:00
|
|
|
#define UPDATE_INTERVAL 500
|
|
|
|
|
|
|
|
#define THREAD
|
2002-06-06 20:26:52 +00:00
|
|
|
#define PAD_SEEK
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar *padname;
|
|
|
|
GstPad *target;
|
|
|
|
GstElement *bin;
|
2003-01-10 10:22:25 +00:00
|
|
|
} dyn_link;
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
static void
|
2003-01-10 10:22:25 +00:00
|
|
|
dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
|
2002-05-28 20:30:11 +00:00
|
|
|
{
|
2003-01-10 10:22:25 +00:00
|
|
|
dyn_link *connect = (dyn_link *) data;
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
if (!strcmp (gst_pad_get_name (newpad), connect->padname)) {
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), connect->bin);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_pad_link (newpad, connect->target);
|
2002-05-28 20:30:11 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_pads = g_list_prepend (seekable_pads, newpad);
|
2002-05-28 20:30:11 +00:00
|
|
|
rate_pads = g_list_prepend (rate_pads, newpad);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-01-10 10:22:25 +00:00
|
|
|
setup_dynamic_linkion (GstElement *element, const gchar *padname, GstPad *target, GstElement *bin)
|
2002-05-28 20:30:11 +00:00
|
|
|
{
|
2003-01-10 10:22:25 +00:00
|
|
|
dyn_link *connect;
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
connect = g_new0 (dyn_link, 1);
|
2002-05-28 20:30:11 +00:00
|
|
|
connect->padname = g_strdup (padname);
|
|
|
|
connect->target = target;
|
|
|
|
connect->bin = bin;
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), connect);
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
|
2002-06-11 19:20:52 +00:00
|
|
|
static GstElement*
|
|
|
|
make_mod_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *decoder, *audiosink;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
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 ("osssink", "sink");
|
2002-06-11 19:20:52 +00:00
|
|
|
//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);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, decoder);
|
|
|
|
gst_element_link (decoder, audiosink);
|
2002-06-11 19:20:52 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_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_pad (decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-06-16 21:54:38 +00:00
|
|
|
static GstElement*
|
|
|
|
make_dv_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *decoder, *audiosink, *videosink;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
|
|
|
src = gst_element_factory_make_or_warn (SOURCE, "src");
|
|
|
|
decoder = gst_element_factory_make_or_warn ("dvdec", "decoder");
|
|
|
|
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
|
|
|
|
audiosink = gst_element_factory_make_or_warn ("osssink", "a_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_bin_add (GST_BIN (pipeline), videosink);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, decoder);
|
|
|
|
gst_element_link (decoder, audiosink);
|
|
|
|
gst_element_link (decoder, videosink);
|
2002-06-16 21:54:38 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_pad (decoder, "video");
|
|
|
|
seekable_pads = g_list_prepend (seekable_pads, seekable);
|
|
|
|
rate_pads = g_list_prepend (rate_pads, seekable);
|
|
|
|
seekable = gst_element_get_pad (decoder, "audio");
|
|
|
|
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_pad (decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-06-08 14:57:15 +00:00
|
|
|
static GstElement*
|
|
|
|
make_wav_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *decoder, *audiosink;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
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 ("osssink", "sink");
|
2002-06-08 14:57:15 +00:00
|
|
|
//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);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, decoder);
|
|
|
|
gst_element_link (decoder, audiosink);
|
2002-06-08 14:57:15 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_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_pad (decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
static GstElement*
|
|
|
|
make_flac_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *decoder, *audiosink;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
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 ("osssink", "sink");
|
2002-06-06 20:26:52 +00:00
|
|
|
//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);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, decoder);
|
|
|
|
gst_element_link (decoder, audiosink);
|
2002-06-06 20:26:52 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_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_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");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
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 ("osssink", "sink");
|
2002-06-06 20:26:52 +00:00
|
|
|
//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);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, decoder);
|
|
|
|
gst_element_link (decoder, audiosink);
|
2002-06-06 20:26:52 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_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_pad (decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-05-28 20:30:11 +00:00
|
|
|
static GstElement*
|
|
|
|
make_parse_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *parser, *fakesink;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
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");
|
2002-12-26 22:53:36 +00:00
|
|
|
g_object_set (G_OBJECT (fakesink), "silent", TRUE, NULL);
|
|
|
|
g_object_set (G_OBJECT (fakesink), "sync", TRUE, NULL);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, parser);
|
|
|
|
gst_element_link (parser, fakesink);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_pad (parser, "src");
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_pads = g_list_prepend (seekable_pads, seekable);
|
2002-05-28 20:30:11 +00:00
|
|
|
rate_pads = g_list_prepend (rate_pads, seekable);
|
|
|
|
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (parser, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
static GstElement*
|
|
|
|
make_vorbis_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *src, *decoder, *audiosink;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
src = gst_element_factory_make_or_warn (SOURCE, "src");
|
|
|
|
decoder = gst_element_factory_make_or_warn ("vorbisfile", "decoder");
|
|
|
|
audiosink = gst_element_factory_make_or_warn ("osssink", "sink");
|
2002-12-26 22:53:36 +00:00
|
|
|
g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
|
2002-06-06 20:26:52 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, decoder);
|
|
|
|
gst_element_link (decoder, audiosink);
|
2002-06-06 20:26:52 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_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_pad (decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-05-28 20:30:11 +00:00
|
|
|
static GstElement*
|
|
|
|
make_mp3_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
2002-06-06 20:26:52 +00:00
|
|
|
GstElement *src, *decoder, *osssink, *queue, *audio_thread;
|
2002-05-28 20:30:11 +00:00
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
src = gst_element_factory_make_or_warn (SOURCE, "src");
|
|
|
|
decoder = gst_element_factory_make_or_warn ("mad", "dec");
|
|
|
|
queue = gst_element_factory_make_or_warn ("queue", "queue");
|
|
|
|
osssink = gst_element_factory_make_or_warn ("osssink", "sink");
|
2002-06-06 20:26:52 +00:00
|
|
|
|
|
|
|
audio_thread = gst_thread_new ("a_decoder_thread");
|
|
|
|
|
|
|
|
seekable_elements = g_list_prepend (seekable_elements, osssink);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "location", location, NULL);
|
|
|
|
g_object_set (G_OBJECT (osssink), "fragment", 0x00180008, NULL);
|
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), src);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), decoder);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), queue);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), osssink);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), audio_thread);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, decoder);
|
|
|
|
gst_element_link (decoder, queue);
|
|
|
|
gst_element_link (queue, osssink);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable = gst_element_get_pad (queue, "src");
|
|
|
|
seekable_pads = g_list_prepend (seekable_pads, seekable);
|
2002-05-28 20:30:11 +00:00
|
|
|
rate_pads = g_list_prepend (rate_pads, seekable);
|
|
|
|
rate_pads = g_list_prepend (rate_pads, gst_element_get_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, *audio_thread = NULL, *v_queue = NULL, *video_thread = NULL;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
src = gst_element_factory_make_or_warn (SOURCE, "src");
|
2002-05-28 20:30:11 +00:00
|
|
|
g_object_set (G_OBJECT (src), "location", location, NULL);
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
demux = gst_element_factory_make_or_warn ("avidemux", "demux");
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_elements = g_list_prepend (seekable_elements, demux);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
gst_bin_add (GST_BIN (pipeline), src);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), demux);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, demux);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
audio_bin = gst_bin_new ("a_decoder_bin");
|
2002-06-13 13:16:52 +00:00
|
|
|
a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
|
2002-05-28 20:30:11 +00:00
|
|
|
audio_thread = gst_thread_new ("a_decoder_thread");
|
2002-06-13 13:16:52 +00:00
|
|
|
audiosink = gst_element_factory_make_or_warn ("osssink", "a_sink");
|
2002-06-06 20:26:52 +00:00
|
|
|
//g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
|
2002-06-13 13:16:52 +00:00
|
|
|
a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (a_decoder, a_queue);
|
|
|
|
gst_element_link (a_queue, audiosink);
|
2002-05-28 20:30:11 +00:00
|
|
|
gst_bin_add (GST_BIN (audio_bin), a_decoder);
|
|
|
|
gst_bin_add (GST_BIN (audio_bin), audio_thread);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), a_queue);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), audiosink);
|
2002-07-24 21:34:23 +00:00
|
|
|
gst_element_set_state (audio_bin, GST_STATE_PAUSED);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
setup_dynamic_linkion (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_pad (a_queue, "src");
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_pads = g_list_prepend (seekable_pads, seekable);
|
2002-05-28 20:30:11 +00:00
|
|
|
rate_pads = g_list_prepend (rate_pads, seekable);
|
|
|
|
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
|
|
|
|
|
|
|
|
video_bin = gst_bin_new ("v_decoder_bin");
|
2002-06-13 13:16:52 +00:00
|
|
|
//v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec");
|
2002-12-26 22:53:36 +00:00
|
|
|
//v_decoder = gst_element_factory_make_or_warn ("windec", "v_dec");
|
|
|
|
v_decoder = gst_element_factory_make_or_warn ("ffdec_msmpeg4", "v_dec");
|
2002-05-28 20:30:11 +00:00
|
|
|
video_thread = gst_thread_new ("v_decoder_thread");
|
2002-06-13 13:16:52 +00:00
|
|
|
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
|
|
|
|
//videosink = gst_element_factory_make_or_warn ("fakesink", "v_sink");
|
2002-05-28 20:30:11 +00:00
|
|
|
//g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
|
2002-06-13 13:16:52 +00:00
|
|
|
v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
|
2002-12-26 22:53:36 +00:00
|
|
|
//g_object_set (G_OBJECT (v_queue), "max_level", 10, NULL);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (v_decoder, v_queue);
|
|
|
|
gst_element_link (v_queue, videosink);
|
2002-05-28 20:30:11 +00:00
|
|
|
gst_bin_add (GST_BIN (video_bin), v_decoder);
|
|
|
|
gst_bin_add (GST_BIN (video_bin), video_thread);
|
|
|
|
gst_bin_add (GST_BIN (video_thread), v_queue);
|
|
|
|
gst_bin_add (GST_BIN (video_thread), videosink);
|
|
|
|
|
2002-07-24 21:34:23 +00:00
|
|
|
gst_element_set_state (video_bin, GST_STATE_PAUSED);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
setup_dynamic_linkion (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_pad (v_queue, "src");
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_pads = g_list_prepend (seekable_pads, seekable);
|
2002-05-28 20:30:11 +00:00
|
|
|
rate_pads = g_list_prepend (rate_pads, seekable);
|
|
|
|
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElement*
|
|
|
|
make_mpeg_pipeline (const gchar *location)
|
|
|
|
{
|
|
|
|
GstElement *pipeline, *audio_bin, *video_bin;
|
2002-06-13 13:16:52 +00:00
|
|
|
GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
|
|
|
|
GstElement *audiosink, *videosink;
|
2002-05-28 20:30:11 +00:00
|
|
|
GstElement *a_queue, *audio_thread, *v_queue, *video_thread;
|
|
|
|
GstPad *seekable;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
src = gst_element_factory_make_or_warn (SOURCE, "src");
|
2002-05-28 20:30:11 +00:00
|
|
|
g_object_set (G_OBJECT (src), "location", location, NULL);
|
|
|
|
|
2002-06-13 13:16:52 +00:00
|
|
|
demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
|
2002-12-30 17:53:18 +00:00
|
|
|
g_object_set (G_OBJECT (demux), "sync", TRUE, NULL);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_elements = g_list_prepend (seekable_elements, demux);
|
|
|
|
|
2002-05-28 20:30:11 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), src);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), demux);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, demux);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
audio_bin = gst_bin_new ("a_decoder_bin");
|
2002-06-13 13:16:52 +00:00
|
|
|
a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
|
2002-05-28 20:30:11 +00:00
|
|
|
audio_thread = gst_thread_new ("a_decoder_thread");
|
2002-06-13 13:16:52 +00:00
|
|
|
a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
|
|
|
|
audiosink = gst_element_factory_make_or_warn ("osssink", "a_sink");
|
2002-05-28 20:30:11 +00:00
|
|
|
g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (a_decoder, a_queue);
|
|
|
|
gst_element_link (a_queue, audiosink);
|
2002-05-28 20:30:11 +00:00
|
|
|
gst_bin_add (GST_BIN (audio_bin), a_decoder);
|
|
|
|
gst_bin_add (GST_BIN (audio_bin), audio_thread);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), a_queue);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), audiosink);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
setup_dynamic_linkion (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_pad (a_queue, "src");
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_pads = g_list_prepend (seekable_pads, seekable);
|
2002-05-28 20:30:11 +00:00
|
|
|
rate_pads = g_list_prepend (rate_pads, seekable);
|
|
|
|
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
|
|
|
|
|
|
|
|
video_bin = gst_bin_new ("v_decoder_bin");
|
2002-06-13 13:16:52 +00:00
|
|
|
v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
|
2002-05-28 20:30:11 +00:00
|
|
|
video_thread = gst_thread_new ("v_decoder_thread");
|
2002-12-26 22:53:36 +00:00
|
|
|
//g_object_set (G_OBJECT (video_thread), "priority", 2, NULL);
|
2002-06-13 13:16:52 +00:00
|
|
|
v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
|
|
|
|
v_filter = gst_element_factory_make_or_warn ("colorspace", "v_filter");
|
|
|
|
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link_many (v_decoder, v_queue, v_filter, NULL);
|
2002-07-08 19:29:16 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (v_filter, videosink);
|
2002-06-13 13:16:52 +00:00
|
|
|
gst_bin_add_many (GST_BIN (video_bin), v_decoder, video_thread, NULL);
|
2002-07-08 19:29:16 +00:00
|
|
|
gst_bin_add_many (GST_BIN (video_thread), v_queue, v_filter, videosink, NULL);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
setup_dynamic_linkion (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_pad (v_queue, "src");
|
2002-06-06 20:26:52 +00:00
|
|
|
seekable_pads = g_list_prepend (seekable_pads, seekable);
|
2002-05-28 20:30:11 +00:00
|
|
|
rate_pads = g_list_prepend (rate_pads, seekable);
|
|
|
|
rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-07-24 21:34:23 +00:00
|
|
|
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, *audio_thread;
|
|
|
|
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);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (src, demux);
|
2002-07-24 21:34:23 +00:00
|
|
|
|
|
|
|
audio_bin = gst_bin_new ("a_decoder_bin");
|
|
|
|
a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
|
|
|
|
audio_thread = gst_thread_new ("a_decoder_thread");
|
|
|
|
a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
|
|
|
|
audiosink = gst_element_factory_make_or_warn ("osssink", "a_sink");
|
|
|
|
//g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link (a_decoder, a_queue);
|
|
|
|
gst_element_link (a_queue, audiosink);
|
2002-07-24 21:34:23 +00:00
|
|
|
gst_bin_add (GST_BIN (audio_bin), a_decoder);
|
|
|
|
gst_bin_add (GST_BIN (audio_bin), audio_thread);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), a_queue);
|
|
|
|
gst_bin_add (GST_BIN (audio_thread), audiosink);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
setup_dynamic_linkion (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
|
2002-07-24 21:34:23 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_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_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 ("colorspace", "v_filter");
|
|
|
|
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_element_link_many (v_decoder, v_filter, videosink, NULL);
|
2002-07-24 21:34:23 +00:00
|
|
|
|
|
|
|
gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL);
|
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
setup_dynamic_linkion (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
|
2002-07-24 21:34:23 +00:00
|
|
|
|
|
|
|
seekable = gst_element_get_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_pad (v_decoder, "sink"));
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2002-05-28 20:30:11 +00:00
|
|
|
static gchar*
|
|
|
|
format_value (GtkScale *scale,
|
|
|
|
gdouble value)
|
|
|
|
{
|
2002-06-06 20:26:52 +00:00
|
|
|
gint64 real;
|
|
|
|
gint64 seconds;
|
|
|
|
gint64 subseconds;
|
|
|
|
|
|
|
|
real = value * duration / 100;
|
|
|
|
seconds = (gint64) real / GST_SECOND;
|
|
|
|
subseconds = (gint64) real / (GST_SECOND / 100);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2002-06-06 20:26:52 +00:00
|
|
|
return g_strdup_printf ("%02lld:%02lld:%02lld",
|
2002-05-28 20:30:11 +00:00
|
|
|
seconds/60,
|
|
|
|
seconds%60,
|
|
|
|
subseconds%100);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
const GstFormat format;
|
|
|
|
} seek_format;
|
|
|
|
|
|
|
|
static seek_format seek_formats[] =
|
|
|
|
{
|
|
|
|
{ "tim", GST_FORMAT_TIME },
|
|
|
|
{ "byt", GST_FORMAT_BYTES },
|
2002-06-06 20:26:52 +00:00
|
|
|
{ "unt", GST_FORMAT_UNITS },
|
2002-05-28 20:30:11 +00:00
|
|
|
{ "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_convert (pad, GST_FORMAT_TIME, GST_SECOND,
|
|
|
|
&format, &value))
|
|
|
|
{
|
2002-06-06 20:26:52 +00:00
|
|
|
g_print ("%s %13lld | ", seek_formats[i].name, value);
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-06-06 20:26:52 +00:00
|
|
|
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
G_GNUC_UNUSED static void
|
2002-06-11 19:20:52 +00:00
|
|
|
query_durations ()
|
2002-05-28 20:30:11 +00:00
|
|
|
{
|
2002-06-11 19:20:52 +00:00
|
|
|
GList *walk = seekable_pads;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstPad *pad = GST_PAD (walk->data);
|
|
|
|
gint i = 0;
|
|
|
|
|
|
|
|
g_print ("durations %8.8s: ", GST_PAD_NAME (pad));
|
|
|
|
while (seek_formats[i].name) {
|
|
|
|
gboolean res;
|
|
|
|
gint64 value;
|
|
|
|
GstFormat format;
|
|
|
|
|
|
|
|
format = seek_formats[i].format;
|
2002-12-30 17:53:18 +00:00
|
|
|
res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &value);
|
2002-06-11 19:20:52 +00:00
|
|
|
if (res) {
|
|
|
|
g_print ("%s %13lld | ", seek_formats[i].name, value);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
|
|
|
|
}
|
|
|
|
i++;
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
2002-06-11 19:20:52 +00:00
|
|
|
g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
G_GNUC_UNUSED static void
|
2002-06-11 19:20:52 +00:00
|
|
|
query_positions ()
|
2002-05-28 20:30:11 +00:00
|
|
|
{
|
2002-06-11 19:20:52 +00:00
|
|
|
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) {
|
|
|
|
gboolean res;
|
|
|
|
gint64 value;
|
|
|
|
GstFormat format;
|
|
|
|
|
|
|
|
format = seek_formats[i].format;
|
2002-12-30 17:53:18 +00:00
|
|
|
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
|
2002-06-11 19:20:52 +00:00
|
|
|
if (res) {
|
|
|
|
g_print ("%s %13lld | ", seek_formats[i].name, value);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
|
|
|
|
}
|
|
|
|
i++;
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
2002-06-11 19:20:52 +00:00
|
|
|
g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
update_scale (gpointer data)
|
|
|
|
{
|
|
|
|
GstClock *clock;
|
2002-06-11 19:20:52 +00:00
|
|
|
guint64 position;
|
|
|
|
GstFormat format = GST_FORMAT_TIME;
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2002-06-11 19:20:52 +00:00
|
|
|
duration = 0;
|
2002-05-28 20:30:11 +00:00
|
|
|
clock = gst_bin_get_clock (GST_BIN (pipeline));
|
|
|
|
|
2002-06-11 19:20:52 +00:00
|
|
|
if (seekable_pads) {
|
|
|
|
GstPad *pad = GST_PAD (seekable_pads->data);
|
2002-12-30 17:53:18 +00:00
|
|
|
gst_pad_query (pad, GST_QUERY_TOTAL, &format, &duration);
|
2002-06-11 19:20:52 +00:00
|
|
|
}
|
|
|
|
position = gst_clock_get_time (clock);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
2002-06-11 19:20:52 +00:00
|
|
|
if (stats) {
|
|
|
|
g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
|
|
|
|
query_durations ();
|
|
|
|
query_positions ();
|
|
|
|
query_rates ();
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (duration > 0) {
|
|
|
|
gtk_adjustment_set_value (adjustment, position * 100.0 / duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
iterate (gpointer data)
|
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
res = gst_bin_iterate (GST_BIN (data));
|
|
|
|
if (!res) {
|
|
|
|
gtk_timeout_remove (update_id);
|
|
|
|
g_print ("stopping iterations\n");
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
|
|
|
|
{
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
|
|
gtk_timeout_remove (update_id);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
|
|
|
|
{
|
|
|
|
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
|
|
|
|
gboolean res;
|
|
|
|
GstEvent *s_event;
|
2002-06-06 20:26:52 +00:00
|
|
|
#ifdef PAD_SEEK
|
|
|
|
GList *walk = seekable_pads;
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstPad *seekable = GST_PAD (walk->data);
|
|
|
|
|
|
|
|
g_print ("seek to %lld on pad %s:%s\n", real, GST_DEBUG_PAD_NAME (seekable));
|
|
|
|
s_event = gst_event_new_seek (GST_FORMAT_TIME |
|
|
|
|
GST_SEEK_METHOD_SET |
|
|
|
|
GST_SEEK_FLAG_FLUSH, real);
|
|
|
|
|
|
|
|
res = gst_pad_send_event (seekable, s_event);
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
2002-06-06 20:26:52 +00:00
|
|
|
#else
|
|
|
|
GList *walk = seekable_elements;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstElement *seekable = GST_ELEMENT (walk->data);
|
|
|
|
|
|
|
|
g_print ("seek to %lld on element %s\n", real, gst_element_get_name (seekable));
|
|
|
|
s_event = gst_event_new_seek (GST_FORMAT_TIME |
|
|
|
|
GST_SEEK_METHOD_SET |
|
|
|
|
GST_SEEK_FLAG_FLUSH, real);
|
|
|
|
|
|
|
|
res = gst_element_send_event (seekable, s_event);
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
#endif
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
gtk_idle_add ((GtkFunction) iterate, pipeline);
|
|
|
|
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
play_cb (GtkButton * button, gpointer data)
|
|
|
|
{
|
2002-06-06 20:26:52 +00:00
|
|
|
if (gst_element_get_state (pipeline) != GST_STATE_PLAYING) {
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
gtk_idle_add ((GtkFunction) iterate, pipeline);
|
|
|
|
update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
|
|
|
|
}
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pause_cb (GtkButton * button, gpointer data)
|
|
|
|
{
|
2002-06-06 20:26:52 +00:00
|
|
|
if (gst_element_get_state (pipeline) != GST_STATE_PAUSED) {
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
|
|
gtk_timeout_remove (update_id);
|
|
|
|
}
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
stop_cb (GtkButton * button, gpointer data)
|
|
|
|
{
|
2002-06-06 20:26:52 +00:00
|
|
|
if (gst_element_get_state (pipeline) != GST_STATE_READY) {
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
|
|
|
gtk_timeout_remove (update_id);
|
|
|
|
}
|
2002-05-28 20:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
GtkWidget *window, *hbox, *vbox,
|
|
|
|
*play_button, *pause_button, *stop_button,
|
|
|
|
*hscale;
|
2002-06-11 19:20:52 +00:00
|
|
|
struct poptOption options[] = {
|
|
|
|
{"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
|
|
|
|
"Show pad stats", NULL},
|
|
|
|
POPT_TABLEEND
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_init_with_popt_table (&argc, &argv, options);
|
2002-05-28 20:30:11 +00:00
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc != 3) {
|
2002-07-24 21:34:23 +00:00
|
|
|
g_print ("usage: %s <type 0=mp3 1=avi 2=mpeg1 3=mpegparse 4=vorbis 5=sid 6=flac 7=wav 8=mod 9=dv 10=mpeg1nothreads> <filename>\n", argv[0]);
|
2002-05-28 20:30:11 +00:00
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (atoi (argv[1]) == 0)
|
|
|
|
pipeline = make_mp3_pipeline (argv[2]);
|
|
|
|
else if (atoi (argv[1]) == 1)
|
|
|
|
pipeline = make_avi_pipeline (argv[2]);
|
|
|
|
else if (atoi (argv[1]) == 2)
|
|
|
|
pipeline = make_mpeg_pipeline (argv[2]);
|
2002-06-06 20:26:52 +00:00
|
|
|
else if (atoi (argv[1]) == 3)
|
2002-05-28 20:30:11 +00:00
|
|
|
pipeline = make_parse_pipeline (argv[2]);
|
2002-06-06 20:26:52 +00:00
|
|
|
else if (atoi (argv[1]) == 4)
|
|
|
|
pipeline = make_vorbis_pipeline (argv[2]);
|
|
|
|
else if (atoi (argv[1]) == 5)
|
|
|
|
pipeline = make_sid_pipeline (argv[2]);
|
|
|
|
else if (atoi (argv[1]) == 6)
|
|
|
|
pipeline = make_flac_pipeline (argv[2]);
|
2002-06-08 14:57:15 +00:00
|
|
|
else if (atoi (argv[1]) == 7)
|
|
|
|
pipeline = make_wav_pipeline (argv[2]);
|
2002-06-11 19:20:52 +00:00
|
|
|
else if (atoi (argv[1]) == 8)
|
|
|
|
pipeline = make_mod_pipeline (argv[2]);
|
2002-06-16 21:54:38 +00:00
|
|
|
else if (atoi (argv[1]) == 9)
|
|
|
|
pipeline = make_dv_pipeline (argv[2]);
|
2002-07-24 21:34:23 +00:00
|
|
|
else if (atoi (argv[1]) == 10)
|
|
|
|
pipeline = make_mpegnt_pipeline (argv[2]);
|
2002-05-28 20:30:11 +00:00
|
|
|
|
|
|
|
/* 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.00, 100.0, 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);
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(hscale),
|
|
|
|
"button_press_event", G_CALLBACK (start_seek), pipeline);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(hscale),
|
|
|
|
"button_release_event", G_CALLBACK (stop_seek), pipeline);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(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);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
2002-12-26 22:53:36 +00:00
|
|
|
g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
|
|
|
|
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
|
|
|
|
|
2002-05-28 20:30:11 +00:00
|
|
|
gtk_main ();
|
|
|
|
|
2002-12-26 22:53:36 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
|
2002-07-08 19:29:16 +00:00
|
|
|
//gst_object_unref (GST_OBJECT (pipeline));
|
|
|
|
gst_buffer_print_stats();
|
|
|
|
gst_event_print_stats();
|
|
|
|
|
2002-05-28 20:30:11 +00:00
|
|
|
//g_mem_chunk_info();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|