• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  *
3  * unit test for lame
4  *
5  * Copyright (C) 2007 Thomas Vander Stichele <thomas at apestaart dot org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #include <gst/check/gstcheck.h>
24 #include <gst/check/gstbufferstraw.h>
25 
26 #ifndef ENCODER
27 #define ENCODER "lamemp3enc"
28 #endif
29 
30 #ifndef GST_DISABLE_PARSE
31 
GST_START_TEST(test_format)32 GST_START_TEST (test_format)
33 {
34   GstElement *bin;
35   GstPad *pad;
36   gchar *pipe_str;
37   GstBuffer *buffer;
38   GError *error = NULL;
39 
40   pipe_str = g_strdup_printf ("audiotestsrc num-buffers=1 "
41       "! audio/x-raw, rate=22050, channels=1 "
42       "! " ENCODER " bitrate=24 ! audio/mpeg,rate=22050 ! fakesink");
43 
44   bin = gst_parse_launch (pipe_str, &error);
45   fail_unless (bin != NULL, "Error parsing pipeline: %s",
46       error ? error->message : "(invalid error)");
47   g_free (pipe_str);
48 
49   /* get the pad */
50   {
51     GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink0");
52 
53     fail_unless (sink != NULL, "Could not get fakesink out of bin");
54     pad = gst_element_get_static_pad (sink, "sink");
55     fail_unless (pad != NULL, "Could not get pad out of fakesink");
56     gst_object_unref (sink);
57   }
58 
59   gst_buffer_straw_start_pipeline (bin, pad);
60 
61   buffer = gst_buffer_straw_get_buffer (bin, pad);
62 
63   gst_buffer_straw_stop_pipeline (bin, pad);
64 
65   gst_buffer_unref (buffer);
66   gst_object_unref (pad);
67   gst_object_unref (bin);
68 }
69 
70 GST_END_TEST;
71 
GST_START_TEST(test_caps_proxy)72 GST_START_TEST (test_caps_proxy)
73 {
74   GstElement *bin;
75   GstPad *pad;
76   gchar *pipe_str;
77   GstBuffer *buffer;
78   GError *error = NULL;
79 
80   pipe_str = g_strdup_printf ("audiotestsrc num-buffers=1 "
81       "! audio/x-raw,rate=48000,channels=1 "
82       "! audioresample "
83       "! " ENCODER " ! audio/mpeg,rate=(int){22050,44100} ! fakesink");
84 
85   bin = gst_parse_launch (pipe_str, &error);
86   fail_unless (bin != NULL, "Error parsing pipeline: %s",
87       error ? error->message : "(invalid error)");
88   g_free (pipe_str);
89 
90   /* get the pad */
91   {
92     GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink0");
93 
94     fail_unless (sink != NULL, "Could not get fakesink out of bin");
95     pad = gst_element_get_static_pad (sink, "sink");
96     fail_unless (pad != NULL, "Could not get pad out of fakesink");
97     gst_object_unref (sink);
98   }
99 
100   gst_buffer_straw_start_pipeline (bin, pad);
101 
102   buffer = gst_buffer_straw_get_buffer (bin, pad);
103 
104   gst_buffer_straw_stop_pipeline (bin, pad);
105 
106   gst_buffer_unref (buffer);
107   gst_object_unref (pad);
108   gst_object_unref (bin);
109 }
110 
111 GST_END_TEST;
112 
113 #endif /* #ifndef GST_DISABLE_PARSE */
114 
115 static Suite *
lame_suite(void)116 lame_suite (void)
117 {
118   Suite *s = suite_create (ENCODER);
119   TCase *tc_chain = tcase_create ("general");
120 
121   suite_add_tcase (s, tc_chain);
122 
123 #ifndef GST_DISABLE_PARSE
124   tcase_add_test (tc_chain, test_format);
125   tcase_add_test (tc_chain, test_caps_proxy);
126 #endif
127 
128   return s;
129 }
130 
131 GST_CHECK_MAIN (lame);
132