~ubuntu-branches/ubuntu/trusty/gstreamer1.0/trusty

« back to all changes in this revision

Viewing changes to tests/check/elements/fakesrc.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2012-08-08 18:12:33 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120808181233-riejwxprfsxh1njl
Tags: 0.11.93-1
* New upstream release:
  + debian/libgstreamer.symbols:
    - Update symbols file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
234
234
 
235
235
GST_END_TEST;
236
236
 
 
237
static void
 
238
handoff_cb (GstElement * element, GstBuffer * buf, GstPad * pad,
 
239
    gint * p_counter)
 
240
{
 
241
  *p_counter += 1;
 
242
  GST_LOG ("counter = %d", *p_counter);
 
243
}
 
244
 
 
245
GST_START_TEST (test_reuse_push)
 
246
{
 
247
  GstElement *src, *sep, *sink, *pipeline;
 
248
  GstBus *bus;
 
249
  gint counter, repeat = 3, num_buffers = 10;
 
250
 
 
251
  pipeline = gst_pipeline_new ("pipeline");
 
252
  fail_unless (pipeline != NULL, "Failed to create pipeline!");
 
253
 
 
254
  bus = gst_element_get_bus (pipeline);
 
255
 
 
256
  src = gst_element_factory_make ("fakesrc", "fakesrc");
 
257
  fail_unless (src != NULL, "Failed to create 'fakesrc' element!");
 
258
 
 
259
  sep = gst_element_factory_make ("queue", "queue");
 
260
  fail_unless (sep != NULL, "Failed to create 'queue' element");
 
261
 
 
262
  sink = gst_element_factory_make ("fakesink", "fakesink");
 
263
  fail_unless (sink != NULL, "Failed to create 'fakesink' element!");
 
264
 
 
265
  g_object_set (sink, "signal-handoffs", TRUE, NULL);
 
266
  g_signal_connect (sink, "handoff", G_CALLBACK (handoff_cb), &counter);
 
267
 
 
268
  gst_bin_add_many (GST_BIN (pipeline), src, sep, sink, NULL);
 
269
 
 
270
  fail_unless (gst_element_link (src, sep));
 
271
  fail_unless (gst_element_link (sep, sink));
 
272
 
 
273
  g_object_set (src, "num-buffers", num_buffers, NULL);
 
274
 
 
275
  do {
 
276
    GstStateChangeReturn state_ret;
 
277
    GstMessage *msg;
 
278
 
 
279
    GST_INFO ("====================== round %d ======================", repeat);
 
280
 
 
281
    counter = 0;
 
282
 
 
283
    state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
 
284
    fail_unless (state_ret != GST_STATE_CHANGE_FAILURE);
 
285
 
 
286
    if (state_ret == GST_STATE_CHANGE_ASYNC) {
 
287
      GST_LOG ("waiting for pipeline to reach PAUSED state");
 
288
      state_ret = gst_element_get_state (pipeline, NULL, NULL, -1);
 
289
      fail_unless_equals_int (state_ret, GST_STATE_CHANGE_SUCCESS);
 
290
    }
 
291
 
 
292
    GST_LOG ("PAUSED, let's read all of it");
 
293
 
 
294
    state_ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
 
295
    fail_unless (state_ret != GST_STATE_CHANGE_FAILURE);
 
296
 
 
297
    msg = gst_bus_poll (bus, GST_MESSAGE_EOS, -1);
 
298
    fail_unless (msg != NULL, "Expected EOS message on bus!");
 
299
 
 
300
    gst_message_unref (msg);
 
301
 
 
302
    if (num_buffers >= 0) {
 
303
      fail_unless_equals_int (counter, num_buffers);
 
304
    }
 
305
 
 
306
    fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_NULL),
 
307
        GST_STATE_CHANGE_SUCCESS);
 
308
 
 
309
    --repeat;
 
310
  } while (repeat > 0);
 
311
 
 
312
  gst_object_unref (bus);
 
313
  gst_object_unref (pipeline);
 
314
}
 
315
 
 
316
GST_END_TEST;
 
317
 
237
318
static Suite *
238
319
fakesrc_suite (void)
239
320
{
246
327
  tcase_add_test (tc_chain, test_sizetype_fixed);
247
328
  tcase_add_test (tc_chain, test_sizetype_random);
248
329
  tcase_add_test (tc_chain, test_no_preroll);
 
330
  tcase_add_test (tc_chain, test_reuse_push);
249
331
 
250
332
  return s;
251
333
}