|
1 /* GStreamer |
|
2 * Copyright (C) 2005 Andy Wingo <wingo@pobox.com> |
|
3 * |
|
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. |
|
8 * |
|
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. |
|
13 * |
|
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. |
|
18 */ |
|
19 |
|
20 |
|
21 #define LOG_FILE "c:\\logs\\stress_logs.txt" |
|
22 #include "std_log_result.h" |
|
23 #include <gst/gst_global.h> |
|
24 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
25 |
|
26 void create_xml(int result) |
|
27 { |
|
28 if(result) |
|
29 assert_failed = 1; |
|
30 |
|
31 testResultXml(xmlfile); |
|
32 close_log_file(); |
|
33 } |
|
34 |
|
35 #include <gst/check/gstcheck.h> |
|
36 |
|
37 static int playing = 1; |
|
38 static int quit = 0; |
|
39 |
|
40 static gboolean |
|
41 change_state_timeout (gpointer data) |
|
42 { |
|
43 GstElement *pipeline = (GstElement *) data; |
|
44 |
|
45 if (quit) |
|
46 return FALSE; |
|
47 |
|
48 if (playing) { |
|
49 playing = 0; |
|
50 gst_element_set_state (pipeline, GST_STATE_NULL); |
|
51 } else { |
|
52 playing = 1; |
|
53 gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
54 } |
|
55 |
|
56 return TRUE; |
|
57 } |
|
58 |
|
59 static gboolean |
|
60 quit_timeout (gpointer data) |
|
61 { |
|
62 quit = 1; |
|
63 return FALSE; |
|
64 } |
|
65 |
|
66 void test_stress_preroll() |
|
67 { |
|
68 GstElement *fakesrc, *fakesink; |
|
69 GstElement *pipeline; |
|
70 xmlfile = "test_stress_preroll"; |
|
71 std_log(LOG_FILENAME_LINE, "Test Started test_stress_preroll"); |
|
72 |
|
73 fakesrc = gst_element_factory_make ("fakesrc", NULL); |
|
74 fakesink = gst_element_factory_make ("fakesink", NULL); |
|
75 pipeline = gst_element_factory_make ("pipeline", NULL); |
|
76 |
|
77 g_return_if_fail (fakesrc && fakesink && pipeline); |
|
78 |
|
79 g_object_set (G_OBJECT (fakesink), "preroll-queue-len", 4, NULL); |
|
80 |
|
81 gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL); |
|
82 gst_element_link (fakesrc, fakesink); |
|
83 |
|
84 gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
85 |
|
86 g_timeout_add (500, &change_state_timeout, pipeline); |
|
87 g_timeout_add (10000, &quit_timeout, NULL); |
|
88 |
|
89 while (!quit) { |
|
90 g_main_context_iteration (NULL, TRUE); |
|
91 } |
|
92 |
|
93 gst_element_set_state (pipeline, GST_STATE_NULL); |
|
94 gst_object_unref (pipeline); |
|
95 |
|
96 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
97 create_xml(0); |
|
98 |
|
99 |
|
100 } |
|
101 |
|
102 |
|
103 |
|
104 void test_stress() |
|
105 { |
|
106 GstElement *fakesrc, *fakesink, *pipeline; |
|
107 gint i; |
|
108 |
|
109 xmlfile = "test_stress"; |
|
110 std_log(LOG_FILENAME_LINE, "Test Started test_stress"); |
|
111 |
|
112 fakesrc = gst_element_factory_make ("fakesrc", NULL); |
|
113 fakesink = gst_element_factory_make ("fakesink", NULL); |
|
114 pipeline = gst_element_factory_make ("pipeline", NULL); |
|
115 |
|
116 g_return_if_fail (fakesrc && fakesink && pipeline); |
|
117 |
|
118 gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL); |
|
119 gst_element_link (fakesrc, fakesink); |
|
120 |
|
121 i = 100; |
|
122 while (i--) { |
|
123 gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
124 gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
125 |
|
126 gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
127 gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
128 gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
129 gst_element_set_state (pipeline, GST_STATE_READY); |
|
130 gst_element_set_state (pipeline, GST_STATE_PLAYING); |
|
131 gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
132 gst_element_set_state (pipeline, GST_STATE_READY); |
|
133 gst_element_set_state (pipeline, GST_STATE_PAUSED); |
|
134 gst_element_set_state (pipeline, GST_STATE_NULL); |
|
135 } |
|
136 |
|
137 gst_object_unref (pipeline); |
|
138 |
|
139 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
140 create_xml(0); |
|
141 |
|
142 } |
|
143 |
|
144 stress_suite (void) |
|
145 { |
|
146 test_stress(); |
|
147 test_stress_preroll(); |
|
148 } |
|
149 |
|
150 |
|
151 |
|
152 void (*fn[2]) (void) = { |
|
153 test_stress_preroll, |
|
154 test_stress, |
|
155 |
|
156 }; |
|
157 |
|
158 char *args[] = { |
|
159 "test_stress_preroll", |
|
160 "test_stress" |
|
161 |
|
162 }; |
|
163 |
|
164 GST_CHECK_MAIN (stress); |
|
165 |
|
166 /* |
|
167 void main() |
|
168 { |
|
169 gst_check_init (NULL, NULL); |
|
170 test_stress_preroll(); |
|
171 } |
|
172 */ |