docs/design/part-events.txt: Small update.

Original commit message from CVS:
* docs/design/part-events.txt:
Small update.

* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync), (gst_base_sink_activate_push),
(gst_base_sink_activate_pull):
Some more comments.

* gst/elements/gstfakesrc.c: (gst_fake_src_class_init),
(gst_fake_src_create):
Fix handoff marshall.

* gst/elements/gstidentity.c: (gst_identity_class_init),
(gst_identity_transform_ip):
We're a real inplace element.

* gst/gstbus.c: (gst_bus_post):
Added some comments.

* tests/lat.c: (fakesrc), (fakesink), (simple), (queue), (main):
* tests/muxing/case1.c: (main):
* tests/sched/dynamic-pipeline.c: (main):
* tests/sched/interrupt1.c: (main):
* tests/sched/interrupt2.c: (main):
* tests/sched/interrupt3.c: (main):
* tests/sched/runxml.c: (main):
* tests/sched/sched-stress.c: (main):
* tests/seeking/seeking1.c: (event_received), (main):
* tests/threadstate/threadstate2.c: (bus_handler), (timeout_func),
(main):
* tests/threadstate/threadstate3.c: (main):
* tests/threadstate/threadstate4.c: (main):
* tests/threadstate/threadstate5.c: (main):
Fix the tests.
This commit is contained in:
Wim Taymans 2005-07-22 11:47:10 +00:00
parent 030ff93e82
commit 9f06376bab
22 changed files with 210 additions and 164 deletions

View file

@ -1,3 +1,40 @@
2005-07-22 Wim Taymans <wim@fluendo.com>
* docs/design/part-events.txt:
Small update.
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync), (gst_base_sink_activate_push),
(gst_base_sink_activate_pull):
Some more comments.
* gst/elements/gstfakesrc.c: (gst_fake_src_class_init),
(gst_fake_src_create):
Fix handoff marshall.
* gst/elements/gstidentity.c: (gst_identity_class_init),
(gst_identity_transform_ip):
We're a real inplace element.
* gst/gstbus.c: (gst_bus_post):
Added some comments.
* tests/lat.c: (fakesrc), (fakesink), (simple), (queue), (main):
* tests/muxing/case1.c: (main):
* tests/sched/dynamic-pipeline.c: (main):
* tests/sched/interrupt1.c: (main):
* tests/sched/interrupt2.c: (main):
* tests/sched/interrupt3.c: (main):
* tests/sched/runxml.c: (main):
* tests/sched/sched-stress.c: (main):
* tests/seeking/seeking1.c: (event_received), (main):
* tests/threadstate/threadstate2.c: (bus_handler), (timeout_func),
(main):
* tests/threadstate/threadstate3.c: (main):
* tests/threadstate/threadstate4.c: (main):
* tests/threadstate/threadstate5.c: (main):
Fix the tests.
2005-07-21 Wim Taymans <wim@fluendo.com>
* docs/design/part-seeking.txt:

View file

@ -28,6 +28,8 @@ The EOS event can only be sent on a sinkpad. It is typically emited by the
source element when it has finished sending data. This event is mainly sent
in the streaming thread but can also be sent from the application thread.
An EOS event sent on a srcpad returns GST_FLOW_UNEXPECTED.
The downstream element should forward the EOS event to its downstream peer
elements. This way the event will eventually reach the renderers which should
then post an EOS message on the bus.
@ -126,7 +128,9 @@ travels upstream.
The seek event contains the new start and end position of playback
after the seek is performed. Optionally the end position can be left
at -1 to continue playback to the end of the stream.
at -1 to continue playback to the end of the stream. The seek event
also contains the new playback rate of the stream, 1.0 is normal playback,
2.0 double speed and negative values mean backwards playback.
A seek usually flushes the graph to minimize latency after the seek this
behaviour is triggered by using the SEEK_FLUSH flag.

View file

