📄 gstbasesink.c
字号:
} gst_object_unref (bsink); return caps;}static gbooleangst_base_sink_pad_setcaps (GstPad * pad, GstCaps * caps){ GstBaseSinkClass *bclass; GstBaseSink *bsink; gboolean res = TRUE; bsink = GST_BASE_SINK (gst_pad_get_parent (pad)); bclass = GST_BASE_SINK_GET_CLASS (bsink); if (bsink->pad_mode == GST_ACTIVATE_PULL) { GstPad *peer = gst_pad_get_peer (pad); if (peer) res = gst_pad_set_caps (peer, caps); else res = FALSE; if (!res) GST_DEBUG_OBJECT (bsink, "peer setcaps() failed"); } if (res && bclass->set_caps) res = bclass->set_caps (bsink, caps); gst_object_unref (bsink); return res;}static voidgst_base_sink_pad_fixate (GstPad * pad, GstCaps * caps){ GstBaseSinkClass *bclass; GstBaseSink *bsink; bsink = GST_BASE_SINK (gst_pad_get_parent (pad)); bclass = GST_BASE_SINK_GET_CLASS (bsink); if (bclass->fixate) bclass->fixate (bsink, caps); gst_object_unref (bsink);}static GstFlowReturngst_base_sink_pad_buffer_alloc (GstPad * pad, guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf){ GstBaseSinkClass *bclass; GstBaseSink *bsink; GstFlowReturn result = GST_FLOW_OK; bsink = GST_BASE_SINK (gst_pad_get_parent (pad)); bclass = GST_BASE_SINK_GET_CLASS (bsink); if (bclass->buffer_alloc) result = bclass->buffer_alloc (bsink, offset, size, caps, buf); else *buf = NULL; /* fallback in gstpad.c will allocate generic buffer */ gst_object_unref (bsink); return result;}static voidgst_base_sink_init (GstBaseSink * basesink, gpointer g_class){ GstPadTemplate *pad_template; GstBaseSinkPrivate *priv; basesink->priv = priv = GST_BASE_SINK_GET_PRIVATE (basesink); pad_template = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "sink"); g_return_if_fail (pad_template != NULL); basesink->sinkpad = gst_pad_new_from_template (pad_template, "sink"); gst_pad_set_getcaps_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_pad_getcaps)); gst_pad_set_setcaps_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_pad_setcaps)); gst_pad_set_fixatecaps_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_pad_fixate)); gst_pad_set_bufferalloc_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_pad_buffer_alloc)); gst_pad_set_activate_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_pad_activate)); gst_pad_set_activatepush_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_pad_activate_push)); gst_pad_set_activatepull_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_pad_activate_pull)); gst_pad_set_event_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_event)); gst_pad_set_chain_function (basesink->sinkpad, GST_DEBUG_FUNCPTR (gst_base_sink_chain)); gst_element_add_pad (GST_ELEMENT_CAST (basesink), basesink->sinkpad); basesink->pad_mode = GST_ACTIVATE_NONE; basesink->preroll_queue = g_queue_new (); basesink->abidata.ABI.clip_segment = gst_segment_new (); priv->have_latency = FALSE; basesink->can_activate_push = DEFAULT_CAN_ACTIVATE_PUSH; basesink->can_activate_pull = DEFAULT_CAN_ACTIVATE_PULL; basesink->sync = DEFAULT_SYNC; basesink->abidata.ABI.max_lateness = DEFAULT_MAX_LATENESS; gst_atomic_int_set (&priv->qos_enabled, DEFAULT_QOS); priv->async_enabled = DEFAULT_ASYNC; priv->ts_offset = DEFAULT_TS_OFFSET; GST_OBJECT_FLAG_SET (basesink, GST_ELEMENT_IS_SINK);}static voidgst_base_sink_finalize (GObject * object){ GstBaseSink *basesink; basesink = GST_BASE_SINK (object); g_queue_free (basesink->preroll_queue); gst_segment_free (basesink->abidata.ABI.clip_segment); G_OBJECT_CLASS (parent_class)->finalize (object);}/** * gst_base_sink_set_sync: * @sink: the sink * @sync: the new sync value. * * Configures @sink to synchronize on the clock or not. When * @sync is FALSE, incomming samples will be played as fast as * possible. If @sync is TRUE, the timestamps of the incomming * buffers will be used to schedule the exact render time of its * contents. * * Since: 0.10.4 */voidgst_base_sink_set_sync (GstBaseSink * sink, gboolean sync){ g_return_if_fail (GST_IS_BASE_SINK (sink)); GST_OBJECT_LOCK (sink); sink->sync = sync; GST_OBJECT_UNLOCK (sink);}/** * gst_base_sink_get_sync: * @sink: the sink * * Checks if @sink is currently configured to synchronize against the * clock. * * Returns: TRUE if the sink is configured to synchronize against the clock. * * Since: 0.10.4 */gbooleangst_base_sink_get_sync (GstBaseSink * sink){ gboolean res; g_return_val_if_fail (GST_IS_BASE_SINK (sink), FALSE); GST_OBJECT_LOCK (sink); res = sink->sync; GST_OBJECT_UNLOCK (sink); return res;}/** * gst_base_sink_set_max_lateness: * @sink: the sink * @max_lateness: the new max lateness value. * * Sets the new max lateness value to @max_lateness. This value is * used to decide if a buffer should be dropped or not based on the * buffer timestamp and the current clock time. A value of -1 means * an unlimited time. * * Since: 0.10.4 */voidgst_base_sink_set_max_lateness (GstBaseSink * sink, gint64 max_lateness){ g_return_if_fail (GST_IS_BASE_SINK (sink)); GST_OBJECT_LOCK (sink); sink->abidata.ABI.max_lateness = max_lateness; GST_OBJECT_UNLOCK (sink);}/** * gst_base_sink_get_max_lateness: * @sink: the sink * * Gets the max lateness value. See gst_base_sink_set_max_lateness for * more details. * * Returns: The maximum time in nanoseconds that a buffer can be late * before it is dropped and not rendered. A value of -1 means an * unlimited time. * * Since: 0.10.4 */gint64gst_base_sink_get_max_lateness (GstBaseSink * sink){ gint64 res; g_return_val_if_fail (GST_IS_BASE_SINK (sink), -1); GST_OBJECT_LOCK (sink); res = sink->abidata.ABI.max_lateness; GST_OBJECT_UNLOCK (sink); return res;}/** * gst_base_sink_set_qos_enabled: * @sink: the sink * @enabled: the new qos value. * * Configures @sink to send Quality-of-Service events upstream. * * Since: 0.10.5 */voidgst_base_sink_set_qos_enabled (GstBaseSink * sink, gboolean enabled){ g_return_if_fail (GST_IS_BASE_SINK (sink)); gst_atomic_int_set (&sink->priv->qos_enabled, enabled);}/** * gst_base_sink_is_qos_enabled: * @sink: the sink * * Checks if @sink is currently configured to send Quality-of-Service events * upstream. * * Returns: TRUE if the sink is configured to perform Quality-of-Service. * * Since: 0.10.5 */gbooleangst_base_sink_is_qos_enabled (GstBaseSink * sink){ gboolean res; g_return_val_if_fail (GST_IS_BASE_SINK (sink), FALSE); res = g_atomic_int_get (&sink->priv->qos_enabled); return res;}/** * gst_base_sink_set_async_enabled: * @sink: the sink * @enabled: the new async value. * * Configures @sink to perform all state changes asynchronusly. When async is * disabled, the sink will immediatly go to PAUSED instead of waiting for a * preroll buffer. This feature is usefull if the sink does not synchronize * against the clock or when it is dealing with sparse streams. * * Since: 0.10.15 */voidgst_base_sink_set_async_enabled (GstBaseSink * sink, gboolean enabled){ g_return_if_fail (GST_IS_BASE_SINK (sink)); GST_PAD_PREROLL_LOCK (sink->sinkpad); sink->priv->async_enabled = enabled; GST_PAD_PREROLL_UNLOCK (sink->sinkpad);}/** * gst_base_sink_is_async_enabled: * @sink: the sink * * Checks if @sink is currently configured to perform asynchronous state * changes to PAUSED. * * Returns: TRUE if the sink is configured to perform asynchronous state * changes. * * Since: 0.10.15 */gbooleangst_base_sink_is_async_enabled (GstBaseSink * sink){ gboolean res; g_return_val_if_fail (GST_IS_BASE_SINK (sink), FALSE); GST_PAD_PREROLL_LOCK (sink->sinkpad); res = sink->priv->async_enabled; GST_PAD_PREROLL_UNLOCK (sink->sinkpad); return res;}/** * gst_base_sink_set_ts_offset: * @sink: the sink * @offset: the new offset * * Adjust the synchronisation of @sink with @offset. A negative value will * render buffers earlier than their timestamp. A positive value will delay * rendering. This function can be used to fix playback of badly timestamped * buffers. * * Since: 0.10.15 */voidgst_base_sink_set_ts_offset (GstBaseSink * sink, GstClockTimeDiff offset){ g_return_if_fail (GST_IS_BASE_SINK (sink)); GST_OBJECT_LOCK (sink); sink->priv->ts_offset = offset; GST_OBJECT_UNLOCK (sink);}/** * gst_base_sink_get_ts_offset: * @sink: the sink * * Get the synchronisation offset of @sink. * * Returns: The synchronisation offset. * * Since: 0.10.15 */GstClockTimeDiffgst_base_sink_get_ts_offset (GstBaseSink * sink){ GstClockTimeDiff res; g_return_val_if_fail (GST_IS_BASE_SINK (sink), 0); GST_OBJECT_LOCK (sink); res = sink->priv->ts_offset; GST_OBJECT_UNLOCK (sink); return res;}/** * gst_base_sink_get_last_buffer: * @sink: the sink * * Get the last buffer that arrived in the sink and was used for preroll or for * rendering. This property can be used to generate thumbnails. * * The #GstCaps on the buffer can be used to determine the type of the buffer. * * Returns: a #GstBuffer. gst_buffer_unref() after usage. This function returns * NULL when no buffer has arrived in the sink yet or when the sink is not in * PAUSED or PLAYING. * * Since: 0.10.15 */GstBuffer *gst_base_sink_get_last_buffer (GstBaseSink * sink){ GstBuffer *res; g_return_val_if_fail (GST_IS_BASE_SINK (sink), NULL); GST_OBJECT_LOCK (sink); if ((res = sink->priv->last_buffer)) gst_buffer_ref (res); GST_OBJECT_UNLOCK (sink); return res;}static voidgst_base_sink_set_last_buffer (GstBaseSink * sink, GstBuffer * buffer){ GstBuffer *old; if (buffer) gst_buffer_ref (buffer); GST_OBJECT_LOCK (sink); old = sink->priv->last_buffer; sink->priv->last_buffer = buffer; GST_OBJECT_UNLOCK (sink); if (old) gst_buffer_unref (old);}/** * gst_base_sink_get_latency: * @sink: the sink * * Get the currently configured latency. * * Returns: The configured latency. * * Since: 0.10.12 */GstClockTimegst_base_sink_get_latency (GstBaseSink * sink){ GstClockTime res; GST_OBJECT_LOCK (sink); res = sink->priv->latency; GST_OBJECT_UNLOCK (sink); return res;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -