diff options
author | Thiago Santos <thiagoss@osg.samsung.com> | 2015-03-23 14:27:04 -0300 |
---|---|---|
committer | Thiago Santos <thiagoss@osg.samsung.com> | 2015-03-23 14:27:04 -0300 |
commit | 6ce1d166bd60a9842225685ee8ebb101046b66bb (patch) | |
tree | 5c9a2c3e6a926f184964787c87c40f694af28427 | |
parent | 9cee81dc1b812e7a42e49495e2da88a304e47df1 (diff) |
-rw-r--r-- | libs/gst/base/gstbaseparse.c | 4 | ||||
-rw-r--r-- | plugins/elements/gstinputselector.c | 5 | ||||
-rw-r--r-- | tests/check/elements/selector.c | 142 |
3 files changed, 118 insertions, 33 deletions
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 013e6822e..93ba8b1aa 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -1166,7 +1166,7 @@ gst_base_parse_sink_event_default (GstBaseParse * parse, GstEvent * event) /* If we STILL have zero frames processed, fire an error */ if (parse->priv->framecount == 0 && !parse->priv->saw_gaps) { - GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE, + GST_ELEMENT_WARNING (parse, STREAM, WRONG_TYPE, ("No valid frames found before end of stream"), (NULL)); } /* newsegment and other serialized events before eos */ @@ -3376,7 +3376,7 @@ pause: } else { /* If we STILL have zero frames processed, fire an error */ if (parse->priv->framecount == 0) { - GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE, + GST_ELEMENT_WARNING (parse, STREAM, WRONG_TYPE, ("No valid frames found before end of stream"), (NULL)); } push_eos = TRUE; diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c index e665fcd87..3ec5b2b8e 100644 --- a/plugins/elements/gstinputselector.c +++ b/plugins/elements/gstinputselector.c @@ -444,6 +444,8 @@ gst_input_selector_wait (GstInputSelector * self, GstSelectorPad * pad) * get unblocked */ GST_INPUT_SELECTOR_WAIT (self); } + GST_ERROR_OBJECT (self, "EOS: %d Blocked: %d flushing: %d %d", self->eos, + self->blocked, self->flushing, pad->flushing); return self->flushing; } @@ -537,7 +539,8 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event) if (!forward) { /* blocked until active the sind pad or flush */ gst_input_selector_wait (sel, selpad); - forward = TRUE; + if (pad == gst_input_selector_activate_sinkpad (sel, pad)) + forward = TRUE; } else { /* Notify all waiting pads about going EOS now */ sel->eos = TRUE; diff --git a/tests/check/elements/selector.c b/tests/check/elements/selector.c index 224d185fa..ebeec5a12 100644 --- a/tests/check/elements/selector.c +++ b/tests/check/elements/selector.c @@ -396,49 +396,130 @@ GST_START_TEST (test_input_selector_buffer_count) GST_END_TEST; -GST_START_TEST (test_input_selector_empty_stream) +static GstElement *selector; +static GstPad *output_pad; +static GstPad *stream1_pad; +static GstPad *stream2_pad; + +enum InputSelectorResult { - GstElement *sel = gst_check_setup_element ("input-selector"); - GstPad *output_pad = gst_check_setup_sink_pad (sel, &sinktemplate); - GstPad *empty_stream_pad; - GstPad *stream_pad; - GstEvent *eos_event; + INPUT_SELECTOR_FORWARD, + INPUT_SELECTOR_DROP +}; + +static void +setup_input_selector_with_2_streams (gint active_stream) +{ + selector = gst_check_setup_element ("input-selector"); + output_pad = gst_check_setup_sink_pad (selector, &sinktemplate); gst_pad_set_active (output_pad, TRUE); - stream_pad = setup_input_pad (sel); - empty_stream_pad = setup_input_pad (sel); + stream1_pad = setup_input_pad (selector); + stream2_pad = setup_input_pad (selector); - g_object_set (sel, "active-pad", GST_PAD_PEER (stream_pad), NULL); + if (active_stream == 1) { + g_object_set (selector, "active-pad", GST_PAD_PEER (stream1_pad), NULL); + } else { + g_object_set (selector, "active-pad", GST_PAD_PEER (stream2_pad), NULL); + } - /* run the test */ - fail_unless (gst_element_set_state (sel, + fail_unless (gst_element_set_state (selector, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, "could not set to playing"); - gst_check_setup_events_with_stream_id (empty_stream_pad, sel, NULL, - GST_FORMAT_TIME, "empty-stream-id"); - gst_check_setup_events_with_stream_id (stream_pad, sel, NULL, - GST_FORMAT_TIME, "stream-id"); + gst_check_setup_events_with_stream_id (stream1_pad, selector, NULL, + GST_FORMAT_TIME, "stream-1-id"); + gst_check_setup_events_with_stream_id (stream2_pad, selector, NULL, + GST_FORMAT_TIME, "stream-2-id"); +} - /* empty stream is just an EOS and it should not be forwarded */ - fail_unless (gst_pad_push_event (empty_stream_pad, gst_event_new_eos ())); - fail_unless (gst_pad_get_sticky_event (output_pad, GST_EVENT_EOS, 0) == NULL); +static void +teardown_input_selector_with_2_streams (void) +{ + fail_unless (gst_element_set_state (selector, + GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); + + gst_pad_set_active (output_pad, FALSE); + gst_check_teardown_sink_pad (selector); + gst_check_teardown_element (selector); +} + +static void +input_selector_push_buffer (gint stream, enum InputSelectorResult res) +{ + GstBuffer *buf; + GstPad *pad = stream == 1 ? stream1_pad : stream2_pad; + buf = gst_buffer_new (); fail_unless (buffers == NULL); - fail_unless (gst_pad_push (stream_pad, gst_buffer_new ()) == GST_FLOW_OK); - fail_unless (buffers != NULL); - fail_unless (gst_pad_push_event (stream_pad, gst_event_new_eos ())); - eos_event = gst_pad_get_sticky_event (output_pad, GST_EVENT_EOS, 0); - fail_unless (eos_event != NULL); - gst_event_unref (eos_event); + fail_unless (gst_pad_push (pad, buf) == GST_FLOW_OK); - fail_unless (gst_element_set_state (sel, - GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); + if (res == INPUT_SELECTOR_DROP) { + fail_unless (buffers == NULL); + } else { + fail_unless (buffers != NULL); + fail_unless (buffers->data == buf); + g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref); + buffers = NULL; + } +} - /* clean up */ - gst_pad_set_active (output_pad, FALSE); - gst_check_teardown_sink_pad (sel); - gst_check_teardown_element (sel); +static void +input_selector_push_eos (gint stream, gboolean active) +{ + GstEvent *eos; + GstPad *pad = stream == 1 ? stream1_pad : stream2_pad; + + fail_unless (gst_pad_push_event (pad, gst_event_new_eos ())); + + eos = gst_pad_get_sticky_event (output_pad, GST_EVENT_EOS, 0); + if (active) { + fail_unless (eos != NULL); + gst_event_unref (eos); + } else { + fail_unless (eos == NULL); + } +} + +GST_START_TEST (test_input_selector_empty_stream) +{ + setup_input_selector_with_2_streams (2); + + /* stream1 is the empty stream, stream2 has data */ + + /* empty stream is just an EOS and it should not be forwarded */ + input_selector_push_eos (1, FALSE); + + input_selector_push_buffer (2, INPUT_SELECTOR_FORWARD); + input_selector_push_eos (2, TRUE); + + teardown_input_selector_with_2_streams (); +} + +GST_END_TEST; + + +GST_START_TEST (test_input_selector_shorter_stream) +{ + setup_input_selector_with_2_streams (2); + + /* stream1 is shorter than stream2 */ + + input_selector_push_buffer (2, INPUT_SELECTOR_FORWARD); + input_selector_push_buffer (1, INPUT_SELECTOR_DROP); + input_selector_push_buffer (2, INPUT_SELECTOR_FORWARD); + input_selector_push_buffer (2, INPUT_SELECTOR_FORWARD); + + /* EOS from inactive stream should not go through */ + input_selector_push_eos (1, FALSE); + + /* buffers from active stream can still flow */ + input_selector_push_buffer (2, INPUT_SELECTOR_FORWARD); + + /* EOS from active stream should go through */ + input_selector_push_eos (2, TRUE); + + teardown_input_selector_with_2_streams (); } GST_END_TEST; @@ -653,6 +734,7 @@ selector_suite (void) tcase_add_test (tc_chain, test_output_selector_buffer_count); tcase_add_test (tc_chain, test_input_selector_buffer_count); tcase_add_test (tc_chain, test_input_selector_empty_stream); + tcase_add_test (tc_chain, test_input_selector_shorter_stream); tcase_add_test (tc_chain, test_output_selector_no_srcpad_negotiation); tc_chain = tcase_create ("output-selector-negotiation"); |