|
1 /* GStreamer |
|
2 * |
|
3 * unit test for sinks |
|
4 * |
|
5 * Copyright (C) <2005> Wim Taymans <wim at fluendo dot com> |
|
6 * |
|
7 * This library is free software; you can redistribute it and/or |
|
8 * modify it under the terms of the GNU Library General Public |
|
9 * License as published by the Free Software Foundation; either |
|
10 * version 2 of the License, or (at your option) any later version. |
|
11 * |
|
12 * This library is distributed in the hope that it will be useful, |
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 * Library General Public License for more details. |
|
16 * |
|
17 * You should have received a copy of the GNU Library General Public |
|
18 * License along with this library; if not, write to the |
|
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
20 * Boston, MA 02111-1307, USA. |
|
21 */ |
|
22 #include <gst/gst_global.h> |
|
23 #include <gst/check/gstcheck.h> |
|
24 #include <libgstreamer_wsd_solution.h> |
|
25 #if EMULATOR |
|
26 static GET_GLOBAL_VAR_FROM_TLS(raised_critical,gstcheck,gboolean) |
|
27 #define _gst_check_raised_critical (*GET_GSTREAMER_WSD_VAR_NAME(raised_critical,gstcheck,g)()) |
|
28 #else |
|
29 extern gboolean _gst_check_raised_critical ; |
|
30 #endif |
|
31 |
|
32 #if EMULATOR |
|
33 static GET_GLOBAL_VAR_FROM_TLS(raised_warning,gstcheck,gboolean) |
|
34 #define _gst_check_raised_warning (*GET_GSTREAMER_WSD_VAR_NAME(raised_warning,gstcheck,g)()) |
|
35 #else |
|
36 extern gboolean _gst_check_raised_warning ; |
|
37 #endif |
|
38 |
|
39 #if EMULATOR |
|
40 static GET_GLOBAL_VAR_FROM_TLS(expecting_log,gstcheck,gboolean) |
|
41 #define _gst_check_expecting_log (*GET_GSTREAMER_WSD_VAR_NAME(expecting_log,gstcheck,g)()) |
|
42 #else |
|
43 extern gboolean _gst_check_expecting_log ; |
|
44 #endif |
|
45 |
|
46 #if EMULATOR |
|
47 static GET_GLOBAL_VAR_FROM_TLS(threads_running,gstcheck,gboolean) |
|
48 #define _gst_check_threads_running (*GET_GSTREAMER_WSD_VAR_NAME(threads_running,gstcheck,g)()) |
|
49 #else |
|
50 extern gboolean _gst_check_threads_running ; |
|
51 #endif |
|
52 |
|
53 #ifndef EMULATOR |
|
54 int failed=0; |
|
55 FILE* fp_std_log_t=NULL; |
|
56 #define assert_failed *(get_assert_failed()) |
|
57 #define fp_std_log *(get_fp_std_log()) |
|
58 #endif |
|
59 |
|
60 #define LOG_FILE "c:\\logs\\sinks_log.txt" |
|
61 |
|
62 #include "std_log_result.h" |
|
63 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
64 |
|
65 |
|
66 #if EMULATOR |
|
67 GET_GLOBAL_VAR_FROM_TLS(buffers,gstcheck,GList*) |
|
68 #define buffers (*GET_GSTREAMER_WSD_VAR_NAME(buffers,gstcheck,g)()) |
|
69 #else |
|
70 extern GList *buffers; |
|
71 #endif |
|
72 |
|
73 |
|
74 #if EMULATOR |
|
75 GET_GLOBAL_VAR_FROM_TLS(thread_list,gstcheck,GList*) |
|
76 #define thread_list (*GET_GSTREAMER_WSD_VAR_NAME(thread_list,gstcheck,g)()) |
|
77 #else |
|
78 extern GList *thread_list; |
|
79 #endif |
|
80 |
|
81 //GMutex *mutex; |
|
82 #if EMULATOR |
|
83 GET_GLOBAL_VAR_FROM_TLS(mutex,gstcheck,GMutex*) |
|
84 #define mutex (*GET_GSTREAMER_WSD_VAR_NAME(mutex,gstcheck,g)()) |
|
85 #else |
|
86 extern GMutex *mutex; |
|
87 #endif |
|
88 |
|
89 //GCond *start_cond; /* used to notify main thread of thread startups */ |
|
90 #if EMULATOR |
|
91 GET_GLOBAL_VAR_FROM_TLS(start_cond,gstcheck,GCond*) |
|
92 #define start_cond (*GET_GSTREAMER_WSD_VAR_NAME(start_cond,gstcheck,g)()) |
|
93 #else |
|
94 extern GCond *start_cond; |
|
95 #endif |
|
96 |
|
97 //GCond *sync_cond; /* used to synchronize all threads and main thread */ |
|
98 #if EMULATOR |
|
99 GET_GLOBAL_VAR_FROM_TLS(sync_cond,gstcheck,GCond*) |
|
100 #define sync_cond (*GET_GSTREAMER_WSD_VAR_NAME(sync_cond,gstcheck,g)()) |
|
101 #else |
|
102 extern GCond *sync_cond; |
|
103 #endif |
|
104 |
|
105 |
|
106 void create_xml(int result) |
|
107 { |
|
108 if(result) |
|
109 assert_failed = 1; |
|
110 |
|
111 testResultXml(xmlfile); |
|
112 close_log_file(); |
|
113 } |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 #if 0 |
|
119 static void |
|
120 pop_state_change_message (GstBus * bus, GstElement * src, GstState old, |
|
121 GstState new, GstState pending) |
|
122 { |
|
123 GstMessage *message = NULL; |
|
124 GstState _old, _new, _pending; |
|
125 //xmlfile = "test_init"; |
|
126 std_log(LOG_FILENAME_LINE, "Test Started test_init"); |
|
127 |
|
128 message = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND); |
|
129 fail_unless (message != NULL, |
|
130 "Expected state change message, but got nothing"); |
|
131 |
|
132 gst_message_parse_state_changed (message, &_old, &_new, &_pending); |
|
133 |
|
134 fail_unless (GST_MESSAGE_SRC (message) == (GstObject *) src, |
|
135 "Unexpected state change order"); |
|
136 fail_unless (old == _old, "Unexpected old state"); |
|
137 fail_unless (new == _new, "Unexpected new state"); |
|
138 fail_unless (pending == _pending, "Unexpected pending state"); |
|
139 |
|
140 gst_message_unref (message); |
|
141 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
142 create_xml(0); |
|
143 } |
|
144 #endif |
|
145 |
|
146 /* a sink should go ASYNC to PAUSE. forcing PLAYING is possible */ |
|
147 void test_sink() |
|
148 { |
|
149 GstElement *sink; |
|
150 GstStateChangeReturn ret; |
|
151 GstState current, pending; |
|
152 //xmlfile = "test_sink"; |
|
153 std_log(LOG_FILENAME_LINE, "Test Started test_sink"); |
|
154 |
|
155 |
|
156 sink = gst_element_factory_make ("fakesink", "sink"); |
|
157 |
|
158 ret = gst_element_set_state (sink, GST_STATE_PAUSED); |
|
159 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); |
|
160 |
|
161 ret = gst_element_set_state (sink, GST_STATE_PLAYING); |
|
162 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no forced async state change"); |
|
163 |
|
164 ret = gst_element_get_state (sink, ¤t, &pending, 0); |
|
165 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async"); |
|
166 fail_unless (current == GST_STATE_READY, "bad current state"); |
|
167 fail_unless (pending == GST_STATE_PLAYING, "bad pending state"); |
|
168 |
|
169 ret = gst_element_set_state (sink, GST_STATE_PAUSED); |
|
170 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async going back to paused"); |
|
171 |
|
172 ret = gst_element_set_state (sink, GST_STATE_READY); |
|
173 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to ready"); |
|
174 |
|
175 ret = gst_element_set_state (sink, GST_STATE_NULL); |
|
176 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to null"); |
|
177 |
|
178 gst_object_unref (sink); |
|
179 |
|
180 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
181 create_xml(0); |
|
182 } |
|
183 |
|
184 |
|
185 /* a sink should go ASYNC to PAUSE and PLAYING, when linking a src, it |
|
186 * should complete the state change. */ |
|
187 void test_sink_completion() |
|
188 { |
|
189 GstElement *sink, *src; |
|
190 GstStateChangeReturn ret; |
|
191 GstState current, pending; |
|
192 //xmlfile = "test_sink_completion"; |
|
193 std_log(LOG_FILENAME_LINE, "Test Started test_sink_completion"); |
|
194 sink = gst_element_factory_make ("fakesink", "sink"); |
|
195 g_object_set (G_OBJECT (sink), "sync", TRUE, NULL); |
|
196 |
|
197 ret = gst_element_set_state (sink, GST_STATE_PLAYING); |
|
198 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); |
|
199 |
|
200 ret = gst_element_get_state (sink, ¤t, &pending, 0); |
|
201 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async"); |
|
202 fail_unless (current == GST_STATE_READY, "bad current state"); |
|
203 fail_unless (pending == GST_STATE_PLAYING, "bad pending state"); |
|
204 |
|
205 src = gst_element_factory_make ("fakesrc", "src"); |
|
206 g_object_set (G_OBJECT (src), "datarate", 200, "sizetype", 2, NULL); |
|
207 gst_element_link (src, sink); |
|
208 |
|
209 ret = gst_element_set_state (src, GST_STATE_PLAYING); |
|
210 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); |
|
211 |
|
212 /* now wait for final state */ |
|
213 ret = gst_element_get_state (sink, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
214 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to change state"); |
|
215 fail_unless (current == GST_STATE_PLAYING, "bad current state"); |
|
216 fail_unless (pending == GST_STATE_VOID_PENDING, "bad pending state"); |
|
217 |
|
218 ret = gst_element_set_state (sink, GST_STATE_NULL); |
|
219 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to null"); |
|
220 |
|
221 ret = gst_element_set_state (src, GST_STATE_NULL); |
|
222 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to null"); |
|
223 |
|
224 gst_object_unref (sink); |
|
225 gst_object_unref (src); |
|
226 |
|
227 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
228 create_xml(0); |
|
229 } |
|
230 |
|
231 |
|
232 /* a sink should go ASYNC to PAUSE. PAUSE should complete when |
|
233 * prerolled. */ |
|
234 void test_src_sink() |
|
235 { |
|
236 GstElement *sink, *src, *pipeline; |
|
237 GstStateChangeReturn ret; |
|
238 GstState current, pending; |
|
239 GstPad *srcpad, *sinkpad; |
|
240 //xmlfile = "test_src_sink"; |
|
241 std_log(LOG_FILENAME_LINE, "Test Started test_src_sink"); |
|
242 |
|
243 pipeline = gst_pipeline_new ("pipeline"); |
|
244 src = gst_element_factory_make ("fakesrc", "src"); |
|
245 sink = gst_element_factory_make ("fakesink", "sink"); |
|
246 |
|
247 gst_bin_add (GST_BIN (pipeline), src); |
|
248 gst_bin_add (GST_BIN (pipeline), sink); |
|
249 |
|
250 srcpad = gst_element_get_pad (src, "src"); |
|
251 sinkpad = gst_element_get_pad (sink, "sink"); |
|
252 gst_pad_link (srcpad, sinkpad); |
|
253 gst_object_unref (srcpad); |
|
254 gst_object_unref (sinkpad); |
|
255 |
|
256 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
257 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); |
|
258 ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); |
|
259 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); |
|
260 |
|
261 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
262 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot start play"); |
|
263 |
|
264 ret = |
|
265 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
266 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); |
|
267 fail_unless (current == GST_STATE_PLAYING, "not playing"); |
|
268 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
269 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
270 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot null pipeline"); |
|
271 |
|
272 gst_object_unref (pipeline); |
|
273 |
|
274 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
275 create_xml(0); |
|
276 |
|
277 } |
|
278 |
|
279 |
|
280 /* a pipeline with live source should return NO_PREROLL in |
|
281 * PAUSE. When removing the live source it should return ASYNC |
|
282 * from the sink */ |
|
283 void test_livesrc_remove() |
|
284 { |
|
285 GstElement *sink, *src, *pipeline; |
|
286 GstStateChangeReturn ret; |
|
287 GstState current, pending; |
|
288 GstPad *srcpad, *sinkpad; |
|
289 //xmlfile = "test_livesrc_remove"; |
|
290 std_log(LOG_FILENAME_LINE, "Test Started test_livesrc_remove"); |
|
291 |
|
292 pipeline = gst_pipeline_new ("pipeline"); |
|
293 src = gst_element_factory_make ("fakesrc", "src"); |
|
294 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
295 sink = gst_element_factory_make ("fakesink", "sink"); |
|
296 |
|
297 gst_object_ref (src); |
|
298 gst_bin_add (GST_BIN (pipeline), src); |
|
299 gst_bin_add (GST_BIN (pipeline), sink); |
|
300 |
|
301 srcpad = gst_element_get_pad (src, "src"); |
|
302 sinkpad = gst_element_get_pad (sink, "sink"); |
|
303 gst_pad_link (srcpad, sinkpad); |
|
304 gst_object_unref (srcpad); |
|
305 gst_object_unref (sinkpad); |
|
306 |
|
307 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
308 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
309 "no no_preroll state return"); |
|
310 |
|
311 ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
312 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); |
|
313 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
314 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
315 |
|
316 gst_bin_remove (GST_BIN (pipeline), src); |
|
317 |
|
318 ret = gst_element_set_state (src, GST_STATE_NULL); |
|
319 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "async going to null"); |
|
320 gst_object_unref (src); |
|
321 |
|
322 ret = gst_element_get_state (pipeline, ¤t, &pending, 0); |
|
323 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); |
|
324 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
325 fail_unless (pending == GST_STATE_PAUSED, "not paused"); |
|
326 |
|
327 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
328 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "async going to null"); |
|
329 gst_object_unref (pipeline); |
|
330 |
|
331 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
332 create_xml(0); |
|
333 } |
|
334 #if 0 |
|
335 |
|
336 /* the sink should go ASYNC to PAUSE. The live source should go |
|
337 * NO_PREROLL to PAUSE. the pipeline returns NO_PREROLL. An |
|
338 * attempt to go to PLAYING will return ASYNC. polling state |
|
339 * completion should return SUCCESS when the sink is gone to |
|
340 * PLAYING. */ |
|
341 void test_livesrc_sink() |
|
342 { |
|
343 GstElement *sink, *src, *pipeline; |
|
344 GstStateChangeReturn ret; |
|
345 GstState current, pending; |
|
346 GstPad *srcpad, *sinkpad; |
|
347 GstBus *bus; |
|
348 // xmlfile = "test_deinit"; |
|
349 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
350 |
|
351 pipeline = gst_pipeline_new ("pipeline"); |
|
352 src = gst_element_factory_make ("fakesrc", "src"); |
|
353 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
354 sink = gst_element_factory_make ("fakesink", "sink"); |
|
355 |
|
356 gst_bin_add (GST_BIN (pipeline), src); |
|
357 gst_bin_add (GST_BIN (pipeline), sink); |
|
358 |
|
359 srcpad = gst_element_get_pad (src, "src"); |
|
360 sinkpad = gst_element_get_pad (sink, "sink"); |
|
361 gst_pad_link (srcpad, sinkpad); |
|
362 gst_object_unref (srcpad); |
|
363 gst_object_unref (sinkpad); |
|
364 |
|
365 bus = gst_element_get_bus (pipeline); |
|
366 |
|
367 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
368 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
369 "no no_preroll state return"); |
|
370 |
|
371 pop_state_change_message (bus, sink, GST_STATE_NULL, GST_STATE_READY, |
|
372 GST_STATE_VOID_PENDING); |
|
373 pop_state_change_message (bus, src, GST_STATE_NULL, GST_STATE_READY, |
|
374 GST_STATE_VOID_PENDING); |
|
375 pop_state_change_message (bus, pipeline, GST_STATE_NULL, GST_STATE_READY, |
|
376 GST_STATE_PAUSED); |
|
377 |
|
378 /* this order only holds true for live sources because they do not push |
|
379 buffers in PAUSED */ |
|
380 pop_state_change_message (bus, src, GST_STATE_READY, GST_STATE_PAUSED, |
|
381 GST_STATE_VOID_PENDING); |
|
382 pop_state_change_message (bus, pipeline, GST_STATE_READY, GST_STATE_PAUSED, |
|
383 GST_STATE_VOID_PENDING); |
|
384 |
|
385 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
386 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
387 "no no_preroll state return the second time"); |
|
388 |
|
389 ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
390 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); |
|
391 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
392 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
393 |
|
394 /* don't block here */ |
|
395 ret = gst_element_get_state (sink, ¤t, &pending, 0); |
|
396 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); |
|
397 fail_unless (current == GST_STATE_READY, "not ready"); |
|
398 fail_unless (pending == GST_STATE_PAUSED, "not paused"); |
|
399 |
|
400 ret = |
|
401 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
402 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); |
|
403 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
404 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
405 |
|
406 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
407 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); |
|
408 ret = |
|
409 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
410 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); |
|
411 fail_unless (current == GST_STATE_PLAYING, "not playing"); |
|
412 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
413 |
|
414 /* now we have four messages on the bus: src from paused to playing, sink from |
|
415 ready to paused and paused to playing, and pipeline from paused to playing. |
|
416 the pipeline message should be last, and the sink messages should go in |
|
417 order, but the src message can be interleaved with the sink one. */ |
|
418 { |
|
419 GstMessage *m; |
|
420 GstState old, new, pending; |
|
421 gint n_src = 1, n_sink = 2; |
|
422 |
|
423 while (n_src + n_sink > 0) { |
|
424 m = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND); |
|
425 fail_unless (m != NULL, "expected state change message"); |
|
426 gst_message_parse_state_changed (m, &old, &new, &pending); |
|
427 if (GST_MESSAGE_SRC (m) == (GstObject *) src) { |
|
428 fail_unless (n_src == 1, "already got one message from the src"); |
|
429 n_src--; |
|
430 fail_unless (old == GST_STATE_PAUSED, "unexpected old"); |
|
431 fail_unless (new == GST_STATE_PLAYING, "unexpected new (got %d)", new); |
|
432 fail_unless (pending == GST_STATE_VOID_PENDING, "unexpected pending"); |
|
433 } else if (GST_MESSAGE_SRC (m) == (GstObject *) sink) { |
|
434 if (n_sink == 2) { |
|
435 fail_unless (old == GST_STATE_READY, "unexpected old"); |
|
436 fail_unless (new == GST_STATE_PAUSED, "unexpected new"); |
|
437 fail_unless (pending == GST_STATE_VOID_PENDING, "unexpected pending"); |
|
438 } else if (n_sink == 1) { |
|
439 fail_unless (old == GST_STATE_PAUSED, "unexpected old"); |
|
440 fail_unless (new == GST_STATE_PLAYING, "unexpected new"); |
|
441 fail_unless (pending == GST_STATE_VOID_PENDING, "unexpected pending"); |
|
442 } else { |
|
443 g_assert_not_reached (); |
|
444 } |
|
445 n_sink--; |
|
446 } else { |
|
447 g_critical |
|
448 ("Unexpected state change message src %s (%d src %d sink pending)", |
|
449 GST_OBJECT_NAME (GST_MESSAGE_SRC (m)), n_src, n_sink); |
|
450 } |
|
451 gst_message_unref (m); |
|
452 } |
|
453 } |
|
454 |
|
455 pop_state_change_message (bus, pipeline, GST_STATE_PAUSED, GST_STATE_PLAYING, |
|
456 GST_STATE_VOID_PENDING); |
|
457 |
|
458 gst_object_unref (bus); |
|
459 gst_element_set_state (pipeline, GST_STATE_NULL); |
|
460 gst_object_unref (pipeline); |
|
461 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
462 create_xml(0); |
|
463 } |
|
464 |
|
465 |
|
466 |
|
467 /* The sink should go ASYNC to PLAYING. The source should go |
|
468 * to PLAYING with SUCCESS. The pipeline returns ASYNC. */ |
|
469 void test_livesrc2_sink() |
|
470 { |
|
471 GstElement *sink, *src, *pipeline; |
|
472 GstStateChangeReturn ret; |
|
473 GstState current, pending; |
|
474 GstPad *srcpad, *sinkpad; |
|
475 //xmlfile = "test_deinit"; |
|
476 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
477 |
|
478 pipeline = gst_pipeline_new ("pipeline"); |
|
479 src = gst_element_factory_make ("fakesrc", "src"); |
|
480 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
481 sink = gst_element_factory_make ("fakesink", "sink"); |
|
482 |
|
483 gst_bin_add (GST_BIN (pipeline), src); |
|
484 gst_bin_add (GST_BIN (pipeline), sink); |
|
485 |
|
486 srcpad = gst_element_get_pad (src, "src"); |
|
487 sinkpad = gst_element_get_pad (sink, "sink"); |
|
488 gst_pad_link (srcpad, sinkpad); |
|
489 gst_object_unref (srcpad); |
|
490 gst_object_unref (sinkpad); |
|
491 |
|
492 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
493 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); |
|
494 |
|
495 ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
496 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); |
|
497 fail_unless (current == GST_STATE_PLAYING, "not playing"); |
|
498 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
499 |
|
500 ret = |
|
501 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
502 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); |
|
503 fail_unless (current == GST_STATE_PLAYING, "not playing"); |
|
504 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
505 |
|
506 /* and back down */ |
|
507 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
508 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
509 "no no_preroll state return"); |
|
510 |
|
511 ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
512 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not no_preroll"); |
|
513 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
514 fail_unless (pending == GST_STATE_VOID_PENDING, "not paused"); |
|
515 |
|
516 /* sink state is not known.. it might be prerolled or not */ |
|
517 |
|
518 /* and to READY */ |
|
519 ret = gst_element_set_state (pipeline, GST_STATE_READY); |
|
520 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); |
|
521 |
|
522 ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
523 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not success"); |
|
524 fail_unless (current == GST_STATE_READY, "not ready"); |
|
525 fail_unless (pending == GST_STATE_VOID_PENDING, "not ready"); |
|
526 |
|
527 ret = gst_element_get_state (sink, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
528 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not success"); |
|
529 fail_unless (current == GST_STATE_READY, "not ready"); |
|
530 fail_unless (pending == GST_STATE_VOID_PENDING, "not ready"); |
|
531 |
|
532 /* And destroy. Must be NULL */ |
|
533 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
534 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); |
|
535 gst_object_unref (pipeline); |
|
536 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
537 create_xml(0); |
|
538 } |
|
539 |
|
540 |
|
541 |
|
542 void test_livesrc3_sink() |
|
543 { |
|
544 GstElement *sink, *src, *pipeline; |
|
545 GstStateChangeReturn ret; |
|
546 GstState current, pending; |
|
547 GstPad *srcpad, *sinkpad; |
|
548 //xmlfile = "test_deinit"; |
|
549 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
550 |
|
551 pipeline = gst_pipeline_new ("pipeline"); |
|
552 src = gst_element_factory_make ("fakesrc", "src"); |
|
553 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
554 sink = gst_element_factory_make ("fakesink", "sink"); |
|
555 |
|
556 gst_bin_add (GST_BIN (pipeline), src); |
|
557 gst_bin_add (GST_BIN (pipeline), sink); |
|
558 |
|
559 srcpad = gst_element_get_pad (src, "src"); |
|
560 sinkpad = gst_element_get_pad (sink, "sink"); |
|
561 gst_pad_link (srcpad, sinkpad); |
|
562 gst_object_unref (srcpad); |
|
563 gst_object_unref (sinkpad); |
|
564 |
|
565 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
566 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); |
|
567 |
|
568 ret = |
|
569 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
570 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); |
|
571 fail_unless (current == GST_STATE_PLAYING, "not playing"); |
|
572 fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); |
|
573 |
|
574 /* and back down */ |
|
575 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
576 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); |
|
577 gst_object_unref (pipeline); |
|
578 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
579 create_xml(0); |
|
580 } |
|
581 |
|
582 #endif |
|
583 |
|
584 void test_locked_sink() |
|
585 { |
|
586 GstElement *sink, *src, *pipeline; |
|
587 GstStateChangeReturn ret; |
|
588 GstState current, pending; |
|
589 //xmlfile = "test_locked_sink"; |
|
590 std_log(LOG_FILENAME_LINE, "Test Started test_locked_sink"); |
|
591 |
|
592 pipeline = gst_pipeline_new ("pipeline"); |
|
593 src = gst_element_factory_make ("fakesrc", "src"); |
|
594 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
595 sink = gst_element_factory_make ("fakesink", "sink"); |
|
596 |
|
597 gst_bin_add (GST_BIN (pipeline), src); |
|
598 gst_bin_add (GST_BIN (pipeline), sink); |
|
599 |
|
600 /* we don't link the elements */ |
|
601 |
|
602 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
603 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
604 "no NO_PREROLL state return"); |
|
605 |
|
606 ret = |
|
607 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
608 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not no_preroll"); |
|
609 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
610 fail_unless (pending == GST_STATE_VOID_PENDING, "have pending"); |
|
611 |
|
612 /* the sink is now async going from ready to paused */ |
|
613 ret = gst_element_get_state (sink, ¤t, &pending, 0); |
|
614 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); |
|
615 fail_unless (current == GST_STATE_READY, "not ready"); |
|
616 fail_unless (pending == GST_STATE_PAUSED, "not paused"); |
|
617 |
|
618 /* lock the sink */ |
|
619 gst_element_set_locked_state (sink, TRUE); |
|
620 |
|
621 /* move to PlAYING, the sink should remain ASYNC. The pipeline |
|
622 * returns ASYNC */ |
|
623 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
624 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
625 |
|
626 /* back to PAUSED, we should get NO_PREROLL again */ |
|
627 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
628 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
629 "no NO_PREROLL state return"); |
|
630 |
|
631 /* unlock the sink */ |
|
632 gst_element_set_locked_state (sink, FALSE); |
|
633 |
|
634 /* and now everything back down */ |
|
635 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
636 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); |
|
637 gst_object_unref (pipeline); |
|
638 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
639 create_xml(0); |
|
640 } |
|
641 |
|
642 |
|
643 |
|
644 void test_unlinked_live() |
|
645 { |
|
646 GstElement *sink, *src, *lsrc, *pipeline; |
|
647 GstStateChangeReturn ret; |
|
648 GstState current, pending; |
|
649 GstPad *srcpad, *sinkpad; |
|
650 // xmlfile = "test_unlinked_live"; |
|
651 std_log(LOG_FILENAME_LINE, "Test Started test_unlinked_live"); |
|
652 |
|
653 pipeline = gst_pipeline_new ("pipeline"); |
|
654 src = gst_element_factory_make ("fakesrc", "src"); |
|
655 lsrc = gst_element_factory_make ("fakesrc", "lsrc"); |
|
656 g_object_set (G_OBJECT (lsrc), "is-live", TRUE, NULL); |
|
657 sink = gst_element_factory_make ("fakesink", "sink"); |
|
658 |
|
659 gst_bin_add (GST_BIN (pipeline), src); |
|
660 gst_bin_add (GST_BIN (pipeline), lsrc); |
|
661 gst_bin_add (GST_BIN (pipeline), sink); |
|
662 |
|
663 /* link non live source to sink */ |
|
664 srcpad = gst_element_get_pad (src, "src"); |
|
665 sinkpad = gst_element_get_pad (sink, "sink"); |
|
666 gst_pad_link (srcpad, sinkpad); |
|
667 gst_object_unref (srcpad); |
|
668 gst_object_unref (sinkpad); |
|
669 |
|
670 /* we don't link the srcpad of the live source, it will not contribute to the |
|
671 * NO_PREROLL. */ |
|
672 |
|
673 /* set state to PAUSED, this should return NO_PREROLL because there is a live |
|
674 * source. since the only sink in this pipeline is linked to a non-live |
|
675 * source, it will preroll eventually. */ |
|
676 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
677 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
678 "no NO_PREROLL state return"); |
|
679 |
|
680 /* wait till the sink is prerolled */ |
|
681 ret = gst_element_get_state (sink, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
682 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not success"); |
|
683 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
684 fail_unless (pending == GST_STATE_VOID_PENDING, "have playing"); |
|
685 |
|
686 /* the pipeline should still return NO_PREROLL */ |
|
687 ret = |
|
688 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
689 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not no_preroll"); |
|
690 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
691 fail_unless (pending == GST_STATE_VOID_PENDING, "have playing"); |
|
692 |
|
693 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
694 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS"); |
|
695 |
|
696 gst_object_unref (pipeline); |
|
697 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
698 create_xml(0); |
|
699 } |
|
700 |
|
701 |
|
702 |
|
703 void test_delayed_async() |
|
704 { |
|
705 GstElement *sink, *src, *pipeline; |
|
706 GstStateChangeReturn ret; |
|
707 GstState current, pending; |
|
708 GstPad *srcpad, *sinkpad; |
|
709 // xmlfile = "test_delayed_async"; |
|
710 std_log(LOG_FILENAME_LINE, "Test Started test_delayed_async"); |
|
711 |
|
712 pipeline = gst_pipeline_new ("pipeline"); |
|
713 src = gst_element_factory_make ("fakesrc", "src"); |
|
714 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
715 sink = gst_element_factory_make ("fakesink", "sink"); |
|
716 |
|
717 /* add source, don't add sink yet */ |
|
718 gst_bin_add (GST_BIN (pipeline), src); |
|
719 |
|
720 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
721 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
722 "no NO_PREROLL state return"); |
|
723 |
|
724 /* add sink now and set to PAUSED */ |
|
725 gst_bin_add (GST_BIN (pipeline), sink); |
|
726 |
|
727 /* This will make the bin notice an ASYNC element. */ |
|
728 ret = gst_element_set_state (sink, GST_STATE_PAUSED); |
|
729 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
730 |
|
731 /* we should still be NO_PREROLL now although there is an async element in the |
|
732 * pipeline. */ |
|
733 ret = |
|
734 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
735 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL"); |
|
736 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
737 fail_unless (pending == GST_STATE_VOID_PENDING, "have pending"); |
|
738 |
|
739 /* link live source to sink */ |
|
740 srcpad = gst_element_get_pad (src, "src"); |
|
741 sinkpad = gst_element_get_pad (sink, "sink"); |
|
742 gst_pad_link (srcpad, sinkpad); |
|
743 gst_object_unref (srcpad); |
|
744 gst_object_unref (sinkpad); |
|
745 |
|
746 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
747 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
748 |
|
749 /* we should get SUCCESS now */ |
|
750 ret = |
|
751 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
752 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not NO_PREROLL"); |
|
753 fail_unless (current == GST_STATE_PLAYING, "not PLAYING"); |
|
754 fail_unless (pending == GST_STATE_VOID_PENDING, "have pending"); |
|
755 |
|
756 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
757 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS"); |
|
758 |
|
759 gst_object_unref (pipeline); |
|
760 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
761 create_xml(0); |
|
762 } |
|
763 |
|
764 |
|
765 |
|
766 void test_added_async() |
|
767 { |
|
768 GstElement *sink, *src, *pipeline; |
|
769 GstStateChangeReturn ret; |
|
770 GstState current, pending; |
|
771 GstPad *srcpad, *sinkpad; |
|
772 //xmlfile = "test_added_async"; |
|
773 std_log(LOG_FILENAME_LINE, "Test Started test_added_async"); |
|
774 |
|
775 pipeline = gst_pipeline_new ("pipeline"); |
|
776 src = gst_element_factory_make ("fakesrc", "src"); |
|
777 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
778 sink = gst_element_factory_make ("fakesink", "sink"); |
|
779 |
|
780 /* add source, don't add sink yet */ |
|
781 gst_bin_add (GST_BIN (pipeline), src); |
|
782 |
|
783 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
784 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
785 "no NO_PREROLL state return"); |
|
786 |
|
787 /* set sink to PAUSED without adding it to the pipeline */ |
|
788 ret = gst_element_set_state (sink, GST_STATE_PAUSED); |
|
789 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
790 |
|
791 /* add sink now, pipeline should notice the async element */ |
|
792 gst_bin_add (GST_BIN (pipeline), sink); |
|
793 |
|
794 /* we should still be NO_PREROLL now although there is an async element in the |
|
795 * pipeline. */ |
|
796 ret = |
|
797 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
798 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL"); |
|
799 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
800 fail_unless (pending == GST_STATE_VOID_PENDING, "have pending"); |
|
801 |
|
802 /* link live source to sink */ |
|
803 srcpad = gst_element_get_pad (src, "src"); |
|
804 sinkpad = gst_element_get_pad (sink, "sink"); |
|
805 gst_pad_link (srcpad, sinkpad); |
|
806 gst_object_unref (srcpad); |
|
807 gst_object_unref (sinkpad); |
|
808 |
|
809 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
810 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
811 |
|
812 /* we should get SUCCESS now */ |
|
813 ret = |
|
814 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
815 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not NO_PREROLL"); |
|
816 fail_unless (current == GST_STATE_PLAYING, "not PLAYING"); |
|
817 fail_unless (pending == GST_STATE_VOID_PENDING, "have pending"); |
|
818 |
|
819 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
820 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS"); |
|
821 |
|
822 gst_object_unref (pipeline); |
|
823 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
824 create_xml(0); |
|
825 } |
|
826 |
|
827 |
|
828 |
|
829 void test_added_async2() |
|
830 { |
|
831 GstElement *sink, *src, *pipeline; |
|
832 GstStateChangeReturn ret; |
|
833 GstState current, pending; |
|
834 //xmlfile = "test_added_async2"; |
|
835 std_log(LOG_FILENAME_LINE, "Test Started test_added_async2"); |
|
836 |
|
837 pipeline = gst_pipeline_new ("pipeline"); |
|
838 src = gst_element_factory_make ("fakesrc", "src"); |
|
839 sink = gst_element_factory_make ("fakesink", "sink"); |
|
840 |
|
841 /* add source, don't add sink yet */ |
|
842 gst_bin_add (GST_BIN (pipeline), src); |
|
843 |
|
844 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
845 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no SUCCESS state return"); |
|
846 |
|
847 /* set sink to PAUSED without adding it to the pipeline */ |
|
848 ret = gst_element_set_state (sink, GST_STATE_PAUSED); |
|
849 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
850 |
|
851 /* add sink now, pipeline should notice the async element */ |
|
852 gst_bin_add (GST_BIN (pipeline), sink); |
|
853 |
|
854 /* we should be ASYNC now because there is an async element in the |
|
855 * pipeline. */ |
|
856 ret = gst_element_get_state (pipeline, ¤t, &pending, 0); |
|
857 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not ASYNC"); |
|
858 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
859 fail_unless (pending == GST_STATE_PAUSED, "not paused"); |
|
860 |
|
861 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
862 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS"); |
|
863 |
|
864 gst_object_unref (pipeline); |
|
865 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
866 create_xml(0); |
|
867 } |
|
868 |
|
869 |
|
870 |
|
871 void test_add_live() |
|
872 { |
|
873 GstElement *sink, *src, *pipeline; |
|
874 GstStateChangeReturn ret; |
|
875 GstState current, pending; |
|
876 // xmlfile = "test_add_live"; |
|
877 std_log(LOG_FILENAME_LINE, "Test Started test_add_live"); |
|
878 |
|
879 pipeline = gst_pipeline_new ("pipeline"); |
|
880 src = gst_element_factory_make ("fakesrc", "src"); |
|
881 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
882 sink = gst_element_factory_make ("fakesink", "sink"); |
|
883 |
|
884 /* add sink, don't add sourc3 yet */ |
|
885 gst_bin_add (GST_BIN (pipeline), sink); |
|
886 |
|
887 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
888 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
889 |
|
890 /* set source to PAUSED without adding it to the pipeline */ |
|
891 ret = gst_element_set_state (src, GST_STATE_PAUSED); |
|
892 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
893 "no NO_PREROLL state return"); |
|
894 |
|
895 /* add source now, pipeline should notice the NO_PREROLL element */ |
|
896 gst_bin_add (GST_BIN (pipeline), src); |
|
897 |
|
898 /* we should be NO_PREROLL now because there is a NO_PREROLL element in the |
|
899 * pipeline. */ |
|
900 ret = |
|
901 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
902 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL"); |
|
903 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
904 fail_unless (pending == GST_STATE_VOID_PENDING, "have pending"); |
|
905 |
|
906 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
907 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS"); |
|
908 |
|
909 gst_object_unref (pipeline); |
|
910 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
911 create_xml(0); |
|
912 } |
|
913 |
|
914 #if 0 |
|
915 |
|
916 static GMutex *blocked_lock; |
|
917 static GCond *blocked_cond; |
|
918 |
|
919 static void |
|
920 pad_blocked_cb (GstPad * pad, gboolean blocked, gpointer user_data) |
|
921 { |
|
922 //xmlfile = "test_deinit"; |
|
923 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
924 g_mutex_lock (blocked_lock); |
|
925 GST_DEBUG ("srcpad blocked: %d, sending signal", blocked); |
|
926 g_cond_signal (blocked_cond); |
|
927 g_mutex_unlock (blocked_lock); |
|
928 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
929 create_xml(0); |
|
930 } |
|
931 |
|
932 void test_add_live2() |
|
933 { |
|
934 GstElement *sink, *src, *pipeline; |
|
935 GstStateChangeReturn ret; |
|
936 GstState current, pending; |
|
937 GstPad *srcpad, *sinkpad; |
|
938 // xmlfile = "test_deinit"; |
|
939 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
940 |
|
941 blocked_lock = g_mutex_new (); |
|
942 blocked_cond = g_cond_new (); |
|
943 |
|
944 pipeline = gst_pipeline_new ("pipeline"); |
|
945 src = gst_element_factory_make ("fakesrc", "src"); |
|
946 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
947 sink = gst_element_factory_make ("fakesink", "sink"); |
|
948 |
|
949 /* add sink, don't add source yet */ |
|
950 gst_bin_add (GST_BIN (pipeline), sink); |
|
951 |
|
952 /* set the pipeline to PLAYING. This will return ASYNC on READY->PAUSED */ |
|
953 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
954 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
955 |
|
956 g_mutex_lock (blocked_lock); |
|
957 |
|
958 GST_DEBUG ("blocking srcpad"); |
|
959 /* block source pad */ |
|
960 srcpad = gst_element_get_pad (src, "src"); |
|
961 gst_pad_set_blocked_async (srcpad, TRUE, pad_blocked_cb, NULL); |
|
962 |
|
963 /* set source to PAUSED without adding it to the pipeline */ |
|
964 ret = gst_element_set_state (src, GST_STATE_PAUSED); |
|
965 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
966 "no NO_PREROLL state return"); |
|
967 |
|
968 /* add source now, pipeline should notice the NO_PREROLL element. This |
|
969 * should trigger as commit of the ASYNC pipeline and make it continue |
|
970 * to PLAYING. We blocked the source pad so that we don't get an unlinked |
|
971 * error. */ |
|
972 gst_bin_add (GST_BIN (pipeline), src); |
|
973 |
|
974 /* wait for pad blocked, this means the source is now PLAYING. */ |
|
975 g_cond_wait (blocked_cond, blocked_lock); |
|
976 g_mutex_unlock (blocked_lock); |
|
977 |
|
978 GST_DEBUG ("linking pads"); |
|
979 |
|
980 /* link to sink */ |
|
981 sinkpad = gst_element_get_pad (sink, "sink"); |
|
982 gst_pad_link (srcpad, sinkpad); |
|
983 gst_object_unref (srcpad); |
|
984 gst_object_unref (sinkpad); |
|
985 |
|
986 GST_DEBUG ("unblocking srcpad"); |
|
987 |
|
988 /* and unblock */ |
|
989 gst_pad_set_blocked_async (srcpad, FALSE, pad_blocked_cb, NULL); |
|
990 |
|
991 GST_DEBUG ("getting state"); |
|
992 |
|
993 /* we should be SUCCESS now and PLAYING */ |
|
994 ret = |
|
995 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
996 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS"); |
|
997 fail_unless (current == GST_STATE_PLAYING, "not PLAYING"); |
|
998 fail_unless (pending == GST_STATE_VOID_PENDING, "have pending"); |
|
999 |
|
1000 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
1001 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not SUCCESS"); |
|
1002 |
|
1003 g_cond_free (blocked_cond); |
|
1004 g_mutex_free (blocked_lock); |
|
1005 gst_object_unref (pipeline); |
|
1006 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1007 create_xml(0); |
|
1008 } |
|
1009 |
|
1010 #endif |
|
1011 |
|
1012 void test_bin_live() |
|
1013 { |
|
1014 GstElement *sink, *src, *pipeline, *bin; |
|
1015 GstStateChangeReturn ret; |
|
1016 GstState current, pending; |
|
1017 GstPad *srcpad, *sinkpad; |
|
1018 //xmlfile = "test_bin_live"; |
|
1019 std_log(LOG_FILENAME_LINE, "Test Started test_bin_live"); |
|
1020 |
|
1021 pipeline = gst_pipeline_new ("pipeline"); |
|
1022 bin = gst_bin_new ("bin"); |
|
1023 src = gst_element_factory_make ("fakesrc", "src"); |
|
1024 g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); |
|
1025 sink = gst_element_factory_make ("fakesink", "sink"); |
|
1026 |
|
1027 gst_bin_add (GST_BIN (bin), src); |
|
1028 gst_bin_add (GST_BIN (bin), sink); |
|
1029 gst_bin_add (GST_BIN (pipeline), bin); |
|
1030 |
|
1031 srcpad = gst_element_get_pad (src, "src"); |
|
1032 sinkpad = gst_element_get_pad (sink, "sink"); |
|
1033 gst_pad_link (srcpad, sinkpad); |
|
1034 gst_object_unref (srcpad); |
|
1035 gst_object_unref (sinkpad); |
|
1036 |
|
1037 /* PAUSED returns NO_PREROLL because of the live source */ |
|
1038 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
1039 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, |
|
1040 "no NO_PREROLL state return"); |
|
1041 ret = |
|
1042 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
1043 fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL"); |
|
1044 fail_unless (current == GST_STATE_PAUSED, "not paused"); |
|
1045 fail_unless (pending == GST_STATE_VOID_PENDING, "not void pending"); |
|
1046 |
|
1047 /* when going to PLAYING, the sink should go to PLAYING ASYNC */ |
|
1048 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
1049 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not ASYNC"); |
|
1050 |
|
1051 /* now wait for PLAYING to complete */ |
|
1052 ret = |
|
1053 gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); |
|
1054 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); |
|
1055 fail_unless (current == GST_STATE_PLAYING, "not playing"); |
|
1056 fail_unless (pending == GST_STATE_VOID_PENDING, "not void pending"); |
|
1057 |
|
1058 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
1059 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot null pipeline"); |
|
1060 |
|
1061 gst_object_unref (pipeline); |
|
1062 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1063 create_xml(0); |
|
1064 } |
|
1065 #if 0 |
|
1066 |
|
1067 send_eos (GstPad * sinkpad) |
|
1068 { |
|
1069 //xmlfile = "test_deinit"; |
|
1070 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1071 gst_pad_send_event (sinkpad, gst_event_new_eos ()); |
|
1072 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1073 create_xml(0); |
|
1074 } |
|
1075 |
|
1076 /* push a buffer with a very long duration in a fakesink, then push an EOS |
|
1077 * event. fakesink should emit EOS after the duration of the buffer expired. |
|
1078 * Going to PAUSED, however should not return ASYNC while processing the |
|
1079 * buffer. */ |
|
1080 void test_fake_eos() |
|
1081 { |
|
1082 GstElement *sink, *pipeline; |
|
1083 GstBuffer *buffer; |
|
1084 GstStateChangeReturn ret; |
|
1085 GstPad *sinkpad; |
|
1086 GstFlowReturn res; |
|
1087 GThread *thread; |
|
1088 //xmlfile = "test_deinit"; |
|
1089 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1090 |
|
1091 pipeline = gst_pipeline_new ("pipeline"); |
|
1092 |
|
1093 sink = gst_element_factory_make ("fakesink", "sink"); |
|
1094 g_object_set (G_OBJECT (sink), "sync", TRUE, NULL); |
|
1095 |
|
1096 sinkpad = gst_element_get_pad (sink, "sink"); |
|
1097 |
|
1098 gst_bin_add (GST_BIN_CAST (pipeline), sink); |
|
1099 |
|
1100 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
1101 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
1102 |
|
1103 /* push buffer of 100 seconds, since it has a timestamp of 0, it should be |
|
1104 * rendered immediatly and the chain function should return immediatly */ |
|
1105 buffer = gst_buffer_new_and_alloc (10); |
|
1106 GST_BUFFER_TIMESTAMP (buffer) = 0; |
|
1107 GST_BUFFER_DURATION (buffer) = 100 * GST_SECOND; |
|
1108 res = gst_pad_chain (sinkpad, buffer); |
|
1109 fail_unless (res == GST_FLOW_OK, "no OK flow return"); |
|
1110 |
|
1111 /* wait for preroll, this should happen really soon. */ |
|
1112 ret = gst_element_get_state (pipeline, NULL, NULL, -1); |
|
1113 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no SUCCESS state return"); |
|
1114 |
|
1115 /* push EOS, this will block for up to 100 seconds, until the previous |
|
1116 * buffer has finished. We therefore push it in another thread so we can do |
|
1117 * something else while it blocks. */ |
|
1118 thread = g_thread_create ((GThreadFunc) send_eos, sinkpad, TRUE, NULL); |
|
1119 fail_if (thread == NULL, "no thread"); |
|
1120 |
|
1121 /* wait a while so that the thread manages to start and push the EOS */ |
|
1122 g_usleep (G_USEC_PER_SEC); |
|
1123 |
|
1124 /* this should cancel rendering of the EOS event and should return SUCCESS |
|
1125 * because the sink is now prerolled on the EOS. */ |
|
1126 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
1127 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no SUCCESS state return"); |
|
1128 |
|
1129 /* we can unref the sinkpad now, we're done with it */ |
|
1130 gst_object_unref (sinkpad); |
|
1131 |
|
1132 /* wait for a second, use the debug log to see that basesink does not discard |
|
1133 * the EOS */ |
|
1134 g_usleep (G_USEC_PER_SEC); |
|
1135 |
|
1136 /* go back to PLAYING, which means waiting some more in EOS, check debug log |
|
1137 * to see this happen. */ |
|
1138 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
1139 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no SUCCESS state return"); |
|
1140 g_usleep (G_USEC_PER_SEC); |
|
1141 |
|
1142 /* teardown and cleanup */ |
|
1143 ret = gst_element_set_state (pipeline, GST_STATE_NULL); |
|
1144 fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no SUCCESS state return"); |
|
1145 |
|
1146 gst_object_unref (pipeline); |
|
1147 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1148 create_xml(0); |
|
1149 } |
|
1150 |
|
1151 |
|
1152 |
|
1153 /* this variable is updated in the same thread, first it is set by the |
|
1154 * handoff-preroll signal, then it is checked when the ASYNC_DONE is posted on |
|
1155 * the bus */ |
|
1156 static gboolean have_preroll = FALSE; |
|
1157 |
|
1158 static void |
|
1159 async_done_handoff (GstElement * element, GstBuffer * buf, GstPad * pad, |
|
1160 GstElement * sink) |
|
1161 { |
|
1162 //xmlfile = "test_deinit"; |
|
1163 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1164 GST_DEBUG ("we have the preroll buffer"); |
|
1165 have_preroll = TRUE; |
|
1166 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1167 create_xml(0); |
|
1168 } |
|
1169 |
|
1170 /* when we get the ASYNC_DONE, query the position */ |
|
1171 static GstBusSyncReply |
|
1172 async_done_func (GstBus * bus, GstMessage * msg, GstElement * sink) |
|
1173 { |
|
1174 //xmlfile = "test_deinit"; |
|
1175 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1176 if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ASYNC_DONE) { |
|
1177 GstFormat format; |
|
1178 gint64 position; |
|
1179 |
|
1180 GST_DEBUG ("we have ASYNC_DONE now"); |
|
1181 fail_unless (have_preroll == TRUE, "no preroll buffer received"); |
|
1182 |
|
1183 /* get the position now */ |
|
1184 format = GST_FORMAT_TIME; |
|
1185 gst_element_query_position (sink, &format, &position); |
|
1186 |
|
1187 GST_DEBUG ("we have position %" GST_TIME_FORMAT, GST_TIME_ARGS (position)); |
|
1188 |
|
1189 fail_unless (position == 10 * GST_SECOND, "position is wrong"); |
|
1190 } |
|
1191 |
|
1192 /* we must unref the message if we return DROP */ |
|
1193 gst_message_unref (msg); |
|
1194 |
|
1195 /* we can drop the message, nothing is listening for it. */ |
|
1196 return GST_BUS_DROP; |
|
1197 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1198 create_xml(0); |
|
1199 } |
|
1200 |
|
1201 static void |
|
1202 send_buffer (GstPad * sinkpad) |
|
1203 { |
|
1204 GstBuffer *buffer; |
|
1205 GstFlowReturn ret; |
|
1206 //xmlfile = "test_deinit"; |
|
1207 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1208 |
|
1209 /* push a second buffer */ |
|
1210 GST_DEBUG ("pushing last buffer"); |
|
1211 buffer = gst_buffer_new_and_alloc (10); |
|
1212 GST_BUFFER_TIMESTAMP (buffer) = 200 * GST_SECOND; |
|
1213 GST_BUFFER_DURATION (buffer) = 100 * GST_SECOND; |
|
1214 |
|
1215 /* this function will initially block */ |
|
1216 ret = gst_pad_chain (sinkpad, buffer); |
|
1217 fail_unless (ret == GST_FLOW_OK, "no OK flow return"); |
|
1218 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1219 create_xml(0); |
|
1220 } |
|
1221 |
|
1222 /* when we get the ASYNC_DONE message from a sink, we want the sink to be able |
|
1223 * to report the duration and position. The sink should also have called the |
|
1224 * render method. */ |
|
1225 void test_async_done() |
|
1226 { |
|
1227 GstElement *sink; |
|
1228 GstBuffer *buffer; |
|
1229 GstEvent *event; |
|
1230 GstStateChangeReturn ret; |
|
1231 GstPad *sinkpad; |
|
1232 GstFlowReturn res; |
|
1233 GstBus *bus; |
|
1234 GThread *thread; |
|
1235 GstFormat format; |
|
1236 gint64 position; |
|
1237 gboolean qret; |
|
1238 // xmlfile = "test_deinit"; |
|
1239 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1240 |
|
1241 sink = gst_element_factory_make ("fakesink", "sink"); |
|
1242 g_object_set (G_OBJECT (sink), "sync", TRUE, NULL); |
|
1243 g_object_set (G_OBJECT (sink), "preroll-queue-len", 2, NULL); |
|
1244 g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL); |
|
1245 |
|
1246 g_signal_connect (sink, "preroll-handoff", (GCallback) async_done_handoff, |
|
1247 sink); |
|
1248 |
|
1249 sinkpad = gst_element_get_pad (sink, "sink"); |
|
1250 |
|
1251 ret = gst_element_set_state (sink, GST_STATE_PAUSED); |
|
1252 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
1253 |
|
1254 /* set bus on element synchronously listen for ASYNC_DONE */ |
|
1255 bus = gst_bus_new (); |
|
1256 gst_element_set_bus (sink, bus); |
|
1257 gst_bus_set_sync_handler (bus, (GstBusSyncHandler) async_done_func, sink); |
|
1258 |
|
1259 /* make newsegment, this sets the position to 10sec when the buffer prerolls */ |
|
1260 GST_DEBUG ("sending segment"); |
|
1261 event = |
|
1262 gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, |
|
1263 10 * GST_SECOND); |
|
1264 res = gst_pad_send_event (sinkpad, event); |
|
1265 |
|
1266 /* We have not yet received any buffers so we are still in the READY state, |
|
1267 * the position is therefore still not queryable. */ |
|
1268 format = GST_FORMAT_TIME; |
|
1269 position = -1; |
|
1270 qret = gst_element_query_position (sink, &format, &position); |
|
1271 fail_unless (qret == FALSE, "position wrong"); |
|
1272 fail_unless (position == -1, "position is wrong"); |
|
1273 |
|
1274 /* Since we are paused and the preroll queue has a length of 2, this function |
|
1275 * will return immediatly, the preroll handoff will be called and the stream |
|
1276 * position should now be 10 seconds. */ |
|
1277 GST_DEBUG ("pushing first buffer"); |
|
1278 buffer = gst_buffer_new_and_alloc (10); |
|
1279 GST_BUFFER_TIMESTAMP (buffer) = 1 * GST_SECOND; |
|
1280 GST_BUFFER_DURATION (buffer) = 100 * GST_SECOND; |
|
1281 res = gst_pad_chain (sinkpad, buffer); |
|
1282 fail_unless (res == GST_FLOW_OK, "no OK flow return"); |
|
1283 |
|
1284 /* scond buffer, will not block either but position should still be 10 |
|
1285 * seconds */ |
|
1286 GST_DEBUG ("pushing second buffer"); |
|
1287 buffer = gst_buffer_new_and_alloc (10); |
|
1288 GST_BUFFER_TIMESTAMP (buffer) = 100 * GST_SECOND; |
|
1289 GST_BUFFER_DURATION (buffer) = 100 * GST_SECOND; |
|
1290 res = gst_pad_chain (sinkpad, buffer); |
|
1291 fail_unless (res == GST_FLOW_OK, "no OK flow return"); |
|
1292 |
|
1293 /* check if position is still 10 seconds */ |
|
1294 format = GST_FORMAT_TIME; |
|
1295 gst_element_query_position (sink, &format, &position); |
|
1296 GST_DEBUG ("first buffer position %" GST_TIME_FORMAT, |
|
1297 GST_TIME_ARGS (position)); |
|
1298 fail_unless (position == 10 * GST_SECOND, "position is wrong"); |
|
1299 |
|
1300 /* last buffer, blocks because preroll queue is filled. Start the push in a |
|
1301 * new thread so that we can check the position */ |
|
1302 GST_DEBUG ("starting thread"); |
|
1303 thread = g_thread_create ((GThreadFunc) send_buffer, sinkpad, TRUE, NULL); |
|
1304 fail_if (thread == NULL, "no thread"); |
|
1305 |
|
1306 GST_DEBUG ("waiting 1 second"); |
|
1307 g_usleep (G_USEC_PER_SEC); |
|
1308 GST_DEBUG ("waiting done"); |
|
1309 |
|
1310 /* check if position is still 10 seconds. This is racy because the above |
|
1311 * thread might not yet have started the push, because of the above sleep, |
|
1312 * this is very unlikely, though. */ |
|
1313 format = GST_FORMAT_TIME; |
|
1314 gst_element_query_position (sink, &format, &position); |
|
1315 GST_DEBUG ("second buffer position %" GST_TIME_FORMAT, |
|
1316 GST_TIME_ARGS (position)); |
|
1317 fail_unless (position == 10 * GST_SECOND, "position is wrong"); |
|
1318 |
|
1319 /* now we go to playing. This should unlock and stop the above thread. */ |
|
1320 GST_DEBUG ("going to PLAYING"); |
|
1321 ret = gst_element_set_state (sink, GST_STATE_PLAYING); |
|
1322 |
|
1323 /* join the thread. At this point we know the sink processed the last buffer |
|
1324 * and the position should now be 210 seconds; the time of the last buffer we |
|
1325 * pushed */ |
|
1326 GST_DEBUG ("joining thread"); |
|
1327 g_thread_join (thread); |
|
1328 |
|
1329 format = GST_FORMAT_TIME; |
|
1330 gst_element_query_position (sink, &format, &position); |
|
1331 GST_DEBUG ("last buffer position %" GST_TIME_FORMAT, |
|
1332 GST_TIME_ARGS (position)); |
|
1333 fail_unless (position == 210 * GST_SECOND, "position is wrong"); |
|
1334 |
|
1335 gst_object_unref (sinkpad); |
|
1336 |
|
1337 gst_element_set_state (sink, GST_STATE_NULL); |
|
1338 gst_object_unref (sink); |
|
1339 gst_object_unref (bus); |
|
1340 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1341 create_xml(0); |
|
1342 } |
|
1343 |
|
1344 |
|
1345 |
|
1346 /* when we get the ASYNC_DONE, query the position */ |
|
1347 static GstBusSyncReply |
|
1348 async_done_eos_func (GstBus * bus, GstMessage * msg, GstElement * sink) |
|
1349 { |
|
1350 //xmlfile = "test_deinit"; |
|
1351 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1352 if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ASYNC_DONE) { |
|
1353 GstFormat format; |
|
1354 gint64 position; |
|
1355 |
|
1356 GST_DEBUG ("we have ASYNC_DONE now"); |
|
1357 |
|
1358 /* get the position now */ |
|
1359 format = GST_FORMAT_TIME; |
|
1360 gst_element_query_position (sink, &format, &position); |
|
1361 |
|
1362 GST_DEBUG ("we have position %" GST_TIME_FORMAT, GST_TIME_ARGS (position)); |
|
1363 |
|
1364 fail_unless (position == 10 * GST_SECOND, "position is wrong"); |
|
1365 } |
|
1366 /* we must unref the message if we return DROP */ |
|
1367 gst_message_unref (msg); |
|
1368 /* we can drop the message, nothing is listening for it. */ |
|
1369 return GST_BUS_DROP; |
|
1370 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1371 create_xml(0); |
|
1372 } |
|
1373 |
|
1374 /* when we get the ASYNC_DONE message from a sink, we want the sink to be able |
|
1375 * to report the duration and position. The sink should also have called the |
|
1376 * render method. */ |
|
1377 void test_async_done_eos() |
|
1378 { |
|
1379 GstElement *sink; |
|
1380 GstEvent *event; |
|
1381 GstStateChangeReturn ret; |
|
1382 GstPad *sinkpad; |
|
1383 gboolean res; |
|
1384 GstBus *bus; |
|
1385 GstFormat format; |
|
1386 gint64 position; |
|
1387 gboolean qret; |
|
1388 //xmlfile = "test_deinit"; |
|
1389 std_log(LOG_FILENAME_LINE, "Test Started test_deinit"); |
|
1390 |
|
1391 sink = gst_element_factory_make ("fakesink", "sink"); |
|
1392 g_object_set (G_OBJECT (sink), "sync", TRUE, NULL); |
|
1393 g_object_set (G_OBJECT (sink), "preroll-queue-len", 1, NULL); |
|
1394 |
|
1395 sinkpad = gst_element_get_pad (sink, "sink"); |
|
1396 |
|
1397 ret = gst_element_set_state (sink, GST_STATE_PAUSED); |
|
1398 fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no ASYNC state return"); |
|
1399 |
|
1400 /* set bus on element synchronously listen for ASYNC_DONE */ |
|
1401 bus = gst_bus_new (); |
|
1402 gst_element_set_bus (sink, bus); |
|
1403 gst_bus_set_sync_handler (bus, (GstBusSyncHandler) async_done_eos_func, sink); |
|
1404 |
|
1405 /* make newsegment, this sets the position to 10sec when the buffer prerolls */ |
|
1406 GST_DEBUG ("sending segment"); |
|
1407 event = |
|
1408 gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, |
|
1409 10 * GST_SECOND); |
|
1410 res = gst_pad_send_event (sinkpad, event); |
|
1411 |
|
1412 /* We have not yet received any buffers so we are still in the READY state, |
|
1413 * the position is therefore still not queryable. */ |
|
1414 format = GST_FORMAT_TIME; |
|
1415 position = -1; |
|
1416 qret = gst_element_query_position (sink, &format, &position); |
|
1417 fail_unless (qret == FALSE, "position wrong"); |
|
1418 fail_unless (position == -1, "position is wrong"); |
|
1419 |
|
1420 /* Since we are paused and the preroll queue has a length of 1, this function |
|
1421 * will return immediatly. The EOS will complete the preroll and the |
|
1422 * position should now be 10 seconds. */ |
|
1423 GST_DEBUG ("pushing EOS"); |
|
1424 event = gst_event_new_eos (); |
|
1425 res = gst_pad_send_event (sinkpad, event); |
|
1426 fail_unless (res == TRUE, "no TRUE return"); |
|
1427 |
|
1428 /* check if position is still 10 seconds */ |
|
1429 format = GST_FORMAT_TIME; |
|
1430 gst_element_query_position (sink, &format, &position); |
|
1431 GST_DEBUG ("EOS position %" GST_TIME_FORMAT, GST_TIME_ARGS (position)); |
|
1432 fail_unless (position == 10 * GST_SECOND, "position is wrong"); |
|
1433 |
|
1434 gst_object_unref (sinkpad); |
|
1435 |
|
1436 gst_element_set_state (sink, GST_STATE_NULL); |
|
1437 gst_object_unref (sink); |
|
1438 gst_object_unref (bus); |
|
1439 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1440 create_xml(0); |
|
1441 } |
|
1442 #endif |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 void (*fn[]) (void) = { |
|
1448 test_sink, |
|
1449 test_sink_completion, |
|
1450 test_src_sink, |
|
1451 test_livesrc_remove, |
|
1452 test_locked_sink, |
|
1453 test_unlinked_live, |
|
1454 test_delayed_async, |
|
1455 test_added_async, |
|
1456 test_added_async2, |
|
1457 test_add_live, |
|
1458 test_bin_live |
|
1459 }; |
|
1460 |
|
1461 char *args[] = { |
|
1462 "test_sink", |
|
1463 "test_sink_completion", |
|
1464 "test_src_sink", |
|
1465 "test_livesrc_remove", |
|
1466 "test_locked_sink", |
|
1467 "test_unlinked_live", |
|
1468 "test_delayed_async", |
|
1469 "test_added_async", |
|
1470 "test_added_async2", |
|
1471 "test_add_live", |
|
1472 "test_bin_live" |
|
1473 }; |
|
1474 |
|
1475 GST_CHECK_MAIN (gst_sinks); |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |