| 1 |
#include "common.h" |
| 2 |
|
| 3 |
GST_START_TEST (test_simple_videotestsrc) |
| 4 |
{ |
| 5 |
GstElement *pipeline; |
| 6 |
GstElement *nlesource, *sink; |
| 7 |
CollectStructure *collect; |
| 8 |
GstBus *bus; |
| 9 |
GstMessage *message; |
| 10 |
gboolean carry_on = TRUE; |
| 11 |
GstPad *sinkpad; |
| 12 |
|
| 13 |
ges_init (); |
| 14 |
|
| 15 |
pipeline = gst_pipeline_new ("test_pipeline"); |
| 16 |
|
| 17 |
/* |
| 18 |
Source 1 |
| 19 |
Start : 1s |
| 20 |
Duration : 1s |
| 21 |
Priority : 1 |
| 22 |
*/ |
| 23 |
nlesource = |
| 24 |
videotest_nle_src ("source1", 1 * GST_SECOND, 1 * GST_SECOND, 2, 1); |
| 25 |
fail_if (nlesource == NULL); |
| 26 |
check_start_stop_duration (nlesource, 1 * GST_SECOND, 2 * GST_SECOND, |
| 27 |
1 * GST_SECOND); |
| 28 |
|
| 29 |
sink = gst_element_factory_make_or_warn ("fakevideosink", "sink"); |
| 30 |
fail_if (sink == NULL); |
| 31 |
g_object_set (sink, "sync", FALSE, NULL); |
| 32 |
|
| 33 |
gst_bin_add_many (GST_BIN (pipeline), nlesource, sink, NULL); |
| 34 |
|
| 35 |
/* Shared data */ |
| 36 |
collect = g_new0 (CollectStructure, 1); |
| 37 |
collect->comp = nlesource; |
| 38 |
collect->sink = sink; |
| 39 |
|
| 40 |
/* Expected segments */ |
| 41 |
collect->expected_segments = g_list_append (collect->expected_segments, |
| 42 |
segment_new (1.0, GST_FORMAT_TIME, |
| 43 |
1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND)); |
| 44 |
|
| 45 |
gst_element_link (nlesource, sink); |
| 46 |
|
| 47 |
sinkpad = gst_element_get_static_pad (sink, "sink"); |
| 48 |
fail_if (sinkpad == NULL); |
| 49 |
gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM, |
| 50 |
(GstPadProbeCallback) sinkpad_probe, collect, NULL); |
| 51 |
|
| 52 |
bus = gst_element_get_bus (pipeline); |
| 53 |
|
| 54 |
GST_DEBUG ("Setting pipeline to PLAYING"); |
| 55 |
ASSERT_OBJECT_REFCOUNT (nlesource, "nlesource", 1); |
| 56 |
|
| 57 |
fail_if (gst_element_set_state (GST_ELEMENT (pipeline), |
| 58 |
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE); |
| 59 |
|
| 60 |
GST_DEBUG ("Let's poll the bus"); |
| 61 |
|
| 62 |
while (carry_on) { |
| 63 |
message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10); |
| 64 |
GST_LOG ("poll"); |
| 65 |
if (message) { |
| 66 |
switch (GST_MESSAGE_TYPE (message)) { |
| 67 |
case GST_MESSAGE_EOS: |
| 68 |
/* we should check if we really finished here */ |
| 69 |
GST_WARNING ("Got an EOS"); |
| 70 |
carry_on = FALSE; |
| 71 |
break; |
| 72 |
case GST_MESSAGE_SEGMENT_START: |
| 73 |
case GST_MESSAGE_SEGMENT_DONE: |
| 74 |
/* We shouldn't see any segement messages, since we didn't do a segment seek */ |
| 75 |
GST_WARNING ("Saw a Segment start/stop"); |
| 76 |
fail_if (FALSE); |
| 77 |
carry_on = FALSE; |
| 78 |
break; |
| 79 |
case GST_MESSAGE_ERROR: |
| 80 |
fail_error_message (message); |
| 81 |
default: |
| 82 |
break; |
| 83 |
} |
| 84 |
gst_mini_object_unref (GST_MINI_OBJECT (message)); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
GST_DEBUG ("Setting pipeline to NULL"); |
| 89 |
|
| 90 |
fail_if (gst_element_set_state (GST_ELEMENT (pipeline), |
| 91 |
GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE); |
| 92 |
|
| 93 |
fail_if (collect->expected_segments != NULL); |
| 94 |
|
| 95 |
gst_object_unref (GST_OBJECT (sinkpad)); |
| 96 |
|
| 97 |
GST_DEBUG ("Resetted pipeline to NULL"); |
| 98 |
|
| 99 |
gst_object_unref (pipeline); |
| 100 |
gst_object_unref (bus); |
| 101 |
|
| 102 |
g_free (collect); |
| 103 |
|
| 104 |
ges_deinit (); |
| 105 |
} |
| 106 |
|
| 107 |
GST_END_TEST; |
| 108 |
|
| 109 |
GST_START_TEST (test_videotestsrc_in_bin) |
| 110 |
{ |
| 111 |
GstElement *pipeline; |
| 112 |
GstElement *nlesource, *sink; |
| 113 |
CollectStructure *collect; |
| 114 |
GstBus *bus; |
| 115 |
GstMessage *message; |
| 116 |
gboolean carry_on = TRUE; |
| 117 |
GstPad *sinkpad; |
| 118 |
|
| 119 |
ges_init (); |
| 120 |
|
| 121 |
pipeline = gst_pipeline_new ("test_pipeline"); |
| 122 |
|
| 123 |
/* |
| 124 |
Source 1 |
| 125 |
Start : 1s |
| 126 |
Duration : 1s |
| 127 |
Priority : 1 |
| 128 |
*/ |
| 129 |
nlesource = videotest_in_bin_nle_src ("source1", 0, 1 * GST_SECOND, 2, 1); |
| 130 |
/* Handle systems which don't have alpha available */ |
| 131 |
if (nlesource == NULL) |
| 132 |
return; |
| 133 |
|
| 134 |
sink = gst_element_factory_make_or_warn ("fakevideosink", "sink"); |
| 135 |
fail_if (sink == NULL); |
| 136 |
g_object_set (sink, "sync", FALSE, NULL); |
| 137 |
|
| 138 |
gst_bin_add_many (GST_BIN (pipeline), nlesource, sink, NULL); |
| 139 |
|
| 140 |
/* Shared data */ |
| 141 |
collect = g_new0 (CollectStructure, 1); |
| 142 |
collect->comp = nlesource; |
| 143 |
collect->sink = sink; |
| 144 |
|
| 145 |
/* Expected segments */ |
| 146 |
collect->expected_segments = g_list_append (collect->expected_segments, |
| 147 |
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0)); |
| 148 |
|
| 149 |
gst_element_link (nlesource, sink); |
| 150 |
|
| 151 |
sinkpad = gst_element_get_static_pad (sink, "sink"); |
| 152 |
fail_if (sinkpad == NULL); |
| 153 |
gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM, |
| 154 |
(GstPadProbeCallback) sinkpad_probe, collect, NULL); |
| 155 |
|
| 156 |
bus = gst_element_get_bus (pipeline); |
| 157 |
|
| 158 |
GST_DEBUG ("Setting pipeline to PLAYING"); |
| 159 |
ASSERT_OBJECT_REFCOUNT (nlesource, "nlesource", 1); |
| 160 |
|
| 161 |
fail_if (gst_element_set_state (GST_ELEMENT (pipeline), |
| 162 |
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE); |
| 163 |
|
| 164 |
GST_DEBUG ("Let's poll the bus"); |
| 165 |
|
| 166 |
while (carry_on) { |
| 167 |
message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10); |
| 168 |
GST_LOG ("poll"); |
| 169 |
if (message) { |
| 170 |
switch (GST_MESSAGE_TYPE (message)) { |
| 171 |
case GST_MESSAGE_EOS: |
| 172 |
/* we should check if we really finished here */ |
| 173 |
GST_WARNING ("Got an EOS"); |
| 174 |
carry_on = FALSE; |
| 175 |
break; |
| 176 |
case GST_MESSAGE_SEGMENT_START: |
| 177 |
case GST_MESSAGE_SEGMENT_DONE: |
| 178 |
/* We shouldn't see any segement messages, since we didn't do a segment seek */ |
| 179 |
GST_WARNING ("Saw a Segment start/stop"); |
| 180 |
fail_if (FALSE); |
| 181 |
carry_on = FALSE; |
| 182 |
break; |
| 183 |
case GST_MESSAGE_ERROR: |
| 184 |
fail_error_message (message); |
| 185 |
default: |
| 186 |
break; |
| 187 |
} |
| 188 |
gst_mini_object_unref (GST_MINI_OBJECT (message)); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
GST_DEBUG ("Setting pipeline to NULL"); |
| 193 |
|
| 194 |
gst_object_unref (GST_OBJECT (sinkpad)); |
| 195 |
|
| 196 |
fail_if (gst_element_set_state (GST_ELEMENT (pipeline), |
| 197 |
GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE); |
| 198 |
|
| 199 |
fail_if (collect->expected_segments != NULL); |
| 200 |
|
| 201 |
GST_DEBUG ("Resetted pipeline to NULL"); |
| 202 |
|
| 203 |
gst_object_unref (pipeline); |
| 204 |
gst_object_unref (bus); |
| 205 |
|
| 206 |
g_free (collect); |
| 207 |
|
| 208 |
ges_deinit (); |
| 209 |
} |
| 210 |
|
| 211 |
GST_END_TEST; |
| 212 |
|
| 213 |
static Suite * |
| 214 |
gnonlin_suite (void) |
| 215 |
{ |
| 216 |
Suite *s = suite_create ("nlesource"); |
| 217 |
TCase *tc_chain = tcase_create ("nlesource"); |
| 218 |
|
| 219 |
suite_add_tcase (s, tc_chain); |
| 220 |
|
| 221 |
if (0) |
| 222 |
tcase_add_test (tc_chain, test_simple_videotestsrc); |
| 223 |
tcase_add_test (tc_chain, test_videotestsrc_in_bin); |
| 224 |
|
| 225 |
return s; |
| 226 |
} |
| 227 |
|
| 228 |
GST_CHECK_MAIN (gnonlin) |