Merge branch 'master' into 0.11
diff --git a/configure.ac b/configure.ac
index 2413c48..d3f4c4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@
 dnl initialize autoconf
 dnl releases only do -Wall, git and prerelease does -Werror too
 dnl use a three digit version number for releases, and four for git/pre
-AC_INIT(GStreamer Good Plug-ins, 0.10.28.2,
+AC_INIT(GStreamer Good Plug-ins, 0.11.0.1,
     http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
     gst-plugins-good)
 
@@ -40,7 +40,7 @@
 dnl our libraries and install dirs use major.minor as a version
 GST_MAJORMINOR=$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR
 dnl we override it here if we need to for the release candidate of new series
-GST_MAJORMINOR=0.10
+GST_MAJORMINOR=0.11
 AC_SUBST(GST_MAJORMINOR)
 
 AG_GST_LIBTOOL_PREPARE
@@ -54,8 +54,8 @@
 AM_PROG_LIBTOOL
 
 dnl *** required versions of GStreamer stuff ***
-GST_REQ=0.10.32.1
-GSTPB_REQ=0.10.32.1
+GST_REQ=0.11.0
+GSTPB_REQ=0.11.0
 
 dnl *** autotools stuff ****
 
@@ -1268,7 +1268,7 @@
     -e "s/.* PACKAGE_STRING$/#define PACKAGE_STRING \"$PACKAGE_STRING\"/" \
     -e 's/.* PACKAGE_TARNAME$/#define PACKAGE_TARNAME "'$PACKAGE_TARNAME'"/' \
     -e 's/.* PACKAGE_VERSION$/#define PACKAGE_VERSION "'$PACKAGE_VERSION'"/' \
-    -e 's/.* PLUGINDIR$/#ifdef _DEBUG\n#  define PLUGINDIR PREFIX "\\\\debug\\\\lib\\\\gstreamer-0.10"\n#else\n#  define PLUGINDIR PREFIX "\\\\lib\\\\gstreamer-0.10"\n#endif/' \
+    -e 's/.* PLUGINDIR$/#ifdef _DEBUG\n#  define PLUGINDIR PREFIX "\\\\debug\\\\lib\\\\gstreamer-0.11"\n#else\n#  define PLUGINDIR PREFIX "\\\\lib\\\\gstreamer-0.11"\n#endif/' \
     -e 's/.* USE_BINARY_REGISTRY$/#define USE_BINARY_REGISTRY/' \
     -e 's/.* VERSION$/#define VERSION "'$VERSION'"/' \
     -e "s/.* DEFAULT_AUDIOSINK$/#define DEFAULT_AUDIOSINK \"directsoundsink\"/" \
diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c
index ec279e9..99547fc 100644
--- a/ext/jpeg/gstjpegdec.c
+++ b/ext/jpeg/gstjpegdec.c
@@ -1061,7 +1061,7 @@
   GST_OBJECT_LOCK (dec);
   dec->proportion = proportion;
   if (G_LIKELY (ts != GST_CLOCK_TIME_NONE)) {
-    if (G_UNLIKELY (diff > 0))
+    if (G_UNLIKELY (diff > dec->qos_duration))
       dec->earliest_time = ts + 2 * diff + dec->qos_duration;
     else
       dec->earliest_time = ts + diff;
diff --git a/ext/pulse/pulsesrc.c b/ext/pulse/pulsesrc.c
index ebb41c1..504a129 100644
--- a/ext/pulse/pulsesrc.c
+++ b/ext/pulse/pulsesrc.c
@@ -1112,7 +1112,7 @@
 {
   GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (userdata);
 
-  pulsesrc->operation_success = ! !success;
+  pulsesrc->operation_success = !!success;
   pa_threaded_mainloop_signal (pulsesrc->mainloop, 0);
 }
 
diff --git a/ext/taglib/gstid3v2mux.cc b/ext/taglib/gstid3v2mux.cc
index 6468048..cc307aa 100644
--- a/ext/taglib/gstid3v2mux.cc
+++ b/ext/taglib/gstid3v2mux.cc
@@ -368,7 +368,7 @@
     GstBuffer *buf;
 
     val = gst_tag_list_get_value_index (list, tag, i);
-    buf = (GstBuffer *) gst_value_get_mini_object (val);
+    buf = (GstBuffer *) g_value_get_boxed (val);
 
     if (buf && GST_BUFFER_CAPS (buf)) {
       GstStructure *s;
@@ -403,7 +403,7 @@
     GST_DEBUG ("image %u/%u", n + 1, num_tags);
 
     val = gst_tag_list_get_value_index (list, tag, n);
-    image = (GstBuffer *) gst_value_get_mini_object (val);
+    image = (GstBuffer *) g_value_get_boxed (val);
 
     if (GST_IS_BUFFER (image) && GST_BUFFER_SIZE (image) > 0 &&
         GST_BUFFER_CAPS (image) != NULL &&
diff --git a/gst/alpha/gstalpha.c b/gst/alpha/gstalpha.c
index d72c8c5..70c9a32 100644
--- a/gst/alpha/gstalpha.c
+++ b/gst/alpha/gstalpha.c
@@ -174,7 +174,7 @@
 
 static gboolean gst_alpha_start (GstBaseTransform * trans);
 static gboolean gst_alpha_get_unit_size (GstBaseTransform * btrans,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 static GstCaps *gst_alpha_transform_caps (GstBaseTransform * btrans,
     GstPadDirection direction, GstCaps * caps);
 static gboolean gst_alpha_set_caps (GstBaseTransform * btrans,
@@ -397,7 +397,7 @@
     case PROP_PREFER_PASSTHROUGH:{
       gboolean prefer_passthrough = g_value_get_boolean (value);
 
-      reconfigure = ((! !prefer_passthrough) != (! !alpha->prefer_passthrough))
+      reconfigure = ((!!prefer_passthrough) != (!!alpha->prefer_passthrough))
           && (alpha->method == ALPHA_METHOD_SET) && (alpha->alpha == 1.0);
       alpha->prefer_passthrough = prefer_passthrough;
       break;
@@ -458,7 +458,7 @@
 
 static gboolean
 gst_alpha_get_unit_size (GstBaseTransform * btrans,
-    GstCaps * caps, guint * size)
+    GstCaps * caps, gsize * size)
 {
   GstVideoFormat format;
   gint width, height;
@@ -2597,6 +2597,8 @@
 {
   GstAlpha *alpha = GST_ALPHA (btrans);
   gint width, height;
+  guint8 *indata, *outdata;
+  gsize insize, outsize;
 
   GST_ALPHA_LOCK (alpha);
 
@@ -2609,8 +2611,13 @@
   width = alpha->width;
   height = alpha->height;
 
-  alpha->process (GST_BUFFER_DATA (in),
-      GST_BUFFER_DATA (out), width, height, alpha);
+  indata = gst_buffer_map (in, &insize, NULL, GST_MAP_READ);
+  outdata = gst_buffer_map (out, &outsize, NULL, GST_MAP_WRITE);
+
+  alpha->process (indata, outdata, width, height, alpha);
+
+  gst_buffer_unmap (out, outdata, outsize);
+  gst_buffer_unmap (in, indata, insize);
 
   GST_ALPHA_UNLOCK (alpha);
 
diff --git a/gst/alpha/gstalphacolor.c b/gst/alpha/gstalphacolor.c
index 2c9eb4a..f4e25eb 100644
--- a/gst/alpha/gstalphacolor.c
+++ b/gst/alpha/gstalphacolor.c
@@ -638,12 +638,8 @@
 gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
 {
   GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
-
-  if (G_UNLIKELY (GST_BUFFER_SIZE (inbuf) != 4 * alpha->width * alpha->height)) {
-    GST_ERROR_OBJECT (alpha, "Invalid buffer size (was %u, expected %u)",
-        GST_BUFFER_SIZE (inbuf), alpha->width * alpha->height);
-    return GST_FLOW_ERROR;
-  }
+  guint8 *data;
+  gsize size;
 
   if (gst_base_transform_is_passthrough (btrans))
     return GST_FLOW_OK;
@@ -653,9 +649,19 @@
     return GST_FLOW_NOT_NEGOTIATED;
   }
 
+  data = gst_buffer_map (inbuf, &size, NULL, GST_MAP_READWRITE);
+
+  if (G_UNLIKELY (size != 4 * alpha->width * alpha->height)) {
+    GST_ERROR_OBJECT (alpha, "Invalid buffer size (was %u, expected %u)",
+        size, alpha->width * alpha->height);
+    gst_buffer_unmap (inbuf, data, size);
+    return GST_FLOW_ERROR;
+  }
+
   /* Transform in place */
-  alpha->process (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf),
-      alpha->matrix);
+  alpha->process (data, size, alpha->matrix);
+
+  gst_buffer_unmap (inbuf, data, size);
 
   return GST_FLOW_OK;
 }
diff --git a/gst/apetag/gstapedemux.c b/gst/apetag/gstapedemux.c
index accebee..d243c89 100644
--- a/gst/apetag/gstapedemux.c
+++ b/gst/apetag/gstapedemux.c
@@ -333,17 +333,25 @@
 gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer,
     gboolean start_tag, guint * tag_size)
 {
-  if (memcmp (GST_BUFFER_DATA (buffer), "APETAGEX", 8) != 0) {
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  if (memcmp (data, "APETAGEX", 8) != 0) {
     GST_DEBUG_OBJECT (demux, "No APETAGEX marker at %s - not an APE file",
         (start_tag) ? "start" : "end");
+    gst_buffer_unmap (buffer, data, size);
     return FALSE;
   }
 
-  *tag_size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buffer) + 12);
+  *tag_size = GST_READ_UINT32_LE (data + 12);
 
   /* size is without header, so add 32 to account for that */
   *tag_size += 32;
 
+  gst_buffer_unmap (buffer, data, size);
+
   return TRUE;
 }
 
@@ -351,17 +359,19 @@
 gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
     gboolean start_tag, guint * tag_size, GstTagList ** tags)
 {
-  const guint8 *data;
-  const guint8 *footer;
+  guint8 *data_start, *data;
+  guint8 *footer;
   gboolean have_header;
   gboolean end_tag = !start_tag;
   GstCaps *sink_caps;
   guint version, footer_size;
+  gsize size;
 
-  GST_LOG_OBJECT (demux, "Parsing buffer of size %u", GST_BUFFER_SIZE (buffer));
+  data_start = data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
-  data = GST_BUFFER_DATA (buffer);
-  footer = GST_BUFFER_DATA (buffer) + GST_BUFFER_SIZE (buffer) - 32;
+  GST_LOG_OBJECT (demux, "Parsing buffer of size %" G_GSIZE_FORMAT, size);
+
+  footer = data + size - 32;
 
   GST_LOG_OBJECT (demux, "Checking for footer at offset 0x%04x",
       (guint) (footer - data));
@@ -420,6 +430,8 @@
       GST_TAG_CONTAINER_FORMAT, sink_caps);
   gst_caps_unref (sink_caps);
 
+  gst_buffer_unmap (buffer, data_start, size);
+
   return GST_TAG_DEMUX_RESULT_OK;
 }
 
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 @@
     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 @@
 
 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/avi/gstavidemux.c b/gst/avi/gstavidemux.c
index e69c08c..6476764 100644
--- a/gst/avi/gstavidemux.c
+++ b/gst/avi/gstavidemux.c
@@ -970,9 +970,10 @@
   if (gst_adapter_available (avi->adapter) < 8)
     return FALSE;
 
-  data = gst_adapter_peek (avi->adapter, 8);
+  data = gst_adapter_map (avi->adapter, 8);
   *tag = GST_READ_UINT32_LE (data);
   *size = GST_READ_UINT32_LE (data + 4);
+  gst_adapter_unmap (avi->adapter, 0);
 
   return TRUE;
 }
@@ -1151,14 +1152,17 @@
     GstBuffer * buf, gst_riff_avih ** _avih)
 {
   gst_riff_avih *avih;
+  gsize size;
 
   if (buf == NULL)
     goto no_buffer;
 
-  if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_avih))
+  size = gst_buffer_get_size (buf);
+  if (size < sizeof (gst_riff_avih))
     goto avih_too_small;
 
-  avih = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  avih = g_malloc (size);
+  gst_buffer_extract (buf, 0, avih, size);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
   avih->us_frame = GUINT32_FROM_LE (avih->us_frame);
@@ -1218,7 +1222,7 @@
   {
     GST_ELEMENT_ERROR (avi, STREAM, DEMUX, (NULL),
         ("Too small avih (%d available, %d needed)",
-            GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_avih)));
+            size, (int) sizeof (gst_riff_avih)));
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -1245,16 +1249,18 @@
   guint16 bpe = 16;
   guint32 num, i;
   guint64 *indexes;
-  guint size;
+  gsize size;
 
   *_indexes = NULL;
 
-  size = buf ? GST_BUFFER_SIZE (buf) : 0;
+  if (buf)
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  else
+    size = 0;
+
   if (size < 24)
     goto too_small;
 
-  data = GST_BUFFER_DATA (buf);
-
   /* check type of index. The opendml2 specs state that
    * there should be 4 dwords per array entry. Type can be
    * either frame or field (and we don't care). */
@@ -1285,6 +1291,7 @@
   indexes[i] = GST_BUFFER_OFFSET_NONE;
   *_indexes = indexes;
 
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   return TRUE;
@@ -1294,16 +1301,18 @@
   {
     GST_ERROR_OBJECT (avi,
         "Not enough data to parse superindex (%d available, 24 needed)", size);
-    if (buf)
+    if (buf) {
+      gst_buffer_unmap (buf, data, size);
       gst_buffer_unref (buf);
+    }
     return FALSE;
   }
 invalid_params:
   {
     GST_ERROR_OBJECT (avi, "invalid index parameters (num = %d, bpe = %d)",
         num, bpe);
-    if (buf)
-      gst_buffer_unref (buf);
+    gst_buffer_unmap (buf, data, size);
+    gst_buffer_unref (buf);
     return FALSE;
   }
 }
@@ -1508,19 +1517,16 @@
   guint16 bpe;
   guint32 num, i;
   guint64 baseoff;
-  guint size;
+  gsize size;
 
-  if (!buf)
+  if (buf == NULL)
     return TRUE;
 
-  size = GST_BUFFER_SIZE (buf);
-
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   /* check size */
   if (size < 24)
     goto too_small;
 
-  data = GST_BUFFER_DATA (buf);
-
   /* We don't support index-data yet */
   if (data[3] & 0x80)
     goto not_implemented;
@@ -1570,6 +1576,8 @@
     if (G_UNLIKELY (!gst_avi_demux_add_index (avi, stream, num, &entry)))
       goto out_of_mem;
   }