@ -473,6 +473,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
* stream time */
if (!gst_event_discont_get_value (event, GST_FORMAT_TIME,
&basesink->discont_start, &basesink->discont_stop)) {
/* this means this sink will not be able to sync to the clock */
basesink->discont_start = 0;
basesink->discont_stop = 0;
}

View file

@ -290,7 +290,8 @@ gst_fake_src_class_init (GstFakeSrcClass * klass)
gst_fake_src_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
gst_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
gst_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, GST_TYPE_BUFFER,
GST_TYPE_PAD);
/*gstbase_src_class->is_seekable = GST_DEBUG_FUNCPTR (gst_fake_src_is_seekable); */
gstbase_src_class->start = GST_DEBUG_FUNCPTR (gst_fake_src_start);
@ -689,7 +690,7 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length,
if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fake_src_signals[SIGNAL_HANDOFF], 0,
buf);
buf, basesrc->srcpad);
GST_LOG_OBJECT (src, "post handoff emit");
}

View file

@ -97,8 +97,8 @@ static void gst_identity_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer * outbuf);
static GstFlowReturn gst_identity_transform_ip (GstBaseTransform * trans,
GstBuffer * buf);
static gboolean gst_identity_start (GstBaseTransform * trans);
static gboolean gst_identity_stop (GstBaseTransform * trans);
@ -210,7 +210,8 @@ gst_identity_class_init (GstIdentityClass * klass)
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize);
gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_identity_event);
gstbasetrans_class->transform = GST_DEBUG_FUNCPTR (gst_identity_transform);
gstbasetrans_class->transform_ip =
GST_DEBUG_FUNCPTR (gst_identity_transform_ip);
gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_identity_start);
gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_identity_stop);
}
@ -290,14 +291,13 @@ gst_identity_check_perfect (GstIdentity * identity, GstBuffer * buf)
}
static GstFlowReturn
gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
GstBuffer * outbuf)
gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstIdentity *identity = GST_IDENTITY (trans);
if (identity->check_perfect)
gst_identity_check_perfect (identity, inbuf);
gst_identity_check_perfect (identity, buf);
if (identity->error_after >= 0) {
identity->error_after--;
@ -316,11 +316,11 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, timestamp: %"
GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p",
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (inbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)),
GST_BUFFER_OFFSET (inbuf), GST_BUFFER_OFFSET_END (inbuf),
GST_BUFFER_FLAGS (inbuf), inbuf);
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
GST_BUFFER_FLAGS (buf), buf);
GST_UNLOCK (identity);
g_object_notify (G_OBJECT (identity), "last-message");
return GST_FLOW_OK;
@ -328,7 +328,7 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
}
if (identity->dump) {
gst_util_dump_mem (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
if (!identity->silent) {
@ -338,11 +338,11 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, timestamp: %"
GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p",
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (inbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)),
GST_BUFFER_OFFSET (inbuf), GST_BUFFER_OFFSET_END (inbuf),
GST_BUFFER_FLAGS (inbuf), inbuf);
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
GST_BUFFER_FLAGS (buf), buf);
GST_UNLOCK (identity);
g_object_notify (G_OBJECT (identity), "last-message");
}
@ -350,13 +350,13 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
if (identity->datarate > 0) {
GstClockTime time = identity->offset * GST_SECOND / identity->datarate;
GST_BUFFER_TIMESTAMP (outbuf) = time;
GST_BUFFER_DURATION (outbuf) =
GST_BUFFER_SIZE (outbuf) * GST_SECOND / identity->datarate;
GST_BUFFER_TIMESTAMP (buf) = time;
GST_BUFFER_DURATION (buf) =
GST_BUFFER_SIZE (buf) * GST_SECOND / identity->datarate;
}
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
outbuf);
buf);
if (identity->sync) {
GstClock *clock;
@ -368,7 +368,7 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
/* save id if we need to unlock */
/* FIXME: actually unlock this somewhere in the state changes */
identity->clock_id = gst_clock_new_single_shot_id (clock,
GST_BUFFER_TIMESTAMP (outbuf) + GST_ELEMENT (identity)->base_time);
GST_BUFFER_TIMESTAMP (buf) + GST_ELEMENT (identity)->base_time);
GST_UNLOCK (identity);
cret = gst_clock_id_wait (identity->clock_id, NULL);
@ -384,7 +384,7 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
GST_UNLOCK (identity);
}
identity->offset += GST_BUFFER_SIZE (outbuf);
identity->offset += GST_BUFFER_SIZE (buf);
if (identity->sleep_time && ret == GST_FLOW_OK)
g_usleep (identity->sleep_time);

