2 * Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
4 * gstevent.c: Unit test for event handling
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #include <gst/check/gstcheck.h>
25 GST_START_TEST (create_events)
27 GstEvent *event, *event2;
28 GstStructure *structure;
32 event = gst_event_new_flush_start ();
33 fail_if (event == NULL);
34 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START);
35 fail_unless (GST_EVENT_IS_UPSTREAM (event));
36 fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
37 fail_if (GST_EVENT_IS_SERIALIZED (event));
38 gst_event_unref (event);
44 event = gst_event_new_flush_stop (TRUE);
45 fail_if (event == NULL);
46 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP);
47 fail_unless (GST_EVENT_IS_UPSTREAM (event));
48 fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
49 fail_unless (GST_EVENT_IS_SERIALIZED (event));
51 gst_event_parse_flush_stop (event, &reset_time);
52 fail_unless (reset_time == TRUE);
53 gst_event_unref (event);
57 event = gst_event_new_eos ();
58 fail_if (event == NULL);
59 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_EOS);
60 fail_if (GST_EVENT_IS_UPSTREAM (event));
61 fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
62 fail_unless (GST_EVENT_IS_SERIALIZED (event));
63 gst_event_unref (event);
67 GstClockTime ts = 0, dur = 0;
69 ASSERT_CRITICAL (gst_event_new_gap (GST_CLOCK_TIME_NONE, GST_SECOND));
71 event = gst_event_new_gap (90 * GST_SECOND, GST_SECOND);
72 fail_if (event == NULL);
73 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_GAP);
74 fail_if (GST_EVENT_IS_UPSTREAM (event));
75 fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
76 fail_unless (GST_EVENT_IS_SERIALIZED (event));
77 gst_event_parse_gap (event, &ts, NULL);
78 fail_unless_equals_int64 (ts, 90 * GST_SECOND);
79 gst_event_parse_gap (event, &ts, &dur);
80 fail_unless_equals_int64 (dur, GST_SECOND);
81 gst_event_unref (event);
85 GstSegment segment, parsed;
87 gst_segment_init (&segment, GST_FORMAT_TIME);
89 segment.applied_rate = 1.0;
91 segment.stop = G_MAXINT64;
92 segment.time = 0xdeadbeef;
94 event = gst_event_new_segment (&segment);
95 fail_if (event == NULL);
96 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
97 fail_if (GST_EVENT_IS_UPSTREAM (event));
98 fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
99 fail_unless (GST_EVENT_IS_SERIALIZED (event));
101 gst_event_copy_segment (event, &parsed);
102 fail_unless (parsed.rate == 0.5);
103 fail_unless (parsed.applied_rate == 1.0);
104 fail_unless (parsed.format == GST_FORMAT_TIME);
105 fail_unless (parsed.start == 1);
106 fail_unless (parsed.stop == G_MAXINT64);
107 fail_unless (parsed.time == 0xdeadbeef);
109 gst_event_unref (event);
114 GstStreamConfigFlags flags = 0x987654;
115 GstBuffer *buf, *cd, *sh1, *sh2;
118 event = gst_event_new_stream_config (GST_STREAM_CONFIG_FLAG_NONE);
120 gst_event_parse_stream_config (event, &flags);
121 fail_unless_equals_int (flags, GST_STREAM_CONFIG_FLAG_NONE);
123 fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 0);
125 /* set buf to something random but guaranteed to be non-NULL */
126 buf = (GstBuffer *) & dummy;
127 gst_event_parse_stream_config_setup_data (event, &buf);
128 fail_unless (buf == NULL);
130 buf = (GstBuffer *) & dummy;
131 gst_event_parse_nth_stream_config_header (event, 0, &buf);
132 fail_unless (buf == NULL);
134 buf = (GstBuffer *) & dummy;
135 gst_event_parse_nth_stream_config_header (event, 98416, &buf);
136 fail_unless (buf == NULL);
138 ASSERT_CRITICAL (gst_event_set_stream_config_setup_data (event, NULL));
139 ASSERT_CRITICAL (gst_event_add_stream_config_header (event, NULL));
141 cd = gst_buffer_new_wrapped_full ((gpointer) "SetMeUpScottie", NULL, 0, 14);
142 gst_event_set_stream_config_setup_data (event, cd);
143 gst_buffer_unref (cd);
145 buf = (GstBuffer *) & dummy;
146 gst_event_parse_nth_stream_config_header (event, 0, &buf);
147 fail_unless (buf == NULL);
148 gst_event_parse_stream_config_setup_data (event, &buf);
149 fail_unless (buf == cd);
150 fail_unless (GST_IS_BUFFER (buf));
152 gst_event_unref (event);
154 event = gst_event_new_stream_config (GST_STREAM_CONFIG_FLAG_NONE);
155 fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 0);
156 sh1 = gst_buffer_new_wrapped_full ((gpointer) "Strea", NULL, 0, 5);
157 gst_event_add_stream_config_header (event, sh1);
158 gst_buffer_unref (sh1);
159 fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 1);
160 sh2 = gst_buffer_new_wrapped_full ((gpointer) "mHeader", NULL, 0, 7);
161 gst_event_add_stream_config_header (event, sh2);
162 gst_buffer_unref (sh2);
163 fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 2);
165 buf = (GstBuffer *) & dummy;
166 gst_event_parse_nth_stream_config_header (event, 1, &buf);
167 fail_unless (buf == sh2);
168 fail_unless (GST_IS_BUFFER (buf));
170 buf = (GstBuffer *) & dummy;
171 gst_event_parse_nth_stream_config_header (event, 0, &buf);
172 fail_unless (buf == sh1);
173 fail_unless (GST_IS_BUFFER (buf));
175 gst_event_unref (event);
180 GstTagList *taglist = gst_tag_list_new_empty ();
181 GstTagList *tl2 = NULL;
183 event = gst_event_new_tag (taglist);
184 fail_if (taglist == NULL);
185 fail_if (event == NULL);
186 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_TAG);
187 fail_if (GST_EVENT_IS_UPSTREAM (event));
188 fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
189 fail_unless (GST_EVENT_IS_SERIALIZED (event));
191 gst_event_parse_tag (event, &tl2);
192 fail_unless (taglist == tl2);
193 gst_event_unref (event);
198 GstQOSType t1 = GST_QOS_TYPE_THROTTLE, t2;
199 gdouble p1 = 1.0, p2;
200 GstClockTimeDiff ctd1 = G_GINT64_CONSTANT (10), ctd2;
201 GstClockTime ct1 = G_GUINT64_CONSTANT (20), ct2;
203 event = gst_event_new_qos (t1, p1, ctd1, ct1);
204 fail_if (event == NULL);
205 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_QOS);
206 fail_unless (GST_EVENT_IS_UPSTREAM (event));
207 fail_if (GST_EVENT_IS_DOWNSTREAM (event));
208 fail_if (GST_EVENT_IS_SERIALIZED (event));
210 gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
211 fail_unless (p1 == p2);
212 fail_unless (ctd1 == ctd2);
213 fail_unless (ct1 == ct2);
214 gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
215 fail_unless (t2 == GST_QOS_TYPE_THROTTLE);
216 fail_unless (p1 == p2);
217 fail_unless (ctd1 == ctd2);
218 fail_unless (ct1 == ct2);
219 gst_event_unref (event);
221 ctd1 = G_GINT64_CONSTANT (-10);
222 event = gst_event_new_qos (t1, p1, ctd1, ct1);
223 gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
224 fail_unless (t2 == GST_QOS_TYPE_THROTTLE);
225 gst_event_unref (event);
227 event = gst_event_new_qos (t1, p1, ctd1, ct1);
228 gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
229 fail_unless (t2 == GST_QOS_TYPE_THROTTLE);
230 fail_unless (p1 == p2);
231 fail_unless (ctd1 == ctd2);
232 fail_unless (ct1 == ct2);
233 gst_event_unref (event);
241 GstSeekType cur_type, stop_type;
244 event = gst_event_new_seek (0.5, GST_FORMAT_BYTES,
245 GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
246 GST_SEEK_TYPE_SET, 1, GST_SEEK_TYPE_NONE, 0xdeadbeef);
248 fail_if (event == NULL);
249 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEEK);
250 fail_unless (GST_EVENT_IS_UPSTREAM (event));
251 fail_if (GST_EVENT_IS_DOWNSTREAM (event));
252 fail_if (GST_EVENT_IS_SERIALIZED (event));
254 gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur,
256 fail_unless (rate == 0.5);
257 fail_unless (format == GST_FORMAT_BYTES);
258 fail_unless (flags == (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE));
259 fail_unless (cur_type == GST_SEEK_TYPE_SET);
260 fail_unless (cur == 1);
261 fail_unless (stop_type == GST_SEEK_TYPE_NONE);
262 fail_unless (stop == 0xdeadbeef);
264 gst_event_unref (event);
269 structure = gst_structure_new ("application/x-gst-navigation", "event",
270 G_TYPE_STRING, "key-press", "key", G_TYPE_STRING, "mon", NULL);
271 fail_if (structure == NULL);
272 event = gst_event_new_navigation (structure);
273 fail_if (event == NULL);
274 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION);
275 fail_unless (GST_EVENT_IS_UPSTREAM (event));
276 fail_if (GST_EVENT_IS_DOWNSTREAM (event));
277 fail_if (GST_EVENT_IS_SERIALIZED (event));
279 fail_unless (gst_event_get_structure (event) == structure);
280 gst_event_unref (event);
283 /* Custom event types */
285 structure = gst_structure_new_empty ("application/x-custom");
286 fail_if (structure == NULL);
287 event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, structure);
288 fail_if (event == NULL);
289 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UPSTREAM);
290 fail_unless (GST_EVENT_IS_UPSTREAM (event));
291 fail_if (GST_EVENT_IS_DOWNSTREAM (event));
292 fail_if (GST_EVENT_IS_SERIALIZED (event));
293 fail_unless (gst_event_get_structure (event) == structure);
294 fail_unless (gst_event_has_name (event, "application/x-custom"));
295 gst_event_unref (event);
297 /* Decided not to test the other custom enum types, as they
298 * only differ by the value of the enum passed to gst_event_new_custom
304 structure = gst_structure_new_empty ("application/x-custom");
305 fail_if (structure == NULL);
306 event = gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, structure);
308 fail_if (event == NULL);
309 event2 = gst_event_copy (event);
310 fail_if (event2 == NULL);
311 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_TYPE (event2));
312 fail_unless (gst_event_has_name (event, "application/x-custom"));
314 /* The structure should have been duplicated */
315 fail_if (gst_event_get_structure (event) ==
316 gst_event_get_structure (event2));
318 gst_event_unref (event);
319 gst_event_unref (event2);
322 /* Make events writable */
324 structure = gst_structure_new_empty ("application/x-custom");
325 fail_if (structure == NULL);
326 event = gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, structure);
327 /* ref the event so that it becomes non-writable */
328 gst_event_ref (event);
329 gst_event_ref (event);
330 /* this should fail if the structure isn't writable */
331 ASSERT_CRITICAL (gst_structure_remove_all_fields ((GstStructure *)
332 gst_event_get_structure (event)));
333 fail_unless (gst_event_has_name (event, "application/x-custom"));
335 /* now make writable */
337 GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
338 fail_unless (event != event2);
339 /* this fail if the structure isn't writable */
340 gst_structure_remove_all_fields ((GstStructure *)
341 gst_event_get_structure (event2));
342 fail_unless (gst_event_has_name (event2, "application/x-custom"));
344 gst_event_unref (event);
345 gst_event_unref (event);
346 gst_event_unref (event2);
352 static GTimeVal sent_event_time;
353 static GstEvent *got_event_before_q, *got_event_after_q;
354 static GTimeVal got_event_time;
356 static GstPadProbeReturn
357 event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
359 GstMiniObject *data = GST_PAD_PROBE_INFO_DATA (info);
360 gboolean before_q = (gboolean) GPOINTER_TO_INT (user_data);
362 GST_DEBUG ("event probe called %p", data);
364 fail_unless (GST_IS_EVENT (data));
367 switch (GST_EVENT_TYPE (GST_EVENT (data))) {
368 case GST_EVENT_CUSTOM_UPSTREAM:
369 case GST_EVENT_CUSTOM_BOTH:
370 case GST_EVENT_CUSTOM_BOTH_OOB:
371 if (got_event_before_q != NULL)
373 gst_event_ref ((GstEvent *) data);
374 g_get_current_time (&got_event_time);
375 got_event_before_q = GST_EVENT (data);
381 switch (GST_EVENT_TYPE (GST_EVENT (data))) {
382 case GST_EVENT_CUSTOM_DOWNSTREAM:
383 case GST_EVENT_CUSTOM_DOWNSTREAM_OOB:
384 case GST_EVENT_CUSTOM_BOTH:
385 case GST_EVENT_CUSTOM_BOTH_OOB:
386 if (got_event_after_q != NULL)
388 gst_event_ref ((GstEvent *) data);
389 g_get_current_time (&got_event_time);
390 got_event_after_q = GST_EVENT (data);
397 return GST_PAD_PROBE_OK;
409 signal_data_init (SignalData * data)
411 GST_DEBUG ("init %p", data);
412 data->lock = g_mutex_new ();
413 data->cond = g_cond_new ();
414 data->signaled = FALSE;
418 signal_data_cleanup (SignalData * data)
420 GST_DEBUG ("free %p", data);
421 g_mutex_free (data->lock);
422 g_cond_free (data->cond);
426 signal_data_signal (SignalData * data)
428 g_mutex_lock (data->lock);
429 data->signaled = TRUE;
430 g_cond_broadcast (data->cond);
431 GST_DEBUG ("signaling %p", data);
432 g_mutex_unlock (data->lock);
436 signal_data_wait (SignalData * data)
438 g_mutex_lock (data->lock);
439 GST_DEBUG ("signal wait %p", data);
440 while (!data->signaled)
441 g_cond_wait (data->cond, data->lock);
442 GST_DEBUG ("signal wait done %p", data);
443 g_mutex_unlock (data->lock);
446 static GstPadProbeReturn
447 signal_blocked (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
449 SignalData *data = (SignalData *) user_data;
451 GST_DEBUG ("signal called %p", data);
452 signal_data_signal (data);
453 GST_DEBUG ("signal done %p", data);
455 return GST_PAD_PROBE_OK;
458 static void test_event
459 (GstBin * pipeline, GstEventType type, GstPad * pad,
460 gboolean expect_before_q, GstPad * fake_srcpad)
468 got_event_before_q = got_event_after_q = NULL;
470 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
471 gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
472 GST_CLOCK_TIME_NONE);
474 GST_DEBUG ("test event called");
476 event = gst_event_new_custom (type,
477 gst_structure_new_empty ("application/x-custom"));
478 g_get_current_time (&sent_event_time);
479 got_event_time.tv_sec = 0;
480 got_event_time.tv_usec = 0;
482 signal_data_init (&data);
484 /* We block the pad so the stream lock is released and we can send the event */
485 id = gst_pad_add_probe (fake_srcpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
486 signal_blocked, &data, NULL);
487 fail_unless (id != 0);
489 signal_data_wait (&data);
491 /* We send on the peer pad, since the pad is blocked */
492 GST_DEBUG ("sending event %p", event);
493 fail_unless ((peer = gst_pad_get_peer (pad)) != NULL);
494 gst_pad_send_event (peer, event);
495 gst_object_unref (peer);
497 gst_pad_remove_probe (fake_srcpad, id);
499 if (expect_before_q) {
500 /* Wait up to 5 seconds for the event to appear */
501 for (i = 0; i < 500; i++) {
502 g_usleep (G_USEC_PER_SEC / 100);
503 if (got_event_before_q != NULL)
506 fail_if (got_event_before_q == NULL,
507 "Expected event failed to appear upstream of the queue "
509 fail_unless (GST_EVENT_TYPE (got_event_before_q) == type);
511 /* Wait up to 10 seconds for the event to appear */
512 for (i = 0; i < 1000; i++) {
513 g_usleep (G_USEC_PER_SEC / 100);
514 if (got_event_after_q != NULL)
517 fail_if (got_event_after_q == NULL,
518 "Expected event failed to appear after the queue within 10 seconds");
519 fail_unless (GST_EVENT_TYPE (got_event_after_q) == type);
522 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
523 gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
524 GST_CLOCK_TIME_NONE);
526 if (got_event_before_q)
527 gst_event_unref (got_event_before_q);
528 if (got_event_after_q)
529 gst_event_unref (got_event_after_q);
531 got_event_before_q = got_event_after_q = NULL;
533 signal_data_cleanup (&data);
537 timediff (GTimeVal * end, GTimeVal * start)
539 return (end->tv_sec - start->tv_sec) * G_USEC_PER_SEC +
540 (end->tv_usec - start->tv_usec);
543 GST_START_TEST (send_custom_events)
545 /* Run some tests on custom events. Checking for serialisation and whatnot.
546 * pipeline is fakesrc ! queue ! fakesink */
548 GstElement *fakesrc, *fakesink, *queue;
549 GstPad *srcpad, *sinkpad;
551 fail_if ((pipeline = (GstBin *) gst_pipeline_new ("testpipe")) == NULL);
552 fail_if ((fakesrc = gst_element_factory_make ("fakesrc", NULL)) == NULL);
553 fail_if ((fakesink = gst_element_factory_make ("fakesink", NULL)) == NULL);
554 fail_if ((queue = gst_element_factory_make ("queue", NULL)) == NULL);
556 gst_bin_add_many (pipeline, fakesrc, queue, fakesink, NULL);
557 fail_unless (gst_element_link_many (fakesrc, queue, fakesink, NULL));
559 g_object_set (G_OBJECT (fakesink), "sync", FALSE, NULL);
561 /* Send 100 buffers per sec */
562 g_object_set (G_OBJECT (fakesrc), "silent", TRUE, "datarate", 100,
563 "sizemax", 1, "sizetype", 2, NULL);
564 g_object_set (G_OBJECT (queue), "max-size-buffers", 0, "max-size-time",
565 (guint64) GST_SECOND, "max-size-bytes", 0, NULL);
566 g_object_set (G_OBJECT (fakesink), "silent", TRUE, "sync", TRUE, NULL);
568 /* add pad-probes to faksrc.src and fakesink.sink */
569 fail_if ((srcpad = gst_element_get_static_pad (fakesrc, "src")) == NULL);
570 gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_EVENT_BOTH,
571 event_probe, GINT_TO_POINTER (TRUE), NULL);
573 fail_if ((sinkpad = gst_element_get_static_pad (fakesink, "sink")) == NULL);
574 gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_EVENT_BOTH,
575 event_probe, GINT_TO_POINTER (FALSE), NULL);
577 /* Upstream events */
578 test_event (pipeline, GST_EVENT_CUSTOM_UPSTREAM, sinkpad, TRUE, srcpad);
579 fail_unless (timediff (&got_event_time,
580 &sent_event_time) < G_USEC_PER_SEC / 2,
581 "GST_EVENT_CUSTOM_UP took too long to reach source: %"
582 G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
584 test_event (pipeline, GST_EVENT_CUSTOM_BOTH, sinkpad, TRUE, srcpad);
585 fail_unless (timediff (&got_event_time,
586 &sent_event_time) < G_USEC_PER_SEC / 2,
587 "GST_EVENT_CUSTOM_BOTH took too long to reach source: %"
588 G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
590 test_event (pipeline, GST_EVENT_CUSTOM_BOTH_OOB, sinkpad, TRUE, srcpad);
591 fail_unless (timediff (&got_event_time,
592 &sent_event_time) < G_USEC_PER_SEC / 2,
593 "GST_EVENT_CUSTOM_BOTH_OOB took too long to reach source: %"
594 G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
596 /* Out of band downstream events */
597 test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM_OOB, srcpad, FALSE, srcpad);
598 fail_unless (timediff (&got_event_time,
599 &sent_event_time) < G_USEC_PER_SEC / 2,
600 "GST_EVENT_CUSTOM_DS_OOB took too long to reach source: %"
601 G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
603 test_event (pipeline, GST_EVENT_CUSTOM_BOTH_OOB, srcpad, FALSE, srcpad);
604 fail_unless (timediff (&got_event_time,
605 &sent_event_time) < G_USEC_PER_SEC / 2,
606 "GST_EVENT_CUSTOM_BOTH_OOB took too long to reach source: %"
607 G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
609 /* In-band downstream events are expected to take at least 1 second
610 * to traverse the queue */
611 test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM, srcpad, FALSE, srcpad);
612 fail_unless (timediff (&got_event_time,
613 &sent_event_time) >= G_USEC_PER_SEC / 2,
614 "GST_EVENT_CUSTOM_DS arrived too quickly for an in-band event: %"
615 G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
617 test_event (pipeline, GST_EVENT_CUSTOM_BOTH, srcpad, FALSE, srcpad);
618 fail_unless (timediff (&got_event_time,
619 &sent_event_time) >= G_USEC_PER_SEC / 2,
620 "GST_EVENT_CUSTOM_BOTH arrived too quickly for an in-band event: %"
621 G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
623 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
624 gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
625 GST_CLOCK_TIME_NONE);
627 gst_object_unref (sinkpad);
628 gst_object_unref (srcpad);
629 gst_object_unref (pipeline);
635 gst_event_suite (void)
637 Suite *s = suite_create ("GstEvent");
638 TCase *tc_chain = tcase_create ("events");
640 tcase_set_timeout (tc_chain, 20);
642 suite_add_tcase (s, tc_chain);
643 tcase_add_test (tc_chain, create_events);
644 tcase_add_test (tc_chain, send_custom_events);
648 GST_CHECK_MAIN (gst_event);