spectrum.c 19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* GStreamer
 *
 * unit test for spectrum
 *
 * Copyright (C) <2007> Stefan Kost <ensonic@users.sf.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <unistd.h>

#include <gst/check/gstcheck.h>

GList *buffers = NULL;
gboolean have_eos = FALSE;

/* For ease of programming we use globals to keep refs for our floating
 * src and sink pads we create; otherwise we always have to do get_pad,
 * get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;

#define SPECT_CAPS_TEMPLATE_STRING \
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    "audio/x-raw-int, "                                               \
    " width = (int) 16, "                                             \
    " depth = (int) 16, "                                             \
    " signed = (boolean) true, "                                      \
    " endianness = (int) BYTE_ORDER, "                                \
    " rate = (int) [ 1, MAX ], "                                      \
    " channels = (int) [ 1, MAX ]; "                                  \
    "audio/x-raw-int, "                                               \
    " width = (int) 32, "                                             \
    " depth = (int) 32, "                                             \
    " signed = (boolean) true, "                                      \
    " endianness = (int) BYTE_ORDER, "                                \
    " rate = (int) [ 1, MAX ], "                                      \
    " channels = (int) [ 1, MAX ]; "                                  \
    "audio/x-raw-float, "                                             \
    " width = (int) { 32, 64 }, "                                     \
    " endianness = (int) BYTE_ORDER, "                                \
    " rate = (int) [ 1, MAX ], "                                      \
    " channels = (int) [ 1, MAX ]"

#define SPECT_CAPS_STRING_S16 \
57
  "audio/x-raw-int, " \
58
59
    "rate = (int) 44100, " \
    "channels = (int) 1, " \
60
    "endianness = (int) BYTE_ORDER, " \
61
62
    "width = (int) 16, " \
    "depth = (int) 16, " \
63
64
    "signed = (boolean) true"

65
#define SPECT_CAPS_STRING_S32 \
66
67
68
69
  "audio/x-raw-int, " \
    "rate = (int) 44100, " \
    "channels = (int) 1, " \
    "endianness = (int) BYTE_ORDER, " \
70
71
    "width = (int) 32, " \
    "depth = (int) 32, " \
72
73
    "signed = (boolean) true"

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#define SPECT_CAPS_STRING_F32 \
    "audio/x-raw-float, "                                             \
    " width = (int) 32, "                                             \
    " endianness = (int) BYTE_ORDER, "                                \
    " rate = (int) 44100, "                                           \
    " channels = (int) 1"

#define SPECT_CAPS_STRING_F64 \
    "audio/x-raw-float, "                                             \
    " width = (int) 64, "                                             \
    " endianness = (int) BYTE_ORDER, "                                \
    " rate = (int) 44100, "                                           \
    " channels = (int) 1"

#define SPECT_BANDS 256
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
    GST_PAD_SINK,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS (SPECT_CAPS_TEMPLATE_STRING)
    );
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
    GST_PAD_SRC,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS (SPECT_CAPS_TEMPLATE_STRING)
    );

/* takes over reference for outcaps */
GstElement *
setup_spectrum ()
{
  GstElement *spectrum;

  GST_DEBUG ("setup_spectrum");
  spectrum = gst_check_setup_element ("spectrum");
  mysrcpad = gst_check_setup_src_pad (spectrum, &srctemplate, NULL);
  mysinkpad = gst_check_setup_sink_pad (spectrum, &sinktemplate, NULL);
  gst_pad_set_active (mysrcpad, TRUE);
  gst_pad_set_active (mysinkpad, TRUE);

  return spectrum;
}

void
cleanup_spectrum (GstElement * spectrum)
{
  GST_DEBUG ("cleanup_spectrum");

  gst_pad_set_active (mysrcpad, FALSE);
  gst_pad_set_active (mysinkpad, FALSE);
  gst_check_teardown_src_pad (spectrum);
  gst_check_teardown_sink_pad (spectrum);
  gst_check_teardown_element (spectrum);
}


GST_START_TEST (test_int16)
{
  GstElement *spectrum;
  GstBuffer *inbuffer, *outbuffer;
  GstBus *bus;
  GstCaps *caps;
  GstMessage *message;
  const GstStructure *structure;
  int i, j;
  gint16 *data;
  const GValue *list, *value;
  GstClockTime endtime;
142
  gfloat level;
143
144

  spectrum = setup_spectrum ();
145
  g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
146
147
148
149
150
151
      "bands", SPECT_BANDS, "threshold", -80, NULL);

  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
      "could not set to playing");

152
  /* create a 1 sec buffer with an 11025 Hz sine wave */
