static GstStateChangeReturn gst_base_rtp_payload_audio_change_state (GstElement
* element, GstStateChange transition);
-static gboolean gst_base_rtp_payload_audio_handle_event (GstPad * pad,
- GstEvent * event);
+static gboolean gst_base_rtp_payload_audio_handle_event (GstBaseRTPPayload
+ * payload, GstEvent * event);
#define gst_base_rtp_audio_payload_parent_class parent_class
G_DEFINE_TYPE (GstBaseRTPAudioPayload, gst_base_rtp_audio_payload,
}
static gboolean
-gst_base_rtp_payload_audio_handle_event (GstPad * pad, GstEvent * event)
+gst_base_rtp_payload_audio_handle_event (GstBaseRTPPayload * basep,
+ GstEvent * event)
{
GstBaseRTPAudioPayload *payload;
gboolean res = FALSE;
- payload = GST_BASE_RTP_AUDIO_PAYLOAD (gst_pad_get_parent (pad));
+ payload = GST_BASE_RTP_AUDIO_PAYLOAD (basep);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
break;
}
- gst_object_unref (payload);
+ /* let parent handle the remainder of the event */
+ res = GST_BASE_RTP_PAYLOAD_CLASS (parent_class)->handle_event (basep, event);
- /* return FALSE to let parent handle the remainder of the event */
return res;
}
static void gst_base_rtp_depayload_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
-static gboolean gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_base_rtp_depayload_chain (GstPad * pad,
GstBuffer * in);
static gboolean gst_base_rtp_depayload_handle_sink_event (GstPad * pad,
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "sink");
g_return_if_fail (pad_template != NULL);
filter->sinkpad = gst_pad_new_from_template (pad_template, "sink");
- gst_pad_set_setcaps_function (filter->sinkpad,
- gst_base_rtp_depayload_setcaps);
gst_pad_set_chain_function (filter->sinkpad, gst_base_rtp_depayload_chain);
gst_pad_set_event_function (filter->sinkpad,
gst_base_rtp_depayload_handle_sink_event);
}
static gboolean
-gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
+gst_base_rtp_depayload_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
{
- GstBaseRTPDepayload *filter;
GstBaseRTPDepayloadClass *bclass;
GstBaseRTPDepayloadPrivate *priv;
gboolean res;
GstStructure *caps_struct;
const GValue *value;
- filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad));
priv = filter->priv;
bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
priv->negotiated = res;
- gst_object_unref (filter);
-
return res;
}
filter->need_newsegment = TRUE;
filter->priv->next_seqnum = -1;
break;
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+
+ res = gst_base_rtp_depayload_setcaps (filter, caps);
+ forward = FALSE;
+ break;
+ }
case GST_EVENT_SEGMENT:
{
gst_event_copy_segment (event, &filter->segment);
gpointer g_class);
static void gst_basertppayload_finalize (GObject * object);
-static gboolean gst_basertppayload_sink_setcaps (GstPad * pad, GstCaps * caps);
static GstCaps *gst_basertppayload_sink_getcaps (GstPad * pad,
GstCaps * filter);
+static gboolean gst_basertppayload_event_default (GstBaseRTPPayload *
+ basertppayload, GstEvent * event);
static gboolean gst_basertppayload_event (GstPad * pad, GstEvent * event);
static GstFlowReturn gst_basertppayload_chain (GstPad * pad,
GstBuffer * buffer);
gstelement_class->change_state = gst_basertppayload_change_state;
+ klass->handle_event = gst_basertppayload_event_default;
+
GST_DEBUG_CATEGORY_INIT (basertppayload_debug, "basertppayload", 0,
"Base class for RTP Payloaders");
}
g_return_if_fail (templ != NULL);
basertppayload->sinkpad = gst_pad_new_from_template (templ, "sink");
- gst_pad_set_setcaps_function (basertppayload->sinkpad,
- gst_basertppayload_sink_setcaps);
gst_pad_set_getcaps_function (basertppayload->sinkpad,
gst_basertppayload_sink_getcaps);
gst_pad_set_event_function (basertppayload->sinkpad,
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static gboolean
-gst_basertppayload_sink_setcaps (GstPad * pad, GstCaps * caps)
-{
- GstBaseRTPPayload *basertppayload;
- GstBaseRTPPayloadClass *basertppayload_class;
- gboolean ret = TRUE;
-
- GST_DEBUG_OBJECT (pad, "setting caps %" GST_PTR_FORMAT, caps);
- basertppayload = GST_BASE_RTP_PAYLOAD (gst_pad_get_parent (pad));
- basertppayload_class = GST_BASE_RTP_PAYLOAD_GET_CLASS (basertppayload);
-
- if (basertppayload_class->set_caps)
- ret = basertppayload_class->set_caps (basertppayload, caps);
-
- gst_object_unref (basertppayload);
-
- return ret;
-}
-
static GstCaps *
gst_basertppayload_sink_getcaps (GstPad * pad, GstCaps * filter)
{
}
static gboolean
-gst_basertppayload_event (GstPad * pad, GstEvent * event)
+gst_basertppayload_event_default (GstBaseRTPPayload * basertppayload,
+ GstEvent * event)
{
- GstBaseRTPPayload *basertppayload;
- GstBaseRTPPayloadClass *basertppayload_class;
- gboolean res;
-
- basertppayload = GST_BASE_RTP_PAYLOAD (gst_pad_get_parent (pad));
- if (G_UNLIKELY (basertppayload == NULL)) {
- gst_event_unref (event);
- return FALSE;
- }
- basertppayload_class = GST_BASE_RTP_PAYLOAD_GET_CLASS (basertppayload);
-
- if (basertppayload_class->handle_event) {
- res = basertppayload_class->handle_event (pad, event);
- if (res)
- goto done;
- }
+ gboolean res = FALSE;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (basertppayload->sinkpad, event);
break;
case GST_EVENT_FLUSH_STOP:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (basertppayload->sinkpad, event);
gst_segment_init (&basertppayload->segment, GST_FORMAT_UNDEFINED);
break;
+ case GST_EVENT_CAPS:
+ {
+ GstBaseRTPPayloadClass *basertppayload_class;
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ GST_DEBUG_OBJECT (basertppayload, "setting caps %" GST_PTR_FORMAT, caps);
+
+ basertppayload_class = GST_BASE_RTP_PAYLOAD_GET_CLASS (basertppayload);
+ if (basertppayload_class->set_caps)
+ res = basertppayload_class->set_caps (basertppayload, caps);
+ break;
+ }
case GST_EVENT_SEGMENT:
{
GstSegment *segment;
GST_DEBUG_OBJECT (basertppayload,
"configured SEGMENT %" GST_SEGMENT_FORMAT, segment);
- /* fallthrough */
+ res = gst_pad_event_default (basertppayload->sinkpad, event);
+ break;
}
default:
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (basertppayload->sinkpad, event);
break;
}
+ return res;
+}
+
+static gboolean
+gst_basertppayload_event (GstPad * pad, GstEvent * event)
+{
+ GstBaseRTPPayload *basertppayload;
+ GstBaseRTPPayloadClass *basertppayload_class;
+ gboolean res = FALSE;
+
+ basertppayload = GST_BASE_RTP_PAYLOAD (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (basertppayload == NULL)) {
+ gst_event_unref (event);
+ return FALSE;
+ }
+
+ basertppayload_class = GST_BASE_RTP_PAYLOAD_GET_CLASS (basertppayload);
+
+ if (basertppayload_class->handle_event)
+ res = basertppayload_class->handle_event (basertppayload, event);
+ else
+ gst_event_unref (event);
-done:
gst_object_unref (basertppayload);
return res;
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");
}