4 * unit test for aacparse
6 * Copyright (C) 2008 Nokia Corporation. All rights reserved.
8 * Contact: Stefan Kost <stefan.kost@nokia.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
26 #include <gst/check/gstcheck.h>
29 #define SRC_CAPS_TMPL "audio/mpeg, parsed=(boolean)false, mpegversion=(int)1"
30 #define SINK_CAPS_TMPL "audio/mpeg, parsed=(boolean)true, mpegversion=(int)1"
32 GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
35 GST_STATIC_CAPS (SINK_CAPS_TMPL)
38 GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
41 GST_STATIC_CAPS (SRC_CAPS_TMPL)
44 const gchar *factory = "aacparse";
47 static guint8 mp3_frame[384] = {
48 0xff, 0xfb, 0x94, 0xc4, 0xff, 0x83, 0xc0, 0x00,
49 0x01, 0xa4, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
50 0x34, 0x80, 0x00, 0x00, 0x04, 0x00,
53 static guint8 garbage_frame[] = {
54 0xff, 0xff, 0xff, 0xff, 0xff
58 GST_START_TEST (test_parse_normal)
60 gst_parser_test_normal (mp3_frame, sizeof (mp3_frame));
66 GST_START_TEST (test_parse_drain_single)
68 gst_parser_test_drain_single (mp3_frame, sizeof (mp3_frame));
74 GST_START_TEST (test_parse_drain_garbage)
76 gst_parser_test_drain_garbage (mp3_frame, sizeof (mp3_frame),
77 garbage_frame, sizeof (garbage_frame));
83 GST_START_TEST (test_parse_split)
85 gst_parser_test_split (mp3_frame, sizeof (mp3_frame));
91 GST_START_TEST (test_parse_skip_garbage)
93 gst_parser_test_skip_garbage (mp3_frame, sizeof (mp3_frame),
94 garbage_frame, sizeof (garbage_frame));
100 #define structure_get_int(s,f) \
101 (g_value_get_int(gst_structure_get_value(s,f)))
102 #define fail_unless_structure_field_int_equals(s,field,num) \
103 fail_unless_equals_int (structure_get_int(s,field), num)
105 GST_START_TEST (test_parse_detect_stream)
110 caps = gst_parser_test_get_output_caps (mp3_frame, sizeof (mp3_frame), NULL);
112 fail_unless (caps != NULL);
114 GST_LOG ("mpegaudio output caps: %" GST_PTR_FORMAT, caps);
115 s = gst_caps_get_structure (caps, 0);
116 fail_unless (gst_structure_has_name (s, "audio/mpeg"));
117 fail_unless_structure_field_int_equals (s, "mpegversion", 1);
118 fail_unless_structure_field_int_equals (s, "layer", 3);
119 fail_unless_structure_field_int_equals (s, "channels", 1);
120 fail_unless_structure_field_int_equals (s, "rate", 48000);
122 gst_caps_unref (caps);
129 mpegaudioparse_suite (void)
131 Suite *s = suite_create ("mpegaudioparse");
132 TCase *tc_chain = tcase_create ("general");
134 suite_add_tcase (s, tc_chain);
135 tcase_add_test (tc_chain, test_parse_normal);
136 tcase_add_test (tc_chain, test_parse_drain_single);
137 tcase_add_test (tc_chain, test_parse_drain_garbage);
138 tcase_add_test (tc_chain, test_parse_split);
139 tcase_add_test (tc_chain, test_parse_skip_garbage);
140 tcase_add_test (tc_chain, test_parse_detect_stream);
148 * - Both push- and pull-modes need to be tested
153 main (int argc, char **argv)
157 Suite *s = mpegaudioparse_suite ();
158 SRunner *sr = srunner_create (s);
160 gst_check_init (&argc, &argv);
162 /* init test context */
163 ctx_factory = "mpegaudioparse";
164 ctx_sink_template = &sinktemplate;
165 ctx_src_template = &srctemplate;
167 srunner_run_all (sr, CK_NORMAL);
168 nf = srunner_ntests_failed (sr);