이벤트 기능은 데이터 스트림에서 발생하는 특수 이벤트 (예: caps, end-of-stream, newsegment, tags 등)를 알려줍니다. 이벤트는 업스트림과 다운스트림 모두로 이동할 수 있으므로 sink pad와 source pad에서 이벤트를 수신할 수 있습니다.
다음은 element의 sink pad에 추가하는 매우 간단한 이벤트 기능입니다.
static gboolean gst_my_filter_sink_event (GstPad *pad,
GstObject *parent,
GstEvent *event);
[..]
static void
gst_my_filter_init (GstMyFilter * filter)
{
[..]
/* configure event function on the pad before adding
* the pad to the element */
gst_pad_set_event_function (filter->sinkpad,
gst_my_filter_sink_event);
[..]
}
static gboolean
gst_my_filter_sink_event (GstPad *pad,
GstObject *parent,
GstEvent *event)
{
gboolean ret;
GstMyFilter *filter = GST_MY_FILTER (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
/* we should handle the format here */
/* push the event downstream */
ret = gst_pad_push_event (filter->srcpad, event);
break;
case GST_EVENT_EOS:
/* end-of-stream, we should close down all stream leftovers here */
gst_my_filter_stop_processing (filter);
ret = gst_pad_event_default (pad, parent, event);
break;
default:
/* just call the default handler */
ret = gst_pad_event_default (pad, parent, event);
break;
}
return ret;
}
알 수 없는 이벤트의 경우 디폴트 이벤트 핸들러 gst_pad_event_default()를 호출하는 것이 좋습니다. 이벤트 유형에 따라 디폴트 핸들러는 이벤트를 전달하거나 단순히 참조 해제합니다. CAPS 이벤트는 기본적으로 전달되지 않으므로 이벤트 핸들러에서 직접 이 작업을 수행해야 합니다.
원문: The event function (gstreamer.freedesktop.org)
The event function
The event function The event function notifies you of special events that happen in the datastream (such as caps, end-of-stream, newsegment, tags, etc.). Events can travel both upstream and downstream, so you can receive them on sink pads as well as source
gstreamer.freedesktop.org
반응형
'IT와 개발 > GStreamer Study' 카테고리의 다른 글
What are states? (4) | 2024.09.27 |
---|---|
The query function (3) | 2024.09.20 |
The chain function (0) | 2024.09.06 |
Specifying the pads (1) | 2024.08.30 |
Constructing the Boilerplate (0) | 2024.08.23 |