View file

@ -166,7 +166,8 @@ gst_bus_new (void)
* @bus: a #GstBus to post on
* @message: The #GstMessage to post
*
* Post a message on the given bus.
* Post a message on the given bus. Ownership of the message
* is taken by the bus.
*
* Returns: TRUE if the message could be posted.
*
@ -210,7 +211,7 @@ gst_bus_post (GstBus * bus, GstMessage * message)
GST_DEBUG_OBJECT (bus, "[msg %p] dropped", message);
break;
case GST_BUS_PASS:
/* pass the message to the async queue */
/* pass the message to the async queue, refcount passed in the queue */
GST_DEBUG_OBJECT (bus, "[msg %p] pushing on async queue", message);
g_mutex_lock (bus->queue_lock);
g_queue_push_tail (bus->queue, message);
@ -354,6 +355,8 @@ gst_bus_pop (GstBus * bus)
*
* MT safe.
*/
/* FIXME, dangerous as the bus could be set to flushing while the app holds
* a ref to the message */
GstMessage *
gst_bus_peek (GstBus * bus)
{

View file

@ -473,6 +473,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
* stream time */
if (!gst_event_discont_get_value (event, GST_FORMAT_TIME,
&basesink->discont_start, &basesink->discont_stop)) {
/* this means this sink will not be able to sync to the clock */
basesink->discont_start = 0;
basesink->discont_stop = 0;
}

View file

@ -290,7 +290,8 @@ gst_fake_src_class_init (GstFakeSrcClass * klass)
gst_fake_src_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
gst_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
gst_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, GST_TYPE_BUFFER,
GST_TYPE_PAD);
/*gstbase_src_class->is_seekable = GST_DEBUG_FUNCPTR (gst_fake_src_is_seekable); */
gstbase_src_class->start = GST_DEBUG_FUNCPTR (gst_fake_src_start);
@ -689,7 +690,7 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length,
if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fake_src_signals[SIGNAL_HANDOFF], 0,
buf);
buf, basesrc->srcpad);
GST_LOG_OBJECT (src, "post handoff emit");
}

View file

