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
#
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:
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 \
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)
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
#
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)
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 \
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)
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
#
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)
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
#
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)
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
#
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)
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
#
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)
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 \
$(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)
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
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)
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 \
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)
#
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
#
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)
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
#
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)
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 \
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)
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 \
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)
#
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 \
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)
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
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)
#
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
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)
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
#
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)
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 \
#
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)
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 \
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)
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)
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
AM_PROG_LIBTOOL
dnl *** required versions of GStreamer stuff ***
-GST_REQ=0.10.32.1
+GST_REQ=0.11.0
dnl *** autotools stuff ****
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")
-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\"/" \
#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;
list = g_list_append (NULL, pspec);
}
- GST_CLASS_UNLOCK (GST_OBJECT_CLASS (klass));
+ G_UNLOCK (probe_lock);
return list;
}
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;
{
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;
}
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;
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;
* 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);
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;
"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);
GstGnomeVFSSink *sink;
GnomeVFSResult result;
GstFlowReturn ret;
+ guint8 *data;
+ gsize size;
sink = GST_GNOME_VFS_SINK (basesink);
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;
}
/* 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;
}
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;
GnomeVFSResult res;
GstBuffer *buf;
GnomeVFSFileSize readbytes;
- guint8 *data;
- guint todo;
+ guint8 *data, *ptr;
+ gsize todo;
GstGnomeVFSSrc *src;
src = GST_GNOME_VFS_SRC (basesrc);
}
}
- 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)))
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;
}
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)));
}
eos:
{
+ gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
GST_DEBUG_OBJECT (src, "Reading data gave EOS");
return GST_FLOW_UNEXPECTED;
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);
gboolean need_skip;
const guint16 *data;
guint64 dist, timestamp;
+ guint8 *outdata;
+ gsize outsize;
GST_DEBUG_OBJECT (visual, "processing 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
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;
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 */
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;
/* 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 */
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;
buffer_too_small:
{
GST_DEBUG_OBJECT (ogg, "codec_data is too small");
+ gst_buffer_unmap (buffer, data, size);
return FALSE;
}
}
/* 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);
{
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);
/* 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);
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;
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);
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;
goto write_failed;
done:
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
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);
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);
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);
/* 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
/* 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. */
/* 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);
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");
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);
GstCaps *caps;
GstStructure *structure;
GstBuffer *hbuf;
+ gsize size;
pad = (GstOggPadData *) walk->data;
thepad = pad->collect.pad;
}
/* 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;
/* 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");
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;
/* 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 */
GstOggPadData *pad = ogg_mux->pulling;
gint64 duration;
gboolean force_flush;
+ gsize size;
GST_LOG_OBJECT (ogg_mux->pulling->collect.pad, "pulling from pad");
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;
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);
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;
}
done:
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
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;
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);
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);
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);
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)
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) {
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);
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");
gst_tag_list_free (*tags);
*tags = list;
- gst_buffer_unref (buf);
-
return ret;
}
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;
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);
{
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;
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) {
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;
}
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
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:
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);
}
/* 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;
/* 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
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);
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' ||
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);
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);
render->width * 4);
}
}
+ gst_buffer_unmap (outbuf, data, size);
ret = gst_pad_push (render->srcpad, outbuf);
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)
theora_dec_chain (pad, buf);
/* skip the data */
- size -= psize;
- data += psize;
+ left -= psize;
+ ptr += psize;
offset += psize;
}
+ gst_buffer_unmap (buffer, data, size);
}
}
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");
int i, plane;
GstVideoFormat format;
guint8 *dest, *src;
+ gsize size;
+ guint8 *data;
switch (dec->info.pixel_fmt) {
case TH_PF_444:
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)
src += buf[plane].stride;
}
}
+ gst_buffer_unmap (*out, data, size);
return GST_FLOW_OK;
}
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;
} else {
result = theora_handle_data_packet (dec, &packet, timestamp, duration);
}
-
done:
+ gst_buffer_unmap (buf, packet.packet, size);
+
return result;
}
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 */
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);
/* 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;
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 */
{
GstFlowReturn ret;
- enc->bytes_out += GST_BUFFER_SIZE (buffer);
+ enc->bytes_out += gst_buffer_get_size (buffer);
ret = gst_pad_push (enc->srcpad, buffer);
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);
}
}
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);
{
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);
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;
}
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;
}
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);
}
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);
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);
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;
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
{
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);
{
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;
}
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 {
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;
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");
guint sample_count;
GstBuffer *out = NULL;
GstFlowReturn result;
- gint size;
+ guint8 *data;
+ gsize size;
if (G_UNLIKELY (!vd->initialized))
goto not_initialized;
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)
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;
}
done:
+ gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer);
+
return result;
empty_buffer:
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)));
}
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 *
}
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;
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)
{
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 +
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;
}
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;
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;
}
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,
{
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) {
{
GstVorbisEnc *vorbisenc;
GstFlowReturn ret = GST_FLOW_OK;
- gfloat *data;
+ gfloat *data, *ptr;
gulong size;
gulong i, j;
float **vorbis_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));
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
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))
}
/* 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);
/* 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);
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));
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);
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 */
{
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) {
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);
}
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);
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)
libgstapp_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/app
libgstapp_@GST_MAJORMINOR@include_HEADERS = \
gstappsrc.h \
- gstappbuffer.h \
gstappsink.h
CLEANFILES = $(BUILT_SOURCES)
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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
-
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);
* 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;
}
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);
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);
}
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);
/* 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;
}
/**
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);
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;
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;
* 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 {
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;
}
if (change_duration)
duration -= gst_util_uint64_scale (diff, GST_SECOND, rate);
- data += diff * frame_size;
+ trim += diff * frame_size;
size -= diff * frame_size;
}
}
}
- /* 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;
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"); \
static gboolean
gst_audio_filter_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
GstStructure *structure;
gboolean ret = TRUE;
/* 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;
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);
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;
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);
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,
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);
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));
}
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;
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;
}
GstBaseAudioSink *sink;
GstRingBuffer *ringbuf;
gint64 diff, align, ctime, cstop;
+ gsize offset;
guint8 *data;
- guint size;
+ gsize size;
guint samples, written;
gint bps;
gint accum;
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;
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 */
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;
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;
/* 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 */
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;
{
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:
GstBaseAudioSink *sink;
GstBuffer *buf;
GstFlowReturn ret;
+ gsize size;
basesink = GST_BASE_SINK (user_data);
sink = GST_BASE_AUDIO_SINK (user_data);
goto error;
}
- GST_PAD_PREROLL_LOCK (basesink->sinkpad);
+ GST_BASE_SINK_PREROLL_LOCK (basesink);
if (basesink->flushing)
goto flushing;
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);
{
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;
}
{
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;
}
return ret;
}
+#if 0
/* should be called with the LOCK */
static GstStateChangeReturn
gst_base_audio_sink_async_play (GstBaseSink * basesink)
return GST_STATE_CHANGE_SUCCESS;
}
+#endif
static GstStateChangeReturn
gst_base_audio_sink_change_state (GstElement * element,
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;
}
{
GstBaseAudioSrc *src = GST_BASE_AUDIO_SRC (bsrc);
GstBuffer *buf;
- guchar *data;
+ guchar *data, *ptr;
guint samples, total_samples;
guint64 sample;
gint bps;
/* 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)
/* 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) {
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;
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;
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);
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 */
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);
GCond *cond;
gboolean open;
gboolean acquired;
- GstBuffer *data;
+ guint8 *memory;
+ gsize size;
GstRingBufferSpec spec;
GstRingBufferSegState *segstate;
gint samples_per_seg;
/* 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);
}
#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 (©->to, &nbuf->to, sizeof (nbuf->to));
- memcpy (©->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;
}
/**
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:
/**
* GstNetAddress:
*
- * An opaque network address as used in #GstNetBuffer.
+ * An opaque network address as used in #GstMetaNetAddress.
*/
struct _GstNetAddress {
/*< private >*/
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);
struct _GstEncodingProfile
{
- GstMiniObject parent;
+ GObject parent;
/*< public > */
gchar *name;
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,
}
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)
}
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;
}
/**
}
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 *
}
static void
-gst_encoding_video_profile_class_init (GstMiniObjectClass * klass)
+gst_encoding_video_profile_class_init (GObjectClass * klass)
{
}
}
static void
-gst_encoding_audio_profile_class_init (GstMiniObjectClass * klass)
+gst_encoding_audio_profile_class_init (GObjectClass * klass)
{
}
{
GstEncodingProfile *prof;
- prof = (GstEncodingProfile *) gst_mini_object_new (objtype);
+ prof = (GstEncodingProfile *) g_object_new (objtype, NULL);
if (name)
prof->name = g_strdup (name);
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
profile = combo_search (s);
if (profile) {
- gst_value_take_mini_object (value, (GstMiniObject *) profile);
+ g_value_take_object (value, (GObject *) profile);
return TRUE;
}
#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);
*
* 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:
*
* 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);
struct _GstEncodingTarget
{
- GstMiniObject parent;
+ GObject parent;
gchar *name;
gchar *category;
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)
}
static void
-gst_encoding_target_finalize (GstEncodingTarget * target)
+gst_encoding_target_finalize (GObject * object)
{
+ GstEncodingTarget *target = (GstEncodingTarget *) object;
+
GST_DEBUG ("Finalizing");
if (target->name)
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;
}
/**
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);
(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);
* 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:
* 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,
/* 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)
}
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);
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 *
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 *
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 *
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 */
}
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 *
}
/* 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)
}
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);
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 *
}
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;
}
/**
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);
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;
}
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;
}
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;
}
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;
/* 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);
#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);
/**
*
* 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);
#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);
#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);
#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);
(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);
*/
struct _GstDiscovererStreamInfo {
- GstMiniObject parent;
+ GObject parent;
GstDiscovererStreamInfo *previous; /* NULL for starting points */
GstDiscovererStreamInfo *next; /* NULL for containers */
};
struct _GstDiscovererInfo {
- GstMiniObject parent;
+ GObject parent;
gchar *uri;
GstDiscovererResult result;
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)
{
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);
{
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);
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",
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;
{
/* 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;
}
{
guint size, bufsize;
guint32 fourcc;
- guint8 *data;
+ guint8 *data, *ptr;
+ gsize bsize;
guint offset = *_offset;
g_return_val_if_fail (element != NULL, FALSE);
*chunk_data = NULL;
*_fourcc = 0;
- bufsize = GST_BUFFER_SIZE (buf);
+ bufsize = gst_buffer_get_size (buf);
if (bufsize == offset)
goto end_offset;
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);
}
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;
{
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);
{
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;
}
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;
}
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)
{
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;
}
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);
/* 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:");
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;
{
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;
}
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);
/* 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 */
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;
{
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;
}
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)
{
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;
}
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;
*_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 */
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);
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)) {
*_taglist = NULL;
gst_tag_list_free (taglist);
}
+ gst_buffer_unmap (buf, data, size);
return;
}
{
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 */
GstBuffer *outbuf;
guint8 *payload;
GstFlowReturn ret;
+ GstRTPBuffer rtp;
basepayload = GST_BASE_RTP_PAYLOAD (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,
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));
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);
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,
"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. */
guint32 rtptime;
gboolean discont;
gint gap;
+ GstRTPBuffer rtp;
filter = GST_BASE_RTP_DEPAYLOAD (GST_OBJECT_PARENT (pad));
priv = filter->priv;
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 %"
/* 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);
}
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 */
depayload->priv->discont = FALSE;
}
- return GST_BUFFER_LIST_SKIP_GROUP;
+ return TRUE;
}
static GstFlowReturn
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 */
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);
/* 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
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->
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;
}
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;
}
/**
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;
}
/**
* 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));
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;
* 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;
{
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 */
* 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
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;
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);
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;
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;
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;
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;
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;
}
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;
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;
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");
}
{
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;
}
{
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;
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;
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;
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;
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;
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;
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;
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)
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;
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;
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;
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);
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;
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++) {
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;
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];
}
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];
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);
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;
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;
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;
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;
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;
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;
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;
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;
}
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);
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;
*/
#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
*/
struct _GstRTCPPacket
{
- GstBuffer *buffer;
- guint offset;
+ GstRTCPBuffer *rtcp;
+ guint offset;
/*< private >*/
gboolean padding; /* padding field of current packet */
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);
{
guint len;
guint8 *data;
+ GstMemory *mem;
g_return_if_fail (csrc_count <= 15);
g_return_if_fail (GST_IS_BUFFER (buffer));
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;
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);
}
/**
* 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;
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;
}
* 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);
}
/**
* 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
*
* 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);
}
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;
/**
* 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.
* 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))
/**
* 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);
}
/**
* 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
* 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;
/**
* 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
* 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;
/**
* 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)
* 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);
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.
* 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);
/**
* 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));
/**
* 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,
- ×tamp);
-}
/**
* 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
*
* 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:
/**
* 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
* 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];
}
/**
- * 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.
* 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);
}
/**
/**
* 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
*/
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;
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;
/**
* 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
*/
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;
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;
/**
* 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
*/
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;
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) {
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));
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));
/**
* 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
*/
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;
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) {
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;
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;
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;
-}
*/
#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
struct _GstExifReader
{
GstTagList *taglist;
- const GstBuffer *buffer;
+ GstBuffer *buffer;
guint32 base_offset;
gint byte_order;
/* 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;
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");
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));
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
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);
}
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);
}
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);
}
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);
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,
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");
}
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;
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;
}
}
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;
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) {
}
}
}
+ 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;
}
}
{
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);
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);
}
* 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;
* 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;
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)) {
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;
}
}
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);
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;
!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,
reader_fail:
GST_WARNING ("Failed to read fields from buffer (too short?)");
+ if (data)
+ gst_buffer_unmap (exif_reader->buffer, data, size);
return ret;
}
GstTagDemuxState state;
GstBuffer *collect;
+ gsize collect_size;
GstCaps *src_caps;
GstTagList *event_tags;
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);
* 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;
}
}
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;
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));
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 "
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:
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);
} 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;
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)
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;
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);
}
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) {
}
/* 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);
gboolean res = FALSE;
guint64 offset;
guint tagsize;
+ gsize bsize;
klass = GST_TAG_DEMUX_CLASS (G_OBJECT_GET_CLASS (demux));
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;
}
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;
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:
gboolean have_tag;
gboolean res = FALSE;
guint req, tagsize;
+ gsize bsize;
klass = GST_TAG_DEMUX_CLASS (G_OBJECT_GET_CLASS (demux));
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;
}
/* 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;
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:
GstFlowReturn ret;
guint64 in_offset;
guint in_length;
+ gsize size;
g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
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 */
}
/**
- * 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
* 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{ \
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)
#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;
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;
&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
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);
const gchar * vendor_string)
{
GstBuffer *buffer;
- guint8 *data;
+ guint8 *data, *odata;
guint i;
GList *l;
MyForEach my_data = { 0, 0, NULL };
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;
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;
}
* 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;
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 */
}
g_free (part);
+ gst_buffer_unmap (buffer, xps, len);
+
return list;
/* Errors */
XmpSerializationData serialization_data;
GString *data;
guint i;
+ gsize bsize;
+ gpointer bdata;
serialization_data.data = g_string_sized_new (4096);
serialization_data.schemas = schemas;
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;
}
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);
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,
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 */
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);
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);
* 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);
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;
+ }
+
}
/* 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
static gboolean
gst_video_filter_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
GstVideoFormat fmt;
gint width, height;
* 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 */
/* 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);
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 */
/* 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,
/* BaseTransform vmethods */
static gboolean
gst_audio_convert_get_unit_size (GstBaseTransform * base, GstCaps * caps,
- guint * size)
+ gsize * size)
{
AudioConvertFmt fmt = { 0 };
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;
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 */
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,
/* 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:
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;
}
}
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 */
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);
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;
}
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
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);
}
/* 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,
static gboolean
gst_audio_resample_get_unit_size (GstBaseTransform * base, GstCaps * caps,
- guint * size)
+ gsize * size)
{
gint width, channels;
GstStructure *structure;
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;
guint out_len, out_processed;
gint err;
guint num, den;
+ guint8 *data;
g_assert (resample->state != NULL);
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,
/* 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));
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));
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);
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;
&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 */
/* 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;
}
}
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));
GstBuffer * outbuf)
{
GstAudioResample *resample = GST_AUDIO_RESAMPLE (base);
- gulong size;
GstFlowReturn ret;
if (resample->state == NULL) {
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));
gint64 next_sample, next_byte;
gint bytes, samples;
GstElementClass *eclass;
+ guint8 *data;
src = GST_AUDIO_TEST_SRC (basesrc);
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))) {
* 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));
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);
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);
/*
* Read a palette from a caps.
*/
-
static void
gst_ffmpeg_get_palette (const GstCaps * caps, 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);
}
}
{
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);
}
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);
static gboolean
gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
GstStructure *structure = NULL;
AVCodecContext *ctx = NULL;
{
GstFFMpegCsp *space;
gint result;
+ guint8 *indata, *outdata;
+ gsize insize, outsize;
space = GST_FFMPEGCSP (btrans);
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 */
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;
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;
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 */
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;
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 *
gst_gdp_pay_class_init (GstGDPPayClass * klass)
{
GObjectClass *gobject_class;
-
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
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);
}
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))
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);
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,
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);
gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
{
GstBuffer *headerbuf;
-
GstBuffer *payloadbuf;
-
guint8 *header, *payload;
-
- guint len;
-
+ guint len, plen;
gboolean ret;
ret =
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);
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 };
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 */
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));
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)",
gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
{
GstGDPPay *this;
-
gboolean res = TRUE;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
-
GstGDPPay *this = GST_GDP_PAY (element);
switch (transition) {
pad->blocked = FALSE;
pad->exposed = FALSE;
pad->drained = FALSE;
- gst_object_ref (pad);
- gst_object_sink (pad);
+ gst_object_ref_sink (pad);
}
static void
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,
}
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
}
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;
/* 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 ? */
* 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,
* 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));
/**
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));
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;
}
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");
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]")) {
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;
/* 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;
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;
}
/* 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;
gboolean discont;
gsize consumed;
gchar *input = NULL;
+ const guint8 *data;
+ gsize avail;
discont = GST_BUFFER_IS_DISCONT (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);
{
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;
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;
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);
}
/* 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
enum
{
PROP_0,
- PROP_PROTOCOL,
PROP_MODE,
PROP_BUFFERS_QUEUED,
PROP_BYTES_QUEUED,
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
*
{
GST_OBJECT_FLAG_UNSET (this, GST_MULTI_FD_SINK_OPEN);
- this->protocol = DEFAULT_PROTOCOL;
this->mode = DEFAULT_MODE;
CLIENTS_LOCK_INIT (this);
}
}
-/* 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)
{
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);
}
}
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);
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;
}
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) {
{
int fd = client->fd.fd;
gboolean more;
- gboolean res;
gboolean flushing;
GstClockTime now;
GTimeVal nowtv;
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;
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
#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.. */
/* 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 */
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;
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;
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;
gboolean discont;
- GstTCPProtocol protocol;
-
gboolean caps_sent;
gboolean new_connection;
GSList *streamheader; /* GSList of GstBuffers to use as streamheader */
gboolean previous_buffer_in_caps;
- GstTCPProtocol protocol;
guint mtu;
gint qos_dscp;
gboolean handle_read;
int ret;
ssize_t bytes_read;
int readsize;
+ guint8 *data;
*buf = NULL;
*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;
/* 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 */
{
GstFlowReturn ret;
guint8 *header = NULL;
+ guint8 *data;
+ gsize size;
GST_LOG_OBJECT (this, "Reading %d bytes for buffer packet header",
GST_DP_HEADER_LENGTH);
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;
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;
- }
-}
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);
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__ */
{
ARG_0,
ARG_HOST,
- ARG_PORT,
- ARG_PROTOCOL
- /* FILL ME */
+ ARG_PORT
};
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
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;
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);
}
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
{
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;
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;
}
}
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);
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);
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 */
};
{
PROP_0,
PROP_HOST,
- PROP_PORT,
- PROP_PROTOCOL
+ PROP_PORT
};
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;
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);
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));
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
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);
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);
GstPollFD sock_fd;
GstPoll *fdset;
- GstTCPProtocol protocol; /* protocol used for reading data */
gboolean caps_received; /* if we have received caps yet */
GstCaps *caps;
};
{
PROP_0,
PROP_HOST,
- PROP_PORT,
- PROP_PROTOCOL
+ PROP_PORT
};
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;
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);
}
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));
("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
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);
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);
GstPoll *fdset;
- GstTCPProtocol protocol; /* protocol used for reading data */
gboolean caps_received; /* if we have received caps yet */
};
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 */
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;
gboolean strict)
{
gboolean got_xmldec;
- guint8 *data;
+ const guint8 *data;
guint offset = 0;
guint pos = 0;
static gboolean
sdp_check_header (GstTypeFind * tf)
{
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 5);
if (!data)
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;
} 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);
}
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'
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);
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 */
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 &&
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);
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);
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) {
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;
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;
mp3_type_find (GstTypeFind * tf, gpointer unused)
{
GstTypeFindProbability prob, mid_prob;
- guint8 *data;
+ const guint8 *data;
guint layer, mid_layer;
guint64 length;
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;
{
guint64 offset;
guint32 blocksize;
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 32);
if (!data)
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;
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);
}
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;
}
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;
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;
{
/* 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) {
/* 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;
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;
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;
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);
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);
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);
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;
static void
jp2_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 24);
if (!data)
static void
qt_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data;
+ const guint8 *data;
guint tip = 0;
guint64 offset = 0;
guint64 size;
}
}
if (size == 1) {
- guint8 *sizedata;
+ const guint8 *sizedata;
sizedata = gst_type_find_peek (tf, offset + 8, 8);
if (sizedata == NULL)
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) {
}
/* 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) {
}
/* 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) {
}
/* 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) {
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;
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') {
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 };
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;
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;
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)
static void
dv_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 5);
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)) {
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;
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)
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))
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)
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)
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)
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 "
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 " */
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 */
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) {
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 */
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;
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) {
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
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) {
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) {
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) {
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 &&
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) {
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);
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)
static void
windows_icon_typefind (GstTypeFind * find, gpointer user_data)
{
- guint8 *data;
+ const guint8 *data;
gint64 datalen;
guint16 type, nimages;
gint32 size, offset;
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)),
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;
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;
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,
static gboolean
gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
GstVideoFormat format;
gint width, height;
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
|| 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) {
}
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;
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;
}
}
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);
/* 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) {
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);
{
GstVolume *self = GST_VOLUME (base);
guint8 *data;
- guint size;
+ gsize size;
GstControlSource *mute_csource, *volume_csource;
if (G_UNLIKELY (!self->negotiated))
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");
} else if (self->current_volume != 1.0) {
self->process (self, data, size);
}
+ gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_OK;
GST_ELEMENT_ERROR (self, CORE, FAILED,
("Failed to get values from controller"), (NULL));
+ gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_ERROR;
}
}
}
}
-#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) {
}
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;
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;
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 \
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
* 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)
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;
}
--- /dev/null
+/* 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);
+}
--- /dev/null
+/* 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__ */
#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);
/* */
/* ============================================================= */
-/* 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,
/* 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);
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 */
}
}
- 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;
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 */
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);
}
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;
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. */
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");
g_mutex_lock (ximagesink->x_lock);
}
+ /* Handle Expose */
while (XCheckWindowEvent (ximagesink->xcontext->disp,
ximagesink->xwindow->win, ExposureMask | StructureNotifyMask, &e)) {
switch (e.type) {
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;
}
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");
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 *
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;
ret &= gst_structure_get_int (structure, "height", &new_height);
fps = gst_structure_get_value (structure, "framerate");
ret &= (fps != NULL);
+
if (!ret)
return FALSE;
/* 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) {
}
/* 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;
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);
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);
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)
{
return TRUE;
}
-
/* Buffer management
*
* The buffer_alloc function must either return a buffer with given size and
GstCaps * caps, GstBuffer ** buf)
{
GstXImageSink *ximagesink;
- GstXImageBuffer *ximage = NULL;
+ GstBuffer *ximage = NULL;
GstStructure *structure = NULL;
GstFlowReturn ret = GST_FLOW_OK;
GstCaps *alloc_caps;
}
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;
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);
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);
ximagesink->display_name = NULL;
ximagesink->xcontext = NULL;
ximagesink->xwindow = NULL;
- ximagesink->ximage = NULL;
ximagesink->cur_image = NULL;
ximagesink->event_thread = NULL;
ximagesink->par = NULL;
- ximagesink->pool_lock = g_mutex_new ();
- ximagesink->buffer_pool = NULL;
+ ximagesink->pool = NULL;
ximagesink->synchronous = FALSE;
ximagesink->keep_aspect = FALSE;
/* 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;
(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
};
/**
- * 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
GstXContext *xcontext;
GstXWindow *xwindow;
- GstXImageBuffer *ximage;
- GstXImageBuffer *cur_image;
+ GstBuffer *cur_image;
GThread *event_thread;
gboolean running;
/* object-set pixel aspect ratio */
GValue *par;
- GMutex *pool_lock;
- GSList *buffer_pool;
+ /* the buffer pool */
+ GstBufferPool *pool;
gboolean synchronous;
gboolean keep_aspect;
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 \
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
--- /dev/null
+/* 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)
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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__*/
/* 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
{
#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
/* */
/* ============================================================= */
-/* 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
/* 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;
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 */
}
}
+ meta = gst_buffer_get_meta_xvimage (xvimage);
+
if (xvimagesink->keep_aspect) {
GstVideoRectangle src, dst;
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);
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);
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);
}
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);
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;
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
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);
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)
{
{
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;
* 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;
("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
/* 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;
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;
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);
break;
}
+beach:
return ret;
}
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;
}
}
}
/* Buffer management */
-
static GstCaps *
gst_xvimage_sink_different_size_suggestion (GstXvImageSink * xvimagesink,
GstCaps * caps)
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,
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) {
{
GST_DEBUG_OBJECT (xvimagesink, "the pool is flushing");
ret = GST_FLOW_WRONG_STATE;
- g_mutex_unlock (xvimagesink->pool_lock);
goto beach;
}
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:
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;
}
}
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);
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
+ GST_DEBUG ("doing expose");
gst_xvimagesink_xwindow_update_geometry (xvimagesink);
gst_xvimagesink_xvimage_put (xvimagesink, NULL);
}
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;
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);
xvimagesink->adaptor_no = 0;
xvimagesink->xcontext = NULL;
xvimagesink->xwindow = NULL;
- xvimagesink->xvimage = NULL;
xvimagesink->cur_image = NULL;
xvimagesink->hue = xvimagesink->saturation = 0;
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;
&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)
#include <stdlib.h>
G_BEGIN_DECLS
-
#define GST_TYPE_XVIMAGESINK \
(gst_xvimagesink_get_type())
#define GST_XVIMAGESINK(obj) \
(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
* Structure used to store various informations collected/calculated for a
* Display.
*/
-struct _GstXContext {
+struct _GstXContext
+{
Display *disp;
Screen *screen;
XvPortID xv_port_id;
guint nb_adaptors;
- gchar ** adaptors;
+ gchar **adaptors;
gint im_format;
GList *formats_list;
*
* Structure used to store informations about a Window.
*/
-struct _GstXWindow {
+struct _GstXWindow
+{
Window win;
gint width, height;
gboolean internal;
*
* 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
*
* The #GstXvImageSink data structure.
*/
-struct _GstXvImageSink {
+struct _GstXvImageSink
+{
/* Our element stuff */
GstVideoSink videosink;
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;
/* 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;
/* 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;
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__ */
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 ();
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;
}
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
/* 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 ();
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);
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);
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);
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);
}
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, outlength) == 0,
"failed converting %s", which);
+#endif
/* make sure that the channel positions are not lost */
{
}
/* 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);
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);
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);
++p;
}
+ gst_buffer_unmap (inbuffer, data, samples * 4);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
GstClockTime ints;
int i, j;
- gint16 *p;
+ gint16 *p, *data;
GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
inrate, outrate, samples, numbuffers);
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);
*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:%"
GstEvent *newseg;
GstBuffer *inbuffer;
GstCaps *caps;
+ guint8 *data;
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
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;
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;
GstBuffer *inbuffer;
GstCaps *desired;
GList *l;
+ guint8 *data;
desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
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;
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 */
/* 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,
"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
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");
"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
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");
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 */
}
/* 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;
}
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);
}
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);
&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);
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;
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);
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);
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 */
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 */
/* 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 */
/* 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);
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);
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 */
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 */
/* 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 */
/* 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);
GstEvent *event;
gchar *caps_string;
gint length;
+ guint8 *data;
+ gsize size;
guint16 crc_calculated, crc_read;
gdppay = setup_gdppay ();
/* 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;
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 */
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,
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
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");
* 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);
/* 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");
/* 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");
/* 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");
/* 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");
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
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",
{
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);
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",
{
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);
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;
}
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);
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);
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);
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);
{
GstStructure *s;
gint x, y, w, h;
+ guint8 *data;
+ gsize size;
fail_unless (buf != NULL);
fail_unless (GST_BUFFER_CAPS (buf) != NULL);
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;
}
GstBuffer *buffer;
GstCaps *caps;
gint w, h, size;
+ guint8 *data;
fail_unless (caps_string != NULL);
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);
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;
/* 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)) ==
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;
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;
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;
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;
"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;
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);
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);
/* ... 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);
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);
/* 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 ()));
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
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 */
"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);
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);
/* 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);
/* 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);
/* 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);
/* 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);
"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);
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 */
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);
/* 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);
/* 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;
GstCaps *caps;
gint8 in[2] = { 64, -16 };
gint8 *res;
+ gsize size;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
"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);
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);
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);
"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);
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);
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);
"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);
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);
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);
"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);
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);
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 *res;
+ gsize size;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
"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);
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);
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);
"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);
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);
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);
"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);
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);
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);
"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);
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);
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]);
"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);
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);
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]);
"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);
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", 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);
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]);
"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);
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", 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);
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]);
"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);
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", 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);
GstCaps *caps;
gint32 in[2] = { 1073741824, -65536 };
gint32 *res;
+ gsize size;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
"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);
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);
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);
"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);
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);
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);
"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);
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);
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);
"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);
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);
GstCaps *caps;
gfloat in[2] = { 0.75, -0.25 };
gfloat *res;
+ gsize size;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
"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);
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]);
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);
"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);
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);
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);
"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);
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);
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);
"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);
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);
GstCaps *caps;
gdouble in[2] = { 0.75, -0.25 };
gdouble *res;
+ gsize size;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
"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);
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]);
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);
"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);
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);
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);
"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);
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);
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);
"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);
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);
"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);
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 *res;
+ gsize size;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 1.0, NULL);
"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);
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);
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 *res;
+ gsize size;
volume = setup_volume ();
"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;
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);
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);
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);
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;
}
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);
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);
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);
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;
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;
}
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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
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);
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);
}
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);
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) {
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) {
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);
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,
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,
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,
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,
/* 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,
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);
*/
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,
*/
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);
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,
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,
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,
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,
/* 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,
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);
*/
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);
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;
}
#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>
#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);
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
};
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 (©->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 (©->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;
/* 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);
/* 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);
/* 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);
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);
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);
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);
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);
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);
/* 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);
/* 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 */
/* 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);
}
{
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);
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,
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);
{
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);
}
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;
}
GST_END_TEST;
+#endif
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;
}
GST_END_TEST;
+#endif
GST_START_TEST (test_rtp_seqnum_compare)
{
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);
}
/* 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);
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);
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);
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);
}
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;
}
GstCheckABIStruct list[] = {
- {"GstAppBufferClass", sizeof (GstAppBufferClass), 16},
- {"GstAppBuffer", sizeof (GstAppBuffer), 88},
{"GstAppSinkCallbacks", sizeof (GstAppSinkCallbacks), 28},
{"GstAppSinkClass", sizeof (GstAppSinkClass), 404},
{"GstAppSink", sizeof (GstAppSink), 404},
{"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},
GstCheckABIStruct list[] = {
- {"GstAppBufferClass", sizeof (GstAppBufferClass), 32},
- {"GstAppBuffer", sizeof (GstAppBuffer), 136},
{"GstAppSinkCallbacks", sizeof (GstAppSinkCallbacks), 56},
{"GstAppSinkClass", sizeof (GstAppSinkClass), 800},
{"GstAppSink", sizeof (GstAppSink), 640},
{"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},
/* 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"));
(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);
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,
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,
GstTagList *list;
GstBuffer *buf;
const gchar *text;
- guint len;
+ gsize len;
/* test data */
list = gst_tag_list_new_full (GST_TAG_TITLE, "test title",
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);
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);
};
/* 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) {
if (list)
gst_tag_list_free (list);
+ gst_buffer_unref (buf);
g_free (text);
i++;
}
-
- gst_buffer_unref (buf);
}
GST_END_TEST;
GstBuffer *buf = NULL;
gint i;
GstTagList *taglist;
+ guint8 *data;
gst_tag_register_musicbrainz_tags ();
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,
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);
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);
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 *
{
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 {
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;
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;
}
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)
* 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);
}
#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 =
on_new_buffer_from_source (GstElement * elt, ProgramData * data)
{
guint size;
- gpointer raw_buffer;
GstBuffer *app_buffer, *buffer;
GstElement *source;
/* 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 */
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;
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);
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);
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);
#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
-#include <gst/app/gstappbuffer.h>
#include <gst/app/gstappsink.h>
#include <stdio.h>
App s_app;
-static void dont_eat_my_chicken_wings (void *priv);
-
int
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);
}
return 0;
}
-
-static void
-dont_eat_my_chicken_wings (void *priv)
-{
- printf ("freeing buffer for pointer %p\n", priv);
- free (priv);
-}
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
/* 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);
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
/* 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);
GstFormat format;
GstStateChangeReturn ret;
gboolean res;
+ guint8 *data;
+ gsize size;
gst_init (&argc, &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");
}
if (buffer) {
guint8 *data;
- guint size;
+ gsize size;
GstFormat format;
gint64 position;
GstClock *clock;
", 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);
}
}
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);
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
EXPORTS
+ gst_meta_net_address_get_info
gst_netaddress_equal
gst_netaddress_get_address_bytes
gst_netaddress_get_ip4_address
gst_netaddress_set_ip4_address
gst_netaddress_set_ip6_address
gst_netaddress_to_string
- gst_netbuffer_get_type
- gst_netbuffer_new
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
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
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
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