153
154
  inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gint16));
  data = (gint16 *) GST_BUFFER_DATA (inbuffer);
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

  for (j = 0; j < 44100; j += 4) {
    *data = 0;
    ++data;
    *data = 32767;
    ++data;
    *data = 0;
    ++data;
    *data = -32767;
    ++data;
  }

  caps = gst_caps_from_string (SPECT_CAPS_STRING_S16);
  gst_buffer_set_caps (inbuffer, caps);
  gst_caps_unref (caps);
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

  /* create a bus to get the spectrum message on */
  bus = gst_bus_new ();
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_element_set_bus (spectrum, bus);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);

  /* pushing gives away my reference ... */
  fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
  /* ... but it ends up being collected on the global buffer list */
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
  ASSERT_OBJECT_REFCOUNT (message, "message", 1);

  fail_unless (message != NULL);
  fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
  fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
  structure = gst_message_get_structure (message);
  fail_if (structure == NULL);
  fail_unless_equals_string ((char *) gst_structure_get_name (structure),
      "spectrum");
  fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));

  list = gst_structure_get_value (structure, "magnitude");
  for (i = 0; i < SPECT_BANDS; ++i) {
    value = gst_value_list_get_value (list, i);
    level = g_value_get_float (value);
    GST_DEBUG ("band[%3d] is %.2f", i, level);
    /* Only the bands in the middle should have a level above 60 */
    fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
205
        && level < -20.0);
206
    fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
207
        && level > -20.0);
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
  }
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  /* clean up */
  /* flush current messages,and future state change messages */
  gst_bus_set_flushing (bus, TRUE);

  /* message has a ref to the element */
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
  gst_message_unref (message);
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);

  gst_element_set_bus (spectrum, NULL);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_object_unref (bus);
  gst_buffer_unref (outbuffer);
  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
  cleanup_spectrum (spectrum);
}

GST_END_TEST;

GST_START_TEST (test_int32)
{
  GstElement *spectrum;
  GstBuffer *inbuffer, *outbuffer;
  GstBus *bus;
  GstCaps *caps;
  GstMessage *message;
  const GstStructure *structure;
  int i, j;
  gint32 *data;
  const GValue *list, *value;
  GstClockTime endtime;
  gfloat level;

  spectrum = setup_spectrum ();
  g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
      "bands", SPECT_BANDS, "threshold", -80, NULL);

  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
      "could not set to playing");

  /* create a 1 sec buffer with an 11025 Hz sine wave */
  inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gint32));
  data = (gint32 *) GST_BUFFER_DATA (inbuffer);
  for (j = 0; j < 44100; j += 4) {
    *data = 0;
    ++data;
    *data = 2147483647;
    ++data;
    *data = 0;
    ++data;
    *data = -2147483647;
    ++data;
  }
  caps = gst_caps_from_string (SPECT_CAPS_STRING_S32);
  gst_buffer_set_caps (inbuffer, caps);
  gst_caps_unref (caps);
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

  /* create a bus to get the spectrum message on */
  bus = gst_bus_new ();
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_element_set_bus (spectrum, bus);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);

  /* pushing gives away my reference ... */
  fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
  /* ... but it ends up being collected on the global buffer list */
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
  ASSERT_OBJECT_REFCOUNT (message, "message", 1);

  fail_unless (message != NULL);
  fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
  fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
  structure = gst_message_get_structure (message);
  fail_if (structure == NULL);
  fail_unless_equals_string ((char *) gst_structure_get_name (structure),
      "spectrum");
  fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));

  list = gst_structure_get_value (structure, "magnitude");
  for (i = 0; i < SPECT_BANDS; ++i) {
    value = gst_value_list_get_value (list, i);
    level = g_value_get_float (value);
    GST_DEBUG ("band[%3d] is %.2f", i, level);
    /* Only the bands in the middle should have a level above 60 */
    fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
307
        && level < -20.0);
308
    fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
309
        && level > -20.0);
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
  }
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  /* clean up */
  /* flush current messages,and future state change messages */
  gst_bus_set_flushing (bus, TRUE);

  /* message has a ref to the element */
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
  gst_message_unref (message);
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);

  gst_element_set_bus (spectrum, NULL);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_object_unref (bus);
  gst_buffer_unref (outbuffer);
  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
  cleanup_spectrum (spectrum);
}

GST_END_TEST;