@ -97,8 +97,8 @@ static void gst_identity_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer * outbuf);
static GstFlowReturn gst_identity_transform_ip (GstBaseTransform * trans,
GstBuffer * buf);
static gboolean gst_identity_start (GstBaseTransform * trans);
static gboolean gst_identity_stop (GstBaseTransform * trans);
@ -210,7 +210,8 @@ gst_identity_class_init (GstIdentityClass * klass)
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize);
gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_identity_event);
gstbasetrans_class->transform = GST_DEBUG_FUNCPTR (gst_identity_transform);
gstbasetrans_class->transform_ip =
GST_DEBUG_FUNCPTR (gst_identity_transform_ip);
gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_identity_start);
gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_identity_stop);
}
@ -290,14 +291,13 @@ gst_identity_check_perfect (GstIdentity * identity, GstBuffer * buf)
}
static GstFlowReturn
gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
GstBuffer * outbuf)
gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstIdentity *identity = GST_IDENTITY (trans);
if (identity->check_perfect)
gst_identity_check_perfect (identity, inbuf);
gst_identity_check_perfect (identity, buf);
if (identity->error_after >= 0) {
identity->error_after--;
@ -316,11 +316,11 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, timestamp: %"
GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p",
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (inbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)),
GST_BUFFER_OFFSET (inbuf), GST_BUFFER_OFFSET_END (inbuf),
GST_BUFFER_FLAGS (inbuf), inbuf);
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
GST_BUFFER_FLAGS (buf), buf);
GST_UNLOCK (identity);
g_object_notify (G_OBJECT (identity), "last-message");
return GST_FLOW_OK;
@ -328,7 +328,7 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
}
if (identity->dump) {
gst_util_dump_mem (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
if (!identity->silent) {
@ -338,11 +338,11 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, timestamp: %"
GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p",
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (inbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)),
GST_BUFFER_OFFSET (inbuf), GST_BUFFER_OFFSET_END (inbuf),
GST_BUFFER_FLAGS (inbuf), inbuf);
GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
GST_BUFFER_FLAGS (buf), buf);
GST_UNLOCK (identity);
g_object_notify (G_OBJECT (identity), "last-message");
}
@ -350,13 +350,13 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
if (identity->datarate > 0) {
GstClockTime time = identity->offset * GST_SECOND / identity->datarate;
GST_BUFFER_TIMESTAMP (outbuf) = time;
GST_BUFFER_DURATION (outbuf) =
GST_BUFFER_SIZE (outbuf) * GST_SECOND / identity->datarate;
GST_BUFFER_TIMESTAMP (buf) = time;
GST_BUFFER_DURATION (buf) =
GST_BUFFER_SIZE (buf) * GST_SECOND / identity->datarate;
}
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
outbuf);
buf);
if (identity->sync) {
GstClock *clock;
@ -368,7 +368,7 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
/* save id if we need to unlock */
/* FIXME: actually unlock this somewhere in the state changes */
identity->clock_id = gst_clock_new_single_shot_id (clock,
GST_BUFFER_TIMESTAMP (outbuf) + GST_ELEMENT (identity)->base_time);
GST_BUFFER_TIMESTAMP (buf) + GST_ELEMENT (identity)->base_time);
GST_UNLOCK (identity);
cret = gst_clock_id_wait (identity->clock_id, NULL);
@ -384,7 +384,7 @@ gst_identity_transform (GstBaseTransform * trans, GstBuffer * inbuf,
GST_UNLOCK (identity);
}
identity->offset += GST_BUFFER_SIZE (outbuf);
identity->offset += GST_BUFFER_SIZE (buf);
if (identity->sleep_time && ret == GST_FLOW_OK)
g_usleep (identity->sleep_time);

View file

@ -72,6 +72,7 @@ fakesrc (void)
g_return_val_if_fail (src != NULL, NULL);
g_object_set (G_OBJECT (src), "silent", TRUE, NULL);
g_object_set (G_OBJECT (src), "num_buffers", iterations, NULL);
g_object_set (G_OBJECT (src), "signal-handoffs", TRUE, NULL);
g_signal_connect (G_OBJECT (src), "handoff", G_CALLBACK (handoff_src), NULL);
return src;
@ -85,6 +86,7 @@ fakesink (void)
sink = gst_element_factory_make ("fakesink", "fakesink");
g_return_val_if_fail (sink != NULL, NULL);
g_object_set (G_OBJECT (sink), "silent", TRUE, NULL);
g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL);
g_signal_connect (G_OBJECT (sink),
"handoff", G_CALLBACK (handoff_sink), NULL);
@ -103,9 +105,6 @@ simple (int argc, int argi, char *argv[])
return NULL;
}
idents = atoi (argv[argi]);
if ((argc - argi) == 2) {
gst_scheduler_factory_set_default_name (argv[argi + 1]);
}
pipeline = GST_PIPELINE (gst_pipeline_new ("pipeline"));
g_return_val_if_fail (pipeline != NULL, NULL);
@ -125,7 +124,7 @@ GstPipeline *
queue (int argc, int argi, char *argv[])
{
GstPipeline *pipeline;
GstElement *last, *src, *sink, *src_thr, *src_q, *sink_q, *sink_thr;
GstElement *last, *src, *sink, *src_q, *sink_q;
int idents;
if ((argc - argi) < 1) {
@ -134,28 +133,19 @@ queue (int argc, int argi, char *argv[])
}
idents = atoi (argv[argi]);
if ((argc - argi) == 2) {
gst_scheduler_factory_set_default_name (argv[argi + 1]);
}
pipeline = GST_PIPELINE (gst_pipeline_new ("pipeline"));
g_return_val_if_fail (pipeline != NULL, NULL);
src_thr = GST_ELEMENT (gst_thread_new ("src_thread"));
g_return_val_if_fail (src_thr != NULL, NULL);
src = fakesrc ();
g_return_val_if_fail (src != NULL, NULL);
gst_bin_add (GST_BIN (src_thr), GST_ELEMENT (src));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src));
src_q = gst_element_factory_make ("queue", "src_q");
g_return_val_if_fail (src_q != NULL, NULL);
gst_bin_add (GST_BIN (src_thr), GST_ELEMENT (src_q));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src_q));
gst_pad_link (gst_element_get_pad (src, "src"),
gst_element_get_pad (src_q, "sink"));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src_thr));
last = identity_add (pipeline, src_q, idents);
sink_q = gst_element_factory_make ("queue", "sink_q");
@ -164,14 +154,9 @@ queue (int argc, int argi, char *argv[])
gst_pad_link (gst_element_get_pad (last, "src"),
gst_element_get_pad (sink_q, "sink"));
sink_thr = GST_ELEMENT (gst_thread_new ("sink_thread"));
g_return_val_if_fail (sink_thr != NULL, NULL);
sink = fakesink ();
g_return_val_if_fail (sink != NULL, NULL);
gst_bin_add (GST_BIN (sink_thr), GST_ELEMENT (sink));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (sink_thr));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (sink));
gst_pad_link (gst_element_get_pad (sink_q, "src"),
gst_element_get_pad (sink, "sink"));
@ -187,8 +172,8 @@ struct test
};
static struct test tests[] = {
{"simple", "ident_count [scheduler_name]", simple},
{"queue", "ident_count [scheduler_name]", queue},
{"simple", "ident_count", simple},
{"queue", "ident_count", queue},
{NULL, NULL, NULL}
};
@ -229,7 +214,7 @@ main (int argc, char *argv[])
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
while (count < iterations) {
gst_bin_iterate (GST_BIN (pipeline));
g_usleep (G_USEC_PER_SEC);
}
g_print ("\n");

View file

@ -66,7 +66,7 @@ main (int argc, char *argv[])
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
while (gst_bin_iterate (pipeline));
g_usleep (2 * G_USEC_PER_SEC);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);

View file

@ -33,13 +33,14 @@ main (int argc, char *argv[])
/* initialize cothreads */
gst_element_set_state (pipe1, GST_STATE_PLAYING);
gst_bin_iterate (GST_BIN (pipe1));
gst_element_set_state (pipe1, GST_STATE_READY);
/* destroy the fakesink, but keep fakesrc (its state is GST_STATE_READY) */
gst_element_unlink_pads (fakesrc, "src", fakesink1, "sink");
gst_object_ref (fakesrc);
gst_bin_remove (GST_BIN (pipe1), fakesrc);
g_usleep (2 * G_USEC_PER_SEC);
gst_bin_remove (GST_BIN (pipe1), fakesink1);
gst_object_unref (pipe1);
@ -56,7 +57,7 @@ main (int argc, char *argv[])
/* try to iterate the pipeline */
gst_element_set_state (pipe2, GST_STATE_PLAYING);
gst_bin_iterate (GST_BIN (pipe2));
g_usleep (2 * G_USEC_PER_SEC);
gst_element_set_state (pipe2, GST_STATE_NULL);
return 0;

View file

