1 /* GStreamer unit tests for matroskaparse
2 * Copyright (C) 2011 Tim-Philipp Müller <tim centricular net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <gst/check/gstcheck.h>
25 run_check_for_file (const gchar * file_name, gboolean push_mode)
27 GstStateChangeReturn state_ret;
29 GstElement *src, *sep, *sink, *matroskaparse, *pipeline;
33 pipeline = gst_pipeline_new ("pipeline");
34 fail_unless (pipeline != NULL, "Failed to create pipeline!");
36 bus = gst_element_get_bus (pipeline);
38 src = gst_element_factory_make ("filesrc", "filesrc");
39 fail_unless (src != NULL, "Failed to create 'filesrc' element!");
42 sep = gst_element_factory_make ("queue", "queue");
43 fail_unless (sep != NULL, "Failed to create 'queue' element");
45 sep = gst_element_factory_make ("identity", "identity");
46 fail_unless (sep != NULL, "Failed to create 'identity' element");
49 matroskaparse = gst_element_factory_make ("matroskaparse", "matroskaparse");
50 fail_unless (matroskaparse != NULL, "Failed to create matroskaparse element");
52 sink = gst_element_factory_make ("fakesink", "fakesink");
53 fail_unless (sink != NULL, "Failed to create 'fakesink' element!");
55 gst_bin_add_many (GST_BIN (pipeline), src, sep, matroskaparse, sink, NULL);
57 fail_unless (gst_element_link (src, sep));
58 fail_unless (gst_element_link (sep, matroskaparse));
59 fail_unless (gst_element_link (matroskaparse, sink));
61 path = g_build_filename (GST_TEST_FILES_PATH, file_name, NULL);
62 GST_LOG ("reading file '%s'", path);
63 g_object_set (src, "location", path, NULL);
65 state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
66 fail_unless (state_ret != GST_STATE_CHANGE_FAILURE);
68 if (state_ret == GST_STATE_CHANGE_ASYNC) {
69 GST_LOG ("waiting for pipeline to reach PAUSED state");
70 state_ret = gst_element_get_state (pipeline, NULL, NULL, -1);
71 fail_unless_equals_int (state_ret, GST_STATE_CHANGE_SUCCESS);
74 GST_LOG ("PAUSED, let's play a little..");
75 state_ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
76 fail_unless (state_ret != GST_STATE_CHANGE_FAILURE);
78 msg = gst_bus_poll (bus, GST_MESSAGE_EOS, -1);
79 fail_unless (msg != NULL, "Expected EOS message on bus! (%s)", file_name);
81 gst_message_unref (msg);
82 gst_object_unref (bus);
84 fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_NULL),
85 GST_STATE_CHANGE_SUCCESS);
86 gst_object_unref (pipeline);
91 GST_START_TEST (test_parse_file_pull)
93 run_check_for_file ("pinknoise-vorbis.mkv", TRUE);
98 GST_START_TEST (test_parse_file_push)
100 run_check_for_file ("pinknoise-vorbis.mkv", FALSE);
106 matroskaparse_suite (void)
108 Suite *s = suite_create ("matroskaparse");
109 TCase *tc_chain = tcase_create ("general");
111 suite_add_tcase (s, tc_chain);
112 tcase_add_test (tc_chain, test_parse_file_pull);
113 tcase_add_test (tc_chain, test_parse_file_push);
118 GST_CHECK_MAIN (matroskaparse)