seek.c 39.5 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 8 9
GST_DEBUG_CATEGORY (seek_debug);
#define GST_CAT_DEFAULT (seek_debug)

10
static GList *seekable_pads = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
11
static GList *rate_pads = NULL;
12
static GList *seekable_elements = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
13 14

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

23 24
static GstState state;
static guint update_id = 0;
25 26
static guint seek_timeout_id = 0;
static gulong changed_id;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
27

Wim Taymans's avatar
Wim Taymans committed
28
//#define SOURCE "filesrc"
29
#define SOURCE "gnomevfssrc"
30 31
#define ASINK "alsasink"
//#define ASINK "osssink"
Wim Taymans's avatar
Wim Taymans committed
32 33 34
#define VSINK "xvimagesink"
//#define VSINK "ximagesink"
//#define VSINK "aasink"
35
//#define VSINK "cacasink"
36

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
37 38
#define UPDATE_INTERVAL 500

39
/* number of milliseconds to play for after a seek */
Wim Taymans's avatar
Wim Taymans committed
40 41
//#define SCRUB_TIME 250
//#define SCRUB
42

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
43
#define THREAD
44
#define PAD_SEEK
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
45 46 47

typedef struct
{
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
48 49 50
  const gchar *padname;
  GstPad *target;
  GstElement *bin;
51 52
}
dyn_link;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
53

54
static GstElement *
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
55
gst_element_factory_make_or_warn (gchar * type, gchar * name)
56 57 58 59
{
  GstElement *element = gst_element_factory_make (type, name);

  if (!element) {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
60
    g_warning ("Failed to create element %s of type %s", name, type);
61 62 63 64 65
  }

  return element;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
66
static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
67
dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
68
{
69
  dyn_link *connect = (dyn_link *) data;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
70

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

77
    //seekable_pads = g_list_prepend (seekable_pads, newpad);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
78 79 80 81 82
    rate_pads = g_list_prepend (rate_pads, newpad);
  }
}

static void
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
83 84
setup_dynamic_link (GstElement * element, const gchar * padname,
    GstPad * target, GstElement * bin)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
