* Boston, MA 02111-1307, USA.
*/
+/**
+ * SECTION:element-rtph261depay
+ * @title: rtph261depay
+ * @see_also: rtph261pay
+ *
+ * Extract encoded H.261 video frames from RTP packets according to RFC 4587.
+ * For detailed information see: https://www.rfc-editor.org/rfc/rfc4587.txt
+ *
+ * The depayloader takes an RTP packet and extracts its H.261 stream. It
+ * aggregates the extracted stream until a complete frame is received before
+ * it pushes it downstream.
+ *
+ * ## Example pipeline
+ * |[
+ * gst-launch-1.0 udpsrc caps='application/x-rtp, payload=31' ! rtph261depay ! avdec_h261 ! autovideosink
+ * ]| This example pipeline will depayload and decode an RTP H.261 video stream.
+ * Refer to the rtph261pay example to create the RTP stream.
+ *
+ */
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include <gst/rtp/gstrtpbuffer.h>
+#include <gst/video/video.h>
#include "gstrtph261depay.h"
#include "gstrtph261pay.h" /* GstRtpH261PayHeader */
+#include "gstrtputils.h"
GST_DEBUG_CATEGORY_STATIC (rtph261depay_debug);
#define GST_CAT_DEFAULT (rtph261depay_debug)
#define parent_class gst_rtp_h261_depay_parent_class
static GstBuffer *
-gst_rtp_h261_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
+gst_rtp_h261_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpH261Depay *depay;
GstBuffer *outbuf = NULL;
const guint header_len = GST_RTP_H261_PAYLOAD_HEADER_LEN;
gboolean marker;
GstRtpH261PayHeader *header;
- GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
depay = GST_RTP_H261_DEPAY (depayload);
- if (GST_BUFFER_IS_DISCONT (buf)) {
+ if (GST_BUFFER_IS_DISCONT (rtp->buffer)) {
GST_DEBUG_OBJECT (depay, "Discont buffer, flushing adapter");
gst_adapter_clear (depay->adapter);
depay->leftover = NO_LEFTOVER;
depay->start = FALSE;
}
- gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
-
- payload_len = gst_rtp_buffer_get_payload_len (&rtp);
- payload = gst_rtp_buffer_get_payload (&rtp);
+ payload_len = gst_rtp_buffer_get_payload_len (rtp);
+ payload = gst_rtp_buffer_get_payload (rtp);
- marker = gst_rtp_buffer_get_marker (&rtp);
+ marker = gst_rtp_buffer_get_marker (rtp);
- if (payload_len < 4) {
- GST_WARNING_OBJECT (depay,
- "Dropping packet with payload length invalid length");
- gst_rtp_buffer_unmap (&rtp);
+ if (payload_len < header_len + 1) {
+ /* Must have at least one byte payload */
+ GST_WARNING_OBJECT (depay, "Dropping packet with invalid payload length");
return NULL;
}
if (header->ebit == 0) {
/* H.261 stream ends on byte boundary, take entire packet */
gst_adapter_push (depay->adapter,
- gst_rtp_buffer_get_payload_subbuffer (&rtp, header_len, payload_len));
+ gst_rtp_buffer_get_payload_subbuffer (rtp, header_len, payload_len));
} else {
/* Take the entire buffer except for the last byte, which will be kept to
* merge with next packet */
gst_adapter_push (depay->adapter,
- gst_rtp_buffer_get_payload_subbuffer (&rtp, header_len,
+ gst_rtp_buffer_get_payload_subbuffer (rtp, header_len,
payload_len - 1));
depay->leftover = payload[payload_len - 1] & (0xFF << header->ebit);
}
avail = gst_adapter_available (depay->adapter);
outbuf = gst_adapter_take_buffer (depay->adapter, avail);
+ gst_rtp_drop_non_video_meta (depay, outbuf);
/* Note that the I flag does not mean intra frame, but that the entire
* stream is intra coded. */
depay->start = TRUE;
}
}
- gst_rtp_buffer_unmap (&rtp);
return outbuf;
}
gstelement_class = GST_ELEMENT_CLASS (klass);
gstrtpbasedepayload_class = GST_RTP_BASE_DEPAYLOAD_CLASS (klass);
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_h261_depay_src_template));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_h261_depay_sink_template));
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_h261_depay_src_template);
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_h261_depay_sink_template);
gst_element_class_set_static_metadata (gstelement_class,
"RTP H261 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts H261 video from RTP packets (RFC 4587)",
"Stian Selnes <stian@pexip.com>");
- gstrtpbasedepayload_class->process = gst_rtp_h261_depay_process;
+ gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_h261_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_h261_depay_setcaps;
gobject_class->dispose = gst_rtp_h261_depay_dispose;