+done:
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   return TRUE;
@@ -1579,21 +1587,20 @@
   {
     GST_ERROR_OBJECT (avi,
         "Not enough data to parse subindex (%d available, 24 needed)", size);
-    gst_buffer_unref (buf);
-    return TRUE;                /* continue */
+    goto done;                  /* continue */
   }
 not_implemented:
   {
     GST_ELEMENT_ERROR (avi, STREAM, NOT_IMPLEMENTED, (NULL),
         ("Subindex-is-data is not implemented"));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
 empty_index:
   {
     GST_DEBUG_OBJECT (avi, "the index is empty");
-    gst_buffer_unref (buf);
-    return TRUE;
+    goto done;                  /* continue */
   }
 out_of_mem:
   {
@@ -1601,6 +1608,7 @@
         ("Cannot allocate memory for %u*%u=%u bytes",
             (guint) sizeof (GstAviIndexEntry), num,
             (guint) sizeof (GstAviIndexEntry) * num));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -1754,14 +1762,18 @@
 {
   gst_riff_vprp *vprp;
   gint k;
+  gsize size;
 
   g_return_val_if_fail (buf != NULL, FALSE);
   g_return_val_if_fail (_vprp != NULL, FALSE);
 
-  if (GST_BUFFER_SIZE (buf) < G_STRUCT_OFFSET (gst_riff_vprp, field_info))
+  size = gst_buffer_get_size (buf);
+
+  if (size < G_STRUCT_OFFSET (gst_riff_vprp, field_info))
     goto too_small;
 
-  vprp = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  vprp = g_malloc (size);
+  gst_buffer_extract (buf, 0, vprp, size);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
   vprp->format_token = GUINT32_FROM_LE (vprp->format_token);
@@ -1777,8 +1789,7 @@
 
   /* size checking */
   /* calculate fields based on size */
-  k = (GST_BUFFER_SIZE (buf) - G_STRUCT_OFFSET (gst_riff_vprp, field_info)) /
-      vprp->fields;
+  k = (size - G_STRUCT_OFFSET (gst_riff_vprp, field_info)) / vprp->fields;
   if (vprp->fields > k) {
     GST_WARNING_OBJECT (element,
         "vprp header indicated %d fields, only %d available", vprp->fields, k);
@@ -1850,8 +1861,7 @@
   {
     GST_ERROR_OBJECT (element,
         "Too small vprp (%d available, at least %d needed)",
-        GST_BUFFER_SIZE (buf),
-        (int) G_STRUCT_OFFSET (gst_riff_vprp, field_info));
+        size, (int) G_STRUCT_OFFSET (gst_riff_vprp, field_info));
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -1893,14 +1903,20 @@
 static inline void
 gst_avi_demux_roundup_list (GstAviDemux * avi, GstBuffer ** buf)
 {
-  if (G_UNLIKELY (GST_BUFFER_SIZE (*buf) & 1)) {
-    GstBuffer *obuf;
+  gsize size;
 
-    GST_DEBUG_OBJECT (avi, "rounding up dubious list size %d",
-        GST_BUFFER_SIZE (*buf));
-    obuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (*buf) + 1);
-    memcpy (GST_BUFFER_DATA (obuf), GST_BUFFER_DATA (*buf),
-        GST_BUFFER_SIZE (*buf));
+  size = gst_buffer_get_size (*buf);
+
+  if (G_UNLIKELY (size & 1)) {
+    GstBuffer *obuf;
+    guint8 *data;
+
+    GST_DEBUG_OBJECT (avi, "rounding up dubious list size %d", size);
+    obuf = gst_buffer_new_and_alloc (size + 1);
+
+    data = gst_buffer_map (obuf, NULL, NULL, GST_MAP_WRITE);
+    gst_buffer_extract (*buf, 0, data, size);
+    gst_buffer_unmap (obuf, data, size + 1);
     gst_buffer_replace (buf, obuf);
   }
 }
@@ -2125,9 +2141,12 @@
       case GST_RIFF_TAG_strn:
         g_free (stream->name);
         if (sub != NULL) {
-          stream->name =
-              g_strndup ((gchar *) GST_BUFFER_DATA (sub),
-              (gsize) GST_BUFFER_SIZE (sub));
+          gchar *bdata;
+          gsize bsize;
+
+          bdata = gst_buffer_map (sub, &bsize, NULL, GST_MAP_READ);
+          stream->name = g_strndup (bdata, bsize);
+          gst_buffer_unmap (sub, bdata, bsize);
           gst_buffer_unref (sub);
           sub = NULL;
         } else {
@@ -2363,20 +2382,26 @@
     switch (tag) {
       case GST_RIFF_TAG_dmlh:{
         gst_riff_dmlh dmlh, *_dmlh;
-        guint size;
+        gsize size;
+        guint8 *data;
 
         /* sub == NULL is possible and means an empty buffer */
-        size = sub ? GST_BUFFER_SIZE (sub) : 0;
+        if (sub == NULL)
+          goto next;
+
+        data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
 
         /* check size */
         if (size < sizeof (gst_riff_dmlh)) {
           GST_ERROR_OBJECT (avi,
               "DMLH entry is too small (%d bytes, %d needed)",
               size, (int) sizeof (gst_riff_dmlh));
+          gst_buffer_unmap (sub, data, size);
           goto next;
         }
-        _dmlh = (gst_riff_dmlh *) GST_BUFFER_DATA (sub);
+        _dmlh = (gst_riff_dmlh *) data;
         dmlh.totalframes = GST_READ_UINT32_LE (&_dmlh->totalframes);
+        gst_buffer_unmap (sub, data, size);
 
         GST_INFO_OBJECT (avi, "dmlh tag found: totalframes: %u",
             dmlh.totalframes);
@@ -2554,7 +2579,7 @@
 gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
 {
   guint8 *data;
-  guint size;
+  gsize size;
   guint i, num, n;
   gst_riff_index_entry *index;
   GstClockTime stamp;
@@ -2565,8 +2590,7 @@
   if (!buf)
     return FALSE;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
 
   stamp = gst_util_get_timestamp ();
 
@@ -2628,6 +2652,7 @@
 
     n++;
   }
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   /* get stream stats now */
@@ -2643,6 +2668,7 @@
 empty_list:
   {
     GST_DEBUG_OBJECT (avi, "empty index");
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -2652,6 +2678,7 @@
         ("Cannot allocate memory for %u*%u=%u bytes",
             (guint) sizeof (GstAviIndexEntry), num,
             (guint) sizeof (GstAviIndexEntry) * num));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -2671,6 +2698,8 @@
   GstBuffer *buf;
   guint32 tag;
   guint32 size;
+  gsize bsize;
+  guint8 *bdata;
 
   GST_DEBUG ("demux stream index at offset %" G_GUINT64_FORMAT, offset);
 
@@ -2678,34 +2707,41 @@
   res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
   if (res != GST_FLOW_OK)
     goto pull_failed;
-  else if (GST_BUFFER_SIZE (buf) < 8)
+
+  bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  if (bsize < 8)
     goto too_small;
 
   /* check tag first before blindy trying to read 'size' bytes */
-  tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
-  size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
+  tag = GST_READ_UINT32_LE (bdata);
+  size = GST_READ_UINT32_LE (bdata + 4);
   if (tag == GST_RIFF_TAG_LIST) {
     /* this is the movi tag */
     GST_DEBUG_OBJECT (avi, "skip LIST chunk, size %" G_GUINT32_FORMAT,
         (8 + GST_ROUND_UP_2 (size)));
     offset += 8 + GST_ROUND_UP_2 (size);
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
+
     res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
     if (res != GST_FLOW_OK)
       goto pull_failed;
-    else if (GST_BUFFER_SIZE (buf) < 8)
+
+    bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+    if (bsize < 8)
       goto too_small;
-    tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
-    size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
+
+    tag = GST_READ_UINT32_LE (bdata);
+    size = GST_READ_UINT32_LE (bdata + 4);
   }
+  gst_buffer_unmap (buf, bdata, bsize);
+  gst_buffer_unref (buf);
 
   if (tag != GST_RIFF_TAG_idx1)
     goto no_index;
   if (!size)
     goto zero_index;
 
-  gst_buffer_unref (buf);
-
   GST_DEBUG ("index found at offset %" G_GUINT64_FORMAT, offset);
 
   /* read chunk, advance offset */
@@ -2714,7 +2750,7 @@
     return;
 
   GST_DEBUG ("will parse index chunk size %u for tag %"
-      GST_FOURCC_FORMAT, GST_BUFFER_SIZE (buf), GST_FOURCC_ARGS (tag));
+      GST_FOURCC_FORMAT, gst_buffer_get_size (buf), GST_FOURCC_ARGS (tag));
 
   gst_avi_demux_parse_index (avi, buf);
 
@@ -2743,6 +2779,7 @@
 too_small:
   {
     GST_DEBUG_OBJECT (avi, "Buffer is too small");
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
     return;
   }
@@ -2751,13 +2788,11 @@
     GST_WARNING_OBJECT (avi,
         "No index data (idx1) after movi chunk, but %" GST_FOURCC_FORMAT,
         GST_FOURCC_ARGS (tag));
-    gst_buffer_unref (buf);
     return;
   }
 zero_index:
   {
     GST_WARNING_OBJECT (avi, "Empty index data (idx1) after movi chunk");
-    gst_buffer_unref (buf);
     return;
   }
 }
@@ -2808,7 +2843,7 @@
   offset += 8 + GST_ROUND_UP_2 (size);
 
   GST_DEBUG ("will parse index chunk size %u for tag %"
-      GST_FOURCC_FORMAT, GST_BUFFER_SIZE (buf), GST_FOURCC_ARGS (tag));
+      GST_FOURCC_FORMAT, gst_buffer_get_size (buf), GST_FOURCC_ARGS (tag));
 
   avi->offset = avi->first_movi_offset;
   gst_avi_demux_parse_index (avi, buf);
@@ -2856,19 +2891,17 @@
 {
   GstFlowReturn res = GST_FLOW_OK;
   GstBuffer *buf = NULL;
-  guint bufsize;
+  gsize bufsize;
   guint8 *bufdata;
 
   res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
   if (res != GST_FLOW_OK)
     goto pull_failed;
 
-  bufsize = GST_BUFFER_SIZE (buf);
+  bufdata = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
   if (bufsize != 8)
     goto wrong_size;
 
-  bufdata = GST_BUFFER_DATA (buf);
-
   *tag = GST_READ_UINT32_LE (bufdata);
   *size = GST_READ_UINT32_LE (bufdata + 4);
 
@@ -2877,6 +2910,7 @@
       *size, offset + 8, offset + 8 + (gint64) * size);
 
 done:
+  gst_buffer_unmap (buf, bufdata, bufsize);
   gst_buffer_unref (buf);
 
   return res;
@@ -3150,6 +3184,7 @@
   gint64 stop;
   gint i;
   GstTagList *tags = NULL;
+  guint8 fourcc[4];
 
   GST_DEBUG ("Reading and parsing avi headers: %d", avi->header_state);
 
@@ -3165,7 +3200,9 @@
         GST_DEBUG ("Reading %d bytes", size);
         buf = gst_adapter_take_buffer (avi->adapter, size);
 
-        if (GST_READ_UINT32_LE (GST_BUFFER_DATA (buf)) != GST_RIFF_LIST_hdrl)
+        gst_buffer_extract (buf, 0, fourcc, 4);
+
+        if (GST_READ_UINT32_LE (fourcc) != GST_RIFF_LIST_hdrl)
           goto header_no_hdrl;
 
         /* mind padding */
@@ -3198,10 +3235,12 @@
 
           switch (tag) {
             case GST_RIFF_TAG_LIST:
-              if (GST_BUFFER_SIZE (sub) < 4)
+              if (gst_buffer_get_size (sub) < 4)
                 goto next;
 
-              switch (GST_READ_UINT32_LE (GST_BUFFER_DATA (sub))) {
+              gst_buffer_extract (sub, 0, fourcc, 4);
+
+              switch (GST_READ_UINT32_LE (fourcc)) {
                 case GST_RIFF_LIST_strl:
                   if (!(gst_avi_demux_parse_stream (avi, sub))) {
                     sub = NULL;
@@ -3218,14 +3257,13 @@
                 default:
                   GST_WARNING_OBJECT (avi,
                       "Unknown list %" GST_FOURCC_FORMAT " in AVI header",
-                      GST_FOURCC_ARGS (GST_READ_UINT32_LE (GST_BUFFER_DATA
-                              (sub))));
+                      GST_FOURCC_ARGS (GST_READ_UINT32_LE (fourcc)));
                   /* fall-through */
                 case GST_RIFF_TAG_JUNQ:
                 case GST_RIFF_TAG_JUNK:
                   goto next;
+                  break;
               }
-              break;
             case GST_RIFF_IDIT:
               gst_avi_demux_parse_idit (avi, sub);
               goto next;
@@ -3268,10 +3306,11 @@
         if (gst_adapter_available (avi->adapter) < 12)
           return GST_FLOW_OK;
 
-        data = gst_adapter_peek (avi->adapter, 12);
+        data = gst_adapter_map (avi->adapter, 12);
         tag = GST_READ_UINT32_LE (data);
         size = GST_READ_UINT32_LE (data + 4);
         ltag = GST_READ_UINT32_LE (data + 8);
+        gst_adapter_unmap (avi->adapter, 0);
 
         if (tag == GST_RIFF_TAG_LIST) {
           switch (ltag) {
@@ -3523,10 +3562,11 @@
 static void
 gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
 {
-  gchar *data = (gchar *) GST_BUFFER_DATA (buf);
-  guint size = GST_BUFFER_SIZE (buf);
+  gchar *data, *ptr;
+  gsize size, left;
   gchar *safedata = NULL;
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   /*
    * According to:
    * http://www.eden-foundation.org/products/code/film_date_stamp/index.html
@@ -3540,24 +3580,27 @@
    */
 
   /* skip eventual initial whitespace */
-  while (size > 0 && g_ascii_isspace (data[0])) {
-    data++;
-    size--;
+  ptr = data;
+  left = size;
+
+  while (left > 0 && g_ascii_isspace (ptr[0])) {
+    ptr++;
+    left--;
   }
 
-  if (size == 0) {
+  if (left == 0) {
     goto non_parsable;
   }
 
   /* make a safe copy to add a \0 to the end of the string */
-  safedata = g_strndup (data, size);
+  safedata = g_strndup (ptr, left);
 
   /* test if the first char is a alpha or a number */
-  if (g_ascii_isdigit (data[0])) {
+  if (g_ascii_isdigit (ptr[0])) {
     gst_avi_demux_parse_idit_nums_only (avi, safedata);
     g_free (safedata);
     return;
-  } else if (g_ascii_isalpha (data[0])) {
+  } else if (g_ascii_isalpha (ptr[0])) {
     gst_avi_demux_parse_idit_text (avi, safedata);
     g_free (safedata);
     return;
@@ -3567,6 +3610,7 @@
 
 non_parsable:
   GST_WARNING_OBJECT (avi, "IDIT tag has no parsable info");
+  gst_buffer_unmap (buf, data, size);
 }
 
 /*
@@ -3583,6 +3627,7 @@
   GstElement *element = GST_ELEMENT_CAST (avi);
   GstClockTime stamp;
   GstTagList *tags = NULL;
+  guint8 fourcc[4];
 
   stamp = gst_util_get_timestamp ();
 
@@ -3592,15 +3637,16 @@
     goto pull_range_failed;
   else if (tag != GST_RIFF_TAG_LIST)
     goto no_list;
-  else if (GST_BUFFER_SIZE (buf) < 4)
+  else if (gst_buffer_get_size (buf) < 4)
     goto no_header;
 
   GST_DEBUG_OBJECT (avi, "parsing headers");
 
   /* Find the 'hdrl' LIST tag */
-  while (GST_READ_UINT32_LE (GST_BUFFER_DATA (buf)) != GST_RIFF_LIST_hdrl) {
+  gst_buffer_extract (buf, 0, fourcc, 4);
+  while (GST_READ_UINT32_LE (fourcc) != GST_RIFF_LIST_hdrl) {
     GST_LOG_OBJECT (avi, "buffer contains %" GST_FOURCC_FORMAT,
-        GST_FOURCC_ARGS (GST_READ_UINT32_LE (GST_BUFFER_DATA (buf))));
+        GST_FOURCC_ARGS (GST_READ_UINT32_LE (fourcc)));
 
     /* Eat up */
     gst_buffer_unref (buf);
@@ -3611,8 +3657,9 @@
       goto pull_range_failed;
     else if (tag != GST_RIFF_TAG_LIST)
       goto no_list;
-    else if (GST_BUFFER_SIZE (buf) < 4)
+    else if (gst_buffer_get_size (buf) < 4)
       goto no_header;
+    gst_buffer_extract (buf, 0, fourcc, 4);
   }
 
   GST_DEBUG_OBJECT (avi, "hdrl LIST tag found");
@@ -3631,23 +3678,21 @@
 
   /* now, read the elements from the header until the end */
   while (gst_riff_parse_chunk (element, buf, &offset, &tag, &sub)) {
+    gsize size;
+    guint8 *data;
+
     /* sub can be NULL on empty tags */
     if (!sub)
       continue;
 
+    data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
+
     switch (tag) {
       case GST_RIFF_TAG_LIST:
-      {
-        guint8 *data;
-        guint32 fourcc;
-
-        if (GST_BUFFER_SIZE (sub) < 4)
+        if (size < 4)
           goto next;
 
-        data = GST_BUFFER_DATA (sub);
-        fourcc = GST_READ_UINT32_LE (data);
-
-        switch (fourcc) {
+        switch (GST_READ_UINT32_LE (data)) {
           case GST_RIFF_LIST_strl:
             if (!(gst_avi_demux_parse_stream (avi, sub))) {
               GST_ELEMENT_WARNING (avi, STREAM, DEMUX, (NULL),
@@ -3661,8 +3706,7 @@
             sub = NULL;
             break;
           case GST_RIFF_LIST_INFO:
-            GST_BUFFER_DATA (sub) = data + 4;
-            GST_BUFFER_SIZE (sub) -= 4;
+            gst_buffer_resize (sub, 4, -1);
             gst_riff_parse_info (element, sub, &tags);
             if (tags) {
               if (avi->globaltags) {
@@ -3677,16 +3721,14 @@
           default:
             GST_WARNING_OBJECT (avi,
                 "Unknown list %" GST_FOURCC_FORMAT " in AVI header",
-                GST_FOURCC_ARGS (fourcc));
-            GST_MEMDUMP_OBJECT (avi, "Unknown list", GST_BUFFER_DATA (sub),
-                GST_BUFFER_SIZE (sub));
+                GST_FOURCC_ARGS (GST_READ_UINT32_LE (data)));
+            GST_MEMDUMP_OBJECT (avi, "Unknown list", data, size);
             /* fall-through */
           case GST_RIFF_TAG_JUNQ:
           case GST_RIFF_TAG_JUNK:
             goto next;
         }
         break;
-      }
       case GST_RIFF_IDIT:
         gst_avi_demux_parse_idit (avi, sub);
         goto next;
@@ -3694,14 +3736,15 @@
         GST_WARNING_OBJECT (avi,
             "Unknown tag %" GST_FOURCC_FORMAT " in AVI header at off %d",
             GST_FOURCC_ARGS (tag), offset);
-        GST_MEMDUMP_OBJECT (avi, "Unknown tag", GST_BUFFER_DATA (sub),
-            GST_BUFFER_SIZE (sub));
+        GST_MEMDUMP_OBJECT (avi, "Unknown tag", data, size);
         /* fall-through */
       case GST_RIFF_TAG_JUNQ:
       case GST_RIFF_TAG_JUNK:
       next:
-        if (sub)
+        if (sub) {
+          gst_buffer_unmap (sub, data, size);
           gst_buffer_unref (sub);
+        }
         sub = NULL;
         break;
     }
@@ -3724,6 +3767,7 @@
   /* Now, find the data (i.e. skip all junk between header and data) */
   do {
     guint size;
+    gsize bsize;
     guint8 *data;
     guint32 tag, ltag;
 
@@ -3731,22 +3775,22 @@
     if (res != GST_FLOW_OK) {
       GST_DEBUG_OBJECT (avi, "pull_range failure while looking for tags");
       goto pull_range_failed;
-    } else if (GST_BUFFER_SIZE (buf) < 12) {
+    } else if (gst_buffer_get_size (buf) < 12) {
       GST_DEBUG_OBJECT (avi, "got %d bytes which is less than 12 bytes",
-          GST_BUFFER_SIZE (buf));
+          gst_buffer_get_size (buf));
       gst_buffer_unref (buf);
       return GST_FLOW_ERROR;
     }
 
-    data = GST_BUFFER_DATA (buf);
-
+    data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
     tag = GST_READ_UINT32_LE (data);
     size = GST_READ_UINT32_LE (data + 4);
     ltag = GST_READ_UINT32_LE (data + 8);
 
     GST_DEBUG ("tag %" GST_FOURCC_FORMAT ", size %u",
         GST_FOURCC_ARGS (tag), size);
-    GST_MEMDUMP ("Tag content", data, GST_BUFFER_SIZE (buf));
+    GST_MEMDUMP ("Tag content", data, bsize);
+    gst_buffer_unmap (buf, data, bsize);
     gst_buffer_unref (buf);
 
     switch (tag) {
@@ -3764,7 +3808,7 @@
               GST_DEBUG_OBJECT (avi, "couldn't read INFO chunk");
               goto pull_range_failed;
             }
-            GST_DEBUG ("got size %u", GST_BUFFER_SIZE (buf));
+            GST_DEBUG ("got size %u", gst_buffer_get_size (buf));
             if (size < 4) {
               GST_DEBUG ("skipping INFO LIST prefix");
               avi->offset += (4 - GST_ROUND_UP_2 (size));
@@ -3772,7 +3816,7 @@
               continue;
             }
 
-            sub = gst_buffer_create_sub (buf, 4, GST_BUFFER_SIZE (buf) - 4);
+            sub = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, 4, -1);
             gst_riff_parse_info (element, sub, &tags);
             if (tags) {
               if (avi->globaltags) {
@@ -3812,7 +3856,9 @@
             GST_DEBUG_OBJECT (avi, "couldn't read INFO chunk");
             goto pull_range_failed;
           }
-          GST_MEMDUMP ("Junk", GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+          data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+          GST_MEMDUMP ("Junk", data, bsize);
+          gst_buffer_unmap (buf, data, bsize);
           gst_buffer_unref (buf);
         }
         avi->offset += 8 + GST_ROUND_UP_2 (size);
@@ -4448,7 +4494,8 @@
   GstStructure *s;
   gint y, w, h;
   gint bpp, stride;
-  guint8 *tmp = NULL;
+  guint8 *tmp = NULL, *data;
+  gsize size;
 
   if (stream->strh->type != GST_RIFF_FCC_vids)
     return buf;
@@ -4473,20 +4520,24 @@
   stride = w * (bpp / 8);
 
   buf = gst_buffer_make_writable (buf);
-  if (GST_BUFFER_SIZE (buf) < (stride * h)) {
+
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+  if (size < (stride * h)) {
     GST_WARNING ("Buffer is smaller than reported Width x Height x Depth");
+    gst_buffer_unmap (buf, data, size);
     return buf;
   }
 
   tmp = g_malloc (stride);
 
   for (y = 0; y < h / 2; y++) {
-    swap_line (GST_BUFFER_DATA (buf) + stride * y,
-        GST_BUFFER_DATA (buf) + stride * (h - 1 - y), tmp, stride);
+    swap_line (data + stride * y, data + stride * (h - 1 - y), tmp, stride);
   }
 
   g_free (tmp);
 
+  gst_buffer_unmap (buf, data, size);
+
   return buf;
 }
 
@@ -4740,7 +4791,7 @@
       goto pull_failed;
 
     /* check for short buffers, this is EOS as well */
-    if (GST_BUFFER_SIZE (buf) < size)
+    if (gst_buffer_get_size (buf) < size)
       goto short_buffer;
 
     /* invert the picture if needed */
@@ -4774,7 +4825,7 @@
     GST_DEBUG_OBJECT (avi, "Pushing buffer of size %u, ts %"
         GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT ", off %" G_GUINT64_FORMAT
         ", off_end %" G_GUINT64_FORMAT,
-        GST_BUFFER_SIZE (buf), GST_TIME_ARGS (timestamp),
+        gst_buffer_get_size (buf), GST_TIME_ARGS (timestamp),
         GST_TIME_ARGS (duration), out_offset, out_offset_end);
 
     ret = gst_pad_push (stream->pad, buf);
@@ -4829,7 +4880,7 @@
   {
     GST_WARNING_OBJECT (avi, "Short read at offset %" G_GUINT64_FORMAT
         ", only got %d/%" G_GUINT64_FORMAT " bytes (truncated file?)", offset,
-        GST_BUFFER_SIZE (buf), size);
+        gst_buffer_get_size (buf), size);
     gst_buffer_unref (buf);
     ret = GST_FLOW_UNEXPECTED;
     goto beach;
@@ -4974,7 +5025,7 @@
         if (size) {
           buf = gst_adapter_take_buffer (avi->adapter, GST_ROUND_UP_2 (size));
           /* patch the size */
-          GST_BUFFER_SIZE (buf) = size;
+          gst_buffer_resize (buf, 0, size);
         } else {
           buf = NULL;
         }
@@ -5231,7 +5282,7 @@
       avi->stream[i].discont = TRUE;
   }
 
-  GST_DEBUG ("Store %d bytes in adapter", GST_BUFFER_SIZE (buf));
+  GST_DEBUG ("Store %d bytes in adapter", gst_buffer_get_size (buf));
   gst_adapter_push (avi->adapter, buf);
 
   switch (avi->state) {
diff --git a/gst/avi/gstavimux.c b/gst/avi/gstavimux.c
index 37f9291..945571f 100644
--- a/gst/avi/gstavimux.c
+++ b/gst/avi/gstavimux.c
@@ -634,7 +634,7 @@
       avipad->vids_codec_data = gst_value_get_buffer (codec_data);
       gst_buffer_ref (avipad->vids_codec_data);
       /* keep global track of size */
-      avimux->codec_data_size += GST_BUFFER_SIZE (avipad->vids_codec_data);
+      avimux->codec_data_size += gst_buffer_get_size (avipad->vids_codec_data);
     } else {
       avipad->prepend_buffer =
           gst_buffer_ref (gst_value_get_buffer (codec_data));
@@ -665,16 +665,14 @@
     GstBuffer * buffer)
 {
   guint8 *data;
-  guint size;
+  gsize size;
   guint spf;
   guint32 header;
   gulong layer;
   gulong version;
   gint lsf, mpg25;
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
-
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   if (size < 4)
     goto not_parsed;
 
@@ -713,6 +711,8 @@
     GST_WARNING_OBJECT (avimux, "input mpeg audio has varying frame size");
     goto cbr_fallback;
   }
+done:
+  gst_buffer_unmap (buffer, data, size);
 
   return GST_FLOW_OK;
 
@@ -728,7 +728,7 @@
     avipad->hdr.scale = 1;
     /* no need to check further */
     avipad->hook = NULL;
-    return GST_FLOW_OK;
+    goto done;
   }
 }
 
@@ -792,7 +792,7 @@
     avipad->auds_codec_data = gst_value_get_buffer (codec_data);
     gst_buffer_ref (avipad->auds_codec_data);
     /* keep global track of size */
-    avimux->codec_data_size += GST_BUFFER_SIZE (avipad->auds_codec_data);
+    avimux->codec_data_size += gst_buffer_get_size (avipad->auds_codec_data);
   }
 
   if (!strcmp (mimetype, "audio/x-raw-int")) {
@@ -871,6 +871,7 @@
           GstBuffer *codec_data_buf = avipad->auds_codec_data;
           const gchar *stream_format;
           guint codec;
+          guint8 data[2];
 
           stream_format = gst_structure_get_string (structure, "stream-format");
           if (stream_format) {
@@ -885,13 +886,14 @@
           }
 
           /* vbr case needs some special handling */
-          if (!codec_data_buf || GST_BUFFER_SIZE (codec_data_buf) < 2) {
+          if (!codec_data_buf || gst_buffer_get_size (codec_data_buf) < 2) {
             GST_WARNING_OBJECT (avimux, "no (valid) codec_data for AAC audio");
             break;
           }
           avipad->auds.format = GST_RIFF_WAVE_FORMAT_AAC;
           /* need to determine frame length */
-          codec = GST_READ_UINT16_BE (GST_BUFFER_DATA (codec_data_buf));
+          gst_buffer_extract (codec_data_buf, 0, data, 2);
+          codec = GST_READ_UINT16_BE (data);
           avipad->parent.hdr.scale = (codec & 0x4) ? 960 : 1024;
           break;
         }
@@ -1190,6 +1192,8 @@
   GstByteWriter bw;
   GSList *node;
   guint avih, riff, hdrl;
+  guint8 *bdata;
+  gsize bsize;
 
   GST_DEBUG_OBJECT (avimux, "creating avi header, data_size %u, idx_size %u",
       avimux->data_size, avimux->idx_size);
@@ -1265,7 +1269,7 @@
 
     if (avipad->is_video) {
       codec_size = vidpad->vids_codec_data ?
-          GST_BUFFER_SIZE (vidpad->vids_codec_data) : 0;
+          gst_buffer_get_size (vidpad->vids_codec_data) : 0;
       /* the video header */
       strf = gst_avi_mux_start_chunk (&bw, "strf", 0);
       /* the actual header */
@@ -1281,9 +1285,11 @@
       gst_byte_writer_put_uint32_le (&bw, vidpad->vids.num_colors);
       gst_byte_writer_put_uint32_le (&bw, vidpad->vids.imp_colors);
       if (vidpad->vids_codec_data) {
-        gst_byte_writer_put_data (&bw,
-            GST_BUFFER_DATA (vidpad->vids_codec_data),
-            GST_BUFFER_SIZE (vidpad->vids_codec_data));
+        bdata =
+            gst_buffer_map (vidpad->vids_codec_data, &bsize, NULL,
+            GST_MAP_READ);
+        gst_byte_writer_put_data (&bw, bdata, bsize);
+        gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
       }
       gst_avi_mux_end_chunk (&bw, strf);
 
@@ -1325,7 +1331,7 @@
       }
     } else {
       codec_size = audpad->auds_codec_data ?
-          GST_BUFFER_SIZE (audpad->auds_codec_data) : 0;
+          gst_buffer_get_size (audpad->auds_codec_data) : 0;
       /* the audio header */
       strf = gst_avi_mux_start_chunk (&bw, "strf", 0);
       /* the actual header */
@@ -1337,9 +1343,11 @@
       gst_byte_writer_put_uint16_le (&bw, audpad->auds.size);
       gst_byte_writer_put_uint16_le (&bw, codec_size);
       if (audpad->auds_codec_data) {
-        gst_byte_writer_put_data (&bw,
-            GST_BUFFER_DATA (audpad->auds_codec_data),
-            GST_BUFFER_SIZE (audpad->auds_codec_data));
+        bdata =
+            gst_buffer_map (audpad->auds_codec_data, &bsize, NULL,
+            GST_MAP_READ);
+        gst_byte_writer_put_data (&bw, bdata, bsize);
+        gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
       }
       gst_avi_mux_end_chunk (&bw, strf);
     }
@@ -1410,12 +1418,13 @@
   buffer = gst_byte_writer_reset_and_get_buffer (&bw);
 
   /* ... but RIFF includes more than just header */
-  size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buffer) + 4);
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READWRITE);
+  size = GST_READ_UINT32_LE (bdata + 4);
   size += 8 + avimux->data_size + avimux->idx_size;
-  GST_WRITE_UINT32_LE (GST_BUFFER_DATA (buffer) + 4, size);
+  GST_WRITE_UINT32_LE (bdata + 4, size);
 
-  GST_MEMDUMP_OBJECT (avimux, "avi header", GST_BUFFER_DATA (buffer),
-      GST_BUFFER_SIZE (buffer));
+  GST_MEMDUMP_OBJECT (avimux, "avi header", bdata, bsize);
+  gst_buffer_unmap (buffer, bdata, bsize);
 
   return buffer;
 }
@@ -1424,17 +1433,19 @@
 gst_avi_mux_riff_get_avix_header (guint32 datax_size)
 {
   GstBuffer *buffer;
-  guint8 *buffdata;
+  guint8 *bdata;
+  gsize bsize;
 
   buffer = gst_buffer_new_and_alloc (24);
-  buffdata = GST_BUFFER_DATA (buffer);
 
-  memcpy (buffdata + 0, "RIFF", 4);
-  GST_WRITE_UINT32_LE (buffdata + 4, datax_size + 3 * 4);
-  memcpy (buffdata + 8, "AVIX", 4);
-  memcpy (buffdata + 12, "LIST", 4);
-  GST_WRITE_UINT32_LE (buffdata + 16, datax_size);
-  memcpy (buffdata + 20, "movi", 4);
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  memcpy (bdata + 0, "RIFF", 4);
+  GST_WRITE_UINT32_LE (bdata + 4, datax_size + 3 * 4);
+  memcpy (bdata + 8, "AVIX", 4);
+  memcpy (bdata + 12, "LIST", 4);
+  GST_WRITE_UINT32_LE (bdata + 16, datax_size);
+  memcpy (bdata + 20, "movi", 4);
+  gst_buffer_unmap (buffer, bdata, bsize);
 
   return buffer;
 }
@@ -1443,12 +1454,15 @@
 gst_avi_mux_riff_get_header (GstAviPad * avipad, guint32 video_frame_size)
 {
   GstBuffer *buffer;
-  guint8 *buffdata;
+  guint8 *bdata;
+  gsize bsize;
 
   buffer = gst_buffer_new_and_alloc (8);
-  buffdata = GST_BUFFER_DATA (buffer);
-  memcpy (buffdata + 0, avipad->tag, 4);
-  GST_WRITE_UINT32_LE (buffdata + 4, video_frame_size);
+
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  memcpy (bdata + 0, avipad->tag, 4);
+  GST_WRITE_UINT32_LE (bdata + 4, video_frame_size);
+  gst_buffer_unmap (buffer, bdata, bsize);
 
   return buffer;
 }
@@ -1461,12 +1475,14 @@
 {
   GstFlowReturn res;
   GstBuffer *buffer;
-  guint8 *buffdata, *data;
+  guint8 *data;
   gst_riff_index_entry *entry;
   gint i;
   guint32 size, entry_count;
   gboolean is_pcm = FALSE;
   guint32 pcm_samples = 0;
+  guint8 *bdata;
+  gsize bsize;
 
   /* check if it is pcm */
   if (avipad && !avipad->is_video) {
@@ -1479,19 +1495,21 @@
 
   /* allocate the maximum possible */
   buffer = gst_buffer_new_and_alloc (32 + 8 * avimux->idx_index);
-  buffdata = GST_BUFFER_DATA (buffer);
+
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  data = bdata;
 
   /* general index chunk info */
-  memcpy (buffdata + 0, chunk, 4);      /* chunk id */
-  GST_WRITE_UINT32_LE (buffdata + 4, 0);        /* chunk size; fill later */
-  GST_WRITE_UINT16_LE (buffdata + 8, 2);        /* index entry is 2 words */
-  buffdata[10] = 0;             /* index subtype */
-  buffdata[11] = GST_AVI_INDEX_OF_CHUNKS;       /* index type: AVI_INDEX_OF_CHUNKS */
-  GST_WRITE_UINT32_LE (buffdata + 12, 0);       /* entries in use; fill later */
-  memcpy (buffdata + 16, code, 4);      /* stream to which index refers */
-  GST_WRITE_UINT64_LE (buffdata + 20, avimux->avix_start);      /* base offset */
-  GST_WRITE_UINT32_LE (buffdata + 28, 0);       /* reserved */
-  buffdata += 32;
+  memcpy (bdata + 0, chunk, 4); /* chunk id */
+  GST_WRITE_UINT32_LE (bdata + 4, 0);   /* chunk size; fill later */
+  GST_WRITE_UINT16_LE (bdata + 8, 2);   /* index entry is 2 words */
+  bdata[10] = 0;                /* index subtype */
+  bdata[11] = GST_AVI_INDEX_OF_CHUNKS;  /* index type: AVI_INDEX_OF_CHUNKS */
+  GST_WRITE_UINT32_LE (bdata + 12, 0);  /* entries in use; fill later */
+  memcpy (bdata + 16, code, 4); /* stream to which index refers */
+  GST_WRITE_UINT64_LE (bdata + 20, avimux->avix_start); /* base offset */
+  GST_WRITE_UINT32_LE (bdata + 28, 0);  /* reserved */
+  bdata += 32;
 
   /* now the actual index entries */
   i = avimux->idx_index;
@@ -1499,23 +1517,23 @@
   while (i > 0) {
     if (memcmp (&entry->id, code, 4) == 0) {
       /* enter relative offset to the data (!) */
-      GST_WRITE_UINT32_LE (buffdata, GUINT32_FROM_LE (entry->offset) + 8);
+      GST_WRITE_UINT32_LE (bdata, GUINT32_FROM_LE (entry->offset) + 8);
       /* msb is set if not (!) keyframe */
-      GST_WRITE_UINT32_LE (buffdata + 4, GUINT32_FROM_LE (entry->size)
+      GST_WRITE_UINT32_LE (bdata + 4, GUINT32_FROM_LE (entry->size)
           | (GUINT32_FROM_LE (entry->flags)
               & GST_RIFF_IF_KEYFRAME ? 0 : 1U << 31));
-      buffdata += 8;
+      bdata += 8;
     }
     i--;
     entry++;
   }
 
   /* ok, now we know the size and no of entries, fill in where needed */
-  data = GST_BUFFER_DATA (buffer);
-  GST_BUFFER_SIZE (buffer) = size = buffdata - data;
+  size = bdata - data;
   GST_WRITE_UINT32_LE (data + 4, size - 8);
   entry_count = (size - 32) / 8;
   GST_WRITE_UINT32_LE (data + 12, entry_count);
+  gst_buffer_unmap (buffer, data, size);
 
   /* decorate and send */
   gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
@@ -1583,12 +1601,15 @@
   GstFlowReturn res;
   GstBuffer *buffer;
   guint8 *buffdata;
+  gsize buffsize;
 
   buffer = gst_buffer_new_and_alloc (8);
-  buffdata = GST_BUFFER_DATA (buffer);
+
+  buffdata = gst_buffer_map (buffer, &buffsize, NULL, GST_MAP_WRITE);
   memcpy (buffdata + 0, "idx1", 4);
   GST_WRITE_UINT32_LE (buffdata + 4,
       avimux->idx_index * sizeof (gst_riff_index_entry));
+  gst_buffer_unmap (buffer, buffdata, buffsize);
 
   gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
   res = gst_pad_push (avimux->srcpad, buffer);
@@ -1596,11 +1617,15 @@
     return res;
 
   buffer = gst_buffer_new ();
-  GST_BUFFER_SIZE (buffer) = avimux->idx_index * sizeof (gst_riff_index_entry);
-  GST_BUFFER_DATA (buffer) = (guint8 *) avimux->idx;
-  GST_BUFFER_MALLOCDATA (buffer) = GST_BUFFER_DATA (buffer);
+
+  buffsize = avimux->idx_index * sizeof (gst_riff_index_entry);
+  buffdata = (guint8 *) avimux->idx;
   avimux->idx = NULL;           /* will be free()'ed by gst_buffer_unref() */
-  avimux->total_data += GST_BUFFER_SIZE (buffer) + 8;
+
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (0, buffdata, g_free, buffsize, 0, buffsize));
+
+  avimux->total_data += buffsize + 8;
 
   gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
   res = gst_pad_push (avimux->srcpad, buffer);
@@ -1682,7 +1707,7 @@
   }
 
   header = gst_avi_mux_riff_get_avix_header (0);
-  avimux->total_data += GST_BUFFER_SIZE (header);
+  avimux->total_data += gst_buffer_get_size (header);
   /* avix_start is used as base offset for the odml index chunk */
   avimux->idx_offset = avimux->total_data - avimux->avix_start;
   gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
@@ -1753,7 +1778,7 @@
   avimux->is_bigfile = FALSE;
 
   header = gst_avi_mux_riff_get_avi_header (avimux);
-  avimux->total_data += GST_BUFFER_SIZE (header);
+  avimux->total_data += gst_buffer_get_size (header);
 
   gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
   res = gst_pad_push (avimux->srcpad, header);
@@ -1899,9 +1924,14 @@
 gst_avi_mux_send_pad_data (GstAviMux * avimux, gulong num_bytes)
 {
   GstBuffer *buffer;
+  guint8 *bdata;
+  gsize bsize;
 
   buffer = gst_buffer_new_and_alloc (num_bytes);
-  memset (GST_BUFFER_DATA (buffer), 0, num_bytes);
+
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  memset (bdata, 0, num_bytes);
+  gst_buffer_unmap (buffer, bdata, bsize);
   gst_buffer_set_caps (buffer, GST_PAD_CAPS (avimux->srcpad));
   return gst_pad_push (avimux->srcpad, buffer);
 }
@@ -1914,10 +1944,11 @@
   GstBuffer *data, *header;
   gulong total_size, pad_bytes = 0;
   guint flags;
+  gsize datasize;
 
   data = gst_collect_pads_pop (avimux->collect, avipad->collect);
   /* arrange downstream running time */
-  data = gst_buffer_make_metadata_writable (data);
+  data = gst_buffer_make_writable (data);
   GST_BUFFER_TIMESTAMP (data) =
       gst_segment_to_running_time (&avipad->collect->segment,
       GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (data));
@@ -1928,7 +1959,7 @@
 
     if (vidpad->prepend_buffer) {
       GstBuffer *newdata = gst_buffer_merge (vidpad->prepend_buffer, data);
-      gst_buffer_copy_metadata (newdata, data, GST_BUFFER_COPY_TIMESTAMPS);
+      gst_buffer_copy_into (newdata, data, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
       gst_buffer_unref (data);
       gst_buffer_unref (vidpad->prepend_buffer);
 
@@ -1942,9 +1973,11 @@
       return res;
   }
 
+  datasize = gst_buffer_get_size (data);
+
   /* need to restart or start a next avix chunk ? */
   if ((avimux->is_bigfile ? avimux->datax_size : avimux->data_size) +
-      GST_BUFFER_SIZE (data) > GST_AVI_MAX_SIZE) {
+      datasize > GST_AVI_MAX_SIZE) {
     if (avimux->enable_large_avi) {
       if ((res = gst_avi_mux_bigfile (avimux, FALSE)) != GST_FLOW_OK)
         return res;
@@ -1955,11 +1988,11 @@
   }
 
   /* get header and record some stats */
-  if (GST_BUFFER_SIZE (data) & 1) {
-    pad_bytes = 2 - (GST_BUFFER_SIZE (data) & 1);
+  if (datasize & 1) {
+    pad_bytes = 2 - (datasize & 1);
   }
-  header = gst_avi_mux_riff_get_header (avipad, GST_BUFFER_SIZE (data));
-  total_size = GST_BUFFER_SIZE (header) + GST_BUFFER_SIZE (data) + pad_bytes;
+  header = gst_avi_mux_riff_get_header (avipad, datasize);
+  total_size = gst_buffer_get_size (header) + datasize + pad_bytes;
 
   if (avimux->is_bigfile) {
     avimux->datax_size += total_size;
@@ -1971,8 +2004,8 @@
     avipad->hook (avimux, avipad, data);
 
   /* the suggested buffer size is the max frame size */
-  if (avipad->hdr.bufsize < GST_BUFFER_SIZE (data))
-    avipad->hdr.bufsize = GST_BUFFER_SIZE (data);
+  if (avipad->hdr.bufsize < datasize)
+    avipad->hdr.bufsize = datasize;
 
   if (avipad->is_video) {
     avimux->total_frames++;
@@ -1990,15 +2023,15 @@
     GstAviAudioPad *audpad = (GstAviAudioPad *) avipad;
 
     flags = 0;
-    audpad->audio_size += GST_BUFFER_SIZE (data);
+    audpad->audio_size += datasize;
     audpad->audio_time += GST_BUFFER_DURATION (data);
   }
 
-  gst_avi_mux_add_index (avimux, avipad, flags, GST_BUFFER_SIZE (data));
+  gst_avi_mux_add_index (avimux, avipad, flags, datasize);
 
   /* prepare buffers for sending */
   gst_buffer_set_caps (header, GST_PAD_CAPS (avimux->srcpad));
-  data = gst_buffer_make_metadata_writable (data);
+  data = gst_buffer_make_writable (data);
   gst_buffer_set_caps (data, GST_PAD_CAPS (avimux->srcpad));
 
   GST_LOG_OBJECT (avimux, "pushing buffers: head, data");
diff --git a/gst/avi/gstavisubtitle.c b/gst/avi/gstavisubtitle.c
index 10c4faf..8c01b9d 100644
--- a/gst/avi/gstavisubtitle.c
+++ b/gst/avi/gstavisubtitle.c
@@ -96,13 +96,17 @@
 {
   const gchar *input_enc = NULL;
   GstBuffer *ret = NULL;
-  gchar *data;
+  gchar *data, *bdata;
+  gsize bsize;
 
-  data = (gchar *) GST_BUFFER_DATA (buffer) + offset;
+  bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
+  data = bdata + offset;
 
   if (len >= (3 + 1) && IS_BOM_UTF8 (data) &&
       g_utf8_validate (data + 3, len - 3, NULL)) {
-    ret = gst_buffer_create_sub (buffer, offset + 3, len - 3);
+    ret =
+        gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset + 3,
+        len - 3);
   } else if (len >= 2 && IS_BOM_UTF16_BE (data)) {
     input_enc = "UTF-16BE";
     data += 2;
@@ -121,11 +125,12 @@
     len -= 4;
   } else if (g_utf8_validate (data, len, NULL)) {
     /* not specified, check if it's UTF-8 */
-    ret = gst_buffer_create_sub (buffer, offset, len);
+    ret = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, len);
   } else {
     /* we could fall back to gst_tag_freeform_to_utf8() here */
     GST_WARNING_OBJECT (sub, "unspecified encoding, and not UTF-8");
-    return NULL;
+    ret = NULL;
+    goto done;
   }
 
   g_return_val_if_fail (ret != NULL || input_enc != NULL, NULL);
@@ -133,6 +138,7 @@
   if (input_enc) {
     GError *err = NULL;
     gchar *utf8;
+    gsize slen;
 
     GST_DEBUG_OBJECT (sub, "converting subtitles from %s to UTF-8", input_enc);
     utf8 = g_convert (data, len, "UTF-8", input_enc, NULL, NULL, &err);
@@ -140,17 +146,22 @@
     if (err != NULL) {
       GST_WARNING_OBJECT (sub, "conversion to UTF-8 failed : %s", err->message);
       g_error_free (err);
-      return NULL;
+      ret = NULL;
+      goto done;
     }
 
     ret = gst_buffer_new ();
-    GST_BUFFER_DATA (ret) = (guint8 *) utf8;
-    GST_BUFFER_MALLOCDATA (ret) = (guint8 *) utf8;
-    GST_BUFFER_SIZE (ret) = strlen (utf8);
+    slen = strlen (utf8);
+    gst_buffer_take_memory (ret,
+        gst_memory_new_wrapped (0, utf8, g_free, slen, 0, slen));
+
     GST_BUFFER_OFFSET (ret) = 0;
   }
-
   GST_BUFFER_CAPS (ret) = gst_caps_new_simple ("application/x-subtitle", NULL);
+
+done:
+  gst_buffer_unmap (buffer, bdata, bsize);
+
   return ret;
 }
 
@@ -175,14 +186,13 @@
 static GstFlowReturn
 gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
 {
-  const guint8 *data;
+  guint8 *data;
   gchar *name_utf8;
   guint name_length;
   guint file_length;
-  guint size;
+  gsize size;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
 
   /* check the magic word "GAB2\0", and the next word must be 2 */
   if (size < 12 || memcmp (data, "GAB2\0\2\0", 5 + 2) != 0)
@@ -222,18 +232,22 @@
   if (sub->subfile == NULL)
     goto extract_failed;
 
+  gst_buffer_unmap (buf, data, size);
+
   return GST_FLOW_OK;
 
   /* ERRORS */
 wrong_magic_word:
   {
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL), ("Wrong magic word"));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 wrong_name_length:
   {
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("name doesn't fit in buffer (%d < %d)", size, 17 + name_length));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 wrong_fixed_word_2:
@@ -241,6 +255,7 @@
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("wrong fixed word: expected %u, got %u", 4,
             GST_READ_UINT16_LE (data + 11 + name_length)));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 wrong_total_length:
@@ -248,12 +263,14 @@
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("buffer size is wrong: need %d bytes, have %d bytes",
             17 + name_length + file_length, size));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 extract_failed:
   {
     GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
         ("could not extract subtitles"));
+    gst_buffer_unmap (buf, data, size);
     return GST_FLOW_ERROR;
   }
 }
diff --git a/gst/debugutils/efence.c b/gst/debugutils/efence.c
index fa64326..7019352 100644
--- a/gst/debugutils/efence.c
+++ b/gst/debugutils/efence.c
@@ -84,26 +84,41 @@
 
 static GstElementClass *parent_class = NULL;
 
-typedef struct _GstFencedBuffer GstFencedBuffer;
-struct _GstFencedBuffer
+typedef struct _GstMetaFenced
 {
-  GstBuffer buffer;
+  GstMeta meta;
+
   void *region;
   unsigned int length;
-};
+} GstMetaFenced;
 
-GType gst_fenced_buffer_get_type (void);
-static void gst_fenced_buffer_finalize (GstFencedBuffer * buf);
-static GstFencedBuffer *gst_fenced_buffer_copy (const GstBuffer * buffer);
+static const GstMetaInfo *
+gst_meta_fenced_get_info (void)
+{
+  static const GstMetaInfo *meta_fenced_info = NULL;
+
+  if (meta_fenced_info == NULL) {
+    meta_fenced_info = gst_meta_register ("GstMetaFenced", "GstMetaFenced",
+        sizeof (GstMetaFenced),
+        (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL,
+        (GstMetaTransformFunction) NULL,
+        (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+  }
+  return meta_fenced_info;
+}
+
+#define GST_META_FENCED_GET(buf) ((GstMetaFenced *)gst_buffer_get_meta(buf,gst_meta_fenced_get_info()))
+#define GST_META_FENCED_ADD(buf) ((GstMetaFenced *)gst_buffer_add_meta(buf,gst_meta_fenced_get_info(),NULL))
+
+static void gst_fenced_buffer_dispose (GstBuffer * buf);
+static GstBuffer *gst_fenced_buffer_copy (const GstBuffer * buffer);
 static void *gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
     gboolean fence_top);
+#if 0
 static GstFlowReturn gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
     guint size, GstCaps * caps, GstBuffer ** buf);
-
-#define GST_TYPE_FENCED_BUFFER (gst_fenced_buffer_get_type())
-
-#define GST_IS_FENCED_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FENCED_BUFFER))
-#define GST_FENCED_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FENCED_BUFFER, GstFencedBuffer))
+#endif
 
 GType
 gst_gst_efence_get_type (void)
@@ -182,8 +197,10 @@
       GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
   gst_pad_set_chain_function (filter->sinkpad,
       GST_DEBUG_FUNCPTR (gst_efence_chain));
+#if 0
   gst_pad_set_bufferalloc_function (filter->sinkpad,
       GST_DEBUG_FUNCPTR (gst_efence_buffer_alloc));
+#endif
   gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
 
   filter->srcpad =
@@ -217,11 +234,13 @@
   efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
   g_return_val_if_fail (GST_IS_EFENCE (efence), GST_FLOW_ERROR);
 
+#if 0
   if (GST_IS_FENCED_BUFFER (buffer)) {
     GST_DEBUG_OBJECT (efence, "Passing on existing fenced buffer with caps %"
         GST_PTR_FORMAT, GST_BUFFER_CAPS (buffer));
     return gst_pad_push (efence->srcpad, buffer);
   }
+#endif
 
   copy = (GstBuffer *) gst_fenced_buffer_copy (buffer);
 
@@ -277,6 +296,7 @@
   return gst_pad_activate_pull (efence->sinkpad, active);
 }
 
+#if 0
 static GstFlowReturn
 gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
     guint size, GstCaps * caps, GstBuffer ** buf)
@@ -306,6 +326,7 @@
 
   return GST_FLOW_OK;
 }
+#endif
 
 static void
 gst_efence_set_property (GObject * object, guint prop_id,
@@ -374,29 +395,23 @@
     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
 
 
-static GstBufferClass *fenced_buffer_parent_class = NULL;
-
 static void
-gst_fenced_buffer_finalize (GstFencedBuffer * buffer)
+gst_fenced_buffer_dispose (GstBuffer * buffer)
 {
-  GstFencedBuffer *fenced_buffer;
+  GstMetaFenced *meta;
+
+  meta = GST_META_FENCED_GET (buffer);
 
   GST_DEBUG ("free buffer=%p", buffer);
 
-  fenced_buffer = GST_FENCED_BUFFER (buffer);
-
   /* free our data */
   if (GST_BUFFER_DATA (buffer)) {
-    GST_DEBUG ("free region %p %d", fenced_buffer->region,
-        fenced_buffer->length);
-    munmap (fenced_buffer->region, fenced_buffer->length);
+    GST_DEBUG ("free region %p %d", meta->region, meta->length);
+    munmap (meta->region, meta->length);
   }
-
-  GST_MINI_OBJECT_CLASS (fenced_buffer_parent_class)->finalize (GST_MINI_OBJECT
-      (buffer));
 }
 
-static GstFencedBuffer *
+static GstBuffer *
 gst_fenced_buffer_copy (const GstBuffer * buffer)
 {
   GstBuffer *copy;
@@ -406,11 +421,10 @@
   g_return_val_if_fail (buffer != NULL, NULL);
 
   /* create a fresh new buffer */
-  copy = (GstBuffer *) gst_mini_object_new (GST_TYPE_FENCED_BUFFER);
+  copy = gst_buffer_new ();
 
   /* we simply copy everything from our parent */
-  ptr = gst_fenced_buffer_alloc (GST_BUFFER (copy),
-      GST_BUFFER_SIZE (buffer), TRUE);
+  ptr = gst_fenced_buffer_alloc (copy, GST_BUFFER_SIZE (buffer), TRUE);
   memcpy (ptr, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
 
   /* copy relevant flags */
@@ -434,7 +448,7 @@
       ", caps: %" GST_PTR_FORMAT, buffer,
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (copy)), GST_BUFFER_CAPS (copy));
 
-  return GST_FENCED_BUFFER (copy);
+  return copy;
 }
 
 void *
@@ -443,7 +457,7 @@
 {
   int alloc_size;
   void *region;
-  GstFencedBuffer *fenced_buffer = (GstFencedBuffer *) buffer;
+  GstMetaFenced *meta;
   int page_size;
 
   GST_DEBUG ("buffer=%p length=%d fence_top=%d", buffer, length, fence_top);
@@ -467,21 +481,29 @@
     g_warning ("mmap failed");
     return NULL;
   }
+
+  GST_MINI_OBJECT_CAST (buffer)->dispose =
+      (GstMiniObjectDisposeFunction) gst_fenced_buffer_dispose;
+  GST_MINI_OBJECT_CAST (buffer)->copy =
+      (GstMiniObjectCopyFunction) gst_fenced_buffer_copy;
+
+  meta = GST_META_FENCED_ADD (buffer);
+
 #if 0
   munmap (region, page_size);
   munmap (region + alloc_size - page_size, page_size);
 
-  fenced_buffer->region = region + page_size;
-  fenced_buffer->length = alloc_size - page_size;
+  meta->region = region + page_size;
+  meta->length = alloc_size - page_size;
 #else
   mprotect (region, page_size, PROT_NONE);
   mprotect ((char *) region + alloc_size - page_size, page_size, PROT_NONE);
 
-  fenced_buffer->region = region;
-  fenced_buffer->length = alloc_size;
+  meta->region = region;
+  meta->length = alloc_size;
 #endif
 
-  GST_DEBUG ("new region %p %d", fenced_buffer->region, fenced_buffer->length);
+  GST_DEBUG ("new region %p %d", meta->region, meta->length);
 
   if (fence_top) {
     int offset;
@@ -494,39 +516,3 @@
     return (void *) ((char *) region + page_size);
   }
 }
-
-static void
-gst_fenced_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  fenced_buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize =
-      (GstMiniObjectFinalizeFunction) gst_fenced_buffer_finalize;
-  mini_object_class->copy = (GstMiniObjectCopyFunction) gst_fenced_buffer_copy;
-}
-
-GType
-gst_fenced_buffer_get_type (void)
-{
-  static GType fenced_buf_type = 0;
-
-  if (G_UNLIKELY (!fenced_buf_type)) {
-    static const GTypeInfo fenced_buf_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_fenced_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstFencedBuffer),
-      0,
-      NULL,
-    };
-
-    fenced_buf_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstFencedBuffer", &fenced_buf_info, 0);
-  }
-  return fenced_buf_type;
-}
diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c
index fae7e41..20ef175 100644
--- a/gst/flv/gstflvdemux.c
+++ b/gst/flv/gstflvdemux.c
@@ -118,11 +118,11 @@
     gboolean key;
 
     gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &time);
