|
1 /* GStreamer |
|
2 * |
|
3 * unit test for queue |
|
4 * |
|
5 * Copyright (C) <2006> Stefan Kost <ensonic@users.sf.net> |
|
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 |
|
23 #include <unistd.h> |
|
24 #include <gst/gst_global.h> |
|
25 #include <gst/check/gstcheck.h> |
|
26 #include <glib_global.h> |
|
27 |
|
28 |
|
29 #define LOG_FILE "c:\\logs\\queue_log1.txt" |
|
30 #include "std_log_result.h" |
|
31 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
32 //char* xmlfile = "queue"; |
|
33 |
|
34 void create_xml(int result) |
|
35 { |
|
36 if(result) |
|
37 assert_failed = 1; |
|
38 |
|
39 testResultXml(xmlfile); |
|
40 close_log_file(); |
|
41 } |
|
42 |
|
43 #include "libgstreamer_wsd_solution.h" |
|
44 |
|
45 #if EMULATOR |
|
46 static GET_GLOBAL_VAR_FROM_TLS(buffers,gstcheck,GList*) |
|
47 #define buffers (*GET_GSTREAMER_WSD_VAR_NAME(buffers,gstcheck,g)()) |
|
48 #else |
|
49 extern GList *buffers; |
|
50 #endif |
|
51 |
|
52 |
|
53 #if EMULATOR |
|
54 GET_GLOBAL_VAR_FROM_TLS(check_mutex,gstcheck,GMutex *) |
|
55 #define check_mutex (*GET_GSTREAMER_WSD_VAR_NAME(check_mutex,gstcheck,g)()) |
|
56 #else |
|
57 extern GMutex *check_mutex; |
|
58 #endif |
|
59 |
|
60 |
|
61 #if EMULATOR |
|
62 GET_GLOBAL_VAR_FROM_TLS(check_cond,gstcheck,GCond *) |
|
63 #define check_cond (*GET_GSTREAMER_WSD_VAR_NAME(check_cond,gstcheck,g)()) |
|
64 #else |
|
65 extern GCond *check_cond; |
|
66 #endif |
|
67 |
|
68 //GList *buffers = NULL; |
|
69 static gint overrun_count = 0; |
|
70 static gint underrun_count = 0; |
|
71 |
|
72 /* For ease of programming we use globals to keep refs for our floating |
|
73 * src and sink pads we create; otherwise we always have to do get_pad, |
|
74 * get_peer, and then remove references in every test function */ |
|
75 static GstPad *mysrcpad, *mysinkpad; |
|
76 |
|
77 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", |
|
78 GST_PAD_SINK, |
|
79 GST_PAD_ALWAYS, |
|
80 GST_STATIC_CAPS_ANY); |
|
81 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", |
|
82 GST_PAD_SRC, |
|
83 GST_PAD_ALWAYS, |
|
84 GST_STATIC_CAPS_ANY); |
|
85 |
|
86 static void |
|
87 queue_overrun (GstElement * queue, gpointer user_data) |
|
88 { |
|
89 GST_DEBUG ("queue overrun"); |
|
90 overrun_count++; |
|
91 } |
|
92 |
|
93 static void |
|
94 queue_underrun (GstElement * queue, gpointer user_data) |
|
95 { |
|
96 GST_DEBUG ("queue underrun"); |
|
97 g_mutex_lock (check_mutex); |
|
98 underrun_count++; |
|
99 g_cond_signal (check_cond); |
|
100 g_mutex_unlock (check_mutex); |
|
101 /// block this thread to wait to push some buffers in main thread. |
|
102 sleep(2); |
|
103 } |
|
104 |
|
105 static GstElement * |
|
106 setup_queue (void) |
|
107 { |
|
108 GstElement *queue; |
|
109 |
|
110 GST_DEBUG ("setup_queue"); |
|
111 |
|
112 overrun_count = 0; |
|
113 underrun_count = 0; |
|
114 |
|
115 queue = gst_check_setup_element ("queue"); |
|
116 g_signal_connect (queue, "overrun", G_CALLBACK (queue_overrun), NULL); |
|
117 g_signal_connect (queue, "underrun", G_CALLBACK (queue_underrun), NULL); |
|
118 |
|
119 return queue; |
|
120 } |
|
121 |
|
122 static void |
|
123 cleanup_queue (GstElement * queue) |
|
124 { |
|
125 GST_DEBUG ("cleanup_queue"); |
|
126 |
|
127 gst_check_teardown_element (queue); |
|
128 } |
|
129 |
|
130 /* set queue size to 2 buffers |
|
131 * pull 1 buffer |
|
132 * check over/underuns |
|
133 */ |
|
134 void test_non_leaky_underrun() |
|
135 { |
|
136 GstElement *queue; |
|
137 GstBuffer *buffer = NULL; |
|
138 |
|
139 xmlfile = "queue_test_non_leaky_underrun"; |
|
140 std_log(LOG_FILENAME_LINE, "Test Started test_non_leaky_underrun"); |
|
141 |
|
142 queue = setup_queue (); |
|
143 mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate, NULL); |
|
144 gst_pad_set_active (mysinkpad, TRUE); |
|
145 g_object_set (G_OBJECT (queue), "max-size-buffers", 2, NULL); |
|
146 |
|
147 GST_DEBUG ("starting"); |
|
148 |
|
149 g_mutex_lock (check_mutex); |
|
150 fail_unless (gst_element_set_state (queue, |
|
151 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, |
|
152 "could not set to playing"); |
|
153 TEST_ASSERT_FAIL |
|
154 g_cond_wait (check_cond, check_mutex); |
|
155 g_mutex_unlock (check_mutex); |
|
156 |
|
157 fail_unless (overrun_count == 0); |
|
158 TEST_ASSERT_FAIL |
|
159 fail_unless (underrun_count == 1); |
|
160 TEST_ASSERT_FAIL |
|
161 |
|
162 fail_unless (buffer == NULL); |
|
163 TEST_ASSERT_FAIL |
|
164 |
|
165 GST_DEBUG ("stopping"); |
|
166 |
|
167 /* cleanup */ |
|
168 gst_pad_set_active (mysinkpad, FALSE); |
|
169 gst_check_teardown_sink_pad (queue); |
|
170 cleanup_queue (queue); |
|
171 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
172 create_xml(0); |
|
173 } |
|
174 |
|
175 |
|
176 /* set queue size to 2 buffers |
|
177 * push 2 buffers |
|
178 * check over/underuns |
|
179 * push 1 more buffer |
|
180 * check over/underuns again |
|
181 */ |
|
182 void test_non_leaky_overrun() |
|
183 { |
|
184 GstElement *queue; |
|
185 GstBuffer *buffer1, *buffer2, *buffer3; |
|
186 |
|
187 xmlfile = "queue_test_non_leaky_overrun"; |
|
188 std_log(LOG_FILENAME_LINE, "Test Started test_non_leaky_overrun"); |
|
189 |
|
190 queue = setup_queue (); |
|
191 mysrcpad = gst_check_setup_src_pad (queue, &srctemplate, NULL); |
|
192 mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate, NULL); |
|
193 gst_pad_set_active (mysrcpad, TRUE); |
|
194 g_object_set (G_OBJECT (queue), "max-size-buffers", 2, NULL); |
|
195 |
|
196 GST_DEBUG ("starting"); |
|
197 |
|
198 g_mutex_lock (check_mutex); |
|
199 fail_unless (gst_element_set_state (queue, |
|
200 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, |
|
201 "could not set to playing"); |
|
202 TEST_ASSERT_FAIL |
|
203 /// wait for under run callback |
|
204 g_cond_wait (check_cond, check_mutex); |
|
205 g_mutex_unlock (check_mutex); |
|
206 /// no buffer pushed, under run has to come, so make it zero |
|
207 underrun_count = 0; |
|
208 |
|
209 buffer1 = gst_buffer_new_and_alloc (4); |
|
210 ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1); |
|
211 TEST_ASSERT_FAIL |
|
212 /* pushing gives away my reference ... */ |
|
213 gst_pad_push (mysrcpad, buffer1); |
|
214 |
|
215 GST_DEBUG ("added 1st"); |
|
216 fail_unless (overrun_count == 0); |
|
217 TEST_ASSERT_FAIL |
|
218 fail_unless (underrun_count == 0); |
|
219 TEST_ASSERT_FAIL |
|
220 |
|
221 buffer2 = gst_buffer_new_and_alloc (4); |
|
222 ASSERT_BUFFER_REFCOUNT (buffer2, "buffer", 1); |
|
223 TEST_ASSERT_FAIL |
|
224 /* pushing gives away my reference ... */ |
|
225 gst_pad_push (mysrcpad, buffer2); |
|
226 |
|
227 GST_DEBUG ("added 2nd"); |
|
228 fail_unless (overrun_count == 0); |
|
229 TEST_ASSERT_FAIL |
|
230 fail_unless (underrun_count == 0); |
|
231 TEST_ASSERT_FAIL |
|
232 |
|
233 buffer3 = gst_buffer_new_and_alloc (4); |
|
234 ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1); |
|
235 TEST_ASSERT_FAIL |
|
236 /* pushing gives away my reference ... */ |
|
237 gst_pad_push (mysrcpad, buffer3); |
|
238 |
|
239 GST_DEBUG ("stopping"); |
|
240 |
|
241 fail_unless (overrun_count == 1); |
|
242 TEST_ASSERT_FAIL |
|
243 fail_unless (underrun_count == 0); |
|
244 TEST_ASSERT_FAIL |
|
245 |
|
246 /* cleanup */ |
|
247 gst_pad_set_active (mysrcpad, FALSE); |
|
248 gst_check_teardown_src_pad (queue); |
|
249 gst_check_teardown_sink_pad (queue); |
|
250 cleanup_queue (queue); |
|
251 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
252 create_xml(0); |
|
253 |
|
254 } |
|
255 |
|
256 /* set queue size to 2 buffers |
|
257 * push 2 buffers |
|
258 * check over/underuns |
|
259 * push 1 more buffer |
|
260 * check over/underuns again |
|
261 * check which buffer was leaked |
|
262 */ |
|
263 void test_leaky_upstream() |
|
264 { |
|
265 GstElement *queue; |
|
266 GstBuffer *buffer1, *buffer2, *buffer3; |
|
267 GstBuffer *buffer; |
|
268 |
|
269 xmlfile = "queue_test_leaky_upstream"; |
|
270 std_log(LOG_FILENAME_LINE, "Test Started test_leaky_upstream"); |
|
271 queue = setup_queue (); |
|
272 mysrcpad = gst_check_setup_src_pad (queue, &srctemplate, NULL); |
|
273 mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate, NULL); |
|
274 g_object_set (G_OBJECT (queue), "max-size-buffers", 2, "leaky", 1, NULL); |
|
275 gst_pad_set_active (mysrcpad, TRUE); |
|
276 |
|
277 GST_DEBUG ("starting"); |
|
278 |
|
279 g_mutex_lock (check_mutex); |
|
280 fail_unless (gst_element_set_state (queue, |
|
281 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, |
|
282 "could not set to playing"); |
|
283 TEST_ASSERT_FAIL |
|
284 g_cond_wait (check_cond, check_mutex); |
|
285 g_mutex_unlock (check_mutex); |
|
286 underrun_count = 0; |
|
287 |
|
288 buffer1 = gst_buffer_new_and_alloc (4); |
|
289 ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1); |
|
290 TEST_ASSERT_FAIL |
|
291 /* pushing gives away my reference ... */ |
|
292 gst_pad_push (mysrcpad, buffer1); |
|
293 |
|
294 GST_DEBUG ("added 1st"); |
|
295 fail_unless (overrun_count == 0); |
|
296 TEST_ASSERT_FAIL |
|
297 fail_unless (underrun_count == 0); |
|
298 TEST_ASSERT_FAIL |
|
299 |
|
300 buffer2 = gst_buffer_new_and_alloc (4); |
|
301 ASSERT_BUFFER_REFCOUNT (buffer2, "buffer", 1); |
|
302 TEST_ASSERT_FAIL |
|
303 /* pushing gives away my reference ... */ |
|
304 gst_pad_push (mysrcpad, buffer2); |
|
305 |
|
306 GST_DEBUG ("added 2nd"); |
|
307 fail_unless (overrun_count == 0); |
|
308 TEST_ASSERT_FAIL |
|
309 fail_unless (underrun_count == 0); |
|
310 TEST_ASSERT_FAIL |
|
311 |
|
312 buffer3 = gst_buffer_new_and_alloc (4); |
|
313 ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1); |
|
314 TEST_ASSERT_FAIL |
|
315 /* pushing gives away my reference ... */ |
|
316 gst_pad_push (mysrcpad, gst_buffer_ref (buffer3)); |
|
317 |
|
318 g_mutex_lock (check_mutex); |
|
319 /* start the src-task briefly leak buffer3 */ |
|
320 gst_pad_set_active (mysinkpad, TRUE); |
|
321 g_cond_wait (check_cond, check_mutex); |
|
322 g_mutex_unlock (check_mutex); |
|
323 |
|
324 gst_pad_set_active (mysinkpad, FALSE); |
|
325 |
|
326 GST_DEBUG ("stopping"); |
|
327 |
|
328 fail_unless (g_list_length (buffers) > 0); |
|
329 TEST_ASSERT_FAIL |
|
330 buffer = g_list_first (buffers)->data; |
|
331 fail_unless (buffer == buffer1); |
|
332 TEST_ASSERT_FAIL |
|
333 ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1); |
|
334 TEST_ASSERT_FAIL |
|
335 |
|
336 /* it still triggers overrun when leaking */ |
|
337 fail_unless (overrun_count == 1); |
|
338 TEST_ASSERT_FAIL |
|
339 /* cleanup */ |
|
340 gst_pad_set_active (mysrcpad, FALSE); |
|
341 gst_buffer_unref (buffer3); |
|
342 gst_check_teardown_src_pad (queue); |
|
343 gst_check_teardown_sink_pad (queue); |
|
344 cleanup_queue (queue); |
|
345 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
346 create_xml(0); |
|
347 } |
|
348 |
|
349 |
|
350 void test_leaky_downstream() |
|
351 { |
|
352 GstElement *queue; |
|
353 GstBuffer *buffer1, *buffer2, *buffer3; |
|
354 GstBuffer *buffer; |
|
355 |
|
356 xmlfile = "queue_test_leaky_downstream"; |
|
357 std_log(LOG_FILENAME_LINE, "Test Started test_leaky_downstream"); |
|
358 |
|
359 queue = setup_queue (); |
|
360 mysrcpad = gst_check_setup_src_pad (queue, &srctemplate, NULL); |
|
361 mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate, NULL); |
|
362 g_object_set (G_OBJECT (queue), "max-size-buffers", 2, "leaky", 2, NULL); |
|
363 gst_pad_set_active (mysrcpad, TRUE); |
|
364 |
|
365 GST_DEBUG ("starting"); |
|
366 |
|
367 g_mutex_lock (check_mutex); |
|
368 fail_unless (gst_element_set_state (queue, |
|
369 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, |
|
370 "could not set to playing"); |
|
371 TEST_ASSERT_FAIL |
|
372 g_cond_wait (check_cond, check_mutex); |
|
373 g_mutex_unlock (check_mutex); |
|
374 underrun_count = 0; |
|
375 |
|
376 buffer1 = gst_buffer_new_and_alloc (4); |
|
377 ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1); |
|
378 TEST_ASSERT_FAIL |
|
379 |
|
380 |
|
381 |
|
382 /* pushing gives away my reference ... */ |
|
383 gst_pad_push (mysrcpad, gst_buffer_ref (buffer1)); |
|
384 |
|
385 GST_DEBUG ("added 1st"); |
|
386 fail_unless (overrun_count == 0); |
|
387 TEST_ASSERT_FAIL |
|
388 fail_unless (underrun_count == 0); |
|
389 TEST_ASSERT_FAIL |
|
390 |
|
391 buffer2 = gst_buffer_new_and_alloc (4); |
|
392 ASSERT_BUFFER_REFCOUNT (buffer2, "buffer", 1); |
|
393 TEST_ASSERT_FAIL |
|
394 /* pushing gives away my reference ... */ |
|
395 gst_pad_push (mysrcpad, buffer2); |
|
396 |
|
397 GST_DEBUG ("added 2nd"); |
|
398 fail_unless (overrun_count == 0); |
|
399 TEST_ASSERT_FAIL |
|
400 fail_unless (underrun_count == 0); |
|
401 TEST_ASSERT_FAIL |
|
402 |
|
403 buffer3 = gst_buffer_new_and_alloc (4); |
|
404 ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1); |
|
405 TEST_ASSERT_FAIL |
|
406 /* pushing gives away my reference ... */ |
|
407 gst_pad_push (mysrcpad, buffer3); |
|
408 |
|
409 g_mutex_lock (check_mutex); |
|
410 /* start the src-task briefly and leak buffer1 */ |
|
411 gst_pad_set_active (mysinkpad, TRUE); |
|
412 g_cond_wait (check_cond, check_mutex); |
|
413 g_mutex_unlock (check_mutex); |
|
414 |
|
415 gst_pad_set_active (mysinkpad, FALSE); |
|
416 |
|
417 GST_DEBUG ("stopping"); |
|
418 |
|
419 fail_unless (g_list_length (buffers) > 0); |
|
420 TEST_ASSERT_FAIL |
|
421 buffer = g_list_first (buffers)->data; |
|
422 fail_unless (buffer == buffer2); |
|
423 TEST_ASSERT_FAIL |
|
424 ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1); |
|
425 TEST_ASSERT_FAIL |
|
426 |
|
427 /* it still triggers overrun when leaking */ |
|
428 fail_unless (overrun_count == 1); |
|
429 TEST_ASSERT_FAIL |
|
430 /* cleanup */ |
|
431 gst_pad_set_active (mysrcpad, FALSE); |
|
432 gst_buffer_unref (buffer1); |
|
433 gst_check_teardown_src_pad (queue); |
|
434 gst_check_teardown_sink_pad (queue); |
|
435 cleanup_queue (queue); |
|
436 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
437 create_xml(0); |
|
438 } |
|
439 |
|
440 /* set queue size to 5 buffers |
|
441 * pull 1 buffer |
|
442 * check over/underuns |
|
443 */ |
|
444 void test_time_level() |
|
445 { |
|
446 GstElement *queue; |
|
447 GstBuffer *buffer = NULL; |
|
448 GstClockTime time; |
|
449 |
|
450 xmlfile = "queue_test_time_level"; |
|
451 std_log(LOG_FILENAME_LINE, "Test Started test_time_level"); |
|
452 |
|
453 queue = setup_queue (); |
|
454 mysrcpad = gst_check_setup_src_pad (queue, &srctemplate, NULL); |
|
455 mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate, NULL); |
|
456 g_object_set (G_OBJECT (queue), "max-size-buffers", 6, NULL); |
|
457 g_object_set (G_OBJECT (queue), "max-size-time", 10 * GST_SECOND, NULL); |
|
458 gst_pad_set_active (mysrcpad, TRUE); |
|
459 gst_pad_set_active (mysinkpad, TRUE); |
|
460 |
|
461 GST_DEBUG ("starting"); |
|
462 |
|
463 fail_unless (gst_element_set_state (queue, |
|
464 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, |
|
465 "could not set to playing"); |
|
466 TEST_ASSERT_FAIL |
|
467 |
|
468 /* push buffer without duration */ |
|
469 buffer = gst_buffer_new_and_alloc (4); |
|
470 GST_BUFFER_TIMESTAMP (buffer) = GST_SECOND; |
|
471 ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); |
|
472 TEST_ASSERT_FAIL |
|
473 /* pushing gives away my reference ... */ |
|
474 gst_pad_push (mysrcpad, buffer); |
|
475 |
|
476 /* level should be 1 seconds because buffer has no duration and starts at 1 |
|
477 * SECOND (sparse stream). */ |
|
478 g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL); |
|
479 fail_if (time != GST_SECOND); |
|
480 TEST_ASSERT_FAIL |
|
481 /* second push should set the level to 2 second */ |
|
482 buffer = gst_buffer_new_and_alloc (4); |
|
483 GST_BUFFER_TIMESTAMP (buffer) = 2 * GST_SECOND; |
|
484 ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); |
|
485 TEST_ASSERT_FAIL |
|
486 /* pushing gives away my reference ... */ |
|
487 gst_pad_push (mysrcpad, buffer); |
|
488 |
|
489 g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL); |
|
490 fail_if (time != 2 * GST_SECOND); |
|
491 TEST_ASSERT_FAIL |
|
492 |
|
493 /* third push should set the level to 4 seconds, the 1 second diff with the |
|
494 * previous buffer (without duration) and the 1 second duration of this |
|
495 * buffer. */ |
|
496 buffer = gst_buffer_new_and_alloc (4); |
|
497 GST_BUFFER_TIMESTAMP (buffer) = 3 * GST_SECOND; |
|
498 GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND; |
|
499 ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); |
|
500 TEST_ASSERT_FAIL |
|
501 /* pushing gives away my reference ... */ |
|
502 gst_pad_push (mysrcpad, buffer); |
|
503 |
|
504 g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL); |
|
505 fail_if (time != 4 * GST_SECOND); |
|
506 TEST_ASSERT_FAIL |
|
507 |
|
508 /* fourth push should set the level to 6 seconds, the 2 second diff with the |
|
509 * previous buffer, same duration. */ |
|
510 buffer = gst_buffer_new_and_alloc (4); |
|
511 GST_BUFFER_TIMESTAMP (buffer) = 5 * GST_SECOND; |
|
512 GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND; |
|
513 ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); |
|
514 TEST_ASSERT_FAIL |
|
515 /* pushing gives away my reference ... */ |
|
516 gst_pad_push (mysrcpad, buffer); |
|
517 |
|
518 g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL); |
|
519 fail_if (time != 6 * GST_SECOND); |
|
520 TEST_ASSERT_FAIL |
|
521 |
|
522 /* fifth push should not adjust the level, the timestamp and duration are the |
|
523 * same, meaning the previous buffer did not really have a duration. */ |
|
524 buffer = gst_buffer_new_and_alloc (4); |
|
525 GST_BUFFER_TIMESTAMP (buffer) = 5 * GST_SECOND; |
|
526 GST_BUFFER_DURATION (buffer) = 1 * GST_SECOND; |
|
527 ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); |
|
528 TEST_ASSERT_FAIL |
|
529 /* pushing gives away my reference ... */ |
|
530 gst_pad_push (mysrcpad, buffer); |
|
531 |
|
532 g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL); |
|
533 fail_if (time != 6 * GST_SECOND); |
|
534 TEST_ASSERT_FAIL |
|
535 |
|
536 /* sixth push should adjust the level with 1 second, we now know the |
|
537 * previous buffer actually had a duration of 2 SECONDS */ |
|
538 buffer = gst_buffer_new_and_alloc (4); |
|
539 GST_BUFFER_TIMESTAMP (buffer) = 7 * GST_SECOND; |
|
540 ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); |
|
541 TEST_ASSERT_FAIL |
|
542 /* pushing gives away my reference ... */ |
|
543 gst_pad_push (mysrcpad, buffer); |
|
544 |
|
545 g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL); |
|
546 fail_if (time != 7 * GST_SECOND); |
|
547 TEST_ASSERT_FAIL |
|
548 |
|
549 GST_DEBUG ("stopping"); |
|
550 |
|
551 /* cleanup */ |
|
552 gst_pad_set_active (mysinkpad, FALSE); |
|
553 gst_check_teardown_sink_pad (queue); |
|
554 cleanup_queue (queue); |
|
555 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
556 create_xml(0); |
|
557 } |
|
558 |
|
559 //static Suite * |
|
560 //queue_suite (void) |
|
561 //{ |
|
562 // Suite *s = suite_create ("queue"); |
|
563 // TCase *tc_chain = tcase_create ("general"); |
|
564 // |
|
565 // suite_add_tcase (s, tc_chain); |
|
566 // tcase_add_test (tc_chain, test_non_leaky_underrun); |
|
567 // tcase_add_test (tc_chain, test_non_leaky_overrun); |
|
568 // tcase_add_test (tc_chain, test_leaky_upstream); |
|
569 // tcase_add_test (tc_chain, test_leaky_downstream); |
|
570 // tcase_add_test (tc_chain, test_time_level); |
|
571 // |
|
572 // return s; |
|
573 //} |
|
574 |
|
575 void (*fn[]) (void) = { |
|
576 test_non_leaky_underrun, |
|
577 test_non_leaky_overrun, |
|
578 test_leaky_upstream, |
|
579 test_leaky_downstream, |
|
580 test_time_level |
|
581 }; |
|
582 |
|
583 char *args[] = { |
|
584 "test_non_leaky_underrun", |
|
585 "test_non_leaky_overrun", |
|
586 "test_leaky_upstream", |
|
587 "test_leaky_downstream", |
|
588 "test_time_level" |
|
589 }; |
|
590 |
|
591 GST_CHECK_MAIN (queue); |