From 43c8433a07f62b55f239a26ce6660b8fa92da203 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 22 Sep 2005 18:07:22 +0000 Subject: [PATCH] gst/base/gstbasesink.c: Prepare for more accurate position reporting and query handling. Original commit message from CVS: * gst/base/gstbasesink.c: (gst_base_sink_class_init), (gst_base_sink_send_event), (gst_base_sink_peer_query), (gst_base_sink_query): Prepare for more accurate position reporting and query handling. * gst/gstelement.c: (gst_element_send_event), (gst_element_set_state): Add some comment. --- ChangeLog | 12 ++++++ gst/base/gstbasesink.c | 79 +++++++++++++++++++++++++++++++++++++ gst/gstelement.c | 2 + libs/gst/base/gstbasesink.c | 79 +++++++++++++++++++++++++++++++++++++ 4 files changed, 172 insertions(+) diff --git a/ChangeLog b/ChangeLog index ffd8afc3ba4..34eb6c72a32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-09-22 Wim Taymans + + * gst/base/gstbasesink.c: (gst_base_sink_class_init), + (gst_base_sink_send_event), (gst_base_sink_peer_query), + (gst_base_sink_query): + Prepare for more accurate position reporting and query + handling. + + * gst/gstelement.c: (gst_element_send_event), + (gst_element_set_state): + Add some comment. + 2005-09-22 Wim Taymans * gst/gstquery.c: (gst_query_new_segment), (gst_query_set_segment), diff --git a/gst/base/gstbasesink.c b/gst/base/gstbasesink.c index 8886f6c87ec..f7be1c4578d 100644 --- a/gst/base/gstbasesink.c +++ b/gst/base/gstbasesink.c @@ -105,6 +105,10 @@ static void gst_base_sink_set_property (GObject * object, guint prop_id, static void gst_base_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static gboolean gst_base_sink_send_event (GstElement * element, + GstEvent * event); +static gboolean gst_base_sink_query (GstElement * element, GstQuery * query); + static GstCaps *gst_base_sink_get_caps (GstBaseSink * sink); static gboolean gst_base_sink_set_caps (GstBaseSink * sink, GstCaps * caps); static GstFlowReturn gst_base_sink_buffer_alloc (GstBaseSink * sink, @@ -162,6 +166,8 @@ gst_base_sink_class_init (GstBaseSinkClass * klass) gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_base_sink_set_clock); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_base_sink_change_state); + gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_base_sink_send_event); + gstelement_class->query = GST_DEBUG_FUNCPTR (gst_base_sink_query); klass->get_caps = GST_DEBUG_FUNCPTR (gst_base_sink_get_caps); klass->set_caps = GST_DEBUG_FUNCPTR (gst_base_sink_set_caps); @@ -1291,6 +1297,79 @@ gst_base_sink_activate_pull (GstPad * pad, gboolean active) return result; } +static gboolean +gst_base_sink_send_event (GstElement * element, GstEvent * event) +{ + GstPad *pad; + GstBaseSink *basesink = GST_BASE_SINK (element); + gboolean result; + + GST_LOCK (element); + pad = basesink->sinkpad; + gst_object_ref (pad); + GST_UNLOCK (element); + + result = gst_pad_push_event (pad, event); + + gst_object_unref (pad); + + return result; +} + +static gboolean +gst_base_sink_peer_query (GstBaseSink * sink, GstQuery * query) +{ + GstPad *peer; + gboolean res = FALSE; + + if ((peer = gst_pad_get_peer (sink->sinkpad))) { + res = gst_pad_query (peer, query); + gst_object_unref (peer); + } + return res; +} + +static gboolean +gst_base_sink_query (GstElement * element, GstQuery * query) +{ + gboolean res = FALSE; + + GstBaseSink *basesink = GST_BASE_SINK (element); + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_POSITION: + res = gst_base_sink_peer_query (basesink, query); + break; + case GST_QUERY_LATENCY: + break; + case GST_QUERY_JITTER: + break; + case GST_QUERY_RATE: + //gst_query_set_rate (query, basesink->segment_rate); + res = TRUE; + break; + case GST_QUERY_SEEKING: + res = gst_base_sink_peer_query (basesink, query); + break; + case GST_QUERY_SEGMENT: + { + gst_query_set_segment (query, basesink->segment_rate, + GST_FORMAT_TIME, basesink->segment_start, basesink->segment_stop, + basesink->segment_base); + break; + } + case GST_QUERY_CONVERT: + res = gst_base_sink_peer_query (basesink, query); + break; + case GST_QUERY_FORMATS: + res = gst_base_sink_peer_query (basesink, query); + break; + default: + break; + } + return res; +} + static GstStateChangeReturn gst_base_sink_change_state (GstElement * element, GstStateChange transition) { diff --git a/gst/gstelement.c b/gst/gstelement.c index 92bd9e1764c..1e880234050 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -1780,6 +1780,8 @@ gst_element_set_state (GstElement * element, GstState state) /* this is the state we should go to */ GST_STATE_FINAL (element) = state; if (ret == GST_STATE_CHANGE_ASYNC) { + /* force next state keeping ASYNC, this is atomic as we hold + * the STATE_LOCK */ gst_element_commit_state (element); gst_element_lost_state (element); } diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 8886f6c87ec..f7be1c4578d 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -105,6 +105,10 @@ static void gst_base_sink_set_property (GObject * object, guint prop_id, static void gst_base_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static gboolean gst_base_sink_send_event (GstElement * element, + GstEvent * event); +static gboolean gst_base_sink_query (GstElement * element, GstQuery * query); + static GstCaps *gst_base_sink_get_caps (GstBaseSink * sink); static gboolean gst_base_sink_set_caps (GstBaseSink * sink, GstCaps * caps); static GstFlowReturn gst_base_sink_buffer_alloc (GstBaseSink * sink, @@ -162,6 +166,8 @@ gst_base_sink_class_init (GstBaseSinkClass * klass) gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_base_sink_set_clock); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_base_sink_change_state); + gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_base_sink_send_event); + gstelement_class->query = GST_DEBUG_FUNCPTR (gst_base_sink_query); klass->get_caps = GST_DEBUG_FUNCPTR (gst_base_sink_get_caps); klass->set_caps = GST_DEBUG_FUNCPTR (gst_base_sink_set_caps); @@ -1291,6 +1297,79 @@ gst_base_sink_activate_pull (GstPad * pad, gboolean active) return result; } +static gboolean +gst_base_sink_send_event (GstElement * element, GstEvent * event) +{ + GstPad *pad; + GstBaseSink *basesink = GST_BASE_SINK (element); + gboolean result; + + GST_LOCK (element); + pad = basesink->sinkpad; + gst_object_ref (pad); + GST_UNLOCK (element); + + result = gst_pad_push_event (pad, event); + + gst_object_unref (pad); + + return result; +} + +static gboolean +gst_base_sink_peer_query (GstBaseSink * sink, GstQuery * query) +{ + GstPad *peer; + gboolean res = FALSE; + + if ((peer = gst_pad_get_peer (sink->sinkpad))) { + res = gst_pad_query (peer, query); + gst_object_unref (peer); + } + return res; +} + +static gboolean +gst_base_sink_query (GstElement * element, GstQuery * query) +{ + gboolean res = FALSE; + + GstBaseSink *basesink = GST_BASE_SINK (element); + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_POSITION: + res = gst_base_sink_peer_query (basesink, query); + break; + case GST_QUERY_LATENCY: + break; + case GST_QUERY_JITTER: + break; + case GST_QUERY_RATE: + //gst_query_set_rate (query, basesink->segment_rate); + res = TRUE; + break; + case GST_QUERY_SEEKING: + res = gst_base_sink_peer_query (basesink, query); + break; + case GST_QUERY_SEGMENT: + { + gst_query_set_segment (query, basesink->segment_rate, + GST_FORMAT_TIME, basesink->segment_start, basesink->segment_stop, + basesink->segment_base); + break; + } + case GST_QUERY_CONVERT: + res = gst_base_sink_peer_query (basesink, query); + break; + case GST_QUERY_FORMATS: + res = gst_base_sink_peer_query (basesink, query); + break; + default: + break; + } + return res; +} + static GstStateChangeReturn gst_base_sink_change_state (GstElement * element, GstStateChange transition) {