seek.c 37 KB
Newer Older
1
#include <stdlib.h>
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
2 3 4 5 6
#include <glib.h>
#include <gtk/gtk.h>
#include <gst/gst.h>
#include <string.h>

7
static GList *seekable_pads = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
8
static GList *rate_pads = NULL;
9
static GList *seekable_elements = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
10 11

static GstElement *pipeline;
Wim Taymans's avatar
Wim Taymans committed
12 13
static gint64 position;
static gint64 duration;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
14
static GtkAdjustment *adjustment;
15
static GtkWidget *hscale;
16
static gboolean stats = FALSE;
17 18
static gboolean elem_seek = FALSE;
static gboolean verbose = FALSE;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
19 20

static guint update_id;
21 22
static guint seek_timeout_id = 0;
static gulong changed_id;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
23

Wim Taymans's avatar
Wim Taymans committed
24
//#define SOURCE "filesrc"
25
#define SOURCE "gnomevfssrc"
26 27
#define ASINK "alsasink"
//#define ASINK "osssink"
Wim Taymans's avatar
Wim Taymans committed
28 29 30
#define VSINK "xvimagesink"
//#define VSINK "ximagesink"
//#define VSINK "aasink"
31
//#define VSINK "cacasink"
32

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
33 34
#define UPDATE_INTERVAL 500

35
/* number of milliseconds to play for after a seek */
Wim Taymans's avatar
Wim Taymans committed
36 37
//#define SCRUB_TIME 250
//#define SCRUB
38

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
39
#define THREAD
40
#define PAD_SEEK
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
41 42 43

typedef struct
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
44 45 46
  const gchar *padname;
  GstPad *target;
  GstElement *bin;
47 48
}
dyn_link;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
49

50
static GstElement *
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
51
gst_element_factory_make_or_warn (gchar * type, gchar * name)
52 53 54 55
{
  GstElement *element = gst_element_factory_make (type, name);

  if (!element) {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
56
    g_warning ("Failed to create element %s of type %s", name, type);
57 58 59 60 61
  }

  return element;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
62
static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
63
dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
64
{
65
  dyn_link *connect = (dyn_link *) data;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
66

67 68 69 70
  if (connect->padname == NULL ||
      !strcmp (gst_pad_get_name (newpad), connect->padname)) {
    if (connect->bin)
      gst_bin_add (GST_BIN (pipeline), connect->bin);
71
    gst_pad_link (newpad, connect->target);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
72

73
    //seekable_pads = g_list_prepend (seekable_pads, newpad);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
74 75 76 77 78
    rate_pads = g_list_prepend (rate_pads, newpad);
  }
}

static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
79 80
setup_dynamic_link (GstElement * element, const gchar * padname,
    GstPad * target, GstElement * bin)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
81
{
82
  dyn_link *connect;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
83

84
  connect = g_new0 (dyn_link, 1);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
85 86 87
  connect->padname = g_strdup (padname);
  connect->target = target;
  connect->bin = bin;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
88

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
89 90
  g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
      connect);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
91 92
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
93 94
static GstElement *
make_mod_pipeline (const gchar * location)
95 96 97 98
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
99

100 101
  pipeline = gst_pipeline_new ("app");

102 103
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("modplug", "decoder");
104
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
105 106 107 108 109 110 111 112
  //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);

113 114
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
115 116 117 118 119 120 121 122 123

  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;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
124 125
static GstElement *
make_dv_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
126 127 128 129
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink, *videosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
130

Wim Taymans's avatar
Wim Taymans committed
131 132 133 134
  pipeline = gst_pipeline_new ("app");

  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("dvdec", "decoder");
135
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
136
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
Wim Taymans's avatar
Wim Taymans committed
137 138 139 140 141 142 143 144 145
  //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);

146 147 148
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
  gst_element_link (decoder, videosink);
Wim Taymans's avatar
Wim Taymans committed
149 150 151 152 153 154 155 156 157 158 159 160

  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;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
161 162
static GstElement *
make_wav_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
163 164 165 166
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
167

Wim Taymans's avatar
Wim Taymans committed
168 169
  pipeline = gst_pipeline_new ("app");

170 171
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("wavparse", "decoder");
172
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
Wim Taymans's avatar
Wim Taymans committed
173 174 175 176 177 178 179 180
  //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);

181 182
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
Wim Taymans's avatar
Wim Taymans committed
183 184 185 186 187 188 189 190 191

  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;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
192 193
static GstElement *
make_flac_pipeline (const gchar * location)
194 195 196 197
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
198

199 200
  pipeline = gst_pipeline_new ("app");

201 202
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("flacdec", "decoder");
203
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
Wim Taymans's avatar
Wim Taymans committed
204
  g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
205 206 207 208 209 210 211

  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);

