seek.c 37.6 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

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

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

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

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

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

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

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

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

  return element;
}

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

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

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

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

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

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

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

103 104
  pipeline = gst_pipeline_new ("app");

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

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

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

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

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

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

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

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

160 161 162 163
  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);
164

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

  return pipeline;
}

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

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

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

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

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

192 193 194 195 196 197 198
  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
199 200 201 202

  return pipeline;
}

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

210 211
  pipeline = gst_pipeline_new ("app");

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

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

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

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

241 242
  pipeline = gst_pipeline_new ("app");

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

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

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

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

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

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

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

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

304 305
  pipeline = gst_pipeline_new ("app");

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

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

315 316
  audio_bin = gst_bin_new ("a_decoder_bin");

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

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

328 329 330 331 332 333
  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);
334 335 336 337 338 339 340 341 342 343 344 345 346 347

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

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

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

373 374 375 376 377 378
  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);
379 380 381 382 383 384 385 386 387

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

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

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

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

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

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

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

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

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

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

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

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

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

  setup_dynamic_link (demux, NULL, gst_element_get_pad (video_bin, "sink"),
      NULL);
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488

  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");
489
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508

  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
509
  videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
  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
530 531
static GstElement *
make_mp3_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
532 533
{
  GstElement *pipeline;
534
  GstElement *src, *decoder, *osssink, *queue;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
535
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
536

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
537 538
  pipeline = gst_pipeline_new ("app");

539 540 541
  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");
542
  osssink = gst_element_factory_make_or_warn (ASINK, "sink");
543

544
  seekable_elements = g_list_prepend (seekable_elements, osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
545 546

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

549 550
  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), decoder);