-    key = ! !(GST_INDEX_ASSOC_FLAGS (entry) & GST_ASSOCIATION_FLAG_KEY_UNIT);
+    key = !!(GST_INDEX_ASSOC_FLAGS (entry) & GST_ASSOCIATION_FLAG_KEY_UNIT);
     GST_LOG_OBJECT (demux, "position already mapped to time %" GST_TIME_FORMAT
         ", keyframe %d", GST_TIME_ARGS (time), key);
     /* there is not really a way to delete the existing one */
-    if (time != ts || key != ! !keyframe)
+    if (time != ts || key != !!keyframe)
       GST_DEBUG_OBJECT (demux, "metadata mismatch");
 #endif
     return;
@@ -2452,7 +2452,7 @@
   if (format != GST_FORMAT_TIME)
     goto wrong_format;
 
-  flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
+  flush = !!(flags & GST_SEEK_FLAG_FLUSH);
   /* FIXME : the keyframe flag is never used ! */
 
   /* Work on a copy until we are sure the seek succeeded. */
@@ -2617,7 +2617,7 @@
     demux->seeking = seeking;
   GST_OBJECT_UNLOCK (demux);
 
-  flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
+  flush = !!(flags & GST_SEEK_FLAG_FLUSH);
   /* FIXME : the keyframe flag is never used */
 
   if (flush) {
diff --git a/gst/imagefreeze/gstimagefreeze.c b/gst/imagefreeze/gstimagefreeze.c
index 080d275..3e122ad 100644
--- a/gst/imagefreeze/gstimagefreeze.c
+++ b/gst/imagefreeze/gstimagefreeze.c
@@ -608,7 +608,7 @@
           &stop_type, &stop);
       gst_event_unref (event);
 