85
{
86
  dyn_link *connect;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
87

88
  connect = g_new0 (dyn_link, 1);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
89 90 91
  connect->padname = g_strdup (padname);
  connect->target = target;
  connect->bin = bin;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
92

93
  g_signal_connect (G_OBJECT (element), "pad-added", G_CALLBACK (dynamic_link),
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
94
      connect);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
95 96
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
97 98
static GstElement *
make_mod_pipeline (const gchar * location)
99 100 101 102
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
103

104 105
  pipeline = gst_pipeline_new ("app");

106 107
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("modplug", "decoder");
108
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
109 110 111 112 113 114 115 116
  //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);

117 118
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
119 120 121 122 123 124 125 126 127

  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
128 129
static GstElement *
make_dv_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
130 131
{
  GstElement *pipeline;
132
  GstElement *src, *demux, *decoder, *audiosink, *videosink;
133
  GstElement *a_queue, *v_queue;
Wim Taymans's avatar
Wim Taymans committed
134
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
135

Wim Taymans's avatar
Wim Taymans committed
136 137 138
  pipeline = gst_pipeline_new ("app");

  src = gst_element_factory_make_or_warn (SOURCE, "src");
139
  demux = gst_element_factory_make_or_warn ("dvdemux", "demuxer");
140
  v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
141 142
  decoder = gst_element_factory_make_or_warn ("ffdec_dvvideo", "decoder");
  videosink = gst_element_factory_make_or_warn ("xvimagesink", "v_sink");
143
  a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
144
  audiosink = gst_element_factory_make_or_warn ("alsasink", "a_sink");
Wim Taymans's avatar
Wim Taymans committed
145 146 147 148

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

  gst_bin_add (GST_BIN (pipeline), src);
149
  gst_bin_add (GST_BIN (pipeline), demux);
150
  gst_bin_add (GST_BIN (pipeline), a_queue);
Wim Taymans's avatar
Wim Taymans committed
151
  gst_bin_add (GST_BIN (pipeline), audiosink);
152
  gst_bin_add (GST_BIN (pipeline), v_queue);
153
  gst_bin_add (GST_BIN (pipeline), decoder);
Wim Taymans's avatar
Wim Taymans committed
154 155
  gst_bin_add (GST_BIN (pipeline), videosink);

156
  gst_element_link (src, demux);
157
  gst_element_link (a_queue, audiosink);
158 159
  gst_element_link (v_queue, decoder);
  gst_element_link (decoder, videosink);
Wim Taymans's avatar
Wim Taymans committed
160

161 162 163 164
  setup_dynamic_link (demux, "video", gst_element_get_pad (v_queue, "sink"),
      NULL);
  setup_dynamic_link (demux, "audio", gst_element_get_pad (a_queue, "sink"),
      NULL);
165

166 167
  seekable = gst_element_get_pad (decoder, "src");
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Wim Taymans's avatar
Wim Taymans committed
168 169 170 171 172
  rate_pads = g_list_prepend (rate_pads, seekable);

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
173 174
static GstElement *
make_wav_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
175 176 177
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
178

Wim Taymans's avatar
Wim Taymans committed
179 180
  pipeline = gst_pipeline_new ("app");

181 182
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("wavparse", "decoder");
183
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
Wim Taymans's avatar
Wim Taymans committed
184 185 186 187 188 189 190

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

191
  gst_element_link (src, decoder);
Wim Taymans's avatar
Wim Taymans committed
192

193 194 195 196 197 198 199
  setup_dynamic_link (decoder, "src", gst_element_get_pad (audiosink, "sink"),
      NULL);

  seekable_elements = g_list_prepend (seekable_elements, audiosink);

  /* force element seeking on this pipeline */
  elem_seek = TRUE;
Wim Taymans's avatar
Wim Taymans committed
200 201 202 203

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
204 205
static GstElement *
make_flac_pipeline (const gchar * location)
206 207 208 209
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
210

211 212
  pipeline = gst_pipeline_new ("app");

213 214
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("flacdec", "decoder");
215
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
Wim Taymans's avatar
Wim Taymans committed
216
  g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
217 218 219 220 221 222 223

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

224 225
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
226 227 228 229 230 231 232 233 234

  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
235 236
static GstElement *
make_sid_pipeline (const gchar * location)
237 238 239 240
{
  GstElement *pipeline;
  GstElement *src, *decoder, *audiosink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
241

242 243
  pipeline = gst_pipeline_new ("app");

244 245
  src = gst_element_factory_make_or_warn (SOURCE, "src");
  decoder = gst_element_factory_make_or_warn ("siddec", "decoder");
246
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
247 248 249 250 251 252 253 254
  //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);

255 256
  gst_element_link (src, decoder);
  gst_element_link (decoder, audiosink);
257 258 259 260 261 262 263 264 265

  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
266 267
static GstElement *
make_parse_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
268 269 270 271
{
  GstElement *pipeline;
  GstElement *src, *parser, *fakesink;
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
272

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
273 274
  pipeline = gst_pipeline_new ("app");

275 276 277
  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
278 279
  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
280 281 282 283 284 285 286

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

287 288
  gst_element_link (src, parser);
  gst_element_link (parser, fakesink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
289 290

  seekable = gst_element_get_pad (parser, "src");
291
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
292 293 294 295 296 297
  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
298 299
static GstElement *
make_vorbis_pipeline (const gchar * location)
300
{
301 302
  GstElement *pipeline, *audio_bin;
  GstElement *src, *demux, *decoder, *convert, *audiosink;
303
  GstPad *pad, *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
304

305 306
  pipeline = gst_pipeline_new ("app");

307
  src = gst_element_factory_make_or_warn (SOURCE, "src");
308 309 310
  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");
311
  audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
Wim Taymans's avatar
Wim Taymans committed
312
  g_object_set (G_OBJECT (audiosink), "sync", TRUE, NULL);
313 314 315

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

316 317
  audio_bin = gst_bin_new ("a_decoder_bin");

318
  gst_bin_add (GST_BIN (pipeline), src);
319 320 321 322 323
  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);
324

325 326 327 328
  gst_element_link (src, demux);
  gst_element_link (decoder, convert);
  gst_element_link (convert, audiosink);

329 330 331 332 333 334
  pad = gst_element_get_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_pad (audio_bin, "sink"),
      NULL);
335 336 337 338 339 340 341 342 343 344 345 346 347 348

  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;
349
  GstPad *pad, *seekable;
350 351 352 353 354 355 356

  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");
Wim Taymans's avatar
Wim Taymans committed
357
  videosink = gst_element_factory_make_or_warn (VSINK, "sink");
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373

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

374 375 376 377 378 379
  pad = gst_element_get_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_pad (video_bin, "sink"),
      NULL);
380 381 382 383 384 385 386 387 388

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

389 390 391 392 393 394 395 396
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
397
  GstPad *pad;
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413

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

416
  gst_bin_add (GST_BIN (pipeline), audio_bin);
417 418 419 420 421 422

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

423 424 425
  gst_element_link (a_queue, a_decoder);
  gst_element_link (a_decoder, a_convert);
  gst_element_link (a_convert, audiosink);
426

Wim Taymans's avatar
Wim Taymans committed
427 428
  pad = gst_element_get_pad (a_queue, "sink");
  gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
429
  gst_object_unref (pad);
430 431 432

  setup_dynamic_link (demux, NULL, gst_element_get_pad (audio_bin, "sink"),
      NULL);
433 434 435 436 437 438

  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
439
  videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
440 441

  gst_bin_add (GST_BIN (pipeline), video_bin);
442 443 444 445 446 447

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

448
  gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
449

Wim Taymans's avatar
Wim Taymans committed
450 451
  pad = gst_element_get_pad (v_queue, "sink");
  gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
452
  gst_object_unref (pad);
453 454 455

  setup_dynamic_link (demux, NULL, gst_element_get_pad (video_bin, "sink"),
      NULL);
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472

  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;
473
  GstPad *seekable, *pad;
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489

  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");
490
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
491 492 493 494 495 496

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

497 498 499 500
  gst_element_link (a_queue, a_decoder);
  gst_element_link (a_decoder, a_convert);
  gst_element_link (a_convert, audiosink);

501 502
  gst_bin_add (GST_BIN (pipeline), audio_bin);

503 504 505 506 507 508
  pad = gst_element_get_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_pad (audio_bin, "sink"),
      NULL);
509 510 511 512 513 514

  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
515
  videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
516 517 518 519 520 521

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

522 523
  gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);

524 525
  gst_bin_add (GST_BIN (pipeline), video_bin);

526 527 528 529 530 531
  pad = gst_element_get_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_pad (video_bin, "sink"),
      NULL);
