*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/*
#include <gst/gst.h>
#include "gstrtpdvdepay.h"
+#include "gstrtputils.h"
GST_DEBUG_CATEGORY (rtpdvdepay_debug);
#define GST_CAT_DEFAULT (rtpdvdepay_debug)
enum
{
- ARG_0,
+ PROP_0,
};
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) { \"video\", \"audio\" },"
- "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
"encoding-name = (string) \"DV\", "
"clock-rate = (int) 90000,"
"encode = (string) { \"SD-VCR/525-60\", \"SD-VCR/625-50\", \"HD-VCR/1125-60\","
static GstStateChangeReturn
gst_rtp_dv_depay_change_state (GstElement * element, GstStateChange transition);
-static GstBuffer *gst_rtp_dv_depay_process (GstBaseRTPDepayload * base,
- GstBuffer * in);
-static gboolean gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_dv_depay_process (GstRTPBaseDepayload * base,
+ GstRTPBuffer * rtp);
+static gboolean gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
#define gst_rtp_dv_depay_parent_class parent_class
-G_DEFINE_TYPE (GstRTPDVDepay, gst_rtp_dv_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRTPDVDepay, gst_rtp_dv_depay, GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
gst_rtp_dv_depay_class_init (GstRTPDVDepayClass * klass)
{
GstElementClass *gstelement_class = (GstElementClass *) klass;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class =
- (GstBaseRTPDepayloadClass *) klass;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class =
+ (GstRTPBaseDepayloadClass *) klass;
GST_DEBUG_CATEGORY_INIT (rtpdvdepay_debug, "rtpdvdepay", 0,
"DV RTP Depayloader");
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_change_state);
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&src_factory));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&sink_factory));
+ gst_element_class_add_static_pad_template (gstelement_class, &src_factory);
+ gst_element_class_add_static_pad_template (gstelement_class, &sink_factory);
- gst_element_class_set_details_simple (gstelement_class, "RTP DV Depayloader",
+ gst_element_class_set_static_metadata (gstelement_class, "RTP DV Depayloader",
"Codec/Depayloader/Network/RTP",
"Depayloads DV from RTP packets (RFC 3189)",
"Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
- gstbasertpdepayload_class->process =
+ gstrtpbasedepayload_class->process_rtp_packet =
GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_process);
- gstbasertpdepayload_class->set_caps =
+ gstrtpbasedepayload_class->set_caps =
GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_setcaps);
}
}
static gboolean
-gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRTPDVDepay *rtpdvdepay;
gint clock_rate;
gboolean systemstream, ret;
const gchar *encode, *media;
- guint8 *data;
- gsize size;
rtpdvdepay = GST_RTP_DV_DEPAY (depayload);
/* Initialize the new accumulator frame.
* If the previous frame exists, copy that into the accumulator frame.
* This way, missing packets in the stream won't show up badly. */
- data = gst_buffer_map (rtpdvdepay->acc, &size, NULL, GST_MAP_WRITE);
- memset (data, 0, rtpdvdepay->frame_size);
- gst_buffer_unmap (rtpdvdepay->acc, data, size);
+ gst_buffer_memset (rtpdvdepay->acc, 0, 0, rtpdvdepay->frame_size);
srccaps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, systemstream,
return location;
}
+static gboolean
+foreach_metadata_drop (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
+{
+ *meta = NULL;
+ return TRUE;
+}
+
/* Process one RTP packet. Accumulate RTP payload in the proper place in a DV
* frame, and return that frame if we detect a new frame, or NULL otherwise.
- * We assume a DV frame is 144000 bytes. That should accomodate PAL as well as
+ * We assume a DV frame is 144000 bytes. That should accommodate PAL as well as
* NTSC.
*/
static GstBuffer *
-gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
+gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp)
{
GstBuffer *out = NULL;
guint8 *payload;
guint payload_len, location;
GstRTPDVDepay *dvdepay = GST_RTP_DV_DEPAY (base);
gboolean marker;
- GstRTPBuffer rtp = { NULL, };
-
- gst_rtp_buffer_map (in, GST_MAP_READ, &rtp);
+ GstMapInfo map;
- marker = gst_rtp_buffer_get_marker (&rtp);
+ marker = gst_rtp_buffer_get_marker (rtp);
/* Check if the received packet contains (the start of) a new frame, we do
* this by checking the RTP timestamp. */
- rtp_ts = gst_rtp_buffer_get_timestamp (&rtp);
+ rtp_ts = gst_rtp_buffer_get_timestamp (rtp);
/* we cannot copy the packet yet if the marker is set, we will do that below
* after taking out the data */
/* return copy of accumulator. */
out = gst_buffer_copy (dvdepay->acc);
+ gst_buffer_foreach_meta (dvdepay->acc, foreach_metadata_drop, NULL);
}
/* Extract the payload */
- 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);
/* copy all DIF chunks in their place. */
+ gst_buffer_map (dvdepay->acc, &map, GST_MAP_READWRITE);
while (payload_len >= 80) {
guint offset;
GST_LOG_OBJECT (dvdepay, "got block at location %d", location);
}
- /* get the byte offset of the dif block */
- offset = location * 80;
+ if (location != -1) {
+ /* get the byte offset of the dif block */
+ offset = location * 80;
- /* And copy it in, provided the location is sane. */
- if (offset >= 0 && offset <= dvdepay->frame_size - 80)
- gst_buffer_fill (dvdepay->acc, offset, payload, 80);
+ /* And copy it in, provided the location is sane. */
+ if (offset <= dvdepay->frame_size - 80) {
+ memcpy (map.data + offset, payload, 80);
+ gst_rtp_copy_meta (GST_ELEMENT_CAST (dvdepay), dvdepay->acc,
+ rtp->buffer, 0);
+ }
+ }
payload += 80;
payload_len -= 80;
}
- gst_rtp_buffer_unmap (&rtp);
+ gst_buffer_unmap (dvdepay->acc, &map);
if (marker) {
GST_DEBUG_OBJECT (dvdepay, "marker bit complete frame %u", rtp_ts);
* will change the timestamp but we won't copy the accumulator again because
* we set the prev_ts to -1. */
out = gst_buffer_copy (dvdepay->acc);
+ gst_buffer_foreach_meta (dvdepay->acc, foreach_metadata_drop, NULL);
} else {
GST_WARNING_OBJECT (dvdepay, "waiting for frame headers %02x",
dvdepay->header_mask);