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)
45 static guint8 mp3_frame[384] = {
46 0xff, 0xfb, 0x94, 0xc4, 0xff, 0x83, 0xc0, 0x00,
47 0x01, 0xa4, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
48 0x34, 0x80, 0x00, 0x00, 0x04, 0x00,
51 static guint8 garbage_frame[] = {
52 0xff, 0xff, 0xff, 0xff, 0xff
56 GST_START_TEST (test_parse_normal)
58 gst_parser_test_normal (mp3_frame, sizeof (mp3_frame));
64 GST_START_TEST (test_parse_drain_single)
66 gst_parser_test_drain_single (mp3_frame, sizeof (mp3_frame));
72 GST_START_TEST (test_parse_drain_garbage)
74 gst_parser_test_drain_garbage (mp3_frame, sizeof (mp3_frame),
75 garbage_frame, sizeof (garbage_frame));
81 GST_START_TEST (test_parse_split)
83 gst_parser_test_split (mp3_frame, sizeof (mp3_frame));
89 GST_START_TEST (test_parse_skip_garbage)
91 gst_parser_test_skip_garbage (mp3_frame, sizeof (mp3_frame),
92 garbage_frame, sizeof (garbage_frame));
98 #define structure_get_int(s,f) \
99 (g_value_get_int(gst_structure_get_value(s,f)))
100 #define fail_unless_structure_field_int_equals(s,field,num) \
101 fail_unless_equals_int (structure_get_int(s,field), num)
103 GST_START_TEST (test_parse_detect_stream)
108 caps = gst_parser_test_get_output_caps (mp3_frame, sizeof (mp3_frame), NULL);
110 fail_unless (caps != NULL);
112 GST_LOG ("mpegaudio output caps: %" GST_PTR_FORMAT, caps);
113 s = gst_caps_get_structure (caps, 0);
114 fail_unless (gst_structure_has_name (s, "audio/mpeg"));
115 fail_unless_structure_field_int_equals (s, "mpegversion", 1);
116 fail_unless_structure_field_int_equals (s, "layer", 3);
117 fail_unless_structure_field_int_equals (s, "channels", 1);
118 fail_unless_structure_field_int_equals (s, "rate", 48000);
120 gst_caps_unref (caps);
127 mpegaudioparse_suite (void)
129 Suite *s = suite_create ("mpegaudioparse");
130 TCase *tc_chain = tcase_create ("general");
132 suite_add_tcase (s, tc_chain);
133 tcase_add_test (tc_chain, test_parse_normal);
134 tcase_add_test (tc_chain, test_parse_drain_single);
135 tcase_add_test (tc_chain, test_parse_drain_garbage);
136 tcase_add_test (tc_chain, test_parse_split);
137 tcase_add_test (tc_chain, test_parse_skip_garbage);
138 tcase_add_test (tc_chain, test_parse_detect_stream);
146 * - Both push- and pull-modes need to be tested
151 main (int argc, char **argv)
155 Suite *s = mpegaudioparse_suite ();
156 SRunner *sr = srunner_create (s);
158 gst_check_init (&argc, &argv);
160 /* init test context */
161 ctx_factory = "mpegaudioparse";
162 ctx_sink_template = &sinktemplate;
163 ctx_src_template = &srctemplate;
165 srunner_run_all (sr, CK_NORMAL);
166 nf = srunner_ntests_failed (sr);