@ -3,7 +3,7 @@
int
main (int argc, char *argv[])
{
GstElement *pipeline, *thread, *queue, *src, *sink;
GstElement *pipeline, *queue, *src, *sink;
gst_init (&argc, &argv);
@ -13,15 +13,12 @@ main (int argc, char *argv[])
src = gst_element_factory_make ("fakesrc", "src");
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), sink);
gst_bin_add (GST_BIN (pipeline), thread);
gst_bin_add (GST_BIN (pipeline), src);
gst_bin_add (GST_BIN (pipeline), queue);
gst_bin_add (GST_BIN (pipeline), sink);
gst_element_link_pads (src, "src", queue, "sink");
gst_element_link_pads (queue, "src", sink, "sink");

View file

@ -3,7 +3,7 @@
int
main (int argc, char *argv[])
{
GstElement *pipeline, *thread, *queue, *src, *identity, *sink;
GstElement *pipeline, *queue, *src, *identity, *sink;
gst_init (&argc, &argv);
@ -13,18 +13,14 @@ main (int argc, char *argv[])
src = gst_element_factory_make ("fakesrc", "src");
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
identity = gst_element_factory_make ("identity", "identity");
g_object_set (G_OBJECT (identity), "loop_based", TRUE, NULL);
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), identity);
gst_bin_add (GST_BIN (thread), sink);
gst_bin_add (GST_BIN (pipeline), thread);
gst_bin_add (GST_BIN (pipeline), src);
gst_bin_add (GST_BIN (pipeline), queue);
gst_bin_add (GST_BIN (pipeline), identity);
gst_bin_add (GST_BIN (pipeline), sink);
gst_element_link_pads (src, "src", queue, "sink");
gst_element_link_pads (queue, "src", identity, "sink");

View file

@ -3,7 +3,7 @@
int
main (int argc, char *argv[])
{
GstElement *pipeline, *thread, *queue, *src, *adder, *sink;
GstElement *pipeline, *queue, *src, *adder, *sink;
GstPad *sinkpad;
gst_init (&argc, &argv);
@ -15,17 +15,14 @@ main (int argc, char *argv[])
src = gst_element_factory_make ("fakesrc", "src");
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
adder = gst_element_factory_make ("adder", "adder");
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), adder);
gst_bin_add (GST_BIN (thread), sink);
gst_bin_add (GST_BIN (pipeline), thread);
gst_bin_add (GST_BIN (pipeline), src);
gst_bin_add (GST_BIN (pipeline), queue);
gst_bin_add (GST_BIN (pipeline), adder);
gst_bin_add (GST_BIN (pipeline), sink);
sinkpad = gst_element_get_request_pad (adder, "sink%d");

View file