-      flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
+      flush = !!(flags & GST_SEEK_FLAG_FLUSH);
 
       if (format != GST_FORMAT_TIME && format != GST_FORMAT_DEFAULT) {
         GST_ERROR_OBJECT (pad, "Seek in invalid format: %s",
diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 4d334b6..ba4ceb2 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -2686,8 +2686,8 @@
         entry->pos + demux->ebml_segment_start);
   }
 
-  flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
-  keyunit = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
+  flush = !!(flags & GST_SEEK_FLAG_FLUSH);
+  keyunit = !!(flags & GST_SEEK_FLAG_KEY_UNIT);
 
   if (flush) {
     GST_DEBUG_OBJECT (demux, "Starting flush");
diff --git a/gst/quicktime/qtdemux.c b/gst/quicktime/qtdemux.c
index 5f6b077..320d380 100644
--- a/gst/quicktime/qtdemux.c
+++ b/gst/quicktime/qtdemux.c
@@ -5229,7 +5229,7 @@
   /* sync sample atom */
   stream->stps_present = FALSE;
   if ((stream->stss_present =
-          ! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stss,
+          !!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stss,
               &stream->stss) ? TRUE : FALSE) == TRUE) {
     /* copy atom data into a new buffer for later use */
     stream->stss.data = g_memdup (stream->stss.data, stream->stss.size);
@@ -5247,7 +5247,7 @@
 
     /* partial sync sample atom */
     if ((stream->stps_present =
-            ! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stps,
+            !!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stps,
                 &stream->stps) ? TRUE : FALSE) == TRUE) {
       /* copy atom data into a new buffer for later use */
       stream->stps.data = g_memdup (stream->stps.data, stream->stps.size);
@@ -5366,7 +5366,7 @@
 
   /* composition time-to-sample */
   if ((stream->ctts_present =
-          ! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_ctts,
+          !!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_ctts,
               &stream->ctts) ? TRUE : FALSE) == TRUE) {
     /* copy atom data into a new buffer for later use */
     stream->ctts.data = g_memdup (stream->ctts.data, stream->ctts.size);
diff --git a/gst/replaygain/Makefile.am b/gst/replaygain/Makefile.am
index 90e84fe..0153e9f 100644
--- a/gst/replaygain/Makefile.am
+++ b/gst/replaygain/Makefile.am
@@ -9,7 +9,7 @@
 libgstreplaygain_la_CFLAGS  = \
 	$(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
 libgstreplaygain_la_LIBADD  = \
-	$(GST_PLUGINS_BASE_LIBS) -lgstpbutils-0.10 \
+	$(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_MAJORMINOR) \
 	$(GST_BASE_LIBS) $(GST_LIBS) $(LIBM)
 libgstreplaygain_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstreplaygain_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/rtp/gstrtpac3depay.c b/gst/rtp/gstrtpac3depay.c
index 2ba4cef..ba622ff 100644
--- a/gst/rtp/gstrtpac3depay.c
+++ b/gst/rtp/gstrtpac3depay.c
@@ -165,47 +165,48 @@
 {
   GstRtpAC3Depay *rtpac3depay;
   GstBuffer *outbuf;
+  GstRTPBuffer rtp = { NULL, };
+  guint8 *payload;
+  guint16 FT, NF;
 
   rtpac3depay = GST_RTP_AC3_DEPAY (depayload);
 
-  {
-    guint8 *payload;
-    guint16 FT, NF;
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-    if (gst_rtp_buffer_get_payload_len (buf) < 2)
-      goto empty_packet;
+  if (gst_rtp_buffer_get_payload_len (&rtp) < 2)
+    goto empty_packet;
 
-    payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
-    /* strip off header
-     *
-     *  0                   1
-     *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     * |    MBZ    | FT|       NF      |
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     */
-    FT = payload[0] & 0x3;
-    NF = payload[1];
+  /* strip off header
+   *
+   *  0                   1
+   *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   * |    MBZ    | FT|       NF      |
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   */
+  FT = payload[0] & 0x3;
+  NF = payload[1];
 
-    GST_DEBUG_OBJECT (rtpac3depay, "FT: %d, NF: %d", FT, NF);
+  GST_DEBUG_OBJECT (rtpac3depay, "FT: %d, NF: %d", FT, NF);
 
-    /* We don't bother with fragmented packets yet */
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 2, -1);
+  /* We don't bother with fragmented packets yet */
+  outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 2, -1);
 
-    GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %d",
-        GST_BUFFER_SIZE (outbuf));
+  gst_rtp_buffer_unmap (&rtp);
 
-    return outbuf;
-  }
+  GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %d",
+      gst_buffer_get_size (outbuf));
 
-  return NULL;
+  return outbuf;
 
   /* ERRORS */
 empty_packet:
   {
     GST_ELEMENT_WARNING (rtpac3depay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }
diff --git a/gst/rtp/gstrtpac3pay.c b/gst/rtp/gstrtpac3pay.c
index fddea38..f474a8c 100644
--- a/gst/rtp/gstrtpac3pay.c
+++ b/gst/rtp/gstrtpac3pay.c
@@ -247,6 +247,7 @@
     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 (2 + avail, 0, 0);
@@ -294,8 +295,9 @@
      *     3: other fragment
      * NF: amount of frames if FT = 0, else number of fragments.
      */
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
     GST_LOG_OBJECT (rtpac3pay, "FT %u, NF %u", FT, NF);
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
     payload[0] = (FT & 3);
     payload[1] = NF;
     payload_len -= 2;
@@ -305,7 +307,8 @@
 
     avail -= 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) = rtpac3pay->first_ts;
     GST_BUFFER_DURATION (outbuf) = rtpac3pay->duration;
