mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-03 16:09:39 +00:00
tests: add a test for wav muxing
This commit is contained in:
parent
35232cd490
commit
4843424da3
3 changed files with 183 additions and 0 deletions
|
@ -143,6 +143,7 @@ check_PROGRAMS = \
|
||||||
elements/y4menc \
|
elements/y4menc \
|
||||||
pipelines/simple-launch-lines \
|
pipelines/simple-launch-lines \
|
||||||
pipelines/effectv \
|
pipelines/effectv \
|
||||||
|
pipelines/wavenc \
|
||||||
$(check_flac) \
|
$(check_flac) \
|
||||||
$(check_gdkpixbuf) \
|
$(check_gdkpixbuf) \
|
||||||
$(check_jpeg) \
|
$(check_jpeg) \
|
||||||
|
@ -236,6 +237,9 @@ elements_gdkpixbufsink_LDADD = \
|
||||||
$(LDADD) $(GDK_PIXBUF_LIBS)
|
$(LDADD) $(GDK_PIXBUF_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
pipelines_wavenc_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
|
||||||
|
pipelines_wavenc_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(LDADD)
|
||||||
|
|
||||||
pipelines_wavpack_LDADD = $(LDADD) $(GST_BASE_LIBS)
|
pipelines_wavpack_LDADD = $(LDADD) $(GST_BASE_LIBS)
|
||||||
pipelines_wavpack_CFLAGS = $(GST_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
|
pipelines_wavpack_CFLAGS = $(GST_BASE_CFLAGS) $(CFLAGS) $(AM_CFLAGS)
|
||||||
|
|
||||||
|
|
1
tests/check/pipelines/.gitignore
vendored
1
tests/check/pipelines/.gitignore
vendored
|
@ -2,5 +2,6 @@
|
||||||
effectv
|
effectv
|
||||||
flacdec
|
flacdec
|
||||||
simple-launch-lines
|
simple-launch-lines
|
||||||
|
wavenc
|
||||||
wavpack
|
wavpack
|
||||||
*.check.xml
|
*.check.xml
|
||||||
|
|
178
tests/check/pipelines/wavenc.c
Normal file
178
tests/check/pipelines/wavenc.c
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
/* GStreamer
|
||||||
|
*
|
||||||
|
* unit test for wavenc
|
||||||
|
*
|
||||||
|
* Copyright (C) <2010> 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 <gst/check/gstcheck.h>
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
bus_handler (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
|
{
|
||||||
|
GMainLoop *loop = (GMainLoop *) data;
|
||||||
|
|
||||||
|
switch (message->type) {
|
||||||
|
case GST_MESSAGE_EOS:
|
||||||
|
g_main_loop_quit (loop);
|
||||||
|
break;
|
||||||
|
case GST_MESSAGE_WARNING:
|
||||||
|
case GST_MESSAGE_ERROR:{
|
||||||
|
GError *gerror;
|
||||||
|
gchar *debug;
|
||||||
|
|
||||||
|
gst_message_parse_error (message, &gerror, &debug);
|
||||||
|
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
|
||||||
|
gst_message_unref (message);
|
||||||
|
g_error_free (gerror);
|
||||||
|
g_free (debug);
|
||||||
|
g_main_loop_quit (loop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gst-launch \
|
||||||
|
* audiotestsrc freq=440 num-buffers=100 ! interleave name=i ! wavenc ! filesink location=/tmp/mc.wav \
|
||||||
|
* audiotestsrc freq=880 num-buffers=100 ! i.
|
||||||
|
* ...
|
||||||
|
*
|
||||||
|
* http://www.microsoft.com/whdc/device/audio/multichaud.mspx
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
make_n_channel_wav (const gint channels, const GValueArray * arr)
|
||||||
|
{
|
||||||
|
GstElement *pipeline;
|
||||||
|
GstElement *audiotestsrc[channels], *interleave, *wavenc, *fakesink;
|
||||||
|
GstBus *bus;
|
||||||
|
GMainLoop *loop;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
|
fail_unless (pipeline != NULL);
|
||||||
|
|
||||||
|
interleave = gst_element_factory_make ("interleave", NULL);
|
||||||
|
fail_unless (interleave != NULL);
|
||||||
|
g_object_set (interleave, "channel-positions", arr, NULL);
|
||||||
|
gst_bin_add (GST_BIN (pipeline), interleave);
|
||||||
|
|
||||||
|
wavenc = gst_element_factory_make ("wavenc", NULL);
|
||||||
|
fail_unless (wavenc != NULL);
|
||||||
|
gst_bin_add (GST_BIN (pipeline), wavenc);
|
||||||
|
fail_unless (gst_element_link (interleave, wavenc));
|
||||||
|
|
||||||
|
fakesink = gst_element_factory_make ("fakesink", NULL);
|
||||||
|
fail_unless (fakesink != NULL);
|
||||||
|
gst_bin_add (GST_BIN (pipeline), fakesink);
|
||||||
|
fail_unless (gst_element_link (wavenc, fakesink));
|
||||||
|
|
||||||
|
for (i = 0; i < channels; i++) {
|
||||||
|
audiotestsrc[i] = gst_element_factory_make ("audiotestsrc", NULL);
|
||||||
|
fail_unless (audiotestsrc[i] != NULL);
|
||||||
|
g_object_set (G_OBJECT (audiotestsrc[i]), "wave", 0, "freq", 440.0 * i,
|
||||||
|
"num-buffers", 100, NULL);
|
||||||
|
gst_bin_add (GST_BIN (pipeline), audiotestsrc[i]);
|
||||||
|
fail_unless (gst_element_link (audiotestsrc[i], interleave));
|
||||||
|
}
|
||||||
|
|
||||||
|
loop = g_main_loop_new (NULL, TRUE);
|
||||||
|
fail_unless (loop != NULL);
|
||||||
|
|
||||||
|
bus = gst_element_get_bus (pipeline);
|
||||||
|
fail_unless (bus != NULL);
|
||||||
|
gst_bus_add_watch (bus, bus_handler, loop);
|
||||||
|
gst_object_unref (bus);
|
||||||
|
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
g_main_loop_run (loop);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_START_TEST (test_encode_stereo)
|
||||||
|
{
|
||||||
|
GValueArray *arr;
|
||||||
|
GValue val = { 0, };
|
||||||
|
|
||||||
|
arr = g_value_array_new (2);
|
||||||
|
g_value_init (&val, GST_TYPE_AUDIO_CHANNEL_POSITION);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_reset (&val);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_unset (&val);
|
||||||
|
|
||||||
|
make_n_channel_wav (2, arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_encode_multichannel)
|
||||||
|
{
|
||||||
|
GValueArray *arr;
|
||||||
|
GValue val = { 0, };
|
||||||
|
|
||||||
|
arr = g_value_array_new (6);
|
||||||
|
g_value_init (&val, GST_TYPE_AUDIO_CHANNEL_POSITION);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_reset (&val);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_reset (&val);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_reset (&val);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_LFE);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_reset (&val);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_reset (&val);
|
||||||
|
g_value_set_enum (&val, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT);
|
||||||
|
g_value_array_append (arr, &val);
|
||||||
|
g_value_unset (&val);
|
||||||
|
|
||||||
|
make_n_channel_wav (6);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
wavenc_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("wavenc");
|
||||||
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test (tc_chain, test_encode_stereo);
|
||||||
|
/* FIXME: improve wavenc
|
||||||
|
tcase_add_test (tc_chain, test_encode_multichannel);
|
||||||
|
*/
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_CHECK_MAIN (wavenc);
|
Loading…
Reference in a new issue