@ -78,12 +78,6 @@ main (int argc, char *argv[])
/* gst_element_set_state(bin, GST_STATE_READY); */
gst_element_set_state (bin, GST_STATE_PLAYING);
if (GST_IS_THREAD (bin)) {
g_usleep (G_USEC_PER_SEC);
} else {
gst_bin_iterate (GST_BIN (bin));
}
if (outcount != 1 && incount != 1) {
g_print ("test failed\n");
exit (-1);

View file

@ -6,7 +6,7 @@ int
main (int argc, char *argv[])
{
GstElement *bin, *src, *dec, *sink;
int i, j;
int i;
gst_init (&argc, &argv);
@ -20,8 +20,6 @@ main (int argc, char *argv[])
gst_bin_add_many (GST_BIN (bin), src, dec, sink, NULL);
gst_element_link_many (src, dec, sink, NULL);
gst_element_set_state (bin, GST_STATE_PLAYING);
for (j = 0; j < 30; j++)
gst_bin_iterate (GST_BIN (bin));
gst_element_set_state (bin, GST_STATE_PAUSED);
}

View file

@ -7,6 +7,7 @@ static GstPad *pad;
static void
event_received (GObject * object, GstEvent * event, GstElement * pipeline)
{
#if 0
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT_DONE) {
g_print ("segment done\n");
if (--looping == 1) {
@ -19,6 +20,7 @@ event_received (GObject * object, GstEvent * event, GstElement * pipeline)
}
gst_pad_send_event (pad, event);
}
#endif
}
gint
@ -27,7 +29,8 @@ main (gint argc, gchar * argv[])
GstElement *pipeline;
GstElement *fakesrc;
GstElement *fakesink;
guint64 value;
/* guint64 value; */
GstFormat format;
gst_init (&argc, &argv);
@ -55,18 +58,20 @@ main (gint argc, gchar * argv[])
format = GST_FORMAT_DEFAULT;
#if 0
gst_pad_query (pad, GST_QUERY_START, &format, &value);
g_print ("configured for start %" G_GINT64_FORMAT "\n", value);
gst_pad_query (pad, GST_QUERY_SEGMENT_END, &format, &value);
g_print ("configured segment end %" G_GINT64_FORMAT "\n", value);
#endif
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL);
G_CALLBACK (gst_object_default_deep_notify), NULL);
while (gst_bin_iterate (GST_BIN (pipeline)));
g_usleep (2 * G_USEC_PER_SEC);
g_print
("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n");
@ -80,14 +85,16 @@ main (gint argc, gchar * argv[])
g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")),
"event_received", G_CALLBACK (event_received), event);
#if 0
gst_pad_query (pad, GST_QUERY_START, &format, &value);
g_print ("configured for start %" G_GINT64_FORMAT "\n", value);
gst_pad_query (pad, GST_QUERY_SEGMENT_END, &format, &value);
g_print ("configured segment end %" G_GINT64_FORMAT "\n", value);
#endif
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
g_usleep (2 * G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_NULL);

View file

@ -1,29 +1,45 @@
#include <stdlib.h>
#include <gst/gst.h>
static GMainLoop *loop;
static gboolean EOS = FALSE;
/* this pipeline is:
* { filesrc ! mad ! osssink }
*/
/* eos will be called when the src element has an end of stream */
void
eos (GstElement * element, gpointer data)
static gboolean
bus_handler (GstBus * bus, GstMessage * message, gpointer data)
{
GstThread *thread = GST_THREAD (data);
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_EOS:
g_print ("have eos, quitting\n");
EOS = TRUE;
if (g_main_loop_is_running (loop))
g_main_loop_quit (loop);
break;
default:
break;
}
return TRUE;
}
g_print ("have eos, quitting\n");
static gboolean
timeout_func (GMainLoop * loop)
{
g_main_loop_quit (loop);
/* stop the bin */
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
return TRUE;
}
int
main (int argc, char *argv[])
{
GstElement *filesrc, *osssink;
GstElement *thread;
GstElement *pipeline;
GstElement *mad;
gint x;
GstBus *bus;
gst_init (&argc, &argv);
@ -32,15 +48,14 @@ main (int argc, char *argv[])
exit (-1);
}
/* create a new thread to hold the elements */
thread = gst_thread_new ("thread");
g_assert (thread != NULL);
/* create a new pipeline to hold the elements */
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
/* create a disk reader */
filesrc = gst_element_factory_make ("filesrc", "disk_source");
g_assert (filesrc != NULL);
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
/* and an audio sink */
osssink = gst_element_factory_make ("osssink", "play_audio");
@ -50,17 +65,25 @@ main (int argc, char *argv[])
mad = gst_element_factory_make ("mad", "mp3_decoder");
g_assert (mad != NULL);
gst_bin_add_many (GST_BIN (thread), filesrc, mad, osssink, NULL);
gst_bin_add_many (GST_BIN (pipeline), filesrc, mad, osssink, NULL);
gst_element_link_many (filesrc, mad, osssink, NULL);
loop = g_main_loop_new (NULL, FALSE);
g_timeout_add (2 * 1000, (GSourceFunc) timeout_func, loop);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, (GstBusHandler) bus_handler, pipeline);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC * 2);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
g_main_loop_run (loop);
if (EOS)
break;
g_print ("pausing %d\n", x);
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PAUSED);
g_usleep (G_USEC_PER_SEC * 2);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
g_main_loop_run (loop);
}
exit (0);