@@ -322,15 +325,14 @@
 {
   GstRtpAC3Pay *rtpac3pay;
   GstFlowReturn ret;
-  guint size, avail, left, NF;
+  gsize size, avail, left, NF;
   guint8 *data, *p;
   guint packet_len;
   GstClockTime duration, timestamp;
 
   rtpac3pay = GST_RTP_AC3_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   duration = GST_BUFFER_DURATION (buffer);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
@@ -374,6 +376,7 @@
     p += frame_size;
     left -= frame_size;
   }
+  gst_buffer_unmap (buffer, data, size);
   if (NF == 0)
     goto no_frames;
 
diff --git a/gst/rtp/gstrtpbvdepay.c b/gst/rtp/gstrtpbvdepay.c
index 3ee660a..7133f8e 100644
--- a/gst/rtp/gstrtpbvdepay.c
+++ b/gst/rtp/gstrtpbvdepay.c
@@ -156,14 +156,18 @@
 {
   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 (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     /* mark start of talkspurt with DISCONT */
diff --git a/gst/rtp/gstrtpceltdepay.c b/gst/rtp/gstrtpceltdepay.c
index c03a5b4..e1fc4c5 100644
--- a/gst/rtp/gstrtpceltdepay.c
+++ b/gst/rtp/gstrtpceltdepay.c
@@ -122,7 +122,8 @@
   GstRtpCELTDepay *rtpceltdepay;
   gint clock_rate, nb_channels = 0, frame_size = 0;
   GstBuffer *buf;
-  guint8 *data;
+  guint8 *data, *ptr;
+  gsize size;
   const gchar *params;
   GstCaps *srccaps;
   gboolean res;
@@ -151,26 +152,27 @@
 
   /* construct minimal header and comment packet for the decoder */
   buf = gst_buffer_new_and_alloc (60);
-  data = GST_BUFFER_DATA (buf);
-  memcpy (data, "CELT    ", 8);
-  data += 8;
-  memcpy (data, "1.1.12", 7);
-  data += 20;
-  GST_WRITE_UINT32_LE (data, 0x80000006);       /* version */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, 56);       /* header_size */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, clock_rate);       /* rate */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, nb_channels);      /* channels */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, frame_size);       /* frame-size */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, -1);       /* overlap */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, -1);       /* bytes_per_packet */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, 0);        /* extra headers */
+  ptr = data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
+  memcpy (ptr, "CELT    ", 8);
+  ptr += 8;
+  memcpy (ptr, "1.1.12", 7);
+  ptr += 20;
+  GST_WRITE_UINT32_LE (ptr, 0x80000006);        /* version */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, 56);        /* header_size */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, clock_rate);        /* rate */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, nb_channels);       /* channels */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, frame_size);        /* frame-size */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, -1);        /* overlap */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, -1);        /* bytes_per_packet */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, 0); /* extra headers */
+  gst_buffer_unmap (buf, data, size);
 
   srccaps = gst_caps_new_simple ("audio/x-celt", NULL);
   res = gst_pad_set_caps (depayload->srcpad, srccaps);
@@ -180,8 +182,7 @@
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpceltdepay), buf);
 
   buf = gst_buffer_new_and_alloc (sizeof (gst_rtp_celt_comment));
-  memcpy (GST_BUFFER_DATA (buf), gst_rtp_celt_comment,
-      sizeof (gst_rtp_celt_comment));
+  gst_buffer_fill (buf, 0, gst_rtp_celt_comment, sizeof (gst_rtp_celt_comment));
 
   gst_buffer_set_caps (buf, GST_PAD_CAPS (depayload->srcpad));
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpceltdepay), buf);
@@ -207,6 +208,7 @@
   GstClockTime framesize_ns = 0, timestamp;
   guint n = 0;
   GstRtpCELTDepay *rtpceltdepay;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpceltdepay = GST_RTP_CELT_DEPAY (depayload);
   clock_rate = depayload->clock_rate;
@@ -215,17 +217,19 @@
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
   GST_LOG_OBJECT (depayload, "got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf),
-      gst_rtp_buffer_get_marker (buf),
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf),
+      gst_rtp_buffer_get_marker (&rtp),
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
   GST_LOG_OBJECT (depayload, "got clock-rate=%d, frame_size=%d, "
       "_ns=%" GST_TIME_FORMAT ", timestamp=%" GST_TIME_FORMAT, clock_rate,
       frame_size, GST_TIME_ARGS (framesize_ns), GST_TIME_ARGS (timestamp));
 
-  payload = gst_rtp_buffer_get_payload (buf);
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   /* first count how many bytes are consumed by the size headers and make offset
    * point to the first data byte */
@@ -250,7 +254,7 @@
       total_size += size + 1;
     } while (s == 0xff);
 
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, offset, size);
+    outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, offset, size);
     offset += size;
 
     if (frame_size != -1 && clock_rate != -1) {
@@ -264,6 +268,8 @@
 
     gst_base_rtp_depayload_push (depayload, outbuf);
   }
+  gst_rtp_buffer_unmap (&rtp);
+
   return NULL;
 }
 
diff --git a/gst/rtp/gstrtpceltpay.c b/gst/rtp/gstrtpceltpay.c
index 05715c1..5d32be9 100644
--- a/gst/rtp/gstrtpceltpay.c
+++ b/gst/rtp/gstrtpceltpay.c
@@ -310,6 +310,7 @@
   guint8 *payload, *spayload;
   guint payload_len;
   GstClockTime duration;
+  GstRTPBuffer rtp = { NULL, };
 
   payload_len = rtpceltpay->bytes + rtpceltpay->sbytes;
   duration = rtpceltpay->qduration;
@@ -322,8 +323,10 @@
 
   GST_BUFFER_DURATION (outbuf) = duration;
 
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
   /* point to the payload for size headers and data */
-  spayload = gst_rtp_buffer_get_payload (outbuf);
+  spayload = gst_rtp_buffer_get_payload (&rtp);
   payload = spayload + rtpceltpay->sbytes;
 
   while ((buf = g_queue_pop_head (rtpceltpay->queue))) {
@@ -334,20 +337,21 @@
       GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
 
     /* write the size to the header */
-    size = GST_BUFFER_SIZE (buf);
+    size = gst_buffer_get_size (buf);
     while (size > 0xff) {
       *spayload++ = 0xff;
       size -= 0xff;
     }
     *spayload++ = size;
 
-    size = GST_BUFFER_SIZE (buf);
     /* copy payload */
-    memcpy (payload, GST_BUFFER_DATA (buf), size);
+    size = gst_buffer_get_size (buf);
+    gst_buffer_extract (buf, 0, payload, size);
     payload += size;
 
     gst_buffer_unref (buf);
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   /* we consumed it all */
   rtpceltpay->bytes = 0;
@@ -365,7 +369,7 @@
 {
   GstFlowReturn ret;
   GstRtpCELTPay *rtpceltpay;
-  guint size, payload_len;
+  gsize size, payload_len;
   guint8 *data;
   GstClockTime duration, packet_dur;
   guint i, ssize, packet_len;
@@ -374,8 +378,7 @@
 
   ret = GST_FLOW_OK;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   switch (rtpceltpay->packet) {
     case 0:
@@ -384,14 +387,15 @@
       if (!gst_rtp_celt_pay_parse_ident (rtpceltpay, data, size))
         goto parse_error;
 
-      goto done;
+      goto cleanup;
     case 1:
       /* comment packet, we ignore it */
-      goto done;
+      goto cleanup;
     default:
       /* other packets go in the payload */
       break;
   }
+  gst_buffer_unmap (buffer, data, size);
 
   duration = GST_BUFFER_DURATION (buffer);
 
@@ -429,10 +433,16 @@
   return ret;
 
   /* ERRORS */
+cleanup:
+  {
+    gst_buffer_unmap (buffer, data, size);
+    goto done;
+  }
 parse_error:
   {
     GST_ELEMENT_ERROR (rtpceltpay, STREAM, DECODE, (NULL),
         ("Error parsing first identification packet."));
+    gst_buffer_unmap (buffer, data, size);
     return GST_FLOW_ERROR;
   }
 }
diff --git a/gst/rtp/gstrtpdvdepay.c b/gst/rtp/gstrtpdvdepay.c
index 883d115..25ebc1a 100644
--- a/gst/rtp/gstrtpdvdepay.c
+++ b/gst/rtp/gstrtpdvdepay.c
@@ -172,6 +172,8 @@
   gint clock_rate;
   gboolean systemstream, ret;
   const gchar *encode, *media;
+  guint8 *data;
+  gsize size;
 
   rtpdvdepay = GST_RTP_DV_DEPAY (depayload);
 
@@ -216,7 +218,9 @@
   /* 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. */
-  memset (GST_BUFFER_DATA (rtpdvdepay->acc), 0, rtpdvdepay->frame_size);
+  data = gst_buffer_map (rtpdvdepay->acc, &size, NULL, GST_MAP_WRITE);
+  memset (data, 0, rtpdvdepay->frame_size);
+  gst_buffer_unmap (rtpdvdepay->acc, data, size);
 
   srccaps = gst_caps_new_simple ("video/x-dv",
       "systemstream", G_TYPE_BOOLEAN, systemstream,
@@ -300,12 +304,15 @@
   guint payload_len, location;
   GstRTPDVDepay *dvdepay = GST_RTP_DV_DEPAY (base);
   gboolean marker;
+  GstRTPBuffer rtp = { NULL, };
 
-  marker = gst_rtp_buffer_get_marker (in);
+  gst_rtp_buffer_map (in, GST_MAP_READ, &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 (in);
+  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 */
@@ -319,8 +326,8 @@
   }
 
   /* Extract the payload */
-  payload_len = gst_rtp_buffer_get_payload_len (in);
-  payload = gst_rtp_buffer_get_payload (in);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /* copy all DIF chunks in their place. */
   while (payload_len >= 80) {
@@ -343,11 +350,12 @@
 
     /* And copy it in, provided the location is sane. */
     if (offset >= 0 && offset <= dvdepay->frame_size - 80)
-      memcpy (GST_BUFFER_DATA (dvdepay->acc) + offset, payload, 80);
+      gst_buffer_fill (dvdepay->acc, offset, payload, 80);
 
     payload += 80;
     payload_len -= 80;
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     GST_DEBUG_OBJECT (dvdepay, "marker bit complete frame %u", rtp_ts);
diff --git a/gst/rtp/gstrtpdvpay.c b/gst/rtp/gstrtpdvpay.c
index 1d6230c..bd87d70 100644
--- a/gst/rtp/gstrtpdvpay.c
+++ b/gst/rtp/gstrtpdvpay.c
@@ -183,7 +183,7 @@
 }
 
 static gboolean
-gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, guint size)
+gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, gsize size)
 {
   const gchar *encode, *media;
   gboolean audio_bundled, res;
@@ -284,10 +284,11 @@
   GstBuffer *outbuf;
   GstFlowReturn ret = GST_FLOW_OK;
   gint hdrlen;
-  guint size;
-  guint8 *data;
+  gsize size, osize;
+  guint8 *data, *odata;
   guint8 *dest;
   guint filled;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpdvpay = GST_RTP_DV_PAY (basepayload);
 
@@ -300,8 +301,10 @@
   max_payload_size = ((GST_BASE_RTP_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
 
   /* The length of the buffer to transmit. */
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  odata = data;
+  osize = size;
 
   GST_DEBUG_OBJECT (rtpdvpay,
       "DV RTP payloader got buffer of %u bytes, splitting in %u byte "
@@ -324,7 +327,9 @@
     if (outbuf == NULL) {
       outbuf = gst_rtp_buffer_new_allocate (max_payload_size, 0, 0);
       GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
-      dest = gst_rtp_buffer_get_payload (outbuf);
+
+      gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+      dest = gst_rtp_buffer_get_payload (&rtp);
       filled = 0;
     }
 
@@ -348,13 +353,15 @@
         guint hlen;
 
         /* set marker */
-        gst_rtp_buffer_set_marker (outbuf, TRUE);
+        gst_rtp_buffer_set_marker (&rtp, TRUE);
 
         /* shrink buffer to last packet */
-        hlen = gst_rtp_buffer_get_header_len (outbuf);
-        gst_rtp_buffer_set_packet_len (outbuf, hlen + filled);
+        hlen = gst_rtp_buffer_get_header_len (&rtp);
+        gst_rtp_buffer_set_packet_len (&rtp, hlen + filled);
       }
+
       /* Push out the created piece, and check for errors. */
+      gst_rtp_buffer_unmap (&rtp);
       ret = gst_basertppayload_push (basepayload, outbuf);
       if (ret != GST_FLOW_OK)
         break;
@@ -362,6 +369,7 @@
       outbuf = NULL;
     }
   }
+  gst_buffer_unmap (buffer, odata, osize);
   gst_buffer_unref (buffer);
 
   return ret;
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 @@
   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_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 @@
    */
 
   /* 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 @@
     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 @@
 
       /* 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 @@
   {
     GST_ELEMENT_WARNING (rtpgstdepay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 too_small:
@@ -310,6 +321,7 @@
         ("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 %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 @@
     GstBuffer * buffer)
 {
   GstRtpGSTPay *rtpgstpay;
-  guint8 *data;
-  guint size;
+  guint8 *data, *ptr;
+  gsize size, left;
   GstBuffer *outbuf;
   GstFlowReturn ret;
   GstClockTime timestamp;
@@ -141,8 +141,7 @@
 
   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 @@
    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    */
   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 @@
 
     /* 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 @@
     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 @@
 {
   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 (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+
+  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 @@
 {
   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;
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-    payload_len = gst_rtp_buffer_get_payload_len (buf);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
-    if (payload_len <= 4)
-      goto empty_packet;
+  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]; */
+#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 (buf, 4, -1);
-    marker = gst_rtp_buffer_get_marker (buf);
+  /* 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_SIZE (outbuf));
-
-    /* FIXME, we can push half mpeg frames when they are split over multiple
-     * RTP packets */
-    return outbuf;
+  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));
 
-  return NULL;
+  gst_rtp_buffer_unmap (&rtp);
+
+  /* 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 @@
     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 @@
     /* 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 @@
      * |             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 @@
     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 @@
 
   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);
 
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index e547352..13b15f4 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -1669,6 +1669,8 @@
     gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
     GstClockTime running_time, guint64 ntpnstime)
 {
+  GstMetaNetAddress *meta;
+
   /* get time of arrival */
   arrival->current_time = current_time;
   arrival->running_time = running_time;
@@ -1684,11 +1686,12 @@
   }
 
   /* for netbuffer we can store the IP address to check for collisions */
-  arrival->have_address = GST_IS_NETBUFFER (buffer);
-  if (arrival->have_address) {
-    GstNetBuffer *netbuf = (GstNetBuffer *) buffer;
-
-    memcpy (&arrival->address, &netbuf->from, sizeof (GstNetAddress));
+  meta = gst_buffer_get_meta_net_address (buffer);
+  if (meta) {
+    arrival->have_address = TRUE;
+    memcpy (&arrival->address, &meta->naddr, sizeof (GstNetAddress));
+  } else {
+    arrival->have_address = FALSE;
   }
 }
 
diff --git a/gst/rtsp/gstrtpdec.c b/gst/rtsp/gstrtpdec.c
index cbd5836..f488538 100644
--- a/gst/rtsp/gstrtpdec.c
+++ b/gst/rtsp/gstrtpdec.c
@@ -464,6 +464,7 @@
   GstRTPDecSession *session;
   guint32 ssrc;
   guint8 pt;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpdec = GST_RTP_DEC (GST_PAD_PARENT (pad));
 
@@ -472,8 +473,11 @@
   if (!gst_rtp_buffer_validate (buffer))
     goto bad_packet;
 
-  ssrc = gst_rtp_buffer_get_ssrc (buffer);
-  pt = gst_rtp_buffer_get_payload_type (buffer);
+
+  gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
+  ssrc = gst_rtp_buffer_get_ssrc (&rtp);
+  pt = gst_rtp_buffer_get_payload_type (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   GST_DEBUG_OBJECT (rtpdec, "SSRC %08x, PT %d", ssrc, pt);
 
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index 8990d6f..4c6241e 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -1588,18 +1588,14 @@
 
   /* we keep these elements, we configure all in configure_transport when the
    * server told us to really use the UDP ports. */
-  stream->udpsrc[0] = gst_object_ref (udpsrc0);
-  stream->udpsrc[1] = gst_object_ref (udpsrc1);
+  stream->udpsrc[0] = gst_object_ref_sink (udpsrc0);
+  stream->udpsrc[1] = gst_object_ref_sink (udpsrc1);
 
   /* keep track of next available port number when we have a range
    * configured */
   if (src->next_port_num != 0)
     src->next_port_num = tmp_rtcp + 1;
 
-  /* they are ours now */
-  gst_object_sink (udpsrc0);
-  gst_object_sink (udpsrc1);
-
   return TRUE;
 
   /* ERRORS */
@@ -2120,6 +2116,7 @@
   GstFlowReturn res = GST_FLOW_OK;
   guint8 *data;
   guint size;
+  gsize bsize;
   GstRTSPResult ret;
   GstRTSPMessage message = { 0 };
   GstRTSPConnection *conn;
@@ -2127,8 +2124,8 @@
   stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
   src = stream->parent;
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
+  size = bsize;
 
   gst_rtsp_message_init_data (&message, stream->channel[1]);
 
@@ -2149,6 +2146,7 @@
   gst_rtsp_message_steal_body (&message, &data, &size);
   gst_rtsp_message_unset (&message);
 
+  gst_buffer_unmap (buffer, data, size);
   gst_buffer_unref (buffer);
 
   return res;
@@ -2706,8 +2704,7 @@
       goto no_element;
 
     /* take ownership */
-    gst_object_ref (stream->udpsrc[0]);
-    gst_object_sink (stream->udpsrc[0]);
+    gst_object_ref_sink (stream->udpsrc[0]);
 
     /* change state */
     gst_element_set_state (stream->udpsrc[0], GST_STATE_PAUSED);
@@ -2722,8 +2719,7 @@
       goto no_element;
 
     /* take ownership */
-    gst_object_ref (stream->udpsrc[1]);
-    gst_object_sink (stream->udpsrc[1]);
+    gst_object_ref_sink (stream->udpsrc[1]);
 
     gst_element_set_state (stream->udpsrc[1], GST_STATE_PAUSED);
   }
@@ -3621,9 +3617,8 @@
   size -= 1;
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = data;
-  GST_BUFFER_MALLOCDATA (buf) = data;
-  GST_BUFFER_SIZE (buf) = size;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, size, 0, size));
 
   /* don't need message anymore */
   gst_rtsp_message_unset (&message);
