2 * Copyright (C) 2005 Benjamin Otte <otte@gnome.org>
4 * channelmixtest.c: simple test of channel mixing
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
26 #include "gstchannelmix.h"
30 main (gint argc, gchar ** argv)
32 GstElement *bin, *src, *sink;
40 gfloat matrix[6][6]; /* use a predefined matrix here, makes stuff simpler */
44 "audio/x-raw, channels=2", "audio/x-raw, channels=1", { {
49 "audio/x-raw, channels=1", "audio/x-raw, channels=2", { {
53 gst_init (&argc, &argv);
55 for (i = 0; i < G_N_ELEMENTS (tests); i++) {
56 g_print ("running test %u\n", i);
57 bin = gst_element_factory_make ("pipeline", NULL);
58 c = g_object_new (GST_TYPE_AUDIO_CONVERT, NULL);
59 /* avoid gst being braindead */
60 gst_object_set_name (GST_OBJECT (c), "shuddup");
61 src = gst_element_factory_make ("fakesrc", NULL);
62 sink = gst_element_factory_make ("fakesink", NULL);
63 gst_bin_add_many (GST_BIN (bin), src, c, sink, NULL);
64 caps = gst_caps_from_string (tests[i].sinkcaps);
66 if (!gst_element_link_filtered (src, GST_ELEMENT (c), caps))
67 g_assert_not_reached ();
68 gst_caps_unref (caps);
69 caps = gst_caps_from_string (tests[i].srccaps);
71 if (!gst_element_link_filtered (GST_ELEMENT (c), sink, caps))
72 g_assert_not_reached ();
73 gst_caps_unref (caps);
74 if (!gst_element_set_state (bin, GST_STATE_PLAYING))
75 g_assert_not_reached ();
76 g_assert (c->srccaps.channels <= 6);
77 g_assert (c->sinkcaps.channels <= 6);
78 for (j = 0; j < 6; j++) {
79 for (k = 0; k < 6; k++) {
80 if (j < c->sinkcaps.channels && k < c->srccaps.channels) {
81 if (tests[i].matrix[j][k] != c->matrix[j][k]) {
82 g_printerr ("matrix[j][k] should be %g but is %g\n",
83 tests[i].matrix[j][k], c->matrix[j][k]);
84 g_assert_not_reached ();
87 g_assert (tests[i].matrix[j][k] == 0);
91 gst_object_unref (bin);