mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
change getcaps to query
Add sink and src event functions in rtpbasepayload Add query vmethod to rtpbasepayload.
This commit is contained in:
parent
3e095382a1
commit
ab9ffa93f5
15 changed files with 333 additions and 123 deletions
|
@ -215,7 +215,6 @@ gst_visual_init (GstVisual * visual)
|
|||
gst_element_add_pad (GST_ELEMENT (visual), visual->sinkpad);
|
||||
|
||||
visual->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
||||
gst_pad_set_getcaps_function (visual->srcpad, gst_visual_getcaps);
|
||||
gst_pad_set_event_function (visual->srcpad, gst_visual_src_event);
|
||||
gst_pad_set_query_function (visual->srcpad, gst_visual_src_query);
|
||||
gst_element_add_pad (GST_ELEMENT (visual), visual->srcpad);
|
||||
|
@ -646,8 +645,18 @@ gst_visual_src_query (GstPad * pad, GstQuery * query)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_visual_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_peer_query (visual->sinkpad, query);
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -319,6 +319,8 @@ static gboolean gst_base_text_overlay_src_query (GstPad * pad,
|
|||
|
||||
static gboolean gst_base_text_overlay_video_event (GstPad * pad,
|
||||
GstEvent * event);
|
||||
static gboolean gst_base_text_overlay_video_query (GstPad * pad,
|
||||
GstQuery * query);
|
||||
static GstFlowReturn gst_base_text_overlay_video_chain (GstPad * pad,
|
||||
GstBuffer * buffer);
|
||||
|
||||
|
@ -614,12 +616,12 @@ gst_base_text_overlay_init (GstBaseTextOverlay * overlay,
|
|||
template = gst_static_pad_template_get (&video_sink_template_factory);
|
||||
overlay->video_sinkpad = gst_pad_new_from_template (template, "video_sink");
|
||||
gst_object_unref (template);
|
||||
gst_pad_set_getcaps_function (overlay->video_sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_base_text_overlay_getcaps));
|
||||
gst_pad_set_event_function (overlay->video_sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_base_text_overlay_video_event));
|
||||
gst_pad_set_chain_function (overlay->video_sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_base_text_overlay_video_chain));
|
||||
gst_pad_set_query_function (overlay->video_sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_base_text_overlay_video_query));
|
||||
gst_element_add_pad (GST_ELEMENT (overlay), overlay->video_sinkpad);
|
||||
|
||||
template =
|
||||
|
@ -645,8 +647,6 @@ gst_base_text_overlay_init (GstBaseTextOverlay * overlay,
|
|||
template = gst_static_pad_template_get (&src_template_factory);
|
||||
overlay->srcpad = gst_pad_new_from_template (template, "src");
|
||||
gst_object_unref (template);
|
||||
gst_pad_set_getcaps_function (overlay->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_base_text_overlay_getcaps));
|
||||
gst_pad_set_event_function (overlay->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_base_text_overlay_src_event));
|
||||
gst_pad_set_query_function (overlay->srcpad,
|
||||
|
@ -1002,7 +1002,22 @@ gst_base_text_overlay_src_query (GstPad * pad, GstQuery * query)
|
|||
if (G_UNLIKELY (!overlay))
|
||||
return FALSE;
|
||||
|
||||
ret = gst_pad_peer_query (overlay->video_sinkpad, query);
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_base_text_overlay_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = gst_pad_peer_query (overlay->video_sinkpad, query);
|
||||
break;
|
||||
}
|
||||
|
||||
gst_object_unref (overlay);
|
||||
|
||||
|
@ -2310,6 +2325,39 @@ gst_base_text_overlay_video_event (GstPad * pad, GstEvent * event)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_base_text_overlay_video_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GstBaseTextOverlay *overlay = NULL;
|
||||
|
||||
overlay = GST_BASE_TEXT_OVERLAY (gst_pad_get_parent (pad));
|
||||
if (G_UNLIKELY (!overlay)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_base_text_overlay_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
|
||||
gst_object_unref (overlay);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Called with lock held */
|
||||
static void
|
||||
gst_base_text_overlay_pop_text (GstBaseTextOverlay * overlay)
|
||||
|
|
|
@ -253,7 +253,7 @@ static gboolean theora_enc_src_event (GstPad * pad, GstEvent * event);
|
|||
static GstFlowReturn theora_enc_chain (GstPad * pad, GstBuffer * buffer);
|
||||
static GstStateChangeReturn theora_enc_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
static GstCaps *theora_enc_sink_getcaps (GstPad * pad, GstCaps * filter);
|
||||
static gboolean theora_enc_sink_query (GstPad * pad, GstQuery * query);
|
||||
static gboolean theora_enc_sink_setcaps (GstTheoraEnc * enc, GstCaps * caps);
|
||||
static void theora_enc_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
|
@ -418,7 +418,7 @@ gst_theora_enc_init (GstTheoraEnc * enc)
|
|||
gst_pad_new_from_static_template (&theora_enc_sink_factory, "sink");
|
||||
gst_pad_set_chain_function (enc->sinkpad, theora_enc_chain);
|
||||
gst_pad_set_event_function (enc->sinkpad, theora_enc_sink_event);
|
||||
gst_pad_set_getcaps_function (enc->sinkpad, theora_enc_sink_getcaps);
|
||||
gst_pad_set_query_function (enc->sinkpad, theora_enc_sink_query);
|
||||
gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad);
|
||||
|
||||
enc->srcpad =
|
||||
|
@ -655,6 +655,31 @@ theora_enc_sink_getcaps (GstPad * pad, GstCaps * filter)
|
|||
return caps;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
theora_enc_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = theora_enc_sink_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
theora_enc_sink_setcaps (GstTheoraEnc * enc, GstCaps * caps)
|
||||
{
|
||||
|
|
|
@ -296,13 +296,15 @@ static void gst_audio_encoder_get_property (GObject * object,
|
|||
static gboolean gst_audio_encoder_sink_activate_push (GstPad * pad,
|
||||
gboolean active);
|
||||
|
||||
static GstCaps *gst_audio_encoder_getcaps_default (GstAudioEncoder * enc,
|
||||
GstCaps * filter);
|
||||
|
||||
static gboolean gst_audio_encoder_sink_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean gst_audio_encoder_sink_setcaps (GstAudioEncoder * enc,
|
||||
GstCaps * caps);
|
||||
static GstFlowReturn gst_audio_encoder_chain (GstPad * pad, GstBuffer * buffer);
|
||||
static gboolean gst_audio_encoder_src_query (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_audio_encoder_sink_query (GstPad * pad, GstQuery * query);
|
||||
static GstCaps *gst_audio_encoder_sink_getcaps (GstPad * pad, GstCaps * filter);
|
||||
|
||||
static void
|
||||
gst_audio_encoder_class_init (GstAudioEncoderClass * klass)
|
||||
|
@ -340,6 +342,8 @@ gst_audio_encoder_class_init (GstAudioEncoderClass * klass)
|
|||
"Consider discontinuity if timestamp jitter/imperfection exceeds tolerance (ns)",
|
||||
0, G_MAXINT64, DEFAULT_TOLERANCE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
klass->getcaps = gst_audio_encoder_getcaps_default;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -358,8 +362,6 @@ gst_audio_encoder_init (GstAudioEncoder * enc, GstAudioEncoderClass * bclass)
|
|||
enc->sinkpad = gst_pad_new_from_template (pad_template, "sink");
|
||||
gst_pad_set_event_function (enc->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_audio_encoder_sink_event));
|
||||
gst_pad_set_getcaps_function (enc->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_audio_encoder_sink_getcaps));
|
||||
gst_pad_set_query_function (enc->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_audio_encoder_sink_query));
|
||||
gst_pad_set_chain_function (enc->sinkpad,
|
||||
|
@ -1192,22 +1194,11 @@ done:
|
|||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_audio_encoder_sink_getcaps (GstPad * pad, GstCaps * filter)
|
||||
gst_audio_encoder_getcaps_default (GstAudioEncoder * enc, GstCaps * filter)
|
||||
{
|
||||
GstAudioEncoder *enc;
|
||||
GstAudioEncoderClass *klass;
|
||||
GstCaps *caps;
|
||||
|
||||
enc = GST_AUDIO_ENCODER (gst_pad_get_parent (pad));
|
||||
klass = GST_AUDIO_ENCODER_GET_CLASS (enc);
|
||||
g_assert (pad == enc->sinkpad);
|
||||
|
||||
if (klass->getcaps)
|
||||
caps = klass->getcaps (enc, filter);
|
||||
else
|
||||
caps = gst_audio_encoder_proxy_getcaps (enc, NULL);
|
||||
gst_object_unref (enc);
|
||||
|
||||
caps = gst_audio_encoder_proxy_getcaps (enc, NULL);
|
||||
GST_LOG_OBJECT (enc, "returning caps %" GST_PTR_FORMAT, caps);
|
||||
|
||||
return caps;
|
||||
|
@ -1372,7 +1363,7 @@ gst_audio_encoder_sink_event (GstPad * pad, GstEvent * event)
|
|||
static gboolean
|
||||
gst_audio_encoder_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
gboolean res = FALSE;
|
||||
GstAudioEncoder *enc;
|
||||
|
||||
enc = GST_AUDIO_ENCODER (gst_pad_get_parent (pad));
|
||||
|
@ -1395,6 +1386,23 @@ gst_audio_encoder_sink_query (GstPad * pad, GstQuery * query)
|
|||
src_fmt, src_val, dest_fmt, &dest_val)))
|
||||
goto error;
|
||||
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
GstAudioEncoderClass *klass;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
|
||||
klass = GST_AUDIO_ENCODER_GET_CLASS (enc);
|
||||
if (klass->getcaps) {
|
||||
caps = klass->getcaps (enc, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1404,6 +1412,7 @@ gst_audio_encoder_sink_query (GstPad * pad, GstQuery * query)
|
|||
|
||||
error:
|
||||
gst_object_unref (enc);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ static GstFlowReturn gst_rtp_base_audio_payload_handle_buffer (GstRTPBasePayload
|
|||
* payload, GstBuffer * buffer);
|
||||
static GstStateChangeReturn gst_rtp_base_payload_audio_change_state (GstElement
|
||||
* element, GstStateChange transition);
|
||||
static gboolean gst_rtp_base_payload_audio_handle_event (GstRTPBasePayload
|
||||
static gboolean gst_rtp_base_payload_audio_sink_event (GstRTPBasePayload
|
||||
* payload, GstEvent * event);
|
||||
|
||||
#define gst_rtp_base_audio_payload_parent_class parent_class
|
||||
|
@ -188,8 +188,8 @@ gst_rtp_base_audio_payload_class_init (GstRTPBaseAudioPayloadClass * klass)
|
|||
|
||||
gstrtpbasepayload_class->handle_buffer =
|
||||
GST_DEBUG_FUNCPTR (gst_rtp_base_audio_payload_handle_buffer);
|
||||
gstrtpbasepayload_class->handle_event =
|
||||
GST_DEBUG_FUNCPTR (gst_rtp_base_payload_audio_handle_event);
|
||||
gstrtpbasepayload_class->sink_event =
|
||||
GST_DEBUG_FUNCPTR (gst_rtp_base_payload_audio_sink_event);
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpbaseaudiopayload_debug, "rtpbaseaudiopayload", 0,
|
||||
"base audio RTP payloader");
|
||||
|
@ -951,7 +951,7 @@ gst_rtp_base_payload_audio_change_state (GstElement * element,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_base_payload_audio_handle_event (GstRTPBasePayload * basep,
|
||||
gst_rtp_base_payload_audio_sink_event (GstRTPBasePayload * basep,
|
||||
GstEvent * event)
|
||||
{
|
||||
GstRTPBaseAudioPayload *payload;
|
||||
|
@ -972,7 +972,7 @@ gst_rtp_base_payload_audio_handle_event (GstRTPBasePayload * basep,
|
|||
}
|
||||
|
||||
/* let parent handle the remainder of the event */
|
||||
res = GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->handle_event (basep, event);
|
||||
res = GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (basep, event);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -96,16 +96,19 @@ static void gst_rtp_base_payload_init (GstRTPBasePayload * rtpbasepayload,
|
|||
gpointer g_class);
|
||||
static void gst_rtp_base_payload_finalize (GObject * object);
|
||||
|
||||
static GstCaps *gst_rtp_base_payload_sink_getcaps (GstPad * pad,
|
||||
GstCaps * filter);
|
||||
static gboolean gst_rtp_base_payload_event_default (GstRTPBasePayload *
|
||||
rtpbasepayload, GstEvent * event);
|
||||
static gboolean gst_rtp_base_payload_event (GstPad * pad, GstEvent * event);
|
||||
static GstFlowReturn gst_rtp_base_payload_chain (GstPad * pad,
|
||||
GstBuffer * buffer);
|
||||
static GstCaps *gst_rtp_base_payload_getcaps_default (GstRTPBasePayload *
|
||||
rtpbasepayload, GstPad * pad, GstCaps * filter);
|
||||
|
||||
static gboolean gst_rtp_base_payload_sink_event_default (GstRTPBasePayload *
|
||||
rtpbasepayload, GstEvent * event);
|
||||
static gboolean gst_rtp_base_payload_sink_event (GstPad * pad,
|
||||
GstEvent * event);
|
||||
static gboolean gst_rtp_base_payload_query_default (GstRTPBasePayload *
|
||||
rtpbasepayload, GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_rtp_base_payload_query (GstPad * pad, GstQuery * query);
|
||||
static GstFlowReturn gst_rtp_base_payload_chain (GstPad * pad,
|
||||
GstBuffer * buffer);
|
||||
|
||||
static void gst_rtp_base_payload_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtp_base_payload_get_property (GObject * object, guint prop_id,
|
||||
|
@ -241,7 +244,8 @@ gst_rtp_base_payload_class_init (GstRTPBasePayloadClass * klass)
|
|||
gstelement_class->change_state = gst_rtp_base_payload_change_state;
|
||||
|
||||
klass->get_caps = gst_rtp_base_payload_getcaps_default;
|
||||
klass->handle_event = gst_rtp_base_payload_event_default;
|
||||
klass->sink_event = gst_rtp_base_payload_sink_event_default;
|
||||
klass->query = gst_rtp_base_payload_query_default;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpbasepayload_debug, "rtpbasepayload", 0,
|
||||
"Base class for RTP Payloaders");
|
||||
|
@ -268,12 +272,12 @@ gst_rtp_base_payload_init (GstRTPBasePayload * rtpbasepayload, gpointer g_class)
|
|||
g_return_if_fail (templ != NULL);
|
||||
|
||||
rtpbasepayload->sinkpad = gst_pad_new_from_template (templ, "sink");
|
||||
gst_pad_set_getcaps_function (rtpbasepayload->sinkpad,
|
||||
gst_rtp_base_payload_sink_getcaps);
|
||||
gst_pad_set_event_function (rtpbasepayload->sinkpad,
|
||||
gst_rtp_base_payload_event);
|
||||
gst_pad_set_chain_function (rtpbasepayload->sinkpad,
|
||||
gst_rtp_base_payload_chain);
|
||||
gst_pad_set_event_function (rtpbasepayload->sinkpad,
|
||||
gst_rtp_base_payload_sink_event);
|
||||
gst_pad_set_query_function (rtpbasepayload->sinkpad,
|
||||
gst_rtp_base_payload_query);
|
||||
gst_element_add_pad (GST_ELEMENT (rtpbasepayload), rtpbasepayload->sinkpad);
|
||||
|
||||
rtpbasepayload->mtu = DEFAULT_MTU;
|
||||
|
@ -335,28 +339,8 @@ gst_rtp_base_payload_getcaps_default (GstRTPBasePayload * rtpbasepayload,
|
|||
return caps;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_rtp_base_payload_sink_getcaps (GstPad * pad, GstCaps * filter)
|
||||
{
|
||||
GstRTPBasePayload *rtpbasepayload;
|
||||
GstRTPBasePayloadClass *rtpbasepayload_class;
|
||||
GstCaps *caps = NULL;
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "getting caps");
|
||||
|
||||
rtpbasepayload = GST_RTP_BASE_PAYLOAD (gst_pad_get_parent (pad));
|
||||
rtpbasepayload_class = GST_RTP_BASE_PAYLOAD_GET_CLASS (rtpbasepayload);
|
||||
|
||||
if (rtpbasepayload_class->get_caps)
|
||||
caps = rtpbasepayload_class->get_caps (rtpbasepayload, pad, filter);
|
||||
|
||||
gst_object_unref (rtpbasepayload);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_base_payload_event_default (GstRTPBasePayload * rtpbasepayload,
|
||||
gst_rtp_base_payload_sink_event_default (GstRTPBasePayload * rtpbasepayload,
|
||||
GstEvent * event)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
@ -406,7 +390,7 @@ gst_rtp_base_payload_event_default (GstRTPBasePayload * rtpbasepayload,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_base_payload_event (GstPad * pad, GstEvent * event)
|
||||
gst_rtp_base_payload_sink_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
GstRTPBasePayload *rtpbasepayload;
|
||||
GstRTPBasePayloadClass *rtpbasepayload_class;
|
||||
|
@ -420,8 +404,8 @@ gst_rtp_base_payload_event (GstPad * pad, GstEvent * event)
|
|||
|
||||
rtpbasepayload_class = GST_RTP_BASE_PAYLOAD_GET_CLASS (rtpbasepayload);
|
||||
|
||||
if (rtpbasepayload_class->handle_event)
|
||||
res = rtpbasepayload_class->handle_event (rtpbasepayload, event);
|
||||
if (rtpbasepayload_class->sink_event)
|
||||
res = rtpbasepayload_class->sink_event (rtpbasepayload, event);
|
||||
else
|
||||
gst_event_unref (event);
|
||||
|
||||
|
@ -430,6 +414,58 @@ gst_rtp_base_payload_event (GstPad * pad, GstEvent * event)
|
|||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_base_payload_query_default (GstRTPBasePayload * rtpbasepayload,
|
||||
GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstRTPBasePayloadClass *rtpbasepayload_class;
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
GST_DEBUG_OBJECT (rtpbasepayload, "getting caps with filter %"
|
||||
GST_PTR_FORMAT, filter);
|
||||
|
||||
rtpbasepayload_class = GST_RTP_BASE_PAYLOAD_GET_CLASS (rtpbasepayload);
|
||||
if (rtpbasepayload_class->get_caps) {
|
||||
caps = rtpbasepayload_class->get_caps (rtpbasepayload, pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
res = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_base_payload_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstRTPBasePayload *rtpbasepayload;
|
||||
GstRTPBasePayloadClass *rtpbasepayload_class;
|
||||
gboolean res = FALSE;
|
||||
|
||||
rtpbasepayload = GST_RTP_BASE_PAYLOAD (gst_pad_get_parent (pad));
|
||||
if (G_UNLIKELY (rtpbasepayload == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rtpbasepayload_class = GST_RTP_BASE_PAYLOAD_GET_CLASS (rtpbasepayload);
|
||||
|
||||
if (rtpbasepayload_class->query)
|
||||
res = rtpbasepayload_class->query (rtpbasepayload, pad, query);
|
||||
|
||||
gst_object_unref (rtpbasepayload);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_rtp_base_payload_chain (GstPad * pad, GstBuffer * buffer)
|
||||
|
@ -826,8 +862,8 @@ gst_rtp_base_payload_prepare_push (GstRTPBasePayload * payload,
|
|||
(is_list) ? -1 : gst_buffer_get_size (GST_BUFFER (obj)),
|
||||
payload->seqnum, data.rtptime, GST_TIME_ARGS (data.timestamp));
|
||||
|
||||
if (g_atomic_int_compare_and_exchange (&payload->priv->
|
||||
notified_first_timestamp, 1, 0)) {
|
||||
if (g_atomic_int_compare_and_exchange (&payload->
|
||||
priv->notified_first_timestamp, 1, 0)) {
|
||||
g_object_notify (G_OBJECT (payload), "timestamp");
|
||||
g_object_notify (G_OBJECT (payload), "seqnum");
|
||||
}
|
||||
|
|
|
@ -114,10 +114,12 @@ struct _GstRTPBasePayload
|
|||
/**
|
||||
* GstRTPBasePayloadClass:
|
||||
* @parent_class: the parent class
|
||||
* @get_caps: get desired caps
|
||||
* @set_caps: configure the payloader
|
||||
* @handle_buffer: process data
|
||||
* @handle_event: custom event handling
|
||||
* @get_caps: get desired caps
|
||||
* @sink_event: custom event handling on the sinkpad
|
||||
* @src_event: custom event handling on the srcpad
|
||||
* @query: custom query handling
|
||||
*
|
||||
* Base class for audio RTP payloader.
|
||||
*/
|
||||
|
@ -134,7 +136,10 @@ struct _GstRTPBasePayloadClass
|
|||
* the RTP buffers. This function takes ownership of the buffer. */
|
||||
GstFlowReturn (*handle_buffer) (GstRTPBasePayload *payload,
|
||||
GstBuffer *buffer);
|
||||
gboolean (*handle_event) (GstRTPBasePayload *payload, GstEvent * event);
|
||||
/* handle events and queries */
|
||||
gboolean (*sink_event) (GstRTPBasePayload *payload, GstEvent * event);
|
||||
gboolean (*src_event) (GstRTPBasePayload *payload, GstEvent * event);
|
||||
gboolean (*query) (GstRTPBasePayload *payload, GstPad *pad, GstQuery * query);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
|
|
|
@ -106,7 +106,8 @@ static void gst_adder_get_property (GObject * object, guint prop_id,
|
|||
|
||||
static gboolean gst_adder_setcaps (GstAdder * adder, GstPad * pad,
|
||||
GstCaps * caps);
|
||||
static gboolean gst_adder_query (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_adder_src_query (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_adder_sink_query (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_adder_src_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean gst_adder_sink_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
|
@ -207,6 +208,30 @@ gst_adder_sink_getcaps (GstPad * pad, GstCaps * filter)
|
|||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_adder_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_adder_sink_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GstPad *pad;
|
||||
|
@ -473,7 +498,7 @@ gst_adder_query_latency (GstAdder * adder, GstQuery * query)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_adder_query (GstPad * pad, GstQuery * query)
|
||||
gst_adder_src_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstAdder *adder = GST_ADDER (gst_pad_get_parent (pad));
|
||||
gboolean res = FALSE;
|
||||
|
@ -830,12 +855,11 @@ gst_adder_init (GstAdder * adder)
|
|||
adder->srcpad = gst_pad_new_from_template (template, "src");
|
||||
gst_object_unref (template);
|
||||
|
||||
gst_pad_set_getcaps_function (adder->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
gst_pad_set_query_function (adder->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_adder_query));
|
||||
GST_DEBUG_FUNCPTR (gst_adder_src_query));
|
||||
gst_pad_set_event_function (adder->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_adder_src_event));
|
||||
GST_PAD_SET_PROXY_CAPS (adder->srcpad);
|
||||
gst_element_add_pad (GST_ELEMENT (adder), adder->srcpad);
|
||||
|
||||
gst_audio_info_init (&adder->info);
|
||||
|
@ -950,8 +974,7 @@ gst_adder_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
|||
GST_DEBUG_OBJECT (adder, "request new pad %s", name);
|
||||
g_free (name);
|
||||
|
||||
gst_pad_set_getcaps_function (newpad,
|
||||
GST_DEBUG_FUNCPTR (gst_adder_sink_getcaps));
|
||||
gst_pad_set_query_function (newpad, GST_DEBUG_FUNCPTR (gst_adder_sink_query));
|
||||
gst_collect_pads_add_pad (adder->collect, newpad, sizeof (GstCollectData));
|
||||
|
||||
/* FIXME: hacked way to override/extend the event function of
|
||||
|
|
|
@ -230,13 +230,13 @@ gst_audio_rate_init (GstAudioRate * audiorate)
|
|||
gst_pad_new_from_static_template (&gst_audio_rate_sink_template, "sink");
|
||||
gst_pad_set_event_function (audiorate->sinkpad, gst_audio_rate_sink_event);
|
||||
gst_pad_set_chain_function (audiorate->sinkpad, gst_audio_rate_chain);
|
||||
gst_pad_set_getcaps_function (audiorate->sinkpad, gst_pad_proxy_getcaps);
|
||||
GST_PAD_SET_PROXY_CAPS (audiorate->sinkpad);
|
||||
gst_element_add_pad (GST_ELEMENT (audiorate), audiorate->sinkpad);
|
||||
|
||||
audiorate->srcpad =
|
||||
gst_pad_new_from_static_template (&gst_audio_rate_src_template, "src");
|
||||
gst_pad_set_event_function (audiorate->srcpad, gst_audio_rate_src_event);
|
||||
gst_pad_set_getcaps_function (audiorate->srcpad, gst_pad_proxy_getcaps);
|
||||
GST_PAD_SET_PROXY_CAPS (audiorate->srcpad);
|
||||
gst_element_add_pad (GST_ELEMENT (audiorate), audiorate->srcpad);
|
||||
|
||||
audiorate->in = 0;
|
||||
|
|
|
@ -80,6 +80,7 @@ static gboolean setup_recoder_pipeline (GstSmartEncoder * smart_encoder);
|
|||
|
||||
static GstFlowReturn gst_smart_encoder_chain (GstPad * pad, GstBuffer * buf);
|
||||
static gboolean smart_encoder_sink_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean smart_encoder_sink_query (GstPad * pad, GstQuery * query);
|
||||
static GstCaps *smart_encoder_sink_getcaps (GstPad * pad, GstCaps * filter);
|
||||
static GstStateChangeReturn
|
||||
gst_smart_encoder_change_state (GstElement * element,
|
||||
|
@ -151,8 +152,7 @@ gst_smart_encoder_init (GstSmartEncoder * smart_encoder)
|
|||
gst_pad_new_from_static_template (&sink_template, "sink");
|
||||
gst_pad_set_chain_function (smart_encoder->sinkpad, gst_smart_encoder_chain);
|
||||
gst_pad_set_event_function (smart_encoder->sinkpad, smart_encoder_sink_event);
|
||||
gst_pad_set_getcaps_function (smart_encoder->sinkpad,
|
||||
smart_encoder_sink_getcaps);
|
||||
gst_pad_set_query_function (smart_encoder->sinkpad, smart_encoder_sink_query);
|
||||
gst_element_add_pad (GST_ELEMENT (smart_encoder), smart_encoder->sinkpad);
|
||||
|
||||
smart_encoder->srcpad =
|
||||
|
@ -406,6 +406,30 @@ smart_encoder_sink_getcaps (GstPad * pad, GstCaps * filter)
|
|||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
smart_encoder_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res;
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = smart_encoder_sink_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* Internal encoder/decoder pipeline *
|
||||
******************************************/
|
||||
|
|
|
@ -131,13 +131,13 @@ gst_stream_combiner_sink_event (GstPad * pad, GstEvent * event)
|
|||
return gst_pad_push_event (stream_combiner->srcpad, event);
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_stream_combiner_sink_getcaps (GstPad * pad, GstCaps * filter)
|
||||
static gboolean
|
||||
gst_stream_combiner_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstStreamCombiner *stream_combiner =
|
||||
(GstStreamCombiner *) GST_PAD_PARENT (pad);
|
||||
|
||||
return gst_pad_peer_get_caps (stream_combiner->srcpad, filter);
|
||||
return gst_pad_peer_query (stream_combiner->srcpad, query);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -157,6 +157,7 @@ gst_stream_combiner_src_event (GstPad * pad, GstEvent * event)
|
|||
if (sinkpad)
|
||||
/* Forward upstream as is */
|
||||
return gst_pad_push_event (sinkpad, event);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -165,7 +166,6 @@ gst_stream_combiner_src_query (GstPad * pad, GstQuery * query)
|
|||
{
|
||||
GstStreamCombiner *stream_combiner =
|
||||
(GstStreamCombiner *) GST_PAD_PARENT (pad);
|
||||
|
||||
GstPad *sinkpad = NULL;
|
||||
|
||||
STREAMS_LOCK (stream_combiner);
|
||||
|
@ -178,6 +178,7 @@ gst_stream_combiner_src_query (GstPad * pad, GstQuery * query)
|
|||
if (sinkpad)
|
||||
/* Forward upstream as is */
|
||||
return gst_pad_peer_query (sinkpad, query);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -207,7 +208,7 @@ gst_stream_combiner_request_new_pad (GstElement * element,
|
|||
sinkpad = gst_pad_new_from_static_template (&sink_template, name);
|
||||
gst_pad_set_chain_function (sinkpad, gst_stream_combiner_chain);
|
||||
gst_pad_set_event_function (sinkpad, gst_stream_combiner_sink_event);
|
||||
gst_pad_set_getcaps_function (sinkpad, gst_stream_combiner_sink_getcaps);
|
||||
gst_pad_set_query_function (sinkpad, gst_stream_combiner_sink_query);
|
||||
|
||||
STREAMS_LOCK (stream_combiner);
|
||||
stream_combiner->sinkpads =
|
||||
|
|
|
@ -302,6 +302,30 @@ beach:
|
|||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_stream_splitter_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res;
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_stream_splitter_sink_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_stream_splitter_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
|
@ -384,15 +408,12 @@ gst_stream_splitter_init (GstStreamSplitter * stream_splitter)
|
|||
{
|
||||
stream_splitter->sinkpad =
|
||||
gst_pad_new_from_static_template (&sink_template, "sink");
|
||||
/* FIXME : No buffer alloc for the time being, it will resort to the fallback */
|
||||
/* gst_pad_set_bufferalloc_function (stream_splitter->sinkpad, */
|
||||
/* gst_stream_splitter_buffer_alloc); */
|
||||
gst_pad_set_chain_function (stream_splitter->sinkpad,
|
||||
gst_stream_splitter_chain);
|
||||
gst_pad_set_event_function (stream_splitter->sinkpad,
|
||||
gst_stream_splitter_sink_event);
|
||||
gst_pad_set_getcaps_function (stream_splitter->sinkpad,
|
||||
gst_stream_splitter_sink_getcaps);
|
||||
gst_pad_set_query_function (stream_splitter->sinkpad,
|
||||
gst_stream_splitter_sink_query);
|
||||
gst_element_add_pad (GST_ELEMENT (stream_splitter), stream_splitter->sinkpad);
|
||||
|
||||
stream_splitter->lock = g_mutex_new ();
|
||||
|
|
|
@ -406,6 +406,30 @@ gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_play_sink_convert_bin_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_play_sink_convert_bin_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
gst_play_sink_convert_bin_remove_elements (GstPlaySinkConvertBin * self)
|
||||
{
|
||||
|
@ -551,8 +575,8 @@ gst_play_sink_convert_bin_init (GstPlaySinkConvertBin * self)
|
|||
self->sinkpad = gst_ghost_pad_new_no_target_from_template ("sink", templ);
|
||||
gst_pad_set_event_function (self->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_sink_event));
|
||||
gst_pad_set_getcaps_function (self->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_getcaps));
|
||||
gst_pad_set_query_function (self->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_query));
|
||||
|
||||
self->sink_proxypad =
|
||||
GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (self->sinkpad)));
|
||||
|
@ -562,8 +586,8 @@ gst_play_sink_convert_bin_init (GstPlaySinkConvertBin * self)
|
|||
|
||||
templ = gst_static_pad_template_get (&srctemplate);
|
||||
self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ);
|
||||
gst_pad_set_getcaps_function (self->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_getcaps));
|
||||
gst_pad_set_query_function (self->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_query));
|
||||
gst_element_add_pad (GST_ELEMENT_CAST (self), self->srcpad);
|
||||
gst_object_unref (templ);
|
||||
|
||||
|
|
|
@ -150,26 +150,6 @@ gst_stream_synchronizer_query (GstPad * pad, GstQuery * query)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_stream_synchronizer_getcaps (GstPad * pad, GstCaps * filter)
|
||||
{
|
||||
GstPad *opad;
|
||||
GstCaps *ret = NULL;
|
||||
|
||||
opad = gst_stream_get_other_pad_from_pad (pad);
|
||||
if (opad) {
|
||||
ret = gst_pad_peer_get_caps (opad, filter);
|
||||
gst_object_unref (opad);
|
||||
}
|
||||
|
||||
if (ret == NULL)
|
||||
ret = (filter ? gst_caps_ref (filter) : gst_caps_new_any ());
|
||||
|
||||
GST_LOG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* srcpad functions */
|
||||
static gboolean
|
||||
gst_stream_synchronizer_src_event (GstPad * pad, GstEvent * event)
|
||||
|
@ -667,8 +647,6 @@ gst_stream_synchronizer_request_new_pad (GstElement * element,
|
|||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_iterate_internal_links));
|
||||
gst_pad_set_query_function (stream->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_query));
|
||||
gst_pad_set_getcaps_function (stream->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_getcaps));
|
||||
gst_pad_set_event_function (stream->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_sink_event));
|
||||
gst_pad_set_chain_function (stream->sinkpad,
|
||||
|
@ -682,8 +660,6 @@ gst_stream_synchronizer_request_new_pad (GstElement * element,
|
|||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_iterate_internal_links));
|
||||
gst_pad_set_query_function (stream->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_query));
|
||||
gst_pad_set_getcaps_function (stream->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_getcaps));
|
||||
gst_pad_set_event_function (stream->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_stream_synchronizer_src_event));
|
||||
|
||||
|
|
|
@ -2060,6 +2060,17 @@ gst_subtitle_overlay_subtitle_sink_query (GstPad * pad, GstQuery * query)
|
|||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
GstCaps *filter, *caps;
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
caps = gst_subtitle_overlay_subtitle_sink_getcaps (pad, filter);
|
||||
gst_query_set_caps_result (query, caps);
|
||||
gst_caps_unref (caps);
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
|
@ -2122,8 +2133,6 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self)
|
|||
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_query));
|
||||
gst_pad_set_chain_function (self->subtitle_sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_chain));
|
||||
gst_pad_set_getcaps_function (self->subtitle_sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_getcaps));
|
||||
|
||||
proxypad =
|
||||
GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
|
||||
|
|
Loading…
Reference in a new issue