diff --git a/gst/udp/gstdynudpsink.c b/gst/udp/gstdynudpsink.c
index d7b5678..f56cd2c 100644
--- a/gst/udp/gstdynudpsink.c
+++ b/gst/udp/gstdynudpsink.c
@@ -209,31 +209,31 @@
 gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
 {
   GstDynUDPSink *sink;
-  gint ret, size;
+  gint ret;
+  gsize size;
   guint8 *data;
-  GstNetBuffer *netbuf;
+  GstMetaNetAddress *meta;
   struct sockaddr_in theiraddr;
   guint16 destport;
   guint32 destaddr;
 
   memset (&theiraddr, 0, sizeof (theiraddr));
 
-  if (GST_IS_NETBUFFER (buffer)) {
-    netbuf = GST_NETBUFFER (buffer);
-  } else {
+  meta = gst_buffer_get_meta_net_address (buffer);
+
+  if (meta == NULL) {
     GST_DEBUG ("Received buffer is not a GstNetBuffer, skipping");
     return GST_FLOW_OK;
   }
 
   sink = GST_DYNUDPSINK (bsink);
 
-  size = GST_BUFFER_SIZE (netbuf);
-  data = GST_BUFFER_DATA (netbuf);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   GST_DEBUG ("about to send %d bytes", size);
 
-  // let's get the address from the netbuffer
-  gst_netaddress_get_ip4_address (&netbuf->to, &destaddr, &destport);
+  /* let's get the address from the metaata */
+  gst_netaddress_get_ip4_address (&meta->naddr, &destaddr, &destport);
 
   GST_DEBUG ("sending %d bytes to client %d port %d", size, destaddr, destport);
 
@@ -247,6 +247,8 @@
 #endif
       (struct sockaddr *) &theiraddr, sizeof (theiraddr));
 
+  gst_buffer_unmap (buffer, data, size);
+
   if (ret < 0) {
     if (errno != EINTR && errno != EAGAIN) {
       goto send_error;
diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c
index bcdb6cd..2a677fc 100644
--- a/gst/udp/gstmultiudpsink.c
+++ b/gst/udp/gstmultiudpsink.c
@@ -120,10 +120,12 @@
 
 static GstFlowReturn gst_multiudpsink_render (GstBaseSink * sink,
     GstBuffer * buffer);
+#if 0
 #ifndef G_OS_WIN32              /* sendmsg() is not available on Windows */
 static GstFlowReturn gst_multiudpsink_render_list (GstBaseSink * bsink,
     GstBufferList * list);
 #endif
+#endif
 static GstStateChangeReturn gst_multiudpsink_change_state (GstElement *
     element, GstStateChange transition);
 
@@ -359,9 +361,11 @@
   gstelement_class->change_state = gst_multiudpsink_change_state;
 
   gstbasesink_class->render = gst_multiudpsink_render;
+#if 0
 #ifndef G_OS_WIN32
   gstbasesink_class->render_list = gst_multiudpsink_render_list;
 #endif
+#endif
   klass->add = gst_multiudpsink_add;
   klass->remove = gst_multiudpsink_remove;
   klass->clear = gst_multiudpsink_clear;
@@ -484,19 +488,21 @@
 #endif
 }
 
+#ifdef G_OS_WIN32
+/* version without sendmsg */
 static GstFlowReturn
 gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
 {
   GstMultiUDPSink *sink;
-  gint ret, size, num = 0, no_clients = 0;
+  gint ret, num = 0, no_clients = 0;
+  gsize size;
   guint8 *data;
   GList *clients;
   gint len;
 
   sink = GST_MULTIUDPSINK (bsink);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   if (size > UDP_MAX_SIZE) {
     GST_WARNING ("Attempting to send a UDP packet larger than maximum "
@@ -554,109 +560,129 @@
   }
   g_mutex_unlock (sink->client_lock);
 
+  gst_buffer_unmap (buffer, data, size);
+
   GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
       no_clients);
 
   return GST_FLOW_OK;
 }
-
-#ifndef G_OS_WIN32
+#else /* !G_OS_WIN32 */
+/* version with sendmsg */
 static GstFlowReturn
-gst_multiudpsink_render_list (GstBaseSink * bsink, GstBufferList * list)
+gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
 {
   GstMultiUDPSink *sink;
   GList *clients;
   gint ret, size = 0, num = 0, no_clients = 0;
   struct iovec *iov;
   struct msghdr msg = { 0 };
-
-  GstBufferListIterator *it;
-  guint gsize;
-  GstBuffer *buf;
+  guint n_mem, i;
+  gpointer bdata;
+  gsize bsize;
+  GstMemory *mem;
 
   sink = GST_MULTIUDPSINK (bsink);
 
-  g_return_val_if_fail (list != NULL, GST_FLOW_ERROR);
+  msg.msg_iovlen = 0;
+  size = 0;
 
-  it = gst_buffer_list_iterate (list);
-  g_return_val_if_fail (it != NULL, GST_FLOW_ERROR);
+  n_mem = gst_buffer_n_memory (buffer);
+  if (n_mem == 0)
+    goto no_data;
 
-  while (gst_buffer_list_iterator_next_group (it)) {
-    msg.msg_iovlen = 0;
-    size = 0;
+  iov = (struct iovec *) g_malloc (n_mem * sizeof (struct iovec));
+  msg.msg_iov = iov;
 
-    if ((gsize = gst_buffer_list_iterator_n_buffers (it)) == 0) {
-      goto invalid_list;
+  for (i = 0; i < n_mem; i++) {
+    mem = gst_buffer_peek_memory (buffer, i, GST_MAP_READ);
+    bdata = gst_memory_map (mem, &bsize, NULL, GST_MAP_READ);
+
+    if (bsize > UDP_MAX_SIZE) {
+      GST_WARNING ("Attempting to send a UDP packet larger than maximum "
+          "size (%d > %d)", bsize, UDP_MAX_SIZE);
     }
 
-    iov = (struct iovec *) g_malloc (gsize * sizeof (struct iovec));
-    msg.msg_iov = iov;
+    msg.msg_iov[msg.msg_iovlen].iov_len = bsize;
+    msg.msg_iov[msg.msg_iovlen].iov_base = bdata;
+    msg.msg_iovlen++;
 
-    while ((buf = gst_buffer_list_iterator_next (it))) {
-      if (GST_BUFFER_SIZE (buf) > UDP_MAX_SIZE) {
-        GST_WARNING ("Attempting to send a UDP packet larger than maximum "
-            "size (%d > %d)", GST_BUFFER_SIZE (buf), UDP_MAX_SIZE);
-      }
+    size += bsize;
+  }
 
-      msg.msg_iov[msg.msg_iovlen].iov_len = GST_BUFFER_SIZE (buf);
-      msg.msg_iov[msg.msg_iovlen].iov_base = GST_BUFFER_DATA (buf);
-      msg.msg_iovlen++;
-      size += GST_BUFFER_SIZE (buf);
-    }
+  sink->bytes_to_serve += size;
 
-    sink->bytes_to_serve += size;
+  /* grab lock while iterating and sending to clients, this should be
+   * fast as UDP never blocks */
+  g_mutex_lock (sink->client_lock);
+  GST_LOG_OBJECT (bsink, "about to send %d bytes", size);
 
-    /* grab lock while iterating and sending to clients, this should be
-     * fast as UDP never blocks */
-    g_mutex_lock (sink->client_lock);
-    GST_LOG_OBJECT (bsink, "about to send %d bytes", size);
+  for (clients = sink->clients; clients; clients = g_list_next (clients)) {
+    GstUDPClient *client;
+    gint count;
 
-    for (clients = sink->clients; clients; clients = g_list_next (clients)) {
-      GstUDPClient *client;
-      gint count;
+    client = (GstUDPClient *) clients->data;
+    no_clients++;
+    GST_LOG_OBJECT (sink, "sending %d bytes to client %p", size, client);
 
-      client = (GstUDPClient *) clients->data;
-      no_clients++;
-      GST_LOG_OBJECT (sink, "sending %d bytes to client %p", size, client);
+    count = sink->send_duplicates ? client->refcount : 1;
 
-      count = sink->send_duplicates ? client->refcount : 1;
+    while (count--) {
+      while (TRUE) {
+        msg.msg_name = (void *) &client->theiraddr;
+        msg.msg_namelen = sizeof (client->theiraddr);
+        ret = sendmsg (*client->sock, &msg, 0);
 
-      while (count--) {
-        while (TRUE) {
-          msg.msg_name = (void *) &client->theiraddr;
-          msg.msg_namelen = sizeof (client->theiraddr);
-          ret = sendmsg (*client->sock, &msg, 0);
-
-          if (ret < 0) {
-            if (!socket_error_is_ignorable ()) {
-              break;
-            }
-          } else {
-            num++;
-            client->bytes_sent += ret;
-            client->packets_sent++;
-            sink->bytes_served += ret;
+        if (ret < 0) {
+          if (!socket_error_is_ignorable ()) {
+            gchar *errormessage = socket_last_error_message ();
+            GST_WARNING_OBJECT (sink, "client %p gave error %d (%s)", client,
+                socket_last_error_code (), errormessage);
+            g_free (errormessage);
+            break;
             break;
           }
+        } else {
+          num++;
+          client->bytes_sent += ret;
+          client->packets_sent++;
+          sink->bytes_served += ret;
+          break;
         }
       }
     }
-    g_mutex_unlock (sink->client_lock);
-
-    g_free (iov);
-    msg.msg_iov = NULL;
-
-    GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
-        no_clients);
   }
+  g_mutex_unlock (sink->client_lock);
 
-  gst_buffer_list_iterator_free (it);
+  /* unmap all memory again */
+  for (i = 0; i < n_mem; i++) {
+    mem = gst_buffer_peek_memory (buffer, i, GST_MAP_READ);
+
+    bsize = msg.msg_iov[i].iov_len;
+    bdata = msg.msg_iov[i].iov_base;
+
+    gst_memory_unmap (mem, bdata, bsize);
+  }
+  g_free (iov);
+
+  GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
+      no_clients);
 
   return GST_FLOW_OK;
 
-invalid_list:
-  gst_buffer_list_iterator_free (it);
-  return GST_FLOW_ERROR;
+no_data:
+  {
+    return GST_FLOW_OK;
+  }
+}
+#endif
+
+#if 0
+/* DISABLED, core sends buffers to our render one by one, we can't really do
+ * much better */
+static GstFlowReturn
+gst_multiudpsink_render_list (GstBaseSink * bsink, GstBufferList * list)
+{
 }
 #endif
 
diff --git a/gst/udp/gstudp.c b/gst/udp/gstudp.c
index fbdbfea..3b77865 100644
--- a/gst/udp/gstudp.c
+++ b/gst/udp/gstudp.c
@@ -36,9 +36,10 @@
     return FALSE;
 #endif
 
-  /* register type of the netbuffer so that we can use it from multiple threads
-   * right away. Note that the plugin loading is always serialized */
-  gst_netbuffer_get_type ();
+  /* register info of the netaddress metadata so that we can use it from
+   * multiple threads right away. Note that the plugin loading is always
+   * serialized */
+  gst_meta_net_address_get_info ();
 
   if (!gst_element_register (plugin, "udpsink", GST_RANK_NONE,
           GST_TYPE_UDPSINK))
diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c
index 4363044..98c7cf1 100644
--- a/gst/udp/gstudpsrc.c
+++ b/gst/udp/gstudpsrc.c
@@ -409,7 +409,8 @@
 gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
 {
   GstUDPSrc *udpsrc;
-  GstNetBuffer *outbuf;
+  GstMetaNetAddress *meta;
+  GstBuffer *outbuf;
   union gst_sockaddr
   {
     struct sockaddr sa;
@@ -420,6 +421,7 @@
   socklen_t slen;
   guint8 *pktdata;
   gint pktsize;
+  gsize offset;
 #ifdef G_OS_UNIX
   gint readsize;
 #elif defined G_OS_WIN32
@@ -498,6 +500,7 @@
 
   pktdata = g_malloc (readsize);
   pktsize = readsize;
+  offset = 0;
 
   while (TRUE) {
     slen = sizeof (sa);
@@ -527,25 +530,26 @@
       break;
   }
 
-  /* special case buffer so receivers can also track the address */
-  outbuf = gst_netbuffer_new ();
-  GST_BUFFER_MALLOCDATA (outbuf) = pktdata;
-
   /* patch pktdata and len when stripping off the headers */
   if (G_UNLIKELY (udpsrc->skip_first_bytes != 0)) {
     if (G_UNLIKELY (readsize <= udpsrc->skip_first_bytes))
       goto skip_error;
 
-    pktdata += udpsrc->skip_first_bytes;
+    offset += udpsrc->skip_first_bytes;
     ret -= udpsrc->skip_first_bytes;
   }
-  GST_BUFFER_DATA (outbuf) = pktdata;
-  GST_BUFFER_SIZE (outbuf) = ret;
+
+  outbuf = gst_buffer_new ();
+  gst_buffer_take_memory (outbuf,
+      gst_memory_new_wrapped (0, pktdata, g_free, pktsize, offset, ret));
+
+  /* use buffer metadata so receivers can also track the address */
+  meta = gst_buffer_add_meta_net_address (outbuf);
 
   switch (sa.sa.sa_family) {
     case AF_INET:
     {
-      gst_netaddress_set_ip4_address (&outbuf->from, sa.sa_in.sin_addr.s_addr,
+      gst_netaddress_set_ip4_address (&meta->naddr, sa.sa_in.sin_addr.s_addr,
           sa.sa_in.sin_port);
     }
       break;
@@ -554,7 +558,7 @@
       guint8 ip6[16];
 
       memcpy (ip6, &sa.sa_in6.sin6_addr, sizeof (ip6));
-      gst_netaddress_set_ip6_address (&outbuf->from, ip6, sa.sa_in6.sin6_port);
+      gst_netaddress_set_ip6_address (&meta->naddr, ip6, sa.sa_in6.sin6_port);
     }
       break;
     default:
diff --git a/gst/videofilter/gstgamma.c b/gst/videofilter/gstgamma.c
index 86663b6..167680e 100644
--- a/gst/videofilter/gstgamma.c
+++ b/gst/videofilter/gstgamma.c
@@ -434,7 +434,7 @@
 {
   GstGamma *gamma = GST_GAMMA (base);
   guint8 *data;
-  guint size;
+  gsize size;
 
   if (!gamma->process)
     goto not_negotiated;
@@ -442,8 +442,7 @@
   if (base->passthrough)
     goto done;
 
-  data = GST_BUFFER_DATA (outbuf);
-  size = GST_BUFFER_SIZE (outbuf);
+  data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
 
   if (size != gamma->size)
     goto wrong_size;
@@ -452,6 +451,8 @@
   gamma->process (gamma, data);
   GST_OBJECT_UNLOCK (gamma);
 
+  gst_buffer_unmap (outbuf, data, size);
+
 done:
   return GST_FLOW_OK;
 
@@ -460,6 +461,7 @@
   {
     GST_ELEMENT_ERROR (gamma, STREAM, FORMAT,
         (NULL), ("Invalid buffer size %d, expected %d", size, gamma->size));
+    gst_buffer_unmap (outbuf, data, size);
     return GST_FLOW_ERROR;
   }
 not_negotiated:
diff --git a/gst/videofilter/gstvideobalance.c b/gst/videofilter/gstvideobalance.c
index 184b893..7fc56a6 100644
--- a/gst/videofilter/gstvideobalance.c
+++ b/gst/videofilter/gstvideobalance.c
@@ -488,7 +488,7 @@
 {
   GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base);
   guint8 *data;
-  guint size;
+  gsize size;
 
   if (!videobalance->process)
     goto not_negotiated;
@@ -497,8 +497,7 @@
   if (base->passthrough)
     goto done;
 
-  data = GST_BUFFER_DATA (outbuf);
-  size = GST_BUFFER_SIZE (outbuf);
+  data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
 
   if (size != videobalance->size)
     goto wrong_size;
@@ -507,6 +506,8 @@
   videobalance->process (videobalance, data);
   GST_OBJECT_UNLOCK (videobalance);
 
+  gst_buffer_unmap (outbuf, data, size);
+
 done:
   return GST_FLOW_OK;
 
@@ -516,6 +517,7 @@
     GST_ELEMENT_ERROR (videobalance, STREAM, FORMAT,
         (NULL), ("Invalid buffer size %d, expected %d", size,
             videobalance->size));
+    gst_buffer_unmap (outbuf, data, size);
     return GST_FLOW_ERROR;
   }
 not_negotiated:
diff --git a/gst/videofilter/gstvideoflip.c b/gst/videofilter/gstvideoflip.c
index 47ab784..3facdd1 100644
--- a/gst/videofilter/gstvideoflip.c
+++ b/gst/videofilter/gstvideoflip.c
@@ -191,7 +191,7 @@
 
 static gboolean
 gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   GstVideoFormat format;
   gint width, height;
@@ -899,13 +899,14 @@
 {
   GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans);
   guint8 *dest;
-  const guint8 *src;
+  guint8 *src;
+  gsize srcsize, destsize;
 
   if (G_UNLIKELY (videoflip->process == NULL))
     goto not_negotiated;
 
-  src = GST_BUFFER_DATA (in);
-  dest = GST_BUFFER_DATA (out);
+  src = gst_buffer_map (in, &srcsize, NULL, GST_MAP_READ);
+  dest = gst_buffer_map (out, &destsize, NULL, GST_MAP_WRITE);
 
   GST_LOG_OBJECT (videoflip, "videoflip: flipping %dx%d to %dx%d (%s)",
       videoflip->from_width, videoflip->from_height, videoflip->to_width,
@@ -915,6 +916,9 @@
   videoflip->process (videoflip, dest, src);
   GST_OBJECT_UNLOCK (videoflip);
 
+  gst_buffer_unmap (in, src, srcsize);
+  gst_buffer_unmap (out, dest, destsize);
+
   return GST_FLOW_OK;
 
 not_negotiated:
diff --git a/gst/videomixer/gstcollectpads2.c b/gst/videomixer/gstcollectpads2.c
index 8ac21d3..df8dd51 100644
--- a/gst/videomixer/gstcollectpads2.c
+++ b/gst/videomixer/gstcollectpads2.c
@@ -1198,7 +1198,7 @@
   /* Do something only on a change and if not locked */
   if (!GST_COLLECT_PADS2_STATE_IS_SET (data, GST_COLLECT_PADS2_STATE_LOCKED) &&
       (GST_COLLECT_PADS2_STATE_IS_SET (data, GST_COLLECT_PADS2_STATE_WAITING) !=
-          ! !waiting)) {
+          !!waiting)) {
     /* Set waiting state for this pad */
     if (waiting)
       GST_COLLECT_PADS2_STATE_SET (data, GST_COLLECT_PADS2_STATE_WAITING);
diff --git a/sys/oss4/oss4-mixer-slider.c b/sys/oss4/oss4-mixer-slider.c
index ea2bc8c..e71d134 100644
--- a/sys/oss4/oss4-mixer-slider.c
+++ b/sys/oss4/oss4-mixer-slider.c
@@ -219,7 +219,7 @@
     }
     ret = gst_oss4_mixer_set_control_val (s->mixer, s->mc, volume);
   } else {
-    ret = gst_oss4_mixer_set_control_val (s->mixer, s->mc->mute, ! !mute);
+    ret = gst_oss4_mixer_set_control_val (s->mixer, s->mc->mute, !!mute);
   }
 
   if (mute) {
@@ -286,7 +286,7 @@
 
   if (s->mc->mute != NULL && s->mc->mute->changed) {
     gst_mixer_mute_toggled (GST_MIXER (s->mixer), track,
-        ! !s->mc->mute->last_val);
+        !!s->mc->mute->last_val);
   } else {
     /* nothing to do here, since we don't/can't easily implement the record
      * flag */
diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
index e976ec5..e2b6de3 100644
--- a/sys/v4l2/gstv4l2bufferpool.c
+++ b/sys/v4l2/gstv4l2bufferpool.c
@@ -52,23 +52,37 @@
 GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
 #define GST_CAT_DEFAULT v4l2_debug
 
-
 /*
  * GstV4l2Buffer:
  */
+const GstMetaInfo *
+gst_meta_v4l2_get_info (void)
+{
+  static const GstMetaInfo *meta_info = NULL;
 
-static GstBufferClass *v4l2buffer_parent_class = NULL;
+  if (meta_info == NULL) {
+    meta_info =
+        gst_meta_register ("GstMetaV4l2", "GstMetaV4l2",
+        sizeof (GstMetaV4l2), (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL, (GstMetaTransformFunction) NULL,
+        (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+  }
+  return meta_info;
+}
 
 static void
-gst_v4l2_buffer_finalize (GstV4l2Buffer * buffer)
+gst_v4l2_buffer_dispose (GstBuffer * buffer)
 {
   GstV4l2BufferPool *pool;
   gboolean resuscitated = FALSE;
   gint index;
+  GstMetaV4l2 *meta;
 
-  pool = buffer->pool;
+  meta = GST_META_V4L2_GET (buffer);
+  g_assert (meta != NULL);
 
-  index = buffer->vbuffer.index;
+  pool = meta->pool;
+  index = meta->vbuffer.index;
 
   GST_LOG_OBJECT (pool->v4l2elem, "finalizing buffer %p %d", buffer, index);
 
@@ -95,7 +109,7 @@
   if (resuscitated) {
     /* FIXME: check that the caps didn't change */
     GST_LOG_OBJECT (pool->v4l2elem, "reviving buffer %p, %d", buffer, index);
-    gst_buffer_ref (GST_BUFFER (buffer));
+    gst_buffer_ref (buffer);
     GST_BUFFER_SIZE (buffer) = 0;
     pool->buffers[index] = buffer;
   }
@@ -105,96 +119,63 @@
   if (!resuscitated) {
     GST_LOG_OBJECT (pool->v4l2elem,
         "buffer %p (data %p, len %u) not recovered, unmapping",
-        buffer, GST_BUFFER_DATA (buffer), buffer->vbuffer.length);
-    gst_mini_object_unref (GST_MINI_OBJECT (pool));
-    v4l2_munmap ((void *) GST_BUFFER_DATA (buffer), buffer->vbuffer.length);
+        buffer, GST_BUFFER_DATA (buffer), meta->vbuffer.length);
+    v4l2_munmap ((void *) GST_BUFFER_DATA (buffer), meta->vbuffer.length);
 
-    GST_MINI_OBJECT_CLASS (v4l2buffer_parent_class)->finalize (GST_MINI_OBJECT
-        (buffer));
+    g_object_unref (pool);
   }
 }
 
-static void
-gst_v4l2_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  v4l2buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_v4l2_buffer_finalize;
-}
-
-GType
-gst_v4l2_buffer_get_type (void)
-{
-  static GType _gst_v4l2_buffer_type;
-
-  if (G_UNLIKELY (_gst_v4l2_buffer_type == 0)) {
-    static const GTypeInfo v4l2_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_v4l2_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstV4l2Buffer),
-      0,
-      NULL,
-      NULL
-    };
-    _gst_v4l2_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstV4l2Buffer", &v4l2_buffer_info, 0);
-  }
-  return _gst_v4l2_buffer_type;
-}
-
-static GstV4l2Buffer *
+static GstBuffer *
 gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
 {
-  GstV4l2Buffer *ret;
-  guint8 *data;
+  GstBuffer *ret;
+  guint8 *mem;
+  GstMetaV4l2 *meta;
 
-  ret = (GstV4l2Buffer *) gst_mini_object_new (GST_TYPE_V4L2_BUFFER);
+  ret = gst_buffer_new ();
+  GST_MINI_OBJECT_CAST (ret)->dispose =
+      (GstMiniObjectDisposeFunction) gst_v4l2_buffer_dispose;
+
+  meta = GST_META_V4L2_ADD (ret);
 
   GST_LOG_OBJECT (pool->v4l2elem, "creating buffer %u, %p in pool %p", index,
       ret, pool);
 
-  ret->pool =
-      (GstV4l2BufferPool *) gst_mini_object_ref (GST_MINI_OBJECT (pool));
+  meta->pool = (GstV4l2BufferPool *) g_object_ref (pool);
 
-  ret->vbuffer.index = index;
-  ret->vbuffer.type = pool->type;
-  ret->vbuffer.memory = V4L2_MEMORY_MMAP;
+  meta->vbuffer.index = index;
+  meta->vbuffer.type = pool->type;
+  meta->vbuffer.memory = V4L2_MEMORY_MMAP;
 
-  if (v4l2_ioctl (pool->video_fd, VIDIOC_QUERYBUF, &ret->vbuffer) < 0)
+  if (v4l2_ioctl (pool->video_fd, VIDIOC_QUERYBUF, &meta->vbuffer) < 0)
     goto querybuf_failed;
 
-  GST_LOG_OBJECT (pool->v4l2elem, "  index:     %u", ret->vbuffer.index);
-  GST_LOG_OBJECT (pool->v4l2elem, "  type:      %d", ret->vbuffer.type);
-  GST_LOG_OBJECT (pool->v4l2elem, "  bytesused: %u", ret->vbuffer.bytesused);
-  GST_LOG_OBJECT (pool->v4l2elem, "  flags:     %08x", ret->vbuffer.flags);
-  GST_LOG_OBJECT (pool->v4l2elem, "  field:     %d", ret->vbuffer.field);
-  GST_LOG_OBJECT (pool->v4l2elem, "  memory:    %d", ret->vbuffer.memory);
-  if (ret->vbuffer.memory == V4L2_MEMORY_MMAP)
+  GST_LOG_OBJECT (pool->v4l2elem, "  index:     %u", meta->vbuffer.index);
+  GST_LOG_OBJECT (pool->v4l2elem, "  type:      %d", meta->vbuffer.type);
+  GST_LOG_OBJECT (pool->v4l2elem, "  bytesused: %u", meta->vbuffer.bytesused);
+  GST_LOG_OBJECT (pool->v4l2elem, "  flags:     %08x", meta->vbuffer.flags);
+  GST_LOG_OBJECT (pool->v4l2elem, "  field:     %d", meta->vbuffer.field);
+  GST_LOG_OBJECT (pool->v4l2elem, "  memory:    %d", meta->vbuffer.memory);
+  if (meta->vbuffer.memory == V4L2_MEMORY_MMAP)
     GST_LOG_OBJECT (pool->v4l2elem, "  MMAP offset:  %u",
-        ret->vbuffer.m.offset);
-  GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
-  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
+        meta->vbuffer.m.offset);
+  GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", meta->vbuffer.length);
+  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", meta->vbuffer.input);
 
-  data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
+  mem = (guint8 *) v4l2_mmap (0, meta->vbuffer.length,
       PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
-      ret->vbuffer.m.offset);
+      meta->vbuffer.m.offset);
 
-  if (data == MAP_FAILED)
+  if (mem == MAP_FAILED)
     goto mmap_failed;
 
-  GST_BUFFER_DATA (ret) = data;
-  GST_BUFFER_SIZE (ret) = ret->vbuffer.length;
+  GST_BUFFER_DATA (ret) = mem;
+  GST_BUFFER_SIZE (ret) = meta->vbuffer.length;
 
   GST_BUFFER_FLAG_SET (ret, GST_BUFFER_FLAG_READONLY);
 
-  gst_buffer_set_caps (GST_BUFFER (ret), caps);
+  gst_buffer_set_caps (ret, caps);
 
   return ret;
 
@@ -204,7 +185,7 @@
     gint errnosave = errno;
 
     GST_WARNING ("Failed QUERYBUF: %s", g_strerror (errnosave));
-    gst_buffer_unref (GST_BUFFER (ret));
+    gst_buffer_unref (ret);
     errno = errnosave;
     return NULL;
   }
@@ -213,7 +194,7 @@
     gint errnosave = errno;
 
     GST_WARNING ("Failed to mmap: %s", g_strerror (errnosave));
-    gst_buffer_unref (GST_BUFFER (ret));
+    gst_buffer_unref (ret);
     errno = errnosave;
     return NULL;
   }
@@ -224,11 +205,13 @@
  * GstV4l2BufferPool:
  */
 
-static GstMiniObjectClass *buffer_pool_parent_class = NULL;
+static GObjectClass *buffer_pool_parent_class = NULL;
 
 static void
-gst_v4l2_buffer_pool_finalize (GstV4l2BufferPool * pool)
+gst_v4l2_buffer_pool_finalize (GObject * object)
 {
+  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (object);
+
   g_mutex_free (pool->lock);
   pool->lock = NULL;
 
@@ -243,8 +226,7 @@
     pool->buffers = NULL;
   }
 
-  GST_MINI_OBJECT_CLASS (buffer_pool_parent_class)->finalize (GST_MINI_OBJECT
-      (pool));
+  buffer_pool_parent_class->finalize (object);
 }
 
 static void
@@ -258,12 +240,11 @@
 static void
 gst_v4l2_buffer_pool_class_init (gpointer g_class, gpointer class_data)
 {
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
+  GObjectClass *object_class = G_OBJECT_CLASS (g_class);
 
   buffer_pool_parent_class = g_type_class_peek_parent (g_class);
 
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_v4l2_buffer_pool_finalize;
+  object_class->finalize = gst_v4l2_buffer_pool_finalize;
 }
 
 GType
@@ -273,7 +254,7 @@
 
   if (G_UNLIKELY (_gst_v4l2_buffer_pool_type == 0)) {
     static const GTypeInfo v4l2_buffer_pool_info = {
-      sizeof (GstMiniObjectClass),
+      sizeof (GObjectClass),
       NULL,
       NULL,
       gst_v4l2_buffer_pool_class_init,
@@ -284,7 +265,7 @@
       (GInstanceInitFunc) gst_v4l2_buffer_pool_init,
       NULL
     };
-    _gst_v4l2_buffer_pool_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
+    _gst_v4l2_buffer_pool_type = g_type_register_static (G_TYPE_OBJECT,
         "GstV4l2BufferPool", &v4l2_buffer_pool_info, 0);
   }
   return _gst_v4l2_buffer_pool_type;
@@ -335,7 +316,7 @@
   gint n;
   struct v4l2_requestbuffers breq;
 
-  pool = (GstV4l2BufferPool *) gst_mini_object_new (GST_TYPE_V4L2_BUFFER_POOL);
+  pool = (GstV4l2BufferPool *) g_object_new (GST_TYPE_V4L2_BUFFER_POOL, NULL);
 
   pool->video_fd = v4l2_dup (fd);
   if (pool->video_fd < 0)
@@ -370,7 +351,7 @@
   pool->requeuebuf = requeuebuf;
   pool->type = type;
   pool->buffer_count = num_buffers;
-  pool->buffers = g_new0 (GstV4l2Buffer *, num_buffers);
+  pool->buffers = g_new0 (GstBuffer *, num_buffers);
   pool->avail_buffers = g_async_queue_new ();
 
   /* now, map the buffers: */
@@ -389,7 +370,7 @@
   {
     gint errnosave = errno;
 
-    gst_mini_object_unref (GST_MINI_OBJECT (pool));
+    g_object_unref (pool);
 
     errno = errnosave;
 
@@ -461,7 +442,7 @@
       gst_buffer_unref (buf);
   }
 
-  gst_mini_object_unref (GST_MINI_OBJECT (pool));
+  g_object_unref (pool);
 }
 
 /**
@@ -472,10 +453,10 @@
  *
  * Get an available buffer in the pool
  */
-GstV4l2Buffer *
+GstBuffer *
 gst_v4l2_buffer_pool_get (GstV4l2BufferPool * pool, gboolean blocking)
 {
-  GstV4l2Buffer *buf;
+  GstBuffer *buf;
 
   if (blocking) {
     buf = g_async_queue_pop (pool->avail_buffers);
@@ -484,8 +465,10 @@
   }
 
   if (buf) {
+    GstMetaV4l2 *meta = GST_META_V4L2_GET (buf);
+
     GST_V4L2_BUFFER_POOL_LOCK (pool);
-    GST_BUFFER_SIZE (buf) = buf->vbuffer.length;
+    GST_BUFFER_SIZE (buf) = meta->vbuffer.length;
     GST_BUFFER_FLAG_UNSET (buf, 0xffffffff);
     GST_V4L2_BUFFER_POOL_UNLOCK (pool);
   }
@@ -506,11 +489,16 @@
  * Returns: %TRUE for success
  */
 gboolean
-gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstV4l2Buffer * buf)
+gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool * pool, GstBuffer * buf)
 {
-  GST_LOG_OBJECT (pool->v4l2elem, "enqueue pool buffer %d", buf->vbuffer.index);
+  GstMetaV4l2 *meta;
 
-  if (v4l2_ioctl (pool->video_fd, VIDIOC_QBUF, &buf->vbuffer) < 0)
+  meta = GST_META_V4L2_GET (buf);
+
+  GST_LOG_OBJECT (pool->v4l2elem, "enqueue pool buffer %d",
+      meta->vbuffer.index);
+
+  if (v4l2_ioctl (pool->video_fd, VIDIOC_QBUF, &meta->vbuffer) < 0)
     return FALSE;
 
   pool->num_live_buffers--;
@@ -530,18 +518,17 @@
  *
  * Returns: a buffer
  */
-GstV4l2Buffer *
+GstBuffer *
 gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool)
 {
   GstV4l2Object *v4l2object = get_v4l2_object (pool->v4l2elem);
-  GstV4l2Buffer *pool_buffer;
+  GstBuffer *pool_buffer;
   struct v4l2_buffer buffer;
 
   memset (&buffer, 0x00, sizeof (buffer));
   buffer.type = pool->type;
   buffer.memory = V4L2_MEMORY_MMAP;
 
-
   if (v4l2_ioctl (pool->video_fd, VIDIOC_DQBUF, &buffer) >= 0) {
 
     GST_V4L2_BUFFER_POOL_LOCK (pool);
diff --git a/sys/v4l2/gstv4l2bufferpool.h b/sys/v4l2/gstv4l2bufferpool.h
index caad9ac..a7e6a74 100644
--- a/sys/v4l2/gstv4l2bufferpool.h
+++ b/sys/v4l2/gstv4l2bufferpool.h
@@ -46,12 +46,12 @@
 
 
 typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
-typedef struct _GstV4l2Buffer GstV4l2Buffer;
+typedef struct _GstMetaV4l2 GstMetaV4l2;
 
 
 struct _GstV4l2BufferPool
 {
-  GstMiniObject parent;
+  GObject parent;
 
   GstElement *v4l2elem;      /* the v4l2 src/sink that owns us.. maybe we should be owned by v4l2object? */
   gboolean requeuebuf;       /* if true, unusued buffers are automatically re-QBUF'd */
@@ -63,11 +63,11 @@
   GAsyncQueue* avail_buffers;/* pool of available buffers, not with the driver and which aren't held outside the bufferpool */
   gint video_fd;             /* a dup(2) of the v4l2object's video_fd */
   guint buffer_count;
-  GstV4l2Buffer **buffers;
+  GstBuffer **buffers;
 };
 
-struct _GstV4l2Buffer {
-  GstBuffer   buffer;
+struct _GstMetaV4l2 {
+  GstMeta meta;
 
   struct v4l2_buffer vbuffer;
 
@@ -78,13 +78,17 @@
   GstV4l2BufferPool *pool;
 };
 
+const GstMetaInfo * gst_meta_v4l2_get_info (void);
+#define GST_META_V4L2_GET(buf) ((GstMetaV4l2 *)gst_buffer_get_meta(buf,gst_meta_v4l2_get_info()))
+#define GST_META_V4L2_ADD(buf) ((GstMetaV4l2 *)gst_buffer_add_meta(buf,gst_meta_v4l2_get_info(),NULL))
+
 void gst_v4l2_buffer_pool_destroy (GstV4l2BufferPool * pool);
 GstV4l2BufferPool *gst_v4l2_buffer_pool_new (GstElement *v4l2elem, gint fd, gint num_buffers, GstCaps * caps, gboolean requeuebuf, enum v4l2_buf_type type);
 
 
-GstV4l2Buffer *gst_v4l2_buffer_pool_get (GstV4l2BufferPool *pool, gboolean blocking);
-gboolean gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool *pool, GstV4l2Buffer *buf);
-GstV4l2Buffer *gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool *pool);
+GstBuffer *gst_v4l2_buffer_pool_get (GstV4l2BufferPool *pool, gboolean blocking);
+gboolean gst_v4l2_buffer_pool_qbuf (GstV4l2BufferPool *pool, GstBuffer *buf);
+GstBuffer *gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool *pool);
 
 gint gst_v4l2_buffer_pool_available_buffers (GstV4l2BufferPool *pool);
 
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index 5296197..851fae6 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -66,21 +66,21 @@
   V4L2_STD_OBJECT_PROPS,
 };
 
+G_LOCK_DEFINE_STATIC (probe_lock);
+
 const GList *
 gst_v4l2_probe_get_properties (GstPropertyProbe * probe)
 {
   GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
   static GList *list = NULL;
 
-  /* well, not perfect, but better than no locking at all.
-   * In the worst case we leak a list node, so who cares? */
-  GST_CLASS_LOCK (GST_OBJECT_CLASS (klass));
+  G_LOCK (probe_lock);
 
   if (!list) {
     list = g_list_append (NULL, g_object_class_find_property (klass, "device"));
   }
 
-  GST_CLASS_UNLOCK (GST_OBJECT_CLASS (klass));
+  G_UNLOCK (probe_lock);
 
   return list;
 }
diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c
index fb6c374..a898503 100644
--- a/sys/v4l2/v4l2src_calls.c
+++ b/sys/v4l2/v4l2src_calls.c
@@ -66,7 +66,7 @@
 gst_v4l2src_buffer_pool_activate (GstV4l2BufferPool * pool,
     GstV4l2Src * v4l2src)
 {
-  GstV4l2Buffer *buf;
+  GstBuffer *buf;
 
   while ((buf = gst_v4l2_buffer_pool_get (pool, FALSE)) != NULL)
     if (!gst_v4l2_buffer_pool_qbuf (pool, buf))
@@ -81,7 +81,8 @@
         (_("Could not enqueue buffers in device '%s'."),
             v4l2src->v4l2object->videodev),
         ("enqueing buffer %d/%d failed: %s",
-            buf->vbuffer.index, v4l2src->num_buffers, g_strerror (errno)));
+            GST_META_V4L2_GET (buf)->vbuffer.index, v4l2src->num_buffers,
+            g_strerror (errno)));
     return FALSE;
   }
 }