212 213
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
214 215 216 217 218 219 220 221 222

  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;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
223 224
static GstElement *
make_sid_pipeline (const gchar * location)
225 226 227 228
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
229

230 231
  pipeline = gst_pipeline_new ("app");

232 233
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("siddec", "decoder");
234
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
235 236 237 238 239 240 241 242
  //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);

243 244
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
245 246 247 248 249 250 251 252 253

  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;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
254 255
static GstElement *
make_parse_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
256 257 258 259
{
  GstElement *pipeline;
  GstElement *src, *parser, *fakesink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
260

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
261 262
  pipeline = gst_pipeline_new ("app");

263 264 265
  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");
Wim Taymans's avatar
Wim Taymans committed
266 267
  g_object_set (G_OBJECT (fakesink), "silent", TRUE, NULL);
  g_object_set (G_OBJECT (fakesink), "sync", TRUE, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
268 269 270 271 272 273 274

  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);

275 276
  gst_element_link (src, parser);
  gst_element_link (parser, fakesink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
277 278

  seekable = gst_element_get_pad (parser, "src");
279
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
280 281 282 283 284 285
  rate_pads = g_list_prepend (rate_pads, seekable);
  rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (parser, "sink"));

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
286 287
static GstElement *
make_vorbis_pipeline (const gchar * location)
288
{
289 290
  GstElement *pipeline, *audio_bin;
  GstElement *src, *demux, *decoder, *convert, *audiosink;
291
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
292

293 294
  pipeline = gst_pipeline_new ("app");

295
  src = gst_element_factory_make_or_warn (SOURCE, "src");
296 297 298
  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");
299
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
Wim Taymans's avatar
Wim Taymans committed
300
  g_object_set (G_OBJECT (audiosink), "sync", TRUE, NULL);
301 302 303

  g_object_set (G_OBJECT (src), "location", location, NULL);

304 305
  audio_bin = gst_bin_new ("a_decoder_bin");

306
  gst_bin_add (GST_BIN (pipeline), src);
307 308 309 310 311
  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);
312

313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
  gst_element_link (src, demux);
  gst_element_link (decoder, convert);
  gst_element_link (convert, audiosink);

  setup_dynamic_link (demux, NULL, gst_element_get_pad (decoder, "sink"), NULL);

  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_theora_pipeline (const gchar * location)
{
  GstElement *pipeline, *video_bin;
  GstElement *src, *demux, *decoder, *convert, *videosink;
  GstElement *queue;
  GstPad *seekable;

  pipeline = gst_pipeline_new ("app");

  src = gst_element_factory_make_or_warn (SOURCE, "src");
  demux = gst_element_factory_make_or_warn ("oggdemux", "demux");
  queue = gst_element_factory_make_or_warn ("queue", "queue");
  decoder = gst_element_factory_make_or_warn ("theoradec", "decoder");
  convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "convert");
Wim Taymans's avatar
Wim Taymans committed
342
  videosink = gst_element_factory_make_or_warn (VSINK, "sink");
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361

  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 (pipeline), queue);
  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 (queue, decoder);
  gst_element_link (decoder, convert);
  gst_element_link (convert, videosink);

  setup_dynamic_link (demux, NULL, gst_element_get_pad (queue, "sink"), NULL);
362 363 364 365 366 367 368 369 370

  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;
}

371 372 373 374 375 376 377 378
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;
  GstPad *seekable;
Wim Taymans's avatar
Wim Taymans committed
379
  GstPad *pad;
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395

  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");
396
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
397

398
  gst_bin_add (GST_BIN (pipeline), audio_bin);
399 400 401 402 403 404

  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);

405 406 407
  gst_element_link (a_queue, a_decoder);
  gst_element_link (a_decoder, a_convert);
  gst_element_link (a_convert, audiosink);
408

Wim Taymans's avatar
Wim Taymans committed
409 410 411
  pad = gst_element_get_pad (a_queue, "sink");
  gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
  gst_object_unref (GST_OBJECT_CAST (pad));
