Merge branch 'master' into 0.11
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Sat, 16 Apr 2011 07:33:44 +0000 (09:33 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Sat, 16 Apr 2011 07:33:44 +0000 (09:33 +0200)
184 files changed:
android/alsa.mk
android/app.mk
android/app_plugin.mk
android/audio.mk
android/audioconvert.mk
android/decodebin.mk
android/decodebin2.mk
android/gdp.mk
android/interfaces.mk
android/netbuffer.mk
android/pbutils.mk
android/playbin.mk
android/queue2.mk
android/riff.mk
android/rtp.mk
android/rtsp.mk
android/sdp.mk
android/tag.mk
android/tcp.mk
android/typefindfunctions.mk
android/video.mk
configure.ac
ext/alsa/gstalsadeviceprobe.c
ext/cdparanoia/gstcdparanoiasrc.c
ext/gio/gstgiobasesink.c
ext/gio/gstgiobasesrc.c
ext/gnomevfs/gstgnomevfssink.c
ext/gnomevfs/gstgnomevfssrc.c
ext/libvisual/visual.c
ext/ogg/gstoggaviparse.c
ext/ogg/gstoggdemux.c
ext/ogg/gstoggmux.c
ext/ogg/gstoggparse.c
ext/ogg/gstoggstream.c
ext/ogg/gstogmparse.c
ext/pango/gsttextoverlay.c
ext/pango/gsttextrender.c
ext/theora/gsttheoradec.c
ext/theora/gsttheoraenc.c
ext/theora/gsttheoraparse.c
ext/vorbis/gstvorbisdec.c
ext/vorbis/gstvorbisdeclib.h
ext/vorbis/gstvorbisenc.c
ext/vorbis/gstvorbisparse.c
ext/vorbis/gstvorbistag.c
gst-libs/gst/app/Makefile.am
gst-libs/gst/app/gstappbuffer.c [deleted file]
gst-libs/gst/app/gstappbuffer.h [deleted file]
gst-libs/gst/app/gstappsink.c
gst-libs/gst/app/gstappsrc.c
gst-libs/gst/audio/audio.c
gst-libs/gst/audio/gstaudiofilter.c
gst-libs/gst/audio/gstaudiosink.c
gst-libs/gst/audio/gstaudiosrc.c
gst-libs/gst/audio/gstbaseaudiosink.c
gst-libs/gst/audio/gstbaseaudiosrc.c
gst-libs/gst/audio/gstringbuffer.c
gst-libs/gst/audio/gstringbuffer.h
gst-libs/gst/cdda/gstcddabasesrc.c
gst-libs/gst/netbuffer/gstnetbuffer.c
gst-libs/gst/netbuffer/gstnetbuffer.h
gst-libs/gst/pbutils/encoding-profile.c
gst-libs/gst/pbutils/encoding-profile.h
gst-libs/gst/pbutils/encoding-target.c
gst-libs/gst/pbutils/encoding-target.h
gst-libs/gst/pbutils/gstdiscoverer-types.c
gst-libs/gst/pbutils/gstdiscoverer.c
gst-libs/gst/pbutils/gstdiscoverer.h
gst-libs/gst/pbutils/pbutils-private.h
gst-libs/gst/riff/riff-media.c
gst-libs/gst/riff/riff-read.c
gst-libs/gst/rtp/gstbasertpaudiopayload.c
gst-libs/gst/rtp/gstbasertpdepayload.c
gst-libs/gst/rtp/gstbasertppayload.c
gst-libs/gst/rtp/gstrtcpbuffer.c
gst-libs/gst/rtp/gstrtcpbuffer.h
gst-libs/gst/rtp/gstrtpbuffer.c
gst-libs/gst/rtp/gstrtpbuffer.h
gst-libs/gst/tag/gstexiftag.c
gst-libs/gst/tag/gsttagdemux.c
gst-libs/gst/tag/gstvorbistag.c
gst-libs/gst/tag/gstxmptag.c
gst-libs/gst/tag/tag.h
gst-libs/gst/tag/tags.c
gst-libs/gst/video/convertframe.c
gst-libs/gst/video/gstvideofilter.c
gst/adder/gstadder.c
gst/audioconvert/gstaudioconvert.c
gst/audiorate/gstaudiorate.c
gst/audioresample/gstaudioresample.c
gst/audiotestsrc/gstaudiotestsrc.c
gst/encoding/gstencodebin.c
gst/ffmpegcolorspace/gstffmpegcodecmap.c
gst/ffmpegcolorspace/gstffmpegcolorspace.c
gst/gdp/gstgdpdepay.c
gst/gdp/gstgdppay.c
gst/playback/gstdecodebin2.c
gst/playback/gstplaybin.c
gst/playback/gstplaybin2.c
gst/playback/gstplaysink.c
gst/playback/gststreamsynchronizer.c
gst/subparse/gstssaparse.c
gst/subparse/gstsubparse.c
gst/tcp/gstmultifdsink.c
gst/tcp/gstmultifdsink.h
gst/tcp/gsttcp.c
gst/tcp/gsttcp.h
gst/tcp/gsttcpclientsink.c
gst/tcp/gsttcpclientsink.h
gst/tcp/gsttcpclientsrc.c
gst/tcp/gsttcpclientsrc.h
gst/tcp/gsttcpserversrc.c
gst/tcp/gsttcpserversrc.h
gst/typefind/gsttypefindfunctions.c
gst/videorate/gstvideorate.c
gst/videoscale/gstvideoscale.c
gst/videotestsrc/gstvideotestsrc.c
gst/volume/gstvolume.c
sys/v4l/v4lsrc_calls.c
sys/ximage/Makefile.am
sys/ximage/ximage.c
sys/ximage/ximagepool.c [new file with mode: 0644]
sys/ximage/ximagepool.h [new file with mode: 0644]
sys/ximage/ximagesink.c
sys/ximage/ximagesink.h
sys/xvimage/Makefile.am
sys/xvimage/xvimage.c [new file with mode: 0644]
sys/xvimage/xvimagepool.c [new file with mode: 0644]
sys/xvimage/xvimagepool.h [new file with mode: 0644]
sys/xvimage/xvimagesink.c
sys/xvimage/xvimagesink.h
tests/check/elements/appsink.c
tests/check/elements/audioconvert.c
tests/check/elements/audiorate.c
tests/check/elements/audioresample.c
tests/check/elements/decodebin.c
tests/check/elements/decodebin2.c
tests/check/elements/ffmpegcolorspace.c
tests/check/elements/gdpdepay.c
tests/check/elements/gdppay.c
tests/check/elements/gnomevfssink.c
tests/check/elements/multifdsink.c
tests/check/elements/playbin.c
tests/check/elements/playbin2.c
tests/check/elements/subparse.c
tests/check/elements/textoverlay.c
tests/check/elements/videorate.c
tests/check/elements/videoscale.c
tests/check/elements/videotestsrc.c
tests/check/elements/volume.c
tests/check/elements/vorbisdec.c
tests/check/elements/vorbistag.c
tests/check/gst/typefindfunctions.c
tests/check/libs/audio.c
tests/check/libs/cddabasesrc.c
tests/check/libs/gstlibscpp.cc
tests/check/libs/libsabi.c
tests/check/libs/netbuffer.c
tests/check/libs/pbutils.c
tests/check/libs/profile.c
tests/check/libs/rtp.c
tests/check/libs/struct_i386.h
tests/check/libs/struct_x86_64.h
tests/check/libs/tag.c
tests/check/libs/video.c
tests/check/libs/xmpwriter.c
tests/check/pipelines/oggmux.c
tests/check/pipelines/streamheader.c
tests/check/pipelines/vorbisenc.c
tests/examples/app/appsink-src.c
tests/examples/app/appsrc-ra.c
tests/examples/app/appsrc-seekable.c
tests/examples/app/appsrc-stream.c
tests/examples/app/appsrc-stream2.c
tests/examples/app/appsrc_ex.c
tests/examples/seek/jsseek.c
tests/examples/seek/seek.c
tests/examples/snapshot/snapshot.c
tests/icles/playbin-text.c
tools/gst-discoverer.c
win32/common/libgstapp.def
win32/common/libgstnetbuffer.def
win32/common/libgstrtp.def
win32/common/libgsttag.def

index c67a1df..b370591 100644 (file)
@@ -19,14 +19,14 @@ LOCAL_SRC_FILES:= $(addprefix ../,$(alsa_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
        libdl                   \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstinterfaces-0.10   \
-       libgstaudio-0.10
+       libgstinterfaces-0.11   \
+       libgstaudio-0.11
 
 LOCAL_MODULE:= libgstalsa
 
@@ -39,8 +39,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H       -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 
 
 $(TARGET_OUT)/lib/libgstalsa.so:
index 88dfb7d..ffa9459 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_app_COPY_HEADERS_TO := gstreamer-0.10/gst/app
+gst_app_COPY_HEADERS_TO := gstreamer-0.11/gst/app
 gst_app_COPY_HEADERS := \
        ../gst-libs/gst/app/gstappbuffer.h \
        ../gst-libs/gst/app/gstappsink.h \
@@ -20,14 +20,14 @@ app_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(app_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0 
 
-LOCAL_MODULE:= libgstapp-0.10
+LOCAL_MODULE:= libgstapp-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H         -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index 8e067fc..179e6c8 100644 (file)
@@ -10,13 +10,13 @@ app_plugin_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(app_plugin_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstapp-0.10
+       libgstapp-0.11
 
 LOCAL_MODULE:= libgstapp
 
@@ -27,8 +27,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index fa24286..cb613a5 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_audio_COPY_HEADERS_TO := gstreamer-0.10/gst/audio
+gst_audio_COPY_HEADERS_TO := gstreamer-0.11/gst/audio
 gst_audio_COPY_HEADERS_BASE := \
        gst-libs/gst/audio/audio.h \
        gst-libs/gst/audio/gstaudioclock.h \
@@ -39,15 +39,15 @@ audio_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(audio_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstinterfaces-0.10
+       libgstinterfaces-0.11
 
-LOCAL_MODULE:= libgstaudio-0.10
+LOCAL_MODULE:= libgstaudio-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index 015f39c..059b295 100644 (file)
@@ -15,14 +15,14 @@ audioconvert_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(audioconvert_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstaudio-0.10        \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstaudio-0.11        \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-    libgstpbutils-0.10
+    libgstpbutils-0.11
 
 LOCAL_MODULE:= libgstaudioconvert
 
@@ -33,8 +33,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index 2d20164..3a94fee 100644 (file)
@@ -11,13 +11,13 @@ decodebin_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(decodebin_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstpbutils-0.10
+       libgstpbutils-0.11
 
 LOCAL_MODULE:= libgstdecodebin
 
@@ -28,8 +28,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H       -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index 30f0ace..c9d32f2 100644 (file)
@@ -13,13 +13,13 @@ decodebin2_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(decodebin2_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstpbutils-0.10
+       libgstpbutils-0.11
 
 LOCAL_MODULE:= libgstdecodebin2
 
@@ -30,8 +30,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H        \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index 156bf28..801ad80 100644 (file)
@@ -12,13 +12,13 @@ gdp_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(gdp_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstdataprotocol-0.10
+       libgstdataprotocol-0.11
 
 LOCAL_MODULE:= libgstgdp
 
@@ -29,8 +29,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H  -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index 61564b3..4f43a82 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_interfaces_COPY_HEADERS_TO := gstreamer-0.10/gst/interfaces
+gst_interfaces_COPY_HEADERS_TO := gstreamer-0.11/gst/interfaces
 gst_interfaces_COPY_HEADERS_BASE := \
        gst-libs/gst/interfaces/colorbalance.h \
        gst-libs/gst/interfaces/colorbalancechannel.h \
@@ -45,15 +45,14 @@ LOCAL_SRC_FILES:= $(addprefix ../,$(interfaces_LOCAL_SRC_FILES_BASE)) \
                                  $(addprefix ../android/,$(interfaces_LOCAL_SRC_FILES_ANDROID))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0
 
-LOCAL_MODULE:= libgstinterfaces-0.10
-
+LOCAL_MODULE:= libgstinterfaces-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index fd904bd..8b217f9 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_netbuffer_COPY_HEADERS_TO := gstreamer-0.10/gst/netbuffer
+gst_netbuffer_COPY_HEADERS_TO := gstreamer-0.11/gst/netbuffer
 gst_netbuffer_COPY_HEADERS := \
        ../gst-libs/gst/netbuffer/gstnetbuffer.h
 
@@ -15,14 +15,14 @@ netbuffer_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(netbuffer_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0
 
-LOCAL_MODULE:= libgstnetbuffer-0.10
+LOCAL_MODULE:= libgstnetbuffer-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index a9aebac..52ca383 100644 (file)
@@ -3,7 +3,7 @@ include $(CLEAR_VARS)
 
 GST_PBUTILS_DIR := gst-libs/gst/pbutils/
 
-gst_pbutils_COPY_HEADERS_TO := gstreamer-0.10/gst/pbutils
+gst_pbutils_COPY_HEADERS_TO := gstreamer-0.11/gst/pbutils
 gst_pbutils_COPY_HEADERS_BASE := \
        gst-libs/gst/pbutils/descriptions.h \
        gst-libs/gst/pbutils/install-plugins.h \
@@ -45,15 +45,15 @@ $(BUILT_SOURCES):
 
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstvideo-0.10        \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstvideo-0.11        \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     
 
-LOCAL_MODULE:= libgstpbutils-0.10
+LOCAL_MODULE:= libgstpbutils-0.11
 LOCAL_CFLAGS := -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
 #
index e792429..b81bf9e 100644 (file)
@@ -19,15 +19,15 @@ playbin_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(playbin_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstpbutils-0.10              \
-       libgstinterfaces-0.10   \
-       libgstvideo-0.10
+       libgstpbutils-0.11              \
+       libgstinterfaces-0.11   \
+       libgstvideo-0.11
 
 LOCAL_MODULE:= libgstplaybin
 
@@ -38,8 +38,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index 6c5fcd4..29b9929 100644 (file)
@@ -12,13 +12,13 @@ LOCAL_SRC_FILES:= $(addprefix ../,$(queue2_LOCAL_SRC_FILES_BASE))
 
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstpbutils-0.10
+       libgstpbutils-0.11
 
 LOCAL_MODULE:= libgstqueue2
 
@@ -29,7 +29,7 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H       \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 
 include $(BUILD_SHARED_LIBRARY)
index 759bdad..958235b 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_riffs_COPY_HEADERS_TO := gstreamer-0.10/gst/riff
+gst_riffs_COPY_HEADERS_TO := gstreamer-0.11/gst/riff
 gst_riffs_COPY_HEADERS := \
        ../gst-libs/gst/riff/riff-ids.h \
        ../gst-libs/gst/riff/riff-media.h \
@@ -19,17 +19,17 @@ riff_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(riff_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgsttag-0.10          \
-    libgstaudio-0.10     
+       libgsttag-0.11          \
+    libgstaudio-0.11     
 
 
-LOCAL_MODULE:= libgstriff-0.10
+LOCAL_MODULE:= libgstriff-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H         -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index 7ad0071..f39f86c 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_rtp_COPY_HEADERS_TO := gstreamer-0.10/gst/rtp
+gst_rtp_COPY_HEADERS_TO := gstreamer-0.11/gst/rtp
 gst_rtp_COPY_HEADERS := \
        ../gst-libs/gst/rtp/gstbasertpaudiopayload.h \
        ../gst-libs/gst/rtp/gstbasertpdepayload.h \
@@ -26,14 +26,14 @@ LOCAL_SRC_FILES:= $(addprefix ../,$(rtp_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
        libdl                   \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0             
 
-LOCAL_MODULE:= libgstrtp-0.10
+LOCAL_MODULE:= libgstrtp-0.11
 LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
 #
index fdc07b9..4f61f4e 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_rtsp_COPY_HEADERS_TO := gstreamer-0.10/gst/rtsp
+gst_rtsp_COPY_HEADERS_TO := gstreamer-0.11/gst/rtsp
 gst_rtsp_COPY_HEADERS_BASE := \
        gst-libs/gst/rtsp/gstrtspbase64.h \
        gst-libs/gst/rtsp/gstrtspdefs.h \
@@ -34,14 +34,14 @@ rtsp_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(rtsp_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0
 
-LOCAL_MODULE:= libgstrtsp-0.10
+LOCAL_MODULE:= libgstrtsp-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H -DINET_ADDRSTRLEN=16 -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index b83002c..7d0e7e8 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_sdp_COPY_HEADERS_TO := gstreamer-0.10/gst/sdp
+gst_sdp_COPY_HEADERS_TO := gstreamer-0.11/gst/sdp
 gst_sdp_COPY_HEADERS := \
        ../gst-libs/gst/sdp/gstsdp.h \
        ../gst-libs/gst/sdp/gstsdpmessage.h
@@ -16,14 +16,14 @@ sdp_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(sdp_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0
 
-LOCAL_MODULE:= libgstsdp-0.10
+LOCAL_MODULE:= libgstsdp-0.11
 LOCAL_CFLAGS := -DHAVE_CONFIG_H  -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
 #
index e4eaee6..7ca9081 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_tag_COPY_HEADERS_TO := gstreamer-0.10/gst/tag
+gst_tag_COPY_HEADERS_TO := gstreamer-0.11/gst/tag
 gst_tag_COPY_HEADERS := \
        ../gst-libs/gst/tag/gsttagdemux.h \
        ../gst-libs/gst/tag/tag.h
@@ -22,15 +22,14 @@ tag_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(tag_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0
 
-LOCAL_MODULE:= libgsttag-0.10
-
+LOCAL_MODULE:= libgsttag-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index 28f1dca..a4d6aa8 100644 (file)
@@ -18,13 +18,13 @@ tcp_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(tcp_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0                     \
-       libgstdataprotocol-0.10
+       libgstdataprotocol-0.11
 
 LOCAL_MODULE:= libgsttcp
 
@@ -35,8 +35,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H  -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index 2650e2b..c1c267c 100644 (file)
@@ -10,9 +10,9 @@ typefindfunctions_LOCAL_SRC_FILES:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(typefindfunctions_LOCAL_SRC_FILES))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
-    libgstpbutils-0.10     \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
+    libgstpbutils-0.11     \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
@@ -27,8 +27,8 @@ LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
 #
 LOCAL_PRELINK_MODULE := false
 
-#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.10
-LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.10
+#It's a gstreamer plugins, and it must be installed on ..../lib/gstreamer-0.11
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/gstreamer-0.11
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
index fdfb6a2..f92949a 100644 (file)
@@ -1,7 +1,7 @@
 LOCAL_PATH:= $(call my-dir)
 #----------------------------------------
 # include 
-gst_video_COPY_HEADERS_TO := gstreamer-0.10/gst/video
+gst_video_COPY_HEADERS_TO := gstreamer-0.11/gst/video
 gst_video_COPY_HEADERS_BASE := \
        gst-libs/gst/video/gstvideofilter.h \
        gst-libs/gst/video/gstvideosink.h \
@@ -24,14 +24,14 @@ video_LOCAL_SRC_FILES_BASE:= \
 LOCAL_SRC_FILES:= $(addprefix ../,$(video_LOCAL_SRC_FILES_BASE))
 
 LOCAL_SHARED_LIBRARIES := \
-    libgstreamer-0.10       \
-    libgstbase-0.10         \
+    libgstreamer-0.11       \
+    libgstbase-0.11         \
     libglib-2.0             \
     libgthread-2.0          \
     libgmodule-2.0          \
     libgobject-2.0
 
-LOCAL_MODULE:= libgstvideo-0.10
+LOCAL_MODULE:= libgstvideo-0.11
 
 LOCAL_CFLAGS := -DHAVE_CONFIG_H        -DGSTREAMER_BUILT_FOR_ANDROID \
        $(GST_PLUGINS_BASE_CFLAGS)
index b91b4f4..f061c74 100644 (file)
@@ -5,7 +5,7 @@ dnl please read gstreamer/docs/random/autotools before changing this file
 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/prerelease
-AC_INIT(GStreamer Base Plug-ins, 0.10.32.1,
+AC_INIT(GStreamer Base Plug-ins, 0.11.0.1,
     http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
     gst-plugins-base)
 
@@ -40,7 +40,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],
 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)
 
 dnl CURRENT, REVISION, AGE
@@ -60,7 +60,7 @@ AC_LIBTOOL_WIN32_DLL
 AM_PROG_LIBTOOL
 
 dnl *** required versions of GStreamer stuff ***
-GST_REQ=0.10.32.1
+GST_REQ=0.11.0
 
 dnl *** autotools stuff ****
 
@@ -439,7 +439,7 @@ AG_GST_CHECK_PLUGIN(volume)
 
 dnl check for gstreamer core features (subsystems)
 dnl FIXME: this assumes srcdir == builddir for uninstalled setups
-GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
+GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.11`"/gst/gstconfig.h"
 AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
 AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1")
 
@@ -1059,7 +1059,7 @@ sed \
     -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\"/" \
index 83596a3..97d5f5e 100644 (file)
 #include "gstalsadeviceprobe.h"
 #include "gst/interfaces/propertyprobe.h"
 
+G_LOCK_DEFINE_STATIC (probe_lock);
+
 static const GList *
 gst_alsa_device_property_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) {
     GParamSpec *pspec;
@@ -43,7 +43,7 @@ gst_alsa_device_property_probe_get_properties (GstPropertyProbe * probe)
     list = g_list_append (NULL, pspec);
   }
 
-  GST_CLASS_UNLOCK (GST_OBJECT_CLASS (klass));
+  G_UNLOCK (probe_lock);
 
   return list;
 }
index 5ea182d..bb1edbf 100644 (file)
@@ -400,7 +400,7 @@ gst_cd_paranoia_src_read_sector (GstCddaBaseSrc * cddabasesrc, gint sector)
     goto read_failed;
 
   buf = gst_buffer_new_and_alloc (CD_FRAMESIZE_RAW);
-  memcpy (GST_BUFFER_DATA (buf), cdda_buf, CD_FRAMESIZE_RAW);
+  gst_buffer_fill (buf, 0, cdda_buf, CD_FRAMESIZE_RAW);
 
   /* cdda base class will take care of timestamping etc. */
   ++src->next_sector;
index 40a64eb..123949b 100644 (file)
@@ -267,26 +267,32 @@ gst_gio_base_sink_render (GstBaseSink * base_sink, GstBuffer * buffer)
 {
   GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
   gssize written;
+  guint8 *data;
+  gsize size;
   gboolean success;
   GError *err = NULL;
 
   g_return_val_if_fail (G_IS_OUTPUT_STREAM (sink->stream), GST_FLOW_ERROR);
 
-  GST_LOG_OBJECT (sink, "writing %u bytes to offset %" G_GUINT64_FORMAT,
-      GST_BUFFER_SIZE (buffer), sink->position);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
-  written = g_output_stream_write (sink->stream,
-      GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), sink->cancel, &err);
+  GST_LOG_OBJECT (sink,
+      "writing %" G_GSIZE_FORMAT " bytes to offset %" G_GUINT64_FORMAT, size,
+      sink->position);
+
+  written =
+      g_output_stream_write (sink->stream, data, size, sink->cancel, &err);
+  gst_buffer_unmap (buffer, data, size);
 
   success = (written >= 0);
 
-  if (G_UNLIKELY (success && written < GST_BUFFER_SIZE (buffer))) {
+  if (G_UNLIKELY (success && written < size)) {
     /* FIXME: Can this happen?  Should we handle it gracefully?  gnomevfssink
      * doesn't... */
     GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
         ("Could not write to stream: (short write, only %"
-            G_GSSIZE_FORMAT " bytes of %d bytes written)",
-            written, GST_BUFFER_SIZE (buffer)));
+            G_GSSIZE_FORMAT " bytes of %" G_GSIZE_FORMAT " bytes written)",
+            written, size));
     return GST_FLOW_ERROR;
   }
 
index 133e12c..7850f9d 100644 (file)
@@ -327,14 +327,14 @@ gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
     GST_DEBUG_OBJECT (src, "Creating subbuffer from cached buffer: offset %"
         G_GUINT64_FORMAT " length %u", offset, size);
 
-    buf = gst_buffer_create_sub (src->cache,
+    buf = gst_buffer_copy_region (src->cache, GST_BUFFER_COPY_ALL,
         offset - GST_BUFFER_OFFSET (src->cache), size);
 
     GST_BUFFER_OFFSET (buf) = offset;
     GST_BUFFER_OFFSET_END (buf) = offset + size;
-    GST_BUFFER_SIZE (buf) = size;
   } else {
     guint cachesize = MAX (4096, size);
+    guint8 *bdata;
     gssize read, res;
     gboolean success, eos;
     GError *err = NULL;
@@ -357,7 +357,7 @@ gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
         return ret;
     }
 
-    src->cache = gst_buffer_try_new_and_alloc (cachesize);
+    src->cache = gst_buffer_new_and_alloc (cachesize);
     if (G_UNLIKELY (src->cache == NULL)) {
       GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", cachesize);
       return GST_FLOW_ERROR;
@@ -371,13 +371,14 @@ gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
      * supports reads up to 64k. So we loop here until we get at
      * at least the requested amount of bytes or a read returns
      * nothing. */
+    bdata = gst_buffer_map (src->cache, NULL, NULL, GST_MAP_WRITE);
     read = 0;
     while (size - read > 0 && (res =
             g_input_stream_read (G_INPUT_STREAM (src->stream),
-                GST_BUFFER_DATA (src->cache) + read, cachesize - read,
-                src->cancel, &err)) > 0) {
+                bdata + read, cachesize - read, src->cancel, &err)) > 0) {
       read += res;
     }
+    gst_buffer_unmap (src->cache, bdata, read);
 
     success = (read >= 0);
     eos = (cachesize > 0 && read == 0);
@@ -390,7 +391,6 @@ gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
 
     if (success && !eos) {
       src->position += read;
-      GST_BUFFER_SIZE (src->cache) = read;
 
       GST_BUFFER_OFFSET (src->cache) = offset;
       GST_BUFFER_OFFSET_END (src->cache) = offset + read;
@@ -400,11 +400,12 @@ gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
           "cached buffer: offset %" G_GUINT64_FORMAT " length %u", offset,
           size);
 
-      buf = gst_buffer_create_sub (src->cache, 0, MIN (size, read));
+      buf =
+          gst_buffer_copy_region (src->cache, GST_BUFFER_COPY_ALL, 0, MIN (size,
+              read));
 
       GST_BUFFER_OFFSET (buf) = offset;
       GST_BUFFER_OFFSET_END (buf) = offset + MIN (size, read);
-      GST_BUFFER_SIZE (buf) = MIN (size, read);
     } else {
       GST_DEBUG_OBJECT (src, "Read not successful");
       gst_buffer_unref (src->cache);
index 1a5f31f..cd7a5dd 100644 (file)
@@ -523,6 +523,8 @@ gst_gnome_vfs_sink_render (GstBaseSink * basesink, GstBuffer * buf)
   GstGnomeVFSSink *sink;
   GnomeVFSResult result;
   GstFlowReturn ret;
+  guint8 *data;
+  gsize size;
 
   sink = GST_GNOME_VFS_SINK (basesink);
 
@@ -531,22 +533,22 @@ gst_gnome_vfs_sink_render (GstBaseSink * basesink, GstBuffer * buf)
     sink->current_pos = cur_pos;
   }
 
-  result = gnome_vfs_write (sink->handle, GST_BUFFER_DATA (buf),
-      GST_BUFFER_SIZE (buf), &written);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  result = gnome_vfs_write (sink->handle, data, size, &written);
+  gst_buffer_unmap (buf, data, size);
 
   switch (result) {
     case GNOME_VFS_OK:{
       GST_DEBUG_OBJECT (sink, "wrote %" G_GINT64_FORMAT " bytes at %"
           G_GINT64_FORMAT, (gint64) written, (gint64) cur_pos);
 
-      if (written < GST_BUFFER_SIZE (buf)) {
+      if (written < size) {
         /* FIXME: what to do here? (tpm) */
-        g_warning ("%s: %d bytes should be written, only %"
-            G_GUINT64_FORMAT " bytes written", G_STRLOC,
-            GST_BUFFER_SIZE (buf), written);
+        g_warning ("%s: %" G_GSIZE_FORMAT " bytes should be written, only %"
+            G_GUINT64_FORMAT " bytes written", G_STRLOC, size, written);
       }
 
-      sink->current_pos += GST_BUFFER_SIZE (buf);
+      sink->current_pos += size;
       ret = GST_FLOW_OK;
       break;
     }
@@ -554,7 +556,7 @@ gst_gnome_vfs_sink_render (GstBaseSink * basesink, GstBuffer * buf)
       /* TODO: emit signal/send msg on out-of-diskspace and
        * handle this gracefully (see open bug) (tpm) */
       GST_ELEMENT_ERROR (sink, RESOURCE, NO_SPACE_LEFT, (NULL),
-          ("bufsize=%u, written=%u", GST_BUFFER_SIZE (buf), (guint) written));
+          ("bufsize=%u, written=%u", size, (guint) written));
       ret = GST_FLOW_ERROR;
       break;
     }
@@ -565,7 +567,7 @@ gst_gnome_vfs_sink_render (GstBaseSink * basesink, GstBuffer * buf)
       GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
           (_("Error while writing to file \"%s\"."), filename),
           ("%s, bufsize=%u, written=%u", gnome_vfs_result_to_string (result),
-              GST_BUFFER_SIZE (buf), (guint) written));
+              size, (guint) written));
 
       g_free (filename);
       ret = GST_FLOW_ERROR;
index 4b2507c..7ad03ca 100644 (file)
@@ -601,8 +601,8 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
   GnomeVFSResult res;
   GstBuffer *buf;
   GnomeVFSFileSize readbytes;
-  guint8 *data;
-  guint todo;
+  guint8 *data, *ptr;
+  gsize todo;
   GstGnomeVFSSrc *src;
 
   src = GST_GNOME_VFS_SRC (basesrc);
@@ -624,18 +624,19 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
     }
   }
 
-  buf = gst_buffer_try_new_and_alloc (size);
+  buf = gst_buffer_new_and_alloc (size);
   if (G_UNLIKELY (buf == NULL)) {
     GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", size);
     return GST_FLOW_ERROR;
   }
 
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
 
+  ptr = data;
   todo = size;
   while (todo > 0) {
     /* this can return less that we ask for */
-    res = gnome_vfs_read (src->handle, data, todo, &readbytes);
+    res = gnome_vfs_read (src->handle, ptr, todo, &readbytes);
 
     if (G_UNLIKELY (res == GNOME_VFS_ERROR_EOF || (res == GNOME_VFS_OK
                 && readbytes == 0)))
@@ -645,13 +646,15 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
       goto read_failed;
 
     if (readbytes < todo) {
-      data = &data[readbytes];
+      ptr += readbytes;
       todo -= readbytes;
     } else {
       todo = 0;
     }
     GST_LOG ("  got size %" G_GUINT64_FORMAT, readbytes);
   }
+  gst_buffer_unmap (buf, data, size);
+
   GST_BUFFER_OFFSET (buf) = src->curoffset;
   src->curoffset += size;
 
@@ -676,6 +679,7 @@ cannot_seek:
   }
 read_failed:
   {
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
         ("Failed to read data: %s", gnome_vfs_result_to_string (res)));
@@ -683,6 +687,7 @@ read_failed:
   }
 eos:
   {
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     GST_DEBUG_OBJECT (src, "Reading data gave EOS");
     return GST_FLOW_UNEXPECTED;
index 48c1e27..6c71c05 100644 (file)
@@ -642,7 +642,8 @@ gst_visual_chain (GstPad * pad, GstBuffer * buffer)
 
   GST_DEBUG_OBJECT (visual,
       "Input buffer has %d samples, time=%" G_GUINT64_FORMAT,
-      GST_BUFFER_SIZE (buffer) / visual->bps, GST_BUFFER_TIMESTAMP (buffer));
+      gst_buffer_get_size (buffer) / visual->bps,
+      GST_BUFFER_TIMESTAMP (buffer));
 
   gst_adapter_push (visual->adapter, buffer);
 
@@ -650,6 +651,8 @@ gst_visual_chain (GstPad * pad, GstBuffer * buffer)
     gboolean need_skip;
     const guint16 *data;
     guint64 dist, timestamp;
+    guint8 *outdata;
+    gsize outsize;
 
     GST_DEBUG_OBJECT (visual, "processing buffer");
 
@@ -696,7 +699,7 @@ gst_visual_chain (GstPad * pad, GstBuffer * buffer)
 
     /* Read VISUAL_SAMPLES samples per channel */
     data =
-        (const guint16 *) gst_adapter_peek (visual->adapter,
+        (const guint16 *) gst_adapter_map (visual->adapter,
         VISUAL_SAMPLES * visual->bps);
 
 #if defined(VISUAL_API_VERSION) && VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
@@ -782,15 +785,20 @@ gst_visual_chain (GstPad * pad, GstBuffer * buffer)
     if (outbuf == NULL) {
       ret = get_buffer (visual, &outbuf);
       if (ret != GST_FLOW_OK) {
+        gst_adapter_unmap (visual->adapter, 0);
         goto beach;
       }
     }
-    visual_video_set_buffer (visual->video, GST_BUFFER_DATA (outbuf));
+    outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
+    visual_video_set_buffer (visual->video, outdata);
     visual_audio_analyze (visual->audio);
     visual_actor_run (visual->actor, visual->audio);
     visual_video_set_buffer (visual->video, NULL);
+    gst_buffer_unmap (outbuf, outdata, outsize);
     GST_DEBUG_OBJECT (visual, "rendered one frame");
 
+    gst_adapter_unmap (visual->adapter, 0);
+
     GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
     GST_BUFFER_DURATION (outbuf) = visual->duration;
 
@@ -828,8 +836,8 @@ gst_visual_change_state (GstElement * element, GstStateChange transition)
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
       visual->actor =
-          visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info->
-          plugname);
+          visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->
+          info->plugname);
       visual->video = visual_video_new ();
       visual->audio = visual_audio_new ();
       /* can't have a play without actors */
index 2851e52..1ebd09f 100644 (file)
@@ -196,8 +196,8 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
   GstStructure *structure;
   const GValue *codec_data;
   GstBuffer *buffer;
-  guint8 *data;
-  guint size;
+  guint8 *data, *ptr;
+  gsize size, left;
   guint32 sizes[3];
   GstCaps *outcaps;
   gint i, offs;
@@ -221,31 +221,33 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
   /* first 22 bytes are bits_per_sample, channel_mask, GUID
    * Then we get 3 LE guint32 with the 3 header sizes
    * then we get the bytes of the 3 headers. */
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  ptr = data;
+  left = size;
 
-  GST_LOG_OBJECT (ogg, "configuring codec_data of size %u", size);
+  GST_LOG_OBJECT (ogg, "configuring codec_data of size %u", left);
 
   /* skip headers */
-  data += 22;
-  size -= 22;
+  ptr += 22;
+  left -= 22;
 
   /* we need at least 12 bytes for the packet sizes of the 3 headers */
-  if (size < 12)
+  if (left < 12)
     goto buffer_too_small;
 
   /* read sizes of the 3 headers */
-  sizes[0] = GST_READ_UINT32_LE (data);
-  sizes[1] = GST_READ_UINT32_LE (data + 4);
-  sizes[2] = GST_READ_UINT32_LE (data + 8);
+  sizes[0] = GST_READ_UINT32_LE (ptr);
+  sizes[1] = GST_READ_UINT32_LE (ptr + 4);
+  sizes[2] = GST_READ_UINT32_LE (ptr + 8);
 
   GST_DEBUG_OBJECT (ogg, "header sizes: %u %u %u", sizes[0], sizes[1],
       sizes[2]);
 
-  size -= 12;
+  left -= 12;
 
   /* and we need at least enough data for all the headers */
-  if (size < sizes[0] + sizes[1] + sizes[2])
+  if (left < sizes[0] + sizes[1] + sizes[2])
     goto buffer_too_small;
 
   /* set caps */
@@ -258,12 +260,13 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
     GstBuffer *out;
 
     /* now output the raw vorbis header packets */
-    out = gst_buffer_create_sub (buffer, offs, sizes[i]);
+    out = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offs, sizes[i]);
     gst_buffer_set_caps (out, outcaps);
     gst_pad_push (ogg->srcpad, out);
 
     offs += sizes[i];
   }
+  gst_buffer_unmap (buffer, data, size);
   gst_caps_unref (outcaps);
 
   return TRUE;
@@ -282,6 +285,7 @@ wrong_format:
 buffer_too_small:
   {
     GST_DEBUG_OBJECT (ogg, "codec_data is too small");
+    gst_buffer_unmap (buffer, data, size);
     return FALSE;
   }
 }
@@ -319,7 +323,7 @@ gst_ogg_avi_parse_push_packet (GstOggAviParse * ogg, ogg_packet * packet)
 
   /* allocate space for header and body */
   buffer = gst_buffer_new_and_alloc (packet->bytes);
-  memcpy (GST_BUFFER_DATA (buffer), packet->packet, packet->bytes);
+  gst_buffer_fill (buffer, 0, packet->packet, packet->bytes);
 
   GST_LOG_OBJECT (ogg, "created buffer %p from page", buffer);
 
@@ -340,15 +344,13 @@ gst_ogg_avi_parse_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstFlowReturn result = GST_FLOW_OK;
   GstOggAviParse *ogg;
-  guint8 *data;
   guint size;
   gchar *oggbuf;
   gint ret = -1;
 
   ogg = GST_OGG_AVI_PARSE (GST_OBJECT_PARENT (pad));
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  size = gst_buffer_get_size (buffer);
 
   GST_LOG_OBJECT (ogg, "Chain function received buffer of size %d", size);
 
@@ -359,7 +361,7 @@ gst_ogg_avi_parse_chain (GstPad * pad, GstBuffer * buffer)
 
   /* write data to sync layer */
   oggbuf = ogg_sync_buffer (&ogg->sync, size);
-  memcpy (oggbuf, data, size);
+  gst_buffer_extract (buffer, 0, oggbuf, size);
   ogg_sync_wrote (&ogg->sync, size);
   gst_buffer_unref (buffer);
 
index 67d2321..e084546 100644 (file)
@@ -581,7 +581,8 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
     GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
 
   /* copy packet in buffer */
-  memcpy (buf->data, packet->packet + offset, packet->bytes - offset - trim);
+  gst_buffer_fill (buf, 0, packet->packet + offset,
+      packet->bytes - offset - trim);
 
   GST_BUFFER_TIMESTAMP (buf) = out_timestamp;
   GST_BUFFER_DURATION (buf) = out_duration;
@@ -1157,8 +1158,7 @@ gst_ogg_chain_new_stream (GstOggChain * chain, glong serialno)
 
   ret = g_object_new (GST_TYPE_OGG_PAD, NULL);
   /* we own this one */
-  gst_object_ref (ret);
-  gst_object_sink (ret);
+  gst_object_ref_sink (ret);
 
   GST_PAD_DIRECTION (ret) = GST_PAD_SRC;
   gst_ogg_pad_mark_discont (ret);
@@ -1401,15 +1401,14 @@ gst_ogg_demux_sink_event (GstPad * pad, GstEvent * event)
 static GstFlowReturn
 gst_ogg_demux_submit_buffer (GstOggDemux * ogg, GstBuffer * buffer)
 {
-  gint size;
+  gsize size;
   guint8 *data;
   gchar *oggbuffer;
   GstFlowReturn ret = GST_FLOW_OK;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
-  GST_DEBUG_OBJECT (ogg, "submitting %u bytes", size);
+  GST_DEBUG_OBJECT (ogg, "submitting %" G_GSIZE_FORMAT " bytes", size);
   if (G_UNLIKELY (size == 0))
     goto done;
 
@@ -1422,6 +1421,7 @@ gst_ogg_demux_submit_buffer (GstOggDemux * ogg, GstBuffer * buffer)
     goto write_failed;
 
 done:
+  gst_buffer_unmap (buffer, data, size);
   gst_buffer_unref (buffer);
 
   return ret;
@@ -1480,7 +1480,7 @@ gst_ogg_demux_get_data (GstOggDemux * ogg, gint64 end_offset)
   if (ret != GST_FLOW_OK)
     goto error;
 
-  ogg->read_offset += GST_BUFFER_SIZE (buffer);
+  ogg->read_offset += gst_buffer_get_size (buffer);
 
   ret = gst_ogg_demux_submit_buffer (ogg, buffer);
 
@@ -1726,7 +1726,7 @@ gst_ogg_demux_set_header_on_caps (GstOggDemux * ogg, GstCaps * caps,
     ogg_packet *op = headers->data;
     g_assert (op);
     buffer = gst_buffer_new_and_alloc (op->bytes);
-    memcpy (GST_BUFFER_DATA (buffer), op->packet, op->bytes);
+    gst_buffer_fill (buffer, 0, op->packet, op->bytes);
     GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
     g_value_init (&value, GST_TYPE_BUFFER);
     gst_value_take_buffer (&value, buffer);
@@ -3271,7 +3271,7 @@ gst_ogg_demux_loop_forward (GstOggDemux * ogg)
     goto done;
   }
 
-  ogg->offset += GST_BUFFER_SIZE (buffer);
+  ogg->offset += gst_buffer_get_size (buffer);
 
   if (G_UNLIKELY (ogg->newsegment)) {
     gst_ogg_demux_send_event (ogg, ogg->newsegment);
index 9f3047f..ae3a173 100644 (file)
@@ -520,9 +520,8 @@ gst_ogg_mux_buffer_from_page (GstOggMux * mux, ogg_page * page, gboolean delta)
 
   /* allocate space for header and body */
   buffer = gst_buffer_new_and_alloc (page->header_len + page->body_len);
-  memcpy (GST_BUFFER_DATA (buffer), page->header, page->header_len);
-  memcpy (GST_BUFFER_DATA (buffer) + page->header_len,
-      page->body, page->body_len);
+  gst_buffer_fill (buffer, 0, page->header, page->header_len);
+  gst_buffer_fill (buffer, page->header_len, page->body, page->body_len);
 
   /* Here we set granulepos as our OFFSET_END to give easy direct access to
    * this value later. Before we push it, we reset this to OFFSET + SIZE
@@ -546,7 +545,7 @@ gst_ogg_mux_push_buffer (GstOggMux * mux, GstBuffer * buffer,
 
   /* fix up OFFSET and OFFSET_END again */
   GST_BUFFER_OFFSET (buffer) = mux->offset;
-  mux->offset += GST_BUFFER_SIZE (buffer);
+  mux->offset += gst_buffer_get_size (buffer);
   GST_BUFFER_OFFSET_END (buffer) = mux->offset;
 
   /* Ensure we have monotonically increasing timestamps in the output. */
@@ -837,9 +836,10 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux)
           /* and we have one */
           ogg_packet packet;
           gboolean is_header;
+          gsize size;
 
-          packet.packet = GST_BUFFER_DATA (buf);
-          packet.bytes = GST_BUFFER_SIZE (buf);
+          packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+          packet.bytes = size;
 
           if (GST_BUFFER_OFFSET_END_IS_VALID (buf))
             packet.granulepos = GST_BUFFER_OFFSET_END (buf);
@@ -863,6 +863,8 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux)
           else                  /* fallback (FIXME 0.11: remove IN_CAPS hack) */
             is_header = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
 
+          gst_buffer_unmap (buf, packet.packet, size);
+
           if (is_header) {
             GST_DEBUG_OBJECT (ogg_mux,
                 "got header buffer in control state, ignoring");
@@ -1008,7 +1010,8 @@ gst_ogg_mux_set_header_on_caps (GstCaps * caps, GList * buffers)
     walk = walk->next;
 
     /* mark buffer */
-    GST_LOG ("Setting IN_CAPS on buffer of length %d", GST_BUFFER_SIZE (buf));
+    GST_LOG ("Setting IN_CAPS on buffer of length %d",
+        gst_buffer_get_size (buf));
     GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
 
     g_value_init (&value, GST_TYPE_BUFFER);
@@ -1076,6 +1079,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
     GstCaps *caps;
     GstStructure *structure;
     GstBuffer *hbuf;
+    gsize size;
 
     pad = (GstOggPadData *) walk->data;
     thepad = pad->collect.pad;
@@ -1107,8 +1111,8 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
     }
 
     /* create a packet from the buffer */
-    packet.packet = GST_BUFFER_DATA (buf);
-    packet.bytes = GST_BUFFER_SIZE (buf);
+    packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    packet.bytes = size;
     packet.granulepos = GST_BUFFER_OFFSET_END (buf);
     if (packet.granulepos == -1)
       packet.granulepos = 0;
@@ -1120,6 +1124,8 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
 
     /* swap the packet in */
     ogg_stream_packetin (&pad->map.stream, &packet);
+
+    gst_buffer_unmap (buf, packet.packet, size);
     gst_buffer_unref (buf);
 
     GST_LOG_OBJECT (thepad, "flushing out BOS page");
@@ -1172,12 +1178,13 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
       GstBuffer *buf = GST_BUFFER (hwalk->data);
       ogg_packet packet;
       ogg_page page;
+      gsize size;
 
       hwalk = hwalk->next;
 
       /* create a packet from the buffer */
-      packet.packet = GST_BUFFER_DATA (buf);
-      packet.bytes = GST_BUFFER_SIZE (buf);
+      packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+      packet.bytes = size;
       packet.granulepos = GST_BUFFER_OFFSET_END (buf);
       if (packet.granulepos == -1)
         packet.granulepos = 0;
@@ -1189,6 +1196,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
 
       /* swap the packet in */
       ogg_stream_packetin (&pad->map.stream, &packet);
+      gst_buffer_unmap (buf, packet.packet, size);
       gst_buffer_unref (buf);
 
       /* if last header, flush page */
@@ -1345,6 +1353,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
     GstOggPadData *pad = ogg_mux->pulling;
     gint64 duration;
     gboolean force_flush;
+    gsize size;
 
     GST_LOG_OBJECT (ogg_mux->pulling->collect.pad, "pulling from pad");
 
@@ -1368,8 +1377,8 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
           GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
     }
     /* create a packet from the buffer */
-    packet.packet = GST_BUFFER_DATA (buf);
-    packet.bytes = GST_BUFFER_SIZE (buf);
+    packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    packet.bytes = size;
     packet.granulepos = GST_BUFFER_OFFSET_END (buf);
     if (packet.granulepos == -1)
       packet.granulepos = 0;
@@ -1458,6 +1467,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
       GST_DEBUG_OBJECT (pad->collect.pad, "swapping in BOS packet");
 
     ogg_stream_packetin (&pad->map.stream, &packet);
+    gst_buffer_unmap (buf, packet.packet, size);
     pad->data_pushed = TRUE;
 
     gp_time = GST_BUFFER_OFFSET (pad->buffer);
index eae0acd..54e1977 100644 (file)
@@ -286,15 +286,14 @@ gst_ogg_parse_dispose (GObject * object)
 static GstFlowReturn
 gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
 {
-  guint size;
+  gsize size;
   guint8 *data;
   gchar *oggbuffer;
   GstFlowReturn ret = GST_FLOW_OK;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
-  GST_DEBUG_OBJECT (ogg, "submitting %u bytes", size);
+  GST_DEBUG_OBJECT (ogg, "submitting %" G_GSIZE_FORMAT " bytes", size);
   if (G_UNLIKELY (size == 0))
     goto done;
 
@@ -314,6 +313,7 @@ gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
   }
 
 done:
+  gst_buffer_unmap (buffer, data, size);
   gst_buffer_unref (buffer);
 
   return ret;
@@ -368,8 +368,8 @@ gst_ogg_parse_buffer_from_page (ogg_page * page,
   int size = page->header_len + page->body_len;
   GstBuffer *buf = gst_buffer_new_and_alloc (size);
 
-  memcpy (GST_BUFFER_DATA (buf), page->header, page->header_len);
-  memcpy (GST_BUFFER_DATA (buf) + page->header_len, page->body, page->body_len);
+  gst_buffer_fill (buf, 0, page->header, page->header_len);
+  gst_buffer_fill (buf, page->header_len, page->body, page->body_len);
 
   GST_BUFFER_TIMESTAMP (buf) = timestamp;
   GST_BUFFER_OFFSET (buf) = offset;
@@ -394,8 +394,9 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
 
   ogg = GST_OGG_PARSE (GST_OBJECT_PARENT (pad));
 
-  GST_LOG_OBJECT (ogg, "Chain function received buffer of size %d",
-      GST_BUFFER_SIZE (buffer));
+  GST_LOG_OBJECT (ogg,
+      "Chain function received buffer of size %" G_GSIZE_FORMAT,
+      gst_buffer_get_size (buffer));
 
   gst_ogg_parse_submit_buffer (ogg, buffer);
 
@@ -603,7 +604,7 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
               GstOggStream *stream = (GstOggStream *) l->data;
               GstBuffer *buf = GST_BUFFER (stream->headers->data);
 
-              buf = gst_buffer_make_metadata_writable (buf);
+              buf = gst_buffer_make_writable (buf);
               gst_buffer_set_caps (buf, caps);
 
               result = gst_pad_push (ogg->srcpad, buf);
@@ -618,7 +619,7 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
               for (j = stream->headers->next; j != NULL; j = j->next) {
                 GstBuffer *buf = GST_BUFFER (j->data);
 
-                buf = gst_buffer_make_metadata_writable (buf);
+                buf = gst_buffer_make_writable (buf);
                 gst_buffer_set_caps (buf, caps);
 
                 result = gst_pad_push (ogg->srcpad, buf);
@@ -649,7 +650,7 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
               for (k = stream->unknown_pages; k != NULL; k = k->next) {
                 GstBuffer *buf;
 
-                buf = gst_buffer_make_metadata_writable (GST_BUFFER (k->data));
+                buf = gst_buffer_make_writable (GST_BUFFER (k->data));
                 gst_buffer_set_caps (buf, caps);
                 result = gst_pad_push (ogg->srcpad, buf);
                 if (result != GST_FLOW_OK)
@@ -669,7 +670,7 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
             while (stream->stored_buffers) {
               GstBuffer *buf = stream->stored_buffers->data;
 
-              buf = gst_buffer_make_metadata_writable (buf);
+              buf = gst_buffer_make_writable (buf);
               gst_buffer_set_caps (buf, ogg->caps);
               GST_BUFFER_TIMESTAMP (buf) = buffertimestamp;
               if (!keyframe) {
@@ -687,7 +688,7 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
                   stream->stored_buffers);
             }
 
-            pagebuffer = gst_buffer_make_metadata_writable (pagebuffer);
+            pagebuffer = gst_buffer_make_writable (pagebuffer);
             gst_buffer_set_caps (pagebuffer, ogg->caps);
             if (!keyframe) {
               GST_BUFFER_FLAG_SET (pagebuffer, GST_BUFFER_FLAG_DELTA_UNIT);
index 3ef2fd0..6102bcb 100644 (file)
@@ -303,19 +303,14 @@ static gboolean
 tag_list_from_vorbiscomment_packet (ogg_packet * packet,
     const guint8 * id_data, const guint id_data_length, GstTagList ** tags)
 {
-  GstBuffer *buf = NULL;
   gchar *encoder = NULL;
   GstTagList *list;
   gboolean ret = TRUE;
 
   g_return_val_if_fail (tags != NULL, FALSE);
 
-  buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (guint8 *) packet->packet;
-  GST_BUFFER_SIZE (buf) = packet->bytes;
-
-  list = gst_tag_list_from_vorbiscomment_buffer (buf, id_data, id_data_length,
-      &encoder);
+  list = gst_tag_list_from_vorbiscomment (packet->packet, packet->bytes,
+      id_data, id_data_length, &encoder);
 
   if (!list) {
     GST_WARNING ("failed to decode vorbis comments");
@@ -335,8 +330,6 @@ exit:
     gst_tag_list_free (*tags);
   *tags = list;
 
-  gst_buffer_unref (buf);
-
   return ret;
 }
 
index 6b054a2..c046cfb 100644 (file)
@@ -725,32 +725,27 @@ gst_ogm_parse_comment_packet (GstOgmParse * ogm, GstBuffer * buf)
 static void
 gst_ogm_text_parse_strip_trailing_zeroes (GstOgmParse * ogm, GstBuffer * buf)
 {
-  const guint8 *data;
-  guint size;
+  guint8 *data;
+  gsize size;
 
-  g_assert (gst_buffer_is_metadata_writable (buf));
+  g_assert (gst_buffer_is_writable (buf));
 
   /* zeroes are not valid UTF-8 characters, so strip them from output */
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
   while (size > 0 && data[size - 1] == '\0') {
     --size;
   }
-
-  GST_BUFFER_SIZE (buf) = size;
+  gst_buffer_unmap (buf, data, size);
 }
 
 static GstFlowReturn
-gst_ogm_parse_data_packet (GstOgmParse * ogm, GstBuffer * buf)
+gst_ogm_parse_data_packet (GstOgmParse * ogm, GstBuffer * buf,
+    const guint8 * data, gsize size)
 {
   GstFlowReturn ret;
-  const guint8 *data;
   GstBuffer *sbuf;
   gboolean keyframe;
-  guint size, len, n, xsize = 0;
-
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  guint len, n, xsize = 0;
 
   if ((data[0] & 0x01) != 0)
     goto invalid_startcode;
@@ -769,7 +764,9 @@ gst_ogm_parse_data_packet (GstOgmParse * ogm, GstBuffer * buf)
   GST_LOG_OBJECT (ogm, "[0x%02x] samples: %d, hdrbytes: %d, datasize: %d",
       data[0], xsize, len, size - len - 1);
 
-  sbuf = gst_buffer_create_sub (buf, len + 1, size - len - 1);
+  sbuf =
+      gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, len + 1,
+      size - len - 1);
 
   if (GST_BUFFER_OFFSET_END_IS_VALID (buf))
     ogm->next_granulepos = GST_BUFFER_OFFSET_END (buf);
@@ -857,9 +854,10 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buf)
 {
   GstFlowReturn ret = GST_FLOW_OK;
   GstOgmParse *ogm = GST_OGM_PARSE (GST_PAD_PARENT (pad));
-  guint8 *data = GST_BUFFER_DATA (buf);
-  guint size = GST_BUFFER_SIZE (buf);
+  guint8 *data;
+  gsize size;
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   if (size < 1)
     goto buffer_too_small;
 
@@ -875,11 +873,12 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buf)
       break;
     }
     default:{
-      ret = gst_ogm_parse_data_packet (ogm, buf);
+      ret = gst_ogm_parse_data_packet (ogm, buf, data, size);
       break;
     }
   }
 
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   if (ret != GST_FLOW_OK) {
@@ -892,6 +891,7 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buf)
 buffer_too_small:
   {
     GST_ELEMENT_ERROR (ogm, STREAM, DECODE, (NULL), ("buffer too small"));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return GST_FLOW_ERROR;
   }
index 914c216..683a478 100644 (file)
@@ -1859,12 +1859,16 @@ gst_text_overlay_push_frame (GstTextOverlay * overlay, GstBuffer * video_frame)
   gint width, height;
   GstTextOverlayVAlign valign;
   GstTextOverlayHAlign halign;
+  guint8 *data;
+  gsize size;
 
   width = overlay->image_width;
   height = overlay->image_height;
 
   video_frame = gst_buffer_make_writable (video_frame);
 
+  data = gst_buffer_map (video_frame, &size, NULL, GST_MAP_WRITE);
+
   if (overlay->use_vertical_render)
     halign = GST_TEXT_OVERLAY_HALIGN_RIGHT;
   else
@@ -1925,54 +1929,54 @@ gst_text_overlay_push_frame (GstTextOverlay * overlay, GstBuffer * video_frame)
       case GST_VIDEO_FORMAT_I420:
       case GST_VIDEO_FORMAT_NV12:
       case GST_VIDEO_FORMAT_NV21:
-        gst_text_overlay_shade_planar_Y (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_planar_Y (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_AYUV:
       case GST_VIDEO_FORMAT_UYVY:
-        gst_text_overlay_shade_packed_Y (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_packed_Y (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_xRGB:
-        gst_text_overlay_shade_xRGB (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_xRGB (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_xBGR:
-        gst_text_overlay_shade_xBGR (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_xBGR (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_BGRx:
-        gst_text_overlay_shade_BGRx (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_BGRx (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_RGBx:
-        gst_text_overlay_shade_RGBx (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_RGBx (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_ARGB:
-        gst_text_overlay_shade_ARGB (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_ARGB (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_ABGR:
-        gst_text_overlay_shade_ABGR (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_ABGR (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_RGBA:
-        gst_text_overlay_shade_RGBA (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_RGBA (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       case GST_VIDEO_FORMAT_BGRA:
-        gst_text_overlay_shade_BGRA (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
+        gst_text_overlay_shade_BGRA (overlay, data,
+            xpos, xpos + overlay->image_width,
             ypos, ypos + overlay->image_height);
         break;
       default:
@@ -1986,58 +1990,48 @@ gst_text_overlay_push_frame (GstTextOverlay * overlay, GstBuffer * video_frame)
   if (overlay->text_image) {
     switch (overlay->format) {
       case GST_VIDEO_FORMAT_I420:
-        gst_text_overlay_blit_I420 (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_I420 (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_NV12:
       case GST_VIDEO_FORMAT_NV21:
-        gst_text_overlay_blit_NV12_NV21 (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_NV12_NV21 (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_UYVY:
-        gst_text_overlay_blit_UYVY (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_UYVY (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_AYUV:
-        gst_text_overlay_blit_AYUV (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_AYUV (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_BGRx:
-        gst_text_overlay_blit_BGRx (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_BGRx (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_xRGB:
-        gst_text_overlay_blit_xRGB (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_xRGB (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_RGBx:
-        gst_text_overlay_blit_RGBx (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_RGBx (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_xBGR:
-        gst_text_overlay_blit_xBGR (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_xBGR (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_ARGB:
-        gst_text_overlay_blit_ARGB (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_ARGB (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_ABGR:
-        gst_text_overlay_blit_ABGR (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_ABGR (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_RGBA:
-        gst_text_overlay_blit_RGBA (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_RGBA (overlay, data, xpos, ypos);
         break;
       case GST_VIDEO_FORMAT_BGRA:
-        gst_text_overlay_blit_BGRA (overlay,
-            GST_BUFFER_DATA (video_frame), xpos, ypos);
+        gst_text_overlay_blit_BGRA (overlay, data, xpos, ypos);
         break;
       default:
         g_assert_not_reached ();
     }
   }
+  gst_buffer_unmap (video_frame, data, size);
+
   return gst_pad_push (overlay->srcpad, video_frame);
 }
 
@@ -2396,7 +2390,7 @@ gst_text_overlay_video_chain (GstPad * pad, GstBuffer * buffer)
   /* if the buffer is only partially in the segment, fix up stamps */
   if (clip_start != start || (stop != -1 && clip_stop != stop)) {
     GST_DEBUG_OBJECT (overlay, "clipping buffer timestamp/duration to segment");
-    buffer = gst_buffer_make_metadata_writable (buffer);
+    buffer = gst_buffer_make_writable (buffer);
     GST_BUFFER_TIMESTAMP (buffer) = clip_start;
     if (stop != -1)
       GST_BUFFER_DURATION (buffer) = clip_stop - clip_start;
@@ -2524,11 +2518,13 @@ wait_for_text_buf:
         /* Push the video frame */
         ret = gst_pad_push (overlay->srcpad, buffer);
       } else {
-        gchar *in_text;
-        gsize in_size;
+        gchar *in_text, *otext;
+        gsize in_size, osize;
 
-        in_text = (gchar *) GST_BUFFER_DATA (overlay->text_buffer);
-        in_size = GST_BUFFER_SIZE (overlay->text_buffer);
+        otext =
+            gst_buffer_map (overlay->text_buffer, &osize, NULL, GST_MAP_READ);
+        in_text = otext;
+        in_size = osize;
 
         /* g_markup_escape_text() absolutely requires valid UTF8 input, it
          * might crash otherwise. We don't fall back on GST_SUBTITLE_ENCODING
@@ -2562,8 +2558,9 @@ wait_for_text_buf:
           GST_DEBUG_OBJECT (overlay, "No text to render (empty buffer)");
           gst_text_overlay_render_text (overlay, " ", 1);
         }
+        gst_buffer_unmap (overlay->text_buffer, otext, osize);
 
-        if (in_text != (gchar *) GST_BUFFER_DATA (overlay->text_buffer))
+        if (in_text != otext)
           g_free (in_text);
 
         GST_OBJECT_UNLOCK (overlay);
index c937244..0c02ad2 100644 (file)
@@ -466,13 +466,15 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
   GstFlowReturn ret;
   GstBuffer *outbuf;
   GstCaps *caps = NULL;
-  guint8 *data = GST_BUFFER_DATA (inbuf);
-  guint size = GST_BUFFER_SIZE (inbuf);
+  guint8 *data;
+  gsize size;
   gint n;
   gint xpos, ypos;
 
   render = GST_TEXT_RENDER (gst_pad_get_parent (pad));
 
+  data = gst_buffer_map (inbuf, &size, NULL, GST_MAP_READ);
+
   /* somehow pango barfs over "\0" buffers... */
   while (size > 0 &&
       (data[size - 1] == '\r' ||
@@ -484,6 +486,7 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
   GST_DEBUG ("rendering '%*s'", size, data);
   pango_layout_set_markup (render->layout, (gchar *) data, size);
   gst_text_render_render_pangocairo (render);
+  gst_buffer_unmap (inbuf, data, size);
 
   gst_text_render_check_argb (render);
 
@@ -512,8 +515,8 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
   if (ret != GST_FLOW_OK)
     goto done;
 
-  gst_buffer_copy_metadata (outbuf, inbuf, GST_BUFFER_COPY_TIMESTAMPS);
-  data = GST_BUFFER_DATA (outbuf);
+  gst_buffer_copy_into (outbuf, inbuf, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
+  data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
 
   if (render->use_ARGB) {
     memset (data, 0, render->width * render->height * 4);
@@ -562,6 +565,7 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
           render->width * 4);
     }
   }
+  gst_buffer_unmap (outbuf, data, size);
 
   ret = gst_pad_push (render->srcpad, outbuf);
 
index 96e12ee..50359af 100644 (file)
@@ -716,30 +716,33 @@ theora_dec_setcaps (GstPad * pad, GstCaps * caps)
   if ((codec_data = gst_structure_get_value (s, "codec_data"))) {
     if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
       GstBuffer *buffer;
-      guint8 *data;
-      guint size;
+      guint8 *data, *ptr;
+      gsize size, left;
       guint offset;
 
       buffer = gst_value_get_buffer (codec_data);
 
       offset = 0;
-      size = GST_BUFFER_SIZE (buffer);
-      data = GST_BUFFER_DATA (buffer);
+      data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
-      while (size > 2) {
+      ptr = data;
+      left = size;
+
+      while (left > 2) {
         guint psize;
         GstBuffer *buf;
 
-        psize = (data[0] << 8) | data[1];
+        psize = (ptr[0] << 8) | ptr[1];
         /* skip header */
-        data += 2;
-        size -= 2;
+        ptr += 2;
+        left -= 2;
         offset += 2;
 
         /* make sure we don't read too much */
-        psize = MIN (psize, size);
+        psize = MIN (psize, left);
 
-        buf = gst_buffer_create_sub (buffer, offset, psize);
+        buf =
+            gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, psize);
 
         /* first buffer is a discont buffer */
         if (offset == 2)
@@ -749,10 +752,11 @@ theora_dec_setcaps (GstPad * pad, GstCaps * caps)
         theora_dec_chain (pad, buf);
 
         /* skip the data */
-        size -= psize;
-        data += psize;
+        left -= psize;
+        ptr += psize;
         offset += psize;
       }
+      gst_buffer_unmap (buffer, data, size);
     }
   }
 
@@ -765,20 +769,13 @@ static GstFlowReturn
 theora_handle_comment_packet (GstTheoraDec * dec, ogg_packet * packet)
 {
   gchar *encoder = NULL;
-  GstBuffer *buf;
   GstTagList *list;
 
   GST_DEBUG_OBJECT (dec, "parsing comment packet");
 
-  buf = gst_buffer_new ();
-  GST_BUFFER_SIZE (buf) = packet->bytes;
-  GST_BUFFER_DATA (buf) = packet->packet;
-
   list =
-      gst_tag_list_from_vorbiscomment_buffer (buf, (guint8 *) "\201theora", 7,
-      &encoder);
-
-  gst_buffer_unref (buf);
+      gst_tag_list_from_vorbiscomment (packet->packet, packet->bytes,
+      (guint8 *) "\201theora", 7, &encoder);
 
   if (!list) {
     GST_ERROR_OBJECT (dec, "couldn't decode comments");
@@ -1056,6 +1053,8 @@ theora_handle_image (GstTheoraDec * dec, th_ycbcr_buffer buf, GstBuffer ** out)
   int i, plane;
   GstVideoFormat format;
   guint8 *dest, *src;
+  gsize size;
+  guint8 *data;
 
   switch (dec->info.pixel_fmt) {
     case TH_PF_444:
@@ -1081,13 +1080,14 @@ theora_handle_image (GstTheoraDec * dec, th_ycbcr_buffer buf, GstBuffer ** out)
     return result;
   }
 
+  data = gst_buffer_map (*out, &size, NULL, GST_MAP_WRITE);
+
   for (plane = 0; plane < 3; plane++) {
     width = gst_video_format_get_component_width (format, plane, dec->width);
     height = gst_video_format_get_component_height (format, plane, dec->height);
     stride = gst_video_format_get_row_stride (format, plane, dec->width);
 
-    dest =
-        GST_BUFFER_DATA (*out) + gst_video_format_get_component_offset (format,
+    dest = data + gst_video_format_get_component_offset (format,
         plane, dec->width, dec->height);
     src = buf[plane].data;
     src += ((height == dec->height) ? dec->offset_y : dec->offset_y / 2)
@@ -1101,6 +1101,7 @@ theora_handle_image (GstTheoraDec * dec, th_ycbcr_buffer buf, GstBuffer ** out)
       src += buf[plane].stride;
     }
   }
+  gst_buffer_unmap (*out, data, size);
 
   return GST_FLOW_OK;
 }
@@ -1268,10 +1269,11 @@ theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf)
   ogg_packet packet;
   GstFlowReturn result = GST_FLOW_OK;
   GstClockTime timestamp, duration;
+  gsize size;
 
   /* make ogg_packet out of the buffer */
-  packet.packet = GST_BUFFER_DATA (buf);
-  packet.bytes = GST_BUFFER_SIZE (buf);
+  packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  packet.bytes = size;
   packet.granulepos = -1;
   packet.packetno = 0;          /* we don't really care */
   packet.b_o_s = dec->have_header ? 0 : 1;
@@ -1299,8 +1301,9 @@ theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf)
   } else {
     result = theora_handle_data_packet (dec, &packet, timestamp, duration);
   }
-
 done:
+  gst_buffer_unmap (buf, packet.packet, size);
+
   return result;
 }
 
@@ -1430,7 +1433,7 @@ theora_dec_chain_reverse (GstTheoraDec * dec, gboolean discont, GstBuffer * buf)
     GST_DEBUG_OBJECT (dec, "received discont,gathering buffers");
     while (dec->gather) {
       GstBuffer *gbuf;
-      guint8 *data;
+      guint8 data[1];
 
       gbuf = GST_BUFFER_CAST (dec->gather->data);
       /* remove from the gather list */
@@ -1439,7 +1442,7 @@ theora_dec_chain_reverse (GstTheoraDec * dec, gboolean discont, GstBuffer * buf)
       dec->decode = g_list_prepend (dec->decode, gbuf);
 
       /* if we copied a keyframe, flush and decode the decode queue */
-      data = GST_BUFFER_DATA (gbuf);
+      gst_buffer_extract (gbuf, 0, data, 1);
       if ((data[0] & 0x40) == 0) {
         GST_DEBUG_OBJECT (dec, "copied keyframe");
         res = theora_dec_flush_decode (dec);
@@ -1449,7 +1452,7 @@ theora_dec_chain_reverse (GstTheoraDec * dec, gboolean discont, GstBuffer * buf)
 
   /* add buffer to gather queue */
   GST_DEBUG_OBJECT (dec, "gathering buffer %p, size %u", buf,
-      GST_BUFFER_SIZE (buf));
+      gst_buffer_get_size (buf));
   dec->gather = g_list_prepend (dec->gather, buf);
 
   return res;
index c580675..f32d230 100644 (file)
@@ -713,7 +713,7 @@ theora_buffer_from_packet (GstTheoraEnc * enc, ogg_packet * packet,
     goto done;
   }
 
-  memcpy (GST_BUFFER_DATA (buf), packet->packet, packet->bytes);
+  gst_buffer_fill (buf, 0, packet->packet, packet->bytes);
   gst_buffer_set_caps (buf, GST_PAD_CAPS (enc->srcpad));
   /* see ext/ogg/README; OFFSET_END takes "our" granulepos, OFFSET its
    * time representation */
@@ -751,7 +751,7 @@ theora_push_buffer (GstTheoraEnc * enc, GstBuffer * buffer)
 {
   GstFlowReturn ret;
 
-  enc->bytes_out += GST_BUFFER_SIZE (buffer);
+  enc->bytes_out += gst_buffer_get_size (buffer);
 
   ret = gst_pad_push (enc->srcpad, buffer);
 
@@ -1014,17 +1014,21 @@ theora_enc_read_multipass_cache (GstTheoraEnc * enc)
 
   while (!done) {
     if (gst_adapter_available (enc->multipass_cache_adapter) == 0) {
+      guint8 *data;
+      gsize size;
+
       cache_buf = gst_buffer_new_and_alloc (512);
+
+      data = gst_buffer_map (cache_buf, &size, NULL, GST_MAP_READ);
       stat = g_io_channel_read_chars (enc->multipass_cache_fd,
-          (gchar *) GST_BUFFER_DATA (cache_buf), GST_BUFFER_SIZE (cache_buf),
-          &bytes_read, NULL);
+          (gchar *) data, size, &bytes_read, NULL);
 
       if (bytes_read <= 0) {
+        gst_buffer_unmap (cache_buf, data, 0);
         gst_buffer_unref (cache_buf);
         break;
       } else {
-        GST_BUFFER_SIZE (cache_buf) = bytes_read;
-
+        gst_buffer_unmap (cache_buf, data, bytes_read);
         gst_adapter_push (enc->multipass_cache_adapter, cache_buf);
       }
     }
@@ -1034,11 +1038,13 @@ theora_enc_read_multipass_cache (GstTheoraEnc * enc)
     bytes_read =
         MIN (gst_adapter_available (enc->multipass_cache_adapter), 512);
 
-    cache_data = gst_adapter_peek (enc->multipass_cache_adapter, bytes_read);
+    cache_data = gst_adapter_map (enc->multipass_cache_adapter, bytes_read);
 
     bytes_consumed =
         th_encode_ctl (enc->encoder, TH_ENCCTL_2PASS_IN, (guint8 *) cache_data,
         bytes_read);
+    gst_adapter_unmap (enc->multipass_cache_adapter, 0);
+
     done = bytes_consumed <= 0;
     if (bytes_consumed > 0)
       gst_adapter_flush (enc->multipass_cache_adapter, bytes_consumed);
@@ -1246,8 +1252,11 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
   {
     th_ycbcr_buffer ycbcr;
     gint res;
+    guint8 *data;
+    gsize size;
 
-    theora_enc_init_buffer (ycbcr, &enc->info, GST_BUFFER_DATA (buffer));
+    data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+    theora_enc_init_buffer (ycbcr, &enc->info, data);
 
     if (theora_enc_is_discontinuous (enc, running_time, duration)) {
       theora_enc_reset (enc);
@@ -1262,6 +1271,7 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
     if (enc->multipass_cache_fd
         && enc->multipass_mode == MULTIPASS_MODE_SECOND_PASS) {
       if (!theora_enc_read_multipass_cache (enc)) {
+        gst_buffer_unmap (buffer, data, size);
         ret = GST_FLOW_ERROR;
         goto multipass_read_failed;
       }
@@ -1274,6 +1284,7 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
     if (enc->multipass_cache_fd
         && enc->multipass_mode == MULTIPASS_MODE_FIRST_PASS) {
       if (!theora_enc_write_multipass_cache (enc, FALSE, FALSE)) {
+        gst_buffer_unmap (buffer, data, size);
         ret = GST_FLOW_ERROR;
         goto multipass_write_failed;
       }
@@ -1290,9 +1301,12 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
           next_time - enc->next_ts);
 
       enc->next_ts = next_time;
-      if (ret != GST_FLOW_OK)
+      if (ret != GST_FLOW_OK) {
+        gst_buffer_unmap (buffer, data, size);
         goto data_push;
+      }
     }
+    gst_buffer_unmap (buffer, data, size);
     gst_buffer_unref (buffer);
   }
 
index 0ce68d9..4e99d9f 100644 (file)
@@ -267,7 +267,7 @@ theora_parse_set_header_on_caps (GstTheoraParse * parse, GstCaps * caps)
     if (bufs[i] == NULL)
       continue;
 
-    bufs[i] = gst_buffer_make_metadata_writable (bufs[i]);
+    bufs[i] = gst_buffer_make_writable (bufs[i]);
     GST_BUFFER_FLAG_SET (bufs[i], GST_BUFFER_FLAG_IN_CAPS);
 
     g_value_init (&value, GST_TYPE_BUFFER);
@@ -302,18 +302,20 @@ theora_parse_set_streamheader (GstTheoraParse * parse)
     ogg_packet packet;
     GstBuffer *buf;
     int ret;
+    gsize size;
 
     buf = parse->streamheader[i];
     if (buf == NULL)
       continue;
 
-    packet.packet = GST_BUFFER_DATA (buf);
-    packet.bytes = GST_BUFFER_SIZE (buf);
+    packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    packet.bytes = size;
     packet.granulepos = GST_BUFFER_OFFSET_END (buf);
     packet.packetno = i + 1;
     packet.e_o_s = 0;
     packet.b_o_s = (i == 0);
     ret = th_decode_headerin (&parse->info, &parse->comment, &setup, &packet);
+    gst_buffer_unmap (buf, packet.packet, size);
     if (ret < 0) {
       GST_WARNING_OBJECT (parse, "Failed to decode Theora header %d: %d\n",
           i + 1, ret);
@@ -367,7 +369,7 @@ theora_parse_push_headers (GstTheoraParse * parse)
     GstBuffer *buf;
 
     if ((buf = parse->streamheader[i])) {
-      buf = gst_buffer_make_metadata_writable (buf);
+      buf = gst_buffer_make_writable (buf);
       gst_buffer_set_caps (buf, GST_PAD_CAPS (parse->srcpad));
       gst_pad_push (parse->srcpad, buf);
       parse->streamheader[i] = NULL;
@@ -435,11 +437,16 @@ parse_granulepos (GstTheoraParse * parse, gint64 granulepos,
 static gboolean
 is_keyframe (GstBuffer * buf)
 {
-  if (!GST_BUFFER_DATA (buf))
-    return FALSE;
-  if (!GST_BUFFER_SIZE (buf))
+  gsize size;
+  guint8 data[1];
+
+  size = gst_buffer_get_size (buf);
+  if (size == 0)
     return FALSE;
-  return ((GST_BUFFER_DATA (buf)[0] & 0x40) == 0);
+
+  gst_buffer_extract (buf, 0, data, 1);
+
+  return ((data[0] & 0x40) == 0);
 }
 
 static void
@@ -624,7 +631,7 @@ theora_parse_queue_buffer (GstTheoraParse * parse, GstBuffer * buf)
 {
   GstFlowReturn ret = GST_FLOW_OK;
 
-  buf = gst_buffer_make_metadata_writable (buf);
+  buf = gst_buffer_make_writable (buf);
 
   g_queue_push_tail (parse->buffer_queue, buf);
 
@@ -644,18 +651,20 @@ theora_parse_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstFlowReturn ret;
   GstTheoraParse *parse;
-  guint8 *data;
-  guint size;
+  guint8 *data, header;
+  gsize size;
   gboolean have_header;
 
   parse = GST_THEORA_PARSE (gst_pad_get_parent (pad));
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
-
   have_header = FALSE;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  header = data[0];
+  gst_buffer_unmap (buffer, data, size);
+
   if (size >= 1) {
-    if (data[0] & 0x80)
+    if (header & 0x80)
       have_header = TRUE;
   }
 
@@ -663,8 +672,8 @@ theora_parse_chain (GstPad * pad, GstBuffer * buffer)
     if (parse->send_streamheader) {
       /* we need to collect the headers still */
       /* so put it on the streamheader list and return */
-      if (data[0] >= 0x80 && data[0] <= 0x82)
-        parse->streamheader[data[0] - 0x80] = buffer;
+      if (header >= 0x80 && header <= 0x82)
+        parse->streamheader[header - 0x80] = buffer;
     }
     ret = GST_FLOW_OK;
   } else {
index ab6a077..9cde7f9 100644 (file)
@@ -635,16 +635,16 @@ vorbis_handle_comment_packet (GstVorbisDec * vd, ogg_packet * packet)
   guint bitrate = 0;
   gchar *encoder = NULL;
   GstTagList *list, *old_list;
-  GstBuffer *buf;
+  guint8 *data;
+  gsize size;
 
   GST_DEBUG_OBJECT (vd, "parsing comment packet");
 
-  buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = gst_ogg_packet_data (packet);
-  GST_BUFFER_SIZE (buf) = gst_ogg_packet_size (packet);
+  data = gst_ogg_packet_data (packet);
+  size = gst_ogg_packet_size (packet);
 
   list =
-      gst_tag_list_from_vorbiscomment_buffer (buf, (guint8 *) "\003vorbis", 7,
+      gst_tag_list_from_vorbiscomment (data, size, (guint8 *) "\003vorbis", 7,
       &encoder);
 
   old_list = vd->taglist;
@@ -653,7 +653,6 @@ vorbis_handle_comment_packet (GstVorbisDec * vd, ogg_packet * packet)
   if (old_list)
     gst_tag_list_free (old_list);
   gst_tag_list_free (list);
-  gst_buffer_unref (buf);
 
   if (!vd->taglist) {
     GST_ERROR_OBJECT (vd, "couldn't decode comments");
@@ -865,7 +864,8 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
   guint sample_count;
   GstBuffer *out = NULL;
   GstFlowReturn result;
-  gint size;
+  guint8 *data;
+  gsize size;
 
   if (G_UNLIKELY (!vd->initialized))
     goto not_initialized;
@@ -905,11 +905,12 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
     goto wrong_samples;
 
   /* copy samples in buffer */
-  vd->copy_samples ((vorbis_sample_t *) GST_BUFFER_DATA (out), pcm,
+  data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
+  vd->copy_samples ((vorbis_sample_t *) data, pcm,
       sample_count, vd->vi.channels, vd->width);
 
   GST_LOG_OBJECT (vd, "setting output size to %d", size);
-  GST_BUFFER_SIZE (out) = size;
+  gst_buffer_unmap (out, data, size);
 
   /* this should not overflow */
   if (duration == -1)
@@ -967,7 +968,7 @@ vorbis_dec_decode_buffer (GstVorbisDec * vd, GstBuffer * buffer)
   GstFlowReturn result = GST_FLOW_OK;
 
   /* make ogg_packet out of the buffer */
-  gst_ogg_packet_wrapper_from_buffer (&packet_wrapper, buffer);
+  gst_ogg_packet_wrapper_map (&packet_wrapper, buffer);
   packet = gst_ogg_packet_from_wrapper (&packet_wrapper);
   /* set some more stuff */
   packet->granulepos = -1;
@@ -1003,6 +1004,8 @@ vorbis_dec_decode_buffer (GstVorbisDec * vd, GstBuffer * buffer)
   }
 
 done:
+  gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer);
+
   return result;
 
 empty_buffer:
@@ -1159,7 +1162,7 @@ vorbis_dec_chain_reverse (GstVorbisDec * vd, gboolean discont, GstBuffer * buf)
   if (G_LIKELY (buf)) {
     GST_DEBUG_OBJECT (vd,
         "gathering buffer %p of size %u, time %" GST_TIME_FORMAT
-        ", dur %" GST_TIME_FORMAT, buf, GST_BUFFER_SIZE (buf),
+        ", dur %" GST_TIME_FORMAT, buf, gst_buffer_get_size (buf),
         GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
         GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
 
index c82f0c8..23e291d 100644 (file)
@@ -60,10 +60,18 @@ gst_ogg_packet_size (ogg_packet * p)
 }
 
 static inline void
-gst_ogg_packet_wrapper_from_buffer (ogg_packet * packet, GstBuffer * buffer)
+gst_ogg_packet_wrapper_map (ogg_packet * packet, GstBuffer * buffer)
 {
-  packet->packet = GST_BUFFER_DATA (buffer);
-  packet->bytes = GST_BUFFER_SIZE (buffer);
+  gsize size;
+
+  packet->packet = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  packet->bytes = size;
+}
+
+static inline void
+gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer)
+{
+  gst_buffer_unmap (buffer, packet->packet, packet->bytes);
 }
 
 static inline ogg_packet *
@@ -121,14 +129,15 @@ gst_ogg_packet_size (ogg_packet * p)
 }
 
 static inline void
-gst_ogg_packet_wrapper_from_buffer (ogg_packet_wrapper * packet,
+gst_ogg_packet_wrapper_map (ogg_packet_wrapper * packet,
     GstBuffer * buffer)
 {
   ogg_reference *ref = &packet->ref;
   ogg_buffer *buf = &packet->buf;
+  gsize size;
 
-  buf->data = GST_BUFFER_DATA (buffer);
-  buf->size = GST_BUFFER_SIZE (buffer);
+  buf->data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  buf->size = size;
   buf->refcount = 1;
   buf->ptr.owner = NULL;
   buf->ptr.next = NULL;
@@ -142,6 +151,16 @@ gst_ogg_packet_wrapper_from_buffer (ogg_packet_wrapper * packet,
   packet->packet.bytes = ref->length;
 }
 
+static inline void
+gst_ogg_packet_wrapper_unmap (ogg_packet_wrapper * packet,
+    GstBuffer * buffer)
+{
+  ogg_reference *ref = &packet->ref;
+  ogg_buffer *buf = &packet->buf;
+
+  gst_buffer_unmap (buffer, buf->data, buf->size);
+}
+
 static inline ogg_packet *
 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
 {
index 9cdf484..79825c6 100644 (file)
@@ -826,7 +826,7 @@ gst_vorbis_enc_buffer_from_packet (GstVorbisEnc * vorbisenc,
   GstBuffer *outbuf;
 
   outbuf = gst_buffer_new_and_alloc (packet->bytes);
-  memcpy (GST_BUFFER_DATA (outbuf), packet->packet, packet->bytes);
+  gst_buffer_fill (outbuf, 0, packet->packet, packet->bytes);
   /* see ext/ogg/README; OFFSET_END takes "our" granulepos, OFFSET its
    * time representation */
   GST_BUFFER_OFFSET_END (outbuf) = packet->granulepos +
@@ -851,7 +851,7 @@ gst_vorbis_enc_buffer_from_packet (GstVorbisEnc * vorbisenc,
   gst_buffer_set_caps (outbuf, vorbisenc->srccaps);
 
   GST_LOG_OBJECT (vorbisenc, "encoded buffer of %d bytes",
-      GST_BUFFER_SIZE (outbuf));
+      gst_buffer_get_size (outbuf));
   return outbuf;
 }
 
@@ -864,7 +864,7 @@ gst_vorbis_enc_buffer_from_header_packet (GstVorbisEnc * vorbisenc,
   GstBuffer *outbuf;
 
   outbuf = gst_buffer_new_and_alloc (packet->bytes);
-  memcpy (GST_BUFFER_DATA (outbuf), packet->packet, packet->bytes);
+  gst_buffer_fill (outbuf, 0, packet->packet, packet->bytes);
   GST_BUFFER_OFFSET (outbuf) = vorbisenc->bytes_out;
   GST_BUFFER_OFFSET_END (outbuf) = 0;
   GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
@@ -873,7 +873,7 @@ gst_vorbis_enc_buffer_from_header_packet (GstVorbisEnc * vorbisenc,
   gst_buffer_set_caps (outbuf, vorbisenc->srccaps);
 
   GST_DEBUG ("created header packet buffer, %d bytes",
-      GST_BUFFER_SIZE (outbuf));
+      gst_buffer_get_size (outbuf));
   return outbuf;
 }
 
@@ -881,7 +881,7 @@ gst_vorbis_enc_buffer_from_header_packet (GstVorbisEnc * vorbisenc,
 static GstFlowReturn
 gst_vorbis_enc_push_buffer (GstVorbisEnc * vorbisenc, GstBuffer * buffer)
 {
-  vorbisenc->bytes_out += GST_BUFFER_SIZE (buffer);
+  vorbisenc->bytes_out += gst_buffer_get_size (buffer);
 
   GST_DEBUG_OBJECT (vorbisenc,
       "Pushing buffer with GP %" G_GINT64_FORMAT ", ts %" GST_TIME_FORMAT,
@@ -1008,6 +1008,10 @@ gst_vorbis_enc_buffer_check_discontinuous (GstVorbisEnc * vorbisenc,
 {
   gboolean ret = FALSE;
 
+  GST_DEBUG_OBJECT (vorbisenc, "exp %" GST_TIME_FORMAT " time %" GST_TIME_FORMAT
+      "dur %" GST_TIME_FORMAT, GST_TIME_ARGS (vorbisenc->expected_ts),
+      GST_TIME_ARGS (timestamp), GST_TIME_ARGS (duration));
+
   if (timestamp != GST_CLOCK_TIME_NONE &&
       vorbisenc->expected_ts != GST_CLOCK_TIME_NONE &&
       timestamp + duration != vorbisenc->expected_ts) {
@@ -1038,7 +1042,7 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstVorbisEnc *vorbisenc;
   GstFlowReturn ret = GST_FLOW_OK;
-  gfloat *data;
+  gfloat *data, *ptr;
   gulong size;
   gulong i, j;
   float **vorbis_buffer;
@@ -1046,6 +1050,7 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
   gboolean first = FALSE;
   GstClockTime timestamp = GST_CLOCK_TIME_NONE;
   GstClockTime running_time = GST_CLOCK_TIME_NONE;
+  gsize bsize;
 
   vorbisenc = GST_VORBISENC (GST_PAD_PARENT (pad));
 
@@ -1062,8 +1067,9 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
       gst_segment_to_running_time (&vorbisenc->segment, GST_FORMAT_TIME,
       GST_BUFFER_TIMESTAMP (buffer));
   timestamp = running_time + vorbisenc->initial_ts;
-  GST_DEBUG_OBJECT (vorbisenc, "Initial ts is %" GST_TIME_FORMAT,
-      GST_TIME_ARGS (vorbisenc->initial_ts));
+  GST_DEBUG_OBJECT (vorbisenc, "Initial ts is %" GST_TIME_FORMAT
+      " timestamp %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (vorbisenc->initial_ts), GST_TIME_ARGS (timestamp));
   if (!vorbisenc->header_sent) {
     /* Vorbis streams begin with three headers; the initial header (with
        most of the codec setup parameters) which is mandated by the Ogg
@@ -1137,22 +1143,24 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
       timestamp < vorbisenc->expected_ts) {
     guint64 diff = vorbisenc->expected_ts - timestamp;
     guint64 diff_bytes;
+    gsize size;
 
     GST_WARNING_OBJECT (vorbisenc, "Buffer is older than previous "
         "timestamp + duration (%" GST_TIME_FORMAT "< %" GST_TIME_FORMAT
         "), cannot handle. Clipping buffer.",
         GST_TIME_ARGS (timestamp), GST_TIME_ARGS (vorbisenc->expected_ts));
 
+    size = gst_buffer_get_size (buffer);
+
     diff_bytes =
         GST_CLOCK_TIME_TO_FRAMES (diff,
         vorbisenc->frequency) * vorbisenc->channels * sizeof (gfloat);
-    if (diff_bytes >= GST_BUFFER_SIZE (buffer)) {
+    if (diff_bytes >= size) {
       gst_buffer_unref (buffer);
       return GST_FLOW_OK;
     }
-    buffer = gst_buffer_make_metadata_writable (buffer);
-    GST_BUFFER_DATA (buffer) += diff_bytes;
-    GST_BUFFER_SIZE (buffer) -= diff_bytes;
+    buffer = gst_buffer_make_writable (buffer);
+    gst_buffer_resize (buffer, diff_bytes, size - diff_bytes);
 
     GST_BUFFER_TIMESTAMP (buffer) += diff;
     if (GST_BUFFER_DURATION_IS_VALID (buffer))
@@ -1187,14 +1195,17 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
   }
 
   /* Sending zero samples to libvorbis marks EOS, so we mustn't do that */
-  if (GST_BUFFER_SIZE (buffer) == 0) {
+  data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+  if (bsize == 0) {
+    gst_buffer_unmap (buffer, data, bsize);
     gst_buffer_unref (buffer);
     return GST_FLOW_OK;
   }
 
   /* data to encode */
-  data = (gfloat *) GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer) / (vorbisenc->channels * sizeof (float));
+  size = bsize / (vorbisenc->channels * sizeof (float));
+
+  ptr = data;
 
   /* expose the buffer to submit data */
   vorbis_buffer = vorbis_analysis_buffer (&vorbisenc->vd, size);
@@ -1202,12 +1213,13 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer)
   /* deinterleave samples, write the buffer data */
   for (i = 0; i < size; i++) {
     for (j = 0; j < vorbisenc->channels; j++) {
-      vorbis_buffer[j][i] = *data++;
+      vorbis_buffer[j][i] = *ptr++;
     }
   }
 
   /* tell the library how much we actually submitted */
   vorbis_analysis_wrote (&vorbisenc->vd, size);
+  gst_buffer_unmap (buffer, data, bsize);
 
   GST_LOG_OBJECT (vorbisenc, "wrote %lu samples to vorbis", size);
 
index 53fd7b1..99f1d2e 100644 (file)
@@ -191,6 +191,7 @@ vorbis_parse_push_headers (GstVorbisParse * parse)
   GstCaps *caps;
   GstBuffer *outbuf, *outbuf1, *outbuf2, *outbuf3;
   ogg_packet packet;
+  gsize size;
 
   /* get the headers into the caps, passing them to vorbis as we go */
   caps = gst_caps_make_writable (gst_pad_get_caps (parse->srcpad));
@@ -200,47 +201,50 @@ vorbis_parse_push_headers (GstVorbisParse * parse)
   gst_caps_unref (caps);
 
   outbuf = GST_BUFFER_CAST (parse->streamheader->data);
-  packet.packet = GST_BUFFER_DATA (outbuf);
-  packet.bytes = GST_BUFFER_SIZE (outbuf);
+  packet.packet = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
+  packet.bytes = size;
   packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
   packet.packetno = 1;
   packet.e_o_s = 0;
   packet.b_o_s = 1;
   vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
+  gst_buffer_unmap (outbuf, packet.packet, size);
   parse->sample_rate = parse->vi.rate;
   outbuf1 = outbuf;
 
   outbuf = GST_BUFFER_CAST (parse->streamheader->next->data);
-  packet.packet = GST_BUFFER_DATA (outbuf);
-  packet.bytes = GST_BUFFER_SIZE (outbuf);
+  packet.packet = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
+  packet.bytes = size;
   packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
   packet.packetno = 2;
   packet.e_o_s = 0;
   packet.b_o_s = 0;
   vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
+  gst_buffer_unmap (outbuf, packet.packet, size);
   outbuf2 = outbuf;
 
   outbuf = GST_BUFFER_CAST (parse->streamheader->next->next->data);
-  packet.packet = GST_BUFFER_DATA (outbuf);
-  packet.bytes = GST_BUFFER_SIZE (outbuf);
+  packet.packet = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
+  packet.bytes = size;
   packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
   packet.packetno = 3;
   packet.e_o_s = 0;
   packet.b_o_s = 0;
   vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
+  gst_buffer_unmap (outbuf, packet.packet, size);
   outbuf3 = outbuf;
 
   /* first process queued events */
   vorbis_parse_drain_event_queue (parse);
 
   /* push out buffers, ignoring return value... */
-  outbuf1 = gst_buffer_make_metadata_writable (outbuf1);
+  outbuf1 = gst_buffer_make_writable (outbuf1);
   gst_buffer_set_caps (outbuf1, GST_PAD_CAPS (parse->srcpad));
   gst_pad_push (parse->srcpad, outbuf1);
-  outbuf2 = gst_buffer_make_metadata_writable (outbuf2);
+  outbuf2 = gst_buffer_make_writable (outbuf2);
   gst_buffer_set_caps (outbuf2, GST_PAD_CAPS (parse->srcpad));
   gst_pad_push (parse->srcpad, outbuf2);
-  outbuf3 = gst_buffer_make_metadata_writable (outbuf3);
+  outbuf3 = gst_buffer_make_writable (outbuf3);
   gst_buffer_set_caps (outbuf3, GST_PAD_CAPS (parse->srcpad));
   gst_pad_push (parse->srcpad, outbuf3);
 
@@ -358,16 +362,18 @@ vorbis_parse_queue_buffer (GstVorbisParse * parse, GstBuffer * buf)
   GstFlowReturn ret = GST_FLOW_OK;
   long blocksize;
   ogg_packet packet;
+  gsize size;
 
-  buf = gst_buffer_make_metadata_writable (buf);
+  buf = gst_buffer_make_writable (buf);
 
-  packet.packet = GST_BUFFER_DATA (buf);
-  packet.bytes = GST_BUFFER_SIZE (buf);
+  packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  packet.bytes = size;
   packet.granulepos = GST_BUFFER_OFFSET_END (buf);
   packet.packetno = parse->packetno + parse->buffer_queue->length;
   packet.e_o_s = 0;
 
   blocksize = vorbis_packet_blocksize (&parse->vi, &packet);
+  gst_buffer_unmap (buf, packet.packet, size);
 
   /* temporarily store the sample count in OFFSET -- we overwrite this later */
 
@@ -391,19 +397,18 @@ vorbis_parse_parse_packet (GstVorbisParse * parse, GstBuffer * buf)
 {
   GstFlowReturn ret;
   guint8 *data;
-  guint size;
+  gsize size;
   gboolean have_header;
 
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
-
   parse->packetno++;
 
   have_header = FALSE;
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   if (size >= 1) {
     if (data[0] >= 0x01 && data[0] <= 0x05)
       have_header = TRUE;
   }
+  gst_buffer_unmap (buf, data, size);
 
   if (have_header) {
     if (!parse->streamheader_sent) {
index 8a2db41..0553f6a 100644 (file)
@@ -111,9 +111,17 @@ gst_vorbis_tag_parse_packet (GstVorbisParse * parse, GstBuffer * buffer)
   GstVorbisTag *tagger;
   gchar *encoder = NULL;
   GstBuffer *new_buf;
+  guint8 *data;
+  gsize size;
+  gboolean do_parse = FALSE;
 
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   /* just pass everything except the comments packet */
-  if (GST_BUFFER_SIZE (buffer) >= 1 && GST_BUFFER_DATA (buffer)[0] != 0x03) {
+  if (size >= 1 && data[0] != 0x03)
+    do_parse = TRUE;
+  gst_buffer_unmap (buffer, data, size);
+
+  if (do_parse) {
     return GST_VORBIS_PARSE_CLASS (parent_class)->parse_packet (parse, buffer);
   }
 
@@ -132,7 +140,7 @@ gst_vorbis_tag_parse_packet (GstVorbisParse * parse, GstBuffer * buffer)
   new_buf =
       gst_tag_list_to_vorbiscomment_buffer (new_tags, (guint8 *) "\003vorbis",
       7, encoder);
-  gst_buffer_copy_metadata (new_buf, buffer, GST_BUFFER_COPY_TIMESTAMPS);
+  gst_buffer_copy_into (new_buf, buffer, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
 
   gst_tag_list_free (new_tags);
   g_free (encoder);
index e88ad44..ac078fa 100644 (file)
@@ -14,7 +14,7 @@ BUILT_SOURCES = $(built_sources) $(built_headers)
 nodist_libgstapp_@GST_MAJORMINOR@_la_SOURCES = \
              $(built_sources)
 
-libgstapp_@GST_MAJORMINOR@_la_SOURCES = gstappsrc.c gstappbuffer.c gstappsink.c 
+libgstapp_@GST_MAJORMINOR@_la_SOURCES = gstappsrc.c gstappsink.c 
 libgstapp_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
        $(GST_BASE_CFLAGS) $(GST_CFLAGS)
 libgstapp_@GST_MAJORMINOR@_la_LIBADD = $(GST_BASE_LIBS)
@@ -24,7 +24,6 @@ libgstapp_@GST_MAJORMINOR@_la_LIBTOOLFLAGS = --tag=disable-static
 libgstapp_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/app
 libgstapp_@GST_MAJORMINOR@include_HEADERS = \
        gstappsrc.h \
-       gstappbuffer.h \
        gstappsink.h
 
 CLEANFILES = $(BUILT_SOURCES)
diff --git a/gst-libs/gst/app/gstappbuffer.c b/gst-libs/gst/app/gstappbuffer.c
deleted file mode 100644 (file)
index 2fa72bb..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* GStreamer
- * Copyright (C) 2007 David Schleef <ds@schleef.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-#include <gst/base/gstpushsrc.h>
-
-#include <string.h>
-
-#include "gstappbuffer.h"
-
-static void gst_app_buffer_init (GstAppBuffer * buffer, gpointer g_class);
-static void gst_app_buffer_class_init (gpointer g_class, gpointer class_data);
-static void gst_app_buffer_finalize (GstAppBuffer * buffer);
-
-static GstBufferClass *parent_class;
-
-GType
-gst_app_buffer_get_type (void)
-{
-  static volatile gsize app_buffer_type = 0;
-
-  if (g_once_init_enter (&app_buffer_type)) {
-    static const GTypeInfo app_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_app_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstAppBuffer),
-      0,
-      (GInstanceInitFunc) gst_app_buffer_init,
-      NULL
-    };
-    GType tmp = g_type_register_static (GST_TYPE_BUFFER, "GstAppBuffer",
-        &app_buffer_info, 0);
-    g_once_init_leave (&app_buffer_type, tmp);
-  }
-
-  return (GType) app_buffer_type;
-}
-
-static void
-gst_app_buffer_init (GstAppBuffer * buffer, gpointer g_class)
-{
-
-}
-
-static void
-gst_app_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  mini_object_class->finalize =
-      (GstMiniObjectFinalizeFunction) gst_app_buffer_finalize;
-
-  parent_class = g_type_class_peek_parent (g_class);
-}
-
-static void
-gst_app_buffer_finalize (GstAppBuffer * buffer)
-{
-  g_return_if_fail (buffer != NULL);
-  g_return_if_fail (GST_IS_APP_BUFFER (buffer));
-
-  if (buffer->finalize) {
-    buffer->finalize (buffer->priv);
-  }
-
-  GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (buffer));
-}
-
-GstBuffer *
-gst_app_buffer_new (void *data, int length,
-    GstAppBufferFinalizeFunc finalize, void *priv)
-{
-  GstAppBuffer *buffer;
-
-  buffer = (GstAppBuffer *) gst_mini_object_new (GST_TYPE_APP_BUFFER);
-
-  GST_BUFFER_DATA (buffer) = data;
-  GST_BUFFER_SIZE (buffer) = length;
-
-  buffer->finalize = finalize;
-  buffer->priv = priv;
-
-  return GST_BUFFER (buffer);
-}
diff --git a/gst-libs/gst/app/gstappbuffer.h b/gst-libs/gst/app/gstappbuffer.h
deleted file mode 100644 (file)
index 532f2ae..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* GStreamer
- * Copyright (C) 2007 David Schleef <ds@schleef.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef _GST_APP_BUFFER_H_
-#define _GST_APP_BUFFER_H_
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_APP_BUFFER \
-  (gst_app_buffer_get_type())
-#define GST_APP_BUFFER(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_BUFFER,GstAppBuffer))
-#define GST_APP_BUFFER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_BUFFER,GstAppBufferClass))
-#define GST_IS_APP_BUFFER(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_BUFFER))
-#define GST_IS_APP_BUFFER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_BUFFER))
-
-typedef struct _GstAppBuffer GstAppBuffer;
-typedef struct _GstAppBufferClass GstAppBufferClass;
-typedef void (*GstAppBufferFinalizeFunc) (void *priv);
-
-struct _GstAppBuffer
-{
-  GstBuffer buffer;
-
-  /*< private >*/
-  GstAppBufferFinalizeFunc finalize;
-  void *priv;
-};
-
-struct _GstAppBufferClass
-{
-  GstBufferClass buffer_class;
-};
-
-GType gst_app_buffer_get_type(void);
-
-GstBuffer *gst_app_buffer_new (void *data, int length,
-    GstAppBufferFinalizeFunc finalize, void *priv);
-
-G_END_DECLS
-
-#endif
-
index 07a3989..11dff32 100644 (file)
@@ -833,10 +833,10 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
 static GstFlowReturn
 gst_app_sink_render_list (GstBaseSink * sink, GstBufferList * list)
 {
-  GstBufferListIterator *it;
   GstFlowReturn flow;
   GstAppSink *appsink;
-  GstBuffer *group;
+  GstBuffer *buffer;
+  guint i, len;
 
   appsink = GST_APP_SINK_CAST (sink);
 
@@ -847,29 +847,16 @@ gst_app_sink_render_list (GstBaseSink * sink, GstBufferList * list)
    * then and push them one-by-one */
   GST_INFO_OBJECT (sink, "chaining each group in list as a merged buffer");
 
-  it = gst_buffer_list_iterate (list);
+  len = gst_buffer_list_len (list);
 
-  if (gst_buffer_list_iterator_next_group (it)) {
-    do {
-      group = gst_buffer_list_iterator_merge_group (it);
-      if (group == NULL) {
-        group = gst_buffer_new ();
-        GST_DEBUG_OBJECT (sink, "chaining empty group");
-      } else {
-        GST_DEBUG_OBJECT (sink, "chaining group");
-      }
-      flow = gst_app_sink_render (sink, group);
-      gst_buffer_unref (group);
-    } while (flow == GST_FLOW_OK && gst_buffer_list_iterator_next_group (it));
-  } else {
-    GST_DEBUG_OBJECT (sink, "chaining empty group");
-    group = gst_buffer_new ();
-    flow = gst_app_sink_render (sink, group);
-    gst_buffer_unref (group);
+  flow = GST_FLOW_OK;
+  for (i = 0; i < len; i++) {
+    buffer = gst_buffer_list_get (list, i);
+    flow = gst_app_sink_render (sink, buffer);
+    if (flow != GST_FLOW_OK)
+      break;
   }
 
-  gst_buffer_list_iterator_free (it);
-
   return flow;
 }
 
index f051711..0883141 100644 (file)
@@ -988,7 +988,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
       guint buf_size;
 
       *buf = g_queue_pop_head (priv->queue);
-      buf_size = GST_BUFFER_SIZE (*buf);
+      buf_size = gst_buffer_get_size (*buf);
 
       GST_DEBUG_OBJECT (appsrc, "we have buffer %p of size %u", *buf, buf_size);
 
@@ -998,7 +998,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
       if (priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS)
         priv->offset += buf_size;
       if (caps) {
-        *buf = gst_buffer_make_metadata_writable (*buf);
+        *buf = gst_buffer_make_writable (*buf);
         gst_buffer_set_caps (*buf, caps);
       }
 
@@ -1492,7 +1492,7 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
   if (!steal_ref)
     gst_buffer_ref (buffer);
   g_queue_push_tail (priv->queue, buffer);
-  priv->queued_bytes += GST_BUFFER_SIZE (buffer);
+  priv->queued_bytes += gst_buffer_get_size (buffer);
   g_cond_broadcast (priv->cond);
   g_mutex_unlock (priv->mutex);
 
index bf99a52..ee15e62 100644 (file)
@@ -93,7 +93,7 @@ gst_audio_frame_length (GstPad * pad, GstBuffer * buf)
   /* FIXME: this function assumes the buffer size to be a whole multiple
    *        of the frame byte size
    */
-  return GST_BUFFER_SIZE (buf) / frame_byte_size;
+  return gst_buffer_get_size (buf) / frame_byte_size;
 }
 
 /**
@@ -129,7 +129,7 @@ gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf)
     length = GST_CLOCK_TIME_NONE;
   } else {
     structure = gst_caps_get_structure (caps, 0);
-    bytes = GST_BUFFER_SIZE (buf);
+    bytes = gst_buffer_get_size (buf);
     gst_structure_get_int (structure, "width", &width);
     gst_structure_get_int (structure, "channels", &channels);
     gst_structure_get_int (structure, "rate", &rate);
@@ -155,7 +155,7 @@ gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf)
 gboolean
 gst_audio_is_buffer_framed (GstPad * pad, GstBuffer * buf)
 {
-  if (GST_BUFFER_SIZE (buf) % gst_audio_frame_byte_size (pad) == 0)
+  if (gst_buffer_get_size (buf) % gst_audio_frame_byte_size (pad) == 0)
     return TRUE;
   else
     return FALSE;
@@ -295,9 +295,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
   GstBuffer *ret;
   GstClockTime timestamp = GST_CLOCK_TIME_NONE, duration = GST_CLOCK_TIME_NONE;
   guint64 offset = GST_BUFFER_OFFSET_NONE, offset_end = GST_BUFFER_OFFSET_NONE;
-  guint8 *data;
-  guint size;
-
+  gsize trim, size;
   gboolean change_duration = TRUE, change_offset = TRUE, change_offset_end =
       TRUE;
 
@@ -313,10 +311,11 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
    * Calculate the missing values for the calculations,
    * they won't be changed later though. */
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
+  trim = 0;
+  size = gst_buffer_get_size (buffer);
 
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
+  GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
   if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
     duration = GST_BUFFER_DURATION (buffer);
   } else {
@@ -359,7 +358,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
         diff = gst_util_uint64_scale (diff, rate, GST_SECOND);
         if (change_offset)
           offset += diff;
-        data += diff * frame_size;
+        trim += diff * frame_size;
         size -= diff * frame_size;
       }
 
@@ -398,7 +397,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
         if (change_duration)
           duration -= gst_util_uint64_scale (diff, GST_SECOND, rate);
 
-        data += diff * frame_size;
+        trim += diff * frame_size;
         size -= diff * frame_size;
       }
 
@@ -417,12 +416,13 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
     }
   }
 
-  /* Get a metadata writable buffer and apply all changes */
-  ret = gst_buffer_make_metadata_writable (buffer);
+  /* Get a writable buffer and apply all changes */
+  GST_DEBUG ("trim %" G_GSIZE_FORMAT " size %" G_GSIZE_FORMAT, trim, size);
+  ret = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, trim, size);
+  gst_buffer_unref (buffer);
 
+  GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
   GST_BUFFER_TIMESTAMP (ret) = timestamp;
-  GST_BUFFER_SIZE (ret) = size;
-  GST_BUFFER_DATA (ret) = data;
 
   if (change_duration)
     GST_BUFFER_DURATION (ret) = duration;
index ca928d6..28bce9d 100644 (file)
@@ -58,7 +58,7 @@ static GstStateChangeReturn gst_audio_filter_change_state (GstElement * element,
 static gboolean gst_audio_filter_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps);
 static gboolean gst_audio_filter_get_unit_size (GstBaseTransform * btrans,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 
 #define do_init G_STMT_START { \
     GST_DEBUG_CATEGORY_INIT (audiofilter_dbg, "audiofilter", 0, "audiofilter"); \
@@ -154,7 +154,7 @@ gst_audio_filter_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
 
 static gboolean
 gst_audio_filter_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   GstStructure *structure;
   gboolean ret = TRUE;
index ce919af..adea6be 100644 (file)
@@ -394,8 +394,8 @@ gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
   /* set latency to one more segment as we need some headroom */
   spec->seglatency = spec->segtotal + 1;
 
-  buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
-  memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data));
+  buf->size = spec->segtotal * spec->segsize;
+  buf->memory = g_malloc0 (buf->size);
 
   return TRUE;
 
@@ -468,8 +468,8 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
   csink = GST_AUDIO_SINK_GET_CLASS (sink);
 
   /* free the buffer */
-  gst_buffer_unref (buf->data);
-  buf->data = NULL;
+  g_free (buf->memory);
+  buf->memory = NULL;
 
   if (csink->unprepare)
     result = csink->unprepare (sink);
index d7a6b54..b8f9e0b 100644 (file)
@@ -376,8 +376,8 @@ gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
   if (!result)
     goto could_not_open;
 
-  buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
-  memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data));
+  buf->size = spec->segtotal * spec->segsize;
+  buf->memory = g_malloc0 (buf->size);
 
   abuf = GST_AUDIORING_BUFFER (buf);
   abuf->running = TRUE;
@@ -418,8 +418,8 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
   GST_OBJECT_LOCK (buf);
 
   /* free the buffer */
-  gst_buffer_unref (buf->data);
-  buf->data = NULL;
+  g_free (buf->memory);
+  buf->memory = NULL;
 
   if (csrc->unprepare)
     result = csrc->unprepare (src);
index 6093092..da1bff0 100644 (file)
@@ -132,8 +132,10 @@ static void gst_base_audio_sink_set_property (GObject * object, guint prop_id,
 static void gst_base_audio_sink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
+#if 0
 static GstStateChangeReturn gst_base_audio_sink_async_play (GstBaseSink *
     basesink);
+#endif
 static GstStateChangeReturn gst_base_audio_sink_change_state (GstElement *
     element, GstStateChange transition);
 static gboolean gst_base_audio_sink_activate_pull (GstBaseSink * basesink,
@@ -240,8 +242,10 @@ gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass)
       GST_DEBUG_FUNCPTR (gst_base_audio_sink_get_times);
   gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_base_audio_sink_setcaps);
   gstbasesink_class->fixate = GST_DEBUG_FUNCPTR (gst_base_audio_sink_fixate);
+#if 0
   gstbasesink_class->async_play =
       GST_DEBUG_FUNCPTR (gst_base_audio_sink_async_play);
+#endif
   gstbasesink_class->activate_pull =
       GST_DEBUG_FUNCPTR (gst_base_audio_sink_activate_pull);
 
@@ -735,7 +739,10 @@ gst_base_audio_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
 
   GST_DEBUG_OBJECT (sink, "release old ringbuffer");
 
-  /* get current time, updates the last_time */
+  /* get current time, updates the last_time. When the subclass has a clock that
+   * restarts from 0 when a new format is negotiated, it will call
+   * gst_audio_clock_reset() which will use this last_time to create an offset
+   * so that time from the clock keeps on increasing monotonically. */
   now = gst_clock_get_time (sink->provided_clock);
 
   GST_DEBUG_OBJECT (sink, "time was %" GST_TIME_FORMAT, GST_TIME_ARGS (now));
@@ -1320,7 +1327,8 @@ flushing:
 }
 
 static gint64
-gst_base_audio_sink_get_alignment (GstBaseAudioSink * sink, GstClockTime sample_offset)
+gst_base_audio_sink_get_alignment (GstBaseAudioSink * sink,
+    GstClockTime sample_offset)
 {
   GstRingBuffer *ringbuf = sink->ringbuffer;
   gint64 align;
@@ -1355,14 +1363,14 @@ gst_base_audio_sink_get_alignment (GstBaseAudioSink * sink, GstClockTime sample_
         G_GINT64_FORMAT, align, maxdrift);
   } else {
     /* calculate sample diff in seconds for error message */
-    gint64 diff_s = gst_util_uint64_scale_int (diff, GST_SECOND, ringbuf->spec.rate);
+    gint64 diff_s =
+        gst_util_uint64_scale_int (diff, GST_SECOND, ringbuf->spec.rate);
     /* timestamps drifted apart from previous samples too much, we need to
      * resync. We log this as an element warning. */
     GST_WARNING_OBJECT (sink,
         "Unexpected discontinuity in audio timestamps of "
         "%s%" GST_TIME_FORMAT ", resyncing",
-        sample_offset > sink->next_sample ? "+" : "-",
-        GST_TIME_ARGS (diff_s));
+        sample_offset > sink->next_sample ? "+" : "-", GST_TIME_ARGS (diff_s));
     align = 0;
   }
 
@@ -1378,8 +1386,9 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
   GstBaseAudioSink *sink;
   GstRingBuffer *ringbuf;
   gint64 diff, align, ctime, cstop;
+  gsize offset;
   guint8 *data;
-  guint size;
+  gsize size;
   guint samples, written;
   gint bps;
   gint accum;
@@ -1417,7 +1426,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
 
   bps = ringbuf->spec.bytes_per_sample;
 
-  size = GST_BUFFER_SIZE (buf);
+  size = gst_buffer_get_size (buf);
   if (G_UNLIKELY (size % bps) != 0)
     goto wrong_size;
 
@@ -1432,7 +1441,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
       GST_TIME_FORMAT ", samples %u", GST_TIME_ARGS (time), in_offset,
       GST_TIME_ARGS (bsink->segment.start), samples);
 
-  data = GST_BUFFER_DATA (buf);
+  offset = 0;
 
   /* if not valid timestamp or we can't clip or sync, try to play
    * sample ASAP */
@@ -1441,7 +1450,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
     render_stop = render_start + samples;
     GST_DEBUG_OBJECT (sink,
         "Buffer of size %u has no time. Using render_start=%" G_GUINT64_FORMAT,
-        GST_BUFFER_SIZE (buf), render_start);
+        size, render_start);
     /* we don't have a start so we don't know stop either */
     stop = -1;
     goto no_sync;
@@ -1495,7 +1504,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
     GST_DEBUG_OBJECT (sink, "clipping start to %" GST_TIME_FORMAT " %"
         G_GUINT64_FORMAT " samples", GST_TIME_ARGS (ctime), diff);
     samples -= diff;
-    data += diff * bps;
+    offset += diff * bps;
     time = ctime;
   }
   diff = stop - cstop;
@@ -1653,10 +1662,11 @@ no_sync:
   /* we need to accumulate over different runs for when we get interrupted */
   accum = 0;
   align_next = TRUE;
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   do {
     written =
-        gst_ring_buffer_commit_full (ringbuf, &sample_offset, data, samples,
-        out_samples, &accum);
+        gst_ring_buffer_commit_full (ringbuf, &sample_offset, data + offset,
+        samples, out_samples, &accum);
 
     GST_DEBUG_OBJECT (sink, "wrote %u of %u", written, samples);
     /* if we wrote all, we're done */
@@ -1680,8 +1690,9 @@ no_sync:
       break;
 
     samples -= written;
-    data += written * bps;
+    offset += written * bps;
   } while (TRUE);
+  gst_buffer_unmap (buf, data, size);
 
   if (align_next)
     sink->next_sample = sample_offset;
@@ -1726,6 +1737,7 @@ stopping:
   {
     GST_DEBUG_OBJECT (sink, "preroll got interrupted: %d (%s)", ret,
         gst_flow_get_name (ret));
+    gst_buffer_unmap (buf, data, size);
     return ret;
   }
 sync_latency_failed:
@@ -1769,6 +1781,7 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
   GstBaseAudioSink *sink;
   GstBuffer *buf;
   GstFlowReturn ret;
+  gsize size;
 
   basesink = GST_BASE_SINK (user_data);
   sink = GST_BASE_AUDIO_SINK (user_data);
@@ -1790,7 +1803,7 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
       goto error;
   }
 
-  GST_PAD_PREROLL_LOCK (basesink->sinkpad);
+  GST_BASE_SINK_PREROLL_LOCK (basesink);
   if (basesink->flushing)
     goto flushing;
 
@@ -1799,17 +1812,18 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
   if (ret != GST_FLOW_OK)
     goto preroll_error;
 
-  if (len != GST_BUFFER_SIZE (buf)) {
+  size = gst_buffer_get_size (buf);
+
+  if (len != size) {
     GST_INFO_OBJECT (basesink,
-        "got different size than requested from sink pad: %u != %u", len,
-        GST_BUFFER_SIZE (buf));
-    len = MIN (GST_BUFFER_SIZE (buf), len);
+        "got different size than requested from sink pad: %u != %u", len, size);
+    len = MIN (size, len);
   }
 
   basesink->segment.last_stop += len;
 
-  memcpy (data, GST_BUFFER_DATA (buf), len);
-  GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
+  gst_buffer_extract (buf, 0, data, len);
+  GST_BASE_SINK_PREROLL_UNLOCK (basesink);
 
   GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
 
@@ -1839,7 +1853,7 @@ flushing:
   {
     GST_DEBUG_OBJECT (sink, "we are flushing");
     gst_ring_buffer_pause (rbuf);
-    GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
+    GST_BASE_SINK_PREROLL_UNLOCK (basesink);
     GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
     return;
   }
@@ -1847,7 +1861,7 @@ preroll_error:
   {
     GST_DEBUG_OBJECT (sink, "error %s", gst_flow_get_name (ret));
     gst_ring_buffer_pause (rbuf);
-    GST_PAD_PREROLL_UNLOCK (basesink->sinkpad);
+    GST_BASE_SINK_PREROLL_UNLOCK (basesink);
     GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
     return;
   }
@@ -1875,6 +1889,7 @@ gst_base_audio_sink_activate_pull (GstBaseSink * basesink, gboolean active)
   return ret;
 }
 
+#if 0
 /* should be called with the LOCK */
 static GstStateChangeReturn
 gst_base_audio_sink_async_play (GstBaseSink * basesink)
@@ -1893,6 +1908,7 @@ gst_base_audio_sink_async_play (GstBaseSink * basesink)
 
   return GST_STATE_CHANGE_SUCCESS;
 }
+#endif
 
 static GstStateChangeReturn
 gst_base_audio_sink_change_state (GstElement * element,
index 7c7ec93..8135e43 100644 (file)
@@ -561,8 +561,7 @@ gst_base_audio_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
   spec->latency_time = src->latency_time;
 
   GST_OBJECT_LOCK (src);
-  if (!gst_ring_buffer_parse_caps (spec, caps))
-  {
+  if (!gst_ring_buffer_parse_caps (spec, caps)) {
     GST_OBJECT_UNLOCK (src);
     goto parse_error;
   }
@@ -759,7 +758,7 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
 {
   GstBaseAudioSrc *src = GST_BASE_AUDIO_SRC (bsrc);
   GstBuffer *buf;
-  guchar *data;
+  guchar *data, *ptr;
   guint samples, total_samples;
   guint64 sample;
   gint bps;
@@ -804,10 +803,9 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
 
   /* FIXME, using a bufferpool would be nice here */
   buf = gst_buffer_new_and_alloc (length);
-  data = GST_BUFFER_DATA (buf);
-
+  data = ptr = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
   do {
-    read = gst_ring_buffer_read (ringbuffer, sample, data, samples);
+    read = gst_ring_buffer_read (ringbuffer, sample, ptr, samples);
     GST_DEBUG_OBJECT (src, "read %u of %u", read, samples);
     /* if we read all, we're done */
     if (read == samples)
@@ -823,8 +821,9 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
     /* read next samples */
     sample += read;
     samples -= read;
-    data += read * bps;
+    ptr += read * bps;
   } while (TRUE);
+  gst_buffer_unmap (buf, data, length);
 
   /* mark discontinuity if needed */
   if (G_UNLIKELY (sample != src->next_sample) && src->next_sample != -1) {
index 2989d06..449398d 100644 (file)
@@ -1601,10 +1601,10 @@ default_commit (GstRingBuffer * buf, guint64 * sample,
   gint inr, outr;
   gboolean reverse;
 
-  g_return_val_if_fail (buf->data != NULL, -1);
+  g_return_val_if_fail (buf->memory != NULL, -1);
   g_return_val_if_fail (data != NULL, -1);
 
-  dest = GST_BUFFER_DATA (buf->data);
+  dest = buf->memory;
   segsize = buf->spec.segsize;
   segtotal = buf->spec.segtotal;
   bps = buf->spec.bytes_per_sample;
@@ -1830,10 +1830,10 @@ gst_ring_buffer_read (GstRingBuffer * buf, guint64 sample, guchar * data,
   guint to_read;
 
   g_return_val_if_fail (GST_IS_RING_BUFFER (buf), -1);
-  g_return_val_if_fail (buf->data != NULL, -1);
+  g_return_val_if_fail (buf->memory != NULL, -1);
   g_return_val_if_fail (data != NULL, -1);
 
-  dest = GST_BUFFER_DATA (buf->data);
+  dest = buf->memory;
   segsize = buf->spec.segsize;
   segtotal = buf->spec.segtotal;
   bps = buf->spec.bytes_per_sample;
@@ -1940,12 +1940,12 @@ gst_ring_buffer_prepare_read (GstRingBuffer * buf, gint * segment,
       return FALSE;
   }
 
-  g_return_val_if_fail (buf->data != NULL, FALSE);
+  g_return_val_if_fail (buf->memory != NULL, FALSE);
   g_return_val_if_fail (segment != NULL, FALSE);
   g_return_val_if_fail (readptr != NULL, FALSE);
   g_return_val_if_fail (len != NULL, FALSE);
 
-  data = GST_BUFFER_DATA (buf->data);
+  data = buf->memory;
 
   /* get the position of the pointer */
   segdone = g_atomic_int_get (&buf->segdone);
@@ -2012,7 +2012,7 @@ gst_ring_buffer_clear (GstRingBuffer * buf, gint segment)
   g_return_if_fail (GST_IS_RING_BUFFER (buf));
 
   /* no data means it's already cleared */
-  if (G_UNLIKELY (buf->data == NULL))
+  if (G_UNLIKELY (buf->memory == NULL))
     return;
 
   /* no empty_seg means it's not opened */
@@ -2021,7 +2021,7 @@ gst_ring_buffer_clear (GstRingBuffer * buf, gint segment)
 
   segment %= buf->spec.segtotal;
 
-  data = GST_BUFFER_DATA (buf->data);
+  data = buf->memory;
   data += segment * buf->spec.segsize;
 
   GST_LOG ("clear segment %d @%p", segment, data);
index 1384d38..5a74cc0 100644 (file)
@@ -257,7 +257,8 @@ struct _GstRingBuffer {
   GCond                 *cond;
   gboolean               open;
   gboolean               acquired;
-  GstBuffer             *data;
+  guint8                *memory;
+  gsize                  size;
   GstRingBufferSpec      spec;
   GstRingBufferSegState *segstate;
   gint                   samples_per_seg;
index e753a56..668217d 100644 (file)
@@ -1647,7 +1647,7 @@ gst_cdda_base_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
 
   /* fallback duration: 4 bytes per sample, 44100 samples per second */
   if (duration == GST_CLOCK_TIME_NONE) {
-    duration = gst_util_uint64_scale_int (GST_BUFFER_SIZE (buf) >> 2,
+    duration = gst_util_uint64_scale_int (gst_buffer_get_size (buf) >> 2,
         GST_SECOND, 44100);
   }
 
index 6328a76..78c6643 100644 (file)
 
 #include "gstnetbuffer.h"
 
-static void gst_netbuffer_finalize (GstNetBuffer * nbuf);
-static GstNetBuffer *gst_netbuffer_copy (GstNetBuffer * nbuf);
-
-static GstBufferClass *parent_class;
-
-G_DEFINE_TYPE (GstNetBuffer, gst_netbuffer, GST_TYPE_BUFFER);
-
-static void
-gst_netbuffer_class_init (GstNetBufferClass * netbuffer_class)
-{
-  GstMiniObjectClass *mo_class = GST_MINI_OBJECT_CLASS (netbuffer_class);
-
-  parent_class = g_type_class_peek_parent (netbuffer_class);
-
-  mo_class->copy = (GstMiniObjectCopyFunction) gst_netbuffer_copy;
-  mo_class->finalize = (GstMiniObjectFinalizeFunction) gst_netbuffer_finalize;
-}
-
 static void
-gst_netbuffer_init (GstNetBuffer * instance)
+meta_net_address_copy (GstBuffer * copybuf, GstMetaNetAddress * meta,
+    GstBuffer * buffer, gsize offset, gsize size)
 {
-}
+  GstMetaNetAddress *naddr;
 
-static void
-gst_netbuffer_finalize (GstNetBuffer * nbuf)
-{
-  GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (nbuf));
+  naddr = gst_buffer_add_meta_net_address (copybuf);
+  memcpy (&naddr->naddr, &meta->naddr, sizeof (meta->naddr));
 }
 
-static GstNetBuffer *
-gst_netbuffer_copy (GstNetBuffer * nbuf)
+const GstMetaInfo *
+gst_meta_net_address_get_info (void)
 {
-  GstNetBuffer *copy;
-
-  copy = gst_netbuffer_new ();
-
-  /* we simply copy everything from our parent */
-  GST_BUFFER_DATA (copy) =
-      g_memdup (GST_BUFFER_DATA (nbuf), GST_BUFFER_SIZE (nbuf));
-  /* make sure it gets freed (even if the parent is subclassed, we return a
-     normal buffer) */
-  GST_BUFFER_MALLOCDATA (copy) = GST_BUFFER_DATA (copy);
-  GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (nbuf);
-
-  memcpy (&copy->to, &nbuf->to, sizeof (nbuf->to));
-  memcpy (&copy->from, &nbuf->from, sizeof (nbuf->from));
-
-  /* copy metadata */
-  gst_buffer_copy_metadata (GST_BUFFER_CAST (copy),
-      GST_BUFFER_CAST (nbuf), GST_BUFFER_COPY_ALL);
-
-  return copy;
-}
-
-/**
- * gst_netbuffer_new:
- *
- * Create a new network buffer.
- *
- * Returns: a new #GstNetBuffer.
- */
-GstNetBuffer *
-gst_netbuffer_new (void)
-{
-  GstNetBuffer *buf;
-
-  buf = (GstNetBuffer *) gst_mini_object_new (GST_TYPE_NETBUFFER);
-
-  return buf;
+  static const GstMetaInfo *meta_info = NULL;
+
+  if (meta_info == NULL) {
+    meta_info = gst_meta_register ("GstMetaNetAddress", "GstMetaNetAddress",
+        sizeof (GstMetaNetAddress),
+        (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) NULL,
+        (GstMetaCopyFunction) meta_net_address_copy,
+        (GstMetaTransformFunction) NULL,
+        (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+  }
+  return meta_info;
 }
 
 /**
index 91770e4..368490a 100644 (file)
 
 G_BEGIN_DECLS
 
+#if 0
 typedef struct _GstNetBuffer GstNetBuffer;
 typedef struct _GstNetBufferClass GstNetBufferClass;
+#endif
 typedef struct _GstNetAddress GstNetAddress;
 
+#if 0
 #define GST_TYPE_NETBUFFER            (gst_netbuffer_get_type())
 #define GST_IS_NETBUFFER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NETBUFFER))
 #define GST_IS_NETBUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_NETBUFFER))
 #define GST_NETBUFFER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_NETBUFFER, GstNetBufferClass))
 #define GST_NETBUFFER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_NETBUFFER, GstNetBuffer))
 #define GST_NETBUFFER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_NETBUFFER, GstNetBufferClass))
+#endif
 
 /**
  * GstNetType:
@@ -62,7 +66,7 @@ typedef enum {
 /**
  * GstNetAddress:
  *
- * An opaque network address as used in #GstNetBuffer.
+ * An opaque network address as used in #GstMetaNetAddress.
  */
 struct _GstNetAddress {
   /*< private >*/
@@ -76,36 +80,26 @@ struct _GstNetAddress {
   gpointer _gst_reserved[GST_PADDING];
 };
 
+typedef struct _GstMetaNetAddress GstMetaNetAddress;
+
 /**
- * GstNetBuffer:
- * @buffer: the parent #GstBuffer
- * @from: the address where this buffer came from.
- * @to: the address where this buffer should go to.
+ * GstMetaNetAddress:
  *
- * buffer for use in network sources and sinks.
- * It contains the source or destination address of the buffer.
+ * Buffer metadata for network addresses.
  */
-struct _GstNetBuffer {
-  GstBuffer buffer;
-
-  GstNetAddress from;
-  GstNetAddress to;
+struct _GstMetaNetAddress {
+  GstMeta       meta;
 
-  /*< private >*/
-  gpointer _gst_reserved[GST_PADDING];
-};
-
-struct _GstNetBufferClass {
-  GstBufferClass  buffer_class;
-
-  /*< private >*/
-  gpointer _gst_reserved[GST_PADDING];
+  GstNetAddress naddr;
 };
 
-/* creating buffers */
-GType           gst_netbuffer_get_type           (void);
+const GstMetaInfo *gst_meta_net_address_get_info (void);
+#define GST_META_NET_ADDRESS_INFO (gst_meta_net_address_get_info())
 
-GstNetBuffer*   gst_netbuffer_new                (void);
+#define gst_buffer_get_meta_net_address(b) \
+  ((GstMetaNetAddress*)gst_buffer_get_meta((b),GST_META_NET_ADDRESS_INFO))
+#define gst_buffer_add_meta_net_address(b) \
+  ((GstMetaNetAddress*)gst_buffer_add_meta((b),GST_META_NET_ADDRESS_INFO,NULL))
 
 /* address operations */
 void            gst_netaddress_set_ip4_address   (GstNetAddress *naddr, guint32 address, guint16 port);
index eaa7507..894822e 100644 (file)
 
 struct _GstEncodingProfile
 {
-  GstMiniObject parent;
+  GObject parent;
 
   /*< public > */
   gchar *name;
@@ -165,8 +165,7 @@ gst_encoding_profile_get_type (void)
   static volatile gsize g_define_type_id__volatile = 0;
 
   if (g_once_init_enter (&g_define_type_id__volatile)) {
-    GType g_define_type_id =
-        g_type_register_static_simple (GST_TYPE_MINI_OBJECT,
+    GType g_define_type_id = g_type_register_static_simple (G_TYPE_OBJECT,
         g_intern_static_string ("GstEncodingProfile"),
         sizeof (GstEncodingProfileClass),
         (GClassInitFunc) gst_encoding_profile_class_intern_init,
@@ -194,8 +193,9 @@ gst_encoding_profile_get_type (void)
 }
 
 static void
-gst_encoding_profile_finalize (GstEncodingProfile * prof)
+gst_encoding_profile_finalize (GObject * object)
 {
+  GstEncodingProfile *prof = (GstEncodingProfile *) object;
   if (prof->name)
     g_free (prof->name);
   if (prof->format)
@@ -209,10 +209,9 @@ gst_encoding_profile_finalize (GstEncodingProfile * prof)
 }
 
 static void
-gst_encoding_profile_class_init (GstMiniObjectClass * klass)
+gst_encoding_profile_class_init (GObjectClass * klass)
 {
-  klass->finalize =
-      (GstMiniObjectFinalizeFunction) gst_encoding_profile_finalize;
+  klass->finalize = gst_encoding_profile_finalize;
 }
 
 /**
@@ -432,20 +431,21 @@ gst_encoding_container_profile_init (GstEncodingContainerProfile * prof)
 }
 
 static void
-gst_encoding_container_profile_finalize (GstEncodingContainerProfile * prof)
+gst_encoding_container_profile_finalize (GObject * object)
 {
-  g_list_foreach (prof->encodingprofiles, (GFunc) gst_mini_object_unref, NULL);
+  GstEncodingContainerProfile *prof = (GstEncodingContainerProfile *) object;
+
+  g_list_foreach (prof->encodingprofiles, (GFunc) g_object_unref, NULL);
   g_list_free (prof->encodingprofiles);
 
-  GST_MINI_OBJECT_CLASS (gst_encoding_container_profile_parent_class)->finalize
-      ((GstMiniObject *) prof);
+  G_OBJECT_CLASS (gst_encoding_container_profile_parent_class)->finalize
+      ((GObject *) prof);
 }
 
 static void
-gst_encoding_container_profile_class_init (GstMiniObjectClass * klass)
+gst_encoding_container_profile_class_init (GObjectClass * klass)
 {
-  klass->finalize =
-      (GstMiniObjectFinalizeFunction) gst_encoding_container_profile_finalize;
+  klass->finalize = gst_encoding_container_profile_finalize;
 }
 
 const GList *
@@ -475,7 +475,7 @@ gst_encoding_video_profile_init (GstEncodingVideoProfile * prof)
 }
 
 static void
-gst_encoding_video_profile_class_init (GstMiniObjectClass * klass)
+gst_encoding_video_profile_class_init (GObjectClass * klass)
 {
 }
 
@@ -562,7 +562,7 @@ gst_encoding_audio_profile_init (GstEncodingAudioProfile * prof)
 }
 
 static void
-gst_encoding_audio_profile_class_init (GstMiniObjectClass * klass)
+gst_encoding_audio_profile_class_init (GObjectClass * klass)
 {
 }
 
@@ -688,7 +688,7 @@ common_creation (GType objtype, GstCaps * format, const gchar * preset,
 {
   GstEncodingProfile *prof;
 
-  prof = (GstEncodingProfile *) gst_mini_object_new (objtype);
+  prof = (GstEncodingProfile *) g_object_new (objtype, NULL);
 
   if (name)
     prof->name = g_strdup (name);
@@ -947,7 +947,7 @@ string_to_profile_transform (const GValue * src_value, GValue * dest_value)
   profile = combo_search (profilename);
 
   if (profile)
-    gst_value_take_mini_object (dest_value, (GstMiniObject *) profile);
+    g_value_take_object (dest_value, (GObject *) profile);
 }
 
 static gboolean
@@ -958,7 +958,7 @@ gst_encoding_profile_deserialize_valfunc (GValue * value, const gchar * s)
   profile = combo_search (s);
 
   if (profile) {
-    gst_value_take_mini_object (value, (GstMiniObject *) profile);
+    g_value_take_object (value, (GObject *) profile);
     return TRUE;
   }
 
index 86becca..d019546 100644 (file)
@@ -43,7 +43,7 @@ G_BEGIN_DECLS
 #define GST_IS_ENCODING_PROFILE(obj)                   \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ENCODING_PROFILE))
 typedef struct _GstEncodingProfile GstEncodingProfile;
-typedef GstMiniObjectClass GstEncodingProfileClass;
+typedef GObjectClass GstEncodingProfileClass;
 GType gst_encoding_profile_get_type (void);
 
 
@@ -115,7 +115,7 @@ GType gst_encoding_audio_profile_get_type (void);
  *
  * Since: 0.10.32
  */
-#define gst_encoding_profile_unref(profile) (gst_mini_object_unref ((GstMiniObject*) profile))
+#define gst_encoding_profile_unref(profile) (g_object_unref ((GObject*) profile))
 
 /**
  * gst_encoding_profile_ref:
@@ -125,7 +125,7 @@ GType gst_encoding_audio_profile_get_type (void);
  *
  * Since: 0.10.32
  */
-#define gst_encoding_profile_ref(profile) (gst_mini_object_ref ((GstMiniObject*) profile))
+#define gst_encoding_profile_ref(profile) (g_object_ref ((GObject*) profile))
 
 const gchar *  gst_encoding_profile_get_name(GstEncodingProfile *profile);
 const gchar *  gst_encoding_profile_get_description(GstEncodingProfile *profile);
index 29e67d0..bb8223d 100644 (file)
@@ -74,7 +74,7 @@
 
 struct _GstEncodingTarget
 {
-  GstMiniObject parent;
+  GObject parent;
 
   gchar *name;
   gchar *category;
@@ -85,7 +85,7 @@ struct _GstEncodingTarget
   gchar *keyfile;
 };
 
-G_DEFINE_TYPE (GstEncodingTarget, gst_encoding_target, GST_TYPE_MINI_OBJECT);
+G_DEFINE_TYPE (GstEncodingTarget, gst_encoding_target, G_TYPE_OBJECT);
 
 static void
 gst_encoding_target_init (GstEncodingTarget * target)
@@ -94,8 +94,10 @@ gst_encoding_target_init (GstEncodingTarget * target)
 }
 
 static void
-gst_encoding_target_finalize (GstEncodingTarget * target)
+gst_encoding_target_finalize (GObject * object)
 {
+  GstEncodingTarget *target = (GstEncodingTarget *) object;
+
   GST_DEBUG ("Finalizing");
 
   if (target->name)
@@ -105,15 +107,14 @@ gst_encoding_target_finalize (GstEncodingTarget * target)
   if (target->description)
     g_free (target->description);
 
-  g_list_foreach (target->profiles, (GFunc) gst_mini_object_unref, NULL);
+  g_list_foreach (target->profiles, (GFunc) g_object_unref, NULL);
   g_list_free (target->profiles);
 }
 
 static void
-gst_encoding_target_class_init (GstMiniObjectClass * klass)
+gst_encoding_target_class_init (GObjectClass * klass)
 {
-  klass->finalize =
-      (GstMiniObjectFinalizeFunction) gst_encoding_target_finalize;
+  klass->finalize = gst_encoding_target_finalize;
 }
 
 /**
@@ -281,7 +282,7 @@ gst_encoding_target_new (const gchar * name, const gchar * category,
   if (!validate_name (category))
     goto invalid_category;
 
-  res = (GstEncodingTarget *) gst_mini_object_new (GST_TYPE_ENCODING_TARGET);
+  res = (GstEncodingTarget *) g_object_new (GST_TYPE_ENCODING_TARGET, NULL);
   res->name = g_strdup (name);
   res->category = g_strdup (category);
   res->description = g_strdup (description);
index 70c049d..4dcf598 100644 (file)
@@ -89,7 +89,7 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ENCODING_TARGET))
 
 typedef struct _GstEncodingTarget GstEncodingTarget;
-typedef GstMiniObjectClass GstEncodingTargetClass;
+typedef GObjectClass GstEncodingTargetClass;
 
 GType gst_encoding_target_get_type (void);
 
@@ -102,7 +102,7 @@ GType gst_encoding_target_get_type (void);
  * Since: 0.10.32
  */
 #define gst_encoding_target_unref(target) \
-  (gst_mini_object_unref ((GstMiniObject*) target))
+  (g_object_unref ((GObject*) target))
 
 /**
  * gst_encoding_target_ref:
@@ -113,7 +113,7 @@ GType gst_encoding_target_get_type (void);
  * Since: 0.10.32
  */
 #define gst_encoding_target_ref(target) \
-  (gst_mini_object_ref ((GstMiniObject*) target))
+  (g_object_ref ((GObject*) target))
 
 GstEncodingTarget *
 gst_encoding_target_new (const gchar *name, const gchar *category,
index 2edf8e9..124328e 100644 (file)
@@ -42,7 +42,7 @@ static GstDiscovererVideoInfo
 /* Per-stream information */
 
 G_DEFINE_TYPE (GstDiscovererStreamInfo, gst_discoverer_stream_info,
-    GST_TYPE_MINI_OBJECT);
+    G_TYPE_OBJECT);
 
 static void
 gst_discoverer_stream_info_init (GstDiscovererStreamInfo * info)
@@ -51,10 +51,12 @@ gst_discoverer_stream_info_init (GstDiscovererStreamInfo * info)
 }
 
 static void
-gst_discoverer_stream_info_finalize (GstDiscovererStreamInfo * info)
+gst_discoverer_stream_info_finalize (GObject * object)
 {
+  GstDiscovererStreamInfo *info = (GstDiscovererStreamInfo *) object;
+
   if (info->next)
-    gst_mini_object_unref ((GstMiniObject *) info->next);
+    g_object_unref ((GObject *) info->next);
 
   if (info->caps)
     gst_caps_unref (info->caps);
@@ -66,25 +68,17 @@ gst_discoverer_stream_info_finalize (GstDiscovererStreamInfo * info)
     gst_structure_free (info->misc);
 }
 
-static GstDiscovererStreamInfo *
-gst_discoverer_stream_info_copy (GstDiscovererStreamInfo * info)
-{
-  return gst_discoverer_info_copy_int (info, NULL);
-}
-
 static void
-gst_discoverer_stream_info_class_init (GstMiniObjectClass * klass)
+gst_discoverer_stream_info_class_init (GObjectClass * klass)
 {
-  klass->finalize =
-      (GstMiniObjectFinalizeFunction) gst_discoverer_stream_info_finalize;
-  klass->copy = (GstMiniObjectCopyFunction) gst_discoverer_stream_info_copy;
+  klass->finalize = gst_discoverer_stream_info_finalize;
 }
 
 static GstDiscovererStreamInfo *
 gst_discoverer_stream_info_new (void)
 {
   return (GstDiscovererStreamInfo *)
-      gst_mini_object_new (GST_TYPE_DISCOVERER_STREAM_INFO);
+      g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
 }
 
 static GstDiscovererStreamInfo *
@@ -147,28 +141,28 @@ static GstDiscovererContainerInfo *
 gst_discoverer_container_info_new (void)
 {
   return (GstDiscovererContainerInfo *)
-      gst_mini_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO);
+      g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
 }
 
 static void
-gst_discoverer_container_info_finalize (GstDiscovererContainerInfo * info)
+gst_discoverer_container_info_finalize (GObject * object)
 {
+  GstDiscovererContainerInfo *info = (GstDiscovererContainerInfo *) object;
   GList *tmp;
 
   for (tmp = ((GstDiscovererContainerInfo *) info)->streams; tmp;
       tmp = tmp->next)
-    gst_mini_object_unref ((GstMiniObject *) tmp->data);
+    g_object_unref ((GObject *) tmp->data);
 
   gst_discoverer_stream_info_list_free (info->streams);
 
-  gst_discoverer_stream_info_finalize ((GstDiscovererStreamInfo *) info);
+  gst_discoverer_stream_info_finalize ((GObject *) info);
 }
 
 static void
-gst_discoverer_container_info_class_init (GstMiniObjectClass * klass)
+gst_discoverer_container_info_class_init (GObjectClass * klass)
 {
-  klass->finalize =
-      (GstMiniObjectFinalizeFunction) gst_discoverer_container_info_finalize;
+  klass->finalize = gst_discoverer_container_info_finalize;
 }
 
 static GstDiscovererContainerInfo *
@@ -214,7 +208,7 @@ static GstDiscovererAudioInfo *
 gst_discoverer_audio_info_new (void)
 {
   return (GstDiscovererAudioInfo *)
-      gst_mini_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO);
+      g_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO, NULL);
 }
 
 static GstDiscovererAudioInfo *
@@ -238,7 +232,7 @@ G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
     GST_TYPE_DISCOVERER_STREAM_INFO);
 
 static void
-gst_discoverer_video_info_class_init (GstMiniObjectClass * klass)
+gst_discoverer_video_info_class_init (GObjectClass * klass)
 {
   /* Nothing to initialize */
 }
@@ -253,7 +247,7 @@ static GstDiscovererVideoInfo *
 gst_discoverer_video_info_new (void)
 {
   return (GstDiscovererVideoInfo *)
-      gst_mini_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO);
+      g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
 }
 
 static GstDiscovererVideoInfo *
@@ -279,7 +273,7 @@ gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
 }
 
 /* Global stream information */
-G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, GST_TYPE_MINI_OBJECT);
+G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, G_TYPE_OBJECT);
 
 static void
 gst_discoverer_info_init (GstDiscovererInfo * info)
@@ -288,12 +282,13 @@ gst_discoverer_info_init (GstDiscovererInfo * info)
 }
 
 static void
-gst_discoverer_info_finalize (GstDiscovererInfo * info)
+gst_discoverer_info_finalize (GObject * object)
 {
+  GstDiscovererInfo *info = (GstDiscovererInfo *) object;
   g_free (info->uri);
 
   if (info->stream_info)
-    gst_mini_object_unref ((GstMiniObject *) info->stream_info);
+    g_object_unref ((GObject *) info->stream_info);
 
   if (info->misc)
     gst_structure_free (info->misc);
@@ -307,7 +302,7 @@ gst_discoverer_info_finalize (GstDiscovererInfo * info)
 static GstDiscovererInfo *
 gst_discoverer_info_new (void)
 {
-  return (GstDiscovererInfo *) gst_mini_object_new (GST_TYPE_DISCOVERER_INFO);
+  return (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
 }
 
 GstDiscovererInfo *
@@ -350,11 +345,9 @@ gst_discoverer_info_copy (GstDiscovererInfo * ptr)
 }
 
 static void
-gst_discoverer_info_class_init (GstMiniObjectClass * klass)
+gst_discoverer_info_class_init (GObjectClass * klass)
 {
-  klass->finalize =
-      (GstMiniObjectFinalizeFunction) gst_discoverer_info_finalize;
-  klass->copy = (GstMiniObjectCopyFunction) gst_discoverer_info_copy;
+  klass->finalize = gst_discoverer_info_finalize;
 }
 
 /**
index 58d3e52..be27e18 100644 (file)
@@ -616,7 +616,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
       return parent;
     else
       return (GstDiscovererStreamInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_STREAM_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
   }
 
   gst_structure_id_get (st, _CAPS_QUARK, GST_TYPE_CAPS, &caps, NULL);
@@ -630,7 +630,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
       info = (GstDiscovererAudioInfo *) parent;
     else {
       info = (GstDiscovererAudioInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO, NULL);
       info->parent.caps = caps;
     }
 
@@ -671,7 +671,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
       info = (GstDiscovererVideoInfo *) parent;
     else {
       info = (GstDiscovererVideoInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
       info->parent.caps = caps;
     }
 
@@ -722,7 +722,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
       info = parent;
     else {
       info = (GstDiscovererStreamInfo *)
-          gst_mini_object_new (GST_TYPE_DISCOVERER_STREAM_INFO);
+          g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
       info->caps = caps;
     }
 
@@ -885,7 +885,7 @@ parse_stream_topology (GstDiscoverer * dc, const GstStructure * topology,
     GST_DEBUG ("next is a list of %d entries", len);
 
     cont = (GstDiscovererContainerInfo *)
-        gst_mini_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO);
+        g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
     cont->parent.caps = caps;
     res = (GstDiscovererStreamInfo *) cont;
 
@@ -1162,7 +1162,7 @@ _setup_locked (GstDiscoverer * dc)
 
   /* Pop URI off the pending URI list */
   dc->priv->current_info =
-      (GstDiscovererInfo *) gst_mini_object_new (GST_TYPE_DISCOVERER_INFO);
+      (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
   dc->priv->current_info->uri = (gchar *) dc->priv->pending_uris->data;
   dc->priv->pending_uris =
       g_list_delete_link (dc->priv->pending_uris, dc->priv->pending_uris);
index 671dbaa..5225738 100644 (file)
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
 #define GST_IS_DISCOVERER_STREAM_INFO(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_STREAM_INFO))
 typedef struct _GstDiscovererStreamInfo GstDiscovererStreamInfo;
-typedef GstMiniObjectClass GstDiscovererStreamInfoClass;
+typedef GObjectClass GstDiscovererStreamInfoClass;
 GType gst_discoverer_stream_info_get_type (void);
 
 /**
@@ -56,8 +56,8 @@ GType gst_discoverer_stream_info_get_type (void);
  *
  * Since: 0.10.31
  */
-#define gst_discoverer_stream_info_ref(info) ((GstDiscovererStreamInfo*) gst_mini_object_ref((GstMiniObject*) info))
-#define gst_discoverer_stream_info_unref(info) (gst_mini_object_unref((GstMiniObject*) info))
+#define gst_discoverer_stream_info_ref(info) ((GstDiscovererStreamInfo*) g_object_ref((GObject*) info))
+#define gst_discoverer_stream_info_unref(info) (g_object_unref((GObject*) info))
 
 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_previous(GstDiscovererStreamInfo* info);
 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_next(GstDiscovererStreamInfo* info);
@@ -80,7 +80,7 @@ const gchar *            gst_discoverer_stream_info_get_stream_type_nick(GstDisc
 #define GST_IS_DISCOVERER_CONTAINER_INFO(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_CONTAINER_INFO))
 typedef struct _GstDiscovererContainerInfo GstDiscovererContainerInfo;
-typedef GstMiniObjectClass GstDiscovererContainerInfoClass;
+typedef GObjectClass GstDiscovererContainerInfoClass;
 
 GType gst_discoverer_container_info_get_type (void);
 
@@ -101,7 +101,7 @@ GList *gst_discoverer_container_info_get_streams(GstDiscovererContainerInfo *inf
 #define GST_IS_DISCOVERER_AUDIO_INFO(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_AUDIO_INFO))
 typedef struct _GstDiscovererAudioInfo GstDiscovererAudioInfo;
-typedef GstMiniObjectClass GstDiscovererAudioInfoClass;
+typedef GObjectClass GstDiscovererAudioInfoClass;
 
 GType gst_discoverer_audio_info_get_type (void);
 
@@ -125,7 +125,7 @@ guint gst_discoverer_audio_info_get_max_bitrate(const GstDiscovererAudioInfo* in
 #define GST_IS_DISCOVERER_VIDEO_INFO(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_VIDEO_INFO))
 typedef struct _GstDiscovererVideoInfo GstDiscovererVideoInfo;
-typedef GstMiniObjectClass GstDiscovererVideoInfoClass;
+typedef GObjectClass GstDiscovererVideoInfoClass;
 GType gst_discoverer_video_info_get_type (void);
 
 guint           gst_discoverer_video_info_get_width(const GstDiscovererVideoInfo* info);
@@ -178,11 +178,11 @@ typedef struct _GstDiscovererInfo GstDiscovererInfo;
   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_INFO, GstDiscovererInfo))
 #define GST_IS_DISCOVERER_INFO(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_INFO))
-typedef GstMiniObjectClass GstDiscovererInfoClass;
+typedef GObjectClass GstDiscovererInfoClass;
 GType gst_discoverer_info_get_type (void);
 
-#define gst_discoverer_info_unref(info) (gst_mini_object_unref((GstMiniObject*)info))
-#define gst_discoverer_info_ref(info) (gst_mini_object_ref((GstMiniObject*)info))
+#define gst_discoverer_info_unref(info) (g_object_unref((GObject*)info))
+#define gst_discoverer_info_ref(info) (g_object_ref((Gbject*)info))
 
 GstDiscovererInfo*        gst_discoverer_info_copy (GstDiscovererInfo * ptr);
 
index 5031df0..2d7fcd8 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 struct _GstDiscovererStreamInfo {
-  GstMiniObject          parent;
+  GObject                parent;
 
   GstDiscovererStreamInfo *previous;  /* NULL for starting points */
   GstDiscovererStreamInfo *next; /* NULL for containers */
@@ -65,7 +65,7 @@ struct _GstDiscovererVideoInfo {
 };
 
 struct _GstDiscovererInfo {
-  GstMiniObject parent;
+  GObject parent;
 
   gchar *uri;
   GstDiscovererResult result;
index 40b2bf6..7d4c148 100644 (file)
@@ -908,18 +908,19 @@ gst_riff_create_video_caps (guint32 codec_fcc,
   if (palette) {
     GstBuffer *copy;
     guint num_colors;
+    gsize size;
 
     if (strf != NULL)
       num_colors = strf->num_colors;
     else
       num_colors = 256;
 
-    if (GST_BUFFER_SIZE (palette) >= (num_colors * 4)) {
+    size = gst_buffer_get_size (palette);
+
+    if (size >= (num_colors * 4)) {
       /* palette is always at least 256*4 bytes */
-      copy =
-          gst_buffer_new_and_alloc (MAX (GST_BUFFER_SIZE (palette), 256 * 4));
-      memcpy (GST_BUFFER_DATA (copy), GST_BUFFER_DATA (palette),
-          GST_BUFFER_SIZE (palette));
+      copy = gst_buffer_new_and_alloc (MAX (size, 256 * 4));
+      gst_buffer_copy_into (copy, palette, GST_BUFFER_COPY_MEMORY, 0, size);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
       {
@@ -1466,25 +1467,28 @@ gst_riff_create_audio_caps (guint16 codec_id,
       guint16 valid_bits_per_sample;
       guint32 channel_mask;
       guint32 subformat_guid[4];
-      const guint8 *data;
+      guint8 *data;
+      gsize size;
 
       channels_max = 8;
 
       /* should be at least 22 bytes */
-      if (strf_data == NULL || GST_BUFFER_SIZE (strf_data) < 22) {
+      size = gst_buffer_get_size (strf_data);
+
+      if (strf_data == NULL || size < 22) {
         GST_WARNING ("WAVE_FORMAT_EXTENSIBLE data size is %d (expected: 22)",
-            (strf_data) ? GST_BUFFER_SIZE (strf_data) : -1);
+            (strf_data) ? size : -1);
         return NULL;
       }
 
-      data = GST_BUFFER_DATA (strf_data);
-
+      data = gst_buffer_map (strf_data, &size, NULL, GST_MAP_READ);
       valid_bits_per_sample = GST_READ_UINT16_LE (data);
       channel_mask = GST_READ_UINT32_LE (data + 2);
       subformat_guid[0] = GST_READ_UINT32_LE (data + 6);
       subformat_guid[1] = GST_READ_UINT32_LE (data + 10);
       subformat_guid[2] = GST_READ_UINT32_LE (data + 14);
       subformat_guid[3] = GST_READ_UINT32_LE (data + 18);
+      gst_buffer_unmap (strf_data, data, size);
 
       GST_DEBUG ("valid bps    = %u", valid_bits_per_sample);
       GST_DEBUG ("channel mask = 0x%08x", channel_mask);
index e5983be..c422f04 100644 (file)
@@ -52,8 +52,10 @@ gst_riff_read_chunk (GstElement * element,
 {
   GstBuffer *buf;
   GstFlowReturn res;
+  guint8 *data;
   guint size;
   guint64 offset = *_offset;
+  gsize bsize;
 
   g_return_val_if_fail (element != NULL, GST_FLOW_ERROR);
   g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
@@ -65,11 +67,13 @@ skip_junk:
   size = 8;
   if ((res = gst_pad_pull_range (pad, offset, size, &buf)) != GST_FLOW_OK)
     return res;
-  else if (GST_BUFFER_SIZE (buf) < size)
+  else if (gst_buffer_get_size (buf) < size)
     goto too_small;
 
-  *tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
-  size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
+  data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  *tag = GST_READ_UINT32_LE (data);
+  size = GST_READ_UINT32_LE (data + 4);
+  gst_buffer_unmap (buf, data, bsize);
   gst_buffer_unref (buf);
 
   GST_DEBUG_OBJECT (element, "fourcc=%" GST_FOURCC_FORMAT ", size=%u",
@@ -86,7 +90,7 @@ skip_junk:
 
   if ((res = gst_pad_pull_range (pad, offset + 8, size, &buf)) != GST_FLOW_OK)
     return res;
-  else if (GST_BUFFER_SIZE (buf) < size)
+  else if (gst_buffer_get_size (buf) < size)
     goto too_small;
 
   *_chunk_data = buf;
@@ -99,7 +103,7 @@ too_small:
   {
     /* short read, we return UNEXPECTED to mark the EOS case */
     GST_DEBUG_OBJECT (element, "not enough data (available=%u, needed=%u)",
-        GST_BUFFER_SIZE (buf), size);
+        gst_buffer_get_size (buf), size);
     gst_buffer_unref (buf);
     return GST_FLOW_UNEXPECTED;
   }
@@ -125,7 +129,8 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
 {
   guint size, bufsize;
   guint32 fourcc;
-  guint8 *data;
+  guint8 *data, *ptr;
+  gsize bsize;
   guint offset = *_offset;
 
   g_return_val_if_fail (element != NULL, FALSE);
@@ -137,7 +142,7 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
   *chunk_data = NULL;
   *_fourcc = 0;
 
-  bufsize = GST_BUFFER_SIZE (buf);
+  bufsize = gst_buffer_get_size (buf);
 
   if (bufsize == offset)
     goto end_offset;
@@ -146,9 +151,11 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
     goto too_small;
 
   /* read header */
-  data = GST_BUFFER_DATA (buf) + offset;
-  fourcc = GST_READ_UINT32_LE (data);
-  size = GST_READ_UINT32_LE (data + 4);
+  data = ptr = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  ptr += offset;
+  fourcc = GST_READ_UINT32_LE (ptr);
+  size = GST_READ_UINT32_LE (ptr + 4);
+  gst_buffer_unmap (buf, data, bsize);
 
   GST_DEBUG_OBJECT (element, "fourcc=%" GST_FOURCC_FORMAT ", size=%u",
       GST_FOURCC_ARGS (fourcc), size);
@@ -165,7 +172,8 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
   }
 
   if (size)
-    *chunk_data = gst_buffer_create_sub (buf, offset + 8, size);
+    *chunk_data =
+        gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset + 8, size);
   else
     *chunk_data = NULL;
 
@@ -217,19 +225,21 @@ gst_riff_parse_file_header (GstElement * element,
 {
   guint8 *data;
   guint32 tag;
+  gsize size;
 
   g_return_val_if_fail (buf != NULL, FALSE);
   g_return_val_if_fail (doctype != NULL, FALSE);
 
-  if (GST_BUFFER_SIZE (buf) < 12)
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  if (size < 12)
     goto too_small;
 
-  data = GST_BUFFER_DATA (buf);
   tag = GST_READ_UINT32_LE (data);
   if (tag != GST_RIFF_TAG_RIFF && tag != GST_RIFF_TAG_AVF0)
     goto not_riff;
 
   *doctype = GST_READ_UINT32_LE (data + 8);
+  gst_buffer_unmap (buf, data, size);
 
   gst_buffer_unref (buf);
 
@@ -240,7 +250,8 @@ too_small:
   {
     GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
         ("Not enough data to parse RIFF header (%d available, %d needed)",
-            GST_BUFFER_SIZE (buf), 12));
+            size, 12));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -249,6 +260,7 @@ not_riff:
     GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
         ("Stream is no RIFF stream: %" GST_FOURCC_FORMAT,
             GST_FOURCC_ARGS (tag)));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -272,14 +284,19 @@ gst_riff_parse_strh (GstElement * element,
     GstBuffer * buf, gst_riff_strh ** _strh)
 {
   gst_riff_strh *strh;
+  guint8 *data;
+  gsize size;
 
   g_return_val_if_fail (buf != NULL, FALSE);
   g_return_val_if_fail (_strh != NULL, FALSE);
 
-  if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strh))
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  if (size < sizeof (gst_riff_strh))
     goto too_small;
 
-  strh = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  strh = g_memdup (data, size);
+  gst_buffer_unmap (buf, data, size);
+
   gst_buffer_unref (buf);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
@@ -329,7 +346,8 @@ too_small:
   {
     GST_ERROR_OBJECT (element,
         "Too small strh (%d available, %d needed)",
-        GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strh));
+        size, (int) sizeof (gst_riff_strh));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -357,15 +375,19 @@ gst_riff_parse_strf_vids (GstElement * element,
     GstBuffer * buf, gst_riff_strf_vids ** _strf, GstBuffer ** data)
 {
   gst_riff_strf_vids *strf;
+  guint8 *bdata;
+  gsize size;
 
   g_return_val_if_fail (buf != NULL, FALSE);
   g_return_val_if_fail (_strf != NULL, FALSE);
   g_return_val_if_fail (data != NULL, FALSE);
 
-  if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_vids))
+  bdata = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  if (size < sizeof (gst_riff_strf_vids))
     goto too_small;
 
-  strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  strf = g_memdup (bdata, size);
+  gst_buffer_unmap (buf, bdata, size);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
   strf->size = GUINT32_FROM_LE (strf->size);
@@ -383,16 +405,18 @@ gst_riff_parse_strf_vids (GstElement * element,
 
   /* size checking */
   *data = NULL;
-  if (strf->size > GST_BUFFER_SIZE (buf)) {
+  if (strf->size > size) {
     GST_WARNING_OBJECT (element,
         "strf_vids header gave %d bytes data, only %d available",
-        strf->size, GST_BUFFER_SIZE (buf));
-    strf->size = GST_BUFFER_SIZE (buf);
+        strf->size, size);
+    strf->size = size;
   }
-  if (sizeof (gst_riff_strf_vids) < GST_BUFFER_SIZE (buf)) {
-    *data = gst_buffer_create_sub (buf, sizeof (gst_riff_strf_vids),
-        GST_BUFFER_SIZE (buf) - sizeof (gst_riff_strf_vids));
+  if (sizeof (gst_riff_strf_vids) < size) {
+    *data =
+        gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL,
+        sizeof (gst_riff_strf_vids), size - sizeof (gst_riff_strf_vids));
   }
+  gst_buffer_unref (buf);
 
   /* debug */
   GST_INFO_OBJECT (element, "strf tag found in context vids:");
@@ -409,9 +433,8 @@ gst_riff_parse_strf_vids (GstElement * element,
   GST_INFO_OBJECT (element, " num_colors  %d", strf->num_colors);
   GST_INFO_OBJECT (element, " imp_colors  %d", strf->imp_colors);
   if (*data)
-    GST_INFO_OBJECT (element, " %d bytes extradata", GST_BUFFER_SIZE (*data));
-
-  gst_buffer_unref (buf);
+    GST_INFO_OBJECT (element, " %d bytes extradata",
+        gst_buffer_get_size (*data));
 
   *_strf = strf;
 
@@ -422,7 +445,8 @@ too_small:
   {
     GST_ERROR_OBJECT (element,
         "Too small strf_vids (%d available, %d needed)",
-        GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_vids));
+        size, (int) sizeof (gst_riff_strf_vids));
+    gst_buffer_unmap (buf, data, size);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -450,18 +474,18 @@ gst_riff_parse_strf_auds (GstElement * element,
     GstBuffer * buf, gst_riff_strf_auds ** _strf, GstBuffer ** data)
 {
   gst_riff_strf_auds *strf;
-  guint bufsize;
+  gsize bsize;
+  guint8 *bdata;
 
   g_return_val_if_fail (buf != NULL, FALSE);
   g_return_val_if_fail (_strf != NULL, FALSE);
   g_return_val_if_fail (data != NULL, FALSE);
 
-  bufsize = GST_BUFFER_SIZE (buf);
-
-  if (bufsize < sizeof (gst_riff_strf_auds))
+  bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  if (bsize < sizeof (gst_riff_strf_auds))
     goto too_small;
 
-  strf = g_memdup (GST_BUFFER_DATA (buf), bufsize);
+  strf = g_memdup (bdata, bsize);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
   strf->format = GUINT16_FROM_LE (strf->format);
@@ -474,18 +498,19 @@ gst_riff_parse_strf_auds (GstElement * element,
 
   /* size checking */
   *data = NULL;
-  if (bufsize > sizeof (gst_riff_strf_auds) + 2) {
+  if (bsize > sizeof (gst_riff_strf_auds) + 2) {
     gint len;
 
-    len = GST_READ_UINT16_LE (&GST_BUFFER_DATA (buf)[16]);
-    if (len + 2 + sizeof (gst_riff_strf_auds) > bufsize) {
+    len = GST_READ_UINT16_LE (&data[16]);
+    if (len + 2 + sizeof (gst_riff_strf_auds) > bsize) {
       GST_WARNING_OBJECT (element,
           "Extradata indicated %d bytes, but only %" G_GSSIZE_FORMAT
-          " available", len, bufsize - 2 - sizeof (gst_riff_strf_auds));
-      len = bufsize - 2 - sizeof (gst_riff_strf_auds);
+          " available", len, bsize - 2 - sizeof (gst_riff_strf_auds));
+      len = bsize - 2 - sizeof (gst_riff_strf_auds);
     }
     if (len)
-      *data = gst_buffer_create_sub (buf, sizeof (gst_riff_strf_auds) + 2, len);
+      *data = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL,
+          sizeof (gst_riff_strf_auds) + 2, len);
   }
 
   /* debug */
@@ -497,8 +522,10 @@ gst_riff_parse_strf_auds (GstElement * element,
   GST_INFO_OBJECT (element, " blockalign  %d", strf->blockalign);
   GST_INFO_OBJECT (element, " size        %d", strf->size);
   if (*data)
-    GST_INFO_OBJECT (element, " %d bytes extradata", GST_BUFFER_SIZE (*data));
+    GST_INFO_OBJECT (element, " %d bytes extradata",
+        gst_buffer_get_size (*data));
 
+  gst_buffer_unmap (buf, bdata, bsize);
   gst_buffer_unref (buf);
 
   *_strf = strf;
@@ -510,7 +537,8 @@ too_small:
   {
     GST_ERROR_OBJECT (element,
         "Too small strf_auds (%d available, %" G_GSSIZE_FORMAT " needed)",
-        bufsize, sizeof (gst_riff_strf_auds));
+        bsize, sizeof (gst_riff_strf_auds));
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -538,15 +566,20 @@ gst_riff_parse_strf_iavs (GstElement * element,
     GstBuffer * buf, gst_riff_strf_iavs ** _strf, GstBuffer ** data)
 {
   gst_riff_strf_iavs *strf;
+  gsize bsize;
+  guint8 *bdata;
 
   g_return_val_if_fail (buf != NULL, FALSE);
   g_return_val_if_fail (_strf != NULL, FALSE);
   g_return_val_if_fail (data != NULL, FALSE);
 
-  if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_iavs))
+  bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  if (bsize < sizeof (gst_riff_strf_iavs))
     goto too_small;
 
-  strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  strf = g_memdup (bdata, bsize);
+  gst_buffer_unmap (buf, bdata, bsize);
+
   gst_buffer_unref (buf);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
@@ -581,7 +614,8 @@ too_small:
   {
     GST_ERROR_OBJECT (element,
         "Too small strf_iavs (%d available, %" G_GSSIZE_FORMAT " needed)",
-        GST_BUFFER_SIZE (buf), sizeof (gst_riff_strf_iavs));
+        bsize, sizeof (gst_riff_strf_iavs));
+    gst_buffer_unmap (buf, bdata, bsize);
     gst_buffer_unref (buf);
     return FALSE;
   }
@@ -601,8 +635,9 @@ void
 gst_riff_parse_info (GstElement * element,
     GstBuffer * buf, GstTagList ** _taglist)
 {
-  guint8 *data;
-  guint size, tsize;
+  guint8 *data, *ptr;
+  gsize size, left;
+  guint tsize;
   guint32 tag;
   const gchar *type;
   GstTagList *taglist;
@@ -614,23 +649,26 @@ gst_riff_parse_info (GstElement * element,
     *_taglist = NULL;
     return;
   }
-  data = GST_BUFFER_DATA (buf);
-  size = GST_BUFFER_SIZE (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
   taglist = gst_tag_list_new ();
 
-  while (size > 8) {
-    tag = GST_READ_UINT32_LE (data);
-    tsize = GST_READ_UINT32_LE (data + 4);
-    size -= 8;
-    data += 8;
+  ptr = data;
+  left = size;
+
+  while (left > 8) {
+    tag = GST_READ_UINT32_LE (ptr);
+    tsize = GST_READ_UINT32_LE (ptr + 4);
+    left -= 8;
+    ptr += 8;
 
     GST_DEBUG ("tag %" GST_FOURCC_FORMAT ", size %u",
         GST_FOURCC_ARGS (tag), tsize);
 
-    if (tsize > size) {
+    if (tsize > left) {
       GST_WARNING_OBJECT (element,
-          "Tagsize %d is larger than available data %d", tsize, size);
-      tsize = size;
+          "Tagsize %d is larger than available data %d", tsize, left);
+      tsize = left;
     }
 
     /* find out the type of metadata */
@@ -712,13 +750,13 @@ gst_riff_parse_info (GstElement * element,
         break;
     }
 
-    if (type != NULL && data[0] != '\0') {
+    if (type != NULL && ptr[0] != '\0') {
       static const gchar *env_vars[] = { "GST_AVI_TAG_ENCODING",
         "GST_RIFF_TAG_ENCODING", "GST_TAG_ENCODING", NULL
       };
       gchar *val;
 
-      val = gst_tag_freeform_string_to_utf8 ((gchar *) data, tsize, env_vars);
+      val = gst_tag_freeform_string_to_utf8 ((gchar *) ptr, tsize, env_vars);
 
       if (val) {
         gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, type, val, NULL);
@@ -730,12 +768,12 @@ gst_riff_parse_info (GstElement * element,
 
     if (tsize & 1) {
       tsize++;
-      if (tsize > size)
-        tsize = size;
+      if (tsize > left)
+        tsize = left;
     }
 
-    data += tsize;
-    size -= tsize;
+    ptr += tsize;
+    left -= tsize;
   }
 
   if (!gst_tag_list_is_empty (taglist)) {
@@ -744,6 +782,7 @@ gst_riff_parse_info (GstElement * element,
     *_taglist = NULL;
     gst_tag_list_free (taglist);
   }
+  gst_buffer_unmap (buf, data, size);
 
   return;
 }
index d8ba21b..67137e4 100644 (file)
@@ -406,19 +406,23 @@ gst_base_rtp_audio_payload_set_meta (GstBaseRTPAudioPayload * payload,
 {
   GstBaseRTPPayload *basepayload;
   GstBaseRTPAudioPayloadPrivate *priv;
+  GstRTPBuffer rtp;
 
   basepayload = GST_BASE_RTP_PAYLOAD_CAST (payload);
   priv = payload->priv;
 
   /* set payload type */
-  gst_rtp_buffer_set_payload_type (buffer, basepayload->pt);
+  gst_rtp_buffer_map (buffer, GST_MAP_WRITE, &rtp);
+  gst_rtp_buffer_set_payload_type (&rtp, basepayload->pt);
   /* set marker bit for disconts */
   if (priv->discont) {
     GST_DEBUG_OBJECT (payload, "Setting marker and DISCONT");
-    gst_rtp_buffer_set_marker (buffer, TRUE);
+    gst_rtp_buffer_set_marker (&rtp, TRUE);
     GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
     priv->discont = FALSE;
   }
+  gst_rtp_buffer_unmap (&rtp);
+
   GST_BUFFER_TIMESTAMP (buffer) = timestamp;
 
   /* get the offset in RTP time */
@@ -458,6 +462,7 @@ gst_base_rtp_audio_payload_push (GstBaseRTPAudioPayload * baseaudiopayload,
   GstBuffer *outbuf;
   guint8 *payload;
   GstFlowReturn ret;
+  GstRTPBuffer rtp;
 
   basepayload = GST_BASE_RTP_PAYLOAD (baseaudiopayload);
 
@@ -468,8 +473,10 @@ gst_base_rtp_audio_payload_push (GstBaseRTPAudioPayload * baseaudiopayload,
   outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
 
   /* copy payload */
-  payload = gst_rtp_buffer_get_payload (outbuf);
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
   memcpy (payload, data, payload_len);
+  gst_rtp_buffer_unmap (&rtp);
 
   /* set metadata */
   gst_base_rtp_audio_payload_set_meta (baseaudiopayload, outbuf, payload_len,
@@ -494,7 +501,7 @@ gst_base_rtp_audio_payload_push_buffer (GstBaseRTPAudioPayload *
   priv = baseaudiopayload->priv;
   basepayload = GST_BASE_RTP_PAYLOAD (baseaudiopayload);
 
-  payload_len = GST_BUFFER_SIZE (buffer);
+  payload_len = gst_buffer_get_size (buffer);
 
   GST_DEBUG_OBJECT (baseaudiopayload, "Pushing %d bytes ts %" GST_TIME_FORMAT,
       payload_len, GST_TIME_ARGS (timestamp));
@@ -513,24 +520,29 @@ gst_base_rtp_audio_payload_push_buffer (GstBaseRTPAudioPayload *
 
   if (priv->buffer_list) {
     GstBufferList *list;
-    GstBufferListIterator *it;
+    guint i, len;
 
     list = gst_buffer_list_new ();
-    it = gst_buffer_list_iterate (list);
-
-    /* add both buffers to the buffer list */
-    gst_buffer_list_iterator_add_group (it);
-    gst_buffer_list_iterator_add (it, outbuf);
-    gst_buffer_list_iterator_add (it, buffer);
+    len = gst_buffer_list_len (list);
 
-    gst_buffer_list_iterator_free (it);
+    for (i = 0; i < len; i++) {
+      /* FIXME */
+      g_warning ("bufferlist not implemented");
+      gst_buffer_list_add (list, outbuf);
+      gst_buffer_list_add (list, buffer);
+    }
 
     GST_DEBUG_OBJECT (baseaudiopayload, "Pushing list %p", list);
     ret = gst_basertppayload_push_list (basepayload, list);
   } else {
+    GstRTPBuffer rtp;
+
     /* copy payload */
-    payload = gst_rtp_buffer_get_payload (outbuf);
-    memcpy (payload, GST_BUFFER_DATA (buffer), payload_len);
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
+    gst_buffer_extract (buffer, 0, payload, payload_len);
+    gst_rtp_buffer_unmap (&rtp);
+
     gst_buffer_unref (buffer);
 
     GST_DEBUG_OBJECT (baseaudiopayload, "Pushing buffer %p", outbuf);
@@ -609,13 +621,17 @@ gst_base_rtp_audio_payload_flush (GstBaseRTPAudioPayload * baseaudiopayload,
         gst_base_rtp_audio_payload_push_buffer (baseaudiopayload, buffer,
         timestamp);
   } else {
+    GstRTPBuffer rtp;
+
     /* create buffer to hold the payload */
     outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
 
     /* copy payload */
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+    payload = gst_rtp_buffer_get_payload (&rtp);
     gst_adapter_copy (adapter, payload, 0, payload_len);
     gst_adapter_flush (adapter, payload_len);
+    gst_rtp_buffer_unmap (&rtp);
 
     /* set metadata */
     gst_base_rtp_audio_payload_set_meta (baseaudiopayload, outbuf, payload_len,
@@ -863,7 +879,7 @@ gst_base_rtp_audio_payload_handle_buffer (GstBaseRTPPayload *
       "Calculated min_payload_len %u and max_payload_len %u",
       min_payload_len, max_payload_len);
 
-  size = GST_BUFFER_SIZE (buffer);
+  size = gst_buffer_get_size (buffer);
 
   /* shortcut, we don't need to use the adapter when the packet can be pushed
    * through directly. */
index 978a262..6a1e076 100644 (file)
@@ -273,6 +273,7 @@ gst_base_rtp_depayload_chain (GstPad * pad, GstBuffer * in)
   guint32 rtptime;
   gboolean discont;
   gint gap;
+  GstRTPBuffer rtp;
 
   filter = GST_BASE_RTP_DEPAYLOAD (GST_OBJECT_PARENT (pad));
   priv = filter->priv;
@@ -297,8 +298,11 @@ gst_base_rtp_depayload_chain (GstPad * pad, GstBuffer * in)
   priv->timestamp = timestamp;
   priv->duration = GST_BUFFER_DURATION (in);
 
-  seqnum = gst_rtp_buffer_get_seq (in);
-  rtptime = gst_rtp_buffer_get_timestamp (in);
+  gst_rtp_buffer_map (in, GST_MAP_READ, &rtp);
+  seqnum = gst_rtp_buffer_get_seq (&rtp);
+  rtptime = gst_rtp_buffer_get_timestamp (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
+
   discont = FALSE;
 
   GST_LOG_OBJECT (filter, "discont %d, seqnum %u, rtptime %u, timestamp %"
@@ -341,7 +345,7 @@ gst_base_rtp_depayload_chain (GstPad * pad, GstBuffer * in)
     /* we detected a seqnum discont but the buffer was not flagged with a discont,
      * set the discont flag so that the subclass can throw away old data. */
     priv->discont = TRUE;
-    in = gst_buffer_make_metadata_writable (in);
+    in = gst_buffer_make_writable (in);
     GST_BUFFER_FLAG_SET (in, GST_BUFFER_FLAG_DISCONT);
   }
 
@@ -528,12 +532,12 @@ typedef struct
   gboolean rtptime;
 } HeaderData;
 
-static GstBufferListItem
-set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
+static gboolean
+set_headers (GstBuffer ** buffer, guint idx, HeaderData * data)
 {
   GstBaseRTPDepayload *depayload = data->depayload;
 
-  *buffer = gst_buffer_make_metadata_writable (*buffer);
+  *buffer = gst_buffer_make_writable (*buffer);
   gst_buffer_set_caps (*buffer, data->caps);
 
   /* set the timestamp if we must and can */
@@ -546,7 +550,7 @@ set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
     depayload->priv->discont = FALSE;
   }
 
-  return GST_BUFFER_LIST_SKIP_GROUP;
+  return TRUE;
 }
 
 static GstFlowReturn
@@ -566,7 +570,7 @@ gst_base_rtp_depayload_prepare_push (GstBaseRTPDepayload * filter,
     gst_buffer_list_foreach (*blist, (GstBufferListFunc) set_headers, &data);
   } else {
     GstBuffer **buf = obj;
-    set_headers (buf, 0, 0, &data);
+    set_headers (buf, 0, &data);
   }
 
   /* if this is the first buffer send a NEWSEGMENT */
index 060e4e0..66084f7 100644 (file)
@@ -714,8 +714,8 @@ typedef struct
   guint32 rtptime;
 } HeaderData;
 
-static GstBufferListItem
-find_timestamp (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
+static gboolean
+find_timestamp (GstBuffer ** buffer, guint idx, HeaderData * data)
 {
   data->timestamp = GST_BUFFER_TIMESTAMP (*buffer);
   data->offset = GST_BUFFER_OFFSET (*buffer);
@@ -723,23 +723,28 @@ find_timestamp (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
   /* stop when we find a timestamp. We take whatever offset is associated with
    * the timestamp (if any) to do perfect timestamps when we need to. */
   if (data->timestamp != -1)
-    return GST_BUFFER_LIST_END;
+    return FALSE;
   else
-    return GST_BUFFER_LIST_CONTINUE;
+    return TRUE;
 }
 
-static GstBufferListItem
+static gboolean
 set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
 {
-  gst_rtp_buffer_set_ssrc (*buffer, data->ssrc);
-  gst_rtp_buffer_set_payload_type (*buffer, data->pt);
-  gst_rtp_buffer_set_seq (*buffer, data->seqnum);
-  gst_rtp_buffer_set_timestamp (*buffer, data->rtptime);
+  GstRTPBuffer rtp;
+
+  gst_rtp_buffer_map (*buffer, GST_MAP_WRITE, &rtp);
+  gst_rtp_buffer_set_ssrc (&rtp, data->ssrc);
+  gst_rtp_buffer_set_payload_type (&rtp, data->pt);
+  gst_rtp_buffer_set_seq (&rtp, data->seqnum);
+  gst_rtp_buffer_set_timestamp (&rtp, data->rtptime);
+  gst_rtp_buffer_unmap (&rtp);
+
   gst_buffer_set_caps (*buffer, data->caps);
   /* increment the seqnum for each buffer */
   data->seqnum++;
 
-  return GST_BUFFER_LIST_SKIP_GROUP;
+  return TRUE;
 }
 
 /* Updates the SSRC, payload type, seqnum and timestamp of the RTP buffer
@@ -825,7 +830,7 @@ gst_basertppayload_prepare_push (GstBaseRTPPayload * payload,
   GST_LOG_OBJECT (payload,
       "Preparing to push packet with size %d, seq=%d, rtptime=%u, timestamp %"
       GST_TIME_FORMAT, (is_list) ? -1 :
-      GST_BUFFER_SIZE (GST_BUFFER (obj)), payload->seqnum, data.rtptime,
+      gst_buffer_get_size (GST_BUFFER (obj)), payload->seqnum, data.rtptime,
       GST_TIME_ARGS (data.timestamp));
 
   if (g_atomic_int_compare_and_exchange (&payload->
index 3b37c6f..57bc81a 100644 (file)
@@ -70,10 +70,8 @@ gst_rtcp_buffer_new_take_data (gpointer data, guint len)
   g_return_val_if_fail (len > 0, NULL);
 
   result = gst_buffer_new ();
-
-  GST_BUFFER_MALLOCDATA (result) = data;
-  GST_BUFFER_DATA (result) = data;
-  GST_BUFFER_SIZE (result) = len;
+  gst_buffer_take_memory (result,
+      gst_memory_new_wrapped (0, data, g_free, len, 0, len));
 
   return result;
 }
@@ -205,15 +203,17 @@ wrong_padding:
 gboolean
 gst_rtcp_buffer_validate (GstBuffer * buffer)
 {
+  gboolean res;
   guint8 *data;
-  guint len;
+  gsize len;
 
   g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
 
-  data = GST_BUFFER_DATA (buffer);
-  len = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READ);
+  res = gst_rtcp_buffer_validate_data (data, len);
+  gst_buffer_unmap (buffer, data, len);
 
-  return gst_rtcp_buffer_validate_data (data, len);
+  return res;
 }
 
 /**
@@ -233,36 +233,64 @@ gst_rtcp_buffer_new (guint mtu)
   g_return_val_if_fail (mtu > 0, NULL);
 
   result = gst_buffer_new ();
-  GST_BUFFER_MALLOCDATA (result) = g_malloc0 (mtu);
-  GST_BUFFER_DATA (result) = GST_BUFFER_MALLOCDATA (result);
-  GST_BUFFER_SIZE (result) = mtu;
+  gst_buffer_take_memory (result,
+      gst_memory_new_wrapped (0, g_malloc0 (mtu), g_free, mtu, 0, mtu));
 
   return result;
 }
 
 /**
- * gst_rtcp_buffer_end:
+ * gst_rtcp_buffer_map:
  * @buffer: a buffer with an RTCP packet
+ * @flags: flags for the mapping
+ * @rtcp: resulting #GstRTCPBuffer
  *
- * Finish @buffer after being constructured. This function is usually called
- * after gst_rtcp_buffer_new() and after adding the RTCP items to the new buffer. 
+ * Open @buffer for reading or writing, depending on @flags. The resulting RTCP
+ * buffer state is stored in @rtcp.
+ */
+gboolean
+gst_rtcp_buffer_map (GstBuffer * buffer, GstMapFlags flags,
+    GstRTCPBuffer * rtcp)
+{
+  g_return_val_if_fail (rtcp != NULL, FALSE);
+  g_return_val_if_fail (rtcp->buffer == NULL, FALSE);
+  g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
+
+  rtcp->buffer = buffer;
+  rtcp->flags = flags;
+  rtcp->data = gst_buffer_map (buffer, &rtcp->size, &rtcp->maxsize, flags);
+
+  return TRUE;
+}
+
+/**
+ * gst_rtcp_buffer_unmap:
+ * @buffer: a buffer with an RTCP packet
+ *
+ * Finish @rtcp after being constructured. This function is usually called
+ * after gst_rtcp_buffer_map() and after adding the RTCP items to the new buffer.
  *
  * The function adjusts the size of @buffer with the total length of all the
  * added packets.
  */
-void
-gst_rtcp_buffer_end (GstBuffer * buffer)
+gboolean
+gst_rtcp_buffer_unmap (GstRTCPBuffer * rtcp)
 {
+  gboolean res;
   GstRTCPPacket packet;
 
-  g_return_if_fail (GST_IS_BUFFER (buffer));
+  g_return_val_if_fail (rtcp != NULL, FALSE);
+  g_return_val_if_fail (GST_IS_BUFFER (rtcp->buffer), FALSE);
 
   /* move to the first free space */
-  if (gst_rtcp_buffer_get_first_packet (buffer, &packet))
+  if (gst_rtcp_buffer_get_first_packet (rtcp, &packet))
     while (gst_rtcp_packet_move_to_next (&packet));
 
   /* shrink size */
-  GST_BUFFER_SIZE (buffer) = packet.offset;
+  res = gst_buffer_unmap (rtcp->buffer, rtcp->data, packet.offset);
+  rtcp->buffer = NULL;
+
+  return res;
 }
 
 /**
@@ -274,15 +302,16 @@ gst_rtcp_buffer_end (GstBuffer * buffer)
  * Returns: the number of RTCP packets in @buffer.
  */
 guint
-gst_rtcp_buffer_get_packet_count (GstBuffer * buffer)
+gst_rtcp_buffer_get_packet_count (GstRTCPBuffer * rtcp)
 {
   GstRTCPPacket packet;
   guint count;
 
-  g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
+  g_return_val_if_fail (rtcp != NULL, 0);
+  g_return_val_if_fail (GST_IS_BUFFER (rtcp->buffer), 0);
 
   count = 0;
-  if (gst_rtcp_buffer_get_first_packet (buffer, &packet)) {
+  if (gst_rtcp_buffer_get_first_packet (rtcp, &packet)) {
     do {
       count++;
     } while (gst_rtcp_packet_move_to_next (&packet));
@@ -307,10 +336,9 @@ read_packet_header (GstRTCPPacket * packet)
   guint offset;
 
   g_return_val_if_fail (packet != NULL, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
-  data = GST_BUFFER_DATA (packet->buffer);
-  size = GST_BUFFER_SIZE (packet->buffer);
+  data = packet->rtcp->data;
+  size = packet->rtcp->size;
 
   offset = packet->offset;
 
@@ -345,13 +373,14 @@ read_packet_header (GstRTCPPacket * packet)
  * Returns: TRUE if the packet existed in @buffer.
  */
 gboolean
-gst_rtcp_buffer_get_first_packet (GstBuffer * buffer, GstRTCPPacket * packet)
+gst_rtcp_buffer_get_first_packet (GstRTCPBuffer * rtcp, GstRTCPPacket * packet)
 {
-  g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
+  g_return_val_if_fail (rtcp != NULL, FALSE);
+  g_return_val_if_fail (GST_IS_BUFFER (rtcp->buffer), FALSE);
   g_return_val_if_fail (packet != NULL, FALSE);
 
   /* init to 0 */
-  packet->buffer = buffer;
+  packet->rtcp = rtcp;
   packet->offset = 0;
   packet->type = GST_RTCP_TYPE_INVALID;
 
@@ -376,7 +405,6 @@ gst_rtcp_packet_move_to_next (GstRTCPPacket * packet)
 {
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type != GST_RTCP_TYPE_INVALID, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   /* if we have a padding or invalid packet, it must be the last, 
    * return FALSE */
@@ -413,22 +441,23 @@ end:
  * if the max mtu is exceeded for the buffer.
  */
 gboolean
-gst_rtcp_buffer_add_packet (GstBuffer * buffer, GstRTCPType type,
+gst_rtcp_buffer_add_packet (GstRTCPBuffer * rtcp, GstRTCPType type,
     GstRTCPPacket * packet)
 {
   guint len, size;
   guint8 *data;
   gboolean result;
 
-  g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
+  g_return_val_if_fail (rtcp != NULL, FALSE);
+  g_return_val_if_fail (GST_IS_BUFFER (rtcp->buffer), FALSE);
   g_return_val_if_fail (type != GST_RTCP_TYPE_INVALID, FALSE);
   g_return_val_if_fail (packet != NULL, FALSE);
 
   /* find free space */
-  if (gst_rtcp_buffer_get_first_packet (buffer, packet))
+  if (gst_rtcp_buffer_get_first_packet (rtcp, packet))
     while (gst_rtcp_packet_move_to_next (packet));
 
-  size = GST_BUFFER_SIZE (buffer);
+  size = rtcp->size;
 
   /* packet->offset is now pointing to the next free offset in the buffer to
    * start a compount packet. Next we figure out if we have enough free space in
@@ -461,7 +490,7 @@ gst_rtcp_buffer_add_packet (GstBuffer * buffer, GstRTCPType type,
   if (packet->offset + len >= size)
     goto no_space;
 
-  data = GST_BUFFER_DATA (buffer) + packet->offset;
+  data = rtcp->data + packet->offset;
 
   data[0] = (GST_RTCP_VERSION << 6);
   data[1] = type;
@@ -510,9 +539,8 @@ gst_rtcp_packet_remove (GstRTCPPacket * packet)
   offset = packet->offset + (packet->length << 2) + 4;
 
   /* Overwrite this packet with the rest of the data */
-  memmove (GST_BUFFER_DATA (packet->buffer) + packet->offset,
-      GST_BUFFER_DATA (packet->buffer) + offset,
-      GST_BUFFER_SIZE (packet->buffer) - offset);
+  memmove (packet->rtcp->data + packet->offset,
+      packet->rtcp->data + offset, packet->rtcp->size - offset);
 
   /* try to read next header */
   ret = read_packet_header (packet);
@@ -612,9 +640,8 @@ gst_rtcp_packet_sr_get_sender_info (GstRTCPPacket * packet, guint32 * ssrc,
 
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_SR);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header */
   data += packet->offset + 4;
@@ -653,9 +680,8 @@ gst_rtcp_packet_sr_set_sender_info (GstRTCPPacket * packet, guint32 ssrc,
 
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_SR);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header */
   data += packet->offset + 4;
@@ -686,9 +712,8 @@ gst_rtcp_packet_rr_get_ssrc (GstRTCPPacket * packet)
 
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RR, 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header */
   data += packet->offset + 4;
@@ -711,9 +736,8 @@ gst_rtcp_packet_rr_set_ssrc (GstRTCPPacket * packet, guint32 ssrc)
 
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_RR);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header */
   data += packet->offset + 4;
@@ -734,7 +758,6 @@ gst_rtcp_packet_get_rb_count (GstRTCPPacket * packet)
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RR ||
       packet->type == GST_RTCP_TYPE_SR, 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
   return packet->count;
 }
@@ -765,9 +788,8 @@ gst_rtcp_packet_get_rb (GstRTCPPacket * packet, guint nth, guint32 * ssrc,
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_RR ||
       packet->type == GST_RTCP_TYPE_SR);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header */
   data += packet->offset + 4;
@@ -835,13 +857,12 @@ gst_rtcp_packet_add_rb (GstRTCPPacket * packet, guint32 ssrc,
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RR ||
       packet->type == GST_RTCP_TYPE_SR, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   if (packet->count >= GST_RTCP_MAX_RB_COUNT)
     goto no_space;
 
-  data = GST_BUFFER_DATA (packet->buffer);
-  size = GST_BUFFER_SIZE (packet->buffer);
+  data = packet->rtcp->data;
+  size = packet->rtcp->size;
 
   /* skip header */
   offset = packet->offset + 4;
@@ -911,7 +932,6 @@ gst_rtcp_packet_set_rb (GstRTCPPacket * packet, guint nth, guint32 ssrc,
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_RR ||
       packet->type == GST_RTCP_TYPE_SR);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
   g_warning ("not implemented");
 }
@@ -930,7 +950,6 @@ gst_rtcp_packet_sdes_get_item_count (GstRTCPPacket * packet)
 {
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
   return packet->count;
 }
@@ -948,7 +967,6 @@ gst_rtcp_packet_sdes_first_item (GstRTCPPacket * packet)
 {
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   packet->item_offset = 4;
   packet->item_count = 0;
@@ -977,14 +995,13 @@ gst_rtcp_packet_sdes_next_item (GstRTCPPacket * packet)
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   /* if we are at the last item, we are done */
   if (packet->item_count == packet->count)
     return FALSE;
 
   /* move to SDES */
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
   data += packet->offset;
   /* move to item */
   offset = packet->item_offset;
@@ -1028,10 +1045,9 @@ gst_rtcp_packet_sdes_get_ssrc (GstRTCPPacket * packet)
 
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
   /* move to SDES */
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
   data += packet->offset;
   /* move to item */
   data += packet->item_offset;
@@ -1057,10 +1073,9 @@ gst_rtcp_packet_sdes_first_entry (GstRTCPPacket * packet)
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   /* move to SDES */
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
   data += packet->offset;
   /* move to item */
   offset = packet->item_offset;
@@ -1096,10 +1111,9 @@ gst_rtcp_packet_sdes_next_entry (GstRTCPPacket * packet)
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   /* move to SDES */
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
   data += packet->offset;
   /* move to item */
   offset = packet->item_offset;
@@ -1150,10 +1164,9 @@ gst_rtcp_packet_sdes_get_entry (GstRTCPPacket * packet,
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   /* move to SDES */
-  bdata = GST_BUFFER_DATA (packet->buffer);
+  bdata = packet->rtcp->data;
   bdata += packet->offset;
   /* move to item */
   offset = packet->item_offset;
@@ -1194,7 +1207,6 @@ gst_rtcp_packet_sdes_copy_entry (GstRTCPPacket * packet,
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   if (!gst_rtcp_packet_sdes_get_entry (packet, type, &tlen, &tdata))
     return FALSE;
@@ -1225,7 +1237,6 @@ gst_rtcp_packet_sdes_add_item (GstRTCPPacket * packet, guint32 ssrc)
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   /* increment item count when possible */
   if (packet->count >= GST_RTCP_MAX_SDES_ITEM_COUNT)
@@ -1238,8 +1249,8 @@ gst_rtcp_packet_sdes_add_item (GstRTCPPacket * packet, guint32 ssrc)
   gst_rtcp_packet_sdes_next_item (packet);
 
   /* move to SDES */
-  data = GST_BUFFER_DATA (packet->buffer);
-  size = GST_BUFFER_SIZE (packet->buffer);
+  data = packet->rtcp->data;
+  size = packet->rtcp->size;
   data += packet->offset;
   /* move to current item */
   offset = packet->item_offset;
@@ -1295,11 +1306,10 @@ gst_rtcp_packet_sdes_add_entry (GstRTCPPacket * packet, GstRTCPSDESType type,
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   /* move to SDES */
-  bdata = GST_BUFFER_DATA (packet->buffer);
-  size = GST_BUFFER_SIZE (packet->buffer);
+  bdata = packet->rtcp->data;
+  size = packet->rtcp->size;
   bdata += packet->offset;
   /* move to item */
   offset = packet->item_offset;
@@ -1371,7 +1381,6 @@ gst_rtcp_packet_bye_get_nth_ssrc (GstRTCPPacket * packet, guint nth)
 
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_BYE, 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
   /* get amount of sources and check that we don't read too much */
   sc = packet->count;
@@ -1389,10 +1398,10 @@ gst_rtcp_packet_bye_get_nth_ssrc (GstRTCPPacket * packet, guint nth)
   offset += packet->offset;
 
   /* check if the packet is valid */
-  if (offset + 4 > GST_BUFFER_SIZE (packet->buffer))
+  if (offset + 4 > packet->rtcp->size)
     return 0;
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
   data += offset;
 
   ssrc = GST_READ_UINT32_BE (data);
@@ -1419,13 +1428,12 @@ gst_rtcp_packet_bye_add_ssrc (GstRTCPPacket * packet, guint32 ssrc)
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_BYE, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   if (packet->count >= GST_RTCP_MAX_BYE_SSRC_COUNT)
     goto no_space;
 
-  data = GST_BUFFER_DATA (packet->buffer);
-  size = GST_BUFFER_SIZE (packet->buffer);
+  data = packet->rtcp->data;
+  size = packet->rtcp->size;
 
   /* skip header */
   offset = packet->offset + 4;
@@ -1477,7 +1485,6 @@ gst_rtcp_packet_bye_add_ssrcs (GstRTCPPacket * packet, guint32 * ssrc,
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_BYE, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   res = TRUE;
   for (i = 0; i < len && res; i++) {
@@ -1504,7 +1511,7 @@ get_reason_offset (GstRTCPPacket * packet)
   offset += packet->offset;
 
   /* check if the packet is valid */
-  if (offset + 1 > GST_BUFFER_SIZE (packet->buffer))
+  if (offset + 1 > packet->rtcp->size)
     return 0;
 
   return offset;
@@ -1527,13 +1534,12 @@ gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket * packet)
 
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_BYE, 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
   roffset = get_reason_offset (packet);
   if (roffset == 0)
     return 0;
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   return data[roffset];
 }
@@ -1556,13 +1562,12 @@ gst_rtcp_packet_bye_get_reason (GstRTCPPacket * packet)
 
   g_return_val_if_fail (packet != NULL, NULL);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_BYE, NULL);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), NULL);
 
   roffset = get_reason_offset (packet);
   if (roffset == 0)
     return NULL;
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* get length of reason string */
   len = data[roffset];
@@ -1573,7 +1578,7 @@ gst_rtcp_packet_bye_get_reason (GstRTCPPacket * packet)
   roffset += 1;
 
   /* check if enough data to copy */
-  if (roffset + len > GST_BUFFER_SIZE (packet->buffer))
+  if (roffset + len > packet->rtcp->size)
     return NULL;
 
   return g_strndup ((gconstpointer) (data + roffset), len);
@@ -1597,7 +1602,6 @@ gst_rtcp_packet_bye_set_reason (GstRTCPPacket * packet, const gchar * reason)
 
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_BYE, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
   if (reason == NULL)
     return TRUE;
@@ -1613,8 +1617,8 @@ gst_rtcp_packet_bye_set_reason (GstRTCPPacket * packet, const gchar * reason)
   if (roffset == 0)
     goto no_space;
 
-  data = GST_BUFFER_DATA (packet->buffer);
-  size = GST_BUFFER_SIZE (packet->buffer);
+  data = packet->rtcp->data;
+  size = packet->rtcp->size;
 
   /* we have 1 byte length and we need to pad to 4 bytes */
   padded = ((len + 1) + 3) & ~3;
@@ -1660,9 +1664,8 @@ gst_rtcp_packet_fb_get_sender_ssrc (GstRTCPPacket * packet)
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail ((packet->type == GST_RTCP_TYPE_RTPFB ||
           packet->type == GST_RTCP_TYPE_PSFB), 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header */
   data += packet->offset + 4;
@@ -1688,9 +1691,8 @@ gst_rtcp_packet_fb_set_sender_ssrc (GstRTCPPacket * packet, guint32 ssrc)
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
       packet->type == GST_RTCP_TYPE_PSFB);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header */
   data += packet->offset + 4;
@@ -1716,9 +1718,8 @@ gst_rtcp_packet_fb_get_media_ssrc (GstRTCPPacket * packet)
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail ((packet->type == GST_RTCP_TYPE_RTPFB ||
           packet->type == GST_RTCP_TYPE_PSFB), 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header and sender ssrc */
   data += packet->offset + 8;
@@ -1744,9 +1745,8 @@ gst_rtcp_packet_fb_set_media_ssrc (GstRTCPPacket * packet, guint32 ssrc)
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
       packet->type == GST_RTCP_TYPE_PSFB);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   /* skip header and sender ssrc */
   data += packet->offset + 8;
@@ -1790,9 +1790,8 @@ gst_rtcp_packet_fb_set_type (GstRTCPPacket * packet, GstRTCPFBType type)
   g_return_if_fail (packet != NULL);
   g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
       packet->type == GST_RTCP_TYPE_PSFB);
-  g_return_if_fail (GST_IS_BUFFER (packet->buffer));
 
-  data = GST_BUFFER_DATA (packet->buffer);
+  data = packet->rtcp->data;
 
   data[packet->offset] = (data[packet->offset] & 0xe0) | type;
   packet->count = type;
@@ -1963,9 +1962,8 @@ gst_rtcp_packet_fb_get_fci_length (GstRTCPPacket * packet)
   g_return_val_if_fail (packet != NULL, 0);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
       packet->type == GST_RTCP_TYPE_PSFB, 0);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), 0);
 
-  data = GST_BUFFER_DATA (packet->buffer) + packet->offset + 2;
+  data = packet->rtcp->data + packet->offset + 2;
 
   return GST_READ_UINT16_BE (data) - 2;
 }
@@ -1990,12 +1988,11 @@ gst_rtcp_packet_fb_set_fci_length (GstRTCPPacket * packet, guint16 wordlen)
   g_return_val_if_fail (packet != NULL, FALSE);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
       packet->type == GST_RTCP_TYPE_PSFB, FALSE);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), FALSE);
 
-  if (GST_BUFFER_SIZE (packet->buffer) < packet->offset + ((wordlen + 3) * 4))
+  if (packet->rtcp->size < packet->offset + ((wordlen + 3) * 4))
     return FALSE;
 
-  data = GST_BUFFER_DATA (packet->buffer) + packet->offset + 2;
+  data = packet->rtcp->data + packet->offset + 2;
   wordlen += 2;
   GST_WRITE_UINT16_BE (data, wordlen);
 
@@ -2020,9 +2017,8 @@ gst_rtcp_packet_fb_get_fci (GstRTCPPacket * packet)
   g_return_val_if_fail (packet != NULL, NULL);
   g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
       packet->type == GST_RTCP_TYPE_PSFB, NULL);
-  g_return_val_if_fail (GST_IS_BUFFER (packet->buffer), NULL);
 
-  data = GST_BUFFER_DATA (packet->buffer) + packet->offset;
+  data = packet->rtcp->data + packet->offset;
 
   if (GST_READ_UINT16_BE (data + 2) <= 2)
     return NULL;
index 6f57fad..a9a547d 100644 (file)
@@ -156,8 +156,19 @@ typedef enum
  */
 #define GST_RTCP_VALID_VALUE ((GST_RTCP_VERSION << 14) | GST_RTCP_TYPE_SR)
 
+typedef struct _GstRTCPBuffer GstRTCPBuffer;
 typedef struct _GstRTCPPacket GstRTCPPacket;
 
+struct _GstRTCPBuffer
+{
+  GstBuffer   *buffer;
+
+  GstMapFlags  flags;
+  guint8      *data;
+  gsize        size;
+  gsize        maxsize;
+};
+
 /**
  * GstRTCPPacket:
  * @buffer: pointer to RTCP buffer
@@ -168,8 +179,8 @@ typedef struct _GstRTCPPacket GstRTCPPacket;
  */
 struct _GstRTCPPacket
 { 
-  GstBuffer   *buffer;
-  guint        offset;
+  GstRTCPBuffer *rtcp;
+  guint         offset;
   
   /*< private >*/
   gboolean     padding;      /* padding field of current packet */
@@ -190,14 +201,16 @@ gboolean        gst_rtcp_buffer_validate_data     (guint8 *data, guint len);
 gboolean        gst_rtcp_buffer_validate          (GstBuffer *buffer);
 
 GstBuffer*      gst_rtcp_buffer_new               (guint mtu);
-void            gst_rtcp_buffer_end               (GstBuffer *buffer);
+
+gboolean        gst_rtcp_buffer_map               (GstBuffer *buffer, GstMapFlags flags, GstRTCPBuffer *rtcp);
+gboolean        gst_rtcp_buffer_unmap             (GstRTCPBuffer *rtcp);
 
 /* adding/retrieving packets */
-guint           gst_rtcp_buffer_get_packet_count  (GstBuffer *buffer);
-gboolean        gst_rtcp_buffer_get_first_packet  (GstBuffer *buffer, GstRTCPPacket *packet);
+guint           gst_rtcp_buffer_get_packet_count  (GstRTCPBuffer *rtcp);
+gboolean        gst_rtcp_buffer_get_first_packet  (GstRTCPBuffer *rtcp, GstRTCPPacket *packet);
 gboolean        gst_rtcp_packet_move_to_next      (GstRTCPPacket *packet);
 
-gboolean        gst_rtcp_buffer_add_packet        (GstBuffer *buffer, GstRTCPType type,
+gboolean        gst_rtcp_buffer_add_packet        (GstRTCPBuffer *rtcp, GstRTCPType type,
                                                   GstRTCPPacket *packet);
 gboolean        gst_rtcp_packet_remove            (GstRTCPPacket *packet);
 
index 141b072..7e5de64 100644 (file)
@@ -101,6 +101,7 @@ gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len,
 {
   guint len;
   guint8 *data;
+  GstMemory *mem;
 
   g_return_if_fail (csrc_count <= 15);
   g_return_if_fail (GST_IS_BUFFER (buffer));
@@ -108,11 +109,9 @@ gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len,
   len = GST_RTP_HEADER_LEN + csrc_count * sizeof (guint32)
       + payload_len + pad_len;
 
-  data = g_malloc (len);
-  GST_BUFFER_MALLOCDATA (buffer) = data;
-  GST_BUFFER_DATA (buffer) = data;
-  GST_BUFFER_SIZE (buffer) = len;
+  mem = gst_memory_new_alloc (len, 0);
 
+  data = gst_memory_map (mem, NULL, NULL, GST_MAP_WRITE);
   /* fill in defaults */
   GST_RTP_HEADER_VERSION (data) = GST_RTP_VERSION;
   GST_RTP_HEADER_PADDING (data) = FALSE;
@@ -125,6 +124,9 @@ gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len,
   GST_RTP_HEADER_SEQ (data) = 0;
   GST_RTP_HEADER_TIMESTAMP (data) = 0;
   GST_RTP_HEADER_SSRC (data) = 0;
+  gst_memory_unmap (mem, data, len);
+
+  gst_buffer_take_memory (buffer, mem);
 }
 
 /**
@@ -139,7 +141,7 @@ gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len,
  * Returns: A newly allocated buffer with @data and of size @len.
  */
 GstBuffer *
-gst_rtp_buffer_new_take_data (gpointer data, guint len)
+gst_rtp_buffer_new_take_data (gpointer data, gsize len)
 {
   GstBuffer *result;
 
@@ -147,10 +149,8 @@ gst_rtp_buffer_new_take_data (gpointer data, guint len)
   g_return_val_if_fail (len > 0, NULL);
 
   result = gst_buffer_new ();
-
-  GST_BUFFER_MALLOCDATA (result) = data;
-  GST_BUFFER_DATA (result) = data;
-  GST_BUFFER_SIZE (result) = len;
+  gst_buffer_take_memory (result,
+      gst_memory_new_wrapped (0, data, g_free, len, 0, len));
 
   return result;
 }
@@ -167,7 +167,7 @@ gst_rtp_buffer_new_take_data (gpointer data, guint len)
  * Returns: A newly allocated buffer with a copy of @data and of size @len.
  */
 GstBuffer *
-gst_rtp_buffer_new_copy_data (gpointer data, guint len)
+gst_rtp_buffer_new_copy_data (gpointer data, gsize len)
 {
   return gst_rtp_buffer_new_take_data (g_memdup (data, len), len);
 }
@@ -201,7 +201,7 @@ gst_rtp_buffer_new_allocate (guint payload_len, guint8 pad_len,
 
 /**
  * gst_rtp_buffer_new_allocate_len:
- * @packet_len: the total length of the packet
+ * @rtp_len: the total length of the packet
  * @pad_len: the amount of padding
  * @csrc_count: the number of CSRC entries
  *
@@ -391,7 +391,7 @@ dump_packet:
  * Returns: TRUE if the data points to a valid RTP packet.
  */
 gboolean
-gst_rtp_buffer_validate_data (guint8 * data, guint len)
+gst_rtp_buffer_validate_data (guint8 * data, gsize len)
 {
   return validate_data (data, len, NULL, 0);
 }
@@ -410,133 +410,80 @@ gst_rtp_buffer_validate_data (guint8 * data, guint len)
 gboolean
 gst_rtp_buffer_validate (GstBuffer * buffer)
 {
+  gboolean res;
   guint8 *data;
-  guint len;
+  gsize len;
 
   g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
 
-  data = GST_BUFFER_DATA (buffer);
-  len = GST_BUFFER_SIZE (buffer);
+  data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READ);
+  res = validate_data (data, len, NULL, 0);
+  gst_buffer_unmap (buffer, data, len);
 
-  return validate_data (data, len, NULL, 0);
+  return res;
 }
 
-/**
- * gst_rtp_buffer_list_validate:
- * @list: the buffer list to validate
- *
- * Check if all RTP packets in the @list are valid using validate_data().
- * Use this function to validate an list before using the other functions in
- * this module.
- *
- * Returns: TRUE if @list consists only of valid RTP packets.
- *
- * Since: 0.10.24
- */
 gboolean
-gst_rtp_buffer_list_validate (GstBufferList * list)
+gst_rtp_buffer_map (GstBuffer * buffer, GstMapFlags flags, GstRTPBuffer * rtp)
 {
-  guint16 prev_seqnum = 0;
-  GstBufferListIterator *it;
-  guint i = 0;
-
-  g_return_val_if_fail (GST_IS_BUFFER_LIST (list), FALSE);
-
-  it = gst_buffer_list_iterate (list);
-  g_return_val_if_fail (it != NULL, FALSE);
-
-  /* iterate through all the RTP packets in the list */
-  while (gst_buffer_list_iterator_next_group (it)) {
-    GstBuffer *rtpbuf;
-    GstBuffer *paybuf;
-    guint8 *packet_header;
-    guint8 *packet_payload;
-    guint payload_size;
-    guint packet_size;
-    guint j, n_buffers;
-
-    /* each group should consists of at least 1 buffer: The first buffer always
-     * contains the complete RTP header. Next buffers contain the payload */
-    n_buffers = gst_buffer_list_iterator_n_buffers (it);
-    if (n_buffers < 1)
-      goto invalid_list;
-
-    /* get the RTP header (and if n_buffers == 1 also the payload) */
-    rtpbuf = gst_buffer_list_iterator_next (it);
-    packet_header = GST_BUFFER_DATA (rtpbuf);
-    if (packet_header == NULL)
-      goto invalid_list;
-
-    /* check the sequence number */
-    if (G_UNLIKELY (i == 0)) {
-      prev_seqnum = g_ntohs (GST_RTP_HEADER_SEQ (packet_header));
-      i++;
-    } else {
-      if (++prev_seqnum != g_ntohs (GST_RTP_HEADER_SEQ (packet_header)))
-        goto invalid_list;
-    }
+  guint8 *data;
+  gsize size, maxsize;
 
-    packet_size = GST_BUFFER_SIZE (rtpbuf);
-    packet_payload = NULL;
-    payload_size = 0;
+  g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
+  g_return_val_if_fail (rtp != NULL, FALSE);
+  g_return_val_if_fail (rtp->buffer == NULL, FALSE);
 
-    /* get the payload buffers */
-    for (j = 1; j < n_buffers; j++) {
-      /* get the payload */
-      paybuf = gst_buffer_list_iterator_next (it);
+  data = gst_buffer_map (buffer, &size, &maxsize, flags);
+  if (data == NULL)
+    return FALSE;
 
-      if ((packet_payload = GST_BUFFER_DATA (paybuf)) == NULL)
-        goto invalid_list;
+  rtp->buffer = buffer;
+  rtp->flags = flags;
+  rtp->data = data;
+  rtp->size = size;
+  rtp->maxsize = maxsize;
 
-      if ((payload_size = GST_BUFFER_SIZE (paybuf)) == 0)
-        goto invalid_list;
+  return TRUE;
+}
 
-      /* the size of the RTP packet within the current group */
-      packet_size += payload_size;
-    }
+gboolean
+gst_rtp_buffer_unmap (GstRTPBuffer * rtp)
+{
+  g_return_val_if_fail (rtp != NULL, FALSE);
+  g_return_val_if_fail (rtp->buffer != NULL, FALSE);
 
-    /* validate packet */
-    if (!validate_data (packet_header, packet_size, packet_payload,
-            payload_size)) {
-      goto invalid_list;
-    }
-  }
+  gst_buffer_unmap (rtp->buffer, rtp->data, rtp->size);
 
-  gst_buffer_list_iterator_free (it);
+  rtp->buffer = NULL;
 
   return TRUE;
-
-  /* ERRORS */
-invalid_list:
-  {
-    gst_buffer_list_iterator_free (it);
-    return FALSE;
-  }
 }
 
+
 /**
  * gst_rtp_buffer_set_packet_len:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @len: the new packet length
  *
- * Set the total @buffer size to @len. The data in the buffer will be made
- * larger if needed. Any padding will be removed from the packet. 
+ * Set the total @rtp size to @len. The data in the buffer will be made
+ * larger if needed. Any padding will be removed from the packet.
  */
 void
-gst_rtp_buffer_set_packet_len (GstBuffer * buffer, guint len)
+gst_rtp_buffer_set_packet_len (GstRTPBuffer * rtp, guint len)
 {
   guint oldlen;
   guint8 *data;
 
-  oldlen = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  oldlen = rtp->size;
+  data = rtp->data;
 
-  if (oldlen < len) {
-    data = g_realloc (GST_BUFFER_MALLOCDATA (buffer), len);
-    GST_BUFFER_MALLOCDATA (buffer) = data;
-    GST_BUFFER_DATA (buffer) = data;
+  if (rtp->maxsize <= len) {
+    /* FIXME, realloc bigger space */
+    g_warning ("not implemented");
   }
-  GST_BUFFER_SIZE (buffer) = len;
+
+  gst_buffer_set_size (rtp->buffer, len);
+  rtp->size = len;
 
   /* remove any padding */
   GST_RTP_HEADER_PADDING (data) = FALSE;
@@ -544,21 +491,21 @@ gst_rtp_buffer_set_packet_len (GstBuffer * buffer, guint len)
 
 /**
  * gst_rtp_buffer_get_packet_len:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Return the total length of the packet in @buffer.
  *
  * Returns: The total length of the packet in @buffer.
  */
 guint
-gst_rtp_buffer_get_packet_len (GstBuffer * buffer)
+gst_rtp_buffer_get_packet_len (GstRTPBuffer * rtp)
 {
-  return GST_BUFFER_SIZE (buffer);
+  return gst_buffer_get_size (rtp->buffer);
 }
 
 /**
  * gst_rtp_buffer_get_header_len:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Return the total length of the header in @buffer. This include the length of
  * the fixed header, the CSRC list and the extension header.
@@ -566,12 +513,12 @@ gst_rtp_buffer_get_packet_len (GstBuffer * buffer)
  * Returns: The total length of the header in @buffer.
  */
 guint
-gst_rtp_buffer_get_header_len (GstBuffer * buffer)
+gst_rtp_buffer_get_header_len (GstRTPBuffer * rtp)
 {
   guint len;
   guint8 *data;
 
-  data = GST_BUFFER_DATA (buffer);
+  data = rtp->data;
 
   len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data);
   if (GST_RTP_HEADER_EXTENSION (data))
@@ -582,45 +529,45 @@ gst_rtp_buffer_get_header_len (GstBuffer * buffer)
 
 /**
  * gst_rtp_buffer_get_version:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get the version number of the RTP packet in @buffer.
  *
  * Returns: The version of @buffer.
  */
 guint8
-gst_rtp_buffer_get_version (GstBuffer * buffer)
+gst_rtp_buffer_get_version (GstRTPBuffer * rtp)
 {
-  return GST_RTP_HEADER_VERSION (GST_BUFFER_DATA (buffer));
+  return GST_RTP_HEADER_VERSION (rtp->data);
 }
 
 /**
  * gst_rtp_buffer_set_version:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @version: the new version
  *
  * Set the version of the RTP packet in @buffer to @version.
  */
 void
-gst_rtp_buffer_set_version (GstBuffer * buffer, guint8 version)
+gst_rtp_buffer_set_version (GstRTPBuffer * rtp, guint8 version)
 {
   g_return_if_fail (version < 0x04);
 
-  GST_RTP_HEADER_VERSION (GST_BUFFER_DATA (buffer)) = version;
+  GST_RTP_HEADER_VERSION (rtp->data) = version;
 }
 
 /**
  * gst_rtp_buffer_get_padding:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Check if the padding bit is set on the RTP packet in @buffer.
  *
  * Returns: TRUE if @buffer has the padding bit set.
  */
 gboolean
-gst_rtp_buffer_get_padding (GstBuffer * buffer)
+gst_rtp_buffer_get_padding (GstRTPBuffer * rtp)
 {
-  return GST_RTP_HEADER_PADDING (GST_BUFFER_DATA (buffer));
+  return GST_RTP_HEADER_PADDING (rtp->data);
 }
 
 /**
@@ -631,14 +578,14 @@ gst_rtp_buffer_get_padding (GstBuffer * buffer)
  * Set the padding bit on the RTP packet in @buffer to @padding.
  */
 void
-gst_rtp_buffer_set_padding (GstBuffer * buffer, gboolean padding)
+gst_rtp_buffer_set_padding (GstRTPBuffer * rtp, gboolean padding)
 {
-  GST_RTP_HEADER_PADDING (GST_BUFFER_DATA (buffer)) = padding;
+  GST_RTP_HEADER_PADDING (rtp->data) = padding;
 }
 
 /**
  * gst_rtp_buffer_pad_to:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @len: the new amount of padding
  *
  * Set the amount of padding in the RTP packet in @buffer to
@@ -647,11 +594,11 @@ gst_rtp_buffer_set_padding (GstBuffer * buffer, gboolean padding)
  * NOTE: This function does not work correctly.
  */
 void
-gst_rtp_buffer_pad_to (GstBuffer * buffer, guint len)
+gst_rtp_buffer_pad_to (GstRTPBuffer * rtp, guint len)
 {
   guint8 *data;
 
-  data = GST_BUFFER_DATA (buffer);
+  data = rtp->data;
 
   if (len > 0)
     GST_RTP_HEADER_PADDING (data) = TRUE;
@@ -663,34 +610,34 @@ gst_rtp_buffer_pad_to (GstBuffer * buffer, guint len)
 
 /**
  * gst_rtp_buffer_get_extension:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Check if the extension bit is set on the RTP packet in @buffer.
  * 
  * Returns: TRUE if @buffer has the extension bit set.
  */
 gboolean
-gst_rtp_buffer_get_extension (GstBuffer * buffer)
+gst_rtp_buffer_get_extension (GstRTPBuffer * rtp)
 {
-  return GST_RTP_HEADER_EXTENSION (GST_BUFFER_DATA (buffer));
+  return GST_RTP_HEADER_EXTENSION (rtp->data);
 }
 
 /**
  * gst_rtp_buffer_set_extension:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @extension: the new extension
  *
  * Set the extension bit on the RTP packet in @buffer to @extension.
  */
 void
-gst_rtp_buffer_set_extension (GstBuffer * buffer, gboolean extension)
+gst_rtp_buffer_set_extension (GstRTPBuffer * rtp, gboolean extension)
 {
-  GST_RTP_HEADER_EXTENSION (GST_BUFFER_DATA (buffer)) = extension;
+  GST_RTP_HEADER_EXTENSION (rtp->data) = extension;
 }
 
 /**
  * gst_rtp_buffer_get_extension_data:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @bits: location for result bits
  * @data: location for data
  * @wordlen: location for length of @data in 32 bits words
@@ -707,13 +654,13 @@ gst_rtp_buffer_set_extension (GstBuffer * buffer, gboolean extension)
  * Since: 0.10.15
  */
 gboolean
-gst_rtp_buffer_get_extension_data (GstBuffer * buffer, guint16 * bits,
+gst_rtp_buffer_get_extension_data (GstRTPBuffer * rtp, guint16 * bits,
     gpointer * data, guint * wordlen)
 {
   guint len;
   guint8 *pdata;
 
-  pdata = GST_BUFFER_DATA (buffer);
+  pdata = rtp->data;
 
   if (!GST_RTP_HEADER_EXTENSION (pdata))
     return FALSE;
@@ -734,7 +681,7 @@ gst_rtp_buffer_get_extension_data (GstBuffer * buffer, guint16 * bits,
 
 /**
  * gst_rtp_buffer_set_extension_data:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @bits: the bits specific for the extension
  * @length: the length that counts the number of 32-bit words in
  * the extension, excluding the extension header ( therefore zero is a valid length)
@@ -748,23 +695,23 @@ gst_rtp_buffer_get_extension_data (GstBuffer * buffer, guint16 * bits,
  * Since: 0.10.18
  */
 gboolean
-gst_rtp_buffer_set_extension_data (GstBuffer * buffer, guint16 bits,
+gst_rtp_buffer_set_extension_data (GstRTPBuffer * rtp, guint16 bits,
     guint16 length)
 {
   guint32 min_size = 0;
   guint8 *data;
 
-  data = GST_BUFFER_DATA (buffer);
+  data = rtp->data;
 
   /* check if the buffer is big enough to hold the extension */
   min_size =
       GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data) + 4 +
       length * sizeof (guint32);
-  if (G_UNLIKELY (min_size > GST_BUFFER_SIZE (buffer)))
+  if (G_UNLIKELY (min_size > rtp->size))
     goto too_small;
 
   /* now we can set the extension bit */
-  gst_rtp_buffer_set_extension (buffer, TRUE);
+  GST_RTP_HEADER_EXTENSION (rtp->data) = TRUE;
 
   data += GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data);
   GST_WRITE_UINT16_BE (data, bits);
@@ -776,100 +723,56 @@ gst_rtp_buffer_set_extension_data (GstBuffer * buffer, guint16 bits,
 too_small:
   {
     g_warning
-        ("rtp buffer too small: need more than %d bytes but only have %d bytes",
-        min_size, GST_BUFFER_SIZE (buffer));
+        ("rtp buffer too small: need more than %d bytes but only have %"
+        G_GSIZE_FORMAT " bytes", min_size, rtp->size);
     return FALSE;
   }
 }
 
 /**
  * gst_rtp_buffer_get_ssrc:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get the SSRC of the RTP packet in @buffer.
  * 
  * Returns: the SSRC of @buffer in host order.
  */
 guint32
-gst_rtp_buffer_get_ssrc (GstBuffer * buffer)
-{
-  return g_ntohl (GST_RTP_HEADER_SSRC (GST_BUFFER_DATA (buffer)));
-}
-
-/**
- * gst_rtp_buffer_list_get_ssrc:
- * @list: the buffer list
- *
- * Get the SSRC of the first RTP packet in @list.
- * All RTP packets within @list have the same SSRC.
- *
- * Returns: the SSRC of @list in host order.
- *
- * Since: 0.10.24
- */
-guint32
-gst_rtp_buffer_list_get_ssrc (GstBufferList * list)
+gst_rtp_buffer_get_ssrc (GstRTPBuffer * rtp)
 {
-  GstBuffer *buffer;
-
-  buffer = gst_buffer_list_get (list, 0, 0);
-  g_return_val_if_fail (buffer != NULL, 0);
-
-  return g_ntohl (GST_RTP_HEADER_SSRC (GST_BUFFER_DATA (buffer)));
+  return g_ntohl (GST_RTP_HEADER_SSRC (rtp->data));
 }
 
 /**
  * gst_rtp_buffer_set_ssrc:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @ssrc: the new SSRC
  *
  * Set the SSRC on the RTP packet in @buffer to @ssrc.
  */
 void
-gst_rtp_buffer_set_ssrc (GstBuffer * buffer, guint32 ssrc)
-{
-  GST_RTP_HEADER_SSRC (GST_BUFFER_DATA (buffer)) = g_htonl (ssrc);
-}
-
-static GstBufferListItem
-set_ssrc_header (GstBuffer ** buffer, guint group, guint idx, guint32 * ssrc)
-{
-  GST_RTP_HEADER_SSRC (GST_BUFFER_DATA (*buffer)) = g_htonl (*ssrc);
-  return GST_BUFFER_LIST_SKIP_GROUP;
-}
-
-/**
- * gst_rtp_buffer_list_set_ssrc:
- * @list: the buffer list
- * @ssrc: the new SSRC
- *
- * Set the SSRC on each RTP packet in @list to @ssrc.
- *
- * Since: 0.10.24
- */
-void
-gst_rtp_buffer_list_set_ssrc (GstBufferList * list, guint32 ssrc)
+gst_rtp_buffer_set_ssrc (GstRTPBuffer * rtp, guint32 ssrc)
 {
-  gst_buffer_list_foreach (list, (GstBufferListFunc) set_ssrc_header, &ssrc);
+  GST_RTP_HEADER_SSRC (rtp->data) = g_htonl (ssrc);
 }
 
 /**
  * gst_rtp_buffer_get_csrc_count:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get the CSRC count of the RTP packet in @buffer.
  * 
  * Returns: the CSRC count of @buffer.
  */
 guint8
-gst_rtp_buffer_get_csrc_count (GstBuffer * buffer)
+gst_rtp_buffer_get_csrc_count (GstRTPBuffer * rtp)
 {
-  return GST_RTP_HEADER_CSRC_COUNT (GST_BUFFER_DATA (buffer));
+  return GST_RTP_HEADER_CSRC_COUNT (rtp->data);
 }
 
 /**
  * gst_rtp_buffer_get_csrc:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @idx: the index of the CSRC to get
  *
  * Get the CSRC at index @idx in @buffer.
@@ -877,11 +780,11 @@ gst_rtp_buffer_get_csrc_count (GstBuffer * buffer)
  * Returns: the CSRC at index @idx in host order.
  */
 guint32
-gst_rtp_buffer_get_csrc (GstBuffer * buffer, guint8 idx)
+gst_rtp_buffer_get_csrc (GstRTPBuffer * rtp, guint8 idx)
 {
   guint8 *data;
 
-  data = GST_BUFFER_DATA (buffer);
+  data = rtp->data;
 
   g_return_val_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data), 0);
 
@@ -890,18 +793,18 @@ gst_rtp_buffer_get_csrc (GstBuffer * buffer, guint8 idx)
 
 /**
  * gst_rtp_buffer_set_csrc:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @idx: the CSRC index to set
  * @csrc: the CSRC in host order to set at @idx
  *
  * Modify the CSRC at index @idx in @buffer to @csrc.
  */
 void
-gst_rtp_buffer_set_csrc (GstBuffer * buffer, guint8 idx, guint32 csrc)
+gst_rtp_buffer_set_csrc (GstRTPBuffer * rtp, guint8 idx, guint32 csrc)
 {
   guint8 *data;
 
-  data = GST_BUFFER_DATA (buffer);
+  data = rtp->data;
 
   g_return_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data));
 
@@ -910,260 +813,118 @@ gst_rtp_buffer_set_csrc (GstBuffer * buffer, guint8 idx, guint32 csrc)
 
 /**
  * gst_rtp_buffer_get_marker:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Check if the marker bit is set on the RTP packet in @buffer.
  *
  * Returns: TRUE if @buffer has the marker bit set.
  */
 gboolean
-gst_rtp_buffer_get_marker (GstBuffer * buffer)
+gst_rtp_buffer_get_marker (GstRTPBuffer * rtp)
 {
-  return GST_RTP_HEADER_MARKER (GST_BUFFER_DATA (buffer));
+  return GST_RTP_HEADER_MARKER (rtp->data);
 }
 
 /**
  * gst_rtp_buffer_set_marker:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @marker: the new marker
  *
  * Set the marker bit on the RTP packet in @buffer to @marker.
  */
 void
-gst_rtp_buffer_set_marker (GstBuffer * buffer, gboolean marker)
+gst_rtp_buffer_set_marker (GstRTPBuffer * rtp, gboolean marker)
 {
-  GST_RTP_HEADER_MARKER (GST_BUFFER_DATA (buffer)) = marker;
+  GST_RTP_HEADER_MARKER (rtp->data) = marker;
 }
 
 /**
  * gst_rtp_buffer_get_payload_type:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get the payload type of the RTP packet in @buffer.
  *
  * Returns: The payload type.
  */
 guint8
-gst_rtp_buffer_get_payload_type (GstBuffer * buffer)
-{
-  return GST_RTP_HEADER_PAYLOAD_TYPE (GST_BUFFER_DATA (buffer));
-}
-
-/**
- * gst_rtp_buffer_list_get_payload_type:
- * @list: the buffer list
- *
- * Get the payload type of the first RTP packet in @list.
- * All packets in @list should have the same payload type.
- *
- * Returns: The payload type.
- *
- * Since: 0.10.24
- */
-guint8
-gst_rtp_buffer_list_get_payload_type (GstBufferList * list)
+gst_rtp_buffer_get_payload_type (GstRTPBuffer * rtp)
 {
-  GstBuffer *buffer;
-
-  buffer = gst_buffer_list_get (list, 0, 0);
-  g_return_val_if_fail (buffer != NULL, 0);
-
-  return GST_RTP_HEADER_PAYLOAD_TYPE (GST_BUFFER_DATA (buffer));
+  return GST_RTP_HEADER_PAYLOAD_TYPE (rtp->data);
 }
 
 /**
  * gst_rtp_buffer_set_payload_type:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @payload_type: the new type
  *
  * Set the payload type of the RTP packet in @buffer to @payload_type.
  */
 void
-gst_rtp_buffer_set_payload_type (GstBuffer * buffer, guint8 payload_type)
+gst_rtp_buffer_set_payload_type (GstRTPBuffer * rtp, guint8 payload_type)
 {
   g_return_if_fail (payload_type < 0x80);
 
-  GST_RTP_HEADER_PAYLOAD_TYPE (GST_BUFFER_DATA (buffer)) = payload_type;
-}
-
-static GstBufferListItem
-set_pt_header (GstBuffer ** buffer, guint group, guint idx, guint8 * pt)
-{
-  GST_RTP_HEADER_PAYLOAD_TYPE (GST_BUFFER_DATA (*buffer)) = *pt;
-  return GST_BUFFER_LIST_SKIP_GROUP;
-}
-
-/**
- * gst_rtp_buffer_list_set_payload_type:
- * @list: the buffer list
- * @payload_type: the new type
- *
- * Set the payload type of each RTP packet in @list to @payload_type.
- *
- * Since: 0.10.24
- */
-void
-gst_rtp_buffer_list_set_payload_type (GstBufferList * list, guint8 payload_type)
-{
-  g_return_if_fail (payload_type < 0x80);
-
-  gst_buffer_list_foreach (list, (GstBufferListFunc) set_pt_header,
-      &payload_type);
+  GST_RTP_HEADER_PAYLOAD_TYPE (rtp->data) = payload_type;
 }
 
 /**
  * gst_rtp_buffer_get_seq:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get the sequence number of the RTP packet in @buffer.
  *
  * Returns: The sequence number in host order.
  */
 guint16
-gst_rtp_buffer_get_seq (GstBuffer * buffer)
+gst_rtp_buffer_get_seq (GstRTPBuffer * rtp)
 {
-  return g_ntohs (GST_RTP_HEADER_SEQ (GST_BUFFER_DATA (buffer)));
+  return g_ntohs (GST_RTP_HEADER_SEQ (rtp->data));
 }
 
 /**
  * gst_rtp_buffer_set_seq:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @seq: the new sequence number
  *
  * Set the sequence number of the RTP packet in @buffer to @seq.
  */
 void
-gst_rtp_buffer_set_seq (GstBuffer * buffer, guint16 seq)
+gst_rtp_buffer_set_seq (GstRTPBuffer * rtp, guint16 seq)
 {
-  GST_RTP_HEADER_SEQ (GST_BUFFER_DATA (buffer)) = g_htons (seq);
-}
-
-static GstBufferListItem
-set_seq_header (GstBuffer ** buffer, guint group, guint idx, guint16 * seq)
-{
-  GST_RTP_HEADER_SEQ (GST_BUFFER_DATA (*buffer)) = g_htons (*seq);
-  (*seq)++;
-  return GST_BUFFER_LIST_SKIP_GROUP;
-}
-
-/**
- * gst_rtp_buffer_list_set_seq:
- * @list: the buffer list
- * @seq: the new sequence number
- *
- * Set the sequence number of each RTP packet in @list to @seq.
- *
- * Returns: The seq number of the last packet in the list + 1.
- *
- * Since: 0.10.24
- */
-guint16
-gst_rtp_buffer_list_set_seq (GstBufferList * list, guint16 seq)
-{
-  gst_buffer_list_foreach (list, (GstBufferListFunc) set_seq_header, &seq);
-  return seq;
+  GST_RTP_HEADER_SEQ (rtp->data) = g_htons (seq);
 }
 
 /**
- * gst_rtp_buffer_list_get_seq:
- * @list: the buffer list
- *
- * Get the sequence number of the first RTP packet in @list.
- * All packets within @list have the same sequence number.
- *
- * Returns: The seq number
- *
- * Since: 0.10.24
- */
-guint16
-gst_rtp_buffer_list_get_seq (GstBufferList * list)
-{
-  GstBuffer *buffer;
-
-  buffer = gst_buffer_list_get (list, 0, 0);
-  g_return_val_if_fail (buffer != NULL, 0);
-
-  return g_ntohl (GST_RTP_HEADER_SEQ (GST_BUFFER_DATA (buffer)));
-}
-
-
-/**
  * gst_rtp_buffer_get_timestamp:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get the timestamp of the RTP packet in @buffer.
  *
  * Returns: The timestamp in host order.
  */
 guint32
-gst_rtp_buffer_get_timestamp (GstBuffer * buffer)
-{
-  return g_ntohl (GST_RTP_HEADER_TIMESTAMP (GST_BUFFER_DATA (buffer)));
-}
-
-/**
- * gst_rtp_buffer_list_get_timestamp:
- * @list: the buffer list
- *
- * Get the timestamp of the first RTP packet in @list.
- * All packets within @list have the same timestamp.
- *
- * Returns: The timestamp in host order.
- *
- * Since: 0.10.24
- */
-guint32
-gst_rtp_buffer_list_get_timestamp (GstBufferList * list)
+gst_rtp_buffer_get_timestamp (GstRTPBuffer * rtp)
 {
-  GstBuffer *buffer;
-
-  buffer = gst_buffer_list_get (list, 0, 0);
-  g_return_val_if_fail (buffer != NULL, 0);
-
-  return g_ntohl (GST_RTP_HEADER_TIMESTAMP (GST_BUFFER_DATA (buffer)));
+  return g_ntohl (GST_RTP_HEADER_TIMESTAMP (rtp->data));
 }
 
 /**
  * gst_rtp_buffer_set_timestamp:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @timestamp: the new timestamp
  *
  * Set the timestamp of the RTP packet in @buffer to @timestamp.
  */
 void
-gst_rtp_buffer_set_timestamp (GstBuffer * buffer, guint32 timestamp)
-{
-  GST_RTP_HEADER_TIMESTAMP (GST_BUFFER_DATA (buffer)) = g_htonl (timestamp);
-}
-
-
-static GstBufferListItem
-set_timestamp_header (GstBuffer ** buffer, guint group, guint idx,
-    guint32 * timestamp)
+gst_rtp_buffer_set_timestamp (GstRTPBuffer * rtp, guint32 timestamp)
 {
-  GST_RTP_HEADER_TIMESTAMP (GST_BUFFER_DATA (*buffer)) = g_htonl (*timestamp);
-  return GST_BUFFER_LIST_SKIP_GROUP;
+  GST_RTP_HEADER_TIMESTAMP (rtp->data) = g_htonl (timestamp);
 }
 
-/**
- * gst_rtp_buffer_list_set_timestamp:
- * @list: the buffer list
- * @timestamp: the new timestamp
- *
- * Set the timestamp of each RTP packet in @list to @timestamp.
- *
- * Since: 0.10.24
- */
-void
-gst_rtp_buffer_list_set_timestamp (GstBufferList * list, guint32 timestamp)
-{
-  gst_buffer_list_foreach (list, (GstBufferListFunc) set_timestamp_header,
-      &timestamp);
-}
 
 /**
  * gst_rtp_buffer_get_payload_subbuffer:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @offset: the offset in the payload
  * @len: the length in the payload
  *
@@ -1176,25 +937,26 @@ gst_rtp_buffer_list_set_timestamp (GstBufferList * list, guint32 timestamp)
  * Since: 0.10.10
  */
 GstBuffer *
-gst_rtp_buffer_get_payload_subbuffer (GstBuffer * buffer, guint offset,
+gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer * rtp, guint offset,
     guint len)
 {
   guint poffset, plen;
 
-  plen = gst_rtp_buffer_get_payload_len (buffer);
+  plen = gst_rtp_buffer_get_payload_len (rtp);
   /* we can't go past the length */
   if (G_UNLIKELY (offset >= plen))
     goto wrong_offset;
 
   /* apply offset */
-  poffset = gst_rtp_buffer_get_header_len (buffer) + offset;
+  poffset = gst_rtp_buffer_get_header_len (rtp) + offset;
   plen -= offset;
 
   /* see if we need to shrink the buffer based on @len */
   if (len != -1 && len < plen)
     plen = len;
 
-  return gst_buffer_create_sub (buffer, poffset, plen);
+  return gst_buffer_copy_region (rtp->buffer, GST_BUFFER_COPY_ALL, poffset,
+      plen);
 
   /* ERRORS */
 wrong_offset:
@@ -1206,7 +968,7 @@ wrong_offset:
 
 /**
  * gst_rtp_buffer_get_payload_buffer:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Create a buffer of the payload of the RTP packet in @buffer. This function
  * will internally create a subbuffer of @buffer so that a memcpy can be
@@ -1215,29 +977,29 @@ wrong_offset:
  * Returns: A new buffer with the data of the payload.
  */
 GstBuffer *
-gst_rtp_buffer_get_payload_buffer (GstBuffer * buffer)
+gst_rtp_buffer_get_payload_buffer (GstRTPBuffer * rtp)
 {
-  return gst_rtp_buffer_get_payload_subbuffer (buffer, 0, -1);
+  return gst_rtp_buffer_get_payload_subbuffer (rtp, 0, -1);
 }
 
 /**
  * gst_rtp_buffer_get_payload_len:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get the length of the payload of the RTP packet in @buffer.
  *
  * Returns: The length of the payload in @buffer.
  */
 guint
-gst_rtp_buffer_get_payload_len (GstBuffer * buffer)
+gst_rtp_buffer_get_payload_len (GstRTPBuffer * rtp)
 {
   guint len, size;
   guint8 *data;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  size = rtp->size;
+  data = rtp->data;
 
-  len = size - gst_rtp_buffer_get_header_len (buffer);
+  len = size - gst_rtp_buffer_get_header_len (rtp);
 
   if (GST_RTP_HEADER_PADDING (data))
     len -= data[size - 1];
@@ -1246,46 +1008,8 @@ gst_rtp_buffer_get_payload_len (GstBuffer * buffer)
 }
 
 /**
- * gst_rtp_buffer_list_get_payload_len:
- * @list: the buffer list
- *
- * Get the length of the payload of the RTP packet in @list.
- *
- * Returns: The length of the payload in @list.
- *
- * Since: 0.10.24
- */
-guint
-gst_rtp_buffer_list_get_payload_len (GstBufferList * list)
-{
-  guint len;
-  GstBufferListIterator *it;
-
-  it = gst_buffer_list_iterate (list);
-  len = 0;
-
-  while (gst_buffer_list_iterator_next_group (it)) {
-    guint i;
-    GstBuffer *buf;
-
-    i = 0;
-    while ((buf = gst_buffer_list_iterator_next (it))) {
-      /* skip the RTP header */
-      if (!i++)
-        continue;
-      /* take the size of the current buffer */
-      len += GST_BUFFER_SIZE (buf);
-    }
-  }
-
-  gst_buffer_list_iterator_free (it);
-
-  return len;
-}
-
-/**
  * gst_rtp_buffer_get_payload:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  *
  * Get a pointer to the payload data in @buffer. This pointer is valid as long
  * as a reference to @buffer is held.
@@ -1293,9 +1017,9 @@ gst_rtp_buffer_list_get_payload_len (GstBufferList * list)
  * Returns: A pointer to the payload data in @buffer.
  */
 gpointer
-gst_rtp_buffer_get_payload (GstBuffer * buffer)
+gst_rtp_buffer_get_payload (GstRTPBuffer * rtp)
 {
-  return GST_BUFFER_DATA (buffer) + gst_rtp_buffer_get_header_len (buffer);
+  return rtp->data + gst_rtp_buffer_get_header_len (rtp);
 }
 
 /**
@@ -1395,7 +1119,7 @@ gst_rtp_buffer_ext_timestamp (guint64 * exttimestamp, guint32 timestamp)
 
 /**
  * gst_rtp_buffer_get_extension_onebyte_header:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @id: The ID of the header extension to be read (between 1 and 14).
  * @nth: Read the nth extension packet with the requested ID
  * @data: location for data
@@ -1410,7 +1134,7 @@ gst_rtp_buffer_ext_timestamp (guint64 * exttimestamp, guint32 timestamp)
  */
 
 gboolean
-gst_rtp_buffer_get_extension_onebyte_header (GstBuffer * buffer, guint8 id,
+gst_rtp_buffer_get_extension_onebyte_header (GstRTPBuffer * rtp, guint8 id,
     guint nth, gpointer * data, guint * size)
 {
   guint16 bits;
@@ -1421,7 +1145,7 @@ gst_rtp_buffer_get_extension_onebyte_header (GstBuffer * buffer, guint8 id,
 
   g_return_val_if_fail (id > 0 && id < 15, FALSE);
 
-  if (!gst_rtp_buffer_get_extension_data (buffer, &bits, (gpointer) & pdata,
+  if (!gst_rtp_buffer_get_extension_data (rtp, &bits, (gpointer) & pdata,
           &wordlen))
     return FALSE;
 
@@ -1474,7 +1198,7 @@ gst_rtp_buffer_get_extension_onebyte_header (GstBuffer * buffer, guint8 id,
 
 /**
  * gst_rtp_buffer_get_extension_twobytes_header:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @appbits: Application specific bits
  * @id: The ID of the header extension to be read (between 1 and 14).
  * @nth: Read the nth extension packet with the requested ID
@@ -1490,7 +1214,7 @@ gst_rtp_buffer_get_extension_onebyte_header (GstBuffer * buffer, guint8 id,
  */
 
 gboolean
-gst_rtp_buffer_get_extension_twobytes_header (GstBuffer * buffer,
+gst_rtp_buffer_get_extension_twobytes_header (GstRTPBuffer * rtp,
     guint8 * appbits, guint8 id, guint nth, gpointer * data, guint * size)
 {
   guint16 bits;
@@ -1500,7 +1224,7 @@ gst_rtp_buffer_get_extension_twobytes_header (GstBuffer * buffer,
   gulong offset = 0;
   guint count = 0;
 
-  if (!gst_rtp_buffer_get_extension_data (buffer, &bits, (gpointer) & pdata,
+  if (!gst_rtp_buffer_get_extension_data (rtp, &bits, (gpointer) & pdata,
           &wordlen))
     return FALSE;
 
@@ -1588,7 +1312,7 @@ get_onebyte_header_end_offset (guint8 * pdata, guint wordlen)
 
 /**
  * gst_rtp_buffer_add_extension_onebyte_header:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @id: The ID of the header extension (between 1 and 14).
  * @data: location for data
  * @size: the size of the data in bytes
@@ -1607,7 +1331,7 @@ get_onebyte_header_end_offset (guint8 * pdata, guint wordlen)
  */
 
 gboolean
-gst_rtp_buffer_add_extension_onebyte_header (GstBuffer * buffer, guint8 id,
+gst_rtp_buffer_add_extension_onebyte_header (GstRTPBuffer * rtp, guint8 id,
     gpointer data, guint size)
 {
   guint16 bits;
@@ -1617,9 +1341,9 @@ gst_rtp_buffer_add_extension_onebyte_header (GstBuffer * buffer, guint8 id,
 
   g_return_val_if_fail (id > 0 && id < 15, FALSE);
   g_return_val_if_fail (size >= 1 && size <= 16, FALSE);
-  g_return_val_if_fail (gst_buffer_is_writable (buffer), FALSE);
+  g_return_val_if_fail (gst_buffer_is_writable (rtp->buffer), FALSE);
 
-  has_bit = gst_rtp_buffer_get_extension_data (buffer, &bits,
+  has_bit = gst_rtp_buffer_get_extension_data (rtp, &bits,
       (gpointer) & pdata, &wordlen);
 
   if (has_bit) {
@@ -1635,10 +1359,10 @@ gst_rtp_buffer_add_extension_onebyte_header (GstBuffer * buffer, guint8 id,
       return FALSE;
 
     nextext = pdata + offset;
-    offset = nextext - GST_BUFFER_DATA (buffer);
+    offset = nextext - rtp->data;
 
     /* Don't add extra header if there isn't enough space */
-    if (GST_BUFFER_SIZE (buffer) < offset + size + 1)
+    if (rtp->size < offset + size + 1)
       return FALSE;
 
     nextext[0] = (id << 4) | (0x0F & (size - 1));
@@ -1652,13 +1376,13 @@ gst_rtp_buffer_add_extension_onebyte_header (GstBuffer * buffer, guint8 id,
       wordlen = extlen / 4;
     }
 
-    gst_rtp_buffer_set_extension_data (buffer, 0xBEDE, wordlen);
+    gst_rtp_buffer_set_extension_data (rtp, 0xBEDE, wordlen);
   } else {
     wordlen = (size + 1) / 4 + (((size + 1) % 4) ? 1 : 0);
 
-    gst_rtp_buffer_set_extension_data (buffer, 0xBEDE, wordlen);
+    gst_rtp_buffer_set_extension_data (rtp, 0xBEDE, wordlen);
 
-    gst_rtp_buffer_get_extension_data (buffer, &bits,
+    gst_rtp_buffer_get_extension_data (rtp, &bits,
         (gpointer) & pdata, &wordlen);
 
     pdata[0] = (id << 4) | (0x0F & (size - 1));
@@ -1708,7 +1432,7 @@ get_twobytes_header_end_offset (guint8 * pdata, guint wordlen)
 
 /**
  * gst_rtp_buffer_add_extension_twobytes_header:
- * @buffer: the buffer
+ * @rtp: the RTP packet
  * @appbits: Application specific bits
  * @id: The ID of the header extension
  * @data: location for data
@@ -1728,7 +1452,7 @@ get_twobytes_header_end_offset (guint8 * pdata, guint wordlen)
  */
 
 gboolean
-gst_rtp_buffer_add_extension_twobytes_header (GstBuffer * buffer,
+gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer * rtp,
     guint8 appbits, guint8 id, gpointer data, guint size)
 {
   guint16 bits;
@@ -1738,9 +1462,9 @@ gst_rtp_buffer_add_extension_twobytes_header (GstBuffer * buffer,
 
   g_return_val_if_fail ((appbits & 0xF0) == 0, FALSE);
   g_return_val_if_fail (size < 256, FALSE);
-  g_return_val_if_fail (gst_buffer_is_writable (buffer), FALSE);
+  g_return_val_if_fail (gst_buffer_is_writable (rtp->buffer), FALSE);
 
-  has_bit = gst_rtp_buffer_get_extension_data (buffer, &bits,
+  has_bit = gst_rtp_buffer_get_extension_data (rtp, &bits,
       (gpointer) & pdata, &wordlen);
 
   if (has_bit) {
@@ -1755,10 +1479,10 @@ gst_rtp_buffer_add_extension_twobytes_header (GstBuffer * buffer,
 
     nextext = pdata + offset;
 
-    offset = nextext - GST_BUFFER_DATA (buffer);
+    offset = nextext - rtp->data;
 
     /* Don't add extra header if there isn't enough space */
-    if (GST_BUFFER_SIZE (buffer) < offset + size + 2)
+    if (rtp->size < offset + size + 2)
       return FALSE;
 
     nextext[0] = id;
@@ -1773,15 +1497,15 @@ gst_rtp_buffer_add_extension_twobytes_header (GstBuffer * buffer,
       wordlen = extlen / 4;
     }
 
-    gst_rtp_buffer_set_extension_data (buffer, (0x100 << 4) | (appbits & 0x0F),
+    gst_rtp_buffer_set_extension_data (rtp, (0x100 << 4) | (appbits & 0x0F),
         wordlen);
   } else {
     wordlen = (size + 2) / 4 + (((size + 2) % 4) ? 1 : 0);
 
-    gst_rtp_buffer_set_extension_data (buffer, (0x100 << 4) | (appbits & 0x0F),
+    gst_rtp_buffer_set_extension_data (rtp, (0x100 << 4) | (appbits & 0x0F),
         wordlen);
 
-    gst_rtp_buffer_get_extension_data (buffer, &bits,
+    gst_rtp_buffer_get_extension_data (rtp, &bits,
         (gpointer) & pdata, &wordlen);
 
     pdata[0] = id;
@@ -1793,267 +1517,3 @@ gst_rtp_buffer_add_extension_twobytes_header (GstBuffer * buffer,
 
   return TRUE;
 }
-
-/**
- * gst_rtp_buffer_list_get_extension_onebyte_header:
- * @bufferlist: the bufferlist
- * @group_idx: The index of the group in the #GstBufferList
- * @id: The ID of the header extension to be read (between 1 and 14).
- * @nth: Read the nth extension packet with the requested ID
- * @data: location for data
- * @size: the size of the data in bytes
- *
- * Parses RFC 5285 style header extensions with a one byte header. It will
- * return the nth extension with the requested id.
- *
- * Returns: TRUE if @buffer had the requested header extension
- *
- * Since: 0.10.31
- */
-
-gboolean
-gst_rtp_buffer_list_get_extension_onebyte_header (GstBufferList * bufferlist,
-    guint group_idx, guint8 id, guint nth, gpointer * data, guint * size)
-{
-  GstBuffer *buffer;
-
-  buffer = gst_buffer_list_get (bufferlist, group_idx, 0);
-
-  if (!buffer)
-    return FALSE;
-
-  return gst_rtp_buffer_get_extension_onebyte_header (buffer, id, nth, data,
-      size);
-}
-
-
-/**
- * gst_rtp_buffer_list_get_extension_twobytes_header:
- * @bufferlist: the bufferlist
- * @group_idx: The index of the group in the #GstBufferList
- * @appbits: Application specific bits
- * @id: The ID of the header extension to be read (between 1 and 14).
- * @nth: Read the nth extension packet with the requested ID
- * @data: location for data
- * @size: the size of the data in bytes
- *
- * Parses RFC 5285 style header extensions with a two bytes header. It will
- * return the nth extension with the requested id.
- *
- * Returns: TRUE if @buffer had the requested header extension
- *
- * Since: 0.10.31
- */
-
-gboolean
-gst_rtp_buffer_list_get_extension_twobytes_header (GstBufferList * bufferlist,
-    guint group_idx, guint8 * appbits, guint8 id, guint nth,
-    gpointer * data, guint * size)
-{
-  GstBuffer *buffer;
-
-  buffer = gst_buffer_list_get (bufferlist, group_idx, 0);
-
-  if (!buffer)
-    return FALSE;
-
-  return gst_rtp_buffer_get_extension_twobytes_header (buffer, appbits, id,
-      nth, data, size);
-}
-
-/**
- * gst_rtp_buffer_list_add_extension_onebyte_header:
- * @it: a #GstBufferListIterator pointing right after the #GstBuffer where
- * the header extension should be added
- * @id: The ID of the header extension (between 1 and 14).
- * @data: location for data
- * @size: the size of the data in bytes
- *
- * Adds a RFC 5285 header extension with a one byte header to the end of the
- * RTP header. If there is already a RFC 5285 header extension with a one byte
- * header, the new extension will be appended.
- * It will not work if there is already a header extension that does not follow
- * the mecanism described in RFC 5285 or if there is a header extension with
- * a two bytes header as described in RFC 5285. In that case, use
- * gst_rtp_buffer_list_add_extension_twobytes_header()
- *
- * This function will not modify the data section of the RTP buffer, only
- * the header.
- *
- * Returns: %TRUE if header extension could be added
- *
- * Since: 0.10.31
- */
-
-gboolean
-gst_rtp_buffer_list_add_extension_onebyte_header (GstBufferListIterator * it,
-    guint8 id, gpointer data, guint size)
-{
-  GstBuffer *buffer;
-  guint16 bits;
-  guint8 *pdata;
-  guint wordlen;
-  gboolean retval;
-  guint endoffset = 0;
-
-  g_return_val_if_fail (gst_buffer_list_iterator_n_buffers (it) == 1, FALSE);
-  g_return_val_if_fail (id > 0 && id < 15, FALSE);
-  g_return_val_if_fail (size >= 1 && size <= 16, FALSE);
-
-  buffer = gst_buffer_list_iterator_steal (it);
-
-  if (GST_RTP_HEADER_EXTENSION (GST_BUFFER_DATA (buffer))) {
-    gst_rtp_buffer_get_extension_data (buffer, &bits, (gpointer) & pdata,
-        &wordlen);
-
-    if (bits != 0xBEDE)
-      return FALSE;
-
-    endoffset = get_onebyte_header_end_offset (pdata, wordlen);
-    if (endoffset == 0)
-      return FALSE;
-    endoffset += pdata - GST_BUFFER_DATA (buffer);
-  } else {
-    endoffset = GST_BUFFER_SIZE (buffer) + 4;
-  }
-
-  if (endoffset + size + 1 > GST_BUFFER_SIZE (buffer)) {
-    guint newsize;
-    GstBuffer *newbuffer;
-
-    newsize = endoffset + size + 1;
-    if (newsize % 4)
-      newsize += 4 - (newsize % 4);
-    newbuffer = gst_buffer_new_and_alloc (newsize);
-    memcpy (GST_BUFFER_DATA (newbuffer), GST_BUFFER_DATA (buffer),
-        GST_BUFFER_SIZE (buffer));
-    gst_buffer_copy_metadata (newbuffer, buffer, GST_BUFFER_COPY_ALL);
-    gst_buffer_unref (buffer);
-    buffer = newbuffer;
-  } else {
-    buffer = gst_buffer_make_writable (buffer);
-  }
-
-  retval = gst_rtp_buffer_add_extension_onebyte_header (buffer, id, data, size);
-
-  gst_buffer_list_iterator_take (it, buffer);
-
-  return retval;
-}
-
-/**
- * gst_rtp_buffer_list_add_extension_twobytes_header:
- * @it: a #GstBufferListIterator pointing right after the #GstBuffer where
- * the header extension should be added
- * @appbits: Application specific bits
- * @id: The ID of the header extension
- * @data: location for data
- * @size: the size of the data in bytes
- *
- * Adds a RFC 5285 header extension with a two bytes header to the end of the
- * RTP header. If there is already a RFC 5285 header extension with a two bytes
- * header, the new extension will be appended.
- * It will not work if there is already a header extension that does not follow
- * the mecanism described in RFC 5285 or if there is a header extension with
- * a one byte header as described in RFC 5285. In that case, use
- * gst_rtp_buffer_add_extension_onebyte_header()
- *
- * This function will not modify the data section of the RTP buffer, only
- * the header.
- *
- * Returns: %TRUE if header extension could be added
- *
- * Since: 0.10.31
- */
-
-gboolean
-gst_rtp_buffer_list_add_extension_twobytes_header (GstBufferListIterator * it,
-    guint8 appbits, guint8 id, gpointer data, guint size)
-{
-  GstBuffer *buffer;
-  guint16 bits;
-  guint8 *pdata;
-  guint wordlen;
-  gboolean retval;
-  guint endoffset;
-
-  g_return_val_if_fail ((appbits & 0xF0) == 0, FALSE);
-  g_return_val_if_fail (size < 256, FALSE);
-  g_return_val_if_fail (gst_buffer_list_iterator_n_buffers (it) == 1, FALSE);
-
-  buffer = gst_buffer_list_iterator_steal (it);
-
-  if (GST_RTP_HEADER_EXTENSION (GST_BUFFER_DATA (buffer))) {
-    gst_rtp_buffer_get_extension_data (buffer, &bits, (gpointer) & pdata,
-        &wordlen);
-
-    if (bits != ((0x100 << 4) | (appbits & 0x0f)))
-      return FALSE;
-
-    endoffset = get_twobytes_header_end_offset (pdata, wordlen);
-    if (endoffset == 0)
-      return FALSE;
-    endoffset += pdata - GST_BUFFER_DATA (buffer);
-  } else {
-    endoffset = GST_BUFFER_SIZE (buffer) + 4;
-  }
-
-  if (endoffset + size + 2 > GST_BUFFER_SIZE (buffer)) {
-    guint newsize;
-    GstBuffer *newbuffer;
-
-    newsize = endoffset + size + 2;
-    if (newsize % 4)
-      newsize += 4 - newsize % 4;
-    newbuffer = gst_buffer_new_and_alloc (newsize);
-    memcpy (GST_BUFFER_DATA (newbuffer), GST_BUFFER_DATA (buffer),
-        GST_BUFFER_SIZE (buffer));
-    gst_buffer_copy_metadata (newbuffer, buffer, GST_BUFFER_COPY_ALL);
-    gst_buffer_unref (buffer);
-    buffer = newbuffer;
-  } else {
-    buffer = gst_buffer_make_writable (buffer);
-  }
-
-  retval = gst_rtp_buffer_add_extension_twobytes_header (buffer, appbits, id,
-      data, size);
-
-  gst_buffer_list_iterator_take (it, buffer);
-
-  return retval;
-}
-
-/**
- * gst_rtp_buffer_list_from_buffer:
- * @buffer: a #GstBuffer containing a RTP packet
- *
- * Splits a #GstBuffer into a #GstBufferList containing separate
- * buffers for the header and data sections.
- *
- * Returns: a #GstBufferList
- */
-
-GstBufferList *
-gst_rtp_buffer_list_from_buffer (GstBuffer * buffer)
-{
-  GstBufferList *bufferlist;
-  GstBuffer *sub;
-  GstBufferListIterator *it;
-  guint8 *payload;
-
-  bufferlist = gst_buffer_list_new ();
-
-  it = gst_buffer_list_iterate (bufferlist);
-  gst_buffer_list_iterator_add_group (it);
-
-  payload = gst_rtp_buffer_get_payload (buffer);
-  sub = gst_buffer_create_sub (buffer, 0, payload - GST_BUFFER_DATA (buffer));
-  gst_buffer_list_iterator_add (it, sub);
-
-  sub = gst_rtp_buffer_get_payload_buffer (buffer);
-  gst_buffer_list_iterator_add (it, sub);
-
-  gst_buffer_list_iterator_free (it);
-
-  return bufferlist;
-}
index c82fd71..b40e714 100644 (file)
@@ -36,129 +36,115 @@ G_BEGIN_DECLS
  */
 #define GST_RTP_VERSION 2
 
+
+typedef struct _GstRTPBuffer GstRTPBuffer;
+
+/**
+ * GstRTPBuffer:
+ * @buffer: pointer to RTP buffer
+ *
+ * Data structure that points to an RTP packet.
+ * The size of the structure is made public to allow stack allocations.
+ */
+struct _GstRTPBuffer
+{
+  GstBuffer   *buffer;
+  GstMapFlags  flags;
+  guint8      *data;
+  gsize        size;
+  gsize        maxsize;
+};
+
 /* creating buffers */
-void            gst_rtp_buffer_allocate_data         (GstBuffer *buffer, guint payload_len, 
+void            gst_rtp_buffer_allocate_data         (GstBuffer *buffer, guint payload_len,
                                                       guint8 pad_len, guint8 csrc_count);
 
-GstBuffer*      gst_rtp_buffer_new_take_data         (gpointer data, guint len);
-GstBuffer*      gst_rtp_buffer_new_copy_data         (gpointer data, guint len);
+GstBuffer*      gst_rtp_buffer_new_take_data         (gpointer data, gsize len);
+GstBuffer*      gst_rtp_buffer_new_copy_data         (gpointer data, gsize len);
 GstBuffer*      gst_rtp_buffer_new_allocate          (guint payload_len, guint8 pad_len, guint8 csrc_count);
 GstBuffer*      gst_rtp_buffer_new_allocate_len      (guint packet_len, guint8 pad_len, guint8 csrc_count);
 
-GstBufferList*  gst_rtp_buffer_list_from_buffer      (GstBuffer * buffer);
-
-
 guint           gst_rtp_buffer_calc_header_len       (guint8 csrc_count);
 guint           gst_rtp_buffer_calc_packet_len       (guint payload_len, guint8 pad_len, guint8 csrc_count);
 guint           gst_rtp_buffer_calc_payload_len      (guint packet_len, guint8 pad_len, guint8 csrc_count);
 
-gboolean        gst_rtp_buffer_validate_data         (guint8 *data, guint len);
+gboolean        gst_rtp_buffer_validate_data         (guint8 *data, gsize len);
 gboolean        gst_rtp_buffer_validate              (GstBuffer *buffer);
-gboolean        gst_rtp_buffer_list_validate         (GstBufferList *list);
 
-void            gst_rtp_buffer_set_packet_len        (GstBuffer *buffer, guint len);
-guint           gst_rtp_buffer_get_packet_len        (GstBuffer *buffer);
 
-guint           gst_rtp_buffer_get_header_len        (GstBuffer *buffer);
+gboolean        gst_rtp_buffer_map                   (GstBuffer *buffer, GstMapFlags flags, GstRTPBuffer *rtp);
+gboolean        gst_rtp_buffer_unmap                 (GstRTPBuffer *rtp);
+
+void            gst_rtp_buffer_set_packet_len        (GstRTPBuffer *rtp, guint len);
+guint           gst_rtp_buffer_get_packet_len        (GstRTPBuffer *rtp);
+
+guint           gst_rtp_buffer_get_header_len        (GstRTPBuffer *rtp);
 
-guint8          gst_rtp_buffer_get_version           (GstBuffer *buffer);
-void            gst_rtp_buffer_set_version           (GstBuffer *buffer, guint8 version);
+guint8          gst_rtp_buffer_get_version           (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_version           (GstRTPBuffer *rtp, guint8 version);
 
-gboolean        gst_rtp_buffer_get_padding           (GstBuffer *buffer);
-void            gst_rtp_buffer_set_padding           (GstBuffer *buffer, gboolean padding);
-void            gst_rtp_buffer_pad_to                (GstBuffer *buffer, guint len);
+gboolean        gst_rtp_buffer_get_padding           (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_padding           (GstRTPBuffer *rtp, gboolean padding);
+void            gst_rtp_buffer_pad_to                (GstRTPBuffer *rtp, guint len);
 
-gboolean        gst_rtp_buffer_get_extension         (GstBuffer *buffer);
-void            gst_rtp_buffer_set_extension         (GstBuffer *buffer, gboolean extension);
-gboolean        gst_rtp_buffer_get_extension_data    (GstBuffer *buffer, guint16 *bits,
+gboolean        gst_rtp_buffer_get_extension         (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_extension         (GstRTPBuffer *rtp, gboolean extension);
+gboolean        gst_rtp_buffer_get_extension_data    (GstRTPBuffer *rtp, guint16 *bits,
                                                       gpointer *data, guint *wordlen);
-gboolean        gst_rtp_buffer_set_extension_data    (GstBuffer *buffer, guint16 bits, guint16 length);
+gboolean        gst_rtp_buffer_set_extension_data    (GstRTPBuffer *rtp, guint16 bits, guint16 length);
 
-guint32         gst_rtp_buffer_get_ssrc              (GstBuffer *buffer);
-guint32         gst_rtp_buffer_list_get_ssrc         (GstBufferList *list);
-void            gst_rtp_buffer_set_ssrc              (GstBuffer *buffer, guint32 ssrc);
-void            gst_rtp_buffer_list_set_ssrc         (GstBufferList *list, guint32 ssrc);
+guint32         gst_rtp_buffer_get_ssrc              (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_ssrc              (GstRTPBuffer *rtp, guint32 ssrc);
 
-guint8          gst_rtp_buffer_get_csrc_count        (GstBuffer *buffer);
-guint32         gst_rtp_buffer_get_csrc              (GstBuffer *buffer, guint8 idx);
-void            gst_rtp_buffer_set_csrc              (GstBuffer *buffer, guint8 idx, guint32 csrc);
+guint8          gst_rtp_buffer_get_csrc_count        (GstRTPBuffer *rtp);
+guint32         gst_rtp_buffer_get_csrc              (GstRTPBuffer *rtp, guint8 idx);
+void            gst_rtp_buffer_set_csrc              (GstRTPBuffer *rtp, guint8 idx, guint32 csrc);
 
-gboolean        gst_rtp_buffer_get_marker            (GstBuffer *buffer);
-void            gst_rtp_buffer_set_marker            (GstBuffer *buffer, gboolean marker);
+gboolean        gst_rtp_buffer_get_marker            (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_marker            (GstRTPBuffer *rtp, gboolean marker);
 
-guint8          gst_rtp_buffer_get_payload_type      (GstBuffer *buffer);
-guint8          gst_rtp_buffer_list_get_payload_type (GstBufferList *list);
-void            gst_rtp_buffer_set_payload_type      (GstBuffer *buffer, guint8 payload_type);
-void            gst_rtp_buffer_list_set_payload_type (GstBufferList *list, guint8 payload_type);
+guint8          gst_rtp_buffer_get_payload_type      (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_payload_type      (GstRTPBuffer *rtp, guint8 payload_type);
 
-guint16         gst_rtp_buffer_get_seq               (GstBuffer *buffer);
-guint16         gst_rtp_buffer_list_get_seq          (GstBufferList *list);
-void            gst_rtp_buffer_set_seq               (GstBuffer *buffer, guint16 seq);
-guint16         gst_rtp_buffer_list_set_seq          (GstBufferList *list, guint16 seq);
+guint16         gst_rtp_buffer_get_seq               (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_seq               (GstRTPBuffer *rtp, guint16 seq);
 
-guint32         gst_rtp_buffer_get_timestamp         (GstBuffer *buffer);
-guint32         gst_rtp_buffer_list_get_timestamp    (GstBufferList *list);
-void            gst_rtp_buffer_set_timestamp         (GstBuffer *buffer, guint32 timestamp);
-void            gst_rtp_buffer_list_set_timestamp    (GstBufferList *list, guint32 timestamp);
+guint32         gst_rtp_buffer_get_timestamp         (GstRTPBuffer *rtp);
+void            gst_rtp_buffer_set_timestamp         (GstRTPBuffer *rtp, guint32 timestamp);
 
-GstBuffer*     gst_rtp_buffer_get_payload_buffer    (GstBuffer *buffer);
-GstBuffer*     gst_rtp_buffer_get_payload_subbuffer (GstBuffer *buffer, guint offset, guint len);
+GstBuffer*     gst_rtp_buffer_get_payload_buffer    (GstRTPBuffer *rtp);
+GstBuffer*     gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer *rtp, guint offset, guint len);
 
-guint           gst_rtp_buffer_get_payload_len       (GstBuffer *buffer);
-guint           gst_rtp_buffer_list_get_payload_len  (GstBufferList *list);
-gpointer        gst_rtp_buffer_get_payload           (GstBuffer *buffer);
+guint           gst_rtp_buffer_get_payload_len       (GstRTPBuffer *rtp);
+gpointer        gst_rtp_buffer_get_payload           (GstRTPBuffer *rtp);
 
 /* some helpers */
 guint32         gst_rtp_buffer_default_clock_rate    (guint8 payload_type);
 gint            gst_rtp_buffer_compare_seqnum        (guint16 seqnum1, guint16 seqnum2);
 guint64         gst_rtp_buffer_ext_timestamp         (guint64 *exttimestamp, guint32 timestamp);
 
-gboolean        gst_rtp_buffer_get_extension_onebyte_header (GstBuffer * buffer,
-                                                             guint8 id,
-                                                             guint nth,
-                                                             gpointer * data,
-                                                             guint * size);
-gboolean        gst_rtp_buffer_get_extension_twobytes_header (GstBuffer * buffer,
+gboolean        gst_rtp_buffer_get_extension_onebyte_header  (GstRTPBuffer *rtp,
+                                                              guint8 id,
+                                                              guint nth,
+                                                              gpointer * data,
+                                                              guint * size);
+gboolean        gst_rtp_buffer_get_extension_twobytes_header (GstRTPBuffer *rtp,
                                                               guint8 * appbits,
                                                               guint8 id,
                                                               guint nth,
                                                               gpointer * data,
                                                               guint * size);
 
-gboolean       gst_rtp_buffer_add_extension_onebyte_header (GstBuffer * buffer,
-                                                            guint8 id,
-                                                            gpointer data,
-                                                            guint size);
-gboolean       gst_rtp_buffer_add_extension_twobytes_header (GstBuffer * buffer,
+gboolean       gst_rtp_buffer_add_extension_onebyte_header  (GstRTPBuffer *rtp,
+                                                             guint8 id,
+                                                             gpointer data,
+                                                             guint size);
+gboolean       gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer *rtp,
                                                              guint8 appbits,
                                                              guint8 id,
                                                              gpointer data,
                                                              guint size);
 
-gboolean       gst_rtp_buffer_list_get_extension_onebyte_header (GstBufferList * bufferlist,
-                                                                 guint group_idx,
-                                                                 guint8 id,
-                                                                 guint nth,
-                                                                 gpointer * data,
-                                                                 guint * size);
-gboolean       gst_rtp_buffer_list_get_extension_twobytes_header (GstBufferList * bufferlist,
-                                                                  guint group_idx,
-                                                                  guint8 * appbits,
-                                                                  guint8 id,
-                                                                  guint nth,
-                                                                  gpointer * data,
-                                                                  guint * size);
-
-gboolean       gst_rtp_buffer_list_add_extension_onebyte_header (GstBufferListIterator * it,
-                                                                  guint8 id,
-                                                                  gpointer data,
-                                                                  guint size);
-gboolean       gst_rtp_buffer_list_add_extension_twobytes_header (GstBufferListIterator * it,
-                                                                  guint8 appbits,
-                                                                  guint8 id,
-                                                                  gpointer data,
-                                                                  guint size);
-
 
 G_END_DECLS
 
index 9f2d76e..e64ada4 100644 (file)
@@ -231,7 +231,7 @@ struct _GstExifWriter
 struct _GstExifReader
 {
   GstTagList *taglist;
-  const GstBuffer *buffer;
+  GstBuffer *buffer;
   guint32 base_offset;
   gint byte_order;
 
@@ -454,7 +454,7 @@ static const GstExifTagMatch tag_map_gps[] = {
 /* GstExifReader functions */
 static void
 gst_exif_reader_init (GstExifReader * reader, gint byte_order,
-    const GstBuffer * buf, guint32 base_offset)
+    GstBuffer * buf, guint32 base_offset)
 {
   reader->taglist = gst_tag_list_new ();
   reader->buffer = buf;
@@ -852,9 +852,10 @@ write_exif_undefined_tag_from_taglist (GstExifWriter * writer,
     const GstTagList * taglist, const GstExifTagMatch * exiftag)
 {
   const GValue *value;
-  const guint8 *data = NULL;
-  gint size = 0;
+  guint8 *data = NULL;
+  gsize size = 0;
   gint tag_size = gst_tag_list_get_tag_size (taglist, exiftag->gst_tag);
+  GstBuffer *buf = NULL;
 
   if (tag_size != 1) {
     GST_WARNING ("Only the first item in the taglist will be serialized");
@@ -871,10 +872,8 @@ write_exif_undefined_tag_from_taglist (GstExifWriter * writer,
       break;
     default:
       if (G_VALUE_TYPE (value) == GST_TYPE_BUFFER) {
-        GstBuffer *buf = gst_value_get_buffer (value);
-
-        data = GST_BUFFER_DATA (buf);
-        size = GST_BUFFER_SIZE (buf);
+        buf = gst_value_get_buffer (value);
+        data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
       } else {
         GST_WARNING ("Conversion from %s to raw data not supported",
             G_VALUE_TYPE_NAME (value));
@@ -882,10 +881,11 @@ write_exif_undefined_tag_from_taglist (GstExifWriter * writer,
       break;
   }
 
-  if (size == 0)
-    return;
+  if (size > 0)
+    write_exif_undefined_tag (writer, exiftag->exif_tag, data, size);
 
-  write_exif_undefined_tag (writer, exiftag->exif_tag, data, size);
+  if (buf)
+    gst_buffer_unmap (buf, data, size);
 }
 
 static void
@@ -1163,6 +1163,9 @@ parse_exif_ascii_tag (GstExifReader * reader, const GstExifTagMatch * tag,
   guint32 real_offset;
 
   if (count > 4) {
+    guint8 *data;
+    gsize size;
+
     if (offset < reader->base_offset) {
       GST_WARNING ("Offset is smaller (%u) than base offset (%u)", offset,
           reader->base_offset);
@@ -1170,15 +1173,17 @@ parse_exif_ascii_tag (GstExifReader * reader, const GstExifTagMatch * tag,
     }
 
     real_offset = offset - reader->base_offset;
-    if (real_offset >= GST_BUFFER_SIZE (reader->buffer)) {
+
+    data = gst_buffer_map (reader->buffer, &size, NULL, GST_MAP_READ);
+    if (real_offset >= size) {
       GST_WARNING ("Invalid offset %u for buffer of size %u, not adding tag %s",
-          real_offset, GST_BUFFER_SIZE (reader->buffer), tag->gst_tag);
+          real_offset, size, tag->gst_tag);
+      gst_buffer_unmap (reader->buffer, data, size);
       return;
     }
 
-    str =
-        g_strndup ((gchar *) (GST_BUFFER_DATA (reader->buffer) + real_offset),
-        count);
+    str = g_strndup ((gchar *) (data + real_offset), count);
+    gst_buffer_unmap (reader->buffer, data, size);
   } else {
     str = g_strndup ((gchar *) offset_as_data, count);
   }
@@ -1239,6 +1244,9 @@ parse_exif_undefined_tag (GstExifReader * reader, const GstExifTagMatch * tag,
   guint32 real_offset;
 
   if (count > 4) {
+    guint8 *bdata;
+    gsize bsize;
+
     if (offset < reader->base_offset) {
       GST_WARNING ("Offset is smaller (%u) than base offset (%u)", offset,
           reader->base_offset);
@@ -1246,16 +1254,22 @@ parse_exif_undefined_tag (GstExifReader * reader, const GstExifTagMatch * tag,
     }
 
     real_offset = offset - reader->base_offset;
-    if (real_offset >= GST_BUFFER_SIZE (reader->buffer)) {
+
+    bdata = gst_buffer_map (reader->buffer, &bsize, NULL, GST_MAP_READ);
+
+    if (real_offset >= bsize) {
       GST_WARNING ("Invalid offset %u for buffer of size %u, not adding tag %s",
-          real_offset, GST_BUFFER_SIZE (reader->buffer), tag->gst_tag);
+          real_offset, bsize, tag->gst_tag);
+      gst_buffer_unmap (reader->buffer, bdata, bsize);
       return;
     }
 
     /* +1 because it could be a string without the \0 */
     data = malloc (sizeof (guint8) * count + 1);
-    memcpy (data, GST_BUFFER_DATA (reader->buffer) + real_offset, count);
+    memcpy (data, bdata + real_offset, count);
     data[count] = 0;
+
+    gst_buffer_unmap (reader->buffer, bdata, bsize);
   } else {
     data = malloc (sizeof (guint8) * count + 1);
     memcpy (data, (guint8 *) offset_as_data, count);
@@ -1267,9 +1281,8 @@ parse_exif_undefined_tag (GstExifReader * reader, const GstExifTagMatch * tag,
     GstBuffer *buf;
 
     buf = gst_buffer_new ();
-    GST_BUFFER_DATA (buf) = data;
-    GST_BUFFER_MALLOCDATA (buf) = data;
-    GST_BUFFER_SIZE (buf) = count;
+    gst_buffer_take_memory (buf,
+        gst_memory_new_wrapped (0, data, g_free, count, 0, count));
     data = NULL;
 
     gst_tag_list_add (reader->taglist, GST_TAG_MERGE_APPEND, tag->gst_tag,
@@ -1295,6 +1308,8 @@ exif_reader_read_rational_tag (GstExifReader * exif_reader,
   guint32 real_offset;
   gint32 frac_n = 0;
   gint32 frac_d = 0;
+  guint8 *data;
+  gsize size;
 
   if (count > 1) {
     GST_WARNING ("Rationals with multiple entries are not supported");
@@ -1306,13 +1321,15 @@ exif_reader_read_rational_tag (GstExifReader * exif_reader,
   }
 
   real_offset = offset - exif_reader->base_offset;
-  if (real_offset >= GST_BUFFER_SIZE (exif_reader->buffer)) {
-    GST_WARNING ("Invalid offset %u for buffer of size %u",
-        real_offset, GST_BUFFER_SIZE (exif_reader->buffer));
-    return FALSE;
+
+  data = gst_buffer_map (exif_reader->buffer, &size, NULL, GST_MAP_READ);
+
+  if (real_offset >= size) {
+    GST_WARNING ("Invalid offset %u for buffer of size %u", real_offset, size);
+    goto reader_fail;
   }
 
-  gst_byte_reader_init_from_buffer (&data_reader, exif_reader->buffer);
+  gst_byte_reader_init (&data_reader, data, size);
   if (!gst_byte_reader_set_pos (&data_reader, real_offset))
     goto reader_fail;
 
@@ -1346,10 +1363,13 @@ exif_reader_read_rational_tag (GstExifReader * exif_reader,
   if (_frac_d)
     *_frac_d = frac_d;
 
+  gst_buffer_unmap (exif_reader->buffer, data, size);
+
   return TRUE;
 
 reader_fail:
   GST_WARNING ("Failed to read from byte reader. (Buffer too short?)");
+  gst_buffer_unmap (exif_reader->buffer, data, size);
   return FALSE;
 }
 
@@ -1449,12 +1469,17 @@ write_exif_ifd (const GstTagList * taglist, gboolean byte_order,
       }
 
       if (inner_ifd) {
+        guint8 *data;
+        gsize size;
+
         GST_DEBUG ("Adding inner ifd: %x", tag_map[i].exif_tag);
         gst_exif_writer_write_tag_header (&writer, tag_map[i].exif_tag,
             EXIF_TYPE_LONG, 1,
             gst_byte_writer_get_size (&writer.datawriter), FALSE);
-        gst_byte_writer_put_data (&writer.datawriter,
-            GST_BUFFER_DATA (inner_ifd), GST_BUFFER_SIZE (inner_ifd));
+
+        data = gst_buffer_map (inner_ifd, &size, NULL, GST_MAP_READ);
+        gst_byte_writer_put_data (&writer.datawriter, data, size);
+        gst_buffer_unmap (inner_ifd, data, size);
         gst_buffer_unref (inner_ifd);
       }
       continue;
@@ -1524,15 +1549,17 @@ parse_exif_ifd (GstExifReader * exif_reader, gint buf_offset,
   GstByteReader reader;
   guint16 entries = 0;
   guint16 i;
+  guint8 *data;
+  gsize size;
 
   g_return_val_if_fail (exif_reader->byte_order == G_LITTLE_ENDIAN
       || exif_reader->byte_order == G_BIG_ENDIAN, FALSE);
 
-  gst_byte_reader_init_from_buffer (&reader, exif_reader->buffer);
-  if (!gst_byte_reader_set_pos (&reader, buf_offset)) {
-    GST_WARNING ("Buffer offset invalid when parsing exif ifd");
-    return FALSE;
-  }
+  data = gst_buffer_map (exif_reader->buffer, &size, NULL, GST_MAP_READ);
+
+  gst_byte_reader_init (&reader, data, size);
+  if (!gst_byte_reader_set_pos (&reader, buf_offset))
+    goto invalid_offset;
 
   /* read the IFD entries number */
   if (exif_reader->byte_order == G_LITTLE_ENDIAN) {
@@ -1642,12 +1669,20 @@ parse_exif_ifd (GstExifReader * exif_reader, gint buf_offset,
       }
     }
   }
+  gst_buffer_unmap (exif_reader->buffer, data, size);
 
   return TRUE;
 
+invalid_offset:
+  {
+    GST_WARNING ("Buffer offset invalid when parsing exif ifd");
+    gst_buffer_unmap (exif_reader->buffer, data, size);
+    return FALSE;
+  }
 read_error:
   {
     GST_WARNING ("Failed to parse the exif ifd");
+    gst_buffer_unmap (exif_reader->buffer, data, size);
     return FALSE;
   }
 }
@@ -1688,14 +1723,18 @@ gst_tag_list_to_exif_buffer_with_tiff_header (const GstTagList * taglist)
 {
   GstBuffer *ifd;
   GstByteWriter writer;
-  guint size;
+  gsize size;
+  guint8 *data;
 
   ifd = gst_tag_list_to_exif_buffer (taglist, G_BYTE_ORDER, 8);
   if (ifd == NULL) {
     GST_WARNING ("Failed to create exif buffer");
     return NULL;
   }
-  size = TIFF_HEADER_SIZE + GST_BUFFER_SIZE (ifd);
+
+  data = gst_buffer_map (ifd, &size, NULL, GST_MAP_READ);
+
+  size += TIFF_HEADER_SIZE;
 
   /* TODO what is the correct endianness here? */
   gst_byte_writer_init_with_size (&writer, size, FALSE);
@@ -1709,17 +1748,19 @@ gst_tag_list_to_exif_buffer_with_tiff_header (const GstTagList * taglist)
     gst_byte_writer_put_uint16_be (&writer, 42);
     gst_byte_writer_put_uint32_be (&writer, 8);
   }
-  if (!gst_byte_writer_put_data (&writer, GST_BUFFER_DATA (ifd),
-          GST_BUFFER_SIZE (ifd))) {
+  if (!gst_byte_writer_put_data (&writer, data, size)) {
     GST_WARNING ("Byte writer size mismatch");
     /* reaching here is a programming error because we should have a buffer
      * large enough */
     g_assert_not_reached ();
+    gst_buffer_unmap (ifd, data, size);
     gst_buffer_unref (ifd);
     gst_byte_writer_reset (&writer);
     return NULL;
   }
+  gst_buffer_unmap (ifd, data, size);
   gst_buffer_unref (ifd);
+
   return gst_byte_writer_reset_and_get_buffer (&writer);
 }
 
@@ -1739,7 +1780,7 @@ gst_tag_list_to_exif_buffer_with_tiff_header (const GstTagList * taglist)
  * Since: 0.10.30
  */
 GstTagList *
-gst_tag_list_from_exif_buffer (const GstBuffer * buffer, gint byte_order,
+gst_tag_list_from_exif_buffer (GstBuffer * buffer, gint byte_order,
     guint32 base_offset)
 {
   GstExifReader reader;
@@ -1772,7 +1813,7 @@ read_error:
  * Since: 0.10.30
  */
 GstTagList *
-gst_tag_list_from_exif_buffer_with_tiff_header (const GstBuffer * buffer)
+gst_tag_list_from_exif_buffer_with_tiff_header (GstBuffer * buffer)
 {
   GstByteReader reader;
   guint16 fortytwo = 42;
@@ -1780,11 +1821,14 @@ gst_tag_list_from_exif_buffer_with_tiff_header (const GstBuffer * buffer)
   guint32 offset;
   GstTagList *taglist = NULL;
   GstBuffer *subbuffer;
+  guint8 *data, *sdata;
+  gsize size, ssize;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
-  GST_LOG ("Parsing exif tags with tiff header of size %u",
-      GST_BUFFER_SIZE (buffer));
+  GST_LOG ("Parsing exif tags with tiff header of size %u", size);
 
-  gst_byte_reader_init_from_buffer (&reader, buffer);
+  gst_byte_reader_init (&reader, data, size);
 
   GST_LOG ("Parsing the tiff header");
   if (!gst_byte_reader_get_uint16_be (&reader, &endianness)) {
@@ -1799,32 +1843,42 @@ gst_tag_list_from_exif_buffer_with_tiff_header (const GstBuffer * buffer)
     if (!gst_byte_reader_get_uint16_be (&reader, &fortytwo) ||
         !gst_byte_reader_get_uint32_be (&reader, &offset))
       goto byte_reader_fail;
-  } else {
-    GST_WARNING ("Invalid endianness number %u", endianness);
-    return NULL;
-  }
+  } else
+    goto invalid_endianness;
 
-  if (fortytwo != 42) {
-    GST_WARNING ("Invalid magic number %u, should be 42", fortytwo);
-    return NULL;
-  }
+  if (fortytwo != 42)
+    goto invalid_magic;
 
-  subbuffer = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buffer) -
-      (TIFF_HEADER_SIZE - 2));
-  memcpy (GST_BUFFER_DATA (subbuffer),
-      GST_BUFFER_DATA (buffer) + TIFF_HEADER_SIZE,
-      GST_BUFFER_SIZE (buffer) - TIFF_HEADER_SIZE);
+  subbuffer = gst_buffer_new_and_alloc (size - (TIFF_HEADER_SIZE - 2));
+
+  sdata = gst_buffer_map (subbuffer, &ssize, NULL, GST_MAP_WRITE);
+  memcpy (sdata, data + TIFF_HEADER_SIZE, size - TIFF_HEADER_SIZE);
+  gst_buffer_unmap (subbuffer, sdata, ssize);
 
   taglist = gst_tag_list_from_exif_buffer (subbuffer,
       endianness == TIFF_LITTLE_ENDIAN ? G_LITTLE_ENDIAN : G_BIG_ENDIAN, 8);
 
   gst_buffer_unref (subbuffer);
+
+done:
+  gst_buffer_unmap (buffer, data, size);
+
   return taglist;
 
 byte_reader_fail:
   {
     GST_WARNING ("Failed to read values from buffer");
-    return NULL;
+    goto done;
+  }
+invalid_endianness:
+  {
+    GST_WARNING ("Invalid endianness number %u", endianness);
+    goto done;
+  }
+invalid_magic:
+  {
+    GST_WARNING ("Invalid magic number %u, should be 42", fortytwo);
+    goto done;
   }
 }
 
@@ -1924,6 +1978,8 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
   gdouble degrees;
   gdouble minutes;
   gdouble seconds;
+  guint8 *data = NULL;
+  gsize size = 0;
 
   GST_LOG ("Starting to parse %s tag in exif 0x%x", exiftag->gst_tag,
       exiftag->exif_tag);
@@ -1980,8 +2036,11 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
     return ret;
   }
 
+  data = gst_buffer_map (exif_reader->buffer, &size, NULL, GST_MAP_READ);
+
   /* now parse the fractions */
-  gst_byte_reader_init_from_buffer (&fractions_reader, exif_reader->buffer);
+  gst_byte_reader_init (&fractions_reader, data, size);
+
   if (!gst_byte_reader_set_pos (&fractions_reader,
           next_tagdata.offset - exif_reader->base_offset))
     goto reader_fail;
@@ -2003,6 +2062,7 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
         !gst_byte_reader_get_uint32_be (&fractions_reader, &seconds_d))
       goto reader_fail;
   }
+  gst_buffer_unmap (exif_reader->buffer, data, size);
 
   GST_DEBUG ("Read degrees fraction for tag %s: %u/%u %u/%u %u/%u",
       exiftag->gst_tag, degrees_n, degrees_d, minutes_n, minutes_d,
@@ -2024,6 +2084,8 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
 
 reader_fail:
   GST_WARNING ("Failed to read fields from buffer (too short?)");
+  if (data)
+    gst_buffer_unmap (exif_reader->buffer, data, size);
   return ret;
 }
 
index 8bb3314..935aea7 100644 (file)
@@ -102,6 +102,7 @@ struct _GstTagDemuxPrivate
 
   GstTagDemuxState state;
   GstBuffer *collect;
+  gsize collect_size;
   GstCaps *src_caps;
 
   GstTagList *event_tags;
@@ -254,6 +255,7 @@ gst_tag_demux_reset (GstTagDemux * tagdemux)
   tagdemux->priv->send_tag_event = FALSE;
 
   gst_buffer_replace (buffer_p, NULL);
+  tagdemux->priv->collect_size = 0;
   gst_caps_replace (caps_p, NULL);
 
   gst_tag_demux_remove_srcpad (tagdemux);
@@ -388,18 +390,23 @@ gst_tag_demux_remove_srcpad (GstTagDemux * demux)
  * also return TRUE and set *buf_ref to NULL if the buffer was before
  * the start of the data */
 static gboolean
-gst_tag_demux_trim_buffer (GstTagDemux * tagdemux, GstBuffer ** buf_ref)
+gst_tag_demux_trim_buffer (GstTagDemux * tagdemux, GstBuffer ** buf_ref,
+    gsize * buf_size)
 {
   GstBuffer *buf = *buf_ref;
 
   guint trim_start = 0;
-  guint out_size = GST_BUFFER_SIZE (buf);
-  guint64 out_offset = GST_BUFFER_OFFSET (buf);
+  guint out_size, bsize;
+  guint64 out_offset, boffset;
   gboolean need_sub = FALSE;
 
+  bsize = out_size = gst_buffer_get_size (buf);
+  boffset = out_offset = GST_BUFFER_OFFSET (buf);
+
   /* Adjust offset and length */
   if (!GST_BUFFER_OFFSET_IS_VALID (buf)) {
     /* Can't change anything without an offset */
+    *buf_size = bsize;
     return TRUE;
   }
 
@@ -439,21 +446,24 @@ gst_tag_demux_trim_buffer (GstTagDemux * tagdemux, GstBuffer ** buf_ref)
   }
 
   if (need_sub == TRUE) {
-    if (out_size != GST_BUFFER_SIZE (buf) || !gst_buffer_is_writable (buf)) {
+    if (out_size != bsize || !gst_buffer_is_writable (buf)) {
       GstBuffer *sub;
 
       GST_DEBUG_OBJECT (tagdemux, "Sub-buffering to trim size %d offset %"
           G_GINT64_FORMAT " to %d offset %" G_GINT64_FORMAT,
-          GST_BUFFER_SIZE (buf), GST_BUFFER_OFFSET (buf), out_size, out_offset);
+          bsize, boffset, out_size, out_offset);
 
-      sub = gst_buffer_create_sub (buf, trim_start, out_size);
+      sub =
+          gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, trim_start,
+          out_size);
       g_return_val_if_fail (sub != NULL, FALSE);
       gst_buffer_unref (buf);
       *buf_ref = buf = sub;
+      *buf_size = out_size;
     } else {
       GST_DEBUG_OBJECT (tagdemux, "Adjusting buffer from size %d offset %"
           G_GINT64_FORMAT " to %d offset %" G_GINT64_FORMAT,
-          GST_BUFFER_SIZE (buf), GST_BUFFER_OFFSET (buf), out_size, out_offset);
+          bsize, boffset, out_size, out_offset);
     }
 
     GST_BUFFER_OFFSET (buf) = out_offset;
@@ -485,7 +495,7 @@ gst_tag_demux_chain_parse_tag (GstTagDemux * demux, GstBuffer * collect)
   guint tagsize = 0;
   guint available;
 
-  g_assert (gst_buffer_is_metadata_writable (collect));
+  g_assert (gst_buffer_is_writable (collect));
 
   klass = GST_TAG_DEMUX_CLASS (G_OBJECT_GET_CLASS (demux));
 
@@ -501,7 +511,7 @@ gst_tag_demux_chain_parse_tag (GstTagDemux * demux, GstBuffer * collect)
   g_assert (klass->identify_tag != NULL);
   g_assert (klass->parse_tag != NULL);
 
-  available = GST_BUFFER_SIZE (collect);
+  available = gst_buffer_get_size (collect);
 
   if (available < klass->min_start_size) {
     GST_DEBUG_OBJECT (demux, "Only %u bytes available, but %u needed "
@@ -535,13 +545,13 @@ gst_tag_demux_chain_parse_tag (GstTagDemux * demux, GstBuffer * collect)
       return;                   /* wait for more data */
     }
 
-    saved_size = GST_BUFFER_SIZE (collect);
-    GST_BUFFER_SIZE (collect) = tagsize;
+    saved_size = gst_buffer_get_size (collect);
+    gst_buffer_set_size (collect, tagsize);
     newsize = tagsize;
 
     parse_ret = klass->parse_tag (demux, collect, TRUE, &newsize, &tags);
 
-    GST_BUFFER_SIZE (collect) = saved_size;
+    gst_buffer_set_size (collect, saved_size);
 
     switch (parse_ret) {
       case GST_TAG_DEMUX_RESULT_OK:
@@ -572,14 +582,17 @@ static GstFlowReturn
 gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
 {
   GstTagDemux *demux;
+  gsize size;
 
   demux = GST_TAG_DEMUX (GST_PAD_PARENT (pad));
 
+  size = gst_buffer_get_size (buf);
+
   /* Update our segment last_stop info */
   if (demux->priv->segment.format == GST_FORMAT_BYTES) {
     if (GST_BUFFER_OFFSET_IS_VALID (buf))
       demux->priv->segment.last_stop = GST_BUFFER_OFFSET (buf);
-    demux->priv->segment.last_stop += GST_BUFFER_SIZE (buf);
+    demux->priv->segment.last_stop += size;
   } else if (demux->priv->segment.format == GST_FORMAT_TIME) {
     if (GST_BUFFER_TIMESTAMP_IS_VALID (buf))
       demux->priv->segment.last_stop = GST_BUFFER_TIMESTAMP (buf);
@@ -592,12 +605,12 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
   } else {
     demux->priv->collect = gst_buffer_join (demux->priv->collect, buf);
   }
+  demux->priv->collect_size += size;
   buf = NULL;
 
   switch (demux->priv->state) {
     case GST_TAG_DEMUX_READ_START_TAG:
-      demux->priv->collect =
-          gst_buffer_make_metadata_writable (demux->priv->collect);
+      demux->priv->collect = gst_buffer_make_writable (demux->priv->collect);
       gst_tag_demux_chain_parse_tag (demux, demux->priv->collect);
       if (demux->priv->state != GST_TAG_DEMUX_TYPEFINDING)
         break;
@@ -605,19 +618,20 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
     case GST_TAG_DEMUX_TYPEFINDING:{
       GstTypeFindProbability probability = 0;
       GstBuffer *typefind_buf = NULL;
+      gsize typefind_size;
       GstCaps *caps;
 
-      if (GST_BUFFER_SIZE (demux->priv->collect) <
+      if (demux->priv->collect_size <
           TYPE_FIND_MIN_SIZE + demux->priv->strip_start)
         break;                  /* Go get more data first */
 
       GST_DEBUG_OBJECT (demux, "Typefinding with size %d",
-          GST_BUFFER_SIZE (demux->priv->collect));
+          demux->priv->collect_size);
 
       /* Trim the buffer and adjust offset for typefinding */
       typefind_buf = demux->priv->collect;
       gst_buffer_ref (typefind_buf);
-      if (!gst_tag_demux_trim_buffer (demux, &typefind_buf))
+      if (!gst_tag_demux_trim_buffer (demux, &typefind_buf, &typefind_size))
         return GST_FLOW_UNEXPECTED;
 
       if (typefind_buf == NULL)
@@ -627,7 +641,7 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
           typefind_buf, &probability);
 
       if (caps == NULL) {
-        if (GST_BUFFER_SIZE (typefind_buf) < TYPE_FIND_MAX_SIZE) {
+        if (typefind_size < TYPE_FIND_MAX_SIZE) {
           /* Just break for more data */
           gst_buffer_unref (typefind_buf);
           return GST_FLOW_OK;
@@ -639,6 +653,7 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
         gst_buffer_unref (typefind_buf);
         gst_buffer_unref (demux->priv->collect);
         demux->priv->collect = NULL;
+        demux->priv->collect_size = 0;
         return GST_FLOW_ERROR;
       }
       gst_buffer_unref (typefind_buf);
@@ -660,12 +675,14 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
     }
     case GST_TAG_DEMUX_STREAMING:{
       GstBuffer *outbuf = NULL;
+      gsize outbuf_size;
 
       /* Trim the buffer and adjust offset */
       if (demux->priv->collect) {
         outbuf = demux->priv->collect;
         demux->priv->collect = NULL;
-        if (!gst_tag_demux_trim_buffer (demux, &outbuf))
+        demux->priv->collect_size = 0;
+        if (!gst_tag_demux_trim_buffer (demux, &outbuf, &outbuf_size))
           return GST_FLOW_UNEXPECTED;
       }
       if (outbuf) {
@@ -693,7 +710,7 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf)
         }
 
         /* Ensure the caps are set correctly */
-        outbuf = gst_buffer_make_metadata_writable (outbuf);
+        outbuf = gst_buffer_make_writable (outbuf);
         gst_buffer_set_caps (outbuf, GST_PAD_CAPS (demux->priv->srcpad));
 
         GST_LOG_OBJECT (demux, "Pushing buffer %p", outbuf);
@@ -885,6 +902,7 @@ gst_tag_demux_pull_end_tag (GstTagDemux * demux, GstTagList ** tags)
   gboolean res = FALSE;
   guint64 offset;
   guint tagsize;
+  gsize bsize;
 
   klass = GST_TAG_DEMUX_CLASS (G_OBJECT_GET_CLASS (demux));
 
@@ -913,9 +931,11 @@ gst_tag_demux_pull_end_tag (GstTagDemux * demux, GstTagList ** tags)
     goto done;
   }
 
-  if (GST_BUFFER_SIZE (buffer) < klass->min_end_size) {
+  bsize = gst_buffer_get_size (buffer);
+
+  if (bsize < klass->min_end_size) {
     GST_DEBUG_OBJECT (demux, "Only managed to read %u bytes from file "
-        "(required: %u bytes)", GST_BUFFER_SIZE (buffer), klass->min_end_size);
+        "(required: %u bytes)", bsize, klass->min_end_size);
     goto done;
   }
 
@@ -937,7 +957,7 @@ gst_tag_demux_pull_end_tag (GstTagDemux * demux, GstTagList ** tags)
     g_assert (tagsize >= klass->min_end_size);
 
     /* Get buffer that's exactly the requested size */
-    if (GST_BUFFER_SIZE (buffer) != tagsize) {
+    if (bsize != tagsize) {
       gst_buffer_unref (buffer);
       buffer = NULL;
 
@@ -953,22 +973,24 @@ gst_tag_demux_pull_end_tag (GstTagDemux * demux, GstTagList ** tags)
         goto done;
       }
 
-      if (GST_BUFFER_SIZE (buffer) < tagsize) {
+      bsize = gst_buffer_get_size (buffer);
+
+      if (bsize < tagsize) {
         GST_DEBUG_OBJECT (demux, "Only managed to read %u bytes from file",
-            GST_BUFFER_SIZE (buffer));
+            bsize);
         goto done;
       }
     }
 
     GST_BUFFER_OFFSET (buffer) = offset;
 
-    saved_size = GST_BUFFER_SIZE (buffer);
-    GST_BUFFER_SIZE (buffer) = tagsize;
+    saved_size = bsize;
+    gst_buffer_set_size (buffer, tagsize);
     newsize = tagsize;
 
     parse_ret = klass->parse_tag (demux, buffer, FALSE, &newsize, &new_tags);
 
-    GST_BUFFER_SIZE (buffer) = saved_size;
+    gst_buffer_set_size (buffer, saved_size);
 
     switch (parse_ret) {
       case GST_TAG_DEMUX_RESULT_OK:
@@ -1015,6 +1037,7 @@ gst_tag_demux_pull_start_tag (GstTagDemux * demux, GstTagList ** tags)
   gboolean have_tag;
   gboolean res = FALSE;
   guint req, tagsize;
+  gsize bsize;
 
   klass = GST_TAG_DEMUX_CLASS (G_OBJECT_GET_CLASS (demux));
 
@@ -1037,9 +1060,11 @@ gst_tag_demux_pull_start_tag (GstTagDemux * demux, GstTagList ** tags)
     goto done;
   }
 
-  if (GST_BUFFER_SIZE (buffer) < klass->min_start_size) {
+  bsize = gst_buffer_get_size (buffer);
+
+  if (bsize < klass->min_start_size) {
     GST_DEBUG_OBJECT (demux, "Only managed to read %u bytes from file - "
-        "no tag in this file", GST_BUFFER_SIZE (buffer));
+        "no tag in this file", bsize);
     goto done;
   }
 
@@ -1061,7 +1086,7 @@ gst_tag_demux_pull_start_tag (GstTagDemux * demux, GstTagList ** tags)
     /* Now pull the entire tag */
     g_assert (tagsize >= klass->min_start_size);
 
-    if (GST_BUFFER_SIZE (buffer) < tagsize) {
+    if (bsize < tagsize) {
       gst_buffer_unref (buffer);
       buffer = NULL;
 
@@ -1072,21 +1097,23 @@ gst_tag_demux_pull_start_tag (GstTagDemux * demux, GstTagList ** tags)
         goto done;
       }
 
-      if (GST_BUFFER_SIZE (buffer) < tagsize) {
+      bsize = gst_buffer_get_size (buffer);
+
+      if (bsize < tagsize) {
         GST_DEBUG_OBJECT (demux, "Only managed to read %u bytes from file",
-            GST_BUFFER_SIZE (buffer));
+            bsize);
         GST_ELEMENT_ERROR (demux, STREAM, DECODE,
             (_("Failed to read tag: not enough data")), (NULL));
         goto done;
       }
     }
 
-    saved_size = GST_BUFFER_SIZE (buffer);
-    GST_BUFFER_SIZE (buffer) = tagsize;
+    saved_size = bsize;
+    gst_buffer_set_size (buffer, tagsize);
     newsize = tagsize;
     parse_ret = klass->parse_tag (demux, buffer, TRUE, &newsize, &new_tags);
 
-    GST_BUFFER_SIZE (buffer) = saved_size;
+    gst_buffer_set_size (buffer, saved_size);
 
     switch (parse_ret) {
       case GST_TAG_DEMUX_RESULT_OK:
@@ -1272,6 +1299,7 @@ gst_tag_demux_read_range (GstTagDemux * demux,
   GstFlowReturn ret;
   guint64 in_offset;
   guint in_length;
+  gsize size;
 
   g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
 
@@ -1294,7 +1322,7 @@ gst_tag_demux_read_range (GstTagDemux * demux,
   ret = gst_pad_pull_range (demux->priv->sinkpad, in_offset, in_length, buffer);
 
   if (ret == GST_FLOW_OK && *buffer) {
-    if (!gst_tag_demux_trim_buffer (demux, buffer))
+    if (!gst_tag_demux_trim_buffer (demux, buffer, &size))
       goto read_beyond_end;
 
     /* this should only happen in streaming mode */
index 400118b..0365509 100644 (file)
@@ -417,8 +417,9 @@ decode_failed:
 }
 
 /**
- * gst_tag_list_from_vorbiscomment_buffer:
- * @buffer: buffer to convert
+ * gst_tag_list_from_vorbiscomment:
+ * @data: data to convert
+ * @size: size of @data
  * @id_data: identification data at start of stream
  * @id_data_length: length of identification data
  * @vendor_string: pointer to a string that should take the vendor string
@@ -431,7 +432,7 @@ decode_failed:
  *          given vorbiscomment buffer or NULL on error.
  */
 GstTagList *
-gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer,
+gst_tag_list_from_vorbiscomment (const guint8 * data, gsize size,
     const guint8 * id_data, const guint id_data_length, gchar ** vendor_string)
 {
 #define ADVANCE(x) G_STMT_START{                                                \
@@ -447,15 +448,12 @@ gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer,
   gchar *cur, *value;
   guint cur_size;
   guint iterations;
-  guint8 *data;
-  guint size, value_len;
+  guint value_len;
   GstTagList *list;
 
-  g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
+  g_return_val_if_fail (data != NULL, NULL);
   g_return_val_if_fail (id_data != NULL || id_data_length == 0, NULL);
 
-  data = GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
   list = gst_tag_list_new ();
 
   if (size < 11 || size <= id_data_length + 4)
@@ -510,6 +508,37 @@ error:
 #undef ADVANCE
 }
 
+/**
+ * gst_tag_list_from_vorbiscomment_buffer:
+ * @buffer: buffer to convert
+ * @id_data: identification data at start of stream
+ * @id_data_length: length of identification data
+ * @vendor_string: pointer to a string that should take the vendor string
+ *                 of this vorbis comment or NULL if you don't need it.
+ *
+ * Creates a new tag list that contains the information parsed out of a
+ * vorbiscomment packet.
+ *
+ * Returns: A new #GstTagList with all tags that could be extracted from the
+ *          given vorbiscomment buffer or NULL on error.
+ */
+GstTagList *
+gst_tag_list_from_vorbiscomment_buffer (GstBuffer * buffer,
+    const guint8 * id_data, const guint id_data_length, gchar ** vendor_string)
+{
+  GstTagList *res;
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  res =
+      gst_tag_list_from_vorbiscomment (data, size, id_data, id_data_length,
+      vendor_string);
+  gst_buffer_unmap (buffer, data, size);
+
+  return res;
+}
+
 typedef struct
 {
   guint count;
@@ -528,6 +557,8 @@ gst_tag_to_metadata_block_picture (const gchar * tag,
   GstStructure *mime_struct;
   GstBuffer *buffer;
   GList *l = NULL;
+  guint8 *data;
+  gsize size;
   GstByteWriter writer;
   GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
   gint width = 0, height = 0;
@@ -549,7 +580,7 @@ gst_tag_to_metadata_block_picture (const gchar * tag,
       &image_type, "width", G_TYPE_INT, &width, "height", G_TYPE_INT, &height,
       NULL);
 
-  metadata_block_len = 32 + mime_type_len + GST_BUFFER_SIZE (buffer);
+  metadata_block_len = 32 + mime_type_len + gst_buffer_get_size (buffer);
   gst_byte_writer_init_with_size (&writer, metadata_block_len, TRUE);
 
   if (image_type == GST_TAG_IMAGE_TYPE_NONE
@@ -575,9 +606,12 @@ gst_tag_to_metadata_block_picture (const gchar * tag,
   gst_byte_writer_put_uint32_be_unchecked (&writer, 0);
   /* for indexed formats the number of colors */
   gst_byte_writer_put_uint32_be_unchecked (&writer, 0);
-  gst_byte_writer_put_uint32_be_unchecked (&writer, GST_BUFFER_SIZE (buffer));
-  gst_byte_writer_put_data_unchecked (&writer, GST_BUFFER_DATA (buffer),
-      GST_BUFFER_SIZE (buffer));
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+  gst_byte_writer_put_uint32_be_unchecked (&writer, size);
+  gst_byte_writer_put_data_unchecked (&writer, data, size);
+  gst_buffer_unmap (buffer, data, size);
+
   g_assert (gst_byte_writer_get_pos (&writer) == metadata_block_len);
 
   metadata_block = gst_byte_writer_reset_and_get_data (&writer);
@@ -743,7 +777,7 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
     const gchar * vendor_string)
 {
   GstBuffer *buffer;
-  guint8 *data;
+  guint8 *data, *odata;
   guint i;
   GList *l;
   MyForEach my_data = { 0, 0, NULL };
@@ -759,8 +793,9 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
   required_size = id_data_length + 4 + vendor_len + 4 + 1;
   gst_tag_list_foreach ((GstTagList *) list, write_one_tag, &my_data);
   required_size += 4 * my_data.count + my_data.data_count;
+
   buffer = gst_buffer_new_and_alloc (required_size);
-  data = GST_BUFFER_DATA (buffer);
+  odata = data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
   if (id_data_length > 0) {
     memcpy (data, id_data, id_data_length);
     data += id_data_length;
@@ -788,6 +823,7 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
   g_list_foreach (my_data.entries, (GFunc) g_free, NULL);
   g_list_free (my_data.entries);
   *data = 1;
+  gst_buffer_unmap (buffer, odata, required_size);
 
   return buffer;
 }
index ca05895..7b0da72 100644 (file)
@@ -1200,11 +1200,11 @@ read_one_tag (GstTagList * list, const gchar * tag, XmpTag * xmptag,
  * Since: 0.10.29
  */
 GstTagList *
-gst_tag_list_from_xmp_buffer (const GstBuffer * buffer)
+gst_tag_list_from_xmp_buffer (GstBuffer * buffer)
 {
   GstTagList *list = NULL;
-  const gchar *xps, *xp1, *xp2, *xpe, *ns, *ne;
-  guint len, max_ft_len;
+  gchar *xps, *xp1, *xp2, *xpe, *ns, *ne;
+  gsize len, max_ft_len;
   gboolean in_tag;
   gchar *part, *pp;
   guint i;
@@ -1225,10 +1225,10 @@ gst_tag_list_from_xmp_buffer (const GstBuffer * buffer)
   xmp_tags_initialize ();
 
   g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
-  g_return_val_if_fail (GST_BUFFER_SIZE (buffer) > 0, NULL);
 
-  xps = (const gchar *) GST_BUFFER_DATA (buffer);
-  len = GST_BUFFER_SIZE (buffer);
+  xps = gst_buffer_map (buffer, &len, NULL, GST_MAP_READ);
+  g_return_val_if_fail (len > 0, NULL);
+
   xpe = &xps[len + 1];
 
   /* check header and footer */
@@ -1433,6 +1433,8 @@ gst_tag_list_from_xmp_buffer (const GstBuffer * buffer)
   }
   g_free (part);
 
+  gst_buffer_unmap (buffer, xps, len);
+
   return list;
 
   /* Errors */
@@ -1608,6 +1610,8 @@ gst_tag_list_to_xmp_buffer_full (const GstTagList * list, gboolean read_only,
   XmpSerializationData serialization_data;
   GString *data;
   guint i;
+  gsize bsize;
+  gpointer bdata;
 
   serialization_data.data = g_string_sized_new (4096);
   serialization_data.schemas = schemas;
@@ -1655,10 +1659,12 @@ gst_tag_list_to_xmp_buffer_full (const GstTagList * list, gboolean read_only,
   g_string_append_printf (data, "<?xpacket end=\"%c\"?>\n",
       (read_only ? 'r' : 'w'));
 
+  bsize = data->len + 1;
+  bdata = g_string_free (data, FALSE);
+
   buffer = gst_buffer_new ();
-  GST_BUFFER_SIZE (buffer) = data->len + 1;
-  GST_BUFFER_DATA (buffer) = (guint8 *) g_string_free (data, FALSE);
-  GST_BUFFER_MALLOCDATA (buffer) = GST_BUFFER_DATA (buffer);
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (0, bdata, g_free, bsize, 0, bsize));
 
   return buffer;
 }
index e9877ed..1e01c89 100644 (file)
@@ -454,7 +454,12 @@ GList *                 gst_tag_to_vorbis_comments              (const GstTagLis
                                                                  const gchar *          tag);
 
 /* functions to convert GstBuffers with vorbiscomment contents to GstTagLists and back */
-GstTagList *            gst_tag_list_from_vorbiscomment_buffer  (const GstBuffer *      buffer,
+GstTagList *            gst_tag_list_from_vorbiscomment         (const guint8 *         data,
+                                                                 gsize                  size,
+                                                                 const guint8 *         id_data,
+                                                                 const guint            id_data_length,
+                                                                 gchar **               vendor_string);
+GstTagList *            gst_tag_list_from_vorbiscomment_buffer  (GstBuffer *            buffer,
                                                                  const guint8 *         id_data,
                                                                  const guint            id_data_length,
                                                                  gchar **               vendor_string);
@@ -480,7 +485,7 @@ gboolean                gst_tag_list_add_id3_image (GstTagList   * tag_list,
                                                     guint          id3_picture_type);
 
 /* functions to  convert GstBuffers with xmp packets contents to GstTagLists and back */
-GstTagList *            gst_tag_list_from_xmp_buffer  (const GstBuffer *  buffer);
+GstTagList *            gst_tag_list_from_xmp_buffer  (GstBuffer *  buffer);
 GstBuffer *             gst_tag_list_to_xmp_buffer    (const GstTagList * list,
                                                        gboolean           read_only);
 GstBuffer *            gst_tag_list_to_xmp_buffer_full (const GstTagList * list,
@@ -494,12 +499,12 @@ GstBuffer *             gst_tag_list_to_exif_buffer (const GstTagList * taglist,
 
 GstBuffer *             gst_tag_list_to_exif_buffer_with_tiff_header (const GstTagList * taglist);
 
-GstTagList *            gst_tag_list_from_exif_buffer (const GstBuffer * buffer,
+GstTagList *            gst_tag_list_from_exif_buffer (GstBuffer * buffer,
                                                        gint byte_order,
                                                        guint32 base_offset);
 
 GstTagList *            gst_tag_list_from_exif_buffer_with_tiff_header (
-                                                      const GstBuffer * buffer);
+                                                      GstBuffer * buffer);
 
 /* other tag-related functions */
 
index a8e867c..cb60b54 100644 (file)
@@ -557,10 +557,9 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
     guint image_data_len, GstTagImageType image_type)
 {
   const gchar *name;
-
   GstBuffer *image;
-
   GstCaps *caps;
+  guint8 *data;
 
   g_return_val_if_fail (image_data != NULL, NULL);
   g_return_val_if_fail (image_data_len > 0, NULL);
@@ -569,14 +568,14 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
   GST_DEBUG ("image data len: %u bytes", image_data_len);
 
   /* allocate space for a NUL terminator for an uri too */
-  image = gst_buffer_try_new_and_alloc (image_data_len + 1);
-  if (image == NULL) {
-    GST_WARNING ("failed to allocate buffer of %d for image", image_data_len);
-    return NULL;
-  }
+  image = gst_buffer_new_and_alloc (image_data_len + 1);
+  if (image == NULL)
+    goto alloc_failed;
 
-  memcpy (GST_BUFFER_DATA (image), image_data, image_data_len);
-  GST_BUFFER_DATA (image)[image_data_len] = '\0';
+  data = gst_buffer_map (image, NULL, NULL, GST_MAP_WRITE);
+  memcpy (data, image_data, image_data_len);
+  data[image_data_len] = '\0';
+  gst_buffer_unmap (image, data, image_data_len + 1);
 
   /* Find GStreamer media type, can't trust declared type */
   caps = gst_type_find_helper_for_buffer (NULL, image, NULL);
@@ -600,7 +599,7 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
    * to keep the original size of the image
    */
   if (!g_str_equal (name, "text/uri-list"))
-    GST_BUFFER_SIZE (image) = image_data_len;
+    gst_buffer_set_size (image, image_data_len);
 
   if (image_type != GST_TAG_IMAGE_TYPE_NONE) {
     GST_LOG ("Setting image type: %d", image_type);
@@ -627,4 +626,11 @@ error:
       gst_caps_unref (caps);
     return NULL;
   }
+alloc_failed:
+  {
+    GST_WARNING ("failed to allocate buffer of %d for image", image_data_len);
+    gst_buffer_unref (image);
+    return NULL;
+  }
+
 }
index c04f2ca..6ba3e30 100644 (file)
@@ -292,7 +292,7 @@ gst_video_convert_frame (GstBuffer * buf, const GstCaps * to_caps,
 
   /* feed buffer in appsrc */
   GST_DEBUG ("feeding buffer %p, size %u, caps %" GST_PTR_FORMAT,
-      buf, GST_BUFFER_SIZE (buf), from_caps);
+      buf, gst_buffer_get_size (buf), from_caps);
   g_signal_emit_by_name (src, "push-buffer", buf, &ret);
 
   /* now see what happens. We either got an error somewhere or the pipeline
index 2d08a60..0f09b82 100644 (file)
@@ -75,7 +75,7 @@ gst_video_filter_get_type (void)
 
 static gboolean
 gst_video_filter_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   GstVideoFormat fmt;
   gint width, height;
index fca3eb2..0ce41e7 100644 (file)
@@ -1102,16 +1102,16 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
        * are the only one referencing this buffer. If this is the last (and
        * only) GAP buffer, it will automatically copy the GAP flag. */
       outbuf = gst_buffer_make_writable (inbuf);
-      outdata = GST_BUFFER_DATA (outbuf);
       gst_buffer_set_caps (outbuf, GST_PAD_CAPS (adder->srcpad));
+
+      outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
     } else {
       if (!is_gap) {
         /* we had a previous output buffer, mix this non-GAP buffer */
         guint8 *indata;
-        guint insize;
+        gsize insize;
 
-        indata = GST_BUFFER_DATA (inbuf);
-        insize = GST_BUFFER_SIZE (inbuf);
+        indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
 
         /* all buffers should have outsize, there are no short buffers because we
          * asked for the max size above */
@@ -1123,6 +1123,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
         /* further buffers, need to add them */
         adder->func ((gpointer) outdata, (gpointer) indata,
             insize / adder->sample_size);
+        gst_buffer_unmap (inbuf, indata, insize);
       } else {
         /* skip gap buffer */
         GST_LOG_OBJECT (adder, "channel %p: skipping GAP buffer", collect_data);
@@ -1130,6 +1131,8 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
       gst_buffer_unref (inbuf);
     }
   }
+  if (outbuf)
+    gst_buffer_unmap (outbuf, outdata, outsize);
 
   if (outbuf == NULL) {
     /* no output buffer, reuse one of the GAP buffers then if we have one */
index 2b3445a..3023093 100644 (file)
@@ -76,7 +76,7 @@ static void gst_audio_convert_dispose (GObject * obj);
 
 /* gstreamer functions */
 static gboolean gst_audio_convert_get_unit_size (GstBaseTransform * base,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 static GstCaps *gst_audio_convert_transform_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps);
 static void gst_audio_convert_fixate_caps (GstBaseTransform * base,
@@ -361,7 +361,7 @@ not_allowed:
 /* BaseTransform vmethods */
 static gboolean
 gst_audio_convert_get_unit_size (GstBaseTransform * base, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   AudioConvertFmt fmt = { 0 };
 
@@ -1069,7 +1069,9 @@ static GstFlowReturn
 gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
     GstBuffer * outbuf)
 {
+  GstFlowReturn ret;
   GstAudioConvert *this = GST_AUDIO_CONVERT (base);
+  gsize srcsize, dstsize;
   gint insize, outsize;
   gint samples;
   gpointer src, dst;
@@ -1079,7 +1081,7 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
       GST_BUFFER_CAPS (outbuf));
 
   /* get amount of samples to convert. */
-  samples = GST_BUFFER_SIZE (inbuf) / this->ctx.in.unit_size;
+  samples = gst_buffer_get_size (inbuf) / this->ctx.in.unit_size;
 
   /* get in/output sizes, to see if the buffers we got are of correct
    * sizes */
@@ -1089,16 +1091,16 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
   if (insize == 0 || outsize == 0)
     return GST_FLOW_OK;
 
+  /* get src and dst data */
+  src = gst_buffer_map (inbuf, &srcsize, NULL, GST_MAP_READ);
+  dst = gst_buffer_map (outbuf, &dstsize, NULL, GST_MAP_WRITE);
+
   /* check in and outsize */
-  if (GST_BUFFER_SIZE (inbuf) < insize)
+  if (srcsize < insize)
     goto wrong_size;
-  if (GST_BUFFER_SIZE (outbuf) < outsize)
+  if (dstsize < outsize)
     goto wrong_size;
 
-  /* get src and dst data */
-  src = GST_BUFFER_DATA (inbuf);
-  dst = GST_BUFFER_DATA (outbuf);
-
   /* and convert the samples */
   if (!GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
     if (!audio_convert_convert (&this->ctx, src, dst,
@@ -1108,10 +1110,13 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
     /* Create silence buffer */
     gst_audio_convert_create_silence_buffer (this, dst, outsize);
   }
+  ret = GST_FLOW_OK;
 
-  GST_BUFFER_SIZE (outbuf) = outsize;
+done:
+  gst_buffer_unmap (outbuf, dst, outsize);
+  gst_buffer_unmap (inbuf, src, srcsize);
 
-  return GST_FLOW_OK;
+  return ret;
 
   /* ERRORS */
 error:
@@ -1125,15 +1130,16 @@ wrong_size:
     GST_ELEMENT_ERROR (this, STREAM, FORMAT,
         (NULL),
         ("input/output buffers are of wrong size in: %d < %d or out: %d < %d",
-            GST_BUFFER_SIZE (inbuf), insize, GST_BUFFER_SIZE (outbuf),
-            outsize));
-    return GST_FLOW_ERROR;
+            srcsize, insize, dstsize, outsize));
+    ret = GST_FLOW_ERROR;
+    goto done;
   }
 convert_error:
   {
     GST_ELEMENT_ERROR (this, STREAM, FORMAT,
         (NULL), ("error while converting"));
-    return GST_FLOW_ERROR;
+    ret = GST_FLOW_ERROR;
+    goto done;
   }
 }
 
index 40d3467..5737e01 100644 (file)
@@ -589,7 +589,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
     in_time = audiorate->next_ts;
   }
 
-  in_size = GST_BUFFER_SIZE (buf);
+  in_size = gst_buffer_get_size (buf);
   in_samples = in_size / audiorate->bytes_per_sample;
 
   /* calculate the buffer offset */
@@ -633,13 +633,17 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
 
     while (fillsamples > 0) {
       guint64 cursamples = MIN (fillsamples, audiorate->rate);
+      guint8 *data;
 
       fillsamples -= cursamples;
       fillsize = cursamples * audiorate->bytes_per_sample;
 
       fill = gst_buffer_new_and_alloc (fillsize);
+
+      data = gst_buffer_map (fill, NULL, NULL, GST_MAP_WRITE);
       /* FIXME, 0 might not be the silence byte for the negotiated format. */
-      memset (GST_BUFFER_DATA (fill), 0, fillsize);
+      memset (data, 0, fillsize);
+      gst_buffer_unmap (fill, data, fillsize);
 
       GST_DEBUG_OBJECT (audiorate, "inserting %" G_GUINT64_FORMAT " samples",
           cursamples);
@@ -705,7 +709,9 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
       truncsize = truncsamples * audiorate->bytes_per_sample;
       leftsize = in_size - truncsize;
 
-      trunc = gst_buffer_create_sub (buf, truncsize, leftsize);
+      trunc =
+          gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, truncsize,
+          leftsize);
 
       gst_buffer_unref (buf);
       buf = trunc;
@@ -722,7 +728,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
   }
 
 send:
-  if (GST_BUFFER_SIZE (buf) == 0)
+  if (gst_buffer_get_size (buf) == 0)
     goto beach;
 
   /* Now calculate parameters for whichever buffer (either the original
@@ -738,14 +744,14 @@ send:
   if (audiorate->discont) {
     /* we need to output a discont buffer, do so now */
     GST_DEBUG_OBJECT (audiorate, "marking DISCONT on output buffer");
-    buf = gst_buffer_make_metadata_writable (buf);
+    buf = gst_buffer_make_writable (buf);
     GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
     audiorate->discont = FALSE;
   } else if (GST_BUFFER_IS_DISCONT (buf)) {
     /* else we make everything continuous so we can safely remove the DISCONT
      * flag from the buffer if there was one */
     GST_DEBUG_OBJECT (audiorate, "removing DISCONT from buffer");
-    buf = gst_buffer_make_metadata_writable (buf);
+    buf = gst_buffer_make_writable (buf);
     GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_DISCONT);
   }
 
index 8f9ea3b..0d23b5d 100644 (file)
@@ -127,14 +127,14 @@ static void gst_audio_resample_get_property (GObject * object,
 
 /* vmethods */
 static gboolean gst_audio_resample_get_unit_size (GstBaseTransform * base,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 static GstCaps *gst_audio_resample_transform_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps);
 static void gst_audio_resample_fixate_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
 static gboolean gst_audio_resample_transform_size (GstBaseTransform * trans,
-    GstPadDirection direction, GstCaps * incaps, guint insize,
-    GstCaps * outcaps, guint * outsize);
+    GstPadDirection direction, GstCaps * incaps, gsize insize,
+    GstCaps * outcaps, gsize * outsize);
 static gboolean gst_audio_resample_set_caps (GstBaseTransform * base,
     GstCaps * incaps, GstCaps * outcaps);
 static GstFlowReturn gst_audio_resample_transform (GstBaseTransform * base,
@@ -282,7 +282,7 @@ gst_audio_resample_stop (GstBaseTransform * base)
 
 static gboolean
 gst_audio_resample_get_unit_size (GstBaseTransform * base, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   gint width, channels;
   GstStructure *structure;
@@ -530,8 +530,8 @@ _gcd (gint a, gint b)
 
 static gboolean
 gst_audio_resample_transform_size (GstBaseTransform * base,
-    GstPadDirection direction, GstCaps * caps, guint size, GstCaps * othercaps,
-    guint * othersize)
+    GstPadDirection direction, GstCaps * caps, gsize size, GstCaps * othercaps,
+    gsize * othersize)
 {
   gboolean ret = TRUE;
   guint32 ratio_den, ratio_num;
@@ -824,6 +824,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
   guint out_len, out_processed;
   gint err;
   guint num, den;
+  guint8 *data;
 
   g_assert (resample->state != NULL);
 
@@ -851,6 +852,8 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
     return;
   }
 
+  data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+
   if (resample->funcs->width != resample->width) {
     /* need to convert data format;  allocate workspace */
     if (!gst_audio_resample_workspace_realloc (&resample->tmp_out,
@@ -866,17 +869,20 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
 
     /* convert output format */
     gst_audio_resample_convert_buffer (resample, resample->tmp_out,
-        GST_BUFFER_DATA (outbuf), out_processed, TRUE);
+        data, out_processed, TRUE);
   } else {
     /* don't need to convert data format;  process */
     err = resample->funcs->process (resample->state, NULL, &in_processed,
-        GST_BUFFER_DATA (outbuf), &out_processed);
+        data, &out_processed);
   }
 
   /* If we wrote more than allocated something is really wrong now
    * and we should better abort immediately */
   g_assert (out_len >= out_processed);
 
+  outsize = out_processed * resample->channels * (resample->width / 8);
+  gst_buffer_unmap (outbuf, data, outsize);
+
   if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
     GST_WARNING_OBJECT (resample, "Failed to process drain: %s",
         resample->funcs->strerror (err));
@@ -914,13 +920,10 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
     return;
   }
 
-  GST_BUFFER_SIZE (outbuf) =
-      out_processed * resample->channels * (resample->width / 8);
-
   GST_LOG_OBJECT (resample,
       "Pushing drain buffer of %u bytes with timestamp %" GST_TIME_FORMAT
       " duration %" GST_TIME_FORMAT " offset %" G_GUINT64_FORMAT " offset_end %"
-      G_GUINT64_FORMAT, GST_BUFFER_SIZE (outbuf),
+      G_GUINT64_FORMAT, outsize,
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
       GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)), GST_BUFFER_OFFSET (outbuf),
       GST_BUFFER_OFFSET_END (outbuf));
@@ -1025,12 +1028,17 @@ static GstFlowReturn
 gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
     GstBuffer * outbuf)
 {
+  gsize in_size, out_size;
+  guint8 *in_data, *out_data;
   guint32 in_len, in_processed;
   guint32 out_len, out_processed;
   guint filt_len = resample->funcs->get_filt_len (resample->state);
 
-  in_len = GST_BUFFER_SIZE (inbuf) / resample->channels;
-  out_len = GST_BUFFER_SIZE (outbuf) / resample->channels;
+  in_data = gst_buffer_map (inbuf, &in_size, NULL, GST_MAP_READ);
+  out_data = gst_buffer_map (outbuf, &out_size, NULL, GST_MAP_WRITE);
+
+  in_len = in_size / resample->channels;
+  out_len = out_size / resample->channels;
 
   in_len /= (resample->width / 8);
   out_len /= (resample->width / 8);
@@ -1062,7 +1070,7 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
       else
         out_processed = 0;
 
-      memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
+      memset (out_data, 0, out_size);
       GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
       resample->num_gap_samples += in_len;
       in_processed = in_len;
@@ -1095,11 +1103,13 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
               &resample->tmp_out_size, out_len * resample->channels *
               (resample->funcs->width / 8))) {
         GST_ERROR_OBJECT (resample, "failed to allocate workspace");
+        gst_buffer_unmap (inbuf, in_data, in_size);
+        gst_buffer_unmap (outbuf, out_data, out_size);
         return GST_FLOW_ERROR;
       }
 
       /* convert input */
-      gst_audio_resample_convert_buffer (resample, GST_BUFFER_DATA (inbuf),
+      gst_audio_resample_convert_buffer (resample, in_data,
           resample->tmp_in, in_len, FALSE);
 
       /* process */
@@ -1108,17 +1118,18 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
 
       /* convert output */
       gst_audio_resample_convert_buffer (resample, resample->tmp_out,
-          GST_BUFFER_DATA (outbuf), out_processed, TRUE);
+          out_data, out_processed, TRUE);
     } else {
       /* no format conversion required;  process */
       err = resample->funcs->process (resample->state,
-          GST_BUFFER_DATA (inbuf), &in_processed,
-          GST_BUFFER_DATA (outbuf), &out_processed);
+          in_data, &in_processed, out_data, &out_processed);
     }
 
     if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
       GST_ERROR_OBJECT (resample, "Failed to convert data: %s",
           resample->funcs->strerror (err));
+      gst_buffer_unmap (inbuf, in_data, in_size);
+      gst_buffer_unmap (outbuf, out_data, out_size);
       return GST_FLOW_ERROR;
     }
   }
@@ -1156,14 +1167,15 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
   resample->samples_out += out_processed;
   resample->samples_in += in_len;
 
-  GST_BUFFER_SIZE (outbuf) =
-      out_processed * resample->channels * (resample->width / 8);
+  out_size = out_processed * resample->channels * (resample->width / 8);
+  gst_buffer_unmap (inbuf, in_data, in_size);
+  gst_buffer_unmap (outbuf, out_data, out_size);
 
   GST_LOG_OBJECT (resample,
       "Converted to buffer of %" G_GUINT32_FORMAT
       " samples (%u bytes) with timestamp %" GST_TIME_FORMAT ", duration %"
       GST_TIME_FORMAT ", offset %" G_GUINT64_FORMAT ", offset_end %"
-      G_GUINT64_FORMAT, out_processed, GST_BUFFER_SIZE (outbuf),
+      G_GUINT64_FORMAT, out_processed, out_size,
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
       GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)),
       GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
@@ -1180,7 +1192,6 @@ gst_audio_resample_transform (GstBaseTransform * base, GstBuffer * inbuf,
     GstBuffer * outbuf)
 {
   GstAudioResample *resample = GST_AUDIO_RESAMPLE (base);
-  gulong size;
   GstFlowReturn ret;
 
   if (resample->state == NULL) {
@@ -1194,12 +1205,10 @@ gst_audio_resample_transform (GstBaseTransform * base, GstBuffer * inbuf,
         gst_audio_resample_get_funcs (resample->width, resample->fp);
   }
 
-  size = GST_BUFFER_SIZE (inbuf);
-
   GST_LOG_OBJECT (resample, "transforming buffer of %ld bytes, ts %"
       GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT ", offset %"
       G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
-      size, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
+      gst_buffer_get_size (inbuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
       GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)),
       GST_BUFFER_OFFSET (inbuf), GST_BUFFER_OFFSET_END (inbuf));
 
index ecbb2fb..dc008f6 100644 (file)
@@ -1034,6 +1034,7 @@ gst_audio_test_src_create (GstBaseSrc * basesrc, guint64 offset,
   gint64 next_sample, next_byte;
   gint bytes, samples;
   GstElementClass *eclass;
+  guint8 *data;
 
   src = GST_AUDIO_TEST_SRC (basesrc);
 
@@ -1130,7 +1131,9 @@ gst_audio_test_src_create (GstBaseSrc * basesrc, guint64 offset,
       src->generate_samples_per_buffer,
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
 
-  src->process (src, GST_BUFFER_DATA (buf));
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+  src->process (src, data);
+  gst_buffer_unmap (buf, data, bytes);
 
   if (G_UNLIKELY ((src->wave == GST_AUDIO_TEST_SRC_WAVE_SILENCE)
           || (src->volume == 0.0))) {
index 4aeb09b..7b0f1b4 100644 (file)
@@ -301,7 +301,7 @@ gst_encode_bin_class_init (GstEncodeBinClass * klass)
    * to %GST_STATE_PAUSED or higher.
    */
   g_object_class_install_property (gobject_klass, PROP_PROFILE,
-      gst_param_spec_mini_object ("profile", "Profile",
+      g_param_spec_object ("profile", "Profile",
           "The GstEncodingProfile to use", GST_TYPE_ENCODING_PROFILE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
@@ -456,7 +456,7 @@ gst_encode_bin_set_property (GObject * object, guint prop_id,
   switch (prop_id) {
     case PROP_PROFILE:
       gst_encode_bin_set_profile (ebin,
-          (GstEncodingProfile *) gst_value_get_mini_object (value));
+          (GstEncodingProfile *) g_value_get_object (value));
       break;
     case PROP_QUEUE_BUFFERS_MAX:
       ebin->queue_buffers_max = g_value_get_uint (value);
@@ -487,7 +487,7 @@ gst_encode_bin_get_property (GObject * object, guint prop_id,
 
   switch (prop_id) {
     case PROP_PROFILE:
-      gst_value_set_mini_object (value, (GstMiniObject *) ebin->profile);
+      g_value_set_object (value, (GObject *) ebin->profile);
       break;
     case PROP_QUEUE_BUFFERS_MAX:
       g_value_set_uint (value, ebin->queue_buffers_max);
index 318a90e..2e73027 100644 (file)
@@ -43,7 +43,6 @@ gst_ff_vid_caps_new (AVCodecContext * context,
 /*
  * Read a palette from a caps.
  */
-
      static void
          gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
 {
@@ -52,15 +51,15 @@ gst_ff_vid_caps_new (AVCodecContext * context,
 
   /* do we have a palette? */
   if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
-    const GstBuffer *palette;
+    GstBuffer *palette;
 
     palette = gst_value_get_buffer (palette_v);
-    if (palette && GST_BUFFER_SIZE (palette) >= 256 * 4) {
+    if (palette && gst_buffer_get_size (palette) >= 256 * 4) {
       if (context->palctrl)
         av_free (context->palctrl);
       context->palctrl = av_malloc (sizeof (AVPaletteControl));
       context->palctrl->palette_changed = 1;
-      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
+      gst_buffer_extract (palette, 0, context->palctrl->palette,
           AVPALETTE_SIZE);
     }
   }
@@ -71,9 +70,13 @@ gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
 {
   if (context->palctrl) {
     GstBuffer *palette = gst_buffer_new_and_alloc (256 * 4);
+    guint8 *data;
+    gsize size;
+
+    data = gst_buffer_map (palette, &size, NULL, GST_MAP_WRITE);
+    memcpy (data, context->palctrl->palette, AVPALETTE_SIZE);
+    gst_buffer_unmap (palette, data, size);
 
-    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
-        AVPALETTE_SIZE);
     gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
     gst_buffer_unref (palette);
   }
index 4ba0204..ef7ad3d 100644 (file)
@@ -87,7 +87,7 @@ GType gst_ffmpegcsp_get_type (void);
 static gboolean gst_ffmpegcsp_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps);
 static gboolean gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 static GstFlowReturn gst_ffmpegcsp_transform (GstBaseTransform * btrans,
     GstBuffer * inbuf, GstBuffer * outbuf);
 
@@ -396,7 +396,7 @@ gst_ffmpegcsp_init (GstFFMpegCsp * space, GstFFMpegCspClass * klass)
 
 static gboolean
 gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   GstStructure *structure = NULL;
   AVCodecContext *ctx = NULL;
@@ -448,6 +448,8 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
 {
   GstFFMpegCsp *space;
   gint result;
+  guint8 *indata, *outdata;
+  gsize insize, outsize;
 
   space = GST_FFMPEGCSP (btrans);
 
@@ -458,8 +460,9 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
     goto unknown_format;
 
   /* fill from with source data */
+  indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
   gst_ffmpegcsp_avpicture_fill (&space->from_frame,
-      GST_BUFFER_DATA (inbuf), space->from_pixfmt, space->width, space->height,
+      indata, space->from_pixfmt, space->width, space->height,
       space->interlaced);
 
   /* fill optional palette */
@@ -467,13 +470,17 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
     space->from_frame.data[1] = (uint8_t *) space->palette->palette;
 
   /* fill target frame */
+  outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
   gst_ffmpegcsp_avpicture_fill (&space->to_frame,
-      GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height,
+      outdata, space->to_pixfmt, space->width, space->height,
       space->interlaced);
 
   /* and convert */
   result = img_convert (&space->to_frame, space->to_pixfmt,
       &space->from_frame, space->from_pixfmt, space->width, space->height);
+  gst_buffer_unmap (outbuf, outdata, outsize);
+  gst_buffer_unmap (inbuf, indata, insize);
+
   if (result == -1)
     goto not_supported;
 
index 702e63f..28a8564 100644 (file)
@@ -285,17 +285,23 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
           goto wrong_type;
         }
 
-        if (this->payload_length
-            && (!gst_dp_validate_payload (GST_DP_HEADER_LENGTH, this->header,
-                    gst_adapter_peek (this->adapter, this->payload_length)))) {
-          goto payload_validate_error;
+        if (this->payload_length) {
+          const guint8 *data;
+          gboolean res;
+
+          data = gst_adapter_map (this->adapter, this->payload_length);
+          res = gst_dp_validate_payload (GST_DP_HEADER_LENGTH, this->header,
+              data);
+          gst_adapter_unmap (this->adapter, 0);
+
+          if (!res)
+            goto payload_validate_error;
         }
 
         break;
       }
       case GST_GDP_DEPAY_STATE_BUFFER:
       {
-
         /* if we receive a buffer without caps first, we error out */
         if (!this->caps)
           goto no_caps;
@@ -309,9 +315,11 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
         if (this->payload_length > 0) {
           guint8 *payload;
 
-          payload = gst_adapter_take (this->adapter, this->payload_length);
-          memcpy (GST_BUFFER_DATA (buf), payload, this->payload_length);
-          g_free (payload);
+          payload = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+          gst_adapter_copy (this->adapter, payload, 0, this->payload_length);
+          gst_buffer_unmap (buf, payload, this->payload_length);
+
+          gst_adapter_flush (this->adapter, this->payload_length);
         }
 
         /* set caps and push */
@@ -319,12 +327,12 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
         GST_LOG_OBJECT (this, "deserialized buffer %p, pushing, timestamp %"
             GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
             ", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT
-            ", size %d, flags 0x%x",
+            ", size %" G_GSIZE_FORMAT ", flags 0x%x",
             buf,
             GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
             GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
             GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
-            GST_BUFFER_SIZE (buf), GST_BUFFER_FLAGS (buf));
+            gst_buffer_get_size (buf), GST_BUFFER_FLAGS (buf));
         ret = gst_pad_push (this->srcpad, buf);
         if (ret != GST_FLOW_OK)
           goto push_error;
index 6da4967..994f56f 100644 (file)
@@ -77,9 +77,7 @@ GST_BOILERPLATE_FULL (GstGDPPay, gst_gdp_pay, GstElement,
 static void gst_gdp_pay_reset (GstGDPPay * this);
 
 static GstFlowReturn gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer);
-
 static gboolean gst_gdp_pay_src_event (GstPad * pad, GstEvent * event);
-
 static gboolean gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event);
 
 static GstStateChangeReturn gst_gdp_pay_change_state (GstElement *
@@ -112,7 +110,6 @@ static void
 gst_gdp_pay_class_init (GstGDPPayClass * klass)
 {
   GObjectClass *gobject_class;
-
   GstElementClass *gstelement_class;
 
   gobject_class = (GObjectClass *) klass;
@@ -216,7 +213,7 @@ static void
 gst_gdp_stamp_buffer (GstGDPPay * this, GstBuffer * buffer)
 {
   GST_BUFFER_OFFSET (buffer) = this->offset;
-  GST_BUFFER_OFFSET_END (buffer) = this->offset + GST_BUFFER_SIZE (buffer);
+  GST_BUFFER_OFFSET_END (buffer) = this->offset + gst_buffer_get_size (buffer);
   this->offset = GST_BUFFER_OFFSET_END (buffer);
 }
 
@@ -224,12 +221,9 @@ static GstBuffer *
 gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
 {
   GstBuffer *headerbuf;
-
   GstBuffer *payloadbuf;
-
   guint8 *header, *payload;
-
-  guint len;
+  guint len, plen;
 
   if (!this->packetizer->packet_from_caps (caps, this->header_flag, &len,
           &header, &payload))
@@ -237,13 +231,13 @@ gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
 
   GST_LOG_OBJECT (this, "creating GDP header and payload buffer from caps");
   headerbuf = gst_buffer_new ();
-  gst_buffer_set_data (headerbuf, header, len);
-  GST_BUFFER_MALLOCDATA (headerbuf) = header;
+  gst_buffer_take_memory (headerbuf,
+      gst_memory_new_wrapped (0, header, g_free, len, 0, len));
 
   payloadbuf = gst_buffer_new ();
-  gst_buffer_set_data (payloadbuf, payload,
-      gst_dp_header_payload_length (header));
-  GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
+  plen = gst_dp_header_payload_length (header);
+  gst_buffer_take_memory (payloadbuf,
+      gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
 
   return gst_buffer_join (headerbuf, payloadbuf);
 
@@ -259,9 +253,7 @@ static GstBuffer *
 gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
 {
   GstBuffer *headerbuf;
-
   guint8 *header;
-
   guint len;
 
   if (!this->packetizer->header_from_buffer (buffer, this->header_flag, &len,
@@ -270,8 +262,8 @@ gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
 
   GST_LOG_OBJECT (this, "creating GDP header and payload buffer from buffer");
   headerbuf = gst_buffer_new ();
-  gst_buffer_set_data (headerbuf, header, len);
-  GST_BUFFER_MALLOCDATA (headerbuf) = header;
+  gst_buffer_take_memory (headerbuf,
+      gst_memory_new_wrapped (0, header, g_free, len, 0, len));
 
   /* we do not want to lose the ref on the incoming buffer */
   gst_buffer_ref (buffer);
@@ -290,13 +282,9 @@ static GstBuffer *
 gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
 {
   GstBuffer *headerbuf;
-
   GstBuffer *payloadbuf;
-
   guint8 *header, *payload;
-
-  guint len;
-
+  guint len, plen;
   gboolean ret;
 
   ret =
@@ -307,13 +295,15 @@ gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
 
   GST_LOG_OBJECT (this, "creating GDP header and payload buffer from event");
   headerbuf = gst_buffer_new ();
-  gst_buffer_set_data (headerbuf, header, len);
-  GST_BUFFER_MALLOCDATA (headerbuf) = header;
+  gst_buffer_take_memory (headerbuf,
+      gst_memory_new_wrapped (0, header, g_free, len, 0, len));
 
   payloadbuf = gst_buffer_new ();
-  gst_buffer_set_data (payloadbuf, payload,
-      gst_dp_header_payload_length (header));
-  GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
+  plen = gst_dp_header_payload_length (header);
+  if (plen && payload != NULL) {
+    gst_buffer_take_memory (payloadbuf,
+        gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
+  }
 
   return gst_buffer_join (headerbuf, payloadbuf);
 
@@ -333,14 +323,10 @@ static GstFlowReturn
 gst_gdp_pay_reset_streamheader (GstGDPPay * this)
 {
   GstCaps *caps;
-
   /* We use copies of these to avoid circular refcounts */
   GstBuffer *new_segment_buf, *caps_buf, *tag_buf;
-
   GstStructure *structure;
-
   GstFlowReturn r = GST_FLOW_OK;
-
   gboolean version_one_zero = TRUE;
 
   GValue array = { 0 };
@@ -474,10 +460,9 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
 
   GST_DEBUG_OBJECT (this, "Setting caps on src pad %" GST_PTR_FORMAT, caps);
   gst_pad_set_caps (this->srcpad, caps);
-  this->caps_buf = gst_buffer_make_metadata_writable (this->caps_buf);
+  this->caps_buf = gst_buffer_make_writable (this->caps_buf);
   gst_buffer_set_caps (this->caps_buf, caps);
-  this->new_segment_buf =
-      gst_buffer_make_metadata_writable (this->new_segment_buf);
+  this->new_segment_buf = gst_buffer_make_writable (this->new_segment_buf);
   gst_buffer_set_caps (this->new_segment_buf, caps);
 
   /* if these are our first ever buffers, send out new_segment first */
@@ -579,11 +564,8 @@ static GstFlowReturn
 gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstGDPPay *this;
-
   GstCaps *caps;
-
   GstBuffer *outbuffer;
-
   GstFlowReturn ret;
 
   this = GST_GDP_PAY (gst_pad_get_parent (pad));
@@ -698,11 +680,8 @@ static gboolean
 gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event)
 {
   GstBuffer *outbuffer;
-
   GstGDPPay *this = GST_GDP_PAY (gst_pad_get_parent (pad));
-
   GstFlowReturn flowret;
-
   gboolean ret = TRUE;
 
   GST_DEBUG_OBJECT (this, "received event %p of type %s (%d)",
@@ -784,7 +763,6 @@ static gboolean
 gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
 {
   GstGDPPay *this;
-
   gboolean res = TRUE;
 
   this = GST_GDP_PAY (gst_pad_get_parent (pad));
@@ -865,7 +843,6 @@ static GstStateChangeReturn
 gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
 {
   GstStateChangeReturn ret;
-
   GstGDPPay *this = GST_GDP_PAY (element);
 
   switch (transition) {
index 31b5ebb..346b892 100644 (file)
@@ -3401,8 +3401,7 @@ gst_decode_pad_init (GstDecodePad * pad)
   pad->blocked = FALSE;
   pad->exposed = FALSE;
   pad->drained = FALSE;
-  gst_object_ref (pad);
-  gst_object_sink (pad);
+  gst_object_ref_sink (pad);
 }
 
 static void
index 57b5dbe..ac26013 100644 (file)
@@ -408,7 +408,7 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
           0.0, VOLUME_MAX_DOUBLE, 1.0,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_klass, ARG_FRAME,
-      gst_param_spec_mini_object ("frame", "Frame",
+      g_param_spec_boxed ("frame", "Frame",
           "The last frame (NULL = no video available)", GST_TYPE_BUFFER,
           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_klass, ARG_FONT_DESC,
@@ -638,8 +638,7 @@ gst_play_bin_set_property (GObject * object, guint prop_id,
       }
       play_bin->video_sink = g_value_get_object (value);
       if (play_bin->video_sink != NULL) {
-        gst_object_ref (play_bin->video_sink);
-        gst_object_sink (GST_OBJECT_CAST (play_bin->video_sink));
+        gst_object_ref_sink (play_bin->video_sink);
       }
       /* when changing the videosink, we just remove the
        * video pipeline from the cache so that it will be
@@ -656,8 +655,7 @@ gst_play_bin_set_property (GObject * object, guint prop_id,
       }
       play_bin->audio_sink = g_value_get_object (value);
       if (play_bin->audio_sink != NULL) {
-        gst_object_ref (play_bin->audio_sink);
-        gst_object_sink (GST_OBJECT_CAST (play_bin->audio_sink));
+        gst_object_ref_sink (play_bin->audio_sink);
       }
       g_hash_table_remove (play_bin->cache, "abin");
       break;
@@ -668,8 +666,7 @@ gst_play_bin_set_property (GObject * object, guint prop_id,
 
       /* Take ownership */
       if (pending_visualisation) {
-        gst_object_ref (pending_visualisation);
-        gst_object_sink (pending_visualisation);
+        gst_object_ref_sink (pending_visualisation);
       }
 
       /* Do we already have a visualisation change pending ? */
index 5f0f964..2b3e981 100644 (file)
@@ -754,7 +754,7 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
    * The #GstCaps on the buffer will describe the format of the buffer.
    */
   g_object_class_install_property (gobject_klass, PROP_FRAME,
-      gst_param_spec_mini_object ("frame", "Frame",
+      g_param_spec_boxed ("frame", "Frame",
           "The last frame (NULL = no video available)",
           GST_TYPE_BUFFER, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_klass, PROP_FONT_DESC,
index 326baa6..832e33a 100644 (file)
@@ -365,7 +365,7 @@ gst_play_sink_class_init (GstPlaySinkClass * klass)
    * Since: 0.10.30
    */
   g_object_class_install_property (gobject_klass, PROP_FRAME,
-      gst_param_spec_mini_object ("frame", "Frame",
+      g_param_spec_boxed ("frame", "Frame",
           "The last frame (NULL = no video available)",
           GST_TYPE_BUFFER, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
   /**
index 9a48ab0..3745efb 100644 (file)
@@ -592,7 +592,7 @@ gst_stream_synchronizer_sink_chain (GstPad * pad, GstBuffer * buffer)
   GST_LOG_OBJECT (pad, "Handling buffer %p: size=%u, timestamp=%"
       GST_TIME_FORMAT " duration=%" GST_TIME_FORMAT
       " offset=%" G_GUINT64_FORMAT " offset_end=%" G_GUINT64_FORMAT,
-      buffer, GST_BUFFER_SIZE (buffer),
+      buffer, gst_buffer_get_size (buffer),
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
       GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)),
       GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET_END (buffer));
@@ -607,7 +607,7 @@ gst_stream_synchronizer_sink_chain (GstPad * pad, GstBuffer * buffer)
 
   stream->seen_data = TRUE;
   if (stream && stream->drop_discont) {
-    buffer = gst_buffer_make_metadata_writable (buffer);
+    buffer = gst_buffer_make_writable (buffer);
     GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DISCONT);
     stream->drop_discont = FALSE;
   }
index 5aa68e3..73289a6 100644 (file)
@@ -138,8 +138,8 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
   GstStructure *s;
   const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
   GstBuffer *priv;
-  gchar *data;
-  guint size;
+  gchar *data, *ptr;
+  gsize size, left;
 
   s = gst_caps_get_structure (caps, 0);
   val = gst_structure_get_value (s, "codec_data");
@@ -152,17 +152,20 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
   parse->framed = TRUE;
   parse->send_tags = TRUE;
 
-  priv = (GstBuffer *) gst_value_get_mini_object (val);
+  priv = (GstBuffer *) g_value_get_boxed (val);
   g_return_val_if_fail (priv != NULL, FALSE);
 
   gst_buffer_ref (priv);
 
-  data = (gchar *) GST_BUFFER_DATA (priv);
-  size = GST_BUFFER_SIZE (priv);
+  data = gst_buffer_map (priv, &size, NULL, GST_MAP_READ);
+
+  ptr = data;
+  left = size;
+
   /* skip UTF-8 BOM */
-  if (size >= 3 && memcmp (data, bom_utf8, 3) == 0) {
-    data += 3;
-    size -= 3;
+  if (left >= 3 && memcmp (ptr, bom_utf8, 3) == 0) {
+    ptr += 3;
+    left -= 3;
   }
 
   if (!strstr (data, "[Script Info]")) {
@@ -171,16 +174,17 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
     return FALSE;
   }
 
-  if (!g_utf8_validate (data, size, NULL)) {
+  if (!g_utf8_validate (ptr, left, NULL)) {
     GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8");
     gst_buffer_unref (priv);
     return FALSE;
   }
 
   /* FIXME: parse initial section */
-  parse->ini = g_strndup (data, size);
+  parse->ini = g_strndup (ptr, left);
   GST_LOG_OBJECT (parse, "Init section:\n%s", parse->ini);
 
+  gst_buffer_unmap (priv, data, size);
   gst_buffer_unref (priv);
 
   return TRUE;
@@ -269,8 +273,8 @@ gst_ssa_parse_push_line (GstSsaParse * parse, gchar * txt,
 
   /* allocate enough for a terminating NUL, but don't include it in buf size */
   buf = gst_buffer_new_and_alloc (len + 1);
-  memcpy (GST_BUFFER_DATA (buf), escaped, len + 1);
-  GST_BUFFER_SIZE (buf) = len;
+  gst_buffer_fill (buf, 0, escaped, len + 1);
+  gst_buffer_set_size (buf, len);
   g_free (escaped);
 
   GST_BUFFER_TIMESTAMP (buf) = start;
@@ -299,6 +303,8 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf)
   GstSsaParse *parse = GST_SSA_PARSE (GST_PAD_PARENT (sinkpad));
   GstClockTime ts;
   gchar *txt;
+  gchar *data;
+  gsize size;
 
   if (G_UNLIKELY (!parse->framed))
     goto not_framed;
@@ -314,7 +320,10 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf)
   }
 
   /* make double-sure it's 0-terminated and all */
-  txt = g_strndup ((gchar *) GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  txt = g_strndup (data, size);
+  gst_buffer_unmap (buf, data, size);
+
   if (txt == NULL)
     goto empty_text;
 
index 7bf0f2d..b2533c6 100644 (file)
@@ -1418,6 +1418,8 @@ feed_textbuf (GstSubParse * self, GstBuffer * buf)
   gboolean discont;
   gsize consumed;
   gchar *input = NULL;
+  const guint8 *data;
+  gsize avail;
 
   discont = GST_BUFFER_IS_DISCONT (buf);
 
@@ -1442,19 +1444,20 @@ feed_textbuf (GstSubParse * self, GstBuffer * buf)
      * subtitles which are discontinuous by nature. */
   }
 
-  self->offset = GST_BUFFER_OFFSET (buf) + GST_BUFFER_SIZE (buf);
+  self->offset = GST_BUFFER_OFFSET (buf) + gst_buffer_get_size (buf);
   self->next_offset = self->offset;
 
   gst_adapter_push (self->adapter, buf);
 
-  input =
-      convert_encoding (self, (const gchar *) gst_adapter_peek (self->adapter,
-          gst_adapter_available (self->adapter)),
-      (gsize) gst_adapter_available (self->adapter), &consumed);
+  avail = gst_adapter_available (self->adapter);
+  data = gst_adapter_map (self->adapter, avail),
+      input = convert_encoding (self, (const gchar *) data, avail, &consumed);
 
   if (input && consumed > 0) {
     self->textbuf = g_string_append (self->textbuf, input);
-    gst_adapter_flush (self->adapter, consumed);
+    gst_adapter_unmap (self->adapter, consumed);
+  } else {
+    gst_adapter_unmap (self->adapter, 0);
   }
 
   g_free (input);
@@ -1465,12 +1468,13 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
 {
   GstFlowReturn ret = GST_FLOW_OK;
   GstCaps *caps = NULL;
-  gchar *line, *subtitle;
+  gchar *line, *subtitle, *data;
+  gsize size;
 
   if (self->first_buffer) {
-    self->detected_encoding =
-        detect_encoding ((gchar *) GST_BUFFER_DATA (buf),
-        GST_BUFFER_SIZE (buf));
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    self->detected_encoding = detect_encoding (data, size);
+    gst_buffer_unmap (buf, data, size);
     self->first_buffer = FALSE;
     self->state.fps_n = self->fps_n;
     self->state.fps_d = self->fps_d;
@@ -1520,8 +1524,9 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
 
       if (ret == GST_FLOW_OK) {
         /* copy terminating NUL character as well */
-        memcpy (GST_BUFFER_DATA (buf), subtitle, subtitle_len + 1);
-        GST_BUFFER_SIZE (buf) = subtitle_len;
+        gst_buffer_fill (buf, 0, subtitle, subtitle_len + 1);
+        gst_buffer_set_size (buf, subtitle_len);
+
         GST_BUFFER_TIMESTAMP (buf) = self->state.start_time;
         GST_BUFFER_DURATION (buf) = self->state.duration;
 
@@ -1602,13 +1607,13 @@ gst_sub_parse_sink_event (GstPad * pad, GstEvent * event)
           self->parser_type == GST_SUB_PARSE_FORMAT_TMPLAYER ||
           self->parser_type == GST_SUB_PARSE_FORMAT_MPL2 ||
           self->parser_type == GST_SUB_PARSE_FORMAT_QTTEXT) {
+        gchar term_chars[] = { '\n', '\n', '\0' };
         GstBuffer *buf = gst_buffer_new_and_alloc (2 + 1);
 
         GST_DEBUG ("EOS. Pushing remaining text (if any)");
-        GST_BUFFER_DATA (buf)[0] = '\n';
-        GST_BUFFER_DATA (buf)[1] = '\n';
-        GST_BUFFER_DATA (buf)[2] = '\0';        /* play it safe */
-        GST_BUFFER_SIZE (buf) = 2;
+        gst_buffer_fill (buf, 0, term_chars, 3);
+        gst_buffer_set_size (buf, 2);
+
         GST_BUFFER_OFFSET (buf) = self->offset;
         gst_sub_parse_chain (pad, buf);
       }
index 98c62d7..51c36e4 100644 (file)
@@ -153,7 +153,6 @@ enum
 
 
 /* this is really arbitrarily chosen */
-#define DEFAULT_PROTOCOL                GST_TCP_PROTOCOL_NONE
 #define DEFAULT_MODE                    1
 #define DEFAULT_BUFFERS_MAX             -1
 #define DEFAULT_BUFFERS_SOFT_MAX        -1
@@ -178,7 +177,6 @@ enum
 enum
 {
   PROP_0,
-  PROP_PROTOCOL,
   PROP_MODE,
   PROP_BUFFERS_QUEUED,
   PROP_BYTES_QUEUED,
@@ -380,12 +378,6 @@ gst_multi_fd_sink_class_init (GstMultiFdSinkClass * klass)
   gobject_class->get_property = gst_multi_fd_sink_get_property;
   gobject_class->finalize = gst_multi_fd_sink_finalize;
 
-  g_object_class_install_property (gobject_class, PROP_PROTOCOL,
-      g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in"
-          ". GDP protocol here is deprecated. Please use gdppay element.",
-          GST_TYPE_TCP_PROTOCOL, DEFAULT_PROTOCOL,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
   /**
    * GstMultiFdSink::mode
    *
@@ -691,7 +683,6 @@ gst_multi_fd_sink_init (GstMultiFdSink * this, GstMultiFdSinkClass * klass)
 {
   GST_OBJECT_FLAG_UNSET (this, GST_MULTI_FD_SINK_OPEN);
 
-  this->protocol = DEFAULT_PROTOCOL;
   this->mode = DEFAULT_MODE;
 
   CLIENTS_LOCK_INIT (this);
@@ -1294,60 +1285,6 @@ ioctl_failed:
   }
 }
 
-/* Queue raw data for this client, creating a new buffer.
- * This takes ownership of the data by
- * setting it as GST_BUFFER_MALLOCDATA() on the created buffer so
- * be sure to pass g_free()-able @data.
- */
-static gboolean
-gst_multi_fd_sink_client_queue_data (GstMultiFdSink * sink,
-    GstTCPClient * client, gchar * data, gint len)
-{
-  GstBuffer *buf;
-
-  buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (guint8 *) data;
-  GST_BUFFER_MALLOCDATA (buf) = (guint8 *) data;
-  GST_BUFFER_SIZE (buf) = len;
-
-  GST_LOG_OBJECT (sink, "[fd %5d] queueing data of length %d",
-      client->fd.fd, len);
-
-  client->sending = g_slist_append (client->sending, buf);
-
-  return TRUE;
-}
-
-/* GDP-encode given caps and queue them for sending */
-static gboolean
-gst_multi_fd_sink_client_queue_caps (GstMultiFdSink * sink,
-    GstTCPClient * client, const GstCaps * caps)
-{
-  guint8 *header;
-  guint8 *payload;
-  guint length;
-  gchar *string;
-
-  g_return_val_if_fail (caps != NULL, FALSE);
-
-  string = gst_caps_to_string (caps);
-  GST_DEBUG_OBJECT (sink, "[fd %5d] Queueing caps %s through GDP",
-      client->fd.fd, string);
-  g_free (string);
-
-  if (!gst_dp_packet_from_caps (caps, sink->header_flags, &length, &header,
-          &payload)) {
-    GST_DEBUG_OBJECT (sink, "Could not create GDP packet from caps");
-    return FALSE;
-  }
-  gst_multi_fd_sink_client_queue_data (sink, client, (gchar *) header, length);
-
-  length = gst_dp_header_payload_length (header);
-  gst_multi_fd_sink_client_queue_data (sink, client, (gchar *) payload, length);
-
-  return TRUE;
-}
-
 static gboolean
 is_sync_frame (GstMultiFdSink * sink, GstBuffer * buffer)
 {
@@ -1457,24 +1394,9 @@ gst_multi_fd_sink_client_queue_buffer (GstMultiFdSink * sink,
         buffer = g_value_peek_pointer (bufval);
         GST_DEBUG_OBJECT (sink,
             "[fd %5d] queueing streamheader buffer of length %d",
-            client->fd.fd, GST_BUFFER_SIZE (buffer));
+            client->fd.fd, gst_buffer_get_size (buffer));
         gst_buffer_ref (buffer);
 
-        if (sink->protocol == GST_TCP_PROTOCOL_GDP) {
-          guint8 *header;
-          guint len;
-
-          if (!gst_dp_header_from_buffer (buffer, sink->header_flags, &len,
-                  &header)) {
-            GST_DEBUG_OBJECT (sink,
-                "[fd %5d] could not create header, removing client",
-                client->fd.fd);
-            return FALSE;
-          }
-          gst_multi_fd_sink_client_queue_data (sink, client, (gchar *) header,
-              len);
-        }
-
         client->sending = g_slist_append (client->sending, buffer);
       }
     }
@@ -1482,21 +1404,9 @@ gst_multi_fd_sink_client_queue_buffer (GstMultiFdSink * sink,
 
   gst_caps_unref (caps);
   caps = NULL;
-  /* now we can send the buffer, possibly sending a GDP header first */
-  if (sink->protocol == GST_TCP_PROTOCOL_GDP) {
-    guint8 *header;
-    guint len;
-
-    if (!gst_dp_header_from_buffer (buffer, sink->header_flags, &len, &header)) {
-      GST_DEBUG_OBJECT (sink,
-          "[fd %5d] could not create header, removing client", client->fd.fd);
-      return FALSE;
-    }
-    gst_multi_fd_sink_client_queue_data (sink, client, (gchar *) header, len);
-  }
 
   GST_LOG_OBJECT (sink, "[fd %5d] queueing buffer of length %d",
-      client->fd.fd, GST_BUFFER_SIZE (buffer));
+      client->fd.fd, gst_buffer_get_size (buffer));
 
   gst_buffer_ref (buffer);
   client->sending = g_slist_append (client->sending, buffer);
@@ -1583,7 +1493,7 @@ get_buffers_max (GstMultiFdSink * sink, gint64 max)
 
       for (i = 0; i < len; i++) {
         buf = g_array_index (sink->bufqueue, GstBuffer *, i);
-        acc += GST_BUFFER_SIZE (buf);
+        acc += gst_buffer_get_size (buf);
 
         if (acc > max)
           return i + 1;
@@ -1666,7 +1576,7 @@ find_limits (GstMultiFdSink * sink,
     }
     buf = g_array_index (sink->bufqueue, GstBuffer *, i);
 
-    bytes += GST_BUFFER_SIZE (buf);
+    bytes += gst_buffer_get_size (buf);
 
     /* take timestamp and save for the base first timestamp */
     if ((time = GST_BUFFER_TIMESTAMP (buf)) != -1) {
@@ -1992,7 +1902,6 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
 {
   int fd = client->fd.fd;
   gboolean more;
-  gboolean res;
   gboolean flushing;
   GstClockTime now;
   GTimeVal nowtv;
@@ -2002,39 +1911,6 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
 
   flushing = client->status == GST_CLIENT_STATUS_FLUSHING;
 
-  /* when using GDP, first check if we have queued caps yet */
-  if (sink->protocol == GST_TCP_PROTOCOL_GDP) {
-    /* don't need to do anything when the client is flushing */
-    if (!client->caps_sent && !flushing) {
-      GstPad *peer;
-      GstCaps *caps;
-
-      peer = gst_pad_get_peer (GST_BASE_SINK_PAD (sink));
-      if (!peer) {
-        GST_WARNING_OBJECT (sink, "pad has no peer");
-        return FALSE;
-      }
-      gst_object_unref (peer);
-
-      caps = gst_pad_get_negotiated_caps (GST_BASE_SINK_PAD (sink));
-      if (!caps) {
-        GST_WARNING_OBJECT (sink, "pad caps not yet negotiated");
-        return FALSE;
-      }
-
-      /* queue caps for sending */
-      res = gst_multi_fd_sink_client_queue_caps (sink, client, caps);
-
-      gst_caps_unref (caps);
-
-      if (!res) {
-        GST_DEBUG_OBJECT (sink, "Failed queueing caps, removing client");
-        return FALSE;
-      }
-      client->caps_sent = TRUE;
-    }
-  }
-
   more = TRUE;
   do {
     gint maxsize;
@@ -2105,10 +1981,14 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
     if (client->sending) {
       ssize_t wrote;
       GstBuffer *head;
+      guint8 *data;
+      gsize size;
 
       /* pick first buffer from list */
       head = GST_BUFFER (client->sending->data);
-      maxsize = GST_BUFFER_SIZE (head) - client->bufoffset;
+
+      data = gst_buffer_map (head, &size, NULL, GST_MAP_READ);
+      maxsize = size - client->bufoffset;
 
       /* try to write the complete buffer */
 #ifdef MSG_NOSIGNAL
@@ -2117,12 +1997,11 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
 #define FLAGS 0
 #endif
       if (client->is_socket) {
-        wrote =
-            send (fd, GST_BUFFER_DATA (head) + client->bufoffset, maxsize,
-            FLAGS);
+        wrote = send (fd, data + client->bufoffset, maxsize, FLAGS);
       } else {
-        wrote = write (fd, GST_BUFFER_DATA (head) + client->bufoffset, maxsize);
+        wrote = write (fd, data + client->bufoffset, maxsize);
       }
+      gst_buffer_unmap (head, data, size);
 
       if (wrote < 0) {
         /* hmm error.. */
@@ -2624,14 +2503,14 @@ gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
 
   /* stamp the buffer with previous caps if no caps set */
   if (!bufcaps) {
-    if (!gst_buffer_is_metadata_writable (buf)) {
+    if (!gst_buffer_is_writable (buf)) {
       /* metadata is not writable, copy will be made and original buffer
        * will be unreffed so we need to ref so that we don't lose the
        * buffer in the render method. */
       gst_buffer_ref (buf);
       /* the new buffer is ours only, we keep it out of the scope of this
        * function */
-      buf = gst_buffer_make_metadata_writable (buf);
+      buf = gst_buffer_make_writable (buf);
     } else {
       /* else the metadata is writable, we ref because we keep the buffer
        * out of the scope of this method */
@@ -2679,13 +2558,13 @@ gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
   if (in_caps) {
     GST_DEBUG_OBJECT (sink,
         "appending IN_CAPS buffer with length %d to streamheader",
-        GST_BUFFER_SIZE (buf));
+        gst_buffer_get_size (buf));
     sink->streamheader = g_slist_append (sink->streamheader, buf);
   } else {
     /* queue the buffer, this is a regular data buffer. */
     gst_multi_fd_sink_queue_buffer (sink, buf);
 
-    sink->bytes_to_serve += GST_BUFFER_SIZE (buf);
+    sink->bytes_to_serve += gst_buffer_get_size (buf);
   }
   return GST_FLOW_OK;
 
@@ -2707,9 +2586,6 @@ gst_multi_fd_sink_set_property (GObject * object, guint prop_id,
   multifdsink = GST_MULTI_FD_SINK (object);
 
   switch (prop_id) {
-    case PROP_PROTOCOL:
-      multifdsink->protocol = g_value_get_enum (value);
-      break;
     case PROP_MODE:
       multifdsink->mode = g_value_get_enum (value);
       break;
@@ -2778,9 +2654,6 @@ gst_multi_fd_sink_get_property (GObject * object, guint prop_id, GValue * value,
   multifdsink = GST_MULTI_FD_SINK (object);
 
   switch (prop_id) {
-    case PROP_PROTOCOL:
-      g_value_set_enum (value, multifdsink->protocol);
-      break;
     case PROP_MODE:
       g_value_set_enum (value, multifdsink->mode);
       break;
index 0ee7888..b0465af 100644 (file)
@@ -153,8 +153,6 @@ typedef struct {
 
   gboolean discont;
 
-  GstTCPProtocol protocol;
-
   gboolean caps_sent;
   gboolean new_connection;
 
@@ -208,7 +206,6 @@ struct _GstMultiFdSink {
   GSList *streamheader; /* GSList of GstBuffers to use as streamheader */
   gboolean previous_buffer_in_caps;
 
-  GstTCPProtocol protocol;
   guint mtu;
   gint qos_dscp;
   gboolean handle_read;
index 894fcb8..471b217 100644 (file)
@@ -228,6 +228,7 @@ gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
   int ret;
   ssize_t bytes_read;
   int readsize;
+  guint8 *data;
 
   *buf = NULL;
 
@@ -251,7 +252,9 @@ gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
 
   *buf = gst_buffer_new_and_alloc (readsize);
 
-  bytes_read = read (socket, GST_BUFFER_DATA (*buf), readsize);
+  data = gst_buffer_map (*buf, NULL, NULL, GST_MAP_WRITE);
+  bytes_read = read (socket, data, readsize);
+  gst_buffer_unmap (*buf, data, bytes_read);
 
   if (bytes_read < 0)
     goto read_error;
@@ -260,7 +263,7 @@ gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
     /* but mom, you promised to give me readsize bytes! */
     goto short_read;
 
-  GST_LOG_OBJECT (this, "returning buffer of size %d", GST_BUFFER_SIZE (*buf));
+  GST_LOG_OBJECT (this, "returning buffer of size %d", bytes_read);
   return GST_FLOW_OK;
 
   /* ERRORS */
@@ -317,6 +320,8 @@ gst_tcp_gdp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
 {
   GstFlowReturn ret;
   guint8 *header = NULL;
+  guint8 *data;
+  gsize size;
 
   GST_LOG_OBJECT (this, "Reading %d bytes for buffer packet header",
       GST_DP_HEADER_LENGTH);
@@ -341,8 +346,9 @@ gst_tcp_gdp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
 
   g_free (header);
 
-  ret = gst_tcp_socket_read (this, socket, GST_BUFFER_DATA (*buf),
-      GST_BUFFER_SIZE (*buf), fdset);
+  data = gst_buffer_map (*buf, &size, NULL, GST_MAP_WRITE);
+  ret = gst_tcp_socket_read (this, socket, data, size, fdset);
+  gst_buffer_unmap (*buf, data, size);
 
   if (ret != GST_FLOW_OK)
     goto data_read_error;
@@ -466,104 +472,3 @@ payload_validate_error:
     return GST_FLOW_ERROR;
   }
 }
-
-/* write a GDP header to the socket.  Return false if fails. */
-gboolean
-gst_tcp_gdp_write_buffer (GstElement * this, int socket, GstBuffer * buffer,
-    gboolean fatal, const gchar * host, int port)
-{
-  guint length;
-  guint8 *header;
-  size_t wrote;
-
-  if (!gst_dp_header_from_buffer (buffer, 0, &length, &header))
-    goto create_error;
-
-  GST_LOG_OBJECT (this, "writing %d bytes for GDP buffer header", length);
-  wrote = gst_tcp_socket_write (socket, header, length);
-  g_free (header);
-
-  if (wrote != length)
-    goto write_error;
-
-  return TRUE;
-
-  /* ERRORS */
-create_error:
-  {
-    if (fatal)
-      GST_ELEMENT_ERROR (this, CORE, TOO_LAZY, (NULL),
-          ("Could not create GDP header from buffer"));
-    return FALSE;
-  }
-write_error:
-  {
-    if (fatal)
-      GST_ELEMENT_ERROR (this, RESOURCE, WRITE,
-          (_("Error while sending data to \"%s:%d\"."), host, port),
-          ("Only %" G_GSIZE_FORMAT " of %u bytes written: %s",
-              wrote, GST_BUFFER_SIZE (buffer), g_strerror (errno)));
-    return FALSE;
-  }
-}
-
-/* write GDP header and payload to the given socket for the given caps.
- * Return false if fails. */
-gboolean
-gst_tcp_gdp_write_caps (GstElement * this, int socket, const GstCaps * caps,
-    gboolean fatal, const char *host, int port)
-{
-  guint length;
-  guint8 *header;
-  guint8 *payload;
-  size_t wrote;
-
-  if (!gst_dp_packet_from_caps (caps, 0, &length, &header, &payload))
-    goto create_error;
-
-  GST_LOG_OBJECT (this, "writing %d bytes for GDP caps header", length);
-  wrote = gst_tcp_socket_write (socket, header, length);
-  if (wrote != length)
-    goto write_header_error;
-
-  length = gst_dp_header_payload_length (header);
-  g_free (header);
-
-  GST_LOG_OBJECT (this, "writing %d bytes for GDP caps payload", length);
-  wrote = gst_tcp_socket_write (socket, payload, length);
-  g_free (payload);
-
-  if (wrote != length)
-    goto write_payload_error;
-
-  return TRUE;
-
-  /* ERRORS */
-create_error:
-  {
-    if (fatal)
-      GST_ELEMENT_ERROR (this, CORE, TOO_LAZY, (NULL),
-          ("Could not create GDP packet from caps"));
-    return FALSE;
-  }
-write_header_error:
-  {
-    g_free (header);
-    g_free (payload);
-    if (fatal)
-      GST_ELEMENT_ERROR (this, RESOURCE, WRITE,
-          (_("Error while sending gdp header data to \"%s:%d\"."), host, port),
-          ("Only %" G_GSIZE_FORMAT " of %u bytes written: %s",
-              wrote, length, g_strerror (errno)));
-    return FALSE;
-  }
-write_payload_error:
-  {
-    if (fatal)
-      GST_ELEMENT_ERROR (this, RESOURCE, WRITE,
-          (_("Error while sending gdp payload data to \"%s:%d\"."), host, port),
-          ("Only %" G_GSIZE_FORMAT " of %u bytes written: %s",
-              wrote, length, g_strerror (errno)));
-    return FALSE;
-  }
-}
index 533c162..64299ef 100644 (file)
 
 G_BEGIN_DECLS
 
-/**
- * GstTCPProtocol:
- * @GST_TCP_PROTOCOL_NONE: Raw data transmission
- * @GST_TCP_PROTOCOL_GDP: #GstBuffers are wrapped and sent/received using the
- *      GDP protocol.
- *
- * This enum is provided by the tcp/multifd elements to configure the format of
- * data transmission/reception.
- *
- * The GDP protocol wraps data buffers in a header that also carries format
- * information and timestamps. The None value indicates the data is
- * sent/received as-is. In that case, format information and timestamping
- * must be transmitted separately, or implicit in the bytestream itself.
- */
-typedef enum
-{
-  GST_TCP_PROTOCOL_NONE,
-  GST_TCP_PROTOCOL_GDP
-} GstTCPProtocol;
-
 gchar * gst_tcp_host_to_ip (GstElement *element, const gchar *host);
 
 gint gst_tcp_socket_write (int socket, const void *buf, size_t count);
@@ -65,12 +45,6 @@ GstFlowReturn gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdse
 GstFlowReturn gst_tcp_gdp_read_buffer (GstElement * this, int socket, GstPoll * fdset, GstBuffer **buf);
 GstFlowReturn gst_tcp_gdp_read_caps (GstElement * this, int socket, GstPoll * fdset, GstCaps **caps);
 
-GstEvent * gst_tcp_gdp_read_event (GstElement *elem, int socket, GstPoll * fdset);
-
-gboolean gst_tcp_gdp_write_buffer (GstElement *elem, int socket, GstBuffer *buffer, gboolean fatal, const gchar *host, int port);
-gboolean gst_tcp_gdp_write_event (GstElement *elem, int socket, GstEvent *event, gboolean fatal, const gchar *host, int port);
-gboolean gst_tcp_gdp_write_caps (GstElement *elem, int socket, const GstCaps *caps, gboolean fatal, const gchar *host, int port);
-
 G_END_DECLS
 
 #endif /* __GST_TCP_HELP_H__ */
index ca60578..fd9ce6b 100644 (file)
@@ -57,9 +57,7 @@ enum
 {
   ARG_0,
   ARG_HOST,
-  ARG_PORT,
-  ARG_PROTOCOL
-      /* FILL ME */
+  ARG_PORT
 };
 
 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
@@ -154,10 +152,6 @@ gst_tcp_client_sink_class_init (GstTCPClientSink * klass)
       g_param_spec_int ("port", "Port", "The port to send the packets to",
           0, TCP_HIGHEST_PORT, TCP_DEFAULT_PORT,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, ARG_PROTOCOL,
-      g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
-          GST_TYPE_TCP_PROTOCOL, GST_TCP_PROTOCOL_NONE,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   gstelement_class->change_state = gst_tcp_client_sink_change_state;
 
@@ -174,7 +168,6 @@ gst_tcp_client_sink_init (GstTCPClientSink * this)
   this->port = TCP_DEFAULT_PORT;
 
   this->sock_fd.fd = -1;
-  this->protocol = GST_TCP_PROTOCOL_NONE;
   GST_OBJECT_FLAG_UNSET (this, GST_TCP_CLIENT_SINK_OPEN);
 }
 
@@ -195,41 +188,7 @@ gst_tcp_client_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
 
   sink = GST_TCP_CLIENT_SINK (bsink);
 
-  /* write the buffer header if we have one */
-  switch (sink->protocol) {
-    case GST_TCP_PROTOCOL_NONE:
-      break;
-
-    case GST_TCP_PROTOCOL_GDP:
-      /* if we haven't send caps yet, send them first */
-      if (!sink->caps_sent) {
-        const GstCaps *caps;
-        gchar *string;
-
-        caps = GST_PAD_CAPS (GST_PAD_PEER (GST_BASE_SINK_PAD (bsink)));
-        string = gst_caps_to_string (caps);
-        GST_DEBUG_OBJECT (sink, "Sending caps %s through GDP", string);
-        g_free (string);
-
-        if (!gst_tcp_gdp_write_caps (GST_ELEMENT (sink), sink->sock_fd.fd,
-                caps, TRUE, sink->host, sink->port))
-          goto gdp_write_error;
-
-        sink->caps_sent = TRUE;
-      }
-      break;
-    default:
-      g_warning ("Unhandled protocol type");
-      break;
-  }
-
   return TRUE;
-
-  /* ERRORS */
-gdp_write_error:
-  {
-    return FALSE;
-  }
 }
 
 static GstFlowReturn
@@ -237,33 +196,21 @@ gst_tcp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
 {
   size_t wrote = 0;
   GstTCPClientSink *sink;
-  gint size;
+  guint8 *data;
+  gsize size;
 
   sink = GST_TCP_CLIENT_SINK (bsink);
 
   g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_TCP_CLIENT_SINK_OPEN),
       GST_FLOW_WRONG_STATE);
 
-  size = GST_BUFFER_SIZE (buf);
-
-  GST_LOG_OBJECT (sink, "writing %d bytes for buffer data", size);
-
-  /* write the buffer header if we have one */
-  switch (sink->protocol) {
-    case GST_TCP_PROTOCOL_NONE:
-      break;
-    case GST_TCP_PROTOCOL_GDP:
-      GST_LOG_OBJECT (sink, "Sending buffer header through GDP");
-      if (!gst_tcp_gdp_write_buffer (GST_ELEMENT (sink), sink->sock_fd.fd, buf,
-              TRUE, sink->host, sink->port))
-        goto gdp_write_error;
-      break;
-    default:
-      break;
-  }
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  GST_LOG_OBJECT (sink, "writing %" G_GSIZE_FORMAT " bytes for buffer data",
+      size);
 
   /* write buffer data */
-  wrote = gst_tcp_socket_write (sink->sock_fd.fd, GST_BUFFER_DATA (buf), size);
+  wrote = gst_tcp_socket_write (sink->sock_fd.fd, data, size);
+  gst_buffer_unmap (buf, data, size);
 
   if (wrote < size)
     goto write_error;
@@ -273,16 +220,12 @@ gst_tcp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
   return GST_FLOW_OK;
 
   /* ERRORS */
-gdp_write_error:
-  {
-    return FALSE;
-  }
 write_error:
   {
     GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
         (_("Error while sending data to \"%s:%d\"."), sink->host, sink->port),
-        ("Only %" G_GSIZE_FORMAT " of %u bytes written: %s",
-            wrote, GST_BUFFER_SIZE (buf), g_strerror (errno)));
+        ("Only %" G_GSIZE_FORMAT " of %" G_GSIZE_FORMAT " bytes written: %s",
+            wrote, size, g_strerror (errno)));
     return GST_FLOW_ERROR;
   }
 }
@@ -308,9 +251,6 @@ gst_tcp_client_sink_set_property (GObject * object, guint prop_id,
     case ARG_PORT:
       tcpclientsink->port = g_value_get_int (value);
       break;
-    case ARG_PROTOCOL:
-      tcpclientsink->protocol = g_value_get_enum (value);
-      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -334,9 +274,6 @@ gst_tcp_client_sink_get_property (GObject * object, guint prop_id,
     case ARG_PORT:
       g_value_set_int (value, tcpclientsink->port);
       break;
-    case ARG_PROTOCOL:
-      g_value_set_enum (value, tcpclientsink->protocol);
-      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
index 4399870..09556ff 100644 (file)
@@ -76,7 +76,6 @@ struct _GstTCPClientSink {
   GstPollFD sock_fd;
 
   size_t data_written; /* how much bytes have we written ? */
-  GstTCPProtocol protocol; /* used with the protocol enum */
   gboolean caps_sent; /* whether or not we sent caps already */
 };
 
index b8ac849..1ecc39c 100644 (file)
@@ -62,8 +62,7 @@ enum
 {
   PROP_0,
   PROP_HOST,
-  PROP_PORT,
-  PROP_PROTOCOL
+  PROP_PORT
 };
 
 
@@ -125,10 +124,6 @@ gst_tcp_client_src_class_init (GstTCPClientSrcClass * klass)
       g_param_spec_int ("port", "Port", "The port to receive packets from", 0,
           TCP_HIGHEST_PORT, TCP_DEFAULT_PORT,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, PROP_PROTOCOL,
-      g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
-          GST_TYPE_TCP_PROTOCOL, GST_TCP_PROTOCOL_NONE,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   gstbasesrc_class->get_caps = gst_tcp_client_src_getcaps;
   gstbasesrc_class->start = gst_tcp_client_src_start;
@@ -148,7 +143,6 @@ gst_tcp_client_src_init (GstTCPClientSrc * this, GstTCPClientSrcClass * g_class)
   this->port = TCP_DEFAULT_PORT;
   this->host = g_strdup (TCP_DEFAULT_HOST);
   this->sock_fd.fd = -1;
-  this->protocol = GST_TCP_PROTOCOL_NONE;
   this->caps = NULL;
 
   GST_OBJECT_FLAG_UNSET (this, GST_TCP_CLIENT_SRC_OPEN);
@@ -196,44 +190,16 @@ gst_tcp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
 
   GST_LOG_OBJECT (src, "asked for a buffer");
 
-  /* read the buffer header if we're using a protocol */
-  switch (src->protocol) {
-    case GST_TCP_PROTOCOL_NONE:
-      ret = gst_tcp_read_buffer (GST_ELEMENT (src), src->sock_fd.fd,
-          src->fdset, outbuf);
-      break;
-
-    case GST_TCP_PROTOCOL_GDP:
-      /* get the caps if we're using GDP */
-      if (!src->caps_received) {
-        GstCaps *caps;
-
-        GST_DEBUG_OBJECT (src, "getting caps through GDP");
-        ret = gst_tcp_gdp_read_caps (GST_ELEMENT (src), src->sock_fd.fd,
-            src->fdset, &caps);
-
-        if (ret != GST_FLOW_OK)
-          goto no_caps;
-
-        src->caps_received = TRUE;
-        src->caps = caps;
-      }
-
-      ret = gst_tcp_gdp_read_buffer (GST_ELEMENT (src), src->sock_fd.fd,
-          src->fdset, outbuf);
-      break;
-    default:
-      /* need to assert as buf == NULL */
-      g_assert ("Unhandled protocol type");
-      break;
-  }
+  /* read the buffer header */
+  ret = gst_tcp_read_buffer (GST_ELEMENT (src), src->sock_fd.fd,
+      src->fdset, outbuf);
 
   if (ret == GST_FLOW_OK) {
     GST_LOG_OBJECT (src,
         "Returning buffer from _get of size %d, ts %"
         GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT
         ", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
-        GST_BUFFER_SIZE (*outbuf),
+        gst_buffer_get_size (*outbuf),
         GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)),
         GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)),
         GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
@@ -248,12 +214,6 @@ wrong_state:
     GST_DEBUG_OBJECT (src, "connection to closed, cannot read data");
     return GST_FLOW_WRONG_STATE;
   }
-no_caps:
-  {
-    GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
-        ("Could not read caps through GDP"));
-    return ret;
-  }
 }
 
 static void
@@ -274,9 +234,6 @@ gst_tcp_client_src_set_property (GObject * object, guint prop_id,
     case PROP_PORT:
       tcpclientsrc->port = g_value_get_int (value);
       break;
-    case PROP_PROTOCOL:
-      tcpclientsrc->protocol = g_value_get_enum (value);
-      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -297,9 +254,6 @@ gst_tcp_client_src_get_property (GObject * object, guint prop_id,
     case PROP_PORT:
       g_value_set_int (value, tcpclientsrc->port);
       break;
-    case PROP_PROTOCOL:
-      g_value_set_enum (value, tcpclientsrc->protocol);
-      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
index 24d31e8..77d5702 100644 (file)
@@ -67,7 +67,6 @@ struct _GstTCPClientSrc {
   GstPollFD sock_fd;
   GstPoll *fdset;
 
-  GstTCPProtocol protocol; /* protocol used for reading data */
   gboolean caps_received;      /* if we have received caps yet */
   GstCaps *caps;
 };
index c4244da..6d1895d 100644 (file)
@@ -63,8 +63,7 @@ enum
 {
   PROP_0,
   PROP_HOST,
-  PROP_PORT,
-  PROP_PROTOCOL
+  PROP_PORT
 };
 
 
@@ -122,10 +121,6 @@ gst_tcp_server_src_class_init (GstTCPServerSrcClass * klass)
       g_param_spec_int ("port", "Port", "The port to listen to",
           0, TCP_HIGHEST_PORT, TCP_DEFAULT_PORT,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  g_object_class_install_property (gobject_class, PROP_PROTOCOL,
-      g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
-          GST_TYPE_TCP_PROTOCOL, GST_TCP_PROTOCOL_NONE,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   gstbasesrc_class->start = gst_tcp_server_src_start;
   gstbasesrc_class->stop = gst_tcp_server_src_stop;
@@ -144,7 +139,6 @@ gst_tcp_server_src_init (GstTCPServerSrc * src, GstTCPServerSrcClass * g_class)
   src->host = g_strdup (TCP_DEFAULT_HOST);
   src->server_sock_fd.fd = -1;
   src->client_sock_fd.fd = -1;
-  src->protocol = GST_TCP_PROTOCOL_NONE;
 
   GST_OBJECT_FLAG_UNSET (src, GST_TCP_SERVER_SRC_OPEN);
 }
@@ -205,54 +199,15 @@ restart:
 
   GST_LOG_OBJECT (src, "asked for a buffer");
 
-  switch (src->protocol) {
-    case GST_TCP_PROTOCOL_NONE:
-      ret = gst_tcp_read_buffer (GST_ELEMENT (src), src->client_sock_fd.fd,
-          src->fdset, outbuf);
-      break;
-
-    case GST_TCP_PROTOCOL_GDP:
-      if (!src->caps_received) {
-        GstCaps *caps;
-        gchar *string;
-
-        ret = gst_tcp_gdp_read_caps (GST_ELEMENT (src), src->client_sock_fd.fd,
-            src->fdset, &caps);
-
-        if (ret == GST_FLOW_WRONG_STATE)
-          goto gdp_cancelled;
-
-        if (ret != GST_FLOW_OK)
-          goto gdp_caps_read_error;
-
-        src->caps_received = TRUE;
-        string = gst_caps_to_string (caps);
-        GST_DEBUG_OBJECT (src, "Received caps through GDP: %s", string);
-        g_free (string);
-
-        gst_pad_set_caps (GST_BASE_SRC_PAD (psrc), caps);
-      }
-
-      ret = gst_tcp_gdp_read_buffer (GST_ELEMENT (src), src->client_sock_fd.fd,
-          src->fdset, outbuf);
-
-      if (ret == GST_FLOW_OK)
-        gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (src)));
-
-      break;
-
-    default:
-      /* need to assert as buf == NULL */
-      g_assert ("Unhandled protocol type");
-      break;
-  }
+  ret = gst_tcp_read_buffer (GST_ELEMENT (src), src->client_sock_fd.fd,
+      src->fdset, outbuf);
 
   if (ret == GST_FLOW_OK) {
     GST_LOG_OBJECT (src,
         "Returning buffer from _get of size %d, ts %"
         GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT
         ", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
-        GST_BUFFER_SIZE (*outbuf),
+        gst_buffer_get_size (*outbuf),
         GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)),
         GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)),
         GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
@@ -282,20 +237,6 @@ accept_error:
         ("Could not accept client on server socket: %s", g_strerror (errno)));
     return GST_FLOW_ERROR;
   }
-gdp_cancelled:
-  {
-    GST_DEBUG_OBJECT (src, "reading gdp canceled");
-    return GST_FLOW_WRONG_STATE;
-  }
-gdp_caps_read_error:
-  {
-    /* if we did not get canceled, report an error */
-    if (ret != GST_FLOW_WRONG_STATE) {
-      GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
-          ("Could not read caps through GDP"));
-    }
-    return ret;
-  }
 }
 
 static void
@@ -316,9 +257,6 @@ gst_tcp_server_src_set_property (GObject * object, guint prop_id,
     case PROP_PORT:
       tcpserversrc->server_port = g_value_get_int (value);
       break;
-    case PROP_PROTOCOL:
-      tcpserversrc->protocol = g_value_get_enum (value);
-      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -339,9 +277,6 @@ gst_tcp_server_src_get_property (GObject * object, guint prop_id,
     case PROP_PORT:
       g_value_set_int (value, tcpserversrc->server_port);
       break;
-    case PROP_PROTOCOL:
-      g_value_set_enum (value, tcpserversrc->protocol);
-      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
index 22c7afe..f5e80e2 100644 (file)
@@ -74,7 +74,6 @@ struct _GstTCPServerSrc {
 
   GstPoll *fdset;
 
-  GstTCPProtocol protocol; /* protocol used for reading data */
   gboolean caps_received;      /* if we have received caps yet */
 };
 
index 98dbade..1000a52 100644 (file)
@@ -130,7 +130,7 @@ static gboolean
 utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset,
     GstTypeFindProbability * prob)
 {
-  guint8 *data;
+  const guint8 *data;
 
   /* randomly decided values */
   guint min_size = 16;          /* minimum size  */
@@ -222,7 +222,7 @@ static GstStaticCaps uri_caps = GST_STATIC_CAPS ("text/uri-list");
 static void
 uri_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE);
+  const guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE);
   guint pos = 0;
   guint offset = 0;
 
@@ -322,7 +322,7 @@ xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen,
     gboolean strict)
 {
   gboolean got_xmldec;
-  guint8 *data;
+  const guint8 *data;
   guint offset = 0;
   guint pos = 0;
 
@@ -386,7 +386,7 @@ static GstStaticCaps sdp_caps = GST_STATIC_CAPS ("application/sdp");
 static gboolean
 sdp_check_header (GstTypeFind * tf)
 {
-  guint8 *data;
+  const guint8 *data;
 
   data = gst_type_find_peek (tf, 0, 5);
   if (!data)
@@ -433,9 +433,9 @@ static GstStaticCaps html_caps = GST_STATIC_CAPS ("text/html");
 static void
 html_type_find (GstTypeFind * tf, gpointer unused)
 {
-  gchar *d, *data;
+  const gchar *d, *data;
 
-  data = (gchar *) gst_type_find_peek (tf, 0, 16);
+  data = (const gchar *) gst_type_find_peek (tf, 0, 16);
   if (!data)
     return;
 
@@ -444,7 +444,7 @@ html_type_find (GstTypeFind * tf, gpointer unused)
   } else if (xml_check_first_element (tf, "html", 4, FALSE)) {
     gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS);
   } else if ((d = memchr (data, '<', 16))) {
-    data = (gchar *) gst_type_find_peek (tf, d - data, 6);
+    data = (const gchar *) gst_type_find_peek (tf, d - data, 6);
     if (data && g_ascii_strncasecmp (data, "<html>", 6) == 0) {
       gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS);
     }
@@ -459,7 +459,7 @@ static GstStaticCaps mid_caps = GST_STATIC_CAPS ("audio/midi");
 static void
 mid_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   /* http://jedi.ks.uiuc.edu/~johns/links/music/midifile.html */
   if (data && data[0] == 'M' && data[1] == 'T' && data[2] == 'h'
@@ -475,7 +475,7 @@ static GstStaticCaps mxmf_caps = GST_STATIC_CAPS ("audio/mobile-xmf");
 static void
 mxmf_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = NULL;
+  const guint8 *data = NULL;
 
   /* Search FileId "XMF_" 4 bytes */
   data = gst_type_find_peek (tf, 0, 4);
@@ -503,7 +503,7 @@ static GstStaticCaps flx_caps = GST_STATIC_CAPS ("video/x-fli");
 static void
 flx_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 134);
+  const guint8 *data = gst_type_find_peek (tf, 0, 134);
 
   if (data) {
     /* check magic and the frame type of the first frame */
@@ -534,7 +534,7 @@ static GstStaticCaps id3_caps = GST_STATIC_CAPS ("application/x-id3");
 static void
 id3v2_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 10);
+  const guint8 *data = gst_type_find_peek (tf, 0, 10);
 
   if (data && memcmp (data, "ID3", 3) == 0 &&
       data[3] != 0xFF && data[4] != 0xFF &&
@@ -547,7 +547,7 @@ id3v2_type_find (GstTypeFind * tf, gpointer unused)
 static void
 id3v1_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, -128, 3);
+  const guint8 *data = gst_type_find_peek (tf, -128, 3);
 
   if (data && memcmp (data, "TAG", 3) == 0) {
     gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, ID3_CAPS);
@@ -562,7 +562,7 @@ static GstStaticCaps apetag_caps = GST_STATIC_CAPS ("application/x-apetag");
 static void
 apetag_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data;
+  const guint8 *data;
 
   /* APEv1/2 at start of file */
   data = gst_type_find_peek (tf, 0, 8);
@@ -587,7 +587,7 @@ static GstStaticCaps tta_caps = GST_STATIC_CAPS ("audio/x-ttafile");
 static void
 tta_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 3);
+  const guint8 *data = gst_type_find_peek (tf, 0, 3);
 
   if (data) {
     if (memcmp (data, "TTA", 3) == 0) {
@@ -985,8 +985,8 @@ static void
 mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
     guint * found_layer, GstTypeFindProbability * found_prob)
 {
-  guint8 *data = NULL;
-  guint8 *data_end = NULL;
+  const guint8 *data = NULL;
+  const guint8 *data_end = NULL;
   guint size;
   guint64 skipped;
   gint last_free_offset = -1;
@@ -1010,7 +1010,7 @@ mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
       data_end = data + size;
     }
     if (*data == 0xFF) {
-      guint8 *head_data = NULL;
+      const guint8 *head_data = NULL;
       guint layer = 0, bitrate, samplerate, channels;
       guint found = 0;          /* number of valid headers found */
       guint64 offset = skipped;
@@ -1123,7 +1123,7 @@ static void
 mp3_type_find (GstTypeFind * tf, gpointer unused)
 {
   GstTypeFindProbability prob, mid_prob;
-  guint8 *data;
+  const guint8 *data;
   guint layer, mid_layer;
   guint64 length;
 
@@ -1193,7 +1193,7 @@ GST_STATIC_CAPS ("audio/x-musepack, streamversion= (int) { 7, 8 }");
 static void
 musepack_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
   GstTypeFindProbability prop = GST_TYPE_FIND_MINIMUM;
   gint streamversion = -1;
 
@@ -1515,7 +1515,7 @@ wavpack_type_find (GstTypeFind * tf, gpointer unused)
 {
   guint64 offset;
   guint32 blocksize;
-  guint8 *data;
+  const guint8 *data;
 
   data = gst_type_find_peek (tf, 0, 32);
   if (!data)
@@ -1578,7 +1578,7 @@ GST_STATIC_CAPS ("application/postscript");
 static void
 postscript_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 3);
+  const guint8 *data = gst_type_find_peek (tf, 0, 3);
   if (!data)
     return;
 
@@ -1628,8 +1628,8 @@ GST_STATIC_CAPS ("multipart/x-mixed-replace");
 static void
 multipart_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data;
-  guint8 *x;
+  const guint8 *data;
+  const guint8 *x;
 
 #define MULTIPART_MAX_BOUNDARY_OFFSET 16
   data = gst_type_find_peek (tf, 0, MULTIPART_MAX_BOUNDARY_OFFSET);
@@ -1738,7 +1738,7 @@ mpeg_sys_is_valid_pack (GstTypeFind * tf, const guint8 * data, guint len,
 }
 
 static gboolean
-mpeg_sys_is_valid_pes (GstTypeFind * tf, guint8 * data, guint len,
+mpeg_sys_is_valid_pes (GstTypeFind * tf, const guint8 * data, guint len,
     guint * pack_size)
 {
   guint pes_packet_len;
@@ -1766,7 +1766,7 @@ mpeg_sys_is_valid_pes (GstTypeFind * tf, guint8 * data, guint len,
 }
 
 static gboolean
-mpeg_sys_is_valid_sys (GstTypeFind * tf, guint8 * data, guint len,
+mpeg_sys_is_valid_sys (GstTypeFind * tf, const guint8 * data, guint len,
     guint * pack_size)
 {
   guint sys_hdr_len;
@@ -1807,7 +1807,7 @@ mpeg_sys_is_valid_sys (GstTypeFind * tf, guint8 * data, guint len,
 static void
 mpeg_sys_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data, *data0, *first_sync, *end;
+  const guint8 *data, *data0, *first_sync, *end;
   gint mpegversion = 0;
   guint pack_headers = 0;
   guint pes_headers = 0;
@@ -1948,7 +1948,7 @@ mpeg_ts_probe_headers (GstTypeFind * tf, guint64 offset, gint packet_size)
 {
   /* We always enter this function having found at least one header already */
   gint found = 1;
-  guint8 *data = NULL;
+  const guint8 *data = NULL;
 
   GST_LOG ("looking for mpeg-ts packets of size %u", packet_size);
   while (found < GST_MPEGTS_TYPEFIND_MAX_HEADERS) {
@@ -1973,8 +1973,7 @@ mpeg_ts_type_find (GstTypeFind * tf, gpointer unused)
   /* TS packet sizes to test: normal, DVHS packet size and 
    * FEC with 16 or 20 byte codes packet size. */
   const gint pack_sizes[] = { 188, 192, 204, 208 };
-
-  guint8 *data = NULL;
+  const guint8 *data = NULL;
   guint size = 0;
   guint64 skipped = 0;
 
@@ -2409,7 +2408,7 @@ static GstStaticCaps aiff_caps = GST_STATIC_CAPS ("audio/x-aiff");
 static void
 aiff_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if (data && memcmp (data, "FORM", 4) == 0) {
     data += 8;
@@ -2426,7 +2425,7 @@ static GstStaticCaps svx_caps = GST_STATIC_CAPS ("audio/x-svx");
 static void
 svx_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if (data && memcmp (data, "FORM", 4) == 0) {
     data += 8;
@@ -2443,7 +2442,7 @@ static GstStaticCaps shn_caps = GST_STATIC_CAPS ("audio/x-shorten");
 static void
 shn_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if (data && memcmp (data, "ajkg", 4) == 0) {
     gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SHN_CAPS);
@@ -2462,7 +2461,7 @@ static GstStaticCaps ape_caps = GST_STATIC_CAPS ("application/x-ape");
 static void
 ape_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if (data && memcmp (data, "MAC ", 4) == 0) {
     gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY + 10, APE_CAPS);
@@ -2479,7 +2478,7 @@ static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a");
 static void
 m4a_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 4, 8);
+  const guint8 *data = gst_type_find_peek (tf, 4, 8);
 
   if (data && (memcmp (data, "ftypM4A ", 8) == 0)) {
     gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS);
@@ -2516,7 +2515,7 @@ q3gp_type_find (GstTypeFind * tf, gpointer unused)
   const gchar *profile;
   guint32 ftyp_size = 0;
   gint offset = 0;
-  guint8 *data = NULL;
+  const guint8 *data = NULL;
 
   if ((data = gst_type_find_peek (tf, 0, 12)) == NULL) {
     return;
@@ -2566,7 +2565,7 @@ static GstStaticCaps jp2_caps = GST_STATIC_CAPS ("image/jp2");
 static void
 jp2_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data;
+  const guint8 *data;
 
   data = gst_type_find_peek (tf, 0, 24);
   if (!data)
@@ -2597,7 +2596,7 @@ static GstStaticCaps qt_caps = GST_STATIC_CAPS ("video/quicktime");
 static void
 qt_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data;
+  const guint8 *data;
   guint tip = 0;
   guint64 offset = 0;
   guint64 size;
@@ -2664,7 +2663,7 @@ qt_type_find (GstTypeFind * tf, gpointer unused)
       }
     }
     if (size == 1) {
-      guint8 *sizedata;
+      const guint8 *sizedata;
 
       sizedata = gst_type_find_peek (tf, offset + 8, 8);
       if (sizedata == NULL)
@@ -2760,7 +2759,7 @@ static GstStaticCaps mod_caps = GST_STATIC_CAPS ("audio/x-mod");
 static void
 mod_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data;
+  const guint8 *data;
 
   /* MOD */
   if ((data = gst_type_find_peek (tf, 1080, 4)) != NULL) {
@@ -2816,7 +2815,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
     }
     /* DSM */
     if (memcmp (data, "RIFF", 4) == 0) {
-      guint8 *data2 = gst_type_find_peek (tf, 8, 4);
+      const guint8 *data2 = gst_type_find_peek (tf, 8, 4);
 
       if (data2) {
         if (memcmp (data2, "DSMF", 4) == 0) {
@@ -2827,7 +2826,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
     }
     /* FAM */
     if (memcmp (data, "FAM\xFE", 4) == 0) {
-      guint8 *data2 = gst_type_find_peek (tf, 44, 3);
+      const guint8 *data2 = gst_type_find_peek (tf, 44, 3);
 
       if (data2) {
         if (memcmp (data2, "compare", 3) == 0) {
@@ -2841,7 +2840,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
     }
     /* GDM */
     if (memcmp (data, "GDM\xFE", 4) == 0) {
-      guint8 *data2 = gst_type_find_peek (tf, 71, 4);
+      const guint8 *data2 = gst_type_find_peek (tf, 71, 4);
 
       if (data2) {
         if (memcmp (data2, "GMFS", 4) == 0) {
@@ -2872,7 +2871,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
   if ((data = gst_type_find_peek (tf, 20, 8)) != NULL) {
     if (g_ascii_strncasecmp ((gchar *) data, "!Scream!", 8) == 0 ||
         g_ascii_strncasecmp ((gchar *) data, "BMOD2STM", 8) == 0) {
-      guint8 *id, *stmtype;
+      const guint8 *id, *stmtype;
 
       if ((id = gst_type_find_peek (tf, 28, 1)) == NULL)
         return;
@@ -2893,7 +2892,7 @@ GST_STATIC_CAPS ("application/x-shockwave-flash");
 static void
 swf_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if (data && (data[0] == 'F' || data[0] == 'C') &&
       data[1] == 'W' && data[2] == 'S') {
@@ -3084,7 +3083,7 @@ static GstStaticCaps tiff_le_caps = GST_STATIC_CAPS ("image/tiff, "
 static void
 tiff_type_find (GstTypeFind * tf, gpointer ununsed)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 8);
+  const guint8 *data = gst_type_find_peek (tf, 0, 8);
   guint8 le_header[4] = { 0x49, 0x49, 0x2A, 0x00 };
   guint8 be_header[4] = { 0x4D, 0x4D, 0x00, 0x2A };
 
@@ -3201,7 +3200,7 @@ static GstStaticCaps sds_caps = GST_STATIC_CAPS ("audio/x-sds");
 static void
 sds_type_find (GstTypeFind * tf, gpointer ununsed)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
   guint8 mask[4] = { 0xFF, 0xFF, 0x80, 0xFF };
   guint8 match[4] = { 0xF0, 0x7E, 0, 0x01 };
   gint x;
@@ -3222,7 +3221,7 @@ static GstStaticCaps ircam_caps = GST_STATIC_CAPS ("audio/x-ircam");
 static void
 ircam_type_find (GstTypeFind * tf, gpointer ununsed)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
   guint8 mask[4] = { 0xFF, 0xFF, 0xF8, 0xFF };
   guint8 match[4] = { 0x64, 0xA3, 0x00, 0x00 };
   gint x;
@@ -3254,7 +3253,7 @@ static gboolean
 ebml_check_header (GstTypeFind * tf, const gchar * doctype, int doctype_len)
 {
   /* 4 bytes for EBML ID, 1 byte for header length identifier */
-  guint8 *data = gst_type_find_peek (tf, 0, 4 + 1);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4 + 1);
   gint len_mask = 0x80, size = 1, n = 1, total;
 
   if (!data)
@@ -3382,7 +3381,7 @@ static GstStaticCaps dv_caps = GST_STATIC_CAPS ("video/x-dv, "
 static void
 dv_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data;
+  const guint8 *data;
 
   data = gst_type_find_peek (tf, 0, 5);
 
@@ -3414,7 +3413,7 @@ static GstStaticCaps ogg_annodex_caps =
 static void
 ogganx_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if ((data != NULL) && (memcmp (data, "OggS", 4) == 0)) {
 
@@ -3436,7 +3435,7 @@ static GstStaticCaps vorbis_caps = GST_STATIC_CAPS ("audio/x-vorbis");
 static void
 vorbis_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 30);
+  const guint8 *data = gst_type_find_peek (tf, 0, 30);
 
   if (data) {
     guint blocksize_0;
@@ -3481,7 +3480,7 @@ static GstStaticCaps theora_caps = GST_STATIC_CAPS ("video/x-theora");
 static void
 theora_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 7); //42);
+  const guint8 *data = gst_type_find_peek (tf, 0, 7);   //42);
 
   if (data) {
     if (data[0] != 0x80)
@@ -3498,7 +3497,7 @@ theora_type_find (GstTypeFind * tf, gpointer private)
 static void
 kate_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 64);
+  const guint8 *data = gst_type_find_peek (tf, 0, 64);
   gchar category[16] = { 0, };
 
   if (G_UNLIKELY (data == NULL))
@@ -3531,7 +3530,7 @@ GST_STATIC_CAPS ("application/x-ogm-video");
 static void
 ogmvideo_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 9);
+  const guint8 *data = gst_type_find_peek (tf, 0, 9);
 
   if (data) {
     if (memcmp (data, "\001video\000\000\000", 9) != 0)
@@ -3546,7 +3545,7 @@ GST_STATIC_CAPS ("application/x-ogm-audio");
 static void
 ogmaudio_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 9);
+  const guint8 *data = gst_type_find_peek (tf, 0, 9);
 
   if (data) {
     if (memcmp (data, "\001audio\000\000\000", 9) != 0)
@@ -3561,7 +3560,7 @@ static GstStaticCaps ogmtext_caps = GST_STATIC_CAPS ("application/x-ogm-text");
 static void
 ogmtext_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 9);
+  const guint8 *data = gst_type_find_peek (tf, 0, 9);
 
   if (data) {
     if (memcmp (data, "\001text\000\000\000\000", 9) != 0)
@@ -3578,7 +3577,7 @@ static GstStaticCaps speex_caps = GST_STATIC_CAPS ("audio/x-speex");
 static void
 speex_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 80);
+  const guint8 *data = gst_type_find_peek (tf, 0, 80);
 
   if (data) {
     /* 8 byte string "Speex   "
@@ -3614,7 +3613,7 @@ static GstStaticCaps celt_caps = GST_STATIC_CAPS ("audio/x-celt");
 static void
 celt_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 8);
+  const guint8 *data = gst_type_find_peek (tf, 0, 8);
 
   if (data) {
     /* 8 byte string "CELT   " */
@@ -3633,7 +3632,7 @@ GST_STATIC_CAPS ("application/x-ogg-skeleton, parsed=(boolean)FALSE");
 static void
 oggskel_type_find (GstTypeFind * tf, gpointer private)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 12);
+  const guint8 *data = gst_type_find_peek (tf, 0, 12);
 
   if (data) {
     /* 8 byte string "fishead\0" for the ogg skeleton stream */
@@ -3659,7 +3658,7 @@ static void
 cmml_type_find (GstTypeFind * tf, gpointer private)
 {
   /* Header is 12 bytes minimum (though we don't check the minor version */
-  guint8 *data = gst_type_find_peek (tf, 0, 12);
+  const guint8 *data = gst_type_find_peek (tf, 0, 12);
 
   if (data) {
 
@@ -3686,7 +3685,7 @@ static GstStaticCaps tar_caps = GST_STATIC_CAPS ("application/x-tar");
 static void
 tar_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 257, 8);
+  const guint8 *data = gst_type_find_peek (tf, 257, 8);
 
   /* of course we are not certain, but we don't want other typefind funcs
    * to detect formats of files within the tar archive, e.g. mp3s */
@@ -3708,7 +3707,7 @@ static GstStaticCaps ar_caps = GST_STATIC_CAPS ("application/x-ar");
 static void
 ar_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 24);
+  const guint8 *data = gst_type_find_peek (tf, 0, 24);
 
   if (data && memcmp (data, "!<arch>", 7) == 0) {
     gint i;
@@ -3735,7 +3734,7 @@ static GstStaticCaps au_caps = GST_STATIC_CAPS ("audio/x-au");
 static void
 au_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if (data) {
     if (memcmp (data, ".snd", 4) == 0 || memcmp (data, "dns.", 4) == 0) {
@@ -3757,7 +3756,7 @@ static GstStaticCaps nuv_caps = GST_STATIC_CAPS ("video/x-nuv");
 static void
 nuv_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 11);
+  const guint8 *data = gst_type_find_peek (tf, 0, 11);
 
   if (data) {
     if (memcmp (data, "MythTVVideo", 11) == 0
@@ -3775,7 +3774,7 @@ static GstStaticCaps paris_caps = GST_STATIC_CAPS ("audio/x-paris");
 static void
 paris_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 4);
+  const guint8 *data = gst_type_find_peek (tf, 0, 4);
 
   if (data) {
     if (memcmp (data, " paf", 4) == 0 || memcmp (data, "fap ", 4) == 0) {
@@ -3792,7 +3791,7 @@ static GstStaticCaps ilbc_caps = GST_STATIC_CAPS ("audio/iLBC-sh");
 static void
 ilbc_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 8);
+  const guint8 *data = gst_type_find_peek (tf, 0, 8);
 
   if (data) {
     if (memcmp (data, "#!iLBC30", 8) == 0 || memcmp (data, "#!iLBC20", 8) == 0) {
@@ -3810,7 +3809,7 @@ GST_STATIC_CAPS ("application/x-ms-dos-executable");
 static void
 msdos_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 64);
+  const guint8 *data = gst_type_find_peek (tf, 0, 64);
 
   if (data && data[0] == 'M' && data[1] == 'Z' &&
       GST_READ_UINT16_LE (data + 8) == 4) {
@@ -3837,7 +3836,7 @@ mmsh_type_find (GstTypeFind * tf, gpointer unused)
     0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
   };
 
-  guint8 *data;
+  const guint8 *data;
 
   data = gst_type_find_peek (tf, 0, 2 + 2 + 4 + 2 + 2 + 16);
   if (data && data[0] == 0x24 && data[1] == 0x48 &&
@@ -3859,7 +3858,7 @@ static GstStaticCaps dirac_caps = GST_STATIC_CAPS ("video/x-dirac");
 static void
 dirac_type_find (GstTypeFind * tf, gpointer unused)
 {
-  guint8 *data = gst_type_find_peek (tf, 0, 8);
+  const guint8 *data = gst_type_find_peek (tf, 0, 8);
 
   if (data) {
     if (memcmp (data, "BBCD", 4) == 0 || memcmp (data, "KW-DIRAC", 8) == 0) {
@@ -3880,7 +3879,7 @@ vivo_type_find (GstTypeFind * tf, gpointer unused)
   static const guint8 vivo_marker[] = { 'V', 'e', 'r', 's', 'i', 'o', 'n',
     ':', 'V', 'i', 'v', 'o', '/'
   };
-  guint8 *data;
+  const guint8 *data;
   guint hdr_len, pos;
 
   data = gst_type_find_peek (tf, 0, 1024);
@@ -3918,7 +3917,7 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data)
   gchar *mimetype;
   gsize length = 16384;
   guint64 tf_length;
-  guint8 *data;
+  const guint8 *data;
   gchar *tmp;
 
   if ((tf_length = gst_type_find_get_length (find)) > 0)
@@ -3970,7 +3969,7 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data)
 static void
 windows_icon_typefind (GstTypeFind * find, gpointer user_data)
 {
-  guint8 *data;
+  const guint8 *data;
   gint64 datalen;
   guint16 type, nimages;
   gint32 size, offset;
@@ -4069,7 +4068,7 @@ static void
 start_with_type_find (GstTypeFind * tf, gpointer private)
 {
   GstTypeFindData *start_with = (GstTypeFindData *) private;
-  guint8 *data;
+  const guint8 *data;
 
   GST_LOG ("trying to find mime type %s with the first %u bytes of data",
       gst_structure_get_name (gst_caps_get_structure (start_with->caps, 0)),
@@ -4109,7 +4108,7 @@ static void
 riff_type_find (GstTypeFind * tf, gpointer private)
 {
   GstTypeFindData *riff_data = (GstTypeFindData *) private;
-  guint8 *data = gst_type_find_peek (tf, 0, 12);
+  const guint8 *data = gst_type_find_peek (tf, 0, 12);
 
   if (data && (memcmp (data, "RIFF", 4) == 0 || memcmp (data, "AVF0", 4) == 0)) {
     data += 8;
index 4f53c81..7d1d9c0 100644 (file)
@@ -469,8 +469,7 @@ gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate)
     goto eos_before_buffers;
 
   /* make sure we can write to the metadata */
-  outbuf = gst_buffer_make_metadata_writable
-      (gst_buffer_ref (videorate->prevbuf));
+  outbuf = gst_buffer_make_writable (gst_buffer_ref (videorate->prevbuf));
 
   GST_BUFFER_OFFSET (outbuf) = videorate->out;
   GST_BUFFER_OFFSET_END (outbuf) = videorate->out + 1;
index ac2968a..21be885 100644 (file)
@@ -201,7 +201,7 @@ static GstCaps *gst_video_scale_transform_caps (GstBaseTransform * trans,
 static gboolean gst_video_scale_set_caps (GstBaseTransform * trans,
     GstCaps * in, GstCaps * out);
 static gboolean gst_video_scale_get_unit_size (GstBaseTransform * trans,
-    GstCaps * caps, guint * size);
+    GstCaps * caps, gsize * size);
 static GstFlowReturn gst_video_scale_transform (GstBaseTransform * trans,
     GstBuffer * in, GstBuffer * out);
 static void gst_video_scale_fixate_caps (GstBaseTransform * base,
@@ -443,7 +443,7 @@ done:
 
 static gboolean
 gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
-    guint * size)
+    gsize * size)
 {
   GstVideoFormat format;
   gint width, height;
@@ -1016,18 +1016,22 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
   gint method;
   const guint8 *black = _get_black_for_format (videoscale->format);
   gboolean add_borders;
+  guint8 *in_data, *out_data;
+  gsize in_size, out_size;
 
   GST_OBJECT_LOCK (videoscale);
   method = videoscale->method;
   add_borders = videoscale->add_borders;
   GST_OBJECT_UNLOCK (videoscale);
 
+  in_data = gst_buffer_map (in, &in_size, NULL, GST_MAP_READ);
+  out_data = gst_buffer_map (out, &out_size, NULL, GST_MAP_WRITE);
+
   gst_video_scale_setup_vs_image (&src, videoscale->format, 0,
-      videoscale->from_width, videoscale->from_height, 0, 0,
-      GST_BUFFER_DATA (in));
+      videoscale->from_width, videoscale->from_height, 0, 0, in_data);
   gst_video_scale_setup_vs_image (&dest, videoscale->format, 0,
       videoscale->to_width, videoscale->to_height, videoscale->borders_w,
-      videoscale->borders_h, GST_BUFFER_DATA (out));
+      videoscale->borders_h, out_data);
 
   if (videoscale->format == GST_VIDEO_FORMAT_I420
       || videoscale->format == GST_VIDEO_FORMAT_YV12
@@ -1035,17 +1039,15 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
       || videoscale->format == GST_VIDEO_FORMAT_Y42B
       || videoscale->format == GST_VIDEO_FORMAT_Y41B) {
     gst_video_scale_setup_vs_image (&src_u, videoscale->format, 1,
-        videoscale->from_width, videoscale->from_height, 0, 0,
-        GST_BUFFER_DATA (in));
+        videoscale->from_width, videoscale->from_height, 0, 0, in_data);
     gst_video_scale_setup_vs_image (&src_v, videoscale->format, 2,
-        videoscale->from_width, videoscale->from_height, 0, 0,
-        GST_BUFFER_DATA (in));
+        videoscale->from_width, videoscale->from_height, 0, 0, in_data);
     gst_video_scale_setup_vs_image (&dest_u, videoscale->format, 1,
         videoscale->to_width, videoscale->to_height, videoscale->borders_w,
-        videoscale->borders_h, GST_BUFFER_DATA (out));
+        videoscale->borders_h, out_data);
     gst_video_scale_setup_vs_image (&dest_v, videoscale->format, 2,
         videoscale->to_width, videoscale->to_height, videoscale->borders_w,
-        videoscale->borders_h, GST_BUFFER_DATA (out));
+        videoscale->borders_h, out_data);
   }
 
   switch (videoscale->format) {
@@ -1252,7 +1254,11 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
   }
 
   GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
-      GST_BUFFER_SIZE (out));
+      gst_buffer_get_size (out));
+
+done:
+  gst_buffer_unmap (in, in_data, in_size);
+  gst_buffer_unmap (out, out_data, out_size);
 
   return ret;
 
@@ -1262,13 +1268,15 @@ unsupported:
     GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL),
         ("Unsupported format %d for scaling method %d",
             videoscale->format, method));
-    return GST_FLOW_ERROR;
+    ret = GST_FLOW_ERROR;
+    goto done;
   }
 unknown_mode:
   {
     GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL),
         ("Unknown scaling method %d", videoscale->method));
-    return GST_FLOW_ERROR;
+    ret = GST_FLOW_ERROR;
+    goto done;
   }
 }
 
index 227e0a9..8b8cb2f 100644 (file)
@@ -828,10 +828,11 @@ static GstFlowReturn
 gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
 {
   GstVideoTestSrc *src;
-  gulong newsize, size;
+  gsize newsize, size;
   GstBuffer *outbuf = NULL;
   GstFlowReturn res;
   GstClockTime next_time;
+  guint8 *data;
 
   src = GST_VIDEO_TEST_SRC (psrc);
 
@@ -860,7 +861,7 @@ gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
 
     /* the buffer could have renegotiated, we need to discard any buffers of the
      * wrong size. */
-    size = GST_BUFFER_SIZE (outbuf);
+    size = gst_buffer_get_size (outbuf);
     newsize = gst_video_test_src_get_size (src, src->width, src->height);
 
     if (size != newsize) {
@@ -874,13 +875,14 @@ gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
     gst_buffer_set_caps (outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)));
   }
 
-  memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
+  data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
+  memset (data, 0, size);
   src->tmpline_u8 = g_malloc (src->width + 8);
   src->tmpline = g_malloc ((src->width + 8) * 4);
   src->tmpline2 = g_malloc ((src->width + 8) * 4);
 
-  src->make_image (src, (void *) GST_BUFFER_DATA (outbuf),
-      src->width, src->height);
+  src->make_image (src, (void *) data, src->width, src->height);
+  gst_buffer_unmap (outbuf, data, size);
 
   g_free (src->tmpline);
   g_free (src->tmpline2);
index a592707..b236245 100644 (file)
@@ -874,7 +874,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
 {
   GstVolume *self = GST_VOLUME (base);
   guint8 *data;
-  guint size;
+  gsize size;
   GstControlSource *mute_csource, *volume_csource;
 
   if (G_UNLIKELY (!self->negotiated))
@@ -885,8 +885,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
       GST_BUFFER_FLAG_IS_SET (outbuf, GST_BUFFER_FLAG_GAP))
     return GST_FLOW_OK;
 
-  data = GST_BUFFER_DATA (outbuf);
-  size = GST_BUFFER_SIZE (outbuf);
+  data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
 
   mute_csource = gst_object_get_control_source (G_OBJECT (self), "mute");
   volume_csource = gst_object_get_control_source (G_OBJECT (self), "volume");
@@ -954,6 +953,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
   } else if (self->current_volume != 1.0) {
     self->process (self, data, size);
   }
+  gst_buffer_unmap (outbuf, data, size);
 
   return GST_FLOW_OK;
 
@@ -973,6 +973,7 @@ controller_failure:
 
     GST_ELEMENT_ERROR (self, CORE, FAILED,
         ("Failed to get values from controller"), (NULL));
+    gst_buffer_unmap (outbuf, data, size);
     return GST_FLOW_ERROR;
   }
 }
index 31bd6de..c4d957c 100644 (file)
@@ -616,78 +616,27 @@ gst_v4lsrc_get_fps_list (GstV4lSrc * v4lsrc)
   }
 }
 
-#define GST_TYPE_V4LSRC_BUFFER (gst_v4lsrc_buffer_get_type())
-#define GST_IS_V4LSRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4LSRC_BUFFER))
-#define GST_V4LSRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_V4LSRC_BUFFER, GstV4lSrcBuffer))
-
-typedef struct _GstV4lSrcBuffer
+typedef struct _GstMetaV4lSrc
 {
-  GstBuffer buffer;
+  GstMeta meta;
 
   GstV4lSrc *v4lsrc;
-
   gint num;
-} GstV4lSrcBuffer;
-
-static void gst_v4lsrc_buffer_class_init (gpointer g_class,
-    gpointer class_data);
-static void gst_v4lsrc_buffer_init (GTypeInstance * instance, gpointer g_class);
-static void gst_v4lsrc_buffer_finalize (GstV4lSrcBuffer * v4lsrc_buffer);
+} GstMetaV4lSrc;
 
-static GstBufferClass *v4lbuffer_parent_class = NULL;
-
-static GType
-gst_v4lsrc_buffer_get_type (void)
-{
-  static GType _gst_v4lsrc_buffer_type;
-
-  if (G_UNLIKELY (_gst_v4lsrc_buffer_type == 0)) {
-    static const GTypeInfo v4lsrc_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_v4lsrc_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstV4lSrcBuffer),
-      0,
-      gst_v4lsrc_buffer_init,
-      NULL
-    };
-    _gst_v4lsrc_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstV4lSrcBuffer", &v4lsrc_buffer_info, 0);
-  }
-  return _gst_v4lsrc_buffer_type;
-}
+#define GST_META_V4LSRC_GET(buf) ((GstMetaV4lSrc *)gst_buffer_get_meta(buf,gst_meta_v4lsrc_get_info()))
+#define GST_META_V4LSRC_ADD(buf) ((GstMetaV4lSrc *)gst_buffer_add_meta(buf,gst_meta_v4lsrc_get_info(), NULL))
 
 static void
-gst_v4lsrc_buffer_class_init (gpointer g_class, gpointer class_data)
+meta_v4lsrc_free (GstMetaV4lSrc * meta, GstBuffer * buffer)
 {
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  v4lbuffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_v4lsrc_buffer_finalize;
-}
-
-static void
-gst_v4lsrc_buffer_init (GTypeInstance * instance, gpointer g_class)
-{
-
-}
-
-static void
-gst_v4lsrc_buffer_finalize (GstV4lSrcBuffer * v4lsrc_buffer)
-{
-  GstMiniObjectClass *miniobject_class;
   GstV4lSrc *v4lsrc;
   gint num;
 
-  v4lsrc = v4lsrc_buffer->v4lsrc;
-  num = v4lsrc_buffer->num;
+  v4lsrc = meta->v4lsrc;
+  num = meta->num;
 
-  GST_LOG_OBJECT (v4lsrc, "freeing buffer %p for frame %d", v4lsrc_buffer, num);
+  GST_LOG_OBJECT (v4lsrc, "freeing buffer %p for frame %d", buffer, num);
 
   /* only requeue if we still have an mmap buffer */
   if (GST_V4LELEMENT (v4lsrc)->buffer) {
@@ -696,15 +645,31 @@ gst_v4lsrc_buffer_finalize (GstV4lSrcBuffer * v4lsrc_buffer)
   }
 
   gst_object_unref (v4lsrc);
+}
 
-  miniobject_class = (GstMiniObjectClass *) v4lbuffer_parent_class;
-  miniobject_class->finalize (GST_MINI_OBJECT_CAST (v4lsrc_buffer));
+static const GstMetaInfo *
+gst_meta_v4lsrc_get_info (void)
+{
+  static const GstMetaInfo *meta_v4lsrc_info = NULL;
+
+  if (meta_v4lsrc_info == NULL) {
+    meta_v4lsrc_info = gst_meta_register ("GstMetaV4lSrc", "GstMetaV4lSrc",
+        sizeof (GstMetaV4lSrc),
+        (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) meta_v4lsrc_free,
+        (GstMetaCopyFunction) NULL,
+        (GstMetaTransformFunction) NULL,
+        (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+  }
+  return meta_v4lsrc_info;
 }
 
+
 /* Create a V4lSrc buffer from our mmap'd data area */
 GstBuffer *
 gst_v4lsrc_buffer_new (GstV4lSrc * v4lsrc, gint num)
 {
+  GstMetaV4lSrc *meta;
   GstClockTime duration, timestamp, latency;
   GstBuffer *buf;
   GstClock *clock;
@@ -715,14 +680,18 @@ gst_v4lsrc_buffer_new (GstV4lSrc * v4lsrc, gint num)
   if (!(gst_v4lsrc_get_fps (v4lsrc, &fps_n, &fps_d)))
     return NULL;
 
-  buf = (GstBuffer *) gst_mini_object_new (GST_TYPE_V4LSRC_BUFFER);
+  buf = gst_buffer_new ();
+
+  /* attach private metadata with the frame num and v4lsrc element */
+  meta = GST_META_V4LSRC_ADD (buf);
+  meta->num = num;
+  meta->v4lsrc = gst_object_ref (v4lsrc);
 
-  GST_V4LSRC_BUFFER (buf)->num = num;
-  GST_V4LSRC_BUFFER (buf)->v4lsrc = gst_object_ref (v4lsrc);
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          gst_v4lsrc_get_buffer (v4lsrc, num), NULL, v4lsrc->buffer_size,
+          0, v4lsrc->buffer_size));
 
-  GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
-  GST_BUFFER_DATA (buf) = gst_v4lsrc_get_buffer (v4lsrc, num);
-  GST_BUFFER_SIZE (buf) = v4lsrc->buffer_size;
   GST_BUFFER_OFFSET (buf) = v4lsrc->offset++;
   GST_BUFFER_OFFSET_END (buf) = v4lsrc->offset;
 
index 69f9bbc..df14448 100644 (file)
@@ -1,6 +1,6 @@
 plugin_LTLIBRARIES = libgstximagesink.la
 
-libgstximagesink_la_SOURCES =  ximagesink.c ximage.c
+libgstximagesink_la_SOURCES =  ximagesink.c ximage.c ximagepool.c
 libgstximagesink_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(X_CFLAGS)
 libgstximagesink_la_LIBADD = \
        $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-$(GST_MAJORMINOR).la \
@@ -11,4 +11,4 @@ libgstximagesink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstximagesink_la_DEPENDENCIES = $(top_builddir)/gst-libs/gst/video/libgstvideo-$(GST_MAJORMINOR).la
 libgstximagesink_la_LIBTOOLFLAGS = --tag=disable-static
 
-noinst_HEADERS = ximagesink.h 
+noinst_HEADERS = ximagesink.h ximagepool.h
index 24b7bf2..24a9e61 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include "ximagesink.h"
 
+GST_DEBUG_CATEGORY (gst_debug_ximagepool);
 GST_DEBUG_CATEGORY (gst_debug_ximagesink);
+GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
 
 static gboolean
 plugin_init (GstPlugin * plugin)
@@ -36,6 +36,10 @@ plugin_init (GstPlugin * plugin)
 
   GST_DEBUG_CATEGORY_INIT (gst_debug_ximagesink, "ximagesink", 0,
       "ximagesink element");
+  GST_DEBUG_CATEGORY_INIT (gst_debug_ximagepool, "ximagepool", 0,
+      "ximagepool object");
+
+  GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
 
   return TRUE;
 }
diff --git a/sys/ximage/ximagepool.c b/sys/ximage/ximagepool.c
new file mode 100644 (file)
index 0000000..6498888
--- /dev/null
@@ -0,0 +1,568 @@
+/* GStreamer
+ * Copyright (C) <2005> Julien Moutte <julien@moutte.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* Object header */
+#include "ximagesink.h"
+
+/* Debugging category */
+#include <gst/gstinfo.h>
+
+GST_DEBUG_CATEGORY_EXTERN (gst_debug_ximagepool);
+#define GST_CAT_DEFAULT gst_debug_ximagepool
+
+static void gst_meta_ximage_free (GstMetaXImage * meta, GstBuffer * buffer);
+
+/* ximage metadata */
+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 ("GstMetaXImage", "GstMetaXImage",
+        sizeof (GstMetaXImage),
+        (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) gst_meta_ximage_free,
+        (GstMetaCopyFunction) NULL,
+        (GstMetaTransformFunction) NULL,
+        (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+  }
+  return meta_ximage_info;
+}
+
+/* X11 stuff */
+static gboolean error_caught = FALSE;
+
+static int
+gst_ximagesink_handle_xerror (Display * display, XErrorEvent * xevent)
+{
+  char error_msg[1024];
+
+  XGetErrorText (display, xevent->error_code, error_msg, 1024);
+  GST_DEBUG ("ximagesink triggered an XError. error: %s", error_msg);
+  error_caught = TRUE;
+  return 0;
+}
+
+GstMetaXImage *
+gst_buffer_add_meta_ximage (GstBuffer * buffer, GstXImageSink * ximagesink,
+    gint width, gint height)
+{
+  int (*handler) (Display *, XErrorEvent *);
+  gboolean success = FALSE;
+  GstXContext *xcontext;
+  GstMetaXImage *meta;
+
+  xcontext = ximagesink->xcontext;
+
+  meta =
+      (GstMetaXImage *) gst_buffer_add_meta (buffer, GST_META_INFO_XIMAGE,
+      NULL);
+#ifdef HAVE_XSHM
+  meta->SHMInfo.shmaddr = ((void *) -1);
+  meta->SHMInfo.shmid = -1;
+#endif
+  meta->width = width;
+  meta->height = height;
+  meta->sink = gst_object_ref (ximagesink);
+
+  GST_DEBUG_OBJECT (ximagesink, "creating image %p (%dx%d)", buffer,
+      meta->width, meta->height);
+
+  g_mutex_lock (ximagesink->x_lock);
+
+  /* Setting an error handler to catch failure */
+  error_caught = FALSE;
+  handler = XSetErrorHandler (gst_ximagesink_handle_xerror);
+
+#ifdef HAVE_XSHM
+  if (xcontext->use_xshm) {
+    meta->ximage = XShmCreateImage (xcontext->disp,
+        xcontext->visual,
+        xcontext->depth,
+        ZPixmap, NULL, &meta->SHMInfo, meta->width, meta->height);
+    if (!meta->ximage || error_caught)
+      goto create_failed;
+
+    /* we have to use the returned bytes_per_line for our shm size */
+    meta->size = meta->ximage->bytes_per_line * meta->ximage->height;
+    GST_LOG_OBJECT (ximagesink,
+        "XShm image size is %" G_GSIZE_FORMAT ", width %d, stride %d",
+        meta->size, meta->width, meta->ximage->bytes_per_line);
+
+    /* get shared memory */
+    meta->SHMInfo.shmid = shmget (IPC_PRIVATE, meta->size, IPC_CREAT | 0777);
+    if (meta->SHMInfo.shmid == -1)
+      goto shmget_failed;
+
+    /* attach */
+    meta->SHMInfo.shmaddr = shmat (meta->SHMInfo.shmid, NULL, 0);
+    if (meta->SHMInfo.shmaddr == ((void *) -1))
+      goto shmat_failed;
+
+    /* now we can set up the image data */
+    meta->ximage->data = meta->SHMInfo.shmaddr;
+    meta->SHMInfo.readOnly = FALSE;
+
+    if (XShmAttach (xcontext->disp, &meta->SHMInfo) == 0)
+      goto xattach_failed;
+
+    XSync (xcontext->disp, FALSE);
+
+    /* Now that everyone has attached, we can delete the shared memory segment.
+     * This way, it will be deleted as soon as we detach later, and not
+     * leaked if we crash. */
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, NULL);
+
+    GST_DEBUG_OBJECT (ximagesink, "XServer ShmAttached to 0x%x, id 0x%lx",
+        meta->SHMInfo.shmid, meta->SHMInfo.shmseg);
+  } else
+#endif /* HAVE_XSHM */
+  {
+    guint allocsize;
+
+    meta->ximage = XCreateImage (xcontext->disp,
+        xcontext->visual,
+        xcontext->depth,
+        ZPixmap, 0, NULL, meta->width, meta->height, xcontext->bpp, 0);
+    if (!meta->ximage || error_caught)
+      goto create_failed;
+
+    /* upstream will assume that rowstrides are multiples of 4, but this
+     * doesn't always seem to be the case with XCreateImage() */
+    if ((meta->ximage->bytes_per_line % 4) != 0) {
+      GST_WARNING_OBJECT (ximagesink, "returned stride not a multiple of 4 as "
+          "usually assumed");
+    }
+
+    /* we have to use the returned bytes_per_line for our image size */
+    meta->size = meta->ximage->bytes_per_line * meta->ximage->height;
+
+    /* alloc a bit more for unexpected strides to avoid crashes upstream.
+     * FIXME: if we get an unrounded stride, the image will be displayed
+     * distorted, since all upstream elements assume a rounded stride */
+    allocsize =
+        GST_ROUND_UP_4 (meta->ximage->bytes_per_line) * meta->ximage->height;
+
+    meta->ximage->data = g_malloc (allocsize);
+    GST_LOG_OBJECT (ximagesink,
+        "non-XShm image size is %" G_GSIZE_FORMAT " (alloced: %u), width %d, "
+        "stride %d", meta->size, allocsize, meta->width,
+        meta->ximage->bytes_per_line);
+
+    XSync (xcontext->disp, FALSE);
+  }
+
+  /* Reset error handler */
+  error_caught = FALSE;
+  XSetErrorHandler (handler);
+
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, meta->ximage->data,
+          NULL, meta->size, 0, meta->size));
+
+  g_mutex_unlock (ximagesink->x_lock);
+
+  success = TRUE;
+
+beach:
+  if (!success)
+    meta = NULL;
+
+  return meta;
+
+  /* ERRORS */
+create_failed:
+  {
+    g_mutex_unlock (ximagesink->x_lock);
+    /* Reset error handler */
+    error_caught = FALSE;
+    XSetErrorHandler (handler);
+    /* Push an error */
+    GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height),
+        ("could not XShmCreateImage a %dx%d image", meta->width, meta->height));
+    goto beach;
+  }
+shmget_failed:
+  {
+    g_mutex_unlock (ximagesink->x_lock);
+    GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height),
+        ("could not get shared memory of %" G_GSIZE_FORMAT " bytes",
+            meta->size));
+    goto beach;
+  }
+shmat_failed:
+  {
+    g_mutex_unlock (ximagesink->x_lock);
+    GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height),
+        ("Failed to shmat: %s", g_strerror (errno)));
+    /* Clean up the shared memory segment */
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, NULL);
+    goto beach;
+  }
+xattach_failed:
+  {
+    /* Clean up the shared memory segment */
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, NULL);
+    g_mutex_unlock (ximagesink->x_lock);
+
+    GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height), ("Failed to XShmAttach"));
+    goto beach;
+  }
+}
+
+static void
+gst_meta_ximage_free (GstMetaXImage * meta, GstBuffer * buffer)
+{
+  GstXImageSink *ximagesink;
+
+  ximagesink = meta->sink;
+
+  GST_DEBUG_OBJECT (ximagesink, "free meta on buffer %p", buffer);
+
+  /* Hold the object lock to ensure the XContext doesn't disappear */
+  GST_OBJECT_LOCK (ximagesink);
+  /* We might have some buffers destroyed after changing state to NULL */
+  if (ximagesink->xcontext == NULL) {
+    GST_DEBUG_OBJECT (ximagesink, "Destroying XImage after XContext");
+#ifdef HAVE_XSHM
+    /* Need to free the shared memory segment even if the x context
+     * was already cleaned up */
+    if (meta->SHMInfo.shmaddr != ((void *) -1)) {
+      shmdt (meta->SHMInfo.shmaddr);
+    }
+#endif
+    goto beach;
+  }
+
+  g_mutex_lock (ximagesink->x_lock);
+
+#ifdef HAVE_XSHM
+  if (ximagesink->xcontext->use_xshm) {
+    if (meta->SHMInfo.shmaddr != ((void *) -1)) {
+      GST_DEBUG_OBJECT (ximagesink, "XServer ShmDetaching from 0x%x id 0x%lx",
+          meta->SHMInfo.shmid, meta->SHMInfo.shmseg);
+      XShmDetach (ximagesink->xcontext->disp, &meta->SHMInfo);
+      XSync (ximagesink->xcontext->disp, FALSE);
+      shmdt (meta->SHMInfo.shmaddr);
+      meta->SHMInfo.shmaddr = (void *) -1;
+    }
+    if (meta->ximage)
+      XDestroyImage (meta->ximage);
+  } else
+#endif /* HAVE_XSHM */
+  {
+    if (meta->ximage) {
+      XDestroyImage (meta->ximage);
+    }
+  }
+
+  XSync (ximagesink->xcontext->disp, FALSE);
+
+  g_mutex_unlock (ximagesink->x_lock);
+
+beach:
+  GST_OBJECT_UNLOCK (ximagesink);
+
+  gst_object_unref (meta->sink);
+}
+
+GstBuffer *
+gst_ximage_buffer_new (GstXImageSink * ximagesink, gint width, gint height)
+{
+  GstBuffer *buffer;
+  GstMetaXImage *meta;
+
+  buffer = gst_buffer_new ();
+  meta = gst_buffer_add_meta_ximage (buffer, ximagesink, width, height);
+  if (meta == NULL) {
+    gst_buffer_unref (buffer);
+    buffer = NULL;
+  }
+  return buffer;
+}
+
+#ifdef HAVE_XSHM
+/* This function checks that it is actually really possible to create an image
+   using XShm */
+gboolean
+gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
+    GstXContext * xcontext)
+{
+  XImage *ximage;
+  XShmSegmentInfo SHMInfo;
+  size_t size;
+  int (*handler) (Display *, XErrorEvent *);
+  gboolean result = FALSE;
+  gboolean did_attach = FALSE;
+
+  g_return_val_if_fail (xcontext != NULL, FALSE);
+
+  /* Sync to ensure any older errors are already processed */
+  XSync (xcontext->disp, FALSE);
+
+  /* Set defaults so we don't free these later unnecessarily */
+  SHMInfo.shmaddr = ((void *) -1);
+  SHMInfo.shmid = -1;
+
+  /* Setting an error handler to catch failure */
+  error_caught = FALSE;
+  handler = XSetErrorHandler (gst_ximagesink_handle_xerror);
+
+  /* Trying to create a 1x1 ximage */
+  GST_DEBUG ("XShmCreateImage of 1x1");
+
+  ximage = XShmCreateImage (xcontext->disp, xcontext->visual,
+      xcontext->depth, ZPixmap, NULL, &SHMInfo, 1, 1);
+
+  /* Might cause an error, sync to ensure it is noticed */
+  XSync (xcontext->disp, FALSE);
+  if (!ximage || error_caught) {
+    GST_WARNING ("could not XShmCreateImage a 1x1 image");
+    goto beach;
+  }
+  size = ximage->height * ximage->bytes_per_line;
+
+  SHMInfo.shmid = shmget (IPC_PRIVATE, size, IPC_CREAT | 0777);
+  if (SHMInfo.shmid == -1) {
+    GST_WARNING ("could not get shared memory of %" G_GSIZE_FORMAT " bytes",
+        size);
+    goto beach;
+  }
+
+  SHMInfo.shmaddr = shmat (SHMInfo.shmid, NULL, 0);
+  if (SHMInfo.shmaddr == ((void *) -1)) {
+    GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
+    /* Clean up the shared memory segment */
+    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
+    goto beach;
+  }
+
+  ximage->data = SHMInfo.shmaddr;
+  SHMInfo.readOnly = FALSE;
+
+  if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
+    GST_WARNING ("Failed to XShmAttach");
+    /* Clean up the shared memory segment */
+    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
+    goto beach;
+  }
+
+  /* Sync to ensure we see any errors we caused */
+  XSync (xcontext->disp, FALSE);
+
+  /* Delete the shared memory segment as soon as everyone is attached.
+   * This way, it will be deleted as soon as we detach later, and not
+   * leaked if we crash. */
+  shmctl (SHMInfo.shmid, IPC_RMID, NULL);
+
+  if (!error_caught) {
+    GST_DEBUG ("XServer ShmAttached to 0x%x, id 0x%lx", SHMInfo.shmid,
+        SHMInfo.shmseg);
+
+    did_attach = TRUE;
+    /* store whether we succeeded in result */
+    result = TRUE;
+  } else {
+    GST_WARNING ("MIT-SHM extension check failed at XShmAttach. "
+        "Not using shared memory.");
+  }
+
+beach:
+  /* Sync to ensure we swallow any errors we caused and reset error_caught */
+  XSync (xcontext->disp, FALSE);
+
+  error_caught = FALSE;
+  XSetErrorHandler (handler);
+
+  if (did_attach) {
+    GST_DEBUG ("XServer ShmDetaching from 0x%x id 0x%lx",
+        SHMInfo.shmid, SHMInfo.shmseg);
+    XShmDetach (xcontext->disp, &SHMInfo);
+    XSync (xcontext->disp, FALSE);
+  }
+  if (SHMInfo.shmaddr != ((void *) -1))
+    shmdt (SHMInfo.shmaddr);
+  if (ximage)
+    XDestroyImage (ximage);
+  return result;
+}
+#endif /* HAVE_XSHM */
+
+/* bufferpool */
+static void gst_ximage_buffer_pool_finalize (GObject * object);
+
+#define GST_XIMAGE_BUFFER_POOL_GET_PRIVATE(obj)  \
+   (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_XIMAGE_BUFFER_POOL, GstXImageBufferPoolPrivate))
+
+struct _GstXImageBufferPoolPrivate
+{
+  GstCaps *caps;
+  gint width, height;
+};
+
+G_DEFINE_TYPE (GstXImageBufferPool, gst_ximage_buffer_pool,
+    GST_TYPE_BUFFER_POOL);
+
+static gboolean
+ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
+{
+  GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
+  GstXImageBufferPoolPrivate *priv = xpool->priv;
+  GstStructure *structure;
+  gint width, height;
+  const GstCaps *caps;
+
+  if (!gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL,
+          NULL, NULL))
+    goto wrong_config;
+
+  if (caps == NULL)
+    goto no_caps;
+
+  /* now parse the caps from the config */
+  structure = gst_caps_get_structure (caps, 0);
+
+  if (!gst_structure_get_int (structure, "width", &width) ||
+      !gst_structure_get_int (structure, "height", &height))
+    goto wrong_caps;
+
+  GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, width, height, caps);
+
+  /* keep track of the width and height and caps */
+  if (priv->caps)
+    gst_caps_unref (priv->caps);
+  priv->caps = gst_caps_copy (caps);
+  priv->width = width;
+  priv->height = height;
+
+  return TRUE;
+
+  /* ERRORS */
+wrong_config:
+  {
+    GST_WARNING_OBJECT (pool, "invalid config");
+    return FALSE;
+  }
+no_caps:
+  {
+    GST_WARNING_OBJECT (pool, "no caps in config");
+    return FALSE;
+  }
+wrong_caps:
+  {
+    GST_WARNING_OBJECT (pool,
+        "failed getting geometry from caps %" GST_PTR_FORMAT, caps);
+    return FALSE;
+  }
+}
+
+/* This function handles GstXImageBuffer creation depending on XShm availability */
+static GstFlowReturn
+ximage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
+    GstBufferPoolParams * params)
+{
+  GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
+  GstXImageBufferPoolPrivate *priv = xpool->priv;
+  GstBuffer *ximage;
+
+  ximage = gst_ximage_buffer_new (xpool->sink, priv->width, priv->height);
+  if (ximage == NULL)
+    goto no_buffer;
+
+  *buffer = ximage;
+
+  return GST_FLOW_OK;
+
+  /* ERROR */
+no_buffer:
+  {
+    GST_WARNING_OBJECT (pool, "can't create image");
+    return GST_FLOW_ERROR;
+  }
+}
+
+static void
+ximage_buffer_pool_free (GstBufferPool * pool, GstBuffer * buffer)
+{
+  gst_buffer_unref (buffer);
+}
+
+GstBufferPool *
+gst_ximage_buffer_pool_new (GstXImageSink * ximagesink)
+{
+  GstXImageBufferPool *pool;
+
+  g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
+
+  pool = g_object_new (GST_TYPE_XIMAGE_BUFFER_POOL, NULL);
+  pool->sink = gst_object_ref (ximagesink);
+
+  GST_LOG_OBJECT (pool, "new XImage buffer pool %p", pool);
+
+  return GST_BUFFER_POOL_CAST (pool);
+}
+
+static void
+gst_ximage_buffer_pool_class_init (GstXImageBufferPoolClass * klass)
+{
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
+
+  g_type_class_add_private (klass, sizeof (GstXImageBufferPoolPrivate));
+
+  gobject_class->finalize = gst_ximage_buffer_pool_finalize;
+
+  gstbufferpool_class->set_config = ximage_buffer_pool_set_config;
+  gstbufferpool_class->alloc_buffer = ximage_buffer_pool_alloc;
+  gstbufferpool_class->free_buffer = ximage_buffer_pool_free;
+}
+
+static void
+gst_ximage_buffer_pool_init (GstXImageBufferPool * pool)
+{
+  pool->priv = GST_XIMAGE_BUFFER_POOL_GET_PRIVATE (pool);
+}
+
+static void
+gst_ximage_buffer_pool_finalize (GObject * object)
+{
+  GstXImageBufferPool *pool = GST_XIMAGE_BUFFER_POOL_CAST (object);
+  GstXImageBufferPoolPrivate *priv = pool->priv;
+
+  GST_LOG_OBJECT (pool, "finalize XImage buffer pool %p", pool);
+
+  if (priv->caps)
+    gst_caps_unref (priv->caps);
+  gst_object_unref (pool->sink);
+
+  G_OBJECT_CLASS (gst_ximage_buffer_pool_parent_class)->finalize (object);
+}
diff --git a/sys/ximage/ximagepool.h b/sys/ximage/ximagepool.h
new file mode 100644 (file)
index 0000000..7f12bdc
--- /dev/null
@@ -0,0 +1,115 @@
+/* GStreamer
+ * Copyright (C) <2005> Julien Moutte <julien@moutte.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_XIMAGEPOOL_H__
+#define __GST_XIMAGEPOOL_H__
+
+#ifdef HAVE_XSHM
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif /* HAVE_XSHM */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#ifdef HAVE_XSHM
+#include <X11/extensions/XShm.h>
+#endif /* HAVE_XSHM */
+
+#include <string.h>
+#include <math.h>
+
+
+G_BEGIN_DECLS
+
+typedef struct _GstMetaXImage GstMetaXImage;
+
+typedef struct _GstXImageBufferPool GstXImageBufferPool;
+typedef struct _GstXImageBufferPoolClass GstXImageBufferPoolClass;
+typedef struct _GstXImageBufferPoolPrivate GstXImageBufferPoolPrivate;
+
+#include "ximagesink.h"
+
+const GstMetaInfo * gst_meta_ximage_get_info (void);
+#define GST_META_INFO_XIMAGE  (gst_meta_ximage_get_info())
+
+#define gst_buffer_get_meta_ximage(b) ((GstMetaXImage*)gst_buffer_get_meta((b),GST_META_INFO_XIMAGE))
+GstMetaXImage * gst_buffer_add_meta_ximage   (GstBuffer *buffer, GstXImageSink * ximagesink,
+                                              gint width, gint height);
+
+/**
+ * GstMetaXImage:
+ * @simagesink: a reference to the our #GstXImageSink
+ * @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 #GstMeta containing additional information about an XImage.
+ */
+struct _GstMetaXImage
+{
+  GstMeta meta;
+
+  /* Reference to the ximagesink we belong to */
+  GstXImageSink *sink;
+
+  XImage *ximage;
+
+#ifdef HAVE_XSHM
+  XShmSegmentInfo SHMInfo;
+#endif                          /* HAVE_XSHM */
+
+  gint width, height;
+  size_t size;
+};
+
+GstBuffer *   gst_ximage_buffer_new    (GstXImageSink *ximagesink, gint width, gint height);
+
+/* buffer pool functions */
+#define GST_TYPE_XIMAGE_BUFFER_POOL      (gst_ximage_buffer_pool_get_type())
+#define GST_IS_XIMAGE_BUFFER_POOL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGE_BUFFER_POOL))
+#define GST_XIMAGE_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGE_BUFFER_POOL, GstXImageBufferPool))
+#define GST_XIMAGE_BUFFER_POOL_CAST(obj) ((GstXImageBufferPool*)(obj))
+
+struct _GstXImageBufferPool
+{
+  GstBufferPool bufferpool;
+
+  GstXImageSink *sink;
+
+  GstXImageBufferPoolPrivate *priv;
+};
+
+struct _GstXImageBufferPoolClass
+{
+  GstBufferPoolClass parent_class;
+};
+
+GType gst_ximage_buffer_pool_get_type (void);
+
+GstBufferPool * gst_ximage_buffer_pool_new     (GstXImageSink * ximagesink);
+
+gboolean gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
+        GstXContext * xcontext);
+
+G_END_DECLS
+
+#endif /* __GST_XIMAGEPOOL_H__ */
index d1780fc..54ea852 100644 (file)
@@ -129,8 +129,6 @@ MotifWmHints, MwmHints;
 #define MWM_HINTS_DECORATIONS   (1L << 1)
 
 static void gst_ximagesink_reset (GstXImageSink * ximagesink);
-static void gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink,
-    GstXImageBuffer * ximage);
 static void gst_ximagesink_xwindow_update_geometry (GstXImageSink * ximagesink);
 static void gst_ximagesink_expose (GstXOverlay * overlay);
 
@@ -164,473 +162,8 @@ static GstVideoSinkClass *parent_class = NULL;
 /*                                                               */
 /* ============================================================= */
 
-/* ximage buffers */
-
-static GstBufferClass *ximage_buffer_parent_class = NULL;
-
-#define GST_TYPE_XIMAGE_BUFFER (gst_ximage_buffer_get_type())
-
-#define GST_IS_XIMAGE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGE_BUFFER))
-#define GST_XIMAGE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGE_BUFFER, GstXImageBuffer))
-#define GST_XIMAGE_BUFFER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_XIMAGE_BUFFER, GstXImageBufferClass))
-
-/* So some words about GstMiniObject, this is pretty messy...
-   GstMiniObject does not use the standard finalizing of GObjects, you are 
-   supposed to call gst_buffer_unref that's going to call gst_mini_objec_unref
-   which will handle its own refcount system and call gst_mini_object_free.
-   gst_mini_object_free will call the class finalize method which is not the 
-   one from GObject, after calling this finalize method it will free the object
-   instance for you if the refcount is still 0 so you should not chain up */
-static void
-gst_ximage_buffer_finalize (GstXImageBuffer * ximage)
-{
-  GstXImageSink *ximagesink = NULL;
-  gboolean recycled = FALSE;
-  gboolean running;
-
-  g_return_if_fail (ximage != NULL);
-
-  ximagesink = ximage->ximagesink;
-  if (G_UNLIKELY (ximagesink == NULL)) {
-    GST_WARNING_OBJECT (ximagesink, "no sink found");
-    goto beach;
-  }
-
-  GST_OBJECT_LOCK (ximagesink);
-  running = ximagesink->running;
-  GST_OBJECT_UNLOCK (ximagesink);
-
-  if (running == FALSE) {
-    /* If the sink is shutting down, need to clear the image */
-    GST_DEBUG_OBJECT (ximagesink,
-        "destroy image %p because the sink is shutting down", ximage);
-    gst_ximagesink_ximage_destroy (ximagesink, ximage);
-  } else if ((ximage->width != GST_VIDEO_SINK_WIDTH (ximagesink)) ||
-      (ximage->height != GST_VIDEO_SINK_HEIGHT (ximagesink))) {
-    /* If our geometry changed we can't reuse that image. */
-    GST_DEBUG_OBJECT (ximagesink,
-        "destroy image %p as its size changed %dx%d vs current %dx%d",
-        ximage, ximage->width, ximage->height,
-        GST_VIDEO_SINK_WIDTH (ximagesink), GST_VIDEO_SINK_HEIGHT (ximagesink));
-    gst_ximagesink_ximage_destroy (ximagesink, ximage);
-  } else {
-    /* In that case we can reuse the image and add it to our image pool. */
-    GST_LOG_OBJECT (ximagesink, "recycling image %p in pool", ximage);
-    /* need to increment the refcount again to recycle */
-    gst_buffer_ref (GST_BUFFER_CAST (ximage));
-    g_mutex_lock (ximagesink->pool_lock);
-    ximagesink->buffer_pool = g_slist_prepend (ximagesink->buffer_pool, ximage);
-    g_mutex_unlock (ximagesink->pool_lock);
-    recycled = TRUE;
-  }
-
-  if (!recycled)
-    GST_MINI_OBJECT_CLASS (ximage_buffer_parent_class)->finalize
-        (GST_MINI_OBJECT (ximage));
-
-beach:
-  return;
-}
-
-static void
-gst_ximage_buffer_free (GstXImageBuffer * ximage)
-{
-  /* make sure it is not recycled */
-  ximage->width = -1;
-  ximage->height = -1;
-  gst_buffer_unref (GST_BUFFER_CAST (ximage));
-}
-
-static void
-gst_ximage_buffer_init (GstXImageBuffer * ximage_buffer, gpointer g_class)
-{
-#ifdef HAVE_XSHM
-  ximage_buffer->SHMInfo.shmaddr = ((void *) -1);
-  ximage_buffer->SHMInfo.shmid = -1;
-#endif
-}
-
-static void
-gst_ximage_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  ximage_buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_ximage_buffer_finalize;
-}
-
-static GType
-gst_ximage_buffer_get_type (void)
-{
-  static GType _gst_ximage_buffer_type;
-
-  if (G_UNLIKELY (_gst_ximage_buffer_type == 0)) {
-    static const GTypeInfo ximage_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_ximage_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstXImageBuffer),
-      0,
-      (GInstanceInitFunc) gst_ximage_buffer_init,
-      NULL
-    };
-    _gst_ximage_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstXImageBuffer", &ximage_buffer_info, 0);
-  }
-  return _gst_ximage_buffer_type;
-}
-
 /* X11 stuff */
 
-static gboolean error_caught = FALSE;
-
-static int
-gst_ximagesink_handle_xerror (Display * display, XErrorEvent * xevent)
-{
-  char error_msg[1024];
-
-  XGetErrorText (display, xevent->error_code, error_msg, 1024);
-  GST_DEBUG ("ximagesink triggered an XError. error: %s", error_msg);
-  error_caught = TRUE;
-  return 0;
-}
-
-#ifdef HAVE_XSHM                /* Check that XShm calls actually work */
-
-static gboolean
-gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
-    GstXContext * xcontext)
-{
-  XImage *ximage;
-  XShmSegmentInfo SHMInfo;
-  size_t size;
-  int (*handler) (Display *, XErrorEvent *);
-  gboolean result = FALSE;
-  gboolean did_attach = FALSE;
-
-  g_return_val_if_fail (xcontext != NULL, FALSE);
-
-  /* Sync to ensure any older errors are already processed */
-  XSync (xcontext->disp, FALSE);
-
-  /* Set defaults so we don't free these later unnecessarily */
-  SHMInfo.shmaddr = ((void *) -1);
-  SHMInfo.shmid = -1;
-
-  /* Setting an error handler to catch failure */
-  error_caught = FALSE;
-  handler = XSetErrorHandler (gst_ximagesink_handle_xerror);
-
-  /* Trying to create a 1x1 ximage */
-  GST_DEBUG ("XShmCreateImage of 1x1");
-
-  ximage = XShmCreateImage (xcontext->disp, xcontext->visual,
-      xcontext->depth, ZPixmap, NULL, &SHMInfo, 1, 1);
-
-  /* Might cause an error, sync to ensure it is noticed */
-  XSync (xcontext->disp, FALSE);
-  if (!ximage || error_caught) {
-    GST_WARNING ("could not XShmCreateImage a 1x1 image");
-    goto beach;
-  }
-  size = ximage->height * ximage->bytes_per_line;
-
-  SHMInfo.shmid = shmget (IPC_PRIVATE, size, IPC_CREAT | 0777);
-  if (SHMInfo.shmid == -1) {
-    GST_WARNING ("could not get shared memory of %" G_GSIZE_FORMAT " bytes",
-        size);
-    goto beach;
-  }
-
-  SHMInfo.shmaddr = shmat (SHMInfo.shmid, NULL, 0);
-  if (SHMInfo.shmaddr == ((void *) -1)) {
-    GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
-    /* Clean up shm seg */
-    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
-    goto beach;
-  }
-
-  ximage->data = SHMInfo.shmaddr;
-  SHMInfo.readOnly = FALSE;
-
-  if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
-    GST_WARNING ("Failed to XShmAttach");
-    /* Clean up shm seg */
-    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
-    goto beach;
-  }
-
-  /* Sync to ensure we see any errors we caused */
-  XSync (xcontext->disp, FALSE);
-
-  /* Delete the shared memory segment as soon as everyone is attached. 
-   * This way, it will be deleted as soon as we detach later, and not
-   * leaked if we crash. */
-  shmctl (SHMInfo.shmid, IPC_RMID, NULL);
-
-  if (!error_caught) {
-    did_attach = TRUE;
-    /* store whether we succeeded in result */
-    result = TRUE;
-  }
-
-beach:
-  /* Sync to ensure we swallow any errors we caused and reset error_caught */
-  XSync (xcontext->disp, FALSE);
-  error_caught = FALSE;
-  XSetErrorHandler (handler);
-
-  if (did_attach) {
-    XShmDetach (xcontext->disp, &SHMInfo);
-    XSync (xcontext->disp, FALSE);
-  }
-  if (SHMInfo.shmaddr != ((void *) -1))
-    shmdt (SHMInfo.shmaddr);
-  if (ximage)
-    XDestroyImage (ximage);
-  return result;
-}
-#endif /* HAVE_XSHM */
-
-/* This function handles GstXImageBuffer creation depending on XShm availability */
-static GstXImageBuffer *
-gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
-{
-  GstXImageBuffer *ximage = NULL;
-  GstStructure *structure = NULL;
-  gboolean succeeded = FALSE;
-  int (*handler) (Display *, XErrorEvent *);
-
-  g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
-
-  ximage = (GstXImageBuffer *) gst_mini_object_new (GST_TYPE_XIMAGE_BUFFER);
-
-  structure = gst_caps_get_structure (caps, 0);
-
-  if (!gst_structure_get_int (structure, "width", &ximage->width) ||
-      !gst_structure_get_int (structure, "height", &ximage->height)) {
-    GST_WARNING ("failed getting geometry from caps %" GST_PTR_FORMAT, caps);
-  }
-
-  GST_DEBUG_OBJECT (ximagesink, "creating image %p (%dx%d)", ximage,
-      ximage->width, ximage->height);
-
-  g_mutex_lock (ximagesink->x_lock);
-
-  /* Setting an error handler to catch failure */
-  error_caught = FALSE;
-  handler = XSetErrorHandler (gst_ximagesink_handle_xerror);
-
-#ifdef HAVE_XSHM
-  if (ximagesink->xcontext->use_xshm) {
-    ximage->ximage = XShmCreateImage (ximagesink->xcontext->disp,
-        ximagesink->xcontext->visual,
-        ximagesink->xcontext->depth,
-        ZPixmap, NULL, &ximage->SHMInfo, ximage->width, ximage->height);
-    if (!ximage->ximage || error_caught) {
-      g_mutex_unlock (ximagesink->x_lock);
-      /* Reset error handler */
-      error_caught = FALSE;
-      XSetErrorHandler (handler);
-      /* Push an error */
-      GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              ximage->width, ximage->height),
-          ("could not XShmCreateImage a %dx%d image",
-              ximage->width, ximage->height));
-      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;
-    GST_LOG_OBJECT (ximagesink,
-        "XShm image size is %" G_GSIZE_FORMAT ", width %d, stride %d",
-        ximage->size, ximage->width, ximage->ximage->bytes_per_line);
-
-    ximage->SHMInfo.shmid = shmget (IPC_PRIVATE, ximage->size,
-        IPC_CREAT | 0777);
-    if (ximage->SHMInfo.shmid == -1) {
-      g_mutex_unlock (ximagesink->x_lock);
-      GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              ximage->width, ximage->height),
-          ("could not get shared memory of %" G_GSIZE_FORMAT " bytes",
-              ximage->size));
-      goto beach;
-    }
-
-    ximage->SHMInfo.shmaddr = shmat (ximage->SHMInfo.shmid, NULL, 0);
-    if (ximage->SHMInfo.shmaddr == ((void *) -1)) {
-      g_mutex_unlock (ximagesink->x_lock);
-      GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              ximage->width, ximage->height),
-          ("Failed to shmat: %s", g_strerror (errno)));
-      /* Clean up the shared memory segment */
-      shmctl (ximage->SHMInfo.shmid, IPC_RMID, NULL);
-      goto beach;
-    }
-
-    ximage->ximage->data = ximage->SHMInfo.shmaddr;
-    ximage->SHMInfo.readOnly = FALSE;
-
-    if (XShmAttach (ximagesink->xcontext->disp, &ximage->SHMInfo) == 0) {
-      /* Clean up shm seg */
-      shmctl (ximage->SHMInfo.shmid, IPC_RMID, NULL);
-
-      g_mutex_unlock (ximagesink->x_lock);
-      GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              ximage->width, ximage->height), ("Failed to XShmAttach"));
-      goto beach;
-    }
-
-    XSync (ximagesink->xcontext->disp, FALSE);
-
-    /* Now that everyone has attached, we can delete the shared memory segment.
-     * This way, it will be deleted as soon as we detach later, and not
-     * leaked if we crash. */
-    shmctl (ximage->SHMInfo.shmid, IPC_RMID, NULL);
-
-  } else
-#endif /* HAVE_XSHM */
-  {
-    guint allocsize;
-
-    ximage->ximage = XCreateImage (ximagesink->xcontext->disp,
-        ximagesink->xcontext->visual,
-        ximagesink->xcontext->depth,
-        ZPixmap, 0, NULL,
-        ximage->width, ximage->height, ximagesink->xcontext->bpp, 0);
-    if (!ximage->ximage || error_caught) {
-      g_mutex_unlock (ximagesink->x_lock);
-      /* Reset error handler */
-      error_caught = FALSE;
-      XSetErrorHandler (handler);
-      /* Push an error */
-      GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              ximage->width, ximage->height),
-          ("could not XCreateImage a %dx%d image",
-              ximage->width, ximage->height));
-      goto beach;
-    }
-
-    /* upstream will assume that rowstrides are multiples of 4, but this
-     * doesn't always seem to be the case with XCreateImage() */
-    if ((ximage->ximage->bytes_per_line % 4) != 0) {
-      GST_WARNING_OBJECT (ximagesink, "returned stride not a multiple of 4 as "
-          "usually assumed");
-    }
-
-    /* we have to use the returned bytes_per_line for our image size */
-    ximage->size = ximage->ximage->bytes_per_line * ximage->ximage->height;
-
-    /* alloc a bit more for unexpected strides to avoid crashes upstream.
-     * FIXME: if we get an unrounded stride, the image will be displayed
-     * distorted, since all upstream elements assume a rounded stride */
-    allocsize =
-        GST_ROUND_UP_4 (ximage->ximage->bytes_per_line) *
-        ximage->ximage->height;
-    ximage->ximage->data = g_malloc (allocsize);
-    GST_LOG_OBJECT (ximagesink,
-        "non-XShm image size is %" G_GSIZE_FORMAT " (alloced: %u), width %d, "
-        "stride %d", ximage->size, allocsize, ximage->width,
-        ximage->ximage->bytes_per_line);
-
-    XSync (ximagesink->xcontext->disp, FALSE);
-  }
-
-  /* Reset error handler */
-  error_caught = FALSE;
-  XSetErrorHandler (handler);
-
-  succeeded = TRUE;
-
-  GST_BUFFER_DATA (ximage) = (guchar *) ximage->ximage->data;
-  GST_BUFFER_SIZE (ximage) = ximage->size;
-
-  /* Keep a ref to our sink */
-  ximage->ximagesink = gst_object_ref (ximagesink);
-
-  g_mutex_unlock (ximagesink->x_lock);
-beach:
-  if (!succeeded) {
-    gst_ximage_buffer_free (ximage);
-    ximage = NULL;
-  }
-
-  return ximage;
-}
-
-/* This function destroys a GstXImageBuffer handling XShm availability */
-static void
-gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink,
-    GstXImageBuffer * ximage)
-{
-  g_return_if_fail (ximage != NULL);
-  g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
-
-  /* Hold the object lock to ensure the XContext doesn't disappear */
-  GST_OBJECT_LOCK (ximagesink);
-
-  /* If the destroyed image is the current one we destroy our reference too */
-  if (ximagesink->cur_image == ximage) {
-    ximagesink->cur_image = NULL;
-  }
-
-  /* We might have some buffers destroyed after changing state to NULL */
-  if (!ximagesink->xcontext) {
-    GST_DEBUG_OBJECT (ximagesink, "Destroying XImage after XContext");
-#ifdef HAVE_XSHM
-    if (ximage->SHMInfo.shmaddr != ((void *) -1)) {
-      shmdt (ximage->SHMInfo.shmaddr);
-    }
-#endif
-    goto beach;
-  }
-
-  g_mutex_lock (ximagesink->x_lock);
-
-#ifdef HAVE_XSHM
-  if (ximagesink->xcontext->use_xshm) {
-    if (ximage->SHMInfo.shmaddr != ((void *) -1)) {
-      XShmDetach (ximagesink->xcontext->disp, &ximage->SHMInfo);
-      XSync (ximagesink->xcontext->disp, 0);
-      shmdt (ximage->SHMInfo.shmaddr);
-    }
-    if (ximage->ximage)
-      XDestroyImage (ximage->ximage);
-
-  } else
-#endif /* HAVE_XSHM */
-  {
-    if (ximage->ximage) {
-      XDestroyImage (ximage->ximage);
-    }
-  }
-
-  XSync (ximagesink->xcontext->disp, FALSE);
-
-  g_mutex_unlock (ximagesink->x_lock);
-
-beach:
-  GST_OBJECT_UNLOCK (ximagesink);
-
-  if (ximage->ximagesink) {
-    /* Release the ref to our sink */
-    ximage->ximagesink = NULL;
-    gst_object_unref (ximagesink);
-  }
-
-  return;
-}
-
 /* We are called with the x_lock taken */
 static void
 gst_ximagesink_xwindow_draw_borders (GstXImageSink * ximagesink,
@@ -669,13 +202,12 @@ gst_ximagesink_xwindow_draw_borders (GstXImageSink * ximagesink,
 
 /* This function puts a GstXImageBuffer on a GstXImageSink's window */
 static gboolean
-gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage)
+gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstBuffer * ximage)
 {
+  GstMetaXImage *meta;
   GstVideoRectangle src, dst, result;
   gboolean draw_border = FALSE;
 
-  g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), FALSE);
-
   /* We take the flow_lock. If expose is in there we don't want to run
      concurrently from the data flow thread */
   g_mutex_lock (ximagesink->flow_lock);
@@ -695,11 +227,10 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage)
   if (ximage && ximagesink->cur_image != ximage) {
     if (ximagesink->cur_image) {
       GST_LOG_OBJECT (ximagesink, "unreffing %p", ximagesink->cur_image);
-      gst_buffer_unref (GST_BUFFER_CAST (ximagesink->cur_image));
+      gst_buffer_unref (ximagesink->cur_image);
     }
     GST_LOG_OBJECT (ximagesink, "reffing %p as our current image", ximage);
-    ximagesink->cur_image =
-        GST_XIMAGE_BUFFER (gst_buffer_ref (GST_BUFFER_CAST (ximage)));
+    ximagesink->cur_image = gst_buffer_ref (ximage);
   }
 
   /* Expose sends a NULL image, we take the latest frame */
@@ -713,8 +244,10 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage)
     }
   }
 
-  src.w = ximage->width;
-  src.h = ximage->height;
+  meta = gst_buffer_get_meta_ximage (ximage);
+
+  src.w = meta->width;
+  src.h = meta->height;
   dst.w = ximagesink->xwindow->width;
   dst.h = ximagesink->xwindow->height;
 
@@ -734,7 +267,7 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage)
         ximage, 0, 0, result.x, result.y, result.w, result.h,
         ximagesink->xwindow->width, ximagesink->xwindow->height);
     XShmPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
-        ximagesink->xwindow->gc, ximage->ximage, 0, 0, result.x, result.y,
+        ximagesink->xwindow->gc, meta->ximage, 0, 0, result.x, result.y,
         result.w, result.h, FALSE);
   } else
 #endif /* HAVE_XSHM */
@@ -744,7 +277,7 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage)
         ximage, 0, 0, result.x, result.y, result.w, result.h,
         ximagesink->xwindow->width, ximagesink->xwindow->height);
     XPutImage (ximagesink->xcontext->disp, ximagesink->xwindow->win,
-        ximagesink->xwindow->gc, ximage->ximage, 0, 0, result.x, result.y,
+        ximagesink->xwindow->gc, meta->ximage, 0, 0, result.x, result.y,
         result.w, result.h);
   }
 
@@ -769,7 +302,8 @@ gst_ximagesink_xwindow_decorate (GstXImageSink * ximagesink,
 
   g_mutex_lock (ximagesink->x_lock);
 
-  hints_atom = XInternAtom (ximagesink->xcontext->disp, "_MOTIF_WM_HINTS", 1);
+  hints_atom = XInternAtom (ximagesink->xcontext->disp, "_MOTIF_WM_HINTS",
+      True);
   if (hints_atom == None) {
     g_mutex_unlock (ximagesink->x_lock);
     return FALSE;
@@ -853,7 +387,7 @@ gst_ximagesink_xwindow_new (GstXImageSink * ximagesink, gint width, gint height)
 
   xwindow->win = XCreateSimpleWindow (ximagesink->xcontext->disp,
       ximagesink->xcontext->root,
-      0, 0, xwindow->width, xwindow->height, 0, 0, ximagesink->xcontext->black);
+      0, 0, width, height, 0, 0, ximagesink->xcontext->black);
 
   /* We have to do that to prevent X from redrawing the background on 
      ConfigureNotify. This takes away flickering of video when resizing. */
@@ -1052,7 +586,6 @@ gst_ximagesink_handle_xevents (GstXImageSink * ximagesink)
           g_mutex_unlock (ximagesink->x_lock);
           gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
               e.type == KeyPress ? "key-press" : "key-release", key_str);
-
         } else {
           gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
               e.type == KeyPress ? "key-press" : "key-release", "unknown");
@@ -1066,6 +599,7 @@ gst_ximagesink_handle_xevents (GstXImageSink * ximagesink)
     g_mutex_lock (ximagesink->x_lock);
   }
 
+  /* Handle Expose */
   while (XCheckWindowEvent (ximagesink->xcontext->disp,
           ximagesink->xwindow->win, ExposureMask | StructureNotifyMask, &e)) {
     switch (e.type) {
@@ -1296,7 +830,7 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
     g_mutex_unlock (ximagesink->x_lock);
     g_free (xcontext->par);
     g_free (xcontext);
-    GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+    GST_ELEMENT_ERROR (ximagesink, RESOURCE, SETTINGS,
         ("Could not get supported pixmap formats"), (NULL));
     return NULL;
   }
@@ -1320,7 +854,7 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
     xcontext->use_xshm = TRUE;
     GST_DEBUG ("ximagesink is using XShm extension");
   } else
-#endif
+#endif /* HAVE_XSHM */
   {
     xcontext->use_xshm = FALSE;
     GST_DEBUG ("ximagesink is not using XShm extension");
@@ -1410,23 +944,6 @@ gst_ximagesink_xcontext_clear (GstXImageSink * ximagesink)
   g_free (xcontext);
 }
 
-static void
-gst_ximagesink_bufferpool_clear (GstXImageSink * ximagesink)
-{
-
-  g_mutex_lock (ximagesink->pool_lock);
-
-  while (ximagesink->buffer_pool) {
-    GstXImageBuffer *ximage = ximagesink->buffer_pool->data;
-
-    ximagesink->buffer_pool = g_slist_delete_link (ximagesink->buffer_pool,
-        ximagesink->buffer_pool);
-    gst_ximage_buffer_free (ximage);
-  }
-
-  g_mutex_unlock (ximagesink->pool_lock);
-}
-
 /* Element stuff */
 
 static GstCaps *
@@ -1465,8 +982,9 @@ static gboolean
 gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
 {
   GstXImageSink *ximagesink;
-  gboolean ret = TRUE;
   GstStructure *structure;
+  GstBufferPool *newpool, *oldpool;
+  gboolean ret = TRUE;
   const GValue *par;
   gint new_width, new_height;
   const GValue *fps;
@@ -1490,6 +1008,7 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
   ret &= gst_structure_get_int (structure, "height", &new_height);
   fps = gst_structure_get_value (structure, "framerate");
   ret &= (fps != NULL);
+
   if (!ret)
     return FALSE;
 
@@ -1524,11 +1043,8 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
 
   /* Creating our window and our image */
   if (GST_VIDEO_SINK_WIDTH (ximagesink) <= 0 ||
-      GST_VIDEO_SINK_HEIGHT (ximagesink) <= 0) {
-    GST_ELEMENT_ERROR (ximagesink, CORE, NEGOTIATION, (NULL),
-        ("Invalid image size."));
-    return FALSE;
-  }
+      GST_VIDEO_SINK_HEIGHT (ximagesink) <= 0)
+    goto invalid_size;
 
   g_mutex_lock (ximagesink->flow_lock);
   if (!ximagesink->xwindow) {
@@ -1537,18 +1053,28 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
   }
   /* Remember to draw borders for next frame */
   ximagesink->draw_border = TRUE;
-  g_mutex_unlock (ximagesink->flow_lock);
 
-  /* If our ximage has changed we destroy it, next chain iteration will create
-     a new one */
-  if ((ximagesink->ximage) &&
-      ((GST_VIDEO_SINK_WIDTH (ximagesink) != ximagesink->ximage->width) ||
-          (GST_VIDEO_SINK_HEIGHT (ximagesink) != ximagesink->ximage->height))) {
-    GST_DEBUG_OBJECT (ximagesink, "our image is not usable anymore, unref %p",
-        ximagesink->ximage);
-    gst_buffer_unref (GST_BUFFER_CAST (ximagesink->ximage));
-    ximagesink->ximage = NULL;
+  /* create a new pool for the new configuration */
+  newpool = gst_ximage_buffer_pool_new (ximagesink);
+
+  structure = gst_buffer_pool_get_config (newpool);
+  gst_buffer_pool_config_set (structure, caps, 0, 0, 0, 0, 0, 16);
+  if (!gst_buffer_pool_set_config (newpool, structure))
+    goto config_failed;
+
+  if (!gst_buffer_pool_set_active (newpool, TRUE))
+    goto activate_failed;
+
+  oldpool = ximagesink->pool;
+  ximagesink->pool = newpool;
+
+  /* unref the old sink */
+  if (oldpool) {
+    /* deactivate */
+    gst_buffer_pool_set_active (oldpool, FALSE);
+    gst_object_unref (oldpool);
   }
+  g_mutex_unlock (ximagesink->flow_lock);
 
   return TRUE;
 
@@ -1563,20 +1089,37 @@ wrong_aspect:
     GST_INFO_OBJECT (ximagesink, "pixel aspect ratio does not match");
     return FALSE;
   }
+invalid_size:
+  {
+    GST_ELEMENT_ERROR (ximagesink, CORE, NEGOTIATION, (NULL),
+        ("Invalid image size."));
+    return FALSE;
+  }
+config_failed:
+  {
+    GST_ERROR_OBJECT (ximagesink, "failed to set config.");
+    g_mutex_unlock (ximagesink->flow_lock);
+    return FALSE;
+  }
+activate_failed:
+  {
+    GST_ERROR_OBJECT (ximagesink, "failed to activate bufferpool.");
+    g_mutex_unlock (ximagesink->flow_lock);
+    return FALSE;
+  }
 }
 
 static GstStateChangeReturn
 gst_ximagesink_change_state (GstElement * element, GstStateChange transition)
 {
-  GstXImageSink *ximagesink;
   GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+  GstXImageSink *ximagesink;
   GstXContext *xcontext = NULL;
 
   ximagesink = GST_XIMAGESINK (element);
 
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
-
       /* Initializing the XContext */
       if (ximagesink->xcontext == NULL) {
         xcontext = gst_ximagesink_xcontext_get (ximagesink);
@@ -1620,6 +1163,10 @@ gst_ximagesink_change_state (GstElement * element, GstStateChange transition)
       ximagesink->fps_d = 1;
       GST_VIDEO_SINK_WIDTH (ximagesink) = 0;
       GST_VIDEO_SINK_HEIGHT (ximagesink) = 0;
+      g_mutex_lock (ximagesink->flow_lock);
+      if (ximagesink->pool)
+        gst_buffer_pool_set_active (ximagesink->pool, FALSE);
+      g_mutex_unlock (ximagesink->flow_lock);
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
       gst_ximagesink_reset (ximagesink);
@@ -1657,70 +1204,93 @@ gst_ximagesink_get_times (GstBaseSink * bsink, GstBuffer * buf,
 static GstFlowReturn
 gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
 {
+  GstFlowReturn res;
   GstXImageSink *ximagesink;
-
-  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
+  GstMetaXImage *meta;
+  GstBuffer *temp;
+  gboolean unref;
 
   ximagesink = GST_XIMAGESINK (vsink);
 
-  /* This shouldn't really happen because state changes will fail
-   * if the xcontext can't be allocated */
-  if (!ximagesink->xcontext)
-    return GST_FLOW_ERROR;
+  meta = gst_buffer_get_meta_ximage (buf);
 
-  /* If this buffer has been allocated using our buffer management we simply
-     put the ximage which is in the PRIVATE pointer */
-  if (GST_IS_XIMAGE_BUFFER (buf)) {
+  if (meta) {
+    /* If this buffer has been allocated using our buffer management we simply
+       put the ximage which is in the PRIVATE pointer */
     GST_LOG_OBJECT (ximagesink, "buffer from our pool, writing directly");
-    if (!gst_ximagesink_ximage_put (ximagesink, GST_XIMAGE_BUFFER (buf)))
-      goto no_window;
+    res = GST_FLOW_OK;
+    unref = FALSE;
   } else {
+    guint8 *data;
+    gsize size;
+
     /* Else we have to copy the data into our private image, */
     /* if we have one... */
-    GST_LOG_OBJECT (ximagesink, "normal buffer, copying from it");
-    if (!ximagesink->ximage) {
-      GST_DEBUG_OBJECT (ximagesink, "creating our ximage");
-      ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
-          GST_BUFFER_CAPS (buf));
-      if (!ximagesink->ximage)
-        /* The create method should have posted an informative error */
-        goto no_ximage;
-
-      if (ximagesink->ximage->size < GST_BUFFER_SIZE (buf)) {
-        GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
-            ("Failed to create output image buffer of %dx%d pixels",
-                ximagesink->ximage->width, ximagesink->ximage->height),
-            ("XServer allocated buffer size did not match input buffer"));
-
-        gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
-        ximagesink->ximage = NULL;
-        goto no_ximage;
-      }
-    }
-    memcpy (GST_BUFFER_DATA (ximagesink->ximage), GST_BUFFER_DATA (buf),
-        MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size));
-    if (!gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage))
-      goto no_window;
+    GST_LOG_OBJECT (ximagesink, "buffer not from our pool, copying");
+
+    /* we should have a pool, configured in setcaps */
+    if (ximagesink->pool == NULL)
+      goto no_pool;
+
+    /* take a buffer form our pool */
+    res = gst_buffer_pool_acquire_buffer (ximagesink->pool, &temp, NULL);
+    if (res != GST_FLOW_OK)
+      goto no_buffer;
+
+    unref = TRUE;
+
+    if (gst_buffer_get_size (temp) < gst_buffer_get_size (buf))
+      goto wrong_size;
+
+    data = gst_buffer_map (temp, &size, NULL, GST_MAP_WRITE);
+    gst_buffer_extract (buf, 0, data, size);
+    gst_buffer_unmap (temp, data, size);
+
+    buf = temp;
   }
 
-  return GST_FLOW_OK;
+  if (!gst_ximagesink_ximage_put (ximagesink, buf))
+    goto no_window;
+
+done:
+  if (unref)
+    gst_buffer_unref (buf);
+
+  return res;
 
   /* ERRORS */
-no_ximage:
+no_pool:
+  {
+    GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+        ("Internal error: can't allocate images"),
+        ("We don't have a bufferpool negotiated"));
+    return GST_FLOW_ERROR;
+  }
+no_buffer:
   {
     /* No image available. That's very bad ! */
     GST_WARNING_OBJECT (ximagesink, "could not create image");
-    return GST_FLOW_ERROR;
+    return res;
+  }
+wrong_size:
+  {
+    GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer"),
+        ("XServer allocated buffer size did not match input buffer %"
+            G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (temp),
+            gst_buffer_get_size (buf)));
+    res = GST_FLOW_ERROR;
+    goto done;
   }
 no_window:
   {
     /* No Window available to put our image into */
     GST_WARNING_OBJECT (ximagesink, "could not output image - no window");
-    return GST_FLOW_ERROR;
+    res = GST_FLOW_ERROR;
+    goto done;
   }
 }
 
-
 static gboolean
 gst_ximagesink_event (GstBaseSink * sink, GstEvent * event)
 {
@@ -1752,7 +1322,6 @@ gst_ximagesink_event (GstBaseSink * sink, GstEvent * event)
     return TRUE;
 }
 
-
 /* Buffer management
  *
  * The buffer_alloc function must either return a buffer with given size and
@@ -1768,7 +1337,7 @@ gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
     GstCaps * caps, GstBuffer ** buf)
 {
   GstXImageSink *ximagesink;
-  GstXImageBuffer *ximage = NULL;
+  GstBuffer *ximage = NULL;
   GstStructure *structure = NULL;
   GstFlowReturn ret = GST_FLOW_OK;
   GstCaps *alloc_caps;
@@ -1896,44 +1465,33 @@ gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
   }
 
 alloc:
-  /* Inspect our buffer pool */
-  g_mutex_lock (ximagesink->pool_lock);
-  while (ximagesink->buffer_pool) {
-    ximage = (GstXImageBuffer *) ximagesink->buffer_pool->data;
-
-    if (ximage) {
-      /* Removing from the pool */
-      ximagesink->buffer_pool = g_slist_delete_link (ximagesink->buffer_pool,
-          ximagesink->buffer_pool);
-
-      /* If the ximage is invalid for our need, destroy */
-      if ((ximage->width != width) || (ximage->height != height)) {
-        gst_ximage_buffer_free (ximage);
-        ximage = NULL;
-      } else {
-        /* We found a suitable ximage */
-        break;
-      }
+
+  if (gst_caps_is_equal (GST_PAD_CAPS (bsink->sinkpad), alloc_caps)) {
+    /* we negotiated this format before, use the pool */
+    if (ximagesink->pool) {
+      GST_LOG_OBJECT (ximagesink, "retrieving buffer from pool");
+      ret = gst_buffer_pool_acquire_buffer (ximagesink->pool, &ximage, NULL);
     }
   }
-  g_mutex_unlock (ximagesink->pool_lock);
 
-  /* We haven't found anything, creating a new one */
-  if (!ximage) {
-    ximage = gst_ximagesink_ximage_new (ximagesink, alloc_caps);
+  if (ximage == NULL) {
+    /* Something new make a new image a new one */
+    GST_LOG_OBJECT (ximagesink, "allocating new image");
+    ximage = gst_ximage_buffer_new (ximagesink, width, height);
   }
+
   /* Now we should have a ximage, set appropriate caps on it */
   if (ximage) {
     /* Make sure the buffer is cleared of any previously used flags */
     GST_MINI_OBJECT_CAST (ximage)->flags = 0;
-    gst_buffer_set_caps (GST_BUFFER_CAST (ximage), alloc_caps);
+    gst_buffer_set_caps (ximage, alloc_caps);
   }
 
   /* could be our new reffed suggestion or the original unreffed caps */
   if (alloc_unref)
     gst_caps_unref (alloc_caps);
 
-  *buf = GST_BUFFER_CAST (ximage);
+  *buf = ximage;
 
 beach:
   return ret;
@@ -2264,18 +1822,18 @@ gst_ximagesink_reset (GstXImageSink * ximagesink)
   if (thread)
     g_thread_join (thread);
 
-  if (ximagesink->ximage) {
-    gst_buffer_unref (GST_BUFFER_CAST (ximagesink->ximage));
-    ximagesink->ximage = NULL;
-  }
   if (ximagesink->cur_image) {
-    gst_buffer_unref (GST_BUFFER_CAST (ximagesink->cur_image));
+    gst_buffer_unref (ximagesink->cur_image);
     ximagesink->cur_image = NULL;
   }
 
-  gst_ximagesink_bufferpool_clear (ximagesink);
-
   g_mutex_lock (ximagesink->flow_lock);
+
+  if (ximagesink->pool) {
+    gst_object_unref (ximagesink->pool);
+    ximagesink->pool = NULL;
+  }
+
   if (ximagesink->xwindow) {
     gst_ximagesink_xwindow_clear (ximagesink, ximagesink->xwindow);
     gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);
@@ -2311,10 +1869,6 @@ gst_ximagesink_finalize (GObject * object)
     g_mutex_free (ximagesink->flow_lock);
     ximagesink->flow_lock = NULL;
   }
-  if (ximagesink->pool_lock) {
-    g_mutex_free (ximagesink->pool_lock);
-    ximagesink->pool_lock = NULL;
-  }
 
   g_free (ximagesink->media_title);
 
@@ -2327,7 +1881,6 @@ gst_ximagesink_init (GstXImageSink * ximagesink)
   ximagesink->display_name = NULL;
   ximagesink->xcontext = NULL;
   ximagesink->xwindow = NULL;
-  ximagesink->ximage = NULL;
   ximagesink->cur_image = NULL;
 
   ximagesink->event_thread = NULL;
@@ -2341,8 +1894,7 @@ gst_ximagesink_init (GstXImageSink * ximagesink)
 
   ximagesink->par = NULL;
 
-  ximagesink->pool_lock = g_mutex_new ();
-  ximagesink->buffer_pool = NULL;
+  ximagesink->pool = NULL;
 
   ximagesink->synchronous = FALSE;
   ximagesink->keep_aspect = FALSE;
@@ -2494,7 +2046,7 @@ gst_ximagesink_get_type (void)
     /* register type and create class in a more safe place instead of at
      * runtime since the type registration and class creation is not
      * threadsafe. */
-    g_type_class_ref (gst_ximage_buffer_get_type ());
+    g_type_class_ref (gst_ximage_buffer_pool_get_type ());
   }
 
   return ximagesink_type;
index 83e973f..b47dcde 100644 (file)
@@ -49,15 +49,15 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_XIMAGESINK))
 #define GST_IS_XIMAGESINK_CLASS(klass) \
   (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XIMAGESINK))
+
 typedef struct _GstXContext GstXContext;
 typedef struct _GstXWindow GstXWindow;
 
-typedef struct _GstXImageBuffer GstXImageBuffer;
-typedef struct _GstXImageBufferClass GstXImageBufferClass;
-
 typedef struct _GstXImageSink GstXImageSink;
 typedef struct _GstXImageSinkClass GstXImageSinkClass;
 
+#include "ximagepool.h"
+
 /*
  * GstXContext:
  * @disp: the X11 Display of this context
@@ -130,33 +130,6 @@ struct _GstXWindow
 };
 
 /**
- * GstXImageBuffer:
- * @ximagesink: a reference to our #GstXImageSink
- * @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.
- */
-struct _GstXImageBuffer
-{
-  GstBuffer buffer;
-
-  /* Reference to the ximagesink we belong to */
-  GstXImageSink *ximagesink;
-
-  XImage *ximage;
-
-#ifdef HAVE_XSHM
-  XShmSegmentInfo SHMInfo;
-#endif                          /* HAVE_XSHM */
-
-  gint width, height;
-  size_t size;
-};
-
-/**
  * GstXImageSink:
  * @display_name: the name of the Display we want to render to
  * @xcontext: our instance's #GstXContext
@@ -194,8 +167,7 @@ struct _GstXImageSink
 
   GstXContext *xcontext;
   GstXWindow *xwindow;
-  GstXImageBuffer *ximage;
-  GstXImageBuffer *cur_image;
+  GstBuffer *cur_image;
 
   GThread *event_thread;
   gboolean running;
@@ -210,8 +182,8 @@ struct _GstXImageSink
   /* object-set pixel aspect ratio */
   GValue *par;
 
-  GMutex *pool_lock;
-  GSList *buffer_pool;
+  /* the buffer pool */
+  GstBufferPool *pool;
 
   gboolean synchronous;
   gboolean keep_aspect;
index fbff4d8..9669e72 100644 (file)
@@ -1,6 +1,6 @@
 plugin_LTLIBRARIES = libgstxvimagesink.la
 
-libgstxvimagesink_la_SOURCES =  xvimagesink.c 
+libgstxvimagesink_la_SOURCES =  xvimagesink.c xvimage.c xvimagepool.c 
 libgstxvimagesink_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(X_CFLAGS)
 libgstxvimagesink_la_LIBADD = \
        $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-$(GST_MAJORMINOR).la \
@@ -12,4 +12,4 @@ libgstxvimagesink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstxvimagesink_la_DEPENDENCIES = $(top_builddir)/gst-libs/gst/video/libgstvideo-$(GST_MAJORMINOR).la
 libgstxvimagesink_la_LIBTOOLFLAGS = --tag=disable-static
 
-noinst_HEADERS = xvimagesink.h 
+noinst_HEADERS = xvimagesink.h xvimagepool.h
diff --git a/sys/xvimage/xvimage.c b/sys/xvimage/xvimage.c
new file mode 100644 (file)
index 0000000..5e2d619
--- /dev/null
@@ -0,0 +1,51 @@
+/* GStreamer
+ * Copyright (C) <2003> Julien Moutte <julien@moutte.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xvimagesink.h"
+
+GST_DEBUG_CATEGORY (gst_debug_xvimagepool);
+GST_DEBUG_CATEGORY (gst_debug_xvimagesink);
+GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  if (!gst_element_register (plugin, "xvimagesink",
+          GST_RANK_PRIMARY, GST_TYPE_XVIMAGESINK))
+    return FALSE;
+
+  GST_DEBUG_CATEGORY_INIT (gst_debug_xvimagesink, "xvimagesink", 0,
+      "xvimagesink element");
+  GST_DEBUG_CATEGORY_INIT (gst_debug_xvimagepool, "xvimagepool", 0,
+      "xvimagepool object");
+
+  GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
+
+  return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    "xvimagesink",
+    "XFree86 video output plugin using Xv extension",
+    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/sys/xvimage/xvimagepool.c b/sys/xvimage/xvimagepool.c
new file mode 100644 (file)
index 0000000..e320f55
--- /dev/null
@@ -0,0 +1,644 @@
+/* GStreamer
+ * Copyright (C) <2005> Julien Moutte <julien@moutte.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* Object header */
+#include "xvimagesink.h"
+
+/* Debugging category */
+#include <gst/gstinfo.h>
+
+GST_DEBUG_CATEGORY_EXTERN (gst_debug_xvimagepool);
+#define GST_CAT_DEFAULT gst_debug_xvimagepool
+
+static void gst_meta_xvimage_free (GstMetaXvImage * meta, GstBuffer * buffer);
+
+/* xvimage metadata */
+const GstMetaInfo *
+gst_meta_xvimage_get_info (void)
+{
+  static const GstMetaInfo *meta_xvimage_info = NULL;
+
+  if (meta_xvimage_info == NULL) {
+    meta_xvimage_info = gst_meta_register ("GstMetaXvImage", "GstMetaXvImage",
+        sizeof (GstMetaXvImage),
+        (GstMetaInitFunction) NULL,
+        (GstMetaFreeFunction) gst_meta_xvimage_free,
+        (GstMetaCopyFunction) NULL,
+        (GstMetaTransformFunction) NULL,
+        (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+  }
+  return meta_xvimage_info;
+}
+
+/* X11 stuff */
+static gboolean error_caught = FALSE;
+
+static int
+gst_xvimagesink_handle_xerror (Display * display, XErrorEvent * xevent)
+{
+  char error_msg[1024];
+
+  XGetErrorText (display, xevent->error_code, error_msg, 1024);
+  GST_DEBUG ("xvimagesink triggered an XError. error: %s", error_msg);
+  error_caught = TRUE;
+  return 0;
+}
+
+GstMetaXvImage *
+gst_buffer_add_meta_xvimage (GstBuffer * buffer, GstXvImageSink * xvimagesink,
+    gint width, gint height, gint im_format)
+{
+  int (*handler) (Display *, XErrorEvent *);
+  gboolean success = FALSE;
+  GstXContext *xcontext;
+  GstMetaXvImage *meta;
+
+  xcontext = xvimagesink->xcontext;
+
+  meta =
+      (GstMetaXvImage *) gst_buffer_add_meta (buffer, GST_META_INFO_XVIMAGE,
+      NULL);
+#ifdef HAVE_XSHM
+  meta->SHMInfo.shmaddr = ((void *) -1);
+  meta->SHMInfo.shmid = -1;
+#endif
+  meta->width = width;
+  meta->height = height;
+  meta->sink = gst_object_ref (xvimagesink);
+  meta->im_format = im_format;
+
+  GST_DEBUG_OBJECT (xvimagesink, "creating image %p (%dx%d)", buffer,
+      meta->width, meta->height);
+
+  g_mutex_lock (xvimagesink->x_lock);
+
+  /* Setting an error handler to catch failure */
+  error_caught = FALSE;
+  handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
+
+#ifdef HAVE_XSHM
+  if (xcontext->use_xshm) {
+    int expected_size;
+
+    meta->xvimage = XvShmCreateImage (xcontext->disp,
+        xcontext->xv_port_id,
+        meta->im_format, NULL, meta->width, meta->height, &meta->SHMInfo);
+    if (!meta->xvimage || error_caught)
+      goto create_failed;
+
+    /* we have to use the returned data_size for our shm size */
+    meta->size = meta->xvimage->data_size;
+    GST_LOG_OBJECT (xvimagesink, "XShm image size is %" G_GSIZE_FORMAT,
+        meta->size);
+
+    /* calculate the expected size.  This is only for sanity checking the
+     * number we get from X. */
+    switch (meta->im_format) {
+      case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+      case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+      {
+        gint pitches[3];
+        gint offsets[3];
+        guint plane;
+
+        offsets[0] = 0;
+        pitches[0] = GST_ROUND_UP_4 (meta->width);
+        offsets[1] = offsets[0] + pitches[0] * GST_ROUND_UP_2 (meta->height);
+        pitches[1] = GST_ROUND_UP_8 (meta->width) / 2;
+        offsets[2] =
+            offsets[1] + pitches[1] * GST_ROUND_UP_2 (meta->height) / 2;
+        pitches[2] = GST_ROUND_UP_8 (pitches[0]) / 2;
+
+        expected_size =
+            offsets[2] + pitches[2] * GST_ROUND_UP_2 (meta->height) / 2;
+
+        for (plane = 0; plane < meta->xvimage->num_planes; plane++) {
+          GST_DEBUG_OBJECT (xvimagesink,
+              "Plane %u has a expected pitch of %d bytes, " "offset of %d",
+              plane, pitches[plane], offsets[plane]);
+        }
+        break;
+      }
+      case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+      case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+        expected_size = meta->height * GST_ROUND_UP_4 (meta->width * 2);
+        break;
+      default:
+        expected_size = 0;
+        break;
+    }
+    if (expected_size != 0 && meta->size != expected_size) {
+      GST_WARNING_OBJECT (xvimagesink,
+          "unexpected XShm image size (got %" G_GSIZE_FORMAT ", expected %d)",
+          meta->size, expected_size);
+    }
+
+    /* Be verbose about our XvImage stride */
+    {
+      guint plane;
+
+      for (plane = 0; plane < meta->xvimage->num_planes; plane++) {
+        GST_DEBUG_OBJECT (xvimagesink, "Plane %u has a pitch of %d bytes, "
+            "offset of %d", plane, meta->xvimage->pitches[plane],
+            meta->xvimage->offsets[plane]);
+      }
+    }
+
+    /* get shared memory */
+    meta->SHMInfo.shmid = shmget (IPC_PRIVATE, meta->size, IPC_CREAT | 0777);
+    if (meta->SHMInfo.shmid == -1)
+      goto shmget_failed;
+
+    /* attach */
+    meta->SHMInfo.shmaddr = shmat (meta->SHMInfo.shmid, NULL, 0);
+    if (meta->SHMInfo.shmaddr == ((void *) -1))
+      goto shmat_failed;
+
+    /* now we can set up the image data */
+    meta->xvimage->data = meta->SHMInfo.shmaddr;
+    meta->SHMInfo.readOnly = FALSE;
+
+    if (XShmAttach (xcontext->disp, &meta->SHMInfo) == 0)
+      goto xattach_failed;
+
+    XSync (xcontext->disp, FALSE);
+
+    /* Delete the shared memory segment as soon as we everyone is attached.
+     * This way, it will be deleted as soon as we detach later, and not
+     * leaked if we crash. */
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, NULL);
+
+    GST_DEBUG_OBJECT (xvimagesink, "XServer ShmAttached to 0x%x, id 0x%lx",
+        meta->SHMInfo.shmid, meta->SHMInfo.shmseg);
+  } else
+#endif /* HAVE_XSHM */
+  {
+    meta->xvimage = XvCreateImage (xcontext->disp,
+        xcontext->xv_port_id, meta->im_format, NULL, meta->width, meta->height);
+    if (!meta->xvimage || error_caught)
+      goto create_failed;
+
+    /* we have to use the returned data_size for our image size */
+    meta->size = meta->xvimage->data_size;
+    meta->xvimage->data = g_malloc (meta->size);
+
+    XSync (xcontext->disp, FALSE);
+  }
+
+  /* Reset error handler */
+  error_caught = FALSE;
+  XSetErrorHandler (handler);
+
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, meta->xvimage->data,
+          NULL, meta->size, 0, meta->size));
+
+  g_mutex_unlock (xvimagesink->x_lock);
+
+  success = TRUE;
+
+beach:
+  if (!success)
+    meta = NULL;
+
+  return meta;
+
+  /* ERRORS */
+create_failed:
+  {
+    g_mutex_unlock (xvimagesink->x_lock);
+    /* Reset error handler */
+    error_caught = FALSE;
+    XSetErrorHandler (handler);
+    /* Push an error */
+    GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height),
+        ("could not XvShmCreateImage a %dx%d image", meta->width,
+            meta->height));
+    goto beach;
+  }
+shmget_failed:
+  {
+    g_mutex_unlock (xvimagesink->x_lock);
+    GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height),
+        ("could not get shared memory of %" G_GSIZE_FORMAT " bytes",
+            meta->size));
+    goto beach;
+  }
+shmat_failed:
+  {
+    g_mutex_unlock (xvimagesink->x_lock);
+    GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height),
+        ("Failed to shmat: %s", g_strerror (errno)));
+    /* Clean up the shared memory segment */
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, NULL);
+    goto beach;
+  }
+xattach_failed:
+  {
+    /* Clean up the shared memory segment */
+    shmctl (meta->SHMInfo.shmid, IPC_RMID, NULL);
+    g_mutex_unlock (xvimagesink->x_lock);
+
+    GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            meta->width, meta->height), ("Failed to XShmAttach"));
+    goto beach;
+  }
+}
+
+static void
+gst_meta_xvimage_free (GstMetaXvImage * meta, GstBuffer * buffer)
+{
+  GstXvImageSink *xvimagesink;
+
+  xvimagesink = meta->sink;
+
+  GST_DEBUG_OBJECT (xvimagesink, "free meta on buffer %p", buffer);
+
+  /* Hold the object lock to ensure the XContext doesn't disappear */
+  GST_OBJECT_LOCK (xvimagesink);
+  /* We might have some buffers destroyed after changing state to NULL */
+  if (xvimagesink->xcontext == NULL) {
+    GST_DEBUG_OBJECT (xvimagesink, "Destroying XvImage after Xcontext");
+#ifdef HAVE_XSHM
+    /* Need to free the shared memory segment even if the x context
+     * was already cleaned up */
+    if (meta->SHMInfo.shmaddr != ((void *) -1)) {
+      shmdt (meta->SHMInfo.shmaddr);
+    }
+#endif
+    goto beach;
+  }
+
+  g_mutex_lock (xvimagesink->x_lock);
+
+#ifdef HAVE_XSHM
+  if (xvimagesink->xcontext->use_xshm) {
+    if (meta->SHMInfo.shmaddr != ((void *) -1)) {
+      GST_DEBUG_OBJECT (xvimagesink, "XServer ShmDetaching from 0x%x id 0x%lx",
+          meta->SHMInfo.shmid, meta->SHMInfo.shmseg);
+      XShmDetach (xvimagesink->xcontext->disp, &meta->SHMInfo);
+      XSync (xvimagesink->xcontext->disp, FALSE);
+      shmdt (meta->SHMInfo.shmaddr);
+      meta->SHMInfo.shmaddr = (void *) -1;
+    }
+    if (meta->xvimage)
+      XFree (meta->xvimage);
+  } else
+#endif /* HAVE_XSHM */
+  {
+    if (meta->xvimage) {
+      g_free (meta->xvimage->data);
+      XFree (meta->xvimage);
+    }
+  }
+
+  XSync (xvimagesink->xcontext->disp, FALSE);
+
+  g_mutex_unlock (xvimagesink->x_lock);
+
+beach:
+  GST_OBJECT_UNLOCK (xvimagesink);
+
+  gst_object_unref (meta->sink);
+}
+
+GstBuffer *
+gst_xvimage_buffer_new (GstXvImageSink * xvimagesink, gint width, gint height,
+    gint im_format)
+{
+  GstBuffer *buffer;
+  GstMetaXvImage *meta;
+
+  buffer = gst_buffer_new ();
+  meta =
+      gst_buffer_add_meta_xvimage (buffer, xvimagesink, width, height,
+      im_format);
+  if (meta == NULL) {
+    gst_buffer_unref (buffer);
+    buffer = NULL;
+  }
+  return buffer;
+}
+
+#ifdef HAVE_XSHM
+/* This function checks that it is actually really possible to create an image
+   using XShm */
+gboolean
+gst_xvimagesink_check_xshm_calls (GstXvImageSink * xvimagesink,
+    GstXContext * xcontext)
+{
+  XvImage *xvimage;
+  XShmSegmentInfo SHMInfo;
+  size_t size;
+  int (*handler) (Display *, XErrorEvent *);
+  gboolean result = FALSE;
+  gboolean did_attach = FALSE;
+
+  g_return_val_if_fail (xcontext != NULL, FALSE);
+
+  /* Sync to ensure any older errors are already processed */
+  XSync (xcontext->disp, FALSE);
+
+  /* Set defaults so we don't free these later unnecessarily */
+  SHMInfo.shmaddr = ((void *) -1);
+  SHMInfo.shmid = -1;
+
+  /* Setting an error handler to catch failure */
+  error_caught = FALSE;
+  handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
+
+  /* Trying to create a 1x1 picture */
+  GST_DEBUG ("XvShmCreateImage of 1x1");
+  xvimage = XvShmCreateImage (xcontext->disp, xcontext->xv_port_id,
+      xcontext->im_format, NULL, 1, 1, &SHMInfo);
+
+  /* Might cause an error, sync to ensure it is noticed */
+  XSync (xcontext->disp, FALSE);
+  if (!xvimage || error_caught) {
+    GST_WARNING ("could not XvShmCreateImage a 1x1 image");
+    goto beach;
+  }
+  size = xvimage->data_size;
+
+  SHMInfo.shmid = shmget (IPC_PRIVATE, size, IPC_CREAT | 0777);
+  if (SHMInfo.shmid == -1) {
+    GST_WARNING ("could not get shared memory of %" G_GSIZE_FORMAT " bytes",
+        size);
+    goto beach;
+  }
+
+  SHMInfo.shmaddr = shmat (SHMInfo.shmid, NULL, 0);
+  if (SHMInfo.shmaddr == ((void *) -1)) {
+    GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
+    /* Clean up the shared memory segment */
+    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
+    goto beach;
+  }
+
+  xvimage->data = SHMInfo.shmaddr;
+  SHMInfo.readOnly = FALSE;
+
+  if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
+    GST_WARNING ("Failed to XShmAttach");
+    /* Clean up the shared memory segment */
+    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
+    goto beach;
+  }
+
+  /* Sync to ensure we see any errors we caused */
+  XSync (xcontext->disp, FALSE);
+
+  /* Delete the shared memory segment as soon as everyone is attached.
+   * This way, it will be deleted as soon as we detach later, and not
+   * leaked if we crash. */
+  shmctl (SHMInfo.shmid, IPC_RMID, NULL);
+
+  if (!error_caught) {
+    GST_DEBUG ("XServer ShmAttached to 0x%x, id 0x%lx", SHMInfo.shmid,
+        SHMInfo.shmseg);
+
+    did_attach = TRUE;
+    /* store whether we succeeded in result */
+    result = TRUE;
+  } else {
+    GST_WARNING ("MIT-SHM extension check failed at XShmAttach. "
+        "Not using shared memory.");
+  }
+
+beach:
+  /* Sync to ensure we swallow any errors we caused and reset error_caught */
+  XSync (xcontext->disp, FALSE);
+
+  error_caught = FALSE;
+  XSetErrorHandler (handler);
+
+  if (did_attach) {
+    GST_DEBUG ("XServer ShmDetaching from 0x%x id 0x%lx",
+        SHMInfo.shmid, SHMInfo.shmseg);
+    XShmDetach (xcontext->disp, &SHMInfo);
+    XSync (xcontext->disp, FALSE);
+  }
+  if (SHMInfo.shmaddr != ((void *) -1))
+    shmdt (SHMInfo.shmaddr);
+  if (xvimage)
+    XFree (xvimage);
+  return result;
+}
+#endif /* HAVE_XSHM */
+
+/* bufferpool */
+static void gst_xvimage_buffer_pool_finalize (GObject * object);
+
+#define GST_XVIMAGE_BUFFER_POOL_GET_PRIVATE(obj)  \
+   (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_XVIMAGE_BUFFER_POOL, GstXvImageBufferPoolPrivate))
+
+struct _GstXvImageBufferPoolPrivate
+{
+  GstCaps *caps;
+  gint width, height;
+  gint im_format;
+};
+
+G_DEFINE_TYPE (GstXvImageBufferPool, gst_xvimage_buffer_pool,
+    GST_TYPE_BUFFER_POOL);
+
+static gboolean
+xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
+{
+  GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
+  GstXvImageBufferPoolPrivate *priv = xvpool->priv;
+  GstStructure *structure;
+  gint width, height;
+  const GstCaps *caps;
+
+  if (!gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL,
+          NULL, NULL))
+    goto wrong_config;
+
+  if (caps == NULL)
+    goto no_caps;
+
+  /* now parse the caps from the config */
+  structure = gst_caps_get_structure (caps, 0);
+
+  if (!gst_structure_get_int (structure, "width", &width) ||
+      !gst_structure_get_int (structure, "height", &height))
+    goto wrong_caps;
+
+  GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, width, height, caps);
+
+  /* keep track of the width and height and caps */
+  if (priv->caps)
+    gst_caps_unref (priv->caps);
+  priv->caps = gst_caps_copy (caps);
+  priv->width = width;
+  priv->height = height;
+  priv->im_format =
+      gst_xvimagesink_get_format_from_caps (xvpool->sink, (GstCaps *) caps);
+
+  if (priv->im_format == -1) {
+    GST_WARNING_OBJECT (xvpool->sink, "failed to get format from caps %"
+        GST_PTR_FORMAT, caps);
+    GST_ELEMENT_ERROR (xvpool->sink, RESOURCE, WRITE,
+        ("Failed to create output image buffer of %dx%d pixels",
+            priv->width, priv->height), ("Invalid input caps"));
+    goto wrong_config;
+  }
+
+  return TRUE;
+
+  /* ERRORS */
+wrong_config:
+  {
+    GST_WARNING_OBJECT (pool, "invalid config");
+    return FALSE;
+  }
+no_caps:
+  {
+    GST_WARNING_OBJECT (pool, "no caps in config");
+    return FALSE;
+  }
+wrong_caps:
+  {
+    GST_WARNING_OBJECT (pool,
+        "failed getting geometry from caps %" GST_PTR_FORMAT, caps);
+    return FALSE;
+  }
+}
+
+/* This function handles GstXImageBuffer creation depending on XShm availability */
+static GstFlowReturn
+xvimage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
+    GstBufferPoolParams * params)
+{
+  GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
+  GstXvImageBufferPoolPrivate *priv = xvpool->priv;
+  GstBuffer *xvimage;
+
+  xvimage =
+      gst_xvimage_buffer_new (xvpool->sink, priv->width, priv->height,
+      priv->im_format);
+  if (xvimage == NULL)
+    goto no_buffer;
+
+  *buffer = xvimage;
+
+  return GST_FLOW_OK;
+
+  /* ERROR */
+no_buffer:
+  {
+    GST_WARNING_OBJECT (pool, "can't create image");
+    return GST_FLOW_ERROR;
+  }
+}
+
+static void
+xvimage_buffer_pool_free (GstBufferPool * pool, GstBuffer * buffer)
+{
+  gst_buffer_unref (buffer);
+}
+
+GstBufferPool *
+gst_xvimage_buffer_pool_new (GstXvImageSink * xvimagesink)
+{
+  GstXvImageBufferPool *pool;
+
+  g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
+
+  pool = g_object_new (GST_TYPE_XVIMAGE_BUFFER_POOL, NULL);
+  pool->sink = gst_object_ref (xvimagesink);
+
+  GST_LOG_OBJECT (pool, "new XvImage buffer pool %p", pool);
+
+  return GST_BUFFER_POOL_CAST (pool);
+}
+
+static void
+gst_xvimage_buffer_pool_class_init (GstXvImageBufferPoolClass * klass)
+{
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
+
+  g_type_class_add_private (klass, sizeof (GstXvImageBufferPoolPrivate));
+
+  gobject_class->finalize = gst_xvimage_buffer_pool_finalize;
+
+  gstbufferpool_class->set_config = xvimage_buffer_pool_set_config;
+  gstbufferpool_class->alloc_buffer = xvimage_buffer_pool_alloc;
+  gstbufferpool_class->free_buffer = xvimage_buffer_pool_free;
+}
+
+static void
+gst_xvimage_buffer_pool_init (GstXvImageBufferPool * pool)
+{
+  pool->priv = GST_XVIMAGE_BUFFER_POOL_GET_PRIVATE (pool);
+}
+
+static void
+gst_xvimage_buffer_pool_finalize (GObject * object)
+{
+  GstXvImageBufferPool *pool = GST_XVIMAGE_BUFFER_POOL_CAST (object);
+  GstXvImageBufferPoolPrivate *priv = pool->priv;
+
+  GST_LOG_OBJECT (pool, "finalize XvImage buffer pool %p", pool);
+
+  if (priv->caps)
+    gst_caps_unref (priv->caps);
+  gst_object_unref (pool->sink);
+
+  G_OBJECT_CLASS (gst_xvimage_buffer_pool_parent_class)->finalize (object);
+}
+
+/* This function tries to get a format matching with a given caps in the
+   supported list of formats we generated in gst_xvimagesink_get_xv_support */
+gint
+gst_xvimagesink_get_format_from_caps (GstXvImageSink * xvimagesink,
+    GstCaps * caps)
+{
+  GList *list = NULL;
+
+  g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), 0);
+
+  list = xvimagesink->xcontext->formats_list;
+
+  while (list) {
+    GstXvImageFormat *format = list->data;
+
+    if (format) {
+      if (gst_caps_can_intersect (caps, format->caps)) {
+        return format->format;
+      }
+    }
+    list = g_list_next (list);
+  }
+
+  return -1;
+}
diff --git a/sys/xvimage/xvimagepool.h b/sys/xvimage/xvimagepool.h
new file mode 100644 (file)
index 0000000..d927251
--- /dev/null
@@ -0,0 +1,120 @@
+/* GStreamer
+ * Copyright (C) <2005> Julien Moutte <julien@moutte.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_XVIMAGEPOOL_H__
+#define __GST_XVIMAGEPOOL_H__
+
+#ifdef HAVE_XSHM
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif /* HAVE_XSHM */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#ifdef HAVE_XSHM
+#include <X11/extensions/XShm.h>
+#endif /* HAVE_XSHM */
+
+#include <string.h>
+#include <math.h>
+
+
+G_BEGIN_DECLS
+
+typedef struct _GstMetaXvImage GstMetaXvImage;
+
+typedef struct _GstXvImageBufferPool GstXvImageBufferPool;
+typedef struct _GstXvImageBufferPoolClass GstXvImageBufferPoolClass;
+typedef struct _GstXvImageBufferPoolPrivate GstXvImageBufferPoolPrivate;
+
+#include "xvimagesink.h"
+
+const GstMetaInfo * gst_meta_xvimage_get_info (void);
+#define GST_META_INFO_XVIMAGE  (gst_meta_xvimage_get_info())
+
+#define gst_buffer_get_meta_xvimage(b) ((GstMetaXvImage*)gst_buffer_get_meta((b),GST_META_INFO_XVIMAGE))
+GstMetaXvImage * gst_buffer_add_meta_xvimage   (GstBuffer *buffer, GstXvImageSink * xvimagesink,
+                                                gint width, gint height, gint im_format);
+
+/**
+ * GstMetaXvImage:
+ * @sink: a reference to the our #GstXvImageSink
+ * @xvimage: the XvImage of this buffer
+ * @width: the width in pixels of XvImage @xvimage
+ * @height: the height in pixels of XvImage @xvimage
+ * @im_format: the format of XvImage @xvimage
+ * @size: the size in bytes of XvImage @xvimage
+ *
+ * Subclass of #GstMeta containing additional information about an XvImage.
+ */
+struct _GstMetaXvImage
+{
+  GstMeta meta;
+
+  /* Reference to the xvimagesink we belong to */
+  GstXvImageSink *sink;
+
+  XvImage *xvimage;
+
+#ifdef HAVE_XSHM
+  XShmSegmentInfo SHMInfo;
+#endif                          /* HAVE_XSHM */
+
+  gint width, height, im_format;
+  size_t size;
+};
+
+GstBuffer *gst_xvimage_buffer_new (GstXvImageSink *xvimagesink, gint width, gint height,
+    gint in_format);
+
+/* buffer pool functions */
+#define GST_TYPE_XVIMAGE_BUFFER_POOL      (gst_xvimage_buffer_pool_get_type())
+#define GST_IS_XVIMAGE_BUFFER_POOL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XVIMAGE_BUFFER_POOL))
+#define GST_XVIMAGE_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XVIMAGE_BUFFER_POOL, GstXvImageBufferPool))
+#define GST_XVIMAGE_BUFFER_POOL_CAST(obj) ((GstXvImageBufferPool*)(obj))
+
+struct _GstXvImageBufferPool
+{
+  GstBufferPool bufferpool;
+
+  GstXvImageSink *sink;
+
+  GstXvImageBufferPoolPrivate *priv;
+};
+
+struct _GstXvImageBufferPoolClass
+{
+  GstBufferPoolClass parent_class;
+};
+
+GType gst_xvimage_buffer_pool_get_type (void);
+
+GstBufferPool *gst_xvimage_buffer_pool_new (GstXvImageSink * xvimagesink);
+
+gboolean gst_xvimagesink_check_xshm_calls (GstXvImageSink * xvimagesink,
+      GstXContext * xcontext);
+
+gint gst_xvimagesink_get_format_from_caps (GstXvImageSink * xvimagesink,
+    GstCaps * caps);
+
+G_END_DECLS
+
+#endif /*__GST_XVIMAGEPOOL_H__*/
index 51b2d9c..6159f2a 100644 (file)
 
 /* Debugging category */
 #include <gst/gstinfo.h>
-GST_DEBUG_CATEGORY_STATIC (gst_debug_xvimagesink);
+
+GST_DEBUG_CATEGORY_EXTERN (gst_debug_xvimagesink);
+GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
 #define GST_CAT_DEFAULT gst_debug_xvimagesink
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
 
 typedef struct
 {
@@ -143,14 +144,8 @@ MotifWmHints, MwmHints;
 #define MWM_HINTS_DECORATIONS   (1L << 1)
 
 static void gst_xvimagesink_reset (GstXvImageSink * xvimagesink);
-
-static GstBufferClass *xvimage_buffer_parent_class = NULL;
-static void gst_xvimage_buffer_finalize (GstXvImageBuffer * xvimage);
-
 static void gst_xvimagesink_xwindow_update_geometry (GstXvImageSink *
     xvimagesink);
-static gint gst_xvimagesink_get_format_from_caps (GstXvImageSink * xvimagesink,
-    GstCaps * caps);
 static void gst_xvimagesink_expose (GstXOverlay * overlay);
 
 /* Default template - initiated with class struct to allow gst-register to work
@@ -199,528 +194,6 @@ static GstVideoSinkClass *parent_class = NULL;
 /*                                                               */
 /* ============================================================= */
 
-/* xvimage buffers */
-
-#define GST_TYPE_XVIMAGE_BUFFER (gst_xvimage_buffer_get_type())
-
-#define GST_IS_XVIMAGE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XVIMAGE_BUFFER))
-#define GST_XVIMAGE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XVIMAGE_BUFFER, GstXvImageBuffer))
-#define GST_XVIMAGE_BUFFER_CAST(obj) ((GstXvImageBuffer *)(obj))
-
-/* This function destroys a GstXvImage handling XShm availability */
-static void
-gst_xvimage_buffer_destroy (GstXvImageBuffer * xvimage)
-{
-  GstXvImageSink *xvimagesink;
-
-  GST_DEBUG_OBJECT (xvimage, "Destroying buffer");
-
-  xvimagesink = xvimage->xvimagesink;
-  if (G_UNLIKELY (xvimagesink == NULL))
-    goto no_sink;
-
-  g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
-  GST_OBJECT_LOCK (xvimagesink);
-
-  /* If the destroyed image is the current one we destroy our reference too */
-  if (xvimagesink->cur_image == xvimage)
-    xvimagesink->cur_image = NULL;
-
-  /* We might have some buffers destroyed after changing state to NULL */
-  if (xvimagesink->xcontext == NULL) {
-    GST_DEBUG_OBJECT (xvimagesink, "Destroying XvImage after Xcontext");
-#ifdef HAVE_XSHM
-    /* Need to free the shared memory segment even if the x context
-     * was already cleaned up */
-    if (xvimage->SHMInfo.shmaddr != ((void *) -1)) {
-      shmdt (xvimage->SHMInfo.shmaddr);
-    }
-#endif
-    goto beach;
-  }
-
-  g_mutex_lock (xvimagesink->x_lock);
-
-#ifdef HAVE_XSHM
-  if (xvimagesink->xcontext->use_xshm) {
-    if (xvimage->SHMInfo.shmaddr != ((void *) -1)) {
-      GST_DEBUG_OBJECT (xvimagesink, "XServer ShmDetaching from 0x%x id 0x%lx",
-          xvimage->SHMInfo.shmid, xvimage->SHMInfo.shmseg);
-      XShmDetach (xvimagesink->xcontext->disp, &xvimage->SHMInfo);
-      XSync (xvimagesink->xcontext->disp, FALSE);
-
-      shmdt (xvimage->SHMInfo.shmaddr);
-    }
-    if (xvimage->xvimage)
-      XFree (xvimage->xvimage);
-  } else
-#endif /* HAVE_XSHM */
-  {
-    if (xvimage->xvimage) {
-      if (xvimage->xvimage->data) {
-        g_free (xvimage->xvimage->data);
-      }
-      XFree (xvimage->xvimage);
-    }
-  }
-
-  XSync (xvimagesink->xcontext->disp, FALSE);
-
-  g_mutex_unlock (xvimagesink->x_lock);
-
-beach:
-  GST_OBJECT_UNLOCK (xvimagesink);
-  xvimage->xvimagesink = NULL;
-  gst_object_unref (xvimagesink);
-
-  GST_MINI_OBJECT_CLASS (xvimage_buffer_parent_class)->finalize (GST_MINI_OBJECT
-      (xvimage));
-
-  return;
-
-no_sink:
-  {
-    GST_WARNING ("no sink found");
-    return;
-  }
-}
-
-static void
-gst_xvimage_buffer_finalize (GstXvImageBuffer * xvimage)
-{
-  GstXvImageSink *xvimagesink;
-  gboolean running;
-
-  xvimagesink = xvimage->xvimagesink;
-  if (G_UNLIKELY (xvimagesink == NULL))
-    goto no_sink;
-
-  g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
-
-  GST_OBJECT_LOCK (xvimagesink);
-  running = xvimagesink->running;
-  GST_OBJECT_UNLOCK (xvimagesink);
-
-  /* If our geometry changed we can't reuse that image. */
-  if (running == FALSE) {
-    GST_LOG_OBJECT (xvimage, "destroy image as sink is shutting down");
-    gst_xvimage_buffer_destroy (xvimage);
-  } else if ((xvimage->width != xvimagesink->video_width) ||
-      (xvimage->height != xvimagesink->video_height)) {
-    GST_LOG_OBJECT (xvimage,
-        "destroy image as its size changed %dx%d vs current %dx%d",
-        xvimage->width, xvimage->height,
-        xvimagesink->video_width, xvimagesink->video_height);
-    gst_xvimage_buffer_destroy (xvimage);
-  } else {
-    /* In that case we can reuse the image and add it to our image pool. */
-    GST_LOG_OBJECT (xvimage, "recycling image in pool");
-    /* need to increment the refcount again to recycle */
-    gst_buffer_ref (GST_BUFFER_CAST (xvimage));
-    g_mutex_lock (xvimagesink->pool_lock);
-    xvimagesink->image_pool = g_slist_prepend (xvimagesink->image_pool,
-        xvimage);
-    g_mutex_unlock (xvimagesink->pool_lock);
-  }
-  return;
-
-no_sink:
-  {
-    GST_WARNING ("no sink found");
-    return;
-  }
-}
-
-static void
-gst_xvimage_buffer_free (GstXvImageBuffer * xvimage)
-{
-  /* make sure it is not recycled */
-  xvimage->width = -1;
-  xvimage->height = -1;
-  gst_buffer_unref (GST_BUFFER (xvimage));
-}
-
-static void
-gst_xvimage_buffer_init (GstXvImageBuffer * xvimage, gpointer g_class)
-{
-#ifdef HAVE_XSHM
-  xvimage->SHMInfo.shmaddr = ((void *) -1);
-  xvimage->SHMInfo.shmid = -1;
-#endif
-}
-
-static void
-gst_xvimage_buffer_class_init (gpointer g_class, gpointer class_data)
-{
-  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
-  xvimage_buffer_parent_class = g_type_class_peek_parent (g_class);
-
-  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-      gst_xvimage_buffer_finalize;
-}
-
-static GType
-gst_xvimage_buffer_get_type (void)
-{
-  static GType _gst_xvimage_buffer_type;
-
-  if (G_UNLIKELY (_gst_xvimage_buffer_type == 0)) {
-    static const GTypeInfo xvimage_buffer_info = {
-      sizeof (GstBufferClass),
-      NULL,
-      NULL,
-      gst_xvimage_buffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstXvImageBuffer),
-      0,
-      (GInstanceInitFunc) gst_xvimage_buffer_init,
-      NULL
-    };
-    _gst_xvimage_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
-        "GstXvImageBuffer", &xvimage_buffer_info, 0);
-  }
-  return _gst_xvimage_buffer_type;
-}
-
-/* X11 stuff */
-
-static gboolean error_caught = FALSE;
-
-static int
-gst_xvimagesink_handle_xerror (Display * display, XErrorEvent * xevent)
-{
-  char error_msg[1024];
-
-  XGetErrorText (display, xevent->error_code, error_msg, 1024);
-  GST_DEBUG ("xvimagesink triggered an XError. error: %s", error_msg);
-  error_caught = TRUE;
-  return 0;
-}
-
-#ifdef HAVE_XSHM
-/* This function checks that it is actually really possible to create an image
-   using XShm */
-static gboolean
-gst_xvimagesink_check_xshm_calls (GstXContext * xcontext)
-{
-  XvImage *xvimage;
-  XShmSegmentInfo SHMInfo;
-  gint size;
-  int (*handler) (Display *, XErrorEvent *);
-  gboolean result = FALSE;
-  gboolean did_attach = FALSE;
-
-  g_return_val_if_fail (xcontext != NULL, FALSE);
-
-  /* Sync to ensure any older errors are already processed */
-  XSync (xcontext->disp, FALSE);
-
-  /* Set defaults so we don't free these later unnecessarily */
-  SHMInfo.shmaddr = ((void *) -1);
-  SHMInfo.shmid = -1;
-
-  /* Setting an error handler to catch failure */
-  error_caught = FALSE;
-  handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
-
-  /* Trying to create a 1x1 picture */
-  GST_DEBUG ("XvShmCreateImage of 1x1");
-  xvimage = XvShmCreateImage (xcontext->disp, xcontext->xv_port_id,
-      xcontext->im_format, NULL, 1, 1, &SHMInfo);
-
-  /* Might cause an error, sync to ensure it is noticed */
-  XSync (xcontext->disp, FALSE);
-  if (!xvimage || error_caught) {
-    GST_WARNING ("could not XvShmCreateImage a 1x1 image");
-    goto beach;
-  }
-  size = xvimage->data_size;
-
-  SHMInfo.shmid = shmget (IPC_PRIVATE, size, IPC_CREAT | 0777);
-  if (SHMInfo.shmid == -1) {
-    GST_WARNING ("could not get shared memory of %d bytes", size);
-    goto beach;
-  }
-
-  SHMInfo.shmaddr = shmat (SHMInfo.shmid, NULL, 0);
-  if (SHMInfo.shmaddr == ((void *) -1)) {
-    GST_WARNING ("Failed to shmat: %s", g_strerror (errno));
-    /* Clean up the shared memory segment */
-    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
-    goto beach;
-  }
-
-  xvimage->data = SHMInfo.shmaddr;
-  SHMInfo.readOnly = FALSE;
-
-  if (XShmAttach (xcontext->disp, &SHMInfo) == 0) {
-    GST_WARNING ("Failed to XShmAttach");
-    /* Clean up the shared memory segment */
-    shmctl (SHMInfo.shmid, IPC_RMID, NULL);
-    goto beach;
-  }
-
-  /* Sync to ensure we see any errors we caused */
-  XSync (xcontext->disp, FALSE);
-
-  /* Delete the shared memory segment as soon as everyone is attached.
-   * This way, it will be deleted as soon as we detach later, and not
-   * leaked if we crash. */
-  shmctl (SHMInfo.shmid, IPC_RMID, NULL);
-
-  if (!error_caught) {
-    GST_DEBUG ("XServer ShmAttached to 0x%x, id 0x%lx", SHMInfo.shmid,
-        SHMInfo.shmseg);
-
-    did_attach = TRUE;
-    /* store whether we succeeded in result */
-    result = TRUE;
-  } else {
-    GST_WARNING ("MIT-SHM extension check failed at XShmAttach. "
-        "Not using shared memory.");
-  }
-
-beach:
-  /* Sync to ensure we swallow any errors we caused and reset error_caught */
-  XSync (xcontext->disp, FALSE);
-
-  error_caught = FALSE;
-  XSetErrorHandler (handler);
-
-  if (did_attach) {
-    GST_DEBUG ("XServer ShmDetaching from 0x%x id 0x%lx",
-        SHMInfo.shmid, SHMInfo.shmseg);
-    XShmDetach (xcontext->disp, &SHMInfo);
-    XSync (xcontext->disp, FALSE);
-  }
-  if (SHMInfo.shmaddr != ((void *) -1))
-    shmdt (SHMInfo.shmaddr);
-  if (xvimage)
-    XFree (xvimage);
-  return result;
-}
-#endif /* HAVE_XSHM */
-
-/* This function handles GstXvImage creation depending on XShm availability */
-static GstXvImageBuffer *
-gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps)
-{
-  GstXvImageBuffer *xvimage = NULL;
-  GstStructure *structure = NULL;
-  gboolean succeeded = FALSE;
-  int (*handler) (Display *, XErrorEvent *);
-
-  g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
-
-  if (caps == NULL)
-    return NULL;
-
-  xvimage = (GstXvImageBuffer *) gst_mini_object_new (GST_TYPE_XVIMAGE_BUFFER);
-  GST_DEBUG_OBJECT (xvimage, "Creating new XvImageBuffer");
-
-  structure = gst_caps_get_structure (caps, 0);
-
-  if (!gst_structure_get_int (structure, "width", &xvimage->width) ||
-      !gst_structure_get_int (structure, "height", &xvimage->height)) {
-    GST_WARNING ("failed getting geometry from caps %" GST_PTR_FORMAT, caps);
-  }
-
-  GST_LOG_OBJECT (xvimagesink, "creating %dx%d", xvimage->width,
-      xvimage->height);
-
-  xvimage->im_format = gst_xvimagesink_get_format_from_caps (xvimagesink, caps);
-  if (xvimage->im_format == -1) {
-    GST_WARNING_OBJECT (xvimagesink, "failed to get format from caps %"
-        GST_PTR_FORMAT, caps);
-    GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
-        ("Failed to create output image buffer of %dx%d pixels",
-            xvimage->width, xvimage->height), ("Invalid input caps"));
-    goto beach_unlocked;
-  }
-  xvimage->xvimagesink = gst_object_ref (xvimagesink);
-
-  g_mutex_lock (xvimagesink->x_lock);
-
-  /* Setting an error handler to catch failure */
-  error_caught = FALSE;
-  handler = XSetErrorHandler (gst_xvimagesink_handle_xerror);
-
-#ifdef HAVE_XSHM
-  if (xvimagesink->xcontext->use_xshm) {
-    int expected_size;
-
-    xvimage->xvimage = XvShmCreateImage (xvimagesink->xcontext->disp,
-        xvimagesink->xcontext->xv_port_id,
-        xvimage->im_format, NULL,
-        xvimage->width, xvimage->height, &xvimage->SHMInfo);
-    if (!xvimage->xvimage || error_caught) {
-      g_mutex_unlock (xvimagesink->x_lock);
-      /* Reset error handler */
-      error_caught = FALSE;
-      XSetErrorHandler (handler);
-      /* Push an error */
-      GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              xvimage->width, xvimage->height),
-          ("could not XvShmCreateImage a %dx%d image",
-              xvimage->width, xvimage->height));
-      goto beach_unlocked;
-    }
-
-    /* we have to use the returned data_size for our shm size */
-    xvimage->size = xvimage->xvimage->data_size;
-    GST_LOG_OBJECT (xvimagesink, "XShm image size is %" G_GSIZE_FORMAT,
-        xvimage->size);
-
-    /* calculate the expected size.  This is only for sanity checking the
-     * number we get from X. */
-    switch (xvimage->im_format) {
-      case GST_MAKE_FOURCC ('I', '4', '2', '0'):
-      case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
-      {
-        gint pitches[3];
-        gint offsets[3];
-        guint plane;
-
-        offsets[0] = 0;
-        pitches[0] = GST_ROUND_UP_4 (xvimage->width);
-        offsets[1] = offsets[0] + pitches[0] * GST_ROUND_UP_2 (xvimage->height);
-        pitches[1] = GST_ROUND_UP_8 (xvimage->width) / 2;
-        offsets[2] =
-            offsets[1] + pitches[1] * GST_ROUND_UP_2 (xvimage->height) / 2;
-        pitches[2] = GST_ROUND_UP_8 (pitches[0]) / 2;
-
-        expected_size =
-            offsets[2] + pitches[2] * GST_ROUND_UP_2 (xvimage->height) / 2;
-
-        for (plane = 0; plane < xvimage->xvimage->num_planes; plane++) {
-          GST_DEBUG_OBJECT (xvimagesink,
-              "Plane %u has a expected pitch of %d bytes, " "offset of %d",
-              plane, pitches[plane], offsets[plane]);
-        }
-        break;
-      }
-      case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
-      case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
-        expected_size = xvimage->height * GST_ROUND_UP_4 (xvimage->width * 2);
-        break;
-      default:
-        expected_size = 0;
-        break;
-    }
-    if (expected_size != 0 && xvimage->size != expected_size) {
-      GST_WARNING_OBJECT (xvimagesink,
-          "unexpected XShm image size (got %" G_GSIZE_FORMAT ", expected %d)",
-          xvimage->size, expected_size);
-    }
-
-    /* Be verbose about our XvImage stride */
-    {
-      guint plane;
-
-      for (plane = 0; plane < xvimage->xvimage->num_planes; plane++) {
-        GST_DEBUG_OBJECT (xvimagesink, "Plane %u has a pitch of %d bytes, "
-            "offset of %d", plane, xvimage->xvimage->pitches[plane],
-            xvimage->xvimage->offsets[plane]);
-      }
-    }
-
-    xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
-        IPC_CREAT | 0777);
-    if (xvimage->SHMInfo.shmid == -1) {
-      g_mutex_unlock (xvimagesink->x_lock);
-      GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              xvimage->width, xvimage->height),
-          ("could not get shared memory of %" G_GSIZE_FORMAT " bytes",
-              xvimage->size));
-      goto beach_unlocked;
-    }
-
-    xvimage->SHMInfo.shmaddr = shmat (xvimage->SHMInfo.shmid, NULL, 0);
-    if (xvimage->SHMInfo.shmaddr == ((void *) -1)) {
-      g_mutex_unlock (xvimagesink->x_lock);
-      GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              xvimage->width, xvimage->height),
-          ("Failed to shmat: %s", g_strerror (errno)));
-      /* Clean up the shared memory segment */
-      shmctl (xvimage->SHMInfo.shmid, IPC_RMID, NULL);
-      goto beach_unlocked;
-    }
-
-    xvimage->xvimage->data = xvimage->SHMInfo.shmaddr;
-    xvimage->SHMInfo.readOnly = FALSE;
-
-    if (XShmAttach (xvimagesink->xcontext->disp, &xvimage->SHMInfo) == 0) {
-      /* Clean up the shared memory segment */
-      shmctl (xvimage->SHMInfo.shmid, IPC_RMID, NULL);
-
-      g_mutex_unlock (xvimagesink->x_lock);
-      GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
-          ("Failed to create output image buffer of %dx%d pixels",
-              xvimage->width, xvimage->height), ("Failed to XShmAttach"));
-      goto beach_unlocked;
-    }
-
-    XSync (xvimagesink->xcontext->disp, FALSE);
-
-    /* Delete the shared memory segment as soon as we everyone is attached.
-     * This way, it will be deleted as soon as we detach later, and not
-     * leaked if we crash. */
-    shmctl (xvimage->SHMInfo.shmid, IPC_RMID, NULL);
-
-    GST_DEBUG_OBJECT (xvimagesink, "XServer ShmAttached to 0x%x, id 0x%lx",
-        xvimage->SHMInfo.shmid, xvimage->SHMInfo.shmseg);
-  } else
-#endif /* HAVE_XSHM */
-  {
-    xvimage->xvimage = XvCreateImage (xvimagesink->xcontext->disp,
-        xvimagesink->xcontext->xv_port_id,
-        xvimage->im_format, NULL, xvimage->width, xvimage->height);
-    if (!xvimage->xvimage || error_caught) {
-      g_mutex_unlock (xvimagesink->x_lock);
-      /* Reset error handler */
-      error_caught = FALSE;
-      XSetErrorHandler (handler);
-      /* Push an error */
-      GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
-          ("Failed to create outputimage buffer of %dx%d pixels",
-              xvimage->width, xvimage->height),
-          ("could not XvCreateImage a %dx%d image",
-              xvimage->width, xvimage->height));
-      goto beach_unlocked;
-    }
-
-    /* we have to use the returned data_size for our image size */
-    xvimage->size = xvimage->xvimage->data_size;
-    xvimage->xvimage->data = g_malloc (xvimage->size);
-
-    XSync (xvimagesink->xcontext->disp, FALSE);
-  }
-
-  /* Reset error handler */
-  error_caught = FALSE;
-  XSetErrorHandler (handler);
-
-  succeeded = TRUE;
-
-  GST_BUFFER_DATA (xvimage) = (guchar *) xvimage->xvimage->data;
-  GST_BUFFER_SIZE (xvimage) = xvimage->size;
-
-  g_mutex_unlock (xvimagesink->x_lock);
-
-beach_unlocked:
-  if (!succeeded) {
-    gst_xvimage_buffer_free (xvimage);
-    xvimage = NULL;
-  }
-
-  return xvimage;
-}
 
 /* We are called with the x_lock taken */
 static void
@@ -769,9 +242,9 @@ gst_xvimagesink_xwindow_draw_borders (GstXvImageSink * xvimagesink,
 /* This function puts a GstXvImage on a GstXvImageSink's window. Returns FALSE
  * if no window was available  */
 static gboolean
-gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink,
-    GstXvImageBuffer * xvimage)
+gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink, GstBuffer * xvimage)
 {
+  GstMetaXvImage *meta;
   GstVideoRectangle result;
   gboolean draw_border = FALSE;
 
@@ -794,11 +267,10 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink,
   if (xvimage && xvimagesink->cur_image != xvimage) {
     if (xvimagesink->cur_image) {
       GST_LOG_OBJECT (xvimagesink, "unreffing %p", xvimagesink->cur_image);
-      gst_buffer_unref (GST_BUFFER_CAST (xvimagesink->cur_image));
+      gst_buffer_unref (xvimagesink->cur_image);
     }
     GST_LOG_OBJECT (xvimagesink, "reffing %p as our current image", xvimage);
-    xvimagesink->cur_image =
-        GST_XVIMAGE_BUFFER_CAST (gst_buffer_ref (GST_BUFFER_CAST (xvimage)));
+    xvimagesink->cur_image = gst_buffer_ref (xvimage);
   }
 
   /* Expose sends a NULL image, we take the latest frame */
@@ -812,6 +284,8 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink,
     }
   }
 
+  meta = gst_buffer_get_meta_xvimage (xvimage);
+
   if (xvimagesink->keep_aspect) {
     GstVideoRectangle src, dst;
 
@@ -836,20 +310,17 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink,
         result);
     xvimagesink->redraw_border = FALSE;
   }
-
-  /* We scale to the window's geometry */
 #ifdef HAVE_XSHM
   if (xvimagesink->xcontext->use_xshm) {
     GST_LOG_OBJECT (xvimagesink,
         "XvShmPutImage with image %dx%d and window %dx%d, from xvimage %"
-        GST_PTR_FORMAT,
-        xvimage->width, xvimage->height,
+        GST_PTR_FORMAT, meta->width, meta->height,
         xvimagesink->render_rect.w, xvimagesink->render_rect.h, xvimage);
 
     XvShmPutImage (xvimagesink->xcontext->disp,
         xvimagesink->xcontext->xv_port_id,
         xvimagesink->xwindow->win,
-        xvimagesink->xwindow->gc, xvimage->xvimage,
+        xvimagesink->xwindow->gc, meta->xvimage,
         xvimagesink->disp_x, xvimagesink->disp_y,
         xvimagesink->disp_width, xvimagesink->disp_height,
         result.x, result.y, result.w, result.h, FALSE);
@@ -859,7 +330,7 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink,
     XvPutImage (xvimagesink->xcontext->disp,
         xvimagesink->xcontext->xv_port_id,
         xvimagesink->xwindow->win,
-        xvimagesink->xwindow->gc, xvimage->xvimage,
+        xvimagesink->xwindow->gc, meta->xvimage,
         xvimagesink->disp_x, xvimagesink->disp_y,
         xvimagesink->disp_width, xvimagesink->disp_height,
         result.x, result.y, result.w, result.h);
@@ -1196,6 +667,7 @@ gst_xvimagesink_handle_xevents (GstXvImageSink * xvimagesink)
     g_mutex_lock (xvimagesink->flow_lock);
     g_mutex_lock (xvimagesink->x_lock);
   }
+
   if (pointer_moved) {
     g_mutex_unlock (xvimagesink->x_lock);
     g_mutex_unlock (xvimagesink->flow_lock);
@@ -1261,7 +733,8 @@ gst_xvimagesink_handle_xevents (GstXvImageSink * xvimagesink)
         }
         break;
       default:
-        GST_DEBUG ("xvimagesink unhandled X event (%d)", e.type);
+        GST_DEBUG_OBJECT (xvimagesink, "xvimagesink unhandled X event (%d)",
+            e.type);
     }
     g_mutex_lock (xvimagesink->flow_lock);
     g_mutex_lock (xvimagesink->x_lock);
@@ -1727,6 +1200,7 @@ gst_xvimagesink_calculate_pixel_aspect_ratio (GstXContext * xcontext)
     ratio = 4.0 * 576 / (3.0 * 720);
   }
   GST_DEBUG ("calculated pixel aspect ratio: %f", ratio);
+
   /* now find the one from par[][2] with the lowest delta to the real one */
   delta = DELTA (0);
   index = 0;
@@ -1843,18 +1317,10 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
 
   xcontext->caps = gst_xvimagesink_get_xv_support (xvimagesink, xcontext);
 
-  if (!xcontext->caps) {
-    XCloseDisplay (xcontext->disp);
-    g_mutex_unlock (xvimagesink->x_lock);
-    g_free (xcontext->par);
-    g_free (xcontext);
-    /* GST_ELEMENT_ERROR is thrown by gst_xvimagesink_get_xv_support */
-    return NULL;
-  }
-#ifdef HAVE_XSHM
   /* Search for XShm extension support */
+#ifdef HAVE_XSHM
   if (XShmQueryExtension (xcontext->disp) &&
-      gst_xvimagesink_check_xshm_calls (xcontext)) {
+      gst_xvimagesink_check_xshm_calls (xvimagesink, xcontext)) {
     xcontext->use_xshm = TRUE;
     GST_DEBUG ("xvimagesink is using XShm extension");
   } else
@@ -1864,6 +1330,15 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink)
     GST_DEBUG ("xvimagesink is not using XShm extension");
   }
 
+  if (!xcontext->caps) {
+    XCloseDisplay (xcontext->disp);
+    g_mutex_unlock (xvimagesink->x_lock);
+    g_free (xcontext->par);
+    g_free (xcontext);
+    /* GST_ELEMENT_ERROR is thrown by gst_xvimagesink_get_xv_support */
+    return NULL;
+  }
+
   xv_attr = XvQueryPortAttributes (xcontext->disp,
       xcontext->xv_port_id, &N_attr);
 
@@ -2000,50 +1475,8 @@ gst_xvimagesink_xcontext_clear (GstXvImageSink * xvimagesink)
   g_free (xcontext);
 }
 
-static void
-gst_xvimagesink_imagepool_clear (GstXvImageSink * xvimagesink)
-{
-  g_mutex_lock (xvimagesink->pool_lock);
-
-  while (xvimagesink->image_pool) {
-    GstXvImageBuffer *xvimage = xvimagesink->image_pool->data;
-
-    xvimagesink->image_pool = g_slist_delete_link (xvimagesink->image_pool,
-        xvimagesink->image_pool);
-    gst_xvimage_buffer_free (xvimage);
-  }
-
-  g_mutex_unlock (xvimagesink->pool_lock);
-}
-
 /* Element stuff */
 
-/* This function tries to get a format matching with a given caps in the
-   supported list of formats we generated in gst_xvimagesink_get_xv_support */
-static gint
-gst_xvimagesink_get_format_from_caps (GstXvImageSink * xvimagesink,
-    GstCaps * caps)
-{
-  GList *list = NULL;
-
-  g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), 0);
-
-  list = xvimagesink->xcontext->formats_list;
-
-  while (list) {
-    GstXvImageFormat *format = list->data;
-
-    if (format) {
-      if (gst_caps_can_intersect (caps, format->caps)) {
-        return format->format;
-      }
-    }
-    list = g_list_next (list);
-  }
-
-  return -1;
-}
-
 static GstCaps *
 gst_xvimagesink_getcaps (GstBaseSink * bsink)
 {
@@ -2064,8 +1497,9 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
 {
   GstXvImageSink *xvimagesink;
   GstStructure *structure;
-  guint32 im_format = 0;
+  GstBufferPool *newpool, *oldpool;
   gboolean ret;
+  guint32 im_format = 0;
   gint video_width, video_height;
   gint disp_x, disp_y;
   gint disp_width, disp_height;
@@ -2203,21 +1637,26 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
    * doesn't cover the same area */
   xvimagesink->redraw_border = TRUE;
 
-  /* We renew our xvimage only if size or format changed;
-   * the xvimage is the same size as the video pixel size */
-  if ((xvimagesink->xvimage) &&
-      ((im_format != xvimagesink->xvimage->im_format) ||
-          (video_width != xvimagesink->xvimage->width) ||
-          (video_height != xvimagesink->xvimage->height))) {
-    GST_DEBUG_OBJECT (xvimagesink,
-        "old format %" GST_FOURCC_FORMAT ", new format %" GST_FOURCC_FORMAT,
-        GST_FOURCC_ARGS (xvimagesink->xvimage->im_format),
-        GST_FOURCC_ARGS (im_format));
-    GST_DEBUG_OBJECT (xvimagesink, "renewing xvimage");
-    gst_buffer_unref (GST_BUFFER (xvimagesink->xvimage));
-    xvimagesink->xvimage = NULL;
-  }
+  /* create a new pool for the new configuration */
+  newpool = gst_xvimage_buffer_pool_new (xvimagesink);
+
+  structure = gst_buffer_pool_get_config (newpool);
+  gst_buffer_pool_config_set (structure, caps, 0, 0, 0, 0, 0, 16);
+  if (!gst_buffer_pool_set_config (newpool, structure))
+    goto config_failed;
+
+  if (!gst_buffer_pool_set_active (newpool, TRUE))
+    goto activate_failed;
 
+  oldpool = xvimagesink->pool;
+  xvimagesink->pool = newpool;
+
+  /* unref the old sink */
+  if (oldpool) {
+    /* deactivate */
+    gst_buffer_pool_set_active (oldpool, FALSE);
+    gst_object_unref (oldpool);
+  }
   g_mutex_unlock (xvimagesink->flow_lock);
 
   return TRUE;
@@ -2252,6 +1691,18 @@ no_display_size:
         ("Error calculating the output display ratio of the video."));
     return FALSE;
   }
+config_failed:
+  {
+    GST_ERROR_OBJECT (xvimagesink, "failed to set config.");
+    g_mutex_unlock (xvimagesink->flow_lock);
+    return FALSE;
+  }
+activate_failed:
+  {
+    GST_ERROR_OBJECT (xvimagesink, "failed to activate bufferpool.");
+    g_mutex_unlock (xvimagesink->flow_lock);
+    return FALSE;
+  }
 }
 
 static GstStateChangeReturn
@@ -2268,8 +1719,10 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
       /* Initializing the XContext */
       if (xvimagesink->xcontext == NULL) {
         xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
-        if (xcontext == NULL)
-          return GST_STATE_CHANGE_FAILURE;
+        if (xcontext == NULL) {
+          ret = GST_STATE_CHANGE_FAILURE;
+          goto beach;
+        }
         GST_OBJECT_LOCK (xvimagesink);
         if (xcontext)
           xvimagesink->xcontext = xcontext;
@@ -2290,16 +1743,10 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
       gst_xvimagesink_manage_event_thread (xvimagesink);
       break;
     case GST_STATE_CHANGE_READY_TO_PAUSED:
-      g_mutex_lock (xvimagesink->pool_lock);
-      xvimagesink->pool_invalid = FALSE;
-      g_mutex_unlock (xvimagesink->pool_lock);
       break;
     case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
       break;
     case GST_STATE_CHANGE_PAUSED_TO_READY:
-      g_mutex_lock (xvimagesink->pool_lock);
-      xvimagesink->pool_invalid = TRUE;
-      g_mutex_unlock (xvimagesink->pool_lock);
       break;
     default:
       break;
@@ -2315,6 +1762,10 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
       xvimagesink->fps_d = 1;
       GST_VIDEO_SINK_WIDTH (xvimagesink) = 0;
       GST_VIDEO_SINK_HEIGHT (xvimagesink) = 0;
+      g_mutex_lock (xvimagesink->flow_lock);
+      if (xvimagesink->pool)
+        gst_buffer_pool_set_active (xvimagesink->pool, FALSE);
+      g_mutex_unlock (xvimagesink->flow_lock);
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
       gst_xvimagesink_reset (xvimagesink);
@@ -2323,6 +1774,7 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
       break;
   }
 
+beach:
   return ret;
 }
 
@@ -2351,66 +1803,89 @@ gst_xvimagesink_get_times (GstBaseSink * bsink, GstBuffer * buf,
 static GstFlowReturn
 gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
 {
+  GstFlowReturn res;
   GstXvImageSink *xvimagesink;
+  GstMetaXvImage *meta;
+  GstBuffer *to_put;
 
   xvimagesink = GST_XVIMAGESINK (vsink);
 
-  /* If this buffer has been allocated using our buffer management we simply
-     put the ximage which is in the PRIVATE pointer */
-  if (GST_IS_XVIMAGE_BUFFER (buf)) {
-    GST_LOG_OBJECT (xvimagesink, "fast put of bufferpool buffer %p", buf);
-    if (!gst_xvimagesink_xvimage_put (xvimagesink,
-            GST_XVIMAGE_BUFFER_CAST (buf)))
-      goto no_window;
+  meta = gst_buffer_get_meta_xvimage (buf);
+
+  if (meta) {
+    /* If this buffer has been allocated using our buffer management we simply
+       put the ximage which is in the PRIVATE pointer */
+    GST_LOG_OBJECT (xvimagesink, "buffer %p from our pool, writing directly",
+        buf);
+    res = GST_FLOW_OK;
+    to_put = buf;
   } else {
-    GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
-        "slow copy into bufferpool buffer %p", buf);
+    guint8 *data;
+    gsize size;
+
     /* Else we have to copy the data into our private image, */
     /* if we have one... */
-    if (!xvimagesink->xvimage) {
-      GST_DEBUG_OBJECT (xvimagesink, "creating our xvimage");
+    GST_LOG_OBJECT (xvimagesink, "buffer %p not from our pool, copying", buf);
 
-      xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
-          GST_BUFFER_CAPS (buf));
+    /* we should have a pool, configured in setcaps */
+    if (xvimagesink->pool == NULL)
+      goto no_pool;
 
-      if (!xvimagesink->xvimage)
-        /* The create method should have posted an informative error */
-        goto no_image;
+    /* take a buffer form our pool */
+    res = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &to_put, NULL);
+    if (res != GST_FLOW_OK)
+      goto no_buffer;
 
-      if (xvimagesink->xvimage->size < GST_BUFFER_SIZE (buf)) {
-        GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
-            ("Failed to create output image buffer of %dx%d pixels",
-                xvimagesink->xvimage->width, xvimagesink->xvimage->height),
-            ("XServer allocated buffer size did not match input buffer"));
+    if (gst_buffer_get_size (to_put) < gst_buffer_get_size (buf))
+      goto wrong_size;
 
-        gst_xvimage_buffer_destroy (xvimagesink->xvimage);
-        xvimagesink->xvimage = NULL;
-        goto no_image;
-      }
-    }
-
-    memcpy (xvimagesink->xvimage->xvimage->data,
-        GST_BUFFER_DATA (buf),
-        MIN (GST_BUFFER_SIZE (buf), xvimagesink->xvimage->size));
+    GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
+        "slow copy into bufferpool buffer %p", to_put);
 
-    if (!gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->xvimage))
-      goto no_window;
+    data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+    gst_buffer_fill (to_put, 0, data, size);
+    gst_buffer_unmap (buf, data, size);
   }
 
-  return GST_FLOW_OK;
+  if (!gst_xvimagesink_xvimage_put (xvimagesink, to_put))
+    goto no_window;
+
+done:
+  if (to_put != buf)
+    gst_buffer_unref (to_put);
+
+  return res;
 
   /* ERRORS */
-no_image:
+no_pool:
+  {
+    GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
+        ("Internal error: can't allocate images"),
+        ("We don't have a bufferpool negotiated"));
+    return GST_FLOW_ERROR;
+  }
+no_buffer:
   {
     /* No image available. That's very bad ! */
     GST_WARNING_OBJECT (xvimagesink, "could not create image");
-    return GST_FLOW_ERROR;
+    return res;
+  }
+wrong_size:
+  {
+    GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
+        ("Failed to create output image buffer"),
+        ("XServer allocated buffer size did not match input buffer %"
+            G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (to_put),
+            gst_buffer_get_size (buf)));
+    res = GST_FLOW_ERROR;
+    goto done;
   }
 no_window:
   {
     /* No Window available to put our image into */
     GST_WARNING_OBJECT (xvimagesink, "could not output image - no window");
-    return GST_FLOW_ERROR;
+    res = GST_FLOW_ERROR;
+    goto done;
   }
 }
 
@@ -2446,7 +1921,6 @@ gst_xvimagesink_event (GstBaseSink * sink, GstEvent * event)
 }
 
 /* Buffer management */
-
 static GstCaps *
 gst_xvimage_sink_different_size_suggestion (GstXvImageSink * xvimagesink,
     GstCaps * caps)
@@ -2499,19 +1973,15 @@ static GstFlowReturn
 gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
     GstCaps * caps, GstBuffer ** buf)
 {
-  GstFlowReturn ret = GST_FLOW_OK;
   GstXvImageSink *xvimagesink;
-  GstXvImageBuffer *xvimage = NULL;
-  GstCaps *intersection = NULL;
+  GstBuffer *xvimage = NULL;
   GstStructure *structure = NULL;
+  GstFlowReturn ret = GST_FLOW_OK;
+  GstCaps *intersection = NULL;
   gint width, height, image_format;
 
   xvimagesink = GST_XVIMAGESINK (bsink);
 
-  g_mutex_lock (xvimagesink->pool_lock);
-  if (G_UNLIKELY (xvimagesink->pool_invalid))
-    goto invalid;
-
   if (G_LIKELY (xvimagesink->xcontext->last_caps &&
           gst_caps_is_equal (caps, xvimagesink->xcontext->last_caps))) {
     GST_LOG_OBJECT (xvimagesink,
@@ -2629,44 +2099,30 @@ gst_xvimagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
 
 reuse_last_caps:
 
-  /* Walking through the pool cleaning unusable images and searching for a
-     suitable one */
-  while (xvimagesink->image_pool) {
-    xvimage = xvimagesink->image_pool->data;
-
-    if (xvimage) {
-      /* Removing from the pool */
-      xvimagesink->image_pool = g_slist_delete_link (xvimagesink->image_pool,
-          xvimagesink->image_pool);
-
-      /* We check for geometry or image format changes */
-      if ((xvimage->width != width) ||
-          (xvimage->height != height) || (xvimage->im_format != image_format)) {
-        /* This image is unusable. Destroying... */
-        gst_xvimage_buffer_free (xvimage);
-        xvimage = NULL;
-      } else {
-        /* We found a suitable image */
-        GST_LOG_OBJECT (xvimagesink, "found usable image in pool");
-        break;
-      }
+  if (gst_caps_is_equal (GST_PAD_CAPS (bsink->sinkpad), caps)) {
+    /* we negotiated this format before, use the pool */
+    if (xvimagesink->pool) {
+      GstBuffer *tmp;
+
+      GST_LOG_OBJECT (xvimagesink, "retrieving buffer from pool");
+      ret = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &tmp, NULL);
+      xvimage = tmp;
     }
   }
 
-  if (!xvimage) {
-    /* We found no suitable image in the pool. Creating... */
-    GST_DEBUG_OBJECT (xvimagesink, "no usable image in pool, creating xvimage");
-    xvimage = gst_xvimagesink_xvimage_new (xvimagesink, intersection);
+  if (xvimage == NULL) {
+    /* Something new make a new image a new one */
+    GST_LOG_OBJECT (xvimagesink, "allocating new image");
+    xvimage = gst_xvimage_buffer_new (xvimagesink, width, height, image_format);
   }
-  g_mutex_unlock (xvimagesink->pool_lock);
 
   if (xvimage) {
     /* Make sure the buffer is cleared of any previously used flags */
     GST_MINI_OBJECT_CAST (xvimage)->flags = 0;
-    gst_buffer_set_caps (GST_BUFFER_CAST (xvimage), intersection);
+    gst_buffer_set_caps (xvimage, intersection);
   }
 
-  *buf = GST_BUFFER_CAST (xvimage);
+  *buf = xvimage;
 
 beach:
   if (intersection) {
@@ -2680,7 +2136,6 @@ invalid:
   {
     GST_DEBUG_OBJECT (xvimagesink, "the pool is flushing");
     ret = GST_FLOW_WRONG_STATE;
-    g_mutex_unlock (xvimagesink->pool_lock);
     goto beach;
   }
 incompatible:
@@ -2690,7 +2145,6 @@ incompatible:
         " are completely incompatible with those caps", caps,
         xvimagesink->xcontext->caps);
     ret = GST_FLOW_NOT_NEGOTIATED;
-    g_mutex_unlock (xvimagesink->pool_lock);
     goto beach;
   }
 invalid_caps:
@@ -2698,7 +2152,6 @@ invalid_caps:
     GST_WARNING_OBJECT (xvimagesink, "invalid caps for buffer allocation %"
         GST_PTR_FORMAT, intersection);
     ret = GST_FLOW_NOT_NEGOTIATED;
-    g_mutex_unlock (xvimagesink->pool_lock);
     goto beach;
   }
 }
@@ -2815,15 +2268,6 @@ gst_xvimagesink_set_window_handle (GstXOverlay * overlay, guintptr id)
 
   gst_xvimagesink_update_colorbalance (xvimagesink);
 
-  /* Clear image pool as the images are unusable anyway */
-  gst_xvimagesink_imagepool_clear (xvimagesink);
-
-  /* Clear the xvimage */
-  if (xvimagesink->xvimage) {
-    gst_xvimage_buffer_free (xvimagesink->xvimage);
-    xvimagesink->xvimage = NULL;
-  }
-
   /* If a window is there already we destroy it */
   if (xvimagesink->xwindow) {
     gst_xvimagesink_xwindow_destroy (xvimagesink, xvimagesink->xwindow);
@@ -2882,6 +2326,7 @@ gst_xvimagesink_expose (GstXOverlay * overlay)
 {
   GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
 
+  GST_DEBUG ("doing expose");
   gst_xvimagesink_xwindow_update_geometry (xvimagesink);
   gst_xvimagesink_xvimage_put (xvimagesink, NULL);
 }
@@ -3387,32 +2832,28 @@ gst_xvimagesink_reset (GstXvImageSink * xvimagesink)
   xvimagesink->event_thread = NULL;
   GST_OBJECT_UNLOCK (xvimagesink);
 
-  /* invalidate the pool, current allocations continue, new buffer_alloc fails
-   * with wrong_state */
-  g_mutex_lock (xvimagesink->pool_lock);
-  xvimagesink->pool_invalid = TRUE;
-  g_mutex_unlock (xvimagesink->pool_lock);
-
   /* Wait for our event thread to finish before we clean up our stuff. */
   if (thread)
     g_thread_join (thread);
 
   if (xvimagesink->cur_image) {
-    gst_buffer_unref (GST_BUFFER_CAST (xvimagesink->cur_image));
+    gst_buffer_unref (xvimagesink->cur_image);
     xvimagesink->cur_image = NULL;
   }
-  if (xvimagesink->xvimage) {
-    gst_buffer_unref (GST_BUFFER_CAST (xvimagesink->xvimage));
-    xvimagesink->xvimage = NULL;
-  }
 
-  gst_xvimagesink_imagepool_clear (xvimagesink);
+  g_mutex_lock (xvimagesink->flow_lock);
+
+  if (xvimagesink->pool) {
+    gst_object_unref (xvimagesink->pool);
+    xvimagesink->pool = NULL;
+  }
 
   if (xvimagesink->xwindow) {
     gst_xvimagesink_xwindow_clear (xvimagesink, xvimagesink->xwindow);
     gst_xvimagesink_xwindow_destroy (xvimagesink, xvimagesink->xwindow);
     xvimagesink->xwindow = NULL;
   }
+  g_mutex_unlock (xvimagesink->flow_lock);
 
   xvimagesink->render_rect.x = xvimagesink->render_rect.y =
       xvimagesink->render_rect.w = xvimagesink->render_rect.h = 0;
@@ -3450,10 +2891,6 @@ gst_xvimagesink_finalize (GObject * object)
     g_mutex_free (xvimagesink->flow_lock);
     xvimagesink->flow_lock = NULL;
   }
-  if (xvimagesink->pool_lock) {
-    g_mutex_free (xvimagesink->pool_lock);
-    xvimagesink->pool_lock = NULL;
-  }
 
   g_free (xvimagesink->media_title);
 
@@ -3467,7 +2904,6 @@ gst_xvimagesink_init (GstXvImageSink * xvimagesink)
   xvimagesink->adaptor_no = 0;
   xvimagesink->xcontext = NULL;
   xvimagesink->xwindow = NULL;
-  xvimagesink->xvimage = NULL;
   xvimagesink->cur_image = NULL;
 
   xvimagesink->hue = xvimagesink->saturation = 0;
@@ -3482,8 +2918,7 @@ gst_xvimagesink_init (GstXvImageSink * xvimagesink)
   xvimagesink->x_lock = g_mutex_new ();
   xvimagesink->flow_lock = g_mutex_new ();
 
-  xvimagesink->image_pool = NULL;
-  xvimagesink->pool_lock = g_mutex_new ();
+  xvimagesink->pool = NULL;
 
   xvimagesink->synchronous = FALSE;
   xvimagesink->double_buffer = TRUE;
@@ -3742,33 +3177,11 @@ gst_xvimagesink_get_type (void)
         &colorbalance_info);
     g_type_add_interface_static (xvimagesink_type, GST_TYPE_PROPERTY_PROBE,
         &propertyprobe_info);
-
-
     /* register type and create class in a more safe place instead of at
      * runtime since the type registration and class creation is not
      * threadsafe. */
-    g_type_class_ref (gst_xvimage_buffer_get_type ());
+    g_type_class_ref (gst_xvimage_buffer_pool_get_type ());
   }
 
   return xvimagesink_type;
 }
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
-  if (!gst_element_register (plugin, "xvimagesink",
-          GST_RANK_PRIMARY, GST_TYPE_XVIMAGESINK))
-    return FALSE;
-
-  GST_DEBUG_CATEGORY_INIT (gst_debug_xvimagesink, "xvimagesink", 0,
-      "xvimagesink element");
-  GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    "xvimagesink",
-    "XFree86 video output plugin using Xv extension",
-    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 0181018..4531cf3 100644 (file)
@@ -43,7 +43,6 @@
 #include <stdlib.h>
 
 G_BEGIN_DECLS
-
 #define GST_TYPE_XVIMAGESINK \
   (gst_xvimagesink_get_type())
 #define GST_XVIMAGESINK(obj) \
@@ -54,16 +53,15 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_XVIMAGESINK))
 #define GST_IS_XVIMAGESINK_CLASS(klass) \
   (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIMAGESINK))
-
 typedef struct _GstXContext GstXContext;
 typedef struct _GstXWindow GstXWindow;
 typedef struct _GstXvImageFormat GstXvImageFormat;
-typedef struct _GstXvImageBuffer GstXvImageBuffer;
-typedef struct _GstXvImageBufferClass GstXvImageBufferClass;
 
 typedef struct _GstXvImageSink GstXvImageSink;
 typedef struct _GstXvImageSinkClass GstXvImageSinkClass;
 
+#include "xvimagepool.h"
+
 /*
  * GstXContext:
  * @disp: the X11 Display of this context
@@ -93,7 +91,8 @@ typedef struct _GstXvImageSinkClass GstXvImageSinkClass;
  * Structure used to store various informations collected/calculated for a
  * Display.
  */
-struct _GstXContext {
+struct _GstXContext
+{
   Display *disp;
 
   Screen *screen;
@@ -117,7 +116,7 @@ struct _GstXContext {
 
   XvPortID xv_port_id;
   guint nb_adaptors;
-  gchar ** adaptors;
+  gchar **adaptors;
   gint im_format;
 
   GList *formats_list;
@@ -143,7 +142,8 @@ struct _GstXContext {
  *
  * Structure used to store informations about a Window.
  */
-struct _GstXWindow {
+struct _GstXWindow
+{
   Window win;
   gint width, height;
   gboolean internal;
@@ -157,45 +157,18 @@ struct _GstXWindow {
  *
  * Structure storing image format to #GstCaps association.
  */
-struct _GstXvImageFormat {
+struct _GstXvImageFormat
+{
   gint format;
   GstCaps *caps;
 };
 
-/**
- * GstXImageBuffer:
- * @xvimagesink: a reference to our #GstXvImageSink
- * @xvimage: the XvImage of this buffer
- * @width: the width in pixels of XvImage @xvimage
- * @height: the height in pixels of XvImage @xvimage
- * @im_format: the image format of XvImage @xvimage
- * @size: the size in bytes of XvImage @xvimage
- *
- * Subclass of #GstBuffer containing additional information about an XvImage.
- */
-struct _GstXvImageBuffer {
-  GstBuffer   buffer;
-
-  /* Reference to the xvimagesink we belong to */
-  GstXvImageSink *xvimagesink;
-
-  XvImage *xvimage;
-
-#ifdef HAVE_XSHM
-  XShmSegmentInfo SHMInfo;
-#endif /* HAVE_XSHM */
-
-  gint width, height, im_format;
-  size_t size;
-};
 
 /**
  * GstXvImageSink:
  * @display_name: the name of the Display we want to render to
  * @xcontext: our instance's #GstXContext
  * @xwindow: the #GstXWindow we are rendering to
- * @xvimage: internal #GstXvImage used to store incoming buffers and render when
- * not using the buffer_alloc optimization mechanism
  * @cur_image: a reference to the last #GstXvImage that was put to @xwindow. It
  * is used when Expose events are received to redraw the latest video frame
  * @event_thread: a thread listening for events on @xwindow and handling them
@@ -225,7 +198,8 @@ struct _GstXvImageBuffer {
  *
  * The #GstXvImageSink data structure.
  */
-struct _GstXvImageSink {
+struct _GstXvImageSink
+{
   /* Our element stuff */
   GstVideoSink videosink;
 
@@ -234,12 +208,12 @@ struct _GstXvImageSink {
 
   GstXContext *xcontext;
   GstXWindow *xwindow;
-  GstXvImageBuffer *xvimage;
-  GstXvImageBuffer *cur_image;
+  GstBuffer *cur_image;
 
   GThread *event_thread;
   gboolean running;
 
+  /* Framerate numerator and denominator */
   gint fps_n;
   gint fps_d;
 
@@ -249,9 +223,8 @@ struct _GstXvImageSink {
   /* object-set pixel aspect ratio */
   GValue *par;
 
-  GMutex *pool_lock;
-  gboolean pool_invalid;
-  GSList *image_pool;
+  /* the buffer pool */
+  GstBufferPool *pool;
 
   gboolean synchronous;
   gboolean double_buffer;
@@ -276,14 +249,14 @@ struct _GstXvImageSink {
   /* port attributes */
   gboolean autopaint_colorkey;
   gint colorkey;
-  
+
   gboolean draw_borders;
-  
+
   /* port features */
   gboolean have_autopaint_colorkey;
   gboolean have_colorkey;
   gboolean have_double_buffer;
-  
+
   /* stream metadata */
   gchar *media_title;
 
@@ -292,12 +265,12 @@ struct _GstXvImageSink {
   gboolean have_render_rect;
 };
 
-struct _GstXvImageSinkClass {
+struct _GstXvImageSinkClass
+{
   GstVideoSinkClass parent_class;
 };
 
-GType gst_xvimagesink_get_type(void);
+GType gst_xvimagesink_get_type (void);
 
 G_END_DECLS
-
 #endif /* __GST_XVIMAGESINK_H__ */
index 34982ef..c26cb08 100644 (file)
@@ -198,10 +198,12 @@ GST_END_TEST;
 static GstBufferList *mylist;
 static GstCaps *mycaps;
 
+static gint values[] = { 1, 2, 4 };
+
 static GstBufferList *
 create_buffer_list (void)
 {
-  GstBufferListIterator *it;
+  guint len;
   GstBuffer *buffer;
 
   mylist = gst_buffer_list_new ();
@@ -210,29 +212,23 @@ create_buffer_list (void)
   mycaps = gst_caps_from_string ("application/x-gst-check");
   fail_if (mycaps == NULL);
 
-  it = gst_buffer_list_iterate (mylist);
-  fail_if (it == NULL);
-
-  gst_buffer_list_iterator_add_group (it);
+  len = gst_buffer_list_len (mylist);
+  fail_if (len != 0);
 
   buffer = gst_buffer_new_and_alloc (sizeof (gint));
-  *(gint *) GST_BUFFER_DATA (buffer) = 1;
+  gst_buffer_fill (buffer, 0, &values[0], sizeof (gint));
   gst_buffer_set_caps (buffer, mycaps);
-  gst_buffer_list_iterator_add (it, buffer);
-
-  gst_buffer_list_iterator_add_group (it);
+  gst_buffer_list_add (mylist, buffer);
 
   buffer = gst_buffer_new_and_alloc (sizeof (gint));
-  *(gint *) GST_BUFFER_DATA (buffer) = 2;
+  gst_buffer_fill (buffer, 0, &values[1], sizeof (gint));
   gst_buffer_set_caps (buffer, mycaps);
-  gst_buffer_list_iterator_add (it, buffer);
+  gst_buffer_list_add (mylist, buffer);
 
   buffer = gst_buffer_new_and_alloc (sizeof (gint));
-  *(gint *) GST_BUFFER_DATA (buffer) = 4;
+  gst_buffer_fill (buffer, 0, &values[2], sizeof (gint));
   gst_buffer_set_caps (buffer, mycaps);
-  gst_buffer_list_iterator_add (it, buffer);
-
-  gst_buffer_list_iterator_free (it);
+  gst_buffer_list_add (mylist, buffer);
 
   return mylist;
 }
@@ -240,43 +236,36 @@ create_buffer_list (void)
 static void
 check_buffer_list (GstBufferList * list)
 {
-  GstBufferListIterator *it;
+  guint len;
   GstBuffer *buf;
   GstCaps *caps;
 
   fail_unless (list == mylist);
-  fail_unless (gst_buffer_list_n_groups (list) == 2);
+  fail_unless (gst_buffer_list_len (list) == 3);
 
-  it = gst_buffer_list_iterate (list);
-  fail_if (it == NULL);
+  len = gst_buffer_list_len (list);
 
-  fail_unless (gst_buffer_list_iterator_next_group (it));
-  fail_unless (gst_buffer_list_iterator_n_buffers (it) == 1);
-  buf = gst_buffer_list_iterator_next (it);
+  buf = gst_buffer_list_get (list, 0);
   fail_if (buf == NULL);
-  fail_unless (*(gint *) GST_BUFFER_DATA (buf) == 1);
+  gst_check_buffer_data (buf, &values[0], sizeof (gint));
   caps = gst_buffer_get_caps (buf);
   fail_unless (caps == mycaps);
   fail_unless (gst_caps_is_equal (caps, mycaps));
   gst_caps_unref (caps);
 
-  fail_unless (gst_buffer_list_iterator_next_group (it));
-  fail_unless (gst_buffer_list_iterator_n_buffers (it) == 2);
-  buf = gst_buffer_list_iterator_next (it);
+  buf = gst_buffer_list_get (list, 1);
   fail_if (buf == NULL);
-  fail_unless (*(gint *) GST_BUFFER_DATA (buf) == 2);
+  gst_check_buffer_data (buf, &values[1], sizeof (gint));
   caps = gst_buffer_get_caps (buf);
   fail_unless (caps == mycaps);
   gst_caps_unref (caps);
 
-  buf = gst_buffer_list_iterator_next (it);
+  buf = gst_buffer_list_get (list, 2);
   fail_if (buf == NULL);
-  fail_unless (*(gint *) GST_BUFFER_DATA (buf) == 4);
+  gst_check_buffer_data (buf, &values[2], sizeof (gint));
   caps = gst_buffer_get_caps (buf);
   fail_unless (caps == mycaps);
   gst_caps_unref (caps);
-
-  gst_buffer_list_iterator_free (it);
 }
 
 static GstFlowReturn
@@ -329,13 +318,16 @@ callback_function_buffer (GstAppSink * appsink, gpointer p_counter)
   /* buffer list has 3 buffers in two groups */
   switch (*p_int_counter) {
     case 0:
-      fail_unless_equals_int (GST_BUFFER_SIZE (buf), sizeof (gint));
-      fail_unless_equals_int ((((gint *) GST_BUFFER_DATA (buf))[0]), 1);
+      fail_unless_equals_int (gst_buffer_get_size (buf), sizeof (gint));
+      gst_check_buffer_data (buf, &values[0], sizeof (gint));
       break;
     case 1:
-      fail_unless_equals_int (GST_BUFFER_SIZE (buf), 2 * sizeof (gint));
-      fail_unless_equals_int ((((gint *) GST_BUFFER_DATA (buf))[0]), 2);
-      fail_unless_equals_int ((((gint *) GST_BUFFER_DATA (buf))[1]), 4);
+      fail_unless_equals_int (gst_buffer_get_size (buf), sizeof (gint));
+      gst_check_buffer_data (buf, &values[1], sizeof (gint));
+      break;
+    case 2:
+      fail_unless_equals_int (gst_buffer_get_size (buf), sizeof (gint));
+      gst_check_buffer_data (buf, &values[2], sizeof (gint));
       break;
     default:
       g_warn_if_reached ();
@@ -367,7 +359,7 @@ GST_START_TEST (test_buffer_list_fallback)
   list = create_buffer_list ();
   fail_unless (gst_pad_push_list (mysrcpad, list) == GST_FLOW_OK);
 
-  fail_unless_equals_int (counter, 2);
+  fail_unless_equals_int (counter, 3);
 
   ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
   cleanup_appsink (sink);
@@ -394,7 +386,7 @@ GST_START_TEST (test_buffer_list_fallback_signal)
   list = create_buffer_list ();
   fail_unless (gst_pad_push_list (mysrcpad, list) == GST_FLOW_OK);
 
-  fail_unless_equals_int (counter, 2);
+  fail_unless_equals_int (counter, 3);
 
   ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
   cleanup_appsink (sink);
index b5e292d..caa9eb6 100644 (file)
@@ -449,7 +449,7 @@ verify_convert (const gchar * which, void *in, int inlength,
 
   GST_DEBUG ("Creating buffer of %d bytes", inlength);
   inbuffer = gst_buffer_new_and_alloc (inlength);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, inlength);
+  gst_buffer_fill (inbuffer, 0, in, inlength);
   gst_buffer_set_caps (inbuffer, incaps);
   ASSERT_CAPS_REFCOUNT (incaps, "incaps", 2);
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -467,8 +467,10 @@ verify_convert (const gchar * which, void *in, int inlength,
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
 
   ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), outlength);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), outlength);
 
+  gst_check_buffer_data (outbuffer, out, outlength);
+#if 0
   if (memcmp (GST_BUFFER_DATA (outbuffer), out, outlength) != 0) {
     g_print ("\nInput data:\n");
     gst_util_dump_mem (in, inlength);
@@ -479,6 +481,7 @@ verify_convert (const gchar * which, void *in, int inlength,
   }
   fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, outlength) == 0,
       "failed converting %s", which);
+#endif
 
   /* make sure that the channel positions are not lost */
   {
index 7845672..75d32a8 100644 (file)
@@ -277,11 +277,12 @@ do_perfect_stream_test (guint rate, guint width, gdouble drop_probability,
     }
 
     /* check buffer size for sanity */
-    fail_unless_equals_int (GST_BUFFER_SIZE (buf) % (width / 8), 0);
+    fail_unless_equals_int (gst_buffer_get_size (buf) % (width / 8), 0);
 
     /* check there is actually as much data as there should be */
     num_samples = GST_BUFFER_OFFSET_END (buf) - GST_BUFFER_OFFSET (buf);
-    fail_unless_equals_int (GST_BUFFER_SIZE (buf), num_samples * (width / 8));
+    fail_unless_equals_int (gst_buffer_get_size (buf),
+        num_samples * (width / 8));
 
     next_time = GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf);
     next_offset = GST_BUFFER_OFFSET_END (buf);
index a8a79a3..d464810 100644 (file)
@@ -175,9 +175,8 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
   GstBuffer *inbuffer, *outbuffer;
   GstCaps *caps;
   guint64 offset = 0;
-
   int i, j;
-  gint16 *p;
+  gint16 *p, *data;
 
   audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
   caps = gst_pad_get_negotiated_caps (mysrcpad);
@@ -198,7 +197,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
 
     gst_buffer_set_caps (inbuffer, caps);
 
-    p = (gint16 *) GST_BUFFER_DATA (inbuffer);
+    p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
 
     /* create a 16 bit signed ramp */
     for (i = 0; i < samples; ++i) {
@@ -207,6 +206,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
       *p = -32767 + i * (65535 / samples);
       ++p;
     }
+    gst_buffer_unmap (inbuffer, data, samples * 4);
 
     /* pushing gives away my reference ... */
     fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
@@ -261,7 +261,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
   GstClockTime ints;
 
   int i, j;
-  gint16 *p;
+  gint16 *p, *data;
 
   GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
       inrate, outrate, samples, numbuffers);
@@ -286,8 +286,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
 
     gst_buffer_set_caps (inbuffer, caps);
 
-    p = (gint16 *) GST_BUFFER_DATA (inbuffer);
-
+    p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
     /* create a 16 bit signed ramp */
     for (i = 0; i < samples; ++i) {
       *p = -32767 + i * (65535 / samples);
@@ -295,6 +294,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
       *p = -32767 + i * (65535 / samples);
       ++p;
     }
+    gst_buffer_unmap (inbuffer, data, samples * 4);
 
     GST_DEBUG ("Sending Buffer time:%" G_GUINT64_FORMAT " duration:%"
         G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
@@ -351,6 +351,7 @@ GST_START_TEST (test_reuse)
   GstEvent *newseg;
   GstBuffer *inbuffer;
   GstCaps *caps;
+  guint8 *data;
 
   audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
   caps = gst_pad_get_negotiated_caps (mysrcpad);
@@ -364,7 +365,9 @@ GST_START_TEST (test_reuse)
   fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
 
   inbuffer = gst_buffer_new_and_alloc (9343 * 4);
-  memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
+  data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+  memset (data, 0, 9343 * 4);
+  gst_buffer_unmap (inbuffer, data, 9343 * 4);
   GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
   GST_BUFFER_TIMESTAMP (inbuffer) = 0;
   GST_BUFFER_OFFSET (inbuffer) = 0;
@@ -388,7 +391,9 @@ GST_START_TEST (test_reuse)
   fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
 
   inbuffer = gst_buffer_new_and_alloc (9343 * 4);
-  memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
+  data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+  memset (data, 0, 9343 * 4);
+  gst_buffer_unmap (inbuffer, data, 9343 * 4);
   GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
   GST_BUFFER_TIMESTAMP (inbuffer) = 0;
   GST_BUFFER_OFFSET (inbuffer) = 0;
@@ -500,6 +505,7 @@ live_switch_push (int rate, GstCaps * caps)
   GstBuffer *inbuffer;
   GstCaps *desired;
   GList *l;
+  guint8 *data;
 
   desired = gst_caps_copy (caps);
   gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
@@ -516,7 +522,10 @@ live_switch_push (int rate, GstCaps * caps)
       desired, GST_BUFFER_CAPS (inbuffer));
   fail_unless (gst_caps_is_equal (desired, GST_BUFFER_CAPS (inbuffer)));
 
-  memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
+  data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+  memset (data, 0, rate * 4);
+  gst_buffer_unmap (inbuffer, data, rate * 4);
+
   GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
   GST_BUFFER_TIMESTAMP (inbuffer) = 0;
   GST_BUFFER_OFFSET (inbuffer) = 0;
@@ -769,7 +778,7 @@ fakesink_handoff_cb (GstElement * object, GstBuffer * buffer, GstPad * pad,
 
   ctx->out_buffer_count++;
   if (ctx->latency == GST_CLOCK_TIME_NONE) {
-    ctx->latency = 1000 - GST_BUFFER_SIZE (buffer) / 8;
+    ctx->latency = 1000 - gst_buffer_get_size (buffer) / 8;
   }
 
   /* Check if we have a perfectly timestampped stream */
@@ -781,10 +790,10 @@ fakesink_handoff_cb (GstElement * object, GstBuffer * buffer, GstPad * pad,
 
   /* Check if we have a perfectly offsetted stream */
   fail_unless (GST_BUFFER_OFFSET_END (buffer) ==
-      GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) / 8,
+      GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
       "expected offset end %" G_GUINT64_FORMAT " got offset end %"
       G_GUINT64_FORMAT,
-      GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) / 8,
+      GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
       GST_BUFFER_OFFSET_END (buffer));
   if (ctx->next_out_off != GST_BUFFER_OFFSET_NONE) {
     fail_unless (GST_BUFFER_OFFSET (buffer) == ctx->next_out_off,
index eb6f38a..005c63f 100644 (file)
@@ -42,12 +42,22 @@ static const gchar dummytext[] =
     "over a Lazy Frog Quick Brown Fox Jumps over a Lazy Frog Quick Brown Fox ";
 
 static void
-src_handoff_cb (GstElement * src, GstBuffer * buf, GstPad * pad, gpointer data)
+src_need_data_cb (GstElement * src, guint size, gpointer data)
 {
-  GST_BUFFER_DATA (buf) = (guint8 *) dummytext;
-  GST_BUFFER_SIZE (buf) = sizeof (dummytext);
+  GstBuffer *buf;
+  GstFlowReturn ret;
+
+  buf = gst_buffer_new ();
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) dummytext, NULL, sizeof (dummytext), 0,
+          sizeof (dummytext)));
+
   GST_BUFFER_OFFSET (buf) = 0;
-  GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
+
+  g_signal_emit_by_name (src, "push-buffer", buf, &ret);
+
+  fail_unless (ret == GST_FLOW_OK);
 }
 
 static void
@@ -68,13 +78,12 @@ GST_START_TEST (test_text_plain_streams)
   pipe = gst_pipeline_new (NULL);
   fail_unless (pipe != NULL, "failed to create pipeline");
 
-  src = gst_element_factory_make ("fakesrc", "src");
-  fail_unless (src != NULL, "Failed to create fakesrc element");
+  src = gst_element_factory_make ("appsrc", "src");
+  fail_unless (src != NULL, "Failed to create appsrc element");
 
-  g_object_set (src, "signal-handoffs", TRUE, NULL);
+  g_object_set (src, "emit-signals", TRUE, NULL);
   g_object_set (src, "num-buffers", 1, NULL);
-  g_object_set (src, "can-activate-pull", FALSE, NULL);
-  g_signal_connect (src, "handoff", G_CALLBACK (src_handoff_cb), NULL);
+  g_signal_connect (src, "need-data", G_CALLBACK (src_need_data_cb), NULL);
 
   decodebin = gst_element_factory_make ("decodebin", "decodebin");
   fail_unless (decodebin != NULL, "Failed to create decodebin element");
index 84cf405..c57be0b 100644 (file)
@@ -42,12 +42,22 @@ static const gchar dummytext[] =
     "over a Lazy Frog Quick Brown Fox Jumps over a Lazy Frog Quick Brown Fox ";
 
 static void
-src_handoff_cb (GstElement * src, GstBuffer * buf, GstPad * pad, gpointer data)
+src_need_data_cb (GstElement * src, guint size, gpointer data)
 {
-  GST_BUFFER_DATA (buf) = (guint8 *) dummytext;
-  GST_BUFFER_SIZE (buf) = sizeof (dummytext);
+  GstBuffer *buf;
+  GstFlowReturn ret;
+
+  buf = gst_buffer_new ();
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) dummytext, NULL, sizeof (dummytext), 0,
+          sizeof (dummytext)));
+
   GST_BUFFER_OFFSET (buf) = 0;
-  GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
+
+  g_signal_emit_by_name (src, "push-buffer", buf, &ret);
+
+  fail_unless (ret == GST_FLOW_OK);
 }
 
 static void
@@ -68,13 +78,12 @@ GST_START_TEST (test_text_plain_streams)
   pipe = gst_pipeline_new (NULL);
   fail_unless (pipe != NULL, "failed to create pipeline");
 
-  src = gst_element_factory_make ("fakesrc", "src");
-  fail_unless (src != NULL, "Failed to create fakesrc element");
+  src = gst_element_factory_make ("appsrc", "src");
+  fail_unless (src != NULL, "Failed to create appsrc element");
 
-  g_object_set (src, "signal-handoffs", TRUE, NULL);
+  g_object_set (src, "emit-signals", TRUE, NULL);
   g_object_set (src, "num-buffers", 1, NULL);
-  g_object_set (src, "can-activate-pull", FALSE, NULL);
-  g_signal_connect (src, "handoff", G_CALLBACK (src_handoff_cb), NULL);
+  g_signal_connect (src, "need-data", G_CALLBACK (src_need_data_cb), NULL);
 
   decodebin = gst_element_factory_make ("decodebin2", "decodebin");
   fail_unless (decodebin != NULL, "Failed to create decodebin element");
index 60179c6..c54532b 100644 (file)
@@ -313,6 +313,8 @@ GST_START_TEST (test_rgb_to_rgb)
       GstStateChangeReturn state_ret;
       RGBFormat *from = &conv->from_fmt;
       RGBFormat *to = &conv->to_fmt;
+      guint8 *data;
+      gsize size;
 
       /* trick compiler into thinking from is used, might throw warning
        * otherwise if the debugging system is disabled */
@@ -393,10 +395,12 @@ GST_START_TEST (test_rgb_to_rgb)
       }
 
       /* now check the top-left pixel */
-      check_rgb_buf (GST_BUFFER_DATA (buf), to->red_mask,
+      data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+      check_rgb_buf (data, to->red_mask,
           to->green_mask, to->blue_mask, to->alpha_mask,
           test_patterns[p].r_expected, test_patterns[p].g_expected,
           test_patterns[p].b_expected, to->endianness, to->bpp, to->depth);
+      gst_buffer_unmap (buf, data, size);
 
       gst_buffer_unref (buf);
       buf = NULL;
index 3ee83c8..6a1a9f1 100644 (file)
@@ -94,14 +94,15 @@ cleanup_gdpdepay (GstElement * gdpdepay)
 }
 
 static void
-gdpdepay_push_per_byte (const gchar * reason, guint8 * bytes, guint length)
+gdpdepay_push_per_byte (const gchar * reason, const guint8 * bytes,
+    guint length)
 {
   int i;
   GstBuffer *inbuffer;
 
   for (i = 0; i < length; ++i) {
     inbuffer = gst_buffer_new_and_alloc (1);
-    GST_BUFFER_DATA (inbuffer)[0] = bytes[i];
+    gst_buffer_fill (inbuffer, 0, &bytes[i], 1);
     fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK,
         "%s: failed pushing byte buffer", reason);
   }
@@ -148,13 +149,13 @@ GST_START_TEST (test_audio_per_byte)
   g_free (payload);
 
   buffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
+  gst_buffer_fill (buffer, 0, "f00d", 4);
   GST_BUFFER_TIMESTAMP (buffer) = GST_SECOND;
   GST_BUFFER_DURATION (buffer) = GST_SECOND / 10;
   fail_unless (pk->header_from_buffer (buffer, 0, &len, &header));
   gdpdepay_push_per_byte ("buffer header", header, len);
   fail_unless_equals_int (g_list_length (buffers), 0);
-  gdpdepay_push_per_byte ("buffer payload", GST_BUFFER_DATA (buffer),
+  gdpdepay_push_per_byte ("buffer payload", (const guint8 *) "f00d",
       gst_dp_header_payload_length (header));
   g_free (header);
   gst_buffer_unref (buffer);
@@ -214,21 +215,20 @@ GST_START_TEST (test_audio_in_one_buffer)
           &caps_payload));
 
   buffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
+  gst_buffer_fill (buffer, 0, "f00d", 4);
   fail_unless (pk->header_from_buffer (buffer, 0, &header_len, &buf_header));
 
   payload_len = gst_dp_header_payload_length (caps_header);
 
   inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
-      payload_len + GST_BUFFER_SIZE (buffer));
-  memcpy (GST_BUFFER_DATA (inbuffer), caps_header, GST_DP_HEADER_LENGTH);
+      payload_len + gst_buffer_get_size (buffer));
+  gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH);
   i = GST_DP_HEADER_LENGTH;
-  memcpy (GST_BUFFER_DATA (inbuffer) + i, caps_payload, payload_len);
+  gst_buffer_fill (inbuffer, i, caps_payload, payload_len);
   i += payload_len;
-  memcpy (GST_BUFFER_DATA (inbuffer) + i, buf_header, GST_DP_HEADER_LENGTH);
+  gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH);
   i += GST_DP_HEADER_LENGTH;
-  memcpy (GST_BUFFER_DATA (inbuffer) + i, GST_BUFFER_DATA (buffer),
-      GST_BUFFER_SIZE (buffer));
+  gst_buffer_fill (inbuffer, i, "f00d", 4);
 
   gst_caps_unref (caps);
   gst_buffer_unref (buffer);
@@ -287,7 +287,8 @@ GST_START_TEST (test_streamheader)
   GstPad *srcpad;
   GstElement *gdpdepay;
   GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
-  guint8 *caps_header, *caps_payload, *buf_header;
+  guint8 *caps_header, *caps_payload, *buf_header, *data;
+  gsize size;
   guint header_len, payload_len;
   guint i;
   GstStructure *structure;
@@ -315,7 +316,7 @@ GST_START_TEST (test_streamheader)
   caps = gst_caps_from_string ("application/x-gst-test-streamheader");
   structure = gst_caps_get_structure (caps, 0);
   buffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
+  gst_buffer_fill (buffer, 0, "f00d", 4);
   GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
   g_value_init (&array, GST_TYPE_ARRAY);
   g_value_init (&value, GST_TYPE_BUFFER);
@@ -338,16 +339,17 @@ GST_START_TEST (test_streamheader)
 
   payload_len = gst_dp_header_payload_length (caps_header);
 
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
-      payload_len + GST_BUFFER_SIZE (buffer));
-  memcpy (GST_BUFFER_DATA (inbuffer), caps_header, GST_DP_HEADER_LENGTH);
+      payload_len + size);
+  gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH);
   i = GST_DP_HEADER_LENGTH;
-  memcpy (GST_BUFFER_DATA (inbuffer) + i, caps_payload, payload_len);
+  gst_buffer_fill (inbuffer, i, caps_payload, payload_len);
   i += payload_len;
-  memcpy (GST_BUFFER_DATA (inbuffer) + i, buf_header, GST_DP_HEADER_LENGTH);
+  gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH);
   i += GST_DP_HEADER_LENGTH;
-  memcpy (GST_BUFFER_DATA (inbuffer) + i, GST_BUFFER_DATA (buffer),
-      GST_BUFFER_SIZE (buffer));
+  gst_buffer_fill (inbuffer, i, data, size);
+  gst_buffer_unmap (buffer, data, size);
 
   gst_caps_unref (caps);
   gst_buffer_unref (buffer);
index 13117a6..05391f1 100644 (file)
@@ -142,7 +142,7 @@ GST_START_TEST (test_audio)
   buffers = g_list_remove (buffers, outbuffer);
   ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
   length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   /* the third buffer is the GDP buffer for our pushed buffer */
@@ -150,7 +150,7 @@ GST_START_TEST (test_audio)
   buffers = g_list_remove (buffers, outbuffer);
   ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
   length = GST_DP_HEADER_LENGTH + 4;
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   /* second buffer */
@@ -170,7 +170,7 @@ GST_START_TEST (test_audio)
 
   /* the third output buffer is data */
   length = GST_DP_HEADER_LENGTH + 4;
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   /* a third buffer without caps set explicitly; should work */
@@ -189,7 +189,7 @@ GST_START_TEST (test_audio)
 
   /* the fourth output buffer is data */
   length = GST_DP_HEADER_LENGTH + 4;
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
 
@@ -263,7 +263,7 @@ GST_START_TEST (test_streamheader)
 
   GST_DEBUG ("first buffer");
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), "head", 4);
+  gst_buffer_fill (inbuffer, 0, "head", 4);
   caps = gst_caps_from_string ("application/x-gst-test-streamheader");
   structure = gst_caps_get_structure (caps, 0);
   GST_BUFFER_FLAG_SET (inbuffer, GST_BUFFER_FLAG_IN_CAPS);
@@ -316,7 +316,7 @@ GST_START_TEST (test_streamheader)
   buffers = g_list_remove (buffers, outbuffer);
   ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
   length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   /* the third buffer is the GDP buffer for our pushed buffer */
@@ -324,7 +324,7 @@ GST_START_TEST (test_streamheader)
   buffers = g_list_remove (buffers, outbuffer);
   ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
   length = GST_DP_HEADER_LENGTH + 4;
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   /* second buffer */
@@ -344,7 +344,7 @@ GST_START_TEST (test_streamheader)
 
   /* the third output buffer is data */
   length = GST_DP_HEADER_LENGTH + 4;
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   /* a third buffer without caps set explicitly; should work */
@@ -363,7 +363,7 @@ GST_START_TEST (test_streamheader)
 
   /* the fourth output buffer is data */
   length = GST_DP_HEADER_LENGTH + 4;
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
 
@@ -464,6 +464,8 @@ GST_START_TEST (test_crc)
   GstEvent *event;
   gchar *caps_string;
   gint length;
+  guint8 *data;
+  gsize size;
   guint16 crc_calculated, crc_read;
 
   gdppay = setup_gdppay ();
@@ -503,16 +505,19 @@ GST_START_TEST (test_crc)
 
   /* verify the header checksum */
   /* CRC's start at 58 in the header */
-  crc_calculated = gst_dp_crc (GST_BUFFER_DATA (outbuffer), 58);
-  crc_read = GST_READ_UINT16_BE (GST_BUFFER_DATA (outbuffer) + 58);
+  outbuffer = gst_buffer_make_writable (outbuffer);
+  data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READWRITE);
+  crc_calculated = gst_dp_crc (data, 58);
+  crc_read = GST_READ_UINT16_BE (data + 58);
   fail_unless_equals_int (crc_calculated, crc_read);
 
   /* change a byte in the header and verify that the checksum now fails */
-  GST_BUFFER_DATA (outbuffer)[0] = 0xff;
-  crc_calculated = gst_dp_crc (GST_BUFFER_DATA (outbuffer), 58);
+  data[0] = 0xff;
+  crc_calculated = gst_dp_crc (data, 58);
   fail_if (crc_calculated == crc_read,
       "Introducing a byte error in the header should make the checksum fail");
 
+  gst_buffer_unmap (outbuffer, data, size);
   gst_buffer_unref (outbuffer);
 
   /* second buffer is the serialized caps;
@@ -521,7 +526,7 @@ GST_START_TEST (test_crc)
   buffers = g_list_remove (buffers, outbuffer);
   ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
   length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   /* the third buffer is the GDP buffer for our pushed buffer */
@@ -529,7 +534,7 @@ GST_START_TEST (test_crc)
   buffers = g_list_remove (buffers, outbuffer);
   ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
   length = GST_DP_HEADER_LENGTH + 4;
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
+  fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
   gst_buffer_unref (outbuffer);
 
   fail_unless (gst_element_set_state (gdppay,
index f0cf64d..912ad7d 100644 (file)
@@ -87,9 +87,12 @@ cleanup_gnomevfssink (GstElement * gnomevfssink)
     G_STMT_START {                                                        \
       GstBuffer *buf = gst_buffer_new_and_alloc(num_bytes);               \
       GRand *rand = g_rand_new_with_seed (num_bytes);                     \
-      guint i;                                                            \
+      gsize i;                                                            \
+      guint8 *data;                                                       \
+      data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);             \
       for (i = 0; i < num_bytes; ++i)                                     \
-        GST_BUFFER_DATA(buf)[i] = (g_rand_int (rand) >> 24) & 0xff;       \
+        data[i] = (g_rand_int (rand) >> 24) & 0xff;                       \
+      gst_buffer_unmap (buf, data, num_bytes);                            \
       fail_unless_equals_int (gst_pad_push (mysrcpad, buf), GST_FLOW_OK); \
       g_rand_free (rand);                                                 \
     } G_STMT_END
index 4eb6e9e..e70402f 100644 (file)
@@ -121,7 +121,7 @@ GST_START_TEST (test_add_client)
   buffer = gst_buffer_new_and_alloc (4);
   gst_buffer_set_caps (buffer, caps);
   ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
-  memcpy (GST_BUFFER_DATA (buffer), "dead", 4);
+  gst_buffer_fill (buffer, 0, "dead", 4);
   fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
 
   GST_DEBUG ("reading");
@@ -176,10 +176,10 @@ gst_multifdsink_create_streamheader (const gchar * data1,
    * buffers */
   *hbuf1 = gst_buffer_new_and_alloc (size1);
   GST_BUFFER_FLAG_SET (*hbuf1, GST_BUFFER_FLAG_IN_CAPS);
-  memcpy (GST_BUFFER_DATA (*hbuf1), data1, size1);
+  gst_buffer_fill (*hbuf1, 0, data1, size1);
   *hbuf2 = gst_buffer_new_and_alloc (size2);
   GST_BUFFER_FLAG_SET (*hbuf2, GST_BUFFER_FLAG_IN_CAPS);
-  memcpy (GST_BUFFER_DATA (*hbuf2), data2, size2);
+  gst_buffer_fill (*hbuf2, 0, data2, size2);
 
   g_value_init (&array, GST_TYPE_ARRAY);
 
@@ -265,7 +265,7 @@ GST_START_TEST (test_streamheader)
   /* push a non-IN_CAPS buffer, this should trigger the client receiving the
    * first three buffers */
   buf = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (buf), "f00d", 4);
+  gst_buffer_fill (buf, 0, "f00d", 4);
   gst_pad_push (mysrcpad, buf);
 
   fail_unless_read ("first client", pfd1[0], 4, "babe");
@@ -281,7 +281,7 @@ GST_START_TEST (test_streamheader)
   /* now push another buffer, which will trigger streamheader for second
    * client */
   buf = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (buf), "deaf", 4);
+  gst_buffer_fill (buf, 0, "deaf", 4);
   gst_pad_push (mysrcpad, buf);
 
   fail_unless_read ("first client", pfd1[0], 4, "deaf");
@@ -360,7 +360,7 @@ GST_START_TEST (test_change_streamheader)
 
   /* now push a buffer and read */
   buf = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (buf), "f00d", 4);
+  gst_buffer_fill (buf, 0, "f00d", 4);
   gst_pad_push (mysrcpad, buf);
 
   fail_unless_read ("change: first client", pfd1[0], 5, "first");
@@ -400,7 +400,7 @@ GST_START_TEST (test_change_streamheader)
   /* now push another buffer, which will trigger streamheader for second
    * client, but should also send new streamheaders to first client */
   buf = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (buf), "deadbabe", 8);
+  gst_buffer_fill (buf, 0, "deadbabe", 8);
   gst_pad_push (mysrcpad, buf);
 
   fail_unless_read ("first client", pfd1[0], 6, "second");
@@ -469,8 +469,9 @@ GST_START_TEST (test_burst_client_bytes)
     gst_buffer_set_caps (buffer, caps);
 
     /* copy some id */
-    data = (gchar *) GST_BUFFER_DATA (buffer);
+    data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
     g_snprintf (data, 16, "deadbee%08x", i);
+    gst_buffer_unmap (buffer, data, 16);
 
     fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
   }
@@ -494,8 +495,9 @@ GST_START_TEST (test_burst_client_bytes)
     gst_buffer_set_caps (buffer, caps);
 
     /* copy some id */
-    data = (gchar *) GST_BUFFER_DATA (buffer);
+    data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
     g_snprintf (data, 16, "deadbee%08x", i);
+    gst_buffer_unmap (buffer, data, 16);
 
     fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
   }
@@ -586,8 +588,9 @@ GST_START_TEST (test_burst_client_bytes_keyframe)
       GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
 
     /* copy some id */
-    data = (gchar *) GST_BUFFER_DATA (buffer);
+    data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
     g_snprintf (data, 16, "deadbee%08x", i);
+    gst_buffer_unmap (buffer, data, 16);
 
     fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
   }
@@ -612,8 +615,9 @@ GST_START_TEST (test_burst_client_bytes_keyframe)
     GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
 
     /* copy some id */
-    data = (gchar *) GST_BUFFER_DATA (buffer);
+    data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
     g_snprintf (data, 16, "deadbee%08x", i);
+    gst_buffer_unmap (buffer, data, 16);
 
     fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
   }
@@ -701,8 +705,9 @@ GST_START_TEST (test_burst_client_bytes_with_keyframe)
       GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
 
     /* copy some id */
-    data = (gchar *) GST_BUFFER_DATA (buffer);
+    data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
     g_snprintf (data, 16, "deadbee%08x", i);
+    gst_buffer_unmap (buffer, data, 16);
 
     fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
   }
@@ -727,8 +732,9 @@ GST_START_TEST (test_burst_client_bytes_with_keyframe)
     GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
 
     /* copy some id */
-    data = (gchar *) GST_BUFFER_DATA (buffer);
+    data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
     g_snprintf (data, 16, "deadbee%08x", i);
+    gst_buffer_unmap (buffer, data, 16);
 
     fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
   }
@@ -813,8 +819,9 @@ GST_START_TEST (test_client_next_keyframe)
     gst_buffer_set_caps (buffer, caps);
 
     /* copy some id */
-    data = (gchar *) GST_BUFFER_DATA (buffer);
+    data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
     g_snprintf (data, 16, "deadbee%08x", i);
+    gst_buffer_unmap (buffer, data, 16);
     if (i > 0)
       GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
 
index 08aace6..88119e9 100644 (file)
@@ -472,14 +472,15 @@ gst_red_video_src_create (GstPushSrc * src, GstBuffer ** p_buf)
   GstCaps *caps;
   guint8 *data;
   guint w = 64, h = 64;
-  guint size;
+  gsize size;
 
   size = w * h * 3 / 2;
   buf = gst_buffer_new_and_alloc (size);
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
   memset (data, 76, w * h);
   memset (data + (w * h), 85, (w * h) / 4);
   memset (data + (w * h) + ((w * h) / 4), 255, (w * h) / 4);
+  gst_buffer_unmap (buf, data, size);
 
   caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC,
       GST_MAKE_FOURCC ('I', '4', '2', '0'), "width", G_TYPE_INT, w, "height",
@@ -582,9 +583,12 @@ gst_codec_src_create (GstPushSrc * src, GstBuffer ** p_buf)
 {
   GstBuffer *buf;
   GstCaps *caps;
+  guint8 *data;
 
   buf = gst_buffer_new_and_alloc (20);
-  memset (GST_BUFFER_DATA (buf), 0, GST_BUFFER_SIZE (buf));
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+  memset (data, 0, 20);
+  gst_buffer_unmap (buf, data, 20);
 
   caps = gst_caps_new_simple ("application/x-codec", NULL);
   gst_buffer_set_caps (buf, caps);
index aef9272..585350f 100644 (file)
@@ -588,10 +588,11 @@ gst_red_video_src_create (GstPushSrc * src, GstBuffer ** p_buf)
 
   size = w * h * 3 / 2;
   buf = gst_buffer_new_and_alloc (size);
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
   memset (data, 76, w * h);
   memset (data + (w * h), 85, (w * h) / 4);
   memset (data + (w * h) + ((w * h) / 4), 255, (w * h) / 4);
+  gst_buffer_unmap (buf, data, size);
 
   caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC,
       GST_MAKE_FOURCC ('I', '4', '2', '0'), "width", G_TYPE_INT, w, "height",
@@ -694,9 +695,12 @@ gst_codec_src_create (GstPushSrc * src, GstBuffer ** p_buf)
 {
   GstBuffer *buf;
   GstCaps *caps;
+  guint8 *data;
 
   buf = gst_buffer_new_and_alloc (20);
-  memset (GST_BUFFER_DATA (buf), 0, GST_BUFFER_SIZE (buf));
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+  memset (data, 0, 20);
+  gst_buffer_unmap (buf, data, 20);
 
   caps = gst_caps_new_simple ("application/x-codec", NULL);
   gst_buffer_set_caps (buf, caps);
index 884140b..8f1c4ed 100644 (file)
@@ -43,11 +43,14 @@ static GstBuffer *
 buffer_from_static_string (const gchar * s)
 {
   GstBuffer *buf;
+  gsize len;
+
+  len = strlen (s);
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (guint8 *) s;
-  GST_BUFFER_SIZE (buf) = strlen (s);
-  GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) s, NULL, len, 0, len));
 
   return buf;
 }
@@ -209,7 +212,7 @@ test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num)
     const GstStructure *buffer_caps_struct;
     GstBuffer *buf;
     gchar *out;
-    guint out_size;
+    gsize out_size;
 
     buf = g_list_nth_data (buffers, n - start_idx);
     fail_unless (buf != NULL);
@@ -218,16 +221,20 @@ test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num)
     fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (buf), input[n].from_ts);
     fail_unless_equals_uint64 (GST_BUFFER_DURATION (buf),
         input[n].to_ts - input[n].from_ts);
-    out = (gchar *) GST_BUFFER_DATA (buf);
-    out_size = GST_BUFFER_SIZE (buf);
-    /* shouldn't have trailing newline characters */
-    fail_if (out_size > 0 && out[out_size - 1] == '\n');
-    /* shouldn't include NUL-terminator in data size */
-    fail_if (out_size > 0 && out[out_size - 1] == '\0');
-    /* but should still have a  NUL-terminator behind the declared data */
-    fail_unless_equals_int (out[out_size], '\0');
-    /* make sure out string matches expected string */
-    fail_unless_equals_string (out, input[n].out);
+
+    out = gst_buffer_map (buf, &out_size, NULL, GST_MAP_READ);
+    /* can be NULL */
+    if (out != NULL) {
+      /* shouldn't have trailing newline characters */
+      fail_if (out_size > 0 && out[out_size - 1] == '\n');
+      /* shouldn't include NUL-terminator in data size */
+      fail_if (out_size > 0 && out[out_size - 1] == '\0');
+      /* but should still have a  NUL-terminator behind the declared data */
+      fail_unless_equals_int (out[out_size], '\0');
+      /* make sure out string matches expected string */
+      fail_unless_equals_string (out, input[n].out);
+    }
+    gst_buffer_unmap (buf, out, out_size);
     /* check caps */
     fail_unless (GST_BUFFER_CAPS (buf) != NULL);
     buffer_caps_struct = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0);
@@ -288,7 +295,7 @@ do_test (SubParseInputChunk * input, guint num, const gchar * media_type)
     const GstStructure *buffer_caps_struct;
     GstBuffer *buf;
     gchar *out;
-    guint out_size;
+    gsize out_size;
 
     buf = g_list_nth_data (buffers, n);
     fail_unless (buf != NULL);
@@ -305,16 +312,19 @@ do_test (SubParseInputChunk * input, guint num, const gchar * media_type)
           input[n].to_ts - input[n].from_ts);
     }
 
-    out = (gchar *) GST_BUFFER_DATA (buf);
-    out_size = GST_BUFFER_SIZE (buf);
-    /* shouldn't have trailing newline characters */
-    fail_if (out_size > 0 && out[out_size - 1] == '\n');
-    /* shouldn't include NUL-terminator in data size */
-    fail_if (out_size > 0 && out[out_size - 1] == '\0');
-    /* but should still have a  NUL-terminator behind the declared data */
-    fail_unless_equals_int (out[out_size], '\0');
-    /* make sure out string matches expected string */
-    fail_unless_equals_string (out, input[n].out);
+    out = gst_buffer_map (buf, &out_size, NULL, GST_MAP_READ);
+    /* can be NULL */
+    if (out != NULL) {
+      /* shouldn't have trailing newline characters */
+      fail_if (out_size > 0 && out[out_size - 1] == '\n');
+      /* shouldn't include NUL-terminator in data size */
+      fail_if (out_size > 0 && out[out_size - 1] == '\0');
+      /* but should still have a  NUL-terminator behind the declared data */
+      fail_unless_equals_int (out[out_size], '\0');
+      /* make sure out string matches expected string */
+      fail_unless_equals_string (out, input[n].out);
+    }
+    gst_buffer_unmap (buf, out, out_size);
     /* check caps */
     fail_unless (GST_BUFFER_CAPS (buf) != NULL);
     buffer_caps_struct = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0);
index 3c970b2..7c89ece 100644 (file)
@@ -164,6 +164,8 @@ buffer_is_all_black (GstBuffer * buf)
 {
   GstStructure *s;
   gint x, y, w, h;
+  guint8 *data;
+  gsize size;
 
   fail_unless (buf != NULL);
   fail_unless (GST_BUFFER_CAPS (buf) != NULL);
@@ -172,16 +174,18 @@ buffer_is_all_black (GstBuffer * buf)
   fail_unless (gst_structure_get_int (s, "width", &w));
   fail_unless (gst_structure_get_int (s, "height", &h));
 
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
   for (y = 0; y < h; ++y) {
-    guint8 *data = GST_BUFFER_DATA (buf) + (y * GST_ROUND_UP_4 (w));
+    guint8 *ptr = data + (y * GST_ROUND_UP_4 (w));
 
     for (x = 0; x < w; ++x) {
-      if (data[x] != 0x00) {
+      if (ptr[x] != 0x00) {
         GST_LOG ("non-black pixel at (x,y) %d,%d", x, y);
         return FALSE;
       }
     }
   }
+  gst_buffer_unmap (buf, data, size);
 
   return TRUE;
 }
@@ -193,6 +197,7 @@ create_black_buffer (const gchar * caps_string)
   GstBuffer *buffer;
   GstCaps *caps;
   gint w, h, size;
+  guint8 *data;
 
   fail_unless (caps_string != NULL);
 
@@ -207,9 +212,12 @@ create_black_buffer (const gchar * caps_string)
   GST_LOG ("creating buffer (%dx%d)", w, h);
   size = I420_SIZE (w, h);
   buffer = gst_buffer_new_and_alloc (size);
+
+  data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
   /* we're only checking the Y plane later, so just zero it all out,
    * even if it's not the blackest black there is */
-  memset (GST_BUFFER_DATA (buffer), 0, size);
+  memset (data, 0, size);
+  gst_buffer_unmap (buffer, data, size);
 
   gst_buffer_set_caps (buffer, caps);
   gst_caps_unref (caps);
@@ -232,7 +240,7 @@ create_text_buffer (const gchar * txt, GstClockTime ts, GstClockTime duration)
   txt_len = strlen (txt);
 
   buffer = gst_buffer_new_and_alloc (txt_len);
-  memcpy (GST_BUFFER_DATA (buffer), txt, txt_len);
+  gst_buffer_fill (buffer, 0, txt, txt_len);
 
   GST_BUFFER_TIMESTAMP (buffer) = ts;
   GST_BUFFER_DURATION (buffer) = duration;
@@ -375,8 +383,8 @@ GST_START_TEST (test_video_passthrough)
   /* pushing gives away one of the two references we have ... */
   fail_unless (gst_pad_push (myvideosrcpad, inbuffer) == GST_FLOW_OK);
 
-  /* should be the parent for a new subbuffer for the stamp fix-up */
-  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 2);
+  /* should be a new buffer for the stamp fix-up */
+  ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_unless (GST_BUFFER_CAST (buffers->data) != inbuffer);
   fail_unless (GST_BUFFER_TIMESTAMP (GST_BUFFER_CAST (buffers->data)) ==
@@ -525,7 +533,7 @@ GST_START_TEST (test_video_waits_for_text)
   fail_unless (buffer_is_all_black (GST_BUFFER_CAST (buffers->data)));
 
   /* now, another video buffer */
-  inbuffer = gst_buffer_make_metadata_writable (inbuffer);
+  inbuffer = gst_buffer_make_writable (inbuffer);
   GST_BUFFER_TIMESTAMP (inbuffer) = GST_SECOND;
   GST_BUFFER_DURATION (inbuffer) = GST_SECOND / 2;
 
@@ -545,7 +553,7 @@ GST_START_TEST (test_video_waits_for_text)
       FALSE);
 
   /* a third video buffer */
-  inbuffer = gst_buffer_make_metadata_writable (inbuffer);
+  inbuffer = gst_buffer_make_writable (inbuffer);
   GST_BUFFER_TIMESTAMP (inbuffer) = 30 * GST_SECOND;
   GST_BUFFER_DURATION (inbuffer) = GST_SECOND / 2;
 
@@ -573,7 +581,7 @@ GST_START_TEST (test_video_waits_for_text)
               next->data)));
 
   /* a fourth video buffer */
-  inbuffer = gst_buffer_make_metadata_writable (inbuffer);
+  inbuffer = gst_buffer_make_writable (inbuffer);
   GST_BUFFER_TIMESTAMP (inbuffer) = 35 * GST_SECOND;
   GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
 
index 69eb3c6..fb881a1 100644 (file)
@@ -142,6 +142,26 @@ cleanup_videorate (GstElement * videorate)
   gst_check_teardown_element (videorate);
 }
 
+static void
+buffer_memset (GstBuffer * buffer, gint val, gsize size)
+{
+  guint8 *data;
+
+  data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
+  memset (data, val, size);
+  gst_buffer_unmap (buffer, data, size);
+}
+
+static guint8
+buffer_get_byte (GstBuffer * buffer, gint offset)
+{
+  guint8 res;
+
+  gst_buffer_extract (buffer, offset, &res, 1);
+
+  return res;
+}
+
 GST_START_TEST (test_one)
 {
   GstElement *videorate;
@@ -154,7 +174,7 @@ GST_START_TEST (test_one)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memset (GST_BUFFER_DATA (inbuffer), 0, 4);
+  buffer_memset (inbuffer, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (inbuffer, caps);
   GST_BUFFER_TIMESTAMP (inbuffer) = 0;
@@ -196,7 +216,7 @@ GST_START_TEST (test_more)
      streams */
   GST_BUFFER_OFFSET (first) = g_rand_int (rand);
   GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
-  memset (GST_BUFFER_DATA (first), 1, 4);
+  buffer_memset (first, 1, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (first, caps);
   gst_caps_unref (caps);
@@ -215,7 +235,7 @@ GST_START_TEST (test_more)
   GST_BUFFER_TIMESTAMP (second) = GST_SECOND * 3 / 50;
   GST_BUFFER_OFFSET (first) = g_rand_int (rand);
   GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
-  memset (GST_BUFFER_DATA (second), 2, 4);
+  buffer_memset (second, 2, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (second, caps);
   gst_caps_unref (caps);
@@ -230,7 +250,7 @@ GST_START_TEST (test_more)
   /* ... and the first one is pushed out, with timestamp 0 */
   fail_unless_equals_int (g_list_length (buffers), 1);
   assert_videorate_stats (videorate, "second buffer", 2, 1, 0, 0);
-  ASSERT_BUFFER_REFCOUNT (first, "first", 2);
+  ASSERT_BUFFER_REFCOUNT (first, "first", 1);
 
   outbuffer = buffers->data;
   fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (outbuffer), 0);
@@ -240,7 +260,7 @@ GST_START_TEST (test_more)
   GST_BUFFER_TIMESTAMP (third) = GST_SECOND * 12 / 50;
   GST_BUFFER_OFFSET (first) = g_rand_int (rand);
   GST_BUFFER_OFFSET_END (first) = g_rand_int (rand);
-  memset (GST_BUFFER_DATA (third), 3, 4);
+  buffer_memset (third, 3, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (third, caps);
   gst_caps_unref (caps);
@@ -258,33 +278,33 @@ GST_START_TEST (test_more)
   /* check timestamp and source correctness */
   l = buffers;
   fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), 0);
-  fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 1);
+  fail_unless_equals_int (buffer_get_byte (l->data, 0), 1);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 0);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 1);
 
   l = g_list_next (l);
   fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data), GST_SECOND / 25);
-  fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 2);
+  fail_unless_equals_int (buffer_get_byte (l->data, 0), 2);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 1);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 2);
 
   l = g_list_next (l);
   fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data),
       GST_SECOND * 2 / 25);
-  fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 2);
+  fail_unless_equals_int (buffer_get_byte (l->data, 0), 2);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 2);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 3);
 
   l = g_list_next (l);
   fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (l->data),
       GST_SECOND * 3 / 25);
-  fail_unless_equals_int (GST_BUFFER_DATA (l->data)[0], 2);
+  fail_unless_equals_int (buffer_get_byte (l->data, 0), 2);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET (l->data), 3);
   fail_unless_equals_uint64 (GST_BUFFER_OFFSET_END (l->data), 4);
 
   fail_unless_equals_int (g_list_length (buffers), 4);
   /* one held by us, three held by each output frame taken from the second */
-  ASSERT_BUFFER_REFCOUNT (second, "second", 4);
+  ASSERT_BUFFER_REFCOUNT (second, "second", 1);
 
   /* now send EOS */
   fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
@@ -320,7 +340,7 @@ GST_START_TEST (test_wrong_order_from_zero)
   /* first buffer */
   first = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (first) = GST_SECOND;
-  memset (GST_BUFFER_DATA (first), 0, 4);
+  buffer_memset (first, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (first, caps);
   gst_caps_unref (caps);
@@ -338,7 +358,7 @@ GST_START_TEST (test_wrong_order_from_zero)
   /* second buffer */
   second = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (second) = 0;
-  memset (GST_BUFFER_DATA (second), 0, 4);
+  buffer_memset (second, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (second, caps);
   gst_caps_unref (caps);
@@ -358,7 +378,7 @@ GST_START_TEST (test_wrong_order_from_zero)
   /* third buffer */
   third = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
-  memset (GST_BUFFER_DATA (third), 0, 4);
+  buffer_memset (third, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (third, caps);
   gst_caps_unref (caps);
@@ -373,7 +393,7 @@ GST_START_TEST (test_wrong_order_from_zero)
   /* and now the first one should be pushed once and dupped 24 + 13 times, to
    * reach the half point between 1 s (first) and 2 s (third) */
   fail_unless_equals_int (g_list_length (buffers), 38);
-  ASSERT_BUFFER_REFCOUNT (first, "first", 39);
+  ASSERT_BUFFER_REFCOUNT (first, "first", 1);
   ASSERT_BUFFER_REFCOUNT (second, "second", 1);
   ASSERT_BUFFER_REFCOUNT (third, "third", 2);
   assert_videorate_stats (videorate, "third", 3, 38, 1, 37);
@@ -409,7 +429,7 @@ GST_START_TEST (test_wrong_order)
   /* first buffer */
   first = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (first) = 0;
-  memset (GST_BUFFER_DATA (first), 0, 4);
+  buffer_memset (first, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (first, caps);
   gst_caps_unref (caps);
@@ -427,7 +447,7 @@ GST_START_TEST (test_wrong_order)
   /* second buffer */
   second = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (second) = GST_SECOND;
-  memset (GST_BUFFER_DATA (second), 0, 4);
+  buffer_memset (second, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (second, caps);
   gst_caps_unref (caps);
@@ -441,12 +461,12 @@ GST_START_TEST (test_wrong_order)
   /* and it created 13 output buffers as copies of the first frame */
   fail_unless_equals_int (g_list_length (buffers), 13);
   assert_videorate_stats (videorate, "second", 2, 13, 0, 12);
-  ASSERT_BUFFER_REFCOUNT (first, "first", 14);
+  ASSERT_BUFFER_REFCOUNT (first, "first", 1);
 
   /* third buffer */
   third = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
-  memset (GST_BUFFER_DATA (third), 0, 4);
+  buffer_memset (third, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (third, caps);
   gst_caps_unref (caps);
@@ -460,15 +480,15 @@ GST_START_TEST (test_wrong_order)
 
   /* submitting a frame with 2 seconds triggers output of 25 more frames */
   fail_unless_equals_int (g_list_length (buffers), 38);
-  ASSERT_BUFFER_REFCOUNT (first, "first", 14);
-  ASSERT_BUFFER_REFCOUNT (second, "second", 26);
+  ASSERT_BUFFER_REFCOUNT (first, "first", 1);
+  ASSERT_BUFFER_REFCOUNT (second, "second", 1);
   /* three frames submitted; two of them output as is, and 36 duplicated */
   assert_videorate_stats (videorate, "third", 3, 38, 0, 36);
 
   /* fourth buffer */
   fourth = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (fourth) = 0;
-  memset (GST_BUFFER_DATA (fourth), 0, 4);
+  buffer_memset (fourth, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (fourth, caps);
   gst_caps_unref (caps);
@@ -481,8 +501,8 @@ GST_START_TEST (test_wrong_order)
   ASSERT_BUFFER_REFCOUNT (fourth, "fourth", 1);
 
   fail_unless_equals_int (g_list_length (buffers), 38);
-  ASSERT_BUFFER_REFCOUNT (first, "first", 14);
-  ASSERT_BUFFER_REFCOUNT (second, "second", 26);
+  ASSERT_BUFFER_REFCOUNT (first, "first", 1);
+  ASSERT_BUFFER_REFCOUNT (second, "second", 1);
   assert_videorate_stats (videorate, "fourth", 4, 38, 1, 36);
 
   /* verify last buffer */
@@ -516,7 +536,7 @@ GST_START_TEST (test_no_framerate)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memset (GST_BUFFER_DATA (inbuffer), 0, 4);
+  buffer_memset (inbuffer, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_NO_FRAMERATE_STRING);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -564,7 +584,7 @@ GST_START_TEST (test_changing_size)
   fail_unless (gst_pad_push_event (mysrcpad, newsegment) == TRUE);
 
   first = gst_buffer_new_and_alloc (4);
-  memset (GST_BUFFER_DATA (first), 0, 4);
+  buffer_memset (first, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   GST_BUFFER_TIMESTAMP (first) = 0;
   gst_buffer_set_caps (first, caps);
@@ -575,7 +595,7 @@ GST_START_TEST (test_changing_size)
   /* second buffer */
   second = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (second) = GST_SECOND / 25;
-  memset (GST_BUFFER_DATA (second), 0, 4);
+  buffer_memset (second, 0, 4);
   gst_buffer_set_caps (second, caps);
 
   fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
@@ -588,7 +608,7 @@ GST_START_TEST (test_changing_size)
   /* third buffer with new size */
   third = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND / 25;
-  memset (GST_BUFFER_DATA (third), 0, 4);
+  buffer_memset (third, 0, 4);
   caps_newsize = gst_caps_from_string (VIDEO_CAPS_NEWSIZE_STRING);
   gst_buffer_set_caps (third, caps_newsize);
 
@@ -603,7 +623,7 @@ GST_START_TEST (test_changing_size)
   /* fourth buffer with original size */
   fourth = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (fourth) = 3 * GST_SECOND / 25;
-  memset (GST_BUFFER_DATA (fourth), 0, 4);
+  buffer_memset (fourth, 0, 4);
   gst_buffer_set_caps (fourth, caps);
 
   fail_unless (gst_pad_push (mysrcpad, fourth) == GST_FLOW_OK);
@@ -612,7 +632,7 @@ GST_START_TEST (test_changing_size)
   /* fifth buffer with original size */
   fifth = gst_buffer_new_and_alloc (4);
   GST_BUFFER_TIMESTAMP (fifth) = 4 * GST_SECOND / 25;
-  memset (GST_BUFFER_DATA (fifth), 0, 4);
+  buffer_memset (fifth, 0, 4);
   gst_buffer_set_caps (fifth, caps);
 
   fail_unless (gst_pad_push (mysrcpad, fifth) == GST_FLOW_OK);
@@ -643,7 +663,7 @@ GST_START_TEST (test_non_ok_flow)
       "could not set to playing");
 
   buf = gst_buffer_new_and_alloc (4);
-  memset (GST_BUFFER_DATA (buf), 0, 4);
+  buffer_memset (buf, 0, 4);
   caps = gst_caps_from_string (VIDEO_CAPS_STRING);
   gst_buffer_set_caps (buf, caps);
   gst_caps_unref (caps);
@@ -666,7 +686,7 @@ GST_START_TEST (test_non_ok_flow)
   gst_pad_set_active (mysinkpad, FALSE);
 
   /* push buffer on deactivated pad */
-  fail_unless (gst_buffer_is_metadata_writable (buf));
+  fail_unless (gst_buffer_is_writable (buf));
   GST_BUFFER_TIMESTAMP (buf) = ts;
 
   /* pushing gives away our reference */
index 75f16df..8d1a2a1 100644 (file)
@@ -240,9 +240,15 @@ GST_START_TEST (test_passthrough)
           l1 = l1->next, l2 = l2->next) {
         GstBuffer *a = l1->data;
         GstBuffer *b = l2->data;
-
-        fail_unless_equals_int (GST_BUFFER_SIZE (a), GST_BUFFER_SIZE (b));
-        fail_unless (GST_BUFFER_DATA (a) == GST_BUFFER_DATA (b));
+        gsize sa, sb;
+        guint8 *pa, *pb;
+
+        pa = gst_buffer_map (a, &sa, NULL, GST_MAP_READ);
+        pb = gst_buffer_map (b, &sb, NULL, GST_MAP_READ);
+        fail_unless_equals_int (sa, sb);
+        fail_unless (pa == pb);
+        gst_buffer_unmap (b, pb, sb);
+        gst_buffer_unmap (a, pa, sa);
 
         gst_buffer_unref (a);
         gst_buffer_unref (b);
index 635ca32..c24c2e1 100644 (file)
@@ -322,6 +322,8 @@ GST_START_TEST (test_rgb_formats)
         /* caps are supported, let's run some tests then ... */
         for (p = 0; p < G_N_ELEMENTS (test_patterns); ++p) {
           GstStateChangeReturn state_ret;
+          guint8 *data;
+          gsize size;
 
           g_object_set (src, "pattern", test_patterns[p].pattern_enum, NULL);
 
@@ -375,11 +377,13 @@ GST_START_TEST (test_rgb_formats)
 
 
           /* now check the first pixel */
-          check_rgb_buf (GST_BUFFER_DATA (buf), rgb_formats[i].red_mask,
+          data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+          check_rgb_buf (data, rgb_formats[i].red_mask,
               rgb_formats[i].green_mask, rgb_formats[i].blue_mask,
               rgb_formats[i].alpha_mask, test_patterns[p].r_expected,
               test_patterns[p].g_expected, test_patterns[p].b_expected,
               endianness, rgb_formats[i].bpp, rgb_formats[i].depth);
+          gst_buffer_unmap (buf, data, size);
 
           gst_buffer_unref (buf);
           buf = NULL;
index d59a96f..b5fcd44 100644 (file)
@@ -185,6 +185,7 @@ GST_START_TEST (test_unity_s8)
   GstCaps *caps;
   gint8 in[2] = { 64, -16 };
   gint8 *res;
+  gsize size;
 
   volume = setup_volume ();
   fail_unless (gst_element_set_state (volume,
@@ -192,7 +193,7 @@ GST_START_TEST (test_unity_s8)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (2);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 2);
+  gst_buffer_fill (inbuffer, 0, in, 2);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -205,9 +206,10 @@ GST_START_TEST (test_unity_s8)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint8 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", in[0], in[1], res[0], res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 2) == 0);
+  fail_unless (memcmp (res, in, 2) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -224,6 +226,7 @@ GST_START_TEST (test_half_s8)
   gint8 in[2] = { 64, -16 };
   gint8 out[2] = { 32, -8 };
   gint8 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -232,8 +235,7 @@ GST_START_TEST (test_half_s8)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (2);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 2);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 2) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 2);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -251,10 +253,11 @@ GST_START_TEST (test_half_s8)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint8 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 2) == 0);
+  fail_unless (memcmp (res, out, 2) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -271,6 +274,7 @@ GST_START_TEST (test_double_s8)
   gint8 in[2] = { 64, -16 };
   gint8 out[2] = { 127, -32 };  /* notice the clamped sample */
   gint8 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -279,8 +283,7 @@ GST_START_TEST (test_double_s8)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (2);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 2);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 2) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 2);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -298,10 +301,11 @@ GST_START_TEST (test_double_s8)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint8 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 2) == 0);
+  fail_unless (memcmp (res, out, 2) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -318,6 +322,7 @@ GST_START_TEST (test_mute_s8)
   gint8 in[2] = { 64, -16 };
   gint8 out[2] = { 0, 0 };
   gint8 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -326,8 +331,7 @@ GST_START_TEST (test_mute_s8)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (2);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 2);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 2) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 2);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -345,10 +349,11 @@ GST_START_TEST (test_mute_s8)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint8 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 2) == 0);
+  fail_unless (memcmp (res, out, 2) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -363,6 +368,7 @@ GST_START_TEST (test_unity_s16)
   GstCaps *caps;
   gint16 in[2] = { 16384, -256 };
   gint16 *res;
+  gsize size;
 
   volume = setup_volume ();
   fail_unless (gst_element_set_state (volume,
@@ -370,7 +376,7 @@ GST_START_TEST (test_unity_s16)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
+  gst_buffer_fill (inbuffer, 0, in, 4);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -383,9 +389,10 @@ GST_START_TEST (test_unity_s16)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", in[0], in[1], res[0], res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+  fail_unless (memcmp (res, in, 4) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -402,6 +409,7 @@ GST_START_TEST (test_half_s16)
   gint16 in[2] = { 16384, -256 };
   gint16 out[2] = { 8192, -128 };
   gint16 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -410,8 +418,7 @@ GST_START_TEST (test_half_s16)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 4);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -429,10 +436,11 @@ GST_START_TEST (test_half_s16)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 4) == 0);
+  fail_unless (memcmp (res, out, 4) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -449,6 +457,7 @@ GST_START_TEST (test_double_s16)
   gint16 in[2] = { 16384, -256 };
   gint16 out[2] = { 32767, -512 };      /* notice the clamped sample */
   gint16 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -457,8 +466,7 @@ GST_START_TEST (test_double_s16)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 4);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -476,10 +484,11 @@ GST_START_TEST (test_double_s16)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 4) == 0);
+  fail_unless (memcmp (res, out, 4) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -497,6 +506,7 @@ GST_START_TEST (test_mute_s16)
   gint16 in[2] = { 16384, -256 };
   gint16 out[2] = { 0, 0 };
   gint16 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -505,8 +515,7 @@ GST_START_TEST (test_mute_s16)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 4);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -524,10 +533,11 @@ GST_START_TEST (test_mute_s16)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 4) == 0);
+  fail_unless (memcmp (res, out, 4) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -552,7 +562,7 @@ GST_START_TEST (test_unity_s24)
   guint8 in[6];
   guint8 *res;
   gint32 res_32[2];
-
+  gsize size;
 
   write_unaligned_u24 (in, in_32[0]);
   write_unaligned_u24 (in + 3, in_32[1]);
@@ -563,7 +573,7 @@ GST_START_TEST (test_unity_s24)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (6);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 6);
+  gst_buffer_fill (inbuffer, 0, in, 6);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -576,14 +586,15 @@ GST_START_TEST (test_unity_s24)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
 
   res_32[0] = get_unaligned_i24 (res);
   res_32[1] = get_unaligned_i24 ((res + 3));
 
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", in_32[0], in_32[1], res_32[0],
       res_32[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 6) == 0);
+  fail_unless (memcmp (res, in, 6) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -602,6 +613,7 @@ GST_START_TEST (test_half_s24)
   guint8 *res;
   gint32 res_32[2];
   gint32 out_32[2] = { 2097152, -2048 };
+  gsize size;
 
   write_unaligned_u24 (in, in_32[0]);
   write_unaligned_u24 (in + 3, in_32[1]);
@@ -613,8 +625,7 @@ GST_START_TEST (test_half_s24)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (6);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 6);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 6) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 6);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -632,7 +643,7 @@ GST_START_TEST (test_half_s24)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
 
   res_32[0] = get_unaligned_i24 (res);
   res_32[1] = get_unaligned_i24 ((res + 3));
@@ -640,6 +651,7 @@ GST_START_TEST (test_half_s24)
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out_32[0], out_32[1],
       res_32[0], res_32[1]);
   fail_unless (memcmp (res_32, out_32, 8) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -658,6 +670,7 @@ GST_START_TEST (test_double_s24)
   guint8 *res;
   gint32 res_32[2];
   gint32 out_32[2] = { 8388607, -8192 };        /* notice the clamped sample */
+  gsize size;
 
   write_unaligned_u24 (in, in_32[0]);
   write_unaligned_u24 (in + 3, in_32[1]);
@@ -669,8 +682,7 @@ GST_START_TEST (test_double_s24)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (6);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 6);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 6) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 6);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -688,7 +700,7 @@ GST_START_TEST (test_double_s24)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
 
   res_32[0] = get_unaligned_i24 (res);
   res_32[1] = get_unaligned_i24 ((res + 3));
@@ -696,6 +708,7 @@ GST_START_TEST (test_double_s24)
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out_32[0], out_32[1],
       res_32[0], res_32[1]);
   fail_unless (memcmp (res_32, out_32, 8) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -715,6 +728,7 @@ GST_START_TEST (test_mute_s24)
   guint8 *res;
   gint32 res_32[2];
   gint32 out_32[2] = { 0, 0 };  /* notice the clamped sample */
+  gsize size;
 
   write_unaligned_u24 (in, in_32[0]);
   write_unaligned_u24 (in + 3, in_32[1]);
@@ -726,8 +740,7 @@ GST_START_TEST (test_mute_s24)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (6);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 6);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 6) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 6);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -746,7 +759,7 @@ GST_START_TEST (test_mute_s24)
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
 
-  res = GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
 
   res_32[0] = get_unaligned_i24 (res);
   res_32[1] = get_unaligned_i24 ((res + 3));
@@ -754,6 +767,7 @@ GST_START_TEST (test_mute_s24)
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out_32[0], out_32[1],
       res_32[0], res_32[1]);
   fail_unless (memcmp (res_32, out_32, 8) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -768,6 +782,7 @@ GST_START_TEST (test_unity_s32)
   GstCaps *caps;
   gint32 in[2] = { 1073741824, -65536 };
   gint32 *res;
+  gsize size;
 
   volume = setup_volume ();
   fail_unless (gst_element_set_state (volume,
@@ -775,7 +790,7 @@ GST_START_TEST (test_unity_s32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -788,9 +803,10 @@ GST_START_TEST (test_unity_s32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint32 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", in[0], in[1], res[0], res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+  fail_unless (memcmp (res, in, 8) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -807,6 +823,7 @@ GST_START_TEST (test_half_s32)
   gint32 in[2] = { 1073741824, -65536 };
   gint32 out[2] = { 536870912, -32768 };
   gint32 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -815,8 +832,7 @@ GST_START_TEST (test_half_s32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -834,10 +850,11 @@ GST_START_TEST (test_half_s32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint32 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+  fail_unless (memcmp (res, out, 8) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -854,6 +871,7 @@ GST_START_TEST (test_double_s32)
   gint32 in[2] = { 1073741824, -65536 };
   gint32 out[2] = { 2147483647, -131072 };      /* notice the clamped sample */
   gint32 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -862,8 +880,7 @@ GST_START_TEST (test_double_s32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -881,10 +898,11 @@ GST_START_TEST (test_double_s32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint32 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+  fail_unless (memcmp (res, out, 8) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -902,6 +920,7 @@ GST_START_TEST (test_mute_s32)
   gint32 in[2] = { 1073741824, -65536 };
   gint32 out[2] = { 0, 0 };
   gint32 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -910,8 +929,7 @@ GST_START_TEST (test_mute_s32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -929,10 +947,11 @@ GST_START_TEST (test_mute_s32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint32 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", out[0], out[1], res[0],
       res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 8) == 0);
+  fail_unless (memcmp (res, out, 8) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -947,6 +966,7 @@ GST_START_TEST (test_unity_f32)
   GstCaps *caps;
   gfloat in[2] = { 0.75, -0.25 };
   gfloat *res;
+  gsize size;
 
   volume = setup_volume ();
   fail_unless (gst_element_set_state (volume,
@@ -954,7 +974,7 @@ GST_START_TEST (test_unity_f32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -967,7 +987,7 @@ GST_START_TEST (test_unity_f32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", in[0], in[1], res[0],
       res[1]);
   fail_unless_equals_float (res[0], in[0]);
@@ -988,6 +1008,7 @@ GST_START_TEST (test_half_f32)
   gfloat in[2] = { 0.75, -0.25 };
   gfloat out[2] = { 0.375, -0.125 };
   gfloat *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -996,8 +1017,7 @@ GST_START_TEST (test_half_f32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1015,11 +1035,12 @@ GST_START_TEST (test_half_f32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", out[0], out[1],
       res[0], res[1]);
   fail_unless_equals_float (res[0], out[0]);
   fail_unless_equals_float (res[1], out[1]);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -1036,6 +1057,7 @@ GST_START_TEST (test_double_f32)
   gfloat in[2] = { 0.75, -0.25 };
   gfloat out[2] = { 1.5, -0.5 };        /* nothing is clamped */
   gfloat *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -1044,8 +1066,7 @@ GST_START_TEST (test_double_f32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1063,11 +1084,12 @@ GST_START_TEST (test_double_f32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", out[0], out[1],
       res[0], res[1]);
   fail_unless_equals_float (res[0], out[0]);
   fail_unless_equals_float (res[1], out[1]);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -1085,6 +1107,7 @@ GST_START_TEST (test_mute_f32)
   gfloat in[2] = { 0.75, -0.25 };
   gfloat out[2] = { 0, 0 };
   gfloat *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -1093,8 +1116,7 @@ GST_START_TEST (test_mute_f32)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (8);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 8);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 8) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 8);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1112,11 +1134,12 @@ GST_START_TEST (test_mute_f32)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", out[0], out[1],
       res[0], res[1]);
   fail_unless_equals_float (res[0], out[0]);
   fail_unless_equals_float (res[1], out[1]);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -1131,6 +1154,7 @@ GST_START_TEST (test_unity_f64)
   GstCaps *caps;
   gdouble in[2] = { 0.75, -0.25 };
   gdouble *res;
+  gsize size;
 
   volume = setup_volume ();
   fail_unless (gst_element_set_state (volume,
@@ -1138,7 +1162,7 @@ GST_START_TEST (test_unity_f64)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (16);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
+  gst_buffer_fill (inbuffer, 0, in, 16);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1151,7 +1175,7 @@ GST_START_TEST (test_unity_f64)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", in[0], in[1], res[0],
       res[1]);
   fail_unless_equals_float (res[0], in[0]);
@@ -1172,6 +1196,7 @@ GST_START_TEST (test_half_f64)
   gdouble in[2] = { 0.75, -0.25 };
   gdouble out[2] = { 0.375, -0.125 };
   gdouble *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -1180,8 +1205,7 @@ GST_START_TEST (test_half_f64)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (16);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 16);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1199,11 +1223,12 @@ GST_START_TEST (test_half_f64)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", out[0], out[1],
       res[0], res[1]);
   fail_unless_equals_float (res[0], out[0]);
   fail_unless_equals_float (res[1], out[1]);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -1220,6 +1245,7 @@ GST_START_TEST (test_double_f64)
   gdouble in[2] = { 0.75, -0.25 };
   gdouble out[2] = { 1.5, -0.5 };       /* nothing is clamped */
   gdouble *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -1228,8 +1254,7 @@ GST_START_TEST (test_double_f64)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (16);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 16);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1247,11 +1272,12 @@ GST_START_TEST (test_double_f64)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", out[0], out[1],
       res[0], res[1]);
   fail_unless_equals_float (res[0], out[0]);
   fail_unless_equals_float (res[1], out[1]);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -1269,6 +1295,7 @@ GST_START_TEST (test_mute_f64)
   gdouble in[2] = { 0.75, -0.25 };
   gdouble out[2] = { 0, 0 };
   gdouble *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -1277,8 +1304,7 @@ GST_START_TEST (test_mute_f64)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (16);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+  gst_buffer_fill (inbuffer, 0, in, 16);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1296,11 +1322,12 @@ GST_START_TEST (test_mute_f64)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+1.4f %+1.4f  real %+1.4f %+1.4f", out[0], out[1],
       res[0], res[1]);
   fail_unless_equals_float (res[0], out[0]);
   fail_unless_equals_float (res[1], out[1]);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -1325,7 +1352,7 @@ GST_START_TEST (test_wrong_caps)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
+  gst_buffer_fill (inbuffer, 0, in, 4);
   caps = gst_caps_from_string (VOLUME_WRONG_CAPS_STRING);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1362,6 +1389,7 @@ GST_START_TEST (test_passthrough)
   GstCaps *caps;
   gint16 in[2] = { 16384, -256 };
   gint16 *res;
+  gsize size;
 
   volume = setup_volume ();
   g_object_set (G_OBJECT (volume), "volume", 1.0, NULL);
@@ -1370,7 +1398,7 @@ GST_START_TEST (test_passthrough)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
+  gst_buffer_fill (inbuffer, 0, in, 4);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
   gst_buffer_set_caps (inbuffer, caps);
   gst_caps_unref (caps);
@@ -1383,9 +1411,10 @@ GST_START_TEST (test_passthrough)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", in[0], in[1], res[0], res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+  fail_unless (memcmp (res, in, 4) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   /* cleanup */
   cleanup_volume (volume);
@@ -1439,6 +1468,7 @@ GST_START_TEST (test_controller_processing)
   GstCaps *caps;
   gint16 in[2] = { 16384, -256 };
   gint16 *res;
+  gsize size;
 
   volume = setup_volume ();
 
@@ -1457,7 +1487,7 @@ GST_START_TEST (test_controller_processing)
       "could not set to playing");
 
   inbuffer = gst_buffer_new_and_alloc (4);
-  memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
+  gst_buffer_fill (inbuffer, 0, in, 4);
   caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
   gst_buffer_set_caps (inbuffer, caps);
   GST_BUFFER_TIMESTAMP (inbuffer) = 0;
@@ -1471,9 +1501,10 @@ GST_START_TEST (test_controller_processing)
   fail_unless_equals_int (g_list_length (buffers), 1);
   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
   fail_unless (inbuffer == outbuffer);
-  res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+  res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
   GST_INFO ("expected %+5d %+5d  real %+5d %+5d", in[0], in[1], res[0], res[1]);
-  fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
+  fail_unless (memcmp (res, in, 4) == 0);
+  gst_buffer_unmap (outbuffer, res, size);
 
   g_object_unref (c);
 
index 29e3cd5..ecdc329 100644 (file)
@@ -147,7 +147,7 @@ GST_START_TEST (test_identification_header)
   bus = gst_bus_new ();
 
   inbuffer = gst_buffer_new_and_alloc (30);
-  memcpy (GST_BUFFER_DATA (inbuffer), identification_header, 30);
+  gst_buffer_fill (inbuffer, 0, identification_header, 30);
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
   gst_buffer_ref (inbuffer);
 
@@ -161,7 +161,7 @@ GST_START_TEST (test_identification_header)
   fail_if ((message = gst_bus_pop (bus)) != NULL);
 
   inbuffer = gst_buffer_new_and_alloc (sizeof (comment_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), comment_header, sizeof (comment_header));
+  gst_buffer_fill (inbuffer, 0, comment_header, sizeof (comment_header));
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
   gst_buffer_ref (inbuffer);
 
@@ -214,7 +214,7 @@ _create_codebook_header_buffer (void)
   vorbis_analysis_headerout (&vd, &vc, &header, &header_comm, &header_code);
 
   buffer = gst_buffer_new_and_alloc (header_code.bytes);
-  memcpy (GST_BUFFER_DATA (buffer), header_code.packet, header_code.bytes);
+  gst_buffer_fill (buffer, 0, header_code.packet, header_code.bytes);
 
   return buffer;
 }
@@ -236,7 +236,7 @@ _create_audio_buffer (void)
   vorbis_bitrate_addblock (&vb);
   vorbis_bitrate_flushpacket (&vd, &packet);
   buffer = gst_buffer_new_and_alloc (packet.bytes);
-  memcpy (GST_BUFFER_DATA (buffer), packet.packet, packet.bytes);
+  gst_buffer_fill (buffer, 0, packet.packet, packet.bytes);
 
   vorbis_comment_clear (&vc);
   vorbis_block_clear (&vb);
@@ -260,7 +260,7 @@ GST_START_TEST (test_empty_vorbis_packet)
   bus = gst_bus_new ();
 
   inbuffer = gst_buffer_new_and_alloc (30);
-  memcpy (GST_BUFFER_DATA (inbuffer), identification_header, 30);
+  gst_buffer_fill (inbuffer, 0, identification_header, 30);
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
   gst_buffer_ref (inbuffer);
 
@@ -275,7 +275,7 @@ GST_START_TEST (test_empty_vorbis_packet)
   fail_if ((message = gst_bus_pop (bus)) != NULL);
 
   inbuffer = gst_buffer_new_and_alloc (sizeof (comment_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), comment_header, sizeof (comment_header));
+  gst_buffer_fill (inbuffer, 0, comment_header, sizeof (comment_header));
   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
   gst_buffer_ref (inbuffer);
 
index 4b20d6d..dd1841b 100644 (file)
@@ -160,6 +160,18 @@ stop_pipeline (GstElement * element)
   pending_buffers = NULL;
 }
 
+static void
+compare_buffer (GstBuffer * buf, const guint8 * data, gsize size)
+{
+  guint8 *bdata;
+  gsize bsize;
+
+  bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  fail_unless_equals_int (bsize, size);
+  fail_unless_equals_int (memcmp (bdata, data, size), 0);
+  gst_buffer_unmap (buf, bdata, bsize);
+}
+
 static vorbis_comment vc;
 static vorbis_dsp_state vd;
 static vorbis_info vi;
@@ -182,7 +194,7 @@ _create_codebook_header_buffer (void)
   vorbis_analysis_headerout (&vd, &vc, &header, &header_comm, &header_code);
 
   buffer = gst_buffer_new_and_alloc (header_code.bytes);
-  memcpy (GST_BUFFER_DATA (buffer), header_code.packet, header_code.bytes);
+  gst_buffer_fill (buffer, 0, header_code.packet, header_code.bytes);
 
   return buffer;
 }
@@ -201,7 +213,7 @@ _create_audio_buffer (void)
   vorbis_bitrate_addblock (&vb);
   vorbis_bitrate_flushpacket (&vd, &packet);
   buffer = gst_buffer_new_and_alloc (packet.bytes);
-  memcpy (GST_BUFFER_DATA (buffer), packet.packet, packet.bytes);
+  gst_buffer_fill (buffer, 0, packet.packet, packet.bytes);
 
   vorbis_comment_clear (&vc);
   vorbis_block_clear (&vb);
@@ -232,13 +244,13 @@ GST_START_TEST (test_empty_tags_set)
 
   /* send identification header */
   inbuffer = gst_buffer_new_and_alloc (sizeof (identification_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), identification_header,
+  gst_buffer_fill (inbuffer, 0, identification_header,
       sizeof (identification_header));
   fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
 
   /* send empty comment buffer */
   inbuffer = gst_buffer_new_and_alloc (sizeof (empty_comment_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), empty_comment_header,
+  gst_buffer_fill (inbuffer, 0, empty_comment_header,
       sizeof (empty_comment_header));
   fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
 
@@ -251,18 +263,14 @@ GST_START_TEST (test_empty_tags_set)
 
   /* check identification header is unchanged */
   outbuffer = get_buffer ();
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer),
+  compare_buffer (outbuffer, identification_header,
       sizeof (identification_header));
-  fail_unless_equals_int (memcmp (GST_BUFFER_DATA (outbuffer),
-          identification_header, sizeof (identification_header)), 0);
   gst_buffer_unref (outbuffer);
 
   /* check comment header is correct */
   outbuffer = get_buffer ();
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer),
+  compare_buffer (outbuffer, title_comment_header,
       sizeof (title_comment_header));
-  fail_unless_equals_int (memcmp (GST_BUFFER_DATA (outbuffer),
-          title_comment_header, sizeof (title_comment_header)), 0);
   gst_buffer_unref (outbuffer);
 
   stop_pipeline (vorbistag);
@@ -291,13 +299,13 @@ GST_START_TEST (test_filled_tags_unset)
 
   /* send identification header */
   inbuffer = gst_buffer_new_and_alloc (sizeof (identification_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), identification_header,
+  gst_buffer_fill (inbuffer, 0, identification_header,
       sizeof (identification_header));
   fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
 
   /* send empty comment buffer */
   inbuffer = gst_buffer_new_and_alloc (sizeof (title_comment_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), title_comment_header,
+  gst_buffer_fill (inbuffer, 0, title_comment_header,
       sizeof (title_comment_header));
   fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
 
@@ -310,18 +318,14 @@ GST_START_TEST (test_filled_tags_unset)
 
   /* check identification header is unchanged */
   outbuffer = get_buffer ();
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer),
+  compare_buffer (outbuffer, identification_header,
       sizeof (identification_header));
-  fail_unless_equals_int (memcmp (GST_BUFFER_DATA (outbuffer),
-          identification_header, sizeof (identification_header)), 0);
   gst_buffer_unref (outbuffer);
 
   /* check comment header is correct */
   outbuffer = get_buffer ();
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer),
+  compare_buffer (outbuffer, empty_comment_header,
       sizeof (empty_comment_header));
-  fail_unless_equals_int (memcmp (GST_BUFFER_DATA (outbuffer),
-          empty_comment_header, sizeof (empty_comment_header)), 0);
   gst_buffer_unref (outbuffer);
 
   stop_pipeline (vorbistag);
@@ -351,13 +355,13 @@ GST_START_TEST (test_filled_tags_change)
 
   /* send identification header */
   inbuffer = gst_buffer_new_and_alloc (sizeof (identification_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), identification_header,
+  gst_buffer_fill (inbuffer, 0, identification_header,
       sizeof (identification_header));
   fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
 
   /* send empty comment buffer */
   inbuffer = gst_buffer_new_and_alloc (sizeof (artist_comment_header));
-  memcpy (GST_BUFFER_DATA (inbuffer), artist_comment_header,
+  gst_buffer_fill (inbuffer, 0, artist_comment_header,
       sizeof (artist_comment_header));
   fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
 
@@ -370,18 +374,14 @@ GST_START_TEST (test_filled_tags_change)
 
   /* check identification header is unchanged */
   outbuffer = get_buffer ();
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer),
+  compare_buffer (outbuffer, identification_header,
       sizeof (identification_header));
-  fail_unless_equals_int (memcmp (GST_BUFFER_DATA (outbuffer),
-          identification_header, sizeof (identification_header)), 0);
   gst_buffer_unref (outbuffer);
 
   /* check comment header is correct */
   outbuffer = get_buffer ();
-  fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer),
+  compare_buffer (outbuffer, title_comment_header,
       sizeof (title_comment_header));
-  fail_unless_equals_int (memcmp (GST_BUFFER_DATA (outbuffer),
-          title_comment_header, sizeof (title_comment_header)), 0);
   gst_buffer_unref (outbuffer);
 
   stop_pipeline (vorbistag);
index c53c671..29dec13 100644 (file)
@@ -62,8 +62,11 @@ GST_START_TEST (test_quicktime_mpeg4video)
   GstCaps *caps = NULL;
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (guint8 *) qt_redirect_396042;
-  GST_BUFFER_SIZE (buf) = sizeof (qt_redirect_396042);
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) qt_redirect_396042, NULL,
+          sizeof (qt_redirect_396042), 0, sizeof (qt_redirect_396042)));
+
   GST_BUFFER_OFFSET (buf) = 0;
 
   caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
@@ -89,8 +92,11 @@ GST_START_TEST (test_broken_flac_in_ogg)
   GstCaps *caps = NULL;
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (guint8 *) flac_id_packet;
-  GST_BUFFER_SIZE (buf) = sizeof (flac_id_packet);
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) flac_id_packet, NULL,
+          sizeof (flac_id_packet), 0, sizeof (flac_id_packet)));
+
   GST_BUFFER_OFFSET (buf) = 0;
 
   caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
@@ -123,8 +129,10 @@ typefind_test_file (const gchar * filename)
   }
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (guint8 *) data;
-  GST_BUFFER_SIZE (buf) = data_len;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) data, NULL, data_len, 0, data_len));
+
   GST_BUFFER_OFFSET (buf) = 0;
 
   caps = gst_type_find_helper_for_buffer (NULL, buf, NULL);
@@ -222,11 +230,14 @@ GST_START_TEST (test_ac3)
   GstBuffer *buf;
   GstCaps *caps = NULL;
   guint bsid;
+  guint8 *data;
 
   for (bsid = 0; bsid < 32; bsid++) {
     buf = gst_buffer_new_and_alloc ((256 + 640) * 2);
-    make_ac3_packet (GST_BUFFER_DATA (buf), 256 * 2, bsid);
-    make_ac3_packet (GST_BUFFER_DATA (buf) + 256 * 2, 640 * 2, bsid);
+    data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+    make_ac3_packet (data, 256 * 2, bsid);
+    make_ac3_packet (data + 256 * 2, 640 * 2, bsid);
+    gst_buffer_unmap (buf, data, (256 + 640) * 2);
 
     caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
     if (bsid <= 8) {
@@ -281,11 +292,14 @@ GST_START_TEST (test_eac3)
   GstBuffer *buf;
   GstCaps *caps = NULL;
   guint bsid;
+  guint8 *data;
 
   for (bsid = 0; bsid <= 32; bsid++) {
     buf = gst_buffer_new_and_alloc (558 + 384);
-    make_eac3_packet (GST_BUFFER_DATA (buf), 558, bsid);
-    make_eac3_packet (GST_BUFFER_DATA (buf) + 558, 384, bsid);
+    data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+    make_eac3_packet (data, 558, bsid);
+    make_eac3_packet (data + 558, 384, bsid);
+    gst_buffer_unmap (buf, data, 558 + 384);
 
     caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
     if (bsid > 10 && bsid <= 16) {
@@ -335,8 +349,10 @@ GST_START_TEST (test_random_data)
     data[i] = g_random_int () & 0xff;
 
   buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = (guint8 *) data;
-  GST_BUFFER_SIZE (buf) = TEST_RANDOM_DATA_SIZE;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          data, NULL, TEST_RANDOM_DATA_SIZE, 0, TEST_RANDOM_DATA_SIZE));
+
   GST_BUFFER_OFFSET (buf) = 0;
 
   caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
index f5fab57..68bb6f8 100644 (file)
@@ -127,18 +127,16 @@ GST_END_TEST;
 GST_START_TEST (test_buffer_clipping_time)
 {
   GstSegment s;
-
   GstBuffer *buf;
-
   GstBuffer *ret;
-
-  guint8 *data;
+  guint8 *data, *sdata;
+  gsize ssize;
 
   /* Clip start and end */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_TIME);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_TIME, 4 * GST_SECOND,
@@ -156,16 +154,18 @@ GST_START_TEST (test_buffer_clipping_time)
   fail_unless (GST_BUFFER_DURATION (ret) == 4 * GST_SECOND);
   fail_unless (GST_BUFFER_OFFSET (ret) == 400);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == 800);
-  fail_unless (GST_BUFFER_DATA (ret) == data + 200);
-  fail_unless (GST_BUFFER_SIZE (ret) == 400);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data + 200);
+  fail_unless (ssize == 400);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
   /* Clip only start */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_TIME);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_TIME, 4 * GST_SECOND,
@@ -183,16 +183,18 @@ GST_START_TEST (test_buffer_clipping_time)
   fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
   fail_unless (GST_BUFFER_OFFSET (ret) == 400);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == 1200);
-  fail_unless (GST_BUFFER_DATA (ret) == data + 200);
-  fail_unless (GST_BUFFER_SIZE (ret) == 800);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data + 200);
+  fail_unless (ssize == 800);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
   /* Clip only stop */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_TIME);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_TIME, 2 * GST_SECOND,
@@ -210,16 +212,18 @@ GST_START_TEST (test_buffer_clipping_time)
   fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
   fail_unless (GST_BUFFER_OFFSET (ret) == 200);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == 1000);
-  fail_unless (GST_BUFFER_DATA (ret) == data);
-  fail_unless (GST_BUFFER_SIZE (ret) == 800);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data);
+  fail_unless (ssize == 800);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
   /* Buffer outside segment */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_TIME);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_TIME, 12 * GST_SECOND,
@@ -236,8 +240,8 @@ GST_START_TEST (test_buffer_clipping_time)
   /* Clip start and end but don't touch duration and offset_end */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_TIME);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_TIME, 4 * GST_SECOND,
@@ -255,8 +259,10 @@ GST_START_TEST (test_buffer_clipping_time)
   fail_unless (GST_BUFFER_DURATION (ret) == GST_CLOCK_TIME_NONE);
   fail_unless (GST_BUFFER_OFFSET (ret) == 400);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == GST_BUFFER_OFFSET_NONE);
-  fail_unless (GST_BUFFER_DATA (ret) == data + 200);
-  fail_unless (GST_BUFFER_SIZE (ret) == 400);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data + 200);
+  fail_unless (ssize == 400);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
@@ -266,8 +272,8 @@ GST_START_TEST (test_buffer_clipping_time)
    */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_TIME);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_TIME, 0 * GST_SECOND,
@@ -289,8 +295,8 @@ GST_START_TEST (test_buffer_clipping_time)
    */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_PERCENT);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_PERCENT, 0, 10, 0);
@@ -311,18 +317,16 @@ GST_END_TEST;
 GST_START_TEST (test_buffer_clipping_samples)
 {
   GstSegment s;
-
   GstBuffer *buf;
-
   GstBuffer *ret;
-
-  guint8 *data;
+  guint8 *data, *sdata;
+  gsize ssize;
 
   /* Clip start and end */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_DEFAULT);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_DEFAULT, 400,
@@ -340,16 +344,18 @@ GST_START_TEST (test_buffer_clipping_samples)
   fail_unless (GST_BUFFER_DURATION (ret) == 4 * GST_SECOND);
   fail_unless (GST_BUFFER_OFFSET (ret) == 400);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == 800);
-  fail_unless (GST_BUFFER_DATA (ret) == data + 200);
-  fail_unless (GST_BUFFER_SIZE (ret) == 400);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data + 200);
+  fail_unless (ssize == 400);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
   /* Clip only start */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_DEFAULT);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_DEFAULT, 400,
@@ -367,16 +373,18 @@ GST_START_TEST (test_buffer_clipping_samples)
   fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
   fail_unless (GST_BUFFER_OFFSET (ret) == 400);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == 1200);
-  fail_unless (GST_BUFFER_DATA (ret) == data + 200);
-  fail_unless (GST_BUFFER_SIZE (ret) == 800);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data + 200);
+  fail_unless (ssize == 800);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
   /* Clip only stop */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_DEFAULT);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_DEFAULT, 200,
@@ -394,16 +402,18 @@ GST_START_TEST (test_buffer_clipping_samples)
   fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
   fail_unless (GST_BUFFER_OFFSET (ret) == 200);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == 1000);
-  fail_unless (GST_BUFFER_DATA (ret) == data);
-  fail_unless (GST_BUFFER_SIZE (ret) == 800);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data);
+  fail_unless (ssize == 800);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
   /* Buffer outside segment */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_DEFAULT);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_DEFAULT, 1200,
@@ -420,8 +430,8 @@ GST_START_TEST (test_buffer_clipping_samples)
   /* Clip start and end but don't touch duration and offset_end */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_DEFAULT);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_DEFAULT, 400,
@@ -439,8 +449,10 @@ GST_START_TEST (test_buffer_clipping_samples)
   fail_unless (GST_BUFFER_DURATION (ret) == GST_CLOCK_TIME_NONE);
   fail_unless (GST_BUFFER_OFFSET (ret) == 400);
   fail_unless (GST_BUFFER_OFFSET_END (ret) == GST_BUFFER_OFFSET_NONE);
-  fail_unless (GST_BUFFER_DATA (ret) == data + 200);
-  fail_unless (GST_BUFFER_SIZE (ret) == 400);
+  sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
+  fail_unless (sdata == data + 200);
+  fail_unless (ssize == 400);
+  gst_buffer_unmap (ret, sdata, ssize);
 
   gst_buffer_unref (ret);
 
@@ -450,8 +462,8 @@ GST_START_TEST (test_buffer_clipping_samples)
    */
   buf = gst_buffer_new ();
   data = (guint8 *) g_malloc (1000);
-  GST_BUFFER_SIZE (buf) = 1000;
-  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
+  gst_buffer_take_memory (buf,
+      gst_memory_new_wrapped (0, data, g_free, 1000, 0, 1000));
 
   gst_segment_init (&s, GST_FORMAT_DEFAULT);
   gst_segment_set_newsegment (&s, FALSE, 1.0, GST_FORMAT_DEFAULT, 0, 10, 0);
index 8747c9a..30e62e0 100644 (file)
@@ -260,9 +260,12 @@ static GstBuffer *
 gst_cd_foo_src_read_sector (GstCddaBaseSrc * cddabasesrc, gint sector)
 {
   GstBuffer *buf;
+  guint8 *data;
 
   buf = gst_buffer_new_and_alloc (CD_FRAMESIZE_RAW);
-  memset (GST_BUFFER_DATA (buf), 0, CD_FRAMESIZE_RAW);
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+  memset (data, 0, CD_FRAMESIZE_RAW);
+  gst_buffer_unmap (buf, data, CD_FRAMESIZE_RAW);
 
   return buf;
 }
index aa80624..3cea168 100644 (file)
@@ -24,7 +24,6 @@
 #include <gst/gst.h>
 #include <gst/check/gstcheck.h>
 
-#include <gst/app/gstappbuffer.h>
 #include <gst/app/gstapp-marshal.h>
 #include <gst/app/gstappsink.h>
 #include <gst/app/gstappsrc.h>
index e2111ba..bebd67d 100644 (file)
@@ -23,7 +23,6 @@
 #include <config.h>
 #include <gst/check/gstcheck.h>
 
-#include <gst/app/gstappbuffer.h>
 #include <gst/app/gstappsrc.h>
 #include <gst/app/gstappsink.h>
 #include <gst/audio/audio.h>
 #endif
 #endif
 
+/* disabled for 0.11 */
+#undef HAVE_ABI_SIZES
+#define HAVE_ABI_SIZES FALSE
+
 GST_START_TEST (test_ABI)
 {
   gst_check_abi_list (list, HAVE_ABI_SIZES);
index 3236a0f..752c224 100644 (file)
@@ -29,7 +29,7 @@
 
 GST_START_TEST (test_netbuffer_copy)
 {
-  GstNetBuffer *netbuf, *copy;
+  GstBuffer *netbuf, *copy;
   guint8 ipv6_addr[16] = { 0xff, 0x11, 0xee, 0x22, 0xdd, 0x33, 0xcc,
     0x44, 0xbb, 0x55, 0xaa, 0x66, 0x00, 0x77, 0x99, 0x88
   };
@@ -38,44 +38,88 @@ GST_START_TEST (test_netbuffer_copy)
   guint16 ipv6_port = 3490;
   guint16 ipv4_port = 5678;
   guint16 port;
+  GstMetaNetAddress *meta, *cmeta;
+  gsize len;
+  guint8 *data1, *data2;
+  gsize size1, size2;
 
-  netbuf = gst_netbuffer_new ();
+  netbuf = gst_buffer_new ();
   fail_unless (netbuf != NULL, "failed to create net buffer");
+  meta = gst_buffer_add_meta_net_address (netbuf);
 
-  gst_netaddress_set_ip4_address (&netbuf->from, ipv4_addr, ipv4_port);
-  gst_netaddress_set_ip6_address (&netbuf->to, ipv6_addr, ipv6_port);
+  gst_netaddress_set_ip4_address (&meta->naddr, ipv4_addr, ipv4_port);
+
+  len = strlen (DATA_STRING);
+  gst_buffer_take_memory (netbuf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) DATA_STRING, NULL, len, 0, len));
 
-  GST_BUFFER_DATA (netbuf) = (guint8 *) DATA_STRING;
-  GST_BUFFER_SIZE (netbuf) = strlen (DATA_STRING);
   GST_BUFFER_FLAG_SET (netbuf, GST_BUFFER_FLAG_DISCONT);
-  GST_BUFFER_FLAG_SET (netbuf, GST_BUFFER_FLAG_READONLY);
 
-  copy = (GstNetBuffer *) gst_buffer_copy (GST_BUFFER_CAST (netbuf));
+  copy = gst_buffer_copy (netbuf);
   fail_unless (copy != NULL, "failed to copy net buffer");
-  fail_unless (GST_IS_NETBUFFER (copy), "copied buffer is not a GstNetBuffer!");
+
+  cmeta = gst_buffer_get_meta_net_address (copy);
+  fail_unless (cmeta != NULL, "copied buffer is not a GstNetBuffer!");
 
   fail_unless_equals_int (GST_MINI_OBJECT_REFCOUNT_VALUE (copy), 1);
 
-  fail_unless_equals_int (GST_BUFFER_SIZE (copy), GST_BUFFER_SIZE (netbuf));
-  fail_unless (memcmp (GST_BUFFER_DATA (copy), GST_BUFFER_DATA (netbuf),
-          GST_BUFFER_SIZE (copy)) == 0);
+  data1 = gst_buffer_map (netbuf, &size1, NULL, GST_MAP_READ);
+  data2 = gst_buffer_map (copy, &size2, NULL, GST_MAP_READ);
+  fail_unless_equals_int (size1, size2);
+  fail_unless (memcmp (data1, data2, size1) == 0);
+  gst_buffer_unmap (copy, data2, size2);
+  gst_buffer_unmap (netbuf, data1, size1);
 
-  fail_if (GST_BUFFER_FLAG_IS_SET (copy, GST_BUFFER_FLAG_READONLY));
   fail_unless (GST_BUFFER_FLAG_IS_SET (copy, GST_BUFFER_FLAG_DISCONT));
 
-  fail_unless (gst_netaddress_get_ip4_address (&copy->from, &ipv4_copy, &port));
+  fail_unless (gst_netaddress_get_ip4_address (&cmeta->naddr, &ipv4_copy,
+          &port));
   fail_unless (ipv4_copy == ipv4_addr,
       "Copied buffer has wrong IPV4 from address");
   fail_unless (port == ipv4_port, "Copied buffer has wrong IPV4 from port");
+  gst_buffer_unref (netbuf);
+  gst_buffer_unref (copy);
+
+  netbuf = gst_buffer_new ();
+  fail_unless (netbuf != NULL, "failed to create net buffer");
+  meta = gst_buffer_add_meta_net_address (netbuf);
+
+  gst_netaddress_set_ip6_address (&meta->naddr, ipv6_addr, ipv6_port);
+
+  len = strlen (DATA_STRING);
+  gst_buffer_take_memory (netbuf,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          (gpointer) DATA_STRING, NULL, len, 0, len));
+
+  GST_BUFFER_FLAG_SET (netbuf, GST_BUFFER_FLAG_DISCONT);
+
+  copy = gst_buffer_copy (netbuf);
+  fail_unless (copy != NULL, "failed to copy net buffer");
+
+  cmeta = gst_buffer_get_meta_net_address (copy);
+  fail_unless (cmeta != NULL, "copied buffer is not a GstNetBuffer!");
+
+  fail_unless_equals_int (GST_MINI_OBJECT_REFCOUNT_VALUE (copy), 1);
+
+  data1 = gst_buffer_map (netbuf, &size1, NULL, GST_MAP_READ);
+  data2 = gst_buffer_map (copy, &size2, NULL, GST_MAP_READ);
+  fail_unless_equals_int (size1, size2);
+  fail_unless (memcmp (data1, data2, size1) == 0);
+  gst_buffer_unmap (copy, data2, size2);
+  gst_buffer_unmap (netbuf, data1, size1);
+
+  fail_unless (GST_BUFFER_FLAG_IS_SET (copy, GST_BUFFER_FLAG_DISCONT));
 
-  fail_unless (gst_netaddress_get_ip6_address (&copy->to, ipv6_copy, &port));
+  fail_unless (gst_netaddress_get_ip6_address (&cmeta->naddr, ipv6_copy,
+          &port));
   fail_unless (memcmp (ipv6_copy, ipv6_addr, 16) == 0,
       "Copied buffer has wrong IPv6 destination address");
   fail_unless (port == ipv6_port,
       "Copied buffer has wrong IPv6 destination port");
+  gst_buffer_unref (netbuf);
+  gst_buffer_unref (copy);
 
-  gst_buffer_unref (GST_BUFFER_CAST (netbuf));
-  gst_buffer_unref (GST_BUFFER_CAST (copy));
 }
 
 GST_END_TEST;
index 144d9a6..c72f753 100644 (file)
@@ -623,7 +623,7 @@ GST_START_TEST (test_pb_utils_installer_details)
   /* uri source */
   detail1 = gst_missing_uri_source_installer_detail_new ("http");
   fail_unless (detail1 != NULL);
-  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.10|"));
+  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.11|"));
   fail_unless (g_str_has_suffix (detail1, "|urisource-http"));
   msg = gst_missing_uri_source_message_new (el, "http");
   fail_unless (msg != NULL);
@@ -637,7 +637,7 @@ GST_START_TEST (test_pb_utils_installer_details)
   /* uri sink */
   detail1 = gst_missing_uri_sink_installer_detail_new ("http");
   fail_unless (detail1 != NULL);
-  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.10|"));
+  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.11|"));
   fail_unless (g_str_has_suffix (detail1, "|urisink-http"));
   msg = gst_missing_uri_sink_message_new (el, "http");
   fail_unless (msg != NULL);
@@ -651,7 +651,7 @@ GST_START_TEST (test_pb_utils_installer_details)
   /* element */
   detail1 = gst_missing_element_installer_detail_new ("deinterlace");
   fail_unless (detail1 != NULL);
-  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.10|"));
+  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.11|"));
   fail_unless (g_str_has_suffix (detail1, "|element-deinterlace"));
   msg = gst_missing_element_message_new (el, "deinterlace");
   fail_unless (msg != NULL);
@@ -667,7 +667,7 @@ GST_START_TEST (test_pb_utils_installer_details)
       2, "channels", G_TYPE_INT, 6, NULL);
   detail1 = gst_missing_decoder_installer_detail_new (caps);
   fail_unless (detail1 != NULL);
-  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.10|"));
+  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.11|"));
   fail_unless (g_str_has_suffix (detail1,
           "|decoder-audio/x-spiffy, spiffyversion=(int)2"));
   msg = gst_missing_decoder_message_new (el, caps);
@@ -684,7 +684,7 @@ GST_START_TEST (test_pb_utils_installer_details)
   caps = gst_caps_new_simple ("audio/x-spiffy", "spiffyversion", G_TYPE_INT,
       2, "channels", G_TYPE_INT, 6, NULL);
   detail1 = gst_missing_encoder_installer_detail_new (caps);
-  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.10|"));
+  fail_unless (g_str_has_prefix (detail1, "gstreamer|0.11|"));
   fail_unless (g_str_has_suffix (detail1,
           "|encoder-audio/x-spiffy, spiffyversion=(int)2"));
   fail_unless (detail1 != NULL);
index 285a58e..4d3c0e2 100644 (file)
@@ -289,7 +289,7 @@ GST_START_TEST (test_saving_profile)
   fail_unless (gst_encoding_target_save (orig, NULL));
 
   /* Check we can load it */
-  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
+  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.11",
       "encoding-profiles", "herding", "myponytarget2.gep", NULL);
   GST_DEBUG ("Loading target from '%s'", profile_file_name);
   loaded = gst_encoding_target_load_from_file (profile_file_name, NULL);
@@ -396,7 +396,7 @@ GST_START_TEST (test_loading_profile)
   GstEncodingProfile *profile;
   GstCaps *tmpcaps;
   GValue strvalue = { 0, };
-  GValue miniobjectvalue = { 0, };
+  GValue objectvalue = { 0, };
 
   /* Test loading using short method and all arguments */
   target = gst_encoding_target_load ("myponytarget", "herding", NULL);
@@ -411,7 +411,7 @@ GST_START_TEST (test_loading_profile)
   gst_encoding_target_unref (target);
 
   /* Test loading using fully specified path */
-  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
+  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.11",
       "encoding-profiles", "herding", "myponytarget.gep", NULL);
 
   GST_DEBUG ("Loading target from '%s'", profile_file_name);
@@ -442,13 +442,13 @@ GST_START_TEST (test_loading_profile)
 
   /* For my next trick, I will need the assistance of a GValue */
   g_value_init (&strvalue, G_TYPE_STRING);
-  g_value_init (&miniobjectvalue, GST_TYPE_ENCODING_PROFILE);
+  g_value_init (&objectvalue, GST_TYPE_ENCODING_PROFILE);
   g_value_set_static_string (&strvalue, "myponytarget/pony");
-  fail_unless (g_value_transform (&strvalue, &miniobjectvalue));
-  profile = (GstEncodingProfile *) gst_value_dup_mini_object (&miniobjectvalue);
+  fail_unless (g_value_transform (&strvalue, &objectvalue));
+  profile = (GstEncodingProfile *) g_value_dup_object (&objectvalue);
   fail_if (profile == NULL);
   g_value_unset (&strvalue);
-  g_value_unset (&miniobjectvalue);
+  g_value_unset (&objectvalue);
   tmpcaps = gst_caps_from_string ("animal/x-pony");
   CHECK_PROFILE (profile, "pony", "I don't want a description !", tmpcaps, NULL,
       0, 0);
@@ -489,7 +489,7 @@ GST_START_TEST (test_target_list)
   /* If tmp is NULL, it means we iterated the whole list without finding
    * our target */
   fail_if (tmp == NULL);
-  g_list_foreach (targets, (GFunc) gst_mini_object_unref, NULL);
+  g_list_foreach (targets, (GFunc) g_object_unref, NULL);
   g_list_free (targets);
 
   /* Try getting all available targets without a specified category */
@@ -503,7 +503,7 @@ GST_START_TEST (test_target_list)
   /* If tmp is NULL, it means we iterated the whole list without finding
    * our target */
   fail_if (tmp == NULL);
-  g_list_foreach (targets, (GFunc) gst_mini_object_unref, NULL);
+  g_list_foreach (targets, (GFunc) g_object_unref, NULL);
   g_list_free (targets);
 }
 
@@ -544,11 +544,11 @@ remove_profile_file (void)
 {
   gchar *profile_file_name;
 
-  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
+  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.11",
       "encoding-profiles", "herding", "myponytarget.gep", NULL);
   g_unlink (profile_file_name);
   g_free (profile_file_name);
-  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
+  profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.11",
       "encoding-profiles", "herding", "myponytarget2.gep", NULL);
   g_unlink (profile_file_name);
   g_free (profile_file_name);
@@ -562,10 +562,10 @@ create_profile_file (void)
   GError *error = NULL;
 
   profile_dir =
-      g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
+      g_build_filename (g_get_home_dir (), ".gstreamer-0.11",
       "encoding-profiles", "herding", NULL);
   profile_file_name =
-      g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
+      g_build_filename (g_get_home_dir (), ".gstreamer-0.11",
       "encoding-profiles", "herding", "myponytarget.gep", NULL);
   g_mkdir_with_parents (profile_dir, S_IRUSR | S_IWUSR | S_IXUSR);
   if (!g_file_set_contents (profile_file_name, profile_string,
@@ -597,7 +597,7 @@ profile_suite (void)
   gchar *gst_dir;
 
   /* cehck if we can create profiles */
-  gst_dir = g_build_filename (g_get_home_dir (), ".gstreamer-0.10", NULL);
+  gst_dir = g_build_filename (g_get_home_dir (), ".gstreamer-0.11", NULL);
   can_write = (g_access (gst_dir, R_OK | W_OK | X_OK) == 0);
   g_free (gst_dir);
 
index defd6b6..a8346c4 100644 (file)
@@ -34,99 +34,109 @@ GST_START_TEST (test_rtp_buffer)
 {
   GstBuffer *buf;
   guint8 *data;
+  gsize size;
+  GstRTPBuffer rtp = { NULL, };
 
   /* check GstRTPHeader structure alignment and packing */
   buf = gst_rtp_buffer_new_allocate (16, 4, 0);
   fail_unless (buf != NULL);
-  fail_unless_equals_int (GST_BUFFER_SIZE (buf), RTP_HEADER_LEN + 16 + 4);
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  fail_unless_equals_int (size, RTP_HEADER_LEN + 16 + 4);
+
+  gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
 
   /* check defaults */
-  fail_unless_equals_int (gst_rtp_buffer_get_version (buf), 2);
-  fail_unless (gst_rtp_buffer_get_padding (buf) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension (buf) == FALSE);
-  fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 0);
-  fail_unless (gst_rtp_buffer_get_marker (buf) == FALSE);
-  fail_unless (gst_rtp_buffer_get_payload_type (buf) == 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_version (&rtp), 2);
+  fail_unless (gst_rtp_buffer_get_padding (&rtp) == FALSE);
+  fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
+  fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (&rtp), 0);
+  fail_unless (gst_rtp_buffer_get_marker (&rtp) == FALSE);
+  fail_unless (gst_rtp_buffer_get_payload_type (&rtp) == 0);
   fail_unless_equals_int (GST_READ_UINT16_BE (data), 0x8000);
 
   /* check version in bitfield */
-  gst_rtp_buffer_set_version (buf, 3);
-  fail_unless_equals_int (gst_rtp_buffer_get_version (buf), 3);
+  gst_rtp_buffer_set_version (&rtp, 3);
+  fail_unless_equals_int (gst_rtp_buffer_get_version (&rtp), 3);
   fail_unless_equals_int ((data[0] & 0xC0) >> 6, 3);
-  gst_rtp_buffer_set_version (buf, 2);
-  fail_unless_equals_int (gst_rtp_buffer_get_version (buf), 2);
+  gst_rtp_buffer_set_version (&rtp, 2);
+  fail_unless_equals_int (gst_rtp_buffer_get_version (&rtp), 2);
   fail_unless_equals_int ((data[0] & 0xC0) >> 6, 2);
 
   /* check padding bit */
-  gst_rtp_buffer_set_padding (buf, TRUE);
-  fail_unless (gst_rtp_buffer_get_padding (buf) == TRUE);
+  gst_rtp_buffer_set_padding (&rtp, TRUE);
+  fail_unless (gst_rtp_buffer_get_padding (&rtp) == TRUE);
   fail_unless_equals_int ((data[0] & 0x20) >> 5, 1);
-  gst_rtp_buffer_set_padding (buf, FALSE);
-  fail_unless (gst_rtp_buffer_get_padding (buf) == FALSE);
+  gst_rtp_buffer_set_padding (&rtp, FALSE);
+  fail_unless (gst_rtp_buffer_get_padding (&rtp) == FALSE);
   fail_unless_equals_int ((data[0] & 0x20) >> 5, 0);
 
   /* check marker bit */
-  gst_rtp_buffer_set_marker (buf, TRUE);
-  fail_unless (gst_rtp_buffer_get_marker (buf) == TRUE);
+  gst_rtp_buffer_set_marker (&rtp, TRUE);
+  fail_unless (gst_rtp_buffer_get_marker (&rtp) == TRUE);
   fail_unless_equals_int ((data[1] & 0x80) >> 7, 1);
-  gst_rtp_buffer_set_marker (buf, FALSE);
-  fail_unless (gst_rtp_buffer_get_marker (buf) == FALSE);
+  gst_rtp_buffer_set_marker (&rtp, FALSE);
+  fail_unless (gst_rtp_buffer_get_marker (&rtp) == FALSE);
   fail_unless_equals_int ((data[1] & 0x80) >> 7, 0);
 
   /* check sequence offset */
-  gst_rtp_buffer_set_seq (buf, 0xF2C9);
-  fail_unless_equals_int (gst_rtp_buffer_get_seq (buf), 0xF2C9);
+  gst_rtp_buffer_set_seq (&rtp, 0xF2C9);
+  fail_unless_equals_int (gst_rtp_buffer_get_seq (&rtp), 0xF2C9);
   fail_unless_equals_int (GST_READ_UINT16_BE (data + 2), 0xF2C9);
-  gst_rtp_buffer_set_seq (buf, 0);
-  fail_unless_equals_int (gst_rtp_buffer_get_seq (buf), 0);
+  gst_rtp_buffer_set_seq (&rtp, 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_seq (&rtp), 0);
   fail_unless_equals_int (GST_READ_UINT16_BE (data + 2), 0);
 
   /* check timestamp offset */
-  gst_rtp_buffer_set_timestamp (buf, 432191);
+  gst_rtp_buffer_set_timestamp (&rtp, 432191);
   fail_unless_equals_int (GST_READ_UINT32_BE (data + 4), 432191);
-  fail_unless_equals_int (gst_rtp_buffer_get_timestamp (buf), 432191);
-  gst_rtp_buffer_set_timestamp (buf, 0);
-  fail_unless_equals_int (gst_rtp_buffer_get_timestamp (buf), 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_timestamp (&rtp), 432191);
+  gst_rtp_buffer_set_timestamp (&rtp, 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_timestamp (&rtp), 0);
   fail_unless_equals_int (GST_READ_UINT32_BE (data + 4), 0);
 
   /* check ssrc offset */
-  gst_rtp_buffer_set_ssrc (buf, 0xf04043C2);
-  fail_unless_equals_int (gst_rtp_buffer_get_ssrc (buf), (gint) 0xf04043c2);
+  gst_rtp_buffer_set_ssrc (&rtp, 0xf04043C2);
+  fail_unless_equals_int (gst_rtp_buffer_get_ssrc (&rtp), (gint) 0xf04043c2);
   fail_unless_equals_int (GST_READ_UINT32_BE (data + 4 + 4), (gint) 0xf04043c2);
-  gst_rtp_buffer_set_ssrc (buf, 0);
-  fail_unless_equals_int (gst_rtp_buffer_get_ssrc (buf), 0);
+  gst_rtp_buffer_set_ssrc (&rtp, 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_ssrc (&rtp), 0);
   fail_unless_equals_int (GST_READ_UINT32_BE (data + 4 + 4), 0);
 
   /* check csrc bits */
-  fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 0);
-  ASSERT_CRITICAL (gst_rtp_buffer_get_csrc (buf, 0));
+  fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (&rtp), 0);
+  ASSERT_CRITICAL (gst_rtp_buffer_get_csrc (&rtp, 0));
   fail_unless_equals_int (data[0] & 0xf, 0);
+
+  gst_rtp_buffer_unmap (&rtp);
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 
   /* and again, this time with CSRCs */
   buf = gst_rtp_buffer_new_allocate (16, 4, 3);
   fail_unless (buf != NULL);
-  fail_unless_equals_int (GST_BUFFER_SIZE (buf),
-      RTP_HEADER_LEN + 16 + 4 + 4 * 3);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  fail_unless_equals_int (size, RTP_HEADER_LEN + 16 + 4 + 4 * 3);
 
-  data = GST_BUFFER_DATA (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
 
-  fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 3);
-  ASSERT_CRITICAL (gst_rtp_buffer_get_csrc (buf, 3));
+  fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (&rtp), 3);
+  ASSERT_CRITICAL (gst_rtp_buffer_get_csrc (&rtp, 3));
   fail_unless_equals_int (data[0] & 0xf, 3);
-  fail_unless_equals_int (gst_rtp_buffer_get_csrc (buf, 0), 0);
-  fail_unless_equals_int (gst_rtp_buffer_get_csrc (buf, 1), 0);
-  fail_unless_equals_int (gst_rtp_buffer_get_csrc (buf, 2), 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_csrc (&rtp, 0), 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_csrc (&rtp, 1), 0);
+  fail_unless_equals_int (gst_rtp_buffer_get_csrc (&rtp, 2), 0);
 
   data += RTP_HEADER_LEN;       /* skip the other header stuff */
-  gst_rtp_buffer_set_csrc (buf, 0, 0xf7c0);
+  gst_rtp_buffer_set_csrc (&rtp, 0, 0xf7c0);
   fail_unless_equals_int (GST_READ_UINT32_BE (data + 0 * 4), 0xf7c0);
-  gst_rtp_buffer_set_csrc (buf, 1, 0xf7c1);
+  gst_rtp_buffer_set_csrc (&rtp, 1, 0xf7c1);
   fail_unless_equals_int (GST_READ_UINT32_BE (data + 1 * 4), 0xf7c1);
-  gst_rtp_buffer_set_csrc (buf, 2, 0xf7c2);
+  gst_rtp_buffer_set_csrc (&rtp, 2, 0xf7c2);
   fail_unless_equals_int (GST_READ_UINT32_BE (data + 2 * 4), 0xf7c2);
-  ASSERT_CRITICAL (gst_rtp_buffer_set_csrc (buf, 3, 0xf123));
+  ASSERT_CRITICAL (gst_rtp_buffer_set_csrc (&rtp, 3, 0xf123));
+
+  gst_rtp_buffer_unmap (&rtp);
+  gst_buffer_unmap (buf, data, size);
   gst_buffer_unref (buf);
 }
 
@@ -143,15 +153,15 @@ GST_START_TEST (test_rtp_buffer_validate_corrupt)
     0xb0, 0x97, 0x63, 0x08, 0x10, 0x4b, 0x43, 0x85, 0x37, 0x2c
   };
 
-  buf = gst_buffer_new ();
-  GST_BUFFER_DATA (buf) = corrupt_rtp_packet;
-  GST_BUFFER_SIZE (buf) = sizeof (corrupt_rtp_packet);
+  buf = gst_buffer_new_and_alloc (sizeof (corrupt_rtp_packet));
+  gst_buffer_fill (buf, 0, corrupt_rtp_packet, sizeof (corrupt_rtp_packet));
   fail_if (gst_rtp_buffer_validate (buf));
   gst_buffer_unref (buf);
 }
 
 GST_END_TEST;
 
+#if 0
 GST_START_TEST (test_rtp_buffer_list)
 {
   GstBuffer *rtp_header;
@@ -203,6 +213,7 @@ GST_START_TEST (test_rtp_buffer_list)
 }
 
 GST_END_TEST;
+#endif
 
 GST_START_TEST (test_rtp_buffer_set_extension_data)
 {
@@ -213,158 +224,185 @@ GST_START_TEST (test_rtp_buffer_set_extension_data)
   guint8 misc_data[4] = { 1, 2, 3, 4 };
   gpointer pointer;
   guint8 appbits;
+  gsize bsize;
+  GstRTPBuffer rtp = { NULL, };
 
   /* check GstRTPHeader structure alignment and packing */
   buf = gst_rtp_buffer_new_allocate (4, 0, 0);
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+
+  gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
 
   /* should be impossible to set the extension data */
-  ASSERT_WARNING (fail_unless (gst_rtp_buffer_set_extension_data (buf, 0,
+  ASSERT_WARNING (fail_unless (gst_rtp_buffer_set_extension_data (&rtp, 0,
               4) == FALSE));
-  fail_unless (gst_rtp_buffer_get_extension (buf) == FALSE);
+  fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
 
   /* should be possible to set the extension data */
-  fail_unless (gst_rtp_buffer_set_extension_data (buf, 270, 0) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension (buf) == TRUE);
-  gst_rtp_buffer_get_extension_data (buf, &bits, &pointer, &size);
+  fail_unless (gst_rtp_buffer_set_extension_data (&rtp, 270, 0) == TRUE);
+  fail_unless (gst_rtp_buffer_get_extension (&rtp) == TRUE);
+  gst_rtp_buffer_get_extension_data (&rtp, &bits, &pointer, &size);
   fail_unless (bits == 270);
   fail_unless (size == 0);
-  fail_unless (pointer == GST_BUFFER_DATA (buf) + 16);
-  pointer = gst_rtp_buffer_get_payload (buf);
-  fail_unless (pointer == GST_BUFFER_DATA (buf) + 16);
+  fail_unless (pointer == data + 16);
+  pointer = gst_rtp_buffer_get_payload (&rtp);
+  fail_unless (pointer == data + 16);
+
+  gst_buffer_unmap (buf, data, bsize);
+  gst_rtp_buffer_unmap (&rtp);
   gst_buffer_unref (buf);
 
   buf = gst_rtp_buffer_new_allocate (20, 0, 0);
-  data = GST_BUFFER_DATA (buf);
-  fail_unless (gst_rtp_buffer_get_extension (buf) == FALSE);
-  fail_unless (gst_rtp_buffer_set_extension_data (buf, 333, 2) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension (buf) == TRUE);
-  gst_rtp_buffer_get_extension_data (buf, &bits, &pointer, &size);
+  data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
+
+  fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
+  fail_unless (gst_rtp_buffer_set_extension_data (&rtp, 333, 2) == TRUE);
+  fail_unless (gst_rtp_buffer_get_extension (&rtp) == TRUE);
+  gst_rtp_buffer_get_extension_data (&rtp, &bits, &pointer, &size);
   fail_unless (bits == 333);
   fail_unless (size == 2);
-  fail_unless (pointer == GST_BUFFER_DATA (buf) + 16);
-  pointer = gst_rtp_buffer_get_payload (buf);
-  fail_unless (pointer == GST_BUFFER_DATA (buf) + 24);
+  fail_unless (pointer == data + 16);
+  pointer = gst_rtp_buffer_get_payload (&rtp);
+  fail_unless (pointer == data + 24);
+
+  gst_buffer_unmap (buf, data, bsize);
+  gst_rtp_buffer_unmap (&rtp);
   gst_buffer_unref (buf);
 
   /* Test header extensions with a one byte header */
   buf = gst_rtp_buffer_new_allocate (20, 0, 0);
-  fail_unless (gst_rtp_buffer_get_extension (buf) == FALSE);
+  data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
 
-  fail_unless (gst_rtp_buffer_add_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
+
+  fail_unless (gst_rtp_buffer_add_extension_onebyte_header (&rtp, 5,
           misc_data, 2) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension_data (buf, &bits, &pointer, &size));
+  fail_unless (gst_rtp_buffer_get_extension_data (&rtp, &bits, &pointer,
+          &size));
   fail_unless (bits == 0xBEDE);
   fail_unless (size == 1);
   data = (guint8 *) pointer;
   fail_unless (data[0] == ((5 << 4) | 1));
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 2,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 2,
           1, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           1, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
 
-  fail_unless (gst_rtp_buffer_add_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_add_extension_onebyte_header (&rtp, 5,
           misc_data, 4) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           1, &pointer, &size) == TRUE);
   fail_unless (size == 4);
   fail_unless (memcmp (pointer, misc_data, 4) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           2, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 2,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 2,
           1, &pointer, &size) == FALSE);
 
-  fail_unless (gst_rtp_buffer_add_extension_onebyte_header (buf, 6,
+  fail_unless (gst_rtp_buffer_add_extension_onebyte_header (&rtp, 6,
           misc_data, 2) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           1, &pointer, &size) == TRUE);
   fail_unless (size == 4);
   fail_unless (memcmp (pointer, misc_data, 4) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           3, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 2,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 2,
           1, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 6,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 6,
           2, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (buf, 5,
+  fail_unless (gst_rtp_buffer_get_extension_onebyte_header (&rtp, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
+
+  gst_buffer_unmap (buf, data, bsize);
+  gst_rtp_buffer_unmap (&rtp);
   gst_buffer_unref (buf);
 
   /* Test header extensions with a two bytes header */
   buf = gst_rtp_buffer_new_allocate (20, 0, 0);
-  fail_unless (gst_rtp_buffer_get_extension (buf) == FALSE);
+  data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
+  gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
+
+  fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
 
-  fail_unless (gst_rtp_buffer_add_extension_twobytes_header (buf, 0, 5,
+  fail_unless (gst_rtp_buffer_add_extension_twobytes_header (&rtp, 0, 5,
           misc_data, 2) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension_data (buf, &bits, &pointer, &size));
+  fail_unless (gst_rtp_buffer_get_extension_data (&rtp, &bits, &pointer,
+          &size));
   fail_unless (bits == 0x100 << 4);
   fail_unless (size == 1);
   data = (guint8 *) pointer;
   fail_unless (data[0] == 5);
   fail_unless (data[1] == 2);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 2,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 2,
           0, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           1, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
 
-  fail_unless (gst_rtp_buffer_add_extension_twobytes_header (buf, 0, 5,
+  fail_unless (gst_rtp_buffer_add_extension_twobytes_header (&rtp, 0, 5,
           misc_data, 4) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           1, &pointer, &size) == TRUE);
   fail_unless (size == 4);
   fail_unless (memcmp (pointer, misc_data, 4) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           2, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 2,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 2,
           0, &pointer, &size) == FALSE);
 
-  fail_unless (gst_rtp_buffer_add_extension_twobytes_header (buf, 0, 6,
+  fail_unless (gst_rtp_buffer_add_extension_twobytes_header (&rtp, 0, 6,
           misc_data, 2) == TRUE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           1, &pointer, &size) == TRUE);
   fail_unless (size == 4);
   fail_unless (memcmp (pointer, misc_data, 4) == 0);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           2, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 2,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 2,
           0, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 6,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 6,
           1, &pointer, &size) == FALSE);
-  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (buf, &appbits, 5,
+  fail_unless (gst_rtp_buffer_get_extension_twobytes_header (&rtp, &appbits, 5,
           0, &pointer, &size) == TRUE);
   fail_unless (size == 2);
   fail_unless (memcmp (pointer, misc_data, 2) == 0);
+
+  gst_buffer_unmap (buf, data, bsize);
+  gst_rtp_buffer_unmap (&rtp);
   gst_buffer_unref (buf);
 }
 
 GST_END_TEST;
 
+#if 0
 GST_START_TEST (test_rtp_buffer_list_set_extension)
 {
   GstBufferList *list;
@@ -544,6 +582,7 @@ GST_START_TEST (test_rtp_buffer_list_set_extension)
 }
 
 GST_END_TEST;
+#endif
 
 GST_START_TEST (test_rtp_seqnum_compare)
 {
@@ -636,18 +675,22 @@ GST_START_TEST (test_rtcp_buffer)
   GstBuffer *buf;
   GstRTCPPacket packet;
   guint8 *data;
+  gsize size;
+  GstRTCPBuffer rtcp = { NULL, };
 
   buf = gst_rtcp_buffer_new (1400);
   fail_unless (buf != NULL);
-  fail_unless_equals_int (GST_BUFFER_SIZE (buf), 1400);
-  data = GST_BUFFER_DATA (buf);
+  data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+  fail_unless_equals_int (size, 1400);
+
+  gst_rtcp_buffer_map (buf, GST_MAP_READWRITE, &rtcp);
 
-  fail_unless (gst_rtcp_buffer_get_first_packet (buf, &packet) == FALSE);
-  fail_unless (gst_rtcp_buffer_get_packet_count (buf) == 0);
   fail_unless (gst_rtcp_buffer_validate (buf) == FALSE);
+  fail_unless (gst_rtcp_buffer_get_first_packet (&rtcp, &packet) == FALSE);
+  fail_unless (gst_rtcp_buffer_get_packet_count (&rtcp) == 0);
 
   /* add an SR packet */
-  fail_unless (gst_rtcp_buffer_add_packet (buf, GST_RTCP_TYPE_SR,
+  fail_unless (gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_SR,
           &packet) == TRUE);
 
   fail_unless (gst_rtcp_packet_get_padding (&packet) == 0);
@@ -675,7 +718,7 @@ GST_START_TEST (test_rtcp_buffer)
   }
 
   /* go to first packet, this should be the packet we just added */
-  fail_unless (gst_rtcp_buffer_get_first_packet (buf, &packet) == TRUE);
+  fail_unless (gst_rtcp_buffer_get_first_packet (&rtcp, &packet) == TRUE);
 
   fail_unless (gst_rtcp_packet_get_padding (&packet) == 0);
   fail_unless (gst_rtcp_packet_get_count (&packet) == 0);
@@ -685,14 +728,14 @@ GST_START_TEST (test_rtcp_buffer)
   fail_unless (gst_rtcp_packet_move_to_next (&packet) == FALSE);
 
   /* add some SDES */
-  fail_unless (gst_rtcp_buffer_add_packet (buf, GST_RTCP_TYPE_SDES,
+  fail_unless (gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_SDES,
           &packet) == TRUE);
   fail_unless (gst_rtcp_packet_sdes_add_item (&packet, 0xff658743) == TRUE);
   fail_unless (gst_rtcp_packet_sdes_add_entry (&packet, GST_RTCP_SDES_CNAME,
           sizeof ("test@foo.bar"), (guint8 *) "test@foo.bar") == TRUE);
 
   /* add some BYE */
-  fail_unless (gst_rtcp_buffer_add_packet (buf, GST_RTCP_TYPE_BYE,
+  fail_unless (gst_rtcp_buffer_add_packet (&rtcp, GST_RTCP_TYPE_BYE,
           &packet) == TRUE);
   fail_unless (gst_rtcp_packet_bye_add_ssrc (&packet, 0x5613212f) == TRUE);
   fail_unless (gst_rtcp_packet_bye_add_ssrc (&packet, 0x00112233) == TRUE);
@@ -704,7 +747,7 @@ GST_START_TEST (test_rtcp_buffer)
   fail_unless (gst_rtcp_packet_get_length (&packet) == 2);
 
   /* move to SDES */
-  fail_unless (gst_rtcp_buffer_get_first_packet (buf, &packet) == TRUE);
+  fail_unless (gst_rtcp_buffer_get_first_packet (&rtcp, &packet) == TRUE);
   fail_unless (gst_rtcp_packet_move_to_next (&packet) == TRUE);
 
   fail_unless (gst_rtcp_packet_get_padding (&packet) == 0);
@@ -722,7 +765,7 @@ GST_START_TEST (test_rtcp_buffer)
   fail_unless (gst_rtcp_packet_get_length (&packet) == 2);
 
   /* close and validate */
-  gst_rtcp_buffer_end (buf);
+  gst_rtcp_buffer_unmap (&rtcp);
   fail_unless (gst_rtcp_buffer_validate (buf) == TRUE);
   gst_buffer_unref (buf);
 }
@@ -739,12 +782,12 @@ rtp_suite (void)
   tcase_add_test (tc_chain, test_rtp_buffer);
   tcase_add_test (tc_chain, test_rtp_buffer_validate_corrupt);
   tcase_add_test (tc_chain, test_rtp_buffer_set_extension_data);
-  tcase_add_test (tc_chain, test_rtp_buffer_list_set_extension);
+  //tcase_add_test (tc_chain, test_rtp_buffer_list_set_extension);
   tcase_add_test (tc_chain, test_rtp_seqnum_compare);
 
   tcase_add_test (tc_chain, test_rtcp_buffer);
 
-  tcase_add_test (tc_chain, test_rtp_buffer_list);
+  //tcase_add_test (tc_chain, test_rtp_buffer_list);
 
   return s;
 }
index 6f504ad..bbedd28 100644 (file)
@@ -1,7 +1,5 @@
 
 GstCheckABIStruct list[] = {
-  {"GstAppBufferClass", sizeof (GstAppBufferClass), 16},
-  {"GstAppBuffer", sizeof (GstAppBuffer), 88},
   {"GstAppSinkCallbacks", sizeof (GstAppSinkCallbacks), 28},
   {"GstAppSinkClass", sizeof (GstAppSinkClass), 404},
   {"GstAppSink", sizeof (GstAppSink), 404},
@@ -49,8 +47,6 @@ GstCheckABIStruct list[] = {
   {"GstMixerTrack", sizeof (GstMixerTrack), 32},
   {"GstNavigationInterface", sizeof (GstNavigationInterface), 28},
   {"GstNetAddress", sizeof (GstNetAddress), 40},
-  {"GstNetBufferClass", sizeof (GstNetBufferClass), 32},
-  {"GstNetBuffer", sizeof (GstNetBuffer), 176},
   {"GstPropertyProbeInterface", sizeof (GstPropertyProbeInterface), 44},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
index 3029e56..ad8bc7c 100644 (file)
@@ -1,7 +1,5 @@
 
 GstCheckABIStruct list[] = {
-  {"GstAppBufferClass", sizeof (GstAppBufferClass), 32},
-  {"GstAppBuffer", sizeof (GstAppBuffer), 136},
   {"GstAppSinkCallbacks", sizeof (GstAppSinkCallbacks), 56},
   {"GstAppSinkClass", sizeof (GstAppSinkClass), 800},
   {"GstAppSink", sizeof (GstAppSink), 640},
@@ -49,8 +47,6 @@ GstCheckABIStruct list[] = {
   {"GstMixerTrack", sizeof (GstMixerTrack), 48},
   {"GstNavigationInterface", sizeof (GstNavigationInterface), 56},
   {"GstNetAddress", sizeof (GstNetAddress), 56},
-  {"GstNetBufferClass", sizeof (GstNetBufferClass), 64},
-  {"GstNetBuffer", sizeof (GstNetBuffer), 264},
   {"GstPropertyProbeInterface", sizeof (GstPropertyProbeInterface), 88},
   {"gst_riff_acid", sizeof (gst_riff_acid), 24},
   {"gst_riff_dmlh", sizeof (gst_riff_dmlh), 4},
index c963ce5..198ba99 100644 (file)
@@ -407,6 +407,8 @@ GST_START_TEST (test_vorbis_tags)
   /* now, while we still have a taglist, test _to_vorbiscomment_buffer() */
   {
     GstBuffer *buf1, *buf2;
+    guint8 *data1, *data2;
+    gsize size1, size2;
 
     ASSERT_CRITICAL (gst_tag_list_to_vorbiscomment_buffer (NULL,
             (const guint8 *) "x", 1, "x"));
@@ -418,8 +420,13 @@ GST_START_TEST (test_vorbis_tags)
         (const guint8 *) "foo", 3, NULL);
     fail_unless (buf2 != NULL);
 
-    fail_unless (memcmp (GST_BUFFER_DATA (buf1), GST_BUFFER_DATA (buf2) + 3,
-            GST_BUFFER_SIZE (buf1)) == 0);
+    data1 = gst_buffer_map (buf1, &size1, NULL, GST_MAP_READ);
+    data2 = gst_buffer_map (buf2, &size2, NULL, GST_MAP_READ);
+
+    fail_unless (memcmp (data1, data2 + 3, size1) == 0);
+
+    gst_buffer_unmap (buf2, data2, size2);
+    gst_buffer_unmap (buf1, data1, size1);
 
     gst_buffer_unref (buf1);
     gst_buffer_unref (buf2);
@@ -437,8 +444,10 @@ GST_START_TEST (test_vorbis_tags)
     gchar *vendor = NULL;
 
     buf = gst_buffer_new ();
-    GST_BUFFER_DATA (buf) = (guint8 *) speex_comments_buf1;
-    GST_BUFFER_SIZE (buf) = sizeof (speex_comments_buf1);
+    gst_buffer_take_memory (buf,
+        gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+            (gpointer) speex_comments_buf1, NULL,
+            sizeof (speex_comments_buf1), 0, sizeof (speex_comments_buf1)));
 
     /* make sure it doesn't memcmp over the end of the buffer */
     fail_unless (gst_tag_list_from_vorbiscomment_buffer (buf,
@@ -480,8 +489,10 @@ GST_START_TEST (test_vorbis_tags)
     gchar *vendor = NULL;
 
     buf = gst_buffer_new ();
-    GST_BUFFER_DATA (buf) = (guint8 *) vorbis_comments_buf;
-    GST_BUFFER_SIZE (buf) = sizeof (vorbis_comments_buf);
+    gst_buffer_take_memory (buf,
+        gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+            (gpointer) vorbis_comments_buf, NULL,
+            sizeof (vorbis_comments_buf), 0, sizeof (vorbis_comments_buf)));
 
     /* make sure it doesn't memcmp over the end of the buffer */
     fail_unless (gst_tag_list_from_vorbiscomment_buffer (buf,
@@ -755,7 +766,7 @@ GST_START_TEST (test_xmp_formatting)
   GstTagList *list;
   GstBuffer *buf;
   const gchar *text;
-  guint len;
+  gsize len;
 
   /* test data */
   list = gst_tag_list_new_full (GST_TAG_TITLE, "test title",
@@ -765,8 +776,7 @@ GST_START_TEST (test_xmp_formatting)
   buf = gst_tag_list_to_xmp_buffer (list, FALSE);
   fail_unless (buf != NULL);
 
-  text = (const gchar *) GST_BUFFER_DATA (buf);
-  len = GST_BUFFER_SIZE (buf);
+  text = gst_buffer_map (buf, &len, NULL, GST_MAP_READ);
 
   /* check the content */
   fail_unless (g_strrstr_len (text, len, "<?xpacket begin") == text);
@@ -775,6 +785,7 @@ GST_START_TEST (test_xmp_formatting)
   fail_unless (g_strrstr_len (text, len, ">keyword1<") != NULL);
   fail_unless (g_strrstr_len (text, len, ">keyword2<") != NULL);
   fail_unless (g_strrstr_len (text, len, "<?xpacket end") != NULL);
+  gst_buffer_unmap (buf, (gpointer) text, len);
 
   gst_buffer_unref (buf);
   gst_tag_list_free (list);
@@ -814,16 +825,18 @@ GST_START_TEST (test_xmp_parsing)
   };
 
   /* test data */
-  buf = gst_buffer_new ();
-
   i = 0;
   while (test_data[i].xmp_data) {
+    gsize len;
+
     GST_DEBUG ("trying test-data %u", i);
 
     text = g_strconcat (xmp_header, test_data[i].xmp_data, xmp_footer, NULL);
-    GST_BUFFER_DATA (buf) = (guint8 *) text;
-    GST_BUFFER_SIZE (buf) = strlen (text) + 1;
 
+    buf = gst_buffer_new ();
+    len = strlen (text) + 1;
+    gst_buffer_take_memory (buf,
+        gst_memory_new_wrapped (0, text, NULL, len, 0, len));
 
     list = gst_tag_list_from_xmp_buffer (buf);
     if (test_data[i].result_size >= 0) {
@@ -844,11 +857,10 @@ GST_START_TEST (test_xmp_parsing)
     if (list)
       gst_tag_list_free (list);
 
+    gst_buffer_unref (buf);
     g_free (text);
     i++;
   }
-
-  gst_buffer_unref (buf);
 }
 
 GST_END_TEST;
@@ -1263,6 +1275,7 @@ GST_START_TEST (test_exif_tags_serialization_deserialization)
   GstBuffer *buf = NULL;
   gint i;
   GstTagList *taglist;
+  guint8 *data;
 
   gst_tag_register_musicbrainz_tags ();
 
@@ -1567,8 +1580,10 @@ GST_START_TEST (test_exif_tags_serialization_deserialization)
 
   g_value_init (&value, GST_TYPE_BUFFER);
   buf = gst_buffer_new_and_alloc (1024);
+  data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
   for (i = 0; i < 1024; i++)
-    GST_BUFFER_DATA (buf)[i] = i % 255;
+    data[i] = i % 255;
+  gst_buffer_unmap (buf, data, 1024);
   gst_value_set_buffer (&value, buf);
   gst_buffer_unref (buf);
   do_simple_exif_tag_serialization_deserialization (GST_TAG_APPLICATION_DATA,
index 05b840c..fc5c674 100644 (file)
@@ -628,14 +628,16 @@ GST_START_TEST (test_convert_frame)
   guint8 *data;
 
   from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
-  data = GST_BUFFER_DATA (from_buffer);
 
+  data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
   for (i = 0; i < 640 * 480; i++) {
     data[4 * i + 0] = 0;        /* x */
     data[4 * i + 1] = 255;      /* R */
     data[4 * i + 2] = 0;        /* G */
     data[4 * i + 3] = 0;        /* B */
   }
+  gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
+
   from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB,
       640, 480, 25, 1, 1, 1);
   gst_buffer_set_caps (from_buffer, from_caps);
@@ -697,14 +699,16 @@ GST_START_TEST (test_convert_frame_async)
   ConvertFrameContext cf_data = { NULL, NULL, NULL };
 
   from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
-  data = GST_BUFFER_DATA (from_buffer);
 
+  data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
   for (i = 0; i < 640 * 480; i++) {
     data[4 * i + 0] = 0;        /* x */
     data[4 * i + 1] = 255;      /* R */
     data[4 * i + 2] = 0;        /* G */
     data[4 * i + 3] = 0;        /* B */
   }
+  gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
+
   from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB,
       640, 480, 25, 1, 1, 1);
   gst_buffer_set_caps (from_buffer, from_caps);
index 99b84ae..3227b07 100644 (file)
@@ -143,11 +143,22 @@ tag_list_equals (GstTagList * taglist, GstTagList * taglist2)
 static gboolean
 gst_buffer_equals (GstBuffer * buf_a, GstBuffer * buf_b)
 {
-  if (GST_BUFFER_SIZE (buf_a) != GST_BUFFER_SIZE (buf_b))
-    return FALSE;
+  gboolean res;
+  gpointer data1, data2;
+  gsize size1, size2;
 
-  return memcmp (GST_BUFFER_DATA (buf_a), GST_BUFFER_DATA (buf_b),
-      GST_BUFFER_SIZE (buf_a)) == 0;
+  data1 = gst_buffer_map (buf_a, &size1, NULL, GST_MAP_READ);
+  data2 = gst_buffer_map (buf_b, &size2, NULL, GST_MAP_READ);
+
+  if (size1 == size2) {
+    res = memcmp (data1, data2, size1) == 0;
+  } else {
+    res = FALSE;
+  }
+  gst_buffer_unmap (buf_a, data1, size1);
+  gst_buffer_unmap (buf_b, data2, size2);
+
+  return res;
 }
 
 static GstTagList *
index a104c25..46655cd 100644 (file)
@@ -162,16 +162,14 @@ eos_buffer_probe (GstPad * pad, GstBuffer * buffer, gpointer unused)
 {
   gint ret;
   gint size;
-  guint8 *data;
   gchar *oggbuffer;
   ChainState *state = NULL;
   gboolean has_video = FALSE;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  size = gst_buffer_get_size (buffer);
 
   oggbuffer = ogg_sync_buffer (&oggsync, size);
-  memcpy (oggbuffer, data, size);
+  gst_buffer_extract (buffer, 0, oggbuffer, size);
   ogg_sync_wrote (&oggsync, size);
 
   do {
index c3872ad..e32ba33 100644 (file)
@@ -122,6 +122,11 @@ static int n_in_caps = 0;
 static gboolean
 buffer_probe_cb (GstPad * pad, GstBuffer * buffer)
 {
+  guint8 *data;
+  gsize size;
+
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
   if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
     GstCaps *caps;
     GstStructure *s;
@@ -143,22 +148,27 @@ buffer_probe_cb (GstPad * pad, GstBuffer * buffer)
 
     for (i = 0; i < 3; ++i) {
       GValue *val;
+      guint8 *data2;
+      gsize size2;
 
       val = &g_array_index (buffers, GValue, i);
       buf = g_value_peek_pointer (val);
       fail_unless (GST_IS_BUFFER (buf));
-      if (GST_BUFFER_SIZE (buf) == GST_BUFFER_SIZE (buffer)) {
-        if (memcmp (GST_BUFFER_DATA (buf), GST_BUFFER_DATA (buffer),
-                GST_BUFFER_SIZE (buffer)) == 0) {
+
+      data2 = gst_buffer_map (buf, &size2, NULL, GST_MAP_READ);
+      if (size2 == size) {
+        if (memcmp (data2, data, size) == 0) {
           found = TRUE;
         }
       }
+      gst_buffer_unmap (buf, data2, size2);
     }
     fail_unless (found, "Did not find incoming IN_CAPS buffer %p on caps",
         buffer);
 
     gst_caps_unref (caps);
   }
+  gst_buffer_unmap (buffer, data, size);
 
   return TRUE;
 }
index b207dff..4e35aeb 100644 (file)
@@ -264,7 +264,12 @@ GST_END_TEST;
 static gboolean
 drop_second_data_buffer (GstPad * droppad, GstBuffer * buffer, gpointer unused)
 {
-  return !(GST_BUFFER_OFFSET (buffer) == 1024);
+  gboolean res;
+
+  res = !(GST_BUFFER_OFFSET (buffer) == 1024);
+  GST_DEBUG ("dropping %d", res);
+
+  return res;
 }
 
 GST_START_TEST (test_discontinuity)
@@ -356,11 +361,11 @@ GST_START_TEST (test_discontinuity)
      * samples (because of the overlap/add), so it won't increment the 
      * granulepos, which should be 2048 after the discontinuity.
      */
+    fail_unless (GST_BUFFER_IS_DISCONT (buffer),
+        "expected discontinuous buffer");
     fail_unless (GST_BUFFER_OFFSET_END (buffer) == 2048,
         "expected granulepos after gap: %" G_GUINT64_FORMAT,
         GST_BUFFER_OFFSET_END (buffer));
-    fail_unless (GST_BUFFER_IS_DISCONT (buffer),
-        "expected discontinuous buffer");
     gst_buffer_unref (buffer);
   }
 
index a92dfb5..0dd6d3e 100644 (file)
@@ -4,7 +4,6 @@
 
 #include <gst/app/gstappsrc.h>
 #include <gst/app/gstappsink.h>
-#include <gst/app/gstappbuffer.h>
 
 /* these are the caps we are going to pass through the appsink and appsrc */
 const gchar *audio_caps =
@@ -23,7 +22,6 @@ static void
 on_new_buffer_from_source (GstElement * elt, ProgramData * data)
 {
   guint size;
-  gpointer raw_buffer;
   GstBuffer *app_buffer, *buffer;
   GstElement *source;
 
@@ -32,11 +30,11 @@ on_new_buffer_from_source (GstElement * elt, ProgramData * data)
 
   /* turn it into an app buffer, it's not really needed, we could simply push
    * the retrieved buffer from appsink into appsrc just fine.  */
-  size = GST_BUFFER_SIZE (buffer);
+  size = gst_buffer_get_size (buffer);
   g_print ("Pushing a buffer of size %d\n", size);
-  raw_buffer = g_malloc0 (size);
-  memcpy (raw_buffer, GST_BUFFER_DATA (buffer), size);
-  app_buffer = gst_app_buffer_new (raw_buffer, size, g_free, raw_buffer);
+  app_buffer = gst_buffer_new_and_alloc (size);
+
+  gst_buffer_copy_into (app_buffer, buffer, GST_BUFFER_COPY_MEMORY, 0, size);
 
   /* newer basesrc will set caps for use automatically but it does not really
    * hurt to set it on the buffer again */
index af5d7a7..d382acf 100644 (file)
@@ -83,8 +83,10 @@ feed_data (GstElement * appsrc, guint size, App * app)
   if (app->offset + size > app->length)
     size = app->length - app->offset;
 
-  GST_BUFFER_DATA (buffer) = app->data + app->offset;
-  GST_BUFFER_SIZE (buffer) = size;
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          app->data, NULL, app->length, app->offset, size));
+
   /* we need to set an offset for random access */
   GST_BUFFER_OFFSET (buffer) = app->offset;
   GST_BUFFER_OFFSET_END (buffer) = app->offset + size;
index 9421f9b..d38e895 100644 (file)
@@ -89,8 +89,9 @@ feed_data (GstElement * appsrc, guint size, App * app)
   if (app->offset + len > app->length)
     len = app->length - app->offset;
 
-  GST_BUFFER_DATA (buffer) = app->data + app->offset;
-  GST_BUFFER_SIZE (buffer) = len;
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          app->data, NULL, app->length, app->offset, len));
 
   GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
       app->offset, len);
index d14e143..65bd04d 100644 (file)
@@ -96,8 +96,9 @@ read_data (App * app)
   if (app->offset + len > app->length)
     len = app->length - app->offset;
 
-  GST_BUFFER_DATA (buffer) = app->data + app->offset;
-  GST_BUFFER_SIZE (buffer) = len;
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          app->data, NULL, app->length, app->offset, len));
 
   GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
       app->offset, len);
index a80e4d1..ed97c3b 100644 (file)
@@ -96,8 +96,9 @@ feed_data (GstElement * appsrc, guint size, App * app)
   if (app->offset + len > app->length)
     len = app->length - app->offset;
 
-  GST_BUFFER_DATA (buffer) = app->data + app->offset;
-  GST_BUFFER_SIZE (buffer) = len;
+  gst_buffer_take_memory (buffer,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+          app->data, NULL, app->length, app->offset, len));
 
   GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", buffer,
       app->offset, len);
index c7aa4b6..5468a66 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <gst/gst.h>
 #include <gst/app/gstappsrc.h>
-#include <gst/app/gstappbuffer.h>
 #include <gst/app/gstappsink.h>
 
 #include <stdio.h>
@@ -25,8 +24,6 @@ struct _App
 
 App s_app;
 
-static void dont_eat_my_chicken_wings (void *priv);
-
 int
 main (int argc, char *argv[])
 {
@@ -59,11 +56,12 @@ main (int argc, char *argv[])
     GstBuffer *buf;
     void *data;
 
-    data = malloc (100);
+    buf = gst_buffer_new_and_alloc (100);
+    data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
     memset (data, i, 100);
+    gst_buffer_unmap (buf, data, 100);
 
-    buf = gst_app_buffer_new (data, 100, dont_eat_my_chicken_wings, data);
-    printf ("%d: creating buffer for pointer %p, %p\n", i, data, buf);
+    printf ("%d: pushing buffer for pointer %p, %p\n", i, data, buf);
     gst_app_src_push_buffer (GST_APP_SRC (app->src), buf);
   }
 
@@ -86,10 +84,3 @@ main (int argc, char *argv[])
 
   return 0;
 }
-
-static void
-dont_eat_my_chicken_wings (void *priv)
-{
-  printf ("freeing buffer for pointer %p\n", priv);
-  free (priv);
-}
index ec74cc8..b7283e8 100644 (file)
@@ -2044,6 +2044,8 @@ shot_cb (GtkButton * button, gpointer data)
     gint width, height;
     GdkPixbuf *pixbuf;
     GError *error = NULL;
+    gsize size;
+    guint8 *data;
 
     /* get the snapshot buffer format now. We set the caps on the appsink so
      * that it can only be an rgb buffer. The only thing we have not specified
@@ -2066,12 +2068,17 @@ shot_cb (GtkButton * button, gpointer data)
 
     /* create pixmap from buffer and save, gstreamer video buffers have a stride
      * that is rounded up to the nearest multiple of 4 */
-    pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer),
+    data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+    pixbuf = gdk_pixbuf_new_from_data (data,
         GDK_COLORSPACE_RGB, FALSE, 8, width, height,
         GST_ROUND_UP_4 (width * 3), NULL, NULL);
 
     /* save the pixbuf */
     gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
+    gst_buffer_unmap (buffer, data, size);
+
+    /* save the pixbuf */
+    gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
 
   done:
     gst_buffer_unref (buffer);
index 8bf0818..b20574e 100644 (file)
@@ -2034,6 +2034,8 @@ shot_cb (GtkButton * button, gpointer data)
     gint width, height;
     GdkPixbuf *pixbuf;
     GError *error = NULL;
+    guint8 *data;
+    gsize size;
 
     /* get the snapshot buffer format now. We set the caps on the appsink so
      * that it can only be an rgb buffer. The only thing we have not specified
@@ -2056,12 +2058,14 @@ shot_cb (GtkButton * button, gpointer data)
 
     /* create pixmap from buffer and save, gstreamer video buffers have a stride
      * that is rounded up to the nearest multiple of 4 */
-    pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer),
+    data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+    pixbuf = gdk_pixbuf_new_from_data (data,
         GDK_COLORSPACE_RGB, FALSE, 8, width, height,
         GST_ROUND_UP_4 (width * 3), NULL, NULL);
 
     /* save the pixbuf */
     gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
+    gst_buffer_unmap (buffer, data, size);
 
   done:
     gst_buffer_unref (buffer);
index 14f2809..252f82f 100644 (file)
@@ -37,6 +37,8 @@ main (int argc, char *argv[])
   GstFormat format;
   GstStateChangeReturn ret;
   gboolean res;
+  guint8 *data;
+  gsize size;
 
   gst_init (&argc, &argv);
 
@@ -133,12 +135,17 @@ main (int argc, char *argv[])
 
     /* create pixmap from buffer and save, gstreamer video buffers have a stride
      * that is rounded up to the nearest multiple of 4 */
-    pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer),
+    data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+    pixbuf = gdk_pixbuf_new_from_data (data,
         GDK_COLORSPACE_RGB, FALSE, 8, width, height,
         GST_ROUND_UP_4 (width * 3), NULL, NULL);
 
     /* save the pixbuf */
     gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
+    gst_buffer_unmap (buffer, data, size);
+
+    /* save the pixbuf */
+    gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
   } else {
     g_print ("could not make snapshot\n");
   }
index 8fc3107..0b32ed0 100644 (file)
@@ -94,7 +94,7 @@ have_subtitle (GstElement * appsink, App * app)
 
   if (buffer) {
     guint8 *data;
-    guint size;
+    gsize size;
     GstFormat format;
     gint64 position;
     GstClock *clock;
@@ -114,10 +114,9 @@ have_subtitle (GstElement * appsink, App * app)
         ", running_time %" GST_TIME_FORMAT, GST_TIME_ARGS (position),
         GST_TIME_ARGS (running_time));
 
-    data = GST_BUFFER_DATA (buffer);
-    size = GST_BUFFER_SIZE (buffer);
-
+    data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
     gst_util_dump_mem (data, size);
+    gst_buffer_unmap (buffer, data, size);
   }
 }
 
index 00d2d0f..bcadc1b 100644 (file)
@@ -249,7 +249,9 @@ print_tag_each (GQuark field_id, const GValue * value, gpointer user_data)
     ser = g_value_dup_string (value);
   else if (GST_VALUE_HOLDS_BUFFER (value)) {
     GstBuffer *buf = gst_value_get_buffer (value);
-    ser = g_strdup_printf ("<GstBuffer [%d bytes]>", GST_BUFFER_SIZE (buf));
+    ser =
+        g_strdup_printf ("<GstBuffer [%" G_GSIZE_FORMAT " bytes]>",
+        gst_buffer_get_size (buf));
   } else
     ser = gst_value_serialize (value);
 
index 892d680..596a576 100644 (file)
@@ -1,6 +1,4 @@
 EXPORTS
-       gst_app_buffer_get_type
-       gst_app_buffer_new
        gst_app_sink_get_caps
        gst_app_sink_get_drop
        gst_app_sink_get_emit_signals
index bd6f8c7..4a191d4 100644 (file)
@@ -1,4 +1,5 @@
 EXPORTS
+       gst_meta_net_address_get_info
        gst_netaddress_equal
        gst_netaddress_get_address_bytes
        gst_netaddress_get_ip4_address
@@ -8,5 +9,3 @@ EXPORTS
        gst_netaddress_set_ip4_address
        gst_netaddress_set_ip6_address
        gst_netaddress_to_string
-       gst_netbuffer_get_type
-       gst_netbuffer_new
index 41c9660..54d855b 100644 (file)
@@ -19,12 +19,13 @@ EXPORTS
        gst_basertppayload_set_options
        gst_basertppayload_set_outcaps
        gst_rtcp_buffer_add_packet
-       gst_rtcp_buffer_end
        gst_rtcp_buffer_get_first_packet
        gst_rtcp_buffer_get_packet_count
+       gst_rtcp_buffer_map
        gst_rtcp_buffer_new
        gst_rtcp_buffer_new_copy_data
        gst_rtcp_buffer_new_take_data
+       gst_rtcp_buffer_unmap
        gst_rtcp_buffer_validate
        gst_rtcp_buffer_validate_data
        gst_rtcp_ntp_to_unix
@@ -99,21 +100,7 @@ EXPORTS
        gst_rtp_buffer_get_ssrc
        gst_rtp_buffer_get_timestamp
        gst_rtp_buffer_get_version
-       gst_rtp_buffer_list_add_extension_onebyte_header
-       gst_rtp_buffer_list_add_extension_twobytes_header
-       gst_rtp_buffer_list_from_buffer
-       gst_rtp_buffer_list_get_extension_onebyte_header
-       gst_rtp_buffer_list_get_extension_twobytes_header
-       gst_rtp_buffer_list_get_payload_len
-       gst_rtp_buffer_list_get_payload_type
-       gst_rtp_buffer_list_get_seq
-       gst_rtp_buffer_list_get_ssrc
-       gst_rtp_buffer_list_get_timestamp
-       gst_rtp_buffer_list_set_payload_type
-       gst_rtp_buffer_list_set_seq
-       gst_rtp_buffer_list_set_ssrc
-       gst_rtp_buffer_list_set_timestamp
-       gst_rtp_buffer_list_validate
+       gst_rtp_buffer_map
        gst_rtp_buffer_new_allocate
        gst_rtp_buffer_new_allocate_len
        gst_rtp_buffer_new_copy_data
@@ -130,6 +117,7 @@ EXPORTS
        gst_rtp_buffer_set_ssrc
        gst_rtp_buffer_set_timestamp
        gst_rtp_buffer_set_version
+       gst_rtp_buffer_unmap
        gst_rtp_buffer_validate
        gst_rtp_buffer_validate_data
        gst_rtp_payload_info_for_name
index bab6bbd..7eab5a5 100644 (file)
@@ -17,6 +17,7 @@ EXPORTS
        gst_tag_list_add_id3_image
        gst_tag_list_from_exif_buffer
        gst_tag_list_from_exif_buffer_with_tiff_header
+       gst_tag_list_from_vorbiscomment
        gst_tag_list_from_vorbiscomment_buffer
        gst_tag_list_from_xmp_buffer
        gst_tag_list_new_from_id3v1