rtpvrawdepay: implement process_rtp_packet() vfunc

For more optimised RTP packet handling: means we don't
need to map the input buffer again but can just re-use
the map the base class has already done.

https://bugzilla.gnome.org/show_bug.cgi?id=750235
This commit is contained in:
Tim-Philipp Müller 2015-05-27 19:19:27 +01:00
parent 582ade2c42
commit fe787425bc

View file

@ -61,8 +61,8 @@ G_DEFINE_TYPE (GstRtpVRawDepay, gst_rtp_vraw_depay,
static gboolean gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, static gboolean gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps); GstCaps * caps);
static GstBuffer *gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, static GstBuffer *gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload *
GstBuffer * buf); depay, GstRTPBuffer * rtp);
static GstStateChangeReturn gst_rtp_vraw_depay_change_state (GstElement * static GstStateChangeReturn gst_rtp_vraw_depay_change_state (GstElement *
element, GstStateChange transition); element, GstStateChange transition);
@ -82,7 +82,8 @@ gst_rtp_vraw_depay_class_init (GstRtpVRawDepayClass * klass)
gstelement_class->change_state = gst_rtp_vraw_depay_change_state; gstelement_class->change_state = gst_rtp_vraw_depay_change_state;
gstrtpbasedepayload_class->set_caps = gst_rtp_vraw_depay_setcaps; gstrtpbasedepayload_class->set_caps = gst_rtp_vraw_depay_setcaps;
gstrtpbasedepayload_class->process = gst_rtp_vraw_depay_process; gstrtpbasedepayload_class->process_rtp_packet =
gst_rtp_vraw_depay_process_packet;
gstrtpbasedepayload_class->handle_event = gst_rtp_vraw_depay_handle_event; gstrtpbasedepayload_class->handle_event = gst_rtp_vraw_depay_handle_event;
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
@ -317,23 +318,21 @@ no_bufferpool:
} }
static GstBuffer * static GstBuffer *
gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf) gst_rtp_vraw_depay_process_packet (GstRTPBaseDepayload * depayload,
GstRTPBuffer * rtp)
{ {
GstRtpVRawDepay *rtpvrawdepay; GstRtpVRawDepay *rtpvrawdepay;
guint8 *payload, *p0, *yp, *up, *vp, *headers; guint8 *payload, *p0, *yp, *up, *vp, *headers;
guint32 timestamp; guint32 timestamp;
guint cont, ystride, uvstride, pgroup, payload_len; guint cont, ystride, uvstride, pgroup, payload_len;
gint width, height, xinc, yinc; gint width, height, xinc, yinc;
GstRTPBuffer rtp = { NULL };
GstVideoFrame *frame; GstVideoFrame *frame;
gboolean marker; gboolean marker;
GstBuffer *outbuf = NULL; GstBuffer *outbuf = NULL;
rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload); rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); timestamp = gst_rtp_buffer_get_timestamp (rtp);
timestamp = gst_rtp_buffer_get_timestamp (&rtp);
if (timestamp != rtpvrawdepay->timestamp || rtpvrawdepay->outbuf == NULL) { if (timestamp != rtpvrawdepay->timestamp || rtpvrawdepay->outbuf == NULL) {
GstBuffer *new_buffer; GstBuffer *new_buffer;
@ -395,8 +394,8 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
xinc = rtpvrawdepay->xinc; xinc = rtpvrawdepay->xinc;
yinc = rtpvrawdepay->yinc; yinc = rtpvrawdepay->yinc;
payload = gst_rtp_buffer_get_payload (&rtp); payload = gst_rtp_buffer_get_payload (rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp); payload_len = gst_rtp_buffer_get_payload_len (rtp);
if (payload_len < 3) if (payload_len < 3)
goto short_packet; goto short_packet;
@ -560,8 +559,7 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
payload_len -= length; payload_len -= length;
} }
marker = gst_rtp_buffer_get_marker (&rtp); marker = gst_rtp_buffer_get_marker (rtp);
gst_rtp_buffer_unmap (&rtp);
if (marker) { if (marker) {
GST_LOG_OBJECT (depayload, "marker, flushing frame"); GST_LOG_OBJECT (depayload, "marker, flushing frame");
@ -577,13 +575,11 @@ unknown_sampling:
{ {
GST_ELEMENT_ERROR (depayload, STREAM, FORMAT, GST_ELEMENT_ERROR (depayload, STREAM, FORMAT,
(NULL), ("unimplemented sampling")); (NULL), ("unimplemented sampling"));
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
alloc_failed: alloc_failed:
{ {
GST_WARNING_OBJECT (depayload, "failed to alloc output buffer"); GST_WARNING_OBJECT (depayload, "failed to alloc output buffer");
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
invalid_frame: invalid_frame:
@ -594,13 +590,11 @@ invalid_frame:
wrong_length: wrong_length:
{ {
GST_WARNING_OBJECT (depayload, "length not multiple of pgroup"); GST_WARNING_OBJECT (depayload, "length not multiple of pgroup");
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
short_packet: short_packet:
{ {
GST_WARNING_OBJECT (depayload, "short packet"); GST_WARNING_OBJECT (depayload, "short packet");
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
} }