X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Frtp%2Fgstrtpdvdepay.c;h=12297f0045f70ef6f5e9ddcb7b847a7249fe3578;hb=775ccdf9775bd7051929b257444b3be915e88ec6;hp=61344779eb097f1dad620c3d634277612f000192;hpb=fdd93fa85dbf3cc81fd26868c5282a75198b9da8;p=platform%2Fupstream%2Fgst-plugins-good.git diff --git a/gst/rtp/gstrtpdvdepay.c b/gst/rtp/gstrtpdvdepay.c index 6134477..12297f0 100644 --- a/gst/rtp/gstrtpdvdepay.c +++ b/gst/rtp/gstrtpdvdepay.c @@ -14,8 +14,8 @@ * * 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. */ /* @@ -33,6 +33,7 @@ #include #include "gstrtpdvdepay.h" +#include "gstrtputils.h" GST_DEBUG_CATEGORY (rtpdvdepay_debug); #define GST_CAT_DEFAULT (rtpdvdepay_debug) @@ -45,7 +46,7 @@ enum enum { - ARG_0, + PROP_0, }; static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", @@ -59,7 +60,6 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", 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\"," @@ -75,21 +75,21 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", 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"); @@ -97,19 +97,17 @@ gst_rtp_dv_depay_class_init (GstRTPDVDepayClass * klass) 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 , Wim Taymans "); - 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); } @@ -159,7 +157,7 @@ parse_encode (GstRTPDVDepay * rtpdvdepay, const gchar * encode) } static gboolean -gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) +gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) { GstStructure *structure; GstRTPDVDepay *rtpdvdepay; @@ -167,8 +165,6 @@ gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) gint clock_rate; gboolean systemstream, ret; const gchar *encode, *media; - guint8 *data; - gsize size; rtpdvdepay = GST_RTP_DV_DEPAY (depayload); @@ -213,9 +209,7 @@ gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) /* 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, @@ -285,13 +279,20 @@ calculate_difblock_location (guint8 * block) 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; @@ -299,15 +300,13 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in) 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 */ @@ -318,13 +317,15 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in) /* 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; @@ -340,17 +341,22 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in) 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); @@ -360,6 +366,7 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in) * 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);