From: Wim Taymans Date: Mon, 18 Apr 2011 08:54:43 +0000 (+0200) Subject: port more plugins to 0.11 X-Git-Tag: RELEASE-0.11.1~614 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4aa6ca55783f9d924e8d2b7b021835d11b9a18ca;p=platform%2Fupstream%2Fgst-plugins-good.git port more plugins to 0.11 --- diff --git a/gst/audiofx/audiopanorama.c b/gst/audiofx/audiopanorama.c index 0bd81b9..768533c 100644 --- a/gst/audiofx/audiopanorama.c +++ b/gst/audiofx/audiopanorama.c @@ -129,7 +129,7 @@ static void gst_audio_panorama_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static gboolean gst_audio_panorama_get_unit_size (GstBaseTransform * base, - GstCaps * caps, guint * size); + GstCaps * caps, gsize * size); static GstCaps *gst_audio_panorama_transform_caps (GstBaseTransform * base, GstPadDirection direction, GstCaps * caps); static gboolean gst_audio_panorama_set_caps (GstBaseTransform * base, @@ -315,7 +315,7 @@ gst_audio_panorama_get_property (GObject * object, guint prop_id, static gboolean gst_audio_panorama_get_unit_size (GstBaseTransform * base, GstCaps * caps, - guint * size) + gsize * size) { gint width, channels; GstStructure *structure; diff --git a/gst/rtp/gstrtpgstdepay.c b/gst/rtp/gstrtpgstdepay.c index 6dc5e51..9b8c438 100644 --- a/gst/rtp/gstrtpgstdepay.c +++ b/gst/rtp/gstrtpgstdepay.c @@ -184,10 +184,13 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) gint payload_len; guint8 *payload; guint CV; + GstRTPBuffer rtp = { NULL }; rtpgstdepay = GST_RTP_GST_DEPAY (depayload); - payload_len = gst_rtp_buffer_get_payload_len (buf); + gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); + + payload_len = gst_rtp_buffer_get_payload_len (&rtp); if (payload_len <= 8) goto empty_packet; @@ -197,7 +200,7 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) gst_adapter_clear (rtpgstdepay->adapter); } - payload = gst_rtp_buffer_get_payload (buf); + payload = gst_rtp_buffer_get_payload (&rtp); /* strip off header * @@ -214,10 +217,10 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) */ /* subbuffer skipping the 8 header bytes */ - subbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 8, -1); + subbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 8, -1); gst_adapter_push (rtpgstdepay->adapter, subbuf); - if (gst_rtp_buffer_get_marker (buf)) { + if (gst_rtp_buffer_get_marker (&rtp)) { guint avail; GstCaps *outcaps; @@ -228,25 +231,30 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) CV = (payload[0] >> 4) & 0x7; if (payload[0] & 0x80) { - guint b, csize, size, offset; + guint b, csize, left, offset; + gsize size; guint8 *data; GstBuffer *subbuf; /* C bit, we have inline caps */ - data = GST_BUFFER_DATA (outbuf); - size = GST_BUFFER_SIZE (outbuf); + data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ); /* start reading the length, we need this to skip to the data later */ csize = offset = 0; + left = size; do { - if (offset >= size) + if (offset >= left) { + gst_buffer_unmap (outbuf, data, size); goto too_small; + } b = data[offset++]; csize = (csize << 7) | (b & 0x7f); } while (b & 0x80); - if (size < csize) + if (left < csize) { + gst_buffer_unmap (outbuf, data, size); goto too_small; + } /* parse and store in cache */ outcaps = gst_caps_from_string ((gchar *) & data[offset]); @@ -254,17 +262,19 @@ gst_rtp_gst_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) /* skip caps */ offset += csize; - size -= csize; + left -= csize; GST_DEBUG_OBJECT (rtpgstdepay, "inline caps %u, length %u, %" GST_PTR_FORMAT, CV, csize, outcaps); /* create real data buffer when needed */ if (size) - subbuf = gst_buffer_create_sub (outbuf, offset, size); + subbuf = + gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_ALL, offset, left); else subbuf = NULL; + gst_buffer_unmap (outbuf, data, size); gst_buffer_unref (outbuf); outbuf = subbuf; } @@ -302,6 +312,7 @@ empty_packet: { GST_ELEMENT_WARNING (rtpgstdepay, STREAM, DECODE, ("Empty Payload."), (NULL)); + gst_rtp_buffer_unmap (&rtp); return NULL; } too_small: @@ -310,6 +321,7 @@ too_small: ("Buffer too small."), (NULL)); if (outbuf) gst_buffer_unref (outbuf); + gst_rtp_buffer_unmap (&rtp); return NULL; } missing_caps: @@ -318,6 +330,7 @@ missing_caps: ("Missing caps %u.", CV), (NULL)); if (outbuf) gst_buffer_unref (outbuf); + gst_rtp_buffer_unmap (&rtp); return NULL; } } diff --git a/gst/rtp/gstrtpgstpay.c b/gst/rtp/gstrtpgstpay.c index dfdd954..dd3ef42 100644 --- a/gst/rtp/gstrtpgstpay.c +++ b/gst/rtp/gstrtpgstpay.c @@ -131,8 +131,8 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload, GstBuffer * buffer) { GstRtpGSTPay *rtpgstpay; - guint8 *data; - guint size; + guint8 *data, *ptr; + gsize size, left; GstBuffer *outbuf; GstFlowReturn ret; GstClockTime timestamp; @@ -141,8 +141,7 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload, rtpgstpay = GST_RTP_GST_PAY (basepayload); - size = GST_BUFFER_SIZE (buffer); - data = GST_BUFFER_DATA (buffer); + data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); timestamp = GST_BUFFER_TIMESTAMP (buffer); ret = GST_FLOW_OK; @@ -168,15 +167,18 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload, * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ frag_offset = 0; + ptr = data; + left = size; - while (size > 0) { + while (left > 0) { guint towrite; guint8 *payload; guint payload_len; guint packet_len; + GstRTPBuffer rtp = { NULL }; /* this will be the total lenght of the packet */ - packet_len = gst_rtp_buffer_calc_packet_len (8 + size, 0, 0); + packet_len = gst_rtp_buffer_calc_packet_len (8 + left, 0, 0); /* fill one MTU or all available bytes */ towrite = MIN (packet_len, GST_BASE_RTP_PAYLOAD_MTU (rtpgstpay)); @@ -186,7 +188,9 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload, /* create buffer to hold the payload */ outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0); - payload = gst_rtp_buffer_get_payload (outbuf); + + gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); + payload = gst_rtp_buffer_get_payload (&rtp); payload[0] = flags; payload[1] = payload[2] = payload[3] = 0; @@ -198,19 +202,22 @@ gst_rtp_gst_pay_handle_buffer (GstBaseRTPPayload * basepayload, payload += 8; payload_len -= 8; - memcpy (payload, data, payload_len); + memcpy (payload, ptr, payload_len); - data += payload_len; - size -= payload_len; + ptr += payload_len; + left -= payload_len; frag_offset += payload_len; - if (size == 0) - gst_rtp_buffer_set_marker (outbuf, TRUE); + if (left == 0) + gst_rtp_buffer_set_marker (&rtp, TRUE); + + gst_rtp_buffer_unmap (&rtp); GST_BUFFER_TIMESTAMP (outbuf) = timestamp; ret = gst_basertppayload_push (basepayload, outbuf); } + gst_buffer_unmap (buffer, data, size); return ret; } diff --git a/gst/rtp/gstrtpilbcdepay.c b/gst/rtp/gstrtpilbcdepay.c index 18ca426..d5512dd 100644 --- a/gst/rtp/gstrtpilbcdepay.c +++ b/gst/rtp/gstrtpilbcdepay.c @@ -179,14 +179,19 @@ gst_rtp_ilbc_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) { GstBuffer *outbuf; gboolean marker; + GstRTPBuffer rtp = { NULL }; - marker = gst_rtp_buffer_get_marker (buf); + gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); + + marker = gst_rtp_buffer_get_marker (&rtp); GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d", - GST_BUFFER_SIZE (buf), marker, - gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf)); + gst_buffer_get_size (buf), marker, + gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp)); + + outbuf = gst_rtp_buffer_get_payload_buffer (&rtp); - outbuf = gst_rtp_buffer_get_payload_buffer (buf); + gst_rtp_buffer_unmap (&rtp); if (marker) { /* mark start of talkspurt with DISCONT */ diff --git a/gst/rtp/gstrtpmpadepay.c b/gst/rtp/gstrtpmpadepay.c index 1fdc8d4..8eae3a7 100644 --- a/gst/rtp/gstrtpmpadepay.c +++ b/gst/rtp/gstrtpmpadepay.c @@ -122,52 +122,60 @@ gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) { GstRtpMPADepay *rtpmpadepay; GstBuffer *outbuf; + GstRTPBuffer rtp = { NULL }; + gint payload_len; +#if 0 + guint8 *payload; + guint16 frag_offset; +#endif + gboolean marker; rtpmpadepay = GST_RTP_MPA_DEPAY (depayload); - { - gint payload_len; - gboolean marker; - - payload_len = gst_rtp_buffer_get_payload_len (buf); - - if (payload_len <= 4) - goto empty_packet; - - /* strip off header - * - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | MBZ | Frag_offset | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - /* frag_offset = (payload[2] << 8) | payload[3]; */ - - /* subbuffer skipping the 4 header bytes */ - outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 4, -1); - marker = gst_rtp_buffer_get_marker (buf); - - if (marker) { - /* mark start of talkspurt with discont */ - GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT); - } - GST_DEBUG_OBJECT (rtpmpadepay, - "gst_rtp_mpa_depay_chain: pushing buffer of size %d", - GST_BUFFER_SIZE (outbuf)); - - /* FIXME, we can push half mpeg frames when they are split over multiple - * RTP packets */ - return outbuf; + gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); + + payload_len = gst_rtp_buffer_get_payload_len (&rtp); + + if (payload_len <= 4) + goto empty_packet; + +#if 0 + payload = gst_rtp_buffer_get_payload (&rtp); + /* strip off header + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | MBZ | Frag_offset | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + frag_offset = (payload[2] << 8) | payload[3]; +#endif + + /* subbuffer skipping the 4 header bytes */ + outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 4, -1); + marker = gst_rtp_buffer_get_marker (&rtp); + + if (marker) { + /* mark start of talkspurt with discont */ + GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT); } + GST_DEBUG_OBJECT (rtpmpadepay, + "gst_rtp_mpa_depay_chain: pushing buffer of size %d", + gst_buffer_get_size (outbuf)); + + gst_rtp_buffer_unmap (&rtp); - return NULL; + /* FIXME, we can push half mpeg frames when they are split over multiple + * RTP packets */ + return outbuf; /* ERRORS */ empty_packet: { GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE, ("Empty Payload."), (NULL)); + gst_rtp_buffer_unmap (&rtp); return NULL; } } diff --git a/gst/rtp/gstrtpmpapay.c b/gst/rtp/gstrtpmpapay.c index f685ef2..3b0970a 100644 --- a/gst/rtp/gstrtpmpapay.c +++ b/gst/rtp/gstrtpmpapay.c @@ -192,6 +192,7 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay) guint8 *payload; guint payload_len; guint packet_len; + GstRTPBuffer rtp = { NULL }; /* this will be the total length of the packet */ packet_len = gst_rtp_buffer_calc_packet_len (4 + avail, 0, 0); @@ -205,9 +206,11 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay) /* create buffer to hold the payload */ outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0); + gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); + payload_len -= 4; - gst_rtp_buffer_set_payload_type (outbuf, GST_RTP_PAYLOAD_MPA); + gst_rtp_buffer_set_payload_type (&rtp, GST_RTP_PAYLOAD_MPA); /* * 0 1 2 3 @@ -216,7 +219,7 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay) * | MBZ | Frag_offset | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ - payload = gst_rtp_buffer_get_payload (outbuf); + payload = gst_rtp_buffer_get_payload (&rtp); payload[0] = 0; payload[1] = 0; payload[2] = frag_offset >> 8; @@ -229,7 +232,9 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay) frag_offset += payload_len; if (avail == 0) - gst_rtp_buffer_set_marker (outbuf, TRUE); + gst_rtp_buffer_set_marker (&rtp, TRUE); + + gst_rtp_buffer_unmap (&rtp); GST_BUFFER_TIMESTAMP (outbuf) = rtpmpapay->first_ts; GST_BUFFER_DURATION (outbuf) = rtpmpapay->duration; @@ -252,7 +257,7 @@ gst_rtp_mpa_pay_handle_buffer (GstBaseRTPPayload * basepayload, rtpmpapay = GST_RTP_MPA_PAY (basepayload); - size = GST_BUFFER_SIZE (buffer); + size = gst_buffer_get_size (buffer); duration = GST_BUFFER_DURATION (buffer); timestamp = GST_BUFFER_TIMESTAMP (buffer);