View file

@ -9,18 +9,18 @@ int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *thread, *thread2;
GstElement *pipeline, *pipeline2;
gint x;
gst_init (&argc, &argv);
thread = gst_thread_new ("thread");
g_assert (thread != NULL);
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
thread2 = gst_thread_new ("thread2");
g_assert (thread2 != NULL);
pipeline2 = gst_pipeline_new ("pipeline2");
g_assert (pipeline2 != NULL);
gst_bin_add (GST_BIN (thread), GST_ELEMENT (thread2));
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (pipeline2));
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
@ -28,16 +28,16 @@ main (int argc, char *argv[])
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (thread2), fakesrc, fakesink, NULL);
gst_bin_add_many (GST_BIN (pipeline2), fakesrc, fakesink, NULL);
gst_element_link (fakesrc, fakesink);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
g_print ("nulling %d\n", x);
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}
exit (0);

View file

@ -9,17 +9,17 @@ int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *thread, *thread2;
GstElement *pipeline, *pipeline2;
GstElement *queue;
gint x;
gst_init (&argc, &argv);
thread = gst_thread_new ("thread");
g_assert (thread != NULL);
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
thread2 = gst_thread_new ("thread");
g_assert (thread2 != NULL);
pipeline2 = gst_pipeline_new ("pipeline");
g_assert (pipeline2 != NULL);
queue = gst_element_factory_make ("queue", "the_queue");
g_assert (queue != NULL);
@ -31,20 +31,20 @@ main (int argc, char *argv[])
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (thread), thread2, queue, fakesink, NULL);
gst_bin_add_many (GST_BIN (pipeline), pipeline2, queue, fakesink, NULL);
gst_bin_add (GST_BIN (thread2), fakesrc);
gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"),
"src");
gst_element_link_many (thread2, queue, fakesink, NULL);
gst_bin_add (GST_BIN (pipeline2), fakesrc);
gst_element_add_pad (pipeline2, gst_ghost_pad_new ("src",
gst_element_get_pad (fakesrc, "src")));
gst_element_link_many (pipeline2, queue, fakesink, NULL);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (thread, GST_STATE_PLAYING);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
g_print ("nulling %d\n", x);
gst_element_set_state (thread, GST_STATE_NULL);
gst_element_set_state (pipeline, GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}

View file

@ -9,17 +9,17 @@ int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *thread, *thread2;
GstElement *pipeline, *pipeline2;
GstElement *queue;
gint x;
gst_init (&argc, &argv);
thread = gst_thread_new ("thread");
g_assert (thread != NULL);
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
thread2 = gst_thread_new ("thread");
g_assert (thread2 != NULL);
pipeline2 = gst_pipeline_new ("pipeline");
g_assert (pipeline2 != NULL);
queue = gst_element_factory_make ("queue", "the_queue");
g_assert (queue != NULL);
@ -30,21 +30,21 @@ main (int argc, char *argv[])
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (thread), fakesrc, thread2, NULL);
gst_bin_add_many (GST_BIN (thread2), queue, fakesink, NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, pipeline2, NULL);
gst_bin_add_many (GST_BIN (pipeline2), queue, fakesink, NULL);
gst_element_add_ghost_pad (thread2, gst_element_get_pad (queue, "sink"),
"sink");
gst_element_add_pad (pipeline2, gst_ghost_pad_new ("sink",
gst_element_get_pad (queue, "sink")));
gst_element_link_many (queue, fakesink, NULL);
gst_element_link_many (fakesrc, thread2, NULL);
gst_element_link_many (fakesrc, pipeline2, NULL);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (thread, GST_STATE_PLAYING);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
g_print ("nulling %d\n", x);
gst_element_set_state (thread, GST_STATE_NULL);
gst_element_set_state (pipeline, GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}