412 413 414

  setup_dynamic_link (demux, NULL, gst_element_get_pad (audio_bin, "sink"),
      NULL);
415 416 417 418 419 420

  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");
Wim Taymans's avatar
Wim Taymans committed
421
  videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
422 423

  gst_bin_add (GST_BIN (pipeline), video_bin);
424 425 426 427 428 429

  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);

430
  gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
431

Wim Taymans's avatar
Wim Taymans committed
432 433 434
  pad = gst_element_get_pad (v_queue, "sink");
  gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
  gst_object_unref (GST_OBJECT_CAST (pad));
435 436 437

  setup_dynamic_link (demux, NULL, gst_element_get_pad (video_bin, "sink"),
      NULL);
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471

  seekable = gst_element_get_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_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;

  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");
472
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491

  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 (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_bin_add (GST_BIN (pipeline), audio_bin);

  setup_dynamic_link (demux, NULL, gst_element_get_pad (a_queue, "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");
Wim Taymans's avatar
Wim Taymans committed
492
  videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
  gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);

  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_bin_add (GST_BIN (pipeline), video_bin);

  setup_dynamic_link (demux, NULL, gst_element_get_pad (v_queue, "sink"), NULL);

  seekable = gst_element_get_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_pad (a_decoder, "sink"));

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
513 514
static GstElement *
make_mp3_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
515 516
{
  GstElement *pipeline;
517
  GstElement *src, *decoder, *osssink, *queue;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
518
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
519

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
520 521
  pipeline = gst_pipeline_new ("app");

522 523 524
  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");
525
  osssink = gst_element_factory_make_or_warn (ASINK, "sink");
526

527
  seekable_elements = g_list_prepend (seekable_elements, osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
528 529

  g_object_set (G_OBJECT (src), "location", location, NULL);
530
  g_object_set (G_OBJECT (osssink), "fragment", 0x00180008, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
531

532 533
  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), decoder);
534 535
  gst_bin_add (GST_BIN (pipeline), queue);
  gst_bin_add (GST_BIN (pipeline), osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
536

537 538
  gst_element_link (src, decoder);
  gst_element_link (decoder, queue);
539
  gst_element_link (queue, osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
540

541 542
  seekable = gst_element_get_pad (queue, "src");
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
543 544 545 546 547 548
  rate_pads = g_list_prepend (rate_pads, seekable);
  rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink"));

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
549 550
static GstElement *
make_avi_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
551 552 553
{
  GstElement *pipeline, *audio_bin, *video_bin;
  GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink;
554
  GstElement *a_queue = NULL, *v_queue = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
555
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
556

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
557 558
  pipeline = gst_pipeline_new ("app");

559
  src = gst_element_factory_make_or_warn (SOURCE, "src");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
560 561
  g_object_set (G_OBJECT (src), "location", location, NULL);

562
  demux = gst_element_factory_make_or_warn ("avidemux", "demux");
563
  seekable_elements = g_list_prepend (seekable_elements, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
564 565 566

  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), demux);
567
  gst_element_link (src, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
568 569

  audio_bin = gst_bin_new ("a_decoder_bin");
570
  a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
571
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
572
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
573
  a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
574 575
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
576
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
577 578
  gst_bin_add (GST_BIN (audio_bin), a_queue);
  gst_bin_add (GST_BIN (audio_bin), audiosink);
Wim Taymans's avatar
Wim Taymans committed
579
  gst_element_set_state (audio_bin, GST_STATE_PAUSED);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
580

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
581
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
582
          "sink"), audio_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
583 584

  seekable = gst_element_get_pad (a_queue, "src");
585
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
586
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
587 588
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
589 590

  video_bin = gst_bin_new ("v_decoder_bin");
591
  //v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
592
  //v_decoder = gst_element_factory_make_or_warn ("windec", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
593
  v_decoder = gst_element_factory_make_or_warn ("ffmpegdecall", "v_dec");
594
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
595
  //videosink = gst_element_factory_make_or_warn ("fakesink", "v_sink");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
596
  //g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
597
  v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
Wim Taymans's avatar
Wim Taymans committed
598
  //g_object_set (G_OBJECT (v_queue), "max_level", 10, NULL);
599 600
  gst_element_link (v_decoder, v_queue);
  gst_element_link (v_queue, videosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
601
  gst_bin_add (GST_BIN (video_bin), v_decoder);
602 603
  gst_bin_add (GST_BIN (video_bin), v_queue);
  gst_bin_add (GST_BIN (video_bin), videosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
604

Wim Taymans's avatar
Wim Taymans committed
605
  gst_element_set_state (video_bin, GST_STATE_PAUSED);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
606

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
607
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
608
          "sink"), video_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
609 610

  seekable = gst_element_get_pad (v_queue, "src");
611
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
612
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
613 614
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
615 616 617 618

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
619 620
static GstElement *
make_mpeg_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
621 622
{
  GstElement *pipeline, *audio_bin, *video_bin;
623 624
  GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
  GstElement *audiosink, *videosink;
625
  GstElement *a_queue, *v_queue;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
626
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
627

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
628 629
  pipeline = gst_pipeline_new ("app");

630
  src = gst_element_factory_make_or_warn (SOURCE, "src");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
631 632
  g_object_set (G_OBJECT (src), "location", location, NULL);

633
  demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
Wim Taymans's avatar
Wim Taymans committed
634
  g_object_set (G_OBJECT (demux), "sync", FALSE, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
635

636 637
  seekable_elements = g_list_prepend (seekable_elements, demux);

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
638 639
  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), demux);
640
  gst_element_link (src, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
641 642

  audio_bin = gst_bin_new ("a_decoder_bin");
643 644
  a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
  a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
645
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
646
  g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
647 648
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
649
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
650 651
  gst_bin_add (GST_BIN (audio_bin), a_queue);
  gst_bin_add (GST_BIN (audio_bin), audiosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
652

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
653
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
654
          "sink"), audio_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
655 656

  seekable = gst_element_get_pad (a_queue, "src");
657
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
658
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
659 660
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
661 662

  video_bin = gst_bin_new ("v_decoder_bin");
663
  v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
664
  //g_object_set (G_OBJECT (video_thread), "priority", 2, NULL);
665
  v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
666
  v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
667
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
668
  gst_element_link_many (v_decoder, v_queue, v_filter, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
669

670
  gst_element_link (v_filter, videosink);
671 672
  gst_bin_add_many (GST_BIN (video_bin), v_decoder, NULL);
  gst_bin_add_many (GST_BIN (video_bin), v_queue, v_filter, videosink, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
673

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
674
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
675
          "sink"), video_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
676 677

  seekable = gst_element_get_pad (v_queue, "src");
678
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
679
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
680 681
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
682 683 684 685

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
686 687
static GstElement *
make_mpegnt_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
688 689 690 691
{
  GstElement *pipeline, *audio_bin, *video_bin;
  GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
  GstElement *audiosink, *videosink;
692
  GstElement *a_queue;
Wim Taymans's avatar
Wim Taymans committed
693
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
694

Wim Taymans's avatar
Wim Taymans committed
695 696 697 698 699 700 701 702 703 704 705 706
  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);
707
  gst_element_link (src, demux);
Wim Taymans's avatar
Wim Taymans committed
708 709 710 711

  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");
712
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
Wim Taymans's avatar
Wim Taymans committed
713 714
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
  g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
715 716
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Wim Taymans's avatar
Wim Taymans committed
717
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
718 719
  gst_bin_add (GST_BIN (audio_bin), a_queue);
  gst_bin_add (GST_BIN (audio_bin), audiosink);
Wim Taymans's avatar
Wim Taymans committed
720

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
721
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
722
          "sink"), audio_bin);
Wim Taymans's avatar
Wim Taymans committed
723 724 725 726

  seekable = gst_element_get_pad (a_queue, "src");
  seekable_pads = g_list_prepend (seekable_pads, seekable);
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
727 728
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Wim Taymans's avatar
Wim Taymans committed
729 730 731

  video_bin = gst_bin_new ("v_decoder_bin");
  v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
732
  v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
733
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
734
  gst_element_link_many (v_decoder, v_filter, videosink, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
735

Wim Taymans's avatar
Wim Taymans committed
736 737
  gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL);

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
738
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
739
          "sink"), video_bin);
Wim Taymans's avatar
Wim Taymans committed
740 741 742 743

  seekable = gst_element_get_pad (v_decoder, "src");
  seekable_pads = g_list_prepend (seekable_pads, seekable);
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
744 745
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Wim Taymans's avatar
Wim Taymans committed
746 747 748 749

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
750 751
static GstElement *
make_playerbin_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
752
{
753
  GstElement *player;
754 755 756 757

  player = gst_element_factory_make ("playbin", "player");
  g_assert (player);

758
  g_object_set (G_OBJECT (player), "uri", location, NULL);
759 760 761 762 763 764 765

  seekable_elements = g_list_prepend (seekable_elements, player);

  /* force element seeking on this pipeline */
  elem_seek = TRUE;

  return player;
Wim Taymans's avatar
Wim Taymans committed
766 767
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
768 769
static gchar *
format_value (GtkScale * scale, gdouble value)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
770
{
771 772 773 774 775 776 777
  gint64 real;
  gint64 seconds;
  gint64 subseconds;

  real = value * duration / 100;
  seconds = (gint64) real / GST_SECOND;
  subseconds = (gint64) real / (GST_SECOND / 100);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
778

779 780
  return g_strdup_printf ("%02" G_GINT64_FORMAT ":%02" G_GINT64_FORMAT ":%02"
      G_GINT64_FORMAT, seconds / 60, seconds % 60, subseconds % 100);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
781 782 783 784 785 786
}

typedef struct
{
  const gchar *name;
  const GstFormat format;
787 788
}
seek_format;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
789

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
790 791 792 793 794 795
static seek_format seek_formats[] = {
  {"tim", GST_FORMAT_TIME},
  {"byt", GST_FORMAT_BYTES},
  {"buf", GST_FORMAT_BUFFERS},
  {"def", GST_FORMAT_DEFAULT},
  {NULL, 0},
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
};

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;

Wim Taymans's avatar
Wim Taymans committed
814 815
      if (gst_pad_query_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format,
              &value)) {
816
        g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
817
      } else {
818
        g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
819 820 821 822 823 824 825 826 827 828 829
      }

      i++;
    }
    g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));

    walk = g_list_next (walk);
  }
}

