在随后的管道filesrc ! wavparse ! my_element ! wavenc ! filesink
中,延迟没有得到补偿。但是,如果添加重采样,则可能会产生额外的延迟,但是这种延迟似乎可以得到补偿。我做错了吗?我在文档中错过了什么?
为您提供信息,在我的元素的set_caps中,我发布了一条消息,提示有新的延迟可用
gst_element_post_message (GST_ELEMENT (my_element), gst_message_new_latency (GST_OBJECT(my_element)));
在源填充查询回调中,我将延迟设置如下:
static gboolean gst_m_element_query(GstPad * pad, GstObject * parent, GstQuery * query)
{
GstMyElement *inst = GST_MY_ELEMENT(parent);
GstBaseTransform *trans = GST_BASE_TRANSFORM(parent);
gboolean res = TRUE;
switch(GST_QUERY_TYPE(query))
{
case GST_QUERY_LATENCY:
if ((res = gst_pad_peer_query(GST_BASE_TRANSFORM_SINK_PAD(trans), query)))
{
GstClockTime min, max;
guint64 latency;
gboolean live;
gint rate = inst->sink_info.rate;
gst_query_parse_latency(query, &live, &min, &max);
latency = gst_util_uint64_scale_round(1000, GST_SECOND, rate);
// add to min/max
min += latency;
if (GST_CLOCK_TIME_IS_VALID(max))
max += latency;
gst_query_set_latency (query, live, min, max);
}
break;
default:
res = gst_pad_query_default(pad, parent, query);
break;
}
return res;
}
谢谢