532 533 534 535 536 537 538 539 540 541

  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
542 543
static GstElement *
make_mp3_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
544 545
{
  GstElement *pipeline;
546
  GstElement *src, *decoder, *osssink, *queue;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
547
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
548

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
549 550
  pipeline = gst_pipeline_new ("app");

551 552 553
  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");
554
  osssink = gst_element_factory_make_or_warn (ASINK, "sink");
555

556
  seekable_elements = g_list_prepend (seekable_elements, osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
557 558

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

561 562
  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), decoder);
563 564
  gst_bin_add (GST_BIN (pipeline), queue);
  gst_bin_add (GST_BIN (pipeline), osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
565

566 567
  gst_element_link (src, decoder);
  gst_element_link (decoder, queue);
568
  gst_element_link (queue, osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
569

570 571
  seekable = gst_element_get_pad (queue, "src");
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
572 573 574 575 576 577
  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
578 579
static GstElement *
make_avi_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
580 581 582
{
  GstElement *pipeline, *audio_bin, *video_bin;
  GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink;
583
  GstElement *a_queue = NULL, *v_queue = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
584
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
585

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
586 587
  pipeline = gst_pipeline_new ("app");

588
  src = gst_element_factory_make_or_warn (SOURCE, "src");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
589 590
  g_object_set (G_OBJECT (src), "location", location, NULL);

591
  demux = gst_element_factory_make_or_warn ("avidemux", "demux");
592
  seekable_elements = g_list_prepend (seekable_elements, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
593 594 595

  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), demux);
596
  gst_element_link (src, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
597 598

  audio_bin = gst_bin_new ("a_decoder_bin");
599
  a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
600
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
601
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
602
  a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
603 604
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
605
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
606 607
  gst_bin_add (GST_BIN (audio_bin), a_queue);
  gst_bin_add (GST_BIN (audio_bin), audiosink);
Wim Taymans's avatar
Wim Taymans committed
608
  gst_element_set_state (audio_bin, GST_STATE_PAUSED);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
609

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
610
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
611
          "sink"), audio_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
612 613

  seekable = gst_element_get_pad (a_queue, "src");
614
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
615
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
616 617
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
618 619

  video_bin = gst_bin_new ("v_decoder_bin");
620
  //v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
621
  //v_decoder = gst_element_factory_make_or_warn ("windec", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
622
  v_decoder = gst_element_factory_make_or_warn ("ffmpegdecall", "v_dec");
623
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
624
  //videosink = gst_element_factory_make_or_warn ("fakesink", "v_sink");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
625
  //g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
626
  v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
Wim Taymans's avatar
Wim Taymans committed
627
  //g_object_set (G_OBJECT (v_queue), "max_level", 10, NULL);
628 629
  gst_element_link (v_decoder, v_queue);
  gst_element_link (v_queue, videosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
630
  gst_bin_add (GST_BIN (video_bin), v_decoder);
631 632
  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
633

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

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
636
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
637
          "sink"), video_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
638 639

  seekable = gst_element_get_pad (v_queue, "src");
640
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
641
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
642 643
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
644 645 646 647

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
648 649
static GstElement *
make_mpeg_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
650 651
{
  GstElement *pipeline, *audio_bin, *video_bin;
652 653
  GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
  GstElement *audiosink, *videosink;
654
  GstElement *a_queue, *v_queue;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
655
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
656

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
657 658
  pipeline = gst_pipeline_new ("app");

659
  src = gst_element_factory_make_or_warn (SOURCE, "src");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
660 661
  g_object_set (G_OBJECT (src), "location", location, NULL);

662
  demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
Wim Taymans's avatar
Wim Taymans committed
663
  g_object_set (G_OBJECT (demux), "sync", FALSE, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
664

665 666
  seekable_elements = g_list_prepend (seekable_elements, demux);

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
667 668
  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), demux);
669
  gst_element_link (src, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
670 671

  audio_bin = gst_bin_new ("a_decoder_bin");
672 673
  a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
  a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
674
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
675
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
676 677
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
678
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
679 680
  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
681

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
682
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
683
          "sink"), audio_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
684 685

  seekable = gst_element_get_pad (a_queue, "src");
686
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
687
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
688 689
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
690 691

  video_bin = gst_bin_new ("v_decoder_bin");
692
  v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
693
  //g_object_set (G_OBJECT (video_thread), "priority", 2, NULL);
694
  v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
695
  v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
696
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
697
  gst_element_link_many (v_decoder, v_queue, v_filter, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
698

699
  gst_element_link (v_filter, videosink);
700 701
  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
702

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
703
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
704
          "sink"), video_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
705 706

  seekable = gst_element_get_pad (v_queue, "src");
707
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
708
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
709 710
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
711 712 713 714

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
715 716
static GstElement *
make_mpegnt_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
717 718 719 720
{
  GstElement *pipeline, *audio_bin, *video_bin;
  GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
  GstElement *audiosink, *videosink;
721
  GstElement *a_queue;
Wim Taymans's avatar
Wim Taymans committed
722
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
723

Wim Taymans's avatar
Wim Taymans committed
724 725 726 727 728 729 730 731 732 733 734 735
  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);
736
  gst_element_link (src, demux);
Wim Taymans's avatar
Wim Taymans committed
737 738 739 740

  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");
741
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
Wim Taymans's avatar
Wim Taymans committed
742 743
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
  g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
744 745
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Wim Taymans's avatar
Wim Taymans committed
746
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
747 748
  gst_bin_add (GST_BIN (audio_bin), a_queue);
  gst_bin_add (GST_BIN (audio_bin), audiosink);
Wim Taymans's avatar
Wim Taymans committed
749

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
750
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
751
          "sink"), audio_bin);
Wim Taymans's avatar
Wim Taymans committed
752 753 754 755

  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
756 757
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Wim Taymans's avatar
Wim Taymans committed
758 759 760

  video_bin = gst_bin_new ("v_decoder_bin");
  v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
761
  v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
762
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
763
  gst_element_link_many (v_decoder, v_filter, videosink, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
764

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

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
767
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
768
          "sink"), video_bin);
Wim Taymans's avatar
Wim Taymans committed
769 770 771 772

  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
773 774
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Wim Taymans's avatar
Wim Taymans committed
775 776 777 778

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
779 780
static GstElement *
make_playerbin_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
781
{
782
  GstElement *player;
783 784 785 786

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

787
  g_object_set (G_OBJECT (player), "uri", location, NULL);
788 789 790 791 792 793 794

  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
795 796
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
797 798
static gchar *
format_value (GtkScale * scale, gdouble value)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
799
{
800 801 802 803 804 805 806
  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
807

808 809
  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
810 811 812 813 814 815
}

typedef struct
{
  const gchar *name;
  const GstFormat format;
816 817
}
seek_format;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
818

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
819 820 821 822 823 824
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
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842
};

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
843 844
      if (gst_pad_query_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format,
              &value)) {
845
        g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
846
      } else {
847
        g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
848 849 850 851 852 853 854 855 856 857 858
      }

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

    walk = g_list_next (walk);
  }
}

G_GNUC_UNUSED static void
859 860 861 862 863 864 865 866 867 868
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
869
      gint64 position, total;
870 871 872
      GstFormat format;

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

      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);
877
      } else {
Wim Taymans's avatar
Wim Taymans committed
878 879
        g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
            "*NA*");
880 881