551 552
  gst_bin_add (GST_BIN (pipeline), queue);
  gst_bin_add (GST_BIN (pipeline), osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
553

554 555
  gst_element_link (src, decoder);
  gst_element_link (decoder, queue);
556
  gst_element_link (queue, osssink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
557

558 559
  seekable = gst_element_get_pad (queue, "src");
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
560 561 562 563 564 565
  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
566 567
static GstElement *
make_avi_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
568 569 570
{
  GstElement *pipeline, *audio_bin, *video_bin;
  GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink;
571
  GstElement *a_queue = NULL, *v_queue = NULL;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
572
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
573

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
574 575
  pipeline = gst_pipeline_new ("app");

576
  src = gst_element_factory_make_or_warn (SOURCE, "src");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
577 578
  g_object_set (G_OBJECT (src), "location", location, NULL);

579
  demux = gst_element_factory_make_or_warn ("avidemux", "demux");
580
  seekable_elements = g_list_prepend (seekable_elements, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
581 582 583

  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), demux);
584
  gst_element_link (src, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
585 586

  audio_bin = gst_bin_new ("a_decoder_bin");
587
  a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
588
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
589
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
590
  a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
591 592
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
593
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
594 595
  gst_bin_add (GST_BIN (audio_bin), a_queue);
  gst_bin_add (GST_BIN (audio_bin), audiosink);
Wim Taymans's avatar
Wim Taymans committed
596
  gst_element_set_state (audio_bin, GST_STATE_PAUSED);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
597

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
598
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
599
          "sink"), audio_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
600 601

  seekable = gst_element_get_pad (a_queue, "src");
602
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
603
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
604 605
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
606 607

  video_bin = gst_bin_new ("v_decoder_bin");
608
  //v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
609
  //v_decoder = gst_element_factory_make_or_warn ("windec", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
610
  v_decoder = gst_element_factory_make_or_warn ("ffmpegdecall", "v_dec");
611
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
612
  //videosink = gst_element_factory_make_or_warn ("fakesink", "v_sink");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
613
  //g_object_set (G_OBJECT (videosink), "sync", TRUE, NULL);
614
  v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
Wim Taymans's avatar
Wim Taymans committed
615
  //g_object_set (G_OBJECT (v_queue), "max_level", 10, NULL);
616 617
  gst_element_link (v_decoder, v_queue);
  gst_element_link (v_queue, videosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
618
  gst_bin_add (GST_BIN (video_bin), v_decoder);
619 620
  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
621

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

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
624
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
625
          "sink"), video_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
626 627

  seekable = gst_element_get_pad (v_queue, "src");
628
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
629
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
630 631
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
632 633 634 635

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
636 637
static GstElement *
make_mpeg_pipeline (const gchar * location)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
638 639
{
  GstElement *pipeline, *audio_bin, *video_bin;
640 641
  GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
  GstElement *audiosink, *videosink;
642
  GstElement *a_queue, *v_queue;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
643
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
644

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
645 646
  pipeline = gst_pipeline_new ("app");

647
  src = gst_element_factory_make_or_warn (SOURCE, "src");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
648 649
  g_object_set (G_OBJECT (src), "location", location, NULL);

650
  demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
Wim Taymans's avatar
Wim Taymans committed
651
  g_object_set (G_OBJECT (demux), "sync", FALSE, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
652

653 654
  seekable_elements = g_list_prepend (seekable_elements, demux);

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
655 656
  gst_bin_add (GST_BIN (pipeline), src);
  gst_bin_add (GST_BIN (pipeline), demux);
657
  gst_element_link (src, demux);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
658 659

  audio_bin = gst_bin_new ("a_decoder_bin");
660 661
  a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
  a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
662
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
663
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
664 665
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
666
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
667 668
  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
669

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
670
  setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
671
          "sink"), audio_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
672 673

  seekable = gst_element_get_pad (a_queue, "src");
674
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
675
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
676 677
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
678 679

  video_bin = gst_bin_new ("v_decoder_bin");
680
  v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
Wim Taymans's avatar
Wim Taymans committed
681
  //g_object_set (G_OBJECT (video_thread), "priority", 2, NULL);
682
  v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
683
  v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
684
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
685
  gst_element_link_many (v_decoder, v_queue, v_filter, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
686

687
  gst_element_link (v_filter, videosink);
688 689
  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
690

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
691
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
692
          "sink"), video_bin);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
693 694

  seekable = gst_element_get_pad (v_queue, "src");
695
  seekable_pads = g_list_prepend (seekable_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
696
  rate_pads = g_list_prepend (rate_pads, seekable);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
697 698
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
699 700 701 702

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
703 704
static GstElement *
make_mpegnt_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
705 706 707 708
{
  GstElement *pipeline, *audio_bin, *video_bin;
  GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
  GstElement *audiosink, *videosink;
709
  GstElement *a_queue;
Wim Taymans's avatar
Wim Taymans committed
710
  GstPad *seekable;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
711

Wim Taymans's avatar
Wim Taymans committed
712 713 714 715 716 717 718 719 720 721 722 723
  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);
724
  gst_element_link (src, demux);
Wim Taymans's avatar
Wim Taymans committed
725 726 727 728

  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");
729
  audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
Wim Taymans's avatar
Wim Taymans committed
730 731
  //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
  g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
732 733
  gst_element_link (a_decoder, a_queue);
  gst_element_link (a_queue, audiosink);
Wim Taymans's avatar
Wim Taymans committed
734
  gst_bin_add (GST_BIN (audio_bin), a_decoder);
735 736
  gst_bin_add (GST_BIN (audio_bin), a_queue);
  gst_bin_add (GST_BIN (audio_bin), audiosink);
Wim Taymans's avatar
Wim Taymans committed
737

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

  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
744 745
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
Wim Taymans's avatar
Wim Taymans committed
746 747 748

  video_bin = gst_bin_new ("v_decoder_bin");
  v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
749
  v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
750
  videosink = gst_element_factory_make_or_warn ("ximagesink", "v_sink");
751
  gst_element_link_many (v_decoder, v_filter, videosink, NULL);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
752

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

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
755
  setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
756
          "sink"), video_bin);
Wim Taymans's avatar
Wim Taymans committed
757 758 759 760

  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
761 762
  rate_pads =
      g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
Wim Taymans's avatar
Wim Taymans committed
763 764 765 766

  return pipeline;
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
767 768
static GstElement *
make_playerbin_pipeline (const gchar * location)
Wim Taymans's avatar
Wim Taymans committed
769
{
770
  GstElement *player;
771 772 773 774

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

775
  g_object_set (G_OBJECT (player), "uri", location, NULL);
776 777 778 779 780 781 782

  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
783 784
}

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
785 786
static gchar *
format_value (GtkScale * scale, gdouble value)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
787
{
788 789 790 791 792 793 794
  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
795

796 797
  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
798 799 800 801 802 803
}

typedef struct
{
  const gchar *name;
  const GstFormat format;
804 805
}
seek_format;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
806

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
807 808 809 810 811 812
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
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
};

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
831 832
      if (gst_pad_query_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format,
              &value)) {
833
        g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
834
      } else {
835
        g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
836 837 838 839 840 841 842 843 844 845 846
      }

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

    walk = g_list_next (walk);
  }
}

G_GNUC_UNUSED static void
847 848 849 850 851 852 853 854 855 856
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
857
      gint64 position, total;
858 859 860
      GstFormat format;

      format = seek_formats[i].format;
Wim Taymans's avatar
Wim Taymans committed
861 862 863 864

      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);
865
      } else {
Wim Taymans's avatar
Wim Taymans committed
866 867
        g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
            "*NA*");
868 869 870 871 872 873 874 875 876 877 878
      }
      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
879
{
880 881 882 883 884 885 886 887 888
  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
889
      gint64 position, total;
890 891

      format = seek_formats[i].format;
Wim Taymans's avatar
Wim Taymans committed
892 893 894 895

      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
896
      } else {
Wim Taymans's avatar
Wim Taymans committed