쿼리 함수를 통해 귀하의 element는 응답해야 하는 쿼리를 받게 됩니다. 여기에는 position, duration과 같은 쿼리뿐만 아니라 element가 지원하는 지원되는 형식과 스케줄링 모드에 대한 쿼리도 포함됩니다. 쿼리는 업스트림과 다운스트림 모두로 이동할 수 있으므로 sink pad와 source pad에서 모두 수신할 수 있습니다.
다음은 element의 source pad에 추가하는 매우 간단한 쿼리 함수입니다.
static gboolean gst_my_filter_src_query (GstPad *pad,
GstObject *parent,
GstQuery *query);
[..]
static void
gst_my_filter_init (GstMyFilter * filter)
{
[..]
/* configure event function on the pad before adding
* the pad to the element */
gst_pad_set_query_function (filter->srcpad,
gst_my_filter_src_query);
[..]
}
static gboolean
gst_my_filter_src_query (GstPad *pad,
GstObject *parent,
GstQuery *query)
{
gboolean ret;
GstMyFilter *filter = GST_MY_FILTER (parent);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
/* we should report the current position */
[...]
break;
case GST_QUERY_DURATION:
/* we should report the duration here */
[...]
break;
case GST_QUERY_CAPS:
/* we should report the supported caps here */
[...]
break;
default:
/* just call the default handler */
ret = gst_pad_query_default (pad, parent, query);
break;
}
return ret;
}
알 수 없는 쿼리의 경우 디폴트 쿼리 핸들러 gst_pad_query_default()를 호출하는 것이 좋습니다. 쿼리 유형에 따라 디폴트 핸들러는 쿼리를 전달하거나 단순히 참조 해제합니다.
원문: The query function (gstreamer.freedesktop.org)
The query function
The query function Through the query function, your element will receive queries that it has to reply to. These are queries like position, duration but also about the supported formats and scheduling modes your element supports. Queries can travel both ups
gstreamer.freedesktop.org
반응형
'IT와 개발 > GStreamer Study' 카테고리의 다른 글
Adding Properties (1) | 2024.10.04 |
---|---|
What are states? (4) | 2024.09.27 |
The event function (0) | 2024.09.13 |
The chain function (0) | 2024.09.06 |
Specifying the pads (1) | 2024.08.30 |