diff --git a/sys/ximage/gstximagesrc.c b/sys/ximage/gstximagesrc.c
index e705ccb..2c2106a 100644
--- a/sys/ximage/gstximagesrc.c
+++ b/sys/ximage/gstximagesrc.c
@@ -80,16 +80,15 @@
 
 /* Called when a buffer is returned from the pipeline */
 static void
-gst_ximage_src_return_buf (GstXImageSrc * ximagesrc,
-    GstXImageSrcBuffer * ximage)
+gst_ximage_src_return_buf (GstXImageSrc * ximagesrc, GstBuffer * ximage)
 {
+  GstMetaXImage *meta = GST_META_XIMAGE_GET (ximage);
+
   /* If our geometry changed we can't reuse that image. */
-  if ((ximage->width != ximagesrc->width) ||
-      (ximage->height != ximagesrc->height)) {
+  if ((meta->width != ximagesrc->width) || (meta->height != ximagesrc->height)) {
     GST_DEBUG_OBJECT (ximagesrc,
         "destroy image %p as its size changed %dx%d vs current %dx%d",
-        ximage, ximage->width, ximage->height,
-        ximagesrc->width, ximagesrc->height);
+        ximage, meta->width, meta->height, ximagesrc->width, ximagesrc->height);
     g_mutex_lock (ximagesrc->x_lock);
     gst_ximageutil_ximage_destroy (ximagesrc->xcontext, ximage);
     g_mutex_unlock (ximagesrc->x_lock);
@@ -97,7 +96,7 @@
     /* In that case we can reuse the image and add it to our image pool. */
     GST_LOG_OBJECT (ximagesrc, "recycling image %p in pool", ximage);
     /* need to increment the refcount again to recycle */
-    gst_buffer_ref (GST_BUFFER (ximage));
+    gst_buffer_ref (ximage);
     g_mutex_lock (ximagesrc->pool_lock);
     ximagesrc->buffer_pool = g_slist_prepend (ximagesrc->buffer_pool, ximage);
     g_mutex_unlock (ximagesrc->pool_lock);
@@ -358,17 +357,20 @@
 
 /* Retrieve an XImageSrcBuffer, preferably from our
  * pool of existing images and populate it from the window */
-static GstXImageSrcBuffer *
+static GstBuffer *
 gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
 {
-  GstXImageSrcBuffer *ximage = NULL;
+  GstBuffer *ximage = NULL;
+  GstMetaXImage *meta;
 
   g_mutex_lock (ximagesrc->pool_lock);
   while (ximagesrc->buffer_pool != NULL) {
     ximage = ximagesrc->buffer_pool->data;
 
-    if ((ximage->width != ximagesrc->width) ||
-        (ximage->height != ximagesrc->height)) {
+    meta = GST_META_XIMAGE_GET (ximage);
+
+    if ((meta->width != ximagesrc->width) ||
+        (meta->height != ximagesrc->height)) {
       gst_ximage_buffer_free (ximage);
     }
 
@@ -413,13 +415,16 @@
         gst_value_get_fraction_numerator (xcontext->par),
         gst_value_get_fraction_denominator (xcontext->par), NULL);
 
-    gst_buffer_set_caps (GST_BUFFER (ximage), caps);
+    gst_buffer_set_caps (ximage, caps);
     g_mutex_unlock (ximagesrc->x_lock);
 
     gst_caps_unref (caps);
   }
 
   g_return_val_if_fail (GST_IS_XIMAGE_SRC (ximagesrc), NULL);
+
+  meta = GST_META_XIMAGE_GET (ximage);
+
 #ifdef HAVE_XDAMAGE
   if (ximagesrc->have_xdamage && ximagesrc->use_damage &&
       ximagesrc->last_ximage != NULL) {
@@ -492,7 +497,7 @@
                     startx, starty, width, height);
                 XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
                     startx, starty, width, height, AllPlanes, ZPixmap,
-                    ximage->ximage, startx - ximagesrc->startx,
+                    meta->ximage, startx - ximagesrc->startx,
                     starty - ximagesrc->starty);
               }
             } else {
@@ -504,7 +509,7 @@
               XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
                   rects[i].x, rects[i].y,
                   rects[i].width, rects[i].height,
-                  AllPlanes, ZPixmap, ximage->ximage, rects[i].x, rects[i].y);
+                  AllPlanes, ZPixmap, meta->ximage, rects[i].x, rects[i].y);
             }
           }
           free (rects);
@@ -566,14 +571,14 @@
           GST_DEBUG_OBJECT (ximagesrc, "Removing cursor from %d,%d", x, y);
           XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
               startx, starty, iwidth, iheight, AllPlanes, ZPixmap,
-              ximage->ximage, startx - ximagesrc->startx,
+              meta->ximage, startx - ximagesrc->startx,
               starty - ximagesrc->starty);
         }
       } else {
 
         GST_DEBUG_OBJECT (ximagesrc, "Removing cursor from %d,%d", x, y);
         XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
-            x, y, width, height, AllPlanes, ZPixmap, ximage->ximage, x, y);
+            x, y, width, height, AllPlanes, ZPixmap, meta->ximage, x, y);
       }
     }
 #endif
@@ -586,7 +591,7 @@
     if (ximagesrc->xcontext->use_xshm) {
       GST_DEBUG_OBJECT (ximagesrc, "Retrieving screen using XShm");
       XShmGetImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
-          ximage->ximage, ximagesrc->startx, ximagesrc->starty, AllPlanes);
+          meta->ximage, ximagesrc->startx, ximagesrc->starty, AllPlanes);
 
     } else
 #endif /* HAVE_XSHM */
@@ -595,9 +600,9 @@
       if (ximagesrc->remote) {
         XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
             ximagesrc->startx, ximagesrc->starty, ximagesrc->width,
-            ximagesrc->height, AllPlanes, ZPixmap, ximage->ximage, 0, 0);
+            ximagesrc->height, AllPlanes, ZPixmap, meta->ximage, 0, 0);
       } else {
-        ximage->ximage =
+        meta->ximage =
             XGetImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
             ximagesrc->startx, ximagesrc->starty, ximagesrc->width,
             ximagesrc->height, AllPlanes, ZPixmap);
@@ -677,7 +682,7 @@
                 (guint8 *) & (ximagesrc->cursor_image->pixels[((j -
                             cy) * ximagesrc->cursor_image->width + (i - cx))]);
             dest =
-                (guint8 *) & (ximage->ximage->data[((j -
+                (guint8 *) & (meta->ximage->data[((j -
                             ximagesrc->starty) * ximagesrc->width + (i -
                             ximagesrc->startx)) * (ximagesrc->xcontext->bpp /
                         8)]);
@@ -708,7 +713,7 @@
 gst_ximage_src_create (GstPushSrc * bs, GstBuffer ** buf)
 {
   GstXImageSrc *s = GST_XIMAGE_SRC (bs);
-  GstXImageSrcBuffer *image;
+  GstBuffer *image;
   GstClockTime base_time;
   GstClockTime next_capture_ts;
   GstClockTime dur;
@@ -889,7 +894,7 @@
 {
   g_mutex_lock (ximagesrc->pool_lock);
   while (ximagesrc->buffer_pool != NULL) {
-    GstXImageSrcBuffer *ximage = ximagesrc->buffer_pool->data;
+    GstBuffer *ximage = ximagesrc->buffer_pool->data;
 
     gst_ximage_buffer_free (ximage);
 
diff --git a/sys/ximage/gstximagesrc.h b/sys/ximage/gstximagesrc.h
index f436df6..732e7af 100644
--- a/sys/ximage/gstximagesrc.h
+++ b/sys/ximage/gstximagesrc.h
@@ -95,7 +95,7 @@
   int damage_event_base;
   XserverRegion damage_region;
   GC damage_copy_gc;
-  GstXImageSrcBuffer *last_ximage;
+  GstBuffer *last_ximage;
 #endif
 };
 
diff --git a/sys/ximage/ximageutil.c b/sys/ximage/ximageutil.c
index 0ef4b06..7138681 100644
--- a/sys/ximage/ximageutil.c
+++ b/sys/ximage/ximageutil.c
@@ -23,6 +23,21 @@
 
 #include "ximageutil.h"
 
+const GstMetaInfo *
+gst_meta_ximage_get_info (void)
+{
+  static const GstMetaInfo *meta_ximage_info = NULL;
+
+  if (meta_ximage_info == NULL) {
+    meta_ximage_info =
+        gst_meta_register ("GstMetaXImageSrc", "GstMetaXImageSrc",
+        sizeof (GstMetaXImage), (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL, (GstMetaTransformFunction) NULL,
+        (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+  }
+  return meta_ximage_info;
+}
+
 #ifdef HAVE_XSHM
 static gboolean error_caught = FALSE;
 
@@ -296,154 +311,116 @@
       gst_value_get_fraction_denominator (xcontext->par));
 }
 
-static GstBufferClass *ximagesrc_buffer_parent_class = NULL;
-
 static void
-gst_ximagesrc_buffer_finalize (GstXImageSrcBuffer * ximage)
+gst_ximagesrc_buffer_dispose (GstBuffer * ximage)
 {
   GstElement *parent;
+  GstMetaXImage *meta;
 
   g_return_if_fail (ximage != NULL);
 
-  parent = ximage->parent;
+  meta = GST_META_XIMAGE_GET (ximage);
+
+  parent = meta->parent;
   if (parent == NULL) {
     g_warning ("XImageSrcBuffer->ximagesrc == NULL");
     goto beach;
   }
 
-  if (ximage->return_func)
-    ximage->return_func (parent, ximage);
+  if (meta->return_func)
+    meta->return_func (parent, ximage);
 
 beach:
-
-  GST_MINI_OBJECT_CLASS (ximagesrc_buffer_parent_class)->finalize
-      (GST_MINI_OBJECT (ximage));
-
   return;
 }
 
 void
-gst_ximage_buffer_free (GstXImageSrcBuffer * ximage)
+gst_ximage_buffer_free (GstBuffer * ximage)
 {
+  GstMetaXImage *meta;
+
+  meta = GST_META_XIMAGE_GET (ximage);
+
   /* make sure it is not recycled */
-  ximage->width = -1;
-  ximage->height = -1;
-  gst_buffer_unref (GST_BUFFER (ximage));
-}
-
-static void
-gst_ximagesrc_buffer_init (GstXImageSrcBuffer * ximage_buffer, gpointer g_class)
-{
-#ifdef HAVE_XSHM
-  ximage_buffer->SHMInfo.shmaddr = ((void *) -1);
-  ximage_buffer->SHMInfo.shmid = -1;
-#endif
-}
-
-static void
-gst_ximagesrc_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  ximagesrc_buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_ximagesrc_buffer_finalize;
-}
-
-static GType
-gst_ximagesrc_buffer_get_type (void)
-{
-  static GType _gst_ximagesrc_buffer_type;
-
-  if (G_UNLIKELY (_gst_ximagesrc_buffer_type == 0)) {
-    static const GTypeInfo ximagesrc_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_ximagesrc_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstXImageSrcBuffer),
-      0,
-      (GInstanceInitFunc) gst_ximagesrc_buffer_init,
-      NULL
-    };
-    _gst_ximagesrc_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstXImageSrcBuffer", &ximagesrc_buffer_info, 0);
-  }
-  return _gst_ximagesrc_buffer_type;
+  meta->width = -1;
+  meta->height = -1;
+  gst_buffer_unref (ximage);
 }
 
 /* This function handles GstXImageSrcBuffer creation depending on XShm availability */
-GstXImageSrcBuffer *
+GstBuffer *
 gst_ximageutil_ximage_new (GstXContext * xcontext,
     GstElement * parent, int width, int height, BufferReturnFunc return_func)
 {
-  GstXImageSrcBuffer *ximage = NULL;
+  GstBuffer *ximage = NULL;
+  GstMetaXImage *meta;
   gboolean succeeded = FALSE;
 
-  ximage =
-      (GstXImageSrcBuffer *) gst_mini_object_new (GST_TYPE_XIMAGESRC_BUFFER);
+  ximage = gst_buffer_new ();
+  GST_MINI_OBJECT_CAST (ximage)->dispose =
+      (GstMiniObjectDisposeFunction) gst_ximagesrc_buffer_dispose;
 
-  ximage->width = width;
-  ximage->height = height;
+  meta = GST_META_XIMAGE_ADD (ximage);
+  meta->width = width;
+  meta->height = height;
 
 #ifdef HAVE_XSHM
+  meta->SHMInfo.shmaddr = ((void *) -1);
+  meta->SHMInfo.shmid = -1;
+
   if (xcontext->use_xshm) {
-    ximage->ximage = XShmCreateImage (xcontext->disp,
+    meta->ximage = XShmCreateImage (xcontext->disp,
         xcontext->visual, xcontext->depth,
-        ZPixmap, NULL, &ximage->SHMInfo, ximage->width, ximage->height);
-    if (!ximage->ximage) {
+        ZPixmap, NULL, &meta->SHMInfo, meta->width, meta->height);
+    if (!meta->ximage) {
       goto beach;
     }
 
     /* we have to use the returned bytes_per_line for our shm size */
-    ximage->size = ximage->ximage->bytes_per_line * ximage->ximage->height;
-    ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size,
-        IPC_CREAT | 0777);
-    if (ximage->SHMInfo.shmid == -1)
+    meta->size = meta->ximage->bytes_per_line * meta->ximage->height;
+    meta->SHMInfo.shmid = shmget (IPC_PRIVATE, meta->size, IPC_CREAT | 0777);
+    if (meta->SHMInfo.shmid == -1)
       goto beach;
 
-    ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, 0, 0);
-    if (ximage->SHMInfo.shmaddr == ((void *) -1))
+    meta->SHMInfo.shmaddr = shmat (meta->SHMInfo.shmid, 0, 0);
+    if (meta->SHMInfo.shmaddr == ((void *) -1))
       goto beach;
 
     /* Delete the SHM segment. It will actually go away automatically
      * when we detach now */
-    shmctl (ximage->SHMInfo.shmid, IPC_RMID, 0);
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, 0);
 
-    ximage->ximage->data = ximage->SHMInfo.shmaddr;
-    ximage->SHMInfo.readOnly = FALSE;
+    meta->ximage->data = meta->SHMInfo.shmaddr;
+    meta->SHMInfo.readOnly = FALSE;
 
-    if (XShmAttach (xcontext->disp, &ximage->SHMInfo) == 0)
+    if (XShmAttach (xcontext->disp, &meta->SHMInfo) == 0)
       goto beach;
 
     XSync (xcontext->disp, FALSE);
   } else
 #endif /* HAVE_XSHM */
   {
-    ximage->ximage = XCreateImage (xcontext->disp,
+    meta->ximage = XCreateImage (xcontext->disp,
         xcontext->visual,
         xcontext->depth,
-        ZPixmap, 0, NULL, ximage->width, ximage->height, xcontext->bpp, 0);
-    if (!ximage->ximage)
+        ZPixmap, 0, NULL, meta->width, meta->height, xcontext->bpp, 0);
+    if (!meta->ximage)
       goto beach;
 
     /* we have to use the returned bytes_per_line for our image size */
-    ximage->size = ximage->ximage->bytes_per_line * ximage->ximage->height;
-    ximage->ximage->data = g_malloc (ximage->size);
+    meta->size = meta->ximage->bytes_per_line * meta->ximage->height;
+    meta->ximage->data = g_malloc (meta->size);
 
     XSync (xcontext->disp, FALSE);
   }
   succeeded = TRUE;
 
-  GST_BUFFER_DATA (ximage) = (guchar *) ximage->ximage->data;
-  GST_BUFFER_SIZE (ximage) = ximage->size;
+  GST_BUFFER_DATA (ximage) = (guchar *) meta->ximage->data;
+  GST_BUFFER_SIZE (ximage) = meta->size;
 
   /* Keep a ref to our src */
-  ximage->parent = gst_object_ref (parent);
-  ximage->return_func = return_func;
+  meta->parent = gst_object_ref (parent);
+  meta->return_func = return_func;
 beach:
   if (!succeeded) {
     gst_ximage_buffer_free (ximage);
@@ -455,9 +432,12 @@
 
 /* This function destroys a GstXImageBuffer handling XShm availability */
 void
-gst_ximageutil_ximage_destroy (GstXContext * xcontext,
-    GstXImageSrcBuffer * ximage)
+gst_ximageutil_ximage_destroy (GstXContext * xcontext, GstBuffer * ximage)
 {
+  GstMetaXImage *meta;
+
+  meta = GST_META_XIMAGE_GET (ximage);
+
   /* We might have some buffers destroyed after changing state to NULL */
   if (!xcontext)
     goto beach;
@@ -466,28 +446,28 @@
 
 #ifdef HAVE_XSHM
   if (xcontext->use_xshm) {
-    if (ximage->SHMInfo.shmaddr != ((void *) -1)) {
-      XShmDetach (xcontext->disp, &ximage->SHMInfo);
+    if (meta->SHMInfo.shmaddr != ((void *) -1)) {
+      XShmDetach (xcontext->disp, &meta->SHMInfo);
       XSync (xcontext->disp, 0);
-      shmdt (ximage->SHMInfo.shmaddr);
+      shmdt (meta->SHMInfo.shmaddr);
     }
-    if (ximage->ximage)
-      XDestroyImage (ximage->ximage);
+    if (meta->ximage)
+      XDestroyImage (meta->ximage);
 
   } else
 #endif /* HAVE_XSHM */
   {
-    if (ximage->ximage) {
-      XDestroyImage (ximage->ximage);
+    if (meta->ximage) {
+      XDestroyImage (meta->ximage);
     }
   }
 
   XSync (xcontext->disp, FALSE);
 beach:
-  if (ximage->parent) {
+  if (meta->parent) {
     /* Release the ref to our parent */
-    gst_object_unref (ximage->parent);
-    ximage->parent = NULL;
+    gst_object_unref (meta->parent);
+    meta->parent = NULL;
   }
 
   return;
diff --git a/sys/ximage/ximageutil.h b/sys/ximage/ximageutil.h
index 517fc8e..aa674de 100644
--- a/sys/ximage/ximageutil.h
+++ b/sys/ximage/ximageutil.h
@@ -43,7 +43,7 @@
 typedef struct _GstXContext GstXContext;
 typedef struct _GstXWindow GstXWindow;
 typedef struct _GstXImage GstXImage;
-typedef struct _GstXImageSrcBuffer GstXImageSrcBuffer;
+typedef struct _GstMetaXImage GstMetaXImage;
 
 /* Global X Context stuff */
 /**
@@ -130,20 +130,20 @@
 /* custom ximagesrc buffer, copied from ximagesink */
 
 /* BufferReturnFunc is called when a buffer is finalised */
-typedef void (*BufferReturnFunc) (GstElement *parent, GstXImageSrcBuffer *buf);
+typedef void (*BufferReturnFunc) (GstElement *parent, GstBuffer *buf);
 
 /**
- * GstXImageSrcBuffer:
+ * GstMetaXImage:
  * @parent: a reference to the element we belong to
  * @ximage: the XImage of this buffer
  * @width: the width in pixels of XImage @ximage
  * @height: the height in pixels of XImage @ximage
  * @size: the size in bytes of XImage @ximage
  *
- * Subclass of #GstBuffer containing additional information about an XImage.
+ * Extra data attached to buffers containing additional information about an XImage.
  */
-struct _GstXImageSrcBuffer {
-  GstBuffer buffer;
+struct _GstMetaXImage {
+  GstMeta meta;
 
   /* Reference to the ximagesrc we belong to */
   GstElement *parent;
@@ -156,26 +156,22 @@
 
   gint width, height;
   size_t size;
-  
+
   BufferReturnFunc return_func;
 };
 
+const GstMetaInfo * gst_meta_ximage_get_info (void);
+#define GST_META_XIMAGE_GET(buf) ((GstMetaXImage *)gst_buffer_get_meta(buf,gst_meta_ximage_get_info()))
+#define GST_META_XIMAGE_ADD(buf) ((GstMetaXImage *)gst_buffer_add_meta(buf,gst_meta_ximage_get_info(),NULL))
 
-GstXImageSrcBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext,
+GstBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext,
   GstElement *parent, int width, int height, BufferReturnFunc return_func);
 
 void gst_ximageutil_ximage_destroy (GstXContext *xcontext, 
-  GstXImageSrcBuffer * ximage);
+  GstBuffer * ximage);
   
 /* Call to manually release a buffer */
-void gst_ximage_buffer_free (GstXImageSrcBuffer *ximage);
-
-#define GST_TYPE_XIMAGESRC_BUFFER            (gst_ximagesrc_buffer_get_type())
-#define GST_IS_XIMAGESRC_BUFFER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGESRC_BUFFER))
-#define GST_IS_XIMAGESRC_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_XIMAGESRC_BUFFER))
-#define GST_XIMAGESRC_BUFFER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBuffer))
-#define GST_XIMAGESRC_BUFFER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBufferClass))
-#define GST_XIMAGESRC_BUFFER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBufferClass))
+void gst_ximage_buffer_free (GstBuffer *ximage);
 
 G_END_DECLS 
 
diff --git a/tests/examples/pulse/Makefile.am b/tests/examples/pulse/Makefile.am
index 5d35e61..e9a2d96 100644
--- a/tests/examples/pulse/Makefile.am
+++ b/tests/examples/pulse/Makefile.am
@@ -1,5 +1,5 @@
 noinst_PROGRAMS = pulse
 pulse_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-pulse_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_BASE_LIBS) $(GST_LIBS)
+pulse_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_LIBS)
 
 
diff --git a/tests/examples/v4l2/Makefile.am b/tests/examples/v4l2/Makefile.am
index 4fdb7e3..7db85d4 100644
--- a/tests/examples/v4l2/Makefile.am
+++ b/tests/examples/v4l2/Makefile.am
@@ -6,5 +6,5 @@
 
 probe_SOURCES = probe.c
 probe_CFLAGS  = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
-probe_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_BASE_LIBS) $(GST_LIBS)
+probe_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_LIBS)
 
diff --git a/tests/icles/Makefile.am b/tests/icles/Makefile.am
index 5b1eb22..8181846 100644
--- a/tests/icles/Makefile.am
+++ b/tests/icles/Makefile.am
@@ -23,7 +23,7 @@
 
 test_oss4_SOURCES = test-oss4.c
 test_oss4_CFLAGS  = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-test_oss4_LDADD   = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_LIBS)
+test_oss4_LDADD   = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR) $(GST_LIBS)
 test_oss4_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 else
 OSS4_TESTS=