153
GST_START_TEST (test_eos)
156
GstElement *pipeline, *sink1, *sink2;
159
GThread *thread1, *thread2;
161
pipeline = gst_pipeline_new ("test_eos");
162
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
164
sink1 = gst_element_factory_make ("fakesink", "sink1");
165
sink2 = gst_element_factory_make ("fakesink", "sink2");
167
gst_bin_add_many (GST_BIN (pipeline), sink1, sink2, NULL);
169
pad1 = gst_check_setup_src_pad_by_name (sink1, &srctemplate, "sink");
170
pad2 = gst_check_setup_src_pad_by_name (sink2, &srctemplate, "sink");
172
gst_pad_set_active (pad1, TRUE);
173
gst_pad_set_active (pad2, TRUE);
175
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
176
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
178
/* Send one EOS to sink1 */
179
thread1 = g_thread_new ("thread1", (GThreadFunc) push_one_eos, pad1);
181
/* Make sure the EOS message is not sent */
183
gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, 2 * GST_SECOND);
184
fail_if (message != NULL);
186
/* Send one EOS to sink2 */
187
thread2 = g_thread_new ("thread2", (GThreadFunc) push_one_eos, pad2);
189
/* Make sure the EOS message is sent then */
190
message = gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, -1);
191
fail_if (message == NULL);
192
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EOS);
193
gst_message_unref (message);
196
g_thread_join (thread1);
197
g_thread_join (thread2);
199
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
200
gst_pad_set_active (pad1, FALSE);
201
gst_pad_set_active (pad2, FALSE);
202
gst_check_teardown_src_pad (sink1);
203
gst_check_teardown_src_pad (sink2);
204
gst_object_unref (pipeline);
209
GST_START_TEST (test_stream_start)
212
GstElement *pipeline, *sink1, *sink2;
215
GThread *thread1, *thread2;
217
pipeline = gst_pipeline_new ("test_stream_start");
218
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
220
sink1 = gst_element_factory_make ("fakesink", "sink1");
221
sink2 = gst_element_factory_make ("fakesink", "sink2");
223
gst_bin_add_many (GST_BIN (pipeline), sink1, sink2, NULL);
225
pad1 = gst_check_setup_src_pad_by_name (sink1, &srctemplate, "sink");
226
pad2 = gst_check_setup_src_pad_by_name (sink2, &srctemplate, "sink");
228
gst_pad_set_active (pad1, TRUE);
229
gst_pad_set_active (pad2, TRUE);
231
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
232
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
234
/* Send one STREAM_START to sink1 */
235
thread1 = g_thread_new ("thread1", (GThreadFunc) push_one_stream_start, pad1);
237
/* Make sure the STREAM_START message is not sent */
239
gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_STREAM_START,
241
fail_if (message != NULL);
243
/* Send one STREAM_START to sink2 */
244
thread2 = g_thread_new ("thread2", (GThreadFunc) push_one_stream_start, pad2);
246
/* Make sure the STREAM_START message is sent then */
248
gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_STREAM_START, -1);
249
fail_if (message == NULL);
250
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
251
gst_message_unref (message);
254
g_thread_join (thread1);
255
g_thread_join (thread2);
257
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
258
gst_pad_set_active (pad1, FALSE);
259
gst_pad_set_active (pad2, FALSE);
260
gst_check_teardown_src_pad (sink1);
261
gst_check_teardown_src_pad (sink2);
262
gst_object_unref (pipeline);
129
267
GST_START_TEST (test_message_state_changed)
1265
1408
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "downward state change failed");
1267
1410
gst_object_unref (pipeline);
1411
gst_object_unref (bus);
1416
GST_START_TEST (test_duration_is_max)
1418
GstElement *bin, *src[3], *sink[3];
1419
GstStateChangeReturn state_res;
1420
GstFormat format = GST_FORMAT_BYTES;
1424
GST_INFO ("preparing test");
1426
/* build pipeline */
1427
bin = gst_pipeline_new ("pipeline");
1429
/* 3 sources, an adder and a fakesink */
1430
src[0] = gst_element_factory_make ("fakesrc", NULL);
1431
src[1] = gst_element_factory_make ("fakesrc", NULL);
1432
src[2] = gst_element_factory_make ("fakesrc", NULL);
1433
sink[0] = gst_element_factory_make ("fakesink", NULL);
1434
sink[1] = gst_element_factory_make ("fakesink", NULL);
1435
sink[2] = gst_element_factory_make ("fakesink", NULL);
1436
gst_bin_add_many (GST_BIN (bin), src[0], src[1], src[2], sink[0], sink[1],
1439
gst_element_link (src[0], sink[0]);
1440
gst_element_link (src[1], sink[1]);
1441
gst_element_link (src[2], sink[2]);
1443
/* irks, duration is reset on basesrc */
1444
state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
1445
fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL);
1447
/* set durations on src */
1448
GST_BASE_SRC (src[0])->segment.duration = 1000;
1449
GST_BASE_SRC (src[1])->segment.duration = 3000;
1450
GST_BASE_SRC (src[2])->segment.duration = 2000;
1452
/* set to playing */
1453
state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
1454
fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL);
1456
/* wait for completion */
1458
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
1459
GST_CLOCK_TIME_NONE);
1460
fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL);
1462
res = gst_element_query_duration (GST_ELEMENT (bin), format, &duration);
1463
fail_unless (res, NULL);
1465
ck_assert_int_eq (duration, 3000);
1467
gst_element_set_state (bin, GST_STATE_NULL);
1468
gst_object_unref (bin);
1473
GST_START_TEST (test_duration_unknown_overrides)
1475
GstElement *bin, *src[3], *sink[3];
1476
GstStateChangeReturn state_res;
1477
GstFormat format = GST_FORMAT_BYTES;
1481
GST_INFO ("preparing test");
1483
/* build pipeline */
1484
bin = gst_pipeline_new ("pipeline");
1486
/* 3 sources, an adder and a fakesink */
1487
src[0] = gst_element_factory_make ("fakesrc", NULL);
1488
src[1] = gst_element_factory_make ("fakesrc", NULL);
1489
src[2] = gst_element_factory_make ("fakesrc", NULL);
1490
sink[0] = gst_element_factory_make ("fakesink", NULL);
1491
sink[1] = gst_element_factory_make ("fakesink", NULL);
1492
sink[2] = gst_element_factory_make ("fakesink", NULL);
1493
gst_bin_add_many (GST_BIN (bin), src[0], src[1], src[2], sink[0], sink[1],
1496
gst_element_link (src[0], sink[0]);
1497
gst_element_link (src[1], sink[1]);
1498
gst_element_link (src[2], sink[2]);
1500
/* irks, duration is reset on basesrc */
1501
state_res = gst_element_set_state (bin, GST_STATE_PAUSED);
1502
fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL);
1504
/* set durations on src */
1505
GST_BASE_SRC (src[0])->segment.duration = GST_CLOCK_TIME_NONE;
1506
GST_BASE_SRC (src[1])->segment.duration = 3000;
1507
GST_BASE_SRC (src[2])->segment.duration = 2000;
1509
/* set to playing */
1510
state_res = gst_element_set_state (bin, GST_STATE_PLAYING);
1511
fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL);
1513
/* wait for completion */
1515
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
1516
GST_CLOCK_TIME_NONE);
1517
fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL);
1519
res = gst_element_query_duration (GST_ELEMENT (bin), format, &duration);
1520
fail_unless (res, NULL);
1522
ck_assert_int_eq (duration, GST_CLOCK_TIME_NONE);
1524
gst_element_set_state (bin, GST_STATE_NULL);
1525
gst_object_unref (bin);
1273
1533
gst_bin_suite (void)