GST_START_TEST (test_float32)
{
  GstElement *spectrum;
  GstBuffer *inbuffer, *outbuffer;
  GstBus *bus;
  GstCaps *caps;
  GstMessage *message;
  const GstStructure *structure;
  int i, j;
  gfloat *data;
  const GValue *list, *value;
  GstClockTime endtime;
  gfloat level;

  spectrum = setup_spectrum ();
  g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
      "bands", SPECT_BANDS, "threshold", -80, NULL);

  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
      "could not set to playing");

  /* create a 1 sec buffer with an 11025 Hz sine wave */
  inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gfloat));
  data = (gfloat *) GST_BUFFER_DATA (inbuffer);
  for (j = 0; j < 44100; j += 4) {
    *data = 0.0;
    ++data;
    *data = 1.0;
    ++data;
    *data = 0.0;
    ++data;
    *data = -1.0;
    ++data;
  }
  caps = gst_caps_from_string (SPECT_CAPS_STRING_F32);
  gst_buffer_set_caps (inbuffer, caps);
  gst_caps_unref (caps);
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

  /* create a bus to get the spectrum message on */
  bus = gst_bus_new ();
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_element_set_bus (spectrum, bus);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);

  /* pushing gives away my reference ... */
  fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
  /* ... but it ends up being collected on the global buffer list */
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
  ASSERT_OBJECT_REFCOUNT (message, "message", 1);

  fail_unless (message != NULL);
  fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
  fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
  structure = gst_message_get_structure (message);
  fail_if (structure == NULL);
  fail_unless_equals_string ((char *) gst_structure_get_name (structure),
      "spectrum");
  fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));

  list = gst_structure_get_value (structure, "magnitude");
  for (i = 0; i < SPECT_BANDS; ++i) {
    value = gst_value_list_get_value (list, i);
    level = g_value_get_float (value);
    GST_DEBUG ("band[%3d] is %.2f", i, level);
    /* Only the bands in the middle should have a level above 60 */
    fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
409
        && level < -20.0);
410
    fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
411
        && level > -20.0);
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
  }
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  /* clean up */
  /* flush current messages,and future state change messages */
  gst_bus_set_flushing (bus, TRUE);

  /* message has a ref to the element */
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
  gst_message_unref (message);
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);

  gst_element_set_bus (spectrum, NULL);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_object_unref (bus);
  gst_buffer_unref (outbuffer);
  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
  cleanup_spectrum (spectrum);
}

GST_END_TEST;

GST_START_TEST (test_float64)
{
  GstElement *spectrum;
  GstBuffer *inbuffer, *outbuffer;
  GstBus *bus;
  GstCaps *caps;
  GstMessage *message;
  const GstStructure *structure;
  int i, j;
  gdouble *data;
  const GValue *list, *value;
  GstClockTime endtime;
  gfloat level;

  spectrum = setup_spectrum ();
  g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
      "bands", SPECT_BANDS, "threshold", -80, NULL);

  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
      "could not set to playing");

  /* create a 1 sec buffer with an 11025 Hz sine wave */
  inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gdouble));
  data = (gdouble *) GST_BUFFER_DATA (inbuffer);
  for (j = 0; j < 44100; j += 4) {
    *data = 0.0;
    ++data;
    *data = 1.0;
    ++data;
    *data = 0.0;
    ++data;
    *data = -1.0;
471
472
    ++data;
  }
473
  caps = gst_caps_from_string (SPECT_CAPS_STRING_F64);
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
  gst_buffer_set_caps (inbuffer, caps);
  gst_caps_unref (caps);
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);

  /* create a bus to get the spectrum message on */
  bus = gst_bus_new ();
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_element_set_bus (spectrum, bus);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);

  /* pushing gives away my reference ... */
  fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
  /* ... but it ends up being collected on the global buffer list */
  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
  ASSERT_OBJECT_REFCOUNT (message, "message", 1);

  fail_unless (message != NULL);
  fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
  fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
  structure = gst_message_get_structure (message);
  fail_if (structure == NULL);
  fail_unless_equals_string ((char *) gst_structure_get_name (structure),
      "spectrum");
  fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));

504
  list = gst_structure_get_value (structure, "magnitude");
505
506
  for (i = 0; i < SPECT_BANDS; ++i) {
    value = gst_value_list_get_value (list, i);
507
508
509
510
    level = g_value_get_float (value);
    GST_DEBUG ("band[%3d] is %.2f", i, level);
    /* Only the bands in the middle should have a level above 60 */
    fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
511
        && level < -20.0);
512
    fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
513
        && level > -20.0);
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
  }
  fail_unless_equals_int (g_list_length (buffers), 1);
  fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
  fail_unless (inbuffer == outbuffer);

  /* clean up */
  /* flush current messages,and future state change messages */
  gst_bus_set_flushing (bus, TRUE);

  /* message has a ref to the element */
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
  gst_message_unref (message);
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);

  gst_element_set_bus (spectrum, NULL);
  ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
  gst_object_unref (bus);
  gst_buffer_unref (outbuffer);
  fail_unless (gst_element_set_state (spectrum,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
  ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
  cleanup_spectrum (spectrum);
}

GST_END_TEST;


Suite *
spectrum_suite (void)
{
  Suite *s = suite_create ("spectrum");
  TCase *tc_chain = tcase_create ("general");

  suite_add_tcase (s, tc_chain);
  tcase_add_test (tc_chain, test_int16);
549
550
551
  tcase_add_test (tc_chain, test_int32);
  tcase_add_test (tc_chain, test_float32);
  tcase_add_test (tc_chain, test_float64);
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571

  return s;
}

int
main (int argc, char **argv)
{
  int nf;

  Suite *s = spectrum_suite ();
  SRunner *sr = srunner_create (s);

  gst_check_init (&argc, &argv);

  srunner_run_all (sr, CK_NORMAL);
  nf = srunner_ntests_failed (sr);
  srunner_free (sr);

  return nf;
}