static GstFlowReturn gst_pad_send_event_unchecked (GstPad * pad,
GstEvent * event, GstPadProbeType type);
static GstFlowReturn gst_pad_push_event_unchecked (GstPad * pad,
- GstEvent ** event, GstPadProbeType type);
+ GstEvent * event, GstPadProbeType type);
static gboolean activate_mode_internal (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active);
/* should be called with LOCK */
static GstEvent *
-_apply_pad_offset (GstPad * pad, GstEvent * event, gint64 applied_offset,
- gboolean upstream)
+_apply_pad_offset (GstPad * pad, GstEvent * event, gboolean upstream)
{
gint64 offset;
gst_event_copy_segment (event, &segment);
gst_event_unref (event);
- gst_segment_offset_running_time (&segment, segment.format, applied_offset);
+ gst_segment_offset_running_time (&segment, segment.format, pad->offset);
event = gst_event_new_segment (&segment);
}
event = gst_event_make_writable (event);
offset = gst_event_get_running_time_offset (event);
if (upstream)
- offset -= applied_offset;
+ offset -= pad->offset;
else
- offset += applied_offset;
+ offset += pad->offset;
gst_event_set_running_time_offset (event, offset);
return event;
apply_pad_offset (GstPad * pad, GstEvent * event, gboolean upstream)
{
if (G_UNLIKELY (pad->offset != 0))
- return _apply_pad_offset (pad, event, pad->offset, upstream);
+ return _apply_pad_offset (pad, event, upstream);
return event;
}
return result;
}
-/* This function will make sure that previously set offset is
- * reverted as otherwise we would end up applying the new offset
- * on top of the previously set one, which is not what we want.
- * The event is also marked as not received. */
static gboolean
-reschedule_event (GstPad * pad, PadEvent * ev, gint64 * prev_offset)
+mark_event_not_received (GstPad * pad, PadEvent * ev, gpointer user_data)
{
- if (*prev_offset != 0)
- ev->event = _apply_pad_offset (pad, ev->event, -*prev_offset, FALSE);
-
ev->received = FALSE;
return TRUE;
}
void
gst_pad_set_offset (GstPad * pad, gint64 offset)
{
- gint64 prev_offset;
g_return_if_fail (GST_IS_PAD (pad));
GST_OBJECT_LOCK (pad);
if (pad->offset == offset)
goto done;
- prev_offset = pad->offset;
pad->offset = offset;
GST_DEBUG_OBJECT (pad, "changed offset to %" GST_STIME_FORMAT,
GST_STIME_ARGS (offset));
/* resend all sticky events with updated offset on next buffer push */
- events_foreach (pad, (PadEventFunction) reschedule_event, &prev_offset);
+ events_foreach (pad, mark_event_not_received, NULL);
GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PENDING_EVENTS);
-
done:
GST_OBJECT_UNLOCK (pad);
}
GST_EVENT_TYPE (data->event) < GST_EVENT_TYPE (event)) {
data->ret = GST_FLOW_CUSTOM_SUCCESS_1;
} else {
- gst_event_ref (event);
- data->ret = gst_pad_push_event_unchecked (pad, &event,
+ data->ret = gst_pad_push_event_unchecked (pad, gst_event_ref (event),
GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM);
- gst_event_replace (&ev->event, event);
if (data->ret == GST_FLOW_CUSTOM_SUCCESS_1)
data->ret = GST_FLOW_OK;
}
PadEvent *ev = find_event_by_type (pad, GST_EVENT_EOS, 0);
if (ev && !ev->received) {
- gst_event_ref (ev->event);
- data.ret = gst_pad_push_event_unchecked (pad, &ev->event,
+ data.ret = gst_pad_push_event_unchecked (pad, gst_event_ref (ev->event),
GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM);
/* the event could have been dropped. Because this can only
* happen if the user asked for it, it's not an error */
/* should be called with pad LOCK */
static GstFlowReturn
-gst_pad_push_event_unchecked (GstPad * pad, GstEvent ** in_event,
+gst_pad_push_event_unchecked (GstPad * pad, GstEvent * event,
GstPadProbeType type)
{
GstFlowReturn ret;
GstPad *peerpad;
GstEventType event_type;
- GstEvent *event = *in_event;
/* pass the adjusted event on. We need to do this even if
* there is no peer pad because of the probes. */
PROBE_NO_DATA (pad, GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_IDLE,
idle_probe_stopped, ret);
}
-
- *in_event = event;
-
return ret;
/* ERROR handling */
GstFlowReturn ret;
/* other events are pushed right away */
- ret = gst_pad_push_event_unchecked (pad, &event, type);
+ ret = gst_pad_push_event_unchecked (pad, event, type);
/* dropped events by a probe are not an error */
res = (ret == GST_FLOW_OK || ret == GST_FLOW_CUSTOM_SUCCESS
|| ret == GST_FLOW_CUSTOM_SUCCESS_1);
#endif
#include <gst/check/gstcheck.h>
-#include <gst/check/gstharness.h>
static GstSegment dummy_segment;
GST_END_TEST;
-static GstPadProbeReturn
-update_stream_start_event_cb (GstPad * pad, GstPadProbeInfo * info,
- const gchar * wanted_stream_id)
-{
- GstEvent *event = info->data;
-
- if (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START) {
- const gchar *stream_id;
-
- gst_event_parse_stream_start (event, &stream_id);
- g_assert_cmpstr (stream_id, !=, wanted_stream_id);
-
- gst_event_unref (event);
-
- info->data = gst_event_new_stream_start (wanted_stream_id);
- }
-
- return GST_PAD_PROBE_OK;
-}
-
-GST_START_TEST (test_sticky_events_changed_in_probe)
-{
- GstPad *srcpad;
- GstHarness *harness;
- GstEvent *stream_start;
- const gchar *stream_id;
- const gchar *wanted_stream_id = "The right stream ID";
- harness = gst_harness_new ("fakesrc");
-
- gst_harness_add_probe (harness, "fakesrc", "src",
- GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
- (GstPadProbeCallback) update_stream_start_event_cb,
- (gpointer) wanted_stream_id, NULL);
- gst_harness_play (harness);
- gst_harness_set_blocking_push_mode (harness);
- gst_buffer_unref (gst_harness_pull (harness));
-
- stream_start =
- gst_pad_get_sticky_event (harness->sinkpad, GST_EVENT_STREAM_START, 0);
- gst_event_parse_stream_start (stream_start, &stream_id);
- fail_unless_equals_string (stream_id, wanted_stream_id);
- gst_event_unref (stream_start);
-
- srcpad = gst_element_get_static_pad (harness->element, "src");
- stream_start = gst_pad_get_sticky_event (srcpad, GST_EVENT_STREAM_START, 0);
- gst_event_unref (stream_start);
- gst_object_unref (srcpad);
- gst_event_parse_stream_start (stream_start, &stream_id);
- fail_unless_equals_string (stream_id, wanted_stream_id);
-
- gst_harness_teardown (harness);
-}
-
-GST_END_TEST;
-
static Suite *
gst_pad_suite (void)
{
tcase_add_test (tc_chain, test_block_async_full_destroy_dispose);
tcase_add_test (tc_chain, test_block_async_replace_callback_no_flush);
tcase_add_test (tc_chain, test_sticky_events);
- tcase_add_test (tc_chain, test_sticky_events_changed_in_probe);
tcase_add_test (tc_chain, test_last_flow_return_push);
tcase_add_test (tc_chain, test_last_flow_return_pull);
tcase_add_test (tc_chain, test_flush_stop_inactive);