G_GNUC_UNUSED static void
830 831 832 833 834 835 836 837 838 839
query_positions_elems ()
{
  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) {
Wim Taymans's avatar
Wim Taymans committed
840
      gint64 position, total;
841 842 843
      GstFormat format;

      format = seek_formats[i].format;
Wim Taymans's avatar
Wim Taymans committed
844 845 846 847

      if (gst_element_query_position (element, &format, &position, &total)) {
        g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
            seek_formats[i].name, position, total);
848
      } else {
Wim Taymans's avatar
Wim Taymans committed
849 850
        g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
            "*NA*");
851 852 853 854 855 856 857 858 859 860 861
      }
      i++;
    }
    g_print (" %s\n", GST_ELEMENT_NAME (element));

    walk = g_list_next (walk);
  }
}

G_GNUC_UNUSED static void
query_positions_pads ()
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
862
{
863 864 865 866 867 868 869 870 871
  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;
Wim Taymans's avatar
Wim Taymans committed
872
      gint64 position, total;
873 874

      format = seek_formats[i].format;
Wim Taymans's avatar
Wim Taymans committed
875 876 877 878

      if (gst_pad_query_position (pad, &format, &position, &total)) {
        g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
            seek_formats[i].name, position, total);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
879
      } else {
Wim Taymans's avatar
Wim Taymans committed
880 881
        g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
            "*NA*");
