|
1 /* |
|
2 * Copyright © 2008 Nokia Corporation. |
|
3 * This material, including documentation and any related |
|
4 * computer programs, is protected by copyright controlled by |
|
5 * Nokia Corporation. All rights are reserved. Copying, |
|
6 * including reproducing, storing, adapting or translating, any |
|
7 * or all of this material requires the prior written consent of |
|
8 * Nokia Corporation. This material also contains confidential |
|
9 * information which may not be disclosed to others without the |
|
10 * prior written consent of Nokia Corporation. |
|
11 * ============================================================================ |
|
12 */ |
|
13 |
|
14 /* GStreamer |
|
15 * Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com> |
|
16 * |
|
17 * gstsegment.c: Unit test for segments |
|
18 * |
|
19 * This library is free software; you can redistribute it and/or |
|
20 * modify it under the terms of the GNU Library General Public |
|
21 * License as published by the Free Software Foundation; either |
|
22 * version 2 of the License, or (at your option) any later version. |
|
23 * |
|
24 * This library is distributed in the hope that it will be useful, |
|
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
27 * Library General Public License for more details. |
|
28 * |
|
29 * You should have received a copy of the GNU Library General Public |
|
30 * License along with this library; if not, write to the |
|
31 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
32 * Boston, MA 02111-1307, USA. |
|
33 */ |
|
34 |
|
35 |
|
36 #include <gst/gst_global.h> |
|
37 #include <gst/check/gstcheck.h> |
|
38 |
|
39 #define LOG_FILE "c:\\logs\\gstsegment_logs.txt" |
|
40 #include "std_log_result.h" |
|
41 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
42 |
|
43 |
|
44 #if EMULATOR |
|
45 static GET_GLOBAL_VAR_FROM_TLS(raised_critical,gstcheck,gboolean) |
|
46 #define _gst_check_raised_critical (*GET_GSTREAMER_WSD_VAR_NAME(raised_critical,gstcheck,g)()) |
|
47 #else |
|
48 extern gboolean _gst_check_raised_critical; |
|
49 #endif |
|
50 |
|
51 //gboolean _gst_check_expecting_log = FALSE; |
|
52 #if EMULATOR |
|
53 static GET_GLOBAL_VAR_FROM_TLS(expecting_log,gstcheck,gboolean) |
|
54 #define _gst_check_expecting_log (*GET_GSTREAMER_WSD_VAR_NAME(expecting_log,gstcheck,g)()) |
|
55 #else |
|
56 extern gboolean _gst_check_expecting_log; |
|
57 #endif |
|
58 |
|
59 |
|
60 //char* xmlfile = "gstsegment"; |
|
61 |
|
62 void create_xml(int result) |
|
63 { |
|
64 if(result) |
|
65 assert_failed = 1; |
|
66 |
|
67 testResultXml(xmlfile); |
|
68 close_log_file(); |
|
69 } |
|
70 |
|
71 void segment_seek_nosize() |
|
72 { |
|
73 GstSegment segment; |
|
74 gboolean res; |
|
75 gint64 cstart, cstop; |
|
76 gboolean update; |
|
77 |
|
78 xmlfile = "segment_seek_nosize"; |
|
79 std_log(LOG_FILENAME_LINE, "Test Started segment_seek_nosize"); |
|
80 |
|
81 gst_segment_init (&segment, GST_FORMAT_BYTES); |
|
82 |
|
83 /* configure segment to start 100 */ |
|
84 gst_segment_set_seek (&segment, 1.0, |
|
85 GST_FORMAT_BYTES, |
|
86 GST_SEEK_FLAG_NONE, |
|
87 GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update); |
|
88 fail_unless (segment.start == 100); |
|
89 fail_unless (segment.stop == -1); |
|
90 fail_unless (update == TRUE); |
|
91 |
|
92 /* configure segment to stop relative, should not do anything since |
|
93 * size is unknown. */ |
|
94 gst_segment_set_seek (&segment, 1.0, |
|
95 GST_FORMAT_BYTES, |
|
96 GST_SEEK_FLAG_NONE, |
|
97 GST_SEEK_TYPE_NONE, 200, GST_SEEK_TYPE_CUR, -100, &update); |
|
98 fail_unless (segment.start == 100); |
|
99 fail_unless (segment.stop == -1); |
|
100 fail_unless (update == FALSE); |
|
101 |
|
102 /* do some clipping on the open range */ |
|
103 /* completely outside */ |
|
104 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop); |
|
105 fail_unless (res == FALSE); |
|
106 |
|
107 /* touching lower bound, still outside of the segment */ |
|
108 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop); |
|
109 fail_unless (res == FALSE); |
|
110 |
|
111 /* partially inside */ |
|
112 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 150, &cstart, &cstop); |
|
113 fail_unless (res == TRUE); |
|
114 fail_unless (cstart == 100); |
|
115 fail_unless (cstop == 150); |
|
116 |
|
117 /* inside, touching lower bound */ |
|
118 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
119 100, 150, &cstart, &cstop); |
|
120 fail_unless (res == TRUE); |
|
121 fail_unless (cstart == 100); |
|
122 fail_unless (cstop == 150); |
|
123 |
|
124 /* special case, 0 duration */ |
|
125 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
126 100, 100, &cstart, &cstop); |
|
127 fail_unless (res == TRUE); |
|
128 fail_unless (cstart == 100); |
|
129 fail_unless (cstop == 100); |
|
130 |
|
131 /* completely inside */ |
|
132 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
133 150, 200, &cstart, &cstop); |
|
134 fail_unless (res == TRUE); |
|
135 fail_unless (cstart == 150); |
|
136 fail_unless (cstop == 200); |
|
137 |
|
138 /* invalid start */ |
|
139 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &cstart, &cstop); |
|
140 fail_unless (res == FALSE); |
|
141 |
|
142 /* start outside, we don't know the stop */ |
|
143 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, -1, &cstart, &cstop); |
|
144 fail_unless (res == TRUE); |
|
145 fail_unless (cstart == 100); |
|
146 fail_unless (cstop == -1); |
|
147 |
|
148 /* start on lower bound */ |
|
149 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 100, -1, &cstart, &cstop); |
|
150 fail_unless (res == TRUE); |
|
151 fail_unless (cstart == 100); |
|
152 fail_unless (cstop == -1); |
|
153 |
|
154 /* start inside */ |
|
155 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 150, -1, &cstart, &cstop); |
|
156 fail_unless (res == TRUE); |
|
157 fail_unless (cstart == 150); |
|
158 fail_unless (cstop == -1); |
|
159 |
|
160 /* add 100 to start, set stop to 300 */ |
|
161 gst_segment_set_seek (&segment, 1.0, |
|
162 GST_FORMAT_BYTES, |
|
163 GST_SEEK_FLAG_NONE, |
|
164 GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 300, &update); |
|
165 fail_unless (segment.start == 200); |
|
166 fail_unless (segment.stop == 300); |
|
167 fail_unless (update == TRUE); |
|
168 |
|
169 update = FALSE; |
|
170 /* add 100 to start (to 300), set stop to 200, this is not allowed. |
|
171 * nothing should be updated in the segment. A g_warning is |
|
172 * emited. */ |
|
173 ASSERT_CRITICAL(gst_segment_set_seek (&segment, 1.0, |
|
174 GST_FORMAT_BYTES, |
|
175 GST_SEEK_FLAG_NONE, |
|
176 GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 200, &update)); |
|
177 |
|
178 fail_unless (segment.start == 200); |
|
179 fail_unless (segment.stop == 300); |
|
180 /* update didn't change */ |
|
181 fail_unless (update == FALSE); |
|
182 |
|
183 update = TRUE; |
|
184 /* seek relative to end, should not do anything since size is |
|
185 * unknown. */ |
|
186 gst_segment_set_seek (&segment, 1.0, |
|
187 GST_FORMAT_BYTES, |
|
188 GST_SEEK_FLAG_NONE, |
|
189 GST_SEEK_TYPE_END, -300, GST_SEEK_TYPE_END, -100, &update); |
|
190 fail_unless (segment.start == 200); |
|
191 fail_unless (segment.stop == 300); |
|
192 fail_unless (update == FALSE); |
|
193 |
|
194 /* completely outside */ |
|
195 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop); |
|
196 fail_unless (res == FALSE); |
|
197 |
|
198 /* touching lower bound */ |
|
199 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 200, &cstart, &cstop); |
|
200 fail_unless (res == FALSE); |
|
201 |
|
202 /* partially inside */ |
|
203 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 250, &cstart, &cstop); |
|
204 fail_unless (res == TRUE); |
|
205 fail_unless (cstart == 200); |
|
206 fail_unless (cstop == 250); |
|
207 |
|
208 /* inside, touching lower bound */ |
|
209 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
210 200, 250, &cstart, &cstop); |
|
211 fail_unless (res == TRUE); |
|
212 fail_unless (cstart == 200); |
|
213 fail_unless (cstop == 250); |
|
214 |
|
215 /* completely inside */ |
|
216 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
217 250, 290, &cstart, &cstop); |
|
218 fail_unless (res == TRUE); |
|
219 fail_unless (cstart == 250); |
|
220 fail_unless (cstop == 290); |
|
221 |
|
222 /* partially inside */ |
|
223 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
224 250, 350, &cstart, &cstop); |
|
225 fail_unless (res == TRUE); |
|
226 fail_unless (cstart == 250); |
|
227 fail_unless (cstop == 300); |
|
228 |
|
229 /* invalid start */ |
|
230 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &cstart, &cstop); |
|
231 fail_unless (res == FALSE); |
|
232 |
|
233 /* start outside */ |
|
234 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, -1, &cstart, &cstop); |
|
235 fail_unless (res == TRUE); |
|
236 fail_unless (cstart == 200); |
|
237 fail_unless (cstop == 300); |
|
238 |
|
239 /* start on lower bound */ |
|
240 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 200, -1, &cstart, &cstop); |
|
241 fail_unless (res == TRUE); |
|
242 fail_unless (cstart == 200); |
|
243 fail_unless (cstop == 300); |
|
244 |
|
245 /* start inside */ |
|
246 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 250, -1, &cstart, &cstop); |
|
247 fail_unless (res == TRUE); |
|
248 fail_unless (cstart == 250); |
|
249 fail_unless (cstop == 300); |
|
250 |
|
251 /* start outside on boundary */ |
|
252 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 300, -1, &cstart, &cstop); |
|
253 fail_unless (res == FALSE); |
|
254 |
|
255 /* start completely outside */ |
|
256 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 350, -1, &cstart, &cstop); |
|
257 fail_unless (res == FALSE); |
|
258 |
|
259 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
260 create_xml(0); |
|
261 } |
|
262 |
|
263 |
|
264 /* mess with the segment structure in the bytes format */ |
|
265 void segment_seek_size() |
|
266 { |
|
267 GstSegment segment; |
|
268 gboolean res; |
|
269 gint64 cstart, cstop; |
|
270 gboolean update; |
|
271 |
|
272 xmlfile = "segment_seek_size"; |
|
273 std_log(LOG_FILENAME_LINE, "Test Started segment_seek_size"); |
|
274 |
|
275 gst_segment_init (&segment, GST_FORMAT_BYTES); |
|
276 gst_segment_set_duration (&segment, GST_FORMAT_BYTES, 200); |
|
277 |
|
278 /* configure segment to start 100 */ |
|
279 gst_segment_set_seek (&segment, 1.0, |
|
280 GST_FORMAT_BYTES, |
|
281 GST_SEEK_FLAG_NONE, |
|
282 GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update); |
|
283 fail_unless (segment.start == 100); |
|
284 fail_unless (segment.stop == -1); |
|
285 fail_unless (update == TRUE); |
|
286 |
|
287 /* configure segment to stop relative, does not update stop |
|
288 * since we did not set it before. */ |
|
289 gst_segment_set_seek (&segment, 1.0, |
|
290 GST_FORMAT_BYTES, |
|
291 GST_SEEK_FLAG_NONE, |
|
292 GST_SEEK_TYPE_NONE, 200, GST_SEEK_TYPE_CUR, -100, &update); |
|
293 fail_unless (segment.start == 100); |
|
294 fail_unless (segment.stop == -1); |
|
295 fail_unless (update == FALSE); |
|
296 |
|
297 /* do some clipping on the open range */ |
|
298 /* completely outside */ |
|
299 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop); |
|
300 fail_unless (res == FALSE); |
|
301 |
|
302 /* touching lower bound */ |
|
303 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop); |
|
304 fail_unless (res == FALSE); |
|
305 |
|
306 /* partially inside */ |
|
307 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 150, &cstart, &cstop); |
|
308 fail_unless (res == TRUE); |
|
309 fail_unless (cstart == 100); |
|
310 fail_unless (cstop == 150); |
|
311 |
|
312 /* inside, touching lower bound */ |
|
313 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
314 100, 150, &cstart, &cstop); |
|
315 fail_unless (res == TRUE); |
|
316 fail_unless (cstart == 100); |
|
317 fail_unless (cstop == 150); |
|
318 |
|
319 /* completely inside */ |
|
320 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
321 150, 200, &cstart, &cstop); |
|
322 fail_unless (res == TRUE); |
|
323 fail_unless (cstart == 150); |
|
324 fail_unless (cstop == 200); |
|
325 |
|
326 /* partially inside, clip to size */ |
|
327 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
328 150, 300, &cstart, &cstop); |
|
329 fail_unless (res == TRUE); |
|
330 fail_unless (cstart == 150); |
|
331 fail_unless (cstop == 200); |
|
332 |
|
333 /* invalid start */ |
|
334 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &cstart, &cstop); |
|
335 fail_unless (res == FALSE); |
|
336 |
|
337 /* start outside */ |
|
338 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, -1, &cstart, &cstop); |
|
339 fail_unless (res == TRUE); |
|
340 fail_unless (cstart == 100); |
|
341 fail_unless (cstop == -1); |
|
342 |
|
343 /* start on lower bound */ |
|
344 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 100, -1, &cstart, &cstop); |
|
345 fail_unless (res == TRUE); |
|
346 fail_unless (cstart == 100); |
|
347 fail_unless (cstop == -1); |
|
348 |
|
349 /* start inside */ |
|
350 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 150, -1, &cstart, &cstop); |
|
351 fail_unless (res == TRUE); |
|
352 fail_unless (cstart == 150); |
|
353 fail_unless (cstop == -1); |
|
354 |
|
355 /* add 100 to start, set stop to 300, stop clips to 200 */ |
|
356 gst_segment_set_seek (&segment, 1.0, |
|
357 GST_FORMAT_BYTES, |
|
358 GST_SEEK_FLAG_NONE, |
|
359 GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 300, &update); |
|
360 fail_unless (segment.start == 200); |
|
361 fail_unless (segment.stop == 200); |
|
362 |
|
363 /* add 100 to start (to 300), set stop to 200, this clips start |
|
364 * to duration */ |
|
365 gst_segment_set_seek (&segment, 1.0, |
|
366 GST_FORMAT_BYTES, |
|
367 GST_SEEK_FLAG_NONE, |
|
368 GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 200, &update); |
|
369 fail_unless (segment.start == 200); |
|
370 fail_unless (segment.stop == 200); |
|
371 fail_unless (update == FALSE); |
|
372 |
|
373 /* seek relative to end */ |
|
374 gst_segment_set_seek (&segment, 1.0, |
|
375 GST_FORMAT_BYTES, |
|
376 GST_SEEK_FLAG_NONE, |
|
377 GST_SEEK_TYPE_END, -100, GST_SEEK_TYPE_END, -20, &update); |
|
378 fail_unless (segment.start == 100); |
|
379 fail_unless (segment.stop == 180); |
|
380 fail_unless (update == TRUE); |
|
381 |
|
382 /* completely outside */ |
|
383 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 0, 50, &cstart, &cstop); |
|
384 fail_unless (res == FALSE); |
|
385 |
|
386 /* touching lower bound */ |
|
387 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop); |
|
388 fail_unless (res == FALSE); |
|
389 |
|
390 /* partially inside */ |
|
391 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 150, &cstart, &cstop); |
|
392 fail_unless (res == TRUE); |
|
393 fail_unless (cstart == 100); |
|
394 fail_unless (cstop == 150); |
|
395 |
|
396 /* inside, touching lower bound */ |
|
397 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
398 100, 150, &cstart, &cstop); |
|
399 fail_unless (res == TRUE); |
|
400 fail_unless (cstart == 100); |
|
401 fail_unless (cstop == 150); |
|
402 |
|
403 /* completely inside */ |
|
404 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
405 150, 170, &cstart, &cstop); |
|
406 fail_unless (res == TRUE); |
|
407 fail_unless (cstart == 150); |
|
408 fail_unless (cstop == 170); |
|
409 |
|
410 /* partially inside */ |
|
411 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, |
|
412 150, 250, &cstart, &cstop); |
|
413 fail_unless (res == TRUE); |
|
414 fail_unless (cstart == 150); |
|
415 fail_unless (cstop == 180); |
|
416 |
|
417 /* invalid start */ |
|
418 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 100, &cstart, &cstop); |
|
419 fail_unless (res == FALSE); |
|
420 |
|
421 /* start outside */ |
|
422 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, -1, &cstart, &cstop); |
|
423 fail_unless (res == TRUE); |
|
424 fail_unless (cstart == 100); |
|
425 fail_unless (cstop == 180); |
|
426 |
|
427 /* start on lower bound */ |
|
428 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 100, -1, &cstart, &cstop); |
|
429 fail_unless (res == TRUE); |
|
430 fail_unless (cstart == 100); |
|
431 fail_unless (cstop == 180); |
|
432 |
|
433 /* start inside */ |
|
434 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 150, -1, &cstart, &cstop); |
|
435 fail_unless (res == TRUE); |
|
436 fail_unless (cstart == 150); |
|
437 fail_unless (cstop == 180); |
|
438 |
|
439 /* start outside on boundary */ |
|
440 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 180, -1, &cstart, &cstop); |
|
441 fail_unless (res == FALSE); |
|
442 |
|
443 /* start completely outside */ |
|
444 res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 250, -1, &cstart, &cstop); |
|
445 fail_unless (res == FALSE); |
|
446 |
|
447 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
448 create_xml(0); |
|
449 } |
|
450 |
|
451 |
|
452 void segment_seek_reverse() |
|
453 { |
|
454 GstSegment segment; |
|
455 gboolean update; |
|
456 |
|
457 xmlfile = "segment_seek_reverse"; |
|
458 std_log(LOG_FILENAME_LINE, "Test Started segment_seek_reverse"); |
|
459 |
|
460 gst_segment_init (&segment, GST_FORMAT_BYTES); |
|
461 gst_segment_set_duration (&segment, GST_FORMAT_BYTES, 200); |
|
462 |
|
463 /* configure segment to stop 100 */ |
|
464 gst_segment_set_seek (&segment, -1.0, |
|
465 GST_FORMAT_BYTES, |
|
466 GST_SEEK_FLAG_NONE, |
|
467 GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, 100, &update); |
|
468 fail_unless (segment.start == 0); |
|
469 |
|
470 fail_unless (segment.stop == 100); |
|
471 |
|
472 fail_unless (segment.time == 0); |
|
473 |
|
474 fail_unless (segment.last_stop == 100); |
|
475 |
|
476 fail_unless (update == TRUE); |
|
477 |
|
478 |
|
479 /* update */ |
|
480 gst_segment_set_seek (&segment, -1.0, |
|
481 GST_FORMAT_BYTES, |
|
482 GST_SEEK_FLAG_NONE, |
|
483 GST_SEEK_TYPE_SET, 10, GST_SEEK_TYPE_CUR, -20, &update); |
|
484 fail_unless (segment.start == 10); |
|
485 |
|
486 fail_unless (segment.stop == 80); |
|
487 |
|
488 fail_unless (segment.time == 10); |
|
489 |
|
490 fail_unless (segment.last_stop == 80); |
|
491 |
|
492 fail_unless (update == TRUE); |
|
493 |
|
494 |
|
495 gst_segment_set_seek (&segment, -1.0, |
|
496 GST_FORMAT_BYTES, |
|
497 GST_SEEK_FLAG_NONE, |
|
498 GST_SEEK_TYPE_SET, 20, GST_SEEK_TYPE_NONE, 0, &update); |
|
499 fail_unless (segment.start == 20); |
|
500 |
|
501 fail_unless (segment.stop == 80); |
|
502 |
|
503 fail_unless (segment.time == 20); |
|
504 |
|
505 fail_unless (segment.last_stop == 80); |
|
506 |
|
507 fail_unless (update == FALSE); |
|
508 |
|
509 |
|
510 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
511 create_xml(0); |
|
512 } |
|
513 |
|
514 |
|
515 /* mess with the segment structure in the bytes format */ |
|
516 void segment_seek_rate() |
|
517 { |
|
518 GstSegment segment; |
|
519 gboolean update; |
|
520 |
|
521 xmlfile = "segment_seek_rate"; |
|
522 std_log(LOG_FILENAME_LINE, "Test Started segment_seek_rate"); |
|
523 |
|
524 gst_segment_init (&segment, GST_FORMAT_BYTES); |
|
525 |
|
526 /* configure segment to rate 2.0, format does not matter when we don't specify |
|
527 * a start or stop position. */ |
|
528 gst_segment_set_seek (&segment, 2.0, |
|
529 GST_FORMAT_UNDEFINED, |
|
530 GST_SEEK_FLAG_NONE, |
|
531 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_NONE, -1, &update); |
|
532 fail_unless (segment.format == GST_FORMAT_BYTES); |
|
533 |
|
534 fail_unless (segment.start == 0); |
|
535 |
|
536 fail_unless (segment.stop == -1); |
|
537 |
|
538 fail_unless (segment.rate == 2.0); |
|
539 |
|
540 fail_unless (update == FALSE); |
|
541 |
|
542 |
|
543 /* 0 is the same in all formats and should not fail */ |
|
544 gst_segment_set_seek (&segment, 2.0, |
|
545 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
546 GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, -1, &update); |
|
547 fail_unless (segment.format == GST_FORMAT_BYTES); |
|
548 |
|
549 |
|
550 /* set to -1 means start from 0 */ |
|
551 gst_segment_set_seek (&segment, 2.0, |
|
552 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
553 GST_SEEK_TYPE_SET, -1, GST_SEEK_TYPE_NONE, -1, &update); |
|
554 fail_unless (segment.format == GST_FORMAT_BYTES); |
|
555 |
|
556 fail_unless (segment.start == 0); |
|
557 |
|
558 |
|
559 gst_segment_set_seek (&segment, 2.0, |
|
560 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
561 GST_SEEK_TYPE_CUR, 0, GST_SEEK_TYPE_NONE, -1, &update); |
|
562 |
|
563 gst_segment_set_seek (&segment, 2.0, |
|
564 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
565 GST_SEEK_TYPE_END, 0, GST_SEEK_TYPE_NONE, -1, &update); |
|
566 |
|
567 /* -1 for end is fine too in all formats */ |
|
568 gst_segment_set_seek (&segment, 2.0, |
|
569 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
570 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_SET, -1, &update); |
|
571 |
|
572 /* 0 as relative end is fine too */ |
|
573 gst_segment_set_seek (&segment, 2.0, |
|
574 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
575 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_CUR, 0, &update); |
|
576 |
|
577 gst_segment_set_seek (&segment, 2.0, |
|
578 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
579 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 0, &update); |
|
580 |
|
581 /* set a real stop position, this must happen in bytes */ |
|
582 gst_segment_set_seek (&segment, 3.0, |
|
583 GST_FORMAT_BYTES, |
|
584 GST_SEEK_FLAG_NONE, |
|
585 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_SET, 100, &update); |
|
586 fail_unless (segment.format == GST_FORMAT_BYTES); |
|
587 |
|
588 fail_unless (segment.start == 0); |
|
589 |
|
590 fail_unless (segment.stop == 100); |
|
591 |
|
592 fail_unless (segment.rate == 3.0); |
|
593 |
|
594 /* no seek should happen, we just updated the stop position in forward |
|
595 * playback mode.*/ |
|
596 fail_unless (update == FALSE); |
|
597 |
|
598 |
|
599 /* 0 as relative end is fine too */ |
|
600 gst_segment_set_seek (&segment, 2.0, |
|
601 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
602 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_CUR, 0, &update); |
|
603 fail_unless (segment.stop == 100); |
|
604 |
|
605 |
|
606 gst_segment_set_seek (&segment, 2.0, |
|
607 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
608 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 0, &update); |
|
609 fail_unless (segment.stop == 100); |
|
610 |
|
611 |
|
612 /* -1 for end is fine too in all formats */ |
|
613 gst_segment_set_seek (&segment, 2.0, |
|
614 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
615 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_SET, -1, &update); |
|
616 fail_unless (segment.stop == -1); |
|
617 |
|
618 |
|
619 /* set some duration, stop -1 END seeks will now work with the |
|
620 * duration, if the formats match */ |
|
621 gst_segment_set_duration (&segment, GST_FORMAT_BYTES, 200); |
|
622 fail_unless (segment.duration == 200); |
|
623 |
|
624 |
|
625 /* seek to end in any format with 0 should set the stop to the |
|
626 * duration */ |
|
627 gst_segment_set_seek (&segment, 2.0, |
|
628 GST_FORMAT_TIME, GST_SEEK_FLAG_NONE, |
|
629 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 0, &update); |
|
630 fail_unless (segment.stop == 200); |
|
631 |
|
632 fail_unless (segment.duration == 200); |
|
633 |
|
634 |
|
635 /* subtract 100 from the end */ |
|
636 gst_segment_set_seek (&segment, 2.0, |
|
637 GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE, |
|
638 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, -100, &update); |
|
639 fail_unless (segment.stop == 100); |
|
640 |
|
641 fail_unless (segment.duration == 200); |
|
642 |
|
643 |
|
644 /* add 100 to the duration, this should be clamped to the duration */ |
|
645 gst_segment_set_seek (&segment, 2.0, |
|
646 GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE, |
|
647 GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 100, &update); |
|
648 fail_unless (segment.stop == 200); |
|
649 |
|
650 fail_unless (segment.duration == 200); |
|
651 |
|
652 |
|
653 /* add 300 to the start, this should be clamped to the duration */ |
|
654 gst_segment_set_seek (&segment, 2.0, |
|
655 GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE, |
|
656 GST_SEEK_TYPE_CUR, 300, GST_SEEK_TYPE_END, 0, &update); |
|
657 fail_unless (segment.start == 200); |
|
658 |
|
659 fail_unless (segment.stop == 200); |
|
660 |
|
661 fail_unless (segment.duration == 200); |
|
662 |
|
663 |
|
664 /* subtract 300 from the start, this should be clamped to 0 */ |
|
665 gst_segment_set_seek (&segment, 2.0, |
|
666 GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE, |
|
667 GST_SEEK_TYPE_CUR, -300, GST_SEEK_TYPE_END, 0, &update); |
|
668 fail_unless (segment.start == 0); |
|
669 |
|
670 fail_unless (segment.stop == 200); |
|
671 |
|
672 fail_unless (segment.duration == 200); |
|
673 |
|
674 |
|
675 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
676 create_xml(0); |
|
677 } |
|
678 |
|
679 |
|
680 /* mess with the segment structure in the bytes format */ |
|
681 void segment_newsegment_open() |
|
682 { |
|
683 GstSegment segment; |
|
684 |
|
685 xmlfile = "segment_newsegment_open"; |
|
686 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_open"); |
|
687 |
|
688 gst_segment_init (&segment, GST_FORMAT_BYTES); |
|
689 |
|
690 /* time should also work for starting from 0 */ |
|
691 gst_segment_set_newsegment (&segment, FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0); |
|
692 |
|
693 fail_unless (segment.rate == 1.0); |
|
694 |
|
695 fail_unless (segment.format == GST_FORMAT_BYTES); |
|
696 |
|
697 fail_unless (segment.flags == 0); |
|
698 |
|
699 fail_unless (segment.start == 0); |
|
700 |
|
701 fail_unless (segment.stop == -1); |
|
702 |
|
703 fail_unless (segment.time == 0); |
|
704 |
|
705 fail_unless (segment.accum == 0); |
|
706 |
|
707 fail_unless (segment.last_stop == 0); |
|
708 |
|
709 fail_unless (segment.duration == -1); |
|
710 |
|
711 |
|
712 /* we set stop but in the wrong format, stop stays open. */ |
|
713 gst_segment_set_newsegment (&segment, FALSE, 1.0, GST_FORMAT_TIME, 0, 200, 0); |
|
714 |
|
715 fail_unless (segment.start == 0); |
|
716 |
|
717 fail_unless (segment.stop == -1); |
|
718 |
|
719 fail_unless (segment.time == 0); |
|
720 |
|
721 fail_unless (segment.accum == 0); |
|
722 |
|
723 |
|
724 /* update, nothing changes */ |
|
725 gst_segment_set_newsegment (&segment, TRUE, 1.0, GST_FORMAT_BYTES, 0, -1, 0); |
|
726 |
|
727 fail_unless (segment.start == 0); |
|
728 |
|
729 fail_unless (segment.stop == -1); |
|
730 |
|
731 fail_unless (segment.time == 0); |
|
732 |
|
733 fail_unless (segment.accum == 0); |
|
734 |
|
735 |
|
736 /* update */ |
|
737 gst_segment_set_newsegment (&segment, TRUE, 1.0, |
|
738 GST_FORMAT_BYTES, 100, -1, 100); |
|
739 |
|
740 fail_unless (segment.start == 100); |
|
741 |
|
742 fail_unless (segment.stop == -1); |
|
743 |
|
744 fail_unless (segment.time == 100); |
|
745 |
|
746 fail_unless (segment.accum == 100); |
|
747 |
|
748 |
|
749 /* last_stop 0, accum does not change */ |
|
750 gst_segment_set_newsegment (&segment, FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0); |
|
751 |
|
752 fail_unless (segment.start == 0); |
|
753 |
|
754 fail_unless (segment.stop == -1); |
|
755 |
|
756 fail_unless (segment.time == 0); |
|
757 |
|
758 fail_unless (segment.accum == 100); |
|
759 |
|
760 |
|
761 gst_segment_set_last_stop (&segment, GST_FORMAT_BYTES, 200); |
|
762 |
|
763 /* last_stop 200, accum changes */ |
|
764 gst_segment_set_newsegment (&segment, FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0); |
|
765 |
|
766 fail_unless (segment.start == 0); |
|
767 |
|
768 fail_unless (segment.stop == -1); |
|
769 |
|
770 fail_unless (segment.time == 0); |
|
771 |
|
772 fail_unless (segment.accum == 300); |
|
773 |
|
774 |
|
775 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
776 create_xml(0); |
|
777 |
|
778 } |
|
779 |
|
780 |
|
781 /* mess with the segment structure in the bytes format */ |
|
782 void segment_newsegment_closed() |
|
783 { |
|
784 GstSegment segment; |
|
785 |
|
786 xmlfile = "segment_newsegment_closed"; |
|
787 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_closed"); |
|
788 |
|
789 gst_segment_init (&segment, GST_FORMAT_BYTES); |
|
790 |
|
791 gst_segment_set_newsegment (&segment, FALSE, 1.0, |
|
792 GST_FORMAT_BYTES, 0, 200, 0); |
|
793 |
|
794 fail_unless (segment.rate == 1.0); |
|
795 |
|
796 fail_unless (segment.format == GST_FORMAT_BYTES); |
|
797 |
|
798 fail_unless (segment.flags == 0); |
|
799 |
|
800 fail_unless (segment.start == 0); |
|
801 |
|
802 fail_unless (segment.stop == 200); |
|
803 |
|
804 fail_unless (segment.time == 0); |
|
805 |
|
806 fail_unless (segment.accum == 0); |
|
807 |
|
808 fail_unless (segment.last_stop == 0); |
|
809 |
|
810 fail_unless (segment.duration == -1); |
|
811 |
|
812 |
|
813 /* do an update */ |
|
814 gst_segment_set_newsegment (&segment, TRUE, 1.0, GST_FORMAT_BYTES, 0, 300, 0); |
|
815 |
|
816 fail_unless (segment.start == 0); |
|
817 |
|
818 fail_unless (segment.stop == 300); |
|
819 |
|
820 fail_unless (segment.time == 0); |
|
821 |
|
822 fail_unless (segment.accum == 0); |
|
823 |
|
824 |
|
825 /* and a new accumulated one */ |
|
826 gst_segment_set_newsegment (&segment, FALSE, 1.0, |
|
827 GST_FORMAT_BYTES, 100, 400, 300); |
|
828 |
|
829 fail_unless (segment.start == 100); |
|
830 |
|
831 fail_unless (segment.stop == 400); |
|
832 |
|
833 fail_unless (segment.time == 300); |
|
834 |
|
835 fail_unless (segment.accum == 300); |
|
836 |
|
837 |
|
838 /* and a new updated one */ |
|
839 gst_segment_set_newsegment (&segment, TRUE, 1.0, |
|
840 GST_FORMAT_BYTES, 100, 500, 300); |
|
841 |
|
842 fail_unless (segment.start == 100); |
|
843 |
|
844 fail_unless (segment.stop == 500); |
|
845 |
|
846 fail_unless (segment.time == 300); |
|
847 |
|
848 fail_unless (segment.accum == 300); |
|
849 |
|
850 |
|
851 /* and a new partially updated one */ |
|
852 gst_segment_set_newsegment (&segment, TRUE, 1.0, |
|
853 GST_FORMAT_BYTES, 200, 500, 400); |
|
854 |
|
855 fail_unless (segment.start == 200); |
|
856 |
|
857 fail_unless (segment.stop == 500); |
|
858 |
|
859 fail_unless (segment.time == 400); |
|
860 |
|
861 fail_unless (segment.accum == 400); |
|
862 |
|
863 |
|
864 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
865 create_xml(0); |
|
866 } |
|
867 |
|
868 |
|
869 |
|
870 /* mess with the segment structure in the time format */ |
|
871 void segment_newsegment_streamtime() |
|
872 { |
|
873 GstSegment segment; |
|
874 gint64 result; |
|
875 |
|
876 xmlfile = "segment_newsegment_streamtime"; |
|
877 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_streamtime"); |
|
878 |
|
879 gst_segment_init (&segment, GST_FORMAT_TIME); |
|
880 |
|
881 /*************************** |
|
882 * Normal segment |
|
883 ***************************/ |
|
884 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 1.0, |
|
885 GST_FORMAT_TIME, 0, 200, 0); |
|
886 |
|
887 fail_unless (segment.rate == 1.0); |
|
888 |
|
889 fail_unless (segment.applied_rate == 1.0); |
|
890 |
|
891 fail_unless (segment.format == GST_FORMAT_TIME); |
|
892 |
|
893 fail_unless (segment.flags == 0); |
|
894 |
|
895 fail_unless (segment.start == 0); |
|
896 |
|
897 fail_unless (segment.stop == 200); |
|
898 |
|
899 fail_unless (segment.time == 0); |
|
900 |
|
901 fail_unless (segment.accum == 0); |
|
902 |
|
903 fail_unless (segment.last_stop == 0); |
|
904 |
|
905 fail_unless (segment.duration == -1); |
|
906 |
|
907 |
|
908 /* invalid time gives invalid result */ |
|
909 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
910 fail_unless (result == -1); |
|
911 |
|
912 |
|
913 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
914 fail_unless (result == 0); |
|
915 |
|
916 |
|
917 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
918 fail_unless (result == 100); |
|
919 |
|
920 |
|
921 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
922 fail_unless (result == 200); |
|
923 |
|
924 |
|
925 /* outside of the segment */ |
|
926 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
927 fail_unless (result == -1); |
|
928 |
|
929 |
|
930 /********************* |
|
931 * time shifted by 500 |
|
932 *********************/ |
|
933 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 1.0, |
|
934 GST_FORMAT_TIME, 0, 200, 500); |
|
935 |
|
936 fail_unless (segment.accum == 200); |
|
937 |
|
938 |
|
939 /* invalid time gives invalid result */ |
|
940 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
941 fail_unless (result == -1); |
|
942 |
|
943 |
|
944 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
945 fail_unless (result == 500); |
|
946 |
|
947 |
|
948 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
949 fail_unless (result == 600); |
|
950 |
|
951 |
|
952 /* outside of the segment */ |
|
953 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 500); |
|
954 fail_unless (result == -1); |
|
955 |
|
956 |
|
957 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
958 fail_unless (result == -1); |
|
959 |
|
960 |
|
961 /********************* |
|
962 * time offset by 500 |
|
963 *********************/ |
|
964 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 1.0, |
|
965 GST_FORMAT_TIME, 500, 700, 0); |
|
966 |
|
967 fail_unless (segment.accum == 400); |
|
968 |
|
969 |
|
970 /* invalid time gives invalid result */ |
|
971 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
972 fail_unless (result == -1); |
|
973 |
|
974 |
|
975 /* before segment is invalid */ |
|
976 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400); |
|
977 fail_unless (result == -1); |
|
978 |
|
979 |
|
980 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 500); |
|
981 fail_unless (result == 0); |
|
982 |
|
983 |
|
984 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600); |
|
985 fail_unless (result == 100); |
|
986 |
|
987 |
|
988 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700); |
|
989 fail_unless (result == 200); |
|
990 |
|
991 |
|
992 /* outside of the segment */ |
|
993 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800); |
|
994 fail_unless (result == -1); |
|
995 |
|
996 |
|
997 /************************************* |
|
998 * time offset by 500, shifted by 200 |
|
999 *************************************/ |
|
1000 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 1.0, |
|
1001 GST_FORMAT_TIME, 500, 700, 200); |
|
1002 |
|
1003 fail_unless (segment.accum == 600); |
|
1004 |
|
1005 |
|
1006 /* invalid time gives invalid result */ |
|
1007 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1008 fail_unless (result == -1); |
|
1009 |
|
1010 |
|
1011 /* before segment is invalid */ |
|
1012 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400); |
|
1013 fail_unless (result == -1); |
|
1014 |
|
1015 |
|
1016 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 500); |
|
1017 fail_unless (result == 200); |
|
1018 |
|
1019 |
|
1020 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600); |
|
1021 fail_unless (result == 300); |
|
1022 |
|
1023 |
|
1024 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700); |
|
1025 fail_unless (result == 400); |
|
1026 |
|
1027 |
|
1028 /* outside of the segment */ |
|
1029 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800); |
|
1030 fail_unless (result == -1); |
|
1031 |
|
1032 |
|
1033 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1034 create_xml(0); |
|
1035 } |
|
1036 |
|
1037 |
|
1038 /* mess with the segment structure in the time format */ |
|
1039 void segment_newsegment_streamtime_rate() |
|
1040 { |
|
1041 GstSegment segment; |
|
1042 gint64 result; |
|
1043 |
|
1044 xmlfile = "segment_newsegment_streamtime_rate"; |
|
1045 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_streamtime_rate"); |
|
1046 |
|
1047 gst_segment_init (&segment, GST_FORMAT_TIME); |
|
1048 |
|
1049 /*************************** |
|
1050 * Normal segment rate 2.0 |
|
1051 ***************************/ |
|
1052 gst_segment_set_newsegment_full (&segment, FALSE, 2.0, 1.0, |
|
1053 GST_FORMAT_TIME, 0, 200, 0); |
|
1054 |
|
1055 fail_unless (segment.rate == 2.0); |
|
1056 |
|
1057 fail_unless (segment.applied_rate == 1.0); |
|
1058 |
|
1059 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1060 |
|
1061 fail_unless (segment.flags == 0); |
|
1062 |
|
1063 fail_unless (segment.start == 0); |
|
1064 |
|
1065 fail_unless (segment.stop == 200); |
|
1066 |
|
1067 fail_unless (segment.time == 0); |
|
1068 |
|
1069 fail_unless (segment.accum == 0); |
|
1070 |
|
1071 fail_unless (segment.last_stop == 0); |
|
1072 |
|
1073 fail_unless (segment.duration == -1); |
|
1074 |
|
1075 |
|
1076 /* invalid time gives invalid result */ |
|
1077 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1078 fail_unless (result == -1); |
|
1079 |
|
1080 |
|
1081 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1082 fail_unless (result == 0); |
|
1083 |
|
1084 |
|
1085 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1086 fail_unless (result == 100); |
|
1087 |
|
1088 |
|
1089 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1090 fail_unless (result == 150); |
|
1091 |
|
1092 |
|
1093 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1094 fail_unless (result == 200); |
|
1095 |
|
1096 |
|
1097 /* outside of the segment */ |
|
1098 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1099 fail_unless (result == -1); |
|
1100 |
|
1101 |
|
1102 /*************************************** |
|
1103 * Normal segment rate 2.0, offset |
|
1104 ***************************************/ |
|
1105 gst_segment_set_newsegment_full (&segment, FALSE, 2.0, 1.0, |
|
1106 GST_FORMAT_TIME, 100, 300, 0); |
|
1107 |
|
1108 fail_unless (segment.accum == 100); |
|
1109 |
|
1110 |
|
1111 /* invalid time gives invalid result */ |
|
1112 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1113 fail_unless (result == -1); |
|
1114 |
|
1115 |
|
1116 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1117 fail_unless (result == 0); |
|
1118 |
|
1119 |
|
1120 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1121 fail_unless (result == 100); |
|
1122 |
|
1123 |
|
1124 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 250); |
|
1125 fail_unless (result == 150); |
|
1126 |
|
1127 |
|
1128 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1129 fail_unless (result == 200); |
|
1130 |
|
1131 |
|
1132 /* outside of the segment */ |
|
1133 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400); |
|
1134 fail_unless (result == -1); |
|
1135 |
|
1136 |
|
1137 /*************************************** |
|
1138 * Normal segment rate -1.0, offset |
|
1139 ***************************************/ |
|
1140 |
|
1141 /* buffers will arrive from 300 to 100 in a sink, stream time |
|
1142 * calculation is unaffected by the rate */ |
|
1143 gst_segment_set_newsegment_full (&segment, FALSE, -1.0, 1.0, |
|
1144 GST_FORMAT_TIME, 100, 300, 0); |
|
1145 |
|
1146 fail_unless (segment.accum == 200); |
|
1147 |
|
1148 |
|
1149 /* invalid time gives invalid result */ |
|
1150 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1151 fail_unless (result == -1); |
|
1152 |
|
1153 |
|
1154 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1155 fail_unless (result == 0); |
|
1156 |
|
1157 |
|
1158 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1159 fail_unless (result == 100); |
|
1160 |
|
1161 |
|
1162 /*********************************************** |
|
1163 * Normal segment rate -1.0, offset, time = 200 |
|
1164 ***********************************************/ |
|
1165 gst_segment_set_newsegment_full (&segment, FALSE, -1.0, 1.0, |
|
1166 GST_FORMAT_TIME, 100, 300, 200); |
|
1167 |
|
1168 /* invalid time gives invalid result */ |
|
1169 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1170 fail_unless (result == -1); |
|
1171 |
|
1172 |
|
1173 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1174 fail_unless (result == 200); |
|
1175 |
|
1176 |
|
1177 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1178 fail_unless (result == 300); |
|
1179 |
|
1180 |
|
1181 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1182 fail_unless (result == 400); |
|
1183 |
|
1184 |
|
1185 /* outside of the segment */ |
|
1186 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400); |
|
1187 fail_unless (result == -1); |
|
1188 |
|
1189 |
|
1190 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1191 create_xml(0); |
|
1192 } |
|
1193 |
|
1194 |
|
1195 /* mess with the segment structure in the time format */ |
|
1196 void segment_newsegment_streamtime_applied_rate() |
|
1197 { |
|
1198 GstSegment segment; |
|
1199 gint64 result; |
|
1200 |
|
1201 xmlfile = "segment_newsegment_streamtime_applied_rate"; |
|
1202 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_streamtime_applied_rate"); |
|
1203 |
|
1204 gst_segment_init (&segment, GST_FORMAT_TIME); |
|
1205 |
|
1206 /*********************************************************** |
|
1207 * Normal segment rate 1.0, applied rate -1.0 |
|
1208 * This means the timestamps represents a stream going backwards |
|
1209 * starting from @time to 0. |
|
1210 ************************************************************/ |
|
1211 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, -1.0, |
|
1212 GST_FORMAT_TIME, 0, 200, 200); |
|
1213 |
|
1214 fail_unless (segment.rate == 1.0); |
|
1215 |
|
1216 fail_unless (segment.applied_rate == -1.0); |
|
1217 |
|
1218 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1219 |
|
1220 fail_unless (segment.flags == 0); |
|
1221 |
|
1222 fail_unless (segment.start == 0); |
|
1223 |
|
1224 fail_unless (segment.stop == 200); |
|
1225 |
|
1226 fail_unless (segment.time == 200); |
|
1227 |
|
1228 fail_unless (segment.accum == 0); |
|
1229 |
|
1230 fail_unless (segment.last_stop == 0); |
|
1231 |
|
1232 fail_unless (segment.duration == -1); |
|
1233 |
|
1234 |
|
1235 /* invalid time gives invalid result */ |
|
1236 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1237 fail_unless (result == -1); |
|
1238 |
|
1239 |
|
1240 /* we count backwards from 200 */ |
|
1241 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1242 fail_unless (result == 200); |
|
1243 |
|
1244 |
|
1245 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1246 fail_unless (result == 100); |
|
1247 |
|
1248 |
|
1249 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1250 fail_unless (result == 50); |
|
1251 |
|
1252 |
|
1253 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1254 fail_unless (result == 0); |
|
1255 |
|
1256 |
|
1257 /* outside of the segment */ |
|
1258 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1259 fail_unless (result == -1); |
|
1260 |
|
1261 |
|
1262 /*********************************************************** |
|
1263 * Normal segment rate 1.0, applied rate 2.0 |
|
1264 * This means the timestamps represents a stream at twice the |
|
1265 * normal rate |
|
1266 ************************************************************/ |
|
1267 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 2.0, |
|
1268 GST_FORMAT_TIME, 0, 200, 0); |
|
1269 |
|
1270 fail_unless (segment.rate == 1.0); |
|
1271 |
|
1272 fail_unless (segment.applied_rate == 2.0); |
|
1273 |
|
1274 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1275 |
|
1276 fail_unless (segment.flags == 0); |
|
1277 |
|
1278 fail_unless (segment.start == 0); |
|
1279 |
|
1280 fail_unless (segment.stop == 200); |
|
1281 |
|
1282 fail_unless (segment.time == 0); |
|
1283 |
|
1284 fail_unless (segment.accum == 200); |
|
1285 |
|
1286 fail_unless (segment.last_stop == 0); |
|
1287 |
|
1288 fail_unless (segment.duration == -1); |
|
1289 |
|
1290 |
|
1291 /* invalid time gives invalid result */ |
|
1292 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1293 fail_unless (result == -1); |
|
1294 |
|
1295 |
|
1296 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1297 fail_unless (result == 0); |
|
1298 |
|
1299 |
|
1300 /* the stream prepresents a stream going twice as fast, the position |
|
1301 * in the segment is therefore scaled by the applied rate */ |
|
1302 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1303 fail_unless (result == 200); |
|
1304 |
|
1305 |
|
1306 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1307 fail_unless (result == 300); |
|
1308 |
|
1309 |
|
1310 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1311 fail_unless (result == 400); |
|
1312 |
|
1313 |
|
1314 /* outside of the segment */ |
|
1315 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1316 fail_unless (result == -1); |
|
1317 |
|
1318 |
|
1319 /*********************************************************** |
|
1320 * Normal segment rate 1.0, applied rate -2.0 |
|
1321 * This means the timestamps represents a stream at twice the |
|
1322 * reverse rate |
|
1323 ************************************************************/ |
|
1324 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, -2.0, |
|
1325 GST_FORMAT_TIME, 0, 200, 400); |
|
1326 |
|
1327 fail_unless (segment.rate == 1.0); |
|
1328 |
|
1329 fail_unless (segment.applied_rate == -2.0); |
|
1330 |
|
1331 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1332 |
|
1333 fail_unless (segment.flags == 0); |
|
1334 |
|
1335 fail_unless (segment.start == 0); |
|
1336 |
|
1337 fail_unless (segment.stop == 200); |
|
1338 |
|
1339 fail_unless (segment.time == 400); |
|
1340 |
|
1341 /* previous segment lasted 200, rate of 2.0 was already applied */ |
|
1342 fail_unless (segment.accum == 400); |
|
1343 |
|
1344 fail_unless (segment.last_stop == 0); |
|
1345 |
|
1346 fail_unless (segment.duration == -1); |
|
1347 |
|
1348 |
|
1349 /* invalid time gives invalid result */ |
|
1350 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1351 fail_unless (result == -1); |
|
1352 |
|
1353 |
|
1354 /* we count backwards from 400 */ |
|
1355 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1356 fail_unless (result == 400); |
|
1357 |
|
1358 |
|
1359 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1360 fail_unless (result == 200); |
|
1361 |
|
1362 |
|
1363 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1364 fail_unless (result == 100); |
|
1365 |
|
1366 |
|
1367 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1368 fail_unless (result == 0); |
|
1369 |
|
1370 |
|
1371 /* outside of the segment */ |
|
1372 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1373 fail_unless (result == -1); |
|
1374 |
|
1375 |
|
1376 /*********************************************************** |
|
1377 * Normal segment rate 1.0, applied rate -2.0 |
|
1378 * This means the timestamps represents a stream at twice the |
|
1379 * reverse rate, start time cannot compensate the complete |
|
1380 * duration of the segment so we stop at 0 |
|
1381 ************************************************************/ |
|
1382 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, -2.0, |
|
1383 GST_FORMAT_TIME, 0, 200, 200); |
|
1384 |
|
1385 fail_unless (segment.rate == 1.0); |
|
1386 |
|
1387 fail_unless (segment.applied_rate == -2.0); |
|
1388 |
|
1389 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1390 |
|
1391 fail_unless (segment.flags == 0); |
|
1392 |
|
1393 fail_unless (segment.start == 0); |
|
1394 |
|
1395 fail_unless (segment.stop == 200); |
|
1396 |
|
1397 fail_unless (segment.time == 200); |
|
1398 |
|
1399 fail_unless (segment.accum == 600); |
|
1400 |
|
1401 fail_unless (segment.last_stop == 0); |
|
1402 |
|
1403 fail_unless (segment.duration == -1); |
|
1404 |
|
1405 |
|
1406 /* invalid time gives invalid result */ |
|
1407 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1408 fail_unless (result == -1); |
|
1409 |
|
1410 |
|
1411 /* we count backwards from 200 */ |
|
1412 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1413 fail_unless (result == 200); |
|
1414 |
|
1415 |
|
1416 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1417 fail_unless (result == 0); |
|
1418 |
|
1419 |
|
1420 /* clamp at 0 */ |
|
1421 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1422 fail_unless (result == 0); |
|
1423 |
|
1424 |
|
1425 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1426 fail_unless (result == 0); |
|
1427 |
|
1428 |
|
1429 /* outside of the segment */ |
|
1430 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1431 fail_unless (result == -1); |
|
1432 |
|
1433 |
|
1434 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1435 create_xml(0); |
|
1436 } |
|
1437 |
|
1438 |
|
1439 /* mess with the segment structure in the time format */ |
|
1440 void segment_newsegment_streamtime_applied_rate_rate() |
|
1441 { |
|
1442 GstSegment segment; |
|
1443 gint64 result; |
|
1444 |
|
1445 xmlfile = "segment_newsegment_streamtime_applied_rate_rate"; |
|
1446 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_streamtime_applied_rate_rate"); |
|
1447 |
|
1448 gst_segment_init (&segment, GST_FORMAT_TIME); |
|
1449 |
|
1450 /*********************************************************** |
|
1451 * Segment rate 2.0, applied rate 2.0 |
|
1452 * this means we have a double speed stream that we should |
|
1453 * speed up by a factor of 2.0 some more. the resulting |
|
1454 * stream will be played at four times the speed. |
|
1455 ************************************************************/ |
|
1456 gst_segment_set_newsegment_full (&segment, FALSE, 2.0, 2.0, |
|
1457 GST_FORMAT_TIME, 0, 200, 0); |
|
1458 |
|
1459 fail_unless (segment.rate == 2.0); |
|
1460 |
|
1461 fail_unless (segment.applied_rate == 2.0); |
|
1462 |
|
1463 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1464 |
|
1465 fail_unless (segment.flags == 0); |
|
1466 |
|
1467 fail_unless (segment.start == 0); |
|
1468 |
|
1469 fail_unless (segment.stop == 200); |
|
1470 |
|
1471 fail_unless (segment.time == 0); |
|
1472 |
|
1473 fail_unless (segment.accum == 0); |
|
1474 |
|
1475 fail_unless (segment.last_stop == 0); |
|
1476 |
|
1477 fail_unless (segment.duration == -1); |
|
1478 |
|
1479 |
|
1480 /* invalid time gives invalid result */ |
|
1481 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1482 fail_unless (result == -1); |
|
1483 |
|
1484 |
|
1485 /* only applied rate affects our calculation of the stream time */ |
|
1486 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1487 fail_unless (result == 0); |
|
1488 |
|
1489 |
|
1490 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1491 fail_unless (result == 200); |
|
1492 |
|
1493 |
|
1494 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1495 fail_unless (result == 300); |
|
1496 |
|
1497 |
|
1498 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1499 fail_unless (result == 400); |
|
1500 |
|
1501 |
|
1502 /* outside of the segment */ |
|
1503 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1504 fail_unless (result == -1); |
|
1505 |
|
1506 |
|
1507 /*********************************************************** |
|
1508 * Segment rate 2.0, applied rate -1.0 |
|
1509 * this means we have a reverse stream that we should |
|
1510 * speed up by a factor of 2.0 |
|
1511 ************************************************************/ |
|
1512 gst_segment_set_newsegment_full (&segment, FALSE, 2.0, -1.0, |
|
1513 GST_FORMAT_TIME, 0, 200, 200); |
|
1514 |
|
1515 fail_unless (segment.rate == 2.0); |
|
1516 |
|
1517 fail_unless (segment.applied_rate == -1.0); |
|
1518 |
|
1519 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1520 |
|
1521 fail_unless (segment.flags == 0); |
|
1522 |
|
1523 fail_unless (segment.start == 0); |
|
1524 |
|
1525 fail_unless (segment.stop == 200); |
|
1526 |
|
1527 fail_unless (segment.time == 200); |
|
1528 |
|
1529 /* previous segment lasted 100 */ |
|
1530 fail_unless (segment.accum == 100); |
|
1531 |
|
1532 fail_unless (segment.last_stop == 0); |
|
1533 |
|
1534 fail_unless (segment.duration == -1); |
|
1535 |
|
1536 |
|
1537 /* invalid time gives invalid result */ |
|
1538 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1539 fail_unless (result == -1); |
|
1540 |
|
1541 |
|
1542 /* only applied rate affects our calculation of the stream time */ |
|
1543 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1544 fail_unless (result == 200); |
|
1545 |
|
1546 |
|
1547 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1548 fail_unless (result == 100); |
|
1549 |
|
1550 |
|
1551 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1552 fail_unless (result == 50); |
|
1553 |
|
1554 |
|
1555 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1556 fail_unless (result == 0); |
|
1557 |
|
1558 |
|
1559 /* outside of the segment */ |
|
1560 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1561 fail_unless (result == -1); |
|
1562 |
|
1563 |
|
1564 /*********************************************************** |
|
1565 * Segment rate -1.0, applied rate -1.0 |
|
1566 * this means we have a reverse stream that we should |
|
1567 * reverse to get the normal stream again. |
|
1568 ************************************************************/ |
|
1569 gst_segment_set_newsegment_full (&segment, FALSE, -1.0, -1.0, |
|
1570 GST_FORMAT_TIME, 0, 200, 200); |
|
1571 |
|
1572 fail_unless (segment.rate == -1.0); |
|
1573 |
|
1574 fail_unless (segment.applied_rate == -1.0); |
|
1575 |
|
1576 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1577 |
|
1578 fail_unless (segment.flags == 0); |
|
1579 |
|
1580 fail_unless (segment.start == 0); |
|
1581 |
|
1582 fail_unless (segment.stop == 200); |
|
1583 |
|
1584 fail_unless (segment.time == 200); |
|
1585 |
|
1586 /* accumulated 100 of previous segment to make 200 */ |
|
1587 fail_unless (segment.accum == 200); |
|
1588 |
|
1589 fail_unless (segment.last_stop == 0); |
|
1590 |
|
1591 fail_unless (segment.duration == -1); |
|
1592 |
|
1593 |
|
1594 /* invalid time gives invalid result */ |
|
1595 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1596 fail_unless (result == -1); |
|
1597 |
|
1598 |
|
1599 /* only applied rate affects our calculation of the stream time */ |
|
1600 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1601 fail_unless (result == 200); |
|
1602 |
|
1603 |
|
1604 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1605 fail_unless (result == 100); |
|
1606 |
|
1607 |
|
1608 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1609 fail_unless (result == 50); |
|
1610 |
|
1611 |
|
1612 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1613 fail_unless (result == 0); |
|
1614 |
|
1615 |
|
1616 /* outside of the segment */ |
|
1617 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1618 fail_unless (result == -1); |
|
1619 |
|
1620 |
|
1621 /*********************************************************** |
|
1622 * Segment rate -1.0, applied rate -1.0 |
|
1623 * this means we have a reverse stream that we should |
|
1624 * reverse to get the normal stream again. |
|
1625 ************************************************************/ |
|
1626 gst_segment_set_newsegment_full (&segment, FALSE, -1.0, 2.0, |
|
1627 GST_FORMAT_TIME, 0, 200, 0); |
|
1628 |
|
1629 fail_unless (segment.rate == -1.0); |
|
1630 |
|
1631 fail_unless (segment.applied_rate == 2.0); |
|
1632 |
|
1633 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1634 |
|
1635 fail_unless (segment.flags == 0); |
|
1636 |
|
1637 fail_unless (segment.start == 0); |
|
1638 |
|
1639 fail_unless (segment.stop == 200); |
|
1640 |
|
1641 fail_unless (segment.time == 0); |
|
1642 |
|
1643 fail_unless (segment.accum == 400); |
|
1644 |
|
1645 fail_unless (segment.last_stop == 0); |
|
1646 |
|
1647 fail_unless (segment.duration == -1); |
|
1648 |
|
1649 |
|
1650 /* invalid time gives invalid result */ |
|
1651 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1); |
|
1652 fail_unless (result == -1); |
|
1653 |
|
1654 |
|
1655 /* only applied rate affects our calculation of the stream time */ |
|
1656 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 0); |
|
1657 fail_unless (result == 0); |
|
1658 |
|
1659 |
|
1660 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100); |
|
1661 fail_unless (result == 200); |
|
1662 |
|
1663 |
|
1664 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150); |
|
1665 fail_unless (result == 300); |
|
1666 |
|
1667 |
|
1668 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200); |
|
1669 fail_unless (result == 400); |
|
1670 |
|
1671 |
|
1672 /* outside of the segment */ |
|
1673 result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300); |
|
1674 fail_unless (result == -1); |
|
1675 |
|
1676 |
|
1677 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1678 create_xml(0); |
|
1679 } |
|
1680 |
|
1681 |
|
1682 /* mess with the segment structure in the time format */ |
|
1683 void segment_newsegment_runningtime() |
|
1684 { |
|
1685 GstSegment segment; |
|
1686 gint64 result; |
|
1687 |
|
1688 xmlfile = "segment_newsegment_runningtime"; |
|
1689 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_runningtime"); |
|
1690 |
|
1691 gst_segment_init (&segment, GST_FORMAT_TIME); |
|
1692 |
|
1693 /*************************** |
|
1694 * Normal segment |
|
1695 ***************************/ |
|
1696 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 1.0, |
|
1697 GST_FORMAT_TIME, 0, 200, 0); |
|
1698 |
|
1699 fail_unless (segment.rate == 1.0); |
|
1700 |
|
1701 fail_unless (segment.applied_rate == 1.0); |
|
1702 |
|
1703 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1704 |
|
1705 fail_unless (segment.flags == 0); |
|
1706 |
|
1707 fail_unless (segment.start == 0); |
|
1708 |
|
1709 fail_unless (segment.stop == 200); |
|
1710 |
|
1711 fail_unless (segment.time == 0); |
|
1712 |
|
1713 fail_unless (segment.accum == 0); |
|
1714 |
|
1715 fail_unless (segment.last_stop == 0); |
|
1716 |
|
1717 fail_unless (segment.duration == -1); |
|
1718 |
|
1719 |
|
1720 /* invalid time gives invalid result */ |
|
1721 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
1722 fail_unless (result == -1); |
|
1723 |
|
1724 |
|
1725 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 0); |
|
1726 fail_unless (result == 0); |
|
1727 |
|
1728 |
|
1729 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100); |
|
1730 fail_unless (result == 100); |
|
1731 |
|
1732 |
|
1733 /* at edge is exactly the segment duration */ |
|
1734 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 200); |
|
1735 fail_unless (result == 200); |
|
1736 |
|
1737 |
|
1738 /* outside of the segment */ |
|
1739 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 300); |
|
1740 fail_unless (result == -1); |
|
1741 |
|
1742 |
|
1743 /*********************************************************** |
|
1744 * time shifted by 500, check if accumulation worked. |
|
1745 * Rate convert to twice the speed which means scaling down |
|
1746 * all positions by 2.0 in this segment. |
|
1747 * Then time argument is not used at all here. |
|
1748 ***********************************************************/ |
|
1749 gst_segment_set_newsegment_full (&segment, FALSE, 2.0, 1.0, |
|
1750 GST_FORMAT_TIME, 0, 200, 500); |
|
1751 |
|
1752 /* normal speed gives elapsed of 200 */ |
|
1753 fail_unless (segment.accum == 200); |
|
1754 |
|
1755 |
|
1756 /* invalid time gives invalid result */ |
|
1757 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
1758 fail_unless (result == -1); |
|
1759 |
|
1760 |
|
1761 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 0); |
|
1762 fail_unless (result == 200); |
|
1763 |
|
1764 |
|
1765 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100); |
|
1766 fail_unless (result == 250); |
|
1767 |
|
1768 |
|
1769 /* outside of the segment */ |
|
1770 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 500); |
|
1771 fail_unless (result == -1); |
|
1772 |
|
1773 |
|
1774 /******************************************** |
|
1775 * time offset by 500 |
|
1776 * applied rate is not used for running time |
|
1777 ********************************************/ |
|
1778 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 2.0, |
|
1779 GST_FORMAT_TIME, 500, 700, 0); |
|
1780 |
|
1781 /* previous segment played at double speed gives elapsed time of |
|
1782 * 100 added to previous accum of 200 gives 300. */ |
|
1783 fail_unless (segment.accum == 300); |
|
1784 |
|
1785 |
|
1786 /* invalid time gives invalid result */ |
|
1787 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
1788 fail_unless (result == -1); |
|
1789 |
|
1790 |
|
1791 /* before segment is invalid */ |
|
1792 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 400); |
|
1793 fail_unless (result == -1); |
|
1794 |
|
1795 |
|
1796 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 500); |
|
1797 fail_unless (result == 300); |
|
1798 |
|
1799 |
|
1800 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600); |
|
1801 fail_unless (result == 400); |
|
1802 |
|
1803 |
|
1804 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700); |
|
1805 fail_unless (result == 500); |
|
1806 |
|
1807 |
|
1808 /* outside of the segment */ |
|
1809 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800); |
|
1810 fail_unless (result == -1); |
|
1811 |
|
1812 |
|
1813 /********************************************************** |
|
1814 * time offset by 500, shifted by 200 |
|
1815 * Negative rate makes the running time go backwards |
|
1816 * relative to the segment stop position. again time |
|
1817 * is ignored. |
|
1818 **********************************************************/ |
|
1819 gst_segment_set_newsegment_full (&segment, FALSE, -1.0, 1.0, |
|
1820 GST_FORMAT_TIME, 500, 700, 200); |
|
1821 |
|
1822 fail_unless (segment.accum == 500); |
|
1823 |
|
1824 |
|
1825 /* invalid time gives invalid result */ |
|
1826 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
1827 fail_unless (result == -1); |
|
1828 |
|
1829 |
|
1830 /* before segment is invalid */ |
|
1831 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 400); |
|
1832 fail_unless (result == -1); |
|
1833 |
|
1834 |
|
1835 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 500); |
|
1836 fail_unless (result == 700); |
|
1837 |
|
1838 |
|
1839 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600); |
|
1840 fail_unless (result == 600); |
|
1841 |
|
1842 |
|
1843 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700); |
|
1844 fail_unless (result == 500); |
|
1845 |
|
1846 |
|
1847 /* outside of the segment */ |
|
1848 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800); |
|
1849 fail_unless (result == -1); |
|
1850 |
|
1851 |
|
1852 /********************************************************** |
|
1853 * time offset by 500, shifted by 200 |
|
1854 * Negative rate makes the running time go backwards at |
|
1855 * twice speed relative to the segment stop position. again |
|
1856 * time is ignored. |
|
1857 **********************************************************/ |
|
1858 gst_segment_set_newsegment_full (&segment, FALSE, -2.0, -2.0, |
|
1859 GST_FORMAT_TIME, 500, 700, 200); |
|
1860 |
|
1861 fail_unless (segment.accum == 700); |
|
1862 |
|
1863 |
|
1864 /* invalid time gives invalid result */ |
|
1865 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
1866 fail_unless (result == -1); |
|
1867 |
|
1868 |
|
1869 /* before segment is invalid */ |
|
1870 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 400); |
|
1871 fail_unless (result == -1); |
|
1872 |
|
1873 |
|
1874 /* total scaled segment time is 100, accum is 700, so we get 800 */ |
|
1875 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 500); |
|
1876 fail_unless (result == 800); |
|
1877 |
|
1878 |
|
1879 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600); |
|
1880 fail_unless (result == 750); |
|
1881 |
|
1882 |
|
1883 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700); |
|
1884 fail_unless (result == 700); |
|
1885 |
|
1886 |
|
1887 /* outside of the segment */ |
|
1888 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800); |
|
1889 fail_unless (result == -1); |
|
1890 |
|
1891 |
|
1892 /* see if negative rate closed segment correctly */ |
|
1893 gst_segment_set_newsegment_full (&segment, FALSE, -2.0, -1.0, |
|
1894 GST_FORMAT_TIME, 500, 700, 200); |
|
1895 |
|
1896 /* previous segment lasted 100, and was at 700 so we should get 800 */ |
|
1897 fail_unless (segment.accum == 800); |
|
1898 |
|
1899 |
|
1900 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
1901 create_xml(0); |
|
1902 } |
|
1903 |
|
1904 |
|
1905 /* mess with the segment structure in the time format */ |
|
1906 void segment_newsegment_accum() |
|
1907 { |
|
1908 GstSegment segment; |
|
1909 gint64 result; |
|
1910 |
|
1911 xmlfile = "segment_newsegment_accum"; |
|
1912 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_accum"); |
|
1913 |
|
1914 gst_segment_init (&segment, GST_FORMAT_TIME); |
|
1915 |
|
1916 /*************************** |
|
1917 * Normal reverse segment |
|
1918 ***************************/ |
|
1919 gst_segment_set_newsegment_full (&segment, FALSE, -1.0, 1.0, |
|
1920 GST_FORMAT_TIME, 0, 200, 0); |
|
1921 |
|
1922 fail_unless (segment.rate == -1.0); |
|
1923 |
|
1924 fail_unless (segment.applied_rate == 1.0); |
|
1925 |
|
1926 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1927 |
|
1928 fail_unless (segment.flags == 0); |
|
1929 |
|
1930 fail_unless (segment.start == 0); |
|
1931 |
|
1932 fail_unless (segment.stop == 200); |
|
1933 |
|
1934 fail_unless (segment.time == 0); |
|
1935 |
|
1936 fail_unless (segment.accum == 0); |
|
1937 |
|
1938 fail_unless (segment.last_stop == 0); |
|
1939 |
|
1940 fail_unless (segment.duration == -1); |
|
1941 |
|
1942 |
|
1943 /* invalid time gives invalid result */ |
|
1944 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
1945 fail_unless (result == -1); |
|
1946 |
|
1947 |
|
1948 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 200); |
|
1949 fail_unless (result == 0); |
|
1950 |
|
1951 |
|
1952 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150); |
|
1953 fail_unless (result == 50); |
|
1954 |
|
1955 |
|
1956 /* update segment, this accumulates 50 from the previous segment. */ |
|
1957 gst_segment_set_newsegment_full (&segment, TRUE, -2.0, 1.0, |
|
1958 GST_FORMAT_TIME, 0, 150, 0); |
|
1959 |
|
1960 fail_unless (segment.rate == -2.0); |
|
1961 |
|
1962 fail_unless (segment.applied_rate == 1.0); |
|
1963 |
|
1964 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1965 |
|
1966 fail_unless (segment.flags == 0); |
|
1967 |
|
1968 fail_unless (segment.start == 0); |
|
1969 |
|
1970 fail_unless (segment.stop == 150); |
|
1971 |
|
1972 fail_unless (segment.time == 0); |
|
1973 |
|
1974 fail_unless (segment.accum == 50); |
|
1975 |
|
1976 fail_unless (segment.last_stop == 0); |
|
1977 |
|
1978 fail_unless (segment.duration == -1); |
|
1979 |
|
1980 |
|
1981 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150); |
|
1982 fail_unless (result == 50); |
|
1983 |
|
1984 |
|
1985 /* 50 accumulated + 50 / 2 */ |
|
1986 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100); |
|
1987 fail_unless (result == 75); |
|
1988 |
|
1989 |
|
1990 /* update segment, this does not accumulate anything. */ |
|
1991 gst_segment_set_newsegment_full (&segment, TRUE, 1.0, 1.0, |
|
1992 GST_FORMAT_TIME, 100, 200, 100); |
|
1993 |
|
1994 fail_unless (segment.rate == 1.0); |
|
1995 |
|
1996 fail_unless (segment.applied_rate == 1.0); |
|
1997 |
|
1998 fail_unless (segment.format == GST_FORMAT_TIME); |
|
1999 |
|
2000 fail_unless (segment.flags == 0); |
|
2001 |
|
2002 fail_unless (segment.start == 100); |
|
2003 |
|
2004 fail_unless (segment.stop == 200); |
|
2005 |
|
2006 fail_unless (segment.time == 100); |
|
2007 |
|
2008 fail_unless (segment.accum == 50); |
|
2009 |
|
2010 fail_unless (segment.last_stop == 100); |
|
2011 |
|
2012 fail_unless (segment.duration == -1); |
|
2013 |
|
2014 |
|
2015 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100); |
|
2016 fail_unless (result == 50); |
|
2017 |
|
2018 |
|
2019 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150); |
|
2020 fail_unless (result == 100); |
|
2021 |
|
2022 |
|
2023 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
2024 create_xml(0); |
|
2025 } |
|
2026 |
|
2027 |
|
2028 /* mess with the segment structure in the time format */ |
|
2029 void segment_newsegment_accum2() |
|
2030 { |
|
2031 GstSegment segment; |
|
2032 gint64 result; |
|
2033 |
|
2034 xmlfile = "segment_newsegment_accum2"; |
|
2035 std_log(LOG_FILENAME_LINE, "Test Started segment_newsegment_accum2"); |
|
2036 |
|
2037 gst_segment_init (&segment, GST_FORMAT_TIME); |
|
2038 |
|
2039 /*************************** |
|
2040 * Normal reverse segment |
|
2041 ***************************/ |
|
2042 gst_segment_set_newsegment_full (&segment, FALSE, -1.0, 1.0, |
|
2043 GST_FORMAT_TIME, 0, 200, 0); |
|
2044 |
|
2045 fail_unless (segment.rate == -1.0); |
|
2046 |
|
2047 fail_unless (segment.applied_rate == 1.0); |
|
2048 |
|
2049 fail_unless (segment.format == GST_FORMAT_TIME); |
|
2050 |
|
2051 fail_unless (segment.flags == 0); |
|
2052 |
|
2053 fail_unless (segment.start == 0); |
|
2054 |
|
2055 fail_unless (segment.stop == 200); |
|
2056 |
|
2057 fail_unless (segment.time == 0); |
|
2058 |
|
2059 fail_unless (segment.accum == 0); |
|
2060 |
|
2061 fail_unless (segment.last_stop == 0); |
|
2062 |
|
2063 fail_unless (segment.duration == -1); |
|
2064 |
|
2065 |
|
2066 /* invalid time gives invalid result */ |
|
2067 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
2068 fail_unless (result == -1); |
|
2069 |
|
2070 |
|
2071 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 200); |
|
2072 fail_unless (result == 0); |
|
2073 |
|
2074 |
|
2075 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150); |
|
2076 fail_unless (result == 50); |
|
2077 |
|
2078 |
|
2079 /* close segment, this accumulates nothing. */ |
|
2080 gst_segment_set_newsegment_full (&segment, TRUE, -1.0, 1.0, |
|
2081 GST_FORMAT_TIME, 150, 200, 0); |
|
2082 |
|
2083 fail_unless (segment.rate == -1.0); |
|
2084 |
|
2085 fail_unless (segment.applied_rate == 1.0); |
|
2086 |
|
2087 fail_unless (segment.format == GST_FORMAT_TIME); |
|
2088 |
|
2089 fail_unless (segment.flags == 0); |
|
2090 |
|
2091 fail_unless (segment.start == 150); |
|
2092 |
|
2093 fail_unless (segment.stop == 200); |
|
2094 |
|
2095 fail_unless (segment.time == 0); |
|
2096 |
|
2097 fail_unless (segment.accum == 0); |
|
2098 |
|
2099 fail_unless (segment.last_stop == 150); |
|
2100 |
|
2101 fail_unless (segment.duration == -1); |
|
2102 |
|
2103 |
|
2104 /* new segment, this accumulates 50. */ |
|
2105 gst_segment_set_newsegment_full (&segment, FALSE, 1.0, 1.0, |
|
2106 GST_FORMAT_TIME, 150, 300, 150); |
|
2107 |
|
2108 fail_unless (segment.rate == 1.0); |
|
2109 |
|
2110 fail_unless (segment.applied_rate == 1.0); |
|
2111 |
|
2112 fail_unless (segment.format == GST_FORMAT_TIME); |
|
2113 |
|
2114 fail_unless (segment.flags == 0); |
|
2115 |
|
2116 fail_unless (segment.start == 150); |
|
2117 |
|
2118 fail_unless (segment.stop == 300); |
|
2119 |
|
2120 fail_unless (segment.time == 150); |
|
2121 |
|
2122 fail_unless (segment.accum == 50); |
|
2123 |
|
2124 fail_unless (segment.last_stop == 150); |
|
2125 |
|
2126 fail_unless (segment.duration == -1); |
|
2127 |
|
2128 |
|
2129 /* invalid time gives invalid result */ |
|
2130 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1); |
|
2131 fail_unless (result == -1); |
|
2132 |
|
2133 |
|
2134 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150); |
|
2135 fail_unless (result == 50); |
|
2136 |
|
2137 |
|
2138 result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 200); |
|
2139 fail_unless (result == 100); |
|
2140 |
|
2141 |
|
2142 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
2143 create_xml(0); |
|
2144 } |
|
2145 |
|
2146 |
|
2147 /*void main(int argc,char** argv) |
|
2148 { |
|
2149 gst_init(&argc,&argv); |
|
2150 segment_seek_reverse(); |
|
2151 segment_seek_rate(); |
|
2152 segment_newsegment_open(); |
|
2153 segment_newsegment_closed(); |
|
2154 segment_newsegment_streamtime(); |
|
2155 segment_newsegment_streamtime_rate(); |
|
2156 segment_newsegment_streamtime_applied_rate(); |
|
2157 segment_newsegment_streamtime_applied_rate_rate(); |
|
2158 segment_newsegment_runningtime(); |
|
2159 segment_newsegment_accum(); |
|
2160 segment_newsegment_accum2(); |
|
2161 }*/ |
|
2162 |
|
2163 |
|
2164 void (*fn[13]) (void) = { |
|
2165 segment_seek_reverse, |
|
2166 segment_seek_rate, |
|
2167 segment_newsegment_open, |
|
2168 segment_newsegment_closed, |
|
2169 segment_newsegment_streamtime, |
|
2170 segment_newsegment_streamtime_rate, |
|
2171 segment_newsegment_streamtime_applied_rate, |
|
2172 segment_newsegment_streamtime_applied_rate_rate, |
|
2173 segment_newsegment_runningtime, |
|
2174 segment_newsegment_accum, |
|
2175 segment_newsegment_accum2, |
|
2176 segment_seek_nosize, |
|
2177 segment_seek_size |
|
2178 }; |
|
2179 |
|
2180 char *args[] = { |
|
2181 "segment_seek_reverse", |
|
2182 "segment_seek_rate", |
|
2183 "segment_newsegment_open", |
|
2184 "segment_newsegment_closed", |
|
2185 "segment_newsegment_streamtime", |
|
2186 "segment_newsegment_streamtime_rate", |
|
2187 "segment_newsegment_streamtime_applied_rate", |
|
2188 "segment_newsegment_streamtime_applied_rate_rate", |
|
2189 "segment_newsegment_runningtime", |
|
2190 "segment_newsegment_accum", |
|
2191 "segment_newsegment_accum2", |
|
2192 "segment_seek_nosize", |
|
2193 "segment_seek_size" |
|
2194 }; |
|
2195 |
|
2196 GST_CHECK_MAIN (gst_segment); |