2005-08-18 15:31:28 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com>
|
|
|
|
*
|
2005-08-20 12:43:18 +00:00
|
|
|
* gstevent.c: Unit test for event handling
|
2005-08-18 15:31:28 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-08-20 12:43:18 +00:00
|
|
|
#include <gst/check/gstcheck.h>
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2008-02-21 10:30:50 +00:00
|
|
|
GST_START_TEST (create_events)
|
2005-08-18 15:31:28 +00:00
|
|
|
{
|
|
|
|
GstEvent *event, *event2;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
/* FLUSH_START */
|
|
|
|
{
|
|
|
|
event = gst_event_new_flush_start ();
|
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START);
|
|
|
|
fail_unless (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
/* FLUSH_STOP */
|
|
|
|
{
|
2011-06-10 09:55:08 +00:00
|
|
|
gboolean reset_time;
|
|
|
|
|
|
|
|
event = gst_event_new_flush_stop (TRUE);
|
2005-08-18 15:31:28 +00:00
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP);
|
|
|
|
fail_unless (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
|
2005-11-21 17:21:15 +00:00
|
|
|
fail_unless (GST_EVENT_IS_SERIALIZED (event));
|
2011-06-10 09:55:08 +00:00
|
|
|
|
|
|
|
gst_event_parse_flush_stop (event, &reset_time);
|
|
|
|
fail_unless (reset_time == TRUE);
|
2005-08-18 15:31:28 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
/* EOS */
|
|
|
|
{
|
|
|
|
event = gst_event_new_eos ();
|
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_EOS);
|
|
|
|
fail_if (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
2012-01-27 18:56:01 +00:00
|
|
|
/* GAP */
|
|
|
|
{
|
|
|
|
GstClockTime ts = 0, dur = 0;
|
|
|
|
|
|
|
|
ASSERT_CRITICAL (gst_event_new_gap (GST_CLOCK_TIME_NONE, GST_SECOND));
|
|
|
|
|
|
|
|
event = gst_event_new_gap (90 * GST_SECOND, GST_SECOND);
|
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_GAP);
|
|
|
|
fail_if (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
gst_event_parse_gap (event, &ts, NULL);
|
|
|
|
fail_unless_equals_int64 (ts, 90 * GST_SECOND);
|
|
|
|
gst_event_parse_gap (event, &ts, &dur);
|
|
|
|
fail_unless_equals_int64 (dur, GST_SECOND);
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
2011-05-13 16:07:24 +00:00
|
|
|
/* SEGMENT */
|
2005-08-18 15:31:28 +00:00
|
|
|
{
|
2011-05-13 16:07:24 +00:00
|
|
|
GstSegment segment, parsed;
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
segment.rate = 0.5;
|
|
|
|
segment.applied_rate = 1.0;
|
|
|
|
segment.start = 1;
|
|
|
|
segment.stop = G_MAXINT64;
|
|
|
|
segment.time = 0xdeadbeef;
|
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear.
Original commit message from CVS:
* docs/design/part-overview.txt:
Make upsteam/downstream concepts more clear.
Give an example of serialized/non-serialized events.
* docs/design/part-events.txt:
* docs/design/part-streams.txt:
Mention applied_rate.
* docs/design/part-trickmodes.txt:
Mention applied rate, flesh out some more use cases.
* gst/gstevent.c: (gst_event_new_new_segment),
(gst_event_parse_new_segment), (gst_event_new_new_segment_full),
(gst_event_parse_new_segment_full), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_buffer_size),
(gst_event_parse_buffer_size), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_parse_seek),
(gst_event_new_navigation):
* gst/gstevent.h:
Add applied_rate field to NEWSEGMENT event.
API: gst_event_new_new_segment_full()
API: gst_event_parse_new_segment_full()
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_set_newsegment_full),
(gst_segment_to_stream_time), (gst_segment_to_running_time):
* gst/gstsegment.h:
Add applied_rate to GstSegment structure.
Make calculation of stream_time and running_time more correct
wrt rate/applied_rate.
Add some more docs.
API: GstSegment::applied_rate field
API: gst_segment_set_newsegment_full();
* libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment),
(gst_base_sink_get_sync_times), (gst_base_sink_get_position):
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_sink_eventfunc),
(gst_base_transform_handle_buffer):
Parse and use applied_rate in the GstSegment field.
* tests/check/gst/gstevent.c: (GST_START_TEST):
Add check for applied_rate field.
* tests/check/gst/gstsegment.c: (GST_START_TEST),
(gstsegments_suite):
Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
|
|
|
|
2011-05-13 16:07:24 +00:00
|
|
|
event = gst_event_new_segment (&segment);
|
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear.
Original commit message from CVS:
* docs/design/part-overview.txt:
Make upsteam/downstream concepts more clear.
Give an example of serialized/non-serialized events.
* docs/design/part-events.txt:
* docs/design/part-streams.txt:
Mention applied_rate.
* docs/design/part-trickmodes.txt:
Mention applied rate, flesh out some more use cases.
* gst/gstevent.c: (gst_event_new_new_segment),
(gst_event_parse_new_segment), (gst_event_new_new_segment_full),
(gst_event_parse_new_segment_full), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_buffer_size),
(gst_event_parse_buffer_size), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_parse_seek),
(gst_event_new_navigation):
* gst/gstevent.h:
Add applied_rate field to NEWSEGMENT event.
API: gst_event_new_new_segment_full()
API: gst_event_parse_new_segment_full()
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_set_newsegment_full),
(gst_segment_to_stream_time), (gst_segment_to_running_time):
* gst/gstsegment.h:
Add applied_rate to GstSegment structure.
Make calculation of stream_time and running_time more correct
wrt rate/applied_rate.
Add some more docs.
API: GstSegment::applied_rate field
API: gst_segment_set_newsegment_full();
* libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment),
(gst_base_sink_get_sync_times), (gst_base_sink_get_position):
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_sink_eventfunc),
(gst_base_transform_handle_buffer):
Parse and use applied_rate in the GstSegment field.
* tests/check/gst/gstevent.c: (GST_START_TEST):
Add check for applied_rate field.
* tests/check/gst/gstsegment.c: (GST_START_TEST),
(gstsegments_suite):
Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
|
|
|
fail_if (event == NULL);
|
2011-05-13 16:07:24 +00:00
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
|
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear.
Original commit message from CVS:
* docs/design/part-overview.txt:
Make upsteam/downstream concepts more clear.
Give an example of serialized/non-serialized events.
* docs/design/part-events.txt:
* docs/design/part-streams.txt:
Mention applied_rate.
* docs/design/part-trickmodes.txt:
Mention applied rate, flesh out some more use cases.
* gst/gstevent.c: (gst_event_new_new_segment),
(gst_event_parse_new_segment), (gst_event_new_new_segment_full),
(gst_event_parse_new_segment_full), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_buffer_size),
(gst_event_parse_buffer_size), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_parse_seek),
(gst_event_new_navigation):
* gst/gstevent.h:
Add applied_rate field to NEWSEGMENT event.
API: gst_event_new_new_segment_full()
API: gst_event_parse_new_segment_full()
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_set_newsegment_full),
(gst_segment_to_stream_time), (gst_segment_to_running_time):
* gst/gstsegment.h:
Add applied_rate to GstSegment structure.
Make calculation of stream_time and running_time more correct
wrt rate/applied_rate.
Add some more docs.
API: GstSegment::applied_rate field
API: gst_segment_set_newsegment_full();
* libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment),
(gst_base_sink_get_sync_times), (gst_base_sink_get_position):
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_sink_eventfunc),
(gst_base_transform_handle_buffer):
Parse and use applied_rate in the GstSegment field.
* tests/check/gst/gstevent.c: (GST_START_TEST):
Add check for applied_rate field.
* tests/check/gst/gstsegment.c: (GST_START_TEST),
(gstsegments_suite):
Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
|
|
|
fail_if (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
|
2011-05-18 14:56:13 +00:00
|
|
|
gst_event_copy_segment (event, &parsed);
|
2011-05-13 16:07:24 +00:00
|
|
|
fail_unless (parsed.rate == 0.5);
|
|
|
|
fail_unless (parsed.applied_rate == 1.0);
|
|
|
|
fail_unless (parsed.format == GST_FORMAT_TIME);
|
|
|
|
fail_unless (parsed.start == 1);
|
|
|
|
fail_unless (parsed.stop == G_MAXINT64);
|
|
|
|
fail_unless (parsed.time == 0xdeadbeef);
|
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear.
Original commit message from CVS:
* docs/design/part-overview.txt:
Make upsteam/downstream concepts more clear.
Give an example of serialized/non-serialized events.
* docs/design/part-events.txt:
* docs/design/part-streams.txt:
Mention applied_rate.
* docs/design/part-trickmodes.txt:
Mention applied rate, flesh out some more use cases.
* gst/gstevent.c: (gst_event_new_new_segment),
(gst_event_parse_new_segment), (gst_event_new_new_segment_full),
(gst_event_parse_new_segment_full), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_buffer_size),
(gst_event_parse_buffer_size), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_parse_seek),
(gst_event_new_navigation):
* gst/gstevent.h:
Add applied_rate field to NEWSEGMENT event.
API: gst_event_new_new_segment_full()
API: gst_event_parse_new_segment_full()
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_set_newsegment_full),
(gst_segment_to_stream_time), (gst_segment_to_running_time):
* gst/gstsegment.h:
Add applied_rate to GstSegment structure.
Make calculation of stream_time and running_time more correct
wrt rate/applied_rate.
Add some more docs.
API: GstSegment::applied_rate field
API: gst_segment_set_newsegment_full();
* libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment),
(gst_base_sink_get_sync_times), (gst_base_sink_get_position):
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_sink_eventfunc),
(gst_base_transform_handle_buffer):
Parse and use applied_rate in the GstSegment field.
* tests/check/gst/gstevent.c: (GST_START_TEST):
Add check for applied_rate field.
* tests/check/gst/gstsegment.c: (GST_START_TEST),
(gstsegments_suite):
Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
|
|
|
|
2005-08-18 15:31:28 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
docs/design/part-overview.txt: Make upsteam/downstream concepts more clear.
Original commit message from CVS:
* docs/design/part-overview.txt:
Make upsteam/downstream concepts more clear.
Give an example of serialized/non-serialized events.
* docs/design/part-events.txt:
* docs/design/part-streams.txt:
Mention applied_rate.
* docs/design/part-trickmodes.txt:
Mention applied rate, flesh out some more use cases.
* gst/gstevent.c: (gst_event_new_new_segment),
(gst_event_parse_new_segment), (gst_event_new_new_segment_full),
(gst_event_parse_new_segment_full), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_buffer_size),
(gst_event_parse_buffer_size), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_parse_seek),
(gst_event_new_navigation):
* gst/gstevent.h:
Add applied_rate field to NEWSEGMENT event.
API: gst_event_new_new_segment_full()
API: gst_event_parse_new_segment_full()
* gst/gstsegment.c: (gst_segment_init), (gst_segment_set_seek),
(gst_segment_set_newsegment), (gst_segment_set_newsegment_full),
(gst_segment_to_stream_time), (gst_segment_to_running_time):
* gst/gstsegment.h:
Add applied_rate to GstSegment structure.
Make calculation of stream_time and running_time more correct
wrt rate/applied_rate.
Add some more docs.
API: GstSegment::applied_rate field
API: gst_segment_set_newsegment_full();
* libs/gst/base/gstbasesink.c: (gst_base_sink_configure_segment),
(gst_base_sink_get_sync_times), (gst_base_sink_get_position):
* libs/gst/base/gstbasetransform.c:
(gst_base_transform_sink_eventfunc),
(gst_base_transform_handle_buffer):
Parse and use applied_rate in the GstSegment field.
* tests/check/gst/gstevent.c: (GST_START_TEST):
Add check for applied_rate field.
* tests/check/gst/gstsegment.c: (GST_START_TEST),
(gstsegments_suite):
Add more checks for various GstSegment operations.
2006-05-08 09:52:33 +00:00
|
|
|
|
2012-01-27 17:39:12 +00:00
|
|
|
/* STREAM CONFIG */
|
|
|
|
{
|
|
|
|
GstStreamConfigFlags flags = 0x987654;
|
|
|
|
GstBuffer *buf, *cd, *sh1, *sh2;
|
|
|
|
gpointer dummy;
|
|
|
|
|
|
|
|
event = gst_event_new_stream_config (GST_STREAM_CONFIG_FLAG_NONE);
|
|
|
|
|
|
|
|
gst_event_parse_stream_config (event, &flags);
|
|
|
|
fail_unless_equals_int (flags, GST_STREAM_CONFIG_FLAG_NONE);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 0);
|
|
|
|
|
|
|
|
/* set buf to something random but guaranteed to be non-NULL */
|
|
|
|
buf = (GstBuffer *) & dummy;
|
2012-02-12 20:51:39 +00:00
|
|
|
gst_event_parse_stream_config_setup_data (event, &buf);
|
2012-01-27 17:39:12 +00:00
|
|
|
fail_unless (buf == NULL);
|
|
|
|
|
|
|
|
buf = (GstBuffer *) & dummy;
|
|
|
|
gst_event_parse_nth_stream_config_header (event, 0, &buf);
|
|
|
|
fail_unless (buf == NULL);
|
|
|
|
|
|
|
|
buf = (GstBuffer *) & dummy;
|
|
|
|
gst_event_parse_nth_stream_config_header (event, 98416, &buf);
|
|
|
|
fail_unless (buf == NULL);
|
|
|
|
|
2012-02-12 20:51:39 +00:00
|
|
|
ASSERT_CRITICAL (gst_event_set_stream_config_setup_data (event, NULL));
|
2012-01-27 17:39:12 +00:00
|
|
|
ASSERT_CRITICAL (gst_event_add_stream_config_header (event, NULL));
|
|
|
|
|
2012-03-20 09:20:29 +00:00
|
|
|
cd = gst_buffer_new_wrapped_full (0, (gpointer) "SetMeUpScottie", 14, 0, 14,
|
|
|
|
NULL, NULL);
|
2012-02-12 20:51:39 +00:00
|
|
|
gst_event_set_stream_config_setup_data (event, cd);
|
2012-01-27 17:39:12 +00:00
|
|
|
gst_buffer_unref (cd);
|
|
|
|
|
|
|
|
buf = (GstBuffer *) & dummy;
|
|
|
|
gst_event_parse_nth_stream_config_header (event, 0, &buf);
|
|
|
|
fail_unless (buf == NULL);
|
2012-02-12 20:51:39 +00:00
|
|
|
gst_event_parse_stream_config_setup_data (event, &buf);
|
2012-01-27 17:39:12 +00:00
|
|
|
fail_unless (buf == cd);
|
|
|
|
fail_unless (GST_IS_BUFFER (buf));
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
event = gst_event_new_stream_config (GST_STREAM_CONFIG_FLAG_NONE);
|
|
|
|
fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 0);
|
2012-03-20 09:20:29 +00:00
|
|
|
sh1 =
|
|
|
|
gst_buffer_new_wrapped_full (0, (gpointer) "Strea", 5, 0, 5, NULL,
|
|
|
|
NULL);
|
2012-01-27 17:39:12 +00:00
|
|
|
gst_event_add_stream_config_header (event, sh1);
|
|
|
|
gst_buffer_unref (sh1);
|
|
|
|
fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 1);
|
2012-03-20 09:20:29 +00:00
|
|
|
sh2 =
|
|
|
|
gst_buffer_new_wrapped_full (0, (gpointer) "mHeader", 7, 0, 7, NULL,
|
|
|
|
NULL);
|
2012-01-27 17:39:12 +00:00
|
|
|
gst_event_add_stream_config_header (event, sh2);
|
|
|
|
gst_buffer_unref (sh2);
|
|
|
|
fail_unless_equals_int (gst_event_get_n_stream_config_headers (event), 2);
|
|
|
|
|
|
|
|
buf = (GstBuffer *) & dummy;
|
|
|
|
gst_event_parse_nth_stream_config_header (event, 1, &buf);
|
|
|
|
fail_unless (buf == sh2);
|
|
|
|
fail_unless (GST_IS_BUFFER (buf));
|
|
|
|
|
|
|
|
buf = (GstBuffer *) & dummy;
|
|
|
|
gst_event_parse_nth_stream_config_header (event, 0, &buf);
|
|
|
|
fail_unless (buf == sh1);
|
|
|
|
fail_unless (GST_IS_BUFFER (buf));
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
|
2005-08-18 15:31:28 +00:00
|
|
|
/* TAGS */
|
|
|
|
{
|
2011-10-30 10:26:11 +00:00
|
|
|
GstTagList *taglist = gst_tag_list_new_empty ();
|
2005-08-18 15:31:28 +00:00
|
|
|
GstTagList *tl2 = NULL;
|
|
|
|
|
|
|
|
event = gst_event_new_tag (taglist);
|
|
|
|
fail_if (taglist == NULL);
|
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_TAG);
|
|
|
|
fail_if (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_unless (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
|
|
|
|
gst_event_parse_tag (event, &tl2);
|
|
|
|
fail_unless (taglist == tl2);
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
|
2008-02-21 10:30:50 +00:00
|
|
|
/* QOS */
|
|
|
|
{
|
2011-02-10 11:02:03 +00:00
|
|
|
GstQOSType t1 = GST_QOS_TYPE_THROTTLE, t2;
|
2008-02-21 10:30:50 +00:00
|
|
|
gdouble p1 = 1.0, p2;
|
|
|
|
GstClockTimeDiff ctd1 = G_GINT64_CONSTANT (10), ctd2;
|
|
|
|
GstClockTime ct1 = G_GUINT64_CONSTANT (20), ct2;
|
|
|
|
|
2011-05-09 16:48:55 +00:00
|
|
|
event = gst_event_new_qos (t1, p1, ctd1, ct1);
|
2008-02-21 10:30:50 +00:00
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_QOS);
|
|
|
|
fail_unless (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
|
2011-05-09 16:48:55 +00:00
|
|
|
gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
|
2008-02-21 10:30:50 +00:00
|
|
|
fail_unless (p1 == p2);
|
|
|
|
fail_unless (ctd1 == ctd2);
|
|
|
|
fail_unless (ct1 == ct2);
|
2011-05-09 16:48:55 +00:00
|
|
|
gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
|
2011-05-18 13:43:20 +00:00
|
|
|
fail_unless (t2 == GST_QOS_TYPE_THROTTLE);
|
2011-02-10 11:02:03 +00:00
|
|
|
fail_unless (p1 == p2);
|
|
|
|
fail_unless (ctd1 == ctd2);
|
|
|
|
fail_unless (ct1 == ct2);
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
ctd1 = G_GINT64_CONSTANT (-10);
|
2011-05-09 16:48:55 +00:00
|
|
|
event = gst_event_new_qos (t1, p1, ctd1, ct1);
|
|
|
|
gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
|
2011-05-18 13:43:20 +00:00
|
|
|
fail_unless (t2 == GST_QOS_TYPE_THROTTLE);
|
2011-02-10 11:02:03 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
|
2011-05-09 16:48:55 +00:00
|
|
|
event = gst_event_new_qos (t1, p1, ctd1, ct1);
|
|
|
|
gst_event_parse_qos (event, &t2, &p2, &ctd2, &ct2);
|
2011-02-10 11:02:03 +00:00
|
|
|
fail_unless (t2 == GST_QOS_TYPE_THROTTLE);
|
|
|
|
fail_unless (p1 == p2);
|
|
|
|
fail_unless (ctd1 == ctd2);
|
|
|
|
fail_unless (ct1 == ct2);
|
2008-02-21 10:30:50 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
/* SEEK */
|
|
|
|
{
|
|
|
|
gdouble rate;
|
|
|
|
GstFormat format;
|
|
|
|
GstSeekFlags flags;
|
|
|
|
GstSeekType cur_type, stop_type;
|
|
|
|
gint64 cur, stop;
|
|
|
|
|
|
|
|
event = gst_event_new_seek (0.5, GST_FORMAT_BYTES,
|
|
|
|
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
|
|
|
|
GST_SEEK_TYPE_SET, 1, GST_SEEK_TYPE_NONE, 0xdeadbeef);
|
|
|
|
|
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEEK);
|
|
|
|
fail_unless (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
|
|
|
|
gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur,
|
|
|
|
&stop_type, &stop);
|
|
|
|
fail_unless (rate == 0.5);
|
|
|
|
fail_unless (format == GST_FORMAT_BYTES);
|
|
|
|
fail_unless (flags == (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE));
|
|
|
|
fail_unless (cur_type == GST_SEEK_TYPE_SET);
|
|
|
|
fail_unless (cur == 1);
|
|
|
|
fail_unless (stop_type == GST_SEEK_TYPE_NONE);
|
|
|
|
fail_unless (stop == 0xdeadbeef);
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NAVIGATION */
|
|
|
|
{
|
|
|
|
structure = gst_structure_new ("application/x-gst-navigation", "event",
|
|
|
|
G_TYPE_STRING, "key-press", "key", G_TYPE_STRING, "mon", NULL);
|
|
|
|
fail_if (structure == NULL);
|
|
|
|
event = gst_event_new_navigation (structure);
|
|
|
|
fail_if (event == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION);
|
|
|
|
fail_unless (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
|
|
|
|
fail_unless (gst_event_get_structure (event) == structure);
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Custom event types */
|
|
|
|
{
|
2011-10-29 07:02:00 +00:00
|
|
|
structure = gst_structure_new_empty ("application/x-custom");
|
2005-08-18 15:31:28 +00:00
|
|
|
fail_if (structure == NULL);
|
2005-11-21 11:06:42 +00:00
|
|
|
event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, structure);
|
2005-08-18 15:31:28 +00:00
|
|
|
fail_if (event == NULL);
|
2005-11-21 11:06:42 +00:00
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UPSTREAM);
|
2005-08-18 15:31:28 +00:00
|
|
|
fail_unless (GST_EVENT_IS_UPSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_DOWNSTREAM (event));
|
|
|
|
fail_if (GST_EVENT_IS_SERIALIZED (event));
|
|
|
|
fail_unless (gst_event_get_structure (event) == structure);
|
2008-04-29 11:23:51 +00:00
|
|
|
fail_unless (gst_event_has_name (event, "application/x-custom"));
|
2005-08-18 15:31:28 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
/* Decided not to test the other custom enum types, as they
|
|
|
|
* only differ by the value of the enum passed to gst_event_new_custom
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Event copying */
|
|
|
|
{
|
2011-10-29 07:02:00 +00:00
|
|
|
structure = gst_structure_new_empty ("application/x-custom");
|
2005-08-18 15:31:28 +00:00
|
|
|
fail_if (structure == NULL);
|
|
|
|
event = gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, structure);
|
|
|
|
|
|
|
|
fail_if (event == NULL);
|
|
|
|
event2 = gst_event_copy (event);
|
|
|
|
fail_if (event2 == NULL);
|
|
|
|
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_TYPE (event2));
|
2008-04-29 11:23:51 +00:00
|
|
|
fail_unless (gst_event_has_name (event, "application/x-custom"));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
/* The structure should have been duplicated */
|
|
|
|
fail_if (gst_event_get_structure (event) ==
|
|
|
|
gst_event_get_structure (event2));
|
2006-10-02 08:37:24 +00:00
|
|
|
|
|
|
|
gst_event_unref (event);
|
|
|
|
gst_event_unref (event2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make events writable */
|
|
|
|
{
|
2011-10-29 07:02:00 +00:00
|
|
|
structure = gst_structure_new_empty ("application/x-custom");
|
2006-10-02 08:37:24 +00:00
|
|
|
fail_if (structure == NULL);
|
|
|
|
event = gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, structure);
|
|
|
|
/* ref the event so that it becomes non-writable */
|
|
|
|
gst_event_ref (event);
|
|
|
|
gst_event_ref (event);
|
|
|
|
/* this should fail if the structure isn't writable */
|
|
|
|
ASSERT_CRITICAL (gst_structure_remove_all_fields ((GstStructure *)
|
|
|
|
gst_event_get_structure (event)));
|
2008-04-29 11:23:51 +00:00
|
|
|
fail_unless (gst_event_has_name (event, "application/x-custom"));
|
2006-10-02 08:37:24 +00:00
|
|
|
|
|
|
|
/* now make writable */
|
|
|
|
event2 =
|
|
|
|
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
|
|
|
|
fail_unless (event != event2);
|
|
|
|
/* this fail if the structure isn't writable */
|
|
|
|
gst_structure_remove_all_fields ((GstStructure *)
|
|
|
|
gst_event_get_structure (event2));
|
2008-04-29 11:23:51 +00:00
|
|
|
fail_unless (gst_event_has_name (event2, "application/x-custom"));
|
2006-10-02 08:37:24 +00:00
|
|
|
|
|
|
|
gst_event_unref (event);
|
2005-08-18 15:31:28 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
gst_event_unref (event2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 12:43:18 +00:00
|
|
|
GST_END_TEST;
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static GTimeVal sent_event_time;
|
|
|
|
static GstEvent *got_event_before_q, *got_event_after_q;
|
|
|
|
static GTimeVal got_event_time;
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2011-11-01 00:13:35 +00:00
|
|
|
static GstPadProbeReturn
|
2011-11-08 10:04:19 +00:00
|
|
|
event_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
2005-08-18 15:31:28 +00:00
|
|
|
{
|
2011-11-08 10:04:19 +00:00
|
|
|
GstMiniObject *data = GST_PAD_PROBE_INFO_DATA (info);
|
2005-08-18 16:42:49 +00:00
|
|
|
gboolean before_q = (gboolean) GPOINTER_TO_INT (user_data);
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("event probe called %p", data);
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2011-05-31 17:16:09 +00:00
|
|
|
fail_unless (GST_IS_EVENT (data));
|
2007-02-15 08:40:38 +00:00
|
|
|
|
2005-08-18 15:31:28 +00:00
|
|
|
if (before_q) {
|
|
|
|
switch (GST_EVENT_TYPE (GST_EVENT (data))) {
|
2005-11-21 11:06:42 +00:00
|
|
|
case GST_EVENT_CUSTOM_UPSTREAM:
|
2005-08-18 15:31:28 +00:00
|
|
|
case GST_EVENT_CUSTOM_BOTH:
|
|
|
|
case GST_EVENT_CUSTOM_BOTH_OOB:
|
2005-08-21 10:54:47 +00:00
|
|
|
if (got_event_before_q != NULL)
|
|
|
|
break;
|
2006-03-21 13:50:52 +00:00
|
|
|
gst_event_ref ((GstEvent *) data);
|
2005-08-18 15:31:28 +00:00
|
|
|
g_get_current_time (&got_event_time);
|
|
|
|
got_event_before_q = GST_EVENT (data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (GST_EVENT_TYPE (GST_EVENT (data))) {
|
2005-11-21 11:06:42 +00:00
|
|
|
case GST_EVENT_CUSTOM_DOWNSTREAM:
|
|
|
|
case GST_EVENT_CUSTOM_DOWNSTREAM_OOB:
|
2005-08-18 15:31:28 +00:00
|
|
|
case GST_EVENT_CUSTOM_BOTH:
|
|
|
|
case GST_EVENT_CUSTOM_BOTH_OOB:
|
2005-08-21 10:54:47 +00:00
|
|
|
if (got_event_after_q != NULL)
|
|
|
|
break;
|
2006-03-21 13:50:52 +00:00
|
|
|
gst_event_ref ((GstEvent *) data);
|
2005-08-18 15:31:28 +00:00
|
|
|
g_get_current_time (&got_event_time);
|
|
|
|
got_event_after_q = GST_EVENT (data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-01 00:13:35 +00:00
|
|
|
return GST_PAD_PROBE_OK;
|
2005-08-18 15:31:28 +00:00
|
|
|
}
|
|
|
|
|
2011-05-30 16:29:06 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GMutex *lock;
|
|
|
|
GCond *cond;
|
|
|
|
gboolean signaled;
|
|
|
|
} SignalData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
signal_data_init (SignalData * data)
|
|
|
|
{
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("init %p", data);
|
2011-05-30 16:29:06 +00:00
|
|
|
data->lock = g_mutex_new ();
|
|
|
|
data->cond = g_cond_new ();
|
|
|
|
data->signaled = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
signal_data_cleanup (SignalData * data)
|
|
|
|
{
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("free %p", data);
|
2011-05-30 16:29:06 +00:00
|
|
|
g_mutex_free (data->lock);
|
|
|
|
g_cond_free (data->cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
signal_data_signal (SignalData * data)
|
|
|
|
{
|
|
|
|
g_mutex_lock (data->lock);
|
|
|
|
data->signaled = TRUE;
|
|
|
|
g_cond_broadcast (data->cond);
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("signaling %p", data);
|
2011-05-30 16:29:06 +00:00
|
|
|
g_mutex_unlock (data->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
signal_data_wait (SignalData * data)
|
|
|
|
{
|
|
|
|
g_mutex_lock (data->lock);
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("signal wait %p", data);
|
2011-05-30 16:29:06 +00:00
|
|
|
while (!data->signaled)
|
|
|
|
g_cond_wait (data->cond, data->lock);
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("signal wait done %p", data);
|
2011-05-30 16:29:06 +00:00
|
|
|
g_mutex_unlock (data->lock);
|
|
|
|
}
|
|
|
|
|
2011-11-01 00:13:35 +00:00
|
|
|
static GstPadProbeReturn
|
2011-11-08 10:04:19 +00:00
|
|
|
signal_blocked (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
2011-05-30 16:29:06 +00:00
|
|
|
{
|
|
|
|
SignalData *data = (SignalData *) user_data;
|
|
|
|
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("signal called %p", data);
|
2011-05-30 16:29:06 +00:00
|
|
|
signal_data_signal (data);
|
2011-05-31 17:16:09 +00:00
|
|
|
GST_DEBUG ("signal done %p", data);
|
|
|
|
|
2011-11-01 00:13:35 +00:00
|
|
|
return GST_PAD_PROBE_OK;
|
2011-05-30 16:29:06 +00:00
|
|
|
}
|
|
|
|
|
2005-08-18 15:31:28 +00:00
|
|
|
static void test_event
|
2005-08-21 10:54:47 +00:00
|
|
|
(GstBin * pipeline, GstEventType type, GstPad * pad,
|
2005-11-22 10:24:31 +00:00
|
|
|
gboolean expect_before_q, GstPad * fake_srcpad)
|
2005-08-18 15:31:28 +00:00
|
|
|
{
|
|
|
|
GstEvent *event;
|
2006-07-03 10:30:49 +00:00
|
|
|
GstPad *peer;
|
2005-08-18 15:31:28 +00:00
|
|
|
gint i;
|
2011-05-30 16:29:06 +00:00
|
|
|
SignalData data;
|
2011-05-31 17:16:09 +00:00
|
|
|
gulong id;
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
got_event_before_q = got_event_after_q = NULL;
|
|
|
|
|
2005-08-21 10:54:47 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
Use GstClockTime in _get_state() instead of GTimeVal.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* check/gst/gstelement.c: (GST_START_TEST):
* check/gst/gstevent.c: (GST_START_TEST), (test_event):
* check/gst/gstghostpad.c: (GST_START_TEST):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/simple_launch_lines.c: (run_pipeline):
* check/states/sinks.c: (GST_START_TEST):
* gst/elements/gsttypefindelement.c: (stop_typefinding):
* gst/gstbin.c: (gst_bin_provide_clock_func), (gst_bin_add_func),
(gst_bin_remove_func), (gst_bin_get_state_func),
(gst_bin_recalc_state), (gst_bin_change_state_func),
(bin_bus_handler):
* gst/gstelement.c: (gst_element_get_state_func),
(gst_element_get_state), (gst_element_abort_state),
(gst_element_commit_state), (gst_element_set_state),
(gst_element_change_state), (gst_element_change_state_func):
* gst/gstelement.h:
* gst/gstpipeline.c: (gst_pipeline_class_init), (do_pipeline_seek),
(gst_pipeline_provide_clock_func):
* gst/gstutils.c: (gst_element_link_pads_filtered):
* tools/gst-launch.c: (main):
* tools/gst-typefind.c: (main):
Use GstClockTime in _get_state() instead of GTimeVal.
Remove old code in gstutils.c
2005-10-12 12:18:48 +00:00
|
|
|
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
|
|
|
|
GST_CLOCK_TIME_NONE);
|
2005-08-21 10:54:47 +00:00
|
|
|
|
2007-02-15 08:40:38 +00:00
|
|
|
GST_DEBUG ("test event called");
|
|
|
|
|
2005-08-18 15:31:28 +00:00
|
|
|
event = gst_event_new_custom (type,
|
2011-10-29 07:02:00 +00:00
|
|
|
gst_structure_new_empty ("application/x-custom"));
|
2005-08-18 15:31:28 +00:00
|
|
|
g_get_current_time (&sent_event_time);
|
|
|
|
got_event_time.tv_sec = 0;
|
|
|
|
got_event_time.tv_usec = 0;
|
|
|
|
|
2011-05-30 16:29:06 +00:00
|
|
|
signal_data_init (&data);
|
|
|
|
|
2006-07-03 10:30:49 +00:00
|
|
|
/* We block the pad so the stream lock is released and we can send the event */
|
2011-11-08 10:04:19 +00:00
|
|
|
id = gst_pad_add_probe (fake_srcpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
|
2011-05-31 17:16:09 +00:00
|
|
|
signal_blocked, &data, NULL);
|
|
|
|
fail_unless (id != 0);
|
2011-05-30 16:29:06 +00:00
|
|
|
|
|
|
|
signal_data_wait (&data);
|
2006-07-03 10:30:49 +00:00
|
|
|
|
|
|
|
/* We send on the peer pad, since the pad is blocked */
|
2011-06-01 17:27:55 +00:00
|
|
|
GST_DEBUG ("sending event %p", event);
|
2006-07-03 10:30:49 +00:00
|
|
|
fail_unless ((peer = gst_pad_get_peer (pad)) != NULL);
|
|
|
|
gst_pad_send_event (peer, event);
|
|
|
|
gst_object_unref (peer);
|
|
|
|
|
2011-05-31 17:16:09 +00:00
|
|
|
gst_pad_remove_probe (fake_srcpad, id);
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
if (expect_before_q) {
|
2006-07-31 15:07:30 +00:00
|
|
|
/* Wait up to 5 seconds for the event to appear */
|
2005-08-18 16:00:34 +00:00
|
|
|
for (i = 0; i < 500; i++) {
|
|
|
|
g_usleep (G_USEC_PER_SEC / 100);
|
2005-08-18 15:31:28 +00:00
|
|
|
if (got_event_before_q != NULL)
|
|
|
|
break;
|
|
|
|
}
|
2006-07-31 15:07:30 +00:00
|
|
|
fail_if (got_event_before_q == NULL,
|
|
|
|
"Expected event failed to appear upstream of the queue "
|
|
|
|
"within 5 seconds");
|
2005-08-18 15:31:28 +00:00
|
|
|
fail_unless (GST_EVENT_TYPE (got_event_before_q) == type);
|
|
|
|
} else {
|
2006-07-31 15:07:30 +00:00
|
|
|
/* Wait up to 10 seconds for the event to appear */
|
|
|
|
for (i = 0; i < 1000; i++) {
|
2005-08-18 16:00:34 +00:00
|
|
|
g_usleep (G_USEC_PER_SEC / 100);
|
2005-08-18 15:31:28 +00:00
|
|
|
if (got_event_after_q != NULL)
|
|
|
|
break;
|
|
|
|
}
|
2006-07-31 15:07:30 +00:00
|
|
|
fail_if (got_event_after_q == NULL,
|
|
|
|
"Expected event failed to appear after the queue within 10 seconds");
|
2005-08-18 15:31:28 +00:00
|
|
|
fail_unless (GST_EVENT_TYPE (got_event_after_q) == type);
|
|
|
|
}
|
2005-08-21 10:54:47 +00:00
|
|
|
|
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
|
Use GstClockTime in _get_state() instead of GTimeVal.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* check/gst/gstelement.c: (GST_START_TEST):
* check/gst/gstevent.c: (GST_START_TEST), (test_event):
* check/gst/gstghostpad.c: (GST_START_TEST):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/simple_launch_lines.c: (run_pipeline):
* check/states/sinks.c: (GST_START_TEST):
* gst/elements/gsttypefindelement.c: (stop_typefinding):
* gst/gstbin.c: (gst_bin_provide_clock_func), (gst_bin_add_func),
(gst_bin_remove_func), (gst_bin_get_state_func),
(gst_bin_recalc_state), (gst_bin_change_state_func),
(bin_bus_handler):
* gst/gstelement.c: (gst_element_get_state_func),
(gst_element_get_state), (gst_element_abort_state),
(gst_element_commit_state), (gst_element_set_state),
(gst_element_change_state), (gst_element_change_state_func):
* gst/gstelement.h:
* gst/gstpipeline.c: (gst_pipeline_class_init), (do_pipeline_seek),
(gst_pipeline_provide_clock_func):
* gst/gstutils.c: (gst_element_link_pads_filtered):
* tools/gst-launch.c: (main):
* tools/gst-typefind.c: (main):
Use GstClockTime in _get_state() instead of GTimeVal.
Remove old code in gstutils.c
2005-10-12 12:18:48 +00:00
|
|
|
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
|
|
|
|
GST_CLOCK_TIME_NONE);
|
2005-08-21 10:54:47 +00:00
|
|
|
|
|
|
|
if (got_event_before_q)
|
|
|
|
gst_event_unref (got_event_before_q);
|
|
|
|
if (got_event_after_q)
|
|
|
|
gst_event_unref (got_event_after_q);
|
|
|
|
|
|
|
|
got_event_before_q = got_event_after_q = NULL;
|
2011-05-31 17:16:09 +00:00
|
|
|
|
|
|
|
signal_data_cleanup (&data);
|
2005-08-21 10:54:47 +00:00
|
|
|
}
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
static gint64
|
|
|
|
timediff (GTimeVal * end, GTimeVal * start)
|
|
|
|
{
|
|
|
|
return (end->tv_sec - start->tv_sec) * G_USEC_PER_SEC +
|
|
|
|
(end->tv_usec - start->tv_usec);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (send_custom_events)
|
|
|
|
{
|
|
|
|
/* Run some tests on custom events. Checking for serialisation and whatnot.
|
|
|
|
* pipeline is fakesrc ! queue ! fakesink */
|
|
|
|
GstBin *pipeline;
|
|
|
|
GstElement *fakesrc, *fakesink, *queue;
|
|
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
|
|
|
|
fail_if ((pipeline = (GstBin *) gst_pipeline_new ("testpipe")) == NULL);
|
|
|
|
fail_if ((fakesrc = gst_element_factory_make ("fakesrc", NULL)) == NULL);
|
|
|
|
fail_if ((fakesink = gst_element_factory_make ("fakesink", NULL)) == NULL);
|
|
|
|
fail_if ((queue = gst_element_factory_make ("queue", NULL)) == NULL);
|
|
|
|
|
|
|
|
gst_bin_add_many (pipeline, fakesrc, queue, fakesink, NULL);
|
|
|
|
fail_unless (gst_element_link_many (fakesrc, queue, fakesink, NULL));
|
|
|
|
|
2005-09-20 15:45:42 +00:00
|
|
|
g_object_set (G_OBJECT (fakesink), "sync", FALSE, NULL);
|
|
|
|
|
2005-08-18 16:00:34 +00:00
|
|
|
/* Send 100 buffers per sec */
|
|
|
|
g_object_set (G_OBJECT (fakesrc), "silent", TRUE, "datarate", 100,
|
2005-08-18 15:31:28 +00:00
|
|
|
"sizemax", 1, "sizetype", 2, NULL);
|
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 0, "max-size-time",
|
2005-08-18 16:00:34 +00:00
|
|
|
(guint64) GST_SECOND, "max-size-bytes", 0, NULL);
|
2005-08-18 15:31:28 +00:00
|
|
|
g_object_set (G_OBJECT (fakesink), "silent", TRUE, "sync", TRUE, NULL);
|
|
|
|
|
2008-02-21 10:30:50 +00:00
|
|
|
/* add pad-probes to faksrc.src and fakesink.sink */
|
2008-05-21 15:57:52 +00:00
|
|
|
fail_if ((srcpad = gst_element_get_static_pad (fakesrc, "src")) == NULL);
|
2011-11-07 16:04:13 +00:00
|
|
|
gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_EVENT_BOTH,
|
2011-06-01 17:27:55 +00:00
|
|
|
event_probe, GINT_TO_POINTER (TRUE), NULL);
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2008-05-21 15:57:52 +00:00
|
|
|
fail_if ((sinkpad = gst_element_get_static_pad (fakesink, "sink")) == NULL);
|
2011-11-07 16:04:13 +00:00
|
|
|
gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_EVENT_BOTH,
|
2011-06-01 17:27:55 +00:00
|
|
|
event_probe, GINT_TO_POINTER (FALSE), NULL);
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
/* Upstream events */
|
2005-11-22 10:24:31 +00:00
|
|
|
test_event (pipeline, GST_EVENT_CUSTOM_UPSTREAM, sinkpad, TRUE, srcpad);
|
2005-08-18 16:00:34 +00:00
|
|
|
fail_unless (timediff (&got_event_time,
|
|
|
|
&sent_event_time) < G_USEC_PER_SEC / 2,
|
2007-02-15 08:40:38 +00:00
|
|
|
"GST_EVENT_CUSTOM_UP took too long to reach source: %"
|
2005-08-21 10:54:47 +00:00
|
|
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2005-11-22 10:24:31 +00:00
|
|
|
test_event (pipeline, GST_EVENT_CUSTOM_BOTH, sinkpad, TRUE, srcpad);
|
2005-08-18 16:00:34 +00:00
|
|
|
fail_unless (timediff (&got_event_time,
|
|
|
|
&sent_event_time) < G_USEC_PER_SEC / 2,
|
2007-02-15 08:40:38 +00:00
|
|
|
"GST_EVENT_CUSTOM_BOTH took too long to reach source: %"
|
2005-08-21 10:54:47 +00:00
|
|
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2005-11-22 10:24:31 +00:00
|
|
|
test_event (pipeline, GST_EVENT_CUSTOM_BOTH_OOB, sinkpad, TRUE, srcpad);
|
2005-08-18 16:00:34 +00:00
|
|
|
fail_unless (timediff (&got_event_time,
|
|
|
|
&sent_event_time) < G_USEC_PER_SEC / 2,
|
2007-02-15 08:40:38 +00:00
|
|
|
"GST_EVENT_CUSTOM_BOTH_OOB took too long to reach source: %"
|
2005-08-21 10:54:47 +00:00
|
|
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
/* Out of band downstream events */
|
2005-11-22 10:24:31 +00:00
|
|
|
test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM_OOB, srcpad, FALSE, srcpad);
|
2005-08-18 16:00:34 +00:00
|
|
|
fail_unless (timediff (&got_event_time,
|
|
|
|
&sent_event_time) < G_USEC_PER_SEC / 2,
|
2007-02-15 08:40:38 +00:00
|
|
|
"GST_EVENT_CUSTOM_DS_OOB took too long to reach source: %"
|
2005-08-21 10:54:47 +00:00
|
|
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2005-11-22 10:24:31 +00:00
|
|
|
test_event (pipeline, GST_EVENT_CUSTOM_BOTH_OOB, srcpad, FALSE, srcpad);
|
2005-08-18 16:00:34 +00:00
|
|
|
fail_unless (timediff (&got_event_time,
|
|
|
|
&sent_event_time) < G_USEC_PER_SEC / 2,
|
2007-02-15 08:40:38 +00:00
|
|
|
"GST_EVENT_CUSTOM_BOTH_OOB took too long to reach source: %"
|
2005-08-21 10:54:47 +00:00
|
|
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2005-08-20 12:43:18 +00:00
|
|
|
/* In-band downstream events are expected to take at least 1 second
|
2011-09-07 11:14:38 +00:00
|
|
|
* to traverse the queue */
|
2005-11-22 10:24:31 +00:00
|
|
|
test_event (pipeline, GST_EVENT_CUSTOM_DOWNSTREAM, srcpad, FALSE, srcpad);
|
2005-08-18 16:00:34 +00:00
|
|
|
fail_unless (timediff (&got_event_time,
|
|
|
|
&sent_event_time) >= G_USEC_PER_SEC / 2,
|
2005-08-21 10:54:47 +00:00
|
|
|
"GST_EVENT_CUSTOM_DS arrived too quickly for an in-band event: %"
|
|
|
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2005-11-22 10:24:31 +00:00
|
|
|
test_event (pipeline, GST_EVENT_CUSTOM_BOTH, srcpad, FALSE, srcpad);
|
2005-08-18 16:00:34 +00:00
|
|
|
fail_unless (timediff (&got_event_time,
|
|
|
|
&sent_event_time) >= G_USEC_PER_SEC / 2,
|
2005-08-21 10:54:47 +00:00
|
|
|
"GST_EVENT_CUSTOM_BOTH arrived too quickly for an in-band event: %"
|
|
|
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
Use GstClockTime in _get_state() instead of GTimeVal.
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* check/gst/gstelement.c: (GST_START_TEST):
* check/gst/gstevent.c: (GST_START_TEST), (test_event):
* check/gst/gstghostpad.c: (GST_START_TEST):
* check/gst/gstpipeline.c: (GST_START_TEST):
* check/pipelines/simple_launch_lines.c: (run_pipeline):
* check/states/sinks.c: (GST_START_TEST):
* gst/elements/gsttypefindelement.c: (stop_typefinding):
* gst/gstbin.c: (gst_bin_provide_clock_func), (gst_bin_add_func),
(gst_bin_remove_func), (gst_bin_get_state_func),
(gst_bin_recalc_state), (gst_bin_change_state_func),
(bin_bus_handler):
* gst/gstelement.c: (gst_element_get_state_func),
(gst_element_get_state), (gst_element_abort_state),
(gst_element_commit_state), (gst_element_set_state),
(gst_element_change_state), (gst_element_change_state_func):
* gst/gstelement.h:
* gst/gstpipeline.c: (gst_pipeline_class_init), (do_pipeline_seek),
(gst_pipeline_provide_clock_func):
* gst/gstutils.c: (gst_element_link_pads_filtered):
* tools/gst-launch.c: (main):
* tools/gst-typefind.c: (main):
Use GstClockTime in _get_state() instead of GTimeVal.
Remove old code in gstutils.c
2005-10-12 12:18:48 +00:00
|
|
|
gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL,
|
|
|
|
GST_CLOCK_TIME_NONE);
|
2005-08-18 15:31:28 +00:00
|
|
|
|
2011-10-11 11:54:45 +00:00
|
|
|
gst_object_unref (sinkpad);
|
|
|
|
gst_object_unref (srcpad);
|
2005-08-18 15:31:28 +00:00
|
|
|
gst_object_unref (pipeline);
|
|
|
|
}
|
|
|
|
|
2005-08-20 12:43:18 +00:00
|
|
|
GST_END_TEST;
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static Suite *
|
2006-07-01 20:56:56 +00:00
|
|
|
gst_event_suite (void)
|
2005-08-18 15:31:28 +00:00
|
|
|
{
|
|
|
|
Suite *s = suite_create ("GstEvent");
|
2008-02-21 10:30:50 +00:00
|
|
|
TCase *tc_chain = tcase_create ("events");
|
2005-08-18 15:31:28 +00:00
|
|
|
|
|
|
|
tcase_set_timeout (tc_chain, 20);
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
2008-02-21 10:30:50 +00:00
|
|
|
tcase_add_test (tc_chain, create_events);
|
2005-08-18 15:31:28 +00:00
|
|
|
tcase_add_test (tc_chain, send_custom_events);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2006-07-01 20:56:56 +00:00
|
|
|
GST_CHECK_MAIN (gst_event);
|