882
      }
Wim Taymans's avatar
Wim Taymans committed
883

884
      i++;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
885
    }
886 887 888
    g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));

    walk = g_list_next (walk);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
889 890 891 892
  }
}

static gboolean
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
893
update_scale (gpointer data)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
894 895
{
  GstClock *clock;
Wim Taymans's avatar
Wim Taymans committed
896
  GstFormat format;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
897

Wim Taymans's avatar
Wim Taymans committed
898
  position = 0;
899
  duration = 0;
900
  clock = gst_pipeline_get_clock (GST_PIPELINE (pipeline));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
901

Wim Taymans's avatar
Wim Taymans committed
902 903
  format = GST_FORMAT_TIME;

904 905 906
  if (elem_seek) {
    if (seekable_elements) {
      GstElement *element = GST_ELEMENT (seekable_elements->data);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
907

Wim Taymans's avatar
Wim Taymans committed
908
      gst_element_query_position (element, &format, &position, &duration);
909 910 911 912 913
    }
  } else {
    if (seekable_pads) {
      GstPad *pad = GST_PAD (seekable_pads->data);

Wim Taymans's avatar
Wim Taymans committed
914
      gst_pad_query_position (pad, &format, &position, &duration);
915
    }
916
  }
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
917

Wim Taymans's avatar