Commit 62204482 authored by Stefan Kost's avatar Stefan Kost
Browse files

tests/examples/seek/seek.c: Destroy and recreate parse-launch based pipeline...

tests/examples/seek/seek.c: Destroy and recreate parse-launch based pipeline after stop to be able to play again. Reo...

Original commit message from CVS:
* tests/examples/seek/seek.c: (update_scale), (play_cb), (stop_cb),
(main):
Destroy and recreate parse-launch based pipeline after stop to be able
to play again. Reorder some code and add more comments.
parent 3b2762a5
2007-06-21 Stefan Kost <ensonic@users.sf.net>
* tests/examples/seek/seek.c: (update_scale), (play_cb), (stop_cb),
(main):
Destroy and recreate parse-launch based pipeline after stop to be able
to play again. Reorder some code and add more comments.
2007-06-20 Jan Schmidt <thaytan@mad.scientist.com>
 
* gst/playback/gstdecodebin2.c: (analyze_new_pad):
......@@ -33,6 +33,31 @@
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 UPDATE_INTERVAL 500
//#define UPDATE_INTERVAL 100
#define UPDATE_INTERVAL 10
/* 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
static GList *seekable_pads = NULL;
static GList *rate_pads = NULL;
static GList *seekable_elements = NULL;
......@@ -46,6 +71,8 @@ static gboolean play_scrub = 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;
......@@ -59,28 +86,8 @@ static guint update_id = 0;
static guint seek_timeout_id = 0;
static gulong changed_id;
//#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 UPDATE_INTERVAL 500
//#define UPDATE_INTERVAL 100
#define UPDATE_INTERVAL 10
/* number of milliseconds to play for after a seek */
#define SCRUB_TIME 100
/* seek timeout */
#define SEEK_TIMEOUT 40 * GST_MSECOND
#define THREAD
#define PAD_SEEK
/* pipeline construction */
typedef struct
{
......@@ -858,6 +865,39 @@ make_parselaunch_pipeline (const gchar * description)
}
#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
{NULL, NULL},
};
#define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
/* ui callbacks and helpers */
static gchar *
format_value (GtkScale * scale, gdouble value)
{
......@@ -1005,8 +1045,8 @@ update_scale (gpointer data)
{
GstFormat format = GST_FORMAT_TIME;
position = 0;
duration = 0;
//position = 0;
//duration = 0;
if (elem_seek) {
if (seekable_elements) {
......@@ -1245,6 +1285,7 @@ play_cb (GtkButton * button, gpointer data)
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE)
goto failed;
//do_seek(hscale);
state = GST_STATE_PLAYING;
}
......@@ -1291,12 +1332,24 @@ stop_cb (GtkButton * button, gpointer data)
set_scale (0.0);
state = GST_STATE_READY;
/* 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);
pipeline = pipelines[pipeline_type].func (pipeline_spec);
g_assert (pipeline);
gst_element_set_state (pipeline, GST_STATE_READY);
}
}
return;
failed:
{
g_print ("READY failed\n");
g_print ("STOP failed\n");
}
}
......@@ -1475,37 +1528,6 @@ msg_segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
set_update_scale (TRUE);
}
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
{NULL, NULL},
};
#define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
static void
print_usage (int argc, char **argv)
{
......@@ -1537,7 +1559,6 @@ main (int argc, char **argv)
"Verbose properties", NULL},
{NULL}
};
gint type;
GOptionContext *ctx;
GError *err = NULL;
......@@ -1562,14 +1583,16 @@ main (int argc, char **argv)
exit (-1);
}
type = atoi (argv[1]);
pipeline_type = atoi (argv[1]);
if (type < 0 || type >= NUM_TYPES) {
if (pipeline_type < 0 || pipeline_type >= NUM_TYPES) {
print_usage (argc, argv);
exit (-1);
}
pipeline = pipelines[type].func (argv[2]);
pipeline_spec = argv[2];
pipeline = pipelines[pipeline_type].func (pipeline_spec);
g_assert (pipeline);
